freetds-1.00.82/m4/ac_caolan_func_which_gethostbyname_r.m4100644 025423 025423 00000005167 12522201763 0017170dnl $Id: ac_caolan_func_which_gethostbyname_r.m4,v 1.3 2006-03-29 16:24:36 freddy77 Exp $ ## # @synopsis AC_caolan_FUNC_WHICH_GETHOSTBYNAME_R # # Provides a test to determine the correct # way to call gethostbyname_r # # defines HAVE_FUNC_GETHOSTBYNAME_R_6 if it needs 6 arguments (e.g linux) # defines HAVE_FUNC_GETHOSTBYNAME_R_5 if it needs 5 arguments (e.g. solaris) # defines HAVE_FUNC_GETHOSTBYNAME_R_3 if it needs 3 arguments (e.g. osf/1) # # if used in conjunction in gethostname.c the api demonstrated # in test.c can be used regardless of which gethostbyname_r # exists. These example files found at # http://www.csn.ul.ie/~caolan/publink/gethostbyname_r # # @author Caolan McNamara # updated with AC_LINK_IFELSE March 2006 . # Could probably be replaced with better version: # http://autoconf-archive.cryp.to/ax_func_which_gethostbyname_r.html # # based on David Arnold's autoconf suggestion in the threads faq ## AC_DEFUN([AC_caolan_FUNC_WHICH_GETHOSTBYNAME_R], [ac_save_CFLAGS=$CFLAGS CFLAGS="$CFLAGS $NETWORK_LIBS" AC_CACHE_CHECK(for which type of gethostbyname_r, ac_cv_func_which_gethostname_r, [ AC_LINK_IFELSE([AC_LANG_PROGRAM([ # include ], [ char *name; struct hostent *he; struct hostent_data data; (void) gethostbyname_r(name, he, &data); ])],ac_cv_func_which_gethostname_r=three, [ dnl ac_cv_func_which_gethostname_r=no AC_LINK_IFELSE([AC_LANG_PROGRAM([ # include ], [[ char *name; struct hostent *he, *res; char buffer[2048]; int buflen = 2048; int h_errnop; (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop) ]])],ac_cv_func_which_gethostname_r=six, [ dnl ac_cv_func_which_gethostname_r=no AC_LINK_IFELSE([AC_LANG_PROGRAM([ # include ], [[ char *name; struct hostent *he; char buffer[2048]; int buflen = 2048; int h_errnop; (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop) ]])],ac_cv_func_which_gethostname_r=five,ac_cv_func_which_gethostname_r=no) ] ) ] )]) if test $ac_cv_func_which_gethostname_r = six; then AC_DEFINE(HAVE_FUNC_GETHOSTBYNAME_R_6, 1, [Define to 1 if your system provides the 6-parameter version of gethostbyname_r().]) elif test $ac_cv_func_which_gethostname_r = five; then AC_DEFINE(HAVE_FUNC_GETHOSTBYNAME_R_5, 1, [Define to 1 if your system provides the 5-parameter version of gethostbyname_r().]) elif test $ac_cv_func_which_gethostname_r = three; then AC_DEFINE(HAVE_FUNC_GETHOSTBYNAME_R_3, 1, [Define to 1 if your system provides the 3-parameter version of gethostbyname_r().]) fi CFLAGS=$ac_save_CFLAGS ]) freetds-1.00.82/m4/ac_have_inaddr_none.m4100644 025423 025423 00000001463 12522201763 0013542dnl $Id: ac_have_inaddr_none.m4,v 1.3 2006-03-29 16:24:37 freddy77 Exp $ AC_DEFUN([AC_HAVE_INADDR_NONE], [ AC_CACHE_CHECK([whether INADDR_NONE is defined], ac_cv_have_inaddr_none, [AC_COMPILE_IFELSE([AC_LANG_PROGRAM( [/* our includes */ #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_ARPA_INET_H #include #endif /* end includes */], [unsigned long foo = INADDR_NONE; /* our test code */])], ac_cv_have_inaddr_none=yes, ac_cv_have_inaddr_none=no) ]) if test $ac_cv_have_inaddr_none != yes; then AC_DEFINE(INADDR_NONE, 0xffffffff, [Define to value of INADDR_NONE if not provided by your system header files.]) fi ] ) freetds-1.00.82/m4/ac_have_malloc_options.m4100644 025423 025423 00000001073 12522201763 0014301dnl $Id: ac_have_malloc_options.m4,v 1.3 2006-03-29 16:24:37 freddy77 Exp $ AC_DEFUN([AC_HAVE_MALLOC_OPTIONS], [AC_CACHE_CHECK([whether malloc_options variable is present], ac_cv_have_malloc_options, [AC_LINK_IFELSE([AC_LANG_PROGRAM([ #include ],[ extern char *malloc_options; malloc_options = "AJR"; ])], ac_cv_have_malloc_options=yes, ac_cv_have_malloc_options=no)]) if test $ac_cv_have_malloc_options = yes; then AC_DEFINE(HAVE_MALLOC_OPTIONS, 1, [Define to 1 if your system provides the malloc_options variable.]) fi]) freetds-1.00.82/m4/ac_nullzero.m4100644 025423 025423 00000002653 12522201763 0012133# TDS_NULL_IS_ZERO ([ACTION-IF-TRUE], [ACTION-IF-FALSE]) # ------------------------------------------------------------------------- AC_DEFUN([TDS_NULL_IS_ZERO], [AC_CACHE_CHECK([whether memset(0) sets pointers to NULL], tds_cv_null_is_zero, [ tds_cv_null_is_zero=no # compile a test program. AC_RUN_IFELSE( [AC_LANG_SOURCE([[#include #include #include #ifdef HAVE_STDDEF_H #include #endif int main () { char *p1,*p2; p1=NULL; memset(&p2,0,sizeof(p2)); return memcmp(&p1,&p2,sizeof(char*))?1:0; }]])], [tds_cv_null_is_zero=yes], [], [# try to guess the endianness by grepping values into an object file AC_COMPILE_IFELSE([AC_LANG_PROGRAM( [[#include struct test { char begin[16]; void *ptrs[4]; char end[16]; } xxx[] = { { "abcdefghijklmnop", { NULL, NULL, NULL, NULL }, "qrstuvwxyzabcdef" }, { "\x81\x82\x83\x84\x85\x86\x87\x88\x89\x91\x92\x93\x94\x95\x96\x97", { NULL, NULL, NULL, NULL }, "\x98\x99\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\x81\x82\x83\x84\x85\x86" } };]], [[]])], [if cat -v conftest.$ac_objext|grep 'abcdefghijklmnop\^@\^@\^@\^@\^@\^@\^@\^@\^@\^@\^@\^@\^@\^@\^@\^@\(\^@\^@\^@\^@\^@\^@\^@\^@\^@\^@\^@\^@\^@\^@\^@\^@\)*qrstuvwxyzabcdef'>/dev/null ; then tds_cv_null_is_zero=yes fi])])]) case $tds_cv_null_is_zero in yes) m4_default([$1], [AC_DEFINE([NULL_REP_IS_ZERO_BYTES], 1, [Define to 1 if memset(0) sets pointers to NULL.])]) ;; no) $2 ;; esac ])# TDS_NULL_IS_ZERO freetds-1.00.82/m4/ac_raf_func_which_getservbyname_r.m4100644 025423 025423 00000004012 12522201763 0016471dnl $Id: ac_raf_func_which_getservbyname_r.m4,v 1.3 2006-03-29 16:24:37 freddy77 Exp $ ## # Found on autoconf archive # Based on Caolan McNamara's gethostbyname_r macro. # Based on David Arnold's autoconf suggestion in the threads faq. AC_DEFUN([AC_raf_FUNC_WHICH_GETSERVBYNAME_R], [ac_save_CFLAGS=$CFLAGS CFLAGS="$CFLAGS $NETWORK_LIBS" AC_CACHE_CHECK(for which type of getservbyname_r, ac_cv_func_which_getservbyname_r, [ AC_LINK_IFELSE([AC_LANG_PROGRAM([ # include ], [ char *name; char *proto; struct servent *se; struct servent_data data; (void) getservbyname_r(name, proto, se, &data); ])],ac_cv_func_which_getservbyname_r=four, [ AC_LINK_IFELSE([AC_LANG_PROGRAM([ # include ], [[ char *name; char *proto; struct servent *se, *res; char buffer[2048]; int buflen = 2048; (void) getservbyname_r(name, proto, se, buffer, buflen, &res) ]])],ac_cv_func_which_getservbyname_r=six, [ AC_LINK_IFELSE([AC_LANG_PROGRAM([ # include ], [[ char *name; char *proto; struct servent *se; char buffer[2048]; int buflen = 2048; (void) getservbyname_r(name, proto, se, buffer, buflen) ]])],ac_cv_func_which_getservbyname_r=five,ac_cv_func_which_getservbyname_r=no) ] ) ] )]) if test $ac_cv_func_which_getservbyname_r = six; then AC_DEFINE(HAVE_FUNC_GETSERVBYNAME_R_6, 1, [Define to 1 if your system provides the 6-parameter version of getservbyname_r().]) elif test $ac_cv_func_which_getservbyname_r = five; then AC_DEFINE(HAVE_FUNC_GETSERVBYNAME_R_5, 1, [Define to 1 if your system provides the 5-parameter version of getservbyname_r().]) elif test $ac_cv_func_which_getservbyname_r = four; then AC_DEFINE(HAVE_FUNC_GETSERVBYNAME_R_4, 1, [Define to 1 if your system provides the 4-parameter version of getservbyname_r().]) fi CFLAGS=$ac_save_CFLAGS ]) freetds-1.00.82/m4/ac_tds_func_which_gethostbyaddr_r.m4100644 025423 025423 00000004001 12522201763 0016501dnl $Id: ac_tds_func_which_gethostbyaddr_r.m4,v 1.3 2006-03-29 16:24:37 freddy77 Exp $ ## # based on gethostbyname_r check and snippits from curl's check ## AC_DEFUN([AC_tds_FUNC_WHICH_GETHOSTBYADDR_R], [ac_save_CFLAGS=$CFLAGS CFLAGS="$CFLAGS $NETWORK_LIBS" AC_CACHE_CHECK(for which type of gethostbyaddr_r, ac_cv_func_which_gethostbyaddr_r, [ AC_LINK_IFELSE([AC_LANG_PROGRAM([ #include #include ], [ char * address; int length; int type; struct hostent h; struct hostent_data hdata; int rc; rc = gethostbyaddr_r(address, length, type, &h, &hdata); ])],ac_cv_func_which_gethostbyaddr_r=five, [ dnl ac_cv_func_which_gethostbyaddr_r=no AC_LINK_IFELSE([AC_LANG_PROGRAM([ #include #include ], [[ char * address; int length; int type; struct hostent h; char buffer[8192]; int h_errnop; struct hostent * hp; hp = gethostbyaddr_r(address, length, type, &h, buffer, 8192, &h_errnop); ]])],ac_cv_func_which_gethostbyaddr_r=seven, [ dnl ac_cv_func_which_gethostbyaddr_r=no AC_LINK_IFELSE([AC_LANG_PROGRAM([ #include #include ], [[ char * address; int length; int type; struct hostent h; char buffer[8192]; int h_errnop; struct hostent * hp; int rc; rc = gethostbyaddr_r(address, length, type, &h, buffer, 8192, &hp, &h_errnop); ]])],ac_cv_func_which_gethostbyaddr_r=eight,ac_cv_func_which_gethostbyaddr_r=no) ] ) ] )]) if test $ac_cv_func_which_gethostbyaddr_r = eight; then AC_DEFINE(HAVE_FUNC_GETHOSTBYADDR_R_8, 1, [Define to 1 if your system provides the 8-parameter version of gethostbyaddr_r().]) elif test $ac_cv_func_which_gethostbyaddr_r = seven; then AC_DEFINE(HAVE_FUNC_GETHOSTBYADDR_R_7, 1, [Define to 1 if your system provides the 7-parameter version of gethostbyaddr_r().]) elif test $ac_cv_func_which_gethostbyaddr_r = five; then AC_DEFINE(HAVE_FUNC_GETHOSTBYADDR_R_5, 1, [Define to 1 if your system provides the 5-parameter version of gethostbyaddr_r().]) fi CFLAGS=$ac_save_CFLAGS ]) freetds-1.00.82/m4/ac_tds_func_which_getpwuid_r.m4100644 025423 025423 00000004651 12522201763 0015501dnl $Id: ac_tds_func_which_getpwuid_r.m4,v 1.4 2006-08-23 14:26:20 freddy77 Exp $ ## # Check getpwuid_r parameters # There are three version of this function # int getpwuid_r(uid_t uid, struct passwd *result, char *buffer, int buflen); # (hp/ux 10.20, digital unix 4) # struct passwd *getpwuid_r(uid_t uid, struct passwd * pwd, char *buffer, int buflen); # (SunOS 5.5, many other) # int getpwuid_r(uid_t uid, struct passwd *pwd, char *buffer, size_t buflen, struct passwd **result); # (hp/ux 11, many other, posix compliant) ## AC_DEFUN([AC_tds_FUNC_WHICH_GETPWUID_R], [if test x$ac_cv_func_getpwuid = xyes; then AC_CACHE_CHECK(for which type of getpwuid_r, ac_cv_func_which_getpwuid_r, [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ #include #include ], [[ struct passwd bpw; char buf[1024]; char *dir = getpwuid_r(getuid(), &bpw, buf, sizeof(buf))->pw_dir; ]])],ac_cv_func_which_getpwuid_r=four_pw, [AC_TRY_RUN([ #include #include int main() { struct passwd bpw; char buf[1024]; getpwuid_r(getuid(), &bpw, buf, sizeof(buf)); return 0; } ],ac_cv_func_which_getpwuid_r=four, [AC_TRY_RUN([ #include #include int main() { struct passwd *pw, bpw; char buf[1024]; getpwuid_r(getuid(), &bpw, buf, sizeof(buf), &pw); return 0; } ],ac_cv_func_which_getpwuid_r=five, ac_cv_func_which_getpwuid_r=no)], [# cross compile case ac_cv_func_which_getpwuid_r=no num_params=four for params in "int" "size_t, struct passwd **"; do AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ #include #include extern int getpwuid_r(uid_t, struct passwd *, char *, $params); ],[])],[ if test $ac_cv_func_which_getpwuid_r != no; then AC_ERROR([Two types of getpwuid_r detected]) fi ac_cv_func_which_getpwuid_r=$num_params ]) num_params=five done ] )] )]) if test $ac_cv_func_which_getpwuid_r = four_pw; then AC_DEFINE(HAVE_FUNC_GETPWUID_R_4, 1, [Define to 1 if your system provides the 4-parameter version of getpwuid_r().]) AC_DEFINE(HAVE_FUNC_GETPWUID_R_4_PW, 1, [Define to 1 if your system getpwuid_r() have 4 parameters and return struct passwd*.]) elif test $ac_cv_func_which_getpwuid_r = four; then AC_DEFINE(HAVE_FUNC_GETPWUID_R_4, 1, [Define to 1 if your system provides the 4-parameter version of getpwuid_r().]) elif test $ac_cv_func_which_getpwuid_r = five; then AC_DEFINE(HAVE_FUNC_GETPWUID_R_5, 1, [Define to 1 if your system provides the 5-parameter version of getpwuid_r().]) fi fi ]) freetds-1.00.82/m4/ac_tds_func_which_localtime_r.m4100644 025423 025423 00000001262 12522201763 0015615dnl $Id: ac_tds_func_which_localtime_r.m4,v 1.3 2006-03-29 16:24:37 freddy77 Exp $ AC_DEFUN([AC_tds_FUNC_WHICH_LOCALTIME_R], [AC_CACHE_CHECK(for which type of localtime_r, ac_cv_func_which_localtime_r, [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ #include #include ], [ struct tm mytm; time_t t; int y = localtime_r(&t, &mytm)->tm_year; ])],ac_cv_func_which_localtime_r=struct, ac_cv_func_which_localtime_r=int) ]) if test $ac_cv_func_which_localtime_r = struct; then AC_DEFINE(HAVE_FUNC_LOCALTIME_R_TM, 1, [Define to 1 if your localtime_r return a struct tm*.]) else AC_DEFINE(HAVE_FUNC_LOCALTIME_R_INT, 1, [Define to 1 if your localtime_r return a int.]) fi ]) freetds-1.00.82/m4/acx_pthread.m4100644 025423 025423 00000022665 12522201763 0012105dnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) dnl dnl @summary figure out how to build C programs using POSIX threads dnl dnl This macro figures out how to build C programs using POSIX threads. dnl It sets the PTHREAD_LIBS output variable to the threads library and dnl linker flags, and the PTHREAD_CFLAGS output variable to any special dnl C compiler flags that are needed. (The user can also force certain dnl compiler flags/libs to be tested by setting these environment dnl variables.) dnl dnl Also sets PTHREAD_CC to any special C compiler that is needed for dnl multi-threaded programs (defaults to the value of CC otherwise). dnl (This is necessary on AIX to use the special cc_r compiler alias.) dnl dnl NOTE: You are assumed to not only compile your program with these dnl flags, but also link it with them as well. e.g. you should link dnl with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS dnl $LIBS dnl dnl If you are only building threads programs, you may wish to use dnl these variables in your default LIBS, CFLAGS, and CC: dnl dnl LIBS="$PTHREAD_LIBS $LIBS" dnl CFLAGS="$CFLAGS $PTHREAD_CFLAGS" dnl CC="$PTHREAD_CC" dnl dnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute dnl constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to dnl that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX). dnl dnl ACTION-IF-FOUND is a list of shell commands to run if a threads dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands to dnl run it if it is not found. If ACTION-IF-FOUND is not specified, the dnl default action will define HAVE_PTHREAD. dnl dnl Please let the authors know if this macro fails on any platform, or dnl if you have any other suggestions or comments. This macro was based dnl on work by SGJ on autoconf scripts for FFTW (www.fftw.org) (with dnl help from M. Frigo), as well as ac_pthread and hb_pthread macros dnl posted by Alejandro Forero Cuervo to the autoconf macro repository. dnl We are also grateful for the helpful feedback of numerous users. dnl dnl @category InstalledPackages dnl @author Steven G. Johnson dnl @version 2006-05-29 dnl @license GPLWithACException AC_DEFUN([ACX_PTHREAD], [ AC_REQUIRE([AC_CANONICAL_HOST]) AC_LANG_SAVE AC_LANG_C acx_pthread_ok=no # We used to check for pthread.h first, but this fails if pthread.h # requires special compiler flags (e.g. on True64 or Sequent). # It gets checked for in the link test anyway. # First of all, check if the user has set any of the PTHREAD_LIBS, # etcetera environment variables, and if threads linking works using # them: if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS]) AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes) AC_MSG_RESULT($acx_pthread_ok) if test x"$acx_pthread_ok" = xno; then PTHREAD_LIBS="" PTHREAD_CFLAGS="" fi LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" fi # We must check for the threads library under a number of different # names; the ordering is very important because some systems # (e.g. DEC) have both -lpthread and -lpthreads, where one of the # libraries is broken (non-POSIX). # Create a list of thread flags to try. Items starting with a "-" are # C compiler flags, and other items are library names, except for "none" # which indicates that we try without any flags at all, and "pthread-config" # which is a program returning the flags for the Pth emulation library. acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" # The ordering *is* (sometimes) important. Some notes on the # individual items follow: # pthreads: AIX (must check this before -lpthread) # none: in case threads are in libc; should be tried before -Kthread and # other compiler flags to prevent continual compiler warnings # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) # -pthreads: Solaris/gcc # -mthreads: Mingw32/gcc, Lynx/gcc # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it # doesn't hurt to check since this sometimes defines pthreads too; # also defines -D_REENTRANT) # ... -mt is also the pthreads flag for HP/aCC # pthread: Linux, etcetera # --thread-safe: KAI C++ # pthread-config: use pthread-config program (for GNU Pth library) case "${host_cpu}-${host_os}" in *solaris*) # On Solaris (at least, for some versions), libc contains stubbed # (non-functional) versions of the pthreads routines, so link-based # tests will erroneously succeed. (We need to link with -pthreads/-mt/ # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather # a function called by this macro, so we could check for that, but # who knows whether they'll stub that too in a future libc.) So, # we'll just look for -pthreads and -lpthread first: acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags" ;; # The HP-UX compiler just warns about options it does not understand # but it needs -mt. *-hpux*) acx_pthread_flags="-mt $acx_pthread_flags" ;; esac if test x"$acx_pthread_ok" = xno; then for flag in $acx_pthread_flags; do case $flag in none) AC_MSG_CHECKING([whether pthreads work without any flags]) ;; -*) AC_MSG_CHECKING([whether pthreads work with $flag]) PTHREAD_CFLAGS="$flag" ;; pthread-config) AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no) if test x"$acx_pthread_config" = xno; then continue; fi PTHREAD_CFLAGS="`pthread-config --cflags`" PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" ;; *) AC_MSG_CHECKING([for the pthreads library -l$flag]) PTHREAD_LIBS="-l$flag" ;; esac save_LIBS="$LIBS" save_CFLAGS="$CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # Check for various functions. We must include pthread.h, # since some functions may be macros. (On the Sequent, we # need a special flag -Kthread to make this header compile.) # We check for pthread_join because it is in -lpthread on IRIX # while pthread_create is in libc. We check for pthread_attr_init # due to DEC craziness with -lpthreads. We check for # pthread_cleanup_push because it is one of the few pthread # functions on Solaris that doesn't have a non-functional libc stub. # We try pthread_create on general principles. AC_TRY_LINK([#include ], [pthread_t th; pthread_join(th, 0); pthread_attr_init(0); pthread_cleanup_push(0, 0); pthread_create(0,0,0,0); pthread_cleanup_pop(0); ], [acx_pthread_ok=yes]) LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" AC_MSG_RESULT($acx_pthread_ok) if test "x$acx_pthread_ok" = xyes; then break; fi PTHREAD_LIBS="" PTHREAD_CFLAGS="" done fi # Various other checks: if test "x$acx_pthread_ok" = xyes; then save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. AC_MSG_CHECKING([for joinable pthread attribute]) attr_name=unknown for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do AC_TRY_LINK([#include ], [int attr=$attr; return attr;], [attr_name=$attr; break]) done AC_MSG_RESULT($attr_name) if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name, [Define to necessary symbol if this constant uses a non-standard name on your system.]) fi AC_MSG_CHECKING([if more special flags are required for pthreads]) flag=no case "${host_cpu}-${host_os}" in *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";; *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";; esac AC_MSG_RESULT(${flag}) if test "x$flag" != xno; then PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" fi LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" # More AIX lossage: must compile with xlc_r or cc_r if test x"$GCC" != xyes; then AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC}) else PTHREAD_CC=$CC fi else PTHREAD_CC="$CC" fi AC_SUBST(PTHREAD_LIBS) AC_SUBST(PTHREAD_CFLAGS) AC_SUBST(PTHREAD_CC) # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: if test x"$acx_pthread_ok" = xyes; then ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1]) : else acx_pthread_ok=no $2 fi AC_LANG_RESTORE ])dnl ACX_PTHREAD freetds-1.00.82/m4/ax_cflags_gcc_option.m4100644 025423 025423 00000015355 12522201763 0013754dnl $Id: ax_cflags_gcc_option.m4,v 1.3 2006-03-29 16:24:37 freddy77 Exp $ dnl @synopsis AX_CFLAGS_GCC_OPTION (optionflag [,[shellvar][,[A][,[NA]]]) dnl dnl AX_CFLAGS_GCC_OPTION(-fvomit-frame) would show a message as like dnl "checking CFLAGS for gcc -fvomit-frame ... yes" and adds the dnl optionflag to CFLAGS if it is understood. You can override the dnl shellvar-default of CFLAGS of course. The order of arguments stems dnl from the explicit macros like AX_CFLAGS_WARN_ALL. dnl dnl The cousin AX_CXXFLAGS_GCC_OPTION would check for an option to add dnl to CXXFLAGS - and it uses the autoconf setup for C++ instead of C dnl (since it is possible to use different compilers for C and C++). dnl dnl The macro is a lot simpler than any special AX_CFLAGS_* macro (or dnl ac_cxx_rtti.m4 macro) but allows to check for arbitrary options. dnl However, if you use this macro in a few places, it would be great dnl if you would make up a new function-macro and submit it to the dnl ac-archive. dnl dnl - $1 option-to-check-for : required ("-option" as non-value) dnl - $2 shell-variable-to-add-to : CFLAGS (or CXXFLAGS in the other case) dnl - $3 action-if-found : add value to shellvariable dnl - $4 action-if-not-found : nothing dnl dnl note: in earlier versions, $1-$2 were swapped. We try to detect the dnl situation and accept a $2=~/-/ as being the old dnl option-to-check-for. dnl dnl also: there are other variants that emerged from the original macro dnl variant which did just test an option to be possibly added. dnl However, some compilers accept an option silently, or possibly for dnl just another option that was not intended. Therefore, we have to do dnl a generic test for a compiler family. For gcc we check "-pedantic" dnl being accepted which is also understood by compilers who just want dnl to be compatible with gcc even when not being made from gcc dnl sources. dnl dnl see also: dnl dnl AX_CFLAGS_SUN_OPTION AX_CFLAGS_HPUX_OPTION dnl AX_CFLAGS_AIX_OPTION AX_CFLAGS_IRIX_OPTION dnl dnl @category C dnl @author Guido Draheim dnl @version 2003-11-04 dnl @license GPLWithACException AC_DEFUN([AX_CFLAGS_GCC_OPTION_OLD], [dnl AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_gcc_option_$2])dnl AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for gcc m4_ifval($2,$2,-option)], VAR,[VAR="no, unknown" AC_LANG_SAVE AC_LANG_C ac_save_[]FLAGS="$[]FLAGS" for ac_arg dnl in "-pedantic % m4_ifval($2,$2,-option)" dnl GCC # do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` AC_COMPILE_IFELSE(AC_LANG_PROGRAM([],[return 0;]), [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) done FLAGS="$ac_save_[]FLAGS" AC_LANG_RESTORE ]) case ".$VAR" in .ok|.ok,*) m4_ifvaln($3,$3) ;; .|.no|.no,*) m4_ifvaln($4,$4) ;; *) m4_ifvaln($3,$3,[ if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR]) else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"]) m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR" fi ]) ;; esac AS_VAR_POPDEF([VAR])dnl AS_VAR_POPDEF([FLAGS])dnl ]) dnl the only difference - the LANG selection... and the default FLAGS AC_DEFUN([AX_CXXFLAGS_GCC_OPTION_OLD], [dnl AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_gcc_option_$2])dnl AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for gcc m4_ifval($2,$2,-option)], VAR,[VAR="no, unknown" AC_LANG_SAVE AC_LANG_CXX ac_save_[]FLAGS="$[]FLAGS" for ac_arg dnl in "-pedantic % m4_ifval($2,$2,-option)" dnl GCC # do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` AC_COMPILE_IFELSE(AC_LANG_PROGRAM([],[return 0;]), [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) done FLAGS="$ac_save_[]FLAGS" AC_LANG_RESTORE ]) case ".$VAR" in .ok|.ok,*) m4_ifvaln($3,$3) ;; .|.no|.no,*) m4_ifvaln($4,$4) ;; *) m4_ifvaln($3,$3,[ if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR]) else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"]) m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR" fi ]) ;; esac AS_VAR_POPDEF([VAR])dnl AS_VAR_POPDEF([FLAGS])dnl ]) dnl ------------------------------------------------------------------------- AC_DEFUN([AX_CFLAGS_GCC_OPTION_NEW], [dnl AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_gcc_option_$1])dnl AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for gcc m4_ifval($1,$1,-option)], VAR,[VAR="no, unknown" AC_LANG_SAVE AC_LANG_C ac_save_[]FLAGS="$[]FLAGS" for ac_arg dnl in "-pedantic % m4_ifval($1,$1,-option)" dnl GCC # do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[return 0;])], [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) done FLAGS="$ac_save_[]FLAGS" AC_LANG_RESTORE ]) case ".$VAR" in .ok|.ok,*) m4_ifvaln($3,$3) ;; .|.no|.no,*) m4_ifvaln($4,$4) ;; *) m4_ifvaln($3,$3,[ if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $VAR " 2>&1 >/dev/null then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $VAR]) else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"]) m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR" fi ]) ;; esac AS_VAR_POPDEF([VAR])dnl AS_VAR_POPDEF([FLAGS])dnl ]) dnl the only difference - the LANG selection... and the default FLAGS AC_DEFUN([AX_CXXFLAGS_GCC_OPTION_NEW], [dnl AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl AS_VAR_PUSHDEF([VAR],[ac_cv_cxxflags_gcc_option_$1])dnl AC_CACHE_CHECK([m4_ifval($2,$2,FLAGS) for gcc m4_ifval($1,$1,-option)], VAR,[VAR="no, unknown" AC_LANG_SAVE AC_LANG_CXX ac_save_[]FLAGS="$[]FLAGS" for ac_arg dnl in "-pedantic % m4_ifval($1,$1,-option)" dnl GCC # do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[return 0;])], [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) done FLAGS="$ac_save_[]FLAGS" AC_LANG_RESTORE ]) case ".$VAR" in .ok|.ok,*) m4_ifvaln($3,$3) ;; .|.no|.no,*) m4_ifvaln($4,$4) ;; *) m4_ifvaln($3,$3,[ if echo " $[]m4_ifval($2,$2,FLAGS) " | grep " $VAR " 2>&1 >/dev/null then AC_RUN_LOG([: m4_ifval($2,$2,FLAGS) does contain $VAR]) else AC_RUN_LOG([: m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR"]) m4_ifval($2,$2,FLAGS)="$m4_ifval($2,$2,FLAGS) $VAR" fi ]) ;; esac AS_VAR_POPDEF([VAR])dnl AS_VAR_POPDEF([FLAGS])dnl ]) AC_DEFUN([AX_CFLAGS_GCC_OPTION],[ifelse(m4_bregexp([$2],[-]),-1, [AX_CFLAGS_GCC_OPTION_NEW($@)],[AX_CFLAGS_GCC_OPTION_OLD($@)])]) AC_DEFUN([AX_CXXFLAGS_GCC_OPTION],[ifelse(m4_bregexp([$2],[-]),-1, [AX_CXXFLAGS_GCC_OPTION_NEW($@)],[AX_CXXFLAGS_GCC_OPTION_OLD($@)])]) freetds-1.00.82/m4/check_openssl.m4100644 025423 025423 00000003162 12717145107 0012437dnl $Id: check_openssl.m4,v 1.2 2006-03-27 07:22:54 jklowden Exp $ # OpenSSL check AC_DEFUN([CHECK_OPENSSL], [AC_MSG_CHECKING(if openssl is wanted) AC_ARG_WITH(openssl, AS_HELP_STRING([--with-openssl], [--with-openssl=DIR build with OpenSSL (license NOT compatible cf. User Guide)])) if test "$with_openssl" != "no"; then AC_MSG_RESULT(yes) old_NETWORK_LIBS="$NETWORK_LIBS" PKG_CHECK_MODULES(OPENSSL, [openssl], [found_ssl=yes CFLAGS="$CFLAGS $OPENSSL_CFLAGS" NETWORK_LIBS="$NETWORK_LIBS $OPENSSL_LIBS"], [found_ssl=no if test "$cross_compiling" != "yes"; then for dir in $withval /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr; do ssldir="$dir" if test -f "$dir/include/openssl/ssl.h"; then echo "OpenSSL found in $ssldir" found_ssl="yes" CFLAGS="$CFLAGS -I$ssldir/include" NETWORK_LIBS="$NETWORK_LIBS -lssl -lcrypto" LDFLAGS="$LDFLAGS -L$ssldir/lib" break fi done fi]) if test x$found_ssl = xyes; then ACX_PUSH_LIBS("$NETWORK_LIBS") AC_TRY_LINK([#include ], [SSL_read(NULL, NULL, 100);], [], [found_ssl=no]) ACX_POP_LIBS fi if test x$found_ssl != xyes -a "$with_openssl" != ""; then AC_MSG_ERROR(Cannot find OpenSSL libraries) NETWORK_LIBS="$old_NETWORK_LIBS" elif test x$found_ssl = xyes; then HAVE_OPENSSL=yes AC_DEFINE(HAVE_OPENSSL, 1, [Define if you have the OpenSSL.]) else NETWORK_LIBS="$old_NETWORK_LIBS" fi AC_SUBST(HAVE_OPENSSL) else AC_MSG_RESULT(no) fi ]) freetds-1.00.82/m4/gettimemilli.m4100644 025423 025423 00000004177 12522201763 0012306dnl $Id: gettimemilli.m4,v 1.1 2006-08-11 12:40:32 freddy77 Exp $ dnl this macros try to detect which is the better implementation dnl for a monotonic clock on different platforms dnl this is the results of some searching starting from dnl clock_gettime dnl dnl Linux and *BSD: clock_gettime(CLOCK_MONOTONIC) dnl IRIX: clock_gettime(CLOCK_SGI_CYCLE) dnl HU-UX: clock_gettime(CLOCK_REALTIME) dnl not monotonic but the better I found, same as gettimeofday dnl Solaris: gethrtime (returns a 64bit, very fine and easy) dnl Windows: GetTickCount dnl dnl I choose millisedonds precision cause this suite very well in dnl a unsigned int dnl check clock_gettime dnl some implemetations require -lrt or -lposix4 (Solaris) AC_DEFUN([TDS_CLOCK_GETTIME], [ AC_SEARCH_LIBS(clock_gettime, [rt posix4]) if test "$ac_cv_search_clock_gettime" != no; then AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if you have the clock_gettime function.]) fi ]) dnl check for constants for clock_gettime AC_DEFUN([TDS_CLOCK_GETTIME_CONST], [ AC_MSG_CHECKING(if clock_gettime support $1) AC_TRY_COMPILE([ #include #ifdef HAVE_SYS_TIME_H #include #endif ], [struct timespec ts; clock_gettime($1, &ts); ], tds_clock_gettime_const=yes, tds_clock_gettime_const=no) AC_MSG_RESULT($tds_clock_gettime_const) ]) dnl check all dnl if windows dnl use GetTickCount dnl else if gethrtime dnl use gethrtime dnl else if clock_gettime dnl check CLOCK_MONOTONIC dnl check CLOCK_SGI_CYCLE dnl check CLOCK_REALTIME dnl else if gettimeofday dnl use gettimeofday dnl end AC_DEFUN([TDS_GETTIMEMILLI], [ if test x$ac_cv_func_gethrtime = xno; then tds_save_LIBS="$LIBS" TDS_CLOCK_GETTIME if test "$ac_cv_search_clock_gettime" != no; then for tds_const in CLOCK_MONOTONIC CLOCK_SGI_CYCLE CLOCK_REALTIME; do TDS_CLOCK_GETTIME_CONST($tds_const) if test $tds_clock_gettime_const = yes; then AC_DEFINE_UNQUOTED(TDS_GETTIMEMILLI_CONST, [$tds_const], [define to constant to use for clock_gettime]) break fi done if test $tds_clock_gettime_const != yes; then LIBS="$tds_save_LIBS" fi fi fi ]) freetds-1.00.82/m4/libtool.m4100644 025423 025423 00001125073 13242511040 0011255# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- # # Copyright (C) 1996-2001, 2003-2015 Free Software Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. m4_define([_LT_COPYING], [dnl # Copyright (C) 2014 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # GNU Libtool 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 of the License, or # (at your option) any later version. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program or library that is built # using GNU Libtool, you may include this file under the same # distribution terms that you use for the rest of that program. # # GNU Libtool 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, see . ]) # serial 58 LT_INIT # LT_PREREQ(VERSION) # ------------------ # Complain and exit if this libtool version is less that VERSION. m4_defun([LT_PREREQ], [m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, [m4_default([$3], [m4_fatal([Libtool version $1 or higher is required], 63)])], [$2])]) # _LT_CHECK_BUILDDIR # ------------------ # Complain if the absolute build directory name contains unusual characters m4_defun([_LT_CHECK_BUILDDIR], [case `pwd` in *\ * | *\ *) AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; esac ]) # LT_INIT([OPTIONS]) # ------------------ AC_DEFUN([LT_INIT], [AC_PREREQ([2.62])dnl We use AC_PATH_PROGS_FEATURE_CHECK AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl AC_BEFORE([$0], [LT_LANG])dnl AC_BEFORE([$0], [LT_OUTPUT])dnl AC_BEFORE([$0], [LTDL_INIT])dnl m4_require([_LT_CHECK_BUILDDIR])dnl dnl Autoconf doesn't catch unexpanded LT_ macros by default: m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 dnl unless we require an AC_DEFUNed macro: AC_REQUIRE([LTOPTIONS_VERSION])dnl AC_REQUIRE([LTSUGAR_VERSION])dnl AC_REQUIRE([LTVERSION_VERSION])dnl AC_REQUIRE([LTOBSOLETE_VERSION])dnl m4_require([_LT_PROG_LTMAIN])dnl _LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}]) dnl Parse OPTIONS _LT_SET_OPTIONS([$0], [$1]) # This can be used to rebuild libtool when needed LIBTOOL_DEPS=$ltmain # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' AC_SUBST(LIBTOOL)dnl _LT_SETUP # Only expand once: m4_define([LT_INIT]) ])# LT_INIT # Old names: AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PROG_LIBTOOL], []) dnl AC_DEFUN([AM_PROG_LIBTOOL], []) # _LT_PREPARE_CC_BASENAME # ----------------------- m4_defun([_LT_PREPARE_CC_BASENAME], [ # Calculate cc_basename. Skip known compiler wrappers and cross-prefix. func_cc_basename () { for cc_temp in @S|@*""; do case $cc_temp in compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; \-*) ;; *) break;; esac done func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` } ])# _LT_PREPARE_CC_BASENAME # _LT_CC_BASENAME(CC) # ------------------- # It would be clearer to call AC_REQUIREs from _LT_PREPARE_CC_BASENAME, # but that macro is also expanded into generated libtool script, which # arranges for $SED and $ECHO to be set by different means. m4_defun([_LT_CC_BASENAME], [m4_require([_LT_PREPARE_CC_BASENAME])dnl AC_REQUIRE([_LT_DECL_SED])dnl AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl func_cc_basename $1 cc_basename=$func_cc_basename_result ]) # _LT_FILEUTILS_DEFAULTS # ---------------------- # It is okay to use these file commands and assume they have been set # sensibly after 'm4_require([_LT_FILEUTILS_DEFAULTS])'. m4_defun([_LT_FILEUTILS_DEFAULTS], [: ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} ])# _LT_FILEUTILS_DEFAULTS # _LT_SETUP # --------- m4_defun([_LT_SETUP], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl _LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl dnl _LT_DECL([], [host_alias], [0], [The host system])dnl _LT_DECL([], [host], [0])dnl _LT_DECL([], [host_os], [0])dnl dnl _LT_DECL([], [build_alias], [0], [The build system])dnl _LT_DECL([], [build], [0])dnl _LT_DECL([], [build_os], [0])dnl dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl dnl AC_REQUIRE([AC_PROG_LN_S])dnl test -z "$LN_S" && LN_S="ln -s" _LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl dnl AC_REQUIRE([LT_CMD_MAX_LEN])dnl _LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl _LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl m4_require([_LT_CMD_RELOAD])dnl m4_require([_LT_CHECK_MAGIC_METHOD])dnl m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl m4_require([_LT_CMD_OLD_ARCHIVE])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_WITH_SYSROOT])dnl m4_require([_LT_CMD_TRUNCATE])dnl _LT_CONFIG_LIBTOOL_INIT([ # See if we are running on zsh, and set the options that allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi ]) if test -n "${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi _LT_CHECK_OBJDIR m4_require([_LT_TAG_COMPILER])dnl case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test set != "${COLLECT_NAMES+set}"; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a '.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld=$lt_cv_prog_gnu_ld old_CC=$CC old_CFLAGS=$CFLAGS # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o _LT_CC_BASENAME([$compiler]) # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then _LT_PATH_MAGIC fi ;; esac # Use C for the default configuration in the libtool script LT_SUPPORTED_TAG([CC]) _LT_LANG_C_CONFIG _LT_LANG_DEFAULT_CONFIG _LT_CONFIG_COMMANDS ])# _LT_SETUP # _LT_PREPARE_SED_QUOTE_VARS # -------------------------- # Define a few sed substitution that help us do robust quoting. m4_defun([_LT_PREPARE_SED_QUOTE_VARS], [# Backslashify metacharacters that are still active within # double-quoted strings. sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\([["`\\]]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' ]) # _LT_PROG_LTMAIN # --------------- # Note that this code is called both from 'configure', and 'config.status' # now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, # 'config.status' has no value for ac_aux_dir unless we are using Automake, # so we pass a copy along to make sure it has a sensible value anyway. m4_defun([_LT_PROG_LTMAIN], [m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl _LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) ltmain=$ac_aux_dir/ltmain.sh ])# _LT_PROG_LTMAIN ## ------------------------------------- ## ## Accumulate code for creating libtool. ## ## ------------------------------------- ## # So that we can recreate a full libtool script including additional # tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS # in macros and then make a single call at the end using the 'libtool' # label. # _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) # ---------------------------------------- # Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL_INIT], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_INIT], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_INIT]) # _LT_CONFIG_LIBTOOL([COMMANDS]) # ------------------------------ # Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) # _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) # ----------------------------------------------------- m4_defun([_LT_CONFIG_SAVE_COMMANDS], [_LT_CONFIG_LIBTOOL([$1]) _LT_CONFIG_LIBTOOL_INIT([$2]) ]) # _LT_FORMAT_COMMENT([COMMENT]) # ----------------------------- # Add leading comment marks to the start of each line, and a trailing # full-stop to the whole comment if one is not present already. m4_define([_LT_FORMAT_COMMENT], [m4_ifval([$1], [ m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) )]) ## ------------------------ ## ## FIXME: Eliminate VARNAME ## ## ------------------------ ## # _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) # ------------------------------------------------------------------- # CONFIGNAME is the name given to the value in the libtool script. # VARNAME is the (base) name used in the configure script. # VALUE may be 0, 1 or 2 for a computed quote escaped value based on # VARNAME. Any other value will be used directly. m4_define([_LT_DECL], [lt_if_append_uniq([lt_decl_varnames], [$2], [, ], [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], [m4_ifval([$1], [$1], [$2])]) lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) m4_ifval([$4], [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) lt_dict_add_subkey([lt_decl_dict], [$2], [tagged?], [m4_ifval([$5], [yes], [no])])]) ]) # _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) # -------------------------------------------------------- m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) # lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_tag_varnames], [_lt_decl_filter([tagged?], [yes], $@)]) # _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) # --------------------------------------------------------- m4_define([_lt_decl_filter], [m4_case([$#], [0], [m4_fatal([$0: too few arguments: $#])], [1], [m4_fatal([$0: too few arguments: $#: $1])], [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], [lt_dict_filter([lt_decl_dict], $@)])[]dnl ]) # lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) # -------------------------------------------------- m4_define([lt_decl_quote_varnames], [_lt_decl_filter([value], [1], $@)]) # lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_dquote_varnames], [_lt_decl_filter([value], [2], $@)]) # lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_varnames_tagged], [m4_assert([$# <= 2])dnl _$0(m4_quote(m4_default([$1], [[, ]])), m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]), m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))]) m4_define([_lt_decl_varnames_tagged], [m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])]) # lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_all_varnames], [_$0(m4_quote(m4_default([$1], [[, ]])), m4_if([$2], [], m4_quote(lt_decl_varnames), m4_quote(m4_shift($@))))[]dnl ]) m4_define([_lt_decl_all_varnames], [lt_join($@, lt_decl_varnames_tagged([$1], lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl ]) # _LT_CONFIG_STATUS_DECLARE([VARNAME]) # ------------------------------------ # Quote a variable value, and forward it to 'config.status' so that its # declaration there will have the same value as in 'configure'. VARNAME # must have a single quote delimited value for this to work. m4_define([_LT_CONFIG_STATUS_DECLARE], [$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`']) # _LT_CONFIG_STATUS_DECLARATIONS # ------------------------------ # We delimit libtool config variables with single quotes, so when # we write them to config.status, we have to be sure to quote all # embedded single quotes properly. In configure, this macro expands # each variable declared with _LT_DECL (and _LT_TAGDECL) into: # # ='`$ECHO "$" | $SED "$delay_single_quote_subst"`' m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], [m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAGS # ---------------- # Output comment and list of tags supported by the script m4_defun([_LT_LIBTOOL_TAGS], [_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl available_tags='_LT_TAGS'dnl ]) # _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) # ----------------------------------- # Extract the dictionary values for VARNAME (optionally with TAG) and # expand to a commented shell variable setting: # # # Some comment about what VAR is for. # visible_name=$lt_internal_name m4_define([_LT_LIBTOOL_DECLARE], [_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [description])))[]dnl m4_pushdef([_libtool_name], m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), [0], [_libtool_name=[$]$1], [1], [_libtool_name=$lt_[]$1], [2], [_libtool_name=$lt_[]$1], [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl ]) # _LT_LIBTOOL_CONFIG_VARS # ----------------------- # Produce commented declarations of non-tagged libtool config variables # suitable for insertion in the LIBTOOL CONFIG section of the 'libtool' # script. Tagged libtool config variables (even for the LIBTOOL CONFIG # section) are produced by _LT_LIBTOOL_TAG_VARS. m4_defun([_LT_LIBTOOL_CONFIG_VARS], [m4_foreach([_lt_var], m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAG_VARS(TAG) # ------------------------- m4_define([_LT_LIBTOOL_TAG_VARS], [m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) # _LT_TAGVAR(VARNAME, [TAGNAME]) # ------------------------------ m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) # _LT_CONFIG_COMMANDS # ------------------- # Send accumulated output to $CONFIG_STATUS. Thanks to the lists of # variables for single and double quote escaping we saved from calls # to _LT_DECL, we can put quote escaped variables declarations # into 'config.status', and then the shell code to quote escape them in # for loops in 'config.status'. Finally, any additional code accumulated # from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. m4_defun([_LT_CONFIG_COMMANDS], [AC_PROVIDE_IFELSE([LT_OUTPUT], dnl If the libtool generation code has been placed in $CONFIG_LT, dnl instead of duplicating it all over again into config.status, dnl then we will have config.status run $CONFIG_LT later, so it dnl needs to know what name is stored there: [AC_CONFIG_COMMANDS([libtool], [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], dnl If the libtool generation code is destined for config.status, dnl expand the accumulated commands and init code now: [AC_CONFIG_COMMANDS([libtool], [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) ])#_LT_CONFIG_COMMANDS # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], [ # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' _LT_CONFIG_STATUS_DECLARATIONS LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$[]1 _LTECHO_EOF' } # Quote evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_quote_varnames); do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_dquote_varnames); do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done _LT_OUTPUT_LIBTOOL_INIT ]) # _LT_GENERATED_FILE_INIT(FILE, [COMMENT]) # ------------------------------------ # Generate a child script FILE with all initialization necessary to # reuse the environment learned by the parent script, and make the # file executable. If COMMENT is supplied, it is inserted after the # '#!' sequence but before initialization text begins. After this # macro, additional text can be appended to FILE to form the body of # the child script. The macro ends with non-zero status if the # file could not be fully written (such as if the disk is full). m4_ifdef([AS_INIT_GENERATED], [m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])], [m4_defun([_LT_GENERATED_FILE_INIT], [m4_require([AS_PREPARE])]dnl [m4_pushdef([AS_MESSAGE_LOG_FD])]dnl [lt_write_fail=0 cat >$1 <<_ASEOF || lt_write_fail=1 #! $SHELL # Generated by $as_me. $2 SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$1 <<\_ASEOF || lt_write_fail=1 AS_SHELL_SANITIZE _AS_PREPARE exec AS_MESSAGE_FD>&1 _ASEOF test 0 = "$lt_write_fail" && chmod +x $1[]dnl m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT # LT_OUTPUT # --------- # This macro allows early generation of the libtool script (before # AC_OUTPUT is called), incase it is used in configure for compilation # tests. AC_DEFUN([LT_OUTPUT], [: ${CONFIG_LT=./config.lt} AC_MSG_NOTICE([creating $CONFIG_LT]) _LT_GENERATED_FILE_INIT(["$CONFIG_LT"], [# Run this file to recreate a libtool stub with the current configuration.]) cat >>"$CONFIG_LT" <<\_LTEOF lt_cl_silent=false exec AS_MESSAGE_LOG_FD>>config.log { echo AS_BOX([Running $as_me.]) } >&AS_MESSAGE_LOG_FD lt_cl_help="\ '$as_me' creates a local libtool stub from the current configuration, for use in further configure time tests before the real libtool is generated. Usage: $[0] [[OPTIONS]] -h, --help print this help, then exit -V, --version print version number, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files Report bugs to ." lt_cl_version="\ m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) configured by $[0], generated by m4_PACKAGE_STRING. Copyright (C) 2011 Free Software Foundation, Inc. This config.lt script is free software; the Free Software Foundation gives unlimited permision to copy, distribute and modify it." while test 0 != $[#] do case $[1] in --version | --v* | -V ) echo "$lt_cl_version"; exit 0 ;; --help | --h* | -h ) echo "$lt_cl_help"; exit 0 ;; --debug | --d* | -d ) debug=: ;; --quiet | --q* | --silent | --s* | -q ) lt_cl_silent=: ;; -*) AC_MSG_ERROR([unrecognized option: $[1] Try '$[0] --help' for more information.]) ;; *) AC_MSG_ERROR([unrecognized argument: $[1] Try '$[0] --help' for more information.]) ;; esac shift done if $lt_cl_silent; then exec AS_MESSAGE_FD>/dev/null fi _LTEOF cat >>"$CONFIG_LT" <<_LTEOF _LT_OUTPUT_LIBTOOL_COMMANDS_INIT _LTEOF cat >>"$CONFIG_LT" <<\_LTEOF AC_MSG_NOTICE([creating $ofile]) _LT_OUTPUT_LIBTOOL_COMMANDS AS_EXIT(0) _LTEOF chmod +x "$CONFIG_LT" # configure is writing to config.log, but config.lt does its own redirection, # appending to config.log, which fails on DOS, as config.log is still kept # open by configure. Here we exec the FD to /dev/null, effectively closing # config.log, so it can be properly (re)opened and appended to by config.lt. lt_cl_success=: test yes = "$silent" && lt_config_lt_args="$lt_config_lt_args --quiet" exec AS_MESSAGE_LOG_FD>/dev/null $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false exec AS_MESSAGE_LOG_FD>>config.log $lt_cl_success || AS_EXIT(1) ])# LT_OUTPUT # _LT_CONFIG(TAG) # --------------- # If TAG is the built-in tag, create an initial libtool script with a # default configuration from the untagged config vars. Otherwise add code # to config.status for appending the configuration named by TAG from the # matching tagged config vars. m4_defun([_LT_CONFIG], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_CONFIG_SAVE_COMMANDS([ m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl m4_if(_LT_TAG, [C], [ # See if we are running on zsh, and set the options that allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi cfgfile=${ofile}T trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # Generated automatically by $as_me ($PACKAGE) $VERSION # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # Provide generalized library-building support services. # Written by Gordon Matzigkeit, 1996 _LT_COPYING _LT_LIBTOOL_TAGS # Configured defaults for sys_lib_dlsearch_path munging. : \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"} # ### BEGIN LIBTOOL CONFIG _LT_LIBTOOL_CONFIG_VARS _LT_LIBTOOL_TAG_VARS # ### END LIBTOOL CONFIG _LT_EOF cat <<'_LT_EOF' >> "$cfgfile" # ### BEGIN FUNCTIONS SHARED WITH CONFIGURE _LT_PREPARE_MUNGE_PATH_LIST _LT_PREPARE_CC_BASENAME # ### END FUNCTIONS SHARED WITH CONFIGURE _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test set != "${COLLECT_NAMES+set}"; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac _LT_PROG_LTMAIN # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" ], [cat <<_LT_EOF >> "$ofile" dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded dnl in a comment (ie after a #). # ### BEGIN LIBTOOL TAG CONFIG: $1 _LT_LIBTOOL_TAG_VARS(_LT_TAG) # ### END LIBTOOL TAG CONFIG: $1 _LT_EOF ])dnl /m4_if ], [m4_if([$1], [], [ PACKAGE='$PACKAGE' VERSION='$VERSION' RM='$RM' ofile='$ofile'], []) ])dnl /_LT_CONFIG_SAVE_COMMANDS ])# _LT_CONFIG # LT_SUPPORTED_TAG(TAG) # --------------------- # Trace this macro to discover what tags are supported by the libtool # --tag option, using: # autoconf --trace 'LT_SUPPORTED_TAG:$1' AC_DEFUN([LT_SUPPORTED_TAG], []) # C support is built-in for now m4_define([_LT_LANG_C_enabled], []) m4_define([_LT_TAGS], []) # LT_LANG(LANG) # ------------- # Enable libtool support for the given language if not already enabled. AC_DEFUN([LT_LANG], [AC_BEFORE([$0], [LT_OUTPUT])dnl m4_case([$1], [C], [_LT_LANG(C)], [C++], [_LT_LANG(CXX)], [Go], [_LT_LANG(GO)], [Java], [_LT_LANG(GCJ)], [Fortran 77], [_LT_LANG(F77)], [Fortran], [_LT_LANG(FC)], [Windows Resource], [_LT_LANG(RC)], [m4_ifdef([_LT_LANG_]$1[_CONFIG], [_LT_LANG($1)], [m4_fatal([$0: unsupported language: "$1"])])])dnl ])# LT_LANG # _LT_LANG(LANGNAME) # ------------------ m4_defun([_LT_LANG], [m4_ifdef([_LT_LANG_]$1[_enabled], [], [LT_SUPPORTED_TAG([$1])dnl m4_append([_LT_TAGS], [$1 ])dnl m4_define([_LT_LANG_]$1[_enabled], [])dnl _LT_LANG_$1_CONFIG($1)])dnl ])# _LT_LANG m4_ifndef([AC_PROG_GO], [ ############################################################ # NOTE: This macro has been submitted for inclusion into # # GNU Autoconf as AC_PROG_GO. When it is available in # # a released version of Autoconf we should remove this # # macro and use it instead. # ############################################################ m4_defun([AC_PROG_GO], [AC_LANG_PUSH(Go)dnl AC_ARG_VAR([GOC], [Go compiler command])dnl AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl _AC_ARG_VAR_LDFLAGS()dnl AC_CHECK_TOOL(GOC, gccgo) if test -z "$GOC"; then if test -n "$ac_tool_prefix"; then AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo]) fi fi if test -z "$GOC"; then AC_CHECK_PROG(GOC, gccgo, gccgo, false) fi ])#m4_defun ])#m4_ifndef # _LT_LANG_DEFAULT_CONFIG # ----------------------- m4_defun([_LT_LANG_DEFAULT_CONFIG], [AC_PROVIDE_IFELSE([AC_PROG_CXX], [LT_LANG(CXX)], [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) AC_PROVIDE_IFELSE([AC_PROG_F77], [LT_LANG(F77)], [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) AC_PROVIDE_IFELSE([AC_PROG_FC], [LT_LANG(FC)], [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal dnl pulling things in needlessly. AC_PROVIDE_IFELSE([AC_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([LT_PROG_GCJ], [LT_LANG(GCJ)], [m4_ifdef([AC_PROG_GCJ], [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([A][M_PROG_GCJ], [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([LT_PROG_GCJ], [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) AC_PROVIDE_IFELSE([AC_PROG_GO], [LT_LANG(GO)], [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])]) AC_PROVIDE_IFELSE([LT_PROG_RC], [LT_LANG(RC)], [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) ])# _LT_LANG_DEFAULT_CONFIG # Obsolete macros: AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_CXX], []) dnl AC_DEFUN([AC_LIBTOOL_F77], []) dnl AC_DEFUN([AC_LIBTOOL_FC], []) dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) dnl AC_DEFUN([AC_LIBTOOL_RC], []) # _LT_TAG_COMPILER # ---------------- m4_defun([_LT_TAG_COMPILER], [AC_REQUIRE([AC_PROG_CC])dnl _LT_DECL([LTCC], [CC], [1], [A C compiler])dnl _LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl _LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl _LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC ])# _LT_TAG_COMPILER # _LT_COMPILER_BOILERPLATE # ------------------------ # Check for compiler boilerplate output or warnings with # the simple compiler test code. m4_defun([_LT_COMPILER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ])# _LT_COMPILER_BOILERPLATE # _LT_LINKER_BOILERPLATE # ---------------------- # Check for linker boilerplate output or warnings with # the simple link test code. m4_defun([_LT_LINKER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* ])# _LT_LINKER_BOILERPLATE # _LT_REQUIRED_DARWIN_CHECKS # ------------------------- m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ case $host_os in rhapsody* | darwin*) AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) AC_CHECK_TOOL([LIPO], [lipo], [:]) AC_CHECK_TOOL([OTOOL], [otool], [:]) AC_CHECK_TOOL([OTOOL64], [otool64], [:]) _LT_DECL([], [DSYMUTIL], [1], [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) _LT_DECL([], [NMEDIT], [1], [Tool to change global to local symbols on Mac OS X]) _LT_DECL([], [LIPO], [1], [Tool to manipulate fat objects and archives on Mac OS X]) _LT_DECL([], [OTOOL], [1], [ldd/readelf like tool for Mach-O binaries on Mac OS X]) _LT_DECL([], [OTOOL64], [1], [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], [lt_cv_apple_cc_single_mod=no if test -z "$LT_MULTI_MODULE"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? # If there is a non-empty error log, and "single_module" # appears in it, assume the flag caused a linker warning if test -s conftest.err && $GREP single_module conftest.err; then cat conftest.err >&AS_MESSAGE_LOG_FD # Otherwise, if the output was created with a 0 exit code from # the compiler, it worked. elif test -f libconftest.dylib && test 0 = "$_lt_result"; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&AS_MESSAGE_LOG_FD fi rm -rf libconftest.dylib* rm -f conftest.* fi]) AC_CACHE_CHECK([for -exported_symbols_list linker flag], [lt_cv_ld_exported_symbols_list], [lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [lt_cv_ld_exported_symbols_list=yes], [lt_cv_ld_exported_symbols_list=no]) LDFLAGS=$save_LDFLAGS ]) AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load], [lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -s conftest.err && $GREP force_load conftest.err; then cat conftest.err >&AS_MESSAGE_LOG_FD elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then lt_cv_ld_force_load=yes else cat conftest.err >&AS_MESSAGE_LOG_FD fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM ]) case $host_os in rhapsody* | darwin1.[[012]]) _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; 10.[[012]][[,.]]*) _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test yes = "$lt_cv_apple_cc_single_mod"; then _lt_dar_single_mod='$single_module' fi if test yes = "$lt_cv_ld_exported_symbols_list"; then _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib' fi if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac ]) # _LT_DARWIN_LINKER_FEATURES([TAG]) # --------------------------------- # Checks for linker and compiler features on darwin m4_defun([_LT_DARWIN_LINKER_FEATURES], [ m4_require([_LT_REQUIRED_DARWIN_CHECKS]) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported if test yes = "$lt_cv_ld_force_load"; then _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes], [FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes]) else _LT_TAGVAR(whole_archive_flag_spec, $1)='' fi _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)=$_lt_dar_allow_undefined case $cc_basename in ifort*|nagfor*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test yes = "$_lt_dar_can_shared"; then output_verbose_link_cmd=func_echo_all _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil" _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" m4_if([$1], [CXX], [ if test yes != "$lt_cv_apple_cc_single_mod"; then _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dsymutil" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dar_export_syms$_lt_dsymutil" fi ],[]) else _LT_TAGVAR(ld_shlibs, $1)=no fi ]) # _LT_SYS_MODULE_PATH_AIX([TAGNAME]) # ---------------------------------- # Links a minimal program and checks the executable # for the system default hardcoded library path. In most cases, # this is /usr/lib:/lib, but when the MPI compilers are used # the location of the communication and MPI libs are included too. # If we don't find anything, use the default library path according # to the aix ld manual. # Store the results from the different compilers for each TAGNAME. # Allow to override them for all tags through lt_cv_aix_libpath. m4_defun([_LT_SYS_MODULE_PATH_AIX], [m4_require([_LT_DECL_SED])dnl if test set = "${lt_cv_aix_libpath+set}"; then aix_libpath=$lt_cv_aix_libpath else AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])], [AC_LINK_IFELSE([AC_LANG_PROGRAM],[ lt_aix_libpath_sed='[ /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }]' _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi],[]) if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=/usr/lib:/lib fi ]) aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1]) fi ])# _LT_SYS_MODULE_PATH_AIX # _LT_SHELL_INIT(ARG) # ------------------- m4_define([_LT_SHELL_INIT], [m4_divert_text([M4SH-INIT], [$1 ])])# _LT_SHELL_INIT # _LT_PROG_ECHO_BACKSLASH # ----------------------- # Find how we can fake an echo command that does not interpret backslash. # In particular, with Autoconf 2.60 or later we add some code to the start # of the generated configure script that will find a shell with a builtin # printf (that we can use as an echo command). m4_defun([_LT_PROG_ECHO_BACKSLASH], [ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO AC_MSG_CHECKING([how to print strings]) # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $[]1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } case $ECHO in printf*) AC_MSG_RESULT([printf]) ;; print*) AC_MSG_RESULT([print -r]) ;; *) AC_MSG_RESULT([cat]) ;; esac m4_ifdef([_AS_DETECT_SUGGESTED], [_AS_DETECT_SUGGESTED([ test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test "X`printf %s $ECHO`" = "X$ECHO" \ || test "X`print -r -- $ECHO`" = "X$ECHO" )])]) _LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) _LT_DECL([], [ECHO], [1], [An echo program that protects backslashes]) ])# _LT_PROG_ECHO_BACKSLASH # _LT_WITH_SYSROOT # ---------------- AC_DEFUN([_LT_WITH_SYSROOT], [AC_MSG_CHECKING([for sysroot]) AC_ARG_WITH([sysroot], [AS_HELP_STRING([--with-sysroot@<:@=DIR@:>@], [Search for dependent libraries within DIR (or the compiler's sysroot if not specified).])], [], [with_sysroot=no]) dnl lt_sysroot will always be passed unquoted. We quote it here dnl in case the user passed a directory name. lt_sysroot= case $with_sysroot in #( yes) if test yes = "$GCC"; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) AC_MSG_RESULT([$with_sysroot]) AC_MSG_ERROR([The sysroot must be an absolute path.]) ;; esac AC_MSG_RESULT([${lt_sysroot:-no}]) _LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl [dependent libraries, and where our libraries should be installed.])]) # _LT_ENABLE_LOCK # --------------- m4_defun([_LT_ENABLE_LOCK], [AC_ARG_ENABLE([libtool-lock], [AS_HELP_STRING([--disable-libtool-lock], [avoid locking (might break parallel builds)])]) test no = "$enable_libtool_lock" || enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out what ABI is being produced by ac_compile, and set mode # options accordingly. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE=32 ;; *ELF-64*) HPUX_IA64_MODE=64 ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then if test yes = "$lt_cv_prog_gnu_ld"; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; mips64*-*linux*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then emul=elf case `/usr/bin/file conftest.$ac_objext` in *32-bit*) emul="${emul}32" ;; *64-bit*) emul="${emul}64" ;; esac case `/usr/bin/file conftest.$ac_objext` in *MSB*) emul="${emul}btsmip" ;; *LSB*) emul="${emul}ltsmip" ;; esac case `/usr/bin/file conftest.$ac_objext` in *N32*) emul="${emul}n32" ;; esac LD="${LD-ld} -m $emul" fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. Note that the listed cases only cover the # situations where additional linker options are needed (such as when # doing 32-bit compilation for a host where ld defaults to 64-bit, or # vice versa); the common cases where no linker options are needed do # not appear in the list. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) case `/usr/bin/file conftest.o` in *x86-64*) LD="${LD-ld} -m elf32_x86_64" ;; *) LD="${LD-ld} -m elf_i386" ;; esac ;; powerpc64le-*linux*) LD="${LD-ld} -m elf32lppclinux" ;; powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; powerpcle-*linux*) LD="${LD-ld} -m elf64lppc" ;; powerpc-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS=$CFLAGS CFLAGS="$CFLAGS -belf" AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, [AC_LANG_PUSH(C) AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) AC_LANG_POP]) if test yes != "$lt_cv_cc_needs_belf"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS=$SAVE_CFLAGS fi ;; *-*solaris*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) case $host in i?86-*-solaris*|x86_64-*-solaris*) LD="${LD-ld} -m elf_x86_64" ;; sparc*-*-solaris*) LD="${LD-ld} -m elf64_sparc" ;; esac # GNU ld 2.21 introduced _sol2 emulations. Use them if available. if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then LD=${LD-ld}_sol2 fi ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks=$enable_libtool_lock ])# _LT_ENABLE_LOCK # _LT_PROG_AR # ----------- m4_defun([_LT_PROG_AR], [AC_CHECK_TOOLS(AR, [ar], false) : ${AR=ar} : ${AR_FLAGS=cru} _LT_DECL([], [AR], [1], [The archiver]) _LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], [lt_cv_ar_at_file=no AC_COMPILE_IFELSE([AC_LANG_PROGRAM], [echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD' AC_TRY_EVAL([lt_ar_try]) if test 0 -eq "$ac_status"; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a AC_TRY_EVAL([lt_ar_try]) if test 0 -ne "$ac_status"; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a ]) ]) if test no = "$lt_cv_ar_at_file"; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi _LT_DECL([], [archiver_list_spec], [1], [How to feed a file listing to the archiver]) ])# _LT_PROG_AR # _LT_CMD_OLD_ARCHIVE # ------------------- m4_defun([_LT_CMD_OLD_ARCHIVE], [_LT_PROG_AR AC_CHECK_TOOL(STRIP, strip, :) test -z "$STRIP" && STRIP=: _LT_DECL([], [STRIP], [1], [A symbol stripping program]) AC_CHECK_TOOL(RANLIB, ranlib, :) test -z "$RANLIB" && RANLIB=: _LT_DECL([], [RANLIB], [1], [Commands used to install an old-style archive]) # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in bitrig* | openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac _LT_DECL([], [old_postinstall_cmds], [2]) _LT_DECL([], [old_postuninstall_cmds], [2]) _LT_TAGDECL([], [old_archive_cmds], [2], [Commands used to build an old-style archive]) _LT_DECL([], [lock_old_archive_extraction], [0], [Whether to use a lock for old archive extraction]) ])# _LT_CMD_OLD_ARCHIVE # _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------------------- # Check whether the given compiler option works AC_DEFUN([_LT_COMPILER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$3" ## exclude from sc_useless_quotes_in_assignment # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi fi $RM conftest* ]) if test yes = "[$]$2"; then m4_if([$5], , :, [$5]) else m4_if([$6], , :, [$6]) fi ])# _LT_COMPILER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) # _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------- # Check whether the given linker option works AC_DEFUN([_LT_LINKER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS $3" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&AS_MESSAGE_LOG_FD $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi else $2=yes fi fi $RM -r conftest* LDFLAGS=$save_LDFLAGS ]) if test yes = "[$]$2"; then m4_if([$4], , :, [$4]) else m4_if([$5], , :, [$5]) fi ])# _LT_LINKER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) # LT_CMD_MAX_LEN #--------------- AC_DEFUN([LT_CMD_MAX_LEN], [AC_REQUIRE([AC_CANONICAL_HOST])dnl # find the maximum length of command line arguments AC_MSG_CHECKING([the maximum length of command line arguments]) AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl i=0 teststring=ABCD case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; mint*) # On MiNT this can take a long time and run out of memory. lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; os2*) # The test takes a long time on OS/2. lt_cv_sys_max_cmd_len=8192 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len" && \ test undefined != "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test X`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test 17 != "$i" # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac ]) if test -n "$lt_cv_sys_max_cmd_len"; then AC_MSG_RESULT($lt_cv_sys_max_cmd_len) else AC_MSG_RESULT(none) fi max_cmd_len=$lt_cv_sys_max_cmd_len _LT_DECL([], [max_cmd_len], [0], [What is the maximum length of a command?]) ])# LT_CMD_MAX_LEN # Old name: AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) # _LT_HEADER_DLFCN # ---------------- m4_defun([_LT_HEADER_DLFCN], [AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl ])# _LT_HEADER_DLFCN # _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, # ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) # ---------------------------------------------------------------- m4_defun([_LT_TRY_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test yes = "$cross_compiling"; then : [$4] else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF [#line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisibility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; }] _LT_EOF if AC_TRY_EVAL(ac_link) && test -s "conftest$ac_exeext" 2>/dev/null; then (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) $1 ;; x$lt_dlneed_uscore) $2 ;; x$lt_dlunknown|x*) $3 ;; esac else : # compilation failed $3 fi fi rm -fr conftest* ])# _LT_TRY_DLOPEN_SELF # LT_SYS_DLOPEN_SELF # ------------------ AC_DEFUN([LT_SYS_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test yes != "$enable_dlopen"; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen=load_add_on lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen=LoadLibrary lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen=dlopen lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl],[ lt_cv_dlopen=dyld lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ]) ;; tpf*) # Don't try to run any link tests for TPF. We know it's impossible # because TPF is a cross-compiler, and we know how we open DSOs. lt_cv_dlopen=dlopen lt_cv_dlopen_libs= lt_cv_dlopen_self=no ;; *) AC_CHECK_FUNC([shl_load], [lt_cv_dlopen=shl_load], [AC_CHECK_LIB([dld], [shl_load], [lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld], [AC_CHECK_FUNC([dlopen], [lt_cv_dlopen=dlopen], [AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl], [AC_CHECK_LIB([svld], [dlopen], [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld], [AC_CHECK_LIB([dld], [dld_link], [lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld]) ]) ]) ]) ]) ]) ;; esac if test no = "$lt_cv_dlopen"; then enable_dlopen=no else enable_dlopen=yes fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS=$CPPFLAGS test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS=$LDFLAGS wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS=$LIBS LIBS="$lt_cv_dlopen_libs $LIBS" AC_CACHE_CHECK([whether a program can dlopen itself], lt_cv_dlopen_self, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) ]) if test yes = "$lt_cv_dlopen_self"; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" AC_CACHE_CHECK([whether a statically linked program can dlopen itself], lt_cv_dlopen_self_static, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) ]) fi CPPFLAGS=$save_CPPFLAGS LDFLAGS=$save_LDFLAGS LIBS=$save_LIBS ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi _LT_DECL([dlopen_support], [enable_dlopen], [0], [Whether dlopen is supported]) _LT_DECL([dlopen_self], [enable_dlopen_self], [0], [Whether dlopen of programs is supported]) _LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], [Whether dlopen of statically linked programs is supported]) ])# LT_SYS_DLOPEN_SELF # Old name: AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) # _LT_COMPILER_C_O([TAGNAME]) # --------------------------- # Check to see if options -c and -o are simultaneously supported by compiler. # This macro does not hard code the compiler like AC_PROG_CC_C_O. m4_defun([_LT_COMPILER_C_O], [m4_require([_LT_DECL_SED])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes fi fi chmod u+w . 2>&AS_MESSAGE_LOG_FD $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* ]) _LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], [Does compiler simultaneously support -c and -o options?]) ])# _LT_COMPILER_C_O # _LT_COMPILER_FILE_LOCKS([TAGNAME]) # ---------------------------------- # Check to see if we can do hard links to lock some files if needed m4_defun([_LT_COMPILER_FILE_LOCKS], [m4_require([_LT_ENABLE_LOCK])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_COMPILER_C_O([$1]) hard_links=nottested if test no = "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" && test no != "$need_locks"; then # do not overwrite the value of need_locks provided by the user AC_MSG_CHECKING([if we can lock with hard links]) hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no AC_MSG_RESULT([$hard_links]) if test no = "$hard_links"; then AC_MSG_WARN(['$CC' does not support '-c -o', so 'make -j' may be unsafe]) need_locks=warn fi else need_locks=no fi _LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) ])# _LT_COMPILER_FILE_LOCKS # _LT_CHECK_OBJDIR # ---------------- m4_defun([_LT_CHECK_OBJDIR], [AC_CACHE_CHECK([for objdir], [lt_cv_objdir], [rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null]) objdir=$lt_cv_objdir _LT_DECL([], [objdir], [0], [The name of the directory that contains temporary libtool files])dnl m4_pattern_allow([LT_OBJDIR])dnl AC_DEFINE_UNQUOTED([LT_OBJDIR], "$lt_cv_objdir/", [Define to the sub-directory where libtool stores uninstalled libraries.]) ])# _LT_CHECK_OBJDIR # _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) # -------------------------------------- # Check hardcoding attributes. m4_defun([_LT_LINKER_HARDCODE_LIBPATH], [AC_MSG_CHECKING([how to hardcode library paths into programs]) _LT_TAGVAR(hardcode_action, $1)= if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || test -n "$_LT_TAGVAR(runpath_var, $1)" || test yes = "$_LT_TAGVAR(hardcode_automatic, $1)"; then # We can hardcode non-existent directories. if test no != "$_LT_TAGVAR(hardcode_direct, $1)" && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" && test no != "$_LT_TAGVAR(hardcode_minus_L, $1)"; then # Linking always hardcodes the temporary library directory. _LT_TAGVAR(hardcode_action, $1)=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. _LT_TAGVAR(hardcode_action, $1)=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. _LT_TAGVAR(hardcode_action, $1)=unsupported fi AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) if test relink = "$_LT_TAGVAR(hardcode_action, $1)" || test yes = "$_LT_TAGVAR(inherit_rpath, $1)"; then # Fast installation is not supported enable_fast_install=no elif test yes = "$shlibpath_overrides_runpath" || test no = "$enable_shared"; then # Fast installation is not necessary enable_fast_install=needless fi _LT_TAGDECL([], [hardcode_action], [0], [How to hardcode a shared library path into an executable]) ])# _LT_LINKER_HARDCODE_LIBPATH # _LT_CMD_STRIPLIB # ---------------- m4_defun([_LT_CMD_STRIPLIB], [m4_require([_LT_DECL_EGREP]) striplib= old_striplib= AC_MSG_CHECKING([whether stripping libraries is possible]) if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" AC_MSG_RESULT([yes]) else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP"; then striplib="$STRIP -x" old_striplib="$STRIP -S" AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi ;; *) AC_MSG_RESULT([no]) ;; esac fi _LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) _LT_DECL([], [striplib], [1]) ])# _LT_CMD_STRIPLIB # _LT_PREPARE_MUNGE_PATH_LIST # --------------------------- # Make sure func_munge_path_list() is defined correctly. m4_defun([_LT_PREPARE_MUNGE_PATH_LIST], [[# func_munge_path_list VARIABLE PATH # ----------------------------------- # VARIABLE is name of variable containing _space_ separated list of # directories to be munged by the contents of PATH, which is string # having a format: # "DIR[:DIR]:" # string "DIR[ DIR]" will be prepended to VARIABLE # ":DIR[:DIR]" # string "DIR[ DIR]" will be appended to VARIABLE # "DIRP[:DIRP]::[DIRA:]DIRA" # string "DIRP[ DIRP]" will be prepended to VARIABLE and string # "DIRA[ DIRA]" will be appended to VARIABLE # "DIR[:DIR]" # VARIABLE will be replaced by "DIR[ DIR]" func_munge_path_list () { case x@S|@2 in x) ;; *:) eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'` \@S|@@S|@1\" ;; x:*) eval @S|@1=\"\@S|@@S|@1 `$ECHO @S|@2 | $SED 's/:/ /g'`\" ;; *::*) eval @S|@1=\"\@S|@@S|@1\ `$ECHO @S|@2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" eval @S|@1=\"`$ECHO @S|@2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \@S|@@S|@1\" ;; *) eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'`\" ;; esac } ]])# _LT_PREPARE_PATH_LIST # _LT_SYS_DYNAMIC_LINKER([TAG]) # ----------------------------- # PORTME Fill in your ld.so characteristics m4_defun([_LT_SYS_DYNAMIC_LINKER], [AC_REQUIRE([AC_CANONICAL_HOST])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_OBJDUMP])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl m4_require([_LT_PREPARE_MUNGE_PATH_LIST])dnl AC_MSG_CHECKING([dynamic linker characteristics]) m4_if([$1], [], [ if test yes = "$GCC"; then case $host_os in darwin*) lt_awk_arg='/^libraries:/,/LR/' ;; *) lt_awk_arg='/^libraries:/' ;; esac case $host_os in mingw* | cegcc*) lt_sed_strip_eq='s|=\([[A-Za-z]]:\)|\1|g' ;; *) lt_sed_strip_eq='s|=/|/|g' ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary... lt_tmp_lt_search_path_spec= lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` # ...but if some path component already ends with the multilib dir we assume # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer). case "$lt_multi_os_dir; $lt_search_path_spec " in "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*) lt_multi_os_dir= ;; esac for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir" elif test -n "$lt_multi_os_dir"; then test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' BEGIN {RS = " "; FS = "/|\n";} { lt_foo = ""; lt_count = 0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo = "/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[[lt_foo]]++; } if (lt_freq[[lt_foo]] == 1) { print lt_foo; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's|/\([[A-Za-z]]:\)|\1|g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi]) library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=.so postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown AC_ARG_VAR([LT_SYS_LIBRARY_PATH], [User-defined run-time library search path.]) case $host_os in aix3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='$libname$release$shared_ext$major' ;; aix[[4-9]]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes if test ia64 = "$host_cpu"; then # AIX 5 supports IA64 library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line '#! .'. This would cause the generated library to # depend on '.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[[01]] | aix4.[[01]].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # Using Import Files as archive members, it is possible to support # filename-based versioning of shared library archives on AIX. While # this would work for both with and without runtime linking, it will # prevent static linking of such archives. So we do filename-based # shared library versioning with .so extension only, which is used # when both runtime linking and shared linking is enabled. # Unfortunately, runtime linking may impact performance, so we do # not want this to be the default eventually. Also, we use the # versioned .so libs for executables only if there is the -brtl # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only. # To allow for filename-based versioning support, we need to create # libNAME.so.V as an archive file, containing: # *) an Import File, referring to the versioned filename of the # archive as well as the shared archive member, telling the # bitwidth (32 or 64) of that shared object, and providing the # list of exported symbols of that shared object, eventually # decorated with the 'weak' keyword # *) the shared object with the F_LOADONLY flag set, to really avoid # it being seen by the linker. # At run time we better use the real file rather than another symlink, # but for link time we create the symlink libNAME.so -> libNAME.so.V case $with_aix_soname,$aix_use_runtimelinking in # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. aix,yes) # traditional libtool dynamic_linker='AIX unversionable lib.so' # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' ;; aix,no) # traditional AIX only dynamic_linker='AIX lib.a[(]lib.so.V[)]' # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='$libname$release.a $libname.a' soname_spec='$libname$release$shared_ext$major' ;; svr4,*) # full svr4 only dynamic_linker="AIX lib.so.V[(]$shared_archive_member_spec.o[)]" library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' # We do not specify a path in Import Files, so LIBPATH fires. shlibpath_overrides_runpath=yes ;; *,yes) # both, prefer svr4 dynamic_linker="AIX lib.so.V[(]$shared_archive_member_spec.o[)], lib.a[(]lib.so.V[)]" library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' # unpreferred sharedlib libNAME.a needs extra handling postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"' postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"' # We do not specify a path in Import Files, so LIBPATH fires. shlibpath_overrides_runpath=yes ;; *,no) # both, prefer aix dynamic_linker="AIX lib.a[(]lib.so.V[)], lib.so.V[(]$shared_archive_member_spec.o[)]" library_names_spec='$libname$release.a $libname.a' soname_spec='$libname$release$shared_ext$major' # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)' postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"' ;; esac shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='$libname$shared_ext' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[[45]]*) version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=.dll need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' library_names_spec='$libname.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec=$LIB if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='$libname$release$major$shared_ext $libname$shared_ext' soname_spec='$libname$release$major$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[[23]].*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[[01]]* | freebsdelf3.[[01]]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=no sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' if test 32 = "$HPUX_IA64_MODE"; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" sys_lib_dlsearch_path_spec=/usr/lib/hpux32 else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" sys_lib_dlsearch_path_spec=/usr/lib/hpux64 fi ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[[3-9]]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test yes = "$lt_cv_prog_gnu_ld"; then version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='$libname$release$shared_ext$major' library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff" sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; linux*android*) version_type=none # Android doesn't support versioned libraries. need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext' soname_spec='$libname$release$shared_ext' finish_cmds= shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes dynamic_linker='Android linker' # Don't embed -rpath directories since the linker doesn't support them. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath], [lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], [lt_cv_shlibpath_overrides_runpath=yes])]) LDFLAGS=$save_LDFLAGS libdir=$save_libdir ]) shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Ideally, we could use ldconfig to report *all* directores which are # searched for libraries, however this is still not possible. Aside from not # being certain /sbin/ldconfig is available, command # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64, # even though it is searched at run-time. Try to do the best guess by # appending ld.so.conf contents (and includes) to the search path. if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd* | bitrig*) version_type=sunos sys_lib_dlsearch_path_spec=/usr/lib need_lib_prefix=no if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then need_version=no else need_version=yes fi library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; os2*) libname_spec='$name' version_type=windows shrext_cmds=.dll need_version=no need_lib_prefix=no # OS/2 can only load a DLL with a base name of 8 characters or less. soname_spec='`test -n "$os2dllname" && libname="$os2dllname"; v=$($ECHO $release$versuffix | tr -d .-); n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _); $ECHO $n$v`$shared_ext' library_names_spec='${libname}_dll.$libext' dynamic_linker='OS/2 ld.exe' shlibpath_var=BEGINLIBPATH sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='$libname$release$shared_ext$major' library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test yes = "$with_gnu_ld"; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec; then version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext' soname_spec='$libname$shared_ext.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=sco need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test yes = "$with_gnu_ld"; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac AC_MSG_RESULT([$dynamic_linker]) test no = "$dynamic_linker" && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test yes = "$GCC"; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec fi if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec fi # remember unaugmented sys_lib_dlsearch_path content for libtool script decls... configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec # ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH" # to be used as default LT_SYS_LIBRARY_PATH value in generated libtool configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH _LT_DECL([], [variables_saved_for_relink], [1], [Variables whose values should be saved in libtool wrapper scripts and restored at link time]) _LT_DECL([], [need_lib_prefix], [0], [Do we need the "lib" prefix for modules?]) _LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) _LT_DECL([], [version_type], [0], [Library versioning type]) _LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) _LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) _LT_DECL([], [shlibpath_overrides_runpath], [0], [Is shlibpath searched before the hard-coded library search path?]) _LT_DECL([], [libname_spec], [1], [Format of library name prefix]) _LT_DECL([], [library_names_spec], [1], [[List of archive names. First name is the real one, the rest are links. The last name is the one that the linker finds with -lNAME]]) _LT_DECL([], [soname_spec], [1], [[The coded name of the library, if different from the real name]]) _LT_DECL([], [install_override_mode], [1], [Permission mode override for installation of shared libraries]) _LT_DECL([], [postinstall_cmds], [2], [Command to use after installation of a shared archive]) _LT_DECL([], [postuninstall_cmds], [2], [Command to use after uninstallation of a shared archive]) _LT_DECL([], [finish_cmds], [2], [Commands used to finish a libtool library installation in a directory]) _LT_DECL([], [finish_eval], [1], [[As "finish_cmds", except a single script fragment to be evaled but not shown]]) _LT_DECL([], [hardcode_into_libs], [0], [Whether we should hardcode library paths into libraries]) _LT_DECL([], [sys_lib_search_path_spec], [2], [Compile-time system search path for libraries]) _LT_DECL([sys_lib_dlsearch_path_spec], [configure_time_dlsearch_path], [2], [Detected run-time system search path for libraries]) _LT_DECL([], [configure_time_lt_sys_library_path], [2], [Explicit LT_SYS_LIBRARY_PATH set during ./configure time]) ])# _LT_SYS_DYNAMIC_LINKER # _LT_PATH_TOOL_PREFIX(TOOL) # -------------------------- # find a file program that can recognize shared library AC_DEFUN([_LT_PATH_TOOL_PREFIX], [m4_require([_LT_DECL_EGREP])dnl AC_MSG_CHECKING([for $1]) AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, [case $MAGIC_CMD in [[\\/*] | ?:[\\/]*]) lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD=$MAGIC_CMD lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR dnl $ac_dummy forces splitting on constant user-supplied paths. dnl POSIX.2 word splitting is done only on the output of word expansions, dnl not every word. This closes a longstanding sh security hole. ac_dummy="m4_if([$2], , $PATH, [$2])" for ac_dir in $ac_dummy; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$1"; then lt_cv_path_MAGIC_CMD=$ac_dir/"$1" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD=$lt_cv_path_MAGIC_CMD if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS=$lt_save_ifs MAGIC_CMD=$lt_save_MAGIC_CMD ;; esac]) MAGIC_CMD=$lt_cv_path_MAGIC_CMD if test -n "$MAGIC_CMD"; then AC_MSG_RESULT($MAGIC_CMD) else AC_MSG_RESULT(no) fi _LT_DECL([], [MAGIC_CMD], [0], [Used to examine libraries when file_magic_cmd begins with "file"])dnl ])# _LT_PATH_TOOL_PREFIX # Old name: AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) # _LT_PATH_MAGIC # -------------- # find a file program that can recognize a shared library m4_defun([_LT_PATH_MAGIC], [_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) else MAGIC_CMD=: fi fi ])# _LT_PATH_MAGIC # LT_PATH_LD # ---------- # find the pathname to the GNU or non-GNU linker AC_DEFUN([LT_PATH_LD], [AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_PROG_ECHO_BACKSLASH])dnl AC_ARG_WITH([gnu-ld], [AS_HELP_STRING([--with-gnu-ld], [assume the C compiler uses GNU ld @<:@default=no@:>@])], [test no = "$withval" || with_gnu_ld=yes], [with_gnu_ld=no])dnl ac_prog=ld if test yes = "$GCC"; then # Check if gcc -print-prog-name=ld gives a path. AC_MSG_CHECKING([for ld used by $CC]) case $host in *-*-mingw*) # gcc leaves a trailing carriage return, which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [[\\/]]* | ?:[[\\/]]*) re_direlt='/[[^/]][[^/]]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD=$ac_prog ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test yes = "$with_gnu_ld"; then AC_MSG_CHECKING([for GNU ld]) else AC_MSG_CHECKING([for non-GNU ld]) fi AC_CACHE_VAL(lt_cv_path_LD, [if test -z "$LD"; then lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD=$ac_dir/$ac_prog # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &1 conftest.i cat conftest.i conftest.i >conftest2.i : ${lt_DD:=$DD} AC_PATH_PROGS_FEATURE_CHECK([lt_DD], [dd], [if "$ac_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then cmp -s conftest.i conftest.out \ && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=: fi]) rm -f conftest.i conftest2.i conftest.out]) ])# _LT_PATH_DD # _LT_CMD_TRUNCATE # ---------------- # find command to truncate a binary pipe m4_defun([_LT_CMD_TRUNCATE], [m4_require([_LT_PATH_DD]) AC_CACHE_CHECK([how to truncate binary pipes], [lt_cv_truncate_bin], [printf 0123456789abcdef0123456789abcdef >conftest.i cat conftest.i conftest.i >conftest2.i lt_cv_truncate_bin= if "$ac_cv_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then cmp -s conftest.i conftest.out \ && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1" fi rm -f conftest.i conftest2.i conftest.out test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q"]) _LT_DECL([lt_truncate_bin], [lt_cv_truncate_bin], [1], [Command to truncate a binary pipe]) ])# _LT_CMD_TRUNCATE # _LT_CHECK_MAGIC_METHOD # ---------------------- # how to check for library dependencies # -- PORTME fill in with the dynamic library characteristics m4_defun([_LT_CHECK_MAGIC_METHOD], [m4_require([_LT_DECL_EGREP]) m4_require([_LT_DECL_OBJDUMP]) AC_CACHE_CHECK([how to recognize dependent libraries], lt_cv_deplibs_check_method, [lt_cv_file_magic_cmd='$MAGIC_CMD' lt_cv_file_magic_test_file= lt_cv_deplibs_check_method='unknown' # Need to set the preceding variable on all platforms that support # interlibrary dependencies. # 'none' -- dependencies not supported. # 'unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. # 'test_compile' -- check by making test program. # 'file_magic [[regex]]' -- check by looking for files in library path # that responds to the $file_magic_cmd with a given extended regex. # If you have 'file' or equivalent on your system and you're not sure # whether 'pass_all' will *always* work, you probably want this one. case $host_os in aix[[4-9]]*) lt_cv_deplibs_check_method=pass_all ;; beos*) lt_cv_deplibs_check_method=pass_all ;; bsdi[[45]]*) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)' lt_cv_file_magic_cmd='/usr/bin/file -L' lt_cv_file_magic_test_file=/shlib/libc.so ;; cygwin*) # func_win32_libid is a shell function defined in ltmain.sh lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' ;; mingw* | pw32*) # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump', # unless we find 'file', for example because we are cross-compiling. if ( file / ) >/dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc*) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; haiku*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'] lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[[3-9]]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) lt_cv_deplibs_check_method=pass_all ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd* | bitrig*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; os2*) lt_cv_deplibs_check_method=pass_all ;; esac ]) file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"` fi ;; esac fi file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown _LT_DECL([], [deplibs_check_method], [1], [Method to check whether dependent libraries are shared objects]) _LT_DECL([], [file_magic_cmd], [1], [Command to use when deplibs_check_method = "file_magic"]) _LT_DECL([], [file_magic_glob], [1], [How to find potential files when deplibs_check_method = "file_magic"]) _LT_DECL([], [want_nocaseglob], [1], [Find potential files using nocaseglob when deplibs_check_method = "file_magic"]) ])# _LT_CHECK_MAGIC_METHOD # LT_PATH_NM # ---------- # find the pathname to a BSD- or MS-compatible name lister AC_DEFUN([LT_PATH_NM], [AC_REQUIRE([AC_PROG_CC])dnl AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, [if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM=$NM else lt_nm_to_check=${ac_tool_prefix}nm if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. tmp_nm=$ac_dir/$lt_tmp_nm if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then # Check to see if the nm accepts a BSD-compat flag. # Adding the 'sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file # MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty case $build_os in mingw*) lt_bad_file=conftest.nm/nofile ;; *) lt_bad_file=/dev/null ;; esac case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in *$lt_bad_file* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break 2 ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break 2 ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS=$lt_save_ifs done : ${lt_cv_path_NM=no} fi]) if test no != "$lt_cv_path_NM"; then NM=$lt_cv_path_NM else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : # Let the user override the test. else AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :) case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols -headers" ;; *) DUMPBIN=: ;; esac fi AC_SUBST([DUMPBIN]) if test : != "$DUMPBIN"; then NM=$DUMPBIN fi fi test -z "$NM" && NM=nm AC_SUBST([NM]) _LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], [lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD) cat conftest.out >&AS_MESSAGE_LOG_FD if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest*]) ])# LT_PATH_NM # Old names: AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_PROG_NM], []) dnl AC_DEFUN([AC_PROG_NM], []) # _LT_CHECK_SHAREDLIB_FROM_LINKLIB # -------------------------------- # how to determine the name of the shared library # associated with a specific link library. # -- PORTME fill in with the dynamic library characteristics m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB], [m4_require([_LT_DECL_EGREP]) m4_require([_LT_DECL_OBJDUMP]) m4_require([_LT_DECL_DLLTOOL]) AC_CACHE_CHECK([how to associate runtime and link libraries], lt_cv_sharedlib_from_linklib_cmd, [lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh; # decide which one to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd=$ECHO ;; esac ]) sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO _LT_DECL([], [sharedlib_from_linklib_cmd], [1], [Command to associate shared and link libraries]) ])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB # _LT_PATH_MANIFEST_TOOL # ---------------------- # locate the manifest tool m4_defun([_LT_PATH_MANIFEST_TOOL], [AC_CHECK_TOOL(MANIFEST_TOOL, mt, :) test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool], [lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&AS_MESSAGE_LOG_FD if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest*]) if test yes != "$lt_cv_path_mainfest_tool"; then MANIFEST_TOOL=: fi _LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl ])# _LT_PATH_MANIFEST_TOOL # _LT_DLL_DEF_P([FILE]) # --------------------- # True iff FILE is a Windows DLL '.def' file. # Keep in sync with func_dll_def_p in the libtool script AC_DEFUN([_LT_DLL_DEF_P], [dnl test DEF = "`$SED -n dnl -e '\''s/^[[ ]]*//'\'' dnl Strip leading whitespace -e '\''/^\(;.*\)*$/d'\'' dnl Delete empty lines and comments -e '\''s/^\(EXPORTS\|LIBRARY\)\([[ ]].*\)*$/DEF/p'\'' dnl -e q dnl Only consider the first "real" line $1`" dnl ])# _LT_DLL_DEF_P # LT_LIB_M # -------- # check for math library AC_DEFUN([LT_LIB_M], [AC_REQUIRE([AC_CANONICAL_HOST])dnl LIBM= case $host in *-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) # These system don't have libm, or don't need it ;; *-ncr-sysv4.3*) AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM=-lmw) AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") ;; *) AC_CHECK_LIB(m, cos, LIBM=-lm) ;; esac AC_SUBST([LIBM]) ])# LT_LIB_M # Old name: AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_CHECK_LIBM], []) # _LT_COMPILER_NO_RTTI([TAGNAME]) # ------------------------------- m4_defun([_LT_COMPILER_NO_RTTI], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= if test yes = "$GCC"; then case $cc_basename in nvcc*) _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;; *) _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;; esac _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], lt_cv_prog_compiler_rtti_exceptions, [-fno-rtti -fno-exceptions], [], [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) fi _LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], [Compiler flag to turn off builtin functions]) ])# _LT_COMPILER_NO_RTTI # _LT_CMD_GLOBAL_SYMBOLS # ---------------------- m4_defun([_LT_CMD_GLOBAL_SYMBOLS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([LT_PATH_NM])dnl AC_REQUIRE([LT_PATH_LD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_TAG_COMPILER])dnl # Check for command to grab the raw symbol name followed by C symbol from nm. AC_MSG_CHECKING([command to parse $NM output from $compiler object]) AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], [ # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[[BCDEGRST]]' # Regexp to match symbols that can be accessed directly from C. sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[[BCDT]]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[[ABCDGISTW]]' ;; hpux*) if test ia64 = "$host_cpu"; then symcode='[[ABCDEGRST]]' fi ;; irix* | nonstopux*) symcode='[[BCDEGRST]]' ;; osf*) symcode='[[BCDEGQRST]]' ;; solaris*) symcode='[[BDRT]]' ;; sco3.2v5*) symcode='[[DT]]' ;; sysv4.2uw2*) symcode='[[DT]]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[[ABDT]]' ;; sysv4) symcode='[[DFNSTU]]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[[ABCDGIRSTW]]' ;; esac if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Gets list of data symbols to import. lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'" # Adjust the below global symbol transforms to fixup imported variables. lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'" lt_c_name_hook=" -e 's/^I .* \(.*\)$/ {\"\1\", (void *) 0},/p'" lt_c_name_lib_hook="\ -e 's/^I .* \(lib.*\)$/ {\"\1\", (void *) 0},/p'\ -e 's/^I .* \(.*\)$/ {\"lib\1\", (void *) 0},/p'" else # Disable hooks by default. lt_cv_sys_global_symbol_to_import= lt_cdecl_hook= lt_c_name_hook= lt_c_name_lib_hook= fi # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n"\ $lt_cdecl_hook\ " -e 's/^T .* \(.*\)$/extern int \1();/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n"\ $lt_c_name_hook\ " -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/p'" # Transform an extracted symbol line into symbol name with lib prefix and # symbol address. lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\ $lt_c_name_lib_hook\ " -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ " -e 's/^$symcode$symcode* .* \(lib.*\)$/ {\"\1\", (void *) \&\1},/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/ {\"lib\1\", (void *) \&\1},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function, # D for any global variable and I for any imported variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK ['"\ " {last_section=section; section=\$ 3};"\ " /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\ " /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\ " /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\ " {split(\$ 0,a,/\||\r/); split(a[2],s)};"\ " s[1]~/^[@?]/{print f,s[1],s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx]" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if AC_TRY_EVAL(ac_compile); then # Now try to grab the symbols. nlist=conftest.nm if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE /* DATA imports from DLLs on WIN32 can't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT@&t@_DLSYM_CONST #elif defined __osf__ /* This system does not cope well with relocations in const data. */ # define LT@&t@_DLSYM_CONST #else # define LT@&t@_DLSYM_CONST const #endif #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ LT@&t@_DLSYM_CONST struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[[]] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS LIBS=conftstm.$ac_objext CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" if AC_TRY_EVAL(ac_link) && test -s conftest$ac_exeext; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD fi else echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test yes = "$pipe_works"; then break else lt_cv_sys_global_symbol_pipe= fi done ]) if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then AC_MSG_RESULT(failed) else AC_MSG_RESULT(ok) fi # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then nm_file_list_spec='@' fi _LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], [Take the output of nm and produce a listing of raw symbols and C names]) _LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], [Transform the output of nm in a proper C declaration]) _LT_DECL([global_symbol_to_import], [lt_cv_sys_global_symbol_to_import], [1], [Transform the output of nm into a list of symbols to manually relocate]) _LT_DECL([global_symbol_to_c_name_address], [lt_cv_sys_global_symbol_to_c_name_address], [1], [Transform the output of nm in a C name address pair]) _LT_DECL([global_symbol_to_c_name_address_lib_prefix], [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], [Transform the output of nm in a C name address pair when lib prefix is needed]) _LT_DECL([nm_interface], [lt_cv_nm_interface], [1], [The name lister interface]) _LT_DECL([], [nm_file_list_spec], [1], [Specify filename containing input files for $NM]) ]) # _LT_CMD_GLOBAL_SYMBOLS # _LT_COMPILER_PIC([TAGNAME]) # --------------------------- m4_defun([_LT_COMPILER_PIC], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_wl, $1)= _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)= m4_if([$1], [CXX], [ # C++ specific cases for pic, static, wl, etc. if test yes = "$GXX"; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the '-m68020' flag to GCC prevents building anything better, # like '-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) case $host_os in os2*) _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static' ;; esac ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; *djgpp*) # DJGPP does not support shared libraries at all _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. _LT_TAGVAR(lt_prog_compiler_static, $1)= ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac else case $host_os in aix[[4-9]]*) # All AIX code is PIC. if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; chorus*) case $cc_basename in cxch68*) # Green Hills C++ Compiler # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" ;; esac ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; dgux*) case $cc_basename in ec++*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; ghcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; freebsd* | dragonfly*) # FreeBSD uses GNU C++ ;; hpux9* | hpux10* | hpux11*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive' if test ia64 != "$host_cpu"; then _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' fi ;; aCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive' case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac ;; *) ;; esac ;; interix*) # This is c89, which is MS Visual C++ (no shared libs) # Anyone wants to do a port? ;; irix5* | irix6* | nonstopux*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' # CC pic flag -KPIC is the default. ;; *) ;; esac ;; linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in KCC*) # KAI C++ Compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; ecpc* ) # old Intel C++ for x86_64, which still supported -KPIC. _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; icpc* ) # Intel C++, used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; pgCC* | pgcpp*) # Portland Group C++ compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; cxx*) # Compaq C++ # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL 8.0, 9.0 on PPC and BlueGene _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; esac ;; esac ;; lynxos*) ;; m88k*) ;; mvs*) case $cc_basename in cxx*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' ;; *) ;; esac ;; netbsd*) ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' ;; RCC*) # Rational C++ 2.4.1 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; cxx*) # Digital/Compaq C++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; *) ;; esac ;; psos*) ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' ;; *) ;; esac ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; lcc*) # Lucid _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; *) ;; esac ;; vxworks*) ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ], [ if test yes = "$GCC"; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the '-m68020' flag to GCC prevents building anything better, # like '-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) case $host_os in os2*) _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static' ;; esac ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. _LT_TAGVAR(lt_prog_compiler_static, $1)= ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker ' if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)" fi ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' case $cc_basename in nagfor*) # NAG Fortran compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; esac ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) case $host_os in os2*) _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static' ;; esac ;; hpux9* | hpux10* | hpux11*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC (with -KPIC) is the default. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in # old Intel for x86_64, which still supported -KPIC. ecc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; # Lahey Fortran 8.1. lf95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' ;; nagfor*) # NAG Fortran compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; tcc*) # Fabrice Bellard et al's Tiny C Compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; ccc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All Alpha code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xl* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='' ;; *Sun\ F* | *Sun*Fortran*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' ;; *Intel*\ [[CF]]*Compiler*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; *Portland\ Group*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; esac ;; esac ;; newsos6) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All OSF/1 code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; rdos*) _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; solaris*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; *) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; esac ;; sunos4*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; unicos*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; uts4*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ]) case $host_os in # For platforms that do not support PIC, -DPIC is meaningless: *djgpp*) _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" ;; esac AC_CACHE_CHECK([for $compiler option to produce PIC], [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)], [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) _LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1) # # Check to make sure the PIC flag actually works. # if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in "" | " "*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; esac], [_LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) fi _LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], [Additional compiler flags for building library objects]) _LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], [How to pass a linker flag through the compiler]) # # Check to make sure the static flag actually works. # wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" _LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), $lt_tmp_static_flag, [], [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) _LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], [Compiler flag to prevent dynamic linking]) ])# _LT_COMPILER_PIC # _LT_LINKER_SHLIBS([TAGNAME]) # ---------------------------- # See if the linker supports building shared libraries. m4_defun([_LT_LINKER_SHLIBS], [AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl m4_require([_LT_PATH_MANIFEST_TOOL])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) m4_if([$1], [CXX], [ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] case $host_os in aix[[4-9]]*) # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to GNU nm, but means don't demangle to AIX nm. # Without the "-l" option, or with the "-B" option, AIX nm treats # weak defined symbols like other global defined symbols, whereas # GNU nm marks them as "W". # While the 'weak' keyword is ignored in the Export File, we need # it in the Import File for the 'aix-soname' feature, so we have # to replace the "-B" option with "-P" for AIX nm. if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' fi ;; pw32*) _LT_TAGVAR(export_symbols_cmds, $1)=$ltdll_cmds ;; cygwin* | mingw* | cegcc*) case $cc_basename in cl*) _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] ;; esac ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' ;; esac ], [ runpath_var= _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_cmds, $1)= _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(old_archive_from_new_cmds, $1)= _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= _LT_TAGVAR(thread_safe_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list _LT_TAGVAR(include_expsyms, $1)= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ' (' and ')$', so one must not match beginning or # end of line. Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc', # as well as any symbol that contains 'd'. _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. dnl Note also adjust exclude_expsyms for C++ above. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test yes != "$GCC"; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd* | bitrig*) with_gnu_ld=no ;; esac _LT_TAGVAR(ld_shlibs, $1)=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test yes = "$with_gnu_ld"; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;; *\ \(GNU\ Binutils\)\ [[3-9]]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test yes = "$lt_use_gnu_ld_interface"; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='$wl' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi supports_anon_versioning=no case `$LD -v | $SED -e 's/([^)]\+)\s\+//' 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[[3-9]]*) # On AIX/PPC, the GNU linker is very broken if test ia64 != "$host_cpu"; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.19, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-all-symbols' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file, use it as # is; otherwise, prepend EXPORTS... _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; os2*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)=unsupported shrext_cmds=.dll _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ prefix_cmds="$SED"~ if test EXPORTS = "`$SED 1q $export_symbols`"; then prefix_cmds="$prefix_cmds -e 1d"; fi~ prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test linux-dietlibc = "$host_os"; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test no = "$tmp_diet" then tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 _LT_TAGVAR(whole_archive_flag_spec, $1)= tmp_sharedflag='--shared' ;; nagfor*) # NAGFOR 5.3 tmp_sharedflag='-Wl,-shared' ;; xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' if test yes = "$supports_anon_versioning"; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' fi case $cc_basename in tcc*) _LT_TAGVAR(export_dynamic_flag_spec, $1)='-rdynamic' ;; xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test yes = "$supports_anon_versioning"; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; sunos4*) _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac if test no = "$_LT_TAGVAR(ld_shlibs, $1)"; then runpath_var= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. _LT_TAGVAR(hardcode_minus_L, $1)=yes if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. _LT_TAGVAR(hardcode_direct, $1)=unsupported fi ;; aix[[4-9]]*) if test ia64 = "$host_cpu"; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag= else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to GNU nm, but means don't demangle to AIX nm. # Without the "-l" option, or with the "-B" option, AIX nm treats # weak defined symbols like other global defined symbols, whereas # GNU nm marks them as "W". # While the 'weak' keyword is ignored in the Export File, we need # it in the Import File for the 'aix-soname' feature, so we have # to replace the "-B" option with "-P" for AIX nm. if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # have runtime linking enabled, and use it for executables. # For shared libraries, we enable/disable runtime linking # depending on the kind of the shared library created - # when "with_aix_soname,aix_use_runtimelinking" is: # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables # "aix,yes" lib.so shared, rtl:yes, for executables # lib.a static archive # "both,no" lib.so.V(shr.o) shared, rtl:yes # lib.a(lib.so.V) shared, rtl:no, for executables # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables # lib.a(lib.so.V) shared, rtl:no # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables # lib.a static archive case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then aix_use_runtimelinking=yes break fi done if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then # With aix-soname=svr4, we create the lib.so.V shared archives only, # so we don't have lib.a shared libs to link our executables. # We have to force runtime linking in this case. aix_use_runtimelinking=yes LDFLAGS="$LDFLAGS -Wl,-brtl" fi ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='$wl-f,' case $with_aix_soname,$aix_use_runtimelinking in aix,*) ;; # traditional, no import file svr4,* | *,yes) # use import file # The Import File defines what to hardcode. _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no ;; esac if test yes = "$GCC"; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`$CC -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi ;; esac shared_flag='-shared' if test yes = "$aix_use_runtimelinking"; then shared_flag="$shared_flag "'$wl-G' fi # Need to ensure runtime linking is disabled for the traditional # shared library, or the linker may eventually find shared libraries # /with/ Import File - we do not want to mix them. shared_flag_aix='-shared' shared_flag_svr4='-shared $wl-G' else # not using gcc if test ia64 = "$host_cpu"; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test yes = "$aix_use_runtimelinking"; then shared_flag='$wl-G' else shared_flag='$wl-bM:SRE' fi shared_flag_aix='$wl-bM:SRE' shared_flag_svr4='$wl-G' fi fi _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. _LT_TAGVAR(always_export_symbols, $1)=yes if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag else if test ia64 = "$host_cpu"; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' $wl-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-berok' if test yes = "$with_gnu_ld"; then # We only use this code for GNU lds that support --whole-archive. _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _LT_TAGVAR(archive_cmds_need_lc, $1)=yes _LT_TAGVAR(archive_expsym_cmds, $1)='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d' # -brtl affects multiple linker settings, -berok does not and is overridden later compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([[, ]]\\)%-berok\\1%g"`' if test svr4 != "$with_aix_soname"; then # This is similar to how AIX traditionally builds its shared libraries. _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname' fi if test aix != "$with_aix_soname"; then _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp' else # used by -dlpreopen to get the symbols _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$MV $output_objdir/$realname.d/$soname $output_objdir' fi _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$RM -r $output_objdir/$realname.d' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; bsdi[[45]]*) _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. case $cc_basename in cl*) # Native MSVC _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then cp "$export_symbols" "$output_objdir/$soname.def"; echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; else $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile=$lt_outputfile.exe lt_tool_outputfile=$lt_tool_outputfile.exe ;; esac~ if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC wrapper _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' # FIXME: Should let the user specify the lib program. _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ;; esac ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; dgux*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2.*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; hpux9*) if test yes = "$GCC"; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' else _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' ;; hpux10*) if test yes,no = "$GCC,$with_gnu_ld"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test no = "$with_gnu_ld"; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes fi ;; hpux11*) if test yes,no = "$GCC,$with_gnu_ld"; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) m4_if($1, [], [ # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) _LT_LINKER_OPTION([if $CC understands -b], _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b], [_LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'], [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])], [_LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags']) ;; esac fi if test no = "$with_gnu_ld"; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test yes = "$GCC"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol], [lt_cv_irix_exported_symbol], [save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null" AC_LINK_IFELSE( [AC_LANG_SOURCE( [AC_LANG_CASE([C], [[int foo (void) { return 0; }]], [C++], [[int foo (void) { return 0; }]], [Fortran 77], [[ subroutine foo end]], [Fortran], [[ subroutine foo end]])])], [lt_cv_irix_exported_symbol=yes], [lt_cv_irix_exported_symbol=no]) LDFLAGS=$save_LDFLAGS]) if test yes = "$lt_cv_irix_exported_symbol"; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib' fi else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes _LT_TAGVAR(link_all_deplibs, $1)=yes ;; linux*) case $cc_basename in tcc*) # Fabrice Bellard et al's Tiny C Compiler _LT_TAGVAR(ld_shlibs, $1)=yes _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; newsos6) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *nto* | *qnx*) ;; openbsd* | bitrig*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' fi else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; os2*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)=unsupported shrext_cmds=.dll _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ prefix_cmds="$SED"~ if test EXPORTS = "`$SED 1q $export_symbols`"; then prefix_cmds="$prefix_cmds -e 1d"; fi~ prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ;; osf3*) if test yes = "$GCC"; then _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test yes = "$GCC"; then _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; solaris*) _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' if test yes = "$GCC"; then wlarc='$wl' _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' _LT_TAGVAR(archive_cmds, $1)='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='$wl' _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands '-z linker_flag'. GCC discards it without '$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test yes = "$GCC"; then _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' else _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' fi ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes ;; sunos4*) if test sequent = "$host_vendor"; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4) case $host_vendor in sni) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' _LT_TAGVAR(hardcode_direct, $1)=no ;; motorola) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4.3*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes _LT_TAGVAR(ld_shlibs, $1)=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' if test yes = "$GCC"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We CANNOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='$wl-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Bexport' runpath_var='LD_RUN_PATH' if test yes = "$GCC"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(ld_shlibs, $1)=no ;; esac if test sni = "$host_vendor"; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Blargedynsym' ;; esac fi fi ]) AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test no = "$_LT_TAGVAR(ld_shlibs, $1)" && can_build_shared=no _LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld _LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl _LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl _LT_DECL([], [extract_expsyms_cmds], [2], [The commands to extract the exported symbol list from a shared archive]) # # Do we need to explicitly link libc? # case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in x|xyes) # Assume -lc should be added _LT_TAGVAR(archive_cmds_need_lc, $1)=yes if test yes,yes = "$GCC,$enable_shared"; then case $_LT_TAGVAR(archive_cmds, $1) in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. AC_CACHE_CHECK([whether -lc should be explicitly linked in], [lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1), [$RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if AC_TRY_EVAL(ac_compile) 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) _LT_TAGVAR(allow_undefined_flag, $1)= if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) then lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no else lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes fi _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* ]) _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1) ;; esac fi ;; esac _LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], [Whether or not to add -lc for building shared libraries]) _LT_TAGDECL([allow_libtool_libs_with_static_runtimes], [enable_shared_with_static_runtimes], [0], [Whether or not to disallow shared libs when runtime libs are static]) _LT_TAGDECL([], [export_dynamic_flag_spec], [1], [Compiler flag to allow reflexive dlopens]) _LT_TAGDECL([], [whole_archive_flag_spec], [1], [Compiler flag to generate shared objects directly from archives]) _LT_TAGDECL([], [compiler_needs_object], [1], [Whether the compiler copes with passing no objects directly]) _LT_TAGDECL([], [old_archive_from_new_cmds], [2], [Create an old-style archive from a shared archive]) _LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], [Create a temporary old-style archive to link instead of a shared archive]) _LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) _LT_TAGDECL([], [archive_expsym_cmds], [2]) _LT_TAGDECL([], [module_cmds], [2], [Commands used to build a loadable module if different from building a shared archive.]) _LT_TAGDECL([], [module_expsym_cmds], [2]) _LT_TAGDECL([], [with_gnu_ld], [1], [Whether we are building with GNU ld or not]) _LT_TAGDECL([], [allow_undefined_flag], [1], [Flag that allows shared libraries with undefined symbols to be built]) _LT_TAGDECL([], [no_undefined_flag], [1], [Flag that enforces no undefined symbols]) _LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], [Flag to hardcode $libdir into a binary during linking. This must work even if $libdir does not exist]) _LT_TAGDECL([], [hardcode_libdir_separator], [1], [Whether we need a single "-rpath" flag with a separated argument]) _LT_TAGDECL([], [hardcode_direct], [0], [Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_direct_absolute], [0], [Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes DIR into the resulting binary and the resulting library dependency is "absolute", i.e impossible to change by setting $shlibpath_var if the library is relocated]) _LT_TAGDECL([], [hardcode_minus_L], [0], [Set to "yes" if using the -LDIR flag during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_shlibpath_var], [0], [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_automatic], [0], [Set to "yes" if building a shared library automatically hardcodes DIR into the library and all subsequent libraries and executables linked against it]) _LT_TAGDECL([], [inherit_rpath], [0], [Set to yes if linker adds runtime paths of dependent libraries to runtime path list]) _LT_TAGDECL([], [link_all_deplibs], [0], [Whether libtool must link a program against all its dependency libraries]) _LT_TAGDECL([], [always_export_symbols], [0], [Set to "yes" if exported symbols are required]) _LT_TAGDECL([], [export_symbols_cmds], [2], [The commands to list exported symbols]) _LT_TAGDECL([], [exclude_expsyms], [1], [Symbols that should not be listed in the preloaded symbols]) _LT_TAGDECL([], [include_expsyms], [1], [Symbols that must always be exported]) _LT_TAGDECL([], [prelink_cmds], [2], [Commands necessary for linking programs (against libraries) with templates]) _LT_TAGDECL([], [postlink_cmds], [2], [Commands necessary for finishing linking programs]) _LT_TAGDECL([], [file_list_spec], [1], [Specify filename containing input files]) dnl FIXME: Not yet implemented dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], dnl [Compiler flag to generate thread safe objects]) ])# _LT_LINKER_SHLIBS # _LT_LANG_C_CONFIG([TAG]) # ------------------------ # Ensure that the configuration variables for a C compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to 'libtool'. m4_defun([_LT_LANG_C_CONFIG], [m4_require([_LT_DECL_EGREP])dnl lt_save_CC=$CC AC_LANG_PUSH(C) # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' _LT_TAG_COMPILER # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) LT_SYS_DLOPEN_SELF _LT_CMD_STRIPLIB # Report what library types will actually be built AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test no = "$can_build_shared" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test yes = "$enable_shared" && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test ia64 != "$host_cpu"; then case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in yes,aix,yes) ;; # shared object as lib.so file only yes,svr4,*) ;; # shared object as lib.so archive member only yes,*) enable_static=no ;; # shared object in lib.a archive as well esac fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test yes = "$enable_shared" || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_CONFIG($1) fi AC_LANG_POP CC=$lt_save_CC ])# _LT_LANG_C_CONFIG # _LT_LANG_CXX_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a C++ compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to 'libtool'. m4_defun([_LT_LANG_CXX_CONFIG], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_PATH_MANIFEST_TOOL])dnl if test -n "$CXX" && ( test no != "$CXX" && ( (test g++ = "$CXX" && `g++ -v >/dev/null 2>&1` ) || (test g++ != "$CXX"))); then AC_PROG_CXXCPP else _lt_caught_CXX_error=yes fi AC_LANG_PUSH(C++) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for C++ test sources. ac_ext=cpp # Object file extension for compiled C++ test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the CXX compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test yes != "$_lt_caught_CXX_error"; then # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_LD=$LD lt_save_GCC=$GCC GCC=$GXX lt_save_with_gnu_ld=$with_gnu_ld lt_save_path_LD=$lt_cv_path_LD if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx else $as_unset lt_cv_prog_gnu_ld fi if test -n "${lt_cv_path_LDCXX+set}"; then lt_cv_path_LD=$lt_cv_path_LDCXX else $as_unset lt_cv_path_LD fi test -z "${LDCXX+set}" || LD=$LDCXX CC=${CXX-"c++"} CFLAGS=$CXXFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then # We don't want -fno-exception when compiling C++ code, so set the # no_builtin_flag separately if test yes = "$GXX"; then _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' else _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= fi if test yes = "$GXX"; then # Set up default GNU C++ configuration LT_PATH_LD # Check if GNU C++ uses GNU ld as the underlying linker, since the # archiving commands below assume that GNU ld is being used. if test yes = "$with_gnu_ld"; then _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' # If archive_cmds runs LD, not CC, wlarc should be empty # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to # investigate it a little bit more. (MM) wlarc='$wl' # ancient GNU ld didn't support --whole-archive et. al. if eval "`$CC -print-prog-name=ld` --help 2>&1" | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else with_gnu_ld=no wlarc= # A generic and very simple default shared library creation # command for GNU C++ for the case where it uses the native # linker, instead of GNU ld. If possible, this setting should # overridden to take advantage of the native linker features on # the platform it is being used on. _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' fi # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else GXX=no with_gnu_ld=no wlarc= fi # PORTME: fill in a description of your system's C++ link characteristics AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) _LT_TAGVAR(ld_shlibs, $1)=yes case $host_os in aix3*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aix[[4-9]]*) if test ia64 = "$host_cpu"; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag= else aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # have runtime linking enabled, and use it for executables. # For shared libraries, we enable/disable runtime linking # depending on the kind of the shared library created - # when "with_aix_soname,aix_use_runtimelinking" is: # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables # "aix,yes" lib.so shared, rtl:yes, for executables # lib.a static archive # "both,no" lib.so.V(shr.o) shared, rtl:yes # lib.a(lib.so.V) shared, rtl:no, for executables # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables # lib.a(lib.so.V) shared, rtl:no # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables # lib.a static archive case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do case $ld_flag in *-brtl*) aix_use_runtimelinking=yes break ;; esac done if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then # With aix-soname=svr4, we create the lib.so.V shared archives only, # so we don't have lib.a shared libs to link our executables. # We have to force runtime linking in this case. aix_use_runtimelinking=yes LDFLAGS="$LDFLAGS -Wl,-brtl" fi ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='$wl-f,' case $with_aix_soname,$aix_use_runtimelinking in aix,*) ;; # no import file svr4,* | *,yes) # use import file # The Import File defines what to hardcode. _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no ;; esac if test yes = "$GXX"; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`$CC -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi esac shared_flag='-shared' if test yes = "$aix_use_runtimelinking"; then shared_flag=$shared_flag' $wl-G' fi # Need to ensure runtime linking is disabled for the traditional # shared library, or the linker may eventually find shared libraries # /with/ Import File - we do not want to mix them. shared_flag_aix='-shared' shared_flag_svr4='-shared $wl-G' else # not using gcc if test ia64 = "$host_cpu"; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test yes = "$aix_use_runtimelinking"; then shared_flag='$wl-G' else shared_flag='$wl-bM:SRE' fi shared_flag_aix='$wl-bM:SRE' shared_flag_svr4='$wl-G' fi fi _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to # export. _LT_TAGVAR(always_export_symbols, $1)=yes if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. # The "-G" linker flag allows undefined symbols. _LT_TAGVAR(no_undefined_flag, $1)='-bernotok' # Determine the default libpath from the value encoded in an empty # executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag else if test ia64 = "$host_cpu"; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' $wl-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-berok' if test yes = "$with_gnu_ld"; then # We only use this code for GNU lds that support --whole-archive. _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _LT_TAGVAR(archive_cmds_need_lc, $1)=yes _LT_TAGVAR(archive_expsym_cmds, $1)='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d' # -brtl affects multiple linker settings, -berok does not and is overridden later compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([[, ]]\\)%-berok\\1%g"`' if test svr4 != "$with_aix_soname"; then # This is similar to how AIX traditionally builds its shared # libraries. Need -bnortl late, we may have -brtl in LDFLAGS. _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname' fi if test aix != "$with_aix_soname"; then _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp' else # used by -dlpreopen to get the symbols _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$MV $output_objdir/$realname.d/$soname $output_objdir' fi _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$RM -r $output_objdir/$realname.d' fi fi ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; chorus*) case $cc_basename in *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; cygwin* | mingw* | pw32* | cegcc*) case $GXX,$cc_basename in ,cl* | no,cl*) # Native MSVC # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then cp "$export_symbols" "$output_objdir/$soname.def"; echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; else $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile=$lt_outputfile.exe lt_tool_outputfile=$lt_tool_outputfile.exe ;; esac~ func_to_tool_file "$lt_outputfile"~ if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # g++ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-all-symbols' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file, use it as # is; otherwise, prepend EXPORTS... _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; os2*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)=unsupported shrext_cmds=.dll _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ prefix_cmds="$SED"~ if test EXPORTS = "`$SED 1q $export_symbols`"; then prefix_cmds="$prefix_cmds -e 1d"; fi~ prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ;; dgux*) case $cc_basename in ec++*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; ghcx*) # Green Hills C++ Compiler # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; freebsd2.*) # C++ shared libraries reported to be fairly broken before # switch to ELF _LT_TAGVAR(ld_shlibs, $1)=no ;; freebsd-elf*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; freebsd* | dragonfly*) # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF # conventions _LT_TAGVAR(ld_shlibs, $1)=yes ;; haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; hpux9*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test yes = "$GXX"; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; hpux10*|hpux11*) if test no = "$with_gnu_ld"; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) ;; *) _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' ;; esac fi case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. ;; esac case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test yes = "$GXX"; then if test no = "$with_gnu_ld"; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac fi else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; irix5* | irix6*) case $cc_basename in CC*) # SGI C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' # Archives containing C++ object files must be created using # "CC -ar", where "CC" is the IRIX C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' ;; *) if test yes = "$GXX"; then if test no = "$with_gnu_ld"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` -o $lib' fi fi _LT_TAGVAR(link_all_deplibs, $1)=yes ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes ;; linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib $wl-retain-symbols-file,$export_symbols; mv \$templib $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' # Archives containing C++ object files must be created using # "CC -Bstatic", where "CC" is the KAI C++ compiler. _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; icpc* | ecpc* ) # Intel C++ with_gnu_ld=yes # version 8.0 and above of icpc choke on multiply defined symbols # if we add $predep_objects and $postdep_objects, however 7.1 and # earlier do not add the objects themselves. case `$CC -V 2>&1` in *"Version 7."*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 8.0 or newer tmp_idyn= case $host_cpu in ia64*) tmp_idyn=' -i_dynamic';; esac _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' ;; esac _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive' ;; pgCC* | pgcpp*) # Portland Group C++ compiler case `$CC -V` in *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*) _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ $RANLIB $oldlib' _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 6 and above use weak symbols _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl--rpath $wl$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' ;; cxx*) # Compaq C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib $wl-retain-symbols-file $wl$export_symbols' runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' ;; xl* | mpixl* | bgxl*) # IBM XL 8.0 on PPC, with GNU ld _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' if test yes = "$supports_anon_versioning"; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' fi ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file $wl$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes # Not sure whether something based on # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 # would be better. output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; esac ;; esac ;; lynxos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; m88k*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; mvs*) case $cc_basename in cxx*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' wlarc= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no fi # Workaround some broken pre-1.5 toolchains output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' ;; *nto* | *qnx*) _LT_TAGVAR(ld_shlibs, $1)=yes ;; openbsd* | bitrig*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`"; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file,$export_symbols -o $lib' _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' fi output_verbose_link_cmd=func_echo_all else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Archives containing C++ object files must be created using # the KAI C++ compiler. case $host in osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; esac ;; RCC*) # Rational C++ 2.4.1 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; cxx*) case $host in osf3*) _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $soname `test -n "$verstring" && func_echo_all "$wl-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' ;; *) _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ echo "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname $wl-input $wl$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~ $RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' ;; esac _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test yes,no = "$GXX,$with_gnu_ld"; then _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' case $host in osf3*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; psos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; lcc*) # Lucid # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(archive_cmds_need_lc,$1)=yes _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G$allow_undefined_flag $wl-M $wl$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands '-z linker_flag'. # Supported since Solaris 2.6 (maybe 2.5.1?) _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' # The C++ compiler must be used to create the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' ;; *) # GNU C++ compiler with Solaris linker if test yes,no = "$GXX,$with_gnu_ld"; then _LT_TAGVAR(no_undefined_flag, $1)=' $wl-z ${wl}defs' if $CC --version | $GREP -v '^2\.7' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else # g++ 2.7 appears to require '-G' NOT '-shared' on this # platform. _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $wl$libdir' case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' ;; esac fi ;; esac ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We CANNOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='$wl-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Bexport' runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~ '"$_LT_TAGVAR(old_archive_cmds, $1)" _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~ '"$_LT_TAGVAR(reload_cmds, $1)" ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; vxworks*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test no = "$_LT_TAGVAR(ld_shlibs, $1)" && can_build_shared=no _LT_TAGVAR(GCC, $1)=$GXX _LT_TAGVAR(LD, $1)=$LD ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS LDCXX=$LD LD=$lt_save_LD GCC=$lt_save_GCC with_gnu_ld=$lt_save_with_gnu_ld lt_cv_path_LDCXX=$lt_cv_path_LD lt_cv_path_LD=$lt_save_path_LD lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld fi # test yes != "$_lt_caught_CXX_error" AC_LANG_POP ])# _LT_LANG_CXX_CONFIG # _LT_FUNC_STRIPNAME_CNF # ---------------------- # func_stripname_cnf prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). # # This function is identical to the (non-XSI) version of func_stripname, # except this one can be used by m4 code that may be executed by configure, # rather than the libtool script. m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl AC_REQUIRE([_LT_DECL_SED]) AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH]) func_stripname_cnf () { case @S|@2 in .*) func_stripname_result=`$ECHO "@S|@3" | $SED "s%^@S|@1%%; s%\\\\@S|@2\$%%"`;; *) func_stripname_result=`$ECHO "@S|@3" | $SED "s%^@S|@1%%; s%@S|@2\$%%"`;; esac } # func_stripname_cnf ])# _LT_FUNC_STRIPNAME_CNF # _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) # --------------------------------- # Figure out "hidden" library dependencies from verbose # compiler output when linking a shared library. # Parse the compiler output and extract the necessary # objects, libraries and library flags. m4_defun([_LT_SYS_HIDDEN_LIBDEPS], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl # Dependencies to place before and after the object being linked: _LT_TAGVAR(predep_objects, $1)= _LT_TAGVAR(postdep_objects, $1)= _LT_TAGVAR(predeps, $1)= _LT_TAGVAR(postdeps, $1)= _LT_TAGVAR(compiler_lib_search_path, $1)= dnl we can't use the lt_simple_compile_test_code here, dnl because it contains code intended for an executable, dnl not a library. It's possible we should let each dnl tag define a new lt_????_link_test_code variable, dnl but it's only used here... m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF int a; void foo (void) { a = 0; } _LT_EOF ], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF class Foo { public: Foo (void) { a = 0; } private: int a; }; _LT_EOF ], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer*4 a a=0 return end _LT_EOF ], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer a a=0 return end _LT_EOF ], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF public class foo { private int a; public void bar (void) { a = 0; } }; _LT_EOF ], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF package foo func foo() { } _LT_EOF ]) _lt_libdeps_save_CFLAGS=$CFLAGS case "$CC $CFLAGS " in #( *\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; *\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; *\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; esac dnl Parse the compiler output and extract the necessary dnl objects, libraries and library flags. if AC_TRY_EVAL(ac_compile); then # Parse the compiler output and extract the necessary # objects, libraries and library flags. # Sentinel used to keep track of whether or not we are before # the conftest object file. pre_test_object_deps_done=no for p in `eval "$output_verbose_link_cmd"`; do case $prev$p in -L* | -R* | -l*) # Some compilers place space between "-{L,R}" and the path. # Remove the space. if test x-L = "$p" || test x-R = "$p"; then prev=$p continue fi # Expand the sysroot to ease extracting the directories later. if test -z "$prev"; then case $p in -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; esac fi case $p in =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; esac if test no = "$pre_test_object_deps_done"; then case $prev in -L | -R) # Internal compiler library paths should come after those # provided the user. The postdeps already come after the # user supplied libs so there is no need to process them. if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then _LT_TAGVAR(compiler_lib_search_path, $1)=$prev$p else _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} $prev$p" fi ;; # The "-l" case would never come before the object being # linked, so don't bother handling this case. esac else if test -z "$_LT_TAGVAR(postdeps, $1)"; then _LT_TAGVAR(postdeps, $1)=$prev$p else _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} $prev$p" fi fi prev= ;; *.lto.$objext) ;; # Ignore GCC LTO objects *.$objext) # This assumes that the test object file only shows up # once in the compiler output. if test "$p" = "conftest.$objext"; then pre_test_object_deps_done=yes continue fi if test no = "$pre_test_object_deps_done"; then if test -z "$_LT_TAGVAR(predep_objects, $1)"; then _LT_TAGVAR(predep_objects, $1)=$p else _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" fi else if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then _LT_TAGVAR(postdep_objects, $1)=$p else _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" fi fi ;; *) ;; # Ignore the rest. esac done # Clean up. rm -f a.out a.exe else echo "libtool.m4: error: problem compiling $1 test program" fi $RM -f confest.$objext CFLAGS=$_lt_libdeps_save_CFLAGS # PORTME: override above test on systems where it is broken m4_if([$1], [CXX], [case $host_os in interix[[3-9]]*) # Interix 3.5 installs completely hosed .la files for C++, so rather than # hack all around it, let's just trust "g++" to DTRT. _LT_TAGVAR(predep_objects,$1)= _LT_TAGVAR(postdep_objects,$1)= _LT_TAGVAR(postdeps,$1)= ;; esac ]) case " $_LT_TAGVAR(postdeps, $1) " in *" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; esac _LT_TAGVAR(compiler_lib_search_dirs, $1)= if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | $SED -e 's! -L! !g' -e 's!^ !!'` fi _LT_TAGDECL([], [compiler_lib_search_dirs], [1], [The directories searched by this compiler when creating a shared library]) _LT_TAGDECL([], [predep_objects], [1], [Dependencies to place before and after the objects being linked to create a shared library]) _LT_TAGDECL([], [postdep_objects], [1]) _LT_TAGDECL([], [predeps], [1]) _LT_TAGDECL([], [postdeps], [1]) _LT_TAGDECL([], [compiler_lib_search_path], [1], [The library search path used internally by the compiler when linking a shared library]) ])# _LT_SYS_HIDDEN_LIBDEPS # _LT_LANG_F77_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a Fortran 77 compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to 'libtool'. m4_defun([_LT_LANG_F77_CONFIG], [AC_LANG_PUSH(Fortran 77) if test -z "$F77" || test no = "$F77"; then _lt_disable_F77=yes fi _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for f77 test sources. ac_ext=f # Object file extension for compiled f77 test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the F77 compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test yes != "$_lt_disable_F77"; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_GCC=$GCC lt_save_CFLAGS=$CFLAGS CC=${F77-"f77"} CFLAGS=$FFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) GCC=$G77 if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test no = "$can_build_shared" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test yes = "$enable_shared" && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test ia64 != "$host_cpu"; then case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in yes,aix,yes) ;; # shared object as lib.so file only yes,svr4,*) ;; # shared object as lib.so archive member only yes,*) enable_static=no ;; # shared object in lib.a archive as well esac fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test yes = "$enable_shared" || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)=$G77 _LT_TAGVAR(LD, $1)=$LD ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS fi # test yes != "$_lt_disable_F77" AC_LANG_POP ])# _LT_LANG_F77_CONFIG # _LT_LANG_FC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for a Fortran compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to 'libtool'. m4_defun([_LT_LANG_FC_CONFIG], [AC_LANG_PUSH(Fortran) if test -z "$FC" || test no = "$FC"; then _lt_disable_FC=yes fi _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for fc test sources. ac_ext=${ac_fc_srcext-f} # Object file extension for compiled fc test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the FC compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test yes != "$_lt_disable_FC"; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_GCC=$GCC lt_save_CFLAGS=$CFLAGS CC=${FC-"f95"} CFLAGS=$FCFLAGS compiler=$CC GCC=$ac_cv_fc_compiler_gnu _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test no = "$can_build_shared" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test yes = "$enable_shared" && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test ia64 != "$host_cpu"; then case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in yes,aix,yes) ;; # shared object as lib.so file only yes,svr4,*) ;; # shared object as lib.so archive member only yes,*) enable_static=no ;; # shared object in lib.a archive as well esac fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test yes = "$enable_shared" || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)=$ac_cv_fc_compiler_gnu _LT_TAGVAR(LD, $1)=$LD ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS fi # test yes != "$_lt_disable_FC" AC_LANG_POP ])# _LT_LANG_FC_CONFIG # _LT_LANG_GCJ_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for the GNU Java Compiler compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to 'libtool'. m4_defun([_LT_LANG_GCJ_CONFIG], [AC_REQUIRE([LT_PROG_GCJ])dnl AC_LANG_SAVE # Source file extension for Java test sources. ac_ext=java # Object file extension for compiled Java test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="class foo {}" # Code to be used in simple link tests lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC=yes CC=${GCJ-"gcj"} CFLAGS=$GCJFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_TAGVAR(LD, $1)=$LD _LT_CC_BASENAME([$compiler]) # GCJ did not exist at the time GCC didn't implicitly link libc in. _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi AC_LANG_RESTORE GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_GCJ_CONFIG # _LT_LANG_GO_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for the GNU Go compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to 'libtool'. m4_defun([_LT_LANG_GO_CONFIG], [AC_REQUIRE([LT_PROG_GO])dnl AC_LANG_SAVE # Source file extension for Go test sources. ac_ext=go # Object file extension for compiled Go test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="package main; func main() { }" # Code to be used in simple link tests lt_simple_link_test_code='package main; func main() { }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC=yes CC=${GOC-"gccgo"} CFLAGS=$GOFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_TAGVAR(LD, $1)=$LD _LT_CC_BASENAME([$compiler]) # Go did not exist at the time GCC didn't implicitly link libc in. _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi AC_LANG_RESTORE GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_GO_CONFIG # _LT_LANG_RC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for the Windows resource compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to 'libtool'. m4_defun([_LT_LANG_RC_CONFIG], [AC_REQUIRE([LT_PROG_RC])dnl AC_LANG_SAVE # Source file extension for RC test sources. ac_ext=rc # Object file extension for compiled RC test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' # Code to be used in simple link tests lt_simple_link_test_code=$lt_simple_compile_test_code # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC= CC=${RC-"windres"} CFLAGS= compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes if test -n "$compiler"; then : _LT_CONFIG($1) fi GCC=$lt_save_GCC AC_LANG_RESTORE CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_RC_CONFIG # LT_PROG_GCJ # ----------- AC_DEFUN([LT_PROG_GCJ], [m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], [AC_CHECK_TOOL(GCJ, gcj,) test set = "${GCJFLAGS+set}" || GCJFLAGS="-g -O2" AC_SUBST(GCJFLAGS)])])[]dnl ]) # Old name: AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_GCJ], []) # LT_PROG_GO # ---------- AC_DEFUN([LT_PROG_GO], [AC_CHECK_TOOL(GOC, gccgo,) ]) # LT_PROG_RC # ---------- AC_DEFUN([LT_PROG_RC], [AC_CHECK_TOOL(RC, windres,) ]) # Old name: AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_RC], []) # _LT_DECL_EGREP # -------------- # If we don't have a new enough Autoconf to choose the best grep # available, choose the one first in the user's PATH. m4_defun([_LT_DECL_EGREP], [AC_REQUIRE([AC_PROG_EGREP])dnl AC_REQUIRE([AC_PROG_FGREP])dnl test -z "$GREP" && GREP=grep _LT_DECL([], [GREP], [1], [A grep program that handles long lines]) _LT_DECL([], [EGREP], [1], [An ERE matcher]) _LT_DECL([], [FGREP], [1], [A literal string matcher]) dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too AC_SUBST([GREP]) ]) # _LT_DECL_OBJDUMP # -------------- # If we don't have a new enough Autoconf to choose the best objdump # available, choose the one first in the user's PATH. m4_defun([_LT_DECL_OBJDUMP], [AC_CHECK_TOOL(OBJDUMP, objdump, false) test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) AC_SUBST([OBJDUMP]) ]) # _LT_DECL_DLLTOOL # ---------------- # Ensure DLLTOOL variable is set. m4_defun([_LT_DECL_DLLTOOL], [AC_CHECK_TOOL(DLLTOOL, dlltool, false) test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [1], [DLL creation program]) AC_SUBST([DLLTOOL]) ]) # _LT_DECL_SED # ------------ # Check for a fully-functional sed program, that truncates # as few characters as possible. Prefer GNU sed if found. m4_defun([_LT_DECL_SED], [AC_PROG_SED test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" _LT_DECL([], [SED], [1], [A sed program that does not truncate output]) _LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], [Sed that helps us avoid accidentally triggering echo(1) options like -n]) ])# _LT_DECL_SED m4_ifndef([AC_PROG_SED], [ ############################################################ # NOTE: This macro has been submitted for inclusion into # # GNU Autoconf as AC_PROG_SED. When it is available in # # a released version of Autoconf we should remove this # # macro and use it instead. # ############################################################ m4_defun([AC_PROG_SED], [AC_MSG_CHECKING([for a sed that does not truncate output]) AC_CACHE_VAL(lt_cv_path_SED, [# Loop through the user's path and test for sed and gsed. # Then use that list of sed's as ones to test for truncation. as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for lt_ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" fi done done done IFS=$as_save_IFS lt_ac_max=0 lt_ac_count=0 # Add /usr/xpg4/bin/sed as it is typically found on Solaris # along with /bin/sed that truncates output. for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do test ! -f "$lt_ac_sed" && continue cat /dev/null > conftest.in lt_ac_count=0 echo $ECHO_N "0123456789$ECHO_C" >conftest.in # Check for GNU sed and select it if it is found. if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then lt_cv_path_SED=$lt_ac_sed break fi while true; do cat conftest.in conftest.in >conftest.tmp mv conftest.tmp conftest.in cp conftest.in conftest.nl echo >>conftest.nl $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break cmp -s conftest.out conftest.nl || break # 10000 chars as input seems more than enough test 10 -lt "$lt_ac_count" && break lt_ac_count=`expr $lt_ac_count + 1` if test "$lt_ac_count" -gt "$lt_ac_max"; then lt_ac_max=$lt_ac_count lt_cv_path_SED=$lt_ac_sed fi done done ]) SED=$lt_cv_path_SED AC_SUBST([SED]) AC_MSG_RESULT([$SED]) ])#AC_PROG_SED ])#m4_ifndef # Old name: AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_SED], []) # _LT_CHECK_SHELL_FEATURES # ------------------------ # Find out whether the shell is Bourne or XSI compatible, # or has some other useful features. m4_defun([_LT_CHECK_SHELL_FEATURES], [if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi _LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac _LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl _LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl ])# _LT_CHECK_SHELL_FEATURES # _LT_PATH_CONVERSION_FUNCTIONS # ----------------------------- # Determine what file name conversion functions should be used by # func_to_host_file (and, implicitly, by func_to_host_path). These are needed # for certain cross-compile configurations and native mingw. m4_defun([_LT_PATH_CONVERSION_FUNCTIONS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_MSG_CHECKING([how to convert $build file names to $host format]) AC_CACHE_VAL(lt_cv_to_host_file_cmd, [case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac ]) to_host_file_cmd=$lt_cv_to_host_file_cmd AC_MSG_RESULT([$lt_cv_to_host_file_cmd]) _LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd], [0], [convert $build file names to $host format])dnl AC_MSG_CHECKING([how to convert $build file names to toolchain format]) AC_CACHE_VAL(lt_cv_to_tool_file_cmd, [#assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac ]) to_tool_file_cmd=$lt_cv_to_tool_file_cmd AC_MSG_RESULT([$lt_cv_to_tool_file_cmd]) _LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd], [0], [convert $build files to toolchain format])dnl ])# _LT_PATH_CONVERSION_FUNCTIONS freetds-1.00.82/m4/ltoptions.m4100644 025423 025423 00000034262 13242511040 0011642# Helper functions for option handling. -*- Autoconf -*- # # Copyright (C) 2004-2005, 2007-2009, 2011-2015 Free Software # Foundation, Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 8 ltoptions.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) # _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) # ------------------------------------------ m4_define([_LT_MANGLE_OPTION], [[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) # _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) # --------------------------------------- # Set option OPTION-NAME for macro MACRO-NAME, and if there is a # matching handler defined, dispatch to it. Other OPTION-NAMEs are # saved as a flag. m4_define([_LT_SET_OPTION], [m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), _LT_MANGLE_DEFUN([$1], [$2]), [m4_warning([Unknown $1 option '$2'])])[]dnl ]) # _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) # ------------------------------------------------------------ # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. m4_define([_LT_IF_OPTION], [m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) # _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) # ------------------------------------------------------- # Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME # are set. m4_define([_LT_UNLESS_OPTIONS], [m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), [m4_define([$0_found])])])[]dnl m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 ])[]dnl ]) # _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) # ---------------------------------------- # OPTION-LIST is a space-separated list of Libtool options associated # with MACRO-NAME. If any OPTION has a matching handler declared with # LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about # the unknown option and exit. m4_defun([_LT_SET_OPTIONS], [# Set options m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [_LT_SET_OPTION([$1], _LT_Option)]) m4_if([$1],[LT_INIT],[ dnl dnl Simply set some default values (i.e off) if boolean options were not dnl specified: _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no ]) _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no ]) dnl dnl If no reference was made to various pairs of opposing options, then dnl we run the default mode handler for the pair. For example, if neither dnl 'shared' nor 'disable-shared' was passed, we enable building of shared dnl archives by default: _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], [_LT_ENABLE_FAST_INSTALL]) _LT_UNLESS_OPTIONS([LT_INIT], [aix-soname=aix aix-soname=both aix-soname=svr4], [_LT_WITH_AIX_SONAME([aix])]) ]) ])# _LT_SET_OPTIONS ## --------------------------------- ## ## Macros to handle LT_INIT options. ## ## --------------------------------- ## # _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) # ----------------------------------------- m4_define([_LT_MANGLE_DEFUN], [[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) # LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) # ----------------------------------------------- m4_define([LT_OPTION_DEFINE], [m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl ])# LT_OPTION_DEFINE # dlopen # ------ LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes ]) AU_DEFUN([AC_LIBTOOL_DLOPEN], [_LT_SET_OPTION([LT_INIT], [dlopen]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the 'dlopen' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) # win32-dll # --------- # Declare package support for building win32 dll's. LT_OPTION_DEFINE([LT_INIT], [win32-dll], [enable_win32_dll=yes case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) AC_CHECK_TOOL(AS, as, false) AC_CHECK_TOOL(DLLTOOL, dlltool, false) AC_CHECK_TOOL(OBJDUMP, objdump, false) ;; esac test -z "$AS" && AS=as _LT_DECL([], [AS], [1], [Assembler program])dnl test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl ])# win32-dll AU_DEFUN([AC_LIBTOOL_WIN32_DLL], [AC_REQUIRE([AC_CANONICAL_HOST])dnl _LT_SET_OPTION([LT_INIT], [win32-dll]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the 'win32-dll' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) # _LT_ENABLE_SHARED([DEFAULT]) # ---------------------------- # implement the --enable-shared flag, and supports the 'shared' and # 'disable-shared' LT_INIT options. # DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'. m4_define([_LT_ENABLE_SHARED], [m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([shared], [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS=$lt_save_ifs ;; esac], [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) _LT_DECL([build_libtool_libs], [enable_shared], [0], [Whether or not to build shared libraries]) ])# _LT_ENABLE_SHARED LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) # Old names: AC_DEFUN([AC_ENABLE_SHARED], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) ]) AC_DEFUN([AC_DISABLE_SHARED], [_LT_SET_OPTION([LT_INIT], [disable-shared]) ]) AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_SHARED], []) dnl AC_DEFUN([AM_DISABLE_SHARED], []) # _LT_ENABLE_STATIC([DEFAULT]) # ---------------------------- # implement the --enable-static flag, and support the 'static' and # 'disable-static' LT_INIT options. # DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'. m4_define([_LT_ENABLE_STATIC], [m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([static], [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS=$lt_save_ifs ;; esac], [enable_static=]_LT_ENABLE_STATIC_DEFAULT) _LT_DECL([build_old_libs], [enable_static], [0], [Whether or not to build static libraries]) ])# _LT_ENABLE_STATIC LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) # Old names: AC_DEFUN([AC_ENABLE_STATIC], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) ]) AC_DEFUN([AC_DISABLE_STATIC], [_LT_SET_OPTION([LT_INIT], [disable-static]) ]) AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_STATIC], []) dnl AC_DEFUN([AM_DISABLE_STATIC], []) # _LT_ENABLE_FAST_INSTALL([DEFAULT]) # ---------------------------------- # implement the --enable-fast-install flag, and support the 'fast-install' # and 'disable-fast-install' LT_INIT options. # DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'. m4_define([_LT_ENABLE_FAST_INSTALL], [m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([fast-install], [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS=$lt_save_ifs ;; esac], [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) _LT_DECL([fast_install], [enable_fast_install], [0], [Whether or not to optimize for fast installation])dnl ])# _LT_ENABLE_FAST_INSTALL LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) # Old names: AU_DEFUN([AC_ENABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the 'fast-install' option into LT_INIT's first parameter.]) ]) AU_DEFUN([AC_DISABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], [disable-fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the 'disable-fast-install' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) # _LT_WITH_AIX_SONAME([DEFAULT]) # ---------------------------------- # implement the --with-aix-soname flag, and support the `aix-soname=aix' # and `aix-soname=both' and `aix-soname=svr4' LT_INIT options. DEFAULT # is either `aix', `both' or `svr4'. If omitted, it defaults to `aix'. m4_define([_LT_WITH_AIX_SONAME], [m4_define([_LT_WITH_AIX_SONAME_DEFAULT], [m4_if($1, svr4, svr4, m4_if($1, both, both, aix))])dnl shared_archive_member_spec= case $host,$enable_shared in power*-*-aix[[5-9]]*,yes) AC_MSG_CHECKING([which variant of shared library versioning to provide]) AC_ARG_WITH([aix-soname], [AS_HELP_STRING([--with-aix-soname=aix|svr4|both], [shared library versioning (aka "SONAME") variant to provide on AIX, @<:@default=]_LT_WITH_AIX_SONAME_DEFAULT[@:>@.])], [case $withval in aix|svr4|both) ;; *) AC_MSG_ERROR([Unknown argument to --with-aix-soname]) ;; esac lt_cv_with_aix_soname=$with_aix_soname], [AC_CACHE_VAL([lt_cv_with_aix_soname], [lt_cv_with_aix_soname=]_LT_WITH_AIX_SONAME_DEFAULT) with_aix_soname=$lt_cv_with_aix_soname]) AC_MSG_RESULT([$with_aix_soname]) if test aix != "$with_aix_soname"; then # For the AIX way of multilib, we name the shared archive member # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o', # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File. # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag, # the AIX toolchain works better with OBJECT_MODE set (default 32). if test 64 = "${OBJECT_MODE-32}"; then shared_archive_member_spec=shr_64 else shared_archive_member_spec=shr fi fi ;; *) with_aix_soname=aix ;; esac _LT_DECL([], [shared_archive_member_spec], [0], [Shared archive member basename, for filename based shared library versioning on AIX])dnl ])# _LT_WITH_AIX_SONAME LT_OPTION_DEFINE([LT_INIT], [aix-soname=aix], [_LT_WITH_AIX_SONAME([aix])]) LT_OPTION_DEFINE([LT_INIT], [aix-soname=both], [_LT_WITH_AIX_SONAME([both])]) LT_OPTION_DEFINE([LT_INIT], [aix-soname=svr4], [_LT_WITH_AIX_SONAME([svr4])]) # _LT_WITH_PIC([MODE]) # -------------------- # implement the --with-pic flag, and support the 'pic-only' and 'no-pic' # LT_INIT options. # MODE is either 'yes' or 'no'. If omitted, it defaults to 'both'. m4_define([_LT_WITH_PIC], [AC_ARG_WITH([pic], [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@], [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], [lt_p=${PACKAGE-default} case $withval in yes|no) pic_mode=$withval ;; *) pic_mode=default # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for lt_pkg in $withval; do IFS=$lt_save_ifs if test "X$lt_pkg" = "X$lt_p"; then pic_mode=yes fi done IFS=$lt_save_ifs ;; esac], [pic_mode=m4_default([$1], [default])]) _LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl ])# _LT_WITH_PIC LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) # Old name: AU_DEFUN([AC_LIBTOOL_PICMODE], [_LT_SET_OPTION([LT_INIT], [pic-only]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the 'pic-only' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) ## ----------------- ## ## LTDL_INIT Options ## ## ----------------- ## m4_define([_LTDL_MODE], []) LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], [m4_define([_LTDL_MODE], [nonrecursive])]) LT_OPTION_DEFINE([LTDL_INIT], [recursive], [m4_define([_LTDL_MODE], [recursive])]) LT_OPTION_DEFINE([LTDL_INIT], [subproject], [m4_define([_LTDL_MODE], [subproject])]) m4_define([_LTDL_TYPE], []) LT_OPTION_DEFINE([LTDL_INIT], [installable], [m4_define([_LTDL_TYPE], [installable])]) LT_OPTION_DEFINE([LTDL_INIT], [convenience], [m4_define([_LTDL_TYPE], [convenience])]) freetds-1.00.82/m4/ltsugar.m4100644 025423 025423 00000010440 13242511040 0011260# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- # # Copyright (C) 2004-2005, 2007-2008, 2011-2015 Free Software # Foundation, Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 6 ltsugar.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) # lt_join(SEP, ARG1, [ARG2...]) # ----------------------------- # Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their # associated separator. # Needed until we can rely on m4_join from Autoconf 2.62, since all earlier # versions in m4sugar had bugs. m4_define([lt_join], [m4_if([$#], [1], [], [$#], [2], [[$2]], [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) m4_define([_lt_join], [m4_if([$#$2], [2], [], [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) # lt_car(LIST) # lt_cdr(LIST) # ------------ # Manipulate m4 lists. # These macros are necessary as long as will still need to support # Autoconf-2.59, which quotes differently. m4_define([lt_car], [[$1]]) m4_define([lt_cdr], [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], [$#], 1, [], [m4_dquote(m4_shift($@))])]) m4_define([lt_unquote], $1) # lt_append(MACRO-NAME, STRING, [SEPARATOR]) # ------------------------------------------ # Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'. # Note that neither SEPARATOR nor STRING are expanded; they are appended # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). # No SEPARATOR is output if MACRO-NAME was previously undefined (different # than defined and empty). # # This macro is needed until we can rely on Autoconf 2.62, since earlier # versions of m4sugar mistakenly expanded SEPARATOR but not STRING. m4_define([lt_append], [m4_define([$1], m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) # lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) # ---------------------------------------------------------- # Produce a SEP delimited list of all paired combinations of elements of # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list # has the form PREFIXmINFIXSUFFIXn. # Needed until we can rely on m4_combine added in Autoconf 2.62. m4_define([lt_combine], [m4_if(m4_eval([$# > 3]), [1], [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl [[m4_foreach([_Lt_prefix], [$2], [m4_foreach([_Lt_suffix], ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) # ----------------------------------------------------------------------- # Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited # by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. m4_define([lt_if_append_uniq], [m4_ifdef([$1], [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], [lt_append([$1], [$2], [$3])$4], [$5])], [lt_append([$1], [$2], [$3])$4])]) # lt_dict_add(DICT, KEY, VALUE) # ----------------------------- m4_define([lt_dict_add], [m4_define([$1($2)], [$3])]) # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) # -------------------------------------------- m4_define([lt_dict_add_subkey], [m4_define([$1($2:$3)], [$4])]) # lt_dict_fetch(DICT, KEY, [SUBKEY]) # ---------------------------------- m4_define([lt_dict_fetch], [m4_ifval([$3], m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) # lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) # ----------------------------------------------------------------- m4_define([lt_if_dict_fetch], [m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], [$5], [$6])]) # lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) # -------------------------------------------------------------- m4_define([lt_dict_filter], [m4_if([$5], [], [], [lt_join(m4_quote(m4_default([$4], [[, ]])), lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl ]) freetds-1.00.82/m4/ltversion.m4100644 025423 025423 00000001273 13242511040 0011630# ltversion.m4 -- version numbers -*- Autoconf -*- # # Copyright (C) 2004, 2011-2015 Free Software Foundation, Inc. # Written by Scott James Remnant, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # @configure_input@ # serial 4179 ltversion.m4 # This file is part of GNU Libtool m4_define([LT_PACKAGE_VERSION], [2.4.6]) m4_define([LT_PACKAGE_REVISION], [2.4.6]) AC_DEFUN([LTVERSION_VERSION], [macro_version='2.4.6' macro_revision='2.4.6' _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) _LT_DECL(, macro_revision, 0) ]) freetds-1.00.82/m4/lt~obsolete.m4100644 025423 025423 00000013774 13242511040 0012166# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- # # Copyright (C) 2004-2005, 2007, 2009, 2011-2015 Free Software # Foundation, Inc. # Written by Scott James Remnant, 2004. # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 5 lt~obsolete.m4 # These exist entirely to fool aclocal when bootstrapping libtool. # # In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN), # which have later been changed to m4_define as they aren't part of the # exported API, or moved to Autoconf or Automake where they belong. # # The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN # in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us # using a macro with the same name in our local m4/libtool.m4 it'll # pull the old libtool.m4 in (it doesn't see our shiny new m4_define # and doesn't know about Autoconf macros at all.) # # So we provide this file, which has a silly filename so it's always # included after everything else. This provides aclocal with the # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything # because those macros already exist, or will be overwritten later. # We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. # # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. # Yes, that means every name once taken will need to remain here until # we give up compatibility with versions before 1.7, at which point # we need to keep only those names which we still refer to. # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])]) m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])]) m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])]) m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])]) m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])]) m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])]) m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])]) freetds-1.00.82/m4/pushlibs.m4100644 025423 025423 00000000276 12717145107 0011453AC_DEFUN([ACX_PUSH_LIBS], [m4_pushdef([SAVELIBS],[LIBS_]__line__)dnl SAVELIBS="$LIBS" LIBS=[$1]]) AC_DEFUN([ACX_POP_LIBS], [LIBS="$SAVELIBS" unset SAVELIBS dnl m4_popdef([SAVELIBS])dnl ]) freetds-1.00.82/m4/sprintf_i64_format.m4100644 025423 025423 00000003442 12522201763 0013332dnl $Id: sprintf_i64_format.m4,v 1.11 2010-12-28 14:37:10 freddy77 Exp $ ## # Test for 64bit integer sprintf format specifier # ld 64 bit machine # lld long long format # I64d Windows format # Ld Watcom compiler format ## AC_DEFUN([SPRINTF_I64_FORMAT], [tds_i64_format= # Win32 case AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ #if !defined(__MINGW32__) || !defined(__MSVCRT__) this should produce an error! #endif ],[return 0;])],[tds_i64_format="I64"]) # long is 64 bit if test "x$ac_cv_sizeof_long" = "x8"; then tds_i64_format=l fi # long long support if test "x$tds_i64_format" = "x"; then AC_LINK_IFELSE([AC_LANG_SOURCE([[ #include #if !defined(__GLIBC__) || __GLIBC__ < 2 || !defined(__GLIBC_MINOR__) || __GLIBC_MINOR__ < 2 # if !defined(__APPLE__) # error no proper glibc or darwin system # endif #endif int main() { char buf[64]; long long ll = atoll(buf); return 0; } ]])],[tds_i64_format="ll"]) fi # extract from inttypes.h if test "x$tds_i64_format" = "x"; then AC_COMPILE_IFELSE([AC_LANG_PROGRAM( [[#include #include char test_fmt[] = "Start PRId64:" PRId64 ":End PRId64"; ]], [[]])], [for arg in l ll I64 L; do if grep "Start PRId64:${arg}d:End PRId64" conftest.$ac_objext >/dev/null ; then tds_i64_format=$arg fi done]) fi if test "x$tds_i64_format" = "x"; then for arg in l ll I64 L; do AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include int main() { char buf[20]; $tds_sysdep_int64_type ll = ((($tds_sysdep_int64_type) 0x12345) << 32) + 0x6789abcd; sprintf(buf, "%${arg}d", ll); return strcmp(buf, "320255973501901") != 0; } ]])],[tds_i64_format="$arg"; break]) done fi if test "x$tds_i64_format" != "x"; then AC_DEFINE_UNQUOTED(TDS_I64_PREFIX, ["$tds_i64_format"], [define to prefix format string used for 64bit integers]) fi ]) freetds-1.00.82/m4/type_socklen_t.m4100644 025423 025423 00000002772 12522201763 0012642dnl $Id: type_socklen_t.m4,v 1.3 2006-03-29 16:24:37 freddy77 Exp $ ## # This macro came from internet, appear in lftp, rsync and others. ## AC_DEFUN([TYPE_SOCKLEN_T], [ AC_CHECK_TYPE([socklen_t], ,[ AC_MSG_CHECKING([for socklen_t equivalent]) AC_CACHE_VAL([xml_cv_socklen_t_equiv], [ # Systems have either "struct sockaddr *" or # "void *" as the second argument to getpeername xml_cv_socklen_t_equiv= for arg2 in "struct sockaddr" void; do for t in int size_t unsigned long "unsigned long"; do AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_WINSOCK2_H # include # include int PASCAL getpeername (SOCKET, $arg2 *, $t *); #elif defined(HAVE_SYS_SOCKET_H) # include int getpeername (int, $arg2 *, $t *); #endif ],[ $t len; getpeername(0,0,&len); ])],[ xml_cv_socklen_t_equiv="$t" break ]) done done if test "x$xml_cv_socklen_t_equiv" = x; then AC_MSG_ERROR([Cannot find a type to use in place of socklen_t]) fi ]) AC_MSG_RESULT($xml_cv_socklen_t_equiv) AC_DEFINE_UNQUOTED(socklen_t, $xml_cv_socklen_t_equiv, [type to use in place of socklen_t if not defined])], [#include #ifdef HAVE_SYS_SOCKET_H # include #endif #ifdef HAVE_WINSOCK2_H # include # include #endif]) ]) freetds-1.00.82/Makefile.am100644 025423 025423 00000003757 12717145107 0011103# version $Id: Makefile.am,v 1.50 2012-01-16 00:27:04 jklowden Exp $ ## SUBDIRS determines in which directories automake will generate a Makefile ## See also AC_OUTPUT in configure.ac SUBDIRS = include src doc samples win32 vms misc ACLOCAL_AMFLAGS = -I m4 EXTRA_DIST = interfaces PWD.in BUGS \ freetds.conf locales.conf \ autogen.sh freetds.spec.in freetds.spec tds.dox \ config.rpath CMakeLists.txt Thanks-1.0 ETC = $(DESTDIR)$(sysconfdir) DOCDIR = doc install-data-local: $(mkinstalldirs) $(ETC) if test ! -f $(ETC)/freetds.conf; then \ $(INSTALL) $(srcdir)/freetds.conf $(ETC)/freetds.conf; \ fi if test ! -f $(ETC)/locales.conf; then \ $(INSTALL) $(srcdir)/locales.conf $(ETC)/locales.conf; \ fi clean-local: find . \( -name \*.test_output -o -name \*.bb -o -name \*.bbg -o -name \*.da -o -name \*.gc\* \) -exec rm -f {} \; # enable some cheat so make distcheck work (see below) DISTCHECK_CONFIGURE_FLAGS = \ --enable-distcheck-build --enable-extra-checks # do not uninstall configuration files (they may have been changed) if DISTCHECK_BUILD uninstall-local: rm -f $(ETC)/freetds.conf $(ETC)/locales.conf $(ETC)/pool.conf PWD endif test: @echo "The 'make test' option has been replaced with 'make check'"; all: if DISTCHECK_BUILD # if we are inside a make distcheck copy our real password file if test ! -f PWD -a -f $(srcdir)/../PWD; then cp $(srcdir)/../PWD PWD; fi endif # this prevent the store of passwords in the source repository if test ! -f PWD; then cp $(srcdir)/PWD.in PWD; fi snapshot: $(MAKE) dist distdir=$(PACKAGE)-`date +"%Y%m%d"` ## The doxygen configuration file understands environment variables. doxy: $(SUBDIRS) if HAVE_DOXYGEN $(MKDIR_P) $(DOCDIR)/reference rm -rf $(DOCDIR)/reference/* SRCDIR=$(top_srcdir) VERSION=$(VERSION) $(DOXYGEN) $(top_srcdir)/tds.dox if test -d $(DOCDIR)/reference/html ; then mv $(DOCDIR)/reference/html/* $(DOCDIR)/reference; rmdir $(DOCDIR)/reference/html; fi else echo 'Doxygen not installed; reference manual not built.' endif freetds-1.00.82/configure100755 025423 025423 00002503115 13242511107 0010740#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for FreeTDS 1.00.82. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 as_fn_exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test \$(( 1 + 1 )) = 2 || exit 1 test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\ || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" SHELL=${CONFIG_SHELL-/bin/sh} test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='FreeTDS' PACKAGE_TARNAME='freetds' PACKAGE_VERSION='1.00.82' PACKAGE_STRING='FreeTDS 1.00.82' PACKAGE_BUGREPORT='' PACKAGE_URL='' ac_unique_file="src/dblib/dblib.c" ac_default_prefix=/usr/local # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS DISTCHECK_BUILD_FALSE DISTCHECK_BUILD_TRUE ODBC_WIDE_TESTS_FALSE ODBC_WIDE_TESTS_TRUE ENABLE_DEVELOPING_FALSE ENABLE_DEVELOPING_TRUE GCRYPT_LIBS GCRYPT_CFLAGS ENABLE_THREADSAFE_FALSE ENABLE_THREADSAFE_TRUE SYBASE_COMPAT_FALSE SYBASE_COMPAT_TRUE dblib_define INCPOOL_FALSE INCPOOL_TRUE INCSERVER_FALSE INCSERVER_TRUE INCAPPS_FALSE INCAPPS_TRUE HAVE_OPENSSL OPENSSL_LIBS OPENSSL_CFLAGS NETTLE_LIBS NETTLE_CFLAGS GNUTLS_LIBS GNUTLS_CFLAGS ODBCNODMLIBAPP ODBCNODMLIB ODBCINSTLIB ODBCLIB ODBC_INC ODBC UNIXODBC_FALSE UNIXODBC_TRUE ODBC_FALSE ODBC_TRUE FREETDS_ODBC_MODULE INCODBC_FALSE INCODBC_TRUE ALLOCA LIBOBJS FREETDS_LIBGCC FREETDS_SYMBOLIC tds_sysdep_intptr_type tds_sysdep_int64_type tds_sysdep_real64_type tds_sysdep_real32_type tds_sysdep_int32_type tds_sysdep_int16_type HAVE_SSPI_FALSE HAVE_SSPI_TRUE AM_CFLAGS PTHREAD_CFLAGS PTHREAD_LIBS PTHREAD_CC acx_pthread_config READLINE_LIBS NETWORK_LIBS MINGW32_FALSE MINGW32_TRUE HAVE_PERL_SOURCES HAVE_PERL_SOURCES_FALSE HAVE_PERL_SOURCES_TRUE ODBC_CONFIG HAVE_DOXYGEN_FALSE HAVE_DOXYGEN_TRUE DOXYGEN LTLIBICONV LIBICONV RC LIBADD_DL LT_DLPREOPEN LIBADD_DLD_LINK LIBADD_SHL_LOAD LIBADD_DLOPEN LT_DLLOADERS LT_SYS_LIBRARY_PATH OTOOL64 OTOOL LIPO NMEDIT DSYMUTIL MANIFEST_TOOL RANLIB ac_ct_AR AR NM ac_ct_DUMPBIN DUMPBIN LD FGREP LIBTOOL OBJDUMP DLLTOOL AS EGREP CPP am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE am__nodep AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE am__quote am__include DEPDIR OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC MACOSX_FALSE MACOSX_TRUE host_os host_vendor host_cpu host build_os build_vendor build_cpu build PKG_CONFIG_LIBDIR PKG_CONFIG_PATH PKG_CONFIG SED LN_S GREP BUILD_NUMBER SUBVERSION MINOR MAJOR AM_BACKSLASH AM_DEFAULT_VERBOSITY AM_DEFAULT_V AM_V am__untar am__tar AMTAR am__leading_dot SET_MAKE AWK mkdir_p MKDIR_P INSTALL_STRIP_PROGRAM STRIP install_sh MAKEINFO AUTOHEADER AUTOMAKE AUTOCONF ACLOCAL VERSION PACKAGE CYGPATH_W am__isrc INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking enable_silent_rules enable_dependency_tracking enable_largefile enable_shared enable_static with_pic enable_fast_install with_aix_soname with_gnu_ld with_sysroot enable_libtool_lock enable_libiconv enable_rpath with_libiconv_prefix enable_krb5 enable_sspi with_tdsver with_iodbc with_unixodbc with_odbc_nodm enable_odbc with_gnutls with_openssl enable_apps enable_server enable_pool enable_msdblib enable_sybase_compat enable_threadsafe enable_debug enable_extra_checks enable_developing enable_mars enable_odbc_wide enable_odbc_wide_tests enable_distcheck_build ' ac_precious_vars='build_alias host_alias target_alias PKG_CONFIG PKG_CONFIG_PATH PKG_CONFIG_LIBDIR CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP LT_SYS_LIBRARY_PATH GNUTLS_CFLAGS GNUTLS_LIBS NETTLE_CFLAGS NETTLE_LIBS OPENSSL_CFLAGS OPENSSL_LIBS GCRYPT_CFLAGS GCRYPT_LIBS' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures FreeTDS 1.00.82 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/freetds] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of FreeTDS 1.00.82:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-silent-rules less verbose build output (undo: "make V=1") --disable-silent-rules verbose build output (undo: "make V=0") --enable-dependency-tracking do not reject slow dependency extractors --disable-dependency-tracking speeds up one-time build --disable-largefile omit support for large files --enable-shared[=PKGS] build shared libraries [default=yes] --enable-static[=PKGS] build static libraries [default=yes] --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) --disable-libiconv do not attempt to include libiconv --disable-rpath do not hardcode runtime library paths --enable-krb5[=LIB] enable Kerberos support, optionally with library --disable-sspi disable SSPI support --disable-odbc do not attempt to build odbc the driver --disable-apps skip build of src/apps (including tsql) --disable-server skip build of src/server directory --disable-pool skip build of src/pool directory --enable-msdblib for MS style dblib --enable-sybase-compat enable increased Open Client binary compatibility --disable-threadsafe disable calls to threadsafe fuctions e.g.,gethostbyname_r --disable-debug disable assert and other things --enable-extra-checks enable extra checks on code --enable-developing enable code still in develop --enable-mars enable MARS code (EXPERIMENTAL) --disable-odbc-wide disable wide string support in odbc --enable-odbc-wide-tests enable compiling ODBC tests to use wide functions --enable-distcheck-build used internally for testing Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use both] --with-aix-soname=aix|svr4|both shared library versioning (aka "SONAME") variant to provide on AIX, [default=aix]. --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-gnu-ld assume the C compiler uses GNU ld [default=no] --with-libiconv-prefix[=DIR] search for libiconv in DIR/include and DIR/lib --without-libiconv-prefix don't search for libiconv in includedir and libdir --with-tdsver=VERSION TDS protocol version (4.2/4.6/5.0/7.0/7.1/7.2/7.3/7.4/auto) [auto] --with-iodbc=DIR build odbc driver against iODBC in DIR --with-unixodbc=DIR build odbc driver against unixODBC in DIR --with-odbc-nodm=DIR build odbc using headers in DIR/include --with-gnutls build with GnuTLS support --with-openssl --with-openssl=DIR build with OpenSSL (license NOT compatible cf. User Guide) Some influential environment variables: PKG_CONFIG path to pkg-config utility PKG_CONFIG_PATH directories to add to pkg-config's search path PKG_CONFIG_LIBDIR path overriding pkg-config's built-in search path CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor LT_SYS_LIBRARY_PATH User-defined run-time library search path. GNUTLS_CFLAGS C compiler flags for GNUTLS, overriding pkg-config GNUTLS_LIBS linker flags for GNUTLS, overriding pkg-config NETTLE_CFLAGS C compiler flags for NETTLE, overriding pkg-config NETTLE_LIBS linker flags for NETTLE, overriding pkg-config OPENSSL_CFLAGS C compiler flags for OPENSSL, overriding pkg-config OPENSSL_LIBS linker flags for OPENSSL, overriding pkg-config GCRYPT_CFLAGS C compiler flags for GCRYPT, overriding pkg-config GCRYPT_LIBS linker flags for GCRYPT, overriding pkg-config Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to the package provider. _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF FreeTDS configure 1.00.82 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || test -x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* 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 $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func # ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES # --------------------------------------------- # Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR # accordingly. ac_fn_c_check_decl () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack as_decl_name=`echo $2|sed 's/ *(.*//'` as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 $as_echo_n "checking whether $as_decl_name is declared... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { #ifndef $as_decl_name #ifdef __cplusplus (void) $as_decl_use; #else (void) $as_decl_name; #endif #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_decl # ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES # ---------------------------------------------------- # Tries to find if the field MEMBER exists in type AGGR, after including # INCLUDES, setting cache variable VAR accordingly. ac_fn_c_check_member () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5 $as_echo_n "checking for $2.$3... " >&6; } if eval \${$4+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $5 int main () { static $2 ac_aggr; if (ac_aggr.$3) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$4=yes" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $5 int main () { static $2 ac_aggr; if (sizeof ac_aggr.$3) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$4=yes" else eval "$4=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$4 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_member # ac_fn_c_compute_int LINENO EXPR VAR INCLUDES # -------------------------------------------- # Tries to find the compile-time value of EXPR in a program that includes # INCLUDES, setting VAR accordingly. Returns whether the value could be # computed ac_fn_c_compute_int () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) >= 0)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_lo=0 ac_mid=0 while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_hi=$ac_mid; break else as_fn_arith $ac_mid + 1 && ac_lo=$as_val if test $ac_lo -le $ac_mid; then ac_lo= ac_hi= break fi as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) < 0)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_hi=-1 ac_mid=-1 while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) >= $ac_mid)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_lo=$ac_mid; break else as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val if test $ac_mid -le $ac_hi; then ac_lo= ac_hi= break fi as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else ac_lo= ac_hi= fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # Binary search between lo and hi bounds. while test "x$ac_lo" != "x$ac_hi"; do as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; test_array [0] = 0; return test_array [0]; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_hi=$ac_mid else as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done case $ac_lo in #(( ?*) eval "$3=\$ac_lo"; ac_retval=0 ;; '') ac_retval=1 ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 static long int longval () { return $2; } static unsigned long int ulongval () { return $2; } #include #include int main () { FILE *f = fopen ("conftest.val", "w"); if (! f) return 1; if (($2) < 0) { long int i = longval (); if (i != ($2)) return 1; fprintf (f, "%ld", i); } else { unsigned long int i = ulongval (); if (i != ($2)) return 1; fprintf (f, "%lu", i); } /* Do not output a trailing newline, as this causes \r\n confusion on some platforms. */ return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : echo >>conftest.val; read $3 &5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof ($2)) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof (($2))) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else eval "$3=yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_type cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by FreeTDS $as_me 1.00.82, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu am__api_version='1.15' ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;; esac # Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". as_fn_error $? "ls -t appears to fail. Make sure there is not a broken alias in your environment" "$LINENO" 5 fi if test "$2" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done test "$2" = conftest.file ) then # Ok. : else as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi rm -f conftest.file test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` # Expand $ac_aux_dir to an absolute path. am_aux_dir=`cd "$ac_aux_dir" && pwd` if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5 $as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;} fi if test x"${install_sh+set}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi # Installed binaries are usually stripped using 'strip' when the user # run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the 'STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; 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_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else 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_prog_STRIP="${ac_tool_prefix}strip" $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 fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; 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_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else 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_prog_ac_ct_STRIP="strip" $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 fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then if ${ac_cv_path_mkdir+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ 'mkdir (fileutils) '4.1*) ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext break 3;; esac done done done IFS=$as_save_IFS fi test -d ./--version && rmdir ./--version if test "${ac_cv_path_mkdir+set}" = set; then MKDIR_P="$ac_cv_path_mkdir -p" else # As a last resort, use the slow shell script. Don't cache a # value for MKDIR_P within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. MKDIR_P="$ac_install_sh -d" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 $as_echo "$MKDIR_P" >&6; } for ac_prog in gawk mawk nawk awk 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_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else 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_prog_AWK="$ac_prog" $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 fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null # Check whether --enable-silent-rules was given. if test "${enable_silent_rules+set}" = set; then : enableval=$enable_silent_rules; fi case $enable_silent_rules in # ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=1;; esac am_make=${MAKE-make} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 $as_echo_n "checking whether $am_make supports nested variables... " >&6; } if ${am_cv_make_support_nested_variables+:} false; then : $as_echo_n "(cached) " >&6 else if $as_echo 'TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 $as_echo "$am_cv_make_support_nested_variables" >&6; } if test $am_cv_make_support_nested_variables = yes; then AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AM_BACKSLASH='\' if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE='freetds' VERSION='1.00.82' cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # mkdir_p='$(MKDIR_P)' # We need awk for the "check" target (and possibly the TAP driver). The # system "awk" is bad on some platforms. # Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AMTAR='$${TAR-tar}' # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar pax cpio none' am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 fi fi # Check whether --enable-silent-rules was given. if test "${enable_silent_rules+set}" = set; then : enableval=$enable_silent_rules; fi case $enable_silent_rules in # ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=0;; esac am_make=${MAKE-make} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 $as_echo_n "checking whether $am_make supports nested variables... " >&6; } if ${am_cv_make_support_nested_variables+:} false; then : $as_echo_n "(cached) " >&6 else if $as_echo 'TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 $as_echo "$am_cv_make_support_nested_variables" >&6; } if test $am_cv_make_support_nested_variables = yes; then AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AM_BACKSLASH='\' ac_config_headers="$ac_config_headers include/config.h" ASAN_OPTIONS='detect_leaks=0' export ASAN_OPTIONS ver=`echo $VERSION.0 | sed 's,^dev\.,,; s,^\([0-9][0-9]*\.[0-9][0-9]*\)rc,\1.dev.,g; s/\.dev\./.9999./'` match='^\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*' if test "`echo $ver | sed \"s,$match,,\"`" != ""; then as_fn_error $? "Invalid version $VERSION specified" "$LINENO" 5 fi MAJOR=`echo $ver | sed "s,$match,\1,"` MINOR=`echo $ver | sed "s,$match,\2,"` SUBVERSION=`echo $ver | sed "s,$match,\3,"` BUILD_NUMBER="`date +1%j` - 1000 + ( `date +%Y` - 2000 )" BUILD_NUMBER="`expr $BUILD_NUMBER \* 366`" if test "$SUBVERSION" = "9999"; then MINOR=`expr $MINOR - 1` fi # ------------------------------------------------------------ # Commands and Utilities # ------------------------------------------------------------ for ac_prog in gawk mawk nawk awk 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_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else 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_prog_AWK="$ac_prog" $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 fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 $as_echo_n "checking whether ln -s works... " >&6; } LN_S=$as_ln_s if test "$LN_S" = "ln -s"; 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, using $LN_S" >&5 $as_echo "no, using $LN_S" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } if ${ac_cv_path_SED+:} false; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for ac_i in 1 2 3 4 5 6 7; do ac_script="$ac_script$as_nl$ac_script" done echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed { ac_script=; unset ac_script;} if test -z "$SED"; then ac_path_SED_found=false # Loop through the user's path and test for each of PROGNAME-LIST 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_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_SED" || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in *GNU*) ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo '' >> "conftest.nl" "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_SED_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_SED="$ac_path_SED" ac_path_SED_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_SED_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_SED"; then as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 fi else ac_cv_path_SED=$SED fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 $as_echo "$ac_cv_path_SED" >&6; } SED="$ac_cv_path_SED" rm -f conftest.sed if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. set dummy ${ac_tool_prefix}pkg-config; 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_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_PKG_CONFIG="$PKG_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_PKG_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 PKG_CONFIG=$ac_cv_path_PKG_CONFIG if test -n "$PKG_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 $as_echo "$PKG_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_PKG_CONFIG"; then ac_pt_PKG_CONFIG=$PKG_CONFIG # Extract the first word of "pkg-config", so it can be a program name with args. set dummy pkg-config; 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_ac_pt_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_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_ac_pt_PKG_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 ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG if test -n "$ac_pt_PKG_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 $as_echo "$ac_pt_PKG_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_PKG_CONFIG" = x; then PKG_CONFIG="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac PKG_CONFIG=$ac_pt_PKG_CONFIG fi else PKG_CONFIG="$ac_cv_path_PKG_CONFIG" fi fi if test -n "$PKG_CONFIG"; then _pkg_min_version=0.9.0 { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 $as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; 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; } PKG_CONFIG="" fi fi # ------------------------------------------------------------ # Host-specific configuration # ------------------------------------------------------------ # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } if ${ac_cv_build+:} false; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } if ${ac_cv_host+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac netdb_reentrant=no case $host in *-*-osf*) CPPFLAGS="$CPPFLAGS -D_OSF_SOURCE -D_XOPEN_SOURCE_EXTENDED -D_POSIX_C_SOURCE=199506L" netdb_reentrant=yes ;; *-*-hpux11*) netdb_reentrant=yes ;; *-*-cygwin*) netdb_reentrant=yes ;; esac case $host_os in darwin* | rhapsody*) if true; then MACOSX_TRUE= MACOSX_FALSE='#' else MACOSX_TRUE='#' MACOSX_FALSE= fi ;; *) if false; then MACOSX_TRUE= MACOSX_FALSE='#' else MACOSX_TRUE='#' MACOSX_FALSE= fi ;; esac if test $netdb_reentrant = yes; then $as_echo "#define NETDB_REENTRANT 1" >>confdefs.h fi DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 $as_echo_n "checking for style of include used by $am_make... " >&6; } am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from 'make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 $as_echo "$_am_result" >&6; } rm -f confinc confmf # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then : enableval=$enable_dependency_tracking; fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; 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_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else 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_prog_CC="${ac_tool_prefix}gcc" $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 fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; 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_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else 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_prog_ac_ct_CC="gcc" $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 fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; 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_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else 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_prog_CC="${ac_tool_prefix}cc" $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 fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; 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_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no 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 if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $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 if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$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_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else 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_prog_CC="$ac_tool_prefix$ac_prog" $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 fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe 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_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else 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_prog_ac_ct_CC="$ac_prog" $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 fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 $as_echo_n "checking whether $CC understands -c and -o together... " >&6; } if ${am_cv_prog_cc_c_o+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 $as_echo "$am_cv_prog_cc_c_o" >&6; } if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done ac_fn_c_check_header_mongrel "$LINENO" "minix/config.h" "ac_cv_header_minix_config_h" "$ac_includes_default" if test "x$ac_cv_header_minix_config_h" = xyes; then : MINIX=yes else MINIX= fi if test "$MINIX" = yes; then $as_echo "#define _POSIX_SOURCE 1" >>confdefs.h $as_echo "#define _POSIX_1_SOURCE 2" >>confdefs.h $as_echo "#define _MINIX 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5 $as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; } if ${ac_cv_safe_to_define___extensions__+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # define __EXTENSIONS__ 1 $ac_includes_default int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_safe_to_define___extensions__=yes else ac_cv_safe_to_define___extensions__=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_define___extensions__" >&5 $as_echo "$ac_cv_safe_to_define___extensions__" >&6; } test $ac_cv_safe_to_define___extensions__ = yes && $as_echo "#define __EXTENSIONS__ 1" >>confdefs.h $as_echo "#define _ALL_SOURCE 1" >>confdefs.h $as_echo "#define _GNU_SOURCE 1" >>confdefs.h $as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h $as_echo "#define _TANDEM_SOURCE 1" >>confdefs.h # Check whether --enable-largefile was given. if test "${enable_largefile+set}" = set; then : enableval=$enable_largefile; fi if test "$enable_largefile" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for special C compiler options needed for large files" >&5 $as_echo_n "checking for special C compiler options needed for large files... " >&6; } if ${ac_cv_sys_largefile_CC+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_sys_largefile_CC=no if test "$GCC" != yes; then ac_save_CC=$CC while :; do # IRIX 6.2 and later do not support large files by default, # so use the C compiler's -n32 option if that helps. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : break fi rm -f core conftest.err conftest.$ac_objext CC="$CC -n32" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_largefile_CC=' -n32'; break fi rm -f core conftest.err conftest.$ac_objext break done CC=$ac_save_CC rm -f conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_CC" >&5 $as_echo "$ac_cv_sys_largefile_CC" >&6; } if test "$ac_cv_sys_largefile_CC" != no; then CC=$CC$ac_cv_sys_largefile_CC fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _FILE_OFFSET_BITS value needed for large files" >&5 $as_echo_n "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; } if ${ac_cv_sys_file_offset_bits+:} false; then : $as_echo_n "(cached) " >&6 else while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_file_offset_bits=no; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _FILE_OFFSET_BITS 64 #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_file_offset_bits=64; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_sys_file_offset_bits=unknown break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_file_offset_bits" >&5 $as_echo "$ac_cv_sys_file_offset_bits" >&6; } case $ac_cv_sys_file_offset_bits in #( no | unknown) ;; *) cat >>confdefs.h <<_ACEOF #define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits _ACEOF ;; esac rm -rf conftest* if test $ac_cv_sys_file_offset_bits = unknown; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGE_FILES value needed for large files" >&5 $as_echo_n "checking for _LARGE_FILES value needed for large files... " >&6; } if ${ac_cv_sys_large_files+:} false; then : $as_echo_n "(cached) " >&6 else while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_large_files=no; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _LARGE_FILES 1 #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_large_files=1; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_sys_large_files=unknown break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_large_files" >&5 $as_echo "$ac_cv_sys_large_files" >&6; } case $ac_cv_sys_large_files in #( no | unknown) ;; *) cat >>confdefs.h <<_ACEOF #define _LARGE_FILES $ac_cv_sys_large_files _ACEOF ;; esac rm -rf conftest* fi fi # ------------------------------------------------------------ # Checks for programs. # ------------------------------------------------------------ ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; 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_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else 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_prog_CC="${ac_tool_prefix}gcc" $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 fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; 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_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else 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_prog_ac_ct_CC="gcc" $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 fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; 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_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else 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_prog_CC="${ac_tool_prefix}cc" $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 fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; 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_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no 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 if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $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 if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$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_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else 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_prog_CC="$ac_tool_prefix$ac_prog" $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 fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe 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_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else 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_prog_ac_ct_CC="$ac_prog" $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 fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 $as_echo_n "checking whether $CC understands -c and -o together... " >&6; } if ${am_cv_prog_cc_c_o+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 $as_echo "$am_cv_prog_cc_c_o" >&6; } if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 $as_echo_n "checking for inline... " >&6; } if ${ac_cv_c_inline+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __cplusplus typedef int foo_t; static $ac_kw foo_t static_foo () {return 0; } $ac_kw foo_t foo () {return 0; } #endif _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_inline=$ac_kw fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext test "$ac_cv_c_inline" != no && break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 $as_echo "$ac_cv_c_inline" >&6; } case $ac_cv_c_inline in inline | yes) ;; *) case $ac_cv_c_inline in no) ac_val=;; *) ac_val=$ac_cv_c_inline;; esac cat >>confdefs.h <<_ACEOF #ifndef __cplusplus #define inline $ac_val #endif _ACEOF ;; esac case `pwd` in *\ * | *\ *) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 $as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; esac macro_version='2.4.6' macro_revision='2.4.6' ltmain=$ac_aux_dir/ltmain.sh # Backslashify metacharacters that are still active within # double-quoted strings. sed_quote_subst='s/\(["`$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 $as_echo_n "checking how to print strings... " >&6; } # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "" } case $ECHO in printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5 $as_echo "printf" >&6; } ;; print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 $as_echo "print -r" >&6; } ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5 $as_echo "cat" >&6; } ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } if ${ac_cv_path_SED+:} false; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for ac_i in 1 2 3 4 5 6 7; do ac_script="$ac_script$as_nl$ac_script" done echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed { ac_script=; unset ac_script;} if test -z "$SED"; then ac_path_SED_found=false # Loop through the user's path and test for each of PROGNAME-LIST 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_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_SED" || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in *GNU*) ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo '' >> "conftest.nl" "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_SED_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_SED="$ac_path_SED" ac_path_SED_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_SED_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_SED"; then as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 fi else ac_cv_path_SED=$SED fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 $as_echo "$ac_cv_path_SED" >&6; } SED="$ac_cv_path_SED" rm -f conftest.sed test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 $as_echo_n "checking for fgrep... " >&6; } if ${ac_cv_path_FGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 then ac_cv_path_FGREP="$GREP -F" else if test -z "$FGREP"; then ac_path_FGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in fgrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_FGREP" || continue # Check for GNU ac_path_FGREP and select it if it is found. # Check for GNU $ac_path_FGREP case `"$ac_path_FGREP" --version 2>&1` in *GNU*) ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'FGREP' >> "conftest.nl" "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_FGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_FGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_FGREP"; then as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_FGREP=$FGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 $as_echo "$ac_cv_path_FGREP" >&6; } FGREP="$ac_cv_path_FGREP" test -z "$GREP" && GREP=grep # Check whether --with-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then : withval=$with_gnu_ld; test no = "$withval" || with_gnu_ld=yes else with_gnu_ld=no fi ac_prog=ld if test yes = "$GCC"; then # Check if gcc -print-prog-name=ld gives a path. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 $as_echo_n "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return, which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | ?:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD=$ac_prog ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test yes = "$with_gnu_ld"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 $as_echo_n "checking for GNU ld... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 $as_echo_n "checking for non-GNU ld... " >&6; } fi if ${lt_cv_path_LD+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$LD"; then lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD=$ac_dir/$ac_prog # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &5 $as_echo "$LD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } if ${lt_cv_prog_gnu_ld+:} false; then : $as_echo_n "(cached) " >&6 else # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &5 $as_echo "$lt_cv_prog_gnu_ld" >&6; } with_gnu_ld=$lt_cv_prog_gnu_ld { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 $as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; } if ${lt_cv_path_NM+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM=$NM else lt_nm_to_check=${ac_tool_prefix}nm if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. tmp_nm=$ac_dir/$lt_tmp_nm if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then # Check to see if the nm accepts a BSD-compat flag. # Adding the 'sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file # MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty case $build_os in mingw*) lt_bad_file=conftest.nm/nofile ;; *) lt_bad_file=/dev/null ;; esac case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in *$lt_bad_file* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break 2 ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break 2 ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS=$lt_save_ifs done : ${lt_cv_path_NM=no} fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 $as_echo "$lt_cv_path_NM" >&6; } if test no != "$lt_cv_path_NM"; then NM=$lt_cv_path_NM else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : # Let the user override the test. else if test -n "$ac_tool_prefix"; then for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$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_prog_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DUMPBIN"; then ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. else 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_prog_DUMPBIN="$ac_tool_prefix$ac_prog" $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 fi fi DUMPBIN=$ac_cv_prog_DUMPBIN if test -n "$DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 $as_echo "$DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$DUMPBIN" && break done fi if test -z "$DUMPBIN"; then ac_ct_DUMPBIN=$DUMPBIN for ac_prog in dumpbin "link -dump" 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_prog_ac_ct_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DUMPBIN"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. else 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_prog_ac_ct_DUMPBIN="$ac_prog" $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 fi fi ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN if test -n "$ac_ct_DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 $as_echo "$ac_ct_DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_DUMPBIN" && break done if test "x$ac_ct_DUMPBIN" = x; then DUMPBIN=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DUMPBIN=$ac_ct_DUMPBIN fi fi case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols -headers" ;; *) DUMPBIN=: ;; esac fi if test : != "$DUMPBIN"; then NM=$DUMPBIN fi fi test -z "$NM" && NM=nm { $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 $as_echo_n "checking the name lister ($NM) interface... " >&6; } if ${lt_cv_nm_interface+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 $as_echo "$lt_cv_nm_interface" >&6; } # find the maximum length of command line arguments { $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 $as_echo_n "checking the maximum length of command line arguments... " >&6; } if ${lt_cv_sys_max_cmd_len+:} false; then : $as_echo_n "(cached) " >&6 else i=0 teststring=ABCD case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; mint*) # On MiNT this can take a long time and run out of memory. lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; os2*) # The test takes a long time on OS/2. lt_cv_sys_max_cmd_len=8192 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len" && \ test undefined != "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test X`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test 17 != "$i" # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac fi if test -n "$lt_cv_sys_max_cmd_len"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 $as_echo "$lt_cv_sys_max_cmd_len" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 $as_echo "none" >&6; } fi max_cmd_len=$lt_cv_sys_max_cmd_len : ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5 $as_echo_n "checking how to convert $build file names to $host format... " >&6; } if ${lt_cv_to_host_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac fi to_host_file_cmd=$lt_cv_to_host_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5 $as_echo "$lt_cv_to_host_file_cmd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5 $as_echo_n "checking how to convert $build file names to toolchain format... " >&6; } if ${lt_cv_to_tool_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else #assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac fi to_tool_file_cmd=$lt_cv_to_tool_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5 $as_echo "$lt_cv_to_tool_file_cmd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 $as_echo_n "checking for $LD option to reload object files... " >&6; } if ${lt_cv_ld_reload_flag+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_reload_flag='-r' fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 $as_echo "$lt_cv_ld_reload_flag" >&6; } reload_flag=$lt_cv_ld_reload_flag case $reload_flag in "" | " "*) ;; *) reload_flag=" $reload_flag" ;; esac reload_cmds='$LD$reload_flag -o $output$reload_objs' case $host_os in cygwin* | mingw* | pw32* | cegcc*) if test yes != "$GCC"; then reload_cmds=false fi ;; darwin*) if test yes = "$GCC"; then reload_cmds='$LTCC $LTCFLAGS -nostdlib $wl-r -o $output$reload_objs' else reload_cmds='$LD$reload_flag -o $output$reload_objs' fi ;; esac if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. set dummy ${ac_tool_prefix}objdump; 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_prog_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJDUMP"; then ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. else 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_prog_OBJDUMP="${ac_tool_prefix}objdump" $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 fi fi OBJDUMP=$ac_cv_prog_OBJDUMP if test -n "$OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 $as_echo "$OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OBJDUMP"; then ac_ct_OBJDUMP=$OBJDUMP # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; 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_prog_ac_ct_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJDUMP"; then ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. else 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_prog_ac_ct_OBJDUMP="objdump" $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 fi fi ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP if test -n "$ac_ct_OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 $as_echo "$ac_ct_OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OBJDUMP" = x; then OBJDUMP="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OBJDUMP=$ac_ct_OBJDUMP fi else OBJDUMP="$ac_cv_prog_OBJDUMP" fi test -z "$OBJDUMP" && OBJDUMP=objdump { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 $as_echo_n "checking how to recognize dependent libraries... " >&6; } if ${lt_cv_deplibs_check_method+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_file_magic_cmd='$MAGIC_CMD' lt_cv_file_magic_test_file= lt_cv_deplibs_check_method='unknown' # Need to set the preceding variable on all platforms that support # interlibrary dependencies. # 'none' -- dependencies not supported. # 'unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. # 'test_compile' -- check by making test program. # 'file_magic [[regex]]' -- check by looking for files in library path # that responds to the $file_magic_cmd with a given extended regex. # If you have 'file' or equivalent on your system and you're not sure # whether 'pass_all' will *always* work, you probably want this one. case $host_os in aix[4-9]*) lt_cv_deplibs_check_method=pass_all ;; beos*) lt_cv_deplibs_check_method=pass_all ;; bsdi[45]*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' lt_cv_file_magic_cmd='/usr/bin/file -L' lt_cv_file_magic_test_file=/shlib/libc.so ;; cygwin*) # func_win32_libid is a shell function defined in ltmain.sh lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' ;; mingw* | pw32*) # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump', # unless we find 'file', for example because we are cross-compiling. if ( file / ) >/dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc*) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; haiku*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]' lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[3-9]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) lt_cv_deplibs_check_method=pass_all ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd* | bitrig*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; os2*) lt_cv_deplibs_check_method=pass_all ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 $as_echo "$lt_cv_deplibs_check_method" >&6; } file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"` fi ;; esac fi file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. set dummy ${ac_tool_prefix}dlltool; 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_prog_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DLLTOOL"; then ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. else 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_prog_DLLTOOL="${ac_tool_prefix}dlltool" $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 fi fi DLLTOOL=$ac_cv_prog_DLLTOOL if test -n "$DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 $as_echo "$DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DLLTOOL"; then ac_ct_DLLTOOL=$DLLTOOL # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; 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_prog_ac_ct_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DLLTOOL"; then ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. else 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_prog_ac_ct_DLLTOOL="dlltool" $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 fi fi ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL if test -n "$ac_ct_DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 $as_echo "$ac_ct_DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DLLTOOL" = x; then DLLTOOL="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DLLTOOL=$ac_ct_DLLTOOL fi else DLLTOOL="$ac_cv_prog_DLLTOOL" fi test -z "$DLLTOOL" && DLLTOOL=dlltool { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5 $as_echo_n "checking how to associate runtime and link libraries... " >&6; } if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh; # decide which one to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd=$ECHO ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5 $as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; } sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO if test -n "$ac_tool_prefix"; then for ac_prog in ar do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$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_prog_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else 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_prog_AR="$ac_tool_prefix$ac_prog" $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 fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 $as_echo "$AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AR" && break done fi if test -z "$AR"; then ac_ct_AR=$AR for ac_prog in ar 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_prog_ac_ct_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else 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_prog_ac_ct_AR="$ac_prog" $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 fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 $as_echo "$ac_ct_AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_AR" && break done if test "x$ac_ct_AR" = x; then AR="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AR=$ac_ct_AR fi fi : ${AR=ar} : ${AR_FLAGS=cru} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5 $as_echo_n "checking for archiver @FILE support... " >&6; } if ${lt_cv_ar_at_file+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ar_at_file=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5' { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test 0 -eq "$ac_status"; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test 0 -ne "$ac_status"; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 $as_echo "$lt_cv_ar_at_file" >&6; } if test no = "$lt_cv_ar_at_file"; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; 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_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else 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_prog_STRIP="${ac_tool_prefix}strip" $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 fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; 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_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else 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_prog_ac_ct_STRIP="strip" $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 fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi test -z "$STRIP" && STRIP=: if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; 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_prog_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else 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_prog_RANLIB="${ac_tool_prefix}ranlib" $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 fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 $as_echo "$RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; 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_prog_ac_ct_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else 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_prog_ac_ct_RANLIB="ranlib" $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 fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 $as_echo "$ac_ct_RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi test -z "$RANLIB" && RANLIB=: # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in bitrig* | openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Check for command to grab the raw symbol name followed by C symbol from nm. { $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 $as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } if ${lt_cv_sys_global_symbol_pipe+:} false; then : $as_echo_n "(cached) " >&6 else # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[BCDEGRST]' # Regexp to match symbols that can be accessed directly from C. sympat='\([_A-Za-z][_A-Za-z0-9]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[BCDT]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[ABCDGISTW]' ;; hpux*) if test ia64 = "$host_cpu"; then symcode='[ABCDEGRST]' fi ;; irix* | nonstopux*) symcode='[BCDEGRST]' ;; osf*) symcode='[BCDEGQRST]' ;; solaris*) symcode='[BDRT]' ;; sco3.2v5*) symcode='[DT]' ;; sysv4.2uw2*) symcode='[DT]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[ABDT]' ;; sysv4) symcode='[DFNSTU]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[ABCDGIRSTW]' ;; esac if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Gets list of data symbols to import. lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'" # Adjust the below global symbol transforms to fixup imported variables. lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'" lt_c_name_hook=" -e 's/^I .* \(.*\)$/ {\"\1\", (void *) 0},/p'" lt_c_name_lib_hook="\ -e 's/^I .* \(lib.*\)$/ {\"\1\", (void *) 0},/p'\ -e 's/^I .* \(.*\)$/ {\"lib\1\", (void *) 0},/p'" else # Disable hooks by default. lt_cv_sys_global_symbol_to_import= lt_cdecl_hook= lt_c_name_hook= lt_c_name_lib_hook= fi # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n"\ $lt_cdecl_hook\ " -e 's/^T .* \(.*\)$/extern int \1();/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n"\ $lt_c_name_hook\ " -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/p'" # Transform an extracted symbol line into symbol name with lib prefix and # symbol address. lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\ $lt_c_name_lib_hook\ " -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ " -e 's/^$symcode$symcode* .* \(lib.*\)$/ {\"\1\", (void *) \&\1},/p'"\ " -e 's/^$symcode$symcode* .* \(.*\)$/ {\"lib\1\", (void *) \&\1},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function, # D for any global variable and I for any imported variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK '"\ " {last_section=section; section=\$ 3};"\ " /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\ " /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\ " /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\ " {split(\$ 0,a,/\||\r/); split(a[2],s)};"\ " s[1]~/^[@?]/{print f,s[1],s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # Now try to grab the symbols. nlist=conftest.nm if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5 (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE /* DATA imports from DLLs on WIN32 can't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined __osf__ /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ LT_DLSYM_CONST struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS LIBS=conftstm.$ac_objext CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest$ac_exeext; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&5 fi else echo "cannot find nm_test_var in $nlist" >&5 fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 fi else echo "$progname: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test yes = "$pipe_works"; then break else lt_cv_sys_global_symbol_pipe= fi done fi if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 $as_echo "failed" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } fi # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then nm_file_list_spec='@' fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 $as_echo_n "checking for sysroot... " >&6; } # Check whether --with-sysroot was given. if test "${with_sysroot+set}" = set; then : withval=$with_sysroot; else with_sysroot=no fi lt_sysroot= case $with_sysroot in #( yes) if test yes = "$GCC"; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_sysroot" >&5 $as_echo "$with_sysroot" >&6; } as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5 $as_echo "${lt_sysroot:-no}" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a working dd" >&5 $as_echo_n "checking for a working dd... " >&6; } if ${ac_cv_path_lt_DD+:} false; then : $as_echo_n "(cached) " >&6 else printf 0123456789abcdef0123456789abcdef >conftest.i cat conftest.i conftest.i >conftest2.i : ${lt_DD:=$DD} if test -z "$lt_DD"; then ac_path_lt_DD_found=false # Loop through the user's path and test for each of PROGNAME-LIST 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_prog in dd; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_lt_DD="$as_dir/$ac_prog$ac_exec_ext" as_fn_executable_p "$ac_path_lt_DD" || continue if "$ac_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then cmp -s conftest.i conftest.out \ && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=: fi $ac_path_lt_DD_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_lt_DD"; then : fi else ac_cv_path_lt_DD=$lt_DD fi rm -f conftest.i conftest2.i conftest.out fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_lt_DD" >&5 $as_echo "$ac_cv_path_lt_DD" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to truncate binary pipes" >&5 $as_echo_n "checking how to truncate binary pipes... " >&6; } if ${lt_cv_truncate_bin+:} false; then : $as_echo_n "(cached) " >&6 else printf 0123456789abcdef0123456789abcdef >conftest.i cat conftest.i conftest.i >conftest2.i lt_cv_truncate_bin= if "$ac_cv_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then cmp -s conftest.i conftest.out \ && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1" fi rm -f conftest.i conftest2.i conftest.out test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_truncate_bin" >&5 $as_echo "$lt_cv_truncate_bin" >&6; } # Calculate cc_basename. Skip known compiler wrappers and cross-prefix. func_cc_basename () { for cc_temp in $*""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` } # Check whether --enable-libtool-lock was given. if test "${enable_libtool_lock+set}" = set; then : enableval=$enable_libtool_lock; fi test no = "$enable_libtool_lock" || enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out what ABI is being produced by ac_compile, and set mode # options accordingly. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE=32 ;; *ELF-64*) HPUX_IA64_MODE=64 ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. echo '#line '$LINENO' "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then if test yes = "$lt_cv_prog_gnu_ld"; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; mips64*-*linux*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. echo '#line '$LINENO' "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then emul=elf case `/usr/bin/file conftest.$ac_objext` in *32-bit*) emul="${emul}32" ;; *64-bit*) emul="${emul}64" ;; esac case `/usr/bin/file conftest.$ac_objext` in *MSB*) emul="${emul}btsmip" ;; *LSB*) emul="${emul}ltsmip" ;; esac case `/usr/bin/file conftest.$ac_objext` in *N32*) emul="${emul}n32" ;; esac LD="${LD-ld} -m $emul" fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. Note that the listed cases only cover the # situations where additional linker options are needed (such as when # doing 32-bit compilation for a host where ld defaults to 64-bit, or # vice versa); the common cases where no linker options are needed do # not appear in the list. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) case `/usr/bin/file conftest.o` in *x86-64*) LD="${LD-ld} -m elf32_x86_64" ;; *) LD="${LD-ld} -m elf_i386" ;; esac ;; powerpc64le-*linux*) LD="${LD-ld} -m elf32lppclinux" ;; powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; powerpcle-*linux*) LD="${LD-ld} -m elf64lppc" ;; powerpc-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS=$CFLAGS CFLAGS="$CFLAGS -belf" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 $as_echo_n "checking whether the C compiler needs -belf... " >&6; } if ${lt_cv_cc_needs_belf+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_cc_needs_belf=yes else lt_cv_cc_needs_belf=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 $as_echo "$lt_cv_cc_needs_belf" >&6; } if test yes != "$lt_cv_cc_needs_belf"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS=$SAVE_CFLAGS fi ;; *-*solaris*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) case $host in i?86-*-solaris*|x86_64-*-solaris*) LD="${LD-ld} -m elf_x86_64" ;; sparc*-*-solaris*) LD="${LD-ld} -m elf64_sparc" ;; esac # GNU ld 2.21 introduced _sol2 emulations. Use them if available. if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then LD=${LD-ld}_sol2 fi ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks=$enable_libtool_lock if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args. set dummy ${ac_tool_prefix}mt; 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_prog_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$MANIFEST_TOOL"; then ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test. else 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_prog_MANIFEST_TOOL="${ac_tool_prefix}mt" $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 fi fi MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL if test -n "$MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5 $as_echo "$MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_MANIFEST_TOOL"; then ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL # Extract the first word of "mt", so it can be a program name with args. set dummy mt; 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_prog_ac_ct_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_MANIFEST_TOOL"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test. else 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_prog_ac_ct_MANIFEST_TOOL="mt" $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 fi fi ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL if test -n "$ac_ct_MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5 $as_echo "$ac_ct_MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_MANIFEST_TOOL" = x; then MANIFEST_TOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL fi else MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL" fi test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 $as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } if ${lt_cv_path_mainfest_tool+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5 $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&5 if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 $as_echo "$lt_cv_path_mainfest_tool" >&6; } if test yes != "$lt_cv_path_mainfest_tool"; then MANIFEST_TOOL=: fi case $host_os in rhapsody* | darwin*) if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. set dummy ${ac_tool_prefix}dsymutil; 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_prog_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DSYMUTIL"; then ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. else 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_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" $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 fi fi DSYMUTIL=$ac_cv_prog_DSYMUTIL if test -n "$DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 $as_echo "$DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DSYMUTIL"; then ac_ct_DSYMUTIL=$DSYMUTIL # Extract the first word of "dsymutil", so it can be a program name with args. set dummy dsymutil; 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_prog_ac_ct_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DSYMUTIL"; then ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. else 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_prog_ac_ct_DSYMUTIL="dsymutil" $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 fi fi ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL if test -n "$ac_ct_DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 $as_echo "$ac_ct_DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DSYMUTIL" = x; then DSYMUTIL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DSYMUTIL=$ac_ct_DSYMUTIL fi else DSYMUTIL="$ac_cv_prog_DSYMUTIL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. set dummy ${ac_tool_prefix}nmedit; 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_prog_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NMEDIT"; then ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. else 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_prog_NMEDIT="${ac_tool_prefix}nmedit" $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 fi fi NMEDIT=$ac_cv_prog_NMEDIT if test -n "$NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 $as_echo "$NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_NMEDIT"; then ac_ct_NMEDIT=$NMEDIT # Extract the first word of "nmedit", so it can be a program name with args. set dummy nmedit; 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_prog_ac_ct_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_NMEDIT"; then ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. else 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_prog_ac_ct_NMEDIT="nmedit" $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 fi fi ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT if test -n "$ac_ct_NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 $as_echo "$ac_ct_NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_NMEDIT" = x; then NMEDIT=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac NMEDIT=$ac_ct_NMEDIT fi else NMEDIT="$ac_cv_prog_NMEDIT" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. set dummy ${ac_tool_prefix}lipo; 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_prog_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$LIPO"; then ac_cv_prog_LIPO="$LIPO" # Let the user override the test. else 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_prog_LIPO="${ac_tool_prefix}lipo" $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 fi fi LIPO=$ac_cv_prog_LIPO if test -n "$LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 $as_echo "$LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_LIPO"; then ac_ct_LIPO=$LIPO # Extract the first word of "lipo", so it can be a program name with args. set dummy lipo; 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_prog_ac_ct_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_LIPO"; then ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. else 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_prog_ac_ct_LIPO="lipo" $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 fi fi ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO if test -n "$ac_ct_LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 $as_echo "$ac_ct_LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_LIPO" = x; then LIPO=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac LIPO=$ac_ct_LIPO fi else LIPO="$ac_cv_prog_LIPO" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. set dummy ${ac_tool_prefix}otool; 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_prog_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL"; then ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. else 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_prog_OTOOL="${ac_tool_prefix}otool" $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 fi fi OTOOL=$ac_cv_prog_OTOOL if test -n "$OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 $as_echo "$OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL"; then ac_ct_OTOOL=$OTOOL # Extract the first word of "otool", so it can be a program name with args. set dummy otool; 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_prog_ac_ct_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL"; then ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. else 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_prog_ac_ct_OTOOL="otool" $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 fi fi ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL if test -n "$ac_ct_OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 $as_echo "$ac_ct_OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL" = x; then OTOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL=$ac_ct_OTOOL fi else OTOOL="$ac_cv_prog_OTOOL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. set dummy ${ac_tool_prefix}otool64; 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_prog_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL64"; then ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. else 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_prog_OTOOL64="${ac_tool_prefix}otool64" $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 fi fi OTOOL64=$ac_cv_prog_OTOOL64 if test -n "$OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 $as_echo "$OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL64"; then ac_ct_OTOOL64=$OTOOL64 # Extract the first word of "otool64", so it can be a program name with args. set dummy otool64; 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_prog_ac_ct_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL64"; then ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. else 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_prog_ac_ct_OTOOL64="otool64" $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 fi fi ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 if test -n "$ac_ct_OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 $as_echo "$ac_ct_OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL64" = x; then OTOOL64=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL64=$ac_ct_OTOOL64 fi else OTOOL64="$ac_cv_prog_OTOOL64" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 $as_echo_n "checking for -single_module linker flag... " >&6; } if ${lt_cv_apple_cc_single_mod+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_apple_cc_single_mod=no if test -z "$LT_MULTI_MODULE"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&5 $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? # If there is a non-empty error log, and "single_module" # appears in it, assume the flag caused a linker warning if test -s conftest.err && $GREP single_module conftest.err; then cat conftest.err >&5 # Otherwise, if the output was created with a 0 exit code from # the compiler, it worked. elif test -f libconftest.dylib && test 0 = "$_lt_result"; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&5 fi rm -rf libconftest.dylib* rm -f conftest.* fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 $as_echo "$lt_cv_apple_cc_single_mod" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 $as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } if ${lt_cv_ld_exported_symbols_list+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_ld_exported_symbols_list=yes else lt_cv_ld_exported_symbols_list=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 $as_echo "$lt_cv_ld_exported_symbols_list" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 $as_echo_n "checking for -force_load linker flag... " >&6; } if ${lt_cv_ld_force_load+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 echo "$AR cru libconftest.a conftest.o" >&5 $AR cru libconftest.a conftest.o 2>&5 echo "$RANLIB libconftest.a" >&5 $RANLIB libconftest.a 2>&5 cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5 $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -s conftest.err && $GREP force_load conftest.err; then cat conftest.err >&5 elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then lt_cv_ld_force_load=yes else cat conftest.err >&5 fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 $as_echo "$lt_cv_ld_force_load" >&6; } case $host_os in rhapsody* | darwin1.[012]) _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[91]*) _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; 10.[012][,.]*) _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test yes = "$lt_cv_apple_cc_single_mod"; then _lt_dar_single_mod='$single_module' fi if test yes = "$lt_cv_ld_exported_symbols_list"; then _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib' fi if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac # func_munge_path_list VARIABLE PATH # ----------------------------------- # VARIABLE is name of variable containing _space_ separated list of # directories to be munged by the contents of PATH, which is string # having a format: # "DIR[:DIR]:" # string "DIR[ DIR]" will be prepended to VARIABLE # ":DIR[:DIR]" # string "DIR[ DIR]" will be appended to VARIABLE # "DIRP[:DIRP]::[DIRA:]DIRA" # string "DIRP[ DIRP]" will be prepended to VARIABLE and string # "DIRA[ DIRA]" will be appended to VARIABLE # "DIR[:DIR]" # VARIABLE will be replaced by "DIR[ DIR]" func_munge_path_list () { case x$2 in x) ;; *:) eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\" ;; x:*) eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\" ;; *::*) eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\" ;; *) eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\" ;; esac } for ac_header in dlfcn.h do : ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default " if test "x$ac_cv_header_dlfcn_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DLFCN_H 1 _ACEOF fi done # Set options enable_win32_dll=yes case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args. set dummy ${ac_tool_prefix}as; 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_prog_AS+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AS"; then ac_cv_prog_AS="$AS" # Let the user override the test. else 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_prog_AS="${ac_tool_prefix}as" $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 fi fi AS=$ac_cv_prog_AS if test -n "$AS"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AS" >&5 $as_echo "$AS" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_AS"; then ac_ct_AS=$AS # Extract the first word of "as", so it can be a program name with args. set dummy as; 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_prog_ac_ct_AS+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AS"; then ac_cv_prog_ac_ct_AS="$ac_ct_AS" # Let the user override the test. else 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_prog_ac_ct_AS="as" $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 fi fi ac_ct_AS=$ac_cv_prog_ac_ct_AS if test -n "$ac_ct_AS"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AS" >&5 $as_echo "$ac_ct_AS" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_AS" = x; then AS="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AS=$ac_ct_AS fi else AS="$ac_cv_prog_AS" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. set dummy ${ac_tool_prefix}dlltool; 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_prog_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DLLTOOL"; then ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. else 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_prog_DLLTOOL="${ac_tool_prefix}dlltool" $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 fi fi DLLTOOL=$ac_cv_prog_DLLTOOL if test -n "$DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 $as_echo "$DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DLLTOOL"; then ac_ct_DLLTOOL=$DLLTOOL # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; 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_prog_ac_ct_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DLLTOOL"; then ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. else 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_prog_ac_ct_DLLTOOL="dlltool" $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 fi fi ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL if test -n "$ac_ct_DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 $as_echo "$ac_ct_DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DLLTOOL" = x; then DLLTOOL="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DLLTOOL=$ac_ct_DLLTOOL fi else DLLTOOL="$ac_cv_prog_DLLTOOL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. set dummy ${ac_tool_prefix}objdump; 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_prog_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJDUMP"; then ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. else 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_prog_OBJDUMP="${ac_tool_prefix}objdump" $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 fi fi OBJDUMP=$ac_cv_prog_OBJDUMP if test -n "$OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 $as_echo "$OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OBJDUMP"; then ac_ct_OBJDUMP=$OBJDUMP # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; 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_prog_ac_ct_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJDUMP"; then ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. else 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_prog_ac_ct_OBJDUMP="objdump" $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 fi fi ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP if test -n "$ac_ct_OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 $as_echo "$ac_ct_OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OBJDUMP" = x; then OBJDUMP="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OBJDUMP=$ac_ct_OBJDUMP fi else OBJDUMP="$ac_cv_prog_OBJDUMP" fi ;; esac test -z "$AS" && AS=as test -z "$DLLTOOL" && DLLTOOL=dlltool test -z "$OBJDUMP" && OBJDUMP=objdump enable_dlopen=no # Check whether --enable-shared was given. if test "${enable_shared+set}" = set; then : enableval=$enable_shared; p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS=$lt_save_ifs ;; esac else enable_shared=yes fi # Check whether --enable-static was given. if test "${enable_static+set}" = set; then : enableval=$enable_static; p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS=$lt_save_ifs ;; esac else enable_static=yes fi # Check whether --with-pic was given. if test "${with_pic+set}" = set; then : withval=$with_pic; lt_p=${PACKAGE-default} case $withval in yes|no) pic_mode=$withval ;; *) pic_mode=default # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for lt_pkg in $withval; do IFS=$lt_save_ifs if test "X$lt_pkg" = "X$lt_p"; then pic_mode=yes fi done IFS=$lt_save_ifs ;; esac else pic_mode=default fi # Check whether --enable-fast-install was given. if test "${enable_fast_install+set}" = set; then : enableval=$enable_fast_install; p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, for pkg in $enableval; do IFS=$lt_save_ifs if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS=$lt_save_ifs ;; esac else enable_fast_install=yes fi shared_archive_member_spec= case $host,$enable_shared in power*-*-aix[5-9]*,yes) { $as_echo "$as_me:${as_lineno-$LINENO}: checking which variant of shared library versioning to provide" >&5 $as_echo_n "checking which variant of shared library versioning to provide... " >&6; } # Check whether --with-aix-soname was given. if test "${with_aix_soname+set}" = set; then : withval=$with_aix_soname; case $withval in aix|svr4|both) ;; *) as_fn_error $? "Unknown argument to --with-aix-soname" "$LINENO" 5 ;; esac lt_cv_with_aix_soname=$with_aix_soname else if ${lt_cv_with_aix_soname+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_with_aix_soname=aix fi with_aix_soname=$lt_cv_with_aix_soname fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_aix_soname" >&5 $as_echo "$with_aix_soname" >&6; } if test aix != "$with_aix_soname"; then # For the AIX way of multilib, we name the shared archive member # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o', # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File. # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag, # the AIX toolchain works better with OBJECT_MODE set (default 32). if test 64 = "${OBJECT_MODE-32}"; then shared_archive_member_spec=shr_64 else shared_archive_member_spec=shr fi fi ;; *) with_aix_soname=aix ;; esac # This can be used to rebuild libtool when needed LIBTOOL_DEPS=$ltmain # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' test -z "$LN_S" && LN_S="ln -s" if test -n "${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 $as_echo_n "checking for objdir... " >&6; } if ${lt_cv_objdir+:} false; then : $as_echo_n "(cached) " >&6 else rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 $as_echo "$lt_cv_objdir" >&6; } objdir=$lt_cv_objdir cat >>confdefs.h <<_ACEOF #define LT_OBJDIR "$lt_cv_objdir/" _ACEOF case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test set != "${COLLECT_NAMES+set}"; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a '.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld=$lt_cv_prog_gnu_ld old_CC=$CC old_CFLAGS=$CFLAGS # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o func_cc_basename $compiler cc_basename=$func_cc_basename_result # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 $as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD=$MAGIC_CMD lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/${ac_tool_prefix}file"; then lt_cv_path_MAGIC_CMD=$ac_dir/"${ac_tool_prefix}file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD=$lt_cv_path_MAGIC_CMD if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS=$lt_save_ifs MAGIC_CMD=$lt_save_MAGIC_CMD ;; esac fi MAGIC_CMD=$lt_cv_path_MAGIC_CMD if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5 $as_echo_n "checking for file... " >&6; } if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD=$MAGIC_CMD lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS=$lt_save_ifs test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/file"; then lt_cv_path_MAGIC_CMD=$ac_dir/"file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD=$lt_cv_path_MAGIC_CMD if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS=$lt_save_ifs MAGIC_CMD=$lt_save_MAGIC_CMD ;; esac fi MAGIC_CMD=$lt_cv_path_MAGIC_CMD if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi else MAGIC_CMD=: fi fi fi ;; esac # Use C for the default configuration in the libtool script lt_save_CC=$CC ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o objext=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then lt_prog_compiler_no_builtin_flag= if test yes = "$GCC"; then case $cc_basename in nvcc*) lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;; *) lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 $as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_rtti_exceptions=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-fno-rtti -fno-exceptions" ## exclude from sc_useless_quotes_in_assignment # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_rtti_exceptions=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 $as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; } if test yes = "$lt_cv_prog_compiler_rtti_exceptions"; then lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" else : fi fi lt_prog_compiler_wl= lt_prog_compiler_pic= lt_prog_compiler_static= if test yes = "$GCC"; then lt_prog_compiler_wl='-Wl,' lt_prog_compiler_static='-static' case $host_os in aix*) # All AIX code is PIC. if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' fi lt_prog_compiler_pic='-fPIC' ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support lt_prog_compiler_pic='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the '-m68020' flag to GCC prevents building anything better, # like '-m68040'. lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries lt_prog_compiler_pic='-DDLL_EXPORT' case $host_os in os2*) lt_prog_compiler_static='$wl-static' ;; esac ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic='-fno-common' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. lt_prog_compiler_static= ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) lt_prog_compiler_pic='-fPIC' ;; esac ;; interix[3-9]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. lt_prog_compiler_can_build_shared=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic=-Kconform_pic fi ;; *) lt_prog_compiler_pic='-fPIC' ;; esac case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 lt_prog_compiler_wl='-Xlinker ' if test -n "$lt_prog_compiler_pic"; then lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic" fi ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) lt_prog_compiler_wl='-Wl,' if test ia64 = "$host_cpu"; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' else lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' fi ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic='-fno-common' case $cc_basename in nagfor*) # NAG Fortran compiler lt_prog_compiler_wl='-Wl,-Wl,,' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; esac ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic='-DDLL_EXPORT' case $host_os in os2*) lt_prog_compiler_static='$wl-static' ;; esac ;; hpux9* | hpux10* | hpux11*) lt_prog_compiler_wl='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? lt_prog_compiler_static='$wl-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) lt_prog_compiler_wl='-Wl,' # PIC (with -KPIC) is the default. lt_prog_compiler_static='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) case $cc_basename in # old Intel for x86_64, which still supported -KPIC. ecc*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; # Lahey Fortran 8.1. lf95*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='--shared' lt_prog_compiler_static='--static' ;; nagfor*) # NAG Fortran compiler lt_prog_compiler_wl='-Wl,-Wl,,' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; tcc*) # Fabrice Bellard et al's Tiny C Compiler lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; ccc*) lt_prog_compiler_wl='-Wl,' # All Alpha code is PIC. lt_prog_compiler_static='-non_shared' ;; xl* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-qpic' lt_prog_compiler_static='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='' ;; *Sun\ F* | *Sun*Fortran*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Qoption ld ' ;; *Sun\ C*) # Sun C 5.9 lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Wl,' ;; *Intel*\ [CF]*Compiler*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; *Portland\ Group*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; esac ;; esac ;; newsos6) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; osf3* | osf4* | osf5*) lt_prog_compiler_wl='-Wl,' # All OSF/1 code is PIC. lt_prog_compiler_static='-non_shared' ;; rdos*) lt_prog_compiler_static='-non_shared' ;; solaris*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) lt_prog_compiler_wl='-Qoption ld ';; *) lt_prog_compiler_wl='-Wl,';; esac ;; sunos4*) lt_prog_compiler_wl='-Qoption ld ' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic='-Kconform_pic' lt_prog_compiler_static='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; unicos*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_can_build_shared=no ;; uts4*) lt_prog_compiler_pic='-pic' lt_prog_compiler_static='-Bstatic' ;; *) lt_prog_compiler_can_build_shared=no ;; esac fi case $host_os in # For platforms that do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic= ;; *) lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 $as_echo_n "checking for $compiler option to produce PIC... " >&6; } if ${lt_cv_prog_compiler_pic+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic=$lt_prog_compiler_pic fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 $as_echo "$lt_cv_prog_compiler_pic" >&6; } lt_prog_compiler_pic=$lt_cv_prog_compiler_pic # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 $as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } if ${lt_cv_prog_compiler_pic_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic_works=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$lt_prog_compiler_pic -DPIC" ## exclude from sc_useless_quotes_in_assignment # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_pic_works=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 $as_echo "$lt_cv_prog_compiler_pic_works" >&6; } if test yes = "$lt_cv_prog_compiler_pic_works"; then case $lt_prog_compiler_pic in "" | " "*) ;; *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; esac else lt_prog_compiler_pic= lt_prog_compiler_can_build_shared=no fi fi # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 $as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } if ${lt_cv_prog_compiler_static_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_static_works=no save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS $lt_tmp_static_flag" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_static_works=yes fi else lt_cv_prog_compiler_static_works=yes fi fi $RM -r conftest* LDFLAGS=$save_LDFLAGS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 $as_echo "$lt_cv_prog_compiler_static_works" >&6; } if test yes = "$lt_cv_prog_compiler_static_works"; then : else lt_prog_compiler_static= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } hard_links=nottested if test no = "$lt_cv_prog_compiler_c_o" && test no != "$need_locks"; then # do not overwrite the value of need_locks provided by the user { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 $as_echo_n "checking if we can lock with hard links... " >&6; } hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 $as_echo "$hard_links" >&6; } if test no = "$hard_links"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5 $as_echo "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;} need_locks=warn fi else need_locks=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 $as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } runpath_var= allow_undefined_flag= always_export_symbols=no archive_cmds= archive_expsym_cmds= compiler_needs_object=no enable_shared_with_static_runtimes=no export_dynamic_flag_spec= export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' hardcode_automatic=no hardcode_direct=no hardcode_direct_absolute=no hardcode_libdir_flag_spec= hardcode_libdir_separator= hardcode_minus_L=no hardcode_shlibpath_var=unsupported inherit_rpath=no link_all_deplibs=unknown module_cmds= module_expsym_cmds= old_archive_from_new_cmds= old_archive_from_expsyms_cmds= thread_safe_flag_spec= whole_archive_flag_spec= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list include_expsyms= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ' (' and ')$', so one must not match beginning or # end of line. Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc', # as well as any symbol that contains 'd'. exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test yes != "$GCC"; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd* | bitrig*) with_gnu_ld=no ;; esac ld_shlibs=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test yes = "$with_gnu_ld"; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;; *\ \(GNU\ Binutils\)\ [3-9]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test yes = "$lt_use_gnu_ld_interface"; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='$wl' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' export_dynamic_flag_spec='$wl--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then whole_archive_flag_spec=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' else whole_archive_flag_spec= fi supports_anon_versioning=no case `$LD -v | $SED -e 's/(^)\+)\s\+//' 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[3-9]*) # On AIX/PPC, the GNU linker is very broken if test ia64 != "$host_cpu"; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.19, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then allow_undefined_flag=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' else ld_shlibs=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' export_dynamic_flag_spec='$wl--export-all-symbols' allow_undefined_flag=unsupported always_export_symbols=no enable_shared_with_static_runtimes=yes export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file, use it as # is; otherwise, prepend EXPORTS... archive_expsym_cmds='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else ld_shlibs=no fi ;; haiku*) archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' link_all_deplibs=yes ;; os2*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes allow_undefined_flag=unsupported shrext_cmds=.dll archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ prefix_cmds="$SED"~ if test EXPORTS = "`$SED 1q $export_symbols`"; then prefix_cmds="$prefix_cmds -e 1d"; fi~ prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' enable_shared_with_static_runtimes=yes ;; interix[3-9]*) hardcode_direct=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='$wl-rpath,$libdir' export_dynamic_flag_spec='$wl-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' archive_expsym_cmds='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test linux-dietlibc = "$host_os"; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test no = "$tmp_diet" then tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 whole_archive_flag_spec= tmp_sharedflag='--shared' ;; nagfor*) # NAGFOR 5.3 tmp_sharedflag='-Wl,-shared' ;; xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' compiler_needs_object=yes ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 whole_archive_flag_spec='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' compiler_needs_object=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' if test yes = "$supports_anon_versioning"; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' fi case $cc_basename in tcc*) export_dynamic_flag_spec='-rdynamic' ;; xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test yes = "$supports_anon_versioning"; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else ld_shlibs=no fi ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac ;; sunos4*) archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= hardcode_direct=yes hardcode_shlibpath_var=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac if test no = "$ld_shlibs"; then runpath_var= hardcode_libdir_flag_spec= export_dynamic_flag_spec= whole_archive_flag_spec= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) allow_undefined_flag=unsupported always_export_symbols=yes archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. hardcode_minus_L=yes if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. hardcode_direct=unsupported fi ;; aix[4-9]*) if test ia64 = "$host_cpu"; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag= else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to GNU nm, but means don't demangle to AIX nm. # Without the "-l" option, or with the "-B" option, AIX nm treats # weak defined symbols like other global defined symbols, whereas # GNU nm marks them as "W". # While the 'weak' keyword is ignored in the Export File, we need # it in the Import File for the 'aix-soname' feature, so we have # to replace the "-B" option with "-P" for AIX nm. if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' else export_symbols_cmds='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # have runtime linking enabled, and use it for executables. # For shared libraries, we enable/disable runtime linking # depending on the kind of the shared library created - # when "with_aix_soname,aix_use_runtimelinking" is: # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables # "aix,yes" lib.so shared, rtl:yes, for executables # lib.a static archive # "both,no" lib.so.V(shr.o) shared, rtl:yes # lib.a(lib.so.V) shared, rtl:no, for executables # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables # lib.a(lib.so.V) shared, rtl:no # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables # lib.a static archive case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) for ld_flag in $LDFLAGS; do if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then aix_use_runtimelinking=yes break fi done if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then # With aix-soname=svr4, we create the lib.so.V shared archives only, # so we don't have lib.a shared libs to link our executables. # We have to force runtime linking in this case. aix_use_runtimelinking=yes LDFLAGS="$LDFLAGS -Wl,-brtl" fi ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. archive_cmds='' hardcode_direct=yes hardcode_direct_absolute=yes hardcode_libdir_separator=':' link_all_deplibs=yes file_list_spec='$wl-f,' case $with_aix_soname,$aix_use_runtimelinking in aix,*) ;; # traditional, no import file svr4,* | *,yes) # use import file # The Import File defines what to hardcode. hardcode_direct=no hardcode_direct_absolute=no ;; esac if test yes = "$GCC"; then case $host_os in aix4.[012]|aix4.[012].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`$CC -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 hardcode_direct=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking hardcode_minus_L=yes hardcode_libdir_flag_spec='-L$libdir' hardcode_libdir_separator= fi ;; esac shared_flag='-shared' if test yes = "$aix_use_runtimelinking"; then shared_flag="$shared_flag "'$wl-G' fi # Need to ensure runtime linking is disabled for the traditional # shared library, or the linker may eventually find shared libraries # /with/ Import File - we do not want to mix them. shared_flag_aix='-shared' shared_flag_svr4='-shared $wl-G' else # not using gcc if test ia64 = "$host_cpu"; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test yes = "$aix_use_runtimelinking"; then shared_flag='$wl-G' else shared_flag='$wl-bM:SRE' fi shared_flag_aix='$wl-bM:SRE' shared_flag_svr4='$wl-G' fi fi export_dynamic_flag_spec='$wl-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. always_export_symbols=yes if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. allow_undefined_flag='-berok' # Determine the default libpath from the value encoded in an # empty executable. if test set = "${lt_cv_aix_libpath+set}"; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=/usr/lib:/lib fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath" archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag else if test ia64 = "$host_cpu"; then hardcode_libdir_flag_spec='$wl-R $libdir:/usr/lib:/lib' allow_undefined_flag="-z nodefs" archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. if test set = "${lt_cv_aix_libpath+set}"; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=/usr/lib:/lib fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. no_undefined_flag=' $wl-bernotok' allow_undefined_flag=' $wl-berok' if test yes = "$with_gnu_ld"; then # We only use this code for GNU lds that support --whole-archive. whole_archive_flag_spec='$wl--whole-archive$convenience $wl--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec='$convenience' fi archive_cmds_need_lc=yes archive_expsym_cmds='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d' # -brtl affects multiple linker settings, -berok does not and is overridden later compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([, ]\\)%-berok\\1%g"`' if test svr4 != "$with_aix_soname"; then # This is similar to how AIX traditionally builds its shared libraries. archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname' fi if test aix != "$with_aix_soname"; then archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp' else # used by -dlpreopen to get the symbols archive_expsym_cmds="$archive_expsym_cmds"'~$MV $output_objdir/$realname.d/$soname $output_objdir' fi archive_expsym_cmds="$archive_expsym_cmds"'~$RM -r $output_objdir/$realname.d' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; bsdi[45]*) export_dynamic_flag_spec=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. case $cc_basename in cl*) # Native MSVC hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported always_export_symbols=yes file_list_spec='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' archive_expsym_cmds='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then cp "$export_symbols" "$output_objdir/$soname.def"; echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; else $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, )='true' enable_shared_with_static_runtimes=yes exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib old_postinstall_cmds='chmod 644 $oldlib' postlink_cmds='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile=$lt_outputfile.exe lt_tool_outputfile=$lt_tool_outputfile.exe ;; esac~ if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC wrapper hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. old_archive_from_new_cmds='true' # FIXME: Should let the user specify the lib program. old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' enable_shared_with_static_runtimes=yes ;; esac ;; darwin* | rhapsody*) archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes hardcode_shlibpath_var=unsupported if test yes = "$lt_cv_ld_force_load"; then whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' else whole_archive_flag_spec='' fi link_all_deplibs=yes allow_undefined_flag=$_lt_dar_allow_undefined case $cc_basename in ifort*|nagfor*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test yes = "$_lt_dar_can_shared"; then output_verbose_link_cmd=func_echo_all archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil" module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil" archive_expsym_cmds="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" module_expsym_cmds="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" else ld_shlibs=no fi ;; dgux*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2.*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; hpux9*) if test yes = "$GCC"; then archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' else archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' fi hardcode_libdir_flag_spec='$wl+b $wl$libdir' hardcode_libdir_separator=: hardcode_direct=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes export_dynamic_flag_spec='$wl-E' ;; hpux10*) if test yes,no = "$GCC,$with_gnu_ld"; then archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test no = "$with_gnu_ld"; then hardcode_libdir_flag_spec='$wl+b $wl$libdir' hardcode_libdir_separator=: hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='$wl-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes fi ;; hpux11*) if test yes,no = "$GCC,$with_gnu_ld"; then case $host_cpu in hppa*64*) archive_cmds='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) archive_cmds='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 $as_echo_n "checking if $CC understands -b... " >&6; } if ${lt_cv_prog_compiler__b+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler__b=no save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS -b" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler__b=yes fi else lt_cv_prog_compiler__b=yes fi fi $RM -r conftest* LDFLAGS=$save_LDFLAGS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 $as_echo "$lt_cv_prog_compiler__b" >&6; } if test yes = "$lt_cv_prog_compiler__b"; then archive_cmds='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi ;; esac fi if test no = "$with_gnu_ld"; then hardcode_libdir_flag_spec='$wl+b $wl$libdir' hardcode_libdir_separator=: case $host_cpu in hppa*64*|ia64*) hardcode_direct=no hardcode_shlibpath_var=no ;; *) hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='$wl-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test yes = "$GCC"; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5 $as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; } if ${lt_cv_irix_exported_symbol+:} false; then : $as_echo_n "(cached) " >&6 else save_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int foo (void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_irix_exported_symbol=yes else lt_cv_irix_exported_symbol=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5 $as_echo "$lt_cv_irix_exported_symbol" >&6; } if test yes = "$lt_cv_irix_exported_symbol"; then archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib' fi else archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' hardcode_libdir_separator=: inherit_rpath=yes link_all_deplibs=yes ;; linux*) case $cc_basename in tcc*) # Fabrice Bellard et al's Tiny C Compiler ld_shlibs=yes archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; newsos6) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' hardcode_libdir_separator=: hardcode_shlibpath_var=no ;; *nto* | *qnx*) ;; openbsd* | bitrig*) if test -f /usr/libexec/ld.so; then hardcode_direct=yes hardcode_shlibpath_var=no hardcode_direct_absolute=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols' hardcode_libdir_flag_spec='$wl-rpath,$libdir' export_dynamic_flag_spec='$wl-E' else archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='$wl-rpath,$libdir' fi else ld_shlibs=no fi ;; os2*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes allow_undefined_flag=unsupported shrext_cmds=.dll archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ $ECHO EXPORTS >> $output_objdir/$libname.def~ prefix_cmds="$SED"~ if test EXPORTS = "`$SED 1q $export_symbols`"; then prefix_cmds="$prefix_cmds -e 1d"; fi~ prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ emximp -o $lib $output_objdir/$libname.def' old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' enable_shared_with_static_runtimes=yes ;; osf3*) if test yes = "$GCC"; then allow_undefined_flag=' $wl-expect_unresolved $wl\*' archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' hardcode_libdir_separator=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test yes = "$GCC"; then allow_undefined_flag=' $wl-expect_unresolved $wl\*' archive_cmds='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' hardcode_libdir_flag_spec='$wl-rpath $wl$libdir' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly hardcode_libdir_flag_spec='-rpath $libdir' fi archive_cmds_need_lc='no' hardcode_libdir_separator=: ;; solaris*) no_undefined_flag=' -z defs' if test yes = "$GCC"; then wlarc='$wl' archive_cmds='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' archive_cmds='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='$wl' archive_cmds='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi hardcode_libdir_flag_spec='-R$libdir' hardcode_shlibpath_var=no case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands '-z linker_flag'. GCC discards it without '$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test yes = "$GCC"; then whole_archive_flag_spec='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' else whole_archive_flag_spec='-z allextract$convenience -z defaultextract' fi ;; esac link_all_deplibs=yes ;; sunos4*) if test sequent = "$host_vendor"; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. archive_cmds='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi hardcode_libdir_flag_spec='-L$libdir' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; sysv4) case $host_vendor in sni) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' reload_cmds='$CC -r -o $output$reload_objs' hardcode_direct=no ;; motorola) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' hardcode_shlibpath_var=no ;; sysv4.3*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no export_dynamic_flag_spec='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes ld_shlibs=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) no_undefined_flag='$wl-z,text' archive_cmds_need_lc=no hardcode_shlibpath_var=no runpath_var='LD_RUN_PATH' if test yes = "$GCC"; then archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We CANNOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. no_undefined_flag='$wl-z,text' allow_undefined_flag='$wl-z,nodefs' archive_cmds_need_lc=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='$wl-R,$libdir' hardcode_libdir_separator=':' link_all_deplibs=yes export_dynamic_flag_spec='$wl-Bexport' runpath_var='LD_RUN_PATH' if test yes = "$GCC"; then archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; *) ld_shlibs=no ;; esac if test sni = "$host_vendor"; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) export_dynamic_flag_spec='$wl-Blargedynsym' ;; esac fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 $as_echo "$ld_shlibs" >&6; } test no = "$ld_shlibs" && can_build_shared=no with_gnu_ld=$with_gnu_ld # # Do we need to explicitly link libc? # case "x$archive_cmds_need_lc" in x|xyes) # Assume -lc should be added archive_cmds_need_lc=yes if test yes,yes = "$GCC,$enable_shared"; then case $archive_cmds in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 $as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } if ${lt_cv_archive_cmds_need_lc+:} false; then : $as_echo_n "(cached) " >&6 else $RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$lt_prog_compiler_wl pic_flag=$lt_prog_compiler_pic compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag allow_undefined_flag= if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then lt_cv_archive_cmds_need_lc=no else lt_cv_archive_cmds_need_lc=yes fi allow_undefined_flag=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 $as_echo "$lt_cv_archive_cmds_need_lc" >&6; } archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc ;; esac fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 $as_echo_n "checking dynamic linker characteristics... " >&6; } if test yes = "$GCC"; then case $host_os in darwin*) lt_awk_arg='/^libraries:/,/LR/' ;; *) lt_awk_arg='/^libraries:/' ;; esac case $host_os in mingw* | cegcc*) lt_sed_strip_eq='s|=\([A-Za-z]:\)|\1|g' ;; *) lt_sed_strip_eq='s|=/|/|g' ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary... lt_tmp_lt_search_path_spec= lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` # ...but if some path component already ends with the multilib dir we assume # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer). case "$lt_multi_os_dir; $lt_search_path_spec " in "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*) lt_multi_os_dir= ;; esac for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir" elif test -n "$lt_multi_os_dir"; then test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' BEGIN {RS = " "; FS = "/|\n";} { lt_foo = ""; lt_count = 0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo = "/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[lt_foo]++; } if (lt_freq[lt_foo] == 1) { print lt_foo; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's|/\([A-Za-z]:\)|\1|g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=.so postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='$libname$release$shared_ext$major' ;; aix[4-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes if test ia64 = "$host_cpu"; then # AIX 5 supports IA64 library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line '#! .'. This would cause the generated library to # depend on '.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # Using Import Files as archive members, it is possible to support # filename-based versioning of shared library archives on AIX. While # this would work for both with and without runtime linking, it will # prevent static linking of such archives. So we do filename-based # shared library versioning with .so extension only, which is used # when both runtime linking and shared linking is enabled. # Unfortunately, runtime linking may impact performance, so we do # not want this to be the default eventually. Also, we use the # versioned .so libs for executables only if there is the -brtl # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only. # To allow for filename-based versioning support, we need to create # libNAME.so.V as an archive file, containing: # *) an Import File, referring to the versioned filename of the # archive as well as the shared archive member, telling the # bitwidth (32 or 64) of that shared object, and providing the # list of exported symbols of that shared object, eventually # decorated with the 'weak' keyword # *) the shared object with the F_LOADONLY flag set, to really avoid # it being seen by the linker. # At run time we better use the real file rather than another symlink, # but for link time we create the symlink libNAME.so -> libNAME.so.V case $with_aix_soname,$aix_use_runtimelinking in # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. aix,yes) # traditional libtool dynamic_linker='AIX unversionable lib.so' # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' ;; aix,no) # traditional AIX only dynamic_linker='AIX lib.a(lib.so.V)' # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='$libname$release.a $libname.a' soname_spec='$libname$release$shared_ext$major' ;; svr4,*) # full svr4 only dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o)" library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' # We do not specify a path in Import Files, so LIBPATH fires. shlibpath_overrides_runpath=yes ;; *,yes) # both, prefer svr4 dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o), lib.a(lib.so.V)" library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' # unpreferred sharedlib libNAME.a needs extra handling postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"' postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"' # We do not specify a path in Import Files, so LIBPATH fires. shlibpath_overrides_runpath=yes ;; *,no) # both, prefer aix dynamic_linker="AIX lib.a(lib.so.V), lib.so.V($shared_archive_member_spec.o)" library_names_spec='$libname$release.a $libname.a' soname_spec='$libname$release$shared_ext$major' # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)' postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"' ;; esac shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='$libname$shared_ext' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[45]*) version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=.dll need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' library_names_spec='$libname.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec=$LIB if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='$libname$release$major$shared_ext $libname$shared_ext' soname_spec='$libname$release$major$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[23].*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[01]* | freebsdelf3.[01]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=no sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' if test 32 = "$HPUX_IA64_MODE"; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" sys_lib_dlsearch_path_spec=/usr/lib/hpux32 else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" sys_lib_dlsearch_path_spec=/usr/lib/hpux64 fi ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[3-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test yes = "$lt_cv_prog_gnu_ld"; then version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='$libname$release$shared_ext$major' library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff" sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; linux*android*) version_type=none # Android doesn't support versioned libraries. need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext' soname_spec='$libname$release$shared_ext' finish_cmds= shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes dynamic_linker='Android linker' # Don't embed -rpath directories since the linker doesn't support them. hardcode_libdir_flag_spec='-L$libdir' ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH if ${lt_cv_shlibpath_overrides_runpath+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : lt_cv_shlibpath_overrides_runpath=yes fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS libdir=$save_libdir fi shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Ideally, we could use ldconfig to report *all* directores which are # searched for libraries, however this is still not possible. Aside from not # being certain /sbin/ldconfig is available, command # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64, # even though it is searched at run-time. Try to do the best guess by # appending ld.so.conf contents (and includes) to the search path. if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd* | bitrig*) version_type=sunos sys_lib_dlsearch_path_spec=/usr/lib need_lib_prefix=no if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then need_version=no else need_version=yes fi library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; os2*) libname_spec='$name' version_type=windows shrext_cmds=.dll need_version=no need_lib_prefix=no # OS/2 can only load a DLL with a base name of 8 characters or less. soname_spec='`test -n "$os2dllname" && libname="$os2dllname"; v=$($ECHO $release$versuffix | tr -d .-); n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _); $ECHO $n$v`$shared_ext' library_names_spec='${libname}_dll.$libext' dynamic_linker='OS/2 ld.exe' shlibpath_var=BEGINLIBPATH sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec postinstall_cmds='base_file=`basename \$file`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='$libname$release$shared_ext$major' library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test yes = "$with_gnu_ld"; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec; then version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext' soname_spec='$libname$shared_ext.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=sco need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test yes = "$with_gnu_ld"; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' soname_spec='$libname$release$shared_ext$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 $as_echo "$dynamic_linker" >&6; } test no = "$dynamic_linker" && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test yes = "$GCC"; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec fi if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec fi # remember unaugmented sys_lib_dlsearch_path content for libtool script decls... configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec # ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH" # to be used as default LT_SYS_LIBRARY_PATH value in generated libtool configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 $as_echo_n "checking how to hardcode library paths into programs... " >&6; } hardcode_action= if test -n "$hardcode_libdir_flag_spec" || test -n "$runpath_var" || test yes = "$hardcode_automatic"; then # We can hardcode non-existent directories. if test no != "$hardcode_direct" && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, )" && test no != "$hardcode_minus_L"; then # Linking always hardcodes the temporary library directory. hardcode_action=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. hardcode_action=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. hardcode_action=unsupported fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 $as_echo "$hardcode_action" >&6; } if test relink = "$hardcode_action" || test yes = "$inherit_rpath"; then # Fast installation is not supported enable_fast_install=no elif test yes = "$shlibpath_overrides_runpath" || test no = "$enable_shared"; then # Fast installation is not necessary enable_fast_install=needless fi if test yes != "$enable_dlopen"; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen=load_add_on lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen=LoadLibrary lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen=dlopen lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $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 dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=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_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl else lt_cv_dlopen=dyld lt_cv_dlopen_libs= lt_cv_dlopen_self=yes fi ;; tpf*) # Don't try to run any link tests for TPF. We know it's impossible # because TPF is a cross-compiler, and we know how we open DSOs. lt_cv_dlopen=dlopen lt_cv_dlopen_libs= lt_cv_dlopen_self=no ;; *) ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" if test "x$ac_cv_func_shl_load" = xyes; then : lt_cv_dlopen=shl_load else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 $as_echo_n "checking for shl_load in -ldld... " >&6; } if ${ac_cv_lib_dld_shl_load+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $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 shl_load (); int main () { return shl_load (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_shl_load=yes else ac_cv_lib_dld_shl_load=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_dld_shl_load" >&5 $as_echo "$ac_cv_lib_dld_shl_load" >&6; } if test "x$ac_cv_lib_dld_shl_load" = xyes; then : lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld else ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" if test "x$ac_cv_func_dlopen" = xyes; then : lt_cv_dlopen=dlopen else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $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 dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=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_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 $as_echo_n "checking for dlopen in -lsvld... " >&6; } if ${ac_cv_lib_svld_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsvld $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 dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_svld_dlopen=yes else ac_cv_lib_svld_dlopen=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_svld_dlopen" >&5 $as_echo "$ac_cv_lib_svld_dlopen" >&6; } if test "x$ac_cv_lib_svld_dlopen" = xyes; then : lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 $as_echo_n "checking for dld_link in -ldld... " >&6; } if ${ac_cv_lib_dld_dld_link+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $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 dld_link (); int main () { return dld_link (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_dld_link=yes else ac_cv_lib_dld_dld_link=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_dld_dld_link" >&5 $as_echo "$ac_cv_lib_dld_dld_link" >&6; } if test "x$ac_cv_lib_dld_dld_link" = xyes; then : lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld fi fi fi fi fi fi ;; esac if test no = "$lt_cv_dlopen"; then enable_dlopen=no else enable_dlopen=yes fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS=$CPPFLAGS test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS=$LDFLAGS wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS=$LIBS LIBS="$lt_cv_dlopen_libs $LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 $as_echo_n "checking whether a program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self+:} false; then : $as_echo_n "(cached) " >&6 else if test yes = "$cross_compiling"; then : lt_cv_dlopen_self=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisibility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; esac else : # compilation failed lt_cv_dlopen_self=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 $as_echo "$lt_cv_dlopen_self" >&6; } if test yes = "$lt_cv_dlopen_self"; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 $as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self_static+:} false; then : $as_echo_n "(cached) " >&6 else if test yes = "$cross_compiling"; then : lt_cv_dlopen_self_static=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisibility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; esac else : # compilation failed lt_cv_dlopen_self_static=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 $as_echo "$lt_cv_dlopen_self_static" >&6; } fi CPPFLAGS=$save_CPPFLAGS LDFLAGS=$save_LDFLAGS LIBS=$save_LIBS ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi striplib= old_striplib= { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 $as_echo_n "checking whether stripping libraries is possible... " >&6; } if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP"; then striplib="$STRIP -x" old_striplib="$STRIP -S" { $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 ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ;; esac fi # Report what library types will actually be built { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 $as_echo_n "checking if libtool supports shared libraries... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 $as_echo "$can_build_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 $as_echo_n "checking whether to build shared libraries... " >&6; } test no = "$can_build_shared" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test yes = "$enable_shared" && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[4-9]*) if test ia64 != "$host_cpu"; then case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in yes,aix,yes) ;; # shared object as lib.so file only yes,svr4,*) ;; # shared object as lib.so archive member only yes,*) enable_static=no ;; # shared object in lib.a archive as well esac fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 $as_echo "$enable_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 $as_echo_n "checking whether to build static libraries... " >&6; } # Make sure either enable_shared or enable_static is yes. test yes = "$enable_shared" || enable_static=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 $as_echo "$enable_static" >&6; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu CC=$lt_save_CC ac_config_commands="$ac_config_commands libtool" # Only expand once: LT_DLLOADERS= ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu lt_dlload_save_LIBS=$LIBS LIBADD_DLOPEN= { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlopen" >&5 $as_echo_n "checking for library containing dlopen... " >&6; } if ${ac_cv_search_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$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 dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF for ac_lib in '' dl; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_dlopen=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_dlopen+:} false; then : break fi done if ${ac_cv_search_dlopen+:} false; then : else ac_cv_search_dlopen=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlopen" >&5 $as_echo "$ac_cv_search_dlopen" >&6; } ac_res=$ac_cv_search_dlopen if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" $as_echo "#define HAVE_LIBDL 1" >>confdefs.h if test "$ac_cv_search_dlopen" != "none required"; then LIBADD_DLOPEN=-ldl fi libltdl_cv_lib_dl_dlopen=yes LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}dlopen.la" else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if HAVE_DLFCN_H # include #endif int main () { dlopen(0, 0); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : $as_echo "#define HAVE_LIBDL 1" >>confdefs.h libltdl_cv_func_dlopen=yes LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}dlopen.la" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 $as_echo_n "checking for dlopen in -lsvld... " >&6; } if ${ac_cv_lib_svld_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsvld $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 dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_svld_dlopen=yes else ac_cv_lib_svld_dlopen=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_svld_dlopen" >&5 $as_echo "$ac_cv_lib_svld_dlopen" >&6; } if test "x$ac_cv_lib_svld_dlopen" = xyes; then : $as_echo "#define HAVE_LIBDL 1" >>confdefs.h LIBADD_DLOPEN=-lsvld libltdl_cv_func_dlopen=yes LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}dlopen.la" fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi if test yes = "$libltdl_cv_func_dlopen" || test yes = "$libltdl_cv_lib_dl_dlopen" then lt_save_LIBS=$LIBS LIBS="$LIBS $LIBADD_DLOPEN" for ac_func in dlerror do : ac_fn_c_check_func "$LINENO" "dlerror" "ac_cv_func_dlerror" if test "x$ac_cv_func_dlerror" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DLERROR 1 _ACEOF fi done LIBS=$lt_save_LIBS fi LIBADD_SHL_LOAD= ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" if test "x$ac_cv_func_shl_load" = xyes; then : $as_echo "#define HAVE_SHL_LOAD 1" >>confdefs.h LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}shl_load.la" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 $as_echo_n "checking for shl_load in -ldld... " >&6; } if ${ac_cv_lib_dld_shl_load+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $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 shl_load (); int main () { return shl_load (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_shl_load=yes else ac_cv_lib_dld_shl_load=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_dld_shl_load" >&5 $as_echo "$ac_cv_lib_dld_shl_load" >&6; } if test "x$ac_cv_lib_dld_shl_load" = xyes; then : $as_echo "#define HAVE_SHL_LOAD 1" >>confdefs.h LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}shl_load.la" LIBADD_SHL_LOAD=-ldld fi fi case $host_os in darwin[1567].*) # We only want this for pre-Mac OS X 10.4. ac_fn_c_check_func "$LINENO" "_dyld_func_lookup" "ac_cv_func__dyld_func_lookup" if test "x$ac_cv_func__dyld_func_lookup" = xyes; then : $as_echo "#define HAVE_DYLD 1" >>confdefs.h LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}dyld.la" fi ;; beos*) LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}load_add_on.la" ;; cygwin* | mingw* | pw32*) ac_fn_c_check_decl "$LINENO" "cygwin_conv_path" "ac_cv_have_decl_cygwin_conv_path" "#include " if test "x$ac_cv_have_decl_cygwin_conv_path" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_CYGWIN_CONV_PATH $ac_have_decl _ACEOF LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}loadlibrary.la" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 $as_echo_n "checking for dld_link in -ldld... " >&6; } if ${ac_cv_lib_dld_dld_link+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $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 dld_link (); int main () { return dld_link (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_dld_link=yes else ac_cv_lib_dld_dld_link=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_dld_dld_link" >&5 $as_echo "$ac_cv_lib_dld_dld_link" >&6; } if test "x$ac_cv_lib_dld_dld_link" = xyes; then : $as_echo "#define HAVE_DLD 1" >>confdefs.h LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}dld_link.la" fi LT_DLPREOPEN= if test -n "$LT_DLLOADERS" then for lt_loader in $LT_DLLOADERS; do LT_DLPREOPEN="$LT_DLPREOPEN-dlpreopen $lt_loader " done $as_echo "#define HAVE_LIBDLLOADER 1" >>confdefs.h fi LIBADD_DL="$LIBADD_DLOPEN $LIBADD_SHL_LOAD" LIBS=$lt_dlload_save_LIBS ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}windres", so it can be a program name with args. set dummy ${ac_tool_prefix}windres; 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_prog_RC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RC"; then ac_cv_prog_RC="$RC" # Let the user override the test. else 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_prog_RC="${ac_tool_prefix}windres" $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 fi fi RC=$ac_cv_prog_RC if test -n "$RC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RC" >&5 $as_echo "$RC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_RC"; then ac_ct_RC=$RC # Extract the first word of "windres", so it can be a program name with args. set dummy windres; 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_prog_ac_ct_RC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RC"; then ac_cv_prog_ac_ct_RC="$ac_ct_RC" # Let the user override the test. else 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_prog_ac_ct_RC="windres" $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 fi fi ac_ct_RC=$ac_cv_prog_ac_ct_RC if test -n "$ac_ct_RC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RC" >&5 $as_echo "$ac_ct_RC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_RC" = x; then RC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RC=$ac_ct_RC fi else RC="$ac_cv_prog_RC" fi # Source file extension for RC test sources. ac_ext=rc # Object file extension for compiled RC test sources. objext=o objext_RC=$objext # Code to be used in simple compile tests lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' # Code to be used in simple link tests lt_simple_link_test_code=$lt_simple_compile_test_code # ltmain only uses $CC for tagged configurations so make sure $CC is set. # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # save warnings/boilerplate of simple test code ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC= CC=${RC-"windres"} CFLAGS= compiler=$CC compiler_RC=$CC func_cc_basename $compiler cc_basename=$func_cc_basename_result lt_cv_prog_compiler_c_o_RC=yes if test -n "$compiler"; then : fi GCC=$lt_save_GCC ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS # Check whether --enable-libiconv was given. if test "${enable_libiconv+set}" = set; then : enableval=$enable_libiconv; use_libiconv=$enableval else use_libiconv=yes fi if test "$use_libiconv" = "yes" ; then if test "X$prefix" = "XNONE"; then acl_final_prefix="$ac_default_prefix" else acl_final_prefix="$prefix" fi if test "X$exec_prefix" = "XNONE"; then acl_final_exec_prefix='${prefix}' else acl_final_exec_prefix="$exec_prefix" fi acl_save_prefix="$prefix" prefix="$acl_final_prefix" eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" prefix="$acl_save_prefix" # Check whether --with-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then : withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes else with_gnu_ld=no fi # Prepare PATH_SEPARATOR. # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which # contains only /bin. Note that ksh looks also at the FPATH variable, # so we have to set that as well for the test. PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ || PATH_SEPARATOR=';' } fi ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 $as_echo_n "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | ?:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the pathname of ld ac_prog=`echo "$ac_prog"| sed 's%\\\\%/%g'` while echo "$ac_prog" | grep "$re_direlt" > /dev/null 2>&1; do ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 $as_echo_n "checking for GNU ld... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 $as_echo_n "checking for non-GNU ld... " >&6; } fi if ${acl_cv_path_LD+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$LD"; then acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$acl_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then acl_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$acl_cv_path_LD" -v 2>&1 &5 $as_echo "$LD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } if ${acl_cv_prog_gnu_ld+:} false; then : $as_echo_n "(cached) " >&6 else # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &5 $as_echo "$acl_cv_prog_gnu_ld" >&6; } with_gnu_ld=$acl_cv_prog_gnu_ld { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5 $as_echo_n "checking for shared library run path origin... " >&6; } if ${acl_cv_rpath+:} false; then : $as_echo_n "(cached) " >&6 else CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh . ./conftest.sh rm -f ./conftest.sh acl_cv_rpath=done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5 $as_echo "$acl_cv_rpath" >&6; } wl="$acl_cv_wl" acl_libext="$acl_cv_libext" acl_shlibext="$acl_cv_shlibext" acl_libname_spec="$acl_cv_libname_spec" acl_library_names_spec="$acl_cv_library_names_spec" acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" acl_hardcode_direct="$acl_cv_hardcode_direct" acl_hardcode_minus_L="$acl_cv_hardcode_minus_L" # Check whether --enable-rpath was given. if test "${enable_rpath+set}" = set; then : enableval=$enable_rpath; : else enable_rpath=yes fi acl_libdirstem=lib acl_libdirstem2= case "$host_os" in solaris*) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for 64-bit host" >&5 $as_echo_n "checking for 64-bit host... " >&6; } if ${gl_cv_solaris_64bit+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef _LP64 sixtyfour bits #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "sixtyfour bits" >/dev/null 2>&1; then : gl_cv_solaris_64bit=yes else gl_cv_solaris_64bit=no fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_solaris_64bit" >&5 $as_echo "$gl_cv_solaris_64bit" >&6; } if test $gl_cv_solaris_64bit = yes; then acl_libdirstem=lib/64 case "$host_cpu" in sparc*) acl_libdirstem2=lib/sparcv9 ;; i*86 | x86_64) acl_libdirstem2=lib/amd64 ;; esac fi ;; *) searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` if test -n "$searchpath"; then acl_save_IFS="${IFS= }"; IFS=":" for searchdir in $searchpath; do if test -d "$searchdir"; then case "$searchdir" in */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; */../ | */.. ) # Better ignore directories of this form. They are misleading. ;; *) searchdir=`cd "$searchdir" && pwd` case "$searchdir" in */lib64 ) acl_libdirstem=lib64 ;; esac ;; esac fi done IFS="$acl_save_IFS" fi ;; esac test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem" use_additional=yes acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" # Check whether --with-libiconv-prefix was given. if test "${with_libiconv_prefix+set}" = set; then : withval=$with_libiconv_prefix; if test "X$withval" = "Xno"; then use_additional=no else if test "X$withval" = "X"; then acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" else additional_includedir="$withval/include" additional_libdir="$withval/$acl_libdirstem" if test "$acl_libdirstem2" != "$acl_libdirstem" \ && ! test -d "$withval/$acl_libdirstem"; then additional_libdir="$withval/$acl_libdirstem2" fi fi fi fi LIBICONV= LTLIBICONV= INCICONV= LIBICONV_PREFIX= HAVE_LIBICONV= rpathdirs= ltrpathdirs= names_already_handled= names_next_round='iconv ' while test -n "$names_next_round"; do names_this_round="$names_next_round" names_next_round= for name in $names_this_round; do already_handled= for n in $names_already_handled; do if test "$n" = "$name"; then already_handled=yes break fi done if test -z "$already_handled"; then names_already_handled="$names_already_handled $name" uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'` eval value=\"\$HAVE_LIB$uppername\" if test -n "$value"; then if test "$value" = yes; then eval value=\"\$LIB$uppername\" test -z "$value" || LIBICONV="${LIBICONV}${LIBICONV:+ }$value" eval value=\"\$LTLIB$uppername\" test -z "$value" || LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }$value" else : fi else found_dir= found_la= found_so= found_a= eval libname=\"$acl_libname_spec\" # typically: libname=lib$name if test -n "$acl_shlibext"; then shrext=".$acl_shlibext" # typically: shrext=.so else shrext= fi if test $use_additional = yes; then dir="$additional_libdir" if test -n "$acl_shlibext"; then if test -f "$dir/$libname$shrext"; then found_dir="$dir" found_so="$dir/$libname$shrext" else if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then ver=`(cd "$dir" && \ for f in "$libname$shrext".*; do echo "$f"; done \ | sed -e "s,^$libname$shrext\\\\.,," \ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | sed 1q ) 2>/dev/null` if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then found_dir="$dir" found_so="$dir/$libname$shrext.$ver" fi else eval library_names=\"$acl_library_names_spec\" for f in $library_names; do if test -f "$dir/$f"; then found_dir="$dir" found_so="$dir/$f" break fi done fi fi fi if test "X$found_dir" = "X"; then if test -f "$dir/$libname.$acl_libext"; then found_dir="$dir" found_a="$dir/$libname.$acl_libext" fi fi if test "X$found_dir" != "X"; then if test -f "$dir/$libname.la"; then found_la="$dir/$libname.la" fi fi fi if test "X$found_dir" = "X"; then for x in $LDFLAGS $LTLIBICONV; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" case "$x" in -L*) dir=`echo "X$x" | sed -e 's/^X-L//'` if test -n "$acl_shlibext"; then if test -f "$dir/$libname$shrext"; then found_dir="$dir" found_so="$dir/$libname$shrext" else if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then ver=`(cd "$dir" && \ for f in "$libname$shrext".*; do echo "$f"; done \ | sed -e "s,^$libname$shrext\\\\.,," \ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | sed 1q ) 2>/dev/null` if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then found_dir="$dir" found_so="$dir/$libname$shrext.$ver" fi else eval library_names=\"$acl_library_names_spec\" for f in $library_names; do if test -f "$dir/$f"; then found_dir="$dir" found_so="$dir/$f" break fi done fi fi fi if test "X$found_dir" = "X"; then if test -f "$dir/$libname.$acl_libext"; then found_dir="$dir" found_a="$dir/$libname.$acl_libext" fi fi if test "X$found_dir" != "X"; then if test -f "$dir/$libname.la"; then found_la="$dir/$libname.la" fi fi ;; esac if test "X$found_dir" != "X"; then break fi done fi if test "X$found_dir" != "X"; then LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$found_dir -l$name" if test "X$found_so" != "X"; then if test "$enable_rpath" = no \ || test "X$found_dir" = "X/usr/$acl_libdirstem" \ || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" else haveit= for x in $ltrpathdirs; do if test "X$x" = "X$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then ltrpathdirs="$ltrpathdirs $found_dir" fi if test "$acl_hardcode_direct" = yes; then LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" else if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" haveit= for x in $rpathdirs; do if test "X$x" = "X$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then rpathdirs="$rpathdirs $found_dir" fi else haveit= for x in $LDFLAGS $LIBICONV; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-L$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then LIBICONV="${LIBICONV}${LIBICONV:+ }-L$found_dir" fi if test "$acl_hardcode_minus_L" != no; then LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" else LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name" fi fi fi fi else if test "X$found_a" != "X"; then LIBICONV="${LIBICONV}${LIBICONV:+ }$found_a" else LIBICONV="${LIBICONV}${LIBICONV:+ }-L$found_dir -l$name" fi fi additional_includedir= case "$found_dir" in */$acl_libdirstem | */$acl_libdirstem/) basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` if test "$name" = 'iconv'; then LIBICONV_PREFIX="$basedir" fi additional_includedir="$basedir/include" ;; */$acl_libdirstem2 | */$acl_libdirstem2/) basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'` if test "$name" = 'iconv'; then LIBICONV_PREFIX="$basedir" fi additional_includedir="$basedir/include" ;; esac if test "X$additional_includedir" != "X"; then if test "X$additional_includedir" != "X/usr/include"; then haveit= if test "X$additional_includedir" = "X/usr/local/include"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then for x in $CPPFLAGS $INCICONV; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-I$additional_includedir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_includedir"; then INCICONV="${INCICONV}${INCICONV:+ }-I$additional_includedir" fi fi fi fi fi if test -n "$found_la"; then save_libdir="$libdir" case "$found_la" in */* | *\\*) . "$found_la" ;; *) . "./$found_la" ;; esac libdir="$save_libdir" for dep in $dependency_libs; do case "$dep" in -L*) additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \ && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then haveit= if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \ || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then haveit= for x in $LDFLAGS $LIBICONV; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_libdir"; then LIBICONV="${LIBICONV}${LIBICONV:+ }-L$additional_libdir" fi fi haveit= for x in $LDFLAGS $LTLIBICONV; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_libdir"; then LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$additional_libdir" fi fi fi fi ;; -R*) dir=`echo "X$dep" | sed -e 's/^X-R//'` if test "$enable_rpath" != no; then haveit= for x in $rpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then rpathdirs="$rpathdirs $dir" fi haveit= for x in $ltrpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then ltrpathdirs="$ltrpathdirs $dir" fi fi ;; -l*) names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` ;; *.la) names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` ;; *) LIBICONV="${LIBICONV}${LIBICONV:+ }$dep" LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }$dep" ;; esac done fi else LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name" LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-l$name" fi fi fi done done if test "X$rpathdirs" != "X"; then if test -n "$acl_hardcode_libdir_separator"; then alldirs= for found_dir in $rpathdirs; do alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" done acl_save_libdir="$libdir" libdir="$alldirs" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIBICONV="${LIBICONV}${LIBICONV:+ }$flag" else for found_dir in $rpathdirs; do acl_save_libdir="$libdir" libdir="$found_dir" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIBICONV="${LIBICONV}${LIBICONV:+ }$flag" done fi fi if test "X$ltrpathdirs" != "X"; then for found_dir in $ltrpathdirs; do LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-R$found_dir" done fi am_save_CPPFLAGS="$CPPFLAGS" for element in $INCICONV; do haveit= for x in $CPPFLAGS; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X$element"; then haveit=yes break fi done if test -z "$haveit"; then CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element" fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv" >&5 $as_echo_n "checking for iconv... " >&6; } if ${am_cv_func_iconv+:} false; then : $as_echo_n "(cached) " >&6 else am_cv_func_iconv="no, consider installing GNU libiconv" am_cv_lib_iconv=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { iconv_t cd = iconv_open("",""); iconv(cd,NULL,NULL,NULL,NULL); iconv_close(cd); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : am_cv_func_iconv=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test "$am_cv_func_iconv" != yes; then am_save_LIBS="$LIBS" LIBS="$LIBS $LIBICONV" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { iconv_t cd = iconv_open("",""); iconv(cd,NULL,NULL,NULL,NULL); iconv_close(cd); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : am_cv_lib_iconv=yes am_cv_func_iconv=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS="$am_save_LIBS" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_func_iconv" >&5 $as_echo "$am_cv_func_iconv" >&6; } if test "$am_cv_func_iconv" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working iconv" >&5 $as_echo_n "checking for working iconv... " >&6; } if ${am_cv_func_iconv_works+:} false; then : $as_echo_n "(cached) " >&6 else am_save_LIBS="$LIBS" if test $am_cv_lib_iconv = yes; then LIBS="$LIBS $LIBICONV" fi am_cv_func_iconv_works=no for ac_iconv_const in '' 'const'; do if test "$cross_compiling" = yes; then : case "$host_os" in aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; *) am_cv_func_iconv_works="guessing yes" ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #ifndef ICONV_CONST # define ICONV_CONST $ac_iconv_const #endif int main () { int result = 0; /* Test against AIX 5.1 bug: Failures are not distinguishable from successful returns. */ { iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); if (cd_utf8_to_88591 != (iconv_t)(-1)) { static ICONV_CONST char input[] = "\342\202\254"; /* EURO SIGN */ char buf[10]; ICONV_CONST char *inptr = input; size_t inbytesleft = strlen (input); char *outptr = buf; size_t outbytesleft = sizeof (buf); size_t res = iconv (cd_utf8_to_88591, &inptr, &inbytesleft, &outptr, &outbytesleft); if (res == 0) result |= 1; iconv_close (cd_utf8_to_88591); } } /* Test against Solaris 10 bug: Failures are not distinguishable from successful returns. */ { iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646"); if (cd_ascii_to_88591 != (iconv_t)(-1)) { static ICONV_CONST char input[] = "\263"; char buf[10]; ICONV_CONST char *inptr = input; size_t inbytesleft = strlen (input); char *outptr = buf; size_t outbytesleft = sizeof (buf); size_t res = iconv (cd_ascii_to_88591, &inptr, &inbytesleft, &outptr, &outbytesleft); if (res == 0) result |= 2; iconv_close (cd_ascii_to_88591); } } /* Test against AIX 6.1..7.1 bug: Buffer overrun. */ { iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1"); if (cd_88591_to_utf8 != (iconv_t)(-1)) { static ICONV_CONST char input[] = "\304"; static char buf[2] = { (char)0xDE, (char)0xAD }; ICONV_CONST char *inptr = input; size_t inbytesleft = 1; char *outptr = buf; size_t outbytesleft = 1; size_t res = iconv (cd_88591_to_utf8, &inptr, &inbytesleft, &outptr, &outbytesleft); if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD) result |= 4; iconv_close (cd_88591_to_utf8); } } #if 0 /* This bug could be worked around by the caller. */ /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */ { iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591"); if (cd_88591_to_utf8 != (iconv_t)(-1)) { static ICONV_CONST char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; char buf[50]; ICONV_CONST char *inptr = input; size_t inbytesleft = strlen (input); char *outptr = buf; size_t outbytesleft = sizeof (buf); size_t res = iconv (cd_88591_to_utf8, &inptr, &inbytesleft, &outptr, &outbytesleft); if ((int)res > 0) result |= 8; iconv_close (cd_88591_to_utf8); } } #endif /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is provided. */ if (/* Try standardized names. */ iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1) /* Try IRIX, OSF/1 names. */ && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1) /* Try AIX names. */ && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1) /* Try HP-UX names. */ && iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) result |= 16; return result; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : am_cv_func_iconv_works=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi test "$am_cv_func_iconv_works" = no || break done LIBS="$am_save_LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_func_iconv_works" >&5 $as_echo "$am_cv_func_iconv_works" >&6; } case "$am_cv_func_iconv_works" in *no) am_func_iconv=no am_cv_lib_iconv=no ;; *) am_func_iconv=yes ;; esac else am_func_iconv=no am_cv_lib_iconv=no fi if test "$am_func_iconv" = yes; then $as_echo "#define HAVE_ICONV 1" >>confdefs.h fi if test "$am_cv_lib_iconv" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libiconv" >&5 $as_echo_n "checking how to link with libiconv... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBICONV" >&5 $as_echo "$LIBICONV" >&6; } else CPPFLAGS="$am_save_CPPFLAGS" LIBICONV= LTLIBICONV= fi if test "$am_cv_func_iconv" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv declaration" >&5 $as_echo_n "checking for iconv declaration... " >&6; } if ${am_cv_proto_iconv+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include extern #ifdef __cplusplus "C" #endif #if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); #else size_t iconv(); #endif int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : am_cv_proto_iconv_arg1="" else am_cv_proto_iconv_arg1="const" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);" fi am_cv_proto_iconv=`echo "$am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_proto_iconv" >&5 $as_echo " $am_cv_proto_iconv" >&6; } cat >>confdefs.h <<_ACEOF #define ICONV_CONST $am_cv_proto_iconv_arg1 _ACEOF fi else { $as_echo "$as_me:${as_lineno-$LINENO}: libiconv disabled" >&5 $as_echo "$as_me: libiconv disabled" >&6;} cat >>confdefs.h <<_ACEOF #define ICONV_CONST const _ACEOF fi # See if we have doxygen installed # Extract the first word of "doxygen", so it can be a program name with args. set dummy doxygen; 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_prog_DOXYGEN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DOXYGEN"; then ac_cv_prog_DOXYGEN="$DOXYGEN" # Let the user override the test. else 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_prog_DOXYGEN="doxygen" $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 fi fi DOXYGEN=$ac_cv_prog_DOXYGEN if test -n "$DOXYGEN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DOXYGEN" >&5 $as_echo "$DOXYGEN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test -n "$DOXYGEN"; then HAVE_DOXYGEN_TRUE= HAVE_DOXYGEN_FALSE='#' else HAVE_DOXYGEN_TRUE='#' HAVE_DOXYGEN_FALSE= fi # Extract the first word of "odbc_config", so it can be a program name with args. set dummy odbc_config; 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_prog_ODBC_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ODBC_CONFIG"; then ac_cv_prog_ODBC_CONFIG="$ODBC_CONFIG" # Let the user override the test. else 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_prog_ODBC_CONFIG="odbc_config" $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 fi fi ODBC_CONFIG=$ac_cv_prog_ODBC_CONFIG if test -n "$ODBC_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ODBC_CONFIG" >&5 $as_echo "$ODBC_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi # ------------------------------------------------------------ # Check for CVS-only sources. # ------------------------------------------------------------ # # Distribution tarballs include some generated files. These # files are not maintained in CVS, but their bases are, and # the bases are not in the tarball. For example, num_limits.h # is distributed, but it is generated from numeric.pl, which # is kept in CVS. # If the base is found, we use it as a source in the Makefile, # otherwise the Makefile will (correctly) assume that the # generated file is already present. # if test -f "${srcdir}/src/tds/num_limits.pl"; then if true; then HAVE_PERL_SOURCES_TRUE= HAVE_PERL_SOURCES_FALSE='#' else HAVE_PERL_SOURCES_TRUE='#' HAVE_PERL_SOURCES_FALSE= fi else if false; then HAVE_PERL_SOURCES_TRUE= HAVE_PERL_SOURCES_FALSE='#' else HAVE_PERL_SOURCES_TRUE='#' HAVE_PERL_SOURCES_FALSE= fi fi # ------------------------------------------------------------ # Checks for libraries. # ------------------------------------------------------------ # Check whether --enable-krb5 was given. if test "${enable_krb5+set}" = set; then : enableval=$enable_krb5; fi krb5_libs=auto case $enable_krb5 in yes) ;; "" | no) krb5_libs= ;; -* | */* | *.a | *.so | *.so.* | *.o) krb5_libs="$enable_krb5" ;; *) krb5_libs="-l$enable_krb5" ;; esac LIBS_168="$LIBS" LIBS="" tds_mingw=no case $host in *-*-mingw*) tds_mingw=yes if test "$host_cpu" = "x86_64"; then LIBS="-lws2_32" elif test -r /usr/lib/w32api/libws2_32.a; then LIBS="-L/usr/lib/w32api -lws2_32" else LIBS="-lws2_32" fi krb5_libs= if true; then MINGW32_TRUE= MINGW32_FALSE='#' else MINGW32_TRUE='#' MINGW32_FALSE= fi ;; *-*-hpux*) # these lines are needed to fix a problem for HP-UX # HP-UX define two versions of sockets, one BSD and one X/Open # these versions are not binary compatible (BSD use int where X/Open # use socklen_t == size_t) and different libraries (BSD in libc and # X/Open in libxnet). X/Open is used if _XOPEN_SOURCE and # _XOPEN_SOURCE_EXTENDED are defined. To complicate the things gcc # by default define _XOPEN_SOURCE_EXTENDED so define always both # constants and link always libxnet! CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED" LIBS="$LIBS -lxnet" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostbyname" >&5 $as_echo_n "checking for library containing gethostbyname... " >&6; } if ${ac_cv_search_gethostbyname+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$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 gethostbyname (); int main () { return gethostbyname (); ; return 0; } _ACEOF for ac_lib in '' nsl; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_gethostbyname=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_gethostbyname+:} false; then : break fi done if ${ac_cv_search_gethostbyname+:} false; then : else ac_cv_search_gethostbyname=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_gethostbyname" >&5 $as_echo "$ac_cv_search_gethostbyname" >&6; } ac_res=$ac_cv_search_gethostbyname if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi # check for _xpg_ functions for ac_func in _xpg_accept _xpg_getpeername _xpg_getsockname _xpg_getsockopt _xpg_recvfrom \ __accept __getpeername __getsockname __getsockopt __recvfrom do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done if false; then MINGW32_TRUE= MINGW32_FALSE='#' else MINGW32_TRUE='#' MINGW32_FALSE= fi ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing socket" >&5 $as_echo_n "checking for library containing socket... " >&6; } if ${ac_cv_search_socket+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$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 socket (); int main () { return socket (); ; return 0; } _ACEOF for ac_lib in '' socket; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_socket=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_socket+:} false; then : break fi done if ${ac_cv_search_socket+:} false; then : else ac_cv_search_socket=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_socket" >&5 $as_echo "$ac_cv_search_socket" >&6; } ac_res=$ac_cv_search_socket if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostbyname" >&5 $as_echo_n "checking for library containing gethostbyname... " >&6; } if ${ac_cv_search_gethostbyname+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$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 gethostbyname (); int main () { return gethostbyname (); ; return 0; } _ACEOF for ac_lib in '' nsl; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_gethostbyname=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_gethostbyname+:} false; then : break fi done if ${ac_cv_search_gethostbyname+:} false; then : else ac_cv_search_gethostbyname=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_gethostbyname" >&5 $as_echo "$ac_cv_search_gethostbyname" >&6; } ac_res=$ac_cv_search_gethostbyname if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi if false; then MINGW32_TRUE= MINGW32_FALSE='#' else MINGW32_TRUE='#' MINGW32_FALSE= fi ;; esac case "$krb5_libs" in "" ) ;; "auto") { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gss_init_sec_context" >&5 $as_echo_n "checking for library containing gss_init_sec_context... " >&6; } if ${ac_cv_search_gss_init_sec_context+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$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 gss_init_sec_context (); int main () { return gss_init_sec_context (); ; return 0; } _ACEOF for ac_lib in '' gssapi_krb5 gssapi; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_gss_init_sec_context=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_gss_init_sec_context+:} false; then : break fi done if ${ac_cv_search_gss_init_sec_context+:} false; then : else ac_cv_search_gss_init_sec_context=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_gss_init_sec_context" >&5 $as_echo "$ac_cv_search_gss_init_sec_context" >&6; } ac_res=$ac_cv_search_gss_init_sec_context if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi if test "$ac_cv_search_gss_init_sec_context" != no; then $as_echo "#define ENABLE_KRB5 1" >>confdefs.h fi ;; *) $as_echo "#define ENABLE_KRB5 1" >>confdefs.h LIBS="$LIBS $krb5_libs" ;; esac if test -n "$krb5_libs"; then for d in /usr/include/heimdal /usr/include/krb5 /usr/include/et; do if test -d "$d"; then CPPFLAGS="$CPPFLAGS -I$d" fi done for ac_func in error_message do : ac_fn_c_check_func "$LINENO" "error_message" "ac_cv_func_error_message" if test "x$ac_cv_func_error_message" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_ERROR_MESSAGE 1 _ACEOF fi done fi NETWORK_LIBS="$LIBS" LIBS="$LIBS_168" unset LIBS_168 if test $tds_mingw = no; then # readline test # Readline is needed by the tty session. Set up a special READLINE_LIBS # substitution for it. # Readline is linked with curses, and on some systems termcap must be # linked in. Others (inc debian) have termcap built into ncurses. LIBS_242="$LIBS" LIBS="" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing tgetent" >&5 $as_echo_n "checking for library containing tgetent... " >&6; } if ${ac_cv_search_tgetent+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$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 tgetent (); int main () { return tgetent (); ; return 0; } _ACEOF for ac_lib in '' readline ncurses curses termcap; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_tgetent=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_tgetent+:} false; then : break fi done if ${ac_cv_search_tgetent+:} false; then : else ac_cv_search_tgetent=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_tgetent" >&5 $as_echo "$ac_cv_search_tgetent" >&6; } ac_res=$ac_cv_search_tgetent if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for readline in -lreadline" >&5 $as_echo_n "checking for readline in -lreadline... " >&6; } if ${ac_cv_lib_readline_readline+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lreadline $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 readline (); int main () { return readline (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_readline_readline=yes else ac_cv_lib_readline_readline=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_readline_readline" >&5 $as_echo "$ac_cv_lib_readline_readline" >&6; } if test "x$ac_cv_lib_readline_readline" = xyes; then : LIBS="$LIBS -lreadline" $as_echo "#define HAVE_READLINE 1" >>confdefs.h else LIBS="" fi for ac_func in rl_on_new_line rl_reset_line_state do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef HAVE_STDLIB_H #include #endif #ifdef HAVE_READLINE #include #include #endif /* HAVE_READLINE */ int main() { rl_inhibit_completion = 1; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : $as_echo "#define HAVE_RL_INHIBIT_COMPLETION 1" >>confdefs.h fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext READLINE_LIBS="$LIBS" LIBS="$LIBS_242" unset LIBS_242 ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu acx_pthread_ok=no # We used to check for pthread.h first, but this fails if pthread.h # requires special compiler flags (e.g. on True64 or Sequent). # It gets checked for in the link test anyway. # First of all, check if the user has set any of the PTHREAD_LIBS, # etcetera environment variables, and if threads linking works using # them: if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS" >&5 $as_echo_n "checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS... " >&6; } 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 pthread_join (); int main () { return pthread_join (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : acx_pthread_ok=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_pthread_ok" >&5 $as_echo "$acx_pthread_ok" >&6; } if test x"$acx_pthread_ok" = xno; then PTHREAD_LIBS="" PTHREAD_CFLAGS="" fi LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" fi # We must check for the threads library under a number of different # names; the ordering is very important because some systems # (e.g. DEC) have both -lpthread and -lpthreads, where one of the # libraries is broken (non-POSIX). # Create a list of thread flags to try. Items starting with a "-" are # C compiler flags, and other items are library names, except for "none" # which indicates that we try without any flags at all, and "pthread-config" # which is a program returning the flags for the Pth emulation library. acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" # The ordering *is* (sometimes) important. Some notes on the # individual items follow: # pthreads: AIX (must check this before -lpthread) # none: in case threads are in libc; should be tried before -Kthread and # other compiler flags to prevent continual compiler warnings # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) # -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) # -pthreads: Solaris/gcc # -mthreads: Mingw32/gcc, Lynx/gcc # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it # doesn't hurt to check since this sometimes defines pthreads too; # also defines -D_REENTRANT) # ... -mt is also the pthreads flag for HP/aCC # pthread: Linux, etcetera # --thread-safe: KAI C++ # pthread-config: use pthread-config program (for GNU Pth library) case "${host_cpu}-${host_os}" in *solaris*) # On Solaris (at least, for some versions), libc contains stubbed # (non-functional) versions of the pthreads routines, so link-based # tests will erroneously succeed. (We need to link with -pthreads/-mt/ # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather # a function called by this macro, so we could check for that, but # who knows whether they'll stub that too in a future libc.) So, # we'll just look for -pthreads and -lpthread first: acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags" ;; # The HP-UX compiler just warns about options it does not understand # but it needs -mt. *-hpux*) acx_pthread_flags="-mt $acx_pthread_flags" ;; esac if test x"$acx_pthread_ok" = xno; then for flag in $acx_pthread_flags; do case $flag in none) { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads work without any flags" >&5 $as_echo_n "checking whether pthreads work without any flags... " >&6; } ;; -*) { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads work with $flag" >&5 $as_echo_n "checking whether pthreads work with $flag... " >&6; } PTHREAD_CFLAGS="$flag" ;; pthread-config) # Extract the first word of "pthread-config", so it can be a program name with args. set dummy pthread-config; 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_prog_acx_pthread_config+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$acx_pthread_config"; then ac_cv_prog_acx_pthread_config="$acx_pthread_config" # Let the user override the test. else 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_prog_acx_pthread_config="yes" $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 test -z "$ac_cv_prog_acx_pthread_config" && ac_cv_prog_acx_pthread_config="no" fi fi acx_pthread_config=$ac_cv_prog_acx_pthread_config if test -n "$acx_pthread_config"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_pthread_config" >&5 $as_echo "$acx_pthread_config" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test x"$acx_pthread_config" = xno; then continue; fi PTHREAD_CFLAGS="`pthread-config --cflags`" PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the pthreads library -l$flag" >&5 $as_echo_n "checking for the pthreads library -l$flag... " >&6; } PTHREAD_LIBS="-l$flag" ;; esac save_LIBS="$LIBS" save_CFLAGS="$CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # Check for various functions. We must include pthread.h, # since some functions may be macros. (On the Sequent, we # need a special flag -Kthread to make this header compile.) # We check for pthread_join because it is in -lpthread on IRIX # while pthread_create is in libc. We check for pthread_attr_init # due to DEC craziness with -lpthreads. We check for # pthread_cleanup_push because it is one of the few pthread # functions on Solaris that doesn't have a non-functional libc stub. # We try pthread_create on general principles. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { pthread_t th; pthread_join(th, 0); pthread_attr_init(0); pthread_cleanup_push(0, 0); pthread_create(0,0,0,0); pthread_cleanup_pop(0); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : acx_pthread_ok=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_pthread_ok" >&5 $as_echo "$acx_pthread_ok" >&6; } if test "x$acx_pthread_ok" = xyes; then break; fi PTHREAD_LIBS="" PTHREAD_CFLAGS="" done fi # Various other checks: if test "x$acx_pthread_ok" = xyes; then save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for joinable pthread attribute" >&5 $as_echo_n "checking for joinable pthread attribute... " >&6; } attr_name=unknown for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { int attr=$attr; return attr; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : attr_name=$attr; break fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext done { $as_echo "$as_me:${as_lineno-$LINENO}: result: $attr_name" >&5 $as_echo "$attr_name" >&6; } if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then cat >>confdefs.h <<_ACEOF #define PTHREAD_CREATE_JOINABLE $attr_name _ACEOF fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if more special flags are required for pthreads" >&5 $as_echo_n "checking if more special flags are required for pthreads... " >&6; } flag=no case "${host_cpu}-${host_os}" in *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";; *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${flag}" >&5 $as_echo "${flag}" >&6; } if test "x$flag" != xno; then PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" fi LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" # More AIX lossage: must compile with xlc_r or cc_r if test x"$GCC" != xyes; then for ac_prog in xlc_r cc_r 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_prog_PTHREAD_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$PTHREAD_CC"; then ac_cv_prog_PTHREAD_CC="$PTHREAD_CC" # Let the user override the test. else 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_prog_PTHREAD_CC="$ac_prog" $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 fi fi PTHREAD_CC=$ac_cv_prog_PTHREAD_CC if test -n "$PTHREAD_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PTHREAD_CC" >&5 $as_echo "$PTHREAD_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$PTHREAD_CC" && break done test -n "$PTHREAD_CC" || PTHREAD_CC="${CC}" else PTHREAD_CC=$CC fi else PTHREAD_CC="$CC" fi # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: if test x"$acx_pthread_ok" = xyes; then $as_echo "#define HAVE_PTHREAD 1" >>confdefs.h : else acx_pthread_ok=no fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu AM_CFLAGS="$AM_CFLAGS $PTHREAD_CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing pthread_condattr_setclock" >&5 $as_echo_n "checking for library containing pthread_condattr_setclock... " >&6; } if ${ac_cv_search_pthread_condattr_setclock+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$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 pthread_condattr_setclock (); int main () { return pthread_condattr_setclock (); ; return 0; } _ACEOF for ac_lib in '' rt posix4 pthread; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_pthread_condattr_setclock=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_pthread_condattr_setclock+:} false; then : break fi done if ${ac_cv_search_pthread_condattr_setclock+:} false; then : else ac_cv_search_pthread_condattr_setclock=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_pthread_condattr_setclock" >&5 $as_echo "$ac_cv_search_pthread_condattr_setclock" >&6; } ac_res=$ac_cv_search_pthread_condattr_setclock if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi for ac_func in pthread_condattr_setclock pthread_cond_timedwait_relative_np do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done fi # check for SSPI # Check whether --enable-sspi was given. if test "${enable_sspi+set}" = set; then : enableval=$enable_sspi; fi # disable by default enable_sspi=${enable_sspi-yes} # only if MingW (TODO other compilers) test $tds_mingw != yes && enable_sspi=no if test "$enable_sspi" = "yes"; then HAVE_SSPI_TRUE= HAVE_SSPI_FALSE='#' else HAVE_SSPI_TRUE='#' HAVE_SSPI_FALSE= fi if test "$enable_sspi" = "yes"; then $as_echo "#define HAVE_SSPI 1" >>confdefs.h fi # ------------------------------------------------------------ # Checks for header files. # ------------------------------------------------------------ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 $as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } if ${ac_cv_header_time+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main () { if ((struct tm *) 0) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_time=yes else ac_cv_header_time=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 $as_echo "$ac_cv_header_time" >&6; } if test $ac_cv_header_time = yes; then $as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether struct tm is in sys/time.h or time.h" >&5 $as_echo_n "checking whether struct tm is in sys/time.h or time.h... " >&6; } if ${ac_cv_struct_tm+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { struct tm tm; int *p = &tm.tm_sec; return !p; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_struct_tm=time.h else ac_cv_struct_tm=sys/time.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_tm" >&5 $as_echo "$ac_cv_struct_tm" >&6; } if test $ac_cv_struct_tm = sys/time.h; then $as_echo "#define TM_IN_SYS_TIME 1" >>confdefs.h fi ac_fn_c_check_member "$LINENO" "struct tm" "tm_zone" "ac_cv_member_struct_tm_tm_zone" "#include #include <$ac_cv_struct_tm> " if test "x$ac_cv_member_struct_tm_tm_zone" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRUCT_TM_TM_ZONE 1 _ACEOF fi if test "$ac_cv_member_struct_tm_tm_zone" = yes; then $as_echo "#define HAVE_TM_ZONE 1" >>confdefs.h else ac_fn_c_check_decl "$LINENO" "tzname" "ac_cv_have_decl_tzname" "#include " if test "x$ac_cv_have_decl_tzname" = xyes; then : ac_have_decl=1 else ac_have_decl=0 fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_TZNAME $ac_have_decl _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking for tzname" >&5 $as_echo_n "checking for tzname... " >&6; } if ${ac_cv_var_tzname+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #if !HAVE_DECL_TZNAME extern char *tzname[]; #endif int main () { return tzname[0][0]; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_var_tzname=yes else ac_cv_var_tzname=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_tzname" >&5 $as_echo "$ac_cv_var_tzname" >&6; } if test $ac_cv_var_tzname = yes; then $as_echo "#define HAVE_TZNAME 1" >>confdefs.h fi fi ac_fn_c_check_member "$LINENO" "struct tm" "__tm_zone" "ac_cv_member_struct_tm___tm_zone" "#include #include <$ac_cv_struct_tm> " if test "x$ac_cv_member_struct_tm___tm_zone" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRUCT_TM___TM_ZONE 1 _ACEOF fi for ac_header in errno.h libgen.h \ limits.h locale.h poll.h \ signal.h stddef.h \ sys/param.h sys/select.h sys/stat.h \ sys/time.h sys/types.h sys/resource.h \ sys/eventfd.h \ sys/wait.h unistd.h netdb.h \ wchar.h inttypes.h winsock2.h \ localcharset.h valgrind/memcheck.h malloc.h dirent.h \ stdbool.h gnutls/abstract.h getopt.h fcntl.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in windows.h sql.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "#ifdef HAVE_WINDOWS_H # include #endif #ifdef HAVE_SQL_H # include #endif " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done if test $tds_mingw = no; then for ac_header in arpa/inet.h \ langinfo.h \ netdb.h \ netinet/in.h \ netinet/tcp.h \ roken.h \ com_err.h \ paths.h \ sys/ioctl.h \ sys/socket.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether INADDR_NONE is defined" >&5 $as_echo_n "checking whether INADDR_NONE is defined... " >&6; } if ${ac_cv_have_inaddr_none+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* our includes */ #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NETINET_IN_H #include #endif #ifdef HAVE_ARPA_INET_H #include #endif /* end includes */ int main () { unsigned long foo = INADDR_NONE; /* our test code */ ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_have_inaddr_none=yes else ac_cv_have_inaddr_none=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_have_inaddr_none" >&5 $as_echo "$ac_cv_have_inaddr_none" >&6; } if test $ac_cv_have_inaddr_none != yes; then $as_echo "#define INADDR_NONE 0xffffffff" >>confdefs.h fi # ------------------------------------------------------------ # Checks for integers/floats of different sizes # ------------------------------------------------------------ # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of char" >&5 $as_echo_n "checking size of char... " >&6; } if ${ac_cv_sizeof_char+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (char))" "ac_cv_sizeof_char" "$ac_includes_default"; then : else if test "$ac_cv_type_char" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (char) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_char=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_char" >&5 $as_echo "$ac_cv_sizeof_char" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_CHAR $ac_cv_sizeof_char _ACEOF # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of short" >&5 $as_echo_n "checking size of short... " >&6; } if ${ac_cv_sizeof_short+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (short))" "ac_cv_sizeof_short" "$ac_includes_default"; then : else if test "$ac_cv_type_short" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (short) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_short=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_short" >&5 $as_echo "$ac_cv_sizeof_short" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_SHORT $ac_cv_sizeof_short _ACEOF # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long" >&5 $as_echo_n "checking size of long... " >&6; } if ${ac_cv_sizeof_long+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long))" "ac_cv_sizeof_long" "$ac_includes_default"; then : else if test "$ac_cv_type_long" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (long) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_long=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long" >&5 $as_echo "$ac_cv_sizeof_long" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_LONG $ac_cv_sizeof_long _ACEOF # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int" >&5 $as_echo_n "checking size of int... " >&6; } if ${ac_cv_sizeof_int+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int))" "ac_cv_sizeof_int" "$ac_includes_default"; then : else if test "$ac_cv_type_int" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (int) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_int=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_int" >&5 $as_echo "$ac_cv_sizeof_int" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_INT $ac_cv_sizeof_int _ACEOF # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of float" >&5 $as_echo_n "checking size of float... " >&6; } if ${ac_cv_sizeof_float+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (float))" "ac_cv_sizeof_float" "$ac_includes_default"; then : else if test "$ac_cv_type_float" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (float) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_float=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_float" >&5 $as_echo "$ac_cv_sizeof_float" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_FLOAT $ac_cv_sizeof_float _ACEOF # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of double" >&5 $as_echo_n "checking size of double... " >&6; } if ${ac_cv_sizeof_double+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (double))" "ac_cv_sizeof_double" "$ac_includes_default"; then : else if test "$ac_cv_type_double" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (double) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_double=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_double" >&5 $as_echo "$ac_cv_sizeof_double" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_DOUBLE $ac_cv_sizeof_double _ACEOF # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long double" >&5 $as_echo_n "checking size of long double... " >&6; } if ${ac_cv_sizeof_long_double+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long double))" "ac_cv_sizeof_long_double" "$ac_includes_default"; then : else if test "$ac_cv_type_long_double" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (long double) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_long_double=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long_double" >&5 $as_echo "$ac_cv_sizeof_long_double" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_LONG_DOUBLE $ac_cv_sizeof_long_double _ACEOF # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long long" >&5 $as_echo_n "checking size of long long... " >&6; } if ${ac_cv_sizeof_long_long+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long long))" "ac_cv_sizeof_long_long" "$ac_includes_default"; then : else if test "$ac_cv_type_long_long" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (long long) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_long_long=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long_long" >&5 $as_echo "$ac_cv_sizeof_long_long" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long _ACEOF # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of __int64" >&5 $as_echo_n "checking size of __int64... " >&6; } if ${ac_cv_sizeof___int64+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (__int64))" "ac_cv_sizeof___int64" "$ac_includes_default"; then : else if test "$ac_cv_type___int64" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (__int64) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof___int64=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof___int64" >&5 $as_echo "$ac_cv_sizeof___int64" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF___INT64 $ac_cv_sizeof___int64 _ACEOF # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of void *" >&5 $as_echo_n "checking size of void *... " >&6; } if ${ac_cv_sizeof_void_p+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (void *))" "ac_cv_sizeof_void_p" "$ac_includes_default"; then : else if test "$ac_cv_type_void_p" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (void *) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_void_p=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_void_p" >&5 $as_echo "$ac_cv_sizeof_void_p" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_VOID_P $ac_cv_sizeof_void_p _ACEOF # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of wchar_t" >&5 $as_echo_n "checking size of wchar_t... " >&6; } if ${ac_cv_sizeof_wchar_t+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (wchar_t))" "ac_cv_sizeof_wchar_t" "$ac_includes_default #ifdef HAVE_WCHAR_H #include #endif "; then : else if test "$ac_cv_type_wchar_t" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (wchar_t) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_wchar_t=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_wchar_t" >&5 $as_echo "$ac_cv_sizeof_wchar_t" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_WCHAR_T $ac_cv_sizeof_wchar_t _ACEOF case 2 in $ac_cv_sizeof_short) tds_sysdep_int16_type=short;; $ac_cv_sizeof_int) tds_sysdep_int16_type=int;; *) as_fn_error $? "No 16-bit int found." "$LINENO" 5 esac case 4 in $ac_cv_sizeof_short) tds_sysdep_int32_type=short;; $ac_cv_sizeof_int) tds_sysdep_int32_type=int;; $ac_cv_sizeof_long) tds_sysdep_int32_type=long;; *) as_fn_error $? "No 32-bit int found." "$LINENO" 5 esac case 4 in $ac_cv_sizeof_float) tds_sysdep_real32_type=float;; $ac_cv_sizeof_double) tds_sysdep_real32_type=double;; $ac_cv_sizeof_long_double) tds_sysdep_real32_type="long double";; *) as_fn_error $? "No 32-bit real found." "$LINENO" 5 esac case 8 in $ac_cv_sizeof_float) tds_sysdep_real64_type=float;; $ac_cv_sizeof_double) tds_sysdep_real64_type=double;; $ac_cv_sizeof_long_double) tds_sysdep_real64_type="long double";; *) as_fn_error $? "No 64-bit real found." "$LINENO" 5 esac case 8 in $ac_cv_sizeof_long) tds_sysdep_int64_type=long;; $ac_cv_sizeof_long_long) tds_sysdep_int64_type="long long";; $ac_cv_sizeof___int64) tds_sysdep_int64_type=__int64;; *) as_fn_error $? "No 64-bit integer found." "$LINENO" 5 esac tds_i64_format= # Win32 case cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if !defined(__MINGW32__) || !defined(__MSVCRT__) this should produce an error! #endif int main () { return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : tds_i64_format="I64" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # long is 64 bit if test "x$ac_cv_sizeof_long" = "x8"; then tds_i64_format=l fi # long long support if test "x$tds_i64_format" = "x"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #if !defined(__GLIBC__) || __GLIBC__ < 2 || !defined(__GLIBC_MINOR__) || __GLIBC_MINOR__ < 2 # if !defined(__APPLE__) # error no proper glibc or darwin system # endif #endif int main() { char buf[64]; long long ll = atoll(buf); return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : tds_i64_format="ll" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi # extract from inttypes.h if test "x$tds_i64_format" = "x"; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include char test_fmt[] = "Start PRId64:" PRId64 ":End PRId64"; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : for arg in l ll I64 L; do if grep "Start PRId64:${arg}d:End PRId64" conftest.$ac_objext >/dev/null ; then tds_i64_format=$arg fi done fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test "x$tds_i64_format" = "x"; then for arg in l ll I64 L; do if test "$cross_compiling" = yes; then : { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run test program while cross compiling See \`config.log' for more details" "$LINENO" 5; } else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main() { char buf[20]; $tds_sysdep_int64_type ll = ((($tds_sysdep_int64_type) 0x12345) << 32) + 0x6789abcd; sprintf(buf, "%${arg}d", ll); return strcmp(buf, "320255973501901") != 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : tds_i64_format="$arg"; break fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi done fi if test "x$tds_i64_format" != "x"; then cat >>confdefs.h <<_ACEOF #define TDS_I64_PREFIX "$tds_i64_format" _ACEOF fi case $ac_cv_sizeof_void_p in $ac_cv_sizeof_short) tds_sysdep_intptr_type=short;; $ac_cv_sizeof_int) tds_sysdep_intptr_type=int;; $ac_cv_sizeof_long) tds_sysdep_intptr_type=long;; $ac_cv_sizeof_long_long) tds_sysdep_intptr_type="long long";; $ac_cv_sizeof___int64) tds_sysdep_intptr_type=__int64;; *) as_fn_error $? "No intptr type found." "$LINENO" 5 esac # ------------------------------------------------------------ # Checks for typedefs and structures # ------------------------------------------------------------ # ---- Solaris needs -DBSD_COMP to get FIONBIO defined ---- { $as_echo "$as_me:${as_lineno-$LINENO}: checking is FIONBIO defined" >&5 $as_echo_n "checking is FIONBIO defined... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef FIONBIO yes #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "yes" >/dev/null 2>&1; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define BSD_COMP #include #ifdef FIONBIO yes #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "yes" >/dev/null 2>&1; then : $as_echo "#define BSD_COMP 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: need -DBSD_COMP" >&5 $as_echo "need -DBSD_COMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f conftest* fi rm -f conftest* ac_fn_c_check_type "$LINENO" "socklen_t" "ac_cv_type_socklen_t" "#include #ifdef HAVE_SYS_SOCKET_H # include #endif #ifdef HAVE_WINSOCK2_H # include # include #endif " if test "x$ac_cv_type_socklen_t" = xyes; then : else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for socklen_t equivalent" >&5 $as_echo_n "checking for socklen_t equivalent... " >&6; } if ${xml_cv_socklen_t_equiv+:} false; then : $as_echo_n "(cached) " >&6 else # Systems have either "struct sockaddr *" or # "void *" as the second argument to getpeername xml_cv_socklen_t_equiv= for arg2 in "struct sockaddr" void; do for t in int size_t unsigned long "unsigned long"; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_WINSOCK2_H # include # include int PASCAL getpeername (SOCKET, $arg2 *, $t *); #elif defined(HAVE_SYS_SOCKET_H) # include int getpeername (int, $arg2 *, $t *); #endif int main () { $t len; getpeername(0,0,&len); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : xml_cv_socklen_t_equiv="$t" break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done done if test "x$xml_cv_socklen_t_equiv" = x; then as_fn_error $? "Cannot find a type to use in place of socklen_t" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $xml_cv_socklen_t_equiv" >&5 $as_echo "$xml_cv_socklen_t_equiv" >&6; } cat >>confdefs.h <<_ACEOF #define socklen_t $xml_cv_socklen_t_equiv _ACEOF fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether getopt has optreset support" >&5 $as_echo_n "checking whether getopt has optreset support... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_GETOPT_H #include #endif int main () { optreset = 0; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define HAVE_GETOPT_OPTRESET 1" >>confdefs.h else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # ------------------------------------------------------------ # Checks for compiler characteristics. # ------------------------------------------------------------ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } if ${ac_cv_c_bigendian+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown # See if we're dealing with a universal compiler. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __APPLE_CC__ not a universal capable compiler #endif typedef int dummy; _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # Check for potential -arch flags. It is not universal unless # there are at least two -arch flags with different values. ac_arch= ac_prev= for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do if test -n "$ac_prev"; then case $ac_word in i?86 | x86_64 | ppc | ppc64) if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then ac_arch=$ac_word else ac_cv_c_bigendian=universal break fi ;; esac ac_prev= elif test "x$ac_word" = "x-arch"; then ac_prev=arch fi done fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_c_bigendian = unknown; then # See if sys/param.h defines the BYTE_ORDER macro. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ && LITTLE_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { #if BYTE_ORDER != BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) bogus endian macros #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to _BIG_ENDIAN or not. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { #ifndef _BIG_ENDIAN not big endian #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else ac_cv_c_bigendian=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # Compile a test program. if test "$cross_compiling" = yes; then : # Try to guess by grepping values from an object file. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; int use_ascii (int i) { return ascii_mm[i] + ascii_ii[i]; } short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; int use_ebcdic (int i) { return ebcdic_mm[i] + ebcdic_ii[i]; } extern int foo; int main () { return use_ascii (foo) == use_ebcdic (foo); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then ac_cv_c_bigendian=yes fi if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then if test "$ac_cv_c_bigendian" = unknown; then ac_cv_c_bigendian=no else # finding both strings is unlikely to happen, but who knows? ac_cv_c_bigendian=unknown fi fi fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { /* Are we little or big endian? From Harbison&Steele. */ union { long int l; char c[sizeof (long int)]; } u; u.l = 1; return u.c[sizeof (long int) - 1] == 1; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_c_bigendian=no else ac_cv_c_bigendian=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 $as_echo "$ac_cv_c_bigendian" >&6; } case $ac_cv_c_bigendian in #( yes) $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h ;; #( no) ;; #( universal) $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h ;; #( *) as_fn_error $? "unknown endianness presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 $as_echo_n "checking for an ANSI C-conforming const... " >&6; } if ${ac_cv_c_const+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __cplusplus /* Ultrix mips cc rejects this sort of thing. */ typedef int charset[2]; const charset cs = { 0, 0 }; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; /* NEC SVR4.0.2 mips cc rejects this. */ struct point {int x, y;}; static struct point const zero = {0,0}; /* AIX XL C 1.02.0.0 rejects this. It does not let you subtract one const X* pointer from another in an arm of an if-expression whose if-part is not a constant expression */ const char *g = "string"; pcpcc = &g + (g ? g-g : 0); /* HPUX 7.0 cc rejects these. */ ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; { /* SCO 3.2v4 cc rejects this sort of thing. */ char tx; char *t = &tx; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; if (s) return 0; } { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ int x[] = {25, 17}; const int *foo = &x[0]; ++foo; } { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ typedef const int *iptr; iptr p = 0; ++p; } { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ struct s { int j; const int *ap[3]; } bx; struct s *b = &bx; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; if (!foo) return 0; } return !cs[0] && !zero.x; #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_const=yes else ac_cv_c_const=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 $as_echo "$ac_cv_c_const" >&6; } if test $ac_cv_c_const = no; then $as_echo "#define const /**/" >>confdefs.h fi case $host_os in mingw*) FREETDS_SYMBOLIC="-no-undefined" ;; hpux* | linux* | solaris*) { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we can use -Wl,-Bsymbolic" >&5 $as_echo_n "checking whether we can use -Wl,-Bsymbolic... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return 1 ; return 0; } _ACEOF rm -f conftest.$ac_objext CMD="$SHELL $(test -n "$ac_top_builddir" && echo $ac_top_builddir || echo .)/libtool --mode=link $CC -o libtest.la conftest.$ac_ext >/dev/null 2>&1" if eval $CMD && test -s libtest.la; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } FREETDS_SYMBOLIC="-Wl,-Bsymbolic" else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f conftest.$ac_objext conftest.$ac_ext libtest.la rm -rf .libs ;; esac # if GNU compiler but no GNU linker add explicitly libgcc # this is required for Solaris for example if test "$GCC" = yes; then for freetds_ldflag in "-static-libgcc" "-Wl,-static-libgcc"; do { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we can use $freetds_ldflag" >&5 $as_echo_n "checking whether we can use $freetds_ldflag... " >&6; } saved_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS $freetds_ldflag" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_use_freetds_flag="yes" else ac_cv_use_freetds_flag="no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$saved_LDFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_use_freetds_flag" >&5 $as_echo "$ac_cv_use_freetds_flag" >&6; } if test "$ac_cv_use_freetds_flag" = "yes"; then FREETDS_LIBGCC="$freetds_ldflag" break; fi done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ static void __attribute__((destructor)) my_uninit(void) {} _ACEOF if ac_fn_c_try_compile "$LINENO"; then : $as_echo "#define TDS_ATTRIBUTE_DESTRUCTOR 1" >>confdefs.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether memset(0) sets pointers to NULL" >&5 $as_echo_n "checking whether memset(0) sets pointers to NULL... " >&6; } if ${tds_cv_null_is_zero+:} false; then : $as_echo_n "(cached) " >&6 else tds_cv_null_is_zero=no # compile a test program. if test "$cross_compiling" = yes; then : # try to guess the endianness by grepping values into an object file cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include struct test { char begin[16]; void *ptrs[4]; char end[16]; } xxx[] = { { "abcdefghijklmnop", { NULL, NULL, NULL, NULL }, "qrstuvwxyzabcdef" }, { "\x81\x82\x83\x84\x85\x86\x87\x88\x89\x91\x92\x93\x94\x95\x96\x97", { NULL, NULL, NULL, NULL }, "\x98\x99\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\x81\x82\x83\x84\x85\x86" } }; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : if cat -v conftest.$ac_objext|grep 'abcdefghijklmnop\^@\^@\^@\^@\^@\^@\^@\^@\^@\^@\^@\^@\^@\^@\^@\^@\(\^@\^@\^@\^@\^@\^@\^@\^@\^@\^@\^@\^@\^@\^@\^@\^@\)*qrstuvwxyzabcdef'>/dev/null ; then tds_cv_null_is_zero=yes fi fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #ifdef HAVE_STDDEF_H #include #endif int main () { char *p1,*p2; p1=NULL; memset(&p2,0,sizeof(p2)); return memcmp(&p1,&p2,sizeof(char*))?1:0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : tds_cv_null_is_zero=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tds_cv_null_is_zero" >&5 $as_echo "$tds_cv_null_is_zero" >&6; } case $tds_cv_null_is_zero in yes) $as_echo "#define NULL_REP_IS_ZERO_BYTES 1" >>confdefs.h ;; no) ;; esac # ------------------------------------------------------------ # Checks for library functions. # ------------------------------------------------------------ for ac_func in vsnprintf _vsnprintf _vscprintf gettimeofday \ nl_langinfo locale_charset setenv putenv \ getuid getpwuid getpwuid_r fstat alarm fork \ gethrtime localtime_r setitimer eventfd \ _fseeki64 _ftelli64 setrlimit pthread_cond_timedwait \ _lock_file _unlock_file usleep nanosleep readdir_r do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done LIBS_496="$LIBS" LIBS="$LIBS $NETWORK_LIBS" for ac_func in inet_ntoa_r getipnodebyaddr getipnodebyname \ getaddrinfo inet_ntop gethostname poll socketpair do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NETDB_H #include #endif #ifdef HAVE_WINSOCK2_H #include #include #endif int main () { return getaddrinfo(NULL, NULL, NULL, NULL); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : $as_echo "#define HAVE_GETADDRINFO 1" >>confdefs.h fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS="$LIBS_496" unset LIBS_496 ac_fn_c_check_func "$LINENO" "asprintf" "ac_cv_func_asprintf" if test "x$ac_cv_func_asprintf" = xyes; then : $as_echo "#define HAVE_ASPRINTF 1" >>confdefs.h else case " $LIBOBJS " in *" asprintf.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS asprintf.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "vasprintf" "ac_cv_func_vasprintf" if test "x$ac_cv_func_vasprintf" = xyes; then : $as_echo "#define HAVE_VASPRINTF 1" >>confdefs.h else case " $LIBOBJS " in *" vasprintf.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS vasprintf.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "strtok_r" "ac_cv_func_strtok_r" if test "x$ac_cv_func_strtok_r" = xyes; then : $as_echo "#define HAVE_STRTOK_R 1" >>confdefs.h else case " $LIBOBJS " in *" strtok_r.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strtok_r.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "readpassphrase" "ac_cv_func_readpassphrase" if test "x$ac_cv_func_readpassphrase" = xyes; then : $as_echo "#define HAVE_READPASSPHRASE 1" >>confdefs.h else case " $LIBOBJS " in *" readpassphrase.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS readpassphrase.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "strlcpy" "ac_cv_func_strlcpy" if test "x$ac_cv_func_strlcpy" = xyes; then : $as_echo "#define HAVE_STRLCPY 1" >>confdefs.h else case " $LIBOBJS " in *" strlcpy.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strlcpy.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "strlcat" "ac_cv_func_strlcat" if test "x$ac_cv_func_strlcat" = xyes; then : $as_echo "#define HAVE_STRLCAT 1" >>confdefs.h else case " $LIBOBJS " in *" strlcat.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strlcat.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "basename" "ac_cv_func_basename" if test "x$ac_cv_func_basename" = xyes; then : $as_echo "#define HAVE_BASENAME 1" >>confdefs.h else case " $LIBOBJS " in *" basename.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS basename.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "getopt" "ac_cv_func_getopt" if test "x$ac_cv_func_getopt" = xyes; then : $as_echo "#define HAVE_GETOPT 1" >>confdefs.h else case " $LIBOBJS " in *" getopt.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS getopt.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "strsep" "ac_cv_func_strsep" if test "x$ac_cv_func_strsep" = xyes; then : $as_echo "#define HAVE_STRSEP 1" >>confdefs.h else case " $LIBOBJS " in *" strsep.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strsep.$ac_objext" ;; esac fi ac_fn_c_check_func "$LINENO" "daemon" "ac_cv_func_daemon" if test "x$ac_cv_func_daemon" = xyes; then : $as_echo "#define HAVE_DAEMON 1" >>confdefs.h else case " $LIBOBJS " in *" daemon.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS daemon.$ac_objext" ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGEFILE_SOURCE value needed for large files" >&5 $as_echo_n "checking for _LARGEFILE_SOURCE value needed for large files... " >&6; } if ${ac_cv_sys_largefile_source+:} false; then : $as_echo_n "(cached) " >&6 else while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* for off_t */ #include int main () { int (*fp) (FILE *, off_t, int) = fseeko; return fseeko (stdin, 0, 0) && fp (stdin, 0, 0); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_sys_largefile_source=no; break fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _LARGEFILE_SOURCE 1 #include /* for off_t */ #include int main () { int (*fp) (FILE *, off_t, int) = fseeko; return fseeko (stdin, 0, 0) && fp (stdin, 0, 0); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_sys_largefile_source=1; break fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext ac_cv_sys_largefile_source=unknown break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_source" >&5 $as_echo "$ac_cv_sys_largefile_source" >&6; } case $ac_cv_sys_largefile_source in #( no | unknown) ;; *) cat >>confdefs.h <<_ACEOF #define _LARGEFILE_SOURCE $ac_cv_sys_largefile_source _ACEOF ;; esac rm -rf conftest* # We used to try defining _XOPEN_SOURCE=500 too, to work around a bug # in glibc 2.1.3, but that breaks too many other things. # If you want fseeko and ftello with glibc, upgrade to a fixed glibc. if test $ac_cv_sys_largefile_source != unknown; then $as_echo "#define HAVE_FSEEKO 1" >>confdefs.h fi if test x$ac_cv_func_gethrtime = xno; then tds_save_LIBS="$LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing clock_gettime" >&5 $as_echo_n "checking for library containing clock_gettime... " >&6; } if ${ac_cv_search_clock_gettime+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$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 clock_gettime (); int main () { return clock_gettime (); ; return 0; } _ACEOF for ac_lib in '' rt posix4; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_clock_gettime=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_clock_gettime+:} false; then : break fi done if ${ac_cv_search_clock_gettime+:} false; then : else ac_cv_search_clock_gettime=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_clock_gettime" >&5 $as_echo "$ac_cv_search_clock_gettime" >&6; } ac_res=$ac_cv_search_clock_gettime if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi if test "$ac_cv_search_clock_gettime" != no; then $as_echo "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h fi if test "$ac_cv_search_clock_gettime" != no; then for tds_const in CLOCK_MONOTONIC CLOCK_SGI_CYCLE CLOCK_REALTIME; do { $as_echo "$as_me:${as_lineno-$LINENO}: checking if clock_gettime support $tds_const" >&5 $as_echo_n "checking if clock_gettime support $tds_const... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifdef HAVE_SYS_TIME_H #include #endif int main () { struct timespec ts; clock_gettime($tds_const, &ts); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : tds_clock_gettime_const=yes else tds_clock_gettime_const=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tds_clock_gettime_const" >&5 $as_echo "$tds_clock_gettime_const" >&6; } if test $tds_clock_gettime_const = yes; then cat >>confdefs.h <<_ACEOF #define TDS_GETTIMEMILLI_CONST $tds_const _ACEOF break fi done if test $tds_clock_gettime_const != yes; then LIBS="$tds_save_LIBS" fi fi fi ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" if test "x$ac_cv_type_size_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define size_t unsigned int _ACEOF fi # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works # for constant arguments. Useless! { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5 $as_echo_n "checking for working alloca.h... " >&6; } if ${ac_cv_working_alloca_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { char *p = (char *) alloca (2 * sizeof (int)); if (p) return 0; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_working_alloca_h=yes else ac_cv_working_alloca_h=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5 $as_echo "$ac_cv_working_alloca_h" >&6; } if test $ac_cv_working_alloca_h = yes; then $as_echo "#define HAVE_ALLOCA_H 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5 $as_echo_n "checking for alloca... " >&6; } if ${ac_cv_func_alloca_works+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __GNUC__ # define alloca __builtin_alloca #else # ifdef _MSC_VER # include # define alloca _alloca # elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) # include # else # ifdef HAVE_ALLOCA_H # include # else # ifdef _AIX #pragma alloca # else # ifndef alloca /* predefined by HP cc +Olibcalls */ void *alloca (size_t); # endif # endif # endif # endif #endif int main () { char *p = (char *) alloca (1); if (p) return 0; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_func_alloca_works=yes else ac_cv_func_alloca_works=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5 $as_echo "$ac_cv_func_alloca_works" >&6; } if test $ac_cv_func_alloca_works = yes; then $as_echo "#define HAVE_ALLOCA 1" >>confdefs.h else # The SVR3 libPW and SVR4 libucb both contain incompatible functions # that cause trouble. Some versions do not even contain alloca or # contain a buggy version. If you still want to use their alloca, # use ar to extract alloca.o from them instead of compiling alloca.c. ALLOCA=\${LIBOBJDIR}alloca.$ac_objext $as_echo "#define C_ALLOCA 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \`alloca.c' needs Cray hooks" >&5 $as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; } if ${ac_cv_os_cray+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined CRAY && ! defined CRAY2 webecray #else wenotbecray #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "webecray" >/dev/null 2>&1; then : ac_cv_os_cray=yes else ac_cv_os_cray=no fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_os_cray" >&5 $as_echo "$ac_cv_os_cray" >&6; } if test $ac_cv_os_cray = yes; then for ac_func in _getb67 GETB67 getb67; do as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define CRAY_STACKSEG_END $ac_func _ACEOF break fi done fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5 $as_echo_n "checking stack direction for C alloca... " >&6; } if ${ac_cv_c_stack_direction+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ac_cv_c_stack_direction=0 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int find_stack_direction (int *addr, int depth) { int dir, dummy = 0; if (! addr) addr = &dummy; *addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1; dir = depth ? find_stack_direction (addr, depth - 1) : 0; return dir + dummy; } int main (int argc, char **argv) { return find_stack_direction (0, argc + !argv + 20) < 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_c_stack_direction=1 else ac_cv_c_stack_direction=-1 fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5 $as_echo "$ac_cv_c_stack_direction" >&6; } cat >>confdefs.h <<_ACEOF #define STACK_DIRECTION $ac_cv_c_stack_direction _ACEOF fi # ------------------------------------------------------------ # Checks for library variables. # ------------------------------------------------------------ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether malloc_options variable is present" >&5 $as_echo_n "checking whether malloc_options variable is present... " >&6; } if ${ac_cv_have_malloc_options+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { extern char *malloc_options; malloc_options = "AJR"; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_have_malloc_options=yes else ac_cv_have_malloc_options=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_have_malloc_options" >&5 $as_echo "$ac_cv_have_malloc_options" >&6; } if test $ac_cv_have_malloc_options = yes; then $as_echo "#define HAVE_MALLOC_OPTIONS 1" >>confdefs.h fi # ------------------------------------------------------------ # Compile time options # ------------------------------------------------------------ { $as_echo "$as_me:${as_lineno-$LINENO}: result: checking compile-time options" >&5 $as_echo "checking compile-time options" >&6; } # Check whether --with-tdsver was given. if test "${with_tdsver+set}" = set; then : withval=$with_tdsver; fi case "$with_tdsver" in 4.2) $as_echo "#define TDS42 1" >>confdefs.h ;; 4.6) $as_echo "#define TDS46 1" >>confdefs.h ;; 5.0) $as_echo "#define TDS50 1" >>confdefs.h ;; 7.0) $as_echo "#define TDS70 1" >>confdefs.h ;; 7.1) $as_echo "#define TDS71 1" >>confdefs.h ;; 7.2) $as_echo "#define TDS72 1" >>confdefs.h ;; 7.3) $as_echo "#define TDS73 1" >>confdefs.h ;; 7.4) $as_echo "#define TDS74 1" >>confdefs.h ;; ""|auto) ;; *) as_fn_error $? "Invalid value specified for --with-tdsver: $with_tdsver" "$LINENO" 5 ;; esac # Check whether --with-iodbc was given. if test "${with_iodbc+set}" = set; then : withval=$with_iodbc; fi if test "$with_iodbc"; then if echo "$with_iodbc" | grep -v '^/'; then with_iodbc="$PWD/$with_iodbc" fi CPPFLAGS="$CPPFLAGS -DIODBC" ODBC_INC="$with_iodbc/include" test -r "$ODBC_INC/isql.h" || as_fn_error $? "isql.h not found" "$LINENO" 5 test -r "$ODBC_INC/isqlext.h" || as_fn_error $? "isqlext.h not found" "$LINENO" 5 ODBC_INC="-I$ODBC_INC" LDFLAGS="$LDFLAGS -L$with_iodbc/lib" ODBCLIB="-liodbc" odbc=true iodbc=true fi # Check whether --with-unixodbc was given. if test "${with_unixodbc+set}" = set; then : withval=$with_unixodbc; fi if test "$with_unixodbc"; then if echo "$with_unixodbc" | grep -v '^/'; then with_unixodbc="$PWD/$with_unixodbc" fi CPPFLAGS="$CPPFLAGS -DUNIXODBC" if test -f "$with_unixodbc/bin/odbc_config"; then ODBC_CONFIG="$with_unixodbc/bin/odbc_config" ODBC_INC=`$ODBC_CONFIG --include-prefix` LDFLAGS="$LDFLAGS -L`$ODBC_CONFIG --lib-prefix`" else # if not available do not use system default ODBC_CONFIG="" ODBC_INC="$with_unixodbc/include" LDFLAGS="$LDFLAGS -L$with_unixodbc/lib" fi test -r "$ODBC_INC/sql.h" || as_fn_error $? "sql.h not found" "$LINENO" 5 test -r "$ODBC_INC/sqlext.h" || as_fn_error $? "sqlext.h not found" "$LINENO" 5 ODBC_INC="-I$ODBC_INC" ODBCLIB="-lodbc" odbc=true unixodbc=true fi # Check whether --with-odbc_nodm was given. if test "${with_odbc_nodm+set}" = set; then : withval=$with_odbc_nodm; fi if test "$with_odbc_nodm"; then if echo "$with_odbc_nodm" | grep -v '^/'; then with_odbc_nodm="$PWD/$with_odbc_nodm" fi CPPFLAGS="$CPPFLAGS -DTDS_NO_DM" ODBC_INC="$with_odbc_nodm/include" test -r "$ODBC_INC/sql.h" || as_fn_error $? "sql.h not found" "$LINENO" 5 test -r "$ODBC_INC/sqlext.h" || as_fn_error $? "sqlext.h not found" "$LINENO" 5 ODBC_INC="-I$ODBC_INC" # The next line is for linking the unittests. Here the ODBC driver # itself is treated as the driver manager to be linked. # Can't use ODBCLIB/LDFLAGS variables since they are used in building # other directories. ODBCNODMLIB="-L.. -ltdsodbc" ODBCNODMLIBAPP="-L../odbc -ltdsodbc" odbc=true fi build_odbc=yes if test "$odbc" != "true"; then # Check whether --enable-odbc was given. if test "${enable_odbc+set}" = set; then : enableval=$enable_odbc; build_odbc=$enableval else build_odbc=yes fi fi if test "$build_odbc" = "yes"; then INCODBC_TRUE= INCODBC_FALSE='#' else INCODBC_TRUE='#' INCODBC_FALSE= fi if test "$build_odbc" = "yes" then case $host_os in darwin* | rhapsody*) if test "$with_odbc_nodm" = ""; then FREETDS_ODBC_MODULE="-module" fi ;; esac # odbc not specified, try to detect it echo looking for installed odbc driver manager if test "$odbc" != "true" -a $tds_mingw = yes; then odbc=true unixodbc=true CPPFLAGS="$CPPFLAGS -DUNIXODBC" ODBCLIB="-lodbc32" elif test "$odbc" != "true"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SQLConnect in -liodbc" >&5 $as_echo_n "checking for SQLConnect in -liodbc... " >&6; } if ${ac_cv_lib_iodbc_SQLConnect+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-liodbc $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 SQLConnect (); int main () { return SQLConnect (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_iodbc_SQLConnect=yes else ac_cv_lib_iodbc_SQLConnect=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_iodbc_SQLConnect" >&5 $as_echo "$ac_cv_lib_iodbc_SQLConnect" >&6; } if test "x$ac_cv_lib_iodbc_SQLConnect" = xyes; then : ac_fn_c_check_header_mongrel "$LINENO" "isql.h" "ac_cv_header_isql_h" "$ac_includes_default" if test "x$ac_cv_header_isql_h" = xyes; then : odbc=true iodbc=true CPPFLAGS="$CPPFLAGS -DIODBC" ODBCLIB="-liodbc" fi else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SQLConnect in -lodbc" >&5 $as_echo_n "checking for SQLConnect in -lodbc... " >&6; } if ${ac_cv_lib_odbc_SQLConnect+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lodbc $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 SQLConnect (); int main () { return SQLConnect (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_odbc_SQLConnect=yes else ac_cv_lib_odbc_SQLConnect=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_odbc_SQLConnect" >&5 $as_echo "$ac_cv_lib_odbc_SQLConnect" >&6; } if test "x$ac_cv_lib_odbc_SQLConnect" = xyes; then : ac_fn_c_check_header_mongrel "$LINENO" "sql.h" "ac_cv_header_sql_h" "$ac_includes_default" if test "x$ac_cv_header_sql_h" = xyes; then : odbc=true unixodbc=true CPPFLAGS="$CPPFLAGS -DUNIXODBC" ODBCLIB="-lodbc" fi fi fi fi if test "$odbc" = "true"; then ODBCINSTLIB= if test $tds_mingw = yes; then ODBCINSTLIB="-lodbccp32" elif test "$unixodbc" = "true"; then if test -n "$ODBC_CONFIG"; then CPPFLAGS="$CPPFLAGS `$ODBC_CONFIG --cflags`" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SQLGetPrivateProfileString in -lodbcinst" >&5 $as_echo_n "checking for SQLGetPrivateProfileString in -lodbcinst... " >&6; } if ${ac_cv_lib_odbcinst_SQLGetPrivateProfileString+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lodbcinst $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 SQLGetPrivateProfileString (); int main () { return SQLGetPrivateProfileString (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_odbcinst_SQLGetPrivateProfileString=yes else ac_cv_lib_odbcinst_SQLGetPrivateProfileString=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_odbcinst_SQLGetPrivateProfileString" >&5 $as_echo "$ac_cv_lib_odbcinst_SQLGetPrivateProfileString" >&6; } if test "x$ac_cv_lib_odbcinst_SQLGetPrivateProfileString" = xyes; then : ODBCINSTLIB="-lodbcinst" fi elif test "$iodbc" = "true"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SQLGetPrivateProfileString in -liodbcinst" >&5 $as_echo_n "checking for SQLGetPrivateProfileString in -liodbcinst... " >&6; } if ${ac_cv_lib_iodbcinst_SQLGetPrivateProfileString+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-liodbcinst $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 SQLGetPrivateProfileString (); int main () { return SQLGetPrivateProfileString (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_iodbcinst_SQLGetPrivateProfileString=yes else ac_cv_lib_iodbcinst_SQLGetPrivateProfileString=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_iodbcinst_SQLGetPrivateProfileString" >&5 $as_echo "$ac_cv_lib_iodbcinst_SQLGetPrivateProfileString" >&6; } if test "x$ac_cv_lib_iodbcinst_SQLGetPrivateProfileString" = xyes; then : ODBCINSTLIB="-liodbcinst" fi fi if test "$ODBCINSTLIB" != ""; then cat >>confdefs.h <<_ACEOF #define HAVE_SQLGETPRIVATEPROFILESTRING 1 _ACEOF fi fi if test "$iodbc" = "true"; then save_cppflags="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $ODBC_INC" for ac_header in iodbcinst.h do : ac_fn_c_check_header_mongrel "$LINENO" "iodbcinst.h" "ac_cv_header_iodbcinst_h" "$ac_includes_default" if test "x$ac_cv_header_iodbcinst_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_IODBCINST_H 1 _ACEOF fi done CPPFLAGS="$save_cppflags" fi # test for SQLLEN (iODBC do not define but typedef it) save_cppflags="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $ODBC_INC" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined(_WIN32) || defined(WIN32) || defined(__MINGW32__) #include #endif #include int main () { SQLLEN len = 123; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : $as_echo "#define HAVE_SQLLEN 1" >>confdefs.h # check SQLColAttribute definition cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined(_WIN32) || defined(WIN32) || defined(__MINGW32__) #include #endif #include #include SQLRETURN SQL_API SQLColAttribute (SQLHSTMT StatementHandle, SQLUSMALLINT ColumnNumber, SQLUSMALLINT FieldIdentifier, SQLPOINTER CharacterAttribute, SQLSMALLINT BufferLength, SQLSMALLINT *StringLength, SQLLEN * NumericAttribute) { } int main () { return 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : $as_echo "#define TDS_SQLCOLATTRIBUTE_SQLLEN 1" >>confdefs.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # check is SQLParamOptions accept SQLULEN cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined(_WIN32) || defined(WIN32) || defined(__MINGW32__) #include #endif #include #include SQLRETURN SQL_API SQLParamOptions(SQLHSTMT hstmt, SQLULEN crow, SQLULEN *pirow) { return SQL_SUCCESS; } int main () { return 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : $as_echo "#define TDS_SQLPARAMOPTIONS_SQLLEN 1" >>confdefs.h fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_fn_c_check_type "$LINENO" "SQLSETPOSIROW" "ac_cv_type_SQLSETPOSIROW" "#if defined(_WIN32) || defined(WIN32) || defined(__MINGW32__) #include #endif #include #include " if test "x$ac_cv_type_SQLSETPOSIROW" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SQLSETPOSIROW 1 _ACEOF fi ac_fn_c_check_type "$LINENO" "SQLROWSETSIZE" "ac_cv_type_SQLROWSETSIZE" "#if defined(_WIN32) || defined(WIN32) || defined(__MINGW32__) #include #endif #include #include " if test "x$ac_cv_type_SQLROWSETSIZE" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SQLROWSETSIZE 1 _ACEOF fi ac_fn_c_check_type "$LINENO" "SQLROWOFFSET" "ac_cv_type_SQLROWOFFSET" "#if defined(_WIN32) || defined(WIN32) || defined(__MINGW32__) #include #endif #include #include " if test "x$ac_cv_type_SQLROWOFFSET" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SQLROWOFFSET 1 _ACEOF fi # test for sizeof(SQLWCHAR) # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of SQLWCHAR" >&5 $as_echo_n "checking size of SQLWCHAR... " >&6; } if ${ac_cv_sizeof_SQLWCHAR+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (SQLWCHAR))" "ac_cv_sizeof_SQLWCHAR" "#if defined(_WIN32) || defined(WIN32) || defined(__MINGW32__) #include #endif #include "; then : else if test "$ac_cv_type_SQLWCHAR" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (SQLWCHAR) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_SQLWCHAR=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_SQLWCHAR" >&5 $as_echo "$ac_cv_sizeof_SQLWCHAR" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_SQLWCHAR $ac_cv_sizeof_SQLWCHAR _ACEOF CPPFLAGS="$save_cppflags" else { $as_echo "$as_me:${as_lineno-$LINENO}: odbc disabled" >&5 $as_echo "$as_me: odbc disabled" >&6;} fi if test "$odbc" = "true"; then ODBC_TRUE= ODBC_FALSE='#' else ODBC_TRUE='#' ODBC_FALSE= fi if test "$unixodbc" = "true"; then UNIXODBC_TRUE= UNIXODBC_FALSE='#' else UNIXODBC_TRUE='#' UNIXODBC_FALSE= fi # Check whether --with-gnutls was given. if test "${with_gnutls+set}" = set; then : withval=$with_gnutls; fi if test "$with_gnutls" = "yes"; then $as_echo "#define HAVE_GNUTLS 1" >>confdefs.h gnutls_backend=unknown pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNUTLS" >&5 $as_echo_n "checking for GNUTLS... " >&6; } if test -n "$GNUTLS_CFLAGS"; then pkg_cv_GNUTLS_CFLAGS="$GNUTLS_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gnutls\""; } >&5 ($PKG_CONFIG --exists --print-errors "gnutls") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_GNUTLS_CFLAGS=`$PKG_CONFIG --cflags "gnutls" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$GNUTLS_LIBS"; then pkg_cv_GNUTLS_LIBS="$GNUTLS_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gnutls\""; } >&5 ($PKG_CONFIG --exists --print-errors "gnutls") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_GNUTLS_LIBS=`$PKG_CONFIG --libs "gnutls" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then GNUTLS_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "gnutls" 2>&1` else GNUTLS_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "gnutls" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$GNUTLS_PKG_ERRORS" >&5 CPPFLAGS="$CPPFLAGS `libgnutls-config --cflags`" NETWORK_LIBS="$NETWORK_LIBS `libgnutls-config --libs`" elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } CPPFLAGS="$CPPFLAGS `libgnutls-config --cflags`" NETWORK_LIBS="$NETWORK_LIBS `libgnutls-config --libs`" else GNUTLS_CFLAGS=$pkg_cv_GNUTLS_CFLAGS GNUTLS_LIBS=$pkg_cv_GNUTLS_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } CPPFLAGS="$CPPFLAGS $GNUTLS_CFLAGS" NETWORK_LIBS="$NETWORK_LIBS $GNUTLS_LIBS" if "$PKG_CONFIG" --libs --static gnutls | grep nettle > /dev/null 2>&1 ; then gnutls_backend=nettle $as_echo "#define GNUTLS_USE_NETTLE 1" >>confdefs.h pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for NETTLE" >&5 $as_echo_n "checking for NETTLE... " >&6; } if test -n "$NETTLE_CFLAGS"; then pkg_cv_NETTLE_CFLAGS="$NETTLE_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"nettle\""; } >&5 ($PKG_CONFIG --exists --print-errors "nettle") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_NETTLE_CFLAGS=`$PKG_CONFIG --cflags "nettle" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$NETTLE_LIBS"; then pkg_cv_NETTLE_LIBS="$NETTLE_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"nettle\""; } >&5 ($PKG_CONFIG --exists --print-errors "nettle") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_NETTLE_LIBS=`$PKG_CONFIG --libs "nettle" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then NETTLE_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "nettle" 2>&1` else NETTLE_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "nettle" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$NETTLE_PKG_ERRORS" >&5 as_fn_error $? "Package requirements (nettle) were not met: $NETTLE_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables NETTLE_CFLAGS and NETTLE_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. Alternatively, you may set the environment variables NETTLE_CFLAGS and NETTLE_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . See \`config.log' for more details" "$LINENO" 5; } else NETTLE_CFLAGS=$pkg_cv_NETTLE_CFLAGS NETTLE_LIBS=$pkg_cv_NETTLE_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } $as_echo "#define HAVE_NETTLE 1" >>confdefs.h NETWORK_LIBS="$NETWORK_LIBS $NETTLE_LIBS" fi LIBS_747="$LIBS" LIBS="$NETWORK_LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { mpz_t x; mpz_init(x); mpz_powm(x,x,x,x); mpz_clear(x); return 0; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : $as_echo "#define HAVE_GMP 1" >>confdefs.h else gmp_save_LIBS="$LIBS" LIBS="$LIBS -lgmp" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { mpz_t x; mpz_init(x); mpz_powm(x,x,x,x); mpz_clear(x); return 0; ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : $as_echo "#define HAVE_GMP 1" >>confdefs.h else LIBS="$gmp_save_LIBS" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing nettle_rsa_public_key_init" >&5 $as_echo_n "checking for library containing nettle_rsa_public_key_init... " >&6; } if ${ac_cv_search_nettle_rsa_public_key_init+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$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 nettle_rsa_public_key_init (); int main () { return nettle_rsa_public_key_init (); ; return 0; } _ACEOF for ac_lib in '' nettle hogweed; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then : ac_cv_search_nettle_rsa_public_key_init=$ac_res fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext if ${ac_cv_search_nettle_rsa_public_key_init+:} false; then : break fi done if ${ac_cv_search_nettle_rsa_public_key_init+:} false; then : else ac_cv_search_nettle_rsa_public_key_init=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_nettle_rsa_public_key_init" >&5 $as_echo "$ac_cv_search_nettle_rsa_public_key_init" >&6; } ac_res=$ac_cv_search_nettle_rsa_public_key_init if test "$ac_res" != no; then : test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi NETWORK_LIBS="$LIBS" LIBS="$LIBS_747" unset LIBS_747 fi fi LIBS_765="$LIBS" LIBS="$NETWORK_LIBS" for ac_func in gnutls_certificate_set_verify_function gnutls_record_disable_padding gnutls_rnd do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done LIBS="$LIBS_765" unset LIBS_765 if test "$gnutls_backend" = "unknown"; then gnutls_backend=gcrypt NETWORK_LIBS="$NETWORK_LIBS -ltasn1" fi else { $as_echo "$as_me:${as_lineno-$LINENO}: checking if openssl is wanted" >&5 $as_echo_n "checking if openssl is wanted... " >&6; } # Check whether --with-openssl was given. if test "${with_openssl+set}" = set; then : withval=$with_openssl; fi if test "$with_openssl" != "no"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } old_NETWORK_LIBS="$NETWORK_LIBS" pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OPENSSL" >&5 $as_echo_n "checking for OPENSSL... " >&6; } if test -n "$OPENSSL_CFLAGS"; then pkg_cv_OPENSSL_CFLAGS="$OPENSSL_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"openssl\""; } >&5 ($PKG_CONFIG --exists --print-errors "openssl") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_OPENSSL_CFLAGS=`$PKG_CONFIG --cflags "openssl" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$OPENSSL_LIBS"; then pkg_cv_OPENSSL_LIBS="$OPENSSL_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"openssl\""; } >&5 ($PKG_CONFIG --exists --print-errors "openssl") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_OPENSSL_LIBS=`$PKG_CONFIG --libs "openssl" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then OPENSSL_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "openssl" 2>&1` else OPENSSL_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "openssl" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$OPENSSL_PKG_ERRORS" >&5 found_ssl=no if test "$cross_compiling" != "yes"; then for dir in $withval /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr; do ssldir="$dir" if test -f "$dir/include/openssl/ssl.h"; then echo "OpenSSL found in $ssldir" found_ssl="yes" CFLAGS="$CFLAGS -I$ssldir/include" NETWORK_LIBS="$NETWORK_LIBS -lssl -lcrypto" LDFLAGS="$LDFLAGS -L$ssldir/lib" break fi done fi elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } found_ssl=no if test "$cross_compiling" != "yes"; then for dir in $withval /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr; do ssldir="$dir" if test -f "$dir/include/openssl/ssl.h"; then echo "OpenSSL found in $ssldir" found_ssl="yes" CFLAGS="$CFLAGS -I$ssldir/include" NETWORK_LIBS="$NETWORK_LIBS -lssl -lcrypto" LDFLAGS="$LDFLAGS -L$ssldir/lib" break fi done fi else OPENSSL_CFLAGS=$pkg_cv_OPENSSL_CFLAGS OPENSSL_LIBS=$pkg_cv_OPENSSL_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } found_ssl=yes CFLAGS="$CFLAGS $OPENSSL_CFLAGS" NETWORK_LIBS="$NETWORK_LIBS $OPENSSL_LIBS" fi if test x$found_ssl = xyes; then LIBS_773="$LIBS" LIBS="$NETWORK_LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { SSL_read(NULL, NULL, 100); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : else found_ssl=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS="$LIBS_773" unset LIBS_773 fi if test x$found_ssl != xyes -a "$with_openssl" != ""; then as_fn_error $? "Cannot find OpenSSL libraries" "$LINENO" 5 NETWORK_LIBS="$old_NETWORK_LIBS" elif test x$found_ssl = xyes; then HAVE_OPENSSL=yes $as_echo "#define HAVE_OPENSSL 1" >>confdefs.h else NETWORK_LIBS="$old_NETWORK_LIBS" fi else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi # Check whether --enable-apps was given. if test "${enable_apps+set}" = set; then : enableval=$enable_apps; fi if test "$enable_apps" != "no"; then INCAPPS_TRUE= INCAPPS_FALSE='#' else INCAPPS_TRUE='#' INCAPPS_FALSE= fi # Check whether --enable-server was given. if test "${enable_server+set}" = set; then : enableval=$enable_server; fi if test "$enable_server" != "no"; then INCSERVER_TRUE= INCSERVER_FALSE='#' else INCSERVER_TRUE='#' INCSERVER_FALSE= fi # Check whether --enable-pool was given. if test "${enable_pool+set}" = set; then : enableval=$enable_pool; fi if test "$enable_pool" != "no"; then INCPOOL_TRUE= INCPOOL_FALSE='#' else INCPOOL_TRUE='#' INCPOOL_FALSE= fi # Check whether --enable-msdblib was given. if test "${enable_msdblib+set}" = set; then : enableval=$enable_msdblib; fi if test "$enable_msdblib" = "yes" ; then dblib_define="#define MSDBLIB 1" else dblib_define="#define SYBDBLIB 1" fi # Check whether --enable-sybase-compat was given. if test "${enable_sybase_compat+set}" = set; then : enableval=$enable_sybase_compat; fi if test x$enable_sybase_compat = xyes; then SYBASE_COMPAT_TRUE= SYBASE_COMPAT_FALSE='#' else SYBASE_COMPAT_TRUE='#' SYBASE_COMPAT_FALSE= fi if test x$enable_sybase_compat = xyes; then $as_echo "#define TDS_SYBASE_COMPAT 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking threadsafety" >&5 $as_echo_n "checking threadsafety... " >&6; } # Enable or disable thread safetiness # This option is enabled by default because most OS's support it. # A more sophisticated approach would be to set the default per-OS. # Check whether --enable-threadsafe was given. if test "${enable_threadsafe+set}" = set; then : enableval=$enable_threadsafe; use_threadsafe=$enableval else use_threadsafe=yes fi if test "$enable_threadsafe" != "no" ; then CPPFLAGS="$CPPFLAGS -D_REENTRANT -D_THREAD_SAFE" { $as_echo "$as_me:${as_lineno-$LINENO}: result: enabled" >&5 $as_echo "enabled" >&6; } else $as_echo "#define TDS_NO_THREADSAFE 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5 $as_echo "disabled" >&6; } fi if test "$enable_threadsafe" != "no"; then ENABLE_THREADSAFE_TRUE= ENABLE_THREADSAFE_FALSE='#' else ENABLE_THREADSAFE_TRUE='#' ENABLE_THREADSAFE_FALSE= fi # newer gcc are configured to fail to resolve references to libraries not # explicitly listed on the linker commandline. # So to make build add explicitly gcrypt library. if test "$enable_threadsafe" != "no" -a "$with_gnutls" = "yes" -a "$gnutls_backend" = "gcrypt"; then pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCRYPT" >&5 $as_echo_n "checking for GCRYPT... " >&6; } if test -n "$GCRYPT_CFLAGS"; then pkg_cv_GCRYPT_CFLAGS="$GCRYPT_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gcrypt\""; } >&5 ($PKG_CONFIG --exists --print-errors "gcrypt") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_GCRYPT_CFLAGS=`$PKG_CONFIG --cflags "gcrypt" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$GCRYPT_LIBS"; then pkg_cv_GCRYPT_LIBS="$GCRYPT_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gcrypt\""; } >&5 ($PKG_CONFIG --exists --print-errors "gcrypt") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_GCRYPT_LIBS=`$PKG_CONFIG --libs "gcrypt" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then GCRYPT_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "gcrypt" 2>&1` else GCRYPT_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "gcrypt" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$GCRYPT_PKG_ERRORS" >&5 CPPFLAGS="$CPPFLAGS `libgcrypt-config --cflags`" NETWORK_LIBS="$NETWORK_LIBS `libgcrypt-config --libs`" elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } CPPFLAGS="$CPPFLAGS `libgcrypt-config --cflags`" NETWORK_LIBS="$NETWORK_LIBS `libgcrypt-config --libs`" else GCRYPT_CFLAGS=$pkg_cv_GCRYPT_CFLAGS GCRYPT_LIBS=$pkg_cv_GCRYPT_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } CPPFLAGS="$CPPFLAGS $GCRYPT_CFLAGS" NETWORK_LIBS="$NETWORK_LIBS $GCRYPT_LIBS" fi fi # we don't need to check netdb functions if they are already threadsafe if test $netdb_reentrant != yes; then ac_save_CFLAGS=$CFLAGS CFLAGS="$CFLAGS $NETWORK_LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for which type of gethostbyname_r" >&5 $as_echo_n "checking for which type of gethostbyname_r... " >&6; } if ${ac_cv_func_which_gethostname_r+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # include int main () { char *name; struct hostent *he; struct hostent_data data; (void) gethostbyname_r(name, he, &data); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_func_which_gethostname_r=three else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # include int main () { char *name; struct hostent *he, *res; char buffer[2048]; int buflen = 2048; int h_errnop; (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop) ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_func_which_gethostname_r=six else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # include int main () { char *name; struct hostent *he; char buffer[2048]; int buflen = 2048; int h_errnop; (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop) ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_func_which_gethostname_r=five else ac_cv_func_which_gethostname_r=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_which_gethostname_r" >&5 $as_echo "$ac_cv_func_which_gethostname_r" >&6; } if test $ac_cv_func_which_gethostname_r = six; then $as_echo "#define HAVE_FUNC_GETHOSTBYNAME_R_6 1" >>confdefs.h elif test $ac_cv_func_which_gethostname_r = five; then $as_echo "#define HAVE_FUNC_GETHOSTBYNAME_R_5 1" >>confdefs.h elif test $ac_cv_func_which_gethostname_r = three; then $as_echo "#define HAVE_FUNC_GETHOSTBYNAME_R_3 1" >>confdefs.h fi CFLAGS=$ac_save_CFLAGS ac_save_CFLAGS=$CFLAGS CFLAGS="$CFLAGS $NETWORK_LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for which type of getservbyname_r" >&5 $as_echo_n "checking for which type of getservbyname_r... " >&6; } if ${ac_cv_func_which_getservbyname_r+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # include int main () { char *name; char *proto; struct servent *se; struct servent_data data; (void) getservbyname_r(name, proto, se, &data); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_func_which_getservbyname_r=four else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # include int main () { char *name; char *proto; struct servent *se, *res; char buffer[2048]; int buflen = 2048; (void) getservbyname_r(name, proto, se, buffer, buflen, &res) ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_func_which_getservbyname_r=six else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ # include int main () { char *name; char *proto; struct servent *se; char buffer[2048]; int buflen = 2048; (void) getservbyname_r(name, proto, se, buffer, buflen) ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_func_which_getservbyname_r=five else ac_cv_func_which_getservbyname_r=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_which_getservbyname_r" >&5 $as_echo "$ac_cv_func_which_getservbyname_r" >&6; } if test $ac_cv_func_which_getservbyname_r = six; then $as_echo "#define HAVE_FUNC_GETSERVBYNAME_R_6 1" >>confdefs.h elif test $ac_cv_func_which_getservbyname_r = five; then $as_echo "#define HAVE_FUNC_GETSERVBYNAME_R_5 1" >>confdefs.h elif test $ac_cv_func_which_getservbyname_r = four; then $as_echo "#define HAVE_FUNC_GETSERVBYNAME_R_4 1" >>confdefs.h fi CFLAGS=$ac_save_CFLAGS ac_save_CFLAGS=$CFLAGS CFLAGS="$CFLAGS $NETWORK_LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for which type of gethostbyaddr_r" >&5 $as_echo_n "checking for which type of gethostbyaddr_r... " >&6; } if ${ac_cv_func_which_gethostbyaddr_r+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { char * address; int length; int type; struct hostent h; struct hostent_data hdata; int rc; rc = gethostbyaddr_r(address, length, type, &h, &hdata); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_func_which_gethostbyaddr_r=five else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { char * address; int length; int type; struct hostent h; char buffer[8192]; int h_errnop; struct hostent * hp; hp = gethostbyaddr_r(address, length, type, &h, buffer, 8192, &h_errnop); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_func_which_gethostbyaddr_r=seven else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { char * address; int length; int type; struct hostent h; char buffer[8192]; int h_errnop; struct hostent * hp; int rc; rc = gethostbyaddr_r(address, length, type, &h, buffer, 8192, &hp, &h_errnop); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_func_which_gethostbyaddr_r=eight else ac_cv_func_which_gethostbyaddr_r=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_which_gethostbyaddr_r" >&5 $as_echo "$ac_cv_func_which_gethostbyaddr_r" >&6; } if test $ac_cv_func_which_gethostbyaddr_r = eight; then $as_echo "#define HAVE_FUNC_GETHOSTBYADDR_R_8 1" >>confdefs.h elif test $ac_cv_func_which_gethostbyaddr_r = seven; then $as_echo "#define HAVE_FUNC_GETHOSTBYADDR_R_7 1" >>confdefs.h elif test $ac_cv_func_which_gethostbyaddr_r = five; then $as_echo "#define HAVE_FUNC_GETHOSTBYADDR_R_5 1" >>confdefs.h fi CFLAGS=$ac_save_CFLAGS fi if test x$ac_cv_func_getpwuid = xyes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for which type of getpwuid_r" >&5 $as_echo_n "checking for which type of getpwuid_r... " >&6; } if ${ac_cv_func_which_getpwuid_r+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { struct passwd bpw; char buf[1024]; char *dir = getpwuid_r(getuid(), &bpw, buf, sizeof(buf))->pw_dir; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_func_which_getpwuid_r=four_pw else if test "$cross_compiling" = yes; then : # cross compile case ac_cv_func_which_getpwuid_r=no num_params=four for params in "int" "size_t, struct passwd **"; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include extern int getpwuid_r(uid_t, struct passwd *, char *, $params); int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : if test $ac_cv_func_which_getpwuid_r != no; then as_fn_error $? "Two types of getpwuid_r detected" "$LINENO" 5 fi ac_cv_func_which_getpwuid_r=$num_params fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext num_params=five done else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main() { struct passwd bpw; char buf[1024]; getpwuid_r(getuid(), &bpw, buf, sizeof(buf)); return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_func_which_getpwuid_r=four else if test "$cross_compiling" = yes; then : { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run test program while cross compiling See \`config.log' for more details" "$LINENO" 5; } else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main() { struct passwd *pw, bpw; char buf[1024]; getpwuid_r(getuid(), &bpw, buf, sizeof(buf), &pw); return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_func_which_getpwuid_r=five else ac_cv_func_which_getpwuid_r=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_which_getpwuid_r" >&5 $as_echo "$ac_cv_func_which_getpwuid_r" >&6; } if test $ac_cv_func_which_getpwuid_r = four_pw; then $as_echo "#define HAVE_FUNC_GETPWUID_R_4 1" >>confdefs.h $as_echo "#define HAVE_FUNC_GETPWUID_R_4_PW 1" >>confdefs.h elif test $ac_cv_func_which_getpwuid_r = four; then $as_echo "#define HAVE_FUNC_GETPWUID_R_4 1" >>confdefs.h elif test $ac_cv_func_which_getpwuid_r = five; then $as_echo "#define HAVE_FUNC_GETPWUID_R_5 1" >>confdefs.h fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for which type of localtime_r" >&5 $as_echo_n "checking for which type of localtime_r... " >&6; } if ${ac_cv_func_which_localtime_r+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { struct tm mytm; time_t t; int y = localtime_r(&t, &mytm)->tm_year; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_func_which_localtime_r=struct else ac_cv_func_which_localtime_r=int fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_which_localtime_r" >&5 $as_echo "$ac_cv_func_which_localtime_r" >&6; } if test $ac_cv_func_which_localtime_r = struct; then $as_echo "#define HAVE_FUNC_LOCALTIME_R_TM 1" >>confdefs.h else $as_echo "#define HAVE_FUNC_LOCALTIME_R_INT 1" >>confdefs.h fi # easy test for pthread (no library, only mutex support) cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #if !defined(_WIN32) pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; #endif int main () { pthread_mutex_lock(&mutex); pthread_mutex_unlock(&mutex) ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : $as_echo "#define TDS_HAVE_PTHREAD_MUTEX 1" >>confdefs.h fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # easy test for locking stdio cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { int c; flockfile(stdin); c = getc_unlocked(stdin); funlockfile(stdin); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : $as_echo "#define TDS_HAVE_STDIO_LOCKED 1" >>confdefs.h fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext # Check whether --enable-debug was given. if test "${enable_debug+set}" = set; then : enableval=$enable_debug; use_debug=$enableval else use_debug=yes fi if test "$use_debug" = "yes" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: debug enabled" >&5 $as_echo "$as_me: debug enabled" >&6;} CPPFLAGS="$CPPFLAGS -DDEBUG=1" # Check whether --enable-extra-checks was given. if test "${enable_extra_checks+set}" = set; then : enableval=$enable_extra_checks; fi if test "$enable_extra_checks" = "yes" ; then cat >>confdefs.h <<_ACEOF #define ENABLE_EXTRA_CHECKS 1 _ACEOF fi else { $as_echo "$as_me:${as_lineno-$LINENO}: debug disabled" >&5 $as_echo "$as_me: debug disabled" >&6;} CPPFLAGS="$CPPFLAGS -DNDEBUG=1" fi # Check whether --enable-developing was given. if test "${enable_developing+set}" = set; then : enableval=$enable_developing; fi if test "$enable_developing" = "yes" ; then cat >>confdefs.h <<_ACEOF #define ENABLE_DEVELOPING 1 _ACEOF fi if test "$enable_developing" = "yes"; then ENABLE_DEVELOPING_TRUE= ENABLE_DEVELOPING_FALSE='#' else ENABLE_DEVELOPING_TRUE='#' ENABLE_DEVELOPING_FALSE= fi # Check whether --enable-mars was given. if test "${enable_mars+set}" = set; then : enableval=$enable_mars; fi if test "$enable_mars" = "yes" ; then cat >>confdefs.h <<_ACEOF #define ENABLE_ODBC_MARS 1 _ACEOF fi # Check whether --enable-odbc-wide was given. if test "${enable_odbc_wide+set}" = set; then : enableval=$enable_odbc_wide; fi if test "$enable_odbc_wide" != "no" ; then cat >>confdefs.h <<_ACEOF #define ENABLE_ODBC_WIDE 1 _ACEOF # Check whether --enable-odbc-wide-tests was given. if test "${enable_odbc_wide_tests+set}" = set; then : enableval=$enable_odbc_wide_tests; fi if test "$enable_odbc_wide_tests" = "yes"; then ODBC_WIDE_TESTS_TRUE= ODBC_WIDE_TESTS_FALSE='#' else ODBC_WIDE_TESTS_TRUE='#' ODBC_WIDE_TESTS_FALSE= fi else if false; then ODBC_WIDE_TESTS_TRUE= ODBC_WIDE_TESTS_FALSE='#' else ODBC_WIDE_TESTS_TRUE='#' ODBC_WIDE_TESTS_FALSE= fi fi # Check whether --enable-distcheck_build was given. if test "${enable_distcheck_build+set}" = set; then : enableval=$enable_distcheck_build; fi if test "$enable_distcheck_build" = "yes" ; then if true; then DISTCHECK_BUILD_TRUE= DISTCHECK_BUILD_FALSE='#' else DISTCHECK_BUILD_TRUE='#' DISTCHECK_BUILD_FALSE= fi else if false; then DISTCHECK_BUILD_TRUE= DISTCHECK_BUILD_FALSE='#' else DISTCHECK_BUILD_TRUE='#' DISTCHECK_BUILD_FALSE= fi fi # ------------------------------------------------------------ # LTLIBOBJS hack (for autoconf-2.53) # ------------------------------------------------------------ # This is necessary so that .o files in LIBOBJS are also built via # the ANSI2KNR-filtering rules. LIBOBJS=`echo "$LIBOBJS" | sed 's,\.[^.]* ,$U&,g;s,\.[^.]*$,$U&,'` LTLIBOBJS=`echo "$LIBOBJS" | sed 's,\.[^.]* ,.lo ,g;s,\.[^.]*$,.lo,'` # enable some warning for gcc if test "$ac_compiler_gnu" = "yes" ; then CPPFLAGS="$CPPFLAGS -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long -Wpointer-arith" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking CFLAGS for gcc -Wdeclaration-after-statement" >&5 $as_echo_n "checking CFLAGS for gcc -Wdeclaration-after-statement... " >&6; } if ${ac_cv_cflags_gcc_option__Wdeclaration_after_statement+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_cflags_gcc_option__Wdeclaration_after_statement="no, unknown" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_save_CFLAGS="$CFLAGS" for ac_arg in "-pedantic % -Wdeclaration-after-statement" # do CFLAGS="$ac_save_CFLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'` cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_cflags_gcc_option__Wdeclaration_after_statement=`echo $ac_arg | sed -e 's,.*% *,,'` ; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done CFLAGS="$ac_save_CFLAGS" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cflags_gcc_option__Wdeclaration_after_statement" >&5 $as_echo "$ac_cv_cflags_gcc_option__Wdeclaration_after_statement" >&6; } case ".$ac_cv_cflags_gcc_option__Wdeclaration_after_statement" in .ok|.ok,*) ;; .|.no|.no,*) ;; *) if echo " $CFLAGS " | grep " $ac_cv_cflags_gcc_option__Wdeclaration_after_statement " 2>&1 >/dev/null then { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS does contain \$ac_cv_cflags_gcc_option__Wdeclaration_after_statement"; } >&5 (: CFLAGS does contain $ac_cv_cflags_gcc_option__Wdeclaration_after_statement) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } else { { $as_echo "$as_me:${as_lineno-$LINENO}: : CFLAGS=\"\$CFLAGS \$ac_cv_cflags_gcc_option__Wdeclaration_after_statement\""; } >&5 (: CFLAGS="$CFLAGS $ac_cv_cflags_gcc_option__Wdeclaration_after_statement") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } CFLAGS="$CFLAGS $ac_cv_cflags_gcc_option__Wdeclaration_after_statement" fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5 $as_echo "done" >&6; } # ------------------------------------------------------------ # Final output # ------------------------------------------------------------ ac_config_files="$ac_config_files include/freetds/version.h include/tds_sysdep_public.h Makefile include/Makefile include/freetds/Makefile doc/Makefile samples/Makefile src/Makefile src/tds/Makefile src/tds/unittests/Makefile src/dblib/Makefile src/dblib/unittests/Makefile src/ctlib/Makefile src/ctlib/unittests/Makefile src/replacements/Makefile src/replacements/unittests/Makefile src/server/Makefile src/pool/Makefile src/odbc/Makefile src/odbc/unittests/Makefile src/apps/Makefile src/apps/fisql/Makefile freetds.spec win32/Makefile win32/freetds.nsh src/odbc/version.rc vms/Makefile misc/Makefile doc/freebcp.1 doc/tsql.1 doc/osql.1 doc/bsqldb.1 doc/bsqlodbc.1 doc/defncopy.1 doc/datacopy.1 doc/fisql.1 doc/freetds.conf.5" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs { $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5 $as_echo_n "checking that generated files are newer than configure... " >&6; } if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5 $as_echo "done" >&6; } if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' else am__EXEEXT_TRUE='#' am__EXEEXT_FALSE= fi 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 "${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 "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then as_fn_error $? "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_DOXYGEN_TRUE}" && test -z "${HAVE_DOXYGEN_FALSE}"; then as_fn_error $? "conditional \"HAVE_DOXYGEN\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_PERL_SOURCES_TRUE}" && test -z "${HAVE_PERL_SOURCES_FALSE}"; then as_fn_error $? "conditional \"HAVE_PERL_SOURCES\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_PERL_SOURCES_TRUE}" && test -z "${HAVE_PERL_SOURCES_FALSE}"; then as_fn_error $? "conditional \"HAVE_PERL_SOURCES\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${MINGW32_TRUE}" && test -z "${MINGW32_FALSE}"; then as_fn_error $? "conditional \"MINGW32\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${MINGW32_TRUE}" && test -z "${MINGW32_FALSE}"; then as_fn_error $? "conditional \"MINGW32\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${MINGW32_TRUE}" && test -z "${MINGW32_FALSE}"; then as_fn_error $? "conditional \"MINGW32\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_SSPI_TRUE}" && test -z "${HAVE_SSPI_FALSE}"; then as_fn_error $? "conditional \"HAVE_SSPI\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${INCODBC_TRUE}" && test -z "${INCODBC_FALSE}"; then as_fn_error $? "conditional \"INCODBC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ODBC_TRUE}" && test -z "${ODBC_FALSE}"; then as_fn_error $? "conditional \"ODBC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${UNIXODBC_TRUE}" && test -z "${UNIXODBC_FALSE}"; then as_fn_error $? "conditional \"UNIXODBC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${INCAPPS_TRUE}" && test -z "${INCAPPS_FALSE}"; then as_fn_error $? "conditional \"INCAPPS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${INCSERVER_TRUE}" && test -z "${INCSERVER_FALSE}"; then as_fn_error $? "conditional \"INCSERVER\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${INCPOOL_TRUE}" && test -z "${INCPOOL_FALSE}"; then as_fn_error $? "conditional \"INCPOOL\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${SYBASE_COMPAT_TRUE}" && test -z "${SYBASE_COMPAT_FALSE}"; then as_fn_error $? "conditional \"SYBASE_COMPAT\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_THREADSAFE_TRUE}" && test -z "${ENABLE_THREADSAFE_FALSE}"; then as_fn_error $? "conditional \"ENABLE_THREADSAFE\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_DEVELOPING_TRUE}" && test -z "${ENABLE_DEVELOPING_FALSE}"; then as_fn_error $? "conditional \"ENABLE_DEVELOPING\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ODBC_WIDE_TESTS_TRUE}" && test -z "${ODBC_WIDE_TESTS_FALSE}"; then as_fn_error $? "conditional \"ODBC_WIDE_TESTS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ODBC_WIDE_TESTS_TRUE}" && test -z "${ODBC_WIDE_TESTS_FALSE}"; then as_fn_error $? "conditional \"ODBC_WIDE_TESTS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${DISTCHECK_BUILD_TRUE}" && test -z "${DISTCHECK_BUILD_FALSE}"; then as_fn_error $? "conditional \"DISTCHECK_BUILD\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${DISTCHECK_BUILD_TRUE}" && test -z "${DISTCHECK_BUILD_FALSE}"; then as_fn_error $? "conditional \"DISTCHECK_BUILD\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by FreeTDS $as_me 1.00.82, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to the package provider." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ FreeTDS config.status 1.00.82 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' MKDIR_P='$MKDIR_P' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`' macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`' AS='`$ECHO "$AS" | $SED "$delay_single_quote_subst"`' DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`' OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`' enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`' enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`' pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`' enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`' shared_archive_member_spec='`$ECHO "$shared_archive_member_spec" | $SED "$delay_single_quote_subst"`' SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`' ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`' PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`' host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`' host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`' host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`' build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`' build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`' build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`' SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`' Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`' GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`' EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`' FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`' LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`' NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`' LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`' max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`' ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`' exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`' lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`' lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`' lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`' lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`' lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`' reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`' want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`' sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`' AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`' STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`' old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`' old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`' old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`' lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`' CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`' CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`' compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`' GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_import='`$ECHO "$lt_cv_sys_global_symbol_to_import" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`' lt_cv_nm_interface='`$ECHO "$lt_cv_nm_interface" | $SED "$delay_single_quote_subst"`' nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`' lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`' lt_cv_truncate_bin='`$ECHO "$lt_cv_truncate_bin" | $SED "$delay_single_quote_subst"`' objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`' MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`' need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`' MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`' DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`' NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`' LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`' OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`' OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`' libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`' shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`' extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`' enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`' export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`' whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`' compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`' old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`' old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`' archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`' module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`' module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`' with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`' allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`' no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`' hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`' hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`' hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`' hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`' hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`' hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`' inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`' link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`' always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`' export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`' exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`' include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`' prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`' postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`' file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`' variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`' need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`' need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`' version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`' runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`' libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`' library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`' soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`' install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`' postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`' postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`' finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`' finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`' hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`' sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`' configure_time_dlsearch_path='`$ECHO "$configure_time_dlsearch_path" | $SED "$delay_single_quote_subst"`' configure_time_lt_sys_library_path='`$ECHO "$configure_time_lt_sys_library_path" | $SED "$delay_single_quote_subst"`' hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`' enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`' enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`' enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`' old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`' striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`' LD_RC='`$ECHO "$LD_RC" | $SED "$delay_single_quote_subst"`' reload_flag_RC='`$ECHO "$reload_flag_RC" | $SED "$delay_single_quote_subst"`' reload_cmds_RC='`$ECHO "$reload_cmds_RC" | $SED "$delay_single_quote_subst"`' old_archive_cmds_RC='`$ECHO "$old_archive_cmds_RC" | $SED "$delay_single_quote_subst"`' compiler_RC='`$ECHO "$compiler_RC" | $SED "$delay_single_quote_subst"`' GCC_RC='`$ECHO "$GCC_RC" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag_RC='`$ECHO "$lt_prog_compiler_no_builtin_flag_RC" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_pic_RC='`$ECHO "$lt_prog_compiler_pic_RC" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_wl_RC='`$ECHO "$lt_prog_compiler_wl_RC" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_static_RC='`$ECHO "$lt_prog_compiler_static_RC" | $SED "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o_RC='`$ECHO "$lt_cv_prog_compiler_c_o_RC" | $SED "$delay_single_quote_subst"`' archive_cmds_need_lc_RC='`$ECHO "$archive_cmds_need_lc_RC" | $SED "$delay_single_quote_subst"`' enable_shared_with_static_runtimes_RC='`$ECHO "$enable_shared_with_static_runtimes_RC" | $SED "$delay_single_quote_subst"`' export_dynamic_flag_spec_RC='`$ECHO "$export_dynamic_flag_spec_RC" | $SED "$delay_single_quote_subst"`' whole_archive_flag_spec_RC='`$ECHO "$whole_archive_flag_spec_RC" | $SED "$delay_single_quote_subst"`' compiler_needs_object_RC='`$ECHO "$compiler_needs_object_RC" | $SED "$delay_single_quote_subst"`' old_archive_from_new_cmds_RC='`$ECHO "$old_archive_from_new_cmds_RC" | $SED "$delay_single_quote_subst"`' old_archive_from_expsyms_cmds_RC='`$ECHO "$old_archive_from_expsyms_cmds_RC" | $SED "$delay_single_quote_subst"`' archive_cmds_RC='`$ECHO "$archive_cmds_RC" | $SED "$delay_single_quote_subst"`' archive_expsym_cmds_RC='`$ECHO "$archive_expsym_cmds_RC" | $SED "$delay_single_quote_subst"`' module_cmds_RC='`$ECHO "$module_cmds_RC" | $SED "$delay_single_quote_subst"`' module_expsym_cmds_RC='`$ECHO "$module_expsym_cmds_RC" | $SED "$delay_single_quote_subst"`' with_gnu_ld_RC='`$ECHO "$with_gnu_ld_RC" | $SED "$delay_single_quote_subst"`' allow_undefined_flag_RC='`$ECHO "$allow_undefined_flag_RC" | $SED "$delay_single_quote_subst"`' no_undefined_flag_RC='`$ECHO "$no_undefined_flag_RC" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec_RC='`$ECHO "$hardcode_libdir_flag_spec_RC" | $SED "$delay_single_quote_subst"`' hardcode_libdir_separator_RC='`$ECHO "$hardcode_libdir_separator_RC" | $SED "$delay_single_quote_subst"`' hardcode_direct_RC='`$ECHO "$hardcode_direct_RC" | $SED "$delay_single_quote_subst"`' hardcode_direct_absolute_RC='`$ECHO "$hardcode_direct_absolute_RC" | $SED "$delay_single_quote_subst"`' hardcode_minus_L_RC='`$ECHO "$hardcode_minus_L_RC" | $SED "$delay_single_quote_subst"`' hardcode_shlibpath_var_RC='`$ECHO "$hardcode_shlibpath_var_RC" | $SED "$delay_single_quote_subst"`' hardcode_automatic_RC='`$ECHO "$hardcode_automatic_RC" | $SED "$delay_single_quote_subst"`' inherit_rpath_RC='`$ECHO "$inherit_rpath_RC" | $SED "$delay_single_quote_subst"`' link_all_deplibs_RC='`$ECHO "$link_all_deplibs_RC" | $SED "$delay_single_quote_subst"`' always_export_symbols_RC='`$ECHO "$always_export_symbols_RC" | $SED "$delay_single_quote_subst"`' export_symbols_cmds_RC='`$ECHO "$export_symbols_cmds_RC" | $SED "$delay_single_quote_subst"`' exclude_expsyms_RC='`$ECHO "$exclude_expsyms_RC" | $SED "$delay_single_quote_subst"`' include_expsyms_RC='`$ECHO "$include_expsyms_RC" | $SED "$delay_single_quote_subst"`' prelink_cmds_RC='`$ECHO "$prelink_cmds_RC" | $SED "$delay_single_quote_subst"`' postlink_cmds_RC='`$ECHO "$postlink_cmds_RC" | $SED "$delay_single_quote_subst"`' file_list_spec_RC='`$ECHO "$file_list_spec_RC" | $SED "$delay_single_quote_subst"`' hardcode_action_RC='`$ECHO "$hardcode_action_RC" | $SED "$delay_single_quote_subst"`' LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } # Quote evaled strings. for var in AS \ DLLTOOL \ OBJDUMP \ SHELL \ ECHO \ PATH_SEPARATOR \ SED \ GREP \ EGREP \ FGREP \ LD \ NM \ LN_S \ lt_SP2NL \ lt_NL2SP \ reload_flag \ deplibs_check_method \ file_magic_cmd \ file_magic_glob \ want_nocaseglob \ sharedlib_from_linklib_cmd \ AR \ AR_FLAGS \ archiver_list_spec \ STRIP \ RANLIB \ CC \ CFLAGS \ compiler \ lt_cv_sys_global_symbol_pipe \ lt_cv_sys_global_symbol_to_cdecl \ lt_cv_sys_global_symbol_to_import \ lt_cv_sys_global_symbol_to_c_name_address \ lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ lt_cv_nm_interface \ nm_file_list_spec \ lt_cv_truncate_bin \ lt_prog_compiler_no_builtin_flag \ lt_prog_compiler_pic \ lt_prog_compiler_wl \ lt_prog_compiler_static \ lt_cv_prog_compiler_c_o \ need_locks \ MANIFEST_TOOL \ DSYMUTIL \ NMEDIT \ LIPO \ OTOOL \ OTOOL64 \ shrext_cmds \ export_dynamic_flag_spec \ whole_archive_flag_spec \ compiler_needs_object \ with_gnu_ld \ allow_undefined_flag \ no_undefined_flag \ hardcode_libdir_flag_spec \ hardcode_libdir_separator \ exclude_expsyms \ include_expsyms \ file_list_spec \ variables_saved_for_relink \ libname_spec \ library_names_spec \ soname_spec \ install_override_mode \ finish_eval \ old_striplib \ striplib \ LD_RC \ reload_flag_RC \ compiler_RC \ lt_prog_compiler_no_builtin_flag_RC \ lt_prog_compiler_pic_RC \ lt_prog_compiler_wl_RC \ lt_prog_compiler_static_RC \ lt_cv_prog_compiler_c_o_RC \ export_dynamic_flag_spec_RC \ whole_archive_flag_spec_RC \ compiler_needs_object_RC \ with_gnu_ld_RC \ allow_undefined_flag_RC \ no_undefined_flag_RC \ hardcode_libdir_flag_spec_RC \ hardcode_libdir_separator_RC \ exclude_expsyms_RC \ include_expsyms_RC \ file_list_spec_RC; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in reload_cmds \ old_postinstall_cmds \ old_postuninstall_cmds \ old_archive_cmds \ extract_expsyms_cmds \ old_archive_from_new_cmds \ old_archive_from_expsyms_cmds \ archive_cmds \ archive_expsym_cmds \ module_cmds \ module_expsym_cmds \ export_symbols_cmds \ prelink_cmds \ postlink_cmds \ postinstall_cmds \ postuninstall_cmds \ finish_cmds \ sys_lib_search_path_spec \ configure_time_dlsearch_path \ configure_time_lt_sys_library_path \ reload_cmds_RC \ old_archive_cmds_RC \ old_archive_from_new_cmds_RC \ old_archive_from_expsyms_cmds_RC \ archive_cmds_RC \ archive_expsym_cmds_RC \ module_cmds_RC \ module_expsym_cmds_RC \ export_symbols_cmds_RC \ prelink_cmds_RC \ postlink_cmds_RC; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done ac_aux_dir='$ac_aux_dir' # See if we are running on zsh, and set the options that allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi PACKAGE='$PACKAGE' VERSION='$VERSION' RM='$RM' ofile='$ofile' _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "include/config.h") CONFIG_HEADERS="$CONFIG_HEADERS include/config.h" ;; "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; "include/freetds/version.h") CONFIG_FILES="$CONFIG_FILES include/freetds/version.h" ;; "include/tds_sysdep_public.h") CONFIG_FILES="$CONFIG_FILES include/tds_sysdep_public.h" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "include/Makefile") CONFIG_FILES="$CONFIG_FILES include/Makefile" ;; "include/freetds/Makefile") CONFIG_FILES="$CONFIG_FILES include/freetds/Makefile" ;; "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; "samples/Makefile") CONFIG_FILES="$CONFIG_FILES samples/Makefile" ;; "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; "src/tds/Makefile") CONFIG_FILES="$CONFIG_FILES src/tds/Makefile" ;; "src/tds/unittests/Makefile") CONFIG_FILES="$CONFIG_FILES src/tds/unittests/Makefile" ;; "src/dblib/Makefile") CONFIG_FILES="$CONFIG_FILES src/dblib/Makefile" ;; "src/dblib/unittests/Makefile") CONFIG_FILES="$CONFIG_FILES src/dblib/unittests/Makefile" ;; "src/ctlib/Makefile") CONFIG_FILES="$CONFIG_FILES src/ctlib/Makefile" ;; "src/ctlib/unittests/Makefile") CONFIG_FILES="$CONFIG_FILES src/ctlib/unittests/Makefile" ;; "src/replacements/Makefile") CONFIG_FILES="$CONFIG_FILES src/replacements/Makefile" ;; "src/replacements/unittests/Makefile") CONFIG_FILES="$CONFIG_FILES src/replacements/unittests/Makefile" ;; "src/server/Makefile") CONFIG_FILES="$CONFIG_FILES src/server/Makefile" ;; "src/pool/Makefile") CONFIG_FILES="$CONFIG_FILES src/pool/Makefile" ;; "src/odbc/Makefile") CONFIG_FILES="$CONFIG_FILES src/odbc/Makefile" ;; "src/odbc/unittests/Makefile") CONFIG_FILES="$CONFIG_FILES src/odbc/unittests/Makefile" ;; "src/apps/Makefile") CONFIG_FILES="$CONFIG_FILES src/apps/Makefile" ;; "src/apps/fisql/Makefile") CONFIG_FILES="$CONFIG_FILES src/apps/fisql/Makefile" ;; "freetds.spec") CONFIG_FILES="$CONFIG_FILES freetds.spec" ;; "win32/Makefile") CONFIG_FILES="$CONFIG_FILES win32/Makefile" ;; "win32/freetds.nsh") CONFIG_FILES="$CONFIG_FILES win32/freetds.nsh" ;; "src/odbc/version.rc") CONFIG_FILES="$CONFIG_FILES src/odbc/version.rc" ;; "vms/Makefile") CONFIG_FILES="$CONFIG_FILES vms/Makefile" ;; "misc/Makefile") CONFIG_FILES="$CONFIG_FILES misc/Makefile" ;; "doc/freebcp.1") CONFIG_FILES="$CONFIG_FILES doc/freebcp.1" ;; "doc/tsql.1") CONFIG_FILES="$CONFIG_FILES doc/tsql.1" ;; "doc/osql.1") CONFIG_FILES="$CONFIG_FILES doc/osql.1" ;; "doc/bsqldb.1") CONFIG_FILES="$CONFIG_FILES doc/bsqldb.1" ;; "doc/bsqlodbc.1") CONFIG_FILES="$CONFIG_FILES doc/bsqlodbc.1" ;; "doc/defncopy.1") CONFIG_FILES="$CONFIG_FILES doc/defncopy.1" ;; "doc/datacopy.1") CONFIG_FILES="$CONFIG_FILES doc/datacopy.1" ;; "doc/fisql.1") CONFIG_FILES="$CONFIG_FILES doc/fisql.1" ;; "doc/freetds.conf.5") CONFIG_FILES="$CONFIG_FILES doc/freetds.conf.5" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac ac_MKDIR_P=$MKDIR_P case $MKDIR_P in [\\/$]* | ?:[\\/]* ) ;; */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi # Compute "$ac_file"'s index in $config_headers. _am_arg="$ac_file" _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || $as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$_am_arg" : 'X\(//\)[^/]' \| \ X"$_am_arg" : 'X\(//\)$' \| \ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'`/stamp-h$_am_stamp_count ;; :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || { # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named 'Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`$as_dirname -- "$mf" || $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$mf" : 'X\(//\)[^/]' \| \ X"$mf" : 'X\(//\)$' \| \ X"$mf" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running 'make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "$am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`$as_dirname -- "$file" || $as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$file" : 'X\(//\)[^/]' \| \ X"$file" : 'X\(//\)$' \| \ X"$file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir=$dirpart/$fdir; as_fn_mkdir_p # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ;; "libtool":C) # See if we are running on zsh, and set the options that allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}"; then setopt NO_GLOB_SUBST fi cfgfile=${ofile}T trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # Generated automatically by $as_me ($PACKAGE) $VERSION # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # Provide generalized library-building support services. # Written by Gordon Matzigkeit, 1996 # Copyright (C) 2014 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # GNU Libtool 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 of the License, or # (at your option) any later version. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program or library that is built # using GNU Libtool, you may include this file under the same # distribution terms that you use for the rest of that program. # # GNU Libtool 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, see . # The names of the tagged configurations supported by this script. available_tags='RC ' # Configured defaults for sys_lib_dlsearch_path munging. : \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"} # ### BEGIN LIBTOOL CONFIG # Which release of libtool.m4 was used? macro_version=$macro_version macro_revision=$macro_revision # Assembler program. AS=$lt_AS # DLL creation program. DLLTOOL=$lt_DLLTOOL # Object dumper program. OBJDUMP=$lt_OBJDUMP # Whether or not to build shared libraries. build_libtool_libs=$enable_shared # Whether or not to build static libraries. build_old_libs=$enable_static # What type of objects to build. pic_mode=$pic_mode # Whether or not to optimize for fast installation. fast_install=$enable_fast_install # Shared archive member basename,for filename based shared library versioning on AIX. shared_archive_member_spec=$shared_archive_member_spec # Shell to use when invoking shell scripts. SHELL=$lt_SHELL # An echo program that protects backslashes. ECHO=$lt_ECHO # The PATH separator for the build system. PATH_SEPARATOR=$lt_PATH_SEPARATOR # The host system. host_alias=$host_alias host=$host host_os=$host_os # The build system. build_alias=$build_alias build=$build build_os=$build_os # A sed program that does not truncate output. SED=$lt_SED # Sed that helps us avoid accidentally triggering echo(1) options like -n. Xsed="\$SED -e 1s/^X//" # A grep program that handles long lines. GREP=$lt_GREP # An ERE matcher. EGREP=$lt_EGREP # A literal string matcher. FGREP=$lt_FGREP # A BSD- or MS-compatible name lister. NM=$lt_NM # Whether we need soft or hard links. LN_S=$lt_LN_S # What is the maximum length of a command? max_cmd_len=$max_cmd_len # Object file suffix (normally "o"). objext=$ac_objext # Executable file suffix (normally ""). exeext=$exeext # whether the shell understands "unset". lt_unset=$lt_unset # turn spaces into newlines. SP2NL=$lt_lt_SP2NL # turn newlines into spaces. NL2SP=$lt_lt_NL2SP # convert \$build file names to \$host format. to_host_file_cmd=$lt_cv_to_host_file_cmd # convert \$build files to toolchain format. to_tool_file_cmd=$lt_cv_to_tool_file_cmd # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method # Command to use when deplibs_check_method = "file_magic". file_magic_cmd=$lt_file_magic_cmd # How to find potential files when deplibs_check_method = "file_magic". file_magic_glob=$lt_file_magic_glob # Find potential files using nocaseglob when deplibs_check_method = "file_magic". want_nocaseglob=$lt_want_nocaseglob # Command to associate shared and link libraries. sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd # The archiver. AR=$lt_AR # Flags to create an archive. AR_FLAGS=$lt_AR_FLAGS # How to feed a file listing to the archiver. archiver_list_spec=$lt_archiver_list_spec # A symbol stripping program. STRIP=$lt_STRIP # Commands used to install an old-style archive. RANLIB=$lt_RANLIB old_postinstall_cmds=$lt_old_postinstall_cmds old_postuninstall_cmds=$lt_old_postuninstall_cmds # Whether to use a lock for old archive extraction. lock_old_archive_extraction=$lock_old_archive_extraction # A C compiler. LTCC=$lt_CC # LTCC compiler flags. LTCFLAGS=$lt_CFLAGS # Take the output of nm and produce a listing of raw symbols and C names. global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe # Transform the output of nm in a proper C declaration. global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl # Transform the output of nm into a list of symbols to manually relocate. global_symbol_to_import=$lt_lt_cv_sys_global_symbol_to_import # Transform the output of nm in a C name address pair. global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address # Transform the output of nm in a C name address pair when lib prefix is needed. global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix # The name lister interface. nm_interface=$lt_lt_cv_nm_interface # Specify filename containing input files for \$NM. nm_file_list_spec=$lt_nm_file_list_spec # The root where to search for dependent libraries,and where our libraries should be installed. lt_sysroot=$lt_sysroot # Command to truncate a binary pipe. lt_truncate_bin=$lt_lt_cv_truncate_bin # The name of the directory that contains temporary libtool files. objdir=$objdir # Used to examine libraries when file_magic_cmd begins with "file". MAGIC_CMD=$MAGIC_CMD # Must we lock files when doing compilation? need_locks=$lt_need_locks # Manifest tool. MANIFEST_TOOL=$lt_MANIFEST_TOOL # Tool to manipulate archived DWARF debug symbol files on Mac OS X. DSYMUTIL=$lt_DSYMUTIL # Tool to change global to local symbols on Mac OS X. NMEDIT=$lt_NMEDIT # Tool to manipulate fat objects and archives on Mac OS X. LIPO=$lt_LIPO # ldd/readelf like tool for Mach-O binaries on Mac OS X. OTOOL=$lt_OTOOL # ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. OTOOL64=$lt_OTOOL64 # Old archive suffix (normally "a"). libext=$libext # Shared library suffix (normally ".so"). shrext_cmds=$lt_shrext_cmds # The commands to extract the exported symbol list from a shared archive. extract_expsyms_cmds=$lt_extract_expsyms_cmds # Variables whose values should be saved in libtool wrapper scripts and # restored at link time. variables_saved_for_relink=$lt_variables_saved_for_relink # Do we need the "lib" prefix for modules? need_lib_prefix=$need_lib_prefix # Do we need a version for libraries? need_version=$need_version # Library versioning type. version_type=$version_type # Shared library runtime path variable. runpath_var=$runpath_var # Shared library path variable. shlibpath_var=$shlibpath_var # Is shlibpath searched before the hard-coded library search path? shlibpath_overrides_runpath=$shlibpath_overrides_runpath # Format of library name prefix. libname_spec=$lt_libname_spec # List of archive names. First name is the real one, the rest are links. # The last name is the one that the linker finds with -lNAME library_names_spec=$lt_library_names_spec # The coded name of the library, if different from the real name. soname_spec=$lt_soname_spec # Permission mode override for installation of shared libraries. install_override_mode=$lt_install_override_mode # Command to use after installation of a shared archive. postinstall_cmds=$lt_postinstall_cmds # Command to use after uninstallation of a shared archive. postuninstall_cmds=$lt_postuninstall_cmds # Commands used to finish a libtool library installation in a directory. finish_cmds=$lt_finish_cmds # As "finish_cmds", except a single script fragment to be evaled but # not shown. finish_eval=$lt_finish_eval # Whether we should hardcode library paths into libraries. hardcode_into_libs=$hardcode_into_libs # Compile-time system search path for libraries. sys_lib_search_path_spec=$lt_sys_lib_search_path_spec # Detected run-time system search path for libraries. sys_lib_dlsearch_path_spec=$lt_configure_time_dlsearch_path # Explicit LT_SYS_LIBRARY_PATH set during ./configure time. configure_time_lt_sys_library_path=$lt_configure_time_lt_sys_library_path # Whether dlopen is supported. dlopen_support=$enable_dlopen # Whether dlopen of programs is supported. dlopen_self=$enable_dlopen_self # Whether dlopen of statically linked programs is supported. dlopen_self_static=$enable_dlopen_self_static # Commands to strip libraries. old_striplib=$lt_old_striplib striplib=$lt_striplib # The linker used to build libraries. LD=$lt_LD # How to create reloadable object files. reload_flag=$lt_reload_flag reload_cmds=$lt_reload_cmds # Commands used to build an old-style archive. old_archive_cmds=$lt_old_archive_cmds # A language specific compiler. CC=$lt_compiler # Is the compiler the GNU compiler? with_gcc=$GCC # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc # Whether or not to disallow shared libs when runtime libs are static. allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec # Whether the compiler copes with passing no objects directly. compiler_needs_object=$lt_compiler_needs_object # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds # Commands used to build a shared archive. archive_cmds=$lt_archive_cmds archive_expsym_cmds=$lt_archive_expsym_cmds # Commands used to build a loadable module if different from building # a shared archive. module_cmds=$lt_module_cmds module_expsym_cmds=$lt_module_expsym_cmds # Whether we are building with GNU ld or not. with_gnu_ld=$lt_with_gnu_ld # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag # Flag that enforces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator # Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes # DIR into the resulting binary. hardcode_direct=$hardcode_direct # Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes # DIR into the resulting binary and the resulting library dependency is # "absolute",i.e impossible to change by setting \$shlibpath_var if the # library is relocated. hardcode_direct_absolute=$hardcode_direct_absolute # Set to "yes" if using the -LDIR flag during linking hardcodes DIR # into the resulting binary. hardcode_minus_L=$hardcode_minus_L # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR # into the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var # Set to "yes" if building a shared library automatically hardcodes DIR # into the library and all subsequent libraries and executables linked # against it. hardcode_automatic=$hardcode_automatic # Set to yes if linker adds runtime paths of dependent libraries # to runtime path list. inherit_rpath=$inherit_rpath # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs # Set to "yes" if exported symbols are required. always_export_symbols=$always_export_symbols # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms # Symbols that must always be exported. include_expsyms=$lt_include_expsyms # Commands necessary for linking programs (against libraries) with templates. prelink_cmds=$lt_prelink_cmds # Commands necessary for finishing linking programs. postlink_cmds=$lt_postlink_cmds # Specify filename containing input files. file_list_spec=$lt_file_list_spec # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action # ### END LIBTOOL CONFIG _LT_EOF cat <<'_LT_EOF' >> "$cfgfile" # ### BEGIN FUNCTIONS SHARED WITH CONFIGURE # func_munge_path_list VARIABLE PATH # ----------------------------------- # VARIABLE is name of variable containing _space_ separated list of # directories to be munged by the contents of PATH, which is string # having a format: # "DIR[:DIR]:" # string "DIR[ DIR]" will be prepended to VARIABLE # ":DIR[:DIR]" # string "DIR[ DIR]" will be appended to VARIABLE # "DIRP[:DIRP]::[DIRA:]DIRA" # string "DIRP[ DIRP]" will be prepended to VARIABLE and string # "DIRA[ DIRA]" will be appended to VARIABLE # "DIR[:DIR]" # VARIABLE will be replaced by "DIR[ DIR]" func_munge_path_list () { case x$2 in x) ;; *:) eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\" ;; x:*) eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\" ;; *::*) eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\" ;; *) eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\" ;; esac } # Calculate cc_basename. Skip known compiler wrappers and cross-prefix. func_cc_basename () { for cc_temp in $*""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` } # ### END FUNCTIONS SHARED WITH CONFIGURE _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test set != "${COLLECT_NAMES+set}"; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac ltmain=$ac_aux_dir/ltmain.sh # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" cat <<_LT_EOF >> "$ofile" # ### BEGIN LIBTOOL TAG CONFIG: RC # The linker used to build libraries. LD=$lt_LD_RC # How to create reloadable object files. reload_flag=$lt_reload_flag_RC reload_cmds=$lt_reload_cmds_RC # Commands used to build an old-style archive. old_archive_cmds=$lt_old_archive_cmds_RC # A language specific compiler. CC=$lt_compiler_RC # Is the compiler the GNU compiler? with_gcc=$GCC_RC # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_RC # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic_RC # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl_RC # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static_RC # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o_RC # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc_RC # Whether or not to disallow shared libs when runtime libs are static. allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_RC # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_RC # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec_RC # Whether the compiler copes with passing no objects directly. compiler_needs_object=$lt_compiler_needs_object_RC # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_RC # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_RC # Commands used to build a shared archive. archive_cmds=$lt_archive_cmds_RC archive_expsym_cmds=$lt_archive_expsym_cmds_RC # Commands used to build a loadable module if different from building # a shared archive. module_cmds=$lt_module_cmds_RC module_expsym_cmds=$lt_module_expsym_cmds_RC # Whether we are building with GNU ld or not. with_gnu_ld=$lt_with_gnu_ld_RC # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag_RC # Flag that enforces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag_RC # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_RC # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator_RC # Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes # DIR into the resulting binary. hardcode_direct=$hardcode_direct_RC # Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes # DIR into the resulting binary and the resulting library dependency is # "absolute",i.e impossible to change by setting \$shlibpath_var if the # library is relocated. hardcode_direct_absolute=$hardcode_direct_absolute_RC # Set to "yes" if using the -LDIR flag during linking hardcodes DIR # into the resulting binary. hardcode_minus_L=$hardcode_minus_L_RC # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR # into the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var_RC # Set to "yes" if building a shared library automatically hardcodes DIR # into the library and all subsequent libraries and executables linked # against it. hardcode_automatic=$hardcode_automatic_RC # Set to yes if linker adds runtime paths of dependent libraries # to runtime path list. inherit_rpath=$inherit_rpath_RC # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs_RC # Set to "yes" if exported symbols are required. always_export_symbols=$always_export_symbols_RC # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds_RC # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms_RC # Symbols that must always be exported. include_expsyms=$lt_include_expsyms_RC # Commands necessary for linking programs (against libraries) with templates. prelink_cmds=$lt_prelink_cmds_RC # Commands necessary for finishing linking programs. postlink_cmds=$lt_postlink_cmds_RC # Specify filename containing input files. file_list_spec=$lt_file_list_spec_RC # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action_RC # ### END LIBTOOL TAG CONFIG: RC _LT_EOF ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi freetds-1.00.82/configure.ac100644 025423 025423 00000073335 13242511101 0011315dnl Process this file with autoconf to produce a configure script. dnl ------------------------------------------------------------ dnl If you're trying to create a new configure test, try dnl dnl http://autogen.sourceforge.net/conftest.html dnl http://autoconf-archive.cryp.to/ dnl dnl ------------------------------------------------------------ # ------------------------------------------------------------ # Initialization # ------------------------------------------------------------ AC_INIT(FreeTDS, 1.00.82) AC_CONFIG_SRCDIR(src/dblib/dblib.c) AC_PREREQ(2.53) AM_INIT_AUTOMAKE([dist-bzip2 parallel-tests subdir-objects]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)]) AC_CONFIG_HEADERS(include/config.h) AC_CONFIG_MACRO_DIR([m4]) dnl configuration directory will be /usr/local/etc AC_PREFIX_DEFAULT(/usr/local) dnl This disable address sanitizer leak detector as dnl some checks cause leaks which are detected as errors ASAN_OPTIONS='detect_leaks=0' export ASAN_OPTIONS dnl 0.X.Y -> 0.X.Y dnl 0.X.dev.date -> 0.(X-1).9999 dnl 0.XrcY -> 0.(X-1).9999 dnl dev.0.X.Y -> 0.X.Y ver=[`echo $VERSION.0 | sed 's,^dev\.,,; s,^\([0-9][0-9]*\.[0-9][0-9]*\)rc,\1.dev.,g; s/\.dev\./.9999./'`] match=['^\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*'] if test "`echo $ver | sed \"s,$match,,\"`" != ""; then AC_MSG_ERROR([Invalid version $VERSION specified]) fi MAJOR=[`echo $ver | sed "s,$match,\1,"`] MINOR=[`echo $ver | sed "s,$match,\2,"`] SUBVERSION=[`echo $ver | sed "s,$match,\3,"`] BUILD_NUMBER="`date +1%j` - 1000 + ( `date +%Y` - 2000 )" BUILD_NUMBER="`expr $BUILD_NUMBER \* 366`" if test "$SUBVERSION" = "9999"; then MINOR=`expr $MINOR - 1` fi AC_SUBST(MAJOR) AC_SUBST(MINOR) AC_SUBST(SUBVERSION) AC_SUBST(BUILD_NUMBER) # ------------------------------------------------------------ # Commands and Utilities # ------------------------------------------------------------ AC_PROG_AWK AC_PROG_GREP AC_PROG_INSTALL AC_PROG_MKDIR_P AC_PROG_LN_S AC_PROG_SED PKG_PROG_PKG_CONFIG # ------------------------------------------------------------ # Host-specific configuration # ------------------------------------------------------------ AC_CANONICAL_HOST netdb_reentrant=no case $host in *-*-osf*) CPPFLAGS="$CPPFLAGS -D_OSF_SOURCE -D_XOPEN_SOURCE_EXTENDED -D_POSIX_C_SOURCE=199506L" netdb_reentrant=yes ;; *-*-hpux11*) netdb_reentrant=yes ;; *-*-cygwin*) netdb_reentrant=yes ;; esac case $host_os in darwin* | rhapsody*) AM_CONDITIONAL(MACOSX, true) ;; *) AM_CONDITIONAL(MACOSX, false) ;; esac if test $netdb_reentrant = yes; then AC_DEFINE(NETDB_REENTRANT, 1, [Define to 1 if the BSD-style netdb interface is reentrant.]) fi AC_GNU_SOURCE AC_SYS_LARGEFILE # ------------------------------------------------------------ # Checks for programs. # ------------------------------------------------------------ AC_PROG_CC AC_PROG_CPP AM_PROG_CC_C_O AC_C_INLINE dnl Disable libtool 1.5 support for languages we don't use dnl (cfr http://lists.gnu.org/archive/html/libtool/2005-08/msg00137.html) define([AC_LIBTOOL_LANG_CXX_CONFIG], [:])dnl define([AC_LIBTOOL_LANG_F77_CONFIG], [:])dnl define([AC_LIBTOOL_LANG_GCJ_CONFIG], [:])dnl LT_INIT([win32-dll]) AC_LTDL_DLLIB LT_AC_PROG_RC AC_ARG_ENABLE(libiconv, AS_HELP_STRING([--disable-libiconv], [do not attempt to include libiconv]), [use_libiconv=$enableval], [use_libiconv=yes]) if test "$use_libiconv" = "yes" ; then AM_ICONV else AC_MSG_NOTICE(libiconv disabled) AC_DEFINE_UNQUOTED(ICONV_CONST, const, [Define as const if the declaration of iconv() needs const.]) fi # See if we have doxygen installed AC_CHECK_PROG(DOXYGEN,doxygen,doxygen) AM_CONDITIONAL(HAVE_DOXYGEN, [test -n "$DOXYGEN"]) AC_CHECK_PROG(ODBC_CONFIG,odbc_config,odbc_config) # ------------------------------------------------------------ # Check for CVS-only sources. # ------------------------------------------------------------ # # Distribution tarballs include some generated files. These # files are not maintained in CVS, but their bases are, and # the bases are not in the tarball. For example, num_limits.h # is distributed, but it is generated from numeric.pl, which # is kept in CVS. # If the base is found, we use it as a source in the Makefile, # otherwise the Makefile will (correctly) assume that the # generated file is already present. # if test -f "${srcdir}/src/tds/num_limits.pl"; then AM_CONDITIONAL(HAVE_PERL_SOURCES, true) else AM_CONDITIONAL(HAVE_PERL_SOURCES, false) fi AC_SUBST(HAVE_PERL_SOURCES) # ------------------------------------------------------------ # Checks for libraries. # ------------------------------------------------------------ AC_ARG_ENABLE(krb5, AS_HELP_STRING([--enable-krb5@<:@=LIB@:>@], [enable Kerberos support, optionally with library])) krb5_libs=auto case $enable_krb5 in yes) ;; "" | no) krb5_libs= ;; -* | */* | *.a | *.so | *.so.* | *.o) krb5_libs="$enable_krb5" ;; *) krb5_libs="-l$enable_krb5" ;; esac ACX_PUSH_LIBS("") tds_mingw=no case $host in *-*-mingw*) tds_mingw=yes if test "$host_cpu" = "x86_64"; then LIBS="-lws2_32" elif test -r /usr/lib/w32api/libws2_32.a; then LIBS="-L/usr/lib/w32api -lws2_32" else LIBS="-lws2_32" fi krb5_libs= AM_CONDITIONAL(MINGW32, true) ;; *-*-hpux*) # these lines are needed to fix a problem for HP-UX # HP-UX define two versions of sockets, one BSD and one X/Open # these versions are not binary compatible (BSD use int where X/Open # use socklen_t == size_t) and different libraries (BSD in libc and # X/Open in libxnet). X/Open is used if _XOPEN_SOURCE and # _XOPEN_SOURCE_EXTENDED are defined. To complicate the things gcc # by default define _XOPEN_SOURCE_EXTENDED so define always both # constants and link always libxnet! CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED" LIBS="$LIBS -lxnet" AC_SEARCH_LIBS(gethostbyname, nsl) # check for _xpg_ functions AC_CHECK_FUNCS([_xpg_accept _xpg_getpeername _xpg_getsockname _xpg_getsockopt _xpg_recvfrom \ __accept __getpeername __getsockname __getsockopt __recvfrom]) AM_CONDITIONAL(MINGW32, false) ;; *) AC_SEARCH_LIBS(socket, socket) AC_SEARCH_LIBS(gethostbyname, nsl) AM_CONDITIONAL(MINGW32, false) ;; esac case "$krb5_libs" in "" ) ;; "auto") AC_SEARCH_LIBS(gss_init_sec_context, [gssapi_krb5 gssapi]) if test "$ac_cv_search_gss_init_sec_context" != no; then AC_DEFINE(ENABLE_KRB5, 1, [Defined if --enable-krb5 used and library detected]) fi ;; *) AC_DEFINE(ENABLE_KRB5, 1, [Defined if --enable-krb5 used and library detected]) LIBS="$LIBS $krb5_libs" ;; esac if test -n "$krb5_libs"; then for d in /usr/include/heimdal /usr/include/krb5 /usr/include/et; do if test -d "$d"; then CPPFLAGS="$CPPFLAGS -I$d" fi done AC_CHECK_FUNCS([error_message]) fi NETWORK_LIBS="$LIBS" ACX_POP_LIBS AC_SUBST(NETWORK_LIBS) if test $tds_mingw = no; then # readline test # Readline is needed by the tty session. Set up a special READLINE_LIBS # substitution for it. # Readline is linked with curses, and on some systems termcap must be # linked in. Others (inc debian) have termcap built into ncurses. ACX_PUSH_LIBS("") AC_SEARCH_LIBS(tgetent, [readline ncurses curses termcap]) AC_CHECK_LIB([readline], [readline], [LIBS="$LIBS -lreadline" AC_DEFINE(HAVE_READLINE, 1, [Define to 1 if you have the GNU Readline library.])], [LIBS=""] ) AC_CHECK_FUNCS([rl_on_new_line rl_reset_line_state]) AC_LINK_IFELSE([AC_LANG_SOURCE([[ #include #ifdef HAVE_STDLIB_H #include #endif #ifdef HAVE_READLINE #include #include #endif /* HAVE_READLINE */ int main() { rl_inhibit_completion = 1; return 0; } ]])],AC_DEFINE(HAVE_RL_INHIBIT_COMPLETION, 1, [Define to 1 if you have rl_inhibit_completion.])) READLINE_LIBS="$LIBS" ACX_POP_LIBS AC_SUBST(READLINE_LIBS) ACX_PTHREAD AM_CFLAGS="$AM_CFLAGS $PTHREAD_CFLAGS" AC_SUBST(AM_CFLAGS) LIBS="$PTHREAD_LIBS $LIBS" AC_SEARCH_LIBS(pthread_condattr_setclock, [rt posix4 pthread]) AC_CHECK_FUNCS([pthread_condattr_setclock pthread_cond_timedwait_relative_np]) fi # check for SSPI AC_ARG_ENABLE(sspi, AS_HELP_STRING([--disable-sspi], [disable SSPI support])) # disable by default enable_sspi=${enable_sspi-yes} # only if MingW (TODO other compilers) test $tds_mingw != yes && enable_sspi=no AM_CONDITIONAL(HAVE_SSPI, test "$enable_sspi" = "yes") if test "$enable_sspi" = "yes"; then AC_DEFINE(HAVE_SSPI, 1, [Defined if not --disable-sspi and SSPI detected]) fi # ------------------------------------------------------------ # Checks for header files. # ------------------------------------------------------------ AC_HEADER_STDC AC_HEADER_TIME AC_STRUCT_TIMEZONE AC_CHECK_MEMBERS([struct tm.__tm_zone],,,[#include #include <$ac_cv_struct_tm> ]) AC_CHECK_HEADERS([errno.h libgen.h \ limits.h locale.h poll.h \ signal.h stddef.h \ sys/param.h sys/select.h sys/stat.h \ sys/time.h sys/types.h sys/resource.h \ sys/eventfd.h \ sys/wait.h unistd.h netdb.h \ wchar.h inttypes.h winsock2.h \ localcharset.h valgrind/memcheck.h malloc.h dirent.h \ stdbool.h gnutls/abstract.h getopt.h fcntl.h]) AC_CHECK_HEADERS([windows.h sql.h],[],[],[[#ifdef HAVE_WINDOWS_H # include #endif #ifdef HAVE_SQL_H # include #endif ]]) if test $tds_mingw = no; then AC_CHECK_HEADERS([ arpa/inet.h \ langinfo.h \ netdb.h \ netinet/in.h \ netinet/tcp.h \ roken.h \ com_err.h \ paths.h \ sys/ioctl.h \ sys/socket.h ]) fi AC_HAVE_INADDR_NONE # ------------------------------------------------------------ # Checks for integers/floats of different sizes # ------------------------------------------------------------ AC_CHECK_SIZEOF(char) AC_CHECK_SIZEOF(short) AC_CHECK_SIZEOF(long) AC_CHECK_SIZEOF(int) AC_CHECK_SIZEOF(float) AC_CHECK_SIZEOF(double) AC_CHECK_SIZEOF(long double) AC_CHECK_SIZEOF(long long) AC_CHECK_SIZEOF(__int64) AC_CHECK_SIZEOF(void *) AC_CHECK_SIZEOF(wchar_t,,[$ac_includes_default #ifdef HAVE_WCHAR_H #include #endif]) case 2 in $ac_cv_sizeof_short) tds_sysdep_int16_type=short;; $ac_cv_sizeof_int) tds_sysdep_int16_type=int;; *) AC_MSG_ERROR(No 16-bit int found.) esac case 4 in $ac_cv_sizeof_short) tds_sysdep_int32_type=short;; $ac_cv_sizeof_int) tds_sysdep_int32_type=int;; $ac_cv_sizeof_long) tds_sysdep_int32_type=long;; *) AC_MSG_ERROR(No 32-bit int found.) esac case 4 in $ac_cv_sizeof_float) tds_sysdep_real32_type=float;; $ac_cv_sizeof_double) tds_sysdep_real32_type=double;; $ac_cv_sizeof_long_double) tds_sysdep_real32_type="long double";; *) AC_MSG_ERROR(No 32-bit real found.) esac case 8 in $ac_cv_sizeof_float) tds_sysdep_real64_type=float;; $ac_cv_sizeof_double) tds_sysdep_real64_type=double;; $ac_cv_sizeof_long_double) tds_sysdep_real64_type="long double";; *) AC_MSG_ERROR(No 64-bit real found.) esac case 8 in $ac_cv_sizeof_long) tds_sysdep_int64_type=long;; $ac_cv_sizeof_long_long) tds_sysdep_int64_type="long long";; $ac_cv_sizeof___int64) tds_sysdep_int64_type=__int64;; *) AC_MSG_ERROR([No 64-bit integer found.]) esac SPRINTF_I64_FORMAT case $ac_cv_sizeof_void_p in $ac_cv_sizeof_short) tds_sysdep_intptr_type=short;; $ac_cv_sizeof_int) tds_sysdep_intptr_type=int;; $ac_cv_sizeof_long) tds_sysdep_intptr_type=long;; $ac_cv_sizeof_long_long) tds_sysdep_intptr_type="long long";; $ac_cv_sizeof___int64) tds_sysdep_intptr_type=__int64;; *) AC_MSG_ERROR(No intptr type found.) esac AC_SUBST(tds_sysdep_int16_type) AC_SUBST(tds_sysdep_int32_type) AC_SUBST(tds_sysdep_real32_type) AC_SUBST(tds_sysdep_real64_type) AC_SUBST(tds_sysdep_int64_type) AC_SUBST(tds_sysdep_intptr_type) # ------------------------------------------------------------ # Checks for typedefs and structures # ------------------------------------------------------------ # ---- Solaris needs -DBSD_COMP to get FIONBIO defined ---- AC_MSG_CHECKING(is FIONBIO defined) AC_EGREP_CPP(yes, [#include #ifdef FIONBIO yes #endif ], AC_MSG_RESULT(yes), [ AC_EGREP_CPP(yes, [#define BSD_COMP #include #ifdef FIONBIO yes #endif ], AC_DEFINE(BSD_COMP, 1, [Define to 1 if you need BSD_COMP defined to get FIONBIO defined.]) AC_MSG_RESULT(need -DBSD_COMP), AC_MSG_RESULT(no)) ]) TYPE_SOCKLEN_T AC_MSG_CHECKING([whether getopt has optreset support]) AC_TRY_LINK([#ifdef HAVE_GETOPT_H #include #endif], [optreset = 0;], [AC_MSG_RESULT(yes) AC_DEFINE(HAVE_GETOPT_OPTRESET, 1, [Define if your getopt(3) defines and uses optreset])], [AC_MSG_RESULT(no)] ) # ------------------------------------------------------------ # Checks for compiler characteristics. # ------------------------------------------------------------ AC_C_BIGENDIAN AC_C_CONST case $host_os in mingw*) FREETDS_SYMBOLIC="-no-undefined" ;; hpux* | linux* | solaris*) AC_MSG_CHECKING([whether we can use -Wl,-Bsymbolic]) AC_LANG_CONFTEST([AC_LANG_PROGRAM([], [return 1])]) rm -f conftest.$ac_objext CMD="$SHELL $(test -n "$ac_top_builddir" && echo $ac_top_builddir || echo .)/libtool --mode=link $CC -o libtest.la conftest.$ac_ext >/dev/null 2>&1" if eval $CMD && test -s libtest.la; then AC_MSG_RESULT(yes) FREETDS_SYMBOLIC="-Wl,-Bsymbolic" else AC_MSG_RESULT(no) fi rm -f conftest.$ac_objext conftest.$ac_ext libtest.la rm -rf .libs ;; esac AC_SUBST(FREETDS_SYMBOLIC) # if GNU compiler but no GNU linker add explicitly libgcc # this is required for Solaris for example if test "$GCC" = yes; then for freetds_ldflag in "-static-libgcc" "-Wl,-static-libgcc"; do AC_MSG_CHECKING([whether we can use $freetds_ldflag]) saved_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS $freetds_ldflag" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [ac_cv_use_freetds_flag="yes"], [ac_cv_use_freetds_flag="no"]) LDFLAGS=$saved_LDFLAGS AC_MSG_RESULT($ac_cv_use_freetds_flag) if test "$ac_cv_use_freetds_flag" = "yes"; then FREETDS_LIBGCC="$freetds_ldflag" break; fi done AC_COMPILE_IFELSE([AC_LANG_SOURCE([static void __attribute__((destructor)) my_uninit(void) {}])], AC_DEFINE(TDS_ATTRIBUTE_DESTRUCTOR, 1, [Define to 1 if your compiler supports __attribute__((destructor)).])) fi AC_SUBST(FREETDS_LIBGCC) TDS_NULL_IS_ZERO # ------------------------------------------------------------ # Checks for library functions. # ------------------------------------------------------------ AC_CHECK_FUNCS([vsnprintf _vsnprintf _vscprintf gettimeofday \ nl_langinfo locale_charset setenv putenv \ getuid getpwuid getpwuid_r fstat alarm fork \ gethrtime localtime_r setitimer eventfd \ _fseeki64 _ftelli64 setrlimit pthread_cond_timedwait \ _lock_file _unlock_file usleep nanosleep readdir_r]) ACX_PUSH_LIBS("$LIBS $NETWORK_LIBS") AC_CHECK_FUNCS([inet_ntoa_r getipnodebyaddr getipnodebyname \ getaddrinfo inet_ntop gethostname poll socketpair]) AC_TRY_LINK([#ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_NETDB_H #include #endif #ifdef HAVE_WINSOCK2_H #include #include #endif], [return getaddrinfo(NULL, NULL, NULL, NULL);], AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if you have getaddrinfo function])) ACX_POP_LIBS AC_REPLACE_FUNCS([asprintf vasprintf strtok_r readpassphrase \ strlcpy strlcat basename getopt strsep daemon]) AC_FUNC_FSEEKO TDS_GETTIMEMILLI AC_FUNC_ALLOCA # ------------------------------------------------------------ # Checks for library variables. # ------------------------------------------------------------ AC_HAVE_MALLOC_OPTIONS # ------------------------------------------------------------ # Compile time options # ------------------------------------------------------------ AC_MSG_RESULT(checking compile-time options) AC_ARG_WITH(tdsver, AS_HELP_STRING([--with-tdsver=VERSION], [TDS protocol version (4.2/4.6/5.0/7.0/7.1/7.2/7.3/7.4/auto) [auto]])) case "$with_tdsver" in 4.2) AC_DEFINE(TDS42, 1, [Define to use TDS 4.2 by default]) ;; 4.6) AC_DEFINE(TDS46, 1, [Define to use TDS 4.6 by default]) ;; 5.0) AC_DEFINE(TDS50, 1, [Define to use TDS 5.0 by default]) ;; 7.0) AC_DEFINE(TDS70, 1, [Define to use TDS 7.0 by default]) ;; 7.1) AC_DEFINE(TDS71, 1, [Define to use TDS 7.1 by default]) ;; 7.2) AC_DEFINE(TDS72, 1, [Define to use TDS 7.2 by default]) ;; 7.3) AC_DEFINE(TDS73, 1, [Define to use TDS 7.3 by default]) ;; 7.4) AC_DEFINE(TDS74, 1, [Define to use TDS 7.4 by default]) ;; ""|auto) ;; *) AC_ERROR([Invalid value specified for --with-tdsver: $with_tdsver]) ;; esac AC_ARG_WITH(iodbc, AS_HELP_STRING([--with-iodbc=DIR], [build odbc driver against iODBC in DIR])) if test "$with_iodbc"; then if echo "$with_iodbc" | grep -v '^/'; then with_iodbc="$PWD/$with_iodbc" fi CPPFLAGS="$CPPFLAGS -DIODBC" ODBC_INC="$with_iodbc/include" test -r "$ODBC_INC/isql.h" || AC_ERROR([isql.h not found]) test -r "$ODBC_INC/isqlext.h" || AC_ERROR([isqlext.h not found]) ODBC_INC="-I$ODBC_INC" LDFLAGS="$LDFLAGS -L$with_iodbc/lib" ODBCLIB="-liodbc" odbc=true iodbc=true fi AC_ARG_WITH(unixodbc, AS_HELP_STRING([--with-unixodbc=DIR], [build odbc driver against unixODBC in DIR])) if test "$with_unixodbc"; then if echo "$with_unixodbc" | grep -v '^/'; then with_unixodbc="$PWD/$with_unixodbc" fi CPPFLAGS="$CPPFLAGS -DUNIXODBC" if test -f "$with_unixodbc/bin/odbc_config"; then ODBC_CONFIG="$with_unixodbc/bin/odbc_config" ODBC_INC=`$ODBC_CONFIG --include-prefix` LDFLAGS="$LDFLAGS -L`$ODBC_CONFIG --lib-prefix`" else # if not available do not use system default ODBC_CONFIG="" ODBC_INC="$with_unixodbc/include" LDFLAGS="$LDFLAGS -L$with_unixodbc/lib" fi test -r "$ODBC_INC/sql.h" || AC_ERROR([sql.h not found]) test -r "$ODBC_INC/sqlext.h" || AC_ERROR([sqlext.h not found]) ODBC_INC="-I$ODBC_INC" ODBCLIB="-lodbc" odbc=true unixodbc=true fi AC_ARG_WITH(odbc_nodm, AS_HELP_STRING([--with-odbc-nodm=DIR], [build odbc using headers in DIR/include])) if test "$with_odbc_nodm"; then if echo "$with_odbc_nodm" | grep -v '^/'; then with_odbc_nodm="$PWD/$with_odbc_nodm" fi CPPFLAGS="$CPPFLAGS -DTDS_NO_DM" ODBC_INC="$with_odbc_nodm/include" test -r "$ODBC_INC/sql.h" || AC_ERROR([sql.h not found]) test -r "$ODBC_INC/sqlext.h" || AC_ERROR([sqlext.h not found]) ODBC_INC="-I$ODBC_INC" # The next line is for linking the unittests. Here the ODBC driver # itself is treated as the driver manager to be linked. # Can't use ODBCLIB/LDFLAGS variables since they are used in building # other directories. ODBCNODMLIB="-L.. -ltdsodbc" ODBCNODMLIBAPP="-L../odbc -ltdsodbc" odbc=true fi build_odbc=yes if test "$odbc" != "true"; then AC_ARG_ENABLE(odbc, AS_HELP_STRING([--disable-odbc], [do not attempt to build odbc the driver]), [build_odbc=$enableval], [build_odbc=yes]) fi AM_CONDITIONAL(INCODBC, test "$build_odbc" = "yes") if test "$build_odbc" = "yes" then case $host_os in darwin* | rhapsody*) if test "$with_odbc_nodm" = ""; then FREETDS_ODBC_MODULE="-module" fi ;; esac AC_SUBST(FREETDS_ODBC_MODULE) # odbc not specified, try to detect it echo looking for installed odbc driver manager if test "$odbc" != "true" -a $tds_mingw = yes; then odbc=true unixodbc=true CPPFLAGS="$CPPFLAGS -DUNIXODBC" ODBCLIB="-lodbc32" elif test "$odbc" != "true"; then AC_CHECK_LIB(iodbc, SQLConnect, [AC_CHECK_HEADER([isql.h], [odbc=true iodbc=true CPPFLAGS="$CPPFLAGS -DIODBC" ODBCLIB="-liodbc"])], [AC_CHECK_LIB(odbc, SQLConnect, [AC_CHECK_HEADER([sql.h], [odbc=true unixodbc=true CPPFLAGS="$CPPFLAGS -DUNIXODBC" ODBCLIB="-lodbc"])] )] ) fi if test "$odbc" = "true"; then ODBCINSTLIB= if test $tds_mingw = yes; then ODBCINSTLIB="-lodbccp32" elif test "$unixodbc" = "true"; then if test -n "$ODBC_CONFIG"; then CPPFLAGS="$CPPFLAGS `$ODBC_CONFIG --cflags`" fi AC_CHECK_LIB(odbcinst, SQLGetPrivateProfileString, [ODBCINSTLIB="-lodbcinst"]) elif test "$iodbc" = "true"; then AC_CHECK_LIB(iodbcinst, SQLGetPrivateProfileString, [ODBCINSTLIB="-liodbcinst"]) fi if test "$ODBCINSTLIB" != ""; then AC_DEFINE_UNQUOTED(HAVE_SQLGETPRIVATEPROFILESTRING, 1, [Define to 1 if you have the SQLGetPrivateProfileString function.]) fi fi if test "$iodbc" = "true"; then save_cppflags="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $ODBC_INC" AC_CHECK_HEADERS(iodbcinst.h) CPPFLAGS="$save_cppflags" fi # test for SQLLEN (iODBC do not define but typedef it) save_cppflags="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $ODBC_INC" AC_TRY_COMPILE([#if defined(_WIN32) || defined(WIN32) || defined(__MINGW32__) #include #endif #include ], [SQLLEN len = 123;], AC_DEFINE(HAVE_SQLLEN, 1, [Define if sqltypes.h define SQLLEN]) # check SQLColAttribute definition AC_TRY_COMPILE([#if defined(_WIN32) || defined(WIN32) || defined(__MINGW32__) #include #endif #include #include SQLRETURN SQL_API SQLColAttribute (SQLHSTMT StatementHandle, SQLUSMALLINT ColumnNumber, SQLUSMALLINT FieldIdentifier, SQLPOINTER CharacterAttribute, SQLSMALLINT BufferLength, SQLSMALLINT *StringLength, SQLLEN * NumericAttribute) { }], [return 0], AC_DEFINE(TDS_SQLCOLATTRIBUTE_SQLLEN, 1, [Define to 1 if last argument of SQLColAttribute it's SQLLEN *])) # check is SQLParamOptions accept SQLULEN AC_TRY_COMPILE([#if defined(_WIN32) || defined(WIN32) || defined(__MINGW32__) #include #endif #include #include SQLRETURN SQL_API SQLParamOptions(SQLHSTMT hstmt, SQLULEN crow, SQLULEN *pirow) { return SQL_SUCCESS; }], [return 0], AC_DEFINE(TDS_SQLPARAMOPTIONS_SQLLEN, 1, [Define to 1 if SQLParamOptions accept SQLULEN as arguments])) ) AC_CHECK_TYPES([SQLSETPOSIROW, SQLROWSETSIZE, SQLROWOFFSET],,, [#if defined(_WIN32) || defined(WIN32) || defined(__MINGW32__) #include #endif #include #include ]) # test for sizeof(SQLWCHAR) AC_CHECK_SIZEOF(SQLWCHAR,,[#if defined(_WIN32) || defined(WIN32) || defined(__MINGW32__) #include #endif #include ]) CPPFLAGS="$save_cppflags" else AC_MSG_NOTICE(odbc disabled) fi AM_CONDITIONAL(ODBC, test "$odbc" = "true") AM_CONDITIONAL(UNIXODBC, test "$unixodbc" = "true") AC_SUBST(ODBC) AC_SUBST(ODBC_INC) AC_SUBST(ODBCLIB) AC_SUBST(ODBCINSTLIB) AC_SUBST(ODBCNODMLIB) AC_SUBST(ODBCNODMLIBAPP) AC_DEFUN([TDS_CHECK_GMP], [ AC_TRY_LINK([#include #include ], [mpz_t x; mpz_init(x); mpz_powm(x,x,x,x); mpz_clear(x); return 0;], AC_DEFINE(HAVE_GMP, 1, [Define if you have GMP library]), [$1])]) AC_DEFUN([TDS_HAVE_GMP], [TDS_CHECK_GMP([gmp_save_LIBS="$LIBS" LIBS="$LIBS -lgmp" TDS_CHECK_GMP([LIBS="$gmp_save_LIBS"])])]) AC_ARG_WITH(gnutls, AS_HELP_STRING([--with-gnutls], [build with GnuTLS support])) if test "$with_gnutls" = "yes"; then AC_DEFINE(HAVE_GNUTLS, 1, [Define to 1 if you have GnuTLS.]) gnutls_backend=unknown PKG_CHECK_MODULES(GNUTLS, gnutls, [CPPFLAGS="$CPPFLAGS $GNUTLS_CFLAGS" NETWORK_LIBS="$NETWORK_LIBS $GNUTLS_LIBS" if "$PKG_CONFIG" --libs --static gnutls | grep nettle > /dev/null 2>&1 ; then gnutls_backend=nettle AC_DEFINE(GNUTLS_USE_NETTLE, 1, [Define to 1 if GNU tls use nettle as backend.]) PKG_CHECK_MODULES(NETTLE, nettle, [AC_DEFINE(HAVE_NETTLE, 1, [Define to 1 if nettle is present.]) NETWORK_LIBS="$NETWORK_LIBS $NETTLE_LIBS"]) ACX_PUSH_LIBS("$NETWORK_LIBS") TDS_HAVE_GMP AC_SEARCH_LIBS(nettle_rsa_public_key_init, [nettle hogweed]) NETWORK_LIBS="$LIBS" ACX_POP_LIBS fi], [CPPFLAGS="$CPPFLAGS `libgnutls-config --cflags`" NETWORK_LIBS="$NETWORK_LIBS `libgnutls-config --libs`"] ) ACX_PUSH_LIBS("$NETWORK_LIBS") AC_CHECK_FUNCS([gnutls_certificate_set_verify_function gnutls_record_disable_padding gnutls_rnd]) ACX_POP_LIBS if test "$gnutls_backend" = "unknown"; then gnutls_backend=gcrypt NETWORK_LIBS="$NETWORK_LIBS -ltasn1" fi else CHECK_OPENSSL fi AC_ARG_ENABLE(apps, AS_HELP_STRING([--disable-apps], [skip build of src/apps (including tsql)])) AM_CONDITIONAL(INCAPPS, test "$enable_apps" != "no") AC_ARG_ENABLE(server, AS_HELP_STRING([--disable-server], [skip build of src/server directory])) AM_CONDITIONAL(INCSERVER, test "$enable_server" != "no") AC_ARG_ENABLE(pool, AS_HELP_STRING([--disable-pool], [skip build of src/pool directory])) AM_CONDITIONAL(INCPOOL, test "$enable_pool" != "no") AC_ARG_ENABLE(msdblib, AS_HELP_STRING([--enable-msdblib], [for MS style dblib])) if test "$enable_msdblib" = "yes" ; then dblib_define="#define MSDBLIB 1" else dblib_define="#define SYBDBLIB 1" fi AC_SUBST(dblib_define) AC_ARG_ENABLE(sybase-compat, AS_HELP_STRING([--enable-sybase-compat], [enable increased Open Client binary compatibility])) AM_CONDITIONAL(SYBASE_COMPAT, test x$enable_sybase_compat = xyes) if test x$enable_sybase_compat = xyes; then AC_DEFINE(TDS_SYBASE_COMPAT, 1, [Defined if --enable-sybase-compat used]) fi AC_MSG_CHECKING(threadsafety) # Enable or disable thread safetiness # This option is enabled by default because most OS's support it. # A more sophisticated approach would be to set the default per-OS. AC_ARG_ENABLE(threadsafe, AS_HELP_STRING([--disable-threadsafe], [disable calls to threadsafe fuctions e.g.,gethostbyname_r ]), [use_threadsafe=$enableval], [use_threadsafe=yes]) if test "$enable_threadsafe" != "no" ; then CPPFLAGS="$CPPFLAGS -D_REENTRANT -D_THREAD_SAFE" AC_MSG_RESULT(enabled) else AC_DEFINE(TDS_NO_THREADSAFE, 1, [Define if you don't care about thread safety]) AC_MSG_RESULT(disabled) fi AM_CONDITIONAL(ENABLE_THREADSAFE, test "$enable_threadsafe" != "no") # newer gcc are configured to fail to resolve references to libraries not # explicitly listed on the linker commandline. # So to make build add explicitly gcrypt library. if test "$enable_threadsafe" != "no" -a "$with_gnutls" = "yes" -a "$gnutls_backend" = "gcrypt"; then PKG_CHECK_MODULES(GCRYPT, gcrypt, [CPPFLAGS="$CPPFLAGS $GCRYPT_CFLAGS" NETWORK_LIBS="$NETWORK_LIBS $GCRYPT_LIBS"], [CPPFLAGS="$CPPFLAGS `libgcrypt-config --cflags`" NETWORK_LIBS="$NETWORK_LIBS `libgcrypt-config --libs`"]) fi # we don't need to check netdb functions if they are already threadsafe if test $netdb_reentrant != yes; then AC_caolan_FUNC_WHICH_GETHOSTBYNAME_R AC_raf_FUNC_WHICH_GETSERVBYNAME_R AC_tds_FUNC_WHICH_GETHOSTBYADDR_R fi AC_tds_FUNC_WHICH_GETPWUID_R AC_tds_FUNC_WHICH_LOCALTIME_R # easy test for pthread (no library, only mutex support) AC_TRY_LINK([#include #if !defined(_WIN32) pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; #endif], [pthread_mutex_lock(&mutex); pthread_mutex_unlock(&mutex)], AC_DEFINE(TDS_HAVE_PTHREAD_MUTEX, 1, [Define if you have pthread with mutex support])) # easy test for locking stdio AC_TRY_LINK([#include ], [int c; flockfile(stdin); c = getc_unlocked(stdin); funlockfile(stdin);], AC_DEFINE(TDS_HAVE_STDIO_LOCKED, 1, [Define if stdio support locking])) AC_ARG_ENABLE(debug, AS_HELP_STRING([--disable-debug], [disable assert and other things]), [use_debug=$enableval], [use_debug=yes]) if test "$use_debug" = "yes" ; then AC_MSG_NOTICE(debug enabled) CPPFLAGS="$CPPFLAGS -DDEBUG=1" AC_ARG_ENABLE(extra-checks, AS_HELP_STRING([--enable-extra-checks], [enable extra checks on code])) if test "$enable_extra_checks" = "yes" ; then AC_DEFINE_UNQUOTED(ENABLE_EXTRA_CHECKS, 1, [Define to enable extra checks on code]) fi else AC_MSG_NOTICE(debug disabled) CPPFLAGS="$CPPFLAGS -DNDEBUG=1" fi AC_ARG_ENABLE(developing, AS_HELP_STRING([--enable-developing], [enable code still in develop])) if test "$enable_developing" = "yes" ; then AC_DEFINE_UNQUOTED(ENABLE_DEVELOPING, 1, [Define to enable work in progress code]) fi AM_CONDITIONAL(ENABLE_DEVELOPING, test "$enable_developing" = "yes") AC_ARG_ENABLE(mars, AS_HELP_STRING([--enable-mars], [enable MARS code (EXPERIMENTAL)])) if test "$enable_mars" = "yes" ; then AC_DEFINE_UNQUOTED(ENABLE_ODBC_MARS, 1, [Define to enable MARS support]) fi AC_ARG_ENABLE(odbc-wide, AS_HELP_STRING([--disable-odbc-wide], [disable wide string support in odbc])) if test "$enable_odbc_wide" != "no" ; then AC_DEFINE_UNQUOTED(ENABLE_ODBC_WIDE, 1, [Define to enable ODBC wide string support]) AC_ARG_ENABLE(odbc-wide-tests, AS_HELP_STRING([--enable-odbc-wide-tests], [enable compiling ODBC tests to use wide functions])) AM_CONDITIONAL(ODBC_WIDE_TESTS, test "$enable_odbc_wide_tests" = "yes") else AM_CONDITIONAL(ODBC_WIDE_TESTS, false) fi AC_ARG_ENABLE(distcheck_build, AS_HELP_STRING([--enable-distcheck-build], [used internally for testing])) if test "$enable_distcheck_build" = "yes" ; then AM_CONDITIONAL(DISTCHECK_BUILD, true) else AM_CONDITIONAL(DISTCHECK_BUILD, false) fi # ------------------------------------------------------------ # LTLIBOBJS hack (for autoconf-2.53) # ------------------------------------------------------------ # This is necessary so that .o files in LIBOBJS are also built via # the ANSI2KNR-filtering rules. LIB@&t@OBJS=`echo "$LIB@&t@OBJS" | sed 's,\.[[^.]]* ,$U&,g;s,\.[[^.]]*$,$U&,'` LTLIBOBJS=`echo "$LIB@&t@OBJS" | sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'` AC_SUBST(LTLIBOBJS) # enable some warning for gcc if test "$ac_compiler_gnu" = "yes" ; then CPPFLAGS="$CPPFLAGS -Wall -Wstrict-prototypes -Wmissing-prototypes -Wno-long-long -Wpointer-arith" fi AX_CFLAGS_GCC_OPTION([-Wdeclaration-after-statement]) AC_MSG_RESULT(done) # ------------------------------------------------------------ # Final output # ------------------------------------------------------------ AC_CONFIG_FILES(include/freetds/version.h \ include/tds_sysdep_public.h \ Makefile \ include/Makefile \ include/freetds/Makefile \ doc/Makefile \ samples/Makefile \ src/Makefile \ src/tds/Makefile src/tds/unittests/Makefile \ src/dblib/Makefile src/dblib/unittests/Makefile \ src/ctlib/Makefile src/ctlib/unittests/Makefile \ src/replacements/Makefile \ src/replacements/unittests/Makefile \ src/server/Makefile \ src/pool/Makefile \ src/odbc/Makefile \ src/odbc/unittests/Makefile \ src/apps/Makefile \ src/apps/fisql/Makefile \ freetds.spec \ win32/Makefile \ win32/freetds.nsh \ src/odbc/version.rc \ vms/Makefile misc/Makefile \ doc/freebcp.1 doc/tsql.1 doc/osql.1 \ doc/bsqldb.1 doc/bsqlodbc.1 doc/defncopy.1 \ doc/datacopy.1 doc/fisql.1 doc/freetds.conf.5 ) AC_OUTPUT freetds-1.00.82/aclocal.m4100644 025423 025423 00000414735 13242511105 0010676# generated automatically by aclocal 1.15 -*- Autoconf -*- # Copyright (C) 1996-2014 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, [m4_warning([this file was generated for autoconf 2.69. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) # iconv.m4 serial 19 (gettext-0.18.2) dnl Copyright (C) 2000-2002, 2007-2014, 2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl From Bruno Haible. AC_DEFUN([AM_ICONV_LINKFLAGS_BODY], [ dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) AC_REQUIRE([AC_LIB_RPATH]) dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV dnl accordingly. AC_LIB_LINKFLAGS_BODY([iconv]) ]) AC_DEFUN([AM_ICONV_LINK], [ dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and dnl those with the standalone portable GNU libiconv installed). AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV dnl accordingly. AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) dnl Add $INCICONV to CPPFLAGS before performing the following checks, dnl because if the user has installed libiconv and not disabled its use dnl via --without-libiconv-prefix, he wants to use it. The first dnl AC_LINK_IFELSE will then fail, the second AC_LINK_IFELSE will succeed. am_save_CPPFLAGS="$CPPFLAGS" AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV]) AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [ am_cv_func_iconv="no, consider installing GNU libiconv" am_cv_lib_iconv=no AC_LINK_IFELSE( [AC_LANG_PROGRAM( [[ #include #include ]], [[iconv_t cd = iconv_open("",""); iconv(cd,NULL,NULL,NULL,NULL); iconv_close(cd);]])], [am_cv_func_iconv=yes]) if test "$am_cv_func_iconv" != yes; then am_save_LIBS="$LIBS" LIBS="$LIBS $LIBICONV" AC_LINK_IFELSE( [AC_LANG_PROGRAM( [[ #include #include ]], [[iconv_t cd = iconv_open("",""); iconv(cd,NULL,NULL,NULL,NULL); iconv_close(cd);]])], [am_cv_lib_iconv=yes] [am_cv_func_iconv=yes]) LIBS="$am_save_LIBS" fi ]) if test "$am_cv_func_iconv" = yes; then AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [ dnl This tests against bugs in AIX 5.1, AIX 6.1..7.1, HP-UX 11.11, dnl Solaris 10. am_save_LIBS="$LIBS" if test $am_cv_lib_iconv = yes; then LIBS="$LIBS $LIBICONV" fi am_cv_func_iconv_works=no for ac_iconv_const in '' 'const'; do AC_RUN_IFELSE( [AC_LANG_PROGRAM( [[ #include #include #ifndef ICONV_CONST # define ICONV_CONST $ac_iconv_const #endif ]], [[int result = 0; /* Test against AIX 5.1 bug: Failures are not distinguishable from successful returns. */ { iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); if (cd_utf8_to_88591 != (iconv_t)(-1)) { static ICONV_CONST char input[] = "\342\202\254"; /* EURO SIGN */ char buf[10]; ICONV_CONST char *inptr = input; size_t inbytesleft = strlen (input); char *outptr = buf; size_t outbytesleft = sizeof (buf); size_t res = iconv (cd_utf8_to_88591, &inptr, &inbytesleft, &outptr, &outbytesleft); if (res == 0) result |= 1; iconv_close (cd_utf8_to_88591); } } /* Test against Solaris 10 bug: Failures are not distinguishable from successful returns. */ { iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646"); if (cd_ascii_to_88591 != (iconv_t)(-1)) { static ICONV_CONST char input[] = "\263"; char buf[10]; ICONV_CONST char *inptr = input; size_t inbytesleft = strlen (input); char *outptr = buf; size_t outbytesleft = sizeof (buf); size_t res = iconv (cd_ascii_to_88591, &inptr, &inbytesleft, &outptr, &outbytesleft); if (res == 0) result |= 2; iconv_close (cd_ascii_to_88591); } } /* Test against AIX 6.1..7.1 bug: Buffer overrun. */ { iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1"); if (cd_88591_to_utf8 != (iconv_t)(-1)) { static ICONV_CONST char input[] = "\304"; static char buf[2] = { (char)0xDE, (char)0xAD }; ICONV_CONST char *inptr = input; size_t inbytesleft = 1; char *outptr = buf; size_t outbytesleft = 1; size_t res = iconv (cd_88591_to_utf8, &inptr, &inbytesleft, &outptr, &outbytesleft); if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD) result |= 4; iconv_close (cd_88591_to_utf8); } } #if 0 /* This bug could be worked around by the caller. */ /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */ { iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591"); if (cd_88591_to_utf8 != (iconv_t)(-1)) { static ICONV_CONST char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; char buf[50]; ICONV_CONST char *inptr = input; size_t inbytesleft = strlen (input); char *outptr = buf; size_t outbytesleft = sizeof (buf); size_t res = iconv (cd_88591_to_utf8, &inptr, &inbytesleft, &outptr, &outbytesleft); if ((int)res > 0) result |= 8; iconv_close (cd_88591_to_utf8); } } #endif /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is provided. */ if (/* Try standardized names. */ iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1) /* Try IRIX, OSF/1 names. */ && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1) /* Try AIX names. */ && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1) /* Try HP-UX names. */ && iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) result |= 16; return result; ]])], [am_cv_func_iconv_works=yes], , [case "$host_os" in aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; *) am_cv_func_iconv_works="guessing yes" ;; esac]) test "$am_cv_func_iconv_works" = no || break done LIBS="$am_save_LIBS" ]) case "$am_cv_func_iconv_works" in *no) am_func_iconv=no am_cv_lib_iconv=no ;; *) am_func_iconv=yes ;; esac else am_func_iconv=no am_cv_lib_iconv=no fi if test "$am_func_iconv" = yes; then AC_DEFINE([HAVE_ICONV], [1], [Define if you have the iconv() function and it works.]) fi if test "$am_cv_lib_iconv" = yes; then AC_MSG_CHECKING([how to link with libiconv]) AC_MSG_RESULT([$LIBICONV]) else dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV dnl either. CPPFLAGS="$am_save_CPPFLAGS" LIBICONV= LTLIBICONV= fi AC_SUBST([LIBICONV]) AC_SUBST([LTLIBICONV]) ]) dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to dnl avoid warnings like dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required". dnl This is tricky because of the way 'aclocal' is implemented: dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN. dnl Otherwise aclocal's initial scan pass would miss the macro definition. dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions. dnl Otherwise aclocal would emit many "Use of uninitialized value $1" dnl warnings. m4_define([gl_iconv_AC_DEFUN], m4_version_prereq([2.64], [[AC_DEFUN_ONCE( [$1], [$2])]], [m4_ifdef([gl_00GNULIB], [[AC_DEFUN_ONCE( [$1], [$2])]], [[AC_DEFUN( [$1], [$2])]])])) gl_iconv_AC_DEFUN([AM_ICONV], [ AM_ICONV_LINK if test "$am_cv_func_iconv" = yes; then AC_MSG_CHECKING([for iconv declaration]) AC_CACHE_VAL([am_cv_proto_iconv], [ AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( [[ #include #include extern #ifdef __cplusplus "C" #endif #if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus) size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); #else size_t iconv(); #endif ]], [[]])], [am_cv_proto_iconv_arg1=""], [am_cv_proto_iconv_arg1="const"]) am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"]) am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` AC_MSG_RESULT([ $am_cv_proto_iconv]) AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1], [Define as const if the declaration of iconv() needs const.]) dnl Also substitute ICONV_CONST in the gnulib generated . m4_ifdef([gl_ICONV_H_DEFAULTS], [AC_REQUIRE([gl_ICONV_H_DEFAULTS]) if test -n "$am_cv_proto_iconv_arg1"; then ICONV_CONST="const" fi ]) fi ]) # lib-ld.m4 serial 6 dnl Copyright (C) 1996-2003, 2009-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl Subroutines of libtool.m4, dnl with replacements s/_*LT_PATH/AC_LIB_PROG/ and s/lt_/acl_/ to avoid dnl collision with libtool.m4. dnl From libtool-2.4. Sets the variable with_gnu_ld to yes or no. AC_DEFUN([AC_LIB_PROG_LD_GNU], [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld], [# I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 /dev/null 2>&1 \ && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \ || PATH_SEPARATOR=';' } fi ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. AC_MSG_CHECKING([for ld used by $CC]) case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [[\\/]]* | ?:[[\\/]]*) re_direlt='/[[^/]][[^/]]*/\.\./' # Canonicalize the pathname of ld ac_prog=`echo "$ac_prog"| sed 's%\\\\%/%g'` while echo "$ac_prog" | grep "$re_direlt" > /dev/null 2>&1; do ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then AC_MSG_CHECKING([for GNU ld]) else AC_MSG_CHECKING([for non-GNU ld]) fi AC_CACHE_VAL([acl_cv_path_LD], [if test -z "$LD"; then acl_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$acl_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then acl_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$acl_cv_path_LD" -v 2>&1 = 1.10 to complain if config.rpath is missing. m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])]) AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [ CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh . ./conftest.sh rm -f ./conftest.sh acl_cv_rpath=done ]) wl="$acl_cv_wl" acl_libext="$acl_cv_libext" acl_shlibext="$acl_cv_shlibext" acl_libname_spec="$acl_cv_libname_spec" acl_library_names_spec="$acl_cv_library_names_spec" acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" acl_hardcode_direct="$acl_cv_hardcode_direct" acl_hardcode_minus_L="$acl_cv_hardcode_minus_L" dnl Determine whether the user wants rpath handling at all. AC_ARG_ENABLE([rpath], [ --disable-rpath do not hardcode runtime library paths], :, enable_rpath=yes) ]) dnl AC_LIB_FROMPACKAGE(name, package) dnl declares that libname comes from the given package. The configure file dnl will then not have a --with-libname-prefix option but a dnl --with-package-prefix option. Several libraries can come from the same dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar dnl macro call that searches for libname. AC_DEFUN([AC_LIB_FROMPACKAGE], [ pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) define([acl_frompackage_]NAME, [$2]) popdef([NAME]) pushdef([PACK],[$2]) pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-], [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) define([acl_libsinpackage_]PACKUP, m4_ifdef([acl_libsinpackage_]PACKUP, [m4_defn([acl_libsinpackage_]PACKUP)[, ]],)[lib$1]) popdef([PACKUP]) popdef([PACK]) ]) dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and dnl the libraries corresponding to explicit and implicit dependencies. dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables. dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem. AC_DEFUN([AC_LIB_LINKFLAGS_BODY], [ AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) pushdef([NAME],[m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./+-], [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])]) pushdef([PACKUP],[m4_translit(PACK,[abcdefghijklmnopqrstuvwxyz./+-], [ABCDEFGHIJKLMNOPQRSTUVWXYZ____])]) pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])]) dnl Autoconf >= 2.61 supports dots in --with options. pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[m4_translit(PACK,[.],[_])],PACK)]) dnl By default, look in $includedir and $libdir. use_additional=yes AC_LIB_WITH_FINAL_PREFIX([ eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" ]) AC_ARG_WITH(P_A_C_K[-prefix], [[ --with-]]P_A_C_K[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib --without-]]P_A_C_K[[-prefix don't search for ]PACKLIBS[ in includedir and libdir]], [ if test "X$withval" = "Xno"; then use_additional=no else if test "X$withval" = "X"; then AC_LIB_WITH_FINAL_PREFIX([ eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" ]) else additional_includedir="$withval/include" additional_libdir="$withval/$acl_libdirstem" if test "$acl_libdirstem2" != "$acl_libdirstem" \ && ! test -d "$withval/$acl_libdirstem"; then additional_libdir="$withval/$acl_libdirstem2" fi fi fi ]) dnl Search the library and its dependencies in $additional_libdir and dnl $LDFLAGS. Using breadth-first-seach. LIB[]NAME= LTLIB[]NAME= INC[]NAME= LIB[]NAME[]_PREFIX= dnl HAVE_LIB${NAME} is an indicator that LIB${NAME}, LTLIB${NAME} have been dnl computed. So it has to be reset here. HAVE_LIB[]NAME= rpathdirs= ltrpathdirs= names_already_handled= names_next_round='$1 $2' while test -n "$names_next_round"; do names_this_round="$names_next_round" names_next_round= for name in $names_this_round; do already_handled= for n in $names_already_handled; do if test "$n" = "$name"; then already_handled=yes break fi done if test -z "$already_handled"; then names_already_handled="$names_already_handled $name" dnl See if it was already located by an earlier AC_LIB_LINKFLAGS dnl or AC_LIB_HAVE_LINKFLAGS call. uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'` eval value=\"\$HAVE_LIB$uppername\" if test -n "$value"; then if test "$value" = yes; then eval value=\"\$LIB$uppername\" test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value" eval value=\"\$LTLIB$uppername\" test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value" else dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined dnl that this library doesn't exist. So just drop it. : fi else dnl Search the library lib$name in $additional_libdir and $LDFLAGS dnl and the already constructed $LIBNAME/$LTLIBNAME. found_dir= found_la= found_so= found_a= eval libname=\"$acl_libname_spec\" # typically: libname=lib$name if test -n "$acl_shlibext"; then shrext=".$acl_shlibext" # typically: shrext=.so else shrext= fi if test $use_additional = yes; then dir="$additional_libdir" dnl The same code as in the loop below: dnl First look for a shared library. if test -n "$acl_shlibext"; then if test -f "$dir/$libname$shrext"; then found_dir="$dir" found_so="$dir/$libname$shrext" else if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then ver=`(cd "$dir" && \ for f in "$libname$shrext".*; do echo "$f"; done \ | sed -e "s,^$libname$shrext\\\\.,," \ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | sed 1q ) 2>/dev/null` if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then found_dir="$dir" found_so="$dir/$libname$shrext.$ver" fi else eval library_names=\"$acl_library_names_spec\" for f in $library_names; do if test -f "$dir/$f"; then found_dir="$dir" found_so="$dir/$f" break fi done fi fi fi dnl Then look for a static library. if test "X$found_dir" = "X"; then if test -f "$dir/$libname.$acl_libext"; then found_dir="$dir" found_a="$dir/$libname.$acl_libext" fi fi if test "X$found_dir" != "X"; then if test -f "$dir/$libname.la"; then found_la="$dir/$libname.la" fi fi fi if test "X$found_dir" = "X"; then for x in $LDFLAGS $LTLIB[]NAME; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) case "$x" in -L*) dir=`echo "X$x" | sed -e 's/^X-L//'` dnl First look for a shared library. if test -n "$acl_shlibext"; then if test -f "$dir/$libname$shrext"; then found_dir="$dir" found_so="$dir/$libname$shrext" else if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then ver=`(cd "$dir" && \ for f in "$libname$shrext".*; do echo "$f"; done \ | sed -e "s,^$libname$shrext\\\\.,," \ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | sed 1q ) 2>/dev/null` if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then found_dir="$dir" found_so="$dir/$libname$shrext.$ver" fi else eval library_names=\"$acl_library_names_spec\" for f in $library_names; do if test -f "$dir/$f"; then found_dir="$dir" found_so="$dir/$f" break fi done fi fi fi dnl Then look for a static library. if test "X$found_dir" = "X"; then if test -f "$dir/$libname.$acl_libext"; then found_dir="$dir" found_a="$dir/$libname.$acl_libext" fi fi if test "X$found_dir" != "X"; then if test -f "$dir/$libname.la"; then found_la="$dir/$libname.la" fi fi ;; esac if test "X$found_dir" != "X"; then break fi done fi if test "X$found_dir" != "X"; then dnl Found the library. LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name" if test "X$found_so" != "X"; then dnl Linking with a shared library. We attempt to hardcode its dnl directory into the executable's runpath, unless it's the dnl standard /usr/lib. if test "$enable_rpath" = no \ || test "X$found_dir" = "X/usr/$acl_libdirstem" \ || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then dnl No hardcoding is needed. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" else dnl Use an explicit option to hardcode DIR into the resulting dnl binary. dnl Potentially add DIR to ltrpathdirs. dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. haveit= for x in $ltrpathdirs; do if test "X$x" = "X$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then ltrpathdirs="$ltrpathdirs $found_dir" fi dnl The hardcoding into $LIBNAME is system dependent. if test "$acl_hardcode_direct" = yes; then dnl Using DIR/libNAME.so during linking hardcodes DIR into the dnl resulting binary. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" else if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then dnl Use an explicit option to hardcode DIR into the resulting dnl binary. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" dnl Potentially add DIR to rpathdirs. dnl The rpathdirs will be appended to $LIBNAME at the end. haveit= for x in $rpathdirs; do if test "X$x" = "X$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then rpathdirs="$rpathdirs $found_dir" fi else dnl Rely on "-L$found_dir". dnl But don't add it if it's already contained in the LDFLAGS dnl or the already constructed $LIBNAME haveit= for x in $LDFLAGS $LIB[]NAME; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-L$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir" fi if test "$acl_hardcode_minus_L" != no; then dnl FIXME: Not sure whether we should use dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" dnl here. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" else dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH dnl here, because this doesn't fit in flags passed to the dnl compiler. So give up. No hardcoding. This affects only dnl very old systems. dnl FIXME: Not sure whether we should use dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" dnl here. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" fi fi fi fi else if test "X$found_a" != "X"; then dnl Linking with a static library. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a" else dnl We shouldn't come here, but anyway it's good to have a dnl fallback. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name" fi fi dnl Assume the include files are nearby. additional_includedir= case "$found_dir" in */$acl_libdirstem | */$acl_libdirstem/) basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` if test "$name" = '$1'; then LIB[]NAME[]_PREFIX="$basedir" fi additional_includedir="$basedir/include" ;; */$acl_libdirstem2 | */$acl_libdirstem2/) basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'` if test "$name" = '$1'; then LIB[]NAME[]_PREFIX="$basedir" fi additional_includedir="$basedir/include" ;; esac if test "X$additional_includedir" != "X"; then dnl Potentially add $additional_includedir to $INCNAME. dnl But don't add it dnl 1. if it's the standard /usr/include, dnl 2. if it's /usr/local/include and we are using GCC on Linux, dnl 3. if it's already present in $CPPFLAGS or the already dnl constructed $INCNAME, dnl 4. if it doesn't exist as a directory. if test "X$additional_includedir" != "X/usr/include"; then haveit= if test "X$additional_includedir" = "X/usr/local/include"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then for x in $CPPFLAGS $INC[]NAME; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-I$additional_includedir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_includedir"; then dnl Really add $additional_includedir to $INCNAME. INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir" fi fi fi fi fi dnl Look for dependencies. if test -n "$found_la"; then dnl Read the .la file. It defines the variables dnl dlname, library_names, old_library, dependency_libs, current, dnl age, revision, installed, dlopen, dlpreopen, libdir. save_libdir="$libdir" case "$found_la" in */* | *\\*) . "$found_la" ;; *) . "./$found_la" ;; esac libdir="$save_libdir" dnl We use only dependency_libs. for dep in $dependency_libs; do case "$dep" in -L*) additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME. dnl But don't add it dnl 1. if it's the standard /usr/lib, dnl 2. if it's /usr/local/lib and we are using GCC on Linux, dnl 3. if it's already present in $LDFLAGS or the already dnl constructed $LIBNAME, dnl 4. if it doesn't exist as a directory. if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \ && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then haveit= if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \ || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then haveit= for x in $LDFLAGS $LIB[]NAME; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_libdir"; then dnl Really add $additional_libdir to $LIBNAME. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir" fi fi haveit= for x in $LDFLAGS $LTLIB[]NAME; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_libdir"; then dnl Really add $additional_libdir to $LTLIBNAME. LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir" fi fi fi fi ;; -R*) dir=`echo "X$dep" | sed -e 's/^X-R//'` if test "$enable_rpath" != no; then dnl Potentially add DIR to rpathdirs. dnl The rpathdirs will be appended to $LIBNAME at the end. haveit= for x in $rpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then rpathdirs="$rpathdirs $dir" fi dnl Potentially add DIR to ltrpathdirs. dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. haveit= for x in $ltrpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then ltrpathdirs="$ltrpathdirs $dir" fi fi ;; -l*) dnl Handle this in the next round. names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` ;; *.la) dnl Handle this in the next round. Throw away the .la's dnl directory; it is already contained in a preceding -L dnl option. names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` ;; *) dnl Most likely an immediate library name. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep" LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep" ;; esac done fi else dnl Didn't find the library; assume it is in the system directories dnl known to the linker and runtime loader. (All the system dnl directories known to the linker should also be known to the dnl runtime loader, otherwise the system is severely misconfigured.) LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name" fi fi fi done done if test "X$rpathdirs" != "X"; then if test -n "$acl_hardcode_libdir_separator"; then dnl Weird platform: only the last -rpath option counts, the user must dnl pass all path elements in one option. We can arrange that for a dnl single library, but not when more than one $LIBNAMEs are used. alldirs= for found_dir in $rpathdirs; do alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" done dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl. acl_save_libdir="$libdir" libdir="$alldirs" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" else dnl The -rpath options are cumulative. for found_dir in $rpathdirs; do acl_save_libdir="$libdir" libdir="$found_dir" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" done fi fi if test "X$ltrpathdirs" != "X"; then dnl When using libtool, the option that works for both libraries and dnl executables is -R. The -R options are cumulative. for found_dir in $ltrpathdirs; do LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir" done fi popdef([P_A_C_K]) popdef([PACKLIBS]) popdef([PACKUP]) popdef([PACK]) popdef([NAME]) ]) dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR, dnl unless already present in VAR. dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes dnl contains two or three consecutive elements that belong together. AC_DEFUN([AC_LIB_APPENDTOVAR], [ for element in [$2]; do haveit= for x in $[$1]; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X$element"; then haveit=yes break fi done if test -z "$haveit"; then [$1]="${[$1]}${[$1]:+ }$element" fi done ]) dnl For those cases where a variable contains several -L and -l options dnl referring to unknown libraries and directories, this macro determines the dnl necessary additional linker options for the runtime path. dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL]) dnl sets LDADDVAR to linker options needed together with LIBSVALUE. dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed, dnl otherwise linking without libtool is assumed. AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS], [ AC_REQUIRE([AC_LIB_RPATH]) AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) $1= if test "$enable_rpath" != no; then if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then dnl Use an explicit option to hardcode directories into the resulting dnl binary. rpathdirs= next= for opt in $2; do if test -n "$next"; then dir="$next" dnl No need to hardcode the standard /usr/lib. if test "X$dir" != "X/usr/$acl_libdirstem" \ && test "X$dir" != "X/usr/$acl_libdirstem2"; then rpathdirs="$rpathdirs $dir" fi next= else case $opt in -L) next=yes ;; -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'` dnl No need to hardcode the standard /usr/lib. if test "X$dir" != "X/usr/$acl_libdirstem" \ && test "X$dir" != "X/usr/$acl_libdirstem2"; then rpathdirs="$rpathdirs $dir" fi next= ;; *) next= ;; esac fi done if test "X$rpathdirs" != "X"; then if test -n ""$3""; then dnl libtool is used for linking. Use -R options. for dir in $rpathdirs; do $1="${$1}${$1:+ }-R$dir" done else dnl The linker is used for linking directly. if test -n "$acl_hardcode_libdir_separator"; then dnl Weird platform: only the last -rpath option counts, the user dnl must pass all path elements in one option. alldirs= for dir in $rpathdirs; do alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir" done acl_save_libdir="$libdir" libdir="$alldirs" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" $1="$flag" else dnl The -rpath options are cumulative. for dir in $rpathdirs; do acl_save_libdir="$libdir" libdir="$dir" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" $1="${$1}${$1:+ }$flag" done fi fi fi fi fi AC_SUBST([$1]) ]) # lib-prefix.m4 serial 7 (gettext-0.18) dnl Copyright (C) 2001-2005, 2008-2016 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. dnl From Bruno Haible. dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't dnl require excessive bracketing. ifdef([AC_HELP_STRING], [AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])], [AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])]) dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed dnl to access previously installed libraries. The basic assumption is that dnl a user will want packages to use other packages he previously installed dnl with the same --prefix option. dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate dnl libraries, but is otherwise very convenient. AC_DEFUN([AC_LIB_PREFIX], [ AC_BEFORE([$0], [AC_LIB_LINKFLAGS]) AC_REQUIRE([AC_PROG_CC]) AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) dnl By default, look in $includedir and $libdir. use_additional=yes AC_LIB_WITH_FINAL_PREFIX([ eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" ]) AC_LIB_ARG_WITH([lib-prefix], [ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib --without-lib-prefix don't search for libraries in includedir and libdir], [ if test "X$withval" = "Xno"; then use_additional=no else if test "X$withval" = "X"; then AC_LIB_WITH_FINAL_PREFIX([ eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" ]) else additional_includedir="$withval/include" additional_libdir="$withval/$acl_libdirstem" fi fi ]) if test $use_additional = yes; then dnl Potentially add $additional_includedir to $CPPFLAGS. dnl But don't add it dnl 1. if it's the standard /usr/include, dnl 2. if it's already present in $CPPFLAGS, dnl 3. if it's /usr/local/include and we are using GCC on Linux, dnl 4. if it doesn't exist as a directory. if test "X$additional_includedir" != "X/usr/include"; then haveit= for x in $CPPFLAGS; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-I$additional_includedir"; then haveit=yes break fi done if test -z "$haveit"; then if test "X$additional_includedir" = "X/usr/local/include"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then if test -d "$additional_includedir"; then dnl Really add $additional_includedir to $CPPFLAGS. CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir" fi fi fi fi dnl Potentially add $additional_libdir to $LDFLAGS. dnl But don't add it dnl 1. if it's the standard /usr/lib, dnl 2. if it's already present in $LDFLAGS, dnl 3. if it's /usr/local/lib and we are using GCC on Linux, dnl 4. if it doesn't exist as a directory. if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then haveit= for x in $LDFLAGS; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then if test -n "$GCC"; then case $host_os in linux*) haveit=yes;; esac fi fi if test -z "$haveit"; then if test -d "$additional_libdir"; then dnl Really add $additional_libdir to $LDFLAGS. LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir" fi fi fi fi fi ]) dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix, dnl acl_final_exec_prefix, containing the values to which $prefix and dnl $exec_prefix will expand at the end of the configure script. AC_DEFUN([AC_LIB_PREPARE_PREFIX], [ dnl Unfortunately, prefix and exec_prefix get only finally determined dnl at the end of configure. if test "X$prefix" = "XNONE"; then acl_final_prefix="$ac_default_prefix" else acl_final_prefix="$prefix" fi if test "X$exec_prefix" = "XNONE"; then acl_final_exec_prefix='${prefix}' else acl_final_exec_prefix="$exec_prefix" fi acl_save_prefix="$prefix" prefix="$acl_final_prefix" eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" prefix="$acl_save_prefix" ]) dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the dnl variables prefix and exec_prefix bound to the values they will have dnl at the end of the configure script. AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX], [ acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" $1 exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" ]) dnl AC_LIB_PREPARE_MULTILIB creates dnl - a variable acl_libdirstem, containing the basename of the libdir, either dnl "lib" or "lib64" or "lib/64", dnl - a variable acl_libdirstem2, as a secondary possible value for dnl acl_libdirstem, either the same as acl_libdirstem or "lib/sparcv9" or dnl "lib/amd64". AC_DEFUN([AC_LIB_PREPARE_MULTILIB], [ dnl There is no formal standard regarding lib and lib64. dnl On glibc systems, the current practice is that on a system supporting dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. We determine dnl the compiler's default mode by looking at the compiler's library search dnl path. If at least one of its elements ends in /lib64 or points to a dnl directory whose absolute pathname ends in /lib64, we assume a 64-bit ABI. dnl Otherwise we use the default, namely "lib". dnl On Solaris systems, the current practice is that on a system supporting dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib. AC_REQUIRE([AC_CANONICAL_HOST]) acl_libdirstem=lib acl_libdirstem2= case "$host_os" in solaris*) dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment dnl . dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link." dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the dnl symlink is missing, so we set acl_libdirstem2 too. AC_CACHE_CHECK([for 64-bit host], [gl_cv_solaris_64bit], [AC_EGREP_CPP([sixtyfour bits], [ #ifdef _LP64 sixtyfour bits #endif ], [gl_cv_solaris_64bit=yes], [gl_cv_solaris_64bit=no]) ]) if test $gl_cv_solaris_64bit = yes; then acl_libdirstem=lib/64 case "$host_cpu" in sparc*) acl_libdirstem2=lib/sparcv9 ;; i*86 | x86_64) acl_libdirstem2=lib/amd64 ;; esac fi ;; *) searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` if test -n "$searchpath"; then acl_save_IFS="${IFS= }"; IFS=":" for searchdir in $searchpath; do if test -d "$searchdir"; then case "$searchdir" in */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; */../ | */.. ) # Better ignore directories of this form. They are misleading. ;; *) searchdir=`cd "$searchdir" && pwd` case "$searchdir" in */lib64 ) acl_libdirstem=lib64 ;; esac ;; esac fi done IFS="$acl_save_IFS" fi ;; esac test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem" ]) # pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- # serial 1 (pkg-config-0.24) # # Copyright © 2004 Scott James Remnant . # # 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # PKG_PROG_PKG_CONFIG([MIN-VERSION]) # ---------------------------------- AC_DEFUN([PKG_PROG_PKG_CONFIG], [m4_pattern_forbid([^_?PKG_[A-Z_]+$]) m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) fi if test -n "$PKG_CONFIG"; then _pkg_min_version=m4_default([$1], [0.9.0]) AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) PKG_CONFIG="" fi fi[]dnl ])# PKG_PROG_PKG_CONFIG # PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # # Check to see whether a particular set of modules exists. Similar # to PKG_CHECK_MODULES(), but does not set variables or print errors. # # Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) # only at the first occurence in configure.ac, so if the first place # it's called might be skipped (such as if it is within an "if", you # have to call PKG_CHECK_EXISTS manually # -------------------------------------------------------------- AC_DEFUN([PKG_CHECK_EXISTS], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl if test -n "$PKG_CONFIG" && \ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then m4_default([$2], [:]) m4_ifvaln([$3], [else $3])dnl fi]) # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) # --------------------------------------------- m4_define([_PKG_CONFIG], [if test -n "$$1"; then pkg_cv_[]$1="$$1" elif test -n "$PKG_CONFIG"; then PKG_CHECK_EXISTS([$3], [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes ], [pkg_failed=yes]) else pkg_failed=untried fi[]dnl ])# _PKG_CONFIG # _PKG_SHORT_ERRORS_SUPPORTED # ----------------------------- AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], [AC_REQUIRE([PKG_PROG_PKG_CONFIG]) if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi[]dnl ])# _PKG_SHORT_ERRORS_SUPPORTED # PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], # [ACTION-IF-NOT-FOUND]) # # # Note that if there is a possibility the first call to # PKG_CHECK_MODULES might not happen, you should be sure to include an # explicit call to PKG_PROG_PKG_CONFIG in your configure.ac # # # -------------------------------------------------------------- AC_DEFUN([PKG_CHECK_MODULES], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl pkg_failed=no AC_MSG_CHECKING([for $1]) _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) _PKG_CONFIG([$1][_LIBS], [libs], [$2]) m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS and $1[]_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.]) if test $pkg_failed = yes; then AC_MSG_RESULT([no]) _PKG_SHORT_ERRORS_SUPPORTED if test $_pkg_short_errors_supported = yes; then $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` else $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD m4_default([$4], [AC_MSG_ERROR( [Package requirements ($2) were not met: $$1_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. _PKG_TEXT])[]dnl ]) elif test $pkg_failed = untried; then AC_MSG_RESULT([no]) m4_default([$4], [AC_MSG_FAILURE( [The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. _PKG_TEXT To get pkg-config, see .])[]dnl ]) else $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS $1[]_LIBS=$pkg_cv_[]$1[]_LIBS AC_MSG_RESULT([yes]) $3 fi[]dnl ])# PKG_CHECK_MODULES # PKG_INSTALLDIR(DIRECTORY) # ------------------------- # Substitutes the variable pkgconfigdir as the location where a module # should install pkg-config .pc files. By default the directory is # $libdir/pkgconfig, but the default can be changed by passing # DIRECTORY. The user can override through the --with-pkgconfigdir # parameter. AC_DEFUN([PKG_INSTALLDIR], [m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) m4_pushdef([pkg_description], [pkg-config installation directory @<:@]pkg_default[@:>@]) AC_ARG_WITH([pkgconfigdir], [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],, [with_pkgconfigdir=]pkg_default) AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) m4_popdef([pkg_default]) m4_popdef([pkg_description]) ]) dnl PKG_INSTALLDIR # PKG_NOARCH_INSTALLDIR(DIRECTORY) # ------------------------- # Substitutes the variable noarch_pkgconfigdir as the location where a # module should install arch-independent pkg-config .pc files. By # default the directory is $datadir/pkgconfig, but the default can be # changed by passing DIRECTORY. The user can override through the # --with-noarch-pkgconfigdir parameter. AC_DEFUN([PKG_NOARCH_INSTALLDIR], [m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) m4_pushdef([pkg_description], [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@]) AC_ARG_WITH([noarch-pkgconfigdir], [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],, [with_noarch_pkgconfigdir=]pkg_default) AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) m4_popdef([pkg_default]) m4_popdef([pkg_description]) ]) dnl PKG_NOARCH_INSTALLDIR # PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # ------------------------------------------- # Retrieves the value of the pkg-config variable for the given module. AC_DEFUN([PKG_CHECK_VAR], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl _PKG_CONFIG([$1], [variable="][$3]["], [$2]) AS_VAR_COPY([$1], [pkg_cv_][$1]) AS_VAR_IF([$1], [""], [$5], [$4])dnl ])# PKG_CHECK_VAR # PKG_WITH_MODULES(VARIABLE-PREFIX, MODULES, # [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND], # [DESCRIPTION], [DEFAULT]) # # Prepare a "--with-" configure option using the lowercase [VARIABLE-PREFIX] # name, merging the behaviour of AC_ARG_WITH and PKG_CHECK_MODULES in a single # macro # # -------------------------------------------------------------- AC_DEFUN([PKG_WITH_MODULES], [ m4_pushdef([with_arg], m4_tolower([$1])) m4_pushdef([description], [m4_default([$5], [build with ]with_arg[ support])]) m4_pushdef([def_arg], [m4_default([$6], [auto])]) m4_pushdef([def_action_if_found], [AS_TR_SH([with_]with_arg)=yes]) m4_pushdef([def_action_if_not_found], [AS_TR_SH([with_]with_arg)=no]) m4_case(def_arg, [yes],[m4_pushdef([with_without], [--without-]with_arg)], [m4_pushdef([with_without],[--with-]with_arg)]) AC_ARG_WITH(with_arg, AS_HELP_STRING(with_without, description[ @<:@default=]def_arg[@:>@]),, [AS_TR_SH([with_]with_arg)=def_arg]) AS_CASE([$AS_TR_SH([with_]with_arg)], [yes],[PKG_CHECK_MODULES([$1],[$2],$3,$4)], [auto],[PKG_CHECK_MODULES([$1],[$2], [m4_n([def_action_if_found]) $3], [m4_n([def_action_if_not_found]) $4])]) m4_popdef([with_arg]) m4_popdef([description]) m4_popdef([def_arg]) ]) dnl PKG_WITH_MODULES # PKG_HAVE_WITH_MODULES(VARIABLE-PREFIX, MODULES, # [DESCRIPTION], [DEFAULT]) # # Convenience macro to trigger AM_CONDITIONAL after # PKG_WITH_MODULES check. # # HAVE_[VARIABLE-PREFIX] is exported as make variable. # # -------------------------------------------------------------- AC_DEFUN([PKG_HAVE_WITH_MODULES], [ PKG_WITH_MODULES([$1],[$2],,,[$3],[$4]) AM_CONDITIONAL([HAVE_][$1], [test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"]) ]) # PKG_HAVE_DEFINE_WITH_MODULES(VARIABLE-PREFIX, MODULES, # [DESCRIPTION], [DEFAULT]) # # Convenience macro to run AM_CONDITIONAL and AC_DEFINE after # PKG_WITH_MODULES check. # # HAVE_[VARIABLE-PREFIX] is exported as make and preprocessor variable. # # -------------------------------------------------------------- AC_DEFUN([PKG_HAVE_DEFINE_WITH_MODULES], [ PKG_HAVE_WITH_MODULES([$1],[$2],[$3],[$4]) AS_IF([test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"], [AC_DEFINE([HAVE_][$1], 1, [Enable ]m4_tolower([$1])[ support])]) ]) # ltdl.m4 - Configure ltdl for the target system. -*-Autoconf-*- # # Copyright (C) 1999-2008, 2011-2015 Free Software Foundation, Inc. # Written by Thomas Tanner, 1999 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 20 LTDL_INIT # LT_CONFIG_LTDL_DIR(DIRECTORY, [LTDL-MODE]) # ------------------------------------------ # DIRECTORY contains the libltdl sources. It is okay to call this # function multiple times, as long as the same DIRECTORY is always given. AC_DEFUN([LT_CONFIG_LTDL_DIR], [AC_BEFORE([$0], [LTDL_INIT]) _$0($*) ])# LT_CONFIG_LTDL_DIR # We break this out into a separate macro, so that we can call it safely # internally without being caught accidentally by the sed scan in libtoolize. m4_defun([_LT_CONFIG_LTDL_DIR], [dnl remove trailing slashes m4_pushdef([_ARG_DIR], m4_bpatsubst([$1], [/*$])) m4_case(_LTDL_DIR, [], [dnl only set lt_ltdl_dir if _ARG_DIR is not simply '.' m4_if(_ARG_DIR, [.], [], [m4_define([_LTDL_DIR], _ARG_DIR) _LT_SHELL_INIT([lt_ltdl_dir=']_ARG_DIR['])])], [m4_if(_ARG_DIR, _LTDL_DIR, [], [m4_fatal([multiple libltdl directories: ']_LTDL_DIR[', ']_ARG_DIR['])])]) m4_popdef([_ARG_DIR]) ])# _LT_CONFIG_LTDL_DIR # Initialise: m4_define([_LTDL_DIR], []) # _LT_BUILD_PREFIX # ---------------- # If Autoconf is new enough, expand to '$(top_build_prefix)', otherwise # to '$(top_builddir)/'. m4_define([_LT_BUILD_PREFIX], [m4_ifdef([AC_AUTOCONF_VERSION], [m4_if(m4_version_compare(m4_defn([AC_AUTOCONF_VERSION]), [2.62]), [-1], [m4_ifdef([_AC_HAVE_TOP_BUILD_PREFIX], [$(top_build_prefix)], [$(top_builddir)/])], [$(top_build_prefix)])], [$(top_builddir)/])[]dnl ]) # LTDL_CONVENIENCE # ---------------- # sets LIBLTDL to the link flags for the libltdl convenience library and # LTDLINCL to the include flags for the libltdl header and adds # --enable-ltdl-convenience to the configure arguments. Note that # AC_CONFIG_SUBDIRS is not called here. LIBLTDL will be prefixed with # '$(top_build_prefix)' if available, otherwise with '$(top_builddir)/', # and LTDLINCL will be prefixed with '$(top_srcdir)/' (note the single # quotes!). If your package is not flat and you're not using automake, # define top_build_prefix, top_builddir, and top_srcdir appropriately # in your Makefiles. AC_DEFUN([LTDL_CONVENIENCE], [AC_BEFORE([$0], [LTDL_INIT])dnl dnl Although the argument is deprecated and no longer documented, dnl LTDL_CONVENIENCE used to take a DIRECTORY orgument, if we have one dnl here make sure it is the same as any other declaration of libltdl's dnl location! This also ensures lt_ltdl_dir is set when configure.ac is dnl not yet using an explicit LT_CONFIG_LTDL_DIR. m4_ifval([$1], [_LT_CONFIG_LTDL_DIR([$1])])dnl _$0() ])# LTDL_CONVENIENCE # AC_LIBLTDL_CONVENIENCE accepted a directory argument in older libtools, # now we have LT_CONFIG_LTDL_DIR: AU_DEFUN([AC_LIBLTDL_CONVENIENCE], [_LT_CONFIG_LTDL_DIR([m4_default([$1], [libltdl])]) _LTDL_CONVENIENCE]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBLTDL_CONVENIENCE], []) # _LTDL_CONVENIENCE # ----------------- # Code shared by LTDL_CONVENIENCE and LTDL_INIT([convenience]). m4_defun([_LTDL_CONVENIENCE], [case $enable_ltdl_convenience in no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;; "") enable_ltdl_convenience=yes ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;; esac LIBLTDL='_LT_BUILD_PREFIX'"${lt_ltdl_dir+$lt_ltdl_dir/}libltdlc.la" LTDLDEPS=$LIBLTDL LTDLINCL='-I$(top_srcdir)'"${lt_ltdl_dir+/$lt_ltdl_dir}" AC_SUBST([LIBLTDL]) AC_SUBST([LTDLDEPS]) AC_SUBST([LTDLINCL]) # For backwards non-gettext consistent compatibility... INCLTDL=$LTDLINCL AC_SUBST([INCLTDL]) ])# _LTDL_CONVENIENCE # LTDL_INSTALLABLE # ---------------- # sets LIBLTDL to the link flags for the libltdl installable library # and LTDLINCL to the include flags for the libltdl header and adds # --enable-ltdl-install to the configure arguments. Note that # AC_CONFIG_SUBDIRS is not called from here. If an installed libltdl # is not found, LIBLTDL will be prefixed with '$(top_build_prefix)' if # available, otherwise with '$(top_builddir)/', and LTDLINCL will be # prefixed with '$(top_srcdir)/' (note the single quotes!). If your # package is not flat and you're not using automake, define top_build_prefix, # top_builddir, and top_srcdir appropriately in your Makefiles. # In the future, this macro may have to be called after LT_INIT. AC_DEFUN([LTDL_INSTALLABLE], [AC_BEFORE([$0], [LTDL_INIT])dnl dnl Although the argument is deprecated and no longer documented, dnl LTDL_INSTALLABLE used to take a DIRECTORY orgument, if we have one dnl here make sure it is the same as any other declaration of libltdl's dnl location! This also ensures lt_ltdl_dir is set when configure.ac is dnl not yet using an explicit LT_CONFIG_LTDL_DIR. m4_ifval([$1], [_LT_CONFIG_LTDL_DIR([$1])])dnl _$0() ])# LTDL_INSTALLABLE # AC_LIBLTDL_INSTALLABLE accepted a directory argument in older libtools, # now we have LT_CONFIG_LTDL_DIR: AU_DEFUN([AC_LIBLTDL_INSTALLABLE], [_LT_CONFIG_LTDL_DIR([m4_default([$1], [libltdl])]) _LTDL_INSTALLABLE]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBLTDL_INSTALLABLE], []) # _LTDL_INSTALLABLE # ----------------- # Code shared by LTDL_INSTALLABLE and LTDL_INIT([installable]). m4_defun([_LTDL_INSTALLABLE], [if test -f "$prefix/lib/libltdl.la"; then lt_save_LDFLAGS=$LDFLAGS LDFLAGS="-L$prefix/lib $LDFLAGS" AC_CHECK_LIB([ltdl], [lt_dlinit], [lt_lib_ltdl=yes]) LDFLAGS=$lt_save_LDFLAGS if test yes = "${lt_lib_ltdl-no}"; then if test yes != "$enable_ltdl_install"; then # Don't overwrite $prefix/lib/libltdl.la without --enable-ltdl-install AC_MSG_WARN([not overwriting libltdl at $prefix, force with '--enable-ltdl-install']) enable_ltdl_install=no fi elif test no = "$enable_ltdl_install"; then AC_MSG_WARN([libltdl not installed, but installation disabled]) fi fi # If configure.ac declared an installable ltdl, and the user didn't override # with --disable-ltdl-install, we will install the shipped libltdl. case $enable_ltdl_install in no) ac_configure_args="$ac_configure_args --enable-ltdl-install=no" LIBLTDL=-lltdl LTDLDEPS= LTDLINCL= ;; *) enable_ltdl_install=yes ac_configure_args="$ac_configure_args --enable-ltdl-install" LIBLTDL='_LT_BUILD_PREFIX'"${lt_ltdl_dir+$lt_ltdl_dir/}libltdl.la" LTDLDEPS=$LIBLTDL LTDLINCL='-I$(top_srcdir)'"${lt_ltdl_dir+/$lt_ltdl_dir}" ;; esac AC_SUBST([LIBLTDL]) AC_SUBST([LTDLDEPS]) AC_SUBST([LTDLINCL]) # For backwards non-gettext consistent compatibility... INCLTDL=$LTDLINCL AC_SUBST([INCLTDL]) ])# LTDL_INSTALLABLE # _LTDL_MODE_DISPATCH # ------------------- m4_define([_LTDL_MODE_DISPATCH], [dnl If _LTDL_DIR is '.', then we are configuring libltdl itself: m4_if(_LTDL_DIR, [], [], dnl if _LTDL_MODE was not set already, the default value is 'subproject': [m4_case(m4_default(_LTDL_MODE, [subproject]), [subproject], [AC_CONFIG_SUBDIRS(_LTDL_DIR) _LT_SHELL_INIT([lt_dlopen_dir=$lt_ltdl_dir])], [nonrecursive], [_LT_SHELL_INIT([lt_dlopen_dir=$lt_ltdl_dir; lt_libobj_prefix=$lt_ltdl_dir/])], [recursive], [], [m4_fatal([unknown libltdl mode: ]_LTDL_MODE)])])dnl dnl Be careful not to expand twice: m4_define([$0], []) ])# _LTDL_MODE_DISPATCH # _LT_LIBOBJ(MODULE_NAME) # ----------------------- # Like AC_LIBOBJ, except that MODULE_NAME goes into _LT_LIBOBJS instead # of into LIBOBJS. AC_DEFUN([_LT_LIBOBJ], [ m4_pattern_allow([^_LT_LIBOBJS$]) _LT_LIBOBJS="$_LT_LIBOBJS $1.$ac_objext" ])# _LT_LIBOBJS # LTDL_INIT([OPTIONS]) # -------------------- # Clients of libltdl can use this macro to allow the installer to # choose between a shipped copy of the ltdl sources or a preinstalled # version of the library. If the shipped ltdl sources are not in a # subdirectory named libltdl, the directory name must be given by # LT_CONFIG_LTDL_DIR. AC_DEFUN([LTDL_INIT], [dnl Parse OPTIONS _LT_SET_OPTIONS([$0], [$1]) dnl We need to keep our own list of libobjs separate from our parent project, dnl and the easiest way to do that is redefine the AC_LIBOBJs macro while dnl we look for our own LIBOBJs. m4_pushdef([AC_LIBOBJ], m4_defn([_LT_LIBOBJ])) m4_pushdef([AC_LIBSOURCES]) dnl If not otherwise defined, default to the 1.5.x compatible subproject mode: m4_if(_LTDL_MODE, [], [m4_define([_LTDL_MODE], m4_default([$2], [subproject])) m4_if([-1], [m4_bregexp(_LTDL_MODE, [\(subproject\|\(non\)?recursive\)])], [m4_fatal([unknown libltdl mode: ]_LTDL_MODE)])]) AC_ARG_WITH([included_ltdl], [AS_HELP_STRING([--with-included-ltdl], [use the GNU ltdl sources included here])]) if test yes != "$with_included_ltdl"; then # We are not being forced to use the included libltdl sources, so # decide whether there is a useful installed version we can use. AC_CHECK_HEADER([ltdl.h], [AC_CHECK_DECL([lt_dlinterface_register], [AC_CHECK_LIB([ltdl], [lt_dladvise_preload], [with_included_ltdl=no], [with_included_ltdl=yes])], [with_included_ltdl=yes], [AC_INCLUDES_DEFAULT #include ])], [with_included_ltdl=yes], [AC_INCLUDES_DEFAULT] ) fi dnl If neither LT_CONFIG_LTDL_DIR, LTDL_CONVENIENCE nor LTDL_INSTALLABLE dnl was called yet, then for old times' sake, we assume libltdl is in an dnl eponymous directory: AC_PROVIDE_IFELSE([LT_CONFIG_LTDL_DIR], [], [_LT_CONFIG_LTDL_DIR([libltdl])]) AC_ARG_WITH([ltdl_include], [AS_HELP_STRING([--with-ltdl-include=DIR], [use the ltdl headers installed in DIR])]) if test -n "$with_ltdl_include"; then if test -f "$with_ltdl_include/ltdl.h"; then : else AC_MSG_ERROR([invalid ltdl include directory: '$with_ltdl_include']) fi else with_ltdl_include=no fi AC_ARG_WITH([ltdl_lib], [AS_HELP_STRING([--with-ltdl-lib=DIR], [use the libltdl.la installed in DIR])]) if test -n "$with_ltdl_lib"; then if test -f "$with_ltdl_lib/libltdl.la"; then : else AC_MSG_ERROR([invalid ltdl library directory: '$with_ltdl_lib']) fi else with_ltdl_lib=no fi case ,$with_included_ltdl,$with_ltdl_include,$with_ltdl_lib, in ,yes,no,no,) m4_case(m4_default(_LTDL_TYPE, [convenience]), [convenience], [_LTDL_CONVENIENCE], [installable], [_LTDL_INSTALLABLE], [m4_fatal([unknown libltdl build type: ]_LTDL_TYPE)]) ;; ,no,no,no,) # If the included ltdl is not to be used, then use the # preinstalled libltdl we found. AC_DEFINE([HAVE_LTDL], [1], [Define this if a modern libltdl is already installed]) LIBLTDL=-lltdl LTDLDEPS= LTDLINCL= ;; ,no*,no,*) AC_MSG_ERROR(['--with-ltdl-include' and '--with-ltdl-lib' options must be used together]) ;; *) with_included_ltdl=no LIBLTDL="-L$with_ltdl_lib -lltdl" LTDLDEPS= LTDLINCL=-I$with_ltdl_include ;; esac INCLTDL=$LTDLINCL # Report our decision... AC_MSG_CHECKING([where to find libltdl headers]) AC_MSG_RESULT([$LTDLINCL]) AC_MSG_CHECKING([where to find libltdl library]) AC_MSG_RESULT([$LIBLTDL]) _LTDL_SETUP dnl restore autoconf definition. m4_popdef([AC_LIBOBJ]) m4_popdef([AC_LIBSOURCES]) AC_CONFIG_COMMANDS_PRE([ _ltdl_libobjs= _ltdl_ltlibobjs= if test -n "$_LT_LIBOBJS"; then # Remove the extension. _lt_sed_drop_objext='s/\.o$//;s/\.obj$//' for i in `for i in $_LT_LIBOBJS; do echo "$i"; done | sed "$_lt_sed_drop_objext" | sort -u`; do _ltdl_libobjs="$_ltdl_libobjs $lt_libobj_prefix$i.$ac_objext" _ltdl_ltlibobjs="$_ltdl_ltlibobjs $lt_libobj_prefix$i.lo" done fi AC_SUBST([ltdl_LIBOBJS], [$_ltdl_libobjs]) AC_SUBST([ltdl_LTLIBOBJS], [$_ltdl_ltlibobjs]) ]) # Only expand once: m4_define([LTDL_INIT]) ])# LTDL_INIT # Old names: AU_DEFUN([AC_LIB_LTDL], [LTDL_INIT($@)]) AU_DEFUN([AC_WITH_LTDL], [LTDL_INIT($@)]) AU_DEFUN([LT_WITH_LTDL], [LTDL_INIT($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIB_LTDL], []) dnl AC_DEFUN([AC_WITH_LTDL], []) dnl AC_DEFUN([LT_WITH_LTDL], []) # _LTDL_SETUP # ----------- # Perform all the checks necessary for compilation of the ltdl objects # -- including compiler checks and header checks. This is a public # interface mainly for the benefit of libltdl's own configure.ac, most # other users should call LTDL_INIT instead. AC_DEFUN([_LTDL_SETUP], [AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([LT_SYS_MODULE_EXT])dnl AC_REQUIRE([LT_SYS_MODULE_PATH])dnl AC_REQUIRE([LT_SYS_DLSEARCH_PATH])dnl AC_REQUIRE([LT_LIB_DLLOAD])dnl AC_REQUIRE([LT_SYS_SYMBOL_USCORE])dnl AC_REQUIRE([LT_FUNC_DLSYM_USCORE])dnl AC_REQUIRE([LT_SYS_DLOPEN_DEPLIBS])dnl AC_REQUIRE([LT_FUNC_ARGZ])dnl m4_require([_LT_CHECK_OBJDIR])dnl m4_require([_LT_HEADER_DLFCN])dnl m4_require([_LT_CHECK_DLPREOPEN])dnl m4_require([_LT_DECL_SED])dnl dnl Don't require this, or it will be expanded earlier than the code dnl that sets the variables it relies on: _LT_ENABLE_INSTALL dnl _LTDL_MODE specific code must be called at least once: _LTDL_MODE_DISPATCH # In order that ltdl.c can compile, find out the first AC_CONFIG_HEADERS # the user used. This is so that ltdl.h can pick up the parent projects # config.h file, The first file in AC_CONFIG_HEADERS must contain the # definitions required by ltdl.c. # FIXME: Remove use of undocumented AC_LIST_HEADERS (2.59 compatibility). AC_CONFIG_COMMANDS_PRE([dnl m4_pattern_allow([^LT_CONFIG_H$])dnl m4_ifset([AH_HEADER], [LT_CONFIG_H=AH_HEADER], [m4_ifset([AC_LIST_HEADERS], [LT_CONFIG_H=`echo "AC_LIST_HEADERS" | $SED 's|^[[ ]]*||;s|[[ :]].*$||'`], [])])]) AC_SUBST([LT_CONFIG_H]) AC_CHECK_HEADERS([unistd.h dl.h sys/dl.h dld.h mach-o/dyld.h dirent.h], [], [], [AC_INCLUDES_DEFAULT]) AC_CHECK_FUNCS([closedir opendir readdir], [], [AC_LIBOBJ([lt__dirent])]) AC_CHECK_FUNCS([strlcat strlcpy], [], [AC_LIBOBJ([lt__strl])]) m4_pattern_allow([LT_LIBEXT])dnl AC_DEFINE_UNQUOTED([LT_LIBEXT],["$libext"],[The archive extension]) name= eval "lt_libprefix=\"$libname_spec\"" m4_pattern_allow([LT_LIBPREFIX])dnl AC_DEFINE_UNQUOTED([LT_LIBPREFIX],["$lt_libprefix"],[The archive prefix]) name=ltdl eval "LTDLOPEN=\"$libname_spec\"" AC_SUBST([LTDLOPEN]) ])# _LTDL_SETUP # _LT_ENABLE_INSTALL # ------------------ m4_define([_LT_ENABLE_INSTALL], [AC_ARG_ENABLE([ltdl-install], [AS_HELP_STRING([--enable-ltdl-install], [install libltdl])]) case ,$enable_ltdl_install,$enable_ltdl_convenience in *yes*) ;; *) enable_ltdl_convenience=yes ;; esac m4_ifdef([AM_CONDITIONAL], [AM_CONDITIONAL(INSTALL_LTDL, test no != "${enable_ltdl_install-no}") AM_CONDITIONAL(CONVENIENCE_LTDL, test no != "${enable_ltdl_convenience-no}")]) ])# _LT_ENABLE_INSTALL # LT_SYS_DLOPEN_DEPLIBS # --------------------- AC_DEFUN([LT_SYS_DLOPEN_DEPLIBS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_CACHE_CHECK([whether deplibs are loaded by dlopen], [lt_cv_sys_dlopen_deplibs], [# PORTME does your system automatically load deplibs for dlopen? # or its logical equivalent (e.g. shl_load for HP-UX < 11) # For now, we just catch OSes we know something about -- in the # future, we'll try test this programmatically. lt_cv_sys_dlopen_deplibs=unknown case $host_os in aix3*|aix4.1.*|aix4.2.*) # Unknown whether this is true for these versions of AIX, but # we want this 'case' here to explicitly catch those versions. lt_cv_sys_dlopen_deplibs=unknown ;; aix[[4-9]]*) lt_cv_sys_dlopen_deplibs=yes ;; amigaos*) case $host_cpu in powerpc) lt_cv_sys_dlopen_deplibs=no ;; esac ;; bitrig*) lt_cv_sys_dlopen_deplibs=yes ;; darwin*) # Assuming the user has installed a libdl from somewhere, this is true # If you are looking for one http://www.opendarwin.org/projects/dlcompat lt_cv_sys_dlopen_deplibs=yes ;; freebsd* | dragonfly*) lt_cv_sys_dlopen_deplibs=yes ;; gnu* | linux* | k*bsd*-gnu | kopensolaris*-gnu) # GNU and its variants, using gnu ld.so (Glibc) lt_cv_sys_dlopen_deplibs=yes ;; hpux10*|hpux11*) lt_cv_sys_dlopen_deplibs=yes ;; interix*) lt_cv_sys_dlopen_deplibs=yes ;; irix[[12345]]*|irix6.[[01]]*) # Catch all versions of IRIX before 6.2, and indicate that we don't # know how it worked for any of those versions. lt_cv_sys_dlopen_deplibs=unknown ;; irix*) # The case above catches anything before 6.2, and it's known that # at 6.2 and later dlopen does load deplibs. lt_cv_sys_dlopen_deplibs=yes ;; netbsd*) lt_cv_sys_dlopen_deplibs=yes ;; openbsd*) lt_cv_sys_dlopen_deplibs=yes ;; osf[[1234]]*) # dlopen did load deplibs (at least at 4.x), but until the 5.x series, # it did *not* use an RPATH in a shared library to find objects the # library depends on, so we explicitly say 'no'. lt_cv_sys_dlopen_deplibs=no ;; osf5.0|osf5.0a|osf5.1) # dlopen *does* load deplibs and with the right loader patch applied # it even uses RPATH in a shared library to search for shared objects # that the library depends on, but there's no easy way to know if that # patch is installed. Since this is the case, all we can really # say is unknown -- it depends on the patch being installed. If # it is, this changes to 'yes'. Without it, it would be 'no'. lt_cv_sys_dlopen_deplibs=unknown ;; osf*) # the two cases above should catch all versions of osf <= 5.1. Read # the comments above for what we know about them. # At > 5.1, deplibs are loaded *and* any RPATH in a shared library # is used to find them so we can finally say 'yes'. lt_cv_sys_dlopen_deplibs=yes ;; qnx*) lt_cv_sys_dlopen_deplibs=yes ;; solaris*) lt_cv_sys_dlopen_deplibs=yes ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) libltdl_cv_sys_dlopen_deplibs=yes ;; esac ]) if test yes != "$lt_cv_sys_dlopen_deplibs"; then AC_DEFINE([LTDL_DLOPEN_DEPLIBS], [1], [Define if the OS needs help to load dependent libraries for dlopen().]) fi ])# LT_SYS_DLOPEN_DEPLIBS # Old name: AU_ALIAS([AC_LTDL_SYS_DLOPEN_DEPLIBS], [LT_SYS_DLOPEN_DEPLIBS]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LTDL_SYS_DLOPEN_DEPLIBS], []) # LT_SYS_MODULE_EXT # ----------------- AC_DEFUN([LT_SYS_MODULE_EXT], [m4_require([_LT_SYS_DYNAMIC_LINKER])dnl AC_CACHE_CHECK([what extension is used for runtime loadable modules], [libltdl_cv_shlibext], [ module=yes eval libltdl_cv_shlibext=$shrext_cmds module=no eval libltdl_cv_shrext=$shrext_cmds ]) if test -n "$libltdl_cv_shlibext"; then m4_pattern_allow([LT_MODULE_EXT])dnl AC_DEFINE_UNQUOTED([LT_MODULE_EXT], ["$libltdl_cv_shlibext"], [Define to the extension used for runtime loadable modules, say, ".so".]) fi if test "$libltdl_cv_shrext" != "$libltdl_cv_shlibext"; then m4_pattern_allow([LT_SHARED_EXT])dnl AC_DEFINE_UNQUOTED([LT_SHARED_EXT], ["$libltdl_cv_shrext"], [Define to the shared library suffix, say, ".dylib".]) fi if test -n "$shared_archive_member_spec"; then m4_pattern_allow([LT_SHARED_LIB_MEMBER])dnl AC_DEFINE_UNQUOTED([LT_SHARED_LIB_MEMBER], ["($shared_archive_member_spec.o)"], [Define to the shared archive member specification, say "(shr.o)".]) fi ])# LT_SYS_MODULE_EXT # Old name: AU_ALIAS([AC_LTDL_SHLIBEXT], [LT_SYS_MODULE_EXT]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LTDL_SHLIBEXT], []) # LT_SYS_MODULE_PATH # ------------------ AC_DEFUN([LT_SYS_MODULE_PATH], [m4_require([_LT_SYS_DYNAMIC_LINKER])dnl AC_CACHE_CHECK([what variable specifies run-time module search path], [lt_cv_module_path_var], [lt_cv_module_path_var=$shlibpath_var]) if test -n "$lt_cv_module_path_var"; then m4_pattern_allow([LT_MODULE_PATH_VAR])dnl AC_DEFINE_UNQUOTED([LT_MODULE_PATH_VAR], ["$lt_cv_module_path_var"], [Define to the name of the environment variable that determines the run-time module search path.]) fi ])# LT_SYS_MODULE_PATH # Old name: AU_ALIAS([AC_LTDL_SHLIBPATH], [LT_SYS_MODULE_PATH]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LTDL_SHLIBPATH], []) # LT_SYS_DLSEARCH_PATH # -------------------- AC_DEFUN([LT_SYS_DLSEARCH_PATH], [m4_require([_LT_SYS_DYNAMIC_LINKER])dnl AC_CACHE_CHECK([for the default library search path], [lt_cv_sys_dlsearch_path], [lt_cv_sys_dlsearch_path=$sys_lib_dlsearch_path_spec]) if test -n "$lt_cv_sys_dlsearch_path"; then sys_dlsearch_path= for dir in $lt_cv_sys_dlsearch_path; do if test -z "$sys_dlsearch_path"; then sys_dlsearch_path=$dir else sys_dlsearch_path=$sys_dlsearch_path$PATH_SEPARATOR$dir fi done m4_pattern_allow([LT_DLSEARCH_PATH])dnl AC_DEFINE_UNQUOTED([LT_DLSEARCH_PATH], ["$sys_dlsearch_path"], [Define to the system default library search path.]) fi ])# LT_SYS_DLSEARCH_PATH # Old name: AU_ALIAS([AC_LTDL_SYSSEARCHPATH], [LT_SYS_DLSEARCH_PATH]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LTDL_SYSSEARCHPATH], []) # _LT_CHECK_DLPREOPEN # ------------------- m4_defun([_LT_CHECK_DLPREOPEN], [m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl AC_CACHE_CHECK([whether libtool supports -dlopen/-dlpreopen], [libltdl_cv_preloaded_symbols], [if test -n "$lt_cv_sys_global_symbol_pipe"; then libltdl_cv_preloaded_symbols=yes else libltdl_cv_preloaded_symbols=no fi ]) if test yes = "$libltdl_cv_preloaded_symbols"; then AC_DEFINE([HAVE_PRELOADED_SYMBOLS], [1], [Define if libtool can extract symbol lists from object files.]) fi ])# _LT_CHECK_DLPREOPEN # LT_LIB_DLLOAD # ------------- AC_DEFUN([LT_LIB_DLLOAD], [m4_pattern_allow([^LT_DLLOADERS$]) LT_DLLOADERS= AC_SUBST([LT_DLLOADERS]) AC_LANG_PUSH([C]) lt_dlload_save_LIBS=$LIBS LIBADD_DLOPEN= AC_SEARCH_LIBS([dlopen], [dl], [AC_DEFINE([HAVE_LIBDL], [1], [Define if you have the libdl library or equivalent.]) if test "$ac_cv_search_dlopen" != "none required"; then LIBADD_DLOPEN=-ldl fi libltdl_cv_lib_dl_dlopen=yes LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}dlopen.la"], [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#if HAVE_DLFCN_H # include #endif ]], [[dlopen(0, 0);]])], [AC_DEFINE([HAVE_LIBDL], [1], [Define if you have the libdl library or equivalent.]) libltdl_cv_func_dlopen=yes LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}dlopen.la"], [AC_CHECK_LIB([svld], [dlopen], [AC_DEFINE([HAVE_LIBDL], [1], [Define if you have the libdl library or equivalent.]) LIBADD_DLOPEN=-lsvld libltdl_cv_func_dlopen=yes LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}dlopen.la"])])]) if test yes = "$libltdl_cv_func_dlopen" || test yes = "$libltdl_cv_lib_dl_dlopen" then lt_save_LIBS=$LIBS LIBS="$LIBS $LIBADD_DLOPEN" AC_CHECK_FUNCS([dlerror]) LIBS=$lt_save_LIBS fi AC_SUBST([LIBADD_DLOPEN]) LIBADD_SHL_LOAD= AC_CHECK_FUNC([shl_load], [AC_DEFINE([HAVE_SHL_LOAD], [1], [Define if you have the shl_load function.]) LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}shl_load.la"], [AC_CHECK_LIB([dld], [shl_load], [AC_DEFINE([HAVE_SHL_LOAD], [1], [Define if you have the shl_load function.]) LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}shl_load.la" LIBADD_SHL_LOAD=-ldld])]) AC_SUBST([LIBADD_SHL_LOAD]) case $host_os in darwin[[1567]].*) # We only want this for pre-Mac OS X 10.4. AC_CHECK_FUNC([_dyld_func_lookup], [AC_DEFINE([HAVE_DYLD], [1], [Define if you have the _dyld_func_lookup function.]) LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}dyld.la"]) ;; beos*) LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}load_add_on.la" ;; cygwin* | mingw* | pw32*) AC_CHECK_DECLS([cygwin_conv_path], [], [], [[#include ]]) LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}loadlibrary.la" ;; esac AC_CHECK_LIB([dld], [dld_link], [AC_DEFINE([HAVE_DLD], [1], [Define if you have the GNU dld library.]) LT_DLLOADERS="$LT_DLLOADERS ${lt_dlopen_dir+$lt_dlopen_dir/}dld_link.la"]) AC_SUBST([LIBADD_DLD_LINK]) m4_pattern_allow([^LT_DLPREOPEN$]) LT_DLPREOPEN= if test -n "$LT_DLLOADERS" then for lt_loader in $LT_DLLOADERS; do LT_DLPREOPEN="$LT_DLPREOPEN-dlpreopen $lt_loader " done AC_DEFINE([HAVE_LIBDLLOADER], [1], [Define if libdlloader will be built on this platform]) fi AC_SUBST([LT_DLPREOPEN]) dnl This isn't used anymore, but set it for backwards compatibility LIBADD_DL="$LIBADD_DLOPEN $LIBADD_SHL_LOAD" AC_SUBST([LIBADD_DL]) LIBS=$lt_dlload_save_LIBS AC_LANG_POP ])# LT_LIB_DLLOAD # Old name: AU_ALIAS([AC_LTDL_DLLIB], [LT_LIB_DLLOAD]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LTDL_DLLIB], []) # LT_SYS_SYMBOL_USCORE # -------------------- # does the compiler prefix global symbols with an underscore? AC_DEFUN([LT_SYS_SYMBOL_USCORE], [m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl AC_CACHE_CHECK([for _ prefix in compiled symbols], [lt_cv_sys_symbol_underscore], [lt_cv_sys_symbol_underscore=no cat > conftest.$ac_ext <<_LT_EOF void nm_test_func(){} int main(){nm_test_func;return 0;} _LT_EOF if AC_TRY_EVAL(ac_compile); then # Now try to grab the symbols. ac_nlist=conftest.nm if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $ac_nlist) && test -s "$ac_nlist"; then # See whether the symbols have a leading underscore. if grep '^. _nm_test_func' "$ac_nlist" >/dev/null; then lt_cv_sys_symbol_underscore=yes else if grep '^. nm_test_func ' "$ac_nlist" >/dev/null; then : else echo "configure: cannot find nm_test_func in $ac_nlist" >&AS_MESSAGE_LOG_FD fi fi else echo "configure: cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD fi else echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD cat conftest.c >&AS_MESSAGE_LOG_FD fi rm -rf conftest* ]) sys_symbol_underscore=$lt_cv_sys_symbol_underscore AC_SUBST([sys_symbol_underscore]) ])# LT_SYS_SYMBOL_USCORE # Old name: AU_ALIAS([AC_LTDL_SYMBOL_USCORE], [LT_SYS_SYMBOL_USCORE]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LTDL_SYMBOL_USCORE], []) # LT_FUNC_DLSYM_USCORE # -------------------- AC_DEFUN([LT_FUNC_DLSYM_USCORE], [AC_REQUIRE([_LT_COMPILER_PIC])dnl for lt_prog_compiler_wl AC_REQUIRE([LT_SYS_SYMBOL_USCORE])dnl for lt_cv_sys_symbol_underscore AC_REQUIRE([LT_SYS_MODULE_EXT])dnl for libltdl_cv_shlibext if test yes = "$lt_cv_sys_symbol_underscore"; then if test yes = "$libltdl_cv_func_dlopen" || test yes = "$libltdl_cv_lib_dl_dlopen"; then AC_CACHE_CHECK([whether we have to add an underscore for dlsym], [libltdl_cv_need_uscore], [libltdl_cv_need_uscore=unknown dlsym_uscore_save_LIBS=$LIBS LIBS="$LIBS $LIBADD_DLOPEN" libname=conftmod # stay within 8.3 filename limits! cat >$libname.$ac_ext <<_LT_EOF [#line $LINENO "configure" #include "confdefs.h" /* When -fvisibility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; }] _LT_EOF # ltfn_module_cmds module_cmds # Execute tilde-delimited MODULE_CMDS with environment primed for # $module_cmds or $archive_cmds type content. ltfn_module_cmds () {( # subshell avoids polluting parent global environment module_cmds_save_ifs=$IFS; IFS='~' for cmd in @S|@1; do IFS=$module_cmds_save_ifs libobjs=$libname.$ac_objext; lib=$libname$libltdl_cv_shlibext rpath=/not-exists; soname=$libname$libltdl_cv_shlibext; output_objdir=. major=; versuffix=; verstring=; deplibs= ECHO=echo; wl=$lt_prog_compiler_wl; allow_undefined_flag= eval $cmd done IFS=$module_cmds_save_ifs )} # Compile a loadable module using libtool macro expansion results. $CC $pic_flag -c $libname.$ac_ext ltfn_module_cmds "${module_cmds:-$archive_cmds}" # Try to fetch fnord with dlsym(). libltdl_dlunknown=0; libltdl_dlnouscore=1; libltdl_dluscore=2 cat >conftest.$ac_ext <<_LT_EOF [#line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifndef RTLD_GLOBAL # ifdef DL_GLOBAL # define RTLD_GLOBAL DL_GLOBAL # else # define RTLD_GLOBAL 0 # endif #endif #ifndef RTLD_NOW # ifdef DL_NOW # define RTLD_NOW DL_NOW # else # define RTLD_NOW 0 # endif #endif int main () { void *handle = dlopen ("`pwd`/$libname$libltdl_cv_shlibext", RTLD_GLOBAL|RTLD_NOW); int status = $libltdl_dlunknown; if (handle) { if (dlsym (handle, "fnord")) status = $libltdl_dlnouscore; else { if (dlsym (handle, "_fnord")) status = $libltdl_dluscore; else puts (dlerror ()); } dlclose (handle); } else puts (dlerror ()); return status; }] _LT_EOF if AC_TRY_EVAL(ac_link) && test -s "conftest$ac_exeext" 2>/dev/null; then (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null libltdl_status=$? case x$libltdl_status in x$libltdl_dlnouscore) libltdl_cv_need_uscore=no ;; x$libltdl_dluscore) libltdl_cv_need_uscore=yes ;; x*) libltdl_cv_need_uscore=unknown ;; esac fi rm -rf conftest* $libname* LIBS=$dlsym_uscore_save_LIBS ]) fi fi if test yes = "$libltdl_cv_need_uscore"; then AC_DEFINE([NEED_USCORE], [1], [Define if dlsym() requires a leading underscore in symbol names.]) fi ])# LT_FUNC_DLSYM_USCORE # Old name: AU_ALIAS([AC_LTDL_DLSYM_USCORE], [LT_FUNC_DLSYM_USCORE]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LTDL_DLSYM_USCORE], []) # Copyright (C) 2002-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.15' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.15], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies # the logic in aclocal, which can simply ignore this definition. m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.15])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to # '$srcdir', '$srcdir/..', or '$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is '.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl # Expand $ac_aux_dir to an absolute path. am_aux_dir=`cd "$ac_aux_dir" && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ([2.52])dnl m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl _AM_SUBST_NOTMAKE([$1_FALSE])dnl m4_define([_AM_COND_VALUE_$1], [$2])dnl if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl m4_if([$1], [CC], [depcc="$CC" am_compiler_list=], [$1], [CXX], [depcc="$CXX" am_compiler_list=], [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'], [$1], [UPC], [depcc="$UPC" am_compiler_list=], [$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi am__universal=false m4_case([$1], [CC], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac], [CXX], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac]) for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES. AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE([dependency-tracking], [dnl AS_HELP_STRING( [--enable-dependency-tracking], [do not reject slow dependency extractors]) AS_HELP_STRING( [--disable-dependency-tracking], [speeds up one-time build])]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl AC_SUBST([am__nodep])dnl _AM_SUBST_NOTMAKE([am__nodep])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named 'Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`AS_DIRNAME("$mf")` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running 'make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "$am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`AS_DIRNAME(["$file"])` AS_MKDIR_P([$dirpart/$fdir]) # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS # AM_OUTPUT_DEPENDENCY_COMMANDS # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking # is enabled. FIXME. This creates each '.P' file that we will # need in order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) ]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC]) [_AM_PROG_CC_C_O ]) # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.65])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl # test to see if srcdir already configured if test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [AC_DIAGNOSE([obsolete], [$0: two- and three-arguments forms are deprecated.]) m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if( m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), [ok:ok],, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) AM_MISSING_PROG([AUTOCONF], [autoconf]) AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) AM_MISSING_PROG([AUTOHEADER], [autoheader]) AM_MISSING_PROG([MAKEINFO], [makeinfo]) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # AC_SUBST([mkdir_p], ['$(MKDIR_P)']) # We need awk for the "check" target (and possibly the TAP driver). The # system "awk" is bad on some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES([CC])], [m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES([CXX])], [m4_define([AC_PROG_CXX], m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES([OBJC])], [m4_define([AC_PROG_OBJC], m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], [_AM_DEPENDENCIES([OBJCXX])], [m4_define([AC_PROG_OBJCXX], m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl ]) AC_REQUIRE([AM_SILENT_RULES])dnl dnl The testsuite driver may need to know about EXEEXT, so add the dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) fi fi dnl The trailing newline in this macro's definition is deliberate, for dnl backward compatibility and to allow trailing 'dnl'-style comments dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841. ]) dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl if test x"${install_sh+set}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST([install_sh])]) # Copyright (C) 2003-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MAKE_INCLUDE() # ----------------- # Check to see how make treats includes. AC_DEFUN([AM_MAKE_INCLUDE], [am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. AC_MSG_CHECKING([for style of include used by $am_make]) am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from 'make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi AC_SUBST([am__include]) AC_SUBST([am__quote]) AC_MSG_RESULT([$_am_result]) rm -f confinc confmf ]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it is modern enough. # If it is, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= AC_MSG_WARN(['missing' script is too old or missing]) fi ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # -------------------- # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), [1])]) # _AM_SET_OPTIONS(OPTIONS) # ------------------------ # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Copyright (C) 1999-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_PROG_CC_C_O # --------------- # Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC # to automatically call this. AC_DEFUN([_AM_PROG_CC_C_O], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([compile])dnl AC_LANG_PUSH([C])dnl AC_CACHE_CHECK( [whether $CC understands -c and -o together], [am_cv_prog_cc_c_o], [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i]) if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi AC_LANG_POP([C])]) # For backward compatibility. AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) # Copyright (C) 2001-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_RUN_LOG(COMMAND) # ------------------- # Run COMMAND, save the exit status in ac_status, and log it. # (This has been adapted from Autoconf's _AC_RUN_LOG macro.) AC_DEFUN([AM_RUN_LOG], [{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD (exit $ac_status); }]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[[\\\"\#\$\&\'\`$am_lf]]*) AC_MSG_ERROR([unsafe absolute working directory name]);; esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; esac # Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi if test "$[2]" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT([yes]) # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi AC_CONFIG_COMMANDS_PRE( [AC_MSG_CHECKING([that generated files are newer than configure]) if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi AC_MSG_RESULT([done])]) rm -f conftest.file ]) # Copyright (C) 2009-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_SILENT_RULES([DEFAULT]) # -------------------------- # Enable less verbose build rules; with the default set to DEFAULT # ("yes" being less verbose, "no" or empty being verbose). AC_DEFUN([AM_SILENT_RULES], [AC_ARG_ENABLE([silent-rules], [dnl AS_HELP_STRING( [--enable-silent-rules], [less verbose build output (undo: "make V=1")]) AS_HELP_STRING( [--disable-silent-rules], [verbose build output (undo: "make V=0")])dnl ]) case $enable_silent_rules in @%:@ ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; esac dnl dnl A few 'make' implementations (e.g., NonStop OS and NextStep) dnl do not support nested variable expansions. dnl See automake bug#9928 and bug#10237. am_make=${MAKE-make} AC_CACHE_CHECK([whether $am_make supports nested variables], [am_cv_make_support_nested_variables], [if AS_ECHO([['TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi]) if test $am_cv_make_support_nested_variables = yes; then dnl Using '$V' instead of '$(V)' breaks IRIX make. AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AC_SUBST([AM_V])dnl AM_SUBST_NOTMAKE([AM_V])dnl AC_SUBST([AM_DEFAULT_V])dnl AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl AC_SUBST([AM_DEFAULT_VERBOSITY])dnl AM_BACKSLASH='\' AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) # Copyright (C) 2001-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor 'install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in "make install-strip", and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using 'strip' when the user # run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the 'STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) # -------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004-2014 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of 'v7', 'ustar', or 'pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar # AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AC_SUBST([AMTAR], ['$${TAR-tar}']) # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' m4_if([$1], [v7], [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], [m4_case([$1], [ustar], [# The POSIX 1988 'ustar' format is defined with fixed-size fields. # There is notably a 21 bits limit for the UID and the GID. In fact, # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 # and bug#13588). am_max_uid=2097151 # 2^21 - 1 am_max_gid=$am_max_uid # The $UID and $GID variables are not portable, so we need to resort # to the POSIX-mandated id(1) utility. Errors in the 'id' calls # below are definitely unexpected, so allow the users to see them # (that is, avoid stderr redirection). am_uid=`id -u || echo unknown` am_gid=`id -g || echo unknown` AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) if test $am_uid -le $am_max_uid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) if test $am_gid -le $am_max_gid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi], [pax], [], [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Go ahead even if we have the value already cached. We do so because we # need to set the values for the 'am__tar' and 'am__untar' variables. _am_tools=${am_cv_prog_tar_$1-$_am_tools} for _am_tool in $_am_tools; do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works. rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR m4_include([m4/ac_caolan_func_which_gethostbyname_r.m4]) m4_include([m4/ac_have_inaddr_none.m4]) m4_include([m4/ac_have_malloc_options.m4]) m4_include([m4/ac_nullzero.m4]) m4_include([m4/ac_raf_func_which_getservbyname_r.m4]) m4_include([m4/ac_tds_func_which_gethostbyaddr_r.m4]) m4_include([m4/ac_tds_func_which_getpwuid_r.m4]) m4_include([m4/ac_tds_func_which_localtime_r.m4]) m4_include([m4/acx_pthread.m4]) m4_include([m4/ax_cflags_gcc_option.m4]) m4_include([m4/check_openssl.m4]) m4_include([m4/gettimemilli.m4]) m4_include([m4/libtool.m4]) m4_include([m4/ltoptions.m4]) m4_include([m4/ltsugar.m4]) m4_include([m4/ltversion.m4]) m4_include([m4/lt~obsolete.m4]) m4_include([m4/pushlibs.m4]) m4_include([m4/sprintf_i64_format.m4]) m4_include([m4/type_socklen_t.m4]) freetds-1.00.82/Makefile.in100644 025423 025423 00000071264 13242511110 0011073# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # version $Id: Makefile.am,v 1.50 2012-01-16 00:27:04 jklowden Exp $ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = \ $(top_srcdir)/m4/ac_caolan_func_which_gethostbyname_r.m4 \ $(top_srcdir)/m4/ac_have_inaddr_none.m4 \ $(top_srcdir)/m4/ac_have_malloc_options.m4 \ $(top_srcdir)/m4/ac_nullzero.m4 \ $(top_srcdir)/m4/ac_raf_func_which_getservbyname_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_gethostbyaddr_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_getpwuid_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_localtime_r.m4 \ $(top_srcdir)/m4/acx_pthread.m4 \ $(top_srcdir)/m4/ax_cflags_gcc_option.m4 \ $(top_srcdir)/m4/check_openssl.m4 \ $(top_srcdir)/m4/gettimemilli.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/pushlibs.m4 \ $(top_srcdir)/m4/sprintf_i64_format.m4 \ $(top_srcdir)/m4/type_socklen_t.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \ $(am__configure_deps) $(am__DIST_COMMON) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = freetds.spec CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ cscope distdir dist dist-all distcheck am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags CSCOPE = cscope DIST_SUBDIRS = $(SUBDIRS) am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/freetds.spec.in \ AUTHORS COPYING COPYING.LIB ChangeLog INSTALL NEWS README TODO \ compile config.guess config.rpath config.sub depcomp \ install-sh ltmain.sh missing mkinstalldirs DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ if test -d "$(distdir)"; then \ find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -rf "$(distdir)" \ || { sleep 5 && rm -rf "$(distdir)"; }; \ else :; fi am__post_remove_distdir = $(am__remove_distdir) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" DIST_ARCHIVES = $(distdir).tar.gz $(distdir).tar.bz2 GZIP_ENV = --best DIST_TARGETS = dist-bzip2 dist-gzip distuninstallcheck_listfiles = find . -type f -print am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BUILD_NUMBER = @BUILD_NUMBER@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOXYGEN = @DOXYGEN@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FREETDS_LIBGCC = @FREETDS_LIBGCC@ FREETDS_ODBC_MODULE = @FREETDS_ODBC_MODULE@ FREETDS_SYMBOLIC = @FREETDS_SYMBOLIC@ GCRYPT_CFLAGS = @GCRYPT_CFLAGS@ GCRYPT_LIBS = @GCRYPT_LIBS@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ HAVE_OPENSSL = @HAVE_OPENSSL@ HAVE_PERL_SOURCES = @HAVE_PERL_SOURCES@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBADD_DL = @LIBADD_DL@ LIBADD_DLD_LINK = @LIBADD_DLD_LINK@ LIBADD_DLOPEN = @LIBADD_DLOPEN@ LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@ LIBICONV = @LIBICONV@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBOBJS = @LTLIBOBJS@ LT_DLLOADERS = @LT_DLLOADERS@ LT_DLPREOPEN = @LT_DLPREOPEN@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ NETTLE_CFLAGS = @NETTLE_CFLAGS@ NETTLE_LIBS = @NETTLE_LIBS@ NETWORK_LIBS = @NETWORK_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ODBC = @ODBC@ ODBCINSTLIB = @ODBCINSTLIB@ ODBCLIB = @ODBCLIB@ ODBCNODMLIB = @ODBCNODMLIB@ ODBCNODMLIBAPP = @ODBCNODMLIBAPP@ ODBC_CONFIG = @ODBC_CONFIG@ ODBC_INC = @ODBC_INC@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ RC = @RC@ READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SUBVERSION = @SUBVERSION@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ dblib_define = @dblib_define@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ tds_sysdep_int16_type = @tds_sysdep_int16_type@ tds_sysdep_int32_type = @tds_sysdep_int32_type@ tds_sysdep_int64_type = @tds_sysdep_int64_type@ tds_sysdep_intptr_type = @tds_sysdep_intptr_type@ tds_sysdep_real32_type = @tds_sysdep_real32_type@ tds_sysdep_real64_type = @tds_sysdep_real64_type@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = include src doc samples win32 vms misc ACLOCAL_AMFLAGS = -I m4 EXTRA_DIST = interfaces PWD.in BUGS \ freetds.conf locales.conf \ autogen.sh freetds.spec.in freetds.spec tds.dox \ config.rpath CMakeLists.txt Thanks-1.0 ETC = $(DESTDIR)$(sysconfdir) DOCDIR = doc # enable some cheat so make distcheck work (see below) DISTCHECK_CONFIGURE_FLAGS = \ --enable-distcheck-build --enable-extra-checks all: all-recursive .SUFFIXES: am--refresh: Makefile @: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \ $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(top_srcdir)/configure: $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): freetds.spec: $(top_builddir)/config.status $(srcdir)/freetds.spec.in cd $(top_builddir) && $(SHELL) ./config.status $@ mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs distclean-libtool: -rm -f libtool config.lt # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscope: cscope.files test ! -s cscope.files \ || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) clean-cscope: -rm -f cscope.files cscope.files: clean-cscope cscopelist cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -rm -f cscope.out cscope.in.out cscope.po.out cscope.files distdir: $(DISTFILES) $(am__remove_distdir) test -d "$(distdir)" || mkdir "$(distdir)" @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done -test -n "$(am__skip_mode_fix)" \ || find "$(distdir)" -type d ! -perm -755 \ -exec chmod u+rwx,go+rx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__post_remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 $(am__post_remove_distdir) dist-lzip: distdir tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz $(am__post_remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__post_remove_distdir) dist-tarZ: distdir @echo WARNING: "Support for distribution archives compressed with" \ "legacy program 'compress' is deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__post_remove_distdir) dist-shar: distdir @echo WARNING: "Support for shar distribution archives is" \ "deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__post_remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__post_remove_distdir) dist dist-all: $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:' $(am__post_remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lz*) \ lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir) chmod u+w $(distdir) mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ && $(am__cd) $(distdir)/_build/sub \ && ../../configure \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ --srcdir=../.. --prefix="$$dc_install_base" \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ && ({ \ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ } || { rm -rf "$$dc_destdir"; exit 1; }) \ && rm -rf "$$dc_destdir" \ && $(MAKE) $(AM_MAKEFLAGS) dist \ && rm -rf $(DIST_ARCHIVES) \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && cd "$$am__cwd" \ || exit 1 $(am__post_remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: @test -n '$(distuninstallcheck_dir)' || { \ echo 'ERROR: trying to run $@ with an empty' \ '$$(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ $(am__cd) '$(distuninstallcheck_dir)' || { \ echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ fi ; \ $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am check: check-recursive all-am: Makefile installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." @DISTCHECK_BUILD_FALSE@uninstall-local: clean: clean-recursive clean-am: clean-generic clean-libtool clean-local mostlyclean-am distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -f Makefile distclean-am: clean-am distclean-generic distclean-libtool \ distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-data-local install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-local .MAKE: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \ am--refresh check check-am clean clean-cscope clean-generic \ clean-libtool clean-local cscope cscopelist-am ctags ctags-am \ dist dist-all dist-bzip2 dist-gzip dist-lzip dist-shar \ dist-tarZ dist-xz dist-zip distcheck distclean \ distclean-generic distclean-libtool distclean-tags \ distcleancheck distdir distuninstallcheck dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-data-local 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-ps install-ps-am install-strip \ installcheck installcheck-am installdirs installdirs-am \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am uninstall-local .PRECIOUS: Makefile install-data-local: $(mkinstalldirs) $(ETC) if test ! -f $(ETC)/freetds.conf; then \ $(INSTALL) $(srcdir)/freetds.conf $(ETC)/freetds.conf; \ fi if test ! -f $(ETC)/locales.conf; then \ $(INSTALL) $(srcdir)/locales.conf $(ETC)/locales.conf; \ fi clean-local: find . \( -name \*.test_output -o -name \*.bb -o -name \*.bbg -o -name \*.da -o -name \*.gc\* \) -exec rm -f {} \; # do not uninstall configuration files (they may have been changed) @DISTCHECK_BUILD_TRUE@uninstall-local: @DISTCHECK_BUILD_TRUE@ rm -f $(ETC)/freetds.conf $(ETC)/locales.conf $(ETC)/pool.conf PWD test: @echo "The 'make test' option has been replaced with 'make check'"; all: # if we are inside a make distcheck copy our real password file @DISTCHECK_BUILD_TRUE@ if test ! -f PWD -a -f $(srcdir)/../PWD; then cp $(srcdir)/../PWD PWD; fi # this prevent the store of passwords in the source repository if test ! -f PWD; then cp $(srcdir)/PWD.in PWD; fi snapshot: $(MAKE) dist distdir=$(PACKAGE)-`date +"%Y%m%d"` doxy: $(SUBDIRS) @HAVE_DOXYGEN_TRUE@ $(MKDIR_P) $(DOCDIR)/reference @HAVE_DOXYGEN_TRUE@ rm -rf $(DOCDIR)/reference/* @HAVE_DOXYGEN_TRUE@ SRCDIR=$(top_srcdir) VERSION=$(VERSION) $(DOXYGEN) $(top_srcdir)/tds.dox @HAVE_DOXYGEN_TRUE@ if test -d $(DOCDIR)/reference/html ; then mv $(DOCDIR)/reference/html/* $(DOCDIR)/reference; rmdir $(DOCDIR)/reference/html; fi @HAVE_DOXYGEN_FALSE@ echo 'Doxygen not installed; reference manual not built.' # 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: freetds-1.00.82/freetds.spec.in100644 025423 025423 00000010424 12717145107 0011751%define name @PACKAGE@ %define version @VERSION@ # compute some additional dependency from vendor name # # SUSE %define tds_dep_suse glibc-locale %undefine tds_builddep %{expand:%%{expand:%%{?tds_builddep_%{?_vendor}:%%%%define tds_builddep %%{?tds_builddep_%{?_vendor}}}}} %undefine tds_dep %{expand:%%{expand:%%{?tds_dep_%{?_vendor}:%%%%define tds_dep %%{?tds_dep_%{?_vendor}}}}} Name: %{name} Version: %{version} Release: 1 Vendor: www.freetds.org License: LGPL Group: System Environment/Libraries Source: http://ibiblio.org/pub/Linux/ALPHA/freetds/stable/%{name}-%{version}.tar.bz2 BuildRoot: %{_tmppath}/%{name}-buildroot BuildRequires: unixODBC-devel >= 2.0.0 gnutls-devel %{?tds_builddep} Requires: gnutls %{?tds_dep} Summary: FreeTDS is a free re-implementation of the TDS (Tabular DataStream) protocol that is used by Sybase and Microsoft for their database products. %description FreeTDS is a project to document and implement the TDS (Tabular DataStream) protocol. TDS is used by Sybase and Microsoft for client to database server communications. FreeTDS includes call level interfaces for DB-Lib, CT-Lib, and ODBC. %package devel Group: Development/Libraries Summary: Include files needed for development with FreeTDS Requires: freetds = %{version} %package unixodbc Group: System Environment/Libraries Summary: FreeTDS ODBC Driver for unixODBC Requires: unixODBC >= 2.0.0 %{?tds_dep:Requires: %tds_dep} %package doc Group: Documentation Summary: User documentation for FreeTDS %description devel The freetds-devel package contains the files necessary for development with the FreeTDS libraries. %description unixodbc The freetds-unixodbc package contains ODBC driver build for unixODBC. %description doc The freetds-doc package contains the useguide and reference of FreeTDS and can be installed even if FreeTDS main package is not installed %prep %setup %build ODBCDIR=`odbc_config --prefix || true` if test ! -r "$ODBCDIR/include/sql.h"; then ODBCDIR=/usr/local fi if test ! -r "$ODBCDIR/include/sql.h"; then ODBCDIR=/usr fi %configure --with-tdsver=auto --with-unixodbc="$ODBCDIR" --with-gnutls make RPM_OPT_FLAGS="$RPM_OPT_FLAGS" %install rm -rf "$RPM_BUILD_ROOT" make DESTDIR="$RPM_BUILD_ROOT" install rm -rf "$RPM_BUILD_ROOT/%{_datadir}/doc/freetds" %post /sbin/ldconfig 2> /dev/null %postun /sbin/ldconfig 2> /dev/null %post unixodbc echo "[FreeTDS] Description = FreeTDS unixODBC Driver Driver = %{_libdir}/libtdsodbc.so.0 Setup = %{_libdir}/libtdsodbc.so.0" | odbcinst -i -d -r > /dev/null 2>&1 || true echo "[SQL Server] Description = FreeTDS unixODBC Driver Driver = %{_libdir}/libtdsodbc.so.0 Setup = %{_libdir}/libtdsodbc.so.0" | odbcinst -i -d -r > /dev/null 2>&1 || true %preun unixodbc odbcinst -u -d -n 'FreeTDS' > /dev/null 2>&1 || true odbcinst -u -d -n 'SQL Server' > /dev/null 2>&1 || true %clean rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root) %doc AUTHORS BUGS COPYING* ChangeLog INSTALL NEWS README TODO %{_bindir}/* %{_mandir}/man?/* %{_libdir}/libct.so.* %{_libdir}/libsybdb.so.* %config %{_sysconfdir}/* %files devel %defattr (-,root,root) %{_libdir}/*.a %{_libdir}/*.la %{_libdir}/*.so %{_includedir}/* %files unixodbc %defattr(-,root,root) %{_libdir}/libtdsodbc.so* %files doc %defattr (-,root,root) %doc doc/userguide doc/images doc/reference %changelog * Fri Nov 13 2015 Frediano Ziglio - set default protocol version to "auto" (automatic) - enable gnutls in RPM packages * Wed Mar 28 2007 Frediano Ziglio - removed libtdssrv * Thu Sep 09 2004 Frediano Ziglio - remove dependency from freetds-unixodbc - fix field name (Copyright instead of License) - updated URL * Sun Mar 30 2003 Frediano Ziglio - add reference to doc package * Wed Feb 5 2003 Ian Grant - 0.61 tweaked. Added libtdssrv libraries and tools in /usr/bin + man pages * Mon Dec 30 2002 David Hollis - 0.60 tweaked. Move .a & .la files to -devel package * Thu Dec 20 2001 Brian Bruns - Modifications for 0.53 ver and removing interfaces file * Fri Jun 28 2001 Brian Bruns - Modifications for 0.52 ver and ODBC drivers * Wed Feb 14 2001 David Hollis - First stab at RPM for 0.51 ver freetds-1.00.82/AUTHORS100644 025423 025423 00000005324 12717145107 0010107Brian Bruns Started this crazy thing James K. Lowden Documentation, maintainer from 2003 to early 2015. Marc Abramowitz Testing and patches, Travis CI tests. Koscheev Andrey Negative money patch. Craig A. Berry VMS support. James Cameron GNU standards compliance and minor fixes. Peter Deacon Lots of help, testing and patches. John F. Dumas Patch to fix memory leaks. David Fraser Testing and patches (NO-DM support). Scott Gray TDS 7.0 numeric support and bug fixes. Alex Hornby Testing and patches. Mihai Ibanescu GNUified the packet. Gregg Jensen Message handlers and extra datatype support and some sybperl stuff? Viktar Klimkovitch ODBC fixes to get libodbc++ working. Bob Kline NTEXT support. Lothar Krauss ODBC fixes. Steve Langasek Off by one fixes and autoconf byte size thing. Debian package maintainer. Mark J. Lilback Implementation of dbstrlen and dbstrcpy. Kevin Lyons Various TDS bug fixes. Steve Murphree Contributed a huge ODBC patch. Dennis Nicklaus vxWorks port and fixes for dbdata() and SYBVARBINARY. Arno Pedusaar Donated his TDS4.2 code to the cause. Brandon M. Reynolds Fix for arbitrarily large queries under dblib. Thomas Rogers Testing and patches. Mark Schaal Cleaned up message handling, bug fixes, ctlib unittests. Ken Seymour ODBC Driver Fixes. Craig Spannring JDBC driver and CVS repository. Martin Spott Testing and patches. Sam Tetherow Various TDS bug fixes. Bill Thompson BCP patches and datetime fixes. Patrick van Kleef Various bug fixes, dbcanquery() and odbc version checks. Geoff Winkless Lost connection stuff. Nicholas S. Castellano Many bug fixes and improvements, contributor of fisql application. Frediano Ziglio Lot of contributions, maintainer since 2015. Special thanks to Michael Peppler , author of the DBD::Sybase Perl module. Thanks go to the folks at A2i, Inc. (http://www.a2i.com) for funding the development of dblib host file bulk copy and writetext support, and to Dave Poyourow there for helping with the debugging. freetds-1.00.82/COPYING100644 025423 025423 00000043254 12717145107 0010076 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. freetds-1.00.82/COPYING.LIB100644 025423 025423 00000061447 12717145107 0010507 GNU LIBRARY GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the library GPL. It is numbered 2 because it goes with version 2 of the ordinary GPL.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Library General Public License, applies to some specially designated Free Software Foundation software, and to any other libraries whose authors decide to use it. You can use it for your libraries, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library, or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link a program with the library, you must provide complete object files to the recipients so that they can relink them with the library, after making changes to the library and recompiling it. And you must show them these terms so they know their rights. Our method of protecting your rights has two steps: (1) copyright the library, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the library. Also, for each distributor's protection, we want to make certain that everyone understands that there is no warranty for this free library. If the library is modified by someone else and passed on, we want its recipients to know that what they have is not the original version, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that companies distributing free software will individually obtain patent licenses, thus in effect transforming the program into proprietary software. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License, which was designed for utility programs. This license, the GNU Library General Public License, applies to certain designated libraries. This license is quite different from the ordinary one; be sure to read it in full, and don't assume that anything in it is the same as in the ordinary license. The reason we have a separate public license for some libraries is that they blur the distinction we usually make between modifying or adding to a program and simply using it. Linking a program with a library, without changing the library, is in some sense simply using the library, and is analogous to running a utility program or application program. However, in a textual and legal sense, the linked executable is a combined work, a derivative of the original library, and the ordinary General Public License treats it as such. Because of this blurred distinction, using the ordinary General Public License for libraries did not effectively promote software sharing, because most developers did not use the libraries. We concluded that weaker conditions might promote sharing better. However, unrestricted linking of non-free programs would deprive the users of those programs of all benefit from the free status of the libraries themselves. This Library General Public License is intended to permit developers of non-free programs to use free libraries, while preserving your freedom as a user of such programs to change the free libraries that are incorporated in them. (We have not seen how to achieve this as regards changes in header files, but we have achieved it as regards changes in the actual functions of the Library.) The hope is that this will lead to faster development of free libraries. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, while the latter only works together with the library. Note that it is possible for a library to be covered by the ordinary General Public License rather than by this special one. GNU LIBRARY GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Library General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also compile or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. c) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. d) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Library General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! freetds-1.00.82/ChangeLog100644 025423 025423 00000053731 13242511101 0010577Author: Frediano Ziglio Date: Sun Feb 18 13:32:05 2018 +0000 Fix a server bug inserting big varchar/varbinary data using BCP Recent MSSQL product seems to not handle correctly VARCHAR(MAX), NVARCHAR(MAX) and VARBINARY(MAX) sent using bulk operation if the data contains the full length. This is not coherent with documentation and the way data is sent using parameter the way server reply these fields (which should have the same format). Using unspecified length (as native client application seems to do) fix the issue. Author: Frediano Ziglio Date: Wed Feb 14 23:12:59 2018 +0000 defncopy: Increase sql_text size to make sure is enough for new servers On MSSQL 2016 onward syscolumns.text field is 8000 characters long. The sql_text variable that should hold the conversion is 16000 bytes which are not enough to convert any converted string. Increase a bit to make sure is big enough. This is a temporary fix, should be allocated dynamically to make sure will continue to work. Author: Travis Schafer Date: Tue Nov 28 17:31:25 2017 +0000 Support TLS versions greater than TLSv1 when using OpenSSL ... just like when using GnuTLS Author: Frediano Ziglio Date: Sat Nov 25 14:16:26 2017 +0000 cmake: Use same version for sybdb library of default build Author: Frediano Ziglio Date: Mon Nov 20 23:00:57 2017 +0000 Always use max size for TEXT/NTEXT/IMAGE The network type information for these types allows to specify a size. However the definition of the type does not came with a size. Former implementation does not allows this type to be output and seems to ignore that length and accept any data even if bigger (data has also another length field). Current implementations allows to have BLOBs as output but not using these types. All tests passes with these sizes specified so feels safe and at the same time does not violate the assertion on other types where the data size has to be maximum the column size. Author: fandrieu Date: Fri Nov 17 16:04:08 2017 +0100 dblib: rpc blob out: common _dbcoldata function dbdata and dbretdata handle the same column structure. The common logic for returning data is now in an internal function _dbcoldata. Author: fandrieu Date: Fri Nov 17 15:46:32 2017 +0100 dblib: rpc blob out: merge dbdata into dbretdata dbretdata is updated with the logic from dbdata. Author: fandrieu Date: Wed Nov 15 01:55:18 2017 +0100 dblib: rpc blob out: minimal fix dbretdata doesn't handle blob data, this patch returns textvalue if needed. Author: Frediano Ziglio Date: Sat Nov 18 00:41:07 2017 +0000 Build fix if C is not C99 Do not use int types defined only in C99 (stdint.h). Author: Frediano Ziglio Date: Fri Nov 17 14:21:27 2017 +0000 Handle routing environment On routing environment (which should arrive during login) client should reconnect to the given server. Author: Frediano Ziglio Date: Fri Nov 17 17:20:38 2017 +0000 dblib: Add support for specifying read-only intent Patch from Joshua Lang. Author: Frediano Ziglio Date: Thu Sep 14 07:33:07 2017 +0100 WIP test library order Author: Frediano Ziglio Date: Tue Oct 31 08:47:02 2017 +0000 tds: Set keep alive values under Windows These settings are necessary for Azure cloud due to firewall rules (long queries will cause disconnections). Author: Frediano Ziglio Date: Tue Oct 31 08:45:37 2017 +0000 tds: Use mnemonics for keep alive values Author: Frediano Ziglio Date: Fri Oct 27 16:17:20 2017 +0100 ctlib: Allows to send dynamic commands without parameters In case of no parameters paraminfoalloc returns NULL, handle it not as an error. Problem reported by Michael Becker. Author: Frediano Ziglio Date: Tue Oct 10 06:05:14 2017 +0100 tds: Empty record set if message received outside record set Author: Frediano Ziglio Date: Tue Oct 10 05:07:02 2017 +0100 apps: Set database name before connecting This fix connection to specific databases on Azure Author: Frediano Ziglio Date: Mon Oct 9 22:10:35 2017 +0100 bsqldb: Set database name before connecting This fix connection to specific databases on Azure Author: Frediano Ziglio Date: Sat Sep 30 22:25:16 2017 +0100 ctlib: Add CS_BIGTIME/CS_BIGDATETIME type declarations Author: Frediano Ziglio Date: Fri Sep 22 12:28:30 2017 +0100 ctlib: Support Microsoft DATE/TIME types Author: Frediano Ziglio Date: Thu Sep 21 18:23:06 2017 +0100 ctlib: Support missing Sybase types in _ct_get_client_type Author: Frediano Ziglio Date: Thu Sep 21 20:57:11 2017 +0100 ctlib: Fix wrong type for TIME and DATE from _ct_get_server_type This caused data to be converted in the wrong way. Author: Frediano Ziglio Date: Wed Sep 20 11:20:37 2017 +0100 tds: Fix possible reading buffer overflow converting from char to float Row column data are not NUL terminated so make sure we use terminated strings. This patch also improve checking format errors converting float numbers using strtod instead of atof. Author: Frediano Ziglio Date: Sun Sep 17 17:34:16 2017 +0100 tds: Add missing declaration for Sybase type Declarations are used for bulk copy and datacopy utility. Author: Frediano Ziglio Date: Sat Sep 16 13:52:48 2017 +0100 ctlib: Do not mix 2 set of results Variable results was used to store 2 states ending up with possible wrong result from _ct_bind_data. Author: Frediano Ziglio Date: Sat Sep 16 12:51:49 2017 +0100 Avoid mixing different column information Was possible that for multiple column recordset the binding were reused between columns combining row binding with empty ones. This could cause some wrong metadata information to be returned. Author: Frediano Ziglio Date: Wed Sep 13 15:48:03 2017 +0100 build: Fix wrong AC_LANG_SOURCE usage This macro requires a single parameter. Usage confused with AC_LANG_PROGRAM. Author: Kokan Date: Wed Aug 30 20:28:50 2017 +0200 Ctlib: ct_options handle TEXTSIZE command Author: Frediano Ziglio Date: Sun Jun 5 00:20:06 2016 +0100 Add some missing include to fisql utility Author: Frediano Ziglio Date: Wed Aug 9 10:44:52 2017 +0100 Fix a compatibility issue caused but _res macro definition Some public header defines _res macro (resolv.h header on some Linux). For compatibility reasons in sybdb.h (which is installed) we just undefine the offending macro. Author: Frediano Ziglio Date: Wed Aug 9 10:42:27 2017 +0100 replacements: Avoid macro redefinitions Some public headers already redefine strlcpy and strlcat. As we decided to use our internal implementation undefine the old macro to make sure we use our versions. Author: Frediano Ziglio Date: Tue Aug 8 09:41:23 2017 +0100 odbc: Check RPC name parsing Author: Frediano Ziglio Date: Tue Aug 8 09:41:03 2017 +0100 odbc: Fix parsing of RPC name RPC name was not parsed correctly causing invalid calls. This affected also SQLTables which try to call an internal store procedure using catalog name. Author: Frediano Ziglio Date: Wed Aug 2 21:11:22 2017 +0100 odbc: fix SQLTables query build if SQL_NTS are used In the case SQL_NTS where used for schema and table and catalog was a pattern string (containing wildcards) instead of calling sp_tableswc the sp_tables was called causing invalid results. This fixes issues #136. Author: Lars Kanis Date: Wed Jul 5 18:05:59 2017 +0200 Fix out-of-tree build on MINGW. Author: Ondřej Hošek Date: Sat Jun 17 20:52:49 2017 +0200 dblib: dbsprhead: tdsdump_log buffer address only The buffer passed to dbsprhead might be uninitialized; printing it as a string doesn't make much sense. Output its address (using "%p") instead. Author: Ondřej Hošek Date: Sat Jun 17 20:49:09 2017 +0200 dblib: dbsprhead: adjust buf_len by name length After copying the column name into the buffer in dbsprhead, reduce buf_len, which is used to guard against writing outside the buffer, by the length of the column name. Author: Ondřej Hošek Date: Sat Jun 17 19:51:04 2017 +0200 tds: Escape left brace in regex in encodings.pl Since Perl v5.22.0, unescaped left braces ('{') in regexes are deprecated; since Perl v5.26.0, they are forbidden in most cases. Escape such a case in encodings.pl using a backslash. Author: Frediano Ziglio Date: Sun Jun 11 09:04:41 2017 +0100 ctlib: fix type cast The argument is a CS_BOOL, not a char. This worked only on little endian platforms. Author: Frediano Ziglio Date: Thu Jun 8 13:53:07 2017 +0100 support Linux system < 2.6.27 having eventfd Before this version eventfd didn't accept and have flags support. Try to create the eventfd without flags and then set later. Author: Frediano Ziglio Date: Tue Jun 6 21:59:57 2017 +0100 pool: Avoid crash if password setting is missing Test on user.c was causing a crash due to NULL dereference. Author: Frediano Ziglio Date: Tue Jun 6 08:04:14 2017 +0100 Fix ct_options for CS_OPT_ARITHIGNORE and CS_OPT_ARITHABORT The two options required just normal boolean processing. This problem was reported by Matt Meissner. Author: Frediano Ziglio Date: Wed May 24 14:46:43 2017 +0100 Fix bulk copy setting By default bulk copy is enabled but the usage of bulk_copy field in TDSLOGIN where a bit weird. Make clear and document that bulk_copy != 0 means enabled. Also fix a mismatch between BCP_SETL and bcp_getl. This fix bug #119 ("BCP_SETL() and bcp_getl() have inconsistant API"). Author: Frediano Ziglio Date: Wed May 17 15:28:56 2017 +0100 Fix compile if TLS is disabled tds_ssl_deinit have to be defined including the proper header. This as if TLS is disabled the function is defined in the header. Author: Frediano Ziglio Date: Tue May 2 23:26:24 2017 +0100 Fix very big login packet using MSSQL If login packet is really big to split into multiple TDS packets and is encrypted MSSQL only encrypt the first TDS packet, the others are not encrypted. Author: Frediano Ziglio Date: Sat Apr 29 22:57:00 2017 +0100 Prevent invalid record parameter This can happen if invalid data are sent. For instance if server send some parameter using PARAMFMT followed by old style PARAM. You potentially get a result which is half composed by a row and half by separate data. Author: Frediano Ziglio Date: Sat Apr 29 22:27:47 2017 +0100 Assure SELECT @@PID query returns a normal row Invalid server response can cause a different row type to be returned causing a NULL pointer dereference in tds_set_spid. Author: Frediano Ziglio Date: Sat Apr 29 21:14:46 2017 +0100 Add an invalid data type to avoid not initialized pointer to functions Always initialize TDSCOLUMN->funcs to avoid NULL pointer dereferences. Author: Frediano Ziglio Date: Sat Apr 29 18:53:18 2017 +0100 Do not send clear text password if encryption login is required on Sybase Password should just be sent encrypted, no reason to send also not encrypted. Author: Frediano Ziglio Date: Sat Apr 15 15:49:12 2017 +0100 Check server is not returning negative values for column sizes Author: Frediano Ziglio Date: Sun Apr 2 15:28:07 2017 +0100 Handle errors getting datatype meta information This prevent server to send wrong encoded types Author: Frediano Ziglio Date: Sat Apr 15 15:20:05 2017 +0100 Detect and handle some protocol problem Author: Frediano Ziglio Date: Sat Apr 15 15:18:48 2017 +0100 Avoid some assert to be triggered by server Instead of crashing the client detect the protocol problem and close the connection. Author: Attila Horváth Date: Fri Mar 10 15:22:50 2017 +0000 Do not override per-connection timeout settings in dbsettime Author: Frediano Ziglio Date: Sat Feb 25 18:29:33 2017 +0000 Support SQL Anywhere connections SQL Anywhere does not support multiple databases and USE statement so don't send the request to avoid connection failures Author: Frediano Ziglio Date: Tue Feb 14 11:20:03 2017 +0000 Provide compatibility with OpenSSL 1.1 OpenSSL 1.1 changed quite a lot API since 1.0. Update code to make it compatible with either versions. Author: Frediano Ziglio Date: Mon Feb 6 14:41:18 2017 +0000 Fix SSPI connections using protocols >7.1 Do not check for a minimal size on the SSPI data received from the server. This fix some connection problems using protocols >7.1. Reported-by: Ladislav Karrach Author: Dave Beaudet Date: Fri Feb 3 21:37:48 2017 +0000 Added support for configurable openssl cipher list Added new option to freetds.conf for specifying the cipher list supplied to openssl. This is necessary for several reasons: 1. organizations that need more control over the specifics of encrypted connections 2. to overcome the occasional incompatibility (sometimes intermittent) between open source encryption libraries and Microsoft's implementations. For example, several users reported intermittent connection problems where roughly 0.5% of connection attempts would fail for some reason. Removing specific key exchange protocols provided relief in at least one case. 3. The cipher list can be specified in more generic terms, e.g. "HIGH:!SSLv2:!aNULL:-DH" rather than having to list specific cipher configurations that are otherwise subject to becoming outdated as the encryption landscape changes. Author: Frediano Ziglio Date: Sat Dec 24 10:36:58 2016 +0000 Fix TLS hostname validation using OpenSSL When attempting to make a connection to a SQL Server and providing a CA Cert file, FreeTDS was unable to validate a hostname. The function check_name_match in tls.c was checking the wrong value from check_wildcard. This fixes GitHub Issue #90 Reported-by: Alex Loney Author: Jeff Farr Date: Mon Dec 5 13:01:21 2016 -0500 Process batch statements without a select correctly If you send a batch of statements in a single call to the database, and these statements don't return rows, the dbresults function doesn't process the data correctly. It will loop over all data the first time it is called and return to the calling function that there are no more rows. Added a return on TDS_DONE_RESULT that stops processing data when a batch of statements doesn't contain a select. Author: Frediano Ziglio Date: Wed Nov 30 23:26:16 2016 +0000 Read trailing tokens after dbnextrow This fix rpc test after batch statement fix. Author: Frediano Ziglio Date: Thu Nov 17 06:17:36 2016 +0000 Fix string conversion in ODBC if string is really long During string conversion is needed to compute and return the size of all converted string even if is returned only partially. In the case the part of the unconverted string was very long this was considered like an error (SQL_ERROR) instead of a warning (SQL_SUCCESS_WITH_INFO). Author: Peter Deacon Date: Tue Nov 15 09:21:40 2016 +0000 Fix invalid free which lead to crash buf is not allocated with a malloc family function, the buffer will be freed as the string is freed. Author: Frediano Ziglio Date: Fri Nov 11 17:24:20 2016 +0000 Fix possible infinite recursive calls calling tds_disconnect In tds_disconnect when sending logout token ran into a problem where tds_put_byte failure leads to a recursive calls to tds_disconnect until process runs out of stack. Rough loop: tds_disconnect tds_put_byte tds_write_packet tds_connection_write tds_goodwrite tds_connection_close close_socket tds_disconnect ... Reported-by: Peter Deacon Author: Frediano Ziglio Date: Sat Nov 5 14:17:21 2016 +0000 Avoid losing sync if a conversion problem happens This happened for TEXT or long strings. Shorter strings already have this behaviour. Author: Frediano Ziglio Date: Sat Nov 5 14:15:53 2016 +0000 Set column_cur_size even on conversion errors Allows to read truncated data instead of discarding everything. This can happen on invalid encoding inside strings. As internal conversions will replace invalid sequence and signal the problem with callbacks client can at least show some data. Author: Frediano Ziglio Date: Fri Nov 4 05:30:47 2016 +0000 bcp: Do not trim non ascii columns This avoid trimming multi byte encoding ending with 0x20 bytes. This fixes http://stackoverflow.com/questions/38984053/freebcp-unicode-data-is-odd-byte-size-for-column-should-be-even-byte-size (https://github.com/FreeTDS/freetds/issues/80) Author: Frediano Ziglio Date: Thu Sep 1 22:41:52 2016 +0100 Update OpenSSL cipher list This increase security and also fix a recent incompatibility between OpenSSL and SChannel (SChannel versions patched in a couple of months). Author: John Kendall Date: Thu Aug 25 12:09:50 2016 +0100 Handle correctly long object in defncopy for ASE servers Author: Frediano Ziglio Date: Fri Jul 22 10:27:08 2016 +0100 Remove some string overflows from VMS code Author: Frediano Ziglio Date: Fri Jul 22 10:29:19 2016 +0100 pool: Avoid to overwrite packet if not entirely written This can happen if packet is not entirely written to server after being read from client. Author: Frediano Ziglio Date: Mon Jul 18 12:09:07 2016 +0100 Extends cs_dt_crack to support newer types This add a new cs_dt_crack_v2 ABI function (cs_dt_crack API is redirected to it using a preprocessor macro). This to make the extension of CS_DATEREC more safe (version of 1.0 could call cs_dt_crack with CS_BIGDATETIME_TYPE/CS_BIGTIME_TYPE without having these fields written which would possible cause memory corruption on version compiled with these fields missing). This make sqsh compile and work with newer date/time types. Author: Frediano Ziglio Date: Mon Jul 18 09:38:13 2016 +0100 Make AppVeyor build with OpenSSL enabled CMake was not finding OpenSSL. Author: Frediano Ziglio Date: Mon Jun 27 12:59:07 2016 +0100 Fix NUMERIC column for bcp native format Prefix was not handled correctly. Author: Frediano Ziglio Date: Sun Jun 26 11:23:15 2016 +0100 Fix freebcp -E (identity columns) output An additional query prevented code to handle correctly column types. Author: Manfroi Fabrice Date: Wed Jun 22 16:33:53 2016 +0200 Fix build error on AIX 6.1 / 7.1 / 7.2 tls.c:719: error: 'AF_INET6' undeclared (first use in this function) tls.c:719: error: (Each undeclared identifier is reported only once tls.c:719: error: for each function it appears in.) tls.c:722: error: 'AF_INET' undeclared (first use in this function) Author: Frediano Ziglio Date: Sat Jun 18 21:08:17 2016 +0100 Fix internal result state in dbcanquery Author: Frediano Ziglio Date: Sat Jun 18 13:27:56 2016 +0100 Avoid to strip spaces from procedure text. NTBSTRINGBIND strip spaces at the end. Using STRINGBIND with 0 size cause string to be just NUL terminated. The 0 would lead to a possible overflow however we check the column len before doing the bind to avoid such possibility. Original patch from Nem W Schlecht. Author: Nem W Schlecht Date: Fri Jun 17 22:38:12 2016 +0100 Avoid crash on connection error and report an error instead Patch from Nem W Schlecht. Author: Frediano Ziglio Date: Sun Jun 12 21:09:43 2016 +0100 allows to specify 5.0 as tds protocol version during configure Author: Frediano Ziglio Date: Sat Jun 11 09:32:43 2016 +0100 do not compile as bundle under Mac OS X is --with-odbc-nodm is specified In this case the driver will be used as a dynamic library (not loaded dynamically) so compile as such. In case a DM is used unit tests/application will link to the DM which will load the driver (requiring to be a module on old Mac OS X versions). Author: Frediano Ziglio Date: Fri Jun 10 11:45:44 2016 +0100 replace BYTE with unsigned char in ODBC files BYTE is not supported on some platforms. This fixes Mac OS X build. unixODBC headers files and Windows platform define it. freetds-1.00.82/INSTALL100644 025423 025423 00000001364 12717146322 0010070 FreeTDS Installation For complete instructions, see the FreeTDS Users Guide. It is included in the distribution inside "doc/userguide/"; simply open "doc/userguide/index.html" and enjoy. It is also online: http://www.freetds.org/userguide/ Brief Instructions $ ./configure --help $ ./configure $ make $ make install Edit the /usr/local/etc/freetds.conf file to add servers. Test the connection with /usr/local/bin/tsql. Build and test the package that requires FreeTDS. If you want to build the ODBC driver, you'll probably first want to install a Driver Manager (on Unix-like systems). This release of FreeTDS was tested with unixODBC 2.2.11. For any other information please see the Users Guide. freetds-1.00.82/NEWS100644 025423 025423 00000057347 12717145107 0007552$Id: b4e6442475cd841716ce9526482ecf7d0e30f471 $ Summary of Changes in release 1.0 -------------------------------------------- User visible (not in a particular order): - Removed "8.0" from protocol version string accepted. Please update configuration files; - Default protocol version is now auto. This could slow down connection but make user experience less painful; - Sybase encrypted login. Set encryption to get it; - Support protocol version 7.4; - Add intent support to specify we don't want to change data; - Allow to attach database file during the login (MS SQL Server); - Support for Sybase time/date/bigdate/bigdatetime; - Pool is working again; - ODBC BCP (not complete); - Improved dbconvert and dbconvert_ps (more compatible); - Fixed dbspid; - Improved ODBC type information; - Better certificate verification; - AppVeyor is used for every build; - Try all IPs from DNS. This allows SQL Cluster connection to secondary servers. Implementation: - Removed Nmake support; - Type conversions simplified; - Better type handle code. Summary of Changes in release 0.95 -------------------------------------------- User visible (not in a particular order): - Support for build with CMake under Windows. - Support MSSQL 2008: - new date/time types; - NBCROWs; - able to retrieve CLR UDT types in binary format. - Moved from CVS to git. - Support MARS under ODBC. - IPv6 support. - Support unsigned Sybase types. - Sybase use some characters conversion like MSSQL. - Bulk-copy improvements: - more types; - support for empty fields; - no needs for seekable file; - avoid possible buffer overflows; - less memory consumption; - handle different BIT fields in Sybase; - -T option for datacopy. - datacopy: - prompting for password (use "-" password on command line); - empty user/password (to use Kerberos). - Support for query notifications in ODBC. - Support for protocols 7.2 and 7.3 under dblib and ctlib. - dblib: - dbpivot extension; - dbprcollen extension to get printable column size; - add DBCOL2 structure for dbtablecolinfo; - support DBTEXTSIZE option for dbsetopt; - support SRCNUMERICBIND and SRCDECIMALBIND binding; - DATETIME2BIND extension binding to support new mssql 2008 type; - ODBC: - add SQL_INFO_FREETDS_TDS_VERSION option to SQLGetInfo to retrieve FreeTDS version; - add --enable-odbc-wide-tests configure option to use wide functions in unit tests. - Better thread support. - Allow to specify server SPN for GSSAPI. - Sybase graceful disconnects. - Better support for VARCHAR(MAX)/VARBINARY(MAX). - Better error reporting from login failure. - More strict test for configuration errors, fails if configuration is wrong. - "use utf-16" option to enable use of UTF-16 for server encoding (MSSQL). - Remove support for Dev-C++. - Remove support for bad iconv, use libiconv instead (Tru64 and HP-UX should be affected), connect will fail. - New NTLM options: - "use lanman"; - "use ntlmv2". - New Kerberos options: - "realm" ("REALM" in ODBC); - "spn" ("ServerSPN" in ODBC). - New certificate options: - "ca file"; - "crl file"; - "check certificate hostname". - Many bug fixes, majors: - SSPI with Kerberos on some setup; - SQLCancel threading; - ctlib numeric; - ODBC statistic function quotings. Implementation: - Introdude streams support to make easier handling large data and making conversions faster. - Use array of flags to make faster to retrieve data type features. - Use callbacks for handling various type functions. - Optimize data conversions. - Store TDS packets in a new structure to handle multiple packets. - New DSTR implementation which use less memory. - Faster logging. - Put mostly data handling in src/tds/data.c. - Move mostly headers to include/freetds directory. - Add a include/freetds/proto.h header to separate protocol declarations. - Add src/tds/packet.c to separate code handling TDS packets. - Modify libTDS error codes, not only TDS_FAIL. - Use DSTR for names in TDSCOLUMN. - Generate graphs in Doxygen. Summary of Changes in release 0.91 -------------------------------------------- 1. Full Kerberos and SSPI support for passwordless login to Microsoft SQL Server from Unix and Windows clients. Includes Kerberos delegation option. 2. Full support for DB-Library under Win32/64 via NMAKE.EXE. 3. Built-in support for UTF-8. 4. Support for wide characters in ODBC. 5. Support for varchar(max) and varbinary(max). 6. Better thread-safety in ODBC. 7. Distinguish between connect and login errors. 8. Bulk-copy functions in CT-Library. TDS versions now reflect Microsoft's nomenclature. The previous version numbers (8.0 and 9.0) are now 7.1 and 7.2. See the UG for details. Executive Summary of Changes in release 0.82 -------------------------------------------- 1. timeout handling 2. encrypted connections 3. fisql (and odbc utilities) 4. autoconf improvements 5. 23,710 lines added or deleted (101,022 total). 6. 85 files added 7. 21 unit tests added Details ------- db-lib - timeouts work! - corrected dbnextrow - implemented dbsetnull and dbsetinterrupt - improved error reporting and checking - fixed rpc parameter processing, now php works correctly ct-lib - added cs_loc_alloc, cs_loc_drop, cs_locale implementations odbc - cursors (mssql) - fixed database setting - return error always if odbc returns SQL_ERROR - fixed SQLGetData result utilities - added support for NUL characters inside terminators in freebcp - added row termination and column termination option to tsql - new fisql application - new ODBC utilities documentation - significant updates to TDS protocol documentation - freetds.conf man page - added tenderfoot sample code general - fixed timeout handling - added freetds.conf option for encryption - added protocol version discovery - NTLM2 session response - read table and real column name from wire - experimental Kerberos support using gssapi - some optimizations for GCC4 - optimized conversions avoiding some memory copy - minor improves to server stuff - improved MingW compile (even cross one) - more verbose log for dblib and odbc - many test added 1 test for libTDS 1 test for ctlib 3 tests for dblib 13 tests for odbc libTDS API changes - tds_add_row_column_size removed - tds_alloc_row return now TDS_SUCCEED/TDS_FAIL - tds_alloc_compute_row return now TDS_SUCCEED/TDS_FAIL - removed TDSCOLUMN->column_offset - added TDSCOLUMN->column_data and TDSCOLUMN->column_data_free - added TDSCURSOR->type and TDSCURSOR->concurrency for mssql support - added fetch_type and i_row parameters to tds_cursor_fetch - added tds_cursor_update and tds_cursor_setname functions - made tds_alloc_get_string static - removed tds_free_cursor - added TDSCURSOR->ref_count - added tds_cursor_deallocated and tds_release_cursor to handle cursor release. tds_cursor_deallocated is called when cursor got deallocated from server while tds_release_cursor is called to decrement reference counter. Reference counter is used cause is difficult to trace pointer owner between libTDS and upper libraries - added TDS_COMPILETIME_SETTINGS->sysconfdir - changed DSTR_STRUCT structure to include dstr_size - changed DSTR type - error handler cannot return TDS_INT_EXIT - removed TDSSOCKET->query_timeout_func TDSSOCKET->query_timeout_param, TDSSOCKET->query_start_time - changed TDSLOGIN->host_name to client_host_name - changed TDSCONNECTION->host_name to client_host_name - changed TDSLOGIN->encrypted to encryption_level - changed TDSCONNECTION->encrypted to encryption_level - added TDSRESULTINFO->row_free handler to free row - added TDSCONTEXT->int_handler handler - removed tds_prtype - removed tds_alloc_param_row - added tds_alloc_param_data - added flags parameter to tds7_send_auth - removed tds_client_msg - added tdserror to report error - added flags parameter to tds_answer_challenge - added is_variable_type macro - added TDSCOLUMN->table_column_name - added tds parameter to tds_set_column_type - renamed BCPCOLDATA->null_column to is_null - added TDSMESSAGE->oserr - remove length, number_upd_cols and cur_col_list from TDSCURSOR (never used) - added new TDSAUTHENTICATION to handle authentication modules - added TDSSOCKET->authentication - added tds_ntlm_get_auth and tds_gss_get_auth - removed TDSANSWER - removed tds7_send_auth (use new tds_ntlm_get_auth) - added tds_get_int8 - add TDSPARAMINFO *params argument to tds_cursor_declare - add TDSPARAMINFO *params argument to tds_cursor_open - changed TDSSOCKET->rows_affected from int to TDS_INT8 - added TDSSOCKET->tds9_transaction (used internally for TDS9) - added TDSCONNECTION->server_host_name needed for Kerberos support * 0.64 - core library - reduced network bandwidth use on Linux and *BSD - do not free TDSSOCKET in tds_connect - moved network stuff into net.c - fixed conversion NUMERIC->NUMERIC changing precision/scale - added named instance support (mssql2k) - fixed cancel and timeout - added support for encrypted connection using mssql (using either GnuTLS or OpenSSL) - improved numeric conversions performance - improved debug logging (added "debug flags" option) - ctlib - ct_dynamic and friends (placeholder support) - dblib - more functions - made threadsafe - improved bcp - support for large files using BCP - fixed buffering - ODBC - fixed compute handling in ODBC - paramset support - constant parameters in rpc (ie {?=call func(10,?)} ) - configure use automatically odbc_config if available - compatibility - improve PHP support - improve DBD::ODBC support - partial dos32 support - improve JDBC support - added msvc6 project to build dblib library on windows - support long password on tsql for all platforms - improved pool server - RPMs - ODBC driver registration (in odbcinst.ini) - better dependency for RedHat and SUSE - a lot of fixes libTDS API changes - tds_connect does not free TDSSOCKET* on failure - TDSSOCKET->env is not a pointer anymore - tds_free_compute_result and tds_free_compute_results are now static - added TDSDYNAMIC->next for linked list - removed TDSCURSOR->client_cursor_id - use TDSCURSOR* cursor instead of TDS_INT client_cursor_it in tds_cursor_* functions - added const char* file param to tdsdump_dump_buf and tdsdump_log and added line information in level - changed tds_alloc_compute_results declaration, pass a TDSSOCKET* - removed tds_do_until_done (not used) - removed tds_set_longquery_handler function (not used) - changed some fields in TDSSOCKET - removed out_len (not used) - renamed cursor to cursors - removed client_cursor_id - added cur_cursor (instead of removed client_cursor_id) - dyns now a pointer to a pointer to first dynamic allocated - removed num_dyns (now useless with linked list) - removed chkintr and hndlintr (use longquery_*) - removed longquery_timeout (use query_timeout) - renamed longquery_func to query_timeout_func - renamed longquery_param to query_timeout_param - queryStarttime to query_start_time - add a DSTR instance_name to TDSCONNECTION - add tds7_get_instance_port - removed tds_free_all_dynamic - tdsdump_append now static - new tds_process_tokens to replace removed - tds_process_result_tokens - tds_process_row_tokens - tds_process_row_tokens_ct - tds_process_trailing_tokens - removed tds_ctx_set_parent/tds_ctx_get_parent, use parent member - added void * parent argument to tds_alloc_context - tds_process_tokens return a TDS_CANCELLED if handle cancellation - removed query_timeout_func and query_timeout_param from TDSCONNECTION and TDSLOGIN - add tds_free_row - renamed TDSLOCALE->char_set to server_charset * 0.63 - ODBC: use tds_dstr* functions to store descriptor information - header privatizations (removing tds.h dependency). This is quite important for future binary compatibility. - ODBC: SQLFetch returns error correctly - ODBC: fix problem rebinding parameters - ODBC: ability to fetch data types after prepare (needed for Oracle bindings and OTL library). - Builds cleanly under OS X. - Improved BCP support for NULL fields and native file format. - ct-lib: ct_blk support (bcp for ct-lib). - ct-lib: Cursors! - apps: added bsqldb and defncopy. - iconv: better collation support, e.g. SQL_Scandinavian_CP850_CI_AS * 0.62 - ct-lib: cursor support - fixed PHP problem handling empty recordsets. See messages on ML: Damian Kramer, September 23, "Possible bug in freeTDS" Steve Hanselman, September 16 "Issue with freetds 0.61.2 ..." - ODBC: improved, best error report - ct-lib: support ct_diag (for Python) - ODBC: fixed SQLMoreResults/SQLRowCount and batch behavior - ODBC: fixes call to {?=store(?)} - ODBC: multiple record with "select id,name from sysobjects where name = 'sysobjects'" - ODBC: fixed early binding - ODBC: autodetect iODBC or unixODBC during configure - ODBC: implemented option 109 in SQLGetConnectOption (for OpenOffice) - freebcp understand \n as newline. Also \r and \0 (null byte). - added --without-libiconv configure option to switch off iconv library - ODBC: test and fixes for NUMERIC parameter - ODBC: dynamic query - SQLPutData - Sybase and blobs ported code for string building from ODBC to libtds - extended TDSSOCKET::iconv_info as an array. Keep converters for non-UCS-2 server charsets. Every TDSCOLINFO holding character data should point to one of these elements. - dblib: src/dblib/unittests/t0017.c (bcp) fixed - changed tds_get_char_data(), ML 2 May 2003, "tds_get_char_data and iconv". - rewrote tds_iconv: - use iconv() signature. - rely on TDSCOLINFO::iconv_info for conversion descriptor, instead of inferring it from the column sizes. - on read error, emit Msg 2403, Severity 16 (EX_INFO): "WARNING! Some character(s) could not be converted into client's character set. Unconverted bytes were changed to question marks ('?')." - on write error emit Msg 2402, Severity 16 (EX_USER): "Error converting client characters into server's character set. Some character(s) could not be converted." and return an error code. Do not proceed. - Cf. ML 16 Apr 2003. "conversion error management". - added doxygen to the nightly build - "make install" put the UG in PREFIX/share/doc/freetds/userguide - "make install" put doxygen html in PREFIX/share/doc/freetds/reference - moved website docs (not UG) to doc/htdoc, put in CVS - added bcp support to tds/dblib/ctlib. (started in dblib) - RPC stuff - added support for TDS 8.0 - TDS 7 Unicode to native charset conversion using iconv - autoconf the connection pooling stuff - DBLIB: output params - set database during login process - libtds: dynamic query - ctlib: null returns zero-length string (see "SELECT '' and TDS 7.0" in message list on 26 Jan 2003) * Jan 2003 - Version 0.61 - Dynamic SQL - Output parameters - Compute rows - Varbinary support - dsn-less ODBC connections - RPC support (db-lib) - Compatibility with DBD::Sybase 0.95 - 68 new functions! (see doc/api_status.txt) - Error/message handling rewritten, uses real error numbers - new sample programs - much cleaner code, warning-free compiles - namespace cleanup - public domain versions of functions for OSs that lack them - autoconf portability improvements - builds in HP-UX, Win32, and cygwin - No dependency on OpenSSL * Sep 2002 - Version 0.60 - Support for SQL Server 2000 datatypes and domain logins. - Support and convertibility of all major datatypes. - Much expanded coverage of the ODBC API. - An all-new BCP implementation, including host variable support. - Character set conversions, via the iconv library. - Threadsafe operation. * [late 2001?] - tdspool now working for big endian systems - Fixed mem leak in ctlib - Added some descriptive text to the PWD file - EINTR handling during login (Kostya Ivanov) - Added support for TLI style interfaces files (thanks Michael for explaining) - Added 'text size' config option which changes textsize on connect - Added preliminary TDS 8.0 support (no new datatypes supported though) - Added 'emulate little endian' config flag - Some TDS5 placeholder stuff. Not ready for primetime yet. - Fixed interfaces handling seg fault * Jul 2001 Brian Bruns - Version 0.52 - Mem leak fixes in dbloginfree() and tds_free_env() (John Dumas) - Added support for new configuration format (freetds.conf) - unixODBC now working - Fixed error in two's complement function for money types - Added support for nullable bits (BITN) - checked in work on tds connection pooling server - added preliminary userguide (James Lowden and me) - a lot of work on ODBC driver, now works with PHP - added config options for iodbc/unixodbc (unixODBC doesn't actually work yet) - image -> char now works (verified with ctlib only) - varbinary -> char now works with destlen of -1 - New config routines - Free socket on login fail - 64bit patches - off by one error - numeric problem with 7.0 fixed - digit cutoff on numerics/floats fixed * Nov 2000 Brian Bruns - Version 0.51 - removed all the old unittests from the samples directory - endian detection fixed - 'make check' and ctlib unittests (Mark) - TDS 7.0 fixes, numerics et al. (Scott) - dead connection handling (Geoff) - query timeout stuff (Jeff) * Dec 1999 Brian Bruns - Version 0.50 - Added TDS 7.0 support for MS SQL 7 - Added hostfile bulk copy for dblib - Added writetext support for dblib - Added CS_CON_STATUS property to ctlib - Fixed bugs for ctlib version of PHP 3/4 - Many changes to text/image handling - New script for running the unittests - dbcancel/ct_cancel now working properly - inserts/updates now return proper rowcount - Numerous bug fixes * Sep 1999 Brian Bruns - Version 0.47 - Added workaround for SQL 7.0 bug handling datetime/money for big endian (testing/bug report - Paul Schaap) - Added TDS 7.0 login function (untested) - Fixed many big endian bugs - Fixed some bus errors on Sparc - Fixed big endian detection - DBD::Sybase 0.19 now passes all tests - Fixed date bug working with PHP 3.x - binary/varbinary support added - Fixed Text datatypes in tds layer - More conversions implemented (Mark Schaal) - Fix make install for not overwriting interfaces (Michael Peppler) - CS_USERDATA now works - Numerous bug fixes (many people) * Thu Aug xx 1999 Brian Bruns - Version 0.46 - Fixed floating type support - Fixed lots of little datatype conversion bugs - Fixed 5.0 login acknowledgement bug - Message processing was cleaned up (Mark Schaal) - Fixed login bug for SQL Server 7.0 - DBD::Sybase 0.19 now compiles and partially works (very partially) - Fixed Solaris #define clash - Numerous bug fixes * Thu Jun 03 1999 Brian Bruns - Version 0.45 - Capabilities added to ctlib code - Numeric support working - MONEY to string conversions now support > 32 bit values - Fixed underread in message handling - Fixed various buffer overflow problems - Fixed NULL handling - Added support for length binding (copied arguement to ct_bind) - Converted ODBC to use iODBC driver manager - SQSH 1.7 runs - PHP 3.0.x with ctlib now runs * Thu Jan 14 1999 Brian Bruns - Version 0.41 - Better row buffering (Craig Spannring) - CT-Lib code improved greatly - Closer behaviour to real dblib - Commonized datatype conversions - Server side code is running somewhat. - SQSH 1.6 running - More ODBC functionality - Many bug fixes - Lots of other stuff I've already forgotten * Sun Nov 22 1998 Brian Bruns - Version 0.40 - Row buffering is now supported for dblib. - Better row handling (side effect of above) - Improved conversion code - Preliminary ODBC layer - PHP now runs basic scripts, maybe more - Many many bug fixes - General cleanup (better error handling, C++ friendly headers, etc...) * Fri Sep 04 1998 Mihai Ibanescu - Version 0.31 - By default the install dir is /usr/local/freetds - The Makefile in the samples dir is automatically built from Makefile.am. The samples dir is not installed, only packaged in the distribution. * Wed Sep 02 1998 Brian Bruns - Version 0.3 - Updated the AUTHORS file - FIXME Brian (added by misa) * Mon Aug 31 1998 Mihai Ibanescu - Version 0.21 - GNUified - Fixed a couple of the TODO issues: byte order is automatically determined, and the TDS version is a configurable option - Modified the README file to reflect the new directory structure Pre-GNUification log by Brian : 2/8/98 Should be able to send the first packet to a server soon, my output is only slightly different than open clients. This codes pretty crappy right now. I need to clean up alot of stuff, remove hardcode values, etc...but I'm anxious to see something work! 2/7/98 Broke the code up a bit, tds.c now handles all wire level stuff, dblib.c handles dblib specific stuff. So, in the future there can be ctlib.c and obdc.c can also sit on top of tds.c to handle the other CLIs 3/16/98 Been working on the code here and there...We can now send a query to the server, dbnumcols() and dbcolname() both work. Almost ready to get some data back. I put in a dummy dbbind to just handle strings so, I could do some work on dbnextrow(). However, we will have revisit almost everything later. 3/23/98 Haven't been able to work on it lately. Still trying to decide on the best way to propagate the row data from tds.c to dblib.c to the calling func. Not that hard, but nothing strikes me as the "Right Way" (tm). 4/2/98 Ok we are ready to release 0.01 (marked by the fact that a simple dblib program actually works!) 5/1/98 Haven't updated in quite a while. A few more dblib commands are supported. dbconvert() support is preliminary. Fixed alot of bugs. A little bit of cleanup. dbbind() sorta works now, needs work still. At least one mem leak that I know of (haven't gotten around to fixing it. Wish I had more time to work on it... 5/2/98 Decided to release what I have. executing sp_who seems to mostly work.. a step in the right direction. Version 0.02. Seem to have generated a little interest after mentioning it in a usenet post. 5/6/98 Can compile against sqsh!!! Did a reorg on tds.c, all dblib func that read data now go through tds_process_messages() which read the marker and calls other routines as necessary. sqsh's output is a little screwy (well I don't have a real dbprrow() yet, but the number of result sets coming back is too many). So, anyway Version 0.04 5/9/98 Decided to upload some new code, mostly just stubs. Sybperl compiles I can't get my perl to work with it. (I need to download perl and link statically, the one that comes on the system won't do). Anyway, most of dblib is present in stub form. 5/17/98 Managed to scrape up some time and release new code. Duplicate result sets went away, and handling of more datatypes (money, bit, more int stuff). Also, improved dbprhead()/row() function. 5/26/98 Ok, I'm doing the long overdue cleaning up of the code. All the kludges should be gone. Thanks, to everyone who contributed code/idea/corrections. 6/3/98 The majority of the overhaul is done...still some work to do, but this is much better than before. I'm bumping the version to 0.1 signifying that I actually use sqsh compiled against it on a regular basis. 6/5/98 TDS 4.2 support seems to be working properly 6/26/98 Gregg Jenson has added support for err and msg handling among other things. I've added some prelimary ctlib support (nothing working yet) 7/3/98 I think we are about ready to release 0.2. Gregg sent some datetime code which appears to work great. I added TDS 4.6 support (small changes really) and tested all the byte order issues on an RS/6000. Also, ctlib code will run the unittest.c and will compile all modules in sqsh 1.6, however there are many missing functions before it will link! 7/10/98 Haven't been able to work on it lately (moved this week). Anyway, trying to add some functions to server. 7/13/98 Tom Poindexter made some changes to get sybtcl to work. 8/8/98 Haven't had much time lately (again), however some small stuff has been fixed and the protocol version stuff has (mostly) been moved to a runtime option. sybperl is supposedly running for simple stuff. freetds-1.00.82/README100644 025423 025423 00000006011 12717146322 0007711README for FreeTDS 1.0 Release date 18 May 2016 * to build FreeTDS read the file INSTALL or the FreeTDS Users Guide (doc/userguide/index.html) and http://www.freetds.org/userguide/ FreeTDS is a free implementation of Sybase's DB-Library, CT-Library, and ODBC libraries. FreeTDS builds and runs on every flavor of unix-like systems we've heard of (and some we haven't) as well as Win32 (with or without Cygwin), VMS, and Mac OS X. Failure to build on your system is probably considered a bug. It has C language bindings, and works also with Perl and PHP, among others. FreeTDS is licensed under the GNU LGPL license. See COPYING.LIB for details. Other files you might want to peruse: AUTHORS Who's involved BUGS Some things we fixed, or think we did NEWS Summary of feature changes and fixes README This file TODO The roadmap, such as it is Also, doc/api_status.txt shows which functions are implemented. For details on what's new in this version, see NEWS. For unbearable detail, see git log. Documentation ============= A User Guide, in sgml and html form, is included in this distribution. Also included is a reference manual, generated in HTML with Doxygen. "make install" installs the HTML documentation, by default to /usr/local/share/doc/freetds-. Note to Users ============= Submissions of test programs (self-contained programs that demonstrate functionality or problems) are greatly appreciated. They should create any tables needed (since we obviously don't have access to your database) and populate them. Unit tests for any of the libraries is appreciated Notes to Developers =================== The code is split into several pieces. 1) tds directory is the wire level stuff, it should be independent of the library using it, this will allow db-lib, ct-lib, and ODBC to sit on top. 2) db-lib directory. This is the actual db-lib code which runs on top of tds. 3) ct-lib directory. This is the ct-lib code which runs on top of tds. 4) server directory. This will be a set of server routines basically to impersonate a dataserver, functions like send_login_ack() etc... 5) odbc directory. ODBC implementation over tds. Uses iODBC or unixODBC as a driver manager. You need to have one of those if you are using the ODBC CLI. 6) unittests directories. Test harness code for ct-lib, db-lib, ODBC and libtds. 6) samples directories. Sample code for getting started with Perl, PHP, etc... 7) pool directory. A connection pooling server for TDS. Useful if you have a connection limited license. Needs some hacking to get configured but is quite stable once configured correctly. Contact the list if interested in how to use it. Please look at doc/getting_started.txt for a description of what is going on in the code. Side note: Brian, as many free software authors, appreciates postcards from all over. So if you live someplace neat (read: not Michigan) and want to send one, email him (brian@bruns.org) for his current snail mail address. $Id: fe43e28922aa8502d1c8c538d601e27c6bceebe4 $ freetds-1.00.82/TODO100644 025423 025423 00000013265 12717145107 0007532This list is ordered top-to-bottom by priority. Things that are broken and need mending are at the top, followed by things that should work before the next release, followed by features that should be added/fixed/reworked (grouped by library). Everyone is encouraged to add to the list. Developers can do it directly; anyone else can post a patch to SourceForge. In this way we can communicate with each other about the project's priorities and needs. To Do List ---------- Must be fixed: . ctlib parameters, handle all case even in tds7 . handle and test prepared query (? and @ syntax should be supported) . cancellation . ctlib seems to hang reading row while in IDLE state (tds_peek if not in pending state hang... update) Applied but could not test fix from ML 21 May 2008: "Problem with FreeTDS validating SQL commands (actually a ct_cancel() error)" I don't know if this is still true. Upper libraries should not use tds_peek as it does handle cancellation. Work in progress: . be able to disable iconv for BCP (see Sybase documentation) I have a patch to disable it, how to handle NVARCHAR? -- freddy77 . BCP under ODBC. There is an experimental patch trying to implement it. For future versions (in priority order within library): All: . Cache protocol discovery (TDSVER=0.0). Save port/instance into some permanent storage. tsql should report progress in verbose mode. . retain values used from freetds.conf, so we can report them. . add a way for tsql to report host, port, and TDS version for the connection it's attempting. Actually libTDS does the name resolution in tds_connect and then just connect so there is no way for tsql to report these information. . move error message macro/prototype to tds.h.in; use in dblib.c. . conversion from ucs2 to utf8, provide for 2+ bytes/character . change numeric format to improve performance ?? . little/big endian based on platform . already packet at word . correctly aligned to read directly packetized . limit copy of data (now wire -> tds -> temp -> client) use a method like zero-copy In token.c getting row should write data even to client (callback, new user types, see ctlib conversion functions) In query.c writing data do the same (use additional column fields?) Situation is much improved in 0.95 version. In ODBC is much better as wire -> tds are never performed and convert extension to give client buffer is used if possible so to avoid the temp step. . review the way parameters are packed (too complicate, see ctlib bulk, cf "bulk copy and row buffer") . improve cursor support on dblib and ctlib . read on partial packet, do not wait entire one . detect if realloc accepts NULL pointers (in configure.ac) . support for password longer than 30 characters under Sybase (anybody know how ??) . under Sybase using prepared statements and BLOBs we shouldn't try to prepare every time (cache failure preparing, see odbc unittests logs, binary_test) done in ODBC ?? . Native bcp has no iconv support; character bcp files are assumed be encoded with the client's charset. More flexibility one both sides would be good. . date/time on Sybase (from 12.5) . encrypted connection for Sybase db-lib . add DBTEXTLIMIT (dbsetopt), PHP require it to support textlimit ini value ct-lib . dynamic placeholders (DBD::Sybase) . ct_option() calls (CS_OPT_ROWCOUNT, CS_OPT_TEXTSIZE, among others) . async function, async calls (dbpoll() and friends) . support all type of bind in ct_bind (CS_VARBINARY_TYPE and other) search "site:.sybase.com CS_VARBINARY ct_bind" on google for more info . complete sqlstate and other field in message (for Python) odbc . SQLDescribeParam (Sybase seems to require it) A 100% success for DBD::ODBC require this. Require parsing of the string to extract placeholders ("?") type, something like "INSERT INTO test_table(field_a) VALUES(?)" -> "SELECT field_a FROM test_table(NOLOCK) WHERE 0=1" . Star Office complains that these TypeInfo constants are not implemented in SQLGetInfo: 47 SQL_USER_NAME (handle environment callbacks) do a "SELECT USER_NAME()". If data pending MS do another connection with same login. . SQLNativeSql and fill SQLGetInfo according (mssql7+ handle odbc escapes directly) . it seems that if statement it's wrong and we issue SQLPrepare on SQLExecute it try to send unprepared dynamic... state on dynamic?? . odbc array binding test large field (like image) have language queries some limits? do we have to split large multiple queries? . report error just before returning SQL_ERROR from inner function? . handle async flags ?? . handle no termination on odbc_set_string* . test and fix: hidden fields (FOR BROWSE select, see flag test on tds) - what happen if we bind to an hidden field?? - if we use SQLGetData?? - if we request informations with SQLDescribeCol/SQLColAttribute(s)/ SQLGetDescField?? - as you noted returning # columns hidden fields are not counted (there is however a setting which is a mssql extension which threat hidden columns as normal) (cfr "SQLNumResultCols() is wrong (+1)" Jan 8 2008) . test: descriptors work - what happen to SQL_DESC_DATETIME_INTERVAL_CODE and SQL_DESC_CONCISE_TYPE changing only SQL_DESC_TYPE (with SQLSetDescField) . test: set SQL_C_DEFAULT and call SQLFetch (numeric, others) . test: SQLGetStmtAttr(SQL_ATTR_ROW_NUMBER) - all binded parameters - no bind and sqlgetdata - before first fetch - after last fetch pool . get connection pooling working with all protocol versions . Make pool configuration a non-recompile process server . Server API needs more work. It's in a quite ugly state. It's more experimental. Should be disabled by default to state it. Done freetds-1.00.82/compile100755 025423 025423 00000016245 13242511045 0010411#! /bin/sh # Wrapper for compilers which do not understand '-c -o'. scriptversion=2012-10-14.11; # UTC # Copyright (C) 1999-2014 Free Software Foundation, Inc. # Written by Tom Tromey . # # 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, 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, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . nl=' ' # We need space, tab and new line, in precisely that order. Quoting is # there to prevent tools from complaining about whitespace usage. IFS=" "" $nl" file_conv= # func_file_conv build_file lazy # Convert a $build file to $host form and store it in $file # Currently only supports Windows hosts. If the determined conversion # type is listed in (the comma separated) LAZY, no conversion will # take place. func_file_conv () { file=$1 case $file in / | /[!/]*) # absolute file, and not a UNC file if test -z "$file_conv"; then # lazily determine how to convert abs files case `uname -s` in MINGW*) file_conv=mingw ;; CYGWIN*) file_conv=cygwin ;; *) file_conv=wine ;; esac fi case $file_conv/,$2, in *,$file_conv,*) ;; mingw/*) file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` ;; cygwin/*) file=`cygpath -m "$file" || echo "$file"` ;; wine/*) file=`winepath -w "$file" || echo "$file"` ;; esac ;; esac } # func_cl_dashL linkdir # Make cl look for libraries in LINKDIR func_cl_dashL () { func_file_conv "$1" if test -z "$lib_path"; then lib_path=$file else lib_path="$lib_path;$file" fi linker_opts="$linker_opts -LIBPATH:$file" } # func_cl_dashl library # Do a library search-path lookup for cl func_cl_dashl () { lib=$1 found=no save_IFS=$IFS IFS=';' for dir in $lib_path $LIB do IFS=$save_IFS if $shared && test -f "$dir/$lib.dll.lib"; then found=yes lib=$dir/$lib.dll.lib break fi if test -f "$dir/$lib.lib"; then found=yes lib=$dir/$lib.lib break fi if test -f "$dir/lib$lib.a"; then found=yes lib=$dir/lib$lib.a break fi done IFS=$save_IFS if test "$found" != yes; then lib=$lib.lib fi } # func_cl_wrapper cl arg... # Adjust compile command to suit cl func_cl_wrapper () { # Assume a capable shell lib_path= shared=: linker_opts= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. eat=1 case $2 in *.o | *.[oO][bB][jJ]) func_file_conv "$2" set x "$@" -Fo"$file" shift ;; *) func_file_conv "$2" set x "$@" -Fe"$file" shift ;; esac ;; -I) eat=1 func_file_conv "$2" mingw set x "$@" -I"$file" shift ;; -I*) func_file_conv "${1#-I}" mingw set x "$@" -I"$file" shift ;; -l) eat=1 func_cl_dashl "$2" set x "$@" "$lib" shift ;; -l*) func_cl_dashl "${1#-l}" set x "$@" "$lib" shift ;; -L) eat=1 func_cl_dashL "$2" ;; -L*) func_cl_dashL "${1#-L}" ;; -static) shared=false ;; -Wl,*) arg=${1#-Wl,} save_ifs="$IFS"; IFS=',' for flag in $arg; do IFS="$save_ifs" linker_opts="$linker_opts $flag" done IFS="$save_ifs" ;; -Xlinker) eat=1 linker_opts="$linker_opts $2" ;; -*) set x "$@" "$1" shift ;; *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) func_file_conv "$1" set x "$@" -Tp"$file" shift ;; *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) func_file_conv "$1" mingw set x "$@" "$file" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -n "$linker_opts"; then linker_opts="-link$linker_opts" fi exec "$@" $linker_opts exit 1 } eat= case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: compile [--help] [--version] PROGRAM [ARGS] Wrapper for compilers which do not understand '-c -o'. Remove '-o dest.o' from ARGS, run PROGRAM with the remaining arguments, and rename the output as expected. If you are trying to build a whole package this is not the right script to run: please start by reading the file 'INSTALL'. Report bugs to . EOF exit $? ;; -v | --v*) echo "compile $scriptversion" exit $? ;; cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) func_cl_wrapper "$@" # Doesn't return... ;; esac ofile= cfile= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. # So we strip '-o arg' only if arg is an object. eat=1 case $2 in *.o | *.obj) ofile=$2 ;; *) set x "$@" -o "$2" shift ;; esac ;; *.c) cfile=$1 set x "$@" "$1" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -z "$ofile" || test -z "$cfile"; then # If no '-o' option was seen then we might have been invoked from a # pattern rule where we don't need one. That is ok -- this is a # normal compilation that the losing compiler can handle. If no # '.c' file was seen then we are probably linking. That is also # ok. exec "$@" fi # Name of file we expect compiler to create. cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` # Create the lock directory. # Note: use '[/\\:.-]' here to ensure that we don't use the same name # that we are using for the .o file. Also, base the name on the expected # object file name, since that is what matters with a parallel build. lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d while true; do if mkdir "$lockdir" >/dev/null 2>&1; then break fi sleep 1 done # FIXME: race condition here if user kills between mkdir and trap. trap "rmdir '$lockdir'; exit 1" 1 2 15 # Run the compile. "$@" ret=$? if test -f "$cofile"; then test "$cofile" = "$ofile" || mv "$cofile" "$ofile" elif test -f "${cofile}bj"; then test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" fi rmdir "$lockdir" exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: freetds-1.00.82/config.guess100755 025423 025423 00000125644 13242511045 0011357#! /bin/sh # Attempt to guess a canonical system name. # Copyright 1992-2017 Free Software Foundation, Inc. timestamp='2017-01-01' # This file 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 3 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, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess # # Please send patches to . me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright 1992-2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown case "${UNAME_SYSTEM}" in Linux|GNU|GNU/*) # If the system lacks a compiler, then just pick glibc. # We could probably try harder. LIBC=gnu eval $set_cc_for_build cat <<-EOF > $dummy.c #include #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc #else LIBC=gnu #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` ;; esac # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ /sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || \ echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; earmv*) arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'` endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'` machine=${arch}${endian}-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently (or will in the future) and ABI. case "${UNAME_MACHINE_ARCH}" in earm*) os=netbsdelf ;; arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # Determine ABI tags. case "${UNAME_MACHINE_ARCH}" in earm*) expr='s/^earmv[0-9]/-eabi/;s/eb$//' abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"` ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}${abi}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:LibertyBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` echo ${UNAME_MACHINE_ARCH}-unknown-libertybsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; *:Sortix:*:*) echo ${UNAME_MACHINE}-unknown-sortix exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE=alpha ;; "EV4.5 (21064)") UNAME_MACHINE=alpha ;; "LCA4 (21066/21068)") UNAME_MACHINE=alpha ;; "EV5 (21164)") UNAME_MACHINE=alphaev5 ;; "EV5.6 (21164A)") UNAME_MACHINE=alphaev56 ;; "EV5.6 (21164PC)") UNAME_MACHINE=alphapca56 ;; "EV5.7 (21164PC)") UNAME_MACHINE=alphapca57 ;; "EV6 (21264)") UNAME_MACHINE=alphaev6 ;; "EV6.7 (21264A)") UNAME_MACHINE=alphaev67 ;; "EV6.8CB (21264C)") UNAME_MACHINE=alphaev68 ;; "EV6.8AL (21264B)") UNAME_MACHINE=alphaev68 ;; "EV6.8CX (21264D)") UNAME_MACHINE=alphaev68 ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE=alphaev69 ;; "EV7 (21364)") UNAME_MACHINE=alphaev7 ;; "EV7.9 (21364A)") UNAME_MACHINE=alphaev79 ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux${UNAME_RELEASE} exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build SUN_ARCH=i386 # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if [ "$CC_FOR_BUILD" != no_compiler_found ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH=x86_64 fi fi echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = x && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/lslpp ] ; then IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH=hppa2.0n ;; 64) HP_ARCH=hppa2.0w ;; '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS="" $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = hppa2.0w ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH=hppa2.0w else HP_ARCH=hppa64 fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` case ${UNAME_PROCESSOR} in amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; *:MINGW64*:*) echo ${UNAME_MACHINE}-pc-mingw64 exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; *:MSYS*:*) echo ${UNAME_MACHINE}-pc-msys exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; *:Interix*:*) case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) echo ia64-unknown-interix${UNAME_RELEASE} exit ;; esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; 8664:Windows_NT:*) echo x86_64-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; aarch64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC=gnulibc1 ; fi echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arc:Linux:*:* | arceb:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo ${UNAME_MACHINE}-unknown-linux-${LIBC} else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi else echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf fi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; cris:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; crisv32:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; e2k:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; frv:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; hexagon:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:Linux:*:*) echo ${UNAME_MACHINE}-pc-linux-${LIBC} exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; k1om:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } ;; mips64el:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; openrisc*:Linux:*:*) echo or1k-unknown-linux-${LIBC} exit ;; or32:Linux:*:* | or1k*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; padre:Linux:*:*) echo sparc-unknown-linux-${LIBC} exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-${LIBC} exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; *) echo hppa-unknown-linux-${LIBC} ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-${LIBC} exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-${LIBC} exit ;; ppc64le:Linux:*:*) echo powerpc64le-unknown-linux-${LIBC} exit ;; ppcle:Linux:*:*) echo powerpcle-unknown-linux-${LIBC} exit ;; riscv32:Linux:*:* | riscv64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux-${LIBC} exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; tile*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-${LIBC} exit ;; x86_64:Linux:*:*) echo ${UNAME_MACHINE}-pc-linux-${LIBC} exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configure will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; x86_64:Haiku:*:*) echo x86_64-unknown-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux${UNAME_RELEASE} exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux${UNAME_RELEASE} exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; SX-ACE:SUPER-UX:*:*) echo sxace-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown eval $set_cc_for_build if test "$UNAME_PROCESSOR" = unknown ; then UNAME_PROCESSOR=powerpc fi if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then if [ "$CC_FOR_BUILD" != no_compiler_found ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then case $UNAME_PROCESSOR in i386) UNAME_PROCESSOR=x86_64 ;; powerpc) UNAME_PROCESSOR=powerpc64 ;; esac fi fi elif test "$UNAME_PROCESSOR" = i386 ; then # Avoid executing cc on OS X 10.9, as it ships with a stub # that puts up a graphical alert prompting to install # developer tools. Any system running Mac OS X 10.7 or # later (Darwin 11 and later) is required to have a 64-bit # processor. This is not true of the ARM version of Darwin # that Apple uses in portable devices. UNAME_PROCESSOR=x86_64 fi echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = x86; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-?:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk${UNAME_RELEASE} exit ;; NSE-*:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = 386; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE} | sed -e 's/ .*$//'` exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; x86_64:VMkernel:*:*) echo ${UNAME_MACHINE}-unknown-esx exit ;; amd64:Isilon\ OneFS:*:*) echo x86_64-unknown-onefs exit ;; esac cat >&2 </dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: freetds-1.00.82/config.rpath100755 025423 025423 00000043647 12525262253 0011360#! /bin/sh # Output a system dependent set of variables, describing how to set the # run time search path of shared libraries in an executable. # # Copyright 1996-2007 Free Software Foundation, Inc. # Taken from GNU libtool, 2001 # Originally by Gordon Matzigkeit , 1996 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # # The first argument passed to this file is the canonical host specification, # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld # should be set by the caller. # # The set of defined variables is at the end of this script. # Known limitations: # - On IRIX 6.5 with CC="cc", the run time search patch must not be longer # than 256 bytes, otherwise the compiler driver will dump core. The only # known workaround is to choose shorter directory names for the build # directory and/or the installation directory. # All known linkers require a `.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a shrext=.so host="$1" host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` # Code taken from libtool.m4's _LT_CC_BASENAME. for cc_temp in $CC""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'` # Code taken from libtool.m4's AC_LIBTOOL_PROG_COMPILER_PIC. wl= if test "$GCC" = yes; then wl='-Wl,' else case "$host_os" in aix*) wl='-Wl,' ;; darwin*) case $cc_basename in xlc*) wl='-Wl,' ;; esac ;; mingw* | cygwin* | pw32* | os2*) ;; hpux9* | hpux10* | hpux11*) wl='-Wl,' ;; irix5* | irix6* | nonstopux*) wl='-Wl,' ;; newsos6) ;; linux* | k*bsd*-gnu) case $cc_basename in icc* | ecc*) wl='-Wl,' ;; pgcc | pgf77 | pgf90) wl='-Wl,' ;; ccc*) wl='-Wl,' ;; como) wl='-lopt=' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) wl='-Wl,' ;; esac ;; esac ;; osf3* | osf4* | osf5*) wl='-Wl,' ;; rdos*) ;; solaris*) wl='-Wl,' ;; sunos4*) wl='-Qoption ld ' ;; sysv4 | sysv4.2uw2* | sysv4.3*) wl='-Wl,' ;; sysv4*MP*) ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) wl='-Wl,' ;; unicos*) wl='-Wl,' ;; uts4*) ;; esac fi # Code taken from libtool.m4's AC_LIBTOOL_PROG_LD_SHLIBS. hardcode_libdir_flag_spec= hardcode_libdir_separator= hardcode_direct=no hardcode_minus_L=no case "$host_os" in cygwin* | mingw* | pw32*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd*) with_gnu_ld=no ;; esac ld_shlibs=yes if test "$with_gnu_ld" = yes; then # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. # Unlike libtool, we use -rpath here, not --rpath, since the documented # option of GNU ld is called -rpath, not --rpath. hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' case "$host_os" in aix3* | aix4* | aix5*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then ld_shlibs=no fi ;; amigaos*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes # Samuel A. Falvo II reports # that the semantics of dynamic libraries on AmigaOS, at least up # to version 4, is to share data among multiple programs linked # with the same dynamic library. Since this doesn't match the # behavior of shared libraries on other platforms, we cannot use # them. ld_shlibs=no ;; beos*) if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then : else ld_shlibs=no fi ;; cygwin* | mingw* | pw32*) # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then : else ld_shlibs=no fi ;; interix[3-9]*) hardcode_direct=no hardcode_libdir_flag_spec='${wl}-rpath,$libdir' ;; gnu* | linux* | k*bsd*-gnu) if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then : else ld_shlibs=no fi ;; netbsd*) ;; solaris*) if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then ld_shlibs=no elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then : else ld_shlibs=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) ld_shlibs=no ;; *) if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`' else ld_shlibs=no fi ;; esac ;; sunos4*) hardcode_direct=yes ;; *) if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then : else ld_shlibs=no fi ;; esac if test "$ld_shlibs" = no; then hardcode_libdir_flag_spec= fi else case "$host_os" in aix3*) # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. hardcode_minus_L=yes if test "$GCC" = yes; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. hardcode_direct=unsupported fi ;; aix4* | aix5*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no else aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[23]|aix4.[23].*|aix5*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done ;; esac fi hardcode_direct=yes hardcode_libdir_separator=':' if test "$GCC" = yes; then case $host_os in aix4.[012]|aix4.[012].*) collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && \ strings "$collect2name" | grep resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 hardcode_direct=unsupported hardcode_minus_L=yes hardcode_libdir_flag_spec='-L$libdir' hardcode_libdir_separator= fi ;; esac fi # Begin _LT_AC_SYS_LIBPATH_AIX. echo 'int main () { return 0; }' > conftest.c ${CC} ${LDFLAGS} conftest.c -o conftest aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } }'` if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } }'` fi if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib" fi rm -f conftest.c conftest # End _LT_AC_SYS_LIBPATH_AIX. if test "$aix_use_runtimelinking" = yes; then hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" else if test "$host_cpu" = ia64; then hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' else hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" fi fi ;; amigaos*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes # see comment about different semantics on the GNU ld section ld_shlibs=no ;; bsdi[45]*) ;; cygwin* | mingw* | pw32*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. hardcode_libdir_flag_spec=' ' libext=lib ;; darwin* | rhapsody*) hardcode_direct=no if test "$GCC" = yes ; then : else case $cc_basename in xlc*) ;; *) ld_shlibs=no ;; esac fi ;; dgux*) hardcode_libdir_flag_spec='-L$libdir' ;; freebsd1*) ld_shlibs=no ;; freebsd2.2*) hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes ;; freebsd2*) hardcode_direct=yes hardcode_minus_L=yes ;; freebsd* | dragonfly*) hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes ;; hpux9*) hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: hardcode_direct=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes ;; hpux10*) if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: hardcode_direct=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes fi ;; hpux11*) if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: case $host_cpu in hppa*64*|ia64*) hardcode_direct=no ;; *) hardcode_direct=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: ;; netbsd*) hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes ;; newsos6) hardcode_direct=yes hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: ;; openbsd*) if test -f /usr/libexec/ld.so; then hardcode_direct=yes if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then hardcode_libdir_flag_spec='${wl}-rpath,$libdir' else case "$host_os" in openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) hardcode_libdir_flag_spec='-R$libdir' ;; *) hardcode_libdir_flag_spec='${wl}-rpath,$libdir' ;; esac fi else ld_shlibs=no fi ;; os2*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; osf3*) hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: ;; osf4* | osf5*) if test "$GCC" = yes; then hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' else # Both cc and cxx compiler support -rpath directly hardcode_libdir_flag_spec='-rpath $libdir' fi hardcode_libdir_separator=: ;; solaris*) hardcode_libdir_flag_spec='-R$libdir' ;; sunos4*) hardcode_libdir_flag_spec='-L$libdir' hardcode_direct=yes hardcode_minus_L=yes ;; sysv4) case $host_vendor in sni) hardcode_direct=yes # is this really true??? ;; siemens) hardcode_direct=no ;; motorola) hardcode_direct=no #Motorola manual says yes, but my tests say they lie ;; esac ;; sysv4.3*) ;; sysv4*MP*) if test -d /usr/nec; then ld_shlibs=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) ;; sysv5* | sco3.2v5* | sco5v6*) hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`' hardcode_libdir_separator=':' ;; uts4*) hardcode_libdir_flag_spec='-L$libdir' ;; *) ld_shlibs=no ;; esac fi # Check dynamic linker characteristics # Code taken from libtool.m4's AC_LIBTOOL_SYS_DYNAMIC_LINKER. # Unlike libtool.m4, here we don't care about _all_ names of the library, but # only about the one the linker finds when passed -lNAME. This is the last # element of library_names_spec in libtool.m4, or possibly two of them if the # linker has special search rules. library_names_spec= # the last element of library_names_spec in libtool.m4 libname_spec='lib$name' case "$host_os" in aix3*) library_names_spec='$libname.a' ;; aix4* | aix5*) library_names_spec='$libname$shrext' ;; amigaos*) library_names_spec='$libname.a' ;; beos*) library_names_spec='$libname$shrext' ;; bsdi[45]*) library_names_spec='$libname$shrext' ;; cygwin* | mingw* | pw32*) shrext=.dll library_names_spec='$libname.dll.a $libname.lib' ;; darwin* | rhapsody*) shrext=.dylib library_names_spec='$libname$shrext' ;; dgux*) library_names_spec='$libname$shrext' ;; freebsd1*) ;; freebsd* | dragonfly*) case "$host_os" in freebsd[123]*) library_names_spec='$libname$shrext$versuffix' ;; *) library_names_spec='$libname$shrext' ;; esac ;; gnu*) library_names_spec='$libname$shrext' ;; hpux9* | hpux10* | hpux11*) case $host_cpu in ia64*) shrext=.so ;; hppa*64*) shrext=.sl ;; *) shrext=.sl ;; esac library_names_spec='$libname$shrext' ;; interix[3-9]*) library_names_spec='$libname$shrext' ;; irix5* | irix6* | nonstopux*) library_names_spec='$libname$shrext' case "$host_os" in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;; *) libsuff= shlibsuff= ;; esac ;; esac ;; linux*oldld* | linux*aout* | linux*coff*) ;; linux* | k*bsd*-gnu) library_names_spec='$libname$shrext' ;; knetbsd*-gnu) library_names_spec='$libname$shrext' ;; netbsd*) library_names_spec='$libname$shrext' ;; newsos6) library_names_spec='$libname$shrext' ;; nto-qnx*) library_names_spec='$libname$shrext' ;; openbsd*) library_names_spec='$libname$shrext$versuffix' ;; os2*) libname_spec='$name' shrext=.dll library_names_spec='$libname.a' ;; osf3* | osf4* | osf5*) library_names_spec='$libname$shrext' ;; rdos*) ;; solaris*) library_names_spec='$libname$shrext' ;; sunos4*) library_names_spec='$libname$shrext$versuffix' ;; sysv4 | sysv4.3*) library_names_spec='$libname$shrext' ;; sysv4*MP*) library_names_spec='$libname$shrext' ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) library_names_spec='$libname$shrext' ;; uts4*) library_names_spec='$libname$shrext' ;; esac sed_quote_subst='s/\(["`$\\]\)/\\\1/g' escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"` shlibext=`echo "$shrext" | sed -e 's,^\.,,'` escaped_libname_spec=`echo "X$libname_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` escaped_library_names_spec=`echo "X$library_names_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # Please send patches to . # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright 1992-2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ kopensolaris*-gnu* | cloudabi*-eabi* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; android-linux) os=-linux-android basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray | -microblaze*) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*178) os=-lynxos178 ;; -lynx*5) os=-lynxos5 ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arceb \ | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ | avr | avr32 \ | ba \ | be32 | be64 \ | bfin \ | c4x | c8051 | clipper \ | d10v | d30v | dlx | dsp16xx \ | e2k | epiphany \ | fido | fr30 | frv | ft32 \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | k1om \ | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa32r6 | mipsisa32r6el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64r6 | mipsisa64r6el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipsr5900 | mipsr5900el \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ | nios | nios2 | nios2eb | nios2el \ | ns16k | ns32k \ | open8 | or1k | or1knd | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pru \ | pyramid \ | riscv32 | riscv64 \ | rl78 | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | visium \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; c54x) basic_machine=tic54x-unknown ;; c55x) basic_machine=tic55x-unknown ;; c6x) basic_machine=tic6x-unknown ;; leon|leon[3-9]) basic_machine=sparc-$basic_machine ;; m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown ;; strongarm | thumb | xscale) basic_machine=arm-unknown ;; xgate) basic_machine=$basic_machine-unknown os=-none ;; xscaleeb) basic_machine=armeb-unknown ;; xscaleel) basic_machine=armel-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | ba-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | c8051-* | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | e2k-* | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | k1om-* \ | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ | microblaze-* | microblazeel-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa32r6-* | mipsisa32r6el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64r6-* | mipsisa64r6el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipsr5900-* | mipsr5900el-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* | nios2eb-* | nios2el-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ | or1k*-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pru-* \ | pyramid-* \ | riscv32-* | riscv64-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ | visium-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aros) basic_machine=i386-pc os=-aros ;; asmjs) basic_machine=asmjs-unknown ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c54x-*) basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c55x-*) basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c6x-*) basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; e500v[12]) basic_machine=powerpc-unknown os=$os"spe" ;; e500v[12]-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` os=$os"spe" ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; leon-*|leon[3-9]-*) basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; microblaze*) basic_machine=microblaze-xilinx ;; mingw64) basic_machine=x86_64-pc os=-mingw64 ;; mingw32) basic_machine=i686-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; moxiebox) basic_machine=moxie-unknown os=-moxiebox ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; msys) basic_machine=i686-pc os=-msys ;; mvs) basic_machine=i370-ibm os=-mvs ;; nacl) basic_machine=le32-unknown os=-nacl ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; neo-tandem) basic_machine=neo-tandem ;; nse-tandem) basic_machine=nse-tandem ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos | rdos64) basic_machine=x86_64-pc os=-rdos ;; rdos32) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh5el) basic_machine=sh5le-unknown ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; strongarm-* | thumb-*) basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tile*) basic_machine=$basic_machine-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; xscale-* | xscalee[bl]-*) basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; z80-*-coff) basic_machine=z80-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* | -plan9* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* | -cloudabi* | -sortix* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-musl* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \ | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -nacl*) ;; -ios) ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; c8051-*) os=-elf ;; hexagon-*) os=-elf ;; tic54x-*) os=-coff ;; tic55x-*) os=-coff ;; tic6x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; pru-*) os=-elf ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -cnk*|-aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: freetds-1.00.82/depcomp100755 025423 025423 00000056016 13242511046 0010411#! /bin/sh # depcomp - compile a program generating dependencies as side-effects scriptversion=2013-05-30.07; # UTC # Copyright (C) 1999-2014 Free Software Foundation, Inc. # 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, 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, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva . case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: depcomp [--help] [--version] PROGRAM [ARGS] Run PROGRAMS ARGS to compile a file, generating dependencies as side-effects. Environment variables: depmode Dependency tracking mode. source Source file read by 'PROGRAMS ARGS'. object Object file output by 'PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. tmpdepfile Temporary file to use when outputting dependencies. libtool Whether libtool is used (yes/no). Report bugs to . EOF exit $? ;; -v | --v*) echo "depcomp $scriptversion" exit $? ;; esac # Get the directory component of the given path, and save it in the # global variables '$dir'. Note that this directory component will # be either empty or ending with a '/' character. This is deliberate. set_dir_from () { case $1 in */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; *) dir=;; esac } # Get the suffix-stripped basename of the given path, and save it the # global variable '$base'. set_base_from () { base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` } # If no dependency file was actually created by the compiler invocation, # we still have to create a dummy depfile, to avoid errors with the # Makefile "include basename.Plo" scheme. make_dummy_depfile () { echo "#dummy" > "$depfile" } # Factor out some common post-processing of the generated depfile. # Requires the auxiliary global variable '$tmpdepfile' to be set. aix_post_process_depfile () { # If the compiler actually managed to produce a dependency file, # post-process it. if test -f "$tmpdepfile"; then # Each line is of the form 'foo.o: dependency.h'. # Do two passes, one to just change these to # $object: dependency.h # and one to simply output # dependency.h: # which is needed to avoid the deleted-header problem. { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" } > "$depfile" rm -f "$tmpdepfile" else make_dummy_depfile fi } # A tabulation character. tab=' ' # A newline character. nl=' ' # Character ranges might be problematic outside the C locale. # These definitions help. upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ lower=abcdefghijklmnopqrstuvwxyz digits=0123456789 alpha=${upper}${lower} if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. depfile=${depfile-`echo "$object" | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Avoid interferences from the environment. gccflag= dashmflag= # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi cygpath_u="cygpath -u -f -" if test "$depmode" = msvcmsys; then # This is just like msvisualcpp but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvisualcpp fi if test "$depmode" = msvc7msys; then # This is just like msvc7 but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvc7 fi if test "$depmode" = xlc; then # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. gccflag=-qmakedep=gcc,-MF depmode=gcc fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. ## Unfortunately, FreeBSD c89 acceptance of flags depends upon ## the command line argument order; so add the flags where they ## appear in depend2.am. Note that the slowdown incurred here ## affects only configure: in makefiles, %FASTDEP% shortcuts this. for arg do case $arg in -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; *) set fnord "$@" "$arg" ;; esac shift # fnord shift # $arg done "$@" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. ## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. ## (see the conditional assignment to $gccflag above). ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). Also, it might not be ## supported by the other compilers which use the 'gcc' depmode. ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The second -e expression handles DOS-style file names with drive # letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the "deleted header file" problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. ## Some versions of gcc put a space before the ':'. On the theory ## that the space means something, we add a space to the output as ## well. hp depmode also adds that space, but also prefixes the VPATH ## to the object. Take care to not repeat it in the output. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like '#:fec' to the end of the # dependency line. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ | tr "$nl" ' ' >> "$depfile" echo >> "$depfile" # The second pass generates a dummy entry for each header file. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> "$depfile" else make_dummy_depfile fi rm -f "$tmpdepfile" ;; xlc) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the # current directory. Also, the AIX compiler puts '$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then tmpdepfile1=$dir$base.u tmpdepfile2=$base.u tmpdepfile3=$dir.libs/$base.u "$@" -Wc,-M else tmpdepfile1=$dir$base.u tmpdepfile2=$dir$base.u tmpdepfile3=$dir$base.u "$@" -M fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done aix_post_process_depfile ;; tcc) # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 # FIXME: That version still under development at the moment of writing. # Make that this statement remains true also for stable, released # versions. # It will wrap lines (doesn't matter whether long or short) with a # trailing '\', as in: # # foo.o : \ # foo.c \ # foo.h \ # # It will put a trailing '\' even on the last line, and will use leading # spaces rather than leading tabs (at least since its commit 0394caf7 # "Emit spaces for -MD"). "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. # We have to change lines of the first kind to '$object: \'. sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" # And for each line of the second kind, we have to emit a 'dep.h:' # dummy dependency, to avoid the deleted-header problem. sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" rm -f "$tmpdepfile" ;; ## The order of this option in the case statement is important, since the ## shell code in configure will try each of these formats in the order ## listed in this file. A plain '-MD' option would be understood by many ## compilers, so we must ensure this comes after the gcc and icc options. pgcc) # Portland's C compiler understands '-MD'. # Will always output deps to 'file.d' where file is the root name of the # source file under compilation, even if file resides in a subdirectory. # The object file name does not affect the name of the '.d' file. # pgcc 10.2 will output # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using '\' : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... set_dir_from "$object" # Use the source, not the object, to determine the base name, since # that's sadly what pgcc will do too. set_base_from "$source" tmpdepfile=$base.d # For projects that build the same source file twice into different object # files, the pgcc approach of using the *source* file root name can cause # problems in parallel builds. Use a locking strategy to avoid stomping on # the same $tmpdepfile. lockdir=$base.d-lock trap " echo '$0: caught signal, cleaning up...' >&2 rmdir '$lockdir' exit 1 " 1 2 13 15 numtries=100 i=$numtries while test $i -gt 0; do # mkdir is a portable test-and-set. if mkdir "$lockdir" 2>/dev/null; then # This process acquired the lock. "$@" -MD stat=$? # Release the lock. rmdir "$lockdir" break else # If the lock is being held by a different process, wait # until the winning process is done or we timeout. while test -d "$lockdir" && test $i -gt 0; do sleep 1 i=`expr $i - 1` done fi i=`expr $i - 1` done trap - 1 2 13 15 if test $i -le 0; then echo "$0: failed to acquire lock after $numtries attempts" >&2 echo "$0: check lockdir '$lockdir'" >&2 exit 1 fi if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each line is of the form `foo.o: dependent.h', # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this invocation # correctly. Breaking it into two sed invocations is a workaround. sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp2) # The "hp" stanza above does not work with aCC (C++) and HP's ia64 # compilers, which have integrated preprocessors. The correct option # to use with these is +Maked; it writes dependencies to a file named # 'foo.d', which lands next to the object file, wherever that # happens to be. # Much of this is similar to the tru64 case; see comments there. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then tmpdepfile1=$dir$base.d tmpdepfile2=$dir.libs/$base.d "$@" -Wc,+Maked else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d "$@" +Maked fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" # Add 'dependent.h:' lines. sed -ne '2,${ s/^ *// s/ \\*$// s/$/:/ p }' "$tmpdepfile" >> "$depfile" else make_dummy_depfile fi rm -f "$tmpdepfile" "$tmpdepfile2" ;; tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in 'foo.d' instead, so we check for that too. # Subdirectories are respected. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then # Libtool generates 2 separate objects for the 2 libraries. These # two compilations output dependencies in $dir.libs/$base.o.d and # in $dir$base.o.d. We have to check for both files, because # one of the two compilations can be disabled. We should prefer # $dir$base.o.d over $dir.libs/$base.o.d because the latter is # automatically cleaned when .libs/ is deleted, while ignoring # the former would cause a distcleancheck panic. tmpdepfile1=$dir$base.o.d # libtool 1.5 tmpdepfile2=$dir.libs/$base.o.d # Likewise. tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 "$@" -Wc,-MD else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d tmpdepfile3=$dir$base.d "$@" -MD fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done # Same post-processing that is required for AIX mode. aix_post_process_depfile ;; msvc7) if test "$libtool" = yes; then showIncludes=-Wc,-showIncludes else showIncludes=-showIncludes fi "$@" $showIncludes > "$tmpdepfile" stat=$? grep -v '^Note: including file: ' "$tmpdepfile" if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The first sed program below extracts the file names and escapes # backslashes for cygpath. The second sed program outputs the file # name when reading, but also accumulates all include files in the # hold buffer in order to output them again at the end. This only # works with sed implementations that can handle large buffers. sed < "$tmpdepfile" -n ' /^Note: including file: *\(.*\)/ { s//\1/ s/\\/\\\\/g p }' | $cygpath_u | sort -u | sed -n ' s/ /\\ /g s/\(.*\)/'"$tab"'\1 \\/p s/.\(.*\) \\/\1:/ H $ { s/.*/'"$tab"'/ G p }' >> "$depfile" echo >> "$depfile" # make sure the fragment doesn't end with a backslash rm -f "$tmpdepfile" ;; msvc7msys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove '-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done test -z "$dashmflag" && dashmflag=-M # Require at least two characters before searching for ':' # in the target name. This is to cope with DOS-style filenames: # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. "$@" $dashmflag | sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this sed invocation # correctly. Breaking it into two sed invocations is a workaround. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # X makedepend shift cleared=no eat=no for arg do case $cleared in no) set ""; shift cleared=yes ;; esac if test $eat = yes; then eat=no continue fi case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift ;; # Strip any option that makedepend may not understand. Remove # the object too, otherwise makedepend will parse it as a source file. -arch) eat=yes ;; -*|$object) ;; *) set fnord "$@" "$arg"; shift ;; esac done obj_suffix=`echo "$object" | sed 's/^.*\././'` touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" # makedepend may prepend the VPATH from the source file name to the object. # No need to regex-escape $object, excess matching of '.' is harmless. sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process the last invocation # correctly. Breaking it into two sed invocations is a workaround. sed '1,2d' "$tmpdepfile" \ | tr ' ' "$nl" \ | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove '-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done "$@" -E \ | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ | sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi IFS=" " for arg do case "$arg" in -o) shift ;; $object) shift ;; "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") set fnord "$@" shift shift ;; *) set fnord "$@" "$arg" shift shift ;; esac done "$@" -E 2>/dev/null | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" echo "$tab" >> "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; msvcmsys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: freetds-1.00.82/install-sh100755 025423 025423 00000015150 13242511045 0011031#!/bin/sh # # $NetBSD: install-sh.in,v 1.6 2012/01/11 13:07:31 hans Exp $ # This script now also installs multiple files, but might choke on installing # multiple files with spaces in the file names. # # install - install a program, script, or datafile # This comes from X11R5 (mit/util/scripts/install.sh). # # Copyright 1991 by the Massachusetts Institute of Technology # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation, and that the name of M.I.T. not be used in advertising or # publicity pertaining to distribution of the software without specific, # written prior permission. M.I.T. makes no representations about the # suitability of this software for any purpose. It is provided "as is" # without express or implied warranty. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. awkprog="${AWKPROG-awk}" mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" instcmd="$cpprog" instflags="" pathcompchmodcmd="$chmodprog 755" chmodcmd="$chmodprog 755" chowncmd="" chgrpcmd="" stripcmd="" stripflags="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" msrc="" dst="" dir_arg="" suffix="" suffixfmt="" while [ x"$1" != x ]; do case $1 in -b) suffix=".old" shift continue;; -B) suffixfmt="$2" shift shift continue;; -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -m*) chmodcmd="$chmodprog ${1#-m}" shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -S) stripcmd="$stripprog" stripflags="-S $2 $stripflags" shift shift continue;; -p) instflags="-p" shift continue;; *) if [ x"$msrc" = x ] then msrc="$dst" else msrc="$msrc $dst" fi src="$dst" dst="$1" shift continue;; esac done if [ x"$dir_arg" = x ] then dstisfile="" if [ ! -d "$dst" ] then if [ x"$msrc" = x"$src" ] then dstisfile=true else echo "install: destination is not a directory" exit 1 fi fi else msrc="$msrc $dst" fi if [ x"$msrc" = x ] then echo "install: no destination specified" exit 1 fi for srcarg in $msrc; do if [ x"$dir_arg" != x ]; then dstarg="$srcarg" else dstarg="$dst" # Waiting for this to be detected by the "$instcmd $srcarg $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f "$srcarg" ] then doinst="$instcmd $instflags" elif [ -d "$srcarg" ] then echo "install: $srcarg: not a regular file" exit 1 elif [ "$srcarg" = "/dev/null" ] then doinst="$cpprog" else echo "install: $srcarg does not exist" exit 1 fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d "$dstarg" ] then dstarg="$dstarg"/`basename "$srcarg"` fi fi ## this sed command emulates the dirname command dstdir=`echo "$dstarg" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $doit $mkdirprog "${pathcomp}" if [ x"$chowncmd" != x ]; then $doit $chowncmd "${pathcomp}"; else true ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "${pathcomp}"; else true ; fi && if [ x"$pathcompchmodcmd" != x ]; then $doit $pathcompchmodcmd "${pathcomp}"; else true ; fi else true fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then if [ -d "$dstarg" ]; then true else $doit $mkdirprog "$dstarg" && if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dstarg"; else true ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dstarg"; else true ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dstarg"; else true ; fi fi else if [ x"$dstisfile" = x ] then file=$srcarg else file=$dst fi dstfile=`basename "$file"` dstfinal="$dstdir/$dstfile" # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Make a backup file name in the proper directory. case x$suffixfmt in *%*) suffix=`echo x | $awkprog -v bname="$dstfinal" -v fmt="$suffixfmt" ' { cnt = 0; do { sfx = sprintf(fmt, cnt++); name = bname sfx; } while (system("test -f " name) == 0); print sfx; }' -`;; x) ;; *) suffix="$suffixfmt";; esac dstbackup="$dstfinal$suffix" # Move or copy the file name to the temp name $doit $doinst $srcarg "$dsttmp" && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else true;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else true;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $stripflags "$dsttmp"; else true;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else true;fi && # Now rename the file to the real destination. if [ x"$suffix" != x ] && [ -f "$dstfinal" ] then $doit $mvcmd "$dstfinal" "$dstbackup" else $doit $rmcmd -f "$dstfinal" fi && $doit $mvcmd "$dsttmp" "$dstfinal" fi done && exit 0 freetds-1.00.82/ltmain.sh100644 025423 025423 00001170771 13242511037 0010662#! /bin/sh ## DO NOT EDIT - This file generated from ./build-aux/ltmain.in ## by inline-source v2014-01-03.01 # libtool (GNU libtool) 2.4.6 # Provide generalized library-building support services. # Written by Gordon Matzigkeit , 1996 # Copyright (C) 1996-2015 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # GNU Libtool 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. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool 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, see . PROGRAM=libtool PACKAGE=libtool VERSION=2.4.6 package_revision=2.4.6 ## ------ ## ## Usage. ## ## ------ ## # Run './libtool --help' for help with using this script from the # command line. ## ------------------------------- ## ## User overridable command paths. ## ## ------------------------------- ## # After configure completes, it has a better idea of some of the # shell tools we need than the defaults used by the functions shared # with bootstrap, so set those here where they can still be over- # ridden by the user, but otherwise take precedence. : ${AUTOCONF="autoconf"} : ${AUTOMAKE="automake"} ## -------------------------- ## ## Source external libraries. ## ## -------------------------- ## # Much of our low-level functionality needs to be sourced from external # libraries, which are installed to $pkgauxdir. # Set a version string for this script. scriptversion=2015-01-20.17; # UTC # General shell script boiler plate, and helper functions. # Written by Gary V. Vaughan, 2004 # Copyright (C) 2004-2015 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # 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 3 of the License, or # (at your option) any later version. # As a special exception to the GNU General Public License, if you distribute # this file as part of a program or library that is built using GNU Libtool, # you may include this file under the same distribution terms that you use # for the rest of that program. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNES 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, see . # Please report bugs or propose patches to gary@gnu.org. ## ------ ## ## Usage. ## ## ------ ## # Evaluate this file near the top of your script to gain access to # the functions and variables defined here: # # . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh # # If you need to override any of the default environment variable # settings, do that before evaluating this file. ## -------------------- ## ## Shell normalisation. ## ## -------------------- ## # Some shells need a little help to be as Bourne compatible as possible. # Before doing anything else, make sure all that help has been provided! DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi # NLS nuisances: We save the old values in case they are required later. _G_user_locale= _G_safe_locale= for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test set = \"\${$_G_var+set}\"; then save_$_G_var=\$$_G_var $_G_var=C export $_G_var _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" fi" done # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Make sure IFS has a sensible default sp=' ' nl=' ' IFS="$sp $nl" # There are apparently some retarded systems that use ';' as a PATH separator! if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi ## ------------------------- ## ## Locate command utilities. ## ## ------------------------- ## # func_executable_p FILE # ---------------------- # Check that FILE is an executable regular file. func_executable_p () { test -f "$1" && test -x "$1" } # func_path_progs PROGS_LIST CHECK_FUNC [PATH] # -------------------------------------------- # Search for either a program that responds to --version with output # containing "GNU", or else returned by CHECK_FUNC otherwise, by # trying all the directories in PATH with each of the elements of # PROGS_LIST. # # CHECK_FUNC should accept the path to a candidate program, and # set $func_check_prog_result if it truncates its output less than # $_G_path_prog_max characters. func_path_progs () { _G_progs_list=$1 _G_check_func=$2 _G_PATH=${3-"$PATH"} _G_path_prog_max=0 _G_path_prog_found=false _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} for _G_dir in $_G_PATH; do IFS=$_G_save_IFS test -z "$_G_dir" && _G_dir=. for _G_prog_name in $_G_progs_list; do for _exeext in '' .EXE; do _G_path_prog=$_G_dir/$_G_prog_name$_exeext func_executable_p "$_G_path_prog" || continue case `"$_G_path_prog" --version 2>&1` in *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; *) $_G_check_func $_G_path_prog func_path_progs_result=$func_check_prog_result ;; esac $_G_path_prog_found && break 3 done done done IFS=$_G_save_IFS test -z "$func_path_progs_result" && { echo "no acceptable sed could be found in \$PATH" >&2 exit 1 } } # We want to be able to use the functions in this file before configure # has figured out where the best binaries are kept, which means we have # to search for them ourselves - except when the results are already set # where we skip the searches. # Unless the user overrides by setting SED, search the path for either GNU # sed, or the sed that truncates its output the least. test -z "$SED" && { _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for _G_i in 1 2 3 4 5 6 7; do _G_sed_script=$_G_sed_script$nl$_G_sed_script done echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed _G_sed_script= func_check_prog_sed () { _G_path_prog=$1 _G_count=0 printf 0123456789 >conftest.in while : do cat conftest.in conftest.in >conftest.tmp mv conftest.tmp conftest.in cp conftest.in conftest.nl echo '' >> conftest.nl "$_G_path_prog" -f conftest.sed conftest.out 2>/dev/null || break diff conftest.out conftest.nl >/dev/null 2>&1 || break _G_count=`expr $_G_count + 1` if test "$_G_count" -gt "$_G_path_prog_max"; then # Best one so far, save it but keep looking for a better one func_check_prog_result=$_G_path_prog _G_path_prog_max=$_G_count fi # 10*(2^10) chars as input seems more than enough test 10 -lt "$_G_count" && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out } func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin rm -f conftest.sed SED=$func_path_progs_result } # Unless the user overrides by setting GREP, search the path for either GNU # grep, or the grep that truncates its output the least. test -z "$GREP" && { func_check_prog_grep () { _G_path_prog=$1 _G_count=0 _G_path_prog_max=0 printf 0123456789 >conftest.in while : do cat conftest.in conftest.in >conftest.tmp mv conftest.tmp conftest.in cp conftest.in conftest.nl echo 'GREP' >> conftest.nl "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' conftest.out 2>/dev/null || break diff conftest.out conftest.nl >/dev/null 2>&1 || break _G_count=`expr $_G_count + 1` if test "$_G_count" -gt "$_G_path_prog_max"; then # Best one so far, save it but keep looking for a better one func_check_prog_result=$_G_path_prog _G_path_prog_max=$_G_count fi # 10*(2^10) chars as input seems more than enough test 10 -lt "$_G_count" && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out } func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin GREP=$func_path_progs_result } ## ------------------------------- ## ## User overridable command paths. ## ## ------------------------------- ## # All uppercase variable names are used for environment variables. These # variables can be overridden by the user before calling a script that # uses them if a suitable command of that name is not already available # in the command search PATH. : ${CP="cp -f"} : ${ECHO="printf %s\n"} : ${EGREP="$GREP -E"} : ${FGREP="$GREP -F"} : ${LN_S="ln -s"} : ${MAKE="make"} : ${MKDIR="mkdir"} : ${MV="mv -f"} : ${RM="rm -f"} : ${SHELL="${CONFIG_SHELL-/bin/sh}"} ## -------------------- ## ## Useful sed snippets. ## ## -------------------- ## sed_dirname='s|/[^/]*$||' sed_basename='s|^.*/||' # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. sed_quote_subst='s|\([`"$\\]\)|\\\1|g' # Same as above, but do not quote variable references. sed_double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution that turns a string into a regex matching for the # string literally. sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' # Sed substitution that converts a w32 file name or path # that contains forward slashes, into one that contains # (escaped) backslashes. A very naive implementation. sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' # Re-'\' parameter expansions in output of sed_double_quote_subst that # were '\'-ed in input to the same. If an odd number of '\' preceded a # '$' in input to sed_double_quote_subst, that '$' was protected from # expansion. Since each input '\' is now two '\'s, look for any number # of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. _G_bs='\\' _G_bs2='\\\\' _G_bs4='\\\\\\\\' _G_dollar='\$' sed_double_backslash="\ s/$_G_bs4/&\\ /g s/^$_G_bs2$_G_dollar/$_G_bs&/ s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g s/\n//g" ## ----------------- ## ## Global variables. ## ## ----------------- ## # Except for the global variables explicitly listed below, the following # functions in the '^func_' namespace, and the '^require_' namespace # variables initialised in the 'Resource management' section, sourcing # this file will not pollute your global namespace with anything # else. There's no portable way to scope variables in Bourne shell # though, so actually running these functions will sometimes place # results into a variable named after the function, and often use # temporary variables in the '^_G_' namespace. If you are careful to # avoid using those namespaces casually in your sourcing script, things # should continue to work as you expect. And, of course, you can freely # overwrite any of the functions or variables defined here before # calling anything to customize them. EXIT_SUCCESS=0 EXIT_FAILURE=1 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. # Allow overriding, eg assuming that you follow the convention of # putting '$debug_cmd' at the start of all your functions, you can get # bash to show function call trace with: # # debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name debug_cmd=${debug_cmd-":"} exit_cmd=: # By convention, finish your script with: # # exit $exit_status # # so that you can set exit_status to non-zero if you want to indicate # something went wrong during execution without actually bailing out at # the point of failure. exit_status=$EXIT_SUCCESS # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh # is ksh but when the shell is invoked as "sh" and the current value of # the _XPG environment variable is not equal to 1 (one), the special # positional parameter $0, within a function call, is the name of the # function. progpath=$0 # The name of this program. progname=`$ECHO "$progpath" |$SED "$sed_basename"` # Make sure we have an absolute progpath for reexecution: case $progpath in [\\/]*|[A-Za-z]:\\*) ;; *[\\/]*) progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` progdir=`cd "$progdir" && pwd` progpath=$progdir/$progname ;; *) _G_IFS=$IFS IFS=${PATH_SEPARATOR-:} for progdir in $PATH; do IFS=$_G_IFS test -x "$progdir/$progname" && break done IFS=$_G_IFS test -n "$progdir" || progdir=`pwd` progpath=$progdir/$progname ;; esac ## ----------------- ## ## Standard options. ## ## ----------------- ## # The following options affect the operation of the functions defined # below, and should be set appropriately depending on run-time para- # meters passed on the command line. opt_dry_run=false opt_quiet=false opt_verbose=false # Categories 'all' and 'none' are always available. Append any others # you will pass as the first argument to func_warning from your own # code. warning_categories= # By default, display warnings according to 'opt_warning_types'. Set # 'warning_func' to ':' to elide all warnings, or func_fatal_error to # treat the next displayed warning as a fatal error. warning_func=func_warn_and_continue # Set to 'all' to display all warnings, 'none' to suppress all # warnings, or a space delimited list of some subset of # 'warning_categories' to display only the listed warnings. opt_warning_types=all ## -------------------- ## ## Resource management. ## ## -------------------- ## # This section contains definitions for functions that each ensure a # particular resource (a file, or a non-empty configuration variable for # example) is available, and if appropriate to extract default values # from pertinent package files. Call them using their associated # 'require_*' variable to ensure that they are executed, at most, once. # # It's entirely deliberate that calling these functions can set # variables that don't obey the namespace limitations obeyed by the rest # of this file, in order that that they be as useful as possible to # callers. # require_term_colors # ------------------- # Allow display of bold text on terminals that support it. require_term_colors=func_require_term_colors func_require_term_colors () { $debug_cmd test -t 1 && { # COLORTERM and USE_ANSI_COLORS environment variables take # precedence, because most terminfo databases neglect to describe # whether color sequences are supported. test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} if test 1 = "$USE_ANSI_COLORS"; then # Standard ANSI escape sequences tc_reset='' tc_bold=''; tc_standout='' tc_red=''; tc_green='' tc_blue=''; tc_cyan='' else # Otherwise trust the terminfo database after all. test -n "`tput sgr0 2>/dev/null`" && { tc_reset=`tput sgr0` test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` tc_standout=$tc_bold test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` } fi } require_term_colors=: } ## ----------------- ## ## Function library. ## ## ----------------- ## # This section contains a variety of useful functions to call in your # scripts. Take note of the portable wrappers for features provided by # some modern shells, which will fall back to slower equivalents on # less featureful shells. # func_append VAR VALUE # --------------------- # Append VALUE onto the existing contents of VAR. # We should try to minimise forks, especially on Windows where they are # unreasonably slow, so skip the feature probes when bash or zsh are # being used: if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then : ${_G_HAVE_ARITH_OP="yes"} : ${_G_HAVE_XSI_OPS="yes"} # The += operator was introduced in bash 3.1 case $BASH_VERSION in [12].* | 3.0 | 3.0*) ;; *) : ${_G_HAVE_PLUSEQ_OP="yes"} ;; esac fi # _G_HAVE_PLUSEQ_OP # Can be empty, in which case the shell is probed, "yes" if += is # useable or anything else if it does not work. test -z "$_G_HAVE_PLUSEQ_OP" \ && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ && _G_HAVE_PLUSEQ_OP=yes if test yes = "$_G_HAVE_PLUSEQ_OP" then # This is an XSI compatible shell, allowing a faster implementation... eval 'func_append () { $debug_cmd eval "$1+=\$2" }' else # ...otherwise fall back to using expr, which is often a shell builtin. func_append () { $debug_cmd eval "$1=\$$1\$2" } fi # func_append_quoted VAR VALUE # ---------------------------- # Quote VALUE and append to the end of shell variable VAR, separated # by a space. if test yes = "$_G_HAVE_PLUSEQ_OP"; then eval 'func_append_quoted () { $debug_cmd func_quote_for_eval "$2" eval "$1+=\\ \$func_quote_for_eval_result" }' else func_append_quoted () { $debug_cmd func_quote_for_eval "$2" eval "$1=\$$1\\ \$func_quote_for_eval_result" } fi # func_append_uniq VAR VALUE # -------------------------- # Append unique VALUE onto the existing contents of VAR, assuming # entries are delimited by the first character of VALUE. For example: # # func_append_uniq options " --another-option option-argument" # # will only append to $options if " --another-option option-argument " # is not already present somewhere in $options already (note spaces at # each end implied by leading space in second argument). func_append_uniq () { $debug_cmd eval _G_current_value='`$ECHO $'$1'`' _G_delim=`expr "$2" : '\(.\)'` case $_G_delim$_G_current_value$_G_delim in *"$2$_G_delim"*) ;; *) func_append "$@" ;; esac } # func_arith TERM... # ------------------ # Set func_arith_result to the result of evaluating TERMs. test -z "$_G_HAVE_ARITH_OP" \ && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ && _G_HAVE_ARITH_OP=yes if test yes = "$_G_HAVE_ARITH_OP"; then eval 'func_arith () { $debug_cmd func_arith_result=$(( $* )) }' else func_arith () { $debug_cmd func_arith_result=`expr "$@"` } fi # func_basename FILE # ------------------ # Set func_basename_result to FILE with everything up to and including # the last / stripped. if test yes = "$_G_HAVE_XSI_OPS"; then # If this shell supports suffix pattern removal, then use it to avoid # forking. Hide the definitions single quotes in case the shell chokes # on unsupported syntax... _b='func_basename_result=${1##*/}' _d='case $1 in */*) func_dirname_result=${1%/*}$2 ;; * ) func_dirname_result=$3 ;; esac' else # ...otherwise fall back to using sed. _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` if test "X$func_dirname_result" = "X$1"; then func_dirname_result=$3 else func_append func_dirname_result "$2" fi' fi eval 'func_basename () { $debug_cmd '"$_b"' }' # func_dirname FILE APPEND NONDIR_REPLACEMENT # ------------------------------------------- # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. eval 'func_dirname () { $debug_cmd '"$_d"' }' # func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT # -------------------------------------------------------- # Perform func_basename and func_dirname in a single function # call: # dirname: Compute the dirname of FILE. If nonempty, # add APPEND to the result, otherwise set result # to NONDIR_REPLACEMENT. # value returned in "$func_dirname_result" # basename: Compute filename of FILE. # value retuned in "$func_basename_result" # For efficiency, we do not delegate to the functions above but instead # duplicate the functionality here. eval 'func_dirname_and_basename () { $debug_cmd '"$_b"' '"$_d"' }' # func_echo ARG... # ---------------- # Echo program name prefixed message. func_echo () { $debug_cmd _G_message=$* func_echo_IFS=$IFS IFS=$nl for _G_line in $_G_message; do IFS=$func_echo_IFS $ECHO "$progname: $_G_line" done IFS=$func_echo_IFS } # func_echo_all ARG... # -------------------- # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } # func_echo_infix_1 INFIX ARG... # ------------------------------ # Echo program name, followed by INFIX on the first line, with any # additional lines not showing INFIX. func_echo_infix_1 () { $debug_cmd $require_term_colors _G_infix=$1; shift _G_indent=$_G_infix _G_prefix="$progname: $_G_infix: " _G_message=$* # Strip color escape sequences before counting printable length for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" do test -n "$_G_tc" && { _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` } done _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes func_echo_infix_1_IFS=$IFS IFS=$nl for _G_line in $_G_message; do IFS=$func_echo_infix_1_IFS $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 _G_prefix=$_G_indent done IFS=$func_echo_infix_1_IFS } # func_error ARG... # ----------------- # Echo program name prefixed message to standard error. func_error () { $debug_cmd $require_term_colors func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 } # func_fatal_error ARG... # ----------------------- # Echo program name prefixed message to standard error, and exit. func_fatal_error () { $debug_cmd func_error "$*" exit $EXIT_FAILURE } # func_grep EXPRESSION FILENAME # ----------------------------- # Check whether EXPRESSION matches any line of FILENAME, without output. func_grep () { $debug_cmd $GREP "$1" "$2" >/dev/null 2>&1 } # func_len STRING # --------------- # Set func_len_result to the length of STRING. STRING may not # start with a hyphen. test -z "$_G_HAVE_XSI_OPS" \ && (eval 'x=a/b/c; test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ && _G_HAVE_XSI_OPS=yes if test yes = "$_G_HAVE_XSI_OPS"; then eval 'func_len () { $debug_cmd func_len_result=${#1} }' else func_len () { $debug_cmd func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` } fi # func_mkdir_p DIRECTORY-PATH # --------------------------- # Make sure the entire path to DIRECTORY-PATH is available. func_mkdir_p () { $debug_cmd _G_directory_path=$1 _G_dir_list= if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then # Protect directory names starting with '-' case $_G_directory_path in -*) _G_directory_path=./$_G_directory_path ;; esac # While some portion of DIR does not yet exist... while test ! -d "$_G_directory_path"; do # ...make a list in topmost first order. Use a colon delimited # list incase some portion of path contains whitespace. _G_dir_list=$_G_directory_path:$_G_dir_list # If the last portion added has no slash in it, the list is done case $_G_directory_path in */*) ;; *) break ;; esac # ...otherwise throw away the child directory and loop _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` done _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` func_mkdir_p_IFS=$IFS; IFS=: for _G_dir in $_G_dir_list; do IFS=$func_mkdir_p_IFS # mkdir can fail with a 'File exist' error if two processes # try to create one of the directories concurrently. Don't # stop in that case! $MKDIR "$_G_dir" 2>/dev/null || : done IFS=$func_mkdir_p_IFS # Bail out if we (or some other process) failed to create a directory. test -d "$_G_directory_path" || \ func_fatal_error "Failed to create '$1'" fi } # func_mktempdir [BASENAME] # ------------------------- # Make a temporary directory that won't clash with other running # libtool processes, and avoids race conditions if possible. If # given, BASENAME is the basename for that directory. func_mktempdir () { $debug_cmd _G_template=${TMPDIR-/tmp}/${1-$progname} if test : = "$opt_dry_run"; then # Return a directory name, but don't create it in dry-run mode _G_tmpdir=$_G_template-$$ else # If mktemp works, use that first and foremost _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` if test ! -d "$_G_tmpdir"; then # Failing that, at least try and use $RANDOM to avoid a race _G_tmpdir=$_G_template-${RANDOM-0}$$ func_mktempdir_umask=`umask` umask 0077 $MKDIR "$_G_tmpdir" umask $func_mktempdir_umask fi # If we're not in dry-run mode, bomb out on failure test -d "$_G_tmpdir" || \ func_fatal_error "cannot create temporary directory '$_G_tmpdir'" fi $ECHO "$_G_tmpdir" } # func_normal_abspath PATH # ------------------------ # Remove doubled-up and trailing slashes, "." path components, # and cancel out any ".." path components in PATH after making # it an absolute path. func_normal_abspath () { $debug_cmd # These SED scripts presuppose an absolute path with a trailing slash. _G_pathcar='s|^/\([^/]*\).*$|\1|' _G_pathcdr='s|^/[^/]*||' _G_removedotparts=':dotsl s|/\./|/|g t dotsl s|/\.$|/|' _G_collapseslashes='s|/\{1,\}|/|g' _G_finalslash='s|/*$|/|' # Start from root dir and reassemble the path. func_normal_abspath_result= func_normal_abspath_tpath=$1 func_normal_abspath_altnamespace= case $func_normal_abspath_tpath in "") # Empty path, that just means $cwd. func_stripname '' '/' "`pwd`" func_normal_abspath_result=$func_stripname_result return ;; # The next three entries are used to spot a run of precisely # two leading slashes without using negated character classes; # we take advantage of case's first-match behaviour. ///*) # Unusual form of absolute path, do nothing. ;; //*) # Not necessarily an ordinary path; POSIX reserves leading '//' # and for example Cygwin uses it to access remote file shares # over CIFS/SMB, so we conserve a leading double slash if found. func_normal_abspath_altnamespace=/ ;; /*) # Absolute path, do nothing. ;; *) # Relative path, prepend $cwd. func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath ;; esac # Cancel out all the simple stuff to save iterations. We also want # the path to end with a slash for ease of parsing, so make sure # there is one (and only one) here. func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` while :; do # Processed it all yet? if test / = "$func_normal_abspath_tpath"; then # If we ascended to the root using ".." the result may be empty now. if test -z "$func_normal_abspath_result"; then func_normal_abspath_result=/ fi break fi func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$_G_pathcar"` func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$_G_pathcdr"` # Figure out what to do with it case $func_normal_abspath_tcomponent in "") # Trailing empty path component, ignore it. ;; ..) # Parent dir; strip last assembled component from result. func_dirname "$func_normal_abspath_result" func_normal_abspath_result=$func_dirname_result ;; *) # Actual path component, append it. func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" ;; esac done # Restore leading double-slash if one was found on entry. func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result } # func_notquiet ARG... # -------------------- # Echo program name prefixed message only when not in quiet mode. func_notquiet () { $debug_cmd $opt_quiet || func_echo ${1+"$@"} # A bug in bash halts the script if the last line of a function # fails when set -e is in force, so we need another command to # work around that: : } # func_relative_path SRCDIR DSTDIR # -------------------------------- # Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. func_relative_path () { $debug_cmd func_relative_path_result= func_normal_abspath "$1" func_relative_path_tlibdir=$func_normal_abspath_result func_normal_abspath "$2" func_relative_path_tbindir=$func_normal_abspath_result # Ascend the tree starting from libdir while :; do # check if we have found a prefix of bindir case $func_relative_path_tbindir in $func_relative_path_tlibdir) # found an exact match func_relative_path_tcancelled= break ;; $func_relative_path_tlibdir*) # found a matching prefix func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" func_relative_path_tcancelled=$func_stripname_result if test -z "$func_relative_path_result"; then func_relative_path_result=. fi break ;; *) func_dirname $func_relative_path_tlibdir func_relative_path_tlibdir=$func_dirname_result if test -z "$func_relative_path_tlibdir"; then # Have to descend all the way to the root! func_relative_path_result=../$func_relative_path_result func_relative_path_tcancelled=$func_relative_path_tbindir break fi func_relative_path_result=../$func_relative_path_result ;; esac done # Now calculate path; take care to avoid doubling-up slashes. func_stripname '' '/' "$func_relative_path_result" func_relative_path_result=$func_stripname_result func_stripname '/' '/' "$func_relative_path_tcancelled" if test -n "$func_stripname_result"; then func_append func_relative_path_result "/$func_stripname_result" fi # Normalisation. If bindir is libdir, return '.' else relative path. if test -n "$func_relative_path_result"; then func_stripname './' '' "$func_relative_path_result" func_relative_path_result=$func_stripname_result fi test -n "$func_relative_path_result" || func_relative_path_result=. : } # func_quote_for_eval ARG... # -------------------------- # Aesthetically quote ARGs to be evaled later. # This function returns two values: # i) func_quote_for_eval_result # double-quoted, suitable for a subsequent eval # ii) func_quote_for_eval_unquoted_result # has all characters that are still active within double # quotes backslashified. func_quote_for_eval () { $debug_cmd func_quote_for_eval_unquoted_result= func_quote_for_eval_result= while test 0 -lt $#; do case $1 in *[\\\`\"\$]*) _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;; *) _G_unquoted_arg=$1 ;; esac if test -n "$func_quote_for_eval_unquoted_result"; then func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg" else func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg" fi case $_G_unquoted_arg in # Double-quote args containing shell metacharacters to delay # word splitting, command substitution and variable expansion # for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") _G_quoted_arg=\"$_G_unquoted_arg\" ;; *) _G_quoted_arg=$_G_unquoted_arg ;; esac if test -n "$func_quote_for_eval_result"; then func_append func_quote_for_eval_result " $_G_quoted_arg" else func_append func_quote_for_eval_result "$_G_quoted_arg" fi shift done } # func_quote_for_expand ARG # ------------------------- # Aesthetically quote ARG to be evaled later; same as above, # but do not quote variable references. func_quote_for_expand () { $debug_cmd case $1 in *[\\\`\"]*) _G_arg=`$ECHO "$1" | $SED \ -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;; *) _G_arg=$1 ;; esac case $_G_arg in # Double-quote args containing shell metacharacters to delay # word splitting and command substitution for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") _G_arg=\"$_G_arg\" ;; esac func_quote_for_expand_result=$_G_arg } # func_stripname PREFIX SUFFIX NAME # --------------------------------- # strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). if test yes = "$_G_HAVE_XSI_OPS"; then eval 'func_stripname () { $debug_cmd # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are # positional parameters, so assign one to ordinary variable first. func_stripname_result=$3 func_stripname_result=${func_stripname_result#"$1"} func_stripname_result=${func_stripname_result%"$2"} }' else func_stripname () { $debug_cmd case $2 in .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; esac } fi # func_show_eval CMD [FAIL_EXP] # ----------------------------- # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. func_show_eval () { $debug_cmd _G_cmd=$1 _G_fail_exp=${2-':'} func_quote_for_expand "$_G_cmd" eval "func_notquiet $func_quote_for_expand_result" $opt_dry_run || { eval "$_G_cmd" _G_status=$? if test 0 -ne "$_G_status"; then eval "(exit $_G_status); $_G_fail_exp" fi } } # func_show_eval_locale CMD [FAIL_EXP] # ------------------------------------ # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. Use the saved locale for evaluation. func_show_eval_locale () { $debug_cmd _G_cmd=$1 _G_fail_exp=${2-':'} $opt_quiet || { func_quote_for_expand "$_G_cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || { eval "$_G_user_locale $_G_cmd" _G_status=$? eval "$_G_safe_locale" if test 0 -ne "$_G_status"; then eval "(exit $_G_status); $_G_fail_exp" fi } } # func_tr_sh # ---------- # Turn $1 into a string suitable for a shell variable name. # Result is stored in $func_tr_sh_result. All characters # not in the set a-zA-Z0-9_ are replaced with '_'. Further, # if $1 begins with a digit, a '_' is prepended as well. func_tr_sh () { $debug_cmd case $1 in [0-9]* | *[!a-zA-Z0-9_]*) func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` ;; * ) func_tr_sh_result=$1 ;; esac } # func_verbose ARG... # ------------------- # Echo program name prefixed message in verbose mode only. func_verbose () { $debug_cmd $opt_verbose && func_echo "$*" : } # func_warn_and_continue ARG... # ----------------------------- # Echo program name prefixed warning message to standard error. func_warn_and_continue () { $debug_cmd $require_term_colors func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 } # func_warning CATEGORY ARG... # ---------------------------- # Echo program name prefixed warning message to standard error. Warning # messages can be filtered according to CATEGORY, where this function # elides messages where CATEGORY is not listed in the global variable # 'opt_warning_types'. func_warning () { $debug_cmd # CATEGORY must be in the warning_categories list! case " $warning_categories " in *" $1 "*) ;; *) func_internal_error "invalid warning category '$1'" ;; esac _G_category=$1 shift case " $opt_warning_types " in *" $_G_category "*) $warning_func ${1+"$@"} ;; esac } # func_sort_ver VER1 VER2 # ----------------------- # 'sort -V' is not generally available. # Note this deviates from the version comparison in automake # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a # but this should suffice as we won't be specifying old # version formats or redundant trailing .0 in bootstrap.conf. # If we did want full compatibility then we should probably # use m4_version_compare from autoconf. func_sort_ver () { $debug_cmd printf '%s\n%s\n' "$1" "$2" \ | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n -k 6,6n -k 7,7n -k 8,8n -k 9,9n } # func_lt_ver PREV CURR # --------------------- # Return true if PREV and CURR are in the correct order according to # func_sort_ver, otherwise false. Use it like this: # # func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." func_lt_ver () { $debug_cmd test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` } # Local variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" # time-stamp-time-zone: "UTC" # End: #! /bin/sh # Set a version string for this script. scriptversion=2014-01-07.03; # UTC # A portable, pluggable option parser for Bourne shell. # Written by Gary V. Vaughan, 2010 # Copyright (C) 2010-2015 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # 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 3 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, see . # Please report bugs or propose patches to gary@gnu.org. ## ------ ## ## Usage. ## ## ------ ## # This file is a library for parsing options in your shell scripts along # with assorted other useful supporting features that you can make use # of too. # # For the simplest scripts you might need only: # # #!/bin/sh # . relative/path/to/funclib.sh # . relative/path/to/options-parser # scriptversion=1.0 # func_options ${1+"$@"} # eval set dummy "$func_options_result"; shift # ...rest of your script... # # In order for the '--version' option to work, you will need to have a # suitably formatted comment like the one at the top of this file # starting with '# Written by ' and ending with '# warranty; '. # # For '-h' and '--help' to work, you will also need a one line # description of your script's purpose in a comment directly above the # '# Written by ' line, like the one at the top of this file. # # The default options also support '--debug', which will turn on shell # execution tracing (see the comment above debug_cmd below for another # use), and '--verbose' and the func_verbose function to allow your script # to display verbose messages only when your user has specified # '--verbose'. # # After sourcing this file, you can plug processing for additional # options by amending the variables from the 'Configuration' section # below, and following the instructions in the 'Option parsing' # section further down. ## -------------- ## ## Configuration. ## ## -------------- ## # You should override these variables in your script after sourcing this # file so that they reflect the customisations you have added to the # option parser. # The usage line for option parsing errors and the start of '-h' and # '--help' output messages. You can embed shell variables for delayed # expansion at the time the message is displayed, but you will need to # quote other shell meta-characters carefully to prevent them being # expanded when the contents are evaled. usage='$progpath [OPTION]...' # Short help message in response to '-h' and '--help'. Add to this or # override it after sourcing this library to reflect the full set of # options your script accepts. usage_message="\ --debug enable verbose shell tracing -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] -v, --verbose verbosely report processing --version print version information and exit -h, --help print short or long help message and exit " # Additional text appended to 'usage_message' in response to '--help'. long_help_message=" Warning categories include: 'all' show all warnings 'none' turn off all the warnings 'error' warnings are treated as fatal errors" # Help message printed before fatal option parsing errors. fatal_help="Try '\$progname --help' for more information." ## ------------------------- ## ## Hook function management. ## ## ------------------------- ## # This section contains functions for adding, removing, and running hooks # to the main code. A hook is just a named list of of function, that can # be run in order later on. # func_hookable FUNC_NAME # ----------------------- # Declare that FUNC_NAME will run hooks added with # 'func_add_hook FUNC_NAME ...'. func_hookable () { $debug_cmd func_append hookable_fns " $1" } # func_add_hook FUNC_NAME HOOK_FUNC # --------------------------------- # Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must # first have been declared "hookable" by a call to 'func_hookable'. func_add_hook () { $debug_cmd case " $hookable_fns " in *" $1 "*) ;; *) func_fatal_error "'$1' does not accept hook functions." ;; esac eval func_append ${1}_hooks '" $2"' } # func_remove_hook FUNC_NAME HOOK_FUNC # ------------------------------------ # Remove HOOK_FUNC from the list of functions called by FUNC_NAME. func_remove_hook () { $debug_cmd eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' } # func_run_hooks FUNC_NAME [ARG]... # --------------------------------- # Run all hook functions registered to FUNC_NAME. # It is assumed that the list of hook functions contains nothing more # than a whitespace-delimited list of legal shell function names, and # no effort is wasted trying to catch shell meta-characters or preserve # whitespace. func_run_hooks () { $debug_cmd case " $hookable_fns " in *" $1 "*) ;; *) func_fatal_error "'$1' does not support hook funcions.n" ;; esac eval _G_hook_fns=\$$1_hooks; shift for _G_hook in $_G_hook_fns; do eval $_G_hook '"$@"' # store returned options list back into positional # parameters for next 'cmd' execution. eval _G_hook_result=\$${_G_hook}_result eval set dummy "$_G_hook_result"; shift done func_quote_for_eval ${1+"$@"} func_run_hooks_result=$func_quote_for_eval_result } ## --------------- ## ## Option parsing. ## ## --------------- ## # In order to add your own option parsing hooks, you must accept the # full positional parameter list in your hook function, remove any # options that you action, and then pass back the remaining unprocessed # options in '_result', escaped suitably for # 'eval'. Like this: # # my_options_prep () # { # $debug_cmd # # # Extend the existing usage message. # usage_message=$usage_message' # -s, --silent don'\''t print informational messages # ' # # func_quote_for_eval ${1+"$@"} # my_options_prep_result=$func_quote_for_eval_result # } # func_add_hook func_options_prep my_options_prep # # # my_silent_option () # { # $debug_cmd # # # Note that for efficiency, we parse as many options as we can # # recognise in a loop before passing the remainder back to the # # caller on the first unrecognised argument we encounter. # while test $# -gt 0; do # opt=$1; shift # case $opt in # --silent|-s) opt_silent=: ;; # # Separate non-argument short options: # -s*) func_split_short_opt "$_G_opt" # set dummy "$func_split_short_opt_name" \ # "-$func_split_short_opt_arg" ${1+"$@"} # shift # ;; # *) set dummy "$_G_opt" "$*"; shift; break ;; # esac # done # # func_quote_for_eval ${1+"$@"} # my_silent_option_result=$func_quote_for_eval_result # } # func_add_hook func_parse_options my_silent_option # # # my_option_validation () # { # $debug_cmd # # $opt_silent && $opt_verbose && func_fatal_help "\ # '--silent' and '--verbose' options are mutually exclusive." # # func_quote_for_eval ${1+"$@"} # my_option_validation_result=$func_quote_for_eval_result # } # func_add_hook func_validate_options my_option_validation # # You'll alse need to manually amend $usage_message to reflect the extra # options you parse. It's preferable to append if you can, so that # multiple option parsing hooks can be added safely. # func_options [ARG]... # --------------------- # All the functions called inside func_options are hookable. See the # individual implementations for details. func_hookable func_options func_options () { $debug_cmd func_options_prep ${1+"$@"} eval func_parse_options \ ${func_options_prep_result+"$func_options_prep_result"} eval func_validate_options \ ${func_parse_options_result+"$func_parse_options_result"} eval func_run_hooks func_options \ ${func_validate_options_result+"$func_validate_options_result"} # save modified positional parameters for caller func_options_result=$func_run_hooks_result } # func_options_prep [ARG]... # -------------------------- # All initialisations required before starting the option parse loop. # Note that when calling hook functions, we pass through the list of # positional parameters. If a hook function modifies that list, and # needs to propogate that back to rest of this script, then the complete # modified list must be put in 'func_run_hooks_result' before # returning. func_hookable func_options_prep func_options_prep () { $debug_cmd # Option defaults: opt_verbose=false opt_warning_types= func_run_hooks func_options_prep ${1+"$@"} # save modified positional parameters for caller func_options_prep_result=$func_run_hooks_result } # func_parse_options [ARG]... # --------------------------- # The main option parsing loop. func_hookable func_parse_options func_parse_options () { $debug_cmd func_parse_options_result= # this just eases exit handling while test $# -gt 0; do # Defer to hook functions for initial option parsing, so they # get priority in the event of reusing an option name. func_run_hooks func_parse_options ${1+"$@"} # Adjust func_parse_options positional parameters to match eval set dummy "$func_run_hooks_result"; shift # Break out of the loop if we already parsed every option. test $# -gt 0 || break _G_opt=$1 shift case $_G_opt in --debug|-x) debug_cmd='set -x' func_echo "enabling shell trace mode" $debug_cmd ;; --no-warnings|--no-warning|--no-warn) set dummy --warnings none ${1+"$@"} shift ;; --warnings|--warning|-W) test $# = 0 && func_missing_arg $_G_opt && break case " $warning_categories $1" in *" $1 "*) # trailing space prevents matching last $1 above func_append_uniq opt_warning_types " $1" ;; *all) opt_warning_types=$warning_categories ;; *none) opt_warning_types=none warning_func=: ;; *error) opt_warning_types=$warning_categories warning_func=func_fatal_error ;; *) func_fatal_error \ "unsupported warning category: '$1'" ;; esac shift ;; --verbose|-v) opt_verbose=: ;; --version) func_version ;; -\?|-h) func_usage ;; --help) func_help ;; # Separate optargs to long options (plugins may need this): --*=*) func_split_equals "$_G_opt" set dummy "$func_split_equals_lhs" \ "$func_split_equals_rhs" ${1+"$@"} shift ;; # Separate optargs to short options: -W*) func_split_short_opt "$_G_opt" set dummy "$func_split_short_opt_name" \ "$func_split_short_opt_arg" ${1+"$@"} shift ;; # Separate non-argument short options: -\?*|-h*|-v*|-x*) func_split_short_opt "$_G_opt" set dummy "$func_split_short_opt_name" \ "-$func_split_short_opt_arg" ${1+"$@"} shift ;; --) break ;; -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; esac done # save modified positional parameters for caller func_quote_for_eval ${1+"$@"} func_parse_options_result=$func_quote_for_eval_result } # func_validate_options [ARG]... # ------------------------------ # Perform any sanity checks on option settings and/or unconsumed # arguments. func_hookable func_validate_options func_validate_options () { $debug_cmd # Display all warnings if -W was not given. test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" func_run_hooks func_validate_options ${1+"$@"} # Bail if the options were screwed! $exit_cmd $EXIT_FAILURE # save modified positional parameters for caller func_validate_options_result=$func_run_hooks_result } ## ----------------- ## ## Helper functions. ## ## ----------------- ## # This section contains the helper functions used by the rest of the # hookable option parser framework in ascii-betical order. # func_fatal_help ARG... # ---------------------- # Echo program name prefixed message to standard error, followed by # a help hint, and exit. func_fatal_help () { $debug_cmd eval \$ECHO \""Usage: $usage"\" eval \$ECHO \""$fatal_help"\" func_error ${1+"$@"} exit $EXIT_FAILURE } # func_help # --------- # Echo long help message to standard output and exit. func_help () { $debug_cmd func_usage_message $ECHO "$long_help_message" exit 0 } # func_missing_arg ARGNAME # ------------------------ # Echo program name prefixed message to standard error and set global # exit_cmd. func_missing_arg () { $debug_cmd func_error "Missing argument for '$1'." exit_cmd=exit } # func_split_equals STRING # ------------------------ # Set func_split_equals_lhs and func_split_equals_rhs shell variables after # splitting STRING at the '=' sign. test -z "$_G_HAVE_XSI_OPS" \ && (eval 'x=a/b/c; test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ && _G_HAVE_XSI_OPS=yes if test yes = "$_G_HAVE_XSI_OPS" then # This is an XSI compatible shell, allowing a faster implementation... eval 'func_split_equals () { $debug_cmd func_split_equals_lhs=${1%%=*} func_split_equals_rhs=${1#*=} test "x$func_split_equals_lhs" = "x$1" \ && func_split_equals_rhs= }' else # ...otherwise fall back to using expr, which is often a shell builtin. func_split_equals () { $debug_cmd func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` func_split_equals_rhs= test "x$func_split_equals_lhs" = "x$1" \ || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` } fi #func_split_equals # func_split_short_opt SHORTOPT # ----------------------------- # Set func_split_short_opt_name and func_split_short_opt_arg shell # variables after splitting SHORTOPT after the 2nd character. if test yes = "$_G_HAVE_XSI_OPS" then # This is an XSI compatible shell, allowing a faster implementation... eval 'func_split_short_opt () { $debug_cmd func_split_short_opt_arg=${1#??} func_split_short_opt_name=${1%"$func_split_short_opt_arg"} }' else # ...otherwise fall back to using expr, which is often a shell builtin. func_split_short_opt () { $debug_cmd func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'` func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` } fi #func_split_short_opt # func_usage # ---------- # Echo short help message to standard output and exit. func_usage () { $debug_cmd func_usage_message $ECHO "Run '$progname --help |${PAGER-more}' for full usage" exit 0 } # func_usage_message # ------------------ # Echo short help message to standard output. func_usage_message () { $debug_cmd eval \$ECHO \""Usage: $usage"\" echo $SED -n 's|^# || /^Written by/{ x;p;x } h /^Written by/q' < "$progpath" echo eval \$ECHO \""$usage_message"\" } # func_version # ------------ # Echo version message to standard output and exit. func_version () { $debug_cmd printf '%s\n' "$progname $scriptversion" $SED -n ' /(C)/!b go :more /\./!{ N s|\n# | | b more } :go /^# Written by /,/# warranty; / { s|^# || s|^# *$|| s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| p } /^# Written by / { s|^# || p } /^warranty; /q' < "$progpath" exit $? } # Local variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" # time-stamp-time-zone: "UTC" # End: # Set a version string. scriptversion='(GNU libtool) 2.4.6' # func_echo ARG... # ---------------- # Libtool also displays the current mode in messages, so override # funclib.sh func_echo with this custom definition. func_echo () { $debug_cmd _G_message=$* func_echo_IFS=$IFS IFS=$nl for _G_line in $_G_message; do IFS=$func_echo_IFS $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" done IFS=$func_echo_IFS } # func_warning ARG... # ------------------- # Libtool warnings are not categorized, so override funclib.sh # func_warning with this simpler definition. func_warning () { $debug_cmd $warning_func ${1+"$@"} } ## ---------------- ## ## Options parsing. ## ## ---------------- ## # Hook in the functions to make sure our own options are parsed during # the option parsing loop. usage='$progpath [OPTION]... [MODE-ARG]...' # Short help message in response to '-h'. usage_message="Options: --config show all configuration variables --debug enable verbose shell tracing -n, --dry-run display commands without modifying any files --features display basic configuration information and exit --mode=MODE use operation mode MODE --no-warnings equivalent to '-Wnone' --preserve-dup-deps don't remove duplicate dependency libraries --quiet, --silent don't print informational messages --tag=TAG use configuration variables from tag TAG -v, --verbose print more informational messages than default --version print version information -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] -h, --help, --help-all print short, long, or detailed help message " # Additional text appended to 'usage_message' in response to '--help'. func_help () { $debug_cmd func_usage_message $ECHO "$long_help_message MODE must be one of the following: clean remove files from the build directory compile compile a source file into a libtool object execute automatically set library path, then run a program finish complete the installation of libtool libraries install install libraries or executables link create a library or an executable uninstall remove libraries from an installed directory MODE-ARGS vary depending on the MODE. When passed as first option, '--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. Try '$progname --help --mode=MODE' for a more detailed description of MODE. When reporting a bug, please describe a test case to reproduce it and include the following information: host-triplet: $host shell: $SHELL compiler: $LTCC compiler flags: $LTCFLAGS linker: $LD (gnu? $with_gnu_ld) version: $progname (GNU libtool) 2.4.6 automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` Report bugs to . GNU libtool home page: . General help using GNU software: ." exit 0 } # func_lo2o OBJECT-NAME # --------------------- # Transform OBJECT-NAME from a '.lo' suffix to the platform specific # object suffix. lo2o=s/\\.lo\$/.$objext/ o2lo=s/\\.$objext\$/.lo/ if test yes = "$_G_HAVE_XSI_OPS"; then eval 'func_lo2o () { case $1 in *.lo) func_lo2o_result=${1%.lo}.$objext ;; * ) func_lo2o_result=$1 ;; esac }' # func_xform LIBOBJ-OR-SOURCE # --------------------------- # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) # suffix to a '.lo' libtool-object suffix. eval 'func_xform () { func_xform_result=${1%.*}.lo }' else # ...otherwise fall back to using sed. func_lo2o () { func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` } func_xform () { func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` } fi # func_fatal_configuration ARG... # ------------------------------- # Echo program name prefixed message to standard error, followed by # a configuration failure hint, and exit. func_fatal_configuration () { func__fatal_error ${1+"$@"} \ "See the $PACKAGE documentation for more information." \ "Fatal configuration error." } # func_config # ----------- # Display the configuration for all the tags in this script. func_config () { re_begincf='^# ### BEGIN LIBTOOL' re_endcf='^# ### END LIBTOOL' # Default configuration. $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" # Now print the configurations for the tags. for tagname in $taglist; do $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" done exit $? } # func_features # ------------- # Display the features supported by this script. func_features () { echo "host: $host" if test yes = "$build_libtool_libs"; then echo "enable shared libraries" else echo "disable shared libraries" fi if test yes = "$build_old_libs"; then echo "enable static libraries" else echo "disable static libraries" fi exit $? } # func_enable_tag TAGNAME # ----------------------- # Verify that TAGNAME is valid, and either flag an error and exit, or # enable the TAGNAME tag. We also add TAGNAME to the global $taglist # variable here. func_enable_tag () { # Global variable: tagname=$1 re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" sed_extractcf=/$re_begincf/,/$re_endcf/p # Validate tagname. case $tagname in *[!-_A-Za-z0-9,/]*) func_fatal_error "invalid tag name: $tagname" ;; esac # Don't test for the "default" C tag, as we know it's # there but not specially marked. case $tagname in CC) ;; *) if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then taglist="$taglist $tagname" # Evaluate the configuration. Be careful to quote the path # and the sed script, to avoid splitting on whitespace, but # also don't use non-portable quotes within backquotes within # quotes we have to do it in 2 steps: extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` eval "$extractedcf" else func_error "ignoring unknown tag $tagname" fi ;; esac } # func_check_version_match # ------------------------ # Ensure that we are using m4 macros, and libtool script from the same # release of libtool. func_check_version_match () { if test "$package_revision" != "$macro_revision"; then if test "$VERSION" != "$macro_version"; then if test -z "$macro_version"; then cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from an older release. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from $PACKAGE $macro_version. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF fi else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, $progname: but the definition of this LT_INIT comes from revision $macro_revision. $progname: You should recreate aclocal.m4 with macros from revision $package_revision $progname: of $PACKAGE $VERSION and run autoconf again. _LT_EOF fi exit $EXIT_MISMATCH fi } # libtool_options_prep [ARG]... # ----------------------------- # Preparation for options parsed by libtool. libtool_options_prep () { $debug_mode # Option defaults: opt_config=false opt_dlopen= opt_dry_run=false opt_help=false opt_mode= opt_preserve_dup_deps=false opt_quiet=false nonopt= preserve_args= # Shorthand for --mode=foo, only valid as the first argument case $1 in clean|clea|cle|cl) shift; set dummy --mode clean ${1+"$@"}; shift ;; compile|compil|compi|comp|com|co|c) shift; set dummy --mode compile ${1+"$@"}; shift ;; execute|execut|execu|exec|exe|ex|e) shift; set dummy --mode execute ${1+"$@"}; shift ;; finish|finis|fini|fin|fi|f) shift; set dummy --mode finish ${1+"$@"}; shift ;; install|instal|insta|inst|ins|in|i) shift; set dummy --mode install ${1+"$@"}; shift ;; link|lin|li|l) shift; set dummy --mode link ${1+"$@"}; shift ;; uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) shift; set dummy --mode uninstall ${1+"$@"}; shift ;; esac # Pass back the list of options. func_quote_for_eval ${1+"$@"} libtool_options_prep_result=$func_quote_for_eval_result } func_add_hook func_options_prep libtool_options_prep # libtool_parse_options [ARG]... # --------------------------------- # Provide handling for libtool specific options. libtool_parse_options () { $debug_cmd # Perform our own loop to consume as many options as possible in # each iteration. while test $# -gt 0; do _G_opt=$1 shift case $_G_opt in --dry-run|--dryrun|-n) opt_dry_run=: ;; --config) func_config ;; --dlopen|-dlopen) opt_dlopen="${opt_dlopen+$opt_dlopen }$1" shift ;; --preserve-dup-deps) opt_preserve_dup_deps=: ;; --features) func_features ;; --finish) set dummy --mode finish ${1+"$@"}; shift ;; --help) opt_help=: ;; --help-all) opt_help=': help-all' ;; --mode) test $# = 0 && func_missing_arg $_G_opt && break opt_mode=$1 case $1 in # Valid mode arguments: clean|compile|execute|finish|install|link|relink|uninstall) ;; # Catch anything else as an error *) func_error "invalid argument for $_G_opt" exit_cmd=exit break ;; esac shift ;; --no-silent|--no-quiet) opt_quiet=false func_append preserve_args " $_G_opt" ;; --no-warnings|--no-warning|--no-warn) opt_warning=false func_append preserve_args " $_G_opt" ;; --no-verbose) opt_verbose=false func_append preserve_args " $_G_opt" ;; --silent|--quiet) opt_quiet=: opt_verbose=false func_append preserve_args " $_G_opt" ;; --tag) test $# = 0 && func_missing_arg $_G_opt && break opt_tag=$1 func_append preserve_args " $_G_opt $1" func_enable_tag "$1" shift ;; --verbose|-v) opt_quiet=false opt_verbose=: func_append preserve_args " $_G_opt" ;; # An option not handled by this hook function: *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; esac done # save modified positional parameters for caller func_quote_for_eval ${1+"$@"} libtool_parse_options_result=$func_quote_for_eval_result } func_add_hook func_parse_options libtool_parse_options # libtool_validate_options [ARG]... # --------------------------------- # Perform any sanity checks on option settings and/or unconsumed # arguments. libtool_validate_options () { # save first non-option argument if test 0 -lt $#; then nonopt=$1 shift fi # preserve --debug test : = "$debug_cmd" || func_append preserve_args " --debug" case $host in # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) # don't eliminate duplications in $postdeps and $predeps opt_duplicate_compiler_generated_deps=: ;; *) opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps ;; esac $opt_help || { # Sanity checks first: func_check_version_match test yes != "$build_libtool_libs" \ && test yes != "$build_old_libs" \ && func_fatal_configuration "not configured to build any kind of library" # Darwin sucks eval std_shrext=\"$shrext_cmds\" # Only execute mode is allowed to have -dlopen flags. if test -n "$opt_dlopen" && test execute != "$opt_mode"; then func_error "unrecognized option '-dlopen'" $ECHO "$help" 1>&2 exit $EXIT_FAILURE fi # Change the help message to a mode-specific one. generic_help=$help help="Try '$progname --help --mode=$opt_mode' for more information." } # Pass back the unparsed argument list func_quote_for_eval ${1+"$@"} libtool_validate_options_result=$func_quote_for_eval_result } func_add_hook func_validate_options libtool_validate_options # Process options as early as possible so that --help and --version # can return quickly. func_options ${1+"$@"} eval set dummy "$func_options_result"; shift ## ----------- ## ## Main. ## ## ----------- ## magic='%%%MAGIC variable%%%' magic_exe='%%%MAGIC EXE variable%%%' # Global variables. extracted_archives= extracted_serial=0 # If this variable is set in any of the actions, the command in it # will be execed at the end. This prevents here-documents from being # left over by shells. exec_cmd= # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } # func_generated_by_libtool # True iff stdin has been generated by Libtool. This function is only # a basic sanity check; it will hardly flush out determined imposters. func_generated_by_libtool_p () { $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 } # func_lalib_p file # True iff FILE is a libtool '.la' library or '.lo' object file. # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_lalib_p () { test -f "$1" && $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p } # func_lalib_unsafe_p file # True iff FILE is a libtool '.la' library or '.lo' object file. # This function implements the same check as func_lalib_p without # resorting to external programs. To this end, it redirects stdin and # closes it afterwards, without saving the original file descriptor. # As a safety measure, use it only where a negative result would be # fatal anyway. Works if 'file' does not exist. func_lalib_unsafe_p () { lalib_p=no if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then for lalib_p_l in 1 2 3 4 do read lalib_p_line case $lalib_p_line in \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; esac done exec 0<&5 5<&- fi test yes = "$lalib_p" } # func_ltwrapper_script_p file # True iff FILE is a libtool wrapper script # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_script_p () { test -f "$1" && $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p } # func_ltwrapper_executable_p file # True iff FILE is a libtool wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_executable_p () { func_ltwrapper_exec_suffix= case $1 in *.exe) ;; *) func_ltwrapper_exec_suffix=.exe ;; esac $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 } # func_ltwrapper_scriptname file # Assumes file is an ltwrapper_executable # uses $file to determine the appropriate filename for a # temporary ltwrapper_script. func_ltwrapper_scriptname () { func_dirname_and_basename "$1" "" "." func_stripname '' '.exe' "$func_basename_result" func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper } # func_ltwrapper_p file # True iff FILE is a libtool wrapper script or wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_p () { func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" } # func_execute_cmds commands fail_cmd # Execute tilde-delimited COMMANDS. # If FAIL_CMD is given, eval that upon failure. # FAIL_CMD may read-access the current command in variable CMD! func_execute_cmds () { $debug_cmd save_ifs=$IFS; IFS='~' for cmd in $1; do IFS=$sp$nl eval cmd=\"$cmd\" IFS=$save_ifs func_show_eval "$cmd" "${2-:}" done IFS=$save_ifs } # func_source file # Source FILE, adding directory component if necessary. # Note that it is not necessary on cygwin/mingw to append a dot to # FILE even if both FILE and FILE.exe exist: automatic-append-.exe # behavior happens only for exec(3), not for open(2)! Also, sourcing # 'FILE.' does not work on cygwin managed mounts. func_source () { $debug_cmd case $1 in */* | *\\*) . "$1" ;; *) . "./$1" ;; esac } # func_resolve_sysroot PATH # Replace a leading = in PATH with a sysroot. Store the result into # func_resolve_sysroot_result func_resolve_sysroot () { func_resolve_sysroot_result=$1 case $func_resolve_sysroot_result in =*) func_stripname '=' '' "$func_resolve_sysroot_result" func_resolve_sysroot_result=$lt_sysroot$func_stripname_result ;; esac } # func_replace_sysroot PATH # If PATH begins with the sysroot, replace it with = and # store the result into func_replace_sysroot_result. func_replace_sysroot () { case $lt_sysroot:$1 in ?*:"$lt_sysroot"*) func_stripname "$lt_sysroot" '' "$1" func_replace_sysroot_result='='$func_stripname_result ;; *) # Including no sysroot. func_replace_sysroot_result=$1 ;; esac } # func_infer_tag arg # Infer tagged configuration to use if any are available and # if one wasn't chosen via the "--tag" command line option. # Only attempt this if the compiler in the base compile # command doesn't match the default compiler. # arg is usually of the form 'gcc ...' func_infer_tag () { $debug_cmd if test -n "$available_tags" && test -z "$tagname"; then CC_quoted= for arg in $CC; do func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case $@ in # Blanks in the command may have been stripped by the calling shell, # but not from the CC environment variable when configure was run. " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; # Blanks at the start of $base_compile will cause this to fail # if we don't check for them as well. *) for z in $available_tags; do if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then # Evaluate the configuration. eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" CC_quoted= for arg in $CC; do # Double-quote args containing other shell metacharacters. func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case "$@ " in " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) # The compiler in the base compile command matches # the one in the tagged configuration. # Assume this is the tagged configuration we want. tagname=$z break ;; esac fi done # If $tagname still isn't set, then no tagged configuration # was found and let the user know that the "--tag" command # line option must be used. if test -z "$tagname"; then func_echo "unable to infer tagged configuration" func_fatal_error "specify a tag with '--tag'" # else # func_verbose "using $tagname tagged configuration" fi ;; esac fi } # func_write_libtool_object output_name pic_name nonpic_name # Create a libtool object file (analogous to a ".la" file), # but don't create it if we're doing a dry run. func_write_libtool_object () { write_libobj=$1 if test yes = "$build_libtool_libs"; then write_lobj=\'$2\' else write_lobj=none fi if test yes = "$build_old_libs"; then write_oldobj=\'$3\' else write_oldobj=none fi $opt_dry_run || { cat >${write_libobj}T </dev/null` if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | $SED -e "$sed_naive_backslashify"` else func_convert_core_file_wine_to_w32_result= fi fi } # end: func_convert_core_file_wine_to_w32 # func_convert_core_path_wine_to_w32 ARG # Helper function used by path conversion functions when $build is *nix, and # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly # configured wine environment available, with the winepath program in $build's # $PATH. Assumes ARG has no leading or trailing path separator characters. # # ARG is path to be converted from $build format to win32. # Result is available in $func_convert_core_path_wine_to_w32_result. # Unconvertible file (directory) names in ARG are skipped; if no directory names # are convertible, then the result may be empty. func_convert_core_path_wine_to_w32 () { $debug_cmd # unfortunately, winepath doesn't convert paths, only file names func_convert_core_path_wine_to_w32_result= if test -n "$1"; then oldIFS=$IFS IFS=: for func_convert_core_path_wine_to_w32_f in $1; do IFS=$oldIFS func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" if test -n "$func_convert_core_file_wine_to_w32_result"; then if test -z "$func_convert_core_path_wine_to_w32_result"; then func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result else func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" fi fi done IFS=$oldIFS fi } # end: func_convert_core_path_wine_to_w32 # func_cygpath ARGS... # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or # (2), returns the Cygwin file name or path in func_cygpath_result (input # file name or path is assumed to be in w32 format, as previously converted # from $build's *nix or MSYS format). In case (3), returns the w32 file name # or path in func_cygpath_result (input file name or path is assumed to be in # Cygwin format). Returns an empty string on error. # # ARGS are passed to cygpath, with the last one being the file name or path to # be converted. # # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH # environment variable; do not put it in $PATH. func_cygpath () { $debug_cmd if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` if test "$?" -ne 0; then # on failure, ensure result is empty func_cygpath_result= fi else func_cygpath_result= func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" fi } #end: func_cygpath # func_convert_core_msys_to_w32 ARG # Convert file name or path ARG from MSYS format to w32 format. Return # result in func_convert_core_msys_to_w32_result. func_convert_core_msys_to_w32 () { $debug_cmd # awkward: cmd appends spaces to result func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` } #end: func_convert_core_msys_to_w32 # func_convert_file_check ARG1 ARG2 # Verify that ARG1 (a file name in $build format) was converted to $host # format in ARG2. Otherwise, emit an error message, but continue (resetting # func_to_host_file_result to ARG1). func_convert_file_check () { $debug_cmd if test -z "$2" && test -n "$1"; then func_error "Could not determine host file name corresponding to" func_error " '$1'" func_error "Continuing, but uninstalled executables may not work." # Fallback: func_to_host_file_result=$1 fi } # end func_convert_file_check # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH # Verify that FROM_PATH (a path in $build format) was converted to $host # format in TO_PATH. Otherwise, emit an error message, but continue, resetting # func_to_host_file_result to a simplistic fallback value (see below). func_convert_path_check () { $debug_cmd if test -z "$4" && test -n "$3"; then func_error "Could not determine the host path corresponding to" func_error " '$3'" func_error "Continuing, but uninstalled executables may not work." # Fallback. This is a deliberately simplistic "conversion" and # should not be "improved". See libtool.info. if test "x$1" != "x$2"; then lt_replace_pathsep_chars="s|$1|$2|g" func_to_host_path_result=`echo "$3" | $SED -e "$lt_replace_pathsep_chars"` else func_to_host_path_result=$3 fi fi } # end func_convert_path_check # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT # and appending REPL if ORIG matches BACKPAT. func_convert_path_front_back_pathsep () { $debug_cmd case $4 in $1 ) func_to_host_path_result=$3$func_to_host_path_result ;; esac case $4 in $2 ) func_append func_to_host_path_result "$3" ;; esac } # end func_convert_path_front_back_pathsep ################################################## # $build to $host FILE NAME CONVERSION FUNCTIONS # ################################################## # invoked via '$to_host_file_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # Result will be available in $func_to_host_file_result. # func_to_host_file ARG # Converts the file name ARG from $build format to $host format. Return result # in func_to_host_file_result. func_to_host_file () { $debug_cmd $to_host_file_cmd "$1" } # end func_to_host_file # func_to_tool_file ARG LAZY # converts the file name ARG from $build format to toolchain format. Return # result in func_to_tool_file_result. If the conversion in use is listed # in (the comma separated) LAZY, no conversion takes place. func_to_tool_file () { $debug_cmd case ,$2, in *,"$to_tool_file_cmd",*) func_to_tool_file_result=$1 ;; *) $to_tool_file_cmd "$1" func_to_tool_file_result=$func_to_host_file_result ;; esac } # end func_to_tool_file # func_convert_file_noop ARG # Copy ARG to func_to_host_file_result. func_convert_file_noop () { func_to_host_file_result=$1 } # end func_convert_file_noop # func_convert_file_msys_to_w32 ARG # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_file_result. func_convert_file_msys_to_w32 () { $debug_cmd func_to_host_file_result=$1 if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_to_host_file_result=$func_convert_core_msys_to_w32_result fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_w32 # func_convert_file_cygwin_to_w32 ARG # Convert file name ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_file_cygwin_to_w32 () { $debug_cmd func_to_host_file_result=$1 if test -n "$1"; then # because $build is cygwin, we call "the" cygpath in $PATH; no need to use # LT_CYGPATH in this case. func_to_host_file_result=`cygpath -m "$1"` fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_cygwin_to_w32 # func_convert_file_nix_to_w32 ARG # Convert file name ARG from *nix to w32 format. Requires a wine environment # and a working winepath. Returns result in func_to_host_file_result. func_convert_file_nix_to_w32 () { $debug_cmd func_to_host_file_result=$1 if test -n "$1"; then func_convert_core_file_wine_to_w32 "$1" func_to_host_file_result=$func_convert_core_file_wine_to_w32_result fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_w32 # func_convert_file_msys_to_cygwin ARG # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_file_msys_to_cygwin () { $debug_cmd func_to_host_file_result=$1 if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_cygpath -u "$func_convert_core_msys_to_w32_result" func_to_host_file_result=$func_cygpath_result fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_cygwin # func_convert_file_nix_to_cygwin ARG # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed # in a wine environment, working winepath, and LT_CYGPATH set. Returns result # in func_to_host_file_result. func_convert_file_nix_to_cygwin () { $debug_cmd func_to_host_file_result=$1 if test -n "$1"; then # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. func_convert_core_file_wine_to_w32 "$1" func_cygpath -u "$func_convert_core_file_wine_to_w32_result" func_to_host_file_result=$func_cygpath_result fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_cygwin ############################################# # $build to $host PATH CONVERSION FUNCTIONS # ############################################# # invoked via '$to_host_path_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # The result will be available in $func_to_host_path_result. # # Path separators are also converted from $build format to $host format. If # ARG begins or ends with a path separator character, it is preserved (but # converted to $host format) on output. # # All path conversion functions are named using the following convention: # file name conversion function : func_convert_file_X_to_Y () # path conversion function : func_convert_path_X_to_Y () # where, for any given $build/$host combination the 'X_to_Y' value is the # same. If conversion functions are added for new $build/$host combinations, # the two new functions must follow this pattern, or func_init_to_host_path_cmd # will break. # func_init_to_host_path_cmd # Ensures that function "pointer" variable $to_host_path_cmd is set to the # appropriate value, based on the value of $to_host_file_cmd. to_host_path_cmd= func_init_to_host_path_cmd () { $debug_cmd if test -z "$to_host_path_cmd"; then func_stripname 'func_convert_file_' '' "$to_host_file_cmd" to_host_path_cmd=func_convert_path_$func_stripname_result fi } # func_to_host_path ARG # Converts the path ARG from $build format to $host format. Return result # in func_to_host_path_result. func_to_host_path () { $debug_cmd func_init_to_host_path_cmd $to_host_path_cmd "$1" } # end func_to_host_path # func_convert_path_noop ARG # Copy ARG to func_to_host_path_result. func_convert_path_noop () { func_to_host_path_result=$1 } # end func_convert_path_noop # func_convert_path_msys_to_w32 ARG # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_path_result. func_convert_path_msys_to_w32 () { $debug_cmd func_to_host_path_result=$1 if test -n "$1"; then # Remove leading and trailing path separator characters from ARG. MSYS # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; # and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result=$func_convert_core_msys_to_w32_result func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_msys_to_w32 # func_convert_path_cygwin_to_w32 ARG # Convert path ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_path_cygwin_to_w32 () { $debug_cmd func_to_host_path_result=$1 if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_cygwin_to_w32 # func_convert_path_nix_to_w32 ARG # Convert path ARG from *nix to w32 format. Requires a wine environment and # a working winepath. Returns result in func_to_host_file_result. func_convert_path_nix_to_w32 () { $debug_cmd func_to_host_path_result=$1 if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result=$func_convert_core_path_wine_to_w32_result func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_nix_to_w32 # func_convert_path_msys_to_cygwin ARG # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_path_msys_to_cygwin () { $debug_cmd func_to_host_path_result=$1 if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_msys_to_w32_result" func_to_host_path_result=$func_cygpath_result func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_msys_to_cygwin # func_convert_path_nix_to_cygwin ARG # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a # a wine environment, working winepath, and LT_CYGPATH set. Returns result in # func_to_host_file_result. func_convert_path_nix_to_cygwin () { $debug_cmd func_to_host_path_result=$1 if test -n "$1"; then # Remove leading and trailing path separator characters from # ARG. msys behavior is inconsistent here, cygpath turns them # into '.;' and ';.', and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" func_to_host_path_result=$func_cygpath_result func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_nix_to_cygwin # func_dll_def_p FILE # True iff FILE is a Windows DLL '.def' file. # Keep in sync with _LT_DLL_DEF_P in libtool.m4 func_dll_def_p () { $debug_cmd func_dll_def_p_tmp=`$SED -n \ -e 's/^[ ]*//' \ -e '/^\(;.*\)*$/d' \ -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ -e q \ "$1"` test DEF = "$func_dll_def_p_tmp" } # func_mode_compile arg... func_mode_compile () { $debug_cmd # Get the compilation command and the source file. base_compile= srcfile=$nonopt # always keep a non-empty value in "srcfile" suppress_opt=yes suppress_output= arg_mode=normal libobj= later= pie_flag= for arg do case $arg_mode in arg ) # do not "continue". Instead, add this to base_compile lastarg=$arg arg_mode=normal ;; target ) libobj=$arg arg_mode=normal continue ;; normal ) # Accept any command-line options. case $arg in -o) test -n "$libobj" && \ func_fatal_error "you cannot specify '-o' more than once" arg_mode=target continue ;; -pie | -fpie | -fPIE) func_append pie_flag " $arg" continue ;; -shared | -static | -prefer-pic | -prefer-non-pic) func_append later " $arg" continue ;; -no-suppress) suppress_opt=no continue ;; -Xcompiler) arg_mode=arg # the next one goes into the "base_compile" arg list continue # The current "srcfile" will either be retained or ;; # replaced later. I would guess that would be a bug. -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result lastarg= save_ifs=$IFS; IFS=, for arg in $args; do IFS=$save_ifs func_append_quoted lastarg "$arg" done IFS=$save_ifs func_stripname ' ' '' "$lastarg" lastarg=$func_stripname_result # Add the arguments to base_compile. func_append base_compile " $lastarg" continue ;; *) # Accept the current argument as the source file. # The previous "srcfile" becomes the current argument. # lastarg=$srcfile srcfile=$arg ;; esac # case $arg ;; esac # case $arg_mode # Aesthetically quote the previous argument. func_append_quoted base_compile "$lastarg" done # for arg case $arg_mode in arg) func_fatal_error "you must specify an argument for -Xcompile" ;; target) func_fatal_error "you must specify a target with '-o'" ;; *) # Get the name of the library object. test -z "$libobj" && { func_basename "$srcfile" libobj=$func_basename_result } ;; esac # Recognize several different file suffixes. # If the user specifies -o file.o, it is replaced with file.lo case $libobj in *.[cCFSifmso] | \ *.ada | *.adb | *.ads | *.asm | \ *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) func_xform "$libobj" libobj=$func_xform_result ;; esac case $libobj in *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; *) func_fatal_error "cannot determine name of library object from '$libobj'" ;; esac func_infer_tag $base_compile for arg in $later; do case $arg in -shared) test yes = "$build_libtool_libs" \ || func_fatal_configuration "cannot build a shared library" build_old_libs=no continue ;; -static) build_libtool_libs=no build_old_libs=yes continue ;; -prefer-pic) pic_mode=yes continue ;; -prefer-non-pic) pic_mode=no continue ;; esac done func_quote_for_eval "$libobj" test "X$libobj" != "X$func_quote_for_eval_result" \ && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ && func_warning "libobj name '$libobj' may not contain shell special characters." func_dirname_and_basename "$obj" "/" "" objname=$func_basename_result xdir=$func_dirname_result lobj=$xdir$objdir/$objname test -z "$base_compile" && \ func_fatal_help "you must specify a compilation command" # Delete any leftover library objects. if test yes = "$build_old_libs"; then removelist="$obj $lobj $libobj ${libobj}T" else removelist="$lobj $libobj ${libobj}T" fi # On Cygwin there's no "real" PIC flag so we must build both object types case $host_os in cygwin* | mingw* | pw32* | os2* | cegcc*) pic_mode=default ;; esac if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then # non-PIC code in shared libraries is not supported pic_mode=default fi # Calculate the filename of the output object if compiler does # not support -o with -c if test no = "$compiler_c_o"; then output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext lockfile=$output_obj.lock else output_obj= need_locks=no lockfile= fi # Lock this critical section if it is needed # We use this script file to make the link, it avoids creating a new file if test yes = "$need_locks"; then until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done elif test warn = "$need_locks"; then if test -f "$lockfile"; then $ECHO "\ *** ERROR, $lockfile exists and contains: `cat $lockfile 2>/dev/null` This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support '-c' and '-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi func_append removelist " $output_obj" $ECHO "$srcfile" > "$lockfile" fi $opt_dry_run || $RM $removelist func_append removelist " $lockfile" trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 srcfile=$func_to_tool_file_result func_quote_for_eval "$srcfile" qsrcfile=$func_quote_for_eval_result # Only build a PIC object if we are building libtool libraries. if test yes = "$build_libtool_libs"; then # Without this assignment, base_compile gets emptied. fbsd_hideous_sh_bug=$base_compile if test no != "$pic_mode"; then command="$base_compile $qsrcfile $pic_flag" else # Don't build PIC code command="$base_compile $qsrcfile" fi func_mkdir_p "$xdir$objdir" if test -z "$output_obj"; then # Place PIC objects in $objdir func_append command " -o $lobj" fi func_show_eval_locale "$command" \ 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' if test warn = "$need_locks" && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support '-c' and '-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed, then go on to compile the next one if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then func_show_eval '$MV "$output_obj" "$lobj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi # Allow error messages only from the first compilation. if test yes = "$suppress_opt"; then suppress_output=' >/dev/null 2>&1' fi fi # Only build a position-dependent object if we build old libraries. if test yes = "$build_old_libs"; then if test yes != "$pic_mode"; then # Don't build PIC code command="$base_compile $qsrcfile$pie_flag" else command="$base_compile $qsrcfile $pic_flag" fi if test yes = "$compiler_c_o"; then func_append command " -o $obj" fi # Suppress compiler output if we already did a PIC compilation. func_append command "$suppress_output" func_show_eval_locale "$command" \ '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' if test warn = "$need_locks" && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support '-c' and '-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then func_show_eval '$MV "$output_obj" "$obj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi fi $opt_dry_run || { func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" # Unlock the critical section if it was locked if test no != "$need_locks"; then removelist=$lockfile $RM "$lockfile" fi } exit $EXIT_SUCCESS } $opt_help || { test compile = "$opt_mode" && func_mode_compile ${1+"$@"} } func_mode_help () { # We need to display help for each of the modes. case $opt_mode in "") # Generic help is extracted from the usage comments # at the start of this file. func_help ;; clean) $ECHO \ "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... Remove files from the build directory. RM is the name of the program to use to delete files associated with each FILE (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed to RM. If FILE is a libtool library, object or program, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; compile) $ECHO \ "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE Compile a source file into a libtool library object. This mode accepts the following additional options: -o OUTPUT-FILE set the output file name to OUTPUT-FILE -no-suppress do not suppress compiler output for multiple passes -prefer-pic try to build PIC objects only -prefer-non-pic try to build non-PIC objects only -shared do not build a '.o' file suitable for static linking -static only build a '.o' file suitable for static linking -Wc,FLAG pass FLAG directly to the compiler COMPILE-COMMAND is a command to be used in creating a 'standard' object file from the given SOURCEFILE. The output file name is determined by removing the directory component from SOURCEFILE, then substituting the C source code suffix '.c' with the library object suffix, '.lo'." ;; execute) $ECHO \ "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... Automatically set library path, then run a program. This mode accepts the following additional options: -dlopen FILE add the directory containing FILE to the library path This mode sets the library path environment variable according to '-dlopen' flags. If any of the ARGS are libtool executable wrappers, then they are translated into their corresponding uninstalled binary, and any of their required library directories are added to the library path. Then, COMMAND is executed, with ARGS as arguments." ;; finish) $ECHO \ "Usage: $progname [OPTION]... --mode=finish [LIBDIR]... Complete the installation of libtool libraries. Each LIBDIR is a directory that contains libtool libraries. The commands that this mode executes may require superuser privileges. Use the '--dry-run' option if you just want to see what would be executed." ;; install) $ECHO \ "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... Install executables or libraries. INSTALL-COMMAND is the installation command. The first component should be either the 'install' or 'cp' program. The following components of INSTALL-COMMAND are treated specially: -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation The rest of the components are interpreted as arguments to that command (only BSD-compatible install options are recognized)." ;; link) $ECHO \ "Usage: $progname [OPTION]... --mode=link LINK-COMMAND... Link object files or libraries together to form another library, or to create an executable program. LINK-COMMAND is a command using the C compiler that you would use to create a program from several object files. The following components of LINK-COMMAND are treated specially: -all-static do not do any dynamic linking at all -avoid-version do not add a version suffix if possible -bindir BINDIR specify path to binaries directory (for systems where libraries must be found in the PATH setting at runtime) -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) -export-symbols SYMFILE try to export only the symbols listed in SYMFILE -export-symbols-regex REGEX try to export only the symbols matching REGEX -LLIBDIR search LIBDIR for required installed libraries -lNAME OUTPUT-FILE requires the installed library libNAME -module build a library that can dlopened -no-fast-install disable the fast-install mode -no-install link a not-installable executable -no-undefined declare that a library does not refer to external symbols -o OUTPUT-FILE create OUTPUT-FILE from the specified objects -objectlist FILE use a list of object files found in FILE to specify objects -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) -precious-files-regex REGEX don't remove output files matching REGEX -release RELEASE specify package release information -rpath LIBDIR the created library will eventually be installed in LIBDIR -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries -shared only do dynamic linking of libtool libraries -shrext SUFFIX override the standard shared library file extension -static do not do any dynamic linking of uninstalled libtool libraries -static-libtool-libs do not do any dynamic linking of libtool libraries -version-info CURRENT[:REVISION[:AGE]] specify library version info [each variable defaults to 0] -weak LIBNAME declare that the target provides the LIBNAME interface -Wc,FLAG -Xcompiler FLAG pass linker-specific FLAG directly to the compiler -Wl,FLAG -Xlinker FLAG pass linker-specific FLAG directly to the linker -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) All other options (arguments beginning with '-') are ignored. Every other argument is treated as a filename. Files ending in '.la' are treated as uninstalled libtool libraries, other files are standard or library object files. If the OUTPUT-FILE ends in '.la', then a libtool library is created, only library objects ('.lo' files) may be specified, and '-rpath' is required, except when creating a convenience library. If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created using 'ar' and 'ranlib', or on Windows using 'lib'. If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file is created, otherwise an executable program is created." ;; uninstall) $ECHO \ "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... Remove libraries from an installation directory. RM is the name of the program to use to delete files associated with each FILE (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed to RM. If FILE is a libtool library, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; *) func_fatal_help "invalid operation mode '$opt_mode'" ;; esac echo $ECHO "Try '$progname --help' for more information about other modes." } # Now that we've collected a possible --mode arg, show help if necessary if $opt_help; then if test : = "$opt_help"; then func_mode_help else { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do func_mode_help done } | $SED -n '1p; 2,$s/^Usage:/ or: /p' { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do echo func_mode_help done } | $SED '1d /^When reporting/,/^Report/{ H d } $x /information about other modes/d /more detailed .*MODE/d s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' fi exit $? fi # func_mode_execute arg... func_mode_execute () { $debug_cmd # The first argument is the command name. cmd=$nonopt test -z "$cmd" && \ func_fatal_help "you must specify a COMMAND" # Handle -dlopen flags immediately. for file in $opt_dlopen; do test -f "$file" \ || func_fatal_help "'$file' is not a file" dir= case $file in *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "'$lib' is not a valid libtool archive" # Read the libtool library. dlname= library_names= func_source "$file" # Skip this library if it cannot be dlopened. if test -z "$dlname"; then # Warn if it was a shared library. test -n "$library_names" && \ func_warning "'$file' was not linked with '-export-dynamic'" continue fi func_dirname "$file" "" "." dir=$func_dirname_result if test -f "$dir/$objdir/$dlname"; then func_append dir "/$objdir" else if test ! -f "$dir/$dlname"; then func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" fi fi ;; *.lo) # Just add the directory containing the .lo file. func_dirname "$file" "" "." dir=$func_dirname_result ;; *) func_warning "'-dlopen' is ignored for non-libtool libraries and objects" continue ;; esac # Get the absolute pathname. absdir=`cd "$dir" && pwd` test -n "$absdir" && dir=$absdir # Now add the directory to shlibpath_var. if eval "test -z \"\$$shlibpath_var\""; then eval "$shlibpath_var=\"\$dir\"" else eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" fi done # This variable tells wrapper scripts just to set shlibpath_var # rather than running their programs. libtool_execute_magic=$magic # Check if any of the arguments is a wrapper script. args= for file do case $file in -* | *.la | *.lo ) ;; *) # Do a test to see if this is really a libtool program. if func_ltwrapper_script_p "$file"; then func_source "$file" # Transform arg to wrapped name. file=$progdir/$program elif func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" func_source "$func_ltwrapper_scriptname_result" # Transform arg to wrapped name. file=$progdir/$program fi ;; esac # Quote arguments (to preserve shell metacharacters). func_append_quoted args "$file" done if $opt_dry_run; then # Display what would be done. if test -n "$shlibpath_var"; then eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" echo "export $shlibpath_var" fi $ECHO "$cmd$args" exit $EXIT_SUCCESS else if test -n "$shlibpath_var"; then # Export the shlibpath_var. eval "export $shlibpath_var" fi # Restore saved environment variables for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${save_$lt_var+set}\" = set; then $lt_var=\$save_$lt_var; export $lt_var else $lt_unset $lt_var fi" done # Now prepare to actually exec the command. exec_cmd=\$cmd$args fi } test execute = "$opt_mode" && func_mode_execute ${1+"$@"} # func_mode_finish arg... func_mode_finish () { $debug_cmd libs= libdirs= admincmds= for opt in "$nonopt" ${1+"$@"} do if test -d "$opt"; then func_append libdirs " $opt" elif test -f "$opt"; then if func_lalib_unsafe_p "$opt"; then func_append libs " $opt" else func_warning "'$opt' is not a valid libtool archive" fi else func_fatal_error "invalid argument '$opt'" fi done if test -n "$libs"; then if test -n "$lt_sysroot"; then sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" else sysroot_cmd= fi # Remove sysroot references if $opt_dry_run; then for lib in $libs; do echo "removing references to $lt_sysroot and '=' prefixes from $lib" done else tmpdir=`func_mktempdir` for lib in $libs; do $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ > $tmpdir/tmp-la mv -f $tmpdir/tmp-la $lib done ${RM}r "$tmpdir" fi fi if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then for libdir in $libdirs; do if test -n "$finish_cmds"; then # Do each command in the finish commands. func_execute_cmds "$finish_cmds" 'admincmds="$admincmds '"$cmd"'"' fi if test -n "$finish_eval"; then # Do the single finish_eval. eval cmds=\"$finish_eval\" $opt_dry_run || eval "$cmds" || func_append admincmds " $cmds" fi done fi # Exit here if they wanted silent mode. $opt_quiet && exit $EXIT_SUCCESS if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then echo "----------------------------------------------------------------------" echo "Libraries have been installed in:" for libdir in $libdirs; do $ECHO " $libdir" done echo echo "If you ever happen to want to link against installed libraries" echo "in a given directory, LIBDIR, you must either use libtool, and" echo "specify the full pathname of the library, or use the '-LLIBDIR'" echo "flag during linking and do at least one of the following:" if test -n "$shlibpath_var"; then echo " - add LIBDIR to the '$shlibpath_var' environment variable" echo " during execution" fi if test -n "$runpath_var"; then echo " - add LIBDIR to the '$runpath_var' environment variable" echo " during linking" fi if test -n "$hardcode_libdir_flag_spec"; then libdir=LIBDIR eval flag=\"$hardcode_libdir_flag_spec\" $ECHO " - use the '$flag' linker flag" fi if test -n "$admincmds"; then $ECHO " - have your system administrator run these commands:$admincmds" fi if test -f /etc/ld.so.conf; then echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" fi echo echo "See any operating system documentation about shared libraries for" case $host in solaris2.[6789]|solaris2.1[0-9]) echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" echo "pages." ;; *) echo "more information, such as the ld(1) and ld.so(8) manual pages." ;; esac echo "----------------------------------------------------------------------" fi exit $EXIT_SUCCESS } test finish = "$opt_mode" && func_mode_finish ${1+"$@"} # func_mode_install arg... func_mode_install () { $debug_cmd # There may be an optional sh(1) argument at the beginning of # install_prog (especially on Windows NT). if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || # Allow the use of GNU shtool's install command. case $nonopt in *shtool*) :;; *) false;; esac then # Aesthetically quote it. func_quote_for_eval "$nonopt" install_prog="$func_quote_for_eval_result " arg=$1 shift else install_prog= arg=$nonopt fi # The real first argument should be the name of the installation program. # Aesthetically quote it. func_quote_for_eval "$arg" func_append install_prog "$func_quote_for_eval_result" install_shared_prog=$install_prog case " $install_prog " in *[\\\ /]cp\ *) install_cp=: ;; *) install_cp=false ;; esac # We need to accept at least all the BSD install flags. dest= files= opts= prev= install_type= isdir=false stripme= no_mode=: for arg do arg2= if test -n "$dest"; then func_append files " $dest" dest=$arg continue fi case $arg in -d) isdir=: ;; -f) if $install_cp; then :; else prev=$arg fi ;; -g | -m | -o) prev=$arg ;; -s) stripme=" -s" continue ;; -*) ;; *) # If the previous option needed an argument, then skip it. if test -n "$prev"; then if test X-m = "X$prev" && test -n "$install_override_mode"; then arg2=$install_override_mode no_mode=false fi prev= else dest=$arg continue fi ;; esac # Aesthetically quote the argument. func_quote_for_eval "$arg" func_append install_prog " $func_quote_for_eval_result" if test -n "$arg2"; then func_quote_for_eval "$arg2" fi func_append install_shared_prog " $func_quote_for_eval_result" done test -z "$install_prog" && \ func_fatal_help "you must specify an install program" test -n "$prev" && \ func_fatal_help "the '$prev' option requires an argument" if test -n "$install_override_mode" && $no_mode; then if $install_cp; then :; else func_quote_for_eval "$install_override_mode" func_append install_shared_prog " -m $func_quote_for_eval_result" fi fi if test -z "$files"; then if test -z "$dest"; then func_fatal_help "no file or destination specified" else func_fatal_help "you must specify a destination" fi fi # Strip any trailing slash from the destination. func_stripname '' '/' "$dest" dest=$func_stripname_result # Check to see that the destination is a directory. test -d "$dest" && isdir=: if $isdir; then destdir=$dest destname= else func_dirname_and_basename "$dest" "" "." destdir=$func_dirname_result destname=$func_basename_result # Not a directory, so check to see that there is only one file specified. set dummy $files; shift test "$#" -gt 1 && \ func_fatal_help "'$dest' is not a directory" fi case $destdir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) for file in $files; do case $file in *.lo) ;; *) func_fatal_help "'$destdir' must be an absolute directory name" ;; esac done ;; esac # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic=$magic staticlibs= future_libdirs= current_libdirs= for file in $files; do # Do each installation. case $file in *.$libext) # Do the static libraries later. func_append staticlibs " $file" ;; *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "'$file' is not a valid libtool archive" library_names= old_library= relink_command= func_source "$file" # Add the libdir to current_libdirs if it is the destination. if test "X$destdir" = "X$libdir"; then case "$current_libdirs " in *" $libdir "*) ;; *) func_append current_libdirs " $libdir" ;; esac else # Note the libdir as a future libdir. case "$future_libdirs " in *" $libdir "*) ;; *) func_append future_libdirs " $libdir" ;; esac fi func_dirname "$file" "/" "" dir=$func_dirname_result func_append dir "$objdir" if test -n "$relink_command"; then # Determine the prefix the user has applied to our future dir. inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` # Don't allow the user to place us outside of our expected # location b/c this prevents finding dependent libraries that # are installed to the same prefix. # At present, this check doesn't affect windows .dll's that # are installed into $libdir/../bin (currently, that works fine) # but it's something to keep an eye on. test "$inst_prefix_dir" = "$destdir" && \ func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" if test -n "$inst_prefix_dir"; then # Stick the inst_prefix_dir data into the link command. relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` else relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` fi func_warning "relinking '$file'" func_show_eval "$relink_command" \ 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' fi # See the names of the shared library. set dummy $library_names; shift if test -n "$1"; then realname=$1 shift srcname=$realname test -n "$relink_command" && srcname=${realname}T # Install the shared library and build the symlinks. func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 'exit $?' tstripme=$stripme case $host_os in cygwin* | mingw* | pw32* | cegcc*) case $realname in *.dll.a) tstripme= ;; esac ;; os2*) case $realname in *_dll.a) tstripme= ;; esac ;; esac if test -n "$tstripme" && test -n "$striplib"; then func_show_eval "$striplib $destdir/$realname" 'exit $?' fi if test "$#" -gt 0; then # Delete the old symlinks, and create new ones. # Try 'ln -sf' first, because the 'ln' binary might depend on # the symlink we replace! Solaris /bin/ln does not understand -f, # so we also need to try rm && ln -s. for linkname do test "$linkname" != "$realname" \ && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" done fi # Do each command in the postinstall commands. lib=$destdir/$realname func_execute_cmds "$postinstall_cmds" 'exit $?' fi # Install the pseudo-library for information purposes. func_basename "$file" name=$func_basename_result instname=$dir/${name}i func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' # Maybe install the static library, too. test -n "$old_library" && func_append staticlibs " $dir/$old_library" ;; *.lo) # Install (i.e. copy) a libtool object. # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile=$destdir/$destname else func_basename "$file" destfile=$func_basename_result destfile=$destdir/$destfile fi # Deduce the name of the destination old-style object file. case $destfile in *.lo) func_lo2o "$destfile" staticdest=$func_lo2o_result ;; *.$objext) staticdest=$destfile destfile= ;; *) func_fatal_help "cannot copy a libtool object to '$destfile'" ;; esac # Install the libtool object if requested. test -n "$destfile" && \ func_show_eval "$install_prog $file $destfile" 'exit $?' # Install the old object if enabled. if test yes = "$build_old_libs"; then # Deduce the name of the old-style object file. func_lo2o "$file" staticobj=$func_lo2o_result func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' fi exit $EXIT_SUCCESS ;; *) # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile=$destdir/$destname else func_basename "$file" destfile=$func_basename_result destfile=$destdir/$destfile fi # If the file is missing, and there is a .exe on the end, strip it # because it is most likely a libtool script we actually want to # install stripped_ext= case $file in *.exe) if test ! -f "$file"; then func_stripname '' '.exe' "$file" file=$func_stripname_result stripped_ext=.exe fi ;; esac # Do a test to see if this is really a libtool program. case $host in *cygwin* | *mingw*) if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" wrapper=$func_ltwrapper_scriptname_result else func_stripname '' '.exe' "$file" wrapper=$func_stripname_result fi ;; *) wrapper=$file ;; esac if func_ltwrapper_script_p "$wrapper"; then notinst_deplibs= relink_command= func_source "$wrapper" # Check the variables that should have been set. test -z "$generated_by_libtool_version" && \ func_fatal_error "invalid libtool wrapper script '$wrapper'" finalize=: for lib in $notinst_deplibs; do # Check to see that each library is installed. libdir= if test -f "$lib"; then func_source "$lib" fi libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` if test -n "$libdir" && test ! -f "$libfile"; then func_warning "'$lib' has not been installed in '$libdir'" finalize=false fi done relink_command= func_source "$wrapper" outputname= if test no = "$fast_install" && test -n "$relink_command"; then $opt_dry_run || { if $finalize; then tmpdir=`func_mktempdir` func_basename "$file$stripped_ext" file=$func_basename_result outputname=$tmpdir/$file # Replace the output file specification. relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` $opt_quiet || { func_quote_for_expand "$relink_command" eval "func_echo $func_quote_for_expand_result" } if eval "$relink_command"; then : else func_error "error: relink '$file' with the above command before installing it" $opt_dry_run || ${RM}r "$tmpdir" continue fi file=$outputname else func_warning "cannot relink '$file'" fi } else # Install the binary that we compiled earlier. file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` fi fi # remove .exe since cygwin /usr/bin/install will append another # one anyway case $install_prog,$host in */usr/bin/install*,*cygwin*) case $file:$destfile in *.exe:*.exe) # this is ok ;; *.exe:*) destfile=$destfile.exe ;; *:*.exe) func_stripname '' '.exe' "$destfile" destfile=$func_stripname_result ;; esac ;; esac func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' $opt_dry_run || if test -n "$outputname"; then ${RM}r "$tmpdir" fi ;; esac done for file in $staticlibs; do func_basename "$file" name=$func_basename_result # Set up the ranlib parameters. oldlib=$destdir/$name func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 tool_oldlib=$func_to_tool_file_result func_show_eval "$install_prog \$file \$oldlib" 'exit $?' if test -n "$stripme" && test -n "$old_striplib"; then func_show_eval "$old_striplib $tool_oldlib" 'exit $?' fi # Do each command in the postinstall commands. func_execute_cmds "$old_postinstall_cmds" 'exit $?' done test -n "$future_libdirs" && \ func_warning "remember to run '$progname --finish$future_libdirs'" if test -n "$current_libdirs"; then # Maybe just do a dry run. $opt_dry_run && current_libdirs=" -n$current_libdirs" exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' else exit $EXIT_SUCCESS fi } test install = "$opt_mode" && func_mode_install ${1+"$@"} # func_generate_dlsyms outputname originator pic_p # Extract symbols from dlprefiles and create ${outputname}S.o with # a dlpreopen symbol table. func_generate_dlsyms () { $debug_cmd my_outputname=$1 my_originator=$2 my_pic_p=${3-false} my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` my_dlsyms= if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then if test -n "$NM" && test -n "$global_symbol_pipe"; then my_dlsyms=${my_outputname}S.c else func_error "not configured to extract global symbols from dlpreopened files" fi fi if test -n "$my_dlsyms"; then case $my_dlsyms in "") ;; *.c) # Discover the nlist of each of the dlfiles. nlist=$output_objdir/$my_outputname.nm func_show_eval "$RM $nlist ${nlist}S ${nlist}T" # Parse the name list into a source file. func_verbose "creating $output_objdir/$my_dlsyms" $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ /* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ /* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ #ifdef __cplusplus extern \"C\" { #endif #if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) #pragma GCC diagnostic ignored \"-Wstrict-prototypes\" #endif /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE /* DATA imports from DLLs on WIN32 can't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined __osf__ /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) /* External symbol declarations for the compiler. */\ " if test yes = "$dlself"; then func_verbose "generating symbol list for '$output'" $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" # Add our own program objects to the symbol list. progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` for progfile in $progfiles; do func_to_tool_file "$progfile" func_convert_file_msys_to_w32 func_verbose "extracting global C symbols from '$func_to_tool_file_result'" $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" done if test -n "$exclude_expsyms"; then $opt_dry_run || { eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi if test -n "$export_symbols_regex"; then $opt_dry_run || { eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi # Prepare the list of exported symbols if test -z "$export_symbols"; then export_symbols=$output_objdir/$outputname.exp $opt_dry_run || { $RM $export_symbols eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' ;; esac } else $opt_dry_run || { eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' ;; esac } fi fi for dlprefile in $dlprefiles; do func_verbose "extracting global C symbols from '$dlprefile'" func_basename "$dlprefile" name=$func_basename_result case $host in *cygwin* | *mingw* | *cegcc* ) # if an import library, we need to obtain dlname if func_win32_import_lib_p "$dlprefile"; then func_tr_sh "$dlprefile" eval "curr_lafile=\$libfile_$func_tr_sh_result" dlprefile_dlbasename= if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then # Use subshell, to avoid clobbering current variable values dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` if test -n "$dlprefile_dlname"; then func_basename "$dlprefile_dlname" dlprefile_dlbasename=$func_basename_result else # no lafile. user explicitly requested -dlpreopen . $sharedlib_from_linklib_cmd "$dlprefile" dlprefile_dlbasename=$sharedlib_from_linklib_result fi fi $opt_dry_run || { if test -n "$dlprefile_dlbasename"; then eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' else func_warning "Could not compute DLL name from $name" eval '$ECHO ": $name " >> "$nlist"' fi func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" } else # not an import lib $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } fi ;; *) $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } ;; esac done $opt_dry_run || { # Make sure we have at least an empty file. test -f "$nlist" || : > "$nlist" if test -n "$exclude_expsyms"; then $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T $MV "$nlist"T "$nlist" fi # Try sorting and uniquifying the output. if $GREP -v "^: " < "$nlist" | if sort -k 3 /dev/null 2>&1; then sort -k 3 else sort +2 fi | uniq > "$nlist"S; then : else $GREP -v "^: " < "$nlist" > "$nlist"S fi if test -f "$nlist"S; then eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' else echo '/* NONE */' >> "$output_objdir/$my_dlsyms" fi func_show_eval '$RM "${nlist}I"' if test -n "$global_symbol_to_import"; then eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' fi echo >> "$output_objdir/$my_dlsyms" "\ /* The mapping between symbol names and symbols. */ typedef struct { const char *name; void *address; } lt_dlsymlist; extern LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[];\ " if test -s "$nlist"I; then echo >> "$output_objdir/$my_dlsyms" "\ static void lt_syminit(void) { LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; for (; symbol->name; ++symbol) {" $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" echo >> "$output_objdir/$my_dlsyms" "\ } }" fi echo >> "$output_objdir/$my_dlsyms" "\ LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[] = { {\"$my_originator\", (void *) 0}," if test -s "$nlist"I; then echo >> "$output_objdir/$my_dlsyms" "\ {\"@INIT@\", (void *) <_syminit}," fi case $need_lib_prefix in no) eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; *) eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; esac echo >> "$output_objdir/$my_dlsyms" "\ {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt_${my_prefix}_LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif\ " } # !$opt_dry_run pic_flag_for_symtable= case "$compile_command " in *" -static "*) ;; *) case $host in # compiling the symbol table file with pic_flag works around # a FreeBSD bug that causes programs to crash when -lm is # linked before any other PIC object. But we must not use # pic_flag when linking with -static. The problem exists in # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; *-*-hpux*) pic_flag_for_symtable=" $pic_flag" ;; *) $my_pic_p && pic_flag_for_symtable=" $pic_flag" ;; esac ;; esac symtab_cflags= for arg in $LTCFLAGS; do case $arg in -pie | -fpie | -fPIE) ;; *) func_append symtab_cflags " $arg" ;; esac done # Now compile the dynamic symbol file. func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' # Clean up the generated files. func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' # Transform the symbol file into the correct name. symfileobj=$output_objdir/${my_outputname}S.$objext case $host in *cygwin* | *mingw* | *cegcc* ) if test -f "$output_objdir/$my_outputname.def"; then compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` else compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` fi ;; *) compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` ;; esac ;; *) func_fatal_error "unknown suffix for '$my_dlsyms'" ;; esac else # We keep going just in case the user didn't refer to # lt_preloaded_symbols. The linker will fail if global_symbol_pipe # really was required. # Nullify the symbol file. compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` fi } # func_cygming_gnu_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is a GNU/binutils-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_gnu_implib_p () { $debug_cmd func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` test -n "$func_cygming_gnu_implib_tmp" } # func_cygming_ms_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is an MS-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_ms_implib_p () { $debug_cmd func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` test -n "$func_cygming_ms_implib_tmp" } # func_win32_libid arg # return the library type of file 'arg' # # Need a lot of goo to handle *both* DLLs and import libs # Has to be a shell function in order to 'eat' the argument # that is supplied when $file_magic_command is called. # Despite the name, also deal with 64 bit binaries. func_win32_libid () { $debug_cmd win32_libid_type=unknown win32_fileres=`file -L $1 2>/dev/null` case $win32_fileres in *ar\ archive\ import\ library*) # definitely import win32_libid_type="x86 archive import" ;; *ar\ archive*) # could be an import, or static # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then case $nm_interface in "MS dumpbin") if func_cygming_ms_implib_p "$1" || func_cygming_gnu_implib_p "$1" then win32_nmres=import else win32_nmres= fi ;; *) func_to_tool_file "$1" func_convert_file_msys_to_w32 win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | $SED -n -e ' 1,100{ / I /{ s|.*|import| p q } }'` ;; esac case $win32_nmres in import*) win32_libid_type="x86 archive import";; *) win32_libid_type="x86 archive static";; esac fi ;; *DLL*) win32_libid_type="x86 DLL" ;; *executable*) # but shell scripts are "executable" too... case $win32_fileres in *MS\ Windows\ PE\ Intel*) win32_libid_type="x86 DLL" ;; esac ;; esac $ECHO "$win32_libid_type" } # func_cygming_dll_for_implib ARG # # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib () { $debug_cmd sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` } # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs # # The is the core of a fallback implementation of a # platform-specific function to extract the name of the # DLL associated with the specified import library LIBNAME. # # SECTION_NAME is either .idata$6 or .idata$7, depending # on the platform and compiler that created the implib. # # Echos the name of the DLL associated with the # specified import library. func_cygming_dll_for_implib_fallback_core () { $debug_cmd match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` $OBJDUMP -s --section "$1" "$2" 2>/dev/null | $SED '/^Contents of section '"$match_literal"':/{ # Place marker at beginning of archive member dllname section s/.*/====MARK====/ p d } # These lines can sometimes be longer than 43 characters, but # are always uninteresting /:[ ]*file format pe[i]\{,1\}-/d /^In archive [^:]*:/d # Ensure marker is printed /^====MARK====/p # Remove all lines with less than 43 characters /^.\{43\}/!d # From remaining lines, remove first 43 characters s/^.\{43\}//' | $SED -n ' # Join marker and all lines until next marker into a single line /^====MARK====/ b para H $ b para b :para x s/\n//g # Remove the marker s/^====MARK====// # Remove trailing dots and whitespace s/[\. \t]*$// # Print /./p' | # we now have a list, one entry per line, of the stringified # contents of the appropriate section of all members of the # archive that possess that section. Heuristic: eliminate # all those that have a first or second character that is # a '.' (that is, objdump's representation of an unprintable # character.) This should work for all archives with less than # 0x302f exports -- but will fail for DLLs whose name actually # begins with a literal '.' or a single character followed by # a '.'. # # Of those that remain, print the first one. $SED -e '/^\./d;/^.\./d;q' } # func_cygming_dll_for_implib_fallback ARG # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # # This fallback implementation is for use when $DLLTOOL # does not support the --identify-strict option. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib_fallback () { $debug_cmd if func_cygming_gnu_implib_p "$1"; then # binutils import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` elif func_cygming_ms_implib_p "$1"; then # ms-generated import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` else # unknown sharedlib_from_linklib_result= fi } # func_extract_an_archive dir oldlib func_extract_an_archive () { $debug_cmd f_ex_an_ar_dir=$1; shift f_ex_an_ar_oldlib=$1 if test yes = "$lock_old_archive_extraction"; then lockfile=$f_ex_an_ar_oldlib.lock until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done fi func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 'stat=$?; rm -f "$lockfile"; exit $stat' if test yes = "$lock_old_archive_extraction"; then $opt_dry_run || rm -f "$lockfile" fi if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then : else func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" fi } # func_extract_archives gentop oldlib ... func_extract_archives () { $debug_cmd my_gentop=$1; shift my_oldlibs=${1+"$@"} my_oldobjs= my_xlib= my_xabs= my_xdir= for my_xlib in $my_oldlibs; do # Extract the objects. case $my_xlib in [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; *) my_xabs=`pwd`"/$my_xlib" ;; esac func_basename "$my_xlib" my_xlib=$func_basename_result my_xlib_u=$my_xlib while :; do case " $extracted_archives " in *" $my_xlib_u "*) func_arith $extracted_serial + 1 extracted_serial=$func_arith_result my_xlib_u=lt$extracted_serial-$my_xlib ;; *) break ;; esac done extracted_archives="$extracted_archives $my_xlib_u" my_xdir=$my_gentop/$my_xlib_u func_mkdir_p "$my_xdir" case $host in *-darwin*) func_verbose "Extracting $my_xabs" # Do not bother doing anything if just a dry run $opt_dry_run || { darwin_orig_dir=`pwd` cd $my_xdir || exit $? darwin_archive=$my_xabs darwin_curdir=`pwd` func_basename "$darwin_archive" darwin_base_archive=$func_basename_result darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` if test -n "$darwin_arches"; then darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` darwin_arch= func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" for darwin_arch in $darwin_arches; do func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" cd "unfat-$$/$darwin_base_archive-$darwin_arch" func_extract_an_archive "`pwd`" "$darwin_base_archive" cd "$darwin_curdir" $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" done # $darwin_arches ## Okay now we've a bunch of thin objects, gotta fatten them up :) darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` darwin_file= darwin_files= for darwin_file in $darwin_filelist; do darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` $LIPO -create -output "$darwin_file" $darwin_files done # $darwin_filelist $RM -rf unfat-$$ cd "$darwin_orig_dir" else cd $darwin_orig_dir func_extract_an_archive "$my_xdir" "$my_xabs" fi # $darwin_arches } # !$opt_dry_run ;; *) func_extract_an_archive "$my_xdir" "$my_xabs" ;; esac my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` done func_extract_archives_result=$my_oldobjs } # func_emit_wrapper [arg=no] # # Emit a libtool wrapper script on stdout. # Don't directly open a file because we may want to # incorporate the script contents within a cygwin/mingw # wrapper executable. Must ONLY be called from within # func_mode_link because it depends on a number of variables # set therein. # # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR # variable will take. If 'yes', then the emitted script # will assume that the directory where it is stored is # the $objdir directory. This is a cygwin/mingw-specific # behavior. func_emit_wrapper () { func_emit_wrapper_arg1=${1-no} $ECHO "\ #! $SHELL # $output - temporary wrapper script for $objdir/$outputname # Generated by $PROGRAM (GNU $PACKAGE) $VERSION # # The $output program cannot be directly executed until all the libtool # libraries that it depends on are installed. # # This wrapper script should never be moved out of the build directory. # If it is, it will not operate correctly. # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. sed_quote_subst='$sed_quote_subst' # Be Bourne compatible if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH relink_command=\"$relink_command\" # This environment variable determines our operation mode. if test \"\$libtool_install_magic\" = \"$magic\"; then # install mode needs the following variables: generated_by_libtool_version='$macro_version' notinst_deplibs='$notinst_deplibs' else # When we are sourced in execute mode, \$file and \$ECHO are already set. if test \"\$libtool_execute_magic\" != \"$magic\"; then file=\"\$0\"" qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` $ECHO "\ # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } ECHO=\"$qECHO\" fi # Very basic option parsing. These options are (a) specific to # the libtool wrapper, (b) are identical between the wrapper # /script/ and the wrapper /executable/ that is used only on # windows platforms, and (c) all begin with the string "--lt-" # (application programs are unlikely to have options that match # this pattern). # # There are only two supported options: --lt-debug and # --lt-dump-script. There is, deliberately, no --lt-help. # # The first argument to this parsing function should be the # script's $0 value, followed by "$@". lt_option_debug= func_parse_lt_options () { lt_script_arg0=\$0 shift for lt_opt do case \"\$lt_opt\" in --lt-debug) lt_option_debug=1 ;; --lt-dump-script) lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` cat \"\$lt_dump_D/\$lt_dump_F\" exit 0 ;; --lt-*) \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 exit 1 ;; esac done # Print the debug banner immediately: if test -n \"\$lt_option_debug\"; then echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 fi } # Used when --lt-debug. Prints its arguments to stdout # (redirection is the responsibility of the caller) func_lt_dump_args () { lt_dump_args_N=1; for lt_arg do \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` done } # Core function for launching the target application func_exec_program_core () { " case $host in # Backslashes separate directories on plain windows *-*-mingw | *-*-os2* | *-cegcc*) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} " ;; *) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir/\$program\" \${1+\"\$@\"} " ;; esac $ECHO "\ \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 exit 1 } # A function to encapsulate launching the target application # Strips options in the --lt-* namespace from \$@ and # launches target application with the remaining arguments. func_exec_program () { case \" \$* \" in *\\ --lt-*) for lt_wr_arg do case \$lt_wr_arg in --lt-*) ;; *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; esac shift done ;; esac func_exec_program_core \${1+\"\$@\"} } # Parse options func_parse_lt_options \"\$0\" \${1+\"\$@\"} # Find the directory that this script lives in. thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` test \"x\$thisdir\" = \"x\$file\" && thisdir=. # Follow symbolic links until we get to the real thisdir. file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` while test -n \"\$file\"; do destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` # If there was a directory component, then change thisdir. if test \"x\$destdir\" != \"x\$file\"; then case \"\$destdir\" in [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; *) thisdir=\"\$thisdir/\$destdir\" ;; esac fi file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` done # Usually 'no', except on cygwin/mingw when embedded into # the cwrapper. WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then # special case for '.' if test \"\$thisdir\" = \".\"; then thisdir=\`pwd\` fi # remove .libs from thisdir case \"\$thisdir\" in *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; $objdir ) thisdir=. ;; esac fi # Try to get the absolute directory name. absdir=\`cd \"\$thisdir\" && pwd\` test -n \"\$absdir\" && thisdir=\"\$absdir\" " if test yes = "$fast_install"; then $ECHO "\ program=lt-'$outputname'$exeext progdir=\"\$thisdir/$objdir\" if test ! -f \"\$progdir/\$program\" || { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ test \"X\$file\" != \"X\$progdir/\$program\"; }; then file=\"\$\$-\$program\" if test ! -d \"\$progdir\"; then $MKDIR \"\$progdir\" else $RM \"\$progdir/\$file\" fi" $ECHO "\ # relink executable if necessary if test -n \"\$relink_command\"; then if relink_command_output=\`eval \$relink_command 2>&1\`; then : else \$ECHO \"\$relink_command_output\" >&2 $RM \"\$progdir/\$file\" exit 1 fi fi $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || { $RM \"\$progdir/\$program\"; $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } $RM \"\$progdir/\$file\" fi" else $ECHO "\ program='$outputname' progdir=\"\$thisdir/$objdir\" " fi $ECHO "\ if test -f \"\$progdir/\$program\"; then" # fixup the dll searchpath if we need to. # # Fix the DLL searchpath if we need to. Do this before prepending # to shlibpath, because on Windows, both are PATH and uninstalled # libraries must come first. if test -n "$dllsearchpath"; then $ECHO "\ # Add the dll search path components to the executable PATH PATH=$dllsearchpath:\$PATH " fi # Export our shlibpath_var if we have one. if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then $ECHO "\ # Add our own library path to $shlibpath_var $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" # Some systems cannot cope with colon-terminated $shlibpath_var # The second colon is a workaround for a bug in BeOS R4 sed $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` export $shlibpath_var " fi $ECHO "\ if test \"\$libtool_execute_magic\" != \"$magic\"; then # Run the actual program with our arguments. func_exec_program \${1+\"\$@\"} fi else # The program doesn't exist. \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 exit 1 fi fi\ " } # func_emit_cwrapperexe_src # emit the source code for a wrapper executable on stdout # Must ONLY be called from within func_mode_link because # it depends on a number of variable set therein. func_emit_cwrapperexe_src () { cat < #include #ifdef _MSC_VER # include # include # include #else # include # include # ifdef __CYGWIN__ # include # endif #endif #include #include #include #include #include #include #include #include #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) /* declarations of non-ANSI functions */ #if defined __MINGW32__ # ifdef __STRICT_ANSI__ int _putenv (const char *); # endif #elif defined __CYGWIN__ # ifdef __STRICT_ANSI__ char *realpath (const char *, char *); int putenv (char *); int setenv (const char *, const char *, int); # endif /* #elif defined other_platform || defined ... */ #endif /* portability defines, excluding path handling macros */ #if defined _MSC_VER # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv # define S_IXUSR _S_IEXEC #elif defined __MINGW32__ # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv #elif defined __CYGWIN__ # define HAVE_SETENV # define FOPEN_WB "wb" /* #elif defined other platforms ... */ #endif #if defined PATH_MAX # define LT_PATHMAX PATH_MAX #elif defined MAXPATHLEN # define LT_PATHMAX MAXPATHLEN #else # define LT_PATHMAX 1024 #endif #ifndef S_IXOTH # define S_IXOTH 0 #endif #ifndef S_IXGRP # define S_IXGRP 0 #endif /* path handling portability macros */ #ifndef DIR_SEPARATOR # define DIR_SEPARATOR '/' # define PATH_SEPARATOR ':' #endif #if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ defined __OS2__ # define HAVE_DOS_BASED_FILE_SYSTEM # define FOPEN_WB "wb" # ifndef DIR_SEPARATOR_2 # define DIR_SEPARATOR_2 '\\' # endif # ifndef PATH_SEPARATOR_2 # define PATH_SEPARATOR_2 ';' # endif #endif #ifndef DIR_SEPARATOR_2 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) #else /* DIR_SEPARATOR_2 */ # define IS_DIR_SEPARATOR(ch) \ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) #endif /* DIR_SEPARATOR_2 */ #ifndef PATH_SEPARATOR_2 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) #else /* PATH_SEPARATOR_2 */ # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) #endif /* PATH_SEPARATOR_2 */ #ifndef FOPEN_WB # define FOPEN_WB "w" #endif #ifndef _O_BINARY # define _O_BINARY 0 #endif #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) #define XFREE(stale) do { \ if (stale) { free (stale); stale = 0; } \ } while (0) #if defined LT_DEBUGWRAPPER static int lt_debug = 1; #else static int lt_debug = 0; #endif const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ void *xmalloc (size_t num); char *xstrdup (const char *string); const char *base_name (const char *name); char *find_executable (const char *wrapper); char *chase_symlinks (const char *pathspec); int make_executable (const char *path); int check_executable (const char *path); char *strendzap (char *str, const char *pat); void lt_debugprintf (const char *file, int line, const char *fmt, ...); void lt_fatal (const char *file, int line, const char *message, ...); static const char *nonnull (const char *s); static const char *nonempty (const char *s); void lt_setenv (const char *name, const char *value); char *lt_extend_str (const char *orig_value, const char *add, int to_end); void lt_update_exe_path (const char *name, const char *value); void lt_update_lib_path (const char *name, const char *value); char **prepare_spawn (char **argv); void lt_dump_script (FILE *f); EOF cat <= 0) && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) return 1; else return 0; } int make_executable (const char *path) { int rval = 0; struct stat st; lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", nonempty (path)); if ((!path) || (!*path)) return 0; if (stat (path, &st) >= 0) { rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); } return rval; } /* Searches for the full path of the wrapper. Returns newly allocated full path name if found, NULL otherwise Does not chase symlinks, even on platforms that support them. */ char * find_executable (const char *wrapper) { int has_slash = 0; const char *p; const char *p_next; /* static buffer for getcwd */ char tmp[LT_PATHMAX + 1]; size_t tmp_len; char *concat_name; lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", nonempty (wrapper)); if ((wrapper == NULL) || (*wrapper == '\0')) return NULL; /* Absolute path? */ #if defined HAVE_DOS_BASED_FILE_SYSTEM if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } else { #endif if (IS_DIR_SEPARATOR (wrapper[0])) { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } #if defined HAVE_DOS_BASED_FILE_SYSTEM } #endif for (p = wrapper; *p; p++) if (*p == '/') { has_slash = 1; break; } if (!has_slash) { /* no slashes; search PATH */ const char *path = getenv ("PATH"); if (path != NULL) { for (p = path; *p; p = p_next) { const char *q; size_t p_len; for (q = p; *q; q++) if (IS_PATH_SEPARATOR (*q)) break; p_len = (size_t) (q - p); p_next = (*q == '\0' ? q : q + 1); if (p_len == 0) { /* empty path: current directory */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); } else { concat_name = XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, p, p_len); concat_name[p_len] = '/'; strcpy (concat_name + p_len + 1, wrapper); } if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } } /* not found in PATH; assume curdir */ } /* Relative path | not found in path: prepend cwd */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); return NULL; } char * chase_symlinks (const char *pathspec) { #ifndef S_ISLNK return xstrdup (pathspec); #else char buf[LT_PATHMAX]; struct stat s; char *tmp_pathspec = xstrdup (pathspec); char *p; int has_symlinks = 0; while (strlen (tmp_pathspec) && !has_symlinks) { lt_debugprintf (__FILE__, __LINE__, "checking path component for symlinks: %s\n", tmp_pathspec); if (lstat (tmp_pathspec, &s) == 0) { if (S_ISLNK (s.st_mode) != 0) { has_symlinks = 1; break; } /* search backwards for last DIR_SEPARATOR */ p = tmp_pathspec + strlen (tmp_pathspec) - 1; while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) p--; if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) { /* no more DIR_SEPARATORS left */ break; } *p = '\0'; } else { lt_fatal (__FILE__, __LINE__, "error accessing file \"%s\": %s", tmp_pathspec, nonnull (strerror (errno))); } } XFREE (tmp_pathspec); if (!has_symlinks) { return xstrdup (pathspec); } tmp_pathspec = realpath (pathspec, buf); if (tmp_pathspec == 0) { lt_fatal (__FILE__, __LINE__, "could not follow symlinks for %s", pathspec); } return xstrdup (tmp_pathspec); #endif } char * strendzap (char *str, const char *pat) { size_t len, patlen; assert (str != NULL); assert (pat != NULL); len = strlen (str); patlen = strlen (pat); if (patlen <= len) { str += len - patlen; if (STREQ (str, pat)) *str = '\0'; } return str; } void lt_debugprintf (const char *file, int line, const char *fmt, ...) { va_list args; if (lt_debug) { (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); va_start (args, fmt); (void) vfprintf (stderr, fmt, args); va_end (args); } } static void lt_error_core (int exit_status, const char *file, int line, const char *mode, const char *message, va_list ap) { fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); vfprintf (stderr, message, ap); fprintf (stderr, ".\n"); if (exit_status >= 0) exit (exit_status); } void lt_fatal (const char *file, int line, const char *message, ...) { va_list ap; va_start (ap, message); lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); va_end (ap); } static const char * nonnull (const char *s) { return s ? s : "(null)"; } static const char * nonempty (const char *s) { return (s && !*s) ? "(empty)" : nonnull (s); } void lt_setenv (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_setenv) setting '%s' to '%s'\n", nonnull (name), nonnull (value)); { #ifdef HAVE_SETENV /* always make a copy, for consistency with !HAVE_SETENV */ char *str = xstrdup (value); setenv (name, str, 1); #else size_t len = strlen (name) + 1 + strlen (value) + 1; char *str = XMALLOC (char, len); sprintf (str, "%s=%s", name, value); if (putenv (str) != EXIT_SUCCESS) { XFREE (str); } #endif } } char * lt_extend_str (const char *orig_value, const char *add, int to_end) { char *new_value; if (orig_value && *orig_value) { size_t orig_value_len = strlen (orig_value); size_t add_len = strlen (add); new_value = XMALLOC (char, add_len + orig_value_len + 1); if (to_end) { strcpy (new_value, orig_value); strcpy (new_value + orig_value_len, add); } else { strcpy (new_value, add); strcpy (new_value + add_len, orig_value); } } else { new_value = xstrdup (add); } return new_value; } void lt_update_exe_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); /* some systems can't cope with a ':'-terminated path #' */ size_t len = strlen (new_value); while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) { new_value[--len] = '\0'; } lt_setenv (name, new_value); XFREE (new_value); } } void lt_update_lib_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); lt_setenv (name, new_value); XFREE (new_value); } } EOF case $host_os in mingw*) cat <<"EOF" /* Prepares an argument vector before calling spawn(). Note that spawn() does not by itself call the command interpreter (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&v); v.dwPlatformId == VER_PLATFORM_WIN32_NT; }) ? "cmd.exe" : "command.com"). Instead it simply concatenates the arguments, separated by ' ', and calls CreateProcess(). We must quote the arguments since Win32 CreateProcess() interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a special way: - Space and tab are interpreted as delimiters. They are not treated as delimiters if they are surrounded by double quotes: "...". - Unescaped double quotes are removed from the input. Their only effect is that within double quotes, space and tab are treated like normal characters. - Backslashes not followed by double quotes are not special. - But 2*n+1 backslashes followed by a double quote become n backslashes followed by a double quote (n >= 0): \" -> " \\\" -> \" \\\\\" -> \\" */ #define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" #define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" char ** prepare_spawn (char **argv) { size_t argc; char **new_argv; size_t i; /* Count number of arguments. */ for (argc = 0; argv[argc] != NULL; argc++) ; /* Allocate new argument vector. */ new_argv = XMALLOC (char *, argc + 1); /* Put quoted arguments into the new argument vector. */ for (i = 0; i < argc; i++) { const char *string = argv[i]; if (string[0] == '\0') new_argv[i] = xstrdup ("\"\""); else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) { int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); size_t length; unsigned int backslashes; const char *s; char *quoted_string; char *p; length = 0; backslashes = 0; if (quote_around) length++; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') length += backslashes + 1; length++; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) length += backslashes + 1; quoted_string = XMALLOC (char, length + 1); p = quoted_string; backslashes = 0; if (quote_around) *p++ = '"'; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') { unsigned int j; for (j = backslashes + 1; j > 0; j--) *p++ = '\\'; } *p++ = c; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) { unsigned int j; for (j = backslashes; j > 0; j--) *p++ = '\\'; *p++ = '"'; } *p = '\0'; new_argv[i] = quoted_string; } else new_argv[i] = (char *) string; } new_argv[argc] = NULL; return new_argv; } EOF ;; esac cat <<"EOF" void lt_dump_script (FILE* f) { EOF func_emit_wrapper yes | $SED -n -e ' s/^\(.\{79\}\)\(..*\)/\1\ \2/ h s/\([\\"]\)/\\\1/g s/$/\\n/ s/\([^\n]*\).*/ fputs ("\1", f);/p g D' cat <<"EOF" } EOF } # end: func_emit_cwrapperexe_src # func_win32_import_lib_p ARG # True if ARG is an import lib, as indicated by $file_magic_cmd func_win32_import_lib_p () { $debug_cmd case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in *import*) : ;; *) false ;; esac } # func_suncc_cstd_abi # !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! # Several compiler flags select an ABI that is incompatible with the # Cstd library. Avoid specifying it if any are in CXXFLAGS. func_suncc_cstd_abi () { $debug_cmd case " $compile_command " in *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) suncc_use_cstd_abi=no ;; *) suncc_use_cstd_abi=yes ;; esac } # func_mode_link arg... func_mode_link () { $debug_cmd case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) # It is impossible to link a dll without this setting, and # we shouldn't force the makefile maintainer to figure out # what system we are compiling for in order to pass an extra # flag for every libtool invocation. # allow_undefined=no # FIXME: Unfortunately, there are problems with the above when trying # to make a dll that has undefined symbols, in which case not # even a static library is built. For now, we need to specify # -no-undefined on the libtool link line when we can be certain # that all symbols are satisfied, otherwise we get a static library. allow_undefined=yes ;; *) allow_undefined=yes ;; esac libtool_args=$nonopt base_compile="$nonopt $@" compile_command=$nonopt finalize_command=$nonopt compile_rpath= finalize_rpath= compile_shlibpath= finalize_shlibpath= convenience= old_convenience= deplibs= old_deplibs= compiler_flags= linker_flags= dllsearchpath= lib_search_path=`pwd` inst_prefix_dir= new_inherited_linker_flags= avoid_version=no bindir= dlfiles= dlprefiles= dlself=no export_dynamic=no export_symbols= export_symbols_regex= generated= libobjs= ltlibs= module=no no_install=no objs= os2dllname= non_pic_objects= precious_files_regex= prefer_static_libs=no preload=false prev= prevarg= release= rpath= xrpath= perm_rpath= temp_rpath= thread_safe=no vinfo= vinfo_number=no weak_libs= single_module=$wl-single_module func_infer_tag $base_compile # We need to know -static, to get the right output filenames. for arg do case $arg in -shared) test yes != "$build_libtool_libs" \ && func_fatal_configuration "cannot build a shared library" build_old_libs=no break ;; -all-static | -static | -static-libtool-libs) case $arg in -all-static) if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then func_warning "complete static linking is impossible in this configuration" fi if test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; -static) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=built ;; -static-libtool-libs) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; esac build_libtool_libs=no build_old_libs=yes break ;; esac done # See if our shared archives depend on static archives. test -n "$old_archive_from_new_cmds" && build_old_libs=yes # Go through the arguments, transforming them on the way. while test "$#" -gt 0; do arg=$1 shift func_quote_for_eval "$arg" qarg=$func_quote_for_eval_unquoted_result func_append libtool_args " $func_quote_for_eval_result" # If the previous option needs an argument, assign it. if test -n "$prev"; then case $prev in output) func_append compile_command " @OUTPUT@" func_append finalize_command " @OUTPUT@" ;; esac case $prev in bindir) bindir=$arg prev= continue ;; dlfiles|dlprefiles) $preload || { # Add the symbol object into the linking commands. func_append compile_command " @SYMFILE@" func_append finalize_command " @SYMFILE@" preload=: } case $arg in *.la | *.lo) ;; # We handle these cases below. force) if test no = "$dlself"; then dlself=needless export_dynamic=yes fi prev= continue ;; self) if test dlprefiles = "$prev"; then dlself=yes elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then dlself=yes else dlself=needless export_dynamic=yes fi prev= continue ;; *) if test dlfiles = "$prev"; then func_append dlfiles " $arg" else func_append dlprefiles " $arg" fi prev= continue ;; esac ;; expsyms) export_symbols=$arg test -f "$arg" \ || func_fatal_error "symbol file '$arg' does not exist" prev= continue ;; expsyms_regex) export_symbols_regex=$arg prev= continue ;; framework) case $host in *-*-darwin*) case "$deplibs " in *" $qarg.ltframework "*) ;; *) func_append deplibs " $qarg.ltframework" # this is fixed later ;; esac ;; esac prev= continue ;; inst_prefix) inst_prefix_dir=$arg prev= continue ;; mllvm) # Clang does not use LLVM to link, so we can simply discard any # '-mllvm $arg' options when doing the link step. prev= continue ;; objectlist) if test -f "$arg"; then save_arg=$arg moreargs= for fil in `cat "$save_arg"` do # func_append moreargs " $fil" arg=$fil # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test none = "$pic_object" && test none = "$non_pic_object"; then func_fatal_error "cannot find name of object for '$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir=$func_dirname_result if test none != "$pic_object"; then # Prepend the subdirectory the object is found in. pic_object=$xdir$pic_object if test dlfiles = "$prev"; then if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test dlprefiles = "$prev"; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg=$pic_object fi # Non-PIC object. if test none != "$non_pic_object"; then # Prepend the subdirectory the object is found in. non_pic_object=$xdir$non_pic_object # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test none = "$pic_object"; then arg=$non_pic_object fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object=$pic_object func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir=$func_dirname_result func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "'$arg' is not a valid libtool object" fi fi done else func_fatal_error "link input file '$arg' does not exist" fi arg=$save_arg prev= continue ;; os2dllname) os2dllname=$arg prev= continue ;; precious_regex) precious_files_regex=$arg prev= continue ;; release) release=-$arg prev= continue ;; rpath | xrpath) # We need an absolute path. case $arg in [\\/]* | [A-Za-z]:[\\/]*) ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac if test rpath = "$prev"; then case "$rpath " in *" $arg "*) ;; *) func_append rpath " $arg" ;; esac else case "$xrpath " in *" $arg "*) ;; *) func_append xrpath " $arg" ;; esac fi prev= continue ;; shrext) shrext_cmds=$arg prev= continue ;; weak) func_append weak_libs " $arg" prev= continue ;; xcclinker) func_append linker_flags " $qarg" func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xcompiler) func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xlinker) func_append linker_flags " $qarg" func_append compiler_flags " $wl$qarg" prev= func_append compile_command " $wl$qarg" func_append finalize_command " $wl$qarg" continue ;; *) eval "$prev=\"\$arg\"" prev= continue ;; esac fi # test -n "$prev" prevarg=$arg case $arg in -all-static) if test -n "$link_static_flag"; then # See comment for -static flag below, for more details. func_append compile_command " $link_static_flag" func_append finalize_command " $link_static_flag" fi continue ;; -allow-undefined) # FIXME: remove this flag sometime in the future. func_fatal_error "'-allow-undefined' must not be used because it is the default" ;; -avoid-version) avoid_version=yes continue ;; -bindir) prev=bindir continue ;; -dlopen) prev=dlfiles continue ;; -dlpreopen) prev=dlprefiles continue ;; -export-dynamic) export_dynamic=yes continue ;; -export-symbols | -export-symbols-regex) if test -n "$export_symbols" || test -n "$export_symbols_regex"; then func_fatal_error "more than one -exported-symbols argument is not allowed" fi if test X-export-symbols = "X$arg"; then prev=expsyms else prev=expsyms_regex fi continue ;; -framework) prev=framework continue ;; -inst-prefix-dir) prev=inst_prefix continue ;; # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* # so, if we see these flags be careful not to treat them like -L -L[A-Z][A-Z]*:*) case $with_gcc/$host in no/*-*-irix* | /*-*-irix*) func_append compile_command " $arg" func_append finalize_command " $arg" ;; esac continue ;; -L*) func_stripname "-L" '' "$arg" if test -z "$func_stripname_result"; then if test "$#" -gt 0; then func_fatal_error "require no space between '-L' and '$1'" else func_fatal_error "need path for '-L' option" fi fi func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) absdir=`cd "$dir" && pwd` test -z "$absdir" && \ func_fatal_error "cannot determine absolute directory name of '$dir'" dir=$absdir ;; esac case "$deplibs " in *" -L$dir "* | *" $arg "*) # Will only happen for absolute or sysroot arguments ;; *) # Preserve sysroot, but never include relative directories case $dir in [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; *) func_append deplibs " -L$dir" ;; esac func_append lib_search_path " $dir" ;; esac case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` case :$dllsearchpath: in *":$dir:"*) ;; ::) dllsearchpath=$dir;; *) func_append dllsearchpath ":$dir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac continue ;; -l*) if test X-lc = "X$arg" || test X-lm = "X$arg"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) # These systems don't actually have a C or math library (as such) continue ;; *-*-os2*) # These systems don't actually have a C library (as such) test X-lc = "X$arg" && continue ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) # Do not include libc due to us having libc/libc_r. test X-lc = "X$arg" && continue ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C and math libraries are in the System framework func_append deplibs " System.ltframework" continue ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype test X-lc = "X$arg" && continue ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work test X-lc = "X$arg" && continue ;; esac elif test X-lc_r = "X$arg"; then case $host in *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*) # Do not include libc_r directly, use -pthread flag. continue ;; esac fi func_append deplibs " $arg" continue ;; -mllvm) prev=mllvm continue ;; -module) module=yes continue ;; # Tru64 UNIX uses -model [arg] to determine the layout of C++ # classes, name mangling, and exception handling. # Darwin uses the -arch flag to determine output architecture. -model|-arch|-isysroot|--sysroot) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" prev=xcompiler continue ;; -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" case "$new_inherited_linker_flags " in *" $arg "*) ;; * ) func_append new_inherited_linker_flags " $arg" ;; esac continue ;; -multi_module) single_module=$wl-multi_module continue ;; -no-fast-install) fast_install=no continue ;; -no-install) case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) # The PATH hackery in wrapper scripts is required on Windows # and Darwin in order for the loader to find any dlls it needs. func_warning "'-no-install' is ignored for $host" func_warning "assuming '-no-fast-install' instead" fast_install=no ;; *) no_install=yes ;; esac continue ;; -no-undefined) allow_undefined=no continue ;; -objectlist) prev=objectlist continue ;; -os2dllname) prev=os2dllname continue ;; -o) prev=output ;; -precious-files-regex) prev=precious_regex continue ;; -release) prev=release continue ;; -rpath) prev=rpath continue ;; -R) prev=xrpath continue ;; -R*) func_stripname '-R' '' "$arg" dir=$func_stripname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; =*) func_stripname '=' '' "$dir" dir=$lt_sysroot$func_stripname_result ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac continue ;; -shared) # The effects of -shared are defined in a previous loop. continue ;; -shrext) prev=shrext continue ;; -static | -static-libtool-libs) # The effects of -static are defined in a previous loop. # We used to do the same as -all-static on platforms that # didn't have a PIC flag, but the assumption that the effects # would be equivalent was wrong. It would break on at least # Digital Unix and AIX. continue ;; -thread-safe) thread_safe=yes continue ;; -version-info) prev=vinfo continue ;; -version-number) prev=vinfo vinfo_number=yes continue ;; -weak) prev=weak continue ;; -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result arg= save_ifs=$IFS; IFS=, for flag in $args; do IFS=$save_ifs func_quote_for_eval "$flag" func_append arg " $func_quote_for_eval_result" func_append compiler_flags " $func_quote_for_eval_result" done IFS=$save_ifs func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Wl,*) func_stripname '-Wl,' '' "$arg" args=$func_stripname_result arg= save_ifs=$IFS; IFS=, for flag in $args; do IFS=$save_ifs func_quote_for_eval "$flag" func_append arg " $wl$func_quote_for_eval_result" func_append compiler_flags " $wl$func_quote_for_eval_result" func_append linker_flags " $func_quote_for_eval_result" done IFS=$save_ifs func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Xcompiler) prev=xcompiler continue ;; -Xlinker) prev=xlinker continue ;; -XCClinker) prev=xcclinker continue ;; # -msg_* for osf cc -msg_*) func_quote_for_eval "$arg" arg=$func_quote_for_eval_result ;; # Flags to be passed through unchanged, with rationale: # -64, -mips[0-9] enable 64-bit mode for the SGI compiler # -r[0-9][0-9]* specify processor for the SGI compiler # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler # +DA*, +DD* enable 64-bit mode for the HP compiler # -q* compiler args for the IBM compiler # -m*, -t[45]*, -txscale* architecture-specific flags for GCC # -F/path path to uninstalled frameworks, gcc on darwin # -p, -pg, --coverage, -fprofile-* profiling flags for GCC # -fstack-protector* stack protector flags for GCC # @file GCC response files # -tp=* Portland pgcc target processor selection # --sysroot=* for sysroot support # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization # -stdlib=* select c++ std lib with clang -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*) func_quote_for_eval "$arg" arg=$func_quote_for_eval_result func_append compile_command " $arg" func_append finalize_command " $arg" func_append compiler_flags " $arg" continue ;; -Z*) if test os2 = "`expr $host : '.*\(os2\)'`"; then # OS/2 uses -Zxxx to specify OS/2-specific options compiler_flags="$compiler_flags $arg" func_append compile_command " $arg" func_append finalize_command " $arg" case $arg in -Zlinker | -Zstack) prev=xcompiler ;; esac continue else # Otherwise treat like 'Some other compiler flag' below func_quote_for_eval "$arg" arg=$func_quote_for_eval_result fi ;; # Some other compiler flag. -* | +*) func_quote_for_eval "$arg" arg=$func_quote_for_eval_result ;; *.$objext) # A standard object. func_append objs " $arg" ;; *.lo) # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test none = "$pic_object" && test none = "$non_pic_object"; then func_fatal_error "cannot find name of object for '$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir=$func_dirname_result test none = "$pic_object" || { # Prepend the subdirectory the object is found in. pic_object=$xdir$pic_object if test dlfiles = "$prev"; then if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test dlprefiles = "$prev"; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg=$pic_object } # Non-PIC object. if test none != "$non_pic_object"; then # Prepend the subdirectory the object is found in. non_pic_object=$xdir$non_pic_object # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test none = "$pic_object"; then arg=$non_pic_object fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object=$pic_object func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir=$func_dirname_result func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "'$arg' is not a valid libtool object" fi fi ;; *.$libext) # An archive. func_append deplibs " $arg" func_append old_deplibs " $arg" continue ;; *.la) # A libtool-controlled library. func_resolve_sysroot "$arg" if test dlfiles = "$prev"; then # This library was specified with -dlopen. func_append dlfiles " $func_resolve_sysroot_result" prev= elif test dlprefiles = "$prev"; then # The library was specified with -dlpreopen. func_append dlprefiles " $func_resolve_sysroot_result" prev= else func_append deplibs " $func_resolve_sysroot_result" fi continue ;; # Some other compiler argument. *) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. func_quote_for_eval "$arg" arg=$func_quote_for_eval_result ;; esac # arg # Now actually substitute the argument into the commands. if test -n "$arg"; then func_append compile_command " $arg" func_append finalize_command " $arg" fi done # argument parsing loop test -n "$prev" && \ func_fatal_help "the '$prevarg' option requires an argument" if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then eval arg=\"$export_dynamic_flag_spec\" func_append compile_command " $arg" func_append finalize_command " $arg" fi oldlibs= # calculate the name of the file, without its directory func_basename "$output" outputname=$func_basename_result libobjs_save=$libobjs if test -n "$shlibpath_var"; then # get the directories listed in $shlibpath_var eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` else shlib_search_path= fi eval sys_lib_search_path=\"$sys_lib_search_path_spec\" eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" # Definition is injected by LT_CONFIG during libtool generation. func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" func_dirname "$output" "/" "" output_objdir=$func_dirname_result$objdir func_to_tool_file "$output_objdir/" tool_output_objdir=$func_to_tool_file_result # Create the object directory. func_mkdir_p "$output_objdir" # Determine the type of output case $output in "") func_fatal_help "you must specify an output file" ;; *.$libext) linkmode=oldlib ;; *.lo | *.$objext) linkmode=obj ;; *.la) linkmode=lib ;; *) linkmode=prog ;; # Anything else should be a program. esac specialdeplibs= libs= # Find all interdependent deplibs by searching for libraries # that are linked more than once (e.g. -la -lb -la) for deplib in $deplibs; do if $opt_preserve_dup_deps; then case "$libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append libs " $deplib" done if test lib = "$linkmode"; then libs="$predeps $libs $compiler_lib_search_path $postdeps" # Compute libraries that are listed more than once in $predeps # $postdeps and mark them as special (i.e., whose duplicates are # not to be eliminated). pre_post_deps= if $opt_duplicate_compiler_generated_deps; then for pre_post_dep in $predeps $postdeps; do case "$pre_post_deps " in *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; esac func_append pre_post_deps " $pre_post_dep" done fi pre_post_deps= fi deplibs= newdependency_libs= newlib_search_path= need_relink=no # whether we're linking any uninstalled libtool libraries notinst_deplibs= # not-installed libtool libraries notinst_path= # paths that contain not-installed libtool libraries case $linkmode in lib) passes="conv dlpreopen link" for file in $dlfiles $dlprefiles; do case $file in *.la) ;; *) func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" ;; esac done ;; prog) compile_deplibs= finalize_deplibs= alldeplibs=false newdlfiles= newdlprefiles= passes="conv scan dlopen dlpreopen link" ;; *) passes="conv" ;; esac for pass in $passes; do # The preopen pass in lib mode reverses $deplibs; put it back here # so that -L comes before libs that need it for instance... if test lib,link = "$linkmode,$pass"; then ## FIXME: Find the place where the list is rebuilt in the wrong ## order, and fix it there properly tmp_deplibs= for deplib in $deplibs; do tmp_deplibs="$deplib $tmp_deplibs" done deplibs=$tmp_deplibs fi if test lib,link = "$linkmode,$pass" || test prog,scan = "$linkmode,$pass"; then libs=$deplibs deplibs= fi if test prog = "$linkmode"; then case $pass in dlopen) libs=$dlfiles ;; dlpreopen) libs=$dlprefiles ;; link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; esac fi if test lib,dlpreopen = "$linkmode,$pass"; then # Collect and forward deplibs of preopened libtool libs for lib in $dlprefiles; do # Ignore non-libtool-libs dependency_libs= func_resolve_sysroot "$lib" case $lib in *.la) func_source "$func_resolve_sysroot_result" ;; esac # Collect preopened libtool deplibs, except any this library # has declared as weak libs for deplib in $dependency_libs; do func_basename "$deplib" deplib_base=$func_basename_result case " $weak_libs " in *" $deplib_base "*) ;; *) func_append deplibs " $deplib" ;; esac done done libs=$dlprefiles fi if test dlopen = "$pass"; then # Collect dlpreopened libraries save_deplibs=$deplibs deplibs= fi for deplib in $libs; do lib= found=false case $deplib in -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) if test prog,link = "$linkmode,$pass"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append compiler_flags " $deplib" if test lib = "$linkmode"; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -l*) if test lib != "$linkmode" && test prog != "$linkmode"; then func_warning "'-l' is ignored for archives/objects" continue fi func_stripname '-l' '' "$deplib" name=$func_stripname_result if test lib = "$linkmode"; then searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" else searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" fi for searchdir in $searchdirs; do for search_ext in .la $std_shrext .so .a; do # Search the libtool library lib=$searchdir/lib$name$search_ext if test -f "$lib"; then if test .la = "$search_ext"; then found=: else found=false fi break 2 fi done done if $found; then # deplib is a libtool library # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, # We need to do some special things here, and not later. if test yes = "$allow_libtool_libs_with_static_runtimes"; then case " $predeps $postdeps " in *" $deplib "*) if func_lalib_p "$lib"; then library_names= old_library= func_source "$lib" for l in $old_library $library_names; do ll=$l done if test "X$ll" = "X$old_library"; then # only static version available found=false func_dirname "$lib" "" "." ladir=$func_dirname_result lib=$ladir/$old_library if test prog,link = "$linkmode,$pass"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" fi continue fi fi ;; *) ;; esac fi else # deplib doesn't seem to be a libtool library if test prog,link = "$linkmode,$pass"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" fi continue fi ;; # -l *.ltframework) if test prog,link = "$linkmode,$pass"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" if test lib = "$linkmode"; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -L*) case $linkmode in lib) deplibs="$deplib $deplibs" test conv = "$pass" && continue newdependency_libs="$deplib $newdependency_libs" func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; prog) if test conv = "$pass"; then deplibs="$deplib $deplibs" continue fi if test scan = "$pass"; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; *) func_warning "'-L' is ignored for archives/objects" ;; esac # linkmode continue ;; # -L -R*) if test link = "$pass"; then func_stripname '-R' '' "$deplib" func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # Make sure the xrpath contains only unique directories. case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac fi deplibs="$deplib $deplibs" continue ;; *.la) func_resolve_sysroot "$deplib" lib=$func_resolve_sysroot_result ;; *.$libext) if test conv = "$pass"; then deplibs="$deplib $deplibs" continue fi case $linkmode in lib) # Linking convenience modules into shared libraries is allowed, # but linking other static libraries is non-portable. case " $dlpreconveniencelibs " in *" $deplib "*) ;; *) valid_a_lib=false case $deplibs_check_method in match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ | $EGREP "$match_pattern_regex" > /dev/null; then valid_a_lib=: fi ;; pass_all) valid_a_lib=: ;; esac if $valid_a_lib; then echo $ECHO "*** Warning: Linking the shared library $output against the" $ECHO "*** static library $deplib is not portable!" deplibs="$deplib $deplibs" else echo $ECHO "*** Warning: Trying to link with static lib archive $deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because the file extensions .$libext of this argument makes me believe" echo "*** that it is just a static archive that I should not use here." fi ;; esac continue ;; prog) if test link != "$pass"; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi continue ;; esac # linkmode ;; # *.$libext *.lo | *.$objext) if test conv = "$pass"; then deplibs="$deplib $deplibs" elif test prog = "$linkmode"; then if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then # If there is no dlopen support or we're linking statically, # we need to preload. func_append newdlprefiles " $deplib" compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append newdlfiles " $deplib" fi fi continue ;; %DEPLIBS%) alldeplibs=: continue ;; esac # case $deplib $found || test -f "$lib" \ || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$lib" \ || func_fatal_error "'$lib' is not a valid libtool archive" func_dirname "$lib" "" "." ladir=$func_dirname_result dlname= dlopen= dlpreopen= libdir= library_names= old_library= inherited_linker_flags= # If the library was installed with an old release of libtool, # it will not redefine variables installed, or shouldnotlink installed=yes shouldnotlink=no avoidtemprpath= # Read the .la file func_source "$lib" # Convert "-framework foo" to "foo.ltframework" if test -n "$inherited_linker_flags"; then tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do case " $new_inherited_linker_flags " in *" $tmp_inherited_linker_flag "*) ;; *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; esac done fi dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` if test lib,link = "$linkmode,$pass" || test prog,scan = "$linkmode,$pass" || { test prog != "$linkmode" && test lib != "$linkmode"; }; then test -n "$dlopen" && func_append dlfiles " $dlopen" test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" fi if test conv = "$pass"; then # Only check for convenience libraries deplibs="$lib $deplibs" if test -z "$libdir"; then if test -z "$old_library"; then func_fatal_error "cannot find name of link library for '$lib'" fi # It is a libtool convenience library, so add in its objects. func_append convenience " $ladir/$objdir/$old_library" func_append old_convenience " $ladir/$objdir/$old_library" elif test prog != "$linkmode" && test lib != "$linkmode"; then func_fatal_error "'$lib' is not a convenience library" fi tmp_libs= for deplib in $dependency_libs; do deplibs="$deplib $deplibs" if $opt_preserve_dup_deps; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done continue fi # $pass = conv # Get the name of the library we link against. linklib= if test -n "$old_library" && { test yes = "$prefer_static_libs" || test built,no = "$prefer_static_libs,$installed"; }; then linklib=$old_library else for l in $old_library $library_names; do linklib=$l done fi if test -z "$linklib"; then func_fatal_error "cannot find name of link library for '$lib'" fi # This library was specified with -dlopen. if test dlopen = "$pass"; then test -z "$libdir" \ && func_fatal_error "cannot -dlopen a convenience library: '$lib'" if test -z "$dlname" || test yes != "$dlopen_support" || test no = "$build_libtool_libs" then # If there is no dlname, no dlopen support or we're linking # statically, we need to preload. We also need to preload any # dependent libraries so libltdl's deplib preloader doesn't # bomb out in the load deplibs phase. func_append dlprefiles " $lib $dependency_libs" else func_append newdlfiles " $lib" fi continue fi # $pass = dlopen # We need an absolute path. case $ladir in [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; *) abs_ladir=`cd "$ladir" && pwd` if test -z "$abs_ladir"; then func_warning "cannot determine absolute directory name of '$ladir'" func_warning "passing it literally to the linker, although it might fail" abs_ladir=$ladir fi ;; esac func_basename "$lib" laname=$func_basename_result # Find the relevant object directory and library name. if test yes = "$installed"; then if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then func_warning "library '$lib' was moved." dir=$ladir absdir=$abs_ladir libdir=$abs_ladir else dir=$lt_sysroot$libdir absdir=$lt_sysroot$libdir fi test yes = "$hardcode_automatic" && avoidtemprpath=yes else if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then dir=$ladir absdir=$abs_ladir # Remove this search path later func_append notinst_path " $abs_ladir" else dir=$ladir/$objdir absdir=$abs_ladir/$objdir # Remove this search path later func_append notinst_path " $abs_ladir" fi fi # $installed = yes func_stripname 'lib' '.la' "$laname" name=$func_stripname_result # This library was specified with -dlpreopen. if test dlpreopen = "$pass"; then if test -z "$libdir" && test prog = "$linkmode"; then func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" fi case $host in # special handling for platforms with PE-DLLs. *cygwin* | *mingw* | *cegcc* ) # Linker will automatically link against shared library if both # static and shared are present. Therefore, ensure we extract # symbols from the import library if a shared library is present # (otherwise, the dlopen module name will be incorrect). We do # this by putting the import library name into $newdlprefiles. # We recover the dlopen module name by 'saving' the la file # name in a special purpose variable, and (later) extracting the # dlname from the la file. if test -n "$dlname"; then func_tr_sh "$dir/$linklib" eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" func_append newdlprefiles " $dir/$linklib" else func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" fi ;; * ) # Prefer using a static library (so that no silly _DYNAMIC symbols # are required to link). if test -n "$old_library"; then func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" # Otherwise, use the dlname, so that lt_dlopen finds it. elif test -n "$dlname"; then func_append newdlprefiles " $dir/$dlname" else func_append newdlprefiles " $dir/$linklib" fi ;; esac fi # $pass = dlpreopen if test -z "$libdir"; then # Link the convenience library if test lib = "$linkmode"; then deplibs="$dir/$old_library $deplibs" elif test prog,link = "$linkmode,$pass"; then compile_deplibs="$dir/$old_library $compile_deplibs" finalize_deplibs="$dir/$old_library $finalize_deplibs" else deplibs="$lib $deplibs" # used for prog,scan pass fi continue fi if test prog = "$linkmode" && test link != "$pass"; then func_append newlib_search_path " $ladir" deplibs="$lib $deplibs" linkalldeplibs=false if test no != "$link_all_deplibs" || test -z "$library_names" || test no = "$build_libtool_libs"; then linkalldeplibs=: fi tmp_libs= for deplib in $dependency_libs; do case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; esac # Need to link against all dependency_libs? if $linkalldeplibs; then deplibs="$deplib $deplibs" else # Need to hardcode shared library paths # or/and link against static libraries newdependency_libs="$deplib $newdependency_libs" fi if $opt_preserve_dup_deps; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done # for deplib continue fi # $linkmode = prog... if test prog,link = "$linkmode,$pass"; then if test -n "$library_names" && { { test no = "$prefer_static_libs" || test built,yes = "$prefer_static_libs,$installed"; } || test -z "$old_library"; }; then # We need to hardcode the library path if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then # Make sure the rpath contains only unique directories. case $temp_rpath: in *"$absdir:"*) ;; *) func_append temp_rpath "$absdir:" ;; esac fi # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi # $linkmode,$pass = prog,link... if $alldeplibs && { test pass_all = "$deplibs_check_method" || { test yes = "$build_libtool_libs" && test -n "$library_names"; }; }; then # We only need to search for static libraries continue fi fi link_static=no # Whether the deplib will be linked statically use_static_libs=$prefer_static_libs if test built = "$use_static_libs" && test yes = "$installed"; then use_static_libs=no fi if test -n "$library_names" && { test no = "$use_static_libs" || test -z "$old_library"; }; then case $host in *cygwin* | *mingw* | *cegcc* | *os2*) # No point in relinking DLLs because paths are not encoded func_append notinst_deplibs " $lib" need_relink=no ;; *) if test no = "$installed"; then func_append notinst_deplibs " $lib" need_relink=yes fi ;; esac # This is a shared library # Warn about portability, can't link against -module's on some # systems (darwin). Don't bleat about dlopened modules though! dlopenmodule= for dlpremoduletest in $dlprefiles; do if test "X$dlpremoduletest" = "X$lib"; then dlopenmodule=$dlpremoduletest break fi done if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then echo if test prog = "$linkmode"; then $ECHO "*** Warning: Linking the executable $output against the loadable module" else $ECHO "*** Warning: Linking the shared library $output against the loadable module" fi $ECHO "*** $linklib is not portable!" fi if test lib = "$linkmode" && test yes = "$hardcode_into_libs"; then # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi if test -n "$old_archive_from_expsyms_cmds"; then # figure out the soname set dummy $library_names shift realname=$1 shift libname=`eval "\\$ECHO \"$libname_spec\""` # use dlname if we got it. it's perfectly good, no? if test -n "$dlname"; then soname=$dlname elif test -n "$soname_spec"; then # bleh windows case $host in *cygwin* | mingw* | *cegcc* | *os2*) func_arith $current - $age major=$func_arith_result versuffix=-$major ;; esac eval soname=\"$soname_spec\" else soname=$realname fi # Make a new name for the extract_expsyms_cmds to use soroot=$soname func_basename "$soroot" soname=$func_basename_result func_stripname 'lib' '.dll' "$soname" newlib=libimp-$func_stripname_result.a # If the library has no export list, then create one now if test -f "$output_objdir/$soname-def"; then : else func_verbose "extracting exported symbol list from '$soname'" func_execute_cmds "$extract_expsyms_cmds" 'exit $?' fi # Create $newlib if test -f "$output_objdir/$newlib"; then :; else func_verbose "generating import library for '$soname'" func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' fi # make sure the library variables are pointing to the new library dir=$output_objdir linklib=$newlib fi # test -n "$old_archive_from_expsyms_cmds" if test prog = "$linkmode" || test relink != "$opt_mode"; then add_shlibpath= add_dir= add= lib_linked=yes case $hardcode_action in immediate | unsupported) if test no = "$hardcode_direct"; then add=$dir/$linklib case $host in *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; *-*-sysv4*uw2*) add_dir=-L$dir ;; *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ *-*-unixware7*) add_dir=-L$dir ;; *-*-darwin* ) # if the lib is a (non-dlopened) module then we cannot # link against it, someone is ignoring the earlier warnings if /usr/bin/file -L $add 2> /dev/null | $GREP ": [^:]* bundle" >/dev/null; then if test "X$dlopenmodule" != "X$lib"; then $ECHO "*** Warning: lib $linklib is a module, not a shared library" if test -z "$old_library"; then echo echo "*** And there doesn't seem to be a static archive available" echo "*** The link will probably fail, sorry" else add=$dir/$old_library fi elif test -n "$old_library"; then add=$dir/$old_library fi fi esac elif test no = "$hardcode_minus_L"; then case $host in *-*-sunos*) add_shlibpath=$dir ;; esac add_dir=-L$dir add=-l$name elif test no = "$hardcode_shlibpath_var"; then add_shlibpath=$dir add=-l$name else lib_linked=no fi ;; relink) if test yes = "$hardcode_direct" && test no = "$hardcode_direct_absolute"; then add=$dir/$linklib elif test yes = "$hardcode_minus_L"; then add_dir=-L$absdir # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add=-l$name elif test yes = "$hardcode_shlibpath_var"; then add_shlibpath=$dir add=-l$name else lib_linked=no fi ;; *) lib_linked=no ;; esac if test yes != "$lib_linked"; then func_fatal_configuration "unsupported hardcode properties" fi if test -n "$add_shlibpath"; then case :$compile_shlibpath: in *":$add_shlibpath:"*) ;; *) func_append compile_shlibpath "$add_shlibpath:" ;; esac fi if test prog = "$linkmode"; then test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" test -n "$add" && compile_deplibs="$add $compile_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" if test yes != "$hardcode_direct" && test yes != "$hardcode_minus_L" && test yes = "$hardcode_shlibpath_var"; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac fi fi fi if test prog = "$linkmode" || test relink = "$opt_mode"; then add_shlibpath= add_dir= add= # Finalize command for both is simple: just hardcode it. if test yes = "$hardcode_direct" && test no = "$hardcode_direct_absolute"; then add=$libdir/$linklib elif test yes = "$hardcode_minus_L"; then add_dir=-L$libdir add=-l$name elif test yes = "$hardcode_shlibpath_var"; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac add=-l$name elif test yes = "$hardcode_automatic"; then if test -n "$inst_prefix_dir" && test -f "$inst_prefix_dir$libdir/$linklib"; then add=$inst_prefix_dir$libdir/$linklib else add=$libdir/$linklib fi else # We cannot seem to hardcode it, guess we'll fake it. add_dir=-L$libdir # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add=-l$name fi if test prog = "$linkmode"; then test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" test -n "$add" && finalize_deplibs="$add $finalize_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" fi fi elif test prog = "$linkmode"; then # Here we assume that one of hardcode_direct or hardcode_minus_L # is not unsupported. This is valid on all known static and # shared platforms. if test unsupported != "$hardcode_direct"; then test -n "$old_library" && linklib=$old_library compile_deplibs="$dir/$linklib $compile_deplibs" finalize_deplibs="$dir/$linklib $finalize_deplibs" else compile_deplibs="-l$name -L$dir $compile_deplibs" finalize_deplibs="-l$name -L$dir $finalize_deplibs" fi elif test yes = "$build_libtool_libs"; then # Not a shared library if test pass_all != "$deplibs_check_method"; then # We're trying link a shared library against a static one # but the system doesn't support it. # Just print a warning and add the library to dependency_libs so # that the program can be linked against the static library. echo $ECHO "*** Warning: This system cannot link to static lib archive $lib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have." if test yes = "$module"; then echo "*** But as you try to build a module library, libtool will still create " echo "*** a static module, that should work as long as the dlopening application" echo "*** is linked with the -dlopen flag to resolve symbols at runtime." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using 'nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** 'nm' from GNU binutils and a full rebuild may help." fi if test no = "$build_old_libs"; then build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi else deplibs="$dir/$old_library $deplibs" link_static=yes fi fi # link shared/static library? if test lib = "$linkmode"; then if test -n "$dependency_libs" && { test yes != "$hardcode_into_libs" || test yes = "$build_old_libs" || test yes = "$link_static"; }; then # Extract -R from dependency_libs temp_deplibs= for libdir in $dependency_libs; do case $libdir in -R*) func_stripname '-R' '' "$libdir" temp_xrpath=$func_stripname_result case " $xrpath " in *" $temp_xrpath "*) ;; *) func_append xrpath " $temp_xrpath";; esac;; *) func_append temp_deplibs " $libdir";; esac done dependency_libs=$temp_deplibs fi func_append newlib_search_path " $absdir" # Link against this library test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" # ... and its dependency_libs tmp_libs= for deplib in $dependency_libs; do newdependency_libs="$deplib $newdependency_libs" case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result";; *) func_resolve_sysroot "$deplib" ;; esac if $opt_preserve_dup_deps; then case "$tmp_libs " in *" $func_resolve_sysroot_result "*) func_append specialdeplibs " $func_resolve_sysroot_result" ;; esac fi func_append tmp_libs " $func_resolve_sysroot_result" done if test no != "$link_all_deplibs"; then # Add the search paths of all dependency libraries for deplib in $dependency_libs; do path= case $deplib in -L*) path=$deplib ;; *.la) func_resolve_sysroot "$deplib" deplib=$func_resolve_sysroot_result func_dirname "$deplib" "" "." dir=$func_dirname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; *) absdir=`cd "$dir" && pwd` if test -z "$absdir"; then func_warning "cannot determine absolute directory name of '$dir'" absdir=$dir fi ;; esac if $GREP "^installed=no" $deplib > /dev/null; then case $host in *-*-darwin*) depdepl= eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` if test -n "$deplibrary_names"; then for tmp in $deplibrary_names; do depdepl=$tmp done if test -f "$absdir/$objdir/$depdepl"; then depdepl=$absdir/$objdir/$depdepl darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` if test -z "$darwin_install_name"; then darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` fi func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" path= fi fi ;; *) path=-L$absdir/$objdir ;; esac else eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` test -z "$libdir" && \ func_fatal_error "'$deplib' is not a valid libtool archive" test "$absdir" != "$libdir" && \ func_warning "'$deplib' seems to be moved" path=-L$absdir fi ;; esac case " $deplibs " in *" $path "*) ;; *) deplibs="$path $deplibs" ;; esac done fi # link_all_deplibs != no fi # linkmode = lib done # for deplib in $libs if test link = "$pass"; then if test prog = "$linkmode"; then compile_deplibs="$new_inherited_linker_flags $compile_deplibs" finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" else compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` fi fi dependency_libs=$newdependency_libs if test dlpreopen = "$pass"; then # Link the dlpreopened libraries before other libraries for deplib in $save_deplibs; do deplibs="$deplib $deplibs" done fi if test dlopen != "$pass"; then test conv = "$pass" || { # Make sure lib_search_path contains only unique directories. lib_search_path= for dir in $newlib_search_path; do case "$lib_search_path " in *" $dir "*) ;; *) func_append lib_search_path " $dir" ;; esac done newlib_search_path= } if test prog,link = "$linkmode,$pass"; then vars="compile_deplibs finalize_deplibs" else vars=deplibs fi for var in $vars dependency_libs; do # Add libraries to $var in reverse order eval tmp_libs=\"\$$var\" new_libs= for deplib in $tmp_libs; do # FIXME: Pedantically, this is the right thing to do, so # that some nasty dependency loop isn't accidentally # broken: #new_libs="$deplib $new_libs" # Pragmatically, this seems to cause very few problems in # practice: case $deplib in -L*) new_libs="$deplib $new_libs" ;; -R*) ;; *) # And here is the reason: when a library appears more # than once as an explicit dependence of a library, or # is implicitly linked in more than once by the # compiler, it is considered special, and multiple # occurrences thereof are not removed. Compare this # with having the same library being listed as a # dependency of multiple other libraries: in this case, # we know (pedantically, we assume) the library does not # need to be listed more than once, so we keep only the # last copy. This is not always right, but it is rare # enough that we require users that really mean to play # such unportable linking tricks to link the library # using -Wl,-lname, so that libtool does not consider it # for duplicate removal. case " $specialdeplibs " in *" $deplib "*) new_libs="$deplib $new_libs" ;; *) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$deplib $new_libs" ;; esac ;; esac ;; esac done tmp_libs= for deplib in $new_libs; do case $deplib in -L*) case " $tmp_libs " in *" $deplib "*) ;; *) func_append tmp_libs " $deplib" ;; esac ;; *) func_append tmp_libs " $deplib" ;; esac done eval $var=\"$tmp_libs\" done # for var fi # Add Sun CC postdeps if required: test CXX = "$tagname" && { case $host_os in linux*) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 func_suncc_cstd_abi if test no != "$suncc_use_cstd_abi"; then func_append postdeps ' -library=Cstd -library=Crun' fi ;; esac ;; solaris*) func_cc_basename "$CC" case $func_cc_basename_result in CC* | sunCC*) func_suncc_cstd_abi if test no != "$suncc_use_cstd_abi"; then func_append postdeps ' -library=Cstd -library=Crun' fi ;; esac ;; esac } # Last step: remove runtime libs from dependency_libs # (they stay in deplibs) tmp_libs= for i in $dependency_libs; do case " $predeps $postdeps $compiler_lib_search_path " in *" $i "*) i= ;; esac if test -n "$i"; then func_append tmp_libs " $i" fi done dependency_libs=$tmp_libs done # for pass if test prog = "$linkmode"; then dlfiles=$newdlfiles fi if test prog = "$linkmode" || test lib = "$linkmode"; then dlprefiles=$newdlprefiles fi case $linkmode in oldlib) if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then func_warning "'-dlopen' is ignored for archives" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "'-l' and '-L' are ignored for archives" ;; esac test -n "$rpath" && \ func_warning "'-rpath' is ignored for archives" test -n "$xrpath" && \ func_warning "'-R' is ignored for archives" test -n "$vinfo" && \ func_warning "'-version-info/-version-number' is ignored for archives" test -n "$release" && \ func_warning "'-release' is ignored for archives" test -n "$export_symbols$export_symbols_regex" && \ func_warning "'-export-symbols' is ignored for archives" # Now set the variables for building old libraries. build_libtool_libs=no oldlibs=$output func_append objs "$old_deplibs" ;; lib) # Make sure we only generate libraries of the form 'libNAME.la'. case $outputname in lib*) func_stripname 'lib' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" ;; *) test no = "$module" \ && func_fatal_help "libtool library '$output' must begin with 'lib'" if test no != "$need_lib_prefix"; then # Add the "lib" prefix for modules if required func_stripname '' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" else func_stripname '' '.la' "$outputname" libname=$func_stripname_result fi ;; esac if test -n "$objs"; then if test pass_all != "$deplibs_check_method"; then func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" else echo $ECHO "*** Warning: Linking the shared library $output against the non-libtool" $ECHO "*** objects $objs is not portable!" func_append libobjs " $objs" fi fi test no = "$dlself" \ || func_warning "'-dlopen self' is ignored for libtool libraries" set dummy $rpath shift test 1 -lt "$#" \ && func_warning "ignoring multiple '-rpath's for a libtool library" install_libdir=$1 oldlibs= if test -z "$rpath"; then if test yes = "$build_libtool_libs"; then # Building a libtool convenience library. # Some compilers have problems with a '.al' extension so # convenience libraries should have the same extension an # archive normally would. oldlibs="$output_objdir/$libname.$libext $oldlibs" build_libtool_libs=convenience build_old_libs=yes fi test -n "$vinfo" && \ func_warning "'-version-info/-version-number' is ignored for convenience libraries" test -n "$release" && \ func_warning "'-release' is ignored for convenience libraries" else # Parse the version information argument. save_ifs=$IFS; IFS=: set dummy $vinfo 0 0 0 shift IFS=$save_ifs test -n "$7" && \ func_fatal_help "too many parameters to '-version-info'" # convert absolute version numbers to libtool ages # this retains compatibility with .la files and attempts # to make the code below a bit more comprehensible case $vinfo_number in yes) number_major=$1 number_minor=$2 number_revision=$3 # # There are really only two kinds -- those that # use the current revision as the major version # and those that subtract age and use age as # a minor version. But, then there is irix # that has an extra 1 added just for fun # case $version_type in # correct linux to gnu/linux during the next big refactor darwin|freebsd-elf|linux|osf|windows|none) func_arith $number_major + $number_minor current=$func_arith_result age=$number_minor revision=$number_revision ;; freebsd-aout|qnx|sunos) current=$number_major revision=$number_minor age=0 ;; irix|nonstopux) func_arith $number_major + $number_minor current=$func_arith_result age=$number_minor revision=$number_minor lt_irix_increment=no ;; esac ;; no) current=$1 revision=$2 age=$3 ;; esac # Check that each of the things are valid numbers. case $current in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "CURRENT '$current' must be a nonnegative integer" func_fatal_error "'$vinfo' is not valid version information" ;; esac case $revision in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "REVISION '$revision' must be a nonnegative integer" func_fatal_error "'$vinfo' is not valid version information" ;; esac case $age in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "AGE '$age' must be a nonnegative integer" func_fatal_error "'$vinfo' is not valid version information" ;; esac if test "$age" -gt "$current"; then func_error "AGE '$age' is greater than the current interface number '$current'" func_fatal_error "'$vinfo' is not valid version information" fi # Calculate the version variables. major= versuffix= verstring= case $version_type in none) ;; darwin) # Like Linux, but with the current version available in # verstring for coding it into the library header func_arith $current - $age major=.$func_arith_result versuffix=$major.$age.$revision # Darwin ld doesn't like 0 for these options... func_arith $current + 1 minor_current=$func_arith_result xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" # On Darwin other compilers case $CC in nagfor*) verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" ;; *) verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" ;; esac ;; freebsd-aout) major=.$current versuffix=.$current.$revision ;; freebsd-elf) func_arith $current - $age major=.$func_arith_result versuffix=$major.$age.$revision ;; irix | nonstopux) if test no = "$lt_irix_increment"; then func_arith $current - $age else func_arith $current - $age + 1 fi major=$func_arith_result case $version_type in nonstopux) verstring_prefix=nonstopux ;; *) verstring_prefix=sgi ;; esac verstring=$verstring_prefix$major.$revision # Add in all the interfaces that we are compatible with. loop=$revision while test 0 -ne "$loop"; do func_arith $revision - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring=$verstring_prefix$major.$iface:$verstring done # Before this point, $major must not contain '.'. major=.$major versuffix=$major.$revision ;; linux) # correct to gnu/linux during the next big refactor func_arith $current - $age major=.$func_arith_result versuffix=$major.$age.$revision ;; osf) func_arith $current - $age major=.$func_arith_result versuffix=.$current.$age.$revision verstring=$current.$age.$revision # Add in all the interfaces that we are compatible with. loop=$age while test 0 -ne "$loop"; do func_arith $current - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring=$verstring:$iface.0 done # Make executables depend on our current version. func_append verstring ":$current.0" ;; qnx) major=.$current versuffix=.$current ;; sco) major=.$current versuffix=.$current ;; sunos) major=.$current versuffix=.$current.$revision ;; windows) # Use '-' rather than '.', since we only want one # extension on DOS 8.3 file systems. func_arith $current - $age major=$func_arith_result versuffix=-$major ;; *) func_fatal_configuration "unknown library version type '$version_type'" ;; esac # Clear the version info if we defaulted, and they specified a release. if test -z "$vinfo" && test -n "$release"; then major= case $version_type in darwin) # we can't check for "0.0" in archive_cmds due to quoting # problems, so we reset it completely verstring= ;; *) verstring=0.0 ;; esac if test no = "$need_version"; then versuffix= else versuffix=.0.0 fi fi # Remove version info from name if versioning should be avoided if test yes,no = "$avoid_version,$need_version"; then major= versuffix= verstring= fi # Check to see if the archive will have undefined symbols. if test yes = "$allow_undefined"; then if test unsupported = "$allow_undefined_flag"; then if test yes = "$build_old_libs"; then func_warning "undefined symbols not allowed in $host shared libraries; building static only" build_libtool_libs=no else func_fatal_error "can't build $host shared library unless -no-undefined is specified" fi fi else # Don't allow undefined symbols. allow_undefined_flag=$no_undefined_flag fi fi func_generate_dlsyms "$libname" "$libname" : func_append libobjs " $symfileobj" test " " = "$libobjs" && libobjs= if test relink != "$opt_mode"; then # Remove our outputs, but don't remove object files since they # may have been created when compiling PIC objects. removelist= tempremovelist=`$ECHO "$output_objdir/*"` for p in $tempremovelist; do case $p in *.$objext | *.gcno) ;; $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) if test -n "$precious_files_regex"; then if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 then continue fi fi func_append removelist " $p" ;; *) ;; esac done test -n "$removelist" && \ func_show_eval "${RM}r \$removelist" fi # Now set the variables for building old libraries. if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then func_append oldlibs " $output_objdir/$libname.$libext" # Transform .lo files to .o files. oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` fi # Eliminate all temporary directories. #for path in $notinst_path; do # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` #done if test -n "$xrpath"; then # If the user specified any rpath flags, then add them. temp_xrpath= for libdir in $xrpath; do func_replace_sysroot "$libdir" func_append temp_xrpath " -R$func_replace_sysroot_result" case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then dependency_libs="$temp_xrpath $dependency_libs" fi fi # Make sure dlfiles contains only unique files that won't be dlpreopened old_dlfiles=$dlfiles dlfiles= for lib in $old_dlfiles; do case " $dlprefiles $dlfiles " in *" $lib "*) ;; *) func_append dlfiles " $lib" ;; esac done # Make sure dlprefiles contains only unique files old_dlprefiles=$dlprefiles dlprefiles= for lib in $old_dlprefiles; do case "$dlprefiles " in *" $lib "*) ;; *) func_append dlprefiles " $lib" ;; esac done if test yes = "$build_libtool_libs"; then if test -n "$rpath"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) # these systems don't actually have a c library (as such)! ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C library is in the System framework func_append deplibs " System.ltframework" ;; *-*-netbsd*) # Don't link with libc until the a.out ld.so is fixed. ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work ;; *) # Add libc to deplibs on all other systems if necessary. if test yes = "$build_libtool_need_lc"; then func_append deplibs " -lc" fi ;; esac fi # Transform deplibs into only deplibs that can be linked in shared. name_save=$name libname_save=$libname release_save=$release versuffix_save=$versuffix major_save=$major # I'm not sure if I'm treating the release correctly. I think # release should show up in the -l (ie -lgmp5) so we don't want to # add it in twice. Is that correct? release= versuffix= major= newdeplibs= droppeddeps=no case $deplibs_check_method in pass_all) # Don't check for shared/static. Everything works. # This might be a little naive. We might want to check # whether the library exists or not. But this is on # osf3 & osf4 and I'm not really sure... Just # implementing what was already the behavior. newdeplibs=$deplibs ;; test_compile) # This code stresses the "libraries are programs" paradigm to its # limits. Maybe even breaks it. We compile a program, linking it # against the deplibs as a proxy for the library. Then we can check # whether they linked in statically or dynamically with ldd. $opt_dry_run || $RM conftest.c cat > conftest.c </dev/null` $nocaseglob else potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` fi for potent_lib in $potential_libs; do # Follow soft links. if ls -lLd "$potent_lib" 2>/dev/null | $GREP " -> " >/dev/null; then continue fi # The statement above tries to avoid entering an # endless loop below, in case of cyclic links. # We might still enter an endless loop, since a link # loop can be closed while we follow links, # but so what? potlib=$potent_lib while test -h "$potlib" 2>/dev/null; do potliblink=`ls -ld $potlib | $SED 's/.* -> //'` case $potliblink in [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; esac done if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | $SED -e 10q | $EGREP "$file_magic_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib= break 2 fi done done fi if test -n "$a_deplib"; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib"; then $ECHO "*** with $libname but no candidates were found. (...for file magic test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a file magic. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` for a_deplib in $deplibs; do case $a_deplib in -l*) func_stripname -l '' "$a_deplib" name=$func_stripname_result if test yes = "$allow_libtool_libs_with_static_runtimes"; then case " $predeps $postdeps " in *" $a_deplib "*) func_append newdeplibs " $a_deplib" a_deplib= ;; esac fi if test -n "$a_deplib"; then libname=`eval "\\$ECHO \"$libname_spec\""` for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do potential_libs=`ls $i/$libname[.-]* 2>/dev/null` for potent_lib in $potential_libs; do potlib=$potent_lib # see symlink-check above in file_magic test if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ $EGREP "$match_pattern_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib= break 2 fi done done fi if test -n "$a_deplib"; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib"; then $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a regex pattern. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; none | unknown | *) newdeplibs= tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` if test yes = "$allow_libtool_libs_with_static_runtimes"; then for i in $predeps $postdeps; do # can't use Xsed below, because $i might contain '/' tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` done fi case $tmp_deplibs in *[!\ \ ]*) echo if test none = "$deplibs_check_method"; then echo "*** Warning: inter-library dependencies are not supported in this platform." else echo "*** Warning: inter-library dependencies are not known to be supported." fi echo "*** All declared inter-library dependencies are being dropped." droppeddeps=yes ;; esac ;; esac versuffix=$versuffix_save major=$major_save release=$release_save libname=$libname_save name=$name_save case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library with the System framework newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac if test yes = "$droppeddeps"; then if test yes = "$module"; then echo echo "*** Warning: libtool could not satisfy all declared inter-library" $ECHO "*** dependencies of module $libname. Therefore, libtool will create" echo "*** a static module, that should work as long as the dlopening" echo "*** application is linked with the -dlopen flag." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using 'nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** 'nm' from GNU binutils and a full rebuild may help." fi if test no = "$build_old_libs"; then oldlibs=$output_objdir/$libname.$libext build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi else echo "*** The inter-library dependencies that have been dropped here will be" echo "*** automatically added whenever a program is linked with this library" echo "*** or is declared to -dlopen it." if test no = "$allow_undefined"; then echo echo "*** Since this library must not contain undefined symbols," echo "*** because either the platform does not support them or" echo "*** it was explicitly requested with -no-undefined," echo "*** libtool will only create a static version of it." if test no = "$build_old_libs"; then oldlibs=$output_objdir/$libname.$libext build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi fi fi # Done checking deplibs! deplibs=$newdeplibs fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" case $host in *-*-darwin*) newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done deplibs=$new_libs # All the library-specific variables (install_libdir is set above). library_names= old_library= dlname= # Test again, we may have decided not to build it any more if test yes = "$build_libtool_libs"; then # Remove $wl instances when linking with ld. # FIXME: should test the right _cmds variable. case $archive_cmds in *\$LD\ *) wl= ;; esac if test yes = "$hardcode_into_libs"; then # Hardcode the library paths hardcode_libdirs= dep_rpath= rpath=$finalize_rpath test relink = "$opt_mode" || rpath=$compile_rpath$rpath for libdir in $rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then func_replace_sysroot "$libdir" libdir=$func_replace_sysroot_result if test -z "$hardcode_libdirs"; then hardcode_libdirs=$libdir else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append dep_rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir=$hardcode_libdirs eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" fi if test -n "$runpath_var" && test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" fi test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" fi shlibpath=$finalize_shlibpath test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath if test -n "$shlibpath"; then eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" fi # Get the real and link names of the library. eval shared_ext=\"$shrext_cmds\" eval library_names=\"$library_names_spec\" set dummy $library_names shift realname=$1 shift if test -n "$soname_spec"; then eval soname=\"$soname_spec\" else soname=$realname fi if test -z "$dlname"; then dlname=$soname fi lib=$output_objdir/$realname linknames= for link do func_append linknames " $link" done # Use standard objects if they are pic test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` test "X$libobjs" = "X " && libobjs= delfiles= if test -n "$export_symbols" && test -n "$include_expsyms"; then $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" export_symbols=$output_objdir/$libname.uexp func_append delfiles " $export_symbols" fi orig_export_symbols= case $host_os in cygwin* | mingw* | cegcc*) if test -n "$export_symbols" && test -z "$export_symbols_regex"; then # exporting using user supplied symfile func_dll_def_p "$export_symbols" || { # and it's NOT already a .def file. Must figure out # which of the given symbols are data symbols and tag # them as such. So, trigger use of export_symbols_cmds. # export_symbols gets reassigned inside the "prepare # the list of exported symbols" if statement, so the # include_expsyms logic still works. orig_export_symbols=$export_symbols export_symbols= always_export_symbols=yes } fi ;; esac # Prepare the list of exported symbols if test -z "$export_symbols"; then if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then func_verbose "generating symbol list for '$libname.la'" export_symbols=$output_objdir/$libname.exp $opt_dry_run || $RM $export_symbols cmds=$export_symbols_cmds save_ifs=$IFS; IFS='~' for cmd1 in $cmds; do IFS=$save_ifs # Take the normal branch if the nm_file_list_spec branch # doesn't work or if tool conversion is not needed. case $nm_file_list_spec~$to_tool_file_cmd in *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) try_normal_branch=yes eval cmd=\"$cmd1\" func_len " $cmd" len=$func_len_result ;; *) try_normal_branch=no ;; esac if test yes = "$try_normal_branch" \ && { test "$len" -lt "$max_cmd_len" \ || test "$max_cmd_len" -le -1; } then func_show_eval "$cmd" 'exit $?' skipped_export=false elif test -n "$nm_file_list_spec"; then func_basename "$output" output_la=$func_basename_result save_libobjs=$libobjs save_output=$output output=$output_objdir/$output_la.nm func_to_tool_file "$output" libobjs=$nm_file_list_spec$func_to_tool_file_result func_append delfiles " $output" func_verbose "creating $NM input file list: $output" for obj in $save_libobjs; do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > "$output" eval cmd=\"$cmd1\" func_show_eval "$cmd" 'exit $?' output=$save_output libobjs=$save_libobjs skipped_export=false else # The command line is too long to execute in one step. func_verbose "using reloadable object file for export list..." skipped_export=: # Break out early, otherwise skipped_export may be # set to false by a later but shorter cmd. break fi done IFS=$save_ifs if test -n "$export_symbols_regex" && test : != "$skipped_export"; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi fi if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols=$export_symbols test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test : != "$skipped_export" && test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for '$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands, which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi tmp_deplibs= for test_deplib in $deplibs; do case " $convenience " in *" $test_deplib "*) ;; *) func_append tmp_deplibs " $test_deplib" ;; esac done deplibs=$tmp_deplibs if test -n "$convenience"; then if test -n "$whole_archive_flag_spec" && test yes = "$compiler_needs_object" && test -z "$libobjs"; then # extract the archives, so we have objects to list. # TODO: could optimize this to just extract one archive. whole_archive_flag_spec= fi if test -n "$whole_archive_flag_spec"; then save_libobjs=$libobjs eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= else gentop=$output_objdir/${outputname}x func_append generated " $gentop" func_extract_archives $gentop $convenience func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi fi if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then eval flag=\"$thread_safe_flag_spec\" func_append linker_flags " $flag" fi # Make a backup of the uninstalled library when relinking if test relink = "$opt_mode"; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? fi # Do each of the archive commands. if test yes = "$module" && test -n "$module_cmds"; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then eval test_cmds=\"$module_expsym_cmds\" cmds=$module_expsym_cmds else eval test_cmds=\"$module_cmds\" cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then eval test_cmds=\"$archive_expsym_cmds\" cmds=$archive_expsym_cmds else eval test_cmds=\"$archive_cmds\" cmds=$archive_cmds fi fi if test : != "$skipped_export" && func_len " $test_cmds" && len=$func_len_result && test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then : else # The command line is too long to link in one step, link piecewise # or, if using GNU ld and skipped_export is not :, use a linker # script. # Save the value of $output and $libobjs because we want to # use them later. If we have whole_archive_flag_spec, we # want to use save_libobjs as it was before # whole_archive_flag_spec was expanded, because we can't # assume the linker understands whole_archive_flag_spec. # This may have to be revisited, in case too many # convenience libraries get linked in and end up exceeding # the spec. if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then save_libobjs=$libobjs fi save_output=$output func_basename "$output" output_la=$func_basename_result # Clear the reloadable object creation command queue and # initialize k to one. test_cmds= concat_cmds= objlist= last_robj= k=1 if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then output=$output_objdir/$output_la.lnkscript func_verbose "creating GNU ld script: $output" echo 'INPUT (' > $output for obj in $save_libobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done echo ')' >> $output func_append delfiles " $output" func_to_tool_file "$output" output=$func_to_tool_file_result elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then output=$output_objdir/$output_la.lnk func_verbose "creating linker input file list: $output" : > $output set x $save_libobjs shift firstobj= if test yes = "$compiler_needs_object"; then firstobj="$1 " shift fi for obj do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done func_append delfiles " $output" func_to_tool_file "$output" output=$firstobj\"$file_list_spec$func_to_tool_file_result\" else if test -n "$save_libobjs"; then func_verbose "creating reloadable object files..." output=$output_objdir/$output_la-$k.$objext eval test_cmds=\"$reload_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 # Loop over the list of objects to be linked. for obj in $save_libobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result if test -z "$objlist" || test "$len" -lt "$max_cmd_len"; then func_append objlist " $obj" else # The command $test_cmds is almost too long, add a # command to the queue. if test 1 -eq "$k"; then # The first file doesn't have a previous command to add. reload_objs=$objlist eval concat_cmds=\"$reload_cmds\" else # All subsequent reloadable object files will link in # the last one created. reload_objs="$objlist $last_robj" eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" fi last_robj=$output_objdir/$output_la-$k.$objext func_arith $k + 1 k=$func_arith_result output=$output_objdir/$output_la-$k.$objext objlist=" $obj" func_len " $last_robj" func_arith $len0 + $func_len_result len=$func_arith_result fi done # Handle the remaining objects by creating one last # reloadable object file. All subsequent reloadable object # files will link in the last one created. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ reload_objs="$objlist $last_robj" eval concat_cmds=\"\$concat_cmds$reload_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" fi func_append delfiles " $output" else output= fi ${skipped_export-false} && { func_verbose "generating symbol list for '$libname.la'" export_symbols=$output_objdir/$libname.exp $opt_dry_run || $RM $export_symbols libobjs=$output # Append the command to create the export file. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" fi } test -n "$save_libobjs" && func_verbose "creating a temporary reloadable object file: $output" # Loop through the commands generated above and execute them. save_ifs=$IFS; IFS='~' for cmd in $concat_cmds; do IFS=$save_ifs $opt_quiet || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test relink = "$opt_mode"; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS=$save_ifs if test -n "$export_symbols_regex" && ${skipped_export-false}; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi ${skipped_export-false} && { if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols=$export_symbols test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for '$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands, which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi } libobjs=$output # Restore the value of output. output=$save_output if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= fi # Expand the library linking commands again to reset the # value of $libobjs for piecewise linking. # Do each of the archive commands. if test yes = "$module" && test -n "$module_cmds"; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then cmds=$module_expsym_cmds else cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then cmds=$archive_expsym_cmds else cmds=$archive_cmds fi fi fi if test -n "$delfiles"; then # Append the command to remove temporary files to $cmds. eval cmds=\"\$cmds~\$RM $delfiles\" fi # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop=$output_objdir/${outputname}x func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi save_ifs=$IFS; IFS='~' for cmd in $cmds; do IFS=$sp$nl eval cmd=\"$cmd\" IFS=$save_ifs $opt_quiet || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test relink = "$opt_mode"; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS=$save_ifs # Restore the uninstalled library and exit if test relink = "$opt_mode"; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? if test -n "$convenience"; then if test -z "$whole_archive_flag_spec"; then func_show_eval '${RM}r "$gentop"' fi fi exit $EXIT_SUCCESS fi # Create links to the real library. for linkname in $linknames; do if test "$realname" != "$linkname"; then func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' fi done # If -module or -export-dynamic was specified, set the dlname. if test yes = "$module" || test yes = "$export_dynamic"; then # On all known operating systems, these are identical. dlname=$soname fi fi ;; obj) if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then func_warning "'-dlopen' is ignored for objects" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "'-l' and '-L' are ignored for objects" ;; esac test -n "$rpath" && \ func_warning "'-rpath' is ignored for objects" test -n "$xrpath" && \ func_warning "'-R' is ignored for objects" test -n "$vinfo" && \ func_warning "'-version-info' is ignored for objects" test -n "$release" && \ func_warning "'-release' is ignored for objects" case $output in *.lo) test -n "$objs$old_deplibs" && \ func_fatal_error "cannot build library object '$output' from non-libtool objects" libobj=$output func_lo2o "$libobj" obj=$func_lo2o_result ;; *) libobj= obj=$output ;; esac # Delete the old objects. $opt_dry_run || $RM $obj $libobj # Objects from convenience libraries. This assumes # single-version convenience libraries. Whenever we create # different ones for PIC/non-PIC, this we'll have to duplicate # the extraction. reload_conv_objs= gentop= # if reload_cmds runs $LD directly, get rid of -Wl from # whole_archive_flag_spec and hope we can get by with turning comma # into space. case $reload_cmds in *\$LD[\ \$]*) wl= ;; esac if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags else gentop=$output_objdir/${obj}x func_append generated " $gentop" func_extract_archives $gentop $convenience reload_conv_objs="$reload_objs $func_extract_archives_result" fi fi # If we're not building shared, we need to use non_pic_objs test yes = "$build_libtool_libs" || libobjs=$non_pic_objects # Create the old-style object. reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs output=$obj func_execute_cmds "$reload_cmds" 'exit $?' # Exit if we aren't doing a library object file. if test -z "$libobj"; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS fi test yes = "$build_libtool_libs" || { if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi # Create an invalid libtool object if no PIC, so that we don't # accidentally link it into a program. # $show "echo timestamp > $libobj" # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? exit $EXIT_SUCCESS } if test -n "$pic_flag" || test default != "$pic_mode"; then # Only do commands if we really have different PIC objects. reload_objs="$libobjs $reload_conv_objs" output=$libobj func_execute_cmds "$reload_cmds" 'exit $?' fi if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS ;; prog) case $host in *cygwin*) func_stripname '' '.exe' "$output" output=$func_stripname_result.exe;; esac test -n "$vinfo" && \ func_warning "'-version-info' is ignored for programs" test -n "$release" && \ func_warning "'-release' is ignored for programs" $preload \ && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library is the System framework compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac case $host in *-*-darwin*) # Don't allow lazy linking, it breaks C++ global constructors # But is supposedly fixed on 10.4 or later (yay!). if test CXX = "$tagname"; then case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10.[0123]) func_append compile_command " $wl-bind_at_load" func_append finalize_command " $wl-bind_at_load" ;; esac fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $compile_deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $compile_deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done compile_deplibs=$new_libs func_append compile_command " $compile_deplibs" func_append finalize_command " $finalize_deplibs" if test -n "$rpath$xrpath"; then # If the user specified any rpath flags, then add them. for libdir in $rpath $xrpath; do # This is the magic to use -rpath. case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done fi # Now hardcode the library paths rpath= hardcode_libdirs= for libdir in $compile_rpath $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs=$libdir else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` case :$dllsearchpath: in *":$libdir:"*) ;; ::) dllsearchpath=$libdir;; *) func_append dllsearchpath ":$libdir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir=$hardcode_libdirs eval rpath=\" $hardcode_libdir_flag_spec\" fi compile_rpath=$rpath rpath= hardcode_libdirs= for libdir in $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs=$libdir else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$finalize_perm_rpath " in *" $libdir "*) ;; *) func_append finalize_perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir=$hardcode_libdirs eval rpath=\" $hardcode_libdir_flag_spec\" fi finalize_rpath=$rpath if test -n "$libobjs" && test yes = "$build_old_libs"; then # Transform all the library objects into standard objects. compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` fi func_generate_dlsyms "$outputname" "@PROGRAM@" false # template prelinking step if test -n "$prelink_cmds"; then func_execute_cmds "$prelink_cmds" 'exit $?' fi wrappers_required=: case $host in *cegcc* | *mingw32ce*) # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. wrappers_required=false ;; *cygwin* | *mingw* ) test yes = "$build_libtool_libs" || wrappers_required=false ;; *) if test no = "$need_relink" || test yes != "$build_libtool_libs"; then wrappers_required=false fi ;; esac $wrappers_required || { # Replace the output file specification. compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` link_command=$compile_command$compile_rpath # We have no uninstalled library dependencies, so finalize right now. exit_status=0 func_show_eval "$link_command" 'exit_status=$?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Delete the generated files. if test -f "$output_objdir/${outputname}S.$objext"; then func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' fi exit $exit_status } if test -n "$compile_shlibpath$finalize_shlibpath"; then compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" fi if test -n "$finalize_shlibpath"; then finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" fi compile_var= finalize_var= if test -n "$runpath_var"; then if test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done compile_var="$runpath_var=\"$rpath\$$runpath_var\" " fi if test -n "$finalize_perm_rpath"; then # We should set the runpath_var. rpath= for dir in $finalize_perm_rpath; do func_append rpath "$dir:" done finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " fi fi if test yes = "$no_install"; then # We don't need to create a wrapper script. link_command=$compile_var$compile_command$compile_rpath # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` # Delete the old output file. $opt_dry_run || $RM $output # Link the executable and exit func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi exit $EXIT_SUCCESS fi case $hardcode_action,$fast_install in relink,*) # Fast installation is not supported link_command=$compile_var$compile_command$compile_rpath relink_command=$finalize_var$finalize_command$finalize_rpath func_warning "this platform does not like uninstalled shared libraries" func_warning "'$output' will be relinked during installation" ;; *,yes) link_command=$finalize_var$compile_command$finalize_rpath relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` ;; *,no) link_command=$compile_var$compile_command$compile_rpath relink_command=$finalize_var$finalize_command$finalize_rpath ;; *,needless) link_command=$finalize_var$compile_command$finalize_rpath relink_command= ;; esac # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` # Delete the old output files. $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output_objdir/$outputname" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Now create the wrapper script. func_verbose "creating $output" # Quote the relink command for shipping. if test -n "$relink_command"; then # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done relink_command="(cd `pwd`; $relink_command)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` fi # Only actually do things if not in dry run mode. $opt_dry_run || { # win32 will think the script is a binary if it has # a .exe suffix, so we strip it off here. case $output in *.exe) func_stripname '' '.exe' "$output" output=$func_stripname_result ;; esac # test for cygwin because mv fails w/o .exe extensions case $host in *cygwin*) exeext=.exe func_stripname '' '.exe' "$outputname" outputname=$func_stripname_result ;; *) exeext= ;; esac case $host in *cygwin* | *mingw* ) func_dirname_and_basename "$output" "" "." output_name=$func_basename_result output_path=$func_dirname_result cwrappersource=$output_path/$objdir/lt-$output_name.c cwrapper=$output_path/$output_name.exe $RM $cwrappersource $cwrapper trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 func_emit_cwrapperexe_src > $cwrappersource # The wrapper executable is built using the $host compiler, # because it contains $host paths and files. If cross- # compiling, it, like the target executable, must be # executed on the $host or under an emulation environment. $opt_dry_run || { $LTCC $LTCFLAGS -o $cwrapper $cwrappersource $STRIP $cwrapper } # Now, create the wrapper script for func_source use: func_ltwrapper_scriptname $cwrapper $RM $func_ltwrapper_scriptname_result trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 $opt_dry_run || { # note: this script will not be executed, so do not chmod. if test "x$build" = "x$host"; then $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result else func_emit_wrapper no > $func_ltwrapper_scriptname_result fi } ;; * ) $RM $output trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 func_emit_wrapper no > $output chmod +x $output ;; esac } exit $EXIT_SUCCESS ;; esac # See if we need to build an old-fashioned archive. for oldlib in $oldlibs; do case $build_libtool_libs in convenience) oldobjs="$libobjs_save $symfileobj" addlibs=$convenience build_libtool_libs=no ;; module) oldobjs=$libobjs_save addlibs=$old_convenience build_libtool_libs=no ;; *) oldobjs="$old_deplibs $non_pic_objects" $preload && test -f "$symfileobj" \ && func_append oldobjs " $symfileobj" addlibs=$old_convenience ;; esac if test -n "$addlibs"; then gentop=$output_objdir/${outputname}x func_append generated " $gentop" func_extract_archives $gentop $addlibs func_append oldobjs " $func_extract_archives_result" fi # Do each command in the archive commands. if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then cmds=$old_archive_from_new_cmds else # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop=$output_objdir/${outputname}x func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append oldobjs " $func_extract_archives_result" fi # POSIX demands no paths to be encoded in archives. We have # to avoid creating archives with duplicate basenames if we # might have to extract them afterwards, e.g., when creating a # static archive out of a convenience library, or when linking # the entirety of a libtool archive into another (currently # not supported by libtool). if (for obj in $oldobjs do func_basename "$obj" $ECHO "$func_basename_result" done | sort | sort -uc >/dev/null 2>&1); then : else echo "copying selected object files to avoid basename conflicts..." gentop=$output_objdir/${outputname}x func_append generated " $gentop" func_mkdir_p "$gentop" save_oldobjs=$oldobjs oldobjs= counter=1 for obj in $save_oldobjs do func_basename "$obj" objbase=$func_basename_result case " $oldobjs " in " ") oldobjs=$obj ;; *[\ /]"$objbase "*) while :; do # Make sure we don't pick an alternate name that also # overlaps. newobj=lt$counter-$objbase func_arith $counter + 1 counter=$func_arith_result case " $oldobjs " in *[\ /]"$newobj "*) ;; *) if test ! -f "$gentop/$newobj"; then break; fi ;; esac done func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" func_append oldobjs " $gentop/$newobj" ;; *) func_append oldobjs " $obj" ;; esac done fi func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 tool_oldlib=$func_to_tool_file_result eval cmds=\"$old_archive_cmds\" func_len " $cmds" len=$func_len_result if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then cmds=$old_archive_cmds elif test -n "$archiver_list_spec"; then func_verbose "using command file archive linking..." for obj in $oldobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > $output_objdir/$libname.libcmd func_to_tool_file "$output_objdir/$libname.libcmd" oldobjs=" $archiver_list_spec$func_to_tool_file_result" cmds=$old_archive_cmds else # the command line is too long to link in one step, link in parts func_verbose "using piecewise archive linking..." save_RANLIB=$RANLIB RANLIB=: objlist= concat_cmds= save_oldobjs=$oldobjs oldobjs= # Is there a better way of finding the last object in the list? for obj in $save_oldobjs do last_oldobj=$obj done eval test_cmds=\"$old_archive_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 for obj in $save_oldobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result func_append objlist " $obj" if test "$len" -lt "$max_cmd_len"; then : else # the above command should be used before it gets too long oldobjs=$objlist if test "$obj" = "$last_oldobj"; then RANLIB=$save_RANLIB fi test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" objlist= len=$len0 fi done RANLIB=$save_RANLIB oldobjs=$objlist if test -z "$oldobjs"; then eval cmds=\"\$concat_cmds\" else eval cmds=\"\$concat_cmds~\$old_archive_cmds\" fi fi fi func_execute_cmds "$cmds" 'exit $?' done test -n "$generated" && \ func_show_eval "${RM}r$generated" # Now create the libtool archive. case $output in *.la) old_library= test yes = "$build_old_libs" && old_library=$libname.$libext func_verbose "creating $output" # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done # Quote the link command for shipping. relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` if test yes = "$hardcode_automatic"; then relink_command= fi # Only create the output if not a dry run. $opt_dry_run || { for installed in no yes; do if test yes = "$installed"; then if test -z "$install_libdir"; then break fi output=$output_objdir/${outputname}i # Replace all uninstalled libtool libraries with the installed ones newdependency_libs= for deplib in $dependency_libs; do case $deplib in *.la) func_basename "$deplib" name=$func_basename_result func_resolve_sysroot "$deplib" eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` test -z "$libdir" && \ func_fatal_error "'$deplib' is not a valid libtool archive" func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" ;; -L*) func_stripname -L '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -L$func_replace_sysroot_result" ;; -R*) func_stripname -R '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -R$func_replace_sysroot_result" ;; *) func_append newdependency_libs " $deplib" ;; esac done dependency_libs=$newdependency_libs newdlfiles= for lib in $dlfiles; do case $lib in *.la) func_basename "$lib" name=$func_basename_result eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "'$lib' is not a valid libtool archive" func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" ;; *) func_append newdlfiles " $lib" ;; esac done dlfiles=$newdlfiles newdlprefiles= for lib in $dlprefiles; do case $lib in *.la) # Only pass preopened files to the pseudo-archive (for # eventual linking with the app. that links it) if we # didn't already link the preopened objects directly into # the library: func_basename "$lib" name=$func_basename_result eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "'$lib' is not a valid libtool archive" func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" ;; esac done dlprefiles=$newdlprefiles else newdlfiles= for lib in $dlfiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlfiles " $abs" done dlfiles=$newdlfiles newdlprefiles= for lib in $dlprefiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlprefiles " $abs" done dlprefiles=$newdlprefiles fi $RM $output # place dlname in correct position for cygwin # In fact, it would be nice if we could use this code for all target # systems that can't hard-code library paths into their executables # and that have no shared library path variable independent of PATH, # but it turns out we can't easily determine that from inspecting # libtool variables, so we have to hard-code the OSs to which it # applies here; at the moment, that means platforms that use the PE # object format with DLL files. See the long comment at the top of # tests/bindir.at for full details. tdlname=$dlname case $host,$output,$installed,$module,$dlname in *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) # If a -bindir argument was supplied, place the dll there. if test -n "$bindir"; then func_relative_path "$install_libdir" "$bindir" tdlname=$func_relative_path_result/$dlname else # Otherwise fall back on heuristic. tdlname=../bin/$dlname fi ;; esac $ECHO > $output "\ # $outputname - a libtool library file # Generated by $PROGRAM (GNU $PACKAGE) $VERSION # # Please DO NOT delete this file! # It is necessary for linking the library. # The name that we can dlopen(3). dlname='$tdlname' # Names of this library. library_names='$library_names' # The name of the static archive. old_library='$old_library' # Linker flags that cannot go in dependency_libs. inherited_linker_flags='$new_inherited_linker_flags' # Libraries that this one depends upon. dependency_libs='$dependency_libs' # Names of additional weak libraries provided by this library weak_library_names='$weak_libs' # Version information for $libname. current=$current age=$age revision=$revision # Is this an already installed library? installed=$installed # Should we warn about portability when linking against -modules? shouldnotlink=$module # Files to dlopen/dlpreopen dlopen='$dlfiles' dlpreopen='$dlprefiles' # Directory that this library needs to be installed in: libdir='$install_libdir'" if test no,yes = "$installed,$need_relink"; then $ECHO >> $output "\ relink_command=\"$relink_command\"" fi done } # Do a symbolic link so that the libtool archive can be found in # LD_LIBRARY_PATH before the program is installed. func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' ;; esac exit $EXIT_SUCCESS } if test link = "$opt_mode" || test relink = "$opt_mode"; then func_mode_link ${1+"$@"} fi # func_mode_uninstall arg... func_mode_uninstall () { $debug_cmd RM=$nonopt files= rmforce=false exit_status=0 # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic=$magic for arg do case $arg in -f) func_append RM " $arg"; rmforce=: ;; -*) func_append RM " $arg" ;; *) func_append files " $arg" ;; esac done test -z "$RM" && \ func_fatal_help "you must specify an RM program" rmdirs= for file in $files; do func_dirname "$file" "" "." dir=$func_dirname_result if test . = "$dir"; then odir=$objdir else odir=$dir/$objdir fi func_basename "$file" name=$func_basename_result test uninstall = "$opt_mode" && odir=$dir # Remember odir for removal later, being careful to avoid duplicates if test clean = "$opt_mode"; then case " $rmdirs " in *" $odir "*) ;; *) func_append rmdirs " $odir" ;; esac fi # Don't error if the file doesn't exist and rm -f was used. if { test -L "$file"; } >/dev/null 2>&1 || { test -h "$file"; } >/dev/null 2>&1 || test -f "$file"; then : elif test -d "$file"; then exit_status=1 continue elif $rmforce; then continue fi rmfiles=$file case $name in *.la) # Possibly a libtool archive, so verify it. if func_lalib_p "$file"; then func_source $dir/$name # Delete the libtool libraries and symlinks. for n in $library_names; do func_append rmfiles " $odir/$n" done test -n "$old_library" && func_append rmfiles " $odir/$old_library" case $opt_mode in clean) case " $library_names " in *" $dlname "*) ;; *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; esac test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" ;; uninstall) if test -n "$library_names"; then # Do each command in the postuninstall commands. func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' fi if test -n "$old_library"; then # Do each command in the old_postuninstall commands. func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' fi # FIXME: should reinstall the best remaining shared library. ;; esac fi ;; *.lo) # Possibly a libtool object, so verify it. if func_lalib_p "$file"; then # Read the .lo file func_source $dir/$name # Add PIC object to the list of files to remove. if test -n "$pic_object" && test none != "$pic_object"; then func_append rmfiles " $dir/$pic_object" fi # Add non-PIC object to the list of files to remove. if test -n "$non_pic_object" && test none != "$non_pic_object"; then func_append rmfiles " $dir/$non_pic_object" fi fi ;; *) if test clean = "$opt_mode"; then noexename=$name case $file in *.exe) func_stripname '' '.exe' "$file" file=$func_stripname_result func_stripname '' '.exe' "$name" noexename=$func_stripname_result # $file with .exe has already been added to rmfiles, # add $file without .exe func_append rmfiles " $file" ;; esac # Do a test to see if this is a libtool program. if func_ltwrapper_p "$file"; then if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" relink_command= func_source $func_ltwrapper_scriptname_result func_append rmfiles " $func_ltwrapper_scriptname_result" else relink_command= func_source $dir/$noexename fi # note $name still contains .exe if it was in $file originally # as does the version of $file that was added into $rmfiles func_append rmfiles " $odir/$name $odir/${name}S.$objext" if test yes = "$fast_install" && test -n "$relink_command"; then func_append rmfiles " $odir/lt-$name" fi if test "X$noexename" != "X$name"; then func_append rmfiles " $odir/lt-$noexename.c" fi fi fi ;; esac func_show_eval "$RM $rmfiles" 'exit_status=1' done # Try to remove the $objdir's in the directories where we deleted files for dir in $rmdirs; do if test -d "$dir"; then func_show_eval "rmdir $dir >/dev/null 2>&1" fi done exit $exit_status } if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then func_mode_uninstall ${1+"$@"} fi test -z "$opt_mode" && { help=$generic_help func_fatal_help "you must specify a MODE" } test -z "$exec_cmd" && \ func_fatal_help "invalid operation mode '$opt_mode'" if test -n "$exec_cmd"; then eval exec "$exec_cmd" exit $EXIT_FAILURE fi exit $exit_status # The TAGs below are defined such that we never get into a situation # where we disable both kinds of libraries. Given conflicting # choices, we go for a static library, that is the most portable, # since we can't tell whether shared libraries were disabled because # the user asked for that or because the platform doesn't support # them. This is particularly important on AIX, because we don't # support having both static and shared libraries enabled at the same # time on that platform, so we default to a shared-only configuration. # If a disable-shared tag is given, we'll fallback to a static-only # configuration. But we'll never go from static-only to shared-only. # ### BEGIN LIBTOOL TAG CONFIG: disable-shared build_libtool_libs=no build_old_libs=yes # ### END LIBTOOL TAG CONFIG: disable-shared # ### BEGIN LIBTOOL TAG CONFIG: disable-static build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` # ### END LIBTOOL TAG CONFIG: disable-static # Local Variables: # mode:shell-script # sh-indentation:2 # End: freetds-1.00.82/missing100755 025423 025423 00000015330 13242511045 0010424#! /bin/sh # Common wrapper for a few potentially missing GNU programs. scriptversion=2013-10-28.13; # UTC # Copyright (C) 1996-2014 Free Software Foundation, Inc. # Originally written by Fran,cois Pinard , 1996. # 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, 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, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try '$0 --help' for more information" exit 1 fi case $1 in --is-lightweight) # Used by our autoconf macros to check whether the available missing # script is modern enough. exit 0 ;; --run) # Back-compat with the calling convention used by older automake. shift ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due to PROGRAM being missing or too old. Options: -h, --help display this help and exit -v, --version output version information and exit Supported PROGRAM values: aclocal autoconf autoheader autom4te automake makeinfo bison yacc flex lex help2man Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 'g' are ignored when checking the name. Send bug reports to ." exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" exit $? ;; -*) echo 1>&2 "$0: unknown '$1' option" echo 1>&2 "Try '$0 --help' for more information" exit 1 ;; esac # Run the given program, remember its exit status. "$@"; st=$? # If it succeeded, we are done. test $st -eq 0 && exit 0 # Also exit now if we it failed (or wasn't found), and '--version' was # passed; such an option is passed most likely to detect whether the # program is present and works. case $2 in --version|--help) exit $st;; esac # Exit code 63 means version mismatch. This often happens when the user # tries to use an ancient version of a tool on a file that requires a # minimum version. if test $st -eq 63; then msg="probably too old" elif test $st -eq 127; then # Program was missing. msg="missing on your system" else # Program was found and executed, but failed. Give up. exit $st fi perl_URL=http://www.perl.org/ flex_URL=http://flex.sourceforge.net/ gnu_software_URL=http://www.gnu.org/software program_details () { case $1 in aclocal|automake) echo "The '$1' program is part of the GNU Automake package:" echo "<$gnu_software_URL/automake>" echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" echo "<$gnu_software_URL/autoconf>" echo "<$gnu_software_URL/m4/>" echo "<$perl_URL>" ;; autoconf|autom4te|autoheader) echo "The '$1' program is part of the GNU Autoconf package:" echo "<$gnu_software_URL/autoconf/>" echo "It also requires GNU m4 and Perl in order to run:" echo "<$gnu_software_URL/m4/>" echo "<$perl_URL>" ;; esac } give_advice () { # Normalize program name to check for. normalized_program=`echo "$1" | sed ' s/^gnu-//; t s/^gnu//; t s/^g//; t'` printf '%s\n' "'$1' is $msg." configure_deps="'configure.ac' or m4 files included by 'configure.ac'" case $normalized_program in autoconf*) echo "You should only need it if you modified 'configure.ac'," echo "or m4 files included by it." program_details 'autoconf' ;; autoheader*) echo "You should only need it if you modified 'acconfig.h' or" echo "$configure_deps." program_details 'autoheader' ;; automake*) echo "You should only need it if you modified 'Makefile.am' or" echo "$configure_deps." program_details 'automake' ;; aclocal*) echo "You should only need it if you modified 'acinclude.m4' or" echo "$configure_deps." program_details 'aclocal' ;; autom4te*) echo "You might have modified some maintainer files that require" echo "the 'autom4te' program to be rebuilt." program_details 'autom4te' ;; bison*|yacc*) echo "You should only need it if you modified a '.y' file." echo "You may want to install the GNU Bison package:" echo "<$gnu_software_URL/bison/>" ;; lex*|flex*) echo "You should only need it if you modified a '.l' file." echo "You may want to install the Fast Lexical Analyzer package:" echo "<$flex_URL>" ;; help2man*) echo "You should only need it if you modified a dependency" \ "of a man page." echo "You may want to install the GNU Help2man package:" echo "<$gnu_software_URL/help2man/>" ;; makeinfo*) echo "You should only need it if you modified a '.texi' file, or" echo "any other file indirectly affecting the aspect of the manual." echo "You might want to install the Texinfo package:" echo "<$gnu_software_URL/texinfo/>" echo "The spurious makeinfo call might also be the consequence of" echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" echo "want to install GNU make:" echo "<$gnu_software_URL/make/>" ;; *) echo "You might have modified some files without having the proper" echo "tools for further handling them. Check the 'README' file, it" echo "often tells you about the needed prerequisites for installing" echo "this package. You may also peek at any GNU archive site, in" echo "case some other package contains this missing '$1' program." ;; esac } give_advice "$1" | sed -e '1s/^/WARNING: /' \ -e '2,$s/^/ /' >&2 # Propagate the correct exit status (expected to be 127 for a program # not found, 63 for a program that failed due to version mismatch). exit $st # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: freetds-1.00.82/mkinstalldirs100755 025423 025423 00000001331 12600465020 0011625#! /bin/sh # mkinstalldirs --- make directory hierarchy # Author: Noah Friedman # Created: 1993-05-16 # Public domain # $Id: mkinstalldirs,v 1.1 2001-10-12 23:28:53 brianb Exp $ errstatus=0 for file do set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` shift pathcomp= for d do pathcomp="$pathcomp$d" case "$pathcomp" in -* ) pathcomp=./$pathcomp ;; esac if test ! -d "$pathcomp"; then echo "mkdir $pathcomp" 1>&2 mkdir "$pathcomp" || lasterr=$? if test ! -d "$pathcomp"; then errstatus=$lasterr fi fi pathcomp="$pathcomp/" done done exit $errstatus # mkinstalldirs ends here freetds-1.00.82/interfaces100644 025423 025423 00000004467 12522201763 0011107# # Note: interfaces has been superceded by freetds.conf, however it can # continue to be used at sites that require compatibility with the # Sybase implementation. # # This format of the interfaces file is this: # # The entry starts with the server name beginning in the first column # (no whitespace preceding it). # # Next comes the services lines. They must be preceded by some # whitespace (preferably a tab). There are five fields in the services # line: # # 1) Service. Currently only "query" means anything "master" is # present for historical reasons only. # # 2) Transport. Currently ignored by FreeTDS, it should be "tcp". # When ipv6 support is added a second option of "tcp6" # will probably be available. # # 3) Physical layer. Sybase uses this field for a description of the # physical layer (usually "ether"), FreeTDS can also # use it to specify the version of the protocol to use # when connecting to the server. # # 4) Hostname. A hostname or IP address of the server machine. # # 5) Port. The TCP port on the server to connect to. # Microsft SQL Server defaults to 1433. # # So putting it all together, let's say you have an NT box running a # Microsoft SQL Server named "myserver" at ip address 10.0.2.1 and we # are connecting using version 4.2 of the protocol, your interfaces # entry would look like this: (without the comments) # #myserver # query tcp 4.2 10.0.2.1 1433 # # This is a Sybase hosted database server, if you are directly on the # net you can use it to test. JDBC query tcp 5.0 192.138.151.39 4444 master tcp 5.0 192.138.151.39 4444 # The same server, using TDS 4.2. Used in configuration examples for the # pool server, since the pool server supports only TDS 4.2. JDBC_42 query tcp 4.2 192.138.151.39 4444 master tcp 4.2 192.138.151.39 4444 # The client connecting to the pool server will use this to find its # listening socket. This entry assumes that the client is on the same # system as the pool server. mypool query tcp 4.2 127.0.0.1 5000 master tcp 4.2 127.0.0.1 5000 #myserver # query tcp ether 127.0.0.1 4000 # master tcp ether 127.0.0.1 4000 # #myserver2 # query tcp ether 127.0.0.1 4001 # master tcp ether 127.0.0.1 4001 freetds-1.00.82/src/Makefile.am100644 025423 025423 00000000375 12717145107 0011663SUBDIRS = replacements tds ctlib dblib DIST_SUBDIRS = $(SUBDIRS) if ODBC SUBDIRS += odbc else DIST_SUBDIRS += odbc endif if INCPOOL SUBDIRS += server pool else !INCPOOL if INCSERVER SUBDIRS += server endif endif if INCAPPS SUBDIRS += apps endif freetds-1.00.82/src/Makefile.in100644 025423 025423 00000050667 13242511110 0011666# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @ODBC_TRUE@am__append_1 = odbc @ODBC_FALSE@am__append_2 = odbc @INCPOOL_TRUE@am__append_3 = server pool @INCPOOL_FALSE@@INCSERVER_TRUE@am__append_4 = server @INCAPPS_TRUE@am__append_5 = apps subdir = src ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = \ $(top_srcdir)/m4/ac_caolan_func_which_gethostbyname_r.m4 \ $(top_srcdir)/m4/ac_have_inaddr_none.m4 \ $(top_srcdir)/m4/ac_have_malloc_options.m4 \ $(top_srcdir)/m4/ac_nullzero.m4 \ $(top_srcdir)/m4/ac_raf_func_which_getservbyname_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_gethostbyaddr_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_getpwuid_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_localtime_r.m4 \ $(top_srcdir)/m4/acx_pthread.m4 \ $(top_srcdir)/m4/ax_cflags_gcc_option.m4 \ $(top_srcdir)/m4/check_openssl.m4 \ $(top_srcdir)/m4/gettimemilli.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/pushlibs.m4 \ $(top_srcdir)/m4/sprintf_i64_format.m4 \ $(top_srcdir)/m4/type_socklen_t.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/mkinstalldirs DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BUILD_NUMBER = @BUILD_NUMBER@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOXYGEN = @DOXYGEN@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FREETDS_LIBGCC = @FREETDS_LIBGCC@ FREETDS_ODBC_MODULE = @FREETDS_ODBC_MODULE@ FREETDS_SYMBOLIC = @FREETDS_SYMBOLIC@ GCRYPT_CFLAGS = @GCRYPT_CFLAGS@ GCRYPT_LIBS = @GCRYPT_LIBS@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ HAVE_OPENSSL = @HAVE_OPENSSL@ HAVE_PERL_SOURCES = @HAVE_PERL_SOURCES@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBADD_DL = @LIBADD_DL@ LIBADD_DLD_LINK = @LIBADD_DLD_LINK@ LIBADD_DLOPEN = @LIBADD_DLOPEN@ LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@ LIBICONV = @LIBICONV@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBOBJS = @LTLIBOBJS@ LT_DLLOADERS = @LT_DLLOADERS@ LT_DLPREOPEN = @LT_DLPREOPEN@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ NETTLE_CFLAGS = @NETTLE_CFLAGS@ NETTLE_LIBS = @NETTLE_LIBS@ NETWORK_LIBS = @NETWORK_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ODBC = @ODBC@ ODBCINSTLIB = @ODBCINSTLIB@ ODBCLIB = @ODBCLIB@ ODBCNODMLIB = @ODBCNODMLIB@ ODBCNODMLIBAPP = @ODBCNODMLIBAPP@ ODBC_CONFIG = @ODBC_CONFIG@ ODBC_INC = @ODBC_INC@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ RC = @RC@ READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SUBVERSION = @SUBVERSION@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ dblib_define = @dblib_define@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ tds_sysdep_int16_type = @tds_sysdep_int16_type@ tds_sysdep_int32_type = @tds_sysdep_int32_type@ tds_sysdep_int64_type = @tds_sysdep_int64_type@ tds_sysdep_intptr_type = @tds_sysdep_intptr_type@ tds_sysdep_real32_type = @tds_sysdep_real32_type@ tds_sysdep_real64_type = @tds_sysdep_real64_type@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = replacements tds ctlib dblib $(am__append_1) $(am__append_3) \ $(am__append_4) $(am__append_5) DIST_SUBDIRS = $(SUBDIRS) $(am__append_2) all: all-recursive .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-recursive -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-generic clean-libtool cscopelist-am ctags \ ctags-am distclean distclean-generic 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-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ installdirs-am maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ ps ps-am tags tags-am uninstall uninstall-am .PRECIOUS: Makefile # 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: freetds-1.00.82/src/replacements/Makefile.am100644 025423 025423 00000001167 12717145107 0014345# $Id: Makefile.am,v 1.20 2012-03-06 20:40:12 freddy77 Exp $ SUBDIRS= . unittests AM_CPPFLAGS= -I$(top_srcdir)/include -I$(top_srcdir)/src/replacements noinst_LTLIBRARIES= libreplacements.la libreplacements_la_SOURCES = \ iconv.c gettimeofday.c poll.c getpassarg.c socketpair.c win_mutex.c \ tds_cond.c getaddrinfo.c sleep.c libreplacements_la_LDFLAGS= libreplacements_la_LIBADD= @LTLIBOBJS@ EXTRA_DIST= asprintf.c \ basename.c \ getopt.c \ readpassphrase.c \ strlcat.c \ getaddrinfo.c \ strlcpy.c \ strtok_r.c \ strsep.c \ vasprintf.c \ socketpair.c \ ptw32_MCS_lock.c \ daemon.c \ CMakeLists.txt freetds-1.00.82/src/replacements/Makefile.in100644 025423 025423 00000064131 13242511111 0014340# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/replacements ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = \ $(top_srcdir)/m4/ac_caolan_func_which_gethostbyname_r.m4 \ $(top_srcdir)/m4/ac_have_inaddr_none.m4 \ $(top_srcdir)/m4/ac_have_malloc_options.m4 \ $(top_srcdir)/m4/ac_nullzero.m4 \ $(top_srcdir)/m4/ac_raf_func_which_getservbyname_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_gethostbyaddr_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_getpwuid_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_localtime_r.m4 \ $(top_srcdir)/m4/acx_pthread.m4 \ $(top_srcdir)/m4/ax_cflags_gcc_option.m4 \ $(top_srcdir)/m4/check_openssl.m4 \ $(top_srcdir)/m4/gettimemilli.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/pushlibs.m4 \ $(top_srcdir)/m4/sprintf_i64_format.m4 \ $(top_srcdir)/m4/type_socklen_t.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libreplacements_la_DEPENDENCIES = @LTLIBOBJS@ am_libreplacements_la_OBJECTS = iconv.lo gettimeofday.lo poll.lo \ getpassarg.lo socketpair.lo win_mutex.lo tds_cond.lo \ getaddrinfo.lo sleep.lo libreplacements_la_OBJECTS = $(am_libreplacements_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = libreplacements_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(AM_CFLAGS) $(CFLAGS) $(libreplacements_la_LDFLAGS) \ $(LDFLAGS) -o $@ AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libreplacements_la_SOURCES) DIST_SOURCES = $(libreplacements_la_SOURCES) RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp \ $(top_srcdir)/mkinstalldirs asprintf.c basename.c daemon.c \ getopt.c readpassphrase.c strlcat.c strlcpy.c strsep.c \ strtok_r.c vasprintf.c DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BUILD_NUMBER = @BUILD_NUMBER@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOXYGEN = @DOXYGEN@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FREETDS_LIBGCC = @FREETDS_LIBGCC@ FREETDS_ODBC_MODULE = @FREETDS_ODBC_MODULE@ FREETDS_SYMBOLIC = @FREETDS_SYMBOLIC@ GCRYPT_CFLAGS = @GCRYPT_CFLAGS@ GCRYPT_LIBS = @GCRYPT_LIBS@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ HAVE_OPENSSL = @HAVE_OPENSSL@ HAVE_PERL_SOURCES = @HAVE_PERL_SOURCES@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBADD_DL = @LIBADD_DL@ LIBADD_DLD_LINK = @LIBADD_DLD_LINK@ LIBADD_DLOPEN = @LIBADD_DLOPEN@ LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@ LIBICONV = @LIBICONV@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBOBJS = @LTLIBOBJS@ LT_DLLOADERS = @LT_DLLOADERS@ LT_DLPREOPEN = @LT_DLPREOPEN@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ NETTLE_CFLAGS = @NETTLE_CFLAGS@ NETTLE_LIBS = @NETTLE_LIBS@ NETWORK_LIBS = @NETWORK_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ODBC = @ODBC@ ODBCINSTLIB = @ODBCINSTLIB@ ODBCLIB = @ODBCLIB@ ODBCNODMLIB = @ODBCNODMLIB@ ODBCNODMLIBAPP = @ODBCNODMLIBAPP@ ODBC_CONFIG = @ODBC_CONFIG@ ODBC_INC = @ODBC_INC@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ RC = @RC@ READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SUBVERSION = @SUBVERSION@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ dblib_define = @dblib_define@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ tds_sysdep_int16_type = @tds_sysdep_int16_type@ tds_sysdep_int32_type = @tds_sysdep_int32_type@ tds_sysdep_int64_type = @tds_sysdep_int64_type@ tds_sysdep_intptr_type = @tds_sysdep_intptr_type@ tds_sysdep_real32_type = @tds_sysdep_real32_type@ tds_sysdep_real64_type = @tds_sysdep_real64_type@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # $Id: Makefile.am,v 1.20 2012-03-06 20:40:12 freddy77 Exp $ SUBDIRS = . unittests AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src/replacements noinst_LTLIBRARIES = libreplacements.la libreplacements_la_SOURCES = \ iconv.c gettimeofday.c poll.c getpassarg.c socketpair.c win_mutex.c \ tds_cond.c getaddrinfo.c sleep.c libreplacements_la_LDFLAGS = libreplacements_la_LIBADD = @LTLIBOBJS@ EXTRA_DIST = asprintf.c \ basename.c \ getopt.c \ readpassphrase.c \ strlcat.c \ getaddrinfo.c \ strlcpy.c \ strtok_r.c \ strsep.c \ vasprintf.c \ socketpair.c \ ptw32_MCS_lock.c \ daemon.c \ CMakeLists.txt all: all-recursive .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/replacements/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/replacements/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libreplacements.la: $(libreplacements_la_OBJECTS) $(libreplacements_la_DEPENDENCIES) $(EXTRA_libreplacements_la_DEPENDENCIES) $(AM_V_CCLD)$(libreplacements_la_LINK) $(libreplacements_la_OBJECTS) $(libreplacements_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asprintf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/basename.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/daemon.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/getopt.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/readpassphrase.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strlcat.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strlcpy.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strsep.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strtok_r.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/vasprintf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getaddrinfo.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getpassarg.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gettimeofday.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/iconv.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/poll.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sleep.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/socketpair.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tds_cond.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/win_mutex.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile $(LTLIBRARIES) installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ mostlyclean-am distclean: distclean-recursive -rm -rf $(DEPDIR) ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -rf $(DEPDIR) ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-generic clean-libtool \ clean-noinstLTLIBRARIES cscopelist-am ctags ctags-am distclean \ distclean-compile distclean-generic 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-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ installdirs-am maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ uninstall-am .PRECIOUS: Makefile # 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: freetds-1.00.82/src/replacements/asprintf.c100644 025423 025423 00000000734 12717145107 0014302/* * asprintf(3) * 20020809 entropy@tappedin.com * public domain. no warranty. use at your own risk. have a nice day. */ #include #include #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include "replacements.h" int tds_asprintf(char **ret, const char *fmt, ...) { int len; va_list ap; va_start(ap, fmt); len = vasprintf(ret, fmt, ap); va_end(ap); return len; } freetds-1.00.82/src/replacements/basename.c100644 025423 025423 00000002755 12717145107 0014234/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2005 Ziglio Frediano * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include "replacements.h" #if ! HAVE_BASENAME #ifdef _WIN32 #define TDS_ISDIR_SEPARATOR(c) ((c) == '/' || (c) == '\\') #else #define TDS_ISDIR_SEPARATOR(c) ((c) == '/') #endif char *tds_basename(char *path) { char *p; if (path == NULL) return path; /* remove trailing directories separators */ for (p = path + strlen(path); --p > path && TDS_ISDIR_SEPARATOR(*p);) *p = '\0'; p = strrchr(path, '/'); if (p) path = p + 1; #ifdef _WIN32 p = strrchr(path, '\\'); if (p) path = p + 1; #endif return path; } #endif freetds-1.00.82/src/replacements/daemon.c100644 025423 025423 00000006360 12717145107 0013720/*---------------------------------------------------------------------------*\ NAME daemon.c - replacement daemon(3) function DESCRIPTION This source file contains a version of a BSD-style daemon(3) function, a function to "daemonize" the calling process. This implementation is based both on the generic daemon logic defined in the Unix Programmer's FAQ and on the daemon_start() function in W. Richard Stevens' _Unix_Network_Programming_ book (Prentice-Hall, 1990). At the time of this writing, the Unix Programmer's FAQ is located at `http://www.whitefang.com/unix/faq_toc.html' (among other places). LICENSE This source code is released under a BSD-style. See the LICENSE file for details. Copyright (c) 2003-2015 Brian M. Clapper, bmc@clapper.org \*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*\ Includes \*---------------------------------------------------------------------------*/ #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_ERRNO_H #include #endif /* HAVE_ERRNO_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #include #include #include #if HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #ifdef HAVE_SYS_FILE_H #include #endif /* HAVE_SYS_FILE_H */ #if HAVE_SYS_STAT_H #include #endif /* HAVE_SYS_STAT_H */ #include "replacements.h" #ifndef _WIN32 /*---------------------------------------------------------------------------*\ Static Routines \*---------------------------------------------------------------------------*/ /* redirect_fds(): redirect stdin, stdout, and stderr to /dev/NULL */ static void redirect_fds(int dev_null) { dup2(dev_null, 0); dup2(dev_null, 1); dup2(dev_null, 2); close(dev_null); } static int do_fork(void) { int status = 0; switch (fork()) { case 0: /* This is the child that will become the daemon. */ break; case -1: /* Fork failure. */ status = -1; break; default: /* Parent: Exit. */ _exit(0); } return status; } /*---------------------------------------------------------------------------*\ Public Routines \*---------------------------------------------------------------------------*/ int tds_daemon(int nochdir, int noclose) { int status = 0; int dev_null = -1; if (!noclose) { dev_null = open("/dev/null", O_RDWR); if (dev_null < 0) return -1; } /* Fork once to go into the background. */ if ((status = do_fork()) < 0) return -1; /* Create new session */ if (setsid() < 0) /* shouldn't fail */ return -1; /* Fork again to ensure that daemon never reacquires a control terminal. */ if ((status = do_fork()) < 0) return -1; /* clear any inherited umask(2) value */ umask(0); /* We're there. */ if (!nochdir) { /* Go to a neutral corner. */ chdir("/"); } if (!noclose) redirect_fds(dev_null); return status; } #endif /* _WIN32 */ freetds-1.00.82/src/replacements/getopt.c100644 025423 025423 00000010363 12717145107 0013755/* $NetBSD: getopt.c,v 1.27 2005/11/29 03:12:00 christos Exp $ */ /* * Copyright (c) 1987, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #undef LIBC_SCCS #if !defined(_WIN32) # include #else # define __UNCONST(x) ((char*)(x)) # define getprogname() (nargv[0]) # define _DIAGASSERT(x) assert((x)) #endif #if !defined(_WIN32) # include "namespace.h" #endif #include #include #include #include #include #if !defined(_WIN32) # include #endif #include #ifdef __weak_alias __weak_alias(getopt,_getopt) #endif int opterr = 1, /* if error message should be printed */ optind = 1, /* index into parent argv vector */ optopt, /* character checked for validity */ optreset; /* reset getopt */ char *optarg; /* argument associated with option */ #define BADCH (int)'?' #define BADARG (int)':' #define EMSG "" /* * getopt -- * Parse argc/argv argument vector. */ int tds_getopt(nargc, nargv, ostr) int nargc; char * const nargv[]; const char *ostr; { static const char *place = EMSG; /* option letter processing */ char *oli; /* option letter list index */ _DIAGASSERT(nargv != NULL); _DIAGASSERT(ostr != NULL); if (optreset || *place == 0) { /* update scanning pointer */ optreset = 0; place = nargv[optind]; if (optind >= nargc || *place++ != '-') { /* Argument is absent or is not an option */ place = EMSG; return (-1); } optopt = *place++; if (optopt == '-' && *place == 0) { /* "--" => end of options */ ++optind; place = EMSG; return (-1); } if (optopt == 0) { /* Solitary '-', treat as a '-' option if the program (eg su) is looking for it. */ place = EMSG; if (strchr(ostr, '-') == NULL) return -1; optopt = '-'; } } else optopt = *place++; /* See if option letter is one the caller wanted... */ if (optopt == ':' || (oli = strchr(ostr, optopt)) == NULL) { if (*place == 0) ++optind; if (opterr && *ostr != ':') (void)fprintf(stderr, "%s: unknown option -- %c\n", getprogname(), optopt); return (BADCH); } /* Does this option need an argument? */ if (oli[1] != ':') { /* don't need argument */ optarg = NULL; if (*place == 0) ++optind; } else { /* Option-argument is either the rest of this argument or the entire next argument. */ if (*place) optarg = __UNCONST(place); else if (nargc > ++optind) optarg = nargv[optind]; else { /* option-argument absent */ place = EMSG; if (*ostr == ':') return (BADARG); if (opterr) (void)fprintf(stderr, "%s: option requires an argument -- %c\n", getprogname(), optopt); return (BADCH); } place = EMSG; ++optind; } return (optopt); /* return option letter */ } freetds-1.00.82/src/replacements/readpassphrase.c100644 025423 025423 00000015042 12717145107 0015457/* OPENBSD ORIGINAL: lib/libc/gen/readpassphrase.c */ /* $OpenBSD: readpassphrase.c,v 1.16 2003/06/17 21:56:23 millert Exp $ */ /* * Copyright (c) 2000-2002 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Sponsored in part by the Defense Advanced Research Projects * Agency (DARPA) and Air Force Research Laboratory, Air Force * Materiel Command, USAF, under agreement number F39502-99-1-0512. */ #if defined(LIBC_SCCS) && !defined(lint) static const char rcsid[] = "$OpenBSD: readpassphrase.c,v 1.16 2003/06/17 21:56:23 millert Exp $"; #endif /* LIBC_SCCS and not lint */ #include #ifndef HAVE_READPASSPHRASE #include #include #ifdef HAVE_STDLIB_H #include #endif #ifdef HAVE_STRING_H #include #endif #include #ifdef HAVE_UNISTD_H #include #endif #ifdef HAVE_SIGNAL_H #include #endif #ifdef HAVE_ERRNO_H #include #endif #ifdef HAVE_SYS_TYPES_H #include #endif #ifdef HAVE_SYS_STAT_H #include #endif #include #ifdef HAVE_PATHS_H #include /* For _PATH_XXX */ #endif #include #if !defined(_WIN32) && !defined(_WIN64) #include #ifndef _PATH_TTY # define _PATH_TTY "/dev/tty" #endif #ifdef TCSASOFT # define _T_FLUSH (TCSAFLUSH|TCSASOFT) #else # define _T_FLUSH (TCSAFLUSH) #endif /* SunOS 4.x which lacks _POSIX_VDISABLE, but has VDISABLE */ #if !defined(_POSIX_VDISABLE) && defined(VDISABLE) # define _POSIX_VDISABLE VDISABLE #endif static volatile sig_atomic_t signo; static void handler(int); char * tds_readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags) { ssize_t nr; int input, output, save_errno; char ch, *p, *end; struct termios term, oterm; struct sigaction sa, savealrm, saveint, savehup, savequit, saveterm; struct sigaction savetstp, savettin, savettou, savepipe; /* I suppose we could alloc on demand in this case (XXX). */ if (bufsiz == 0) { errno = EINVAL; return(NULL); } restart: signo = 0; /* * Read and write to /dev/tty if available. If not, read from * stdin and write to stderr unless a tty is required. */ if ((flags & RPP_STDIN) || (input = output = open(_PATH_TTY, O_RDWR)) == -1) { if (flags & RPP_REQUIRE_TTY) { errno = ENOTTY; return(NULL); } input = STDIN_FILENO; output = STDERR_FILENO; } /* * Catch signals that would otherwise cause the user to end * up with echo turned off in the shell. Don't worry about * things like SIGXCPU and SIGVTALRM for now. */ sigemptyset(&sa.sa_mask); sa.sa_flags = 0; /* don't restart system calls */ sa.sa_handler = handler; (void)sigaction(SIGALRM, &sa, &savealrm); (void)sigaction(SIGHUP, &sa, &savehup); (void)sigaction(SIGINT, &sa, &saveint); (void)sigaction(SIGPIPE, &sa, &savepipe); (void)sigaction(SIGQUIT, &sa, &savequit); (void)sigaction(SIGTERM, &sa, &saveterm); (void)sigaction(SIGTSTP, &sa, &savetstp); (void)sigaction(SIGTTIN, &sa, &savettin); (void)sigaction(SIGTTOU, &sa, &savettou); /* Turn off echo if possible. */ if (input != STDIN_FILENO && tcgetattr(input, &oterm) == 0) { memcpy(&term, &oterm, sizeof(term)); if (!(flags & RPP_ECHO_ON)) term.c_lflag &= ~(ECHO | ECHONL); #ifdef VSTATUS if (term.c_cc[VSTATUS] != _POSIX_VDISABLE) term.c_cc[VSTATUS] = _POSIX_VDISABLE; #endif (void)tcsetattr(input, _T_FLUSH, &term); } else { memset(&term, 0, sizeof(term)); term.c_lflag |= ECHO; memset(&oterm, 0, sizeof(oterm)); oterm.c_lflag |= ECHO; } if (!(flags & RPP_STDIN)) (void)write(output, prompt, strlen(prompt)); end = buf + bufsiz - 1; for (p = buf; (nr = read(input, &ch, 1)) == 1 && ch != '\n' && ch != '\r';) { if (p < end) { if ((flags & RPP_SEVENBIT)) ch &= 0x7f; if (isalpha((unsigned char) ch)) { if ((flags & RPP_FORCELOWER)) ch = tolower((unsigned char) ch); if ((flags & RPP_FORCEUPPER)) ch = toupper((unsigned char) ch); } *p++ = ch; } } *p = '\0'; save_errno = errno; if (!(term.c_lflag & ECHO)) (void)write(output, "\n", 1); /* Restore old terminal settings and signals. */ if (memcmp(&term, &oterm, sizeof(term)) != 0) (void)tcsetattr(input, _T_FLUSH, &oterm); (void)sigaction(SIGALRM, &savealrm, NULL); (void)sigaction(SIGHUP, &savehup, NULL); (void)sigaction(SIGINT, &saveint, NULL); (void)sigaction(SIGQUIT, &savequit, NULL); (void)sigaction(SIGPIPE, &savepipe, NULL); (void)sigaction(SIGTERM, &saveterm, NULL); (void)sigaction(SIGTSTP, &savetstp, NULL); (void)sigaction(SIGTTIN, &savettin, NULL); if (input != STDIN_FILENO) (void)close(input); /* * If we were interrupted by a signal, resend it to ourselves * now that we have restored the signal handlers. */ if (signo) { kill(getpid(), signo); switch (signo) { case SIGTSTP: case SIGTTIN: case SIGTTOU: goto restart; } } errno = save_errno; return(nr == -1 ? NULL : buf); } #if 0 char * getpass(const char *prompt) { static char buf[_PASSWORD_LEN + 1]; return(readpassphrase(prompt, buf, sizeof(buf), RPP_ECHO_OFF)); } #endif static void handler(int s) { signo = s; } #else /* _WIN32 */ char * tds_readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags) { int save_errno, ch; char *p, *end; /* I suppose we could alloc on demand in this case (XXX). */ if (bufsiz == 0) { errno = EINVAL; return(NULL); } printf("%s", prompt); fflush(stdout); end = buf + bufsiz - 1; for (p = buf; (ch = getchar()) != EOF && ch != '\n' && ch != '\r';) { if (p < end) { ch &= 0xff; if ((flags & RPP_SEVENBIT)) ch &= 0x7f; if (isalpha(ch)) { if ((flags & RPP_FORCELOWER)) ch = tolower(ch); if ((flags & RPP_FORCEUPPER)) ch = toupper(ch); } *p++ = ch; } } *p = '\0'; save_errno = errno; printf("\n"); errno = save_errno; return (ch == EOF ? NULL : buf); } #endif /* _WIN32 */ #endif /* HAVE_READPASSPHRASE */ freetds-1.00.82/src/replacements/strlcat.c100644 025423 025423 00000002553 12717145107 0014131/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2005 Ziglio Frediano * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include "replacements.h" size_t tds_strlcat(char *dest, const char *src, size_t len) { size_t dest_len = strlen(dest); size_t src_len = strlen(src); if (len) { --len; if (dest_len + src_len > len) { if (len > dest_len) { memcpy(dest + dest_len, src, len - dest_len); dest[len] = 0; } } else { memcpy(dest + dest_len, src, src_len + 1); } } return dest_len + src_len; } freetds-1.00.82/src/replacements/strlcpy.c100644 025423 025423 00000002334 12717145107 0014152/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2005 Ziglio Frediano * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include "replacements.h" size_t tds_strlcpy(char *dest, const char *src, size_t len) { size_t l = strlen(src); if (len) { --len; if (l > len) { memcpy(dest, src, len); dest[len] = 0; } else { memcpy(dest, src, l + 1); } } return l; } freetds-1.00.82/src/replacements/strsep.c100644 025423 025423 00000003600 12717145107 0013767/* Copyright (C) 1992, 93, 96, 97, 98, 99, 2004 Free Software Foundation, Inc. * This file is part of the GNU C Library. * * The GNU C Library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * The GNU C Library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with the GNU C Library; if not, write to the Free * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * 02111-1307 USA. */ #include #include #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include "replacements.h" /* Taken from glibc 2.6.1 */ char * tds_strsep(char **stringp, const char *delim) { char *begin, *end; begin = *stringp; if (begin == NULL) return NULL; /* A frequent case is when the delimiter string contains only one * character. Here we don't need to call the expensive `strpbrk' * function and instead work using `strchr'. */ if (delim[0] == '\0' || delim[1] == '\0') { char ch = delim[0]; if (ch == '\0') { end = NULL; } else { if (*begin == ch) end = begin; else if (*begin == '\0') end = NULL; else end = strchr(begin + 1, ch); } } else { /* Find the end of the token. */ end = strpbrk(begin, delim); } if (end) { /* Terminate the token and set *STRINGP past NUL character. */ *end++ = '\0'; *stringp = end; } else { /* No more delimiters; this is the last token. */ *stringp = NULL; } return begin; } freetds-1.00.82/src/replacements/strtok_r.c100644 025423 025423 00000001234 12717145107 0014317/* * strtok_r(3) * 20020927 entropy@tappedin.com * public domain. no warranty. use at your own risk. have a nice day. */ #include #include #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include "replacements.h" char * tds_strtok_r(char *str, const char *sep, char **lasts) { char *p; if (str == NULL) { str = *lasts; } if (str == NULL) { return NULL; } str += strspn(str, sep); /* skip any separators */ if ((p = strpbrk(str, sep)) != NULL) { *lasts = p + 1; *p = '\0'; } else { if (!*str) str = NULL; *lasts = NULL; } return str; } freetds-1.00.82/src/replacements/vasprintf.c100644 025423 025423 00000004670 12717145107 0014473/* * vasprintf(3) * 20020809 entropy@tappedin.com * public domain. no warranty. use at your own risk. have a nice day. */ #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_ERRNO_H #include #endif /* HAVE_ERRNO_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #if HAVE_PATHS_H #include #endif /* HAVE_PATHS_H */ #include #include "replacements.h" #if defined(HAVE__VSNPRINTF) && !defined(HAVE_VSNPRINTF) #undef HAVE_VSNPRINTF #undef vsnprintf #define HAVE_VSNPRINTF 1 #define vsnprintf _vsnprintf #endif #ifndef _PATH_DEVNULL #define _PATH_DEVNULL "/dev/null" #endif #define CHUNKSIZE 512 int tds_vasprintf(char **ret, const char *fmt, va_list ap) { #if HAVE__VSCPRINTF int len = _vscprintf(fmt, ap); if (len >= 0) { *ret = malloc(len + 1); if (*ret) { vsprintf(*ret, fmt, ap); return len; } errno = ENOMEM; } *ret = NULL; return -1; #elif HAVE_VSNPRINTF size_t chunks; size_t buflen; char *buf; int len; chunks = ((strlen(fmt) + 1) / CHUNKSIZE) + 1; buflen = chunks * CHUNKSIZE; for (;;) { if ((buf = malloc(buflen)) == NULL) { errno = ENOMEM; *ret = NULL; return -1; } len = vsnprintf(buf, buflen, fmt, ap); if (0 <= len && (size_t) len < buflen - 1) { break; } free(buf); buflen = (++chunks) * CHUNKSIZE; /* * len >= 0 is required for vsnprintf implementations that * return -1 for insufficient buffer */ if (len >= 0 && buflen <= (size_t) len) { buflen = len + 1; } } *ret = buf; return len; #else /* HAVE_VSNPRINTF */ #ifdef _REENTRANT FILE *fp; #else /* !_REENTRANT */ static FILE *fp = NULL; #endif /* !_REENTRANT */ int len; char *buf; *ret = NULL; #ifdef _REENTRANT # ifdef _WIN32 # error Win32 do not have /dev/null, should use vsnprintf version # endif if ((fp = fopen(_PATH_DEVNULL, "w")) == NULL) return -1; #else /* !_REENTRANT */ if ((fp == NULL) && ((fp = fopen(_PATH_DEVNULL, "w")) == NULL)) return -1; #endif /* !_REENTRANT */ len = vfprintf(fp, fmt, ap); #ifdef _REENTRANT if (fclose(fp) != 0) return -1; #endif /* _REENTRANT */ if (len < 0) return len; if ((buf = malloc(len + 1)) == NULL) { errno = ENOMEM; return -1; } if (vsprintf(buf, fmt, ap) != len) return -1; *ret = buf; return len; #endif /* HAVE_VSNPRINTF */ } freetds-1.00.82/src/replacements/iconv.c100644 025423 025423 00000024503 12717145107 0013572/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2003, 2004 James K. Lowden, based on original work by Brian Bruns * Copyright (C) 2011 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /** * \file * This file implements a very simple iconv. * Its purpose is to allow ASCII clients to communicate with Microsoft servers * that encode their metadata in Unicode (UTF-16). * * It supports ISO-8859-1, ASCII, UTF-16, UCS-4 and UTF-8 */ #include #if ! HAVE_ICONV #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_ERRNO_H #include #endif #include #include #include #include #include /** * \addtogroup conv * @{ */ enum ICONV_CD_VALUE { Like_to_Like = 0x100 }; typedef TDS_UINT ICONV_CHAR; static const unsigned char utf8_lengths[256] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 0, 0, }; static const unsigned char utf8_masks[7] = { 0, 0x7f, 0x1f, 0x0f, 0x07, 0x03, 0x01 }; /* * Return values for get_*: * - >0 bytes readed * - -EINVAL not enough data to read * - -EILSEQ invalid encoding detected * Return values for put_*: * - >0 bytes written * - -E2BIG no space left on output * - -EILSEQ character can't be encoded in output charset */ static int get_utf8(const unsigned char *p, size_t len, ICONV_CHAR *out) { ICONV_CHAR uc; size_t l; l = utf8_lengths[p[0]]; if (TDS_UNLIKELY(l == 0)) return -EILSEQ; if (TDS_UNLIKELY(len < l)) return -EINVAL; len = l; uc = *p++ & utf8_masks[l]; while(--l) uc = (uc << 6) | (*p++ & 0x3f); *out = uc; return len; } static int put_utf8(unsigned char *buf, size_t buf_len, ICONV_CHAR c) { #define MASK(n) ((0xffffffffu << (n)) & 0xffffffffu) size_t o_len; if ((c & MASK(7)) == 0) { if (buf_len < 1) return -E2BIG; *buf = (unsigned char) c; return 1; } o_len = 2; for (;;) { if ((c & MASK(11)) == 0) break; ++o_len; if ((c & MASK(16)) == 0) break; ++o_len; if ((c & MASK(21)) == 0) break; ++o_len; if ((c & MASK(26)) == 0) break; ++o_len; if ((c & MASK(31)) != 0) return -EILSEQ; } if (buf_len < o_len) return -E2BIG; buf += o_len; buf_len = o_len - 1; do { *--buf = 0x80 | (c & 0x3f); c >>= 6; } while (--buf_len); *--buf = (0xff00u >> o_len) | c; return o_len; } static int get_ucs4le(const unsigned char *p, size_t len, ICONV_CHAR *out) { if (len < 4) return -EINVAL; *out = TDS_GET_A4LE(p); return 4; } static int put_ucs4le(unsigned char *buf, size_t buf_len, ICONV_CHAR c) { if (buf_len < 4) return -E2BIG; TDS_PUT_A4LE(buf, c); return 4; } static int get_ucs4be(const unsigned char *p, size_t len, ICONV_CHAR *out) { if (len < 4) return -EINVAL; *out = TDS_GET_A4BE(p); return 4; } static int put_ucs4be(unsigned char *buf, size_t buf_len, ICONV_CHAR c) { if (buf_len < 4) return -E2BIG; TDS_PUT_A4BE(buf, c); return 4; } static int get_utf16le(const unsigned char *p, size_t len, ICONV_CHAR *out) { ICONV_CHAR c, c2; if (len < 2) return -EINVAL; c = TDS_GET_A2LE(p); if ((c & 0xfc00) == 0xd800) { if (len < 4) return -EINVAL; c2 = TDS_GET_A2LE(p+2); if ((c2 & 0xfc00) != 0xdc00) return -EILSEQ; *out = (c << 10) + c2 - ((0xd800 << 10) + 0xdc00 - 0x10000); return 4; } *out = c; return 2; } static int put_utf16le(unsigned char *buf, size_t buf_len, ICONV_CHAR c) { if (c >= 0x110000u) return -EILSEQ; if (c < 0x10000u) { if (buf_len < 2) return -E2BIG; TDS_PUT_A2LE(buf, c); return 2; } if (buf_len < 4) return -E2BIG; c -= 0x10000u; TDS_PUT_A2LE(buf, 0xd800 + (c >> 10)); TDS_PUT_A2LE(buf+2, 0xdc00 + (c & 0x3ffu)); return 4; } static int get_utf16be(const unsigned char *p, size_t len, ICONV_CHAR *out) { ICONV_CHAR c, c2; if (len < 2) return -EINVAL; c = TDS_GET_A2BE(p); if ((c & 0xfc00) == 0xd800) { if (len < 4) return -EINVAL; c2 = TDS_GET_A2BE(p+2); if ((c2 & 0xfc00) != 0xdc00) return -EILSEQ; *out = (c << 10) + c2 - ((0xd800 << 10) + 0xdc00 - 0x10000); return 4; } *out = c; return 2; } static int put_utf16be(unsigned char *buf, size_t buf_len, ICONV_CHAR c) { if (c >= 0x110000u) return -EILSEQ; if (c < 0x10000u) { if (buf_len < 2) return -E2BIG; TDS_PUT_A2BE(buf, c); return 2; } if (buf_len < 4) return -E2BIG; c -= 0x10000u; TDS_PUT_A2BE(buf, 0xd800 + (c >> 10)); TDS_PUT_A2BE(buf+2, 0xdc00 + (c & 0x3ffu)); return 4; } static int get_iso1(const unsigned char *p, size_t len, ICONV_CHAR *out) { *out = p[0]; return 1; } static int put_iso1(unsigned char *buf, size_t buf_len, ICONV_CHAR c) { if (c >= 0x100u) return -EILSEQ; if (buf_len < 1) return -E2BIG; buf[0] = (unsigned char) c; return 1; } static int get_ascii(const unsigned char *p, size_t len, ICONV_CHAR *out) { if (p[0] >= 0x80) return -EILSEQ; *out = p[0]; return 1; } static int put_ascii(unsigned char *buf, size_t buf_len, ICONV_CHAR c) { if (c >= 0x80u) return -EILSEQ; if (buf_len < 1) return -E2BIG; buf[0] = (unsigned char) c; return 1; } static int get_err(const unsigned char *p, size_t len, ICONV_CHAR *out) { return -EILSEQ; } static int put_err(unsigned char *buf, size_t buf_len, ICONV_CHAR c) { return -EILSEQ; } typedef int (*iconv_get_t)(const unsigned char *p, size_t len, ICONV_CHAR *out); typedef int (*iconv_put_t)(unsigned char *buf, size_t buf_len, ICONV_CHAR c); static const iconv_get_t iconv_gets[8] = { get_iso1, get_ascii, get_utf16le, get_utf16be, get_ucs4le, get_ucs4be, get_utf8, get_err }; static const iconv_put_t iconv_puts[8] = { put_iso1, put_ascii, put_utf16le, put_utf16be, put_ucs4le, put_ucs4be, put_utf8, put_err }; /** * Inputs are FreeTDS canonical names, no other. No alias list is consulted. */ iconv_t tds_sys_iconv_open (const char* tocode, const char* fromcode) { int i; unsigned int fromto; const char *enc_name; unsigned char encodings[2]; static char first_time = 1; if (TDS_UNLIKELY(first_time)) { first_time = 0; tdsdump_log(TDS_DBG_INFO1, "Using trivial iconv\n"); } /* match both inputs to our canonical names */ enc_name = fromcode; for (i=0; i < 2; ++i) { unsigned char encoding; if (strcmp(enc_name, "ISO-8859-1") == 0) encoding = 0; else if (strcmp(enc_name, "US-ASCII") == 0) encoding = 1; else if (strcmp(enc_name, "UCS-2LE") == 0 || strcmp(enc_name, "UTF-16LE") == 0) encoding = 2; else if (strcmp(enc_name, "UCS-2BE") == 0 || strcmp(enc_name, "UTF-16BE") == 0) encoding = 3; else if (strcmp(enc_name, "UCS-4LE") == 0) encoding = 4; else if (strcmp(enc_name, "UCS-4BE") == 0) encoding = 5; else if (strcmp(enc_name, "UTF-8") == 0) encoding = 6; else { errno = EINVAL; return (iconv_t)(-1); } encodings[i] = encoding; enc_name = tocode; } fromto = (encodings[0] << 4) | (encodings[1] & 0x0F); /* like to like */ if (encodings[0] == encodings[1]) { fromto = Like_to_Like; } return (iconv_t) (TDS_INTPTR) fromto; } int tds_sys_iconv_close (iconv_t cd) { return 0; } size_t tds_sys_iconv (iconv_t cd, const char* * inbuf, size_t *inbytesleft, char* * outbuf, size_t *outbytesleft) { const unsigned char *ib; unsigned char *ob; size_t il, ol; int local_errno; #undef CD #define CD ((int) (TDS_INTPTR) cd) /* iconv defines valid semantics for NULL inputs, but we don't support them. */ if (!inbuf || !*inbuf || !inbytesleft || !outbuf || !*outbuf || !outbytesleft) return 0; /* * some optimizations * - do not use errno directly only assign a time * (some platform define errno as a complex macro) * - some processors have few registers, deference and copy input variable * (this make also compiler optimize more due to removed aliasing) * also we use unsigned to remove required unsigned casts */ local_errno = 0; il = *inbytesleft; ol = *outbytesleft; ib = (const unsigned char*) *inbuf; ob = (unsigned char*) *outbuf; if (CD == Like_to_Like) { size_t copybytes = (il < ol)? il : ol; memcpy(ob, ib, copybytes); ob += copybytes; ol -= copybytes; ib += copybytes; il -= copybytes; } else if (CD & ~0x77) { local_errno = EINVAL; } else { iconv_get_t get_func = iconv_gets[(CD>>4) & 7]; iconv_put_t put_func = iconv_puts[ CD & 7]; while (il) { ICONV_CHAR out_c; int readed = get_func(ib, il, &out_c), written; TDS_EXTRA_CHECK(assert(readed > 0 || readed == -EINVAL || readed == -EILSEQ)); if (TDS_UNLIKELY(readed < 0)) { local_errno = -readed; break; } written = put_func(ob, ol, out_c); TDS_EXTRA_CHECK(assert(written > 0 || written == -E2BIG || written == -EILSEQ)); if (TDS_UNLIKELY(written < 0)) { local_errno = -written; break; } il -= readed; ib += readed; ol -= written; ob += written; } } /* back to source */ *inbytesleft = il; *outbytesleft = ol; *inbuf = (const char*) ib; *outbuf = (char*) ob; if (il && !local_errno) local_errno = E2BIG; if (local_errno) { errno = local_errno; return (size_t)(-1); } return 0; } /** @} */ #endif freetds-1.00.82/src/replacements/gettimeofday.c100644 025423 025423 00000004004 12717145107 0015127/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2003, 2004 James K. Lowden, based on original work by Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #if defined(_WIN32) #if HAVE_ERRNO_H #include #endif #include #include "replacements.h" /* * Number of micro-seconds between the beginning of the Windows epoch * (Jan. 1, 1601) and the Unix epoch (Jan. 1, 1970). * * This assumes all Win32 compilers have 64-bit support. */ #if defined(_MSC_VER) || defined(_MSC_EXTENSIONS) || defined(__WATCOMC__) # define DELTA_EPOCH_IN_USEC 11644473600000000Ui64 #else # define DELTA_EPOCH_IN_USEC 11644473600000000ULL #endif int tds_gettimeofday (struct timeval *tv, void *tz) { FILETIME ft; TDS_UINT8 tim; TDS_UINT r; if (!tv) { errno = EINVAL; return -1; } /* * Although this function returns 10^-7 precision the real * precision is less than milliseconds on Windows XP */ GetSystemTimeAsFileTime (&ft); tim = ((((TDS_UINT8) ft.dwHighDateTime) << 32) | ft.dwLowDateTime) - (DELTA_EPOCH_IN_USEC * 10U); /* * here we use same division to compute quotient * and remainder at the same time (gcc) */ tv->tv_sec = (long) (tim / 10000000UL); r = tim % 10000000UL; tv->tv_usec = (long) (r / 10L); return 0; } #endif freetds-1.00.82/src/replacements/poll.c100644 025423 025423 00000010161 12717145107 0013415/* * poll(2) implemented with select(2), for systems without poll(2). * Warning: a call to this poll() takes about 4K of stack space. * * This file and the accompanying poll.h * are based on poll.h in C++ by * * Greg Parker gparker-web@sealiesoftware.com December 2000 * This code is in the public domain. * * Updated May 2002: * * fix crash when an fd is less than 0 * * set errno=EINVAL if an fd is greater or equal to FD_SETSIZE * * don't set POLLIN or POLLOUT in revents if it wasn't requested * in events (only happens when an fd is in the poll set twice) * * Converted to C and spruced up by James K. Lowden December 2008. */ #include #ifndef HAVE_POLL #include #include #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #include "replacements.h" #if HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #if HAVE_ERRNO_H #include #endif /* HAVE_ERRNO_H */ #include #include #include int tds_poll(struct pollfd fds[], int nfds, int timeout) { struct timeval tv, *tvp; fd_set fdsr, fdsw, fdsp; struct pollfd *p; const struct pollfd *endp = fds? fds + nfds : NULL; int selected, polled = 0, maxfd = 0; #if defined(_WIN32) typedef int (WSAAPI *WSAPoll_t)(struct pollfd fds[], ULONG nfds, INT timeout); static WSAPoll_t poll_p = (WSAPoll_t) -1; if (poll_p == (WSAPoll_t) -1) { HMODULE mod; poll_p = NULL; mod = GetModuleHandle("ws2_32"); if (mod) poll_p = (WSAPoll_t) GetProcAddress(mod, "WSAPoll"); } /* Windows 2008 have WSAPoll which is semantically equal to poll */ if (poll_p != NULL) return poll_p(fds, nfds, timeout); #endif if (fds == NULL) { errno = EFAULT; return -1; } FD_ZERO(&fdsr); FD_ZERO(&fdsw); FD_ZERO(&fdsp); /* * Transcribe flags from the poll set to the fd sets. * Also ensure we don't exceed select's capabilities. */ for (p = fds; p < endp; p++) { /* Negative fd checks nothing and always reports zero */ if (p->fd < 0) { continue; } #if defined(_WIN32) /* Win32 cares about the number of descriptors, not the highest one. */ ++maxfd; #else if (p->fd > maxfd) maxfd = p->fd; #endif /* POLLERR is never set coming in; poll(2) always reports errors */ /* But don't report if we're not listening to anything at all. */ if (p->events & POLLIN) FD_SET(p->fd, &fdsr); if (p->events & POLLOUT) FD_SET(p->fd, &fdsw); if (p->events != 0) FD_SET(p->fd, &fdsp); } /* * If any FD is too big for select(2), we need to return an error. * Which one, though, is debatable. There's no defined errno for * this for poll(2) because it's an "impossible" condition; * there's no such thing as "too many" FD's to check. * select(2) returns EINVAL, and so do we. * EFAULT might be better. */ #if !defined(_WIN32) if (maxfd > FD_SETSIZE) { assert(FD_SETSIZE > 0); errno = EINVAL; return -1; } #endif /* * poll timeout is in milliseconds. Convert to struct timeval. * timeout == -1: wait forever : select timeout of NULL * timeout == 0: return immediately : select timeout of zero */ if (timeout >= 0) { tv.tv_sec = timeout / 1000; tv.tv_usec = (timeout % 1000) * 1000; tvp = &tv; } else { tvp = NULL; } /* * call select(2) */ if ((selected = select(maxfd+1, &fdsr, &fdsw, &fdsp, tvp)) < 0) { return -1; /* error */ } /* timeout, clear all result bits and return zero. */ if (selected == 0) { for (p = fds; p < endp; p++) { p->revents = 0; } return 0; } /* * Select found something * Transcribe result from fd sets to poll set. * Return the number of ready fds. */ for (polled=0, p=fds; p < endp; p++) { p->revents = 0; /* Negative fd always reports zero */ if (p->fd < 0) { continue; } if ((p->events & POLLIN) && FD_ISSET(p->fd, &fdsr)) { p->revents |= POLLIN; } if ((p->events & POLLOUT) && FD_ISSET(p->fd, &fdsw)) { p->revents |= POLLOUT; } if ((p->events != 0) && FD_ISSET(p->fd, &fdsp)) { p->revents |= POLLERR; } if (p->revents) polled++; } assert(polled == selected); return polled; } #endif /* HAVE_POLL */ freetds-1.00.82/src/replacements/getpassarg.c100644 025423 025423 00000003041 12717145107 0014606/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns * Copyright (C) 2006, 2007, 2008, 2009, 2010 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include "replacements.h" /* * return a copy of the password, reading from stdin if arg is '-' * trashing he argument in the process. */ char * tds_getpassarg(char *arg) { char pwd[256], *ptr, *q; if (strcmp(arg, "-") == 0) { if (fgets(pwd, sizeof(pwd), stdin) == NULL) return NULL; ptr = strchr(pwd, '\n'); if (ptr) *ptr = '\0'; arg = pwd; } ptr = strdup(arg); memset(pwd, 0, sizeof(pwd)); for (q = arg; *q; *q++ = '*') continue; return ptr; } freetds-1.00.82/src/replacements/socketpair.c100644 025423 025423 00000005065 12717145107 0014622/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2011 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #if !defined(HAVE_SOCKETPAIR) #if defined(_WIN32) #include #include #endif #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #if HAVE_ERRNO_H #include #endif #include #include "replacements.h" int tds_socketpair(int domain, int type, int protocol, TDS_SYS_SOCKET sv[2]) { struct sockaddr_in sa, sa2; SOCKLEN_T addrlen; TDS_SYS_SOCKET s; if (!sv) return -1; /* create a listener */ s = socket(AF_INET, type, 0); if (TDS_IS_SOCKET_INVALID(s)) return -1; sv[1] = INVALID_SOCKET; sv[0] = socket(AF_INET, type, 0); if (TDS_IS_SOCKET_INVALID(sv[0])) goto Cleanup; /* bind to a random port */ sa.sin_family = AF_INET; sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK); sa.sin_port = 0; if (bind(s, (struct sockaddr*) &sa, sizeof(sa)) < 0) goto Cleanup; if (listen(s, 1) < 0) goto Cleanup; /* connect to kernel choosen port */ addrlen = sizeof(sa); if (tds_getsockname(s, (struct sockaddr*) &sa, &addrlen) < 0) goto Cleanup; if (connect(sv[0], (struct sockaddr*) &sa, sizeof(sa)) < 0) goto Cleanup; addrlen = sizeof(sa2); sv[1] = tds_accept(s, (struct sockaddr*) &sa2, &addrlen); if (TDS_IS_SOCKET_INVALID(sv[1])) goto Cleanup; /* check proper connection */ addrlen = sizeof(sa); if (tds_getsockname(sv[0], (struct sockaddr*) &sa, &addrlen) < 0) goto Cleanup; addrlen = sizeof(sa2); if (tds_getpeername(sv[1], (struct sockaddr*) &sa2, &addrlen) < 0) goto Cleanup; if (sa.sin_family != sa2.sin_family || sa.sin_port != sa2.sin_port || sa.sin_addr.s_addr != sa2.sin_addr.s_addr) goto Cleanup; CLOSESOCKET(s); return 0; Cleanup: CLOSESOCKET(s); CLOSESOCKET(sv[0]); CLOSESOCKET(sv[1]); return -1; } #endif freetds-1.00.82/src/replacements/win_mutex.c100644 025423 025423 00000003537 12717145107 0014477/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2010 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #ifdef _WIN32 #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include "ptw32_MCS_lock.c" void tds_win_mutex_lock(tds_raw_mutex * mutex) { if (!InterlockedExchangeAdd(&mutex->done, 0)) { /* MBR fence */ ptw32_mcs_local_node_t node; ptw32_mcs_lock_acquire(&mutex->lock, &node); if (!mutex->done) { InitializeCriticalSection(&mutex->crit); mutex->done = 1; } ptw32_mcs_lock_release(&node); } EnterCriticalSection(&mutex->crit); } int tds_raw_mutex_trylock(tds_raw_mutex * mutex) { if (!mutex->done && !InterlockedExchangeAdd(&mutex->done, 0)) { /* MBR fence */ ptw32_mcs_local_node_t node; ptw32_mcs_lock_acquire(&mutex->lock, &node); if (!mutex->done) { InitializeCriticalSection(&mutex->crit); mutex->done = 1; } ptw32_mcs_lock_release(&node); } if (TryEnterCriticalSection(&mutex->crit)) return 0; return -1; } #endif freetds-1.00.82/src/replacements/tds_cond.c100644 025423 025423 00000014207 12717145107 0014251/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2012 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #ifdef _WIN32 #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include #include #ifndef ETIMEDOUT #define ETIMEDOUT WSAETIMEDOUT #endif /* implementation for systems that support Condition Variables */ typedef VOID(WINAPI * init_cv_t) (TDS_CONDITION_VARIABLE * cv); typedef BOOL(WINAPI * sleep_cv_t) (TDS_CONDITION_VARIABLE * cv, CRITICAL_SECTION * crit, DWORD milli); typedef VOID(WINAPI * wake_cv_t) (TDS_CONDITION_VARIABLE * cv); static init_cv_t init_cv = NULL; static sleep_cv_t sleep_cv = NULL; static wake_cv_t wake_cv = NULL; static int new_cond_init(tds_condition * cond) { init_cv(&cond->cv); return 0; } static int new_cond_destroy(tds_condition * cond) { return 0; } static int new_cond_signal(tds_condition * cond) { wake_cv(&cond->cv); return 0; } static int new_cond_timedwait(tds_condition * cond, tds_raw_mutex * mtx, int timeout_sec) { if (sleep_cv(&cond->cv, &mtx->crit, timeout_sec < 0 ? INFINITE : timeout_sec * 1000)) return 0; return ETIMEDOUT; } /* implementation for systems that do not support Condition Variables */ static int old_cond_init(tds_condition * cond) { cond->ev = CreateEvent(NULL, FALSE, FALSE, NULL); if (!cond->ev) return ENOMEM; return 0; } static int old_cond_destroy(tds_condition * cond) { CloseHandle(cond->ev); return 0; } static int old_cond_signal(tds_condition * cond) { SetEvent(cond->ev); return 0; } static int old_cond_timedwait(tds_condition * cond, tds_raw_mutex * mtx, int timeout_sec) { int res; LeaveCriticalSection(&mtx->crit); res = WaitForSingleObject(cond->ev, timeout_sec < 0 ? INFINITE : timeout_sec * 1000); EnterCriticalSection(&mtx->crit); return res == WAIT_TIMEOUT ? ETIMEDOUT : 0; } /* dummy implementation used to detect which version above to use */ static void detect_cond(void) { /* detect if this Windows support condition variables */ HMODULE mod = GetModuleHandle("kernel32"); init_cv = (init_cv_t) GetProcAddress(mod, "InitializeConditionVariable"); sleep_cv = (sleep_cv_t) GetProcAddress(mod, "SleepConditionVariableCS"); wake_cv = (wake_cv_t) GetProcAddress(mod, "WakeConditionVariable"); if (init_cv && sleep_cv && wake_cv) { tds_raw_cond_init = new_cond_init; tds_raw_cond_destroy = new_cond_destroy; tds_raw_cond_signal = new_cond_signal; tds_raw_cond_timedwait = new_cond_timedwait; } else { tds_raw_cond_init = old_cond_init; tds_raw_cond_destroy = old_cond_destroy; tds_raw_cond_signal = old_cond_signal; tds_raw_cond_timedwait = old_cond_timedwait; } } static int detect_cond_init(tds_condition * cond) { detect_cond(); return tds_raw_cond_init(cond); } static int detect_cond_destroy(tds_condition * cond) { detect_cond(); return tds_raw_cond_destroy(cond); } static int detect_cond_signal(tds_condition * cond) { detect_cond(); return tds_raw_cond_signal(cond); } static int detect_cond_timedwait(tds_condition * cond, tds_raw_mutex * mtx, int timeout_sec) { detect_cond(); return tds_raw_cond_timedwait(cond, mtx, timeout_sec); } int (*tds_raw_cond_init) (tds_condition * cond) = detect_cond_init; int (*tds_raw_cond_destroy) (tds_condition * cond) = detect_cond_destroy; int (*tds_raw_cond_signal) (tds_condition * cond) = detect_cond_signal; int (*tds_raw_cond_timedwait) (tds_condition * cond, tds_raw_mutex * mtx, int timeout_sec) = detect_cond_timedwait; #elif defined(TDS_HAVE_PTHREAD_MUTEX) && !defined(TDS_NO_THREADSAFE) #include #include #include /* check if we can use clock_gettime */ #undef USE_CLOCK_IN_COND #if !defined(HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP) && \ defined(HAVE_CLOCK_GETTIME) && (defined(CLOCK_REALTIME) || defined(CLOCK_MONOTONIC)) #define USE_CLOCK_IN_COND 1 #endif /* check if we can use CLOCK_MONOTONIC for conditions */ #undef USE_MONOTONIC_CLOCK_IN_COND #if defined(USE_CLOCK_IN_COND) && defined(HAVE_PTHREAD_CONDATTR_SETCLOCK) && defined(CLOCK_MONOTONIC) #define USE_MONOTONIC_CLOCK_IN_COND 1 #endif int tds_raw_cond_init(tds_condition *cond) { #ifdef USE_MONOTONIC_CLOCK_IN_COND int res; pthread_condattr_t attr; pthread_condattr_init(&attr); res = pthread_condattr_setclock(&attr, CLOCK_MONOTONIC); if (!res) res = pthread_cond_init(cond, &attr); pthread_condattr_destroy(&attr); return res; #else return pthread_cond_init(cond, NULL); #endif } int tds_raw_cond_timedwait(tds_condition *cond, tds_raw_mutex *mtx, int timeout_sec) { struct timespec ts; #if !defined(HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP) && !defined(USE_CLOCK_IN_COND) struct timeval tv; #endif if (timeout_sec < 0) return tds_raw_cond_wait(cond, mtx); #if defined(HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP) ts.tv_sec = timeout_sec; ts.tv_nsec = 0; return pthread_cond_timedwait_relative_np(cond, mtx, &ts); #else # ifdef USE_CLOCK_IN_COND # if defined(USE_MONOTONIC_CLOCK_IN_COND) clock_gettime(CLOCK_MONOTONIC, &ts); # else clock_gettime(CLOCK_REALTIME, &ts); # endif # elif defined(HAVE_GETTIMEOFDAY) gettimeofday(&tv, NULL); ts.tv_sec = tv.tv_sec; ts.tv_nsec = tv.tv_usec * 1000u; # else # error No way to get a proper time! # endif ts.tv_sec += timeout_sec; return pthread_cond_timedwait(cond, mtx, &ts); #endif } #endif freetds-1.00.82/src/replacements/getaddrinfo.c100644 025423 025423 00000006100 12717145107 0014733/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2013 Peter Deacon * Copyright (C) 2013 Ziglio Frediano * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #if !defined(HAVE_GETADDRINFO) #include #include #include #include #include #include "replacements.h" /* Incomplete implementation, single ipv4 addr, service does not work, hints do not work */ int tds_getaddrinfo(const char *node, const char *service, const struct tds_addrinfo *hints, struct tds_addrinfo **res) { struct tds_addrinfo *addr; struct sockaddr_in *sin = NULL; struct hostent *host; in_addr_t ipaddr; char buffer[4096]; struct hostent result; int h_errnop, port = 0; assert(node != NULL); if ((addr = (tds_addrinfo *) calloc(1, sizeof(struct tds_addrinfo))) == NULL) goto Cleanup; if ((sin = (struct sockaddr_in *) calloc(1, sizeof(struct sockaddr_in))) == NULL) goto Cleanup; addr->ai_addr = (struct sockaddr *) sin; addr->ai_addrlen = sizeof(struct sockaddr_in); addr->ai_family = AF_INET; if ((ipaddr = inet_addr(node)) == INADDR_NONE) { if ((host = tds_gethostbyname_r(node, &result, buffer, sizeof(buffer), &h_errnop)) == NULL) goto Cleanup; if (host->h_name) addr->ai_canonname = strdup(host->h_name); ipaddr = *(in_addr_t *) host->h_addr; } if (service) { port = atoi(service); if (!port) port = tds_getservice(service); } sin->sin_family = AF_INET; sin->sin_addr.s_addr = ipaddr; sin->sin_port = htons(port); *res = addr; return 0; Cleanup: if (addr != NULL) tds_freeaddrinfo(addr); return -1; } /* Incomplete implementation, ipv4 only, port does not work, flags do not work */ int tds_getnameinfo(const struct sockaddr *sa, size_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags) { struct sockaddr_in *sin = (struct sockaddr_in *) sa; if (sa->sa_family != AF_INET) return EAI_FAMILY; if (host == NULL || hostlen < 16) return EAI_OVERFLOW; #if defined(AF_INET) && HAVE_INET_NTOP inet_ntop(AF_INET, &sin->sin_addr, host, hostlen); #elif HAVE_INET_NTOA_R inet_ntoa_r(sin->sin_addr, host, hostlen); #else strlcpy(hostip, inet_ntoa(sin->sin_addr), hostlen); #endif return 0; } void tds_freeaddrinfo(struct tds_addrinfo *addr) { assert(addr != NULL); free(addr->ai_canonname); free(addr->ai_addr); free(addr); } #endif freetds-1.00.82/src/replacements/sleep.c100644 025423 025423 00000003146 12522201763 0013557/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2015 Ziglio Frediano * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #if HAVE_ERRNO_H #include #endif /* HAVE_ERRNO_H */ #if HAVE_POLL_H #include #endif /* HAVE_POLL_H */ #include #include #include "replacements.h" void tds_sleep_s(unsigned sec) { #ifdef _WIN32 Sleep(sec * 1000u); #else sleep(sec); #endif } void tds_sleep_ms(unsigned ms) { #ifdef _WIN32 Sleep(ms); #elif defined(HAVE_NANOSLEEP) struct timespec ts = { ms / 1000u, (ms % 1000u) * 1000000lu }, rem; int r; for (;;) { r = nanosleep(&ts, &rem); if (!r || errno != EINTR) break; ts = rem; } #elif defined(HAVE_USLEEP) usleep(ms * 1000u); #else struct pollfd fd; poll(&fd, 0, ms); #endif } freetds-1.00.82/src/replacements/ptw32_MCS_lock.c100644 025423 025423 00000014727 12522201763 0015147/* * ptw32_MCS_lock.c * * Description: * This translation unit implements queue-based locks. * * -------------------------------------------------------------------------- * * Pthreads-win32 - POSIX Threads Library for Win32 * Copyright(C) 1998 John E. Bossom * Copyright(C) 1999,2005 Pthreads-win32 contributors * * Contact Email: rpj@callisto.canberra.edu.au * * The current list of contributors is contained * in the file CONTRIBUTORS included with the source * code distribution. The list can also be seen at the * following World Wide Web location: * http://sources.redhat.com/pthreads-win32/contributors.html * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library in the file COPYING.LIB; * if not, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ /* * About MCS locks: * * MCS locks are queue-based locks, where the queue nodes are local to the * thread. The 'lock' is nothing more than a global pointer that points to * the last node in the queue, or is NULL if the queue is empty. * * Originally designed for use as spin locks requiring no kernel resources * for synchronisation or blocking, the implementation below has adapted * the MCS spin lock for use as a general mutex that will suspend threads * when there is lock contention. * * Because the queue nodes are thread-local, most of the memory read/write * operations required to add or remove nodes from the queue do not trigger * cache-coherence updates. * * Like 'named' mutexes, MCS locks consume system resources transiently - * they are able to acquire and free resources automatically - but MCS * locks do not require any unique 'name' to identify the lock to all * threads using it. * * Usage of MCS locks: * * - you need a global ptw32_mcs_lock_t instance initialised to 0 or NULL. * - you need a local thread-scope ptw32_mcs_local_node_t instance, which * may serve several different locks but you need at least one node for * every lock held concurrently by a thread. * * E.g.: * * ptw32_mcs_lock_t lock1 = 0; * ptw32_mcs_lock_t lock2 = 0; * * void *mythread(void *arg) * { * ptw32_mcs_local_node_t node; * * ptw32_mcs_acquire (&lock1, &node); * ptw32_mcs_release (&node); * * ptw32_mcs_acquire (&lock2, &node); * ptw32_mcs_release (&node); * { * ptw32_mcs_local_node_t nodex; * * ptw32_mcs_acquire (&lock1, &node); * ptw32_mcs_acquire (&lock2, &nodex); * * ptw32_mcs_release (&nodex); * ptw32_mcs_release (&node); * } * return (void *)0; * } */ #if 0 #include "implement.h" #include "pthread.h" #endif struct ptw32_mcs_node_t_ { struct ptw32_mcs_node_t_ **lock; /* ptr to tail of queue */ struct ptw32_mcs_node_t_ *next; /* ptr to successor in queue */ void *readyFlag; /* set after lock is released by predecessor */ void *nextFlag; /* set after 'next' ptr is set by successor */ }; typedef struct ptw32_mcs_node_t_ ptw32_mcs_local_node_t; typedef struct ptw32_mcs_node_t_ *ptw32_mcs_lock_t; /* * ptw32_mcs_flag_set -- notify another thread about an event. * * Set event if an event handle has been stored in the flag, and * set flag to -1 otherwise. Note that -1 cannot be a valid handle value. */ static inline void ptw32_mcs_flag_set(PVOID volatile *flag) { HANDLE e = (HANDLE) InterlockedCompareExchangePointer(flag, (void *) -1, (void *) 0); if ((HANDLE) 0 != e) { /* another thread has already stored an event handle in the flag */ SetEvent(e); } } /* * ptw32_mcs_flag_set -- wait for notification from another. * * Store an event handle in the flag and wait on it if the flag has not been * set, and proceed without creating an event otherwise. */ static inline void ptw32_mcs_flag_wait(PVOID volatile *flag) { if (0 == InterlockedCompareExchangePointer(flag, 0, 0)) { /* MBR fence */ /* the flag is not set. create event. */ HANDLE e = CreateEvent(NULL, FALSE, FALSE, NULL); if (0 == InterlockedCompareExchangePointer(flag, (void *) e, (void *) 0)) { /* stored handle in the flag. wait on it now. */ WaitForSingleObject(e, INFINITE); } CloseHandle(e); } } /* * ptw32_mcs_lock_acquire -- acquire an MCS lock. * * See: * J. M. Mellor-Crummey and M. L. Scott. * Algorithms for Scalable Synchronization on Shared-Memory Multiprocessors. * ACM Transactions on Computer Systems, 9(1):21-65, Feb. 1991. */ static inline void ptw32_mcs_lock_acquire(ptw32_mcs_lock_t * lock, ptw32_mcs_local_node_t * node) { ptw32_mcs_local_node_t *pred; node->lock = lock; node->nextFlag = 0; node->readyFlag = 0; node->next = 0; /* initially, no successor */ /* queue for the lock */ pred = (ptw32_mcs_local_node_t *) InterlockedExchangePointer((void **) lock, node); if (0 != pred) { /* the lock was not free. link behind predecessor. */ pred->next = node; ptw32_mcs_flag_set(&pred->nextFlag); ptw32_mcs_flag_wait(&node->readyFlag); } } /* * ptw32_mcs_lock_release -- release an MCS lock. * * See: * J. M. Mellor-Crummey and M. L. Scott. * Algorithms for Scalable Synchronization on Shared-Memory Multiprocessors. * ACM Transactions on Computer Systems, 9(1):21-65, Feb. 1991. */ static inline void ptw32_mcs_lock_release(ptw32_mcs_local_node_t * node) { ptw32_mcs_lock_t *lock = node->lock; ptw32_mcs_local_node_t *next = (ptw32_mcs_local_node_t *) InterlockedCompareExchangePointer((void * volatile*) &node->next, 0, 0); /* MBR fence */ if (0 == next) { /* no known successor */ if (node == (ptw32_mcs_local_node_t *) InterlockedCompareExchangePointer((void * volatile*) lock, 0, node)) { /* no successor, lock is free now */ return; } /* wait for successor */ ptw32_mcs_flag_wait(&node->nextFlag); next = (ptw32_mcs_local_node_t *) InterlockedCompareExchangePointer((void * volatile*) &node->next, 0, 0); /* MBR fence */ } /* pass the lock */ ptw32_mcs_flag_set(&next->readyFlag); } freetds-1.00.82/src/replacements/CMakeLists.txt100644 025423 025423 00000001145 12717145107 0015045include_directories(.) include(CheckFunctionExists) set(FUNCS asprintf vasprintf strtok_r readpassphrase strlcpy strlcat basename getopt strsep) set(add_SRCS) foreach(func ${FUNCS}) string(TOUPPER "HAVE_${func}" var) check_function_exists(${func} ${var}) if(NOT ${var}) set(add_SRCS ${add_SRCS} ${func}.c) endif() endforeach(func) add_library(replacements STATIC iconv.c gettimeofday.c poll.c getpassarg.c socketpair.c win_mutex.c tds_cond.c getaddrinfo.c sleep.c ${add_SRCS} ) if (NOT WIN32) set_target_properties(replacements PROPERTIES COMPILE_FLAGS -fPIC) endif() add_subdirectory(unittests) freetds-1.00.82/src/replacements/unittests/Makefile.am100644 025423 025423 00000000647 12717145107 0016411TESTS = mutex1$(EXEEXT) condition$(EXEEXT) strings$(EXEEXT) passarg$(EXEEXT) \ strtok_r$(EXEEXT) check_PROGRAMS = $(TESTS) mutex1_SOURCES = mutex1.c condition_SOURCES = condition.c strings_SOURCES = strings.c passarg_SOURCES = passarg.c strtok_r_SOURCES = strtok_r.c AM_CPPFLAGS = -I$(top_srcdir)/include -I$(srcdir)/.. -I../ LIBS = ../../replacements/libreplacements.la $(NETWORK_LIBS) EXTRA_DIST = CMakeLists.txt freetds-1.00.82/src/replacements/unittests/Makefile.in100644 025423 025423 00000107723 13242511111 0016407# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/replacements/unittests ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = \ $(top_srcdir)/m4/ac_caolan_func_which_gethostbyname_r.m4 \ $(top_srcdir)/m4/ac_have_inaddr_none.m4 \ $(top_srcdir)/m4/ac_have_malloc_options.m4 \ $(top_srcdir)/m4/ac_nullzero.m4 \ $(top_srcdir)/m4/ac_raf_func_which_getservbyname_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_gethostbyaddr_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_getpwuid_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_localtime_r.m4 \ $(top_srcdir)/m4/acx_pthread.m4 \ $(top_srcdir)/m4/ax_cflags_gcc_option.m4 \ $(top_srcdir)/m4/check_openssl.m4 \ $(top_srcdir)/m4/gettimemilli.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/pushlibs.m4 \ $(top_srcdir)/m4/sprintf_i64_format.m4 \ $(top_srcdir)/m4/type_socklen_t.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am_condition_OBJECTS = condition.$(OBJEXT) condition_OBJECTS = $(am_condition_OBJECTS) condition_LDADD = $(LDADD) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = am_mutex1_OBJECTS = mutex1.$(OBJEXT) mutex1_OBJECTS = $(am_mutex1_OBJECTS) mutex1_LDADD = $(LDADD) am_passarg_OBJECTS = passarg.$(OBJEXT) passarg_OBJECTS = $(am_passarg_OBJECTS) passarg_LDADD = $(LDADD) am_strings_OBJECTS = strings.$(OBJEXT) strings_OBJECTS = $(am_strings_OBJECTS) strings_LDADD = $(LDADD) am_strtok_r_OBJECTS = strtok_r.$(OBJEXT) strtok_r_OBJECTS = $(am_strtok_r_OBJECTS) strtok_r_LDADD = $(LDADD) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(condition_SOURCES) $(mutex1_SOURCES) $(passarg_SOURCES) \ $(strings_SOURCES) $(strtok_r_SOURCES) DIST_SOURCES = $(condition_SOURCES) $(mutex1_SOURCES) \ $(passarg_SOURCES) $(strings_SOURCES) $(strtok_r_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__tty_colors_dummy = \ mgn= red= grn= lgn= blu= brg= std=; \ am__color_tests=no am__tty_colors = { \ $(am__tty_colors_dummy); \ if test "X$(AM_COLOR_TESTS)" = Xno; then \ am__color_tests=no; \ elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ am__color_tests=yes; \ elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ am__color_tests=yes; \ fi; \ if test $$am__color_tests = yes; then \ red=''; \ grn=''; \ lgn=''; \ blu=''; \ mgn=''; \ brg=''; \ std=''; \ fi; \ } am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__recheck_rx = ^[ ]*:recheck:[ ]* am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* # A command that, given a newline-separated list of test names on the # standard input, print the name of the tests that are to be re-run # upon "make recheck". am__list_recheck_tests = $(AWK) '{ \ recheck = 1; \ while ((rc = (getline line < ($$0 ".trs"))) != 0) \ { \ if (rc < 0) \ { \ if ((getline line2 < ($$0 ".log")) < 0) \ recheck = 0; \ break; \ } \ else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ { \ recheck = 0; \ break; \ } \ else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ { \ break; \ } \ }; \ if (recheck) \ print $$0; \ close ($$0 ".trs"); \ close ($$0 ".log"); \ }' # A command that, given a newline-separated list of test names on the # standard input, create the global log from their .trs and .log files. am__create_global_log = $(AWK) ' \ function fatal(msg) \ { \ print "fatal: making $@: " msg | "cat >&2"; \ exit 1; \ } \ function rst_section(header) \ { \ print header; \ len = length(header); \ for (i = 1; i <= len; i = i + 1) \ printf "="; \ printf "\n\n"; \ } \ { \ copy_in_global_log = 1; \ global_test_result = "RUN"; \ while ((rc = (getline line < ($$0 ".trs"))) != 0) \ { \ if (rc < 0) \ fatal("failed to read from " $$0 ".trs"); \ if (line ~ /$(am__global_test_result_rx)/) \ { \ sub("$(am__global_test_result_rx)", "", line); \ sub("[ ]*$$", "", line); \ global_test_result = line; \ } \ else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ copy_in_global_log = 0; \ }; \ if (copy_in_global_log) \ { \ rst_section(global_test_result ": " $$0); \ while ((rc = (getline line < ($$0 ".log"))) != 0) \ { \ if (rc < 0) \ fatal("failed to read from " $$0 ".log"); \ print line; \ }; \ printf "\n"; \ }; \ close ($$0 ".trs"); \ close ($$0 ".log"); \ }' # Restructured Text title. am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } # Solaris 10 'make', and several other traditional 'make' implementations, # pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it # by disabling -e (using the XSI extension "set +e") if it's set. am__sh_e_setup = case $$- in *e*) set +e;; esac # Default flags passed to test drivers. am__common_driver_flags = \ --color-tests "$$am__color_tests" \ --enable-hard-errors "$$am__enable_hard_errors" \ --expect-failure "$$am__expect_failure" # To be inserted before the command running the test. Creates the # directory for the log if needed. Stores in $dir the directory # containing $f, in $tst the test, in $log the log. Executes the # developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and # passes TESTS_ENVIRONMENT. Set up options for the wrapper that # will run the test scripts (or their associated LOG_COMPILER, if # thy have one). am__check_pre = \ $(am__sh_e_setup); \ $(am__vpath_adj_setup) $(am__vpath_adj) \ $(am__tty_colors); \ srcdir=$(srcdir); export srcdir; \ case "$@" in \ */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ *) am__odir=.;; \ esac; \ test "x$$am__odir" = x"." || test -d "$$am__odir" \ || $(MKDIR_P) "$$am__odir" || exit $$?; \ if test -f "./$$f"; then dir=./; \ elif test -f "$$f"; then dir=; \ else dir="$(srcdir)/"; fi; \ tst=$$dir$$f; log='$@'; \ if test -n '$(DISABLE_HARD_ERRORS)'; then \ am__enable_hard_errors=no; \ else \ am__enable_hard_errors=yes; \ fi; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ am__expect_failure=yes;; \ *) \ am__expect_failure=no;; \ esac; \ $(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) # A shell command to get the names of the tests scripts with any registered # extension removed (i.e., equivalently, the names of the test logs, with # the '.log' extension removed). The result is saved in the shell variable # '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, # we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", # since that might cause problem with VPATH rewrites for suffix-less tests. # See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. am__set_TESTS_bases = \ bases='$(TEST_LOGS)'; \ bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ bases=`echo $$bases` RECHECK_LOGS = $(TEST_LOGS) AM_RECURSIVE_TARGETS = check recheck TEST_SUITE_LOG = test-suite.log TEST_EXTENSIONS = @EXEEXT@ .test LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) am__set_b = \ case '$@' in \ */*) \ case '$*' in \ */*) b='$*';; \ *) b=`echo '$@' | sed 's/\.log$$//'`; \ esac;; \ *) \ b='$*';; \ esac am__test_logs1 = $(TESTS:=.log) am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) TEST_LOGS = $(am__test_logs2:.test.log=.log) TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ $(TEST_LOG_FLAGS) am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp \ $(top_srcdir)/mkinstalldirs $(top_srcdir)/test-driver DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BUILD_NUMBER = @BUILD_NUMBER@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOXYGEN = @DOXYGEN@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FREETDS_LIBGCC = @FREETDS_LIBGCC@ FREETDS_ODBC_MODULE = @FREETDS_ODBC_MODULE@ FREETDS_SYMBOLIC = @FREETDS_SYMBOLIC@ GCRYPT_CFLAGS = @GCRYPT_CFLAGS@ GCRYPT_LIBS = @GCRYPT_LIBS@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ HAVE_OPENSSL = @HAVE_OPENSSL@ HAVE_PERL_SOURCES = @HAVE_PERL_SOURCES@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBADD_DL = @LIBADD_DL@ LIBADD_DLD_LINK = @LIBADD_DLD_LINK@ LIBADD_DLOPEN = @LIBADD_DLOPEN@ LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@ LIBICONV = @LIBICONV@ LIBOBJS = @LIBOBJS@ LIBS = ../../replacements/libreplacements.la $(NETWORK_LIBS) LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBOBJS = @LTLIBOBJS@ LT_DLLOADERS = @LT_DLLOADERS@ LT_DLPREOPEN = @LT_DLPREOPEN@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ NETTLE_CFLAGS = @NETTLE_CFLAGS@ NETTLE_LIBS = @NETTLE_LIBS@ NETWORK_LIBS = @NETWORK_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ODBC = @ODBC@ ODBCINSTLIB = @ODBCINSTLIB@ ODBCLIB = @ODBCLIB@ ODBCNODMLIB = @ODBCNODMLIB@ ODBCNODMLIBAPP = @ODBCNODMLIBAPP@ ODBC_CONFIG = @ODBC_CONFIG@ ODBC_INC = @ODBC_INC@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ RC = @RC@ READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SUBVERSION = @SUBVERSION@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ dblib_define = @dblib_define@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ tds_sysdep_int16_type = @tds_sysdep_int16_type@ tds_sysdep_int32_type = @tds_sysdep_int32_type@ tds_sysdep_int64_type = @tds_sysdep_int64_type@ tds_sysdep_intptr_type = @tds_sysdep_intptr_type@ tds_sysdep_real32_type = @tds_sysdep_real32_type@ tds_sysdep_real64_type = @tds_sysdep_real64_type@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ TESTS = mutex1$(EXEEXT) condition$(EXEEXT) strings$(EXEEXT) passarg$(EXEEXT) \ strtok_r$(EXEEXT) check_PROGRAMS = $(TESTS) mutex1_SOURCES = mutex1.c condition_SOURCES = condition.c strings_SOURCES = strings.c passarg_SOURCES = passarg.c strtok_r_SOURCES = strtok_r.c AM_CPPFLAGS = -I$(top_srcdir)/include -I$(srcdir)/.. -I../ EXTRA_DIST = CMakeLists.txt all: all-am .SUFFIXES: .SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/replacements/unittests/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/replacements/unittests/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-checkPROGRAMS: @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list condition$(EXEEXT): $(condition_OBJECTS) $(condition_DEPENDENCIES) $(EXTRA_condition_DEPENDENCIES) @rm -f condition$(EXEEXT) $(AM_V_CCLD)$(LINK) $(condition_OBJECTS) $(condition_LDADD) $(LIBS) mutex1$(EXEEXT): $(mutex1_OBJECTS) $(mutex1_DEPENDENCIES) $(EXTRA_mutex1_DEPENDENCIES) @rm -f mutex1$(EXEEXT) $(AM_V_CCLD)$(LINK) $(mutex1_OBJECTS) $(mutex1_LDADD) $(LIBS) passarg$(EXEEXT): $(passarg_OBJECTS) $(passarg_DEPENDENCIES) $(EXTRA_passarg_DEPENDENCIES) @rm -f passarg$(EXEEXT) $(AM_V_CCLD)$(LINK) $(passarg_OBJECTS) $(passarg_LDADD) $(LIBS) strings$(EXEEXT): $(strings_OBJECTS) $(strings_DEPENDENCIES) $(EXTRA_strings_DEPENDENCIES) @rm -f strings$(EXEEXT) $(AM_V_CCLD)$(LINK) $(strings_OBJECTS) $(strings_LDADD) $(LIBS) strtok_r$(EXEEXT): $(strtok_r_OBJECTS) $(strtok_r_DEPENDENCIES) $(EXTRA_strtok_r_DEPENDENCIES) @rm -f strtok_r$(EXEEXT) $(AM_V_CCLD)$(LINK) $(strtok_r_OBJECTS) $(strtok_r_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/condition.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mutex1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/passarg.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strings.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strtok_r.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags # Recover from deleted '.trs' file; this should ensure that # "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create # both 'foo.log' and 'foo.trs'. Break the recipe in two subshells # to avoid problems with "make -n". .log.trs: rm -f $< $@ $(MAKE) $(AM_MAKEFLAGS) $< # Leading 'am--fnord' is there to ensure the list of targets does not # expand to empty, as could happen e.g. with make check TESTS=''. am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) am--force-recheck: @: $(TEST_SUITE_LOG): $(TEST_LOGS) @$(am__set_TESTS_bases); \ am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ redo_bases=`for i in $$bases; do \ am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ done`; \ if test -n "$$redo_bases"; then \ redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ if $(am__make_dryrun); then :; else \ rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ fi; \ fi; \ if test -n "$$am__remaking_logs"; then \ echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ "recursion detected" >&2; \ elif test -n "$$redo_logs"; then \ am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ fi; \ if $(am__make_dryrun); then :; else \ st=0; \ errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ for i in $$redo_bases; do \ test -f $$i.trs && test -r $$i.trs \ || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ test -f $$i.log && test -r $$i.log \ || { echo "$$errmsg $$i.log" >&2; st=1; }; \ done; \ test $$st -eq 0 || exit 1; \ fi @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ ws='[ ]'; \ results=`for b in $$bases; do echo $$b.trs; done`; \ test -n "$$results" || results=/dev/null; \ all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ if test `expr $$fail + $$xpass + $$error` -eq 0; then \ success=true; \ else \ success=false; \ fi; \ br='==================='; br=$$br$$br$$br$$br; \ result_count () \ { \ if test x"$$1" = x"--maybe-color"; then \ maybe_colorize=yes; \ elif test x"$$1" = x"--no-color"; then \ maybe_colorize=no; \ else \ echo "$@: invalid 'result_count' usage" >&2; exit 4; \ fi; \ shift; \ desc=$$1 count=$$2; \ if test $$maybe_colorize = yes && test $$count -gt 0; then \ color_start=$$3 color_end=$$std; \ else \ color_start= color_end=; \ fi; \ echo "$${color_start}# $$desc $$count$${color_end}"; \ }; \ create_testsuite_report () \ { \ result_count $$1 "TOTAL:" $$all "$$brg"; \ result_count $$1 "PASS: " $$pass "$$grn"; \ result_count $$1 "SKIP: " $$skip "$$blu"; \ result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ result_count $$1 "FAIL: " $$fail "$$red"; \ result_count $$1 "XPASS:" $$xpass "$$red"; \ result_count $$1 "ERROR:" $$error "$$mgn"; \ }; \ { \ echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ $(am__rst_title); \ create_testsuite_report --no-color; \ echo; \ echo ".. contents:: :depth: 2"; \ echo; \ for b in $$bases; do echo $$b; done \ | $(am__create_global_log); \ } >$(TEST_SUITE_LOG).tmp || exit 1; \ mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ if $$success; then \ col="$$grn"; \ else \ col="$$red"; \ test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ fi; \ echo "$${col}$$br$${std}"; \ echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ echo "$${col}$$br$${std}"; \ create_testsuite_report --maybe-color; \ echo "$$col$$br$$std"; \ if $$success; then :; else \ echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ if test -n "$(PACKAGE_BUGREPORT)"; then \ echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ fi; \ echo "$$col$$br$$std"; \ fi; \ $$success || exit 1 check-TESTS: @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ log_list=`for i in $$bases; do echo $$i.log; done`; \ trs_list=`for i in $$bases; do echo $$i.trs; done`; \ log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ exit $$?; recheck: all $(check_PROGRAMS) @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ bases=`for i in $$bases; do echo $$i; done \ | $(am__list_recheck_tests)` || exit 1; \ log_list=`for i in $$bases; do echo $$i.log; done`; \ log_list=`echo $$log_list`; \ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ am__force_recheck=am--force-recheck \ TEST_LOGS="$$log_list"; \ exit $$? mutex1.log: mutex1$(EXEEXT) @p='mutex1$(EXEEXT)'; \ b='mutex1'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) condition.log: condition$(EXEEXT) @p='condition$(EXEEXT)'; \ b='condition'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) strings.log: strings$(EXEEXT) @p='strings$(EXEEXT)'; \ b='strings'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) passarg.log: passarg$(EXEEXT) @p='passarg$(EXEEXT)'; \ b='passarg'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) strtok_r.log: strtok_r$(EXEEXT) @p='strtok_r$(EXEEXT)'; \ b='strtok_r'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) .test.log: @p='$<'; \ $(am__set_b); \ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) @am__EXEEXT_TRUE@.test$(EXEEXT).log: @am__EXEEXT_TRUE@ @p='$<'; \ @am__EXEEXT_TRUE@ $(am__set_b); \ @am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ @am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ @am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ @am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-am all-am: Makefile installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: check-am install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am clean \ clean-checkPROGRAMS clean-generic clean-libtool cscopelist-am \ ctags ctags-am distclean distclean-compile distclean-generic \ 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-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 \ recheck tags tags-am uninstall uninstall-am .PRECIOUS: Makefile # 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: freetds-1.00.82/src/replacements/unittests/condition.c100644 025423 025423 00000005364 12522201763 0016503/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2012 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #ifdef HAVE_UNISTD_H #include #endif #include "tds_sysdep_public.h" #include #include "replacements.h" #define int2ptr(i) ((void*)(((char*)0)+(i))) #define ptr2int(p) ((int)(((char*)(p))-((char*)0))) #if !defined(TDS_NO_THREADSAFE) static tds_mutex mtx = TDS_MUTEX_INITIALIZER; static TDS_THREAD_PROC_DECLARE(signal_proc, arg) { tds_condition *cond = (tds_condition *) arg; /* success */ int res = 0; tds_mutex_lock(&mtx); if (tds_cond_signal(cond)) { /* failure */ res = 1; } tds_mutex_unlock(&mtx); return int2ptr(res); } static void check(int cond, const char *msg) { if (cond) { fprintf(stderr, "%s\n", msg); exit(1); } } int main(void) { tds_condition cond; tds_thread th; void *res; check(tds_cond_init(&cond), "failed initializing condition"); tds_mutex_lock(&mtx); check(tds_thread_create(&th, signal_proc, &cond) != 0, "error creating thread"); tds_sleep_ms(100); check(tds_cond_wait(&cond, &mtx), "failed waiting condition"); res = &th; check(tds_thread_join(th, &res) != 0, "error waiting thread"); check(ptr2int(res) != 0, "error signaling condition"); /* under Windows mutex are recursive */ #ifndef _WIN32 check(tds_mutex_trylock(&mtx) == 0, "mutex should be locked"); #endif /* check timed version */ check(tds_cond_timedwait(&cond, &mtx, 1) == 0, "should not succeed to wait condition"); check(tds_thread_create(&th, signal_proc, &cond) != 0, "error creating thread"); check(tds_cond_timedwait(&cond, &mtx, 1), "error on timed waiting condition"); res = &th; check(tds_thread_join(th, &res) != 0, "error waiting thread"); check(ptr2int(res) != 0, "error signaling condition"); tds_mutex_unlock(&mtx); check(tds_cond_destroy(&cond), "failed destroying condition"); return 0; } #else int main(void) { return 0; } #endif freetds-1.00.82/src/replacements/unittests/mutex1.c100644 025423 025423 00000004737 12522201763 0015743/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2012 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #include "tds_sysdep_public.h" #include #define int2ptr(i) ((void*)(((char*)0)+(i))) #define ptr2int(p) ((int)(((char*)(p))-((char*)0))) #if !defined(TDS_NO_THREADSAFE) static tds_mutex mtx = TDS_MUTEX_INITIALIZER; static TDS_THREAD_PROC_DECLARE(trylock_proc, arg) { tds_mutex *mtx = (tds_mutex *) arg; if (!tds_mutex_trylock(mtx)) { /* got mutex, failure as should be locked */ return int2ptr(1); } /* success */ return int2ptr(0); } static void test(tds_mutex *mtx) { tds_thread th; void *res; if (tds_mutex_trylock(mtx)) { fprintf(stderr, "mutex should be unlocked\n"); exit(1); } /* this success on Windows cause mutex are recursive */ #ifndef _WIN32 if (!tds_mutex_trylock(mtx)) { fprintf(stderr, "mutex should be locked\n"); exit(1); } #endif if (tds_thread_create(&th, trylock_proc, mtx) != 0) { fprintf(stderr, "error creating thread\n"); exit(1); } if (tds_thread_join(th, &res) != 0) { fprintf(stderr, "error waiting thread\n"); exit(1); } if (ptr2int(res) != 0) { fprintf(stderr, "mutex should be locked inside thread\n"); exit(1); } tds_mutex_unlock(mtx); } int main(void) { tds_mutex local; test(&mtx); /* try allocating it */ if (tds_mutex_init(&local)) { fprintf(stderr, "error creating mutex\n"); exit(1); } test(&local); tds_mutex_free(&local); /* try again */ if (tds_mutex_init(&local)) { fprintf(stderr, "error creating mutex\n"); exit(1); } test(&local); tds_mutex_free(&local); return 0; } #else int main(void) { return 0; } #endif freetds-1.00.82/src/replacements/unittests/passarg.c100644 025423 025423 00000003070 12717145107 0016152/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2014 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #undef NDEBUG #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #ifdef HAVE_UNISTD_H #include #endif #include #include #include "replacements.h" int main(void) { FILE *f; char *pwd = strdup("password"); char *p; p = tds_getpassarg(pwd); assert(p); assert(strcmp(pwd, "********") == 0); assert(strcmp(p, "password") == 0); free(p); free(pwd); f = fopen("passarg.in", "w"); assert(f); fputs("line1pwd\nline2pwd\n", f); fclose(f); f = freopen("passarg.in", "r", stdin); assert(f); p = tds_getpassarg("-"); assert(p); assert(strcmp(p, "line1pwd") == 0); free(p); unlink("passarg.in"); return 0; } freetds-1.00.82/src/replacements/unittests/strings.c100644 025423 025423 00000005365 12717145107 0016214/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2014 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #undef NDEBUG #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #include #include "replacements.h" /* If the system supplies these, we're going to simulate the situation * where it doesn't so we're always testing our own versions. */ #if HAVE_STRLCPY size_t tds_strlcpy(char *dest, const char *src, size_t len); #include "../strlcpy.c" #endif #if HAVE_STRLCAT size_t tds_strlcat(char *dest, const char *src, size_t len); #include "../strlcat.c" #endif int main(void) { char *buf = (char *) malloc(10); /* test tds_strlcpy */ memset(buf, 0xff, 10); assert(tds_strlcpy(buf, "test", 10) == 4); assert(strcmp(buf, "test") == 0); memset(buf, 0xff, 10); assert(tds_strlcpy(buf, "TESTTEST", 10) == 8); assert(strcmp(buf, "TESTTEST") == 0); memset(buf, 0xff, 10); assert(tds_strlcpy(buf, "abcdefghi", 10) == 9); assert(strcmp(buf, "abcdefghi") == 0); memset(buf, 0xff, 10); assert(tds_strlcpy(buf, "1234567890", 10) == 10); assert(strcmp(buf, "123456789") == 0); memset(buf, 0xff, 10); assert(tds_strlcpy(buf, "xyzabc1234567890", 10) == 16); assert(strcmp(buf, "xyzabc123") == 0); /* test tds_strlcat */ strcpy(buf, "xyz"); assert(tds_strlcat(buf, "test", 10) == 7); assert(strcmp(buf, "xyztest") == 0); strcpy(buf, "xyz"); assert(tds_strlcat(buf, "TESTAB", 10) == 9); assert(strcmp(buf, "xyzTESTAB") == 0); strcpy(buf, "xyz"); assert(tds_strlcat(buf, "TESTabc", 10) == 10); assert(strcmp(buf, "xyzTESTab") == 0); strcpy(buf, "xyz"); assert(tds_strlcat(buf, "123456789012345", 10) == 18); assert(strcmp(buf, "xyz123456") == 0); strcpy(buf, "123456789"); assert(tds_strlcat(buf, "test", 4) == 13); assert(strcmp(buf, "123456789") == 0); /* test length == 0 */ assert(tds_strlcpy(buf + 10, "test", 0) == 4); strcpy(buf, "123"); assert(tds_strlcat(buf, "456", 0) == 6); assert(strcmp(buf, "123") == 0); free(buf); return 0; } freetds-1.00.82/src/replacements/unittests/strtok_r.c100644 025423 025423 00000004022 12717145107 0016357/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2010-2015 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #define TDS_INTERNAL_TEST 1 #include #ifdef HAVE_STRTOK_R char *tds_strtok_r(char *str, const char *sep, char **lasts); #include "../strtok_r.c" #else #include #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include "replacements.h" #endif #include static void test(const char *s, const char *sep) { size_t len = strlen(s); char *c1 = (char*) malloc(len+1); char *c2 = (char*) malloc(len+1); char *last = NULL, *s1, *s2; const char *p1, *p2; printf("testint '%s' with '%s' separator(s)\n", s, sep); strcpy(c1, s); strcpy(c2, s); s1 = c1; s2 = c2; for (;;) { p1 = strtok(s1, sep); p2 = tds_strtok_r(s2, sep, &last); s1 = s2 = NULL; if ((p1 && !p2) || (!p1 && p2)) { fprintf(stderr, "ptr mistmach %p %p\n", p1, p2); exit(1); } if (!p1) break; if (strcmp(p1, p2) != 0) { fprintf(stderr, "string mistmach '%s' '%s'\n", p1, p2); exit(1); } printf("got string %s\n", p1); } printf("\n"); free(c1); free(c2); } int main(void) { test("a b\tc", "\t "); test(" x y \t z", " \t"); test("a;b;c;", ";"); test("a;b; c;;", ";"); test("", ";"); test(";;;", ";"); return 0; } freetds-1.00.82/src/replacements/unittests/CMakeLists.txt100644 025423 025423 00000000370 12717145107 0017106foreach(target mutex1 condition strings passarg strtok_r) add_executable(r_${target} ${target}.c) set_target_properties(r_${target} PROPERTIES OUTPUT_NAME ${target}) target_link_libraries(r_${target} replacements ${lib_BASE}) endforeach(target) freetds-1.00.82/src/tds/Makefile.am100644 025423 025423 00000003415 12717145107 0012453 SUBDIRS = . unittests AM_CPPFLAGS = -I$(top_srcdir)/include noinst_LTLIBRARIES = libtds.la if HAVE_SSPI AUTH_FILES_DIST = challenge.c md4.c md5.c des.c gssapi.c hmac_md5.c AUTH_FILES = sspi.c else AUTH_FILES = challenge.c md4.c md5.c des.c gssapi.c hmac_md5.c AUTH_FILES_DIST = sspi.c endif libtds_la_SOURCES= mem.c token.c util.c login.c read.c \ write.c convert.c numeric.c config.c query.c iconv.c \ locale.c threadsafe.c vstrbuild.c \ tdsstring.c getmac.c data.c net.c tls.c \ tds_checks.c log.c dlist.c \ bulk.c packet.c stream.c random.c \ sec_negotiate_gnutls.h sec_negotiate_openssl.h sec_negotiate.c \ $(AUTH_FILES) libtds_la_LDFLAGS= libtds_la_LIBADD = $(NETWORK_LIBS) noinst_HEADERS = tds_willconvert.h encodings.h num_limits.h tds_types.h EXTRA_DIST = tds_willconvert.h encodings.h num_limits.h tds_types.h \ CMakeLists.txt $(AUTH_FILES_DIST) # Perl is needed to build from a repository checkout. # Perl is *not* needed to build from a tarball. ## We have to build num_limits.h because automake can't infer the ## dependency (on num_limits.pl). data.c: tds_types.h if HAVE_PERL_SOURCES BUILT_SOURCES = tds_willconvert.h encodings.h num_limits.h tds_types.h clean-local: cd $(srcdir) && rm -f $(BUILT_SOURCES) tds_willconvert.h: tds_willconvert.pl Makefile perl $(srcdir)/tds_willconvert.pl $(top_srcdir)/include/freetds/proto.h > $@.tmp mv $@.tmp $@ encodings.h: encodings.pl alternative_character_sets.h Makefile perl $(srcdir)/encodings.pl $(srcdir) > $@.tmp 2> /dev/null mv $@.tmp $@ num_limits.h: num_limits.pl Makefile perl $(srcdir)/num_limits.pl > $@.tmp mv $@.tmp $@ tds_types.h: types.pl Makefile $(top_srcdir)/misc/types.csv perl $(srcdir)/types.pl $(top_srcdir)/misc/types.csv $(top_srcdir)/include/freetds/proto.h > $@.tmp mv $@.tmp $@ endif freetds-1.00.82/src/tds/tds_willconvert.h100644 025423 025423 00000010640 13242511127 0014001/*** Please do not edit this file! ***/ /*** It was generated with 'perl tds_willconvert.pl > tds_willconvert.h' ***/ /*** It is much easier to edit the __DATA__ table than this file. ***/ /*** ***/ /*** Thank you. ***/ static const TDS_TINYINT type2category[256] = { 0, /* 0 */ 0, /* 1 */ 0, /* 2 */ 0, /* 3 */ 0, /* 4 */ 0, /* 5 */ 0, /* 6 */ 0, /* 7 */ 0, /* 8 */ 0, /* 9 */ 0, /* 10 */ 0, /* 11 */ 0, /* 12 */ 0, /* 13 */ 0, /* 14 */ 0, /* 15 */ 0, /* 16 */ 0, /* 17 */ 0, /* 18 */ 0, /* 19 */ 0, /* 20 */ 0, /* 21 */ 0, /* 22 */ 0, /* 23 */ 0, /* 24 */ 0, /* 25 */ 0, /* 26 */ 0, /* 27 */ 0, /* 28 */ 0, /* 29 */ 0, /* 30 */ 0, /* SYBVOID */ 0, /* 32 */ 0, /* 33 */ 3, /* SYBIMAGE */ 1, /* SYBTEXT */ 5, /* SYBBLOB */ 3, /* SYBVARBINARY */ 0, /* SYBINTN */ 1, /* SYBVARCHAR */ 7, /* SYBMSDATE */ 7, /* SYBMSTIME */ 7, /* SYBMSDATETIME2 */ 7, /* SYBMSDATETIMEOFFSET */ 0, /* 44 */ 3, /* SYBBINARY */ 0, /* SYBINTERVAL */ 1, /* SYBCHAR */ 6, /* SYBINT1 */ 7, /* SYBDATE */ 2, /* SYBBIT */ 7, /* SYBTIME */ 6, /* SYBINT2 */ 0, /* 53 */ 0, /* 54 */ 0, /* 55 */ 6, /* SYBINT4 */ 0, /* 57 */ 7, /* SYBDATETIME4 */ 6, /* SYBREAL */ 6, /* SYBMONEY */ 7, /* SYBDATETIME */ 6, /* SYBFLT8 */ 0, /* 63 */ 6, /* SYBUINT1 */ 6, /* SYBUINT2 */ 6, /* SYBUINT4 */ 6, /* SYBUINT8 */ 0, /* SYBUINTN */ 0, /* 69 */ 0, /* 70 */ 0, /* 71 */ 0, /* 72 */ 0, /* 73 */ 0, /* 74 */ 0, /* 75 */ 0, /* 76 */ 0, /* 77 */ 0, /* 78 */ 0, /* 79 */ 0, /* 80 */ 0, /* 81 */ 0, /* 82 */ 0, /* 83 */ 0, /* 84 */ 0, /* 85 */ 0, /* 86 */ 0, /* 87 */ 0, /* 88 */ 0, /* 89 */ 0, /* 90 */ 0, /* 91 */ 0, /* 92 */ 0, /* 93 */ 0, /* 94 */ 0, /* 95 */ 0, /* 96 */ 0, /* 97 */ 0, /* SYBVARIANT */ 0, /* SYBNTEXT */ 0, /* 100 */ 0, /* 101 */ 0, /* 102 */ 4, /* SYBSENSITIVITY */ 2, /* SYBBOUNDARY */ 0, /* 105 */ 2, /* SYBDECIMAL */ 0, /* 107 */ 2, /* SYBNUMERIC */ 0, /* SYBFLTN */ 0, /* SYBMONEYN */ 0, /* SYBDATETIMN */ 0, /* 112 */ 0, /* 113 */ 0, /* 114 */ 0, /* 115 */ 0, /* 116 */ 0, /* 117 */ 0, /* 118 */ 0, /* 119 */ 0, /* 120 */ 0, /* 121 */ 6, /* SYBMONEY4 */ 0, /* SYBDATEN */ 0, /* 124 */ 0, /* 125 */ 0, /* 126 */ 6, /* SYBINT8 */ 0, /* 128 */ 0, /* 129 */ 0, /* 130 */ 0, /* 131 */ 0, /* 132 */ 0, /* 133 */ 0, /* 134 */ 0, /* 135 */ 0, /* 136 */ 0, /* 137 */ 0, /* 138 */ 0, /* 139 */ 0, /* 140 */ 0, /* 141 */ 0, /* 142 */ 0, /* 143 */ 0, /* 144 */ 0, /* 145 */ 0, /* 146 */ 0, /* SYBTIMEN */ 0, /* 148 */ 0, /* 149 */ 0, /* 150 */ 0, /* 151 */ 0, /* 152 */ 0, /* 153 */ 0, /* 154 */ 0, /* 155 */ 0, /* 156 */ 0, /* 157 */ 0, /* 158 */ 0, /* 159 */ 0, /* 160 */ 0, /* 161 */ 0, /* 162 */ 0, /* SYBXML */ 0, /* 164 */ 3, /* XSYBVARBINARY */ 0, /* 166 */ 1, /* XSYBVARCHAR */ 0, /* 168 */ 0, /* 169 */ 0, /* 170 */ 0, /* 171 */ 0, /* 172 */ 3, /* XSYBBINARY */ 0, /* SYBUNITEXT */ 1, /* SYBLONGCHAR */ 0, /* SYBSINT1 */ 0, /* 177 */ 0, /* 178 */ 0, /* 179 */ 0, /* 180 */ 0, /* 181 */ 0, /* 182 */ 0, /* 183 */ 0, /* 184 */ 0, /* 185 */ 0, /* 186 */ 7, /* SYB5BIGDATETIME */ 7, /* SYB5BIGTIME */ 0, /* 189 */ 0, /* 190 */ 0, /* SYB5INT8 */ 0, /* 192 */ 0, /* 193 */ 0, /* 194 */ 0, /* 195 */ 0, /* 196 */ 0, /* 197 */ 0, /* 198 */ 0, /* 199 */ 0, /* 200 */ 0, /* 201 */ 0, /* 202 */ 0, /* 203 */ 0, /* 204 */ 0, /* 205 */ 0, /* 206 */ 0, /* 207 */ 0, /* 208 */ 0, /* 209 */ 0, /* 210 */ 0, /* 211 */ 0, /* 212 */ 0, /* 213 */ 0, /* 214 */ 0, /* 215 */ 0, /* 216 */ 0, /* 217 */ 0, /* 218 */ 0, /* 219 */ 0, /* 220 */ 0, /* 221 */ 0, /* 222 */ 0, /* 223 */ 0, /* 224 */ 3, /* SYBLONGBINARY */ 0, /* 226 */ 0, /* 227 */ 0, /* 228 */ 0, /* 229 */ 0, /* 230 */ 0, /* XSYBNVARCHAR */ 0, /* 232 */ 0, /* 233 */ 0, /* 234 */ 0, /* 235 */ 0, /* 236 */ 0, /* 237 */ 0, /* 238 */ 0, /* XSYBNCHAR */ 0, /* SYBMSUDT */ 0, /* SYBMSXML */ 0, /* 242 */ 0, /* 243 */ 0, /* 244 */ 0, /* 245 */ 0, /* 246 */ 0, /* 247 */ 0, /* 248 */ 0, /* 249 */ 0, /* 250 */ 0, /* 251 */ 0, /* 252 */ 0, /* 253 */ 0, /* 254 */ 0, /* 255 */ }; static const TDS_UINT category_conversion[] = { 0, 238, /* SYBTEXT */ 78, /* SYBBIT */ 74, /* SYBIMAGE */ 0, /* SYBSENSITIVITY */ 42, /* SYBUNIQUE */ 78, /* SYBINT1 */ 138, /* SYBMSDATE */ }; freetds-1.00.82/src/tds/encodings.h100644 025423 025423 00000057413 13242511127 0012541/* * This file produced from ./encodings.pl on Mon Feb 19 09:01:11 2018 * $Id: encodings.pl,v 1.12 2010-11-26 19:46:55 freddy77 Exp $ */ #ifdef TDS_ICONV_ENCODING_TABLES static const TDS_ENCODING canonic_charsets[] = { { "ISO-8859-1", 1, 1, 0}, /* 0 */ { "UTF-8", 1, 4, 1}, /* 1 */ { "UCS-2LE", 2, 2, 2}, /* 2 */ { "UCS-2BE", 2, 2, 3}, /* 3 */ { "ARMSCII-8", 1, 1, 4}, /* 4 */ { "BIG-5", 1, 2, 5}, /* 5 */ { "BIG5-HKSCS", 1, 2, 6}, /* 6 */ { "C99", 1, 1, 7}, /* 7 */ { "CHINESE", 1, 1, 8}, /* 8 */ { "CN", 1, 1, 9}, /* 9 */ { "CN-GB", 1, 2, 10}, /* 10 */ { "CN-GB-ISOIR165", 1, 1, 11}, /* 11 */ { "CP1133", 1, 1, 12}, /* 12 */ { "CP1250", 1, 1, 13}, /* 13 */ { "CP1251", 1, 1, 14}, /* 14 */ { "CP1252", 1, 1, 15}, /* 15 */ { "CP1253", 1, 1, 16}, /* 16 */ { "CP1254", 1, 1, 17}, /* 17 */ { "CP1255", 1, 1, 18}, /* 18 */ { "CP1256", 1, 1, 19}, /* 19 */ { "CP1257", 1, 1, 20}, /* 20 */ { "CP1258", 1, 1, 21}, /* 21 */ { "CP1361", 1, 2, 22}, /* 22 */ { "CP437", 1, 1, 23}, /* 23 */ { "CP850", 1, 1, 24}, /* 24 */ { "CP862", 1, 1, 25}, /* 25 */ { "CP866", 1, 1, 26}, /* 26 */ { "CP874", 1, 1, 27}, /* 27 */ { "CP932", 1, 2, 28}, /* 28 */ { "CP936", 1, 2, 29}, /* 29 */ { "CP949", 1, 2, 30}, /* 30 */ { "CP950", 1, 2, 31}, /* 31 */ { "EUC-JP", 1, 3, 32}, /* 32 */ { "EUC-KR", 1, 2, 33}, /* 33 */ { "EUC-TW", 1, 4, 34}, /* 34 */ { "GB18030", 1, 4, 35}, /* 35 */ { "GEORGIAN-ACADEMY", 1, 1, 36}, /* 36 */ { "GEORGIAN-PS", 1, 1, 37}, /* 37 */ { "HZ", 1, 1, 38}, /* 38 */ { "ISO-2022-CN", 1, 4, 39}, /* 39 */ { "ISO-2022-CN-EXT", 1, 4, 40}, /* 40 */ { "ISO-2022-JP", 1, 1, 41}, /* 41 */ { "ISO-2022-JP-1", 1, 1, 42}, /* 42 */ { "ISO-2022-JP-2", 1, 1, 43}, /* 43 */ { "ISO-2022-KR", 1, 2, 44}, /* 44 */ { "ISO-8859-10", 1, 1, 45}, /* 45 */ { "ISO-8859-13", 1, 1, 46}, /* 46 */ { "ISO-8859-14", 1, 1, 47}, /* 47 */ { "ISO-8859-15", 1, 1, 48}, /* 48 */ { "ISO-8859-16", 1, 1, 49}, /* 49 */ { "ISO-8859-2", 1, 1, 50}, /* 50 */ { "ISO-8859-3", 1, 1, 51}, /* 51 */ { "ISO-8859-4", 1, 1, 52}, /* 52 */ { "ISO-8859-5", 1, 1, 53}, /* 53 */ { "ISO-8859-6", 1, 1, 54}, /* 54 */ { "ISO-8859-7", 1, 1, 55}, /* 55 */ { "ISO-8859-8", 1, 1, 56}, /* 56 */ { "ISO-8859-9", 1, 1, 57}, /* 57 */ { "ISO-IR-14", 1, 1, 58}, /* 58 */ { "ISO-IR-149", 1, 1, 59}, /* 59 */ { "ISO-IR-159", 1, 1, 60}, /* 60 */ { "ISO-IR-166", 1, 1, 61}, /* 61 */ { "ISO-IR-87", 1, 1, 62}, /* 62 */ { "JAVA", 1, 1, 63}, /* 63 */ { "JISX0201-1976", 1, 1, 64}, /* 64 */ { "KOI8-R", 1, 1, 65}, /* 65 */ { "KOI8-RU", 1, 1, 66}, /* 66 */ { "KOI8-T", 1, 1, 67}, /* 67 */ { "KOI8-U", 1, 1, 68}, /* 68 */ { "MAC", 1, 1, 69}, /* 69 */ { "MACARABIC", 1, 1, 70}, /* 70 */ { "MACCENTRALEUROPE", 1, 1, 71}, /* 71 */ { "MACCROATIAN", 1, 1, 72}, /* 72 */ { "MACCYRILLIC", 1, 1, 73}, /* 73 */ { "MACGREEK", 1, 1, 74}, /* 74 */ { "MACHEBREW", 1, 1, 75}, /* 75 */ { "MACICELAND", 1, 1, 76}, /* 76 */ { "MACROMANIA", 1, 1, 77}, /* 77 */ { "MACTHAI", 1, 1, 78}, /* 78 */ { "MACTURKISH", 1, 1, 79}, /* 79 */ { "MACUKRAINE", 1, 1, 80}, /* 80 */ { "MULELAO-1", 1, 1, 81}, /* 81 */ { "NEXTSTEP", 1, 1, 82}, /* 82 */ { "ROMAN8", 1, 1, 83}, /* 83 */ { "SJIS", 1, 2, 84}, /* 84 */ { "TCVN", 1, 1, 85}, /* 85 */ { "UCS-2", 2, 2, 86}, /* 86 */ { "UCS-2-INTERNAL", 2, 2, 87}, /* 87 */ { "UCS-2-SWAPPED", 2, 2, 88}, /* 88 */ { "UCS-4", 4, 4, 89}, /* 89 */ { "UCS-4-INTERNAL", 4, 4, 90}, /* 90 */ { "UCS-4-SWAPPED", 4, 4, 91}, /* 91 */ { "UCS-4BE", 4, 4, 92}, /* 92 */ { "UCS-4LE", 4, 4, 93}, /* 93 */ { "US-ASCII", 1, 1, 94}, /* 94 */ { "UTF-16", 2, 4, 95}, /* 95 */ { "UTF-16BE", 2, 4, 96}, /* 96 */ { "UTF-16LE", 2, 4, 97}, /* 97 */ { "UTF-32", 4, 4, 98}, /* 98 */ { "UTF-32BE", 4, 4, 99}, /* 99 */ { "UTF-32LE", 4, 4, 100}, /* 100 */ { "UTF-7", 1, 4, 101}, /* 101 */ { "VISCII", 1, 1, 102}, /* 102 */ }; static const CHARACTER_SET_ALIAS iconv_aliases[] = { { "646", 94 }, { "850", 24 }, { "862", 25 }, { "866", 26 }, { "ANSI_X3.4-1968", 94 }, { "ANSI_X3.4-1986", 94 }, { "ARABIC", 54 }, { "ARMSCII-8", 4 }, { "ASCII", 94 }, { "ASMO-708", 54 }, { "BIG-5", 5 }, { "BIG-FIVE", 5 }, { "BIG5", 5 }, { "BIG5-HKSCS", 6 }, { "BIG5HKSCS", 6 }, { "BIGFIVE", 5 }, { "C99", 7 }, { "CHINESE", 8 }, { "CN", 9 }, { "CN-BIG5", 5 }, { "CN-GB", 10 }, { "CN-GB-ISOIR165", 11 }, { "CP1133", 12 }, { "CP1250", 13 }, { "CP1251", 14 }, { "CP1252", 15 }, { "CP1253", 16 }, { "CP1254", 17 }, { "CP1255", 18 }, { "CP1256", 19 }, { "CP1257", 20 }, { "CP1258", 21 }, { "CP1361", 22 }, { "CP367", 94 }, { "CP437", 23 }, { "CP819", 0 }, { "CP850", 24 }, { "CP862", 25 }, { "CP866", 26 }, { "CP874", 27 }, { "CP932", 28 }, { "CP936", 29 }, { "CP949", 30 }, { "CP950", 31 }, { "CSASCII", 94 }, { "CSBIG5", 5 }, { "CSEUCKR", 33 }, { "CSEUCPKDFMTJAPANESE", 32 }, { "CSEUCTW", 34 }, { "CSGB2312", 10 }, { "CSHALFWIDTHKATAKANA", 64 }, { "CSHPROMAN8", 83 }, { "CSIBM866", 26 }, { "CSISO14JISC6220RO", 58 }, { "CSISO159JISX02121990", 60 }, { "CSISO2022CN", 39 }, { "CSISO2022JP", 41 }, { "CSISO2022JP2", 43 }, { "CSISO2022KR", 44 }, { "CSISO57GB1988", 9 }, { "CSISO58GB231280", 8 }, { "CSISO87JISX0208", 62 }, { "CSISOLATIN1", 0 }, { "CSISOLATIN2", 50 }, { "CSISOLATIN3", 51 }, { "CSISOLATIN4", 52 }, { "CSISOLATIN5", 57 }, { "CSISOLATIN6", 45 }, { "CSISOLATINARABIC", 54 }, { "CSISOLATINCYRILLIC", 53 }, { "CSISOLATINGREEK", 55 }, { "CSISOLATINHEBREW", 56 }, { "CSKOI8R", 65 }, { "CSKSC56011987", 59 }, { "CSMACINTOSH", 69 }, { "CSPC850MULTILINGUAL", 24 }, { "CSPC862LATINHEBREW", 25 }, { "CSSHIFTJIS", 84 }, { "CSUCS4", 89 }, { "CSUNICODE", 86 }, { "CSUNICODE11", 3 }, { "CSUNICODE11UTF7", 101 }, { "CSVISCII", 102 }, { "CYRILLIC", 53 }, { "ECMA-114", 54 }, { "ECMA-118", 55 }, { "ELOT_928", 55 }, { "EUC-CN", 10 }, { "EUC-JP", 32 }, { "EUC-KR", 33 }, { "EUC-TW", 34 }, { "EUCCN", 10 }, { "EUCJP", 32 }, { "EUCKR", 33 }, { "EUCTW", 34 }, {"EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE", 32 }, { "GB18030", 35 }, { "GB2312", 10 }, { "GBK", 29 }, { "GB_1988-80", 9 }, { "GB_2312-80", 8 }, { "GEORGIAN-ACADEMY", 36 }, { "GEORGIAN-PS", 37 }, { "GREEK", 55 }, { "GREEK8", 55 }, { "HEBREW", 56 }, { "HP-ROMAN8", 83 }, { "HZ", 38 }, { "HZ-GB-2312", 38 }, { "IBM-CP1133", 12 }, { "IBM367", 94 }, { "IBM437", 23 }, { "IBM819", 0 }, { "IBM850", 24 }, { "IBM862", 25 }, { "IBM866", 26 }, { "ISO-10646-UCS-2", 86 }, { "ISO-10646-UCS-4", 89 }, { "ISO-2022-CN", 39 }, { "ISO-2022-CN-EXT", 40 }, { "ISO-2022-JP", 41 }, { "ISO-2022-JP-1", 42 }, { "ISO-2022-JP-2", 43 }, { "ISO-2022-KR", 44 }, { "ISO-8859-1", 0 }, { "ISO-8859-10", 45 }, { "ISO-8859-13", 46 }, { "ISO-8859-14", 47 }, { "ISO-8859-15", 48 }, { "ISO-8859-16", 49 }, { "ISO-8859-2", 50 }, { "ISO-8859-3", 51 }, { "ISO-8859-4", 52 }, { "ISO-8859-5", 53 }, { "ISO-8859-6", 54 }, { "ISO-8859-7", 55 }, { "ISO-8859-8", 56 }, { "ISO-8859-9", 57 }, { "ISO-CELTIC", 47 }, { "ISO-IR-100", 0 }, { "ISO-IR-101", 50 }, { "ISO-IR-109", 51 }, { "ISO-IR-110", 52 }, { "ISO-IR-126", 55 }, { "ISO-IR-127", 54 }, { "ISO-IR-138", 56 }, { "ISO-IR-14", 58 }, { "ISO-IR-144", 53 }, { "ISO-IR-148", 57 }, { "ISO-IR-149", 59 }, { "ISO-IR-157", 45 }, { "ISO-IR-159", 60 }, { "ISO-IR-165", 11 }, { "ISO-IR-166", 61 }, { "ISO-IR-179", 46 }, { "ISO-IR-199", 47 }, { "ISO-IR-203", 48 }, { "ISO-IR-226", 49 }, { "ISO-IR-57", 9 }, { "ISO-IR-58", 8 }, { "ISO-IR-6", 94 }, { "ISO-IR-87", 62 }, { "ISO646-CN", 9 }, { "ISO646-JP", 58 }, { "ISO646-US", 94 }, { "ISO8859-1", 0 }, { "ISO8859-10", 45 }, { "ISO8859-15", 48 }, { "ISO8859-2", 50 }, { "ISO8859-4", 52 }, { "ISO8859-5", 53 }, { "ISO8859-6", 54 }, { "ISO8859-7", 55 }, { "ISO8859-8", 56 }, { "ISO8859-9", 57 }, { "ISO_646.IRV:1991", 94 }, { "ISO_8859-1", 0 }, { "ISO_8859-10", 45 }, { "ISO_8859-10:1992", 45 }, { "ISO_8859-13", 46 }, { "ISO_8859-14", 47 }, { "ISO_8859-14:1998", 47 }, { "ISO_8859-15", 48 }, { "ISO_8859-15:1998", 48 }, { "ISO_8859-16", 49 }, { "ISO_8859-16:2000", 49 }, { "ISO_8859-1:1987", 0 }, { "ISO_8859-2", 50 }, { "ISO_8859-2:1987", 50 }, { "ISO_8859-3", 51 }, { "ISO_8859-3:1988", 51 }, { "ISO_8859-4", 52 }, { "ISO_8859-4:1988", 52 }, { "ISO_8859-5", 53 }, { "ISO_8859-5:1988", 53 }, { "ISO_8859-6", 54 }, { "ISO_8859-6:1987", 54 }, { "ISO_8859-7", 55 }, { "ISO_8859-7:1987", 55 }, { "ISO_8859-8", 56 }, { "ISO_8859-8:1988", 56 }, { "ISO_8859-9", 57 }, { "ISO_8859-9:1989", 57 }, { "JAVA", 63 }, { "JIS0208", 62 }, { "JISX0201-1976", 64 }, { "JIS_C6220-1969-RO", 58 }, { "JIS_C6226-1983", 62 }, { "JIS_X0201", 64 }, { "JIS_X0208", 62 }, { "JIS_X0208-1983", 62 }, { "JIS_X0208-1990", 62 }, { "JIS_X0212", 60 }, { "JIS_X0212-1990", 60 }, { "JIS_X0212.1990-0", 60 }, { "JOHAB", 22 }, { "JP", 58 }, { "KOI8-R", 65 }, { "KOI8-RU", 66 }, { "KOI8-T", 67 }, { "KOI8-U", 68 }, { "KOREAN", 59 }, { "KSC_5601", 59 }, { "KS_C_5601-1987", 59 }, { "KS_C_5601-1989", 59 }, { "L1", 0 }, { "L2", 50 }, { "L3", 51 }, { "L4", 52 }, { "L5", 57 }, { "L6", 45 }, { "L7", 46 }, { "L8", 47 }, { "LATIN1", 0 }, { "LATIN2", 50 }, { "LATIN3", 51 }, { "LATIN4", 52 }, { "LATIN5", 57 }, { "LATIN6", 45 }, { "LATIN7", 46 }, { "LATIN8", 47 }, { "MAC", 69 }, { "MACARABIC", 70 }, { "MACCENTRALEUROPE", 71 }, { "MACCROATIAN", 72 }, { "MACCYRILLIC", 73 }, { "MACGREEK", 74 }, { "MACHEBREW", 75 }, { "MACICELAND", 76 }, { "MACINTOSH", 69 }, { "MACROMAN", 69 }, { "MACROMANIA", 77 }, { "MACTHAI", 78 }, { "MACTURKISH", 79 }, { "MACUKRAINE", 80 }, { "MS-ANSI", 15 }, { "MS-ARAB", 19 }, { "MS-CYRL", 14 }, { "MS-EE", 13 }, { "MS-GREEK", 16 }, { "MS-HEBR", 18 }, { "MS-TURK", 17 }, { "MS_KANJI", 84 }, { "MULELAO-1", 81 }, { "NEXTSTEP", 82 }, { "R8", 83 }, { "ROMAN8", 83 }, { "SHIFT-JIS", 84 }, { "SHIFT_JIS", 84 }, { "SJIS", 84 }, { "TCVN", 85 }, { "TCVN-5712", 85 }, { "TCVN5712-1", 85 }, { "TCVN5712-1:1993", 85 }, { "TIS-620", 61 }, { "TIS620", 61 }, { "TIS620-0", 61 }, { "TIS620.2529-1", 61 }, { "TIS620.2533-0", 61 }, { "TIS620.2533-1", 61 }, { "UCS-2", 86 }, { "UCS-2-INTERNAL", 87 }, { "UCS-2-SWAPPED", 88 }, { "UCS-2BE", 3 }, { "UCS-2LE", 2 }, { "UCS-4", 89 }, { "UCS-4-INTERNAL", 90 }, { "UCS-4-SWAPPED", 91 }, { "UCS-4BE", 92 }, { "UCS-4LE", 93 }, { "UCS2", 86 }, { "UCS4", 89 }, { "UHC", 30 }, { "UNICODE-1-1", 3 }, { "UNICODE-1-1-UTF-7", 101 }, { "UNICODEBIG", 3 }, { "UNICODELITTLE", 2 }, { "US", 94 }, { "US-ASCII", 94 }, { "UTF-16", 95 }, { "UTF-16BE", 96 }, { "UTF-16LE", 97 }, { "UTF-32", 98 }, { "UTF-32BE", 99 }, { "UTF-32LE", 100 }, { "UTF-7", 101 }, { "UTF-8", 1 }, { "UTF16", 95 }, { "UTF7", 101 }, { "UTF8", 1 }, { "VISCII", 102 }, { "VISCII1.1-1", 102 }, { "WINBALTRIM", 20 }, { "WINDOWS-1250", 13 }, { "WINDOWS-1251", 14 }, { "WINDOWS-1252", 15 }, { "WINDOWS-1253", 16 }, { "WINDOWS-1254", 17 }, { "WINDOWS-1255", 18 }, { "WINDOWS-1256", 19 }, { "WINDOWS-1257", 20 }, { "WINDOWS-1258", 21 }, { "WINDOWS-874", 27 }, { "X0201", 64 }, { "X0208", 62 }, { "X0212", 60 }, { "big5", 5 }, { "cp1250", 13 }, { "cp1251", 14 }, { "cp1252", 15 }, { "cp1253", 16 }, { "cp1254", 17 }, { "cp1255", 18 }, { "cp1256", 19 }, { "cp1257", 20 }, { "cp1258", 21 }, { "cp437", 23 }, { "cp850", 24 }, { "cp862", 25 }, { "cp866", 26 }, { "cp874", 27 }, { "eucJP", 32 }, { "eucKR", 33 }, { "eucTW", 34 }, { "hp15CN", 8 }, { "iso81", 0 }, { "iso815", 48 }, { "iso82", 50 }, { "iso83", 51 }, { "iso84", 52 }, { "iso85", 53 }, { "iso86", 54 }, { "iso87", 55 }, { "iso88", 56 }, { "iso88591", 0 }, { "iso885915", 48 }, { "iso88592", 50 }, { "iso88593", 51 }, { "iso88594", 52 }, { "iso88595", 53 }, { "iso88596", 54 }, { "iso88597", 55 }, { "iso88598", 56 }, { "iso88599", 57 }, { "iso89", 57 }, { "roma8", 83 }, { "roman8", 83 }, { "sjis", 84 }, { "thai8", 61 }, { "tis620", 61 }, { "ucs2", 86 }, { "ucs4", 89 }, { "utf8", 1 }, {NULL, 0} }; static const CHARACTER_SET_ALIAS sybase_aliases[] = { { "ascii_8", 0 }, { "big5", 5 }, { "cp1250", 13 }, { "cp1251", 14 }, { "cp1252", 15 }, { "cp1253", 16 }, { "cp1254", 17 }, { "cp1255", 18 }, { "cp1256", 19 }, { "cp1257", 20 }, { "cp1258", 21 }, { "cp437", 23 }, { "cp850", 24 }, { "cp862", 25 }, { "cp866", 26 }, { "cp874", 27 }, { "cp932", 28 }, { "cp936", 29 }, { "cp949", 30 }, { "cp950", 31 }, { "greek8", 55 }, { "iso10", 45 }, { "iso13", 46 }, { "iso14", 47 }, { "iso15", 48 }, { "iso646", 94 }, { "iso88592", 50 }, { "iso88595", 53 }, { "iso88596", 54 }, { "iso88597", 55 }, { "iso88598", 56 }, { "iso88599", 57 }, { "iso_1", 0 }, { "koi8", 65 }, { "mac", 69 }, { "mac_cyr", 73 }, { "macgreek", 74 }, { "macthai", 78 }, { "macturk", 79 }, { "roman8", 83 }, { "sjis", 84 }, { "tis620", 61 }, { "utf8", 1 }, {NULL, 0} }; #endif enum { TDS_CHARSET_ISO_8859_1 = 0, TDS_CHARSET_UTF_8 = 1, TDS_CHARSET_UCS_2LE = 2, TDS_CHARSET_UCS_2BE = 3, TDS_CHARSET_ARMSCII_8 = 4, TDS_CHARSET_BIG_5 = 5, TDS_CHARSET_BIG5_HKSCS = 6, TDS_CHARSET_C99 = 7, TDS_CHARSET_CHINESE = 8, TDS_CHARSET_CN = 9, TDS_CHARSET_CN_GB = 10, TDS_CHARSET_CN_GB_ISOIR165 = 11, TDS_CHARSET_CP1133 = 12, TDS_CHARSET_CP1250 = 13, TDS_CHARSET_CP1251 = 14, TDS_CHARSET_CP1252 = 15, TDS_CHARSET_CP1253 = 16, TDS_CHARSET_CP1254 = 17, TDS_CHARSET_CP1255 = 18, TDS_CHARSET_CP1256 = 19, TDS_CHARSET_CP1257 = 20, TDS_CHARSET_CP1258 = 21, TDS_CHARSET_CP1361 = 22, TDS_CHARSET_CP437 = 23, TDS_CHARSET_CP850 = 24, TDS_CHARSET_CP862 = 25, TDS_CHARSET_CP866 = 26, TDS_CHARSET_CP874 = 27, TDS_CHARSET_CP932 = 28, TDS_CHARSET_CP936 = 29, TDS_CHARSET_CP949 = 30, TDS_CHARSET_CP950 = 31, TDS_CHARSET_EUC_JP = 32, TDS_CHARSET_EUC_KR = 33, TDS_CHARSET_EUC_TW = 34, TDS_CHARSET_GB18030 = 35, TDS_CHARSET_GEORGIAN_ACADEMY = 36, TDS_CHARSET_GEORGIAN_PS = 37, TDS_CHARSET_HZ = 38, TDS_CHARSET_ISO_2022_CN = 39, TDS_CHARSET_ISO_2022_CN_EXT = 40, TDS_CHARSET_ISO_2022_JP = 41, TDS_CHARSET_ISO_2022_JP_1 = 42, TDS_CHARSET_ISO_2022_JP_2 = 43, TDS_CHARSET_ISO_2022_KR = 44, TDS_CHARSET_ISO_8859_10 = 45, TDS_CHARSET_ISO_8859_13 = 46, TDS_CHARSET_ISO_8859_14 = 47, TDS_CHARSET_ISO_8859_15 = 48, TDS_CHARSET_ISO_8859_16 = 49, TDS_CHARSET_ISO_8859_2 = 50, TDS_CHARSET_ISO_8859_3 = 51, TDS_CHARSET_ISO_8859_4 = 52, TDS_CHARSET_ISO_8859_5 = 53, TDS_CHARSET_ISO_8859_6 = 54, TDS_CHARSET_ISO_8859_7 = 55, TDS_CHARSET_ISO_8859_8 = 56, TDS_CHARSET_ISO_8859_9 = 57, TDS_CHARSET_ISO_IR_14 = 58, TDS_CHARSET_ISO_IR_149 = 59, TDS_CHARSET_ISO_IR_159 = 60, TDS_CHARSET_ISO_IR_166 = 61, TDS_CHARSET_ISO_IR_87 = 62, TDS_CHARSET_JAVA = 63, TDS_CHARSET_JISX0201_1976 = 64, TDS_CHARSET_KOI8_R = 65, TDS_CHARSET_KOI8_RU = 66, TDS_CHARSET_KOI8_T = 67, TDS_CHARSET_KOI8_U = 68, TDS_CHARSET_MAC = 69, TDS_CHARSET_MACARABIC = 70, TDS_CHARSET_MACCENTRALEUROPE = 71, TDS_CHARSET_MACCROATIAN = 72, TDS_CHARSET_MACCYRILLIC = 73, TDS_CHARSET_MACGREEK = 74, TDS_CHARSET_MACHEBREW = 75, TDS_CHARSET_MACICELAND = 76, TDS_CHARSET_MACROMANIA = 77, TDS_CHARSET_MACTHAI = 78, TDS_CHARSET_MACTURKISH = 79, TDS_CHARSET_MACUKRAINE = 80, TDS_CHARSET_MULELAO_1 = 81, TDS_CHARSET_NEXTSTEP = 82, TDS_CHARSET_ROMAN8 = 83, TDS_CHARSET_SJIS = 84, TDS_CHARSET_TCVN = 85, TDS_CHARSET_UCS_2 = 86, TDS_CHARSET_UCS_2_INTERNAL = 87, TDS_CHARSET_UCS_2_SWAPPED = 88, TDS_CHARSET_UCS_4 = 89, TDS_CHARSET_UCS_4_INTERNAL = 90, TDS_CHARSET_UCS_4_SWAPPED = 91, TDS_CHARSET_UCS_4BE = 92, TDS_CHARSET_UCS_4LE = 93, TDS_CHARSET_US_ASCII = 94, TDS_CHARSET_UTF_16 = 95, TDS_CHARSET_UTF_16BE = 96, TDS_CHARSET_UTF_16LE = 97, TDS_CHARSET_UTF_32 = 98, TDS_CHARSET_UTF_32BE = 99, TDS_CHARSET_UTF_32LE = 100, TDS_CHARSET_UTF_7 = 101, TDS_CHARSET_VISCII = 102, TDS_NUM_CHARSETS = 103 }; freetds-1.00.82/src/tds/num_limits.h100644 025423 025423 00000020133 13242511127 0012735#define LIMIT_INDEXES_ADJUST 4 static const signed char limit_indexes[79]= { 0, /* 0 */ -3, /* 1 */ -6, /* 2 */ -9, /* 3 */ -12, /* 4 */ -15, /* 5 */ -18, /* 6 */ -21, /* 7 */ -24, /* 8 */ -27, /* 9 */ -30, /* 10 */ -32, /* 11 */ -34, /* 12 */ -36, /* 13 */ -38, /* 14 */ -40, /* 15 */ -42, /* 16 */ -44, /* 17 */ -46, /* 18 */ -48, /* 19 */ -50, /* 20 */ -51, /* 21 */ -52, /* 22 */ -53, /* 23 */ -54, /* 24 */ -55, /* 25 */ -56, /* 26 */ -57, /* 27 */ -58, /* 28 */ -59, /* 29 */ -59, /* 30 */ -59, /* 31 */ -59, /* 32 */ -60, /* 33 */ -61, /* 34 */ -62, /* 35 */ -63, /* 36 */ -64, /* 37 */ -65, /* 38 */ -66, /* 39 */ -66, /* 40 */ -66, /* 41 */ -66, /* 42 */ -66, /* 43 */ -66, /* 44 */ -66, /* 45 */ -66, /* 46 */ -66, /* 47 */ -66, /* 48 */ -66, /* 49 */ -65, /* 50 */ -64, /* 51 */ -63, /* 52 */ -62, /* 53 */ -61, /* 54 */ -60, /* 55 */ -59, /* 56 */ -58, /* 57 */ -57, /* 58 */ -55, /* 59 */ -53, /* 60 */ -51, /* 61 */ -49, /* 62 */ -47, /* 63 */ -45, /* 64 */ -44, /* 65 */ -43, /* 66 */ -42, /* 67 */ -41, /* 68 */ -39, /* 69 */ -37, /* 70 */ -35, /* 71 */ -33, /* 72 */ -31, /* 73 */ -29, /* 74 */ -27, /* 75 */ -25, /* 76 */ -23, /* 77 */ -21, /* 78 */ }; static const TDS_WORD limits[]= { 0x00000001u, /* 0 */ 0x0000000au, /* 1 */ 0x00000064u, /* 2 */ 0x000003e8u, /* 3 */ 0x00002710u, /* 4 */ 0x000186a0u, /* 5 */ 0x000f4240u, /* 6 */ 0x00989680u, /* 7 */ 0x05f5e100u, /* 8 */ 0x3b9aca00u, /* 9 */ 0x00000002u, /* 10 */ 0x540be400u, /* 11 */ 0x00000017u, /* 12 */ 0x4876e800u, /* 13 */ 0x000000e8u, /* 14 */ 0xd4a51000u, /* 15 */ 0x00000918u, /* 16 */ 0x4e72a000u, /* 17 */ 0x00005af3u, /* 18 */ 0x107a4000u, /* 19 */ 0x00038d7eu, /* 20 */ 0xa4c68000u, /* 21 */ 0x002386f2u, /* 22 */ 0x6fc10000u, /* 23 */ 0x01634578u, /* 24 */ 0x5d8a0000u, /* 25 */ 0x0de0b6b3u, /* 26 */ 0xa7640000u, /* 27 */ 0x8ac72304u, /* 28 */ 0x89e80000u, /* 29 */ 0x00000005u, /* 30 */ 0x6bc75e2du, /* 31 */ 0x63100000u, /* 32 */ 0x00000036u, /* 33 */ 0x35c9adc5u, /* 34 */ 0xdea00000u, /* 35 */ 0x0000021eu, /* 36 */ 0x19e0c9bau, /* 37 */ 0xb2400000u, /* 38 */ 0x0000152du, /* 39 */ 0x02c7e14au, /* 40 */ 0xf6800000u, /* 41 */ 0x0000d3c2u, /* 42 */ 0x1bceccedu, /* 43 */ 0xa1000000u, /* 44 */ 0x00084595u, /* 45 */ 0x16140148u, /* 46 */ 0x4a000000u, /* 47 */ 0x0052b7d2u, /* 48 */ 0xdcc80cd2u, /* 49 */ 0xe4000000u, /* 50 */ 0x033b2e3cu, /* 51 */ 0x9fd0803cu, /* 52 */ 0xe8000000u, /* 53 */ 0x204fce5eu, /* 54 */ 0x3e250261u, /* 55 */ 0x10000000u, /* 56 */ 0x00000001u, /* 57 */ 0x431e0faeu, /* 58 */ 0x6d7217cau, /* 59 */ 0xa0000000u, /* 60 */ 0x0000000cu, /* 61 */ 0x9f2c9cd0u, /* 62 */ 0x4674edeau, /* 63 */ 0x40000000u, /* 64 */ 0x0000007eu, /* 65 */ 0x37be2022u, /* 66 */ 0xc0914b26u, /* 67 */ 0x80000000u, /* 68 */ 0x000004eeu, /* 69 */ 0x2d6d415bu, /* 70 */ 0x85acef81u, /* 71 */ 0x0000314du, /* 72 */ 0xc6448d93u, /* 73 */ 0x38c15b0au, /* 74 */ 0x0001ed09u, /* 75 */ 0xbead87c0u, /* 76 */ 0x378d8e64u, /* 77 */ 0x00134261u, /* 78 */ 0x72c74d82u, /* 79 */ 0x2b878fe8u, /* 80 */ 0x00c097ceu, /* 81 */ 0x7bc90715u, /* 82 */ 0xb34b9f10u, /* 83 */ 0x0785ee10u, /* 84 */ 0xd5da46d9u, /* 85 */ 0x00f436a0u, /* 86 */ 0x4b3b4ca8u, /* 87 */ 0x5a86c47au, /* 88 */ 0x098a2240u, /* 89 */ 0x00000002u, /* 90 */ 0xf050fe93u, /* 91 */ 0x8943acc4u, /* 92 */ 0x5f655680u, /* 93 */ 0x0000001du, /* 94 */ 0x6329f1c3u, /* 95 */ 0x5ca4bfabu, /* 96 */ 0xb9f56100u, /* 97 */ 0x00000125u, /* 98 */ 0xdfa371a1u, /* 99 */ 0x9e6f7cb5u, /* 100 */ 0x4395ca00u, /* 101 */ 0x00000b7au, /* 102 */ 0xbc627050u, /* 103 */ 0x305adf14u, /* 104 */ 0xa3d9e400u, /* 105 */ 0x000072cbu, /* 106 */ 0x5bd86321u, /* 107 */ 0xe38cb6ceu, /* 108 */ 0x6682e800u, /* 109 */ 0x00047bf1u, /* 110 */ 0x9673df52u, /* 111 */ 0xe37f2410u, /* 112 */ 0x011d1000u, /* 113 */ 0x002cd76fu, /* 114 */ 0xe086b93cu, /* 115 */ 0xe2f768a0u, /* 116 */ 0x0b22a000u, /* 117 */ 0x01c06a5eu, /* 118 */ 0xc5433c60u, /* 119 */ 0xddaa1640u, /* 120 */ 0x6f5a4000u, /* 121 */ 0x118427b3u, /* 122 */ 0xb4a05bc8u, /* 123 */ 0xa8a4de84u, /* 124 */ 0x59868000u, /* 125 */ 0xaf298d05u, /* 126 */ 0x0e4395d6u, /* 127 */ 0x9670b12bu, /* 128 */ 0x7f410000u, /* 129 */ 0x00000006u, /* 130 */ 0xd79f8232u, /* 131 */ 0x8ea3da61u, /* 132 */ 0xe066ebb2u, /* 133 */ 0xf88a0000u, /* 134 */ 0x00000044u, /* 135 */ 0x6c3b15f9u, /* 136 */ 0x926687d2u, /* 137 */ 0xc40534fdu, /* 138 */ 0xb5640000u, /* 139 */ 0x000002acu, /* 140 */ 0x3a4edbbfu, /* 141 */ 0xb8014e3bu, /* 142 */ 0xa83411e9u, /* 143 */ 0x15e80000u, /* 144 */ 0x00001abau, /* 145 */ 0x4714957du, /* 146 */ 0x300d0e54u, /* 147 */ 0x9208b31au, /* 148 */ 0xdb100000u, /* 149 */ 0x00010b46u, /* 150 */ 0xc6cdd6e3u, /* 151 */ 0xe0828f4du, /* 152 */ 0xb456ff0cu, /* 153 */ 0x8ea00000u, /* 154 */ 0x000a70c3u, /* 155 */ 0xc40a64e6u, /* 156 */ 0xc5199909u, /* 157 */ 0x0b65f67du, /* 158 */ 0x92400000u, /* 159 */ 0x006867a5u, /* 160 */ 0xa867f103u, /* 161 */ 0xb2fffa5au, /* 162 */ 0x71fba0e7u, /* 163 */ 0xb6800000u, /* 164 */ 0x04140c78u, /* 165 */ 0x940f6a24u, /* 166 */ 0xfdffc788u, /* 167 */ 0x73d4490du, /* 168 */ 0x21000000u, /* 169 */ 0x28c87cb5u, /* 170 */ 0xc89a2571u, /* 171 */ 0xebfdcb54u, /* 172 */ 0x864ada83u, /* 173 */ 0x4a000000u, /* 174 */ 0x00000001u, /* 175 */ 0x97d4df19u, /* 176 */ 0xd6057673u, /* 177 */ 0x37e9f14du, /* 178 */ 0x3eec8920u, /* 179 */ 0xe4000000u, /* 180 */ 0x0000000fu, /* 181 */ 0xee50b702u, /* 182 */ 0x5c36a080u, /* 183 */ 0x2f236d04u, /* 184 */ 0x753d5b48u, /* 185 */ 0xe8000000u, /* 186 */ 0x0000009fu, /* 187 */ 0x4f272617u, /* 188 */ 0x9a224501u, /* 189 */ 0xd762422cu, /* 190 */ 0x946590d9u, /* 191 */ 0x10000000u, /* 192 */ 0x00000639u, /* 193 */ 0x17877cecu, /* 194 */ 0x0556b212u, /* 195 */ 0x69d695bdu, /* 196 */ 0xcbf7a87au, /* 197 */ 0xa0000000u, /* 198 */ 0x00003e3au, /* 199 */ 0xeb4ae138u, /* 200 */ 0x3562f4b8u, /* 201 */ 0x2261d969u, /* 202 */ 0xf7ac94cau, /* 203 */ 0x40000000u, /* 204 */ 0x00026e4du, /* 205 */ 0x30eccc32u, /* 206 */ 0x15dd8f31u, /* 207 */ 0x57d27e23u, /* 208 */ 0xacbdcfe6u, /* 209 */ 0x80000000u, /* 210 */ 0x00184f03u, /* 211 */ 0xe93ff9f4u, /* 212 */ 0xdaa797edu, /* 213 */ 0x6e38ed64u, /* 214 */ 0xbf6a1f01u, /* 215 */ 0x00f31627u, /* 216 */ 0x1c7fc390u, /* 217 */ 0x8a8bef46u, /* 218 */ 0x4e3945efu, /* 219 */ 0x7a25360au, /* 220 */ 0x097edd87u, /* 221 */ 0x1cfda3a5u, /* 222 */ 0x697758bfu, /* 223 */ 0x0e3cbb5au, /* 224 */ 0xc5741c64u, /* 225 */ 0x5ef4a747u, /* 226 */ 0x21e86476u, /* 227 */ 0x1ea97776u, /* 228 */ 0x8e5f518bu, /* 229 */ 0xb6891be8u, /* 230 */ 0x00000003u, /* 231 */ 0xb58e88c7u, /* 232 */ 0x5313ec9du, /* 233 */ 0x329eaaa1u, /* 234 */ 0x8fb92f75u, /* 235 */ 0x215b1710u, /* 236 */ 0x00000025u, /* 237 */ 0x179157c9u, /* 238 */ 0x3ec73e23u, /* 239 */ 0xfa32aa4fu, /* 240 */ 0x9d3bda93u, /* 241 */ 0x4d8ee6a0u, /* 242 */ 0x00000172u, /* 243 */ 0xebad6ddcu, /* 244 */ 0x73c86d67u, /* 245 */ 0xc5faa71cu, /* 246 */ 0x245689c1u, /* 247 */ 0x07950240u, /* 248 */ 0x00000e7du, /* 249 */ 0x34c64a9cu, /* 250 */ 0x85d4460du, /* 251 */ 0xbbca8719u, /* 252 */ 0x6b61618au, /* 253 */ 0x4bd21680u, /* 254 */ 0x000090e4u, /* 255 */ 0x0fbeea1du, /* 256 */ 0x3a4abc89u, /* 257 */ 0x55e946feu, /* 258 */ 0x31cdcf66u, /* 259 */ 0xf634e100u, /* 260 */ 0x0005a8e8u, /* 261 */ 0x9d752524u, /* 262 */ 0x46eb5d5du, /* 263 */ 0x5b1cc5edu, /* 264 */ 0xf20a1a05u, /* 265 */ 0x9e10ca00u, /* 266 */ 0x00389916u, /* 267 */ 0x2693736au, /* 268 */ 0xc531a5a5u, /* 269 */ 0x8f1fbb4bu, /* 270 */ 0x74650438u, /* 271 */ 0x2ca7e400u, /* 272 */ 0x0235faddu, /* 273 */ 0x81c2822bu, /* 274 */ 0xb3f07877u, /* 275 */ 0x973d50f2u, /* 276 */ 0x8bf22a31u, /* 277 */ 0xbe8ee800u, /* 278 */ 0x161bcca7u, /* 279 */ 0x119915b5u, /* 280 */ 0x0764b4abu, /* 281 */ 0xe8652979u, /* 282 */ 0x7775a5f1u, /* 283 */ 0x71951000u, /* 284 */ 0xdd15fe86u, /* 285 */ 0xaffad912u, /* 286 */ 0x49ef0eb7u, /* 287 */ 0x13f39ebeu, /* 288 */ 0xaa987b6eu, /* 289 */ 0x6fd2a000u, /* 290 */ }; freetds-1.00.82/src/tds/tds_types.h100644 025423 025423 00000112034 13242511127 0012575/* * This file produced from ./types.pl */ /** * Return the number of bytes needed by specified type. */ int tds_get_size_by_type(TDS_SERVER_TYPE servertype) { switch (servertype) { case SYBVOID: return 0; case SYBBIT: case SYBBITN: case SYBINT1: case SYBSINT1: case SYBUINT1: return 1; case SYBINT2: case SYBUINT2: return 2; case SYBMSDATE: return 3; case SYBDATE: case SYBDATEN: case SYBDATETIME4: case SYBINT4: case SYBMONEY4: case SYBREAL: case SYBTIME: case SYBTIMEN: case SYBUINT4: return 4; case SYB5BIGDATETIME: case SYB5BIGTIME: case SYB5INT8: case SYBDATETIME: case SYBFLT8: case SYBINT8: case SYBINTERVAL: case SYBMONEY: case SYBUINT8: return 8; case SYBUNIQUE: return 16; default: return 0; } } /** * tds_get_varint_size() returns the size of a variable length integer * returned in a TDS 7.0 result string */ int tds_get_varint_size(TDSCONNECTION * conn, int datatype) { switch (datatype) { case SYBBIT: case SYBDATETIME: case SYBDATETIME4: case SYBFLT8: case SYBINT1: case SYBINT2: case SYBINT4: case SYBMONEY: case SYBMONEY4: case SYBREAL: case SYBVOID: return 0; case SYBIMAGE: case SYBTEXT: return 4; } if (IS_TDS7_PLUS(conn)) { switch (datatype) { case SYBINT8: return 0; case XSYBBINARY: case XSYBCHAR: case XSYBNCHAR: case XSYBNVARCHAR: case XSYBVARBINARY: case XSYBVARCHAR: return 2; case SYBNTEXT: case SYBVARIANT: return 4; case SYBMSUDT: case SYBMSXML: return 8; } } else if (IS_TDS50(conn)) { switch (datatype) { case SYB5INT8: case SYBDATE: case SYBINTERVAL: case SYBSINT1: case SYBTIME: case SYBUINT1: case SYBUINT2: case SYBUINT4: case SYBUINT8: return 0; case SYBUNITEXT: case SYBXML: return 4; case SYBLONGBINARY: case SYBLONGCHAR: return 5; } } return 1; } /** * Return type suitable for conversions (convert all nullable types to fixed type) * @param srctype type to convert * @param colsize size of type * @result type for conversion */ TDS_SERVER_TYPE tds_get_conversion_type(TDS_SERVER_TYPE srctype, int colsize) { switch (srctype) { case SYBBITN: return SYBBIT; case SYBDATEN: return SYBDATE; case SYBDATETIMN: switch (colsize) { case 8: return SYBDATETIME; case 4: return SYBDATETIME4; } break; case SYBFLTN: switch (colsize) { case 8: return SYBFLT8; case 4: return SYBREAL; } break; case SYBINTN: switch (colsize) { case 8: return SYBINT8; case 4: return SYBINT4; case 2: return SYBINT2; case 1: return SYBINT1; } break; case SYBMONEYN: switch (colsize) { case 8: return SYBMONEY; case 4: return SYBMONEY4; } break; case SYBTIMEN: return SYBTIME; case SYBUINTN: switch (colsize) { case 8: return SYBUINT8; case 4: return SYBUINT4; case 2: return SYBUINT2; case 1: return SYBUINT1; } break; case SYB5INT8: return SYBINT8; default: break; } return srctype; } const unsigned char tds_type_flags_ms[256] = { /* 0 empty */ TDS_TYPEFLAG_INVALID, /* 1 empty */ TDS_TYPEFLAG_INVALID, /* 2 empty */ TDS_TYPEFLAG_INVALID, /* 3 empty */ TDS_TYPEFLAG_INVALID, /* 4 empty */ TDS_TYPEFLAG_INVALID, /* 5 empty */ TDS_TYPEFLAG_INVALID, /* 6 empty */ TDS_TYPEFLAG_INVALID, /* 7 empty */ TDS_TYPEFLAG_INVALID, /* 8 empty */ TDS_TYPEFLAG_INVALID, /* 9 empty */ TDS_TYPEFLAG_INVALID, /* 10 empty */ TDS_TYPEFLAG_INVALID, /* 11 empty */ TDS_TYPEFLAG_INVALID, /* 12 empty */ TDS_TYPEFLAG_INVALID, /* 13 empty */ TDS_TYPEFLAG_INVALID, /* 14 empty */ TDS_TYPEFLAG_INVALID, /* 15 empty */ TDS_TYPEFLAG_INVALID, /* 16 empty */ TDS_TYPEFLAG_INVALID, /* 17 empty */ TDS_TYPEFLAG_INVALID, /* 18 empty */ TDS_TYPEFLAG_INVALID, /* 19 empty */ TDS_TYPEFLAG_INVALID, /* 20 empty */ TDS_TYPEFLAG_INVALID, /* 21 empty */ TDS_TYPEFLAG_INVALID, /* 22 empty */ TDS_TYPEFLAG_INVALID, /* 23 empty */ TDS_TYPEFLAG_INVALID, /* 24 empty */ TDS_TYPEFLAG_INVALID, /* 25 empty */ TDS_TYPEFLAG_INVALID, /* 26 empty */ TDS_TYPEFLAG_INVALID, /* 27 empty */ TDS_TYPEFLAG_INVALID, /* 28 empty */ TDS_TYPEFLAG_INVALID, /* 29 empty */ TDS_TYPEFLAG_INVALID, /* 30 empty */ TDS_TYPEFLAG_INVALID, /* 31 SYBVOID */ TDS_TYPEFLAG_FIXED, /* 32 empty */ TDS_TYPEFLAG_INVALID, /* 33 empty */ TDS_TYPEFLAG_INVALID, /* 34 SYBIMAGE */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE, /* 35 SYBTEXT */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_COLLATE|TDS_TYPEFLAG_ASCII, /* 36 SYBUNIQUE */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_FIXED, /* 37 SYBVARBINARY */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE, /* 38 SYBINTN */ TDS_TYPEFLAG_NULLABLE, /* 39 SYBVARCHAR */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_ASCII, /* 40 SYBMSDATE */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_FIXED|TDS_TYPEFLAG_DATETIME, /* 41 SYBMSTIME */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_DATETIME, /* 42 SYBMSDATETIME2 */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_DATETIME, /* 43 SYBMSDATETIMEOFFSET */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_DATETIME, /* 44 empty */ TDS_TYPEFLAG_INVALID, /* 45 SYBBINARY */ TDS_TYPEFLAG_VARIABLE, /* 46 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_FIXED, /* 47 SYBCHAR */ TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_ASCII, /* 48 SYBINT1 */ TDS_TYPEFLAG_FIXED, /* 49 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_FIXED|TDS_TYPEFLAG_DATETIME, /* 50 SYBBIT */ TDS_TYPEFLAG_FIXED, /* 51 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_FIXED|TDS_TYPEFLAG_DATETIME, /* 52 SYBINT2 */ TDS_TYPEFLAG_FIXED, /* 53 empty */ TDS_TYPEFLAG_INVALID, /* 54 empty */ TDS_TYPEFLAG_INVALID, /* 55 empty */ TDS_TYPEFLAG_INVALID, /* 56 SYBINT4 */ TDS_TYPEFLAG_FIXED, /* 57 empty */ TDS_TYPEFLAG_INVALID, /* 58 SYBDATETIME4 */ TDS_TYPEFLAG_FIXED|TDS_TYPEFLAG_DATETIME, /* 59 SYBREAL */ TDS_TYPEFLAG_FIXED, /* 60 SYBMONEY */ TDS_TYPEFLAG_FIXED, /* 61 SYBDATETIME */ TDS_TYPEFLAG_FIXED|TDS_TYPEFLAG_DATETIME, /* 62 SYBFLT8 */ TDS_TYPEFLAG_FIXED, /* 63 empty */ TDS_TYPEFLAG_INVALID, /* 64 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_FIXED, /* 65 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_FIXED, /* 66 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_FIXED, /* 67 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_FIXED, /* 68 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE, /* 69 empty */ TDS_TYPEFLAG_INVALID, /* 70 empty */ TDS_TYPEFLAG_INVALID, /* 71 empty */ TDS_TYPEFLAG_INVALID, /* 72 empty */ TDS_TYPEFLAG_INVALID, /* 73 empty */ TDS_TYPEFLAG_INVALID, /* 74 empty */ TDS_TYPEFLAG_INVALID, /* 75 empty */ TDS_TYPEFLAG_INVALID, /* 76 empty */ TDS_TYPEFLAG_INVALID, /* 77 empty */ TDS_TYPEFLAG_INVALID, /* 78 empty */ TDS_TYPEFLAG_INVALID, /* 79 empty */ TDS_TYPEFLAG_INVALID, /* 80 empty */ TDS_TYPEFLAG_INVALID, /* 81 empty */ TDS_TYPEFLAG_INVALID, /* 82 empty */ TDS_TYPEFLAG_INVALID, /* 83 empty */ TDS_TYPEFLAG_INVALID, /* 84 empty */ TDS_TYPEFLAG_INVALID, /* 85 empty */ TDS_TYPEFLAG_INVALID, /* 86 empty */ TDS_TYPEFLAG_INVALID, /* 87 empty */ TDS_TYPEFLAG_INVALID, /* 88 empty */ TDS_TYPEFLAG_INVALID, /* 89 empty */ TDS_TYPEFLAG_INVALID, /* 90 empty */ TDS_TYPEFLAG_INVALID, /* 91 empty */ TDS_TYPEFLAG_INVALID, /* 92 empty */ TDS_TYPEFLAG_INVALID, /* 93 empty */ TDS_TYPEFLAG_INVALID, /* 94 empty */ TDS_TYPEFLAG_INVALID, /* 95 empty */ TDS_TYPEFLAG_INVALID, /* 96 empty */ TDS_TYPEFLAG_INVALID, /* 97 empty */ TDS_TYPEFLAG_INVALID, /* 98 SYBVARIANT */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE, /* 99 SYBNTEXT */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_COLLATE|TDS_TYPEFLAG_UNICODE, /* 100 empty */ TDS_TYPEFLAG_INVALID, /* 101 empty */ TDS_TYPEFLAG_INVALID, /* 102 empty */ TDS_TYPEFLAG_INVALID, /* 103 SYBNVARCHAR */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_UNICODE, /* 104 SYBBITN */ TDS_TYPEFLAG_NULLABLE, /* 105 empty */ TDS_TYPEFLAG_INVALID, /* 106 SYBDECIMAL */ TDS_TYPEFLAG_NUMERIC, /* 107 empty */ TDS_TYPEFLAG_INVALID, /* 108 SYBNUMERIC */ TDS_TYPEFLAG_NUMERIC, /* 109 SYBFLTN */ TDS_TYPEFLAG_NULLABLE, /* 110 SYBMONEYN */ TDS_TYPEFLAG_NULLABLE, /* 111 SYBDATETIMN */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_DATETIME, /* 112 empty */ TDS_TYPEFLAG_INVALID, /* 113 empty */ TDS_TYPEFLAG_INVALID, /* 114 empty */ TDS_TYPEFLAG_INVALID, /* 115 empty */ TDS_TYPEFLAG_INVALID, /* 116 empty */ TDS_TYPEFLAG_INVALID, /* 117 empty */ TDS_TYPEFLAG_INVALID, /* 118 empty */ TDS_TYPEFLAG_INVALID, /* 119 empty */ TDS_TYPEFLAG_INVALID, /* 120 empty */ TDS_TYPEFLAG_INVALID, /* 121 empty */ TDS_TYPEFLAG_INVALID, /* 122 SYBMONEY4 */ TDS_TYPEFLAG_FIXED, /* 123 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_DATETIME, /* 124 empty */ TDS_TYPEFLAG_INVALID, /* 125 empty */ TDS_TYPEFLAG_INVALID, /* 126 empty */ TDS_TYPEFLAG_INVALID, /* 127 SYBINT8 */ TDS_TYPEFLAG_FIXED, /* 128 empty */ TDS_TYPEFLAG_INVALID, /* 129 empty */ TDS_TYPEFLAG_INVALID, /* 130 empty */ TDS_TYPEFLAG_INVALID, /* 131 empty */ TDS_TYPEFLAG_INVALID, /* 132 empty */ TDS_TYPEFLAG_INVALID, /* 133 empty */ TDS_TYPEFLAG_INVALID, /* 134 empty */ TDS_TYPEFLAG_INVALID, /* 135 empty */ TDS_TYPEFLAG_INVALID, /* 136 empty */ TDS_TYPEFLAG_INVALID, /* 137 empty */ TDS_TYPEFLAG_INVALID, /* 138 empty */ TDS_TYPEFLAG_INVALID, /* 139 empty */ TDS_TYPEFLAG_INVALID, /* 140 empty */ TDS_TYPEFLAG_INVALID, /* 141 empty */ TDS_TYPEFLAG_INVALID, /* 142 empty */ TDS_TYPEFLAG_INVALID, /* 143 empty */ TDS_TYPEFLAG_INVALID, /* 144 empty */ TDS_TYPEFLAG_INVALID, /* 145 empty */ TDS_TYPEFLAG_INVALID, /* 146 empty */ TDS_TYPEFLAG_INVALID, /* 147 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_DATETIME, /* 148 empty */ TDS_TYPEFLAG_INVALID, /* 149 empty */ TDS_TYPEFLAG_INVALID, /* 150 empty */ TDS_TYPEFLAG_INVALID, /* 151 empty */ TDS_TYPEFLAG_INVALID, /* 152 empty */ TDS_TYPEFLAG_INVALID, /* 153 empty */ TDS_TYPEFLAG_INVALID, /* 154 empty */ TDS_TYPEFLAG_INVALID, /* 155 empty */ TDS_TYPEFLAG_INVALID, /* 156 empty */ TDS_TYPEFLAG_INVALID, /* 157 empty */ TDS_TYPEFLAG_INVALID, /* 158 empty */ TDS_TYPEFLAG_INVALID, /* 159 empty */ TDS_TYPEFLAG_INVALID, /* 160 empty */ TDS_TYPEFLAG_INVALID, /* 161 empty */ TDS_TYPEFLAG_INVALID, /* 162 empty */ TDS_TYPEFLAG_INVALID, /* 163 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE, /* 164 empty */ TDS_TYPEFLAG_INVALID, /* 165 XSYBVARBINARY */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE, /* 166 empty */ TDS_TYPEFLAG_INVALID, /* 167 XSYBVARCHAR */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_COLLATE|TDS_TYPEFLAG_ASCII, /* 168 empty */ TDS_TYPEFLAG_INVALID, /* 169 empty */ TDS_TYPEFLAG_INVALID, /* 170 empty */ TDS_TYPEFLAG_INVALID, /* 171 empty */ TDS_TYPEFLAG_INVALID, /* 172 empty */ TDS_TYPEFLAG_INVALID, /* 173 XSYBBINARY */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE, /* 174 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_UNICODE, /* 175 XSYBCHAR */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_COLLATE|TDS_TYPEFLAG_ASCII, /* 176 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_FIXED, /* 177 empty */ TDS_TYPEFLAG_INVALID, /* 178 empty */ TDS_TYPEFLAG_INVALID, /* 179 empty */ TDS_TYPEFLAG_INVALID, /* 180 empty */ TDS_TYPEFLAG_INVALID, /* 181 empty */ TDS_TYPEFLAG_INVALID, /* 182 empty */ TDS_TYPEFLAG_INVALID, /* 183 empty */ TDS_TYPEFLAG_INVALID, /* 184 empty */ TDS_TYPEFLAG_INVALID, /* 185 empty */ TDS_TYPEFLAG_INVALID, /* 186 empty */ TDS_TYPEFLAG_INVALID, /* 187 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_DATETIME, /* 188 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_DATETIME, /* 189 empty */ TDS_TYPEFLAG_INVALID, /* 190 empty */ TDS_TYPEFLAG_INVALID, /* 191 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_FIXED, /* 192 empty */ TDS_TYPEFLAG_INVALID, /* 193 empty */ TDS_TYPEFLAG_INVALID, /* 194 empty */ TDS_TYPEFLAG_INVALID, /* 195 empty */ TDS_TYPEFLAG_INVALID, /* 196 empty */ TDS_TYPEFLAG_INVALID, /* 197 empty */ TDS_TYPEFLAG_INVALID, /* 198 empty */ TDS_TYPEFLAG_INVALID, /* 199 empty */ TDS_TYPEFLAG_INVALID, /* 200 empty */ TDS_TYPEFLAG_INVALID, /* 201 empty */ TDS_TYPEFLAG_INVALID, /* 202 empty */ TDS_TYPEFLAG_INVALID, /* 203 empty */ TDS_TYPEFLAG_INVALID, /* 204 empty */ TDS_TYPEFLAG_INVALID, /* 205 empty */ TDS_TYPEFLAG_INVALID, /* 206 empty */ TDS_TYPEFLAG_INVALID, /* 207 empty */ TDS_TYPEFLAG_INVALID, /* 208 empty */ TDS_TYPEFLAG_INVALID, /* 209 empty */ TDS_TYPEFLAG_INVALID, /* 210 empty */ TDS_TYPEFLAG_INVALID, /* 211 empty */ TDS_TYPEFLAG_INVALID, /* 212 empty */ TDS_TYPEFLAG_INVALID, /* 213 empty */ TDS_TYPEFLAG_INVALID, /* 214 empty */ TDS_TYPEFLAG_INVALID, /* 215 empty */ TDS_TYPEFLAG_INVALID, /* 216 empty */ TDS_TYPEFLAG_INVALID, /* 217 empty */ TDS_TYPEFLAG_INVALID, /* 218 empty */ TDS_TYPEFLAG_INVALID, /* 219 empty */ TDS_TYPEFLAG_INVALID, /* 220 empty */ TDS_TYPEFLAG_INVALID, /* 221 empty */ TDS_TYPEFLAG_INVALID, /* 222 empty */ TDS_TYPEFLAG_INVALID, /* 223 empty */ TDS_TYPEFLAG_INVALID, /* 224 empty */ TDS_TYPEFLAG_INVALID, /* 225 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE, /* 226 empty */ TDS_TYPEFLAG_INVALID, /* 227 empty */ TDS_TYPEFLAG_INVALID, /* 228 empty */ TDS_TYPEFLAG_INVALID, /* 229 empty */ TDS_TYPEFLAG_INVALID, /* 230 empty */ TDS_TYPEFLAG_INVALID, /* 231 XSYBNVARCHAR */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_COLLATE|TDS_TYPEFLAG_UNICODE, /* 232 empty */ TDS_TYPEFLAG_INVALID, /* 233 empty */ TDS_TYPEFLAG_INVALID, /* 234 empty */ TDS_TYPEFLAG_INVALID, /* 235 empty */ TDS_TYPEFLAG_INVALID, /* 236 empty */ TDS_TYPEFLAG_INVALID, /* 237 empty */ TDS_TYPEFLAG_INVALID, /* 238 empty */ TDS_TYPEFLAG_INVALID, /* 239 XSYBNCHAR */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_COLLATE|TDS_TYPEFLAG_UNICODE, /* 240 SYBMSUDT */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE, /* 241 SYBMSXML */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_UNICODE, /* 242 empty */ TDS_TYPEFLAG_INVALID, /* 243 empty */ TDS_TYPEFLAG_INVALID, /* 244 empty */ TDS_TYPEFLAG_INVALID, /* 245 empty */ TDS_TYPEFLAG_INVALID, /* 246 empty */ TDS_TYPEFLAG_INVALID, /* 247 empty */ TDS_TYPEFLAG_INVALID, /* 248 empty */ TDS_TYPEFLAG_INVALID, /* 249 empty */ TDS_TYPEFLAG_INVALID, /* 250 empty */ TDS_TYPEFLAG_INVALID, /* 251 empty */ TDS_TYPEFLAG_INVALID, /* 252 empty */ TDS_TYPEFLAG_INVALID, /* 253 empty */ TDS_TYPEFLAG_INVALID, /* 254 empty */ TDS_TYPEFLAG_INVALID, /* 255 empty */ TDS_TYPEFLAG_INVALID, }; #if 0 const unsigned char tds_type_flags_syb[256] = { /* 0 empty */ TDS_TYPEFLAG_INVALID, /* 1 empty */ TDS_TYPEFLAG_INVALID, /* 2 empty */ TDS_TYPEFLAG_INVALID, /* 3 empty */ TDS_TYPEFLAG_INVALID, /* 4 empty */ TDS_TYPEFLAG_INVALID, /* 5 empty */ TDS_TYPEFLAG_INVALID, /* 6 empty */ TDS_TYPEFLAG_INVALID, /* 7 empty */ TDS_TYPEFLAG_INVALID, /* 8 empty */ TDS_TYPEFLAG_INVALID, /* 9 empty */ TDS_TYPEFLAG_INVALID, /* 10 empty */ TDS_TYPEFLAG_INVALID, /* 11 empty */ TDS_TYPEFLAG_INVALID, /* 12 empty */ TDS_TYPEFLAG_INVALID, /* 13 empty */ TDS_TYPEFLAG_INVALID, /* 14 empty */ TDS_TYPEFLAG_INVALID, /* 15 empty */ TDS_TYPEFLAG_INVALID, /* 16 empty */ TDS_TYPEFLAG_INVALID, /* 17 empty */ TDS_TYPEFLAG_INVALID, /* 18 empty */ TDS_TYPEFLAG_INVALID, /* 19 empty */ TDS_TYPEFLAG_INVALID, /* 20 empty */ TDS_TYPEFLAG_INVALID, /* 21 empty */ TDS_TYPEFLAG_INVALID, /* 22 empty */ TDS_TYPEFLAG_INVALID, /* 23 empty */ TDS_TYPEFLAG_INVALID, /* 24 empty */ TDS_TYPEFLAG_INVALID, /* 25 empty */ TDS_TYPEFLAG_INVALID, /* 26 empty */ TDS_TYPEFLAG_INVALID, /* 27 empty */ TDS_TYPEFLAG_INVALID, /* 28 empty */ TDS_TYPEFLAG_INVALID, /* 29 empty */ TDS_TYPEFLAG_INVALID, /* 30 empty */ TDS_TYPEFLAG_INVALID, /* 31 SYBVOID */ TDS_TYPEFLAG_FIXED, /* 32 empty */ TDS_TYPEFLAG_INVALID, /* 33 empty */ TDS_TYPEFLAG_INVALID, /* 34 SYBIMAGE */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE, /* 35 SYBTEXT */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_COLLATE|TDS_TYPEFLAG_ASCII, /* 36 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_FIXED|TDS_TYPEFLAG_NULLABLE, /* 37 SYBVARBINARY */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE, /* 38 SYBINTN */ TDS_TYPEFLAG_NULLABLE, /* 39 SYBVARCHAR */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_ASCII, /* 40 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_FIXED|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_DATETIME, /* 41 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_DATETIME, /* 42 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_DATETIME, /* 43 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_DATETIME, /* 44 empty */ TDS_TYPEFLAG_INVALID, /* 45 SYBBINARY */ TDS_TYPEFLAG_VARIABLE, /* 46 SYBINTERVAL */ TDS_TYPEFLAG_FIXED, /* 47 SYBCHAR */ TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_ASCII, /* 48 SYBINT1 */ TDS_TYPEFLAG_FIXED, /* 49 SYBDATE */ TDS_TYPEFLAG_FIXED|TDS_TYPEFLAG_DATETIME, /* 50 SYBBIT */ TDS_TYPEFLAG_FIXED, /* 51 SYBTIME */ TDS_TYPEFLAG_FIXED|TDS_TYPEFLAG_DATETIME, /* 52 SYBINT2 */ TDS_TYPEFLAG_FIXED, /* 53 empty */ TDS_TYPEFLAG_INVALID, /* 54 empty */ TDS_TYPEFLAG_INVALID, /* 55 empty */ TDS_TYPEFLAG_INVALID, /* 56 SYBINT4 */ TDS_TYPEFLAG_FIXED, /* 57 empty */ TDS_TYPEFLAG_INVALID, /* 58 SYBDATETIME4 */ TDS_TYPEFLAG_FIXED|TDS_TYPEFLAG_DATETIME, /* 59 SYBREAL */ TDS_TYPEFLAG_FIXED, /* 60 SYBMONEY */ TDS_TYPEFLAG_FIXED, /* 61 SYBDATETIME */ TDS_TYPEFLAG_FIXED|TDS_TYPEFLAG_DATETIME, /* 62 SYBFLT8 */ TDS_TYPEFLAG_FIXED, /* 63 empty */ TDS_TYPEFLAG_INVALID, /* 64 SYBUINT1 */ TDS_TYPEFLAG_FIXED, /* 65 SYBUINT2 */ TDS_TYPEFLAG_FIXED, /* 66 SYBUINT4 */ TDS_TYPEFLAG_FIXED, /* 67 SYBUINT8 */ TDS_TYPEFLAG_FIXED, /* 68 SYBUINTN */ TDS_TYPEFLAG_NULLABLE, /* 69 empty */ TDS_TYPEFLAG_INVALID, /* 70 empty */ TDS_TYPEFLAG_INVALID, /* 71 empty */ TDS_TYPEFLAG_INVALID, /* 72 empty */ TDS_TYPEFLAG_INVALID, /* 73 empty */ TDS_TYPEFLAG_INVALID, /* 74 empty */ TDS_TYPEFLAG_INVALID, /* 75 empty */ TDS_TYPEFLAG_INVALID, /* 76 empty */ TDS_TYPEFLAG_INVALID, /* 77 empty */ TDS_TYPEFLAG_INVALID, /* 78 empty */ TDS_TYPEFLAG_INVALID, /* 79 empty */ TDS_TYPEFLAG_INVALID, /* 80 empty */ TDS_TYPEFLAG_INVALID, /* 81 empty */ TDS_TYPEFLAG_INVALID, /* 82 empty */ TDS_TYPEFLAG_INVALID, /* 83 empty */ TDS_TYPEFLAG_INVALID, /* 84 empty */ TDS_TYPEFLAG_INVALID, /* 85 empty */ TDS_TYPEFLAG_INVALID, /* 86 empty */ TDS_TYPEFLAG_INVALID, /* 87 empty */ TDS_TYPEFLAG_INVALID, /* 88 empty */ TDS_TYPEFLAG_INVALID, /* 89 empty */ TDS_TYPEFLAG_INVALID, /* 90 empty */ TDS_TYPEFLAG_INVALID, /* 91 empty */ TDS_TYPEFLAG_INVALID, /* 92 empty */ TDS_TYPEFLAG_INVALID, /* 93 empty */ TDS_TYPEFLAG_INVALID, /* 94 empty */ TDS_TYPEFLAG_INVALID, /* 95 empty */ TDS_TYPEFLAG_INVALID, /* 96 empty */ TDS_TYPEFLAG_INVALID, /* 97 empty */ TDS_TYPEFLAG_INVALID, /* 98 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE, /* 99 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_UNICODE, /* 100 empty */ TDS_TYPEFLAG_INVALID, /* 101 empty */ TDS_TYPEFLAG_INVALID, /* 102 empty */ TDS_TYPEFLAG_INVALID, /* 103 SYBSENSITIVITY */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_ASCII, /* 104 SYBBOUNDARY */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_ASCII, /* 105 empty */ TDS_TYPEFLAG_INVALID, /* 106 SYBDECIMAL */ TDS_TYPEFLAG_NUMERIC, /* 107 empty */ TDS_TYPEFLAG_INVALID, /* 108 SYBNUMERIC */ TDS_TYPEFLAG_NUMERIC, /* 109 SYBFLTN */ TDS_TYPEFLAG_NULLABLE, /* 110 SYBMONEYN */ TDS_TYPEFLAG_NULLABLE, /* 111 SYBDATETIMN */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_DATETIME, /* 112 empty */ TDS_TYPEFLAG_INVALID, /* 113 empty */ TDS_TYPEFLAG_INVALID, /* 114 empty */ TDS_TYPEFLAG_INVALID, /* 115 empty */ TDS_TYPEFLAG_INVALID, /* 116 empty */ TDS_TYPEFLAG_INVALID, /* 117 empty */ TDS_TYPEFLAG_INVALID, /* 118 empty */ TDS_TYPEFLAG_INVALID, /* 119 empty */ TDS_TYPEFLAG_INVALID, /* 120 empty */ TDS_TYPEFLAG_INVALID, /* 121 empty */ TDS_TYPEFLAG_INVALID, /* 122 SYBMONEY4 */ TDS_TYPEFLAG_FIXED, /* 123 SYBDATEN */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_DATETIME, /* 124 empty */ TDS_TYPEFLAG_INVALID, /* 125 empty */ TDS_TYPEFLAG_INVALID, /* 126 empty */ TDS_TYPEFLAG_INVALID, /* 127 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_FIXED, /* 128 empty */ TDS_TYPEFLAG_INVALID, /* 129 empty */ TDS_TYPEFLAG_INVALID, /* 130 empty */ TDS_TYPEFLAG_INVALID, /* 131 empty */ TDS_TYPEFLAG_INVALID, /* 132 empty */ TDS_TYPEFLAG_INVALID, /* 133 empty */ TDS_TYPEFLAG_INVALID, /* 134 empty */ TDS_TYPEFLAG_INVALID, /* 135 empty */ TDS_TYPEFLAG_INVALID, /* 136 empty */ TDS_TYPEFLAG_INVALID, /* 137 empty */ TDS_TYPEFLAG_INVALID, /* 138 empty */ TDS_TYPEFLAG_INVALID, /* 139 empty */ TDS_TYPEFLAG_INVALID, /* 140 empty */ TDS_TYPEFLAG_INVALID, /* 141 empty */ TDS_TYPEFLAG_INVALID, /* 142 empty */ TDS_TYPEFLAG_INVALID, /* 143 empty */ TDS_TYPEFLAG_INVALID, /* 144 empty */ TDS_TYPEFLAG_INVALID, /* 145 empty */ TDS_TYPEFLAG_INVALID, /* 146 empty */ TDS_TYPEFLAG_INVALID, /* 147 SYBTIMEN */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_DATETIME, /* 148 empty */ TDS_TYPEFLAG_INVALID, /* 149 empty */ TDS_TYPEFLAG_INVALID, /* 150 empty */ TDS_TYPEFLAG_INVALID, /* 151 empty */ TDS_TYPEFLAG_INVALID, /* 152 empty */ TDS_TYPEFLAG_INVALID, /* 153 empty */ TDS_TYPEFLAG_INVALID, /* 154 empty */ TDS_TYPEFLAG_INVALID, /* 155 empty */ TDS_TYPEFLAG_INVALID, /* 156 empty */ TDS_TYPEFLAG_INVALID, /* 157 empty */ TDS_TYPEFLAG_INVALID, /* 158 empty */ TDS_TYPEFLAG_INVALID, /* 159 empty */ TDS_TYPEFLAG_INVALID, /* 160 empty */ TDS_TYPEFLAG_INVALID, /* 161 empty */ TDS_TYPEFLAG_INVALID, /* 162 empty */ TDS_TYPEFLAG_INVALID, /* 163 SYBXML */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE, /* 164 empty */ TDS_TYPEFLAG_INVALID, /* 165 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE, /* 166 empty */ TDS_TYPEFLAG_INVALID, /* 167 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE, /* 168 empty */ TDS_TYPEFLAG_INVALID, /* 169 empty */ TDS_TYPEFLAG_INVALID, /* 170 empty */ TDS_TYPEFLAG_INVALID, /* 171 empty */ TDS_TYPEFLAG_INVALID, /* 172 empty */ TDS_TYPEFLAG_INVALID, /* 173 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE, /* 174 SYBUNITEXT */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_UNICODE, /* 175 SYBLONGCHAR */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_ASCII, /* 176 SYBSINT1 */ TDS_TYPEFLAG_FIXED, /* 177 empty */ TDS_TYPEFLAG_INVALID, /* 178 empty */ TDS_TYPEFLAG_INVALID, /* 179 empty */ TDS_TYPEFLAG_INVALID, /* 180 empty */ TDS_TYPEFLAG_INVALID, /* 181 empty */ TDS_TYPEFLAG_INVALID, /* 182 empty */ TDS_TYPEFLAG_INVALID, /* 183 empty */ TDS_TYPEFLAG_INVALID, /* 184 empty */ TDS_TYPEFLAG_INVALID, /* 185 empty */ TDS_TYPEFLAG_INVALID, /* 186 empty */ TDS_TYPEFLAG_INVALID, /* 187 SYB5BIGDATETIME */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_DATETIME, /* 188 SYB5BIGTIME */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_DATETIME, /* 189 empty */ TDS_TYPEFLAG_INVALID, /* 190 empty */ TDS_TYPEFLAG_INVALID, /* 191 SYB5INT8 */ TDS_TYPEFLAG_FIXED, /* 192 empty */ TDS_TYPEFLAG_INVALID, /* 193 empty */ TDS_TYPEFLAG_INVALID, /* 194 empty */ TDS_TYPEFLAG_INVALID, /* 195 empty */ TDS_TYPEFLAG_INVALID, /* 196 empty */ TDS_TYPEFLAG_INVALID, /* 197 empty */ TDS_TYPEFLAG_INVALID, /* 198 empty */ TDS_TYPEFLAG_INVALID, /* 199 empty */ TDS_TYPEFLAG_INVALID, /* 200 empty */ TDS_TYPEFLAG_INVALID, /* 201 empty */ TDS_TYPEFLAG_INVALID, /* 202 empty */ TDS_TYPEFLAG_INVALID, /* 203 empty */ TDS_TYPEFLAG_INVALID, /* 204 empty */ TDS_TYPEFLAG_INVALID, /* 205 empty */ TDS_TYPEFLAG_INVALID, /* 206 empty */ TDS_TYPEFLAG_INVALID, /* 207 empty */ TDS_TYPEFLAG_INVALID, /* 208 empty */ TDS_TYPEFLAG_INVALID, /* 209 empty */ TDS_TYPEFLAG_INVALID, /* 210 empty */ TDS_TYPEFLAG_INVALID, /* 211 empty */ TDS_TYPEFLAG_INVALID, /* 212 empty */ TDS_TYPEFLAG_INVALID, /* 213 empty */ TDS_TYPEFLAG_INVALID, /* 214 empty */ TDS_TYPEFLAG_INVALID, /* 215 empty */ TDS_TYPEFLAG_INVALID, /* 216 empty */ TDS_TYPEFLAG_INVALID, /* 217 empty */ TDS_TYPEFLAG_INVALID, /* 218 empty */ TDS_TYPEFLAG_INVALID, /* 219 empty */ TDS_TYPEFLAG_INVALID, /* 220 empty */ TDS_TYPEFLAG_INVALID, /* 221 empty */ TDS_TYPEFLAG_INVALID, /* 222 empty */ TDS_TYPEFLAG_INVALID, /* 223 empty */ TDS_TYPEFLAG_INVALID, /* 224 empty */ TDS_TYPEFLAG_INVALID, /* 225 SYBLONGBINARY */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE, /* 226 empty */ TDS_TYPEFLAG_INVALID, /* 227 empty */ TDS_TYPEFLAG_INVALID, /* 228 empty */ TDS_TYPEFLAG_INVALID, /* 229 empty */ TDS_TYPEFLAG_INVALID, /* 230 empty */ TDS_TYPEFLAG_INVALID, /* 231 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_UNICODE, /* 232 empty */ TDS_TYPEFLAG_INVALID, /* 233 empty */ TDS_TYPEFLAG_INVALID, /* 234 empty */ TDS_TYPEFLAG_INVALID, /* 235 empty */ TDS_TYPEFLAG_INVALID, /* 236 empty */ TDS_TYPEFLAG_INVALID, /* 237 empty */ TDS_TYPEFLAG_INVALID, /* 238 empty */ TDS_TYPEFLAG_INVALID, /* 239 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_UNICODE, /* 240 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE, /* 241 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_UNICODE, /* 242 empty */ TDS_TYPEFLAG_INVALID, /* 243 empty */ TDS_TYPEFLAG_INVALID, /* 244 empty */ TDS_TYPEFLAG_INVALID, /* 245 empty */ TDS_TYPEFLAG_INVALID, /* 246 empty */ TDS_TYPEFLAG_INVALID, /* 247 empty */ TDS_TYPEFLAG_INVALID, /* 248 empty */ TDS_TYPEFLAG_INVALID, /* 249 empty */ TDS_TYPEFLAG_INVALID, /* 250 empty */ TDS_TYPEFLAG_INVALID, /* 251 empty */ TDS_TYPEFLAG_INVALID, /* 252 empty */ TDS_TYPEFLAG_INVALID, /* 253 empty */ TDS_TYPEFLAG_INVALID, /* 254 empty */ TDS_TYPEFLAG_INVALID, /* 255 empty */ TDS_TYPEFLAG_INVALID, }; const char *const tds_type_names[256] = { /* 0 */ "", /* 1 */ "", /* 2 */ "", /* 3 */ "", /* 4 */ "", /* 5 */ "", /* 6 */ "", /* 7 */ "", /* 8 */ "", /* 9 */ "", /* 10 */ "", /* 11 */ "", /* 12 */ "", /* 13 */ "", /* 14 */ "", /* 15 */ "", /* 16 */ "", /* 17 */ "", /* 18 */ "", /* 19 */ "", /* 20 */ "", /* 21 */ "", /* 22 */ "", /* 23 */ "", /* 24 */ "", /* 25 */ "", /* 26 */ "", /* 27 */ "", /* 28 */ "", /* 29 */ "", /* 30 */ "", /* 31 */ "SYBVOID", /* 32 */ "", /* 33 */ "", /* 34 */ "SYBIMAGE", /* 35 */ "SYBTEXT", /* 36 */ "SYBUNIQUE", /* 37 */ "SYBVARBINARY", /* 38 */ "SYBINTN", /* 39 */ "SYBVARCHAR", /* 40 */ "SYBMSDATE", /* 41 */ "SYBMSTIME", /* 42 */ "SYBMSDATETIME2", /* 43 */ "SYBMSDATETIMEOFFSET", /* 44 */ "", /* 45 */ "SYBBINARY", /* 46 */ "SYBINTERVAL", /* 47 */ "SYBCHAR", /* 48 */ "SYBINT1", /* 49 */ "SYBDATE", /* 50 */ "SYBBIT", /* 51 */ "SYBTIME", /* 52 */ "SYBINT2", /* 53 */ "", /* 54 */ "", /* 55 */ "", /* 56 */ "SYBINT4", /* 57 */ "", /* 58 */ "SYBDATETIME4", /* 59 */ "SYBREAL", /* 60 */ "SYBMONEY", /* 61 */ "SYBDATETIME", /* 62 */ "SYBFLT8", /* 63 */ "", /* 64 */ "SYBUINT1", /* 65 */ "SYBUINT2", /* 66 */ "SYBUINT4", /* 67 */ "SYBUINT8", /* 68 */ "SYBUINTN", /* 69 */ "", /* 70 */ "", /* 71 */ "", /* 72 */ "", /* 73 */ "", /* 74 */ "", /* 75 */ "", /* 76 */ "", /* 77 */ "", /* 78 */ "", /* 79 */ "", /* 80 */ "", /* 81 */ "", /* 82 */ "", /* 83 */ "", /* 84 */ "", /* 85 */ "", /* 86 */ "", /* 87 */ "", /* 88 */ "", /* 89 */ "", /* 90 */ "", /* 91 */ "", /* 92 */ "", /* 93 */ "", /* 94 */ "", /* 95 */ "", /* 96 */ "", /* 97 */ "", /* 98 */ "SYBVARIANT", /* 99 */ "SYBNTEXT", /* 100 */ "", /* 101 */ "", /* 102 */ "", /* 103 */ "SYBNVARCHAR or SYBSENSITIVITY", /* 104 */ "SYBBITN or SYBBOUNDARY", /* 105 */ "", /* 106 */ "SYBDECIMAL", /* 107 */ "", /* 108 */ "SYBNUMERIC", /* 109 */ "SYBFLTN", /* 110 */ "SYBMONEYN", /* 111 */ "SYBDATETIMN", /* 112 */ "", /* 113 */ "", /* 114 */ "", /* 115 */ "", /* 116 */ "", /* 117 */ "", /* 118 */ "", /* 119 */ "", /* 120 */ "", /* 121 */ "", /* 122 */ "SYBMONEY4", /* 123 */ "SYBDATEN", /* 124 */ "", /* 125 */ "", /* 126 */ "", /* 127 */ "SYBINT8", /* 128 */ "", /* 129 */ "", /* 130 */ "", /* 131 */ "", /* 132 */ "", /* 133 */ "", /* 134 */ "", /* 135 */ "", /* 136 */ "", /* 137 */ "", /* 138 */ "", /* 139 */ "", /* 140 */ "", /* 141 */ "", /* 142 */ "", /* 143 */ "", /* 144 */ "", /* 145 */ "", /* 146 */ "", /* 147 */ "SYBTIMEN", /* 148 */ "", /* 149 */ "", /* 150 */ "", /* 151 */ "", /* 152 */ "", /* 153 */ "", /* 154 */ "", /* 155 */ "", /* 156 */ "", /* 157 */ "", /* 158 */ "", /* 159 */ "", /* 160 */ "", /* 161 */ "", /* 162 */ "", /* 163 */ "SYBXML", /* 164 */ "", /* 165 */ "XSYBVARBINARY", /* 166 */ "", /* 167 */ "XSYBVARCHAR", /* 168 */ "", /* 169 */ "", /* 170 */ "", /* 171 */ "", /* 172 */ "", /* 173 */ "XSYBBINARY", /* 174 */ "SYBUNITEXT", /* 175 */ "XSYBCHAR or SYBLONGCHAR", /* 176 */ "SYBSINT1", /* 177 */ "", /* 178 */ "", /* 179 */ "", /* 180 */ "", /* 181 */ "", /* 182 */ "", /* 183 */ "", /* 184 */ "", /* 185 */ "", /* 186 */ "", /* 187 */ "SYB5BIGDATETIME", /* 188 */ "SYB5BIGTIME", /* 189 */ "", /* 190 */ "", /* 191 */ "SYB5INT8", /* 192 */ "", /* 193 */ "", /* 194 */ "", /* 195 */ "", /* 196 */ "", /* 197 */ "", /* 198 */ "", /* 199 */ "", /* 200 */ "", /* 201 */ "", /* 202 */ "", /* 203 */ "", /* 204 */ "", /* 205 */ "", /* 206 */ "", /* 207 */ "", /* 208 */ "", /* 209 */ "", /* 210 */ "", /* 211 */ "", /* 212 */ "", /* 213 */ "", /* 214 */ "", /* 215 */ "", /* 216 */ "", /* 217 */ "", /* 218 */ "", /* 219 */ "", /* 220 */ "", /* 221 */ "", /* 222 */ "", /* 223 */ "", /* 224 */ "", /* 225 */ "SYBLONGBINARY", /* 226 */ "", /* 227 */ "", /* 228 */ "", /* 229 */ "", /* 230 */ "", /* 231 */ "XSYBNVARCHAR", /* 232 */ "", /* 233 */ "", /* 234 */ "", /* 235 */ "", /* 236 */ "", /* 237 */ "", /* 238 */ "", /* 239 */ "XSYBNCHAR", /* 240 */ "SYBMSUDT", /* 241 */ "SYBMSXML", /* 242 */ "", /* 243 */ "", /* 244 */ "", /* 245 */ "", /* 246 */ "", /* 247 */ "", /* 248 */ "", /* 249 */ "", /* 250 */ "", /* 251 */ "", /* 252 */ "", /* 253 */ "", /* 254 */ "", /* 255 */ "", }; #endif freetds-1.00.82/src/tds/Makefile.in100644 025423 025423 00000072427 13242511111 0012457# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/tds ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = \ $(top_srcdir)/m4/ac_caolan_func_which_gethostbyname_r.m4 \ $(top_srcdir)/m4/ac_have_inaddr_none.m4 \ $(top_srcdir)/m4/ac_have_malloc_options.m4 \ $(top_srcdir)/m4/ac_nullzero.m4 \ $(top_srcdir)/m4/ac_raf_func_which_getservbyname_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_gethostbyaddr_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_getpwuid_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_localtime_r.m4 \ $(top_srcdir)/m4/acx_pthread.m4 \ $(top_srcdir)/m4/ax_cflags_gcc_option.m4 \ $(top_srcdir)/m4/check_openssl.m4 \ $(top_srcdir)/m4/gettimemilli.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/pushlibs.m4 \ $(top_srcdir)/m4/sprintf_i64_format.m4 \ $(top_srcdir)/m4/type_socklen_t.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(noinst_HEADERS) \ $(am__DIST_COMMON) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) am__DEPENDENCIES_1 = libtds_la_DEPENDENCIES = $(am__DEPENDENCIES_1) am__libtds_la_SOURCES_DIST = mem.c token.c util.c login.c read.c \ write.c convert.c numeric.c config.c query.c iconv.c locale.c \ threadsafe.c vstrbuild.c tdsstring.c getmac.c data.c net.c \ tls.c tds_checks.c log.c dlist.c bulk.c packet.c stream.c \ random.c sec_negotiate_gnutls.h sec_negotiate_openssl.h \ sec_negotiate.c challenge.c md4.c md5.c des.c gssapi.c \ hmac_md5.c sspi.c @HAVE_SSPI_FALSE@am__objects_1 = challenge.lo md4.lo md5.lo des.lo \ @HAVE_SSPI_FALSE@ gssapi.lo hmac_md5.lo @HAVE_SSPI_TRUE@am__objects_1 = sspi.lo am_libtds_la_OBJECTS = mem.lo token.lo util.lo login.lo read.lo \ write.lo convert.lo numeric.lo config.lo query.lo iconv.lo \ locale.lo threadsafe.lo vstrbuild.lo tdsstring.lo getmac.lo \ data.lo net.lo tls.lo tds_checks.lo log.lo dlist.lo bulk.lo \ packet.lo stream.lo random.lo sec_negotiate.lo \ $(am__objects_1) libtds_la_OBJECTS = $(am_libtds_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = libtds_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(libtds_la_LDFLAGS) $(LDFLAGS) -o $@ AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libtds_la_SOURCES) DIST_SOURCES = $(am__libtds_la_SOURCES_DIST) RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac HEADERS = $(noinst_HEADERS) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp \ $(top_srcdir)/mkinstalldirs DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BUILD_NUMBER = @BUILD_NUMBER@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOXYGEN = @DOXYGEN@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FREETDS_LIBGCC = @FREETDS_LIBGCC@ FREETDS_ODBC_MODULE = @FREETDS_ODBC_MODULE@ FREETDS_SYMBOLIC = @FREETDS_SYMBOLIC@ GCRYPT_CFLAGS = @GCRYPT_CFLAGS@ GCRYPT_LIBS = @GCRYPT_LIBS@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ HAVE_OPENSSL = @HAVE_OPENSSL@ HAVE_PERL_SOURCES = @HAVE_PERL_SOURCES@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBADD_DL = @LIBADD_DL@ LIBADD_DLD_LINK = @LIBADD_DLD_LINK@ LIBADD_DLOPEN = @LIBADD_DLOPEN@ LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@ LIBICONV = @LIBICONV@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBOBJS = @LTLIBOBJS@ LT_DLLOADERS = @LT_DLLOADERS@ LT_DLPREOPEN = @LT_DLPREOPEN@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ NETTLE_CFLAGS = @NETTLE_CFLAGS@ NETTLE_LIBS = @NETTLE_LIBS@ NETWORK_LIBS = @NETWORK_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ODBC = @ODBC@ ODBCINSTLIB = @ODBCINSTLIB@ ODBCLIB = @ODBCLIB@ ODBCNODMLIB = @ODBCNODMLIB@ ODBCNODMLIBAPP = @ODBCNODMLIBAPP@ ODBC_CONFIG = @ODBC_CONFIG@ ODBC_INC = @ODBC_INC@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ RC = @RC@ READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SUBVERSION = @SUBVERSION@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ dblib_define = @dblib_define@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ tds_sysdep_int16_type = @tds_sysdep_int16_type@ tds_sysdep_int32_type = @tds_sysdep_int32_type@ tds_sysdep_int64_type = @tds_sysdep_int64_type@ tds_sysdep_intptr_type = @tds_sysdep_intptr_type@ tds_sysdep_real32_type = @tds_sysdep_real32_type@ tds_sysdep_real64_type = @tds_sysdep_real64_type@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = . unittests AM_CPPFLAGS = -I$(top_srcdir)/include noinst_LTLIBRARIES = libtds.la @HAVE_SSPI_FALSE@AUTH_FILES_DIST = sspi.c @HAVE_SSPI_TRUE@AUTH_FILES_DIST = challenge.c md4.c md5.c des.c gssapi.c hmac_md5.c @HAVE_SSPI_FALSE@AUTH_FILES = challenge.c md4.c md5.c des.c gssapi.c hmac_md5.c @HAVE_SSPI_TRUE@AUTH_FILES = sspi.c libtds_la_SOURCES = mem.c token.c util.c login.c read.c \ write.c convert.c numeric.c config.c query.c iconv.c \ locale.c threadsafe.c vstrbuild.c \ tdsstring.c getmac.c data.c net.c tls.c \ tds_checks.c log.c dlist.c \ bulk.c packet.c stream.c random.c \ sec_negotiate_gnutls.h sec_negotiate_openssl.h sec_negotiate.c \ $(AUTH_FILES) libtds_la_LDFLAGS = libtds_la_LIBADD = $(NETWORK_LIBS) noinst_HEADERS = tds_willconvert.h encodings.h num_limits.h tds_types.h EXTRA_DIST = tds_willconvert.h encodings.h num_limits.h tds_types.h \ CMakeLists.txt $(AUTH_FILES_DIST) @HAVE_PERL_SOURCES_TRUE@BUILT_SOURCES = tds_willconvert.h encodings.h num_limits.h tds_types.h all: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/tds/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/tds/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libtds.la: $(libtds_la_OBJECTS) $(libtds_la_DEPENDENCIES) $(EXTRA_libtds_la_DEPENDENCIES) $(AM_V_CCLD)$(libtds_la_LINK) $(libtds_la_OBJECTS) $(libtds_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bulk.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/challenge.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/config.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/convert.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/data.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/des.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dlist.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getmac.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gssapi.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hmac_md5.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/iconv.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/locale.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/login.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/md4.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/md5.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mem.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/net.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/numeric.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/packet.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/query.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/random.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/read.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sec_negotiate.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sspi.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stream.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tds_checks.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tdsstring.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/threadsafe.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tls.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/token.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/util.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vstrbuild.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/write.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) check-recursive all-am: Makefile $(LTLIBRARIES) $(HEADERS) installdirs: installdirs-recursive installdirs-am: install: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) @HAVE_PERL_SOURCES_FALSE@clean-local: clean: clean-recursive clean-am: clean-generic clean-libtool clean-local \ clean-noinstLTLIBRARIES mostlyclean-am distclean: distclean-recursive -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(am__recursive_targets) all check install install-am \ install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-generic clean-libtool clean-local \ clean-noinstLTLIBRARIES cscopelist-am ctags ctags-am distclean \ distclean-compile distclean-generic 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-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ installdirs-am maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ uninstall-am .PRECIOUS: Makefile # Perl is needed to build from a repository checkout. # Perl is *not* needed to build from a tarball. data.c: tds_types.h @HAVE_PERL_SOURCES_TRUE@clean-local: @HAVE_PERL_SOURCES_TRUE@ cd $(srcdir) && rm -f $(BUILT_SOURCES) @HAVE_PERL_SOURCES_TRUE@tds_willconvert.h: tds_willconvert.pl Makefile @HAVE_PERL_SOURCES_TRUE@ perl $(srcdir)/tds_willconvert.pl $(top_srcdir)/include/freetds/proto.h > $@.tmp @HAVE_PERL_SOURCES_TRUE@ mv $@.tmp $@ @HAVE_PERL_SOURCES_TRUE@encodings.h: encodings.pl alternative_character_sets.h Makefile @HAVE_PERL_SOURCES_TRUE@ perl $(srcdir)/encodings.pl $(srcdir) > $@.tmp 2> /dev/null @HAVE_PERL_SOURCES_TRUE@ mv $@.tmp $@ @HAVE_PERL_SOURCES_TRUE@num_limits.h: num_limits.pl Makefile @HAVE_PERL_SOURCES_TRUE@ perl $(srcdir)/num_limits.pl > $@.tmp @HAVE_PERL_SOURCES_TRUE@ mv $@.tmp $@ @HAVE_PERL_SOURCES_TRUE@tds_types.h: types.pl Makefile $(top_srcdir)/misc/types.csv @HAVE_PERL_SOURCES_TRUE@ perl $(srcdir)/types.pl $(top_srcdir)/misc/types.csv $(top_srcdir)/include/freetds/proto.h > $@.tmp @HAVE_PERL_SOURCES_TRUE@ mv $@.tmp $@ # 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: freetds-1.00.82/src/tds/mem.c100644 025423 025423 00000131073 13203773221 0011336/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns * Copyright (C) 2005-2015 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #include #include #include #include #include #include #include "replacements.h" #include #if HAVE_SYS_SOCKET_H #include #endif #ifdef HAVE_STRING_H #include #endif #ifdef HAVE_LOCALE_H #include #endif /* HAVE_LOCALE_H */ #ifdef HAVE_LANGINFO_H #include #endif /* HAVE_LANGINFO_H */ static void tds_free_env(TDSCONNECTION * conn); static void tds_free_compute_results(TDSSOCKET * tds); static void tds_free_compute_result(TDSCOMPUTEINFO * comp_info); #undef TEST_MALLOC #define TEST_MALLOC(dest,type) \ {if (!(dest = (type*)calloc(1, sizeof(type)))) goto Cleanup;} #undef TEST_CALLOC #define TEST_CALLOC(dest,type,n) \ {if (!(dest = (type*)calloc((n), sizeof(type)))) goto Cleanup;} /** * \ingroup libtds * \defgroup mem Memory allocation * Allocate or free resources. Allocation can fail only on out of memory. * In such case they return NULL and leave the state as before call. * Mainly function names are in the form tds_alloc_XX or tds_free_XXX. * tds_alloc_XXX functions allocate structures and return pointer to allocated * data while tds_free_XXX take structure pointers and free them. Some functions * require additional parameters to initialize structure correctly. * The main exception are structures that use reference counting. These structures * have tds_alloc_XXX functions but instead of tds_free_XXX use tds_release_XXX. */ /** * \addtogroup mem * @{ */ static volatile unsigned int inc_num = 1; /** * Get an id for dynamic query based on TDS information * \param conn state information for the connection and the TDS protocol * \return TDS_FAIL or TDS_SUCCESS */ static char * tds_get_dynid(TDSCONNECTION * conn, char *id) { unsigned long n; int i; char *p; char c; CHECK_CONN_EXTRA(conn); inc_num = (inc_num + 1) & 0xffff; /* some version of Sybase require length <= 10, so we code id */ n = (unsigned long) (TDS_INTPTR) conn; p = id; *p++ = (char) ('a' + (n % 26u)); n /= 26u; for (i = 0; i < 9; ++i) { c = (char) ('0' + (n % 36u)); *p++ = (c < ('0' + 10)) ? c : c + ('a' - '0' - 10); /* printf("%d -> %d(%c)\n",n%36u,p[-1],p[-1]); */ n /= 36u; if (i == 4) n += 3u * inc_num; } *p = 0; return id; } extern const TDSCOLUMNFUNCS tds_invalid_funcs; static TDSCOLUMN * tds_alloc_column(void) { TDSCOLUMN *col; TEST_MALLOC(col, TDSCOLUMN); tds_dstr_init(&col->table_name); tds_dstr_init(&col->column_name); tds_dstr_init(&col->table_column_name); col->funcs = &tds_invalid_funcs; Cleanup: return col; } static void tds_free_column(TDSCOLUMN *col) { tds_dstr_free(&col->table_name); tds_dstr_free(&col->column_name); tds_dstr_free(&col->table_column_name); free(col); } /** * \fn TDSDYNAMIC *tds_alloc_dynamic(TDSCONNECTION *conn, const char *id) * \brief Allocate a dynamic statement. * \param conn the connection within which to allocate the statement. * \param id a character label identifying the statement. * \return a pointer to the allocated structure (NULL on failure). * * tds_alloc_dynamic is used to implement placeholder code under TDS 5.0 */ TDSDYNAMIC * tds_alloc_dynamic(TDSCONNECTION * conn, const char *id) { TDSDYNAMIC *dyn; char tmp_id[30]; if (id) { /* check to see if id already exists (shouldn't) */ if (tds_lookup_dynamic(conn, id)) return NULL; } else { unsigned int n; id = tmp_id; for (n = 0;;) { if (!tds_lookup_dynamic(conn, tds_get_dynid(conn, tmp_id))) break; if (++n == 256) return NULL; } } TEST_MALLOC(dyn, TDSDYNAMIC); /* take into account pointer in list */ dyn->ref_count = 2; /* insert into list */ dyn->next = conn->dyns; conn->dyns = dyn; strlcpy(dyn->id, id, TDS_MAX_DYNID_LEN); return dyn; Cleanup: return NULL; } /** * \fn void tds_free_input_params(TDSDYNAMIC *dyn) * \brief Frees all allocated input parameters of a dynamic statement. * \param dyn the dynamic statement whose input parameter are to be freed * * tds_free_input_params frees all parameters for the give dynamic statement */ void tds_free_input_params(TDSDYNAMIC * dyn) { TDSPARAMINFO *info; info = dyn->params; if (info) { tds_free_param_results(info); dyn->params = NULL; } } /* * Called when dynamic got deallocated from server */ void tds_dynamic_deallocated(TDSCONNECTION *conn, TDSDYNAMIC *dyn) { TDSDYNAMIC **victim; tdsdump_log(TDS_DBG_FUNC, "tds_dynamic_deallocated() : freeing dynamic_id %s\n", dyn->id); victim = &conn->dyns; while (*victim != dyn) { if (*victim == NULL) { tdsdump_log(TDS_DBG_FUNC, "tds_dynamic_deallocated() : cannot find id %s\n", dyn->id); return; } victim = &(*victim)->next; } /* remove from list */ *victim = dyn->next; dyn->next = NULL; /* assure there is no id left */ dyn->num_id = 0; tds_release_dynamic(&dyn); } /** * \fn void tds_release_dynamic(TDSDYNAMIC **pdyn) * \brief Frees dynamic statement * \param pdyn pointer to dynamic statement to be freed. */ void tds_release_dynamic(TDSDYNAMIC ** pdyn) { TDSDYNAMIC *dyn; dyn = *pdyn; *pdyn = NULL; if (!dyn || --dyn->ref_count > 0) return; tds_detach_results(dyn->res_info); tds_free_results(dyn->res_info); tds_free_input_params(dyn); free(dyn->query); free(dyn); } /** * \fn TDSPARAMINFO *tds_alloc_param_result(TDSPARAMINFO *old_param) * \brief Adds a output parameter to TDSPARAMINFO. * \param old_param a pointer to the TDSPARAMINFO structure containing the * current set of output parameter, or NULL if none exists. * \return a pointer to the new TDSPARAMINFO structure. * * tds_alloc_param_result() works a bit differently than the other alloc result * functions. Output parameters come in individually with no total number * given in advance, so we simply call this func every time with get a * TDS_PARAM_TOKEN and let it realloc the columns struct one bigger. * tds_free_all_results() usually cleans up after us. */ TDSPARAMINFO * tds_alloc_param_result(TDSPARAMINFO * old_param) { TDSPARAMINFO *param_info; TDSCOLUMN *colinfo; /* parameters cannot have row associated */ if (old_param && (old_param->current_row || old_param->row_free)) return NULL; colinfo = tds_alloc_column(); if (!colinfo) return NULL; param_info = old_param; if (!param_info) { TEST_MALLOC(param_info, TDSPARAMINFO); param_info->ref_count = 1; } if (!TDS_RESIZE(param_info->columns, param_info->num_cols + 1u)) goto Cleanup; param_info->columns[param_info->num_cols++] = colinfo; return param_info; Cleanup: if (!old_param) free(param_info); free(colinfo); return NULL; } /** * Delete latest parameter */ void tds_free_param_result(TDSPARAMINFO * param_info) { TDSCOLUMN *col; if (!param_info || param_info->num_cols <= 0) return; col = param_info->columns[--param_info->num_cols]; if (col->column_data && col->column_data_free) col->column_data_free(col); if (param_info->num_cols == 0) TDS_ZERO_FREE(param_info->columns); /* * NOTE some informations should be freed too but when this function * is called are not used. I hope to remove the need for this * function ASAP * A better way is to support different way to allocate and get * parameters * -- freddy77 */ tds_free_column(col); } static void tds_param_free(TDSCOLUMN *col) { if (!col->column_data) return; if (is_blob_col(col)) { TDSBLOB *blob = (TDSBLOB *) col->column_data; free(blob->textvalue); } TDS_ZERO_FREE(col->column_data); } /** * Allocate data for a parameter. * @param curparam parameter to retrieve size information * @return NULL on failure or new data */ void * tds_alloc_param_data(TDSCOLUMN * curparam) { TDS_INT data_size; void *data; CHECK_COLUMN_EXTRA(curparam); data_size = curparam->funcs->row_len(curparam); /* allocate data */ if (curparam->column_data && curparam->column_data_free) curparam->column_data_free(curparam); curparam->column_data_free = tds_param_free; data = malloc(data_size); curparam->column_data = (unsigned char*) data; if (!data) return NULL; /* if is a blob reset buffer */ if (is_blob_col(curparam)) memset(data, 0, sizeof(TDSBLOB)); return data; } /** * Allocate memory for storing compute info * return NULL on out of memory */ static TDSCOMPUTEINFO * tds_alloc_compute_result(TDS_USMALLINT num_cols, TDS_USMALLINT by_cols) { TDS_USMALLINT col; TDSCOMPUTEINFO *info; TEST_MALLOC(info, TDSCOMPUTEINFO); info->ref_count = 1; TEST_CALLOC(info->columns, TDSCOLUMN *, num_cols); info->num_cols = num_cols; for (col = 0; col < num_cols; col++) if (!(info->columns[col] = tds_alloc_column())) goto Cleanup; if (by_cols) { TEST_CALLOC(info->bycolumns, TDS_SMALLINT, by_cols); info->by_cols = by_cols; } return info; Cleanup: tds_free_compute_result(info); return NULL; } TDSCOMPUTEINFO ** tds_alloc_compute_results(TDSSOCKET * tds, TDS_USMALLINT num_cols, TDS_USMALLINT by_cols) { TDS_UINT n; TDSCOMPUTEINFO **comp_info; TDSCOMPUTEINFO *cur_comp_info; tdsdump_log(TDS_DBG_FUNC, "alloc_compute_result. num_cols = %d bycols = %d\n", num_cols, by_cols); tdsdump_log(TDS_DBG_FUNC, "alloc_compute_result. num_comp_info = %d\n", tds->num_comp_info); cur_comp_info = tds_alloc_compute_result(num_cols, by_cols); if (!cur_comp_info) return NULL; n = tds->num_comp_info; comp_info = (TDSCOMPUTEINFO **) TDS_RESIZE(tds->comp_info, n + 1u); if (!comp_info) { tds_free_compute_result(cur_comp_info); return NULL; } tds->comp_info = comp_info; comp_info[n] = cur_comp_info; tds->num_comp_info = n + 1u; tdsdump_log(TDS_DBG_FUNC, "alloc_compute_result. num_comp_info = %d\n", tds->num_comp_info); return comp_info; } TDSRESULTINFO * tds_alloc_results(TDS_USMALLINT num_cols) { TDSRESULTINFO *res_info; TDS_USMALLINT col; TEST_MALLOC(res_info, TDSRESULTINFO); res_info->ref_count = 1; if (num_cols) TEST_CALLOC(res_info->columns, TDSCOLUMN *, num_cols); for (col = 0; col < num_cols; col++) if (!(res_info->columns[col] = tds_alloc_column())) goto Cleanup; res_info->num_cols = num_cols; res_info->row_size = 0; return res_info; Cleanup: tds_free_results(res_info); return NULL; } void tds_set_current_results(TDSSOCKET *tds, TDSRESULTINFO *info) { tds_detach_results(info); if (tds->current_results) tds->current_results->attached_to = NULL; if (info) info->attached_to = tds; tds->in_row = (info != NULL); tds->current_results = info; } /** * Detach result info from it current socket */ void tds_detach_results(TDSRESULTINFO *info) { if (info && info->attached_to) { info->attached_to->current_results = NULL; info->attached_to->in_row = false; info->attached_to = NULL; } } static void tds_row_free(TDSRESULTINFO *res_info, unsigned char *row) { int i; const TDSCOLUMN *col; if (!res_info || !row) return; for (i = 0; i < res_info->num_cols; ++i) { col = res_info->columns[i]; if (is_blob_col(col)) { TDSBLOB *blob = (TDSBLOB *) &row[col->column_data - res_info->current_row]; if (blob->textvalue) TDS_ZERO_FREE(blob->textvalue); } } free(row); } /** * Allocate space for row store * return NULL on out of memory */ TDSRET tds_alloc_row(TDSRESULTINFO * res_info) { int i, num_cols = res_info->num_cols; unsigned char *ptr; TDSCOLUMN *col; TDS_UINT row_size; /* compute row size */ row_size = 0; for (i = 0; i < num_cols; ++i) { col = res_info->columns[i]; col->column_data_free = NULL; row_size += col->funcs->row_len(col); row_size += (TDS_ALIGN_SIZE - 1); row_size -= row_size % TDS_ALIGN_SIZE; } res_info->row_size = row_size; ptr = tds_new0(unsigned char, res_info->row_size); res_info->current_row = ptr; if (!ptr) return TDS_FAIL; res_info->row_free = tds_row_free; /* fill column_data */ row_size = 0; for (i = 0; i < num_cols; ++i) { col = res_info->columns[i]; col->column_data = ptr + row_size; row_size += col->funcs->row_len(col); row_size += (TDS_ALIGN_SIZE - 1); row_size -= row_size % TDS_ALIGN_SIZE; } return TDS_SUCCESS; } TDSRET tds_alloc_compute_row(TDSCOMPUTEINFO * res_info) { return tds_alloc_row(res_info); } void tds_free_param_results(TDSPARAMINFO * param_info) { tds_free_results(param_info); } static void tds_free_compute_result(TDSCOMPUTEINFO * comp_info) { tds_free_results(comp_info); } static void tds_free_compute_results(TDSSOCKET * tds) { TDSCOMPUTEINFO ** comp_info = tds->comp_info; TDS_UINT i, num_comp = tds->num_comp_info; tds->comp_info = NULL; tds->num_comp_info = 0; for (i = 0; i < num_comp; i++) { if (comp_info && comp_info[i]) { tds_detach_results(comp_info[i]); tds_free_compute_result(comp_info[i]); } } if (num_comp) free(comp_info); } void tds_free_row(TDSRESULTINFO * res_info, unsigned char *row) { assert(res_info); if (!row || !res_info->row_free) return; res_info->row_free(res_info, row); } void tds_free_results(TDSRESULTINFO * res_info) { int i; TDSCOLUMN *curcol; if (!res_info) return; if (--res_info->ref_count != 0) return; tds_detach_results(res_info); if (res_info->num_cols && res_info->columns) { for (i = 0; i < res_info->num_cols; i++) if ((curcol = res_info->columns[i]) != NULL) { if (curcol->bcp_terminator) TDS_ZERO_FREE(curcol->bcp_terminator); tds_free_bcp_column_data(curcol->bcp_column_data); curcol->bcp_column_data = NULL; if (curcol->column_data && curcol->column_data_free) curcol->column_data_free(curcol); } } if (res_info->current_row && res_info->row_free) res_info->row_free(res_info, res_info->current_row); if (res_info->num_cols && res_info->columns) { for (i = 0; i < res_info->num_cols; i++) if ((curcol = res_info->columns[i]) != NULL) tds_free_column(curcol); free(res_info->columns); } free(res_info->bycolumns); free(res_info); } void tds_free_all_results(TDSSOCKET * tds) { tdsdump_log(TDS_DBG_FUNC, "tds_free_all_results()\n"); tds_detach_results(tds->res_info); tds_free_results(tds->res_info); tds->res_info = NULL; tds_detach_results(tds->param_info); tds_free_param_results(tds->param_info); tds->param_info = NULL; tds_free_compute_results(tds); tds->has_status = 0; tds->in_row = false; tds->ret_status = 0; if (tds->cur_dyn) tds_detach_results(tds->cur_dyn->res_info); } /* * Return 1 if winsock is initialized, else 0. */ static int winsock_initialized(void) { #if defined(_WIN32) || defined(_WIN64) static bool initialized = false; static tds_mutex mtx = TDS_MUTEX_INITIALIZER; WSADATA wsa_data; int erc; if (initialized) return 1; tds_mutex_lock(&mtx); /* same check inside the mutex */ if (initialized) { tds_mutex_unlock(&mtx); return 1; } /* initialize the socket layer */ erc = WSAStartup(MAKEWORD(2, 2), &wsa_data); initialized = (erc == 0); tds_mutex_unlock(&mtx); if (erc != 0) { char *errstr = sock_strerror(erc); tdsdump_log(TDS_DBG_ERROR, "tds_init_winsock: WSAStartup failed with %d (%s)\n", erc, errstr); sock_strerror_free(errstr); return 0; } #endif return 1; } TDSCONTEXT * tds_alloc_context(void * parent) { TDSCONTEXT *context; TDSLOCALE *locale; if (!winsock_initialized()) return NULL; if ((locale = tds_get_locale()) == NULL) return NULL; if ((context = tds_new0(TDSCONTEXT, 1)) == NULL) { tds_free_locale(locale); return NULL; } context->locale = locale; context->parent = parent; return context; } void tds_free_context(TDSCONTEXT * context) { if (!context) return; tds_free_locale(context->locale); free(context); } TDSLOCALE * tds_alloc_locale(void) { TDSLOCALE *locale; TEST_MALLOC(locale, TDSLOCALE); return locale; Cleanup: tds_free_locale(locale); return NULL; } /* * Default capabilities. */ #undef REQ #define SUPPORTED_REQ_CAP(i) \ REQ(i,LANG) REQ(i,RPC) REQ(i,EVT) REQ(i,MSTMT) REQ(i,BCP) REQ(i,CURSOR) REQ(i,DYNF) \ REQ(i,MSG) REQ(i,PARAM) REQ(i,DATA_INT1) REQ(i,DATA_INT2) REQ(i,DATA_INT4) REQ(i,DATA_BIT) \ REQ(i,DATA_CHAR) REQ(i,DATA_VCHAR) REQ(i,DATA_BIN) REQ(i,DATA_VBIN) REQ(i,DATA_MNY8) \ REQ(i,DATA_MNY4) REQ(i,DATA_DATE8) REQ(i,DATA_DATE4) REQ(i,DATA_FLT4) REQ(i,DATA_FLT8) \ REQ(i,DATA_NUM) REQ(i,DATA_TEXT) REQ(i,DATA_IMAGE) REQ(i,DATA_DEC) REQ(i,DATA_LCHAR) \ REQ(i,DATA_LBIN) REQ(i,DATA_INTN) REQ(i,DATA_DATETIMEN) REQ(i,DATA_MONEYN) \ REQ(i,CSR_PREV) REQ(i,CSR_FIRST) REQ(i,CSR_LAST) REQ(i,CSR_ABS) REQ(i,CSR_REL) \ REQ(i,CSR_MULTI) REQ(i,CON_INBAND) REQ(i,PROTO_TEXT) REQ(i,PROTO_BULK) \ REQ(i,DATA_SENSITIVITY) REQ(i,DATA_BOUNDARY) REQ(i,PROTO_DYNPROC) REQ(i,DATA_FLTN) \ REQ(i,DATA_BITN) REQ(i,DATA_INT8) REQ(i,WIDETABLE) \ REQ(i,DATA_UINT2) REQ(i,DATA_UINT4) REQ(i,DATA_UINT8) REQ(i,DATA_UINTN) REQ(i,LARGEIDENT) \ REQ(i,SRVPKTSIZE) REQ(i,DATA_DATE) REQ(i,DATA_TIME) REQ(i,DATA_BIGTIME) REQ(i,DATA_BIGDATETIME) #define REQ(i,n) |(((TDS_REQ_ ## n / 8) == i)?(1<<(TDS_REQ_ ## n & 7)):0) #define REQB(i) 0 SUPPORTED_REQ_CAP(i) #undef RES #define SUPPORTED_RES_CAP(i) \ RES(i,CON_NOOOB) RES(i,PROTO_NOTEXT) RES(i,PROTO_NOBULK) RES(i,NOTDSDEBUG) #define RES(i,n) |(((TDS_RES_ ## n / 8) == i)?(1<<(TDS_RES_ ## n & 7)):0) #define RESB(i) 0 SUPPORTED_RES_CAP(i) static const TDS_CAPABILITIES defaultcaps = { { /* type, len, data, data, data, data, data, data, data, data, data, data, data, data, data, data (14 bytes) */ { 1, 14, { REQB(13), REQB(12), REQB(11), REQB(10), REQB(9), REQB(8), REQB(7), REQB(6), REQB(5), REQB(4), REQB(3), REQB(2), REQB(1), REQB(0) } }, { 2, 14, { RESB(13), RESB(12), RESB(11), RESB(10), RESB(9), RESB(8), RESB(7), RESB(6), RESB(5), RESB(4), RESB(3), RESB(2), RESB(1), RESB(0) } } } }; /* check we match the values size */ TDS_COMPILE_CHECK(tds_values_len, sizeof(defaultcaps.types[0].values) == 14); /* check we match the default size */ TDS_COMPILE_CHECK(tds_cap_len, sizeof(defaultcaps) == TDS_MAX_CAPABILITY); /** * Initialize login structure with locale information and other stuff for connection * @param locale locale information (copied to configuration information) * @result login structure or NULL if initialization error */ TDSLOGIN* tds_init_login(TDSLOGIN *login, TDSLOCALE * locale) { char hostname[128]; #if HAVE_NL_LANGINFO && defined(CODESET) const char *charset; #else char *lc_all, *tok = NULL; #endif /* * TDS 7.0: * 0x02 indicates ODBC driver * 0x01 means change to initial language must succeed */ login->option_flag2 = 0x03; login->tds_version = TDS_DEFAULT_VERSION; login->block_size = 0; #if HAVE_NL_LANGINFO && defined(CODESET) charset = nl_langinfo(CODESET); if (strcmp(tds_canonical_charset_name(charset), "US-ASCII") == 0) charset = "ISO-8859-1"; if (!tds_dstr_copy(&login->client_charset, charset)) return NULL; #else if (!tds_dstr_copy(&login->client_charset, "ISO-8859-1")) return NULL; if ((lc_all = strdup(setlocale(LC_ALL, NULL))) == NULL) return NULL; if (strtok_r(lc_all, ".", &tok)) { char *encoding = strtok_r(NULL, "@", &tok); #ifdef _WIN32 /* windows give numeric codepage*/ if (encoding && atoi(encoding) > 0) { char *p; if (asprintf(&p, "CP%s", encoding) >= 0) { free(lc_all); lc_all = encoding = p; } } #endif if (encoding) { if (!tds_dstr_copy(&login->client_charset, encoding)) return NULL; } } free(lc_all); #endif if (locale) { if (locale->language) if (!tds_dstr_copy(&login->language, locale->language)) return NULL; if (locale->server_charset) if (!tds_dstr_copy(&login->server_charset, locale->server_charset)) return NULL; } if (tds_dstr_isempty(&login->language)) { if (!tds_dstr_copy(&login->language, TDS_DEF_LANG)) return NULL; } memset(hostname, '\0', sizeof(hostname)); gethostname(hostname, sizeof(hostname)); hostname[sizeof(hostname) - 1] = '\0'; /* make sure it's terminated */ if (!tds_dstr_copy(&login->client_host_name, hostname)) return NULL; login->valid_configuration = 1; login->check_ssl_hostname = 1; return login; } TDSCURSOR * tds_alloc_cursor(TDSSOCKET *tds, const char *name, TDS_INT namelen, const char *query, TDS_INT querylen) { TDSCURSOR *cursor; TDSCURSOR *pcursor; TEST_MALLOC(cursor, TDSCURSOR); cursor->ref_count = 1; cursor->type = TDS_CUR_TYPE_KEYSET; cursor->concurrency = TDS_CUR_CONCUR_OPTIMISTIC; TEST_CALLOC(cursor->cursor_name, char, namelen + 1); memcpy(cursor->cursor_name, name, namelen); TEST_CALLOC(cursor->query, char, querylen + 1); memcpy(cursor->query, query, querylen); if (tds->conn->cursors == NULL) { tds->conn->cursors = cursor; } else { for (pcursor = tds->conn->cursors; pcursor->next; pcursor = pcursor->next) continue; pcursor->next = cursor; } /* take into account reference in connection list */ ++cursor->ref_count; return cursor; Cleanup: tds_release_cursor(&cursor); return NULL; } /* * Called when cursor got deallocated from server */ void tds_cursor_deallocated(TDSCONNECTION *conn, TDSCURSOR *cursor) { TDSCURSOR **victim; tdsdump_log(TDS_DBG_FUNC, "tds_cursor_deallocated() : freeing cursor_id %d\n", cursor->cursor_id); victim = &conn->cursors; while (*victim != cursor) { if (*victim == NULL) { tdsdump_log(TDS_DBG_FUNC, "tds_cursor_deallocated() : cannot find cursor_id %d\n", cursor->cursor_id); return; } victim = &(*victim)->next; } /* remove from list */ *victim = cursor->next; cursor->next = NULL; tds_release_cursor(&cursor); } /* * Decrement reference counter and free if necessary. * Called internally by libTDS and by upper library when you don't need * cursor reference anymore */ void tds_release_cursor(TDSCURSOR **pcursor) { TDSCURSOR *cursor = *pcursor; *pcursor = NULL; if (!cursor || --cursor->ref_count > 0) return; tdsdump_log(TDS_DBG_FUNC, "tds_release_cursor() : freeing cursor_id %d\n", cursor->cursor_id); tdsdump_log(TDS_DBG_FUNC, "tds_release_cursor() : freeing cursor results\n"); tds_detach_results(cursor->res_info); tds_free_results(cursor->res_info); if (cursor->cursor_name) { tdsdump_log(TDS_DBG_FUNC, "tds_release_cursor() : freeing cursor name\n"); free(cursor->cursor_name); } if (cursor->query) { tdsdump_log(TDS_DBG_FUNC, "tds_release_cursor() : freeing cursor query\n"); free(cursor->query); } tdsdump_log(TDS_DBG_FUNC, "tds_release_cursor() : cursor_id %d freed\n", cursor->cursor_id); free(cursor); } TDSLOGIN * tds_alloc_login(int use_environment) { TDSLOGIN *login = NULL; const char *server_name = TDS_DEF_SERVER; TEST_MALLOC(login, TDSLOGIN); login->check_ssl_hostname = 1; login->use_utf16 = 1; login->bulk_copy = 1; tds_dstr_init(&login->server_name); tds_dstr_init(&login->language); tds_dstr_init(&login->server_charset); tds_dstr_init(&login->client_host_name); tds_dstr_init(&login->server_host_name); tds_dstr_init(&login->app_name); tds_dstr_init(&login->user_name); tds_dstr_init(&login->password); tds_dstr_init(&login->library); tds_dstr_init(&login->new_password); login->ip_addrs = NULL; login->connected_addr = NULL; tds_dstr_init(&login->database); tds_dstr_init(&login->dump_file); tds_dstr_init(&login->client_charset); tds_dstr_init(&login->instance_name); tds_dstr_init(&login->server_realm_name); tds_dstr_init(&login->server_spn); tds_dstr_init(&login->cafile); tds_dstr_init(&login->crlfile); tds_dstr_init(&login->db_filename); tds_dstr_init(&login->openssl_ciphers); tds_dstr_init(&login->routing_address); if (use_environment) { const char *s; if ((s=getenv("DSQUERY")) != NULL) server_name = s; if ((s=getenv("TDSQUERY")) != NULL) server_name = s; } if (!tds_dstr_copy(&login->server_name, server_name)) { free(login); return NULL; } login->capabilities = defaultcaps; Cleanup: return login; } void tds_free_login(TDSLOGIN * login) { if (!login) return; /* for security reason clear memory */ tds_dstr_zero(&login->password); tds_dstr_free(&login->password); tds_dstr_zero(&login->new_password); tds_dstr_free(&login->new_password); tds_dstr_free(&login->server_name); tds_dstr_free(&login->language); tds_dstr_free(&login->server_charset); tds_dstr_free(&login->client_host_name); tds_dstr_free(&login->app_name); tds_dstr_free(&login->user_name); tds_dstr_free(&login->library); tds_dstr_free(&login->client_charset); tds_dstr_free(&login->server_host_name); if (login->ip_addrs != NULL) freeaddrinfo(login->ip_addrs); tds_dstr_free(&login->database); tds_dstr_free(&login->dump_file); tds_dstr_free(&login->instance_name); tds_dstr_free(&login->server_realm_name); tds_dstr_free(&login->server_spn); tds_dstr_free(&login->cafile); tds_dstr_free(&login->crlfile); tds_dstr_free(&login->db_filename); tds_dstr_free(&login->openssl_ciphers); tds_dstr_free(&login->routing_address); free(login); } TDSPACKET * tds_alloc_packet(void *buf, unsigned len) { TDSPACKET *packet = (TDSPACKET *) malloc(len + TDS_OFFSET(TDSPACKET, buf)); if (TDS_LIKELY(packet)) { packet->len = 0; packet->capacity = len; packet->sid = 0; packet->next = NULL; if (buf) { memcpy(packet->buf, buf, len); packet->len = len; } } return packet; } TDSPACKET * tds_realloc_packet(TDSPACKET *packet, unsigned len) { if (packet->capacity < len) { packet = (TDSPACKET *) realloc(packet, len + TDS_OFFSET(TDSPACKET, buf)); if (TDS_LIKELY(packet)) packet->capacity = len; } return packet; } void tds_free_packets(TDSPACKET *packet) { TDSPACKET *next; for (; packet; packet = next) { next = packet->next; free(packet); } } static void tds_deinit_connection(TDSCONNECTION *conn) { if (conn->authentication) conn->authentication->free(conn, conn->authentication); conn->authentication = NULL; while (conn->dyns) tds_dynamic_deallocated(conn, conn->dyns); while (conn->cursors) tds_cursor_deallocated(conn, conn->cursors); tds_ssl_deinit(conn); /* close connection and free inactive sockets */ tds_connection_close(conn); tds_wakeup_close(&conn->wakeup); tds_iconv_free(conn); free(conn->product_name); free(conn->server); tds_free_env(conn); #if ENABLE_ODBC_MARS tds_mutex_free(&conn->list_mtx); tds_free_packets(conn->packets); tds_free_packets(conn->recv_packet); tds_free_packets(conn->send_packets); tds_free_packets(conn->packet_cache); free(conn->sessions); #endif } static TDSCONNECTION * tds_init_connection(TDSCONNECTION *conn, TDSCONTEXT *context, unsigned int bufsize) { conn->env.block_size = bufsize; conn->s = INVALID_SOCKET; conn->use_iconv = 1; conn->tds_ctx = context; if (tds_wakeup_init(&conn->wakeup)) goto Cleanup; if (tds_iconv_alloc(conn)) goto Cleanup; #if ENABLE_ODBC_MARS if (tds_mutex_init(&conn->list_mtx)) goto Cleanup; TEST_CALLOC(conn->sessions, TDSSOCKET*, 64); conn->num_sessions = 64; #endif return conn; Cleanup: tds_wakeup_close(&conn->wakeup); tds_iconv_free(conn); return NULL; } static TDSSOCKET * tds_init_socket(TDSSOCKET * tds_socket, unsigned int bufsize) { tds_socket->parent = NULL; tds_socket->recv_packet = tds_alloc_packet(NULL, bufsize); if (!tds_socket->recv_packet) goto Cleanup; tds_socket->in_buf = tds_socket->recv_packet->buf; tds_socket->send_packet = tds_alloc_packet(NULL, bufsize + TDS_ADDITIONAL_SPACE); if (!tds_socket->send_packet) goto Cleanup; tds_socket->out_buf = tds_socket->send_packet->buf; tds_socket->out_buf_max = bufsize; /* Jeff's hack, init to no timeout */ tds_socket->query_timeout = 0; tds_init_write_buf(tds_socket); tds_socket->state = TDS_DEAD; tds_socket->env_chg_func = NULL; if (tds_mutex_init(&tds_socket->wire_mtx)) goto Cleanup; #ifdef ENABLE_ODBC_MARS tds_socket->sid = 0; if (tds_cond_init(&tds_socket->packet_cond)) goto Cleanup; #endif return tds_socket; Cleanup: tds_free_packets(tds_socket->recv_packet); tds_free_packets(tds_socket->send_packet); return NULL; } #if ENABLE_ODBC_MARS static void tds_free_connection(TDSCONNECTION *conn) { if (!conn) return; assert(conn->in_net_tds == NULL); tds_deinit_connection(conn); free(conn); } static TDSCONNECTION * tds_alloc_connection(TDSCONTEXT *context, unsigned int bufsize) { TDSCONNECTION *conn; TEST_MALLOC(conn, TDSCONNECTION); if (!tds_init_connection(conn, context, bufsize)) goto Cleanup; return conn; Cleanup: tds_free_connection(conn); return NULL; } static TDSSOCKET * tds_alloc_socket_base(unsigned int bufsize) { TDSSOCKET *tds_socket; TEST_MALLOC(tds_socket, TDSSOCKET); if (!tds_init_socket(tds_socket, bufsize)) goto Cleanup; return tds_socket; Cleanup: tds_free_socket(tds_socket); return NULL; } TDSSOCKET * tds_alloc_socket(TDSCONTEXT * context, unsigned int bufsize) { TDSCONNECTION *conn = tds_alloc_connection(context, bufsize); TDSSOCKET *tds; if (!conn) return NULL; tds = tds_alloc_socket_base(bufsize); if (tds) { conn->sessions[0] = tds; tds->conn = conn; return tds; } tds_free_connection(conn); return NULL; } TDSSOCKET * tds_alloc_additional_socket(TDSCONNECTION *conn) { TDSSOCKET *tds; if (!IS_TDS72_PLUS(conn) || !conn->mars) return NULL; tds = tds_alloc_socket_base(conn->env.block_size); if (!tds) return NULL; tds->sid = -1; tds->conn = conn; tds->state = TDS_IDLE; return tds; } #else /* !ENABLE_ODBC_MARS */ TDSSOCKET * tds_alloc_socket(TDSCONTEXT * context, unsigned int bufsize) { TDSSOCKET *tds_socket; TEST_MALLOC(tds_socket, TDSSOCKET); if (!tds_init_connection(tds_socket->conn, context, bufsize)) goto Cleanup; if (!tds_init_socket(tds_socket, bufsize)) goto Cleanup; return tds_socket; Cleanup: tds_free_socket(tds_socket); return NULL; } #endif /* !ENABLE_ODBC_MARS */ TDSSOCKET * tds_realloc_socket(TDSSOCKET * tds, size_t bufsize) { TDSPACKET *packet; assert(tds && tds->out_buf && tds->send_packet); if (bufsize < 512) bufsize = 512; tds->conn->env.block_size = bufsize; if (tds->out_pos > bufsize) return NULL; packet = tds_realloc_packet(tds->send_packet, bufsize + TDS_ADDITIONAL_SPACE); if (packet == NULL) return NULL; tds->out_buf = packet->buf; tds->out_buf_max = bufsize; tds->send_packet = packet; return tds; } #if ENABLE_ODBC_MARS static void tds_connection_remove_socket(TDSCONNECTION *conn, TDSSOCKET *tds) { unsigned n; int must_free = 1; tds_mutex_lock(&conn->list_mtx); if (tds->sid >= 0 && tds->sid < conn->num_sessions) conn->sessions[tds->sid] = NULL; for (n = 0; n < conn->num_sessions; ++n) if (TDSSOCKET_VALID(conn->sessions[n])) { must_free = 0; break; } if (!must_free) { /* tds use connection member so must be valid */ tds_append_fin(tds); } tds_mutex_unlock(&conn->list_mtx); /* detach entirely */ tds->sid = -1; tds->conn = NULL; if (must_free) tds_free_connection(conn); } #else static void inline tds_connection_remove_socket(TDSCONNECTION *conn, TDSSOCKET *tds) { tds_deinit_connection(conn); } #endif void tds_free_socket(TDSSOCKET * tds) { #if ENABLE_EXTRA_CHECKS TDSDYNAMIC *dyn; TDSCURSOR *cur; #endif if (!tds) return; /* detach this socket */ tds_release_cur_dyn(tds); tds_release_cursor(&tds->cur_cursor); tds_detach_results(tds->current_results); #if ENABLE_EXTRA_CHECKS for (dyn = tds->conn->dyns; dyn; dyn = dyn->next) { if (dyn->res_info && dyn->res_info->attached_to == tds) { assert(0); } } for (cur = tds->conn->cursors; cur; cur = cur->next) { if (cur->res_info && cur->res_info->attached_to == tds) { assert(0); } } #endif tds_free_all_results(tds); #if ENABLE_ODBC_MARS tds_cond_destroy(&tds->packet_cond); #endif tds_connection_remove_socket(tds->conn, tds); tds_free_packets(tds->recv_packet); tds_free_packets(tds->send_packet); free(tds); } void tds_free_locale(TDSLOCALE * locale) { if (!locale) return; free(locale->language); free(locale->server_charset); free(locale->date_fmt); free(locale); } static void tds_free_env(TDSCONNECTION* conn) { if (conn->env.language) TDS_ZERO_FREE(conn->env.language); if (conn->env.charset) TDS_ZERO_FREE(conn->env.charset); if (conn->env.database) TDS_ZERO_FREE(conn->env.database); } void tds_free_msg(TDSMESSAGE * message) { if (message) { message->priv_msg_type = 0; message->msgno = 0; message->state = 0; message->severity = 0; message->line_number = 0; TDS_ZERO_FREE(message->message); TDS_ZERO_FREE(message->server); TDS_ZERO_FREE(message->proc_name); TDS_ZERO_FREE(message->sql_state); } } #define SQLS_ENTRY(number,state) case number: p = state; break char * tds_alloc_client_sqlstate(int msgno) { const char *p = NULL; switch (msgno) { SQLS_ENTRY(17000, "S1T00"); /* timeouts ??? */ SQLS_ENTRY(20004, "08S01"); /* Communication link failure */ SQLS_ENTRY(20006, "08S01"); SQLS_ENTRY(20009, "08S01"); SQLS_ENTRY(20020, "08S01"); SQLS_ENTRY(20019, "24000"); /* Invalid cursor state */ SQLS_ENTRY(20014, "28000"); /* Invalid authorization specification */ SQLS_ENTRY(2400, "42000"); /* Syntax error or access violation */ SQLS_ENTRY(2401, "42000"); SQLS_ENTRY(2403, "42000"); SQLS_ENTRY(2404, "42000"); SQLS_ENTRY(2402, "S1000"); /* General error */ } if (p != NULL) return strdup(p); else return NULL; } char * tds_alloc_lookup_sqlstate(TDSSOCKET * tds, int msgno) { const char *p = NULL; char *q = NULL; if (TDS_IS_MSSQL(tds)) { switch (msgno) { /* MSSQL Server */ SQLS_ENTRY(3621,"01000"); SQLS_ENTRY(8153,"01003"); /* Null in aggregate */ SQLS_ENTRY(911, "08004"); /* Server rejected connection */ SQLS_ENTRY(512, "21000"); /* Subquery returns more than one value */ SQLS_ENTRY(213, "21S01"); /* Insert column list mismatch */ SQLS_ENTRY(109, "21S01"); SQLS_ENTRY(110, "21S01"); SQLS_ENTRY(1774,"21S02"); /* Ref column mismatch */ SQLS_ENTRY(8152,"22001"); /* String data would be truncated */ SQLS_ENTRY(5146,"22003"); /* Numeric value out of range */ SQLS_ENTRY(168, "22003"); /* Arithmetic overflow */ SQLS_ENTRY(220, "22003"); SQLS_ENTRY(232, "22003"); SQLS_ENTRY(234, "22003"); SQLS_ENTRY(236, "22003"); SQLS_ENTRY(238, "22003"); SQLS_ENTRY(244, "22003"); SQLS_ENTRY(246, "22003"); SQLS_ENTRY(248, "22003"); SQLS_ENTRY(519, "22003"); SQLS_ENTRY(520, "22003"); SQLS_ENTRY(521, "22003"); SQLS_ENTRY(522, "22003"); SQLS_ENTRY(523, "22003"); SQLS_ENTRY(524, "22003"); SQLS_ENTRY(1007,"22003"); SQLS_ENTRY(3606,"22003"); SQLS_ENTRY(8115,"22003"); SQLS_ENTRY(206, "22005"); /* Error in assignment */ SQLS_ENTRY(235, "22005"); SQLS_ENTRY(247, "22005"); SQLS_ENTRY(249, "22005"); SQLS_ENTRY(256, "22005"); SQLS_ENTRY(257, "22005"); SQLS_ENTRY(305, "22005"); SQLS_ENTRY(409, "22005"); SQLS_ENTRY(518, "22005"); SQLS_ENTRY(529, "22005"); SQLS_ENTRY(210, "22007"); /* Invalid datetime format */ SQLS_ENTRY(241, "22007"); SQLS_ENTRY(295, "22007"); SQLS_ENTRY(242, "22008"); /* Datetime out of range */ SQLS_ENTRY(296, "22008"); SQLS_ENTRY(298, "22008"); SQLS_ENTRY(535, "22008"); SQLS_ENTRY(542, "22008"); SQLS_ENTRY(517, "22008"); SQLS_ENTRY(3607, "22012"); /* Div by zero */ SQLS_ENTRY(8134, "22012"); SQLS_ENTRY(245, "22018"); /* Syntax error? */ SQLS_ENTRY(2627, "23000"); /* Constraint violation */ SQLS_ENTRY(515, "23000"); SQLS_ENTRY(233, "23000"); SQLS_ENTRY(273, "23000"); SQLS_ENTRY(530, "23000"); SQLS_ENTRY(2601,"23000"); SQLS_ENTRY(2615,"23000"); SQLS_ENTRY(2626,"23000"); SQLS_ENTRY(3604,"23000"); SQLS_ENTRY(3605,"23000"); SQLS_ENTRY(544, "23000"); SQLS_ENTRY(547, "23000"); SQLS_ENTRY(550, "23000"); SQLS_ENTRY(4415, "23000"); SQLS_ENTRY(1505, "23000"); SQLS_ENTRY(1508, "23000"); SQLS_ENTRY(3725, "23000"); SQLS_ENTRY(3726, "23000"); SQLS_ENTRY(4712, "23000"); SQLS_ENTRY(10055, "23000"); SQLS_ENTRY(10065, "23000"); SQLS_ENTRY(11011, "23000"); SQLS_ENTRY(11040, "23000"); SQLS_ENTRY(16999, "24000"); /* Invalid cursor state */ SQLS_ENTRY(16905, "24000"); SQLS_ENTRY(16917, "24000"); SQLS_ENTRY(16946, "24000"); SQLS_ENTRY(16950, "24000"); SQLS_ENTRY(266, "25000"); /* Invalid transaction state */ SQLS_ENTRY(277,"25000"); SQLS_ENTRY(611,"25000"); SQLS_ENTRY(3906,"25000"); SQLS_ENTRY(3908,"25000"); SQLS_ENTRY(6401,"25000"); SQLS_ENTRY(626, "25000"); SQLS_ENTRY(627, "25000"); SQLS_ENTRY(628, "25000"); SQLS_ENTRY(3902, "25000"); SQLS_ENTRY(3903, "25000"); SQLS_ENTRY(3916, "25000"); SQLS_ENTRY(3918, "25000"); SQLS_ENTRY(3919, "25000"); SQLS_ENTRY(3921, "25000"); SQLS_ENTRY(3922, "25000"); SQLS_ENTRY(3926, "25000"); SQLS_ENTRY(7969, "25000"); SQLS_ENTRY(8506, "25000"); SQLS_ENTRY(15626, "25000"); SQLS_ENTRY(18456, "28000"); /* Login failed? */ SQLS_ENTRY(6104, "37000"); /* Syntax error or access violation */ SQLS_ENTRY(8114, "37000"); SQLS_ENTRY(131, "37000"); SQLS_ENTRY(137, "37000"); SQLS_ENTRY(170, "37000"); SQLS_ENTRY(174, "37000"); SQLS_ENTRY(201, "37000"); SQLS_ENTRY(2812, "37000"); SQLS_ENTRY(2526, "37000"); SQLS_ENTRY(8144, "37000"); SQLS_ENTRY(17308, "42000"); /* Syntax/Access violation */ SQLS_ENTRY(17571, "42000"); SQLS_ENTRY(18002, "42000"); SQLS_ENTRY(229, "42000"); SQLS_ENTRY(230, "42000"); SQLS_ENTRY(262, "42000"); SQLS_ENTRY(2557, "42000"); SQLS_ENTRY(2571, "42000"); SQLS_ENTRY(2760, "42000"); SQLS_ENTRY(3110, "42000"); SQLS_ENTRY(3704, "42000"); SQLS_ENTRY(4613, "42000"); SQLS_ENTRY(4618, "42000"); SQLS_ENTRY(4834, "42000"); SQLS_ENTRY(5011, "42000"); SQLS_ENTRY(5116, "42000"); SQLS_ENTRY(5812, "42000"); SQLS_ENTRY(6004, "42000"); SQLS_ENTRY(6102, "42000"); SQLS_ENTRY(7956, "42000"); SQLS_ENTRY(11010, "42000"); SQLS_ENTRY(11045, "42000"); SQLS_ENTRY(14126, "42000"); SQLS_ENTRY(15247, "42000"); SQLS_ENTRY(15622, "42000"); SQLS_ENTRY(20604, "42000"); SQLS_ENTRY(21049, "42000"); SQLS_ENTRY(113, "42000"); SQLS_ENTRY(2714, "42S01"); /* Table or view already exists */ SQLS_ENTRY(208, "42S02"); /* Table or view not found */ SQLS_ENTRY(3701, "42S02"); SQLS_ENTRY(1913, "42S11"); /* Index already exists */ SQLS_ENTRY(15605, "42S11"); SQLS_ENTRY(307, "42S12"); /* Index not found */ SQLS_ENTRY(308, "42S12"); SQLS_ENTRY(10033, "42S12"); SQLS_ENTRY(15323, "42S12"); SQLS_ENTRY(18833, "42S12"); SQLS_ENTRY(4925, "42S21"); /* Column already exists */ SQLS_ENTRY(21255, "42S21"); SQLS_ENTRY(1911, "42S22"); /* Column not found */ SQLS_ENTRY(207, "42S22"); SQLS_ENTRY(4924, "42S22"); SQLS_ENTRY(4926, "42S22"); SQLS_ENTRY(15645, "42S22"); SQLS_ENTRY(21166, "42S22"); } } else { switch (msgno) { /* Sybase */ SQLS_ENTRY(3621, "01000"); SQLS_ENTRY(9501, "01003"); /* Null in aggregate */ SQLS_ENTRY(911, "08004"); /* Server rejected connection */ SQLS_ENTRY(512, "21000"); /* Subquery returns more than one value */ SQLS_ENTRY(213, "21S01"); /* Insert column list mismatch */ SQLS_ENTRY(109, "21S01"); SQLS_ENTRY(110, "21S01"); SQLS_ENTRY(1715, "21S02"); /* Ref column mismatch */ SQLS_ENTRY(9502, "22001"); /* String data would be truncated */ SQLS_ENTRY(220, "22003"); /* Arithmetic overflow */ SQLS_ENTRY(168, "22003"); SQLS_ENTRY(227, "22003"); SQLS_ENTRY(232, "22003"); SQLS_ENTRY(234, "22003"); SQLS_ENTRY(236, "22003"); SQLS_ENTRY(238, "22003"); SQLS_ENTRY(244, "22003"); SQLS_ENTRY(246, "22003"); SQLS_ENTRY(247, "22003"); SQLS_ENTRY(248, "22003"); SQLS_ENTRY(519, "22003"); SQLS_ENTRY(520, "22003"); SQLS_ENTRY(521, "22003"); SQLS_ENTRY(522, "22003"); SQLS_ENTRY(523, "22003"); SQLS_ENTRY(524, "22003"); SQLS_ENTRY(3606, "22003"); SQLS_ENTRY(206, "22005"); /* Error in assignment */ SQLS_ENTRY(235, "22005"); SQLS_ENTRY(249, "22005"); SQLS_ENTRY(256, "22005"); SQLS_ENTRY(305, "22005"); SQLS_ENTRY(409, "22005"); SQLS_ENTRY(518, "22005"); SQLS_ENTRY(529, "22005"); SQLS_ENTRY(535, "22008"); /* Datetime out of range */ SQLS_ENTRY(542, "22008"); SQLS_ENTRY(517, "22008"); SQLS_ENTRY(3607, "22012"); /* Div by zero */ SQLS_ENTRY(245, "22018"); /* Syntax error? */ SQLS_ENTRY(544, "23000"); /* Constraint violation */ SQLS_ENTRY(233, "23000"); SQLS_ENTRY(273, "23000"); SQLS_ENTRY(530, "23000"); SQLS_ENTRY(2601,"23000"); SQLS_ENTRY(2615,"23000"); SQLS_ENTRY(2626,"23000"); SQLS_ENTRY(3604,"23000"); SQLS_ENTRY(3605,"23000"); SQLS_ENTRY(545, "23000"); SQLS_ENTRY(546, "23000"); SQLS_ENTRY(547, "23000"); SQLS_ENTRY(548, "23000"); SQLS_ENTRY(549, "23000"); SQLS_ENTRY(550, "23000"); SQLS_ENTRY(1505, "23000"); SQLS_ENTRY(1508, "23000"); SQLS_ENTRY(565, "24000"); /* Invalid cursor state */ SQLS_ENTRY(558, "24000"); SQLS_ENTRY(559, "24000"); SQLS_ENTRY(6235, "24000"); SQLS_ENTRY(583, "24000"); SQLS_ENTRY(6259, "24000"); SQLS_ENTRY(6260, "24000"); SQLS_ENTRY(562, "24000"); SQLS_ENTRY(277, "25000"); /* Invalid transaction state */ SQLS_ENTRY(611,"25000"); SQLS_ENTRY(3906,"25000"); SQLS_ENTRY(3908,"25000"); SQLS_ENTRY(6401,"25000"); SQLS_ENTRY(627, "25000"); SQLS_ENTRY(628, "25000"); SQLS_ENTRY(641, "25000"); SQLS_ENTRY(642, "25000"); SQLS_ENTRY(1276, "25000"); SQLS_ENTRY(3902, "25000"); SQLS_ENTRY(3903, "25000"); SQLS_ENTRY(6104, "37000"); /* Syntax error or access violation */ SQLS_ENTRY(102, "37000"); SQLS_ENTRY(137, "37000"); SQLS_ENTRY(7327, "37000"); SQLS_ENTRY(201, "37000"); SQLS_ENTRY(257, "37000"); SQLS_ENTRY(2812, "37000"); SQLS_ENTRY(2526, "37000"); SQLS_ENTRY(11021, "37000"); SQLS_ENTRY(229, "42000"); /* Syntax/Access violation */ SQLS_ENTRY(230, "42000"); SQLS_ENTRY(262, "42000"); SQLS_ENTRY(4602, "42000"); SQLS_ENTRY(4603, "42000"); SQLS_ENTRY(4608, "42000"); SQLS_ENTRY(10306, "42000"); SQLS_ENTRY(10323, "42000"); SQLS_ENTRY(10330, "42000"); SQLS_ENTRY(10331, "42000"); SQLS_ENTRY(10332, "42000"); SQLS_ENTRY(11110, "42000"); SQLS_ENTRY(11113, "42000"); SQLS_ENTRY(11118, "42000"); SQLS_ENTRY(11121, "42000"); SQLS_ENTRY(17222, "42000"); SQLS_ENTRY(17223, "42000"); SQLS_ENTRY(18350, "42000"); SQLS_ENTRY(18351, "42000"); SQLS_ENTRY(113, "42000"); SQLS_ENTRY(2714, "42S01"); /* Table or view already exists */ SQLS_ENTRY(208, "42S02"); /* Table or view not found */ SQLS_ENTRY(3701, "42S02"); SQLS_ENTRY(1913, "42S11"); /* Index already exists */ SQLS_ENTRY(307, "42S12"); /* Index not found */ SQLS_ENTRY(7010, "42S12"); SQLS_ENTRY(18091, "42S12"); SQLS_ENTRY(1921, "42S21"); /* Column already exists */ SQLS_ENTRY(1720, "42S22"); /* Column not found */ SQLS_ENTRY(207, "42S22"); SQLS_ENTRY(4934, "42S22"); SQLS_ENTRY(18117, "42S22"); } } if (p != NULL && (q = strdup(p)) != NULL) { /* FIXME correct here ?? */ /* Convert known ODBC 3.x states listed above to 2.x */ if (memcmp(q, "42S", 3) == 0) memcpy(q, "S00", 3); return q; } return NULL; } BCPCOLDATA * tds_alloc_bcp_column_data(unsigned int column_size) { BCPCOLDATA *coldata; TEST_MALLOC(coldata, BCPCOLDATA); if (column_size > 4 * 1024) column_size = 4 * 1024; TEST_CALLOC(coldata->data, unsigned char, column_size); return coldata; Cleanup: tds_free_bcp_column_data(coldata); return NULL; } void tds_free_bcp_column_data(BCPCOLDATA * coldata) { if (!coldata) return; free(coldata->data); free(coldata); } TDSBCPINFO * tds_alloc_bcpinfo(void) { TDSBCPINFO *bcpinfo; TEST_MALLOC(bcpinfo, TDSBCPINFO); tds_dstr_init(&bcpinfo->tablename); return bcpinfo; Cleanup: return NULL; } void tds_deinit_bcpinfo(TDSBCPINFO *bcpinfo) { tds_dstr_free(&bcpinfo->tablename); TDS_ZERO_FREE(bcpinfo->insert_stmt); tds_free_results(bcpinfo->bindinfo); bcpinfo->bindinfo = NULL; } void tds_free_bcpinfo(TDSBCPINFO *bcpinfo) { if (bcpinfo) { tds_deinit_bcpinfo(bcpinfo); free(bcpinfo); } } /** * Reallocate a pointer and update it if success * \param pp pointer to pointer to be reallocated * \param new_size new size to be allocated * \return new pointer allocated, NULL on failure */ void * tds_realloc(void **pp, size_t new_size) { void *p; /* some implementation of malloc/realloc does not like size==0 */ if (!new_size) new_size = 1; /* use malloc if not allocated before, some implementation require it */ if (*pp) p = realloc(*pp, new_size); else p = malloc(new_size); /* update pointer only on success */ if (p) *pp = p; return p; } /** @} */ freetds-1.00.82/src/tds/token.c100644 025423 025423 00000257252 13203773221 0011710/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns * Copyright (C) 2005-2015 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /** * \file * \brief Contains all routines to get replies from server */ #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #include #if HAVE_MALLOC_H #include #endif /* HAVE_MALLOC_H */ #include #include #include #include #include #include #include #include "replacements.h" /** \cond HIDDEN_SYMBOLS */ #define USE_ICONV (tds->conn->use_iconv) #define TDS_GET_COLUMN_TYPE(col) do { \ TDS_TINYINT _tds_type = tds_get_byte(tds); \ if (!is_tds_type_valid(_tds_type)) \ return TDS_FAIL; \ tds_set_column_type(tds->conn, col, (TDS_SERVER_TYPE) _tds_type); \ } while(0) #define TDS_GET_COLUMN_INFO(tds, col) do { \ TDSRET _tds_rc = col->funcs->get_info(tds, col); \ if (TDS_FAILED(_tds_rc)) \ return _tds_rc; \ } while(0) /** \endcond */ static TDSRET tds_process_info(TDSSOCKET * tds, int marker); static TDSRET tds_process_compute_result(TDSSOCKET * tds); static TDSRET tds_process_compute_names(TDSSOCKET * tds); static TDSRET tds7_process_compute_result(TDSSOCKET * tds); static TDSRET tds5_process_result(TDSSOCKET * tds); static TDSRET tds_process_col_name(TDSSOCKET * tds); static TDSRET tds_process_col_fmt(TDSSOCKET * tds); static TDSRET tds_process_tabname(TDSSOCKET *tds); static TDSRET tds_process_colinfo(TDSSOCKET * tds, char **names, int num_names); static TDSRET tds_process_compute(TDSSOCKET * tds); static TDSRET tds_process_cursor_tokens(TDSSOCKET * tds); static TDSRET tds_process_row(TDSSOCKET * tds); static TDSRET tds_process_nbcrow(TDSSOCKET * tds); static TDSRET tds_process_featureextack(TDSSOCKET * tds); static TDSRET tds_process_param_result(TDSSOCKET * tds, TDSPARAMINFO ** info); static TDSRET tds7_process_result(TDSSOCKET * tds); static TDSDYNAMIC *tds_process_dynamic(TDSSOCKET * tds); static TDSRET tds_process_auth(TDSSOCKET * tds); static TDSRET tds_process_env_chg(TDSSOCKET * tds); static TDSRET tds_process_param_result_tokens(TDSSOCKET * tds); static TDSRET tds_process_params_result_token(TDSSOCKET * tds); static TDSRET tds_process_dyn_result(TDSSOCKET * tds); static TDSRET tds5_process_result2(TDSSOCKET * tds); static TDSRET tds5_process_dyn_result2(TDSSOCKET * tds); static TDSRET tds_process_default_tokens(TDSSOCKET * tds, int marker); static TDSRET tds5_process_optioncmd(TDSSOCKET * tds); static TDSRET tds_process_end(TDSSOCKET * tds, int marker, /*@out@*/ int *flags_parm); static TDSRET tds_get_data_info(TDSSOCKET * tds, TDSCOLUMN * curcol, int is_param); static /*@observer@*/ const char *tds_token_name(unsigned char marker); static void adjust_character_column_size(TDSSOCKET * tds, TDSCOLUMN * curcol); int determine_adjusted_size(const TDSICONV * char_conv, int size); static /*@observer@*/ const char *tds_pr_op(int op); static int tds_alloc_get_string(TDSSOCKET * tds, /*@special@*/ char **string, size_t len) /*allocates *string*/; /** * \ingroup libtds * \defgroup token Results processing * Handle tokens in packets. Many PDU (packets data unit) contain tokens. * (like result description, rows, data, errors and many other). */ /** * \addtogroup token * @{ */ /** * tds_process_default_tokens() is a catch all function that is called to * process tokens not known to other tds_process_* routines * @tds * @param marker Token type */ static TDSRET tds_process_default_tokens(TDSSOCKET * tds, int marker) { int tok_size; int done_flags; TDS_INT ret_status; TDS_CAPABILITY_TYPE *cap; CHECK_TDS_EXTRA(tds); tdsdump_log(TDS_DBG_FUNC, "tds_process_default_tokens() marker is %x(%s)\n", marker, tds_token_name(marker)); if (IS_TDSDEAD(tds)) { tdsdump_log(TDS_DBG_FUNC, "leaving tds_process_default_tokens() connection dead\n"); tds_close_socket(tds); return TDS_FAIL; } switch (marker) { case TDS_AUTH_TOKEN: return tds_process_auth(tds); break; case TDS_ENVCHANGE_TOKEN: return tds_process_env_chg(tds); break; case TDS_DONE_TOKEN: case TDS_DONEPROC_TOKEN: case TDS_DONEINPROC_TOKEN: return tds_process_end(tds, marker, &done_flags); break; case TDS_PROCID_TOKEN: tds_get_n(tds, NULL, 8); break; case TDS_RETURNSTATUS_TOKEN: ret_status = tds_get_int(tds); marker = tds_peek(tds); if (marker != TDS_PARAM_TOKEN && marker != TDS_DONEPROC_TOKEN && marker != TDS_DONE_TOKEN) break; tds->has_status = 1; tds->ret_status = ret_status; tdsdump_log(TDS_DBG_INFO1, "tds_process_default_tokens: return status is %d\n", tds->ret_status); break; case TDS_ERROR_TOKEN: case TDS_INFO_TOKEN: case TDS_EED_TOKEN: return tds_process_info(tds, marker); break; case TDS_CAPABILITY_TOKEN: tok_size = tds_get_usmallint(tds); cap = tds->conn->capabilities.types; memset(cap, 0, 2*sizeof(*cap)); cap[0].type = 1; cap[0].len = sizeof(cap[0].values); cap[1].type = 2; cap[1].len = sizeof(cap[1].values); while (tok_size > 1) { unsigned char type, size, *p; type = tds_get_byte(tds); size = tds_get_byte(tds); tok_size -= 2 + size; if (type != 1 && type != 2) { tds_get_n(tds, NULL, size); continue; } if (size > sizeof(cap->values)) { tds_get_n(tds, NULL, size - sizeof(cap->values)); size = sizeof(cap->values); } p = (unsigned char *) &cap[type]; if (tds_get_n(tds, p-size, size) == NULL) return TDS_FAIL; /* * Sybase 11.0 servers return the wrong length in the capability packet, * causing us to read past the done packet. */ if (tds->conn->product_version < TDS_SYB_VER(12, 0, 0) && type == 2) break; } break; /* PARAM_TOKEN can be returned inserting text in db, to return new timestamp */ case TDS_PARAM_TOKEN: tds_unget_byte(tds); return tds_process_param_result_tokens(tds); break; case TDS7_RESULT_TOKEN: return tds7_process_result(tds); break; case TDS_OPTIONCMD_TOKEN: return tds5_process_optioncmd(tds); break; case TDS_RESULT_TOKEN: return tds5_process_result(tds); break; case TDS_ROWFMT2_TOKEN: return tds5_process_result2(tds); break; case TDS_COLNAME_TOKEN: return tds_process_col_name(tds); break; case TDS_COLFMT_TOKEN: return tds_process_col_fmt(tds); break; case TDS_ROW_TOKEN: return tds_process_row(tds); break; case TDS5_PARAMFMT_TOKEN: /* store discarded parameters in param_info, not in old dynamic */ tds_release_cur_dyn(tds); return tds_process_dyn_result(tds); break; case TDS5_PARAMFMT2_TOKEN: tds_release_cur_dyn(tds); return tds5_process_dyn_result2(tds); break; case TDS5_PARAMS_TOKEN: /* save params */ return tds_process_params_result_token(tds); break; case TDS_CURINFO_TOKEN: return tds_process_cursor_tokens(tds); break; case TDS_CONTROL_FEATUREEXTACK_TOKEN: if (IS_TDS74_PLUS(tds->conn)) return tds_process_featureextack(tds); /* fall through */ case TDS5_DYNAMIC_TOKEN: case TDS_LOGINACK_TOKEN: case TDS_ORDERBY_TOKEN: tdsdump_log(TDS_DBG_WARN, "Eating %s token\n", tds_token_name(marker)); tds_get_n(tds, NULL, tds_get_usmallint(tds)); break; case TDS_MSG_TOKEN: tok_size = tds_get_byte(tds); if (tok_size >= 3) { tds_get_byte(tds); tds5_negotiate_set_msg_type(tds, tds->conn->authentication, tds_get_usmallint(tds)); tok_size -= 3; } tds_get_n(tds, NULL, tok_size); break; case TDS_TABNAME_TOKEN: /* used for FOR BROWSE query */ return tds_process_tabname(tds); break; case TDS_COLINFO_TOKEN: return tds_process_colinfo(tds, NULL, 0); break; case TDS_SESSIONSTATE_TOKEN: case TDS_ORDERBY2_TOKEN: tdsdump_log(TDS_DBG_WARN, "Eating %s token\n", tds_token_name(marker)); tds_get_n(tds, NULL, tds_get_uint(tds)); break; case TDS_NBC_ROW_TOKEN: return tds_process_nbcrow(tds); break; default: tds_close_socket(tds); tdserror(tds_get_ctx(tds), tds, TDSEBTOK, 0); tdsdump_log(TDS_DBG_ERROR, "Unknown marker: %d(%x)!!\n", marker, (unsigned char) marker); return TDS_FAIL; } return TDS_SUCCESS; } /** * tds_process_login_tokens() is called after sending the login packet * to the server. It returns the success or failure of the login * dependent on the protocol version. 4.2 sends an ACK token only when * successful, TDS 5.0 sends it always with a success byte within * @tds */ TDSRET tds_process_login_tokens(TDSSOCKET * tds) { TDSRET succeed = TDS_FAIL; int marker; unsigned int len; int memrc = 0; unsigned char ack; TDS_UINT product_version; CHECK_TDS_EXTRA(tds); tdsdump_log(TDS_DBG_FUNC, "tds_process_login_tokens()\n"); do { struct { unsigned char major, minor, tiny[2]; unsigned int reported; const char *name; } ver; marker = tds_get_byte(tds); tdsdump_log(TDS_DBG_FUNC, "looking for login token, got %x(%s)\n", marker, tds_token_name(marker)); switch (marker) { case TDS_LOGINACK_TOKEN: /* TODO function */ tds->conn->tds71rev1 = 0; len = tds_get_usmallint(tds); if (len < 10) return TDS_FAIL; ack = tds_get_byte(tds); ver.major = tds_get_byte(tds); ver.minor = tds_get_byte(tds); ver.tiny[0] = tds_get_byte(tds); ver.tiny[1] = tds_get_byte(tds); ver.reported = (ver.major << 24) | (ver.minor << 16) | (ver.tiny[0] << 8) | ver.tiny[1]; if (ver.reported == 0x07010000) tds->conn->tds71rev1 = 1; /* Log reported server product name, cf. MS-TDS LOGINACK documentation. */ switch(ver.reported) { case 0x07000000: ver.name = "7.0"; break; case 0x07010000: ver.name = "2000"; break; case 0x71000001: ver.name = "2000 SP1"; break; case 0x72090002: ver.name = "2005"; break; case 0x730A0003: ver.name = "2008 (no NBCROW or fSparseColumnSet)"; break; case 0x730B0003: ver.name = "2008"; break; default: ver.name = "unknown"; break; } tdsdump_log(TDS_DBG_FUNC, "server reports TDS version %x.%x.%x.%x\n", ver.major, ver.minor, ver.tiny[0], ver.tiny[1]); tdsdump_log(TDS_DBG_FUNC, "Product name for 0x%x is %s\n", ver.reported, ver.name); /* Get server product name. */ /* Ignore product name length; some servers seem to set it incorrectly. */ tds_get_byte(tds); product_version = 0; /* Compute product name length from packet length. */ len -= 10; free(tds->conn->product_name); if (ver.major >= 7u) { product_version = 0x80000000u; memrc += tds_alloc_get_string(tds, &tds->conn->product_name, len / 2); } else if (ver.major >= 5) { memrc += tds_alloc_get_string(tds, &tds->conn->product_name, len); } else { memrc += tds_alloc_get_string(tds, &tds->conn->product_name, len); if (tds->conn->product_name != NULL && strstr(tds->conn->product_name, "Microsoft") != NULL) product_version = 0x80000000u; } product_version |= ((TDS_UINT) tds_get_byte(tds)) << 24; product_version |= ((TDS_UINT) tds_get_byte(tds)) << 16; product_version |= ((TDS_UINT) tds_get_byte(tds)) << 8; product_version |= tds_get_byte(tds); /* * MSSQL 6.5 and 7.0 seem to return strange values for this * using TDS 4.2, something like 5F 06 32 FF for 6.50 */ if (ver.major == 4 && ver.minor == 2 && (product_version & 0xff0000ffu) == 0x5f0000ffu) product_version = ((product_version & 0xffff00u) | 0x800000u) << 8; tds->conn->product_version = product_version; tdsdump_log(TDS_DBG_FUNC, "Product version %lX\n", (unsigned long) product_version); /* * TDS 5.0 reports 5 on success 6 on failure * TDS 4.2 reports 1 on success and is not * present on failure */ if (ack == 5 || ack == 1) { succeed = TDS_SUCCESS; /* authentication is now useless */ if (tds->conn->authentication) { tds->conn->authentication->free(tds->conn, tds->conn->authentication); tds->conn->authentication = NULL; } } break; default: if (TDS_FAILED(tds_process_default_tokens(tds, marker))) return TDS_FAIL; break; } if (marker == TDS_DONE_TOKEN && IS_TDS50(tds->conn) && tds->conn->authentication) { TDSAUTHENTICATION *auth = tds->conn->authentication; if (TDS_SUCCEED(auth->handle_next(tds, auth, 0))) { marker = 0; continue; } } } while (marker != TDS_DONE_TOKEN); /* set the spid */ if (memrc == 0 && TDS_IS_MSSQL(tds)) tds->conn->spid = TDS_GET_A2BE(tds->in_buf+4); if (memrc != 0) succeed = TDS_FAIL; tdsdump_log(TDS_DBG_FUNC, "tds_process_login_tokens() returning %s\n", (succeed == TDS_SUCCESS)? "TDS_SUCCESS" : "TDS_FAIL"); return succeed; } /** * Process authentication token. * This token is only TDS 7.0+. * \tds */ static TDSRET tds_process_auth(TDSSOCKET * tds) { unsigned int pdu_size; CHECK_TDS_EXTRA(tds); #if ENABLE_EXTRA_CHECKS if (!IS_TDS7_PLUS(tds->conn)) tdsdump_log(TDS_DBG_ERROR, "Called auth on TDS version < 7\n"); #endif pdu_size = tds_get_usmallint(tds); tdsdump_log(TDS_DBG_INFO1, "TDS_AUTH_TOKEN PDU size %u\n", pdu_size); if (!tds->conn->authentication) return TDS_FAIL; return tds->conn->authentication->handle_next(tds, tds->conn->authentication, pdu_size); } /** * process all streams. * tds_process_tokens() is called after submitting a query with * tds_submit_query() and is responsible for calling the routines to * populate tds->res_info if appropriate (some query have no result sets) * @tds * @param result_type A pointer to an integer variable which * tds_process_tokens sets to indicate the current type of result. * @par * Values that indicate command status * * * * *
TDS_DONE_RESULTThe results of a command have been completely processed. * This command returned no rows.
TDS_DONEPROC_RESULTThe results of a command have been completely processed. * This command returned rows.
TDS_DONEINPROC_RESULTThe results of a command have been completely processed. * This command returned rows.
* Values that indicate results information is available * * * * * * * * * *
TDS_ROWFMT_RESULTRegular Data format informationtds->res_info now contains the result details ; tds->current_results now points to that data
TDS_COMPUTEFMT_ RESULTCompute data format informationtds->comp_info now contains the result data; tds->current_results now points to that data
TDS_DESCRIBE_RESULT
* Values that indicate data is available * * * * * * * * * * * * * * *
ValueMeaningInformation returned
TDS_ROW_RESULTRegular row results1 or more rows of regular data can now be retrieved
TDS_COMPUTE_RESULTCompute row resultsA single row of compute data can now be retrieved
TDS_PARAM_RESULTReturn parameter resultsparam_info or cur_dyn->params contain returned parameters
TDS_STATUS_RESULTStored procedure status resultstds->ret_status contain the returned code
* @param done_flags Flags contained in the TDS_DONE*_TOKEN readed * @param flag Flags to select token type to stop/return * @todo Complete TDS_DESCRIBE_RESULT description * @retval TDS_SUCCESS if a result set is available for processing. * @retval TDS_FAIL on error. * @retval TDS_NO_MORE_RESULTS if all results have been completely processed. * @retval anything returned by one of the many functions it calls. :-( */ TDSRET tds_process_tokens(TDSSOCKET *tds, TDS_INT *result_type, int *done_flags, unsigned flag) { int marker; TDSPARAMINFO *pinfo = NULL; TDSCOLUMN *curcol; TDSRET rc; TDS_INT8 saved_rows_affected = tds->rows_affected; TDS_INT ret_status; int cancel_seen = 0; unsigned return_flag = 0; /** \cond HIDDEN_SYMBOLS */ #define SET_RETURN(ret, f) do { \ *result_type = ret; \ return_flag = TDS_RETURN_##f | TDS_STOPAT_##f; \ if (flag & TDS_STOPAT_##f) {\ tds_unget_byte(tds); \ tdsdump_log(TDS_DBG_FUNC, "tds_process_tokens::SET_RETURN stopping on current token\n"); \ goto set_return_exit; \ } } while(0) /** \endcond */ CHECK_TDS_EXTRA(tds); tdsdump_log(TDS_DBG_FUNC, "tds_process_tokens(%p, %p, %p, 0x%x)\n", tds, result_type, done_flags, flag); if (tds->state == TDS_IDLE || tds->state == TDS_SENDING) { tdsdump_log(TDS_DBG_FUNC, "tds_process_tokens() state is COMPLETED\n"); *result_type = TDS_DONE_RESULT; return TDS_NO_MORE_RESULTS; } if (tds_set_state(tds, TDS_READING) != TDS_READING) return TDS_FAIL; rc = TDS_SUCCESS; for (;;) { marker = tds_get_byte(tds); tdsdump_log(TDS_DBG_INFO1, "processing result tokens. marker is %x(%s)\n", marker, tds_token_name(marker)); switch (marker) { case TDS7_RESULT_TOKEN: /* * If we're processing the results of a cursor fetch * from sql server we don't want to pass back the * TDS_ROWFMT_RESULT to the calling API */ if (tds->current_op != TDS_OP_CURSORFETCH) SET_RETURN(TDS_ROWFMT_RESULT, ROWFMT); rc = tds7_process_result(tds); if (TDS_FAILED(rc)) break; /* handle browse information (if present) */ marker = tds_get_byte(tds); if (marker != TDS_TABNAME_TOKEN) tds_unget_byte(tds); else rc = tds_process_tabname(tds); break; case TDS_RESULT_TOKEN: SET_RETURN(TDS_ROWFMT_RESULT, ROWFMT); rc = tds5_process_result(tds); break; case TDS_ROWFMT2_TOKEN: SET_RETURN(TDS_ROWFMT_RESULT, ROWFMT); rc = tds5_process_result2(tds); break; case TDS_COLNAME_TOKEN: rc = tds_process_col_name(tds); break; case TDS_COLFMT_TOKEN: SET_RETURN(TDS_ROWFMT_RESULT, ROWFMT); rc = tds_process_col_fmt(tds); if (TDS_FAILED(rc)) break; /* handle browse information (if present) */ marker = tds_get_byte(tds); if (marker != TDS_TABNAME_TOKEN) tds_unget_byte(tds); else rc = tds_process_tabname(tds); break; case TDS_PARAM_TOKEN: tds_unget_byte(tds); if (tds->current_op) { tdsdump_log(TDS_DBG_FUNC, "processing parameters for op %d\n", tds->current_op); while ((marker = tds_get_byte(tds)) == TDS_PARAM_TOKEN) { tdsdump_log(TDS_DBG_INFO1, "calling tds_process_param_result\n"); rc = tds_process_param_result(tds, &pinfo); if (TDS_FAILED(rc)) goto set_return_exit; } tds_unget_byte(tds); tdsdump_log(TDS_DBG_FUNC, "%d hidden return parameters\n", pinfo ? pinfo->num_cols : -1); if (pinfo && pinfo->num_cols > 0) { curcol = pinfo->columns[0]; if (tds->current_op == TDS_OP_CURSOROPEN && tds->cur_cursor) { TDSCURSOR *cursor = tds->cur_cursor; cursor->cursor_id = *(TDS_INT *) curcol->column_data; tdsdump_log(TDS_DBG_FUNC, "stored internal cursor id %d\n", cursor->cursor_id); cursor->srv_status &= ~(TDS_CUR_ISTAT_CLOSED|TDS_CUR_ISTAT_OPEN|TDS_CUR_ISTAT_DEALLOC); cursor->srv_status |= cursor->cursor_id ? TDS_CUR_ISTAT_OPEN : TDS_CUR_ISTAT_CLOSED|TDS_CUR_ISTAT_DEALLOC; } if ((tds->current_op == TDS_OP_PREPARE || tds->current_op == TDS_OP_PREPEXEC) && tds->cur_dyn && tds->cur_dyn->num_id == 0 && curcol->column_cur_size > 0) { tds->cur_dyn->num_id = *(TDS_INT *) curcol->column_data; } if (tds->current_op == TDS_OP_UNPREPARE) tds_dynamic_deallocated(tds->conn, tds->cur_dyn); } tds_free_param_results(pinfo); } else { SET_RETURN(TDS_PARAM_RESULT, PROC); rc = tds_process_param_result_tokens(tds); } break; case TDS_COMPUTE_NAMES_TOKEN: rc = tds_process_compute_names(tds); break; case TDS_COMPUTE_RESULT_TOKEN: SET_RETURN(TDS_COMPUTEFMT_RESULT, COMPUTEFMT); rc = tds_process_compute_result(tds); break; case TDS7_COMPUTE_RESULT_TOKEN: SET_RETURN(TDS_COMPUTEFMT_RESULT, COMPUTEFMT); rc = tds7_process_compute_result(tds); break; case TDS_ROW_TOKEN: case TDS_NBC_ROW_TOKEN: /* overstepped the mark... */ if (tds->cur_cursor) { tds_set_current_results(tds, tds->cur_cursor->res_info); tdsdump_log(TDS_DBG_INFO1, "tds_process_tokens(). set current_results to cursor->res_info\n"); } else { /* assure that we point to row, not to compute */ if (tds->res_info) tds_set_current_results(tds, tds->res_info); } /* I don't know when this it's false but it happened, also server can send garbage... */ if (tds->current_results) tds->current_results->rows_exist = 1; SET_RETURN(TDS_ROW_RESULT, ROW); switch (marker) { case TDS_ROW_TOKEN: rc = tds_process_row(tds); break; case TDS_NBC_ROW_TOKEN: rc = tds_process_nbcrow(tds); break; } break; case TDS_CMP_ROW_TOKEN: /* I don't know when this it's false but it happened, also server can send garbage... */ if (tds->res_info) tds->res_info->rows_exist = 1; SET_RETURN(TDS_COMPUTE_RESULT, COMPUTE); rc = tds_process_compute(tds); break; case TDS_RETURNSTATUS_TOKEN: ret_status = tds_get_int(tds); marker = tds_peek(tds); if (marker != TDS_PARAM_TOKEN && marker != TDS_DONEPROC_TOKEN && marker != TDS_DONE_TOKEN && marker != TDS5_PARAMFMT_TOKEN && marker != TDS5_PARAMFMT2_TOKEN) break; if (tds->current_op) { /* TODO perhaps we should use ret_status ?? */ } else { /* TODO optimize */ flag &= ~TDS_STOPAT_PROC; SET_RETURN(TDS_STATUS_RESULT, PROC); tds->has_status = 1; tds->ret_status = ret_status; tdsdump_log(TDS_DBG_FUNC, "tds_process_tokens: return status is %d\n", tds->ret_status); rc = TDS_SUCCESS; } break; case TDS5_DYNAMIC_TOKEN: /* process acknowledge dynamic */ tds_set_cur_dyn(tds, tds_process_dynamic(tds)); /* special case, prepared statement cannot be prepared */ if (!tds->cur_dyn || tds->cur_dyn->emulated) break; marker = tds_get_byte(tds); if (marker != TDS_EED_TOKEN) { tds_unget_byte(tds); break; } tds_process_info(tds, marker); if (!tds->cur_dyn || !tds->cur_dyn->emulated) break; marker = tds_get_byte(tds); if (marker != TDS_DONE_TOKEN) { tds_unget_byte(tds); break; } rc = tds_process_end(tds, marker, done_flags); if (done_flags) *done_flags &= ~TDS_DONE_ERROR; /* FIXME warning to macro expansion */ SET_RETURN(TDS_DONE_RESULT, DONE); break; case TDS5_PARAMFMT_TOKEN: SET_RETURN(TDS_DESCRIBE_RESULT, PARAMFMT); rc = tds_process_dyn_result(tds); break; case TDS5_PARAMFMT2_TOKEN: SET_RETURN(TDS_DESCRIBE_RESULT, PARAMFMT); rc = tds5_process_dyn_result2(tds); break; case TDS5_PARAMS_TOKEN: SET_RETURN(TDS_PARAM_RESULT, PROC); rc = tds_process_params_result_token(tds); break; case TDS_CURINFO_TOKEN: rc = tds_process_cursor_tokens(tds); break; case TDS_DONE_TOKEN: SET_RETURN(TDS_DONE_RESULT, DONE); rc = tds_process_end(tds, marker, done_flags); switch (tds->current_op) { case TDS_OP_DYN_DEALLOC: if (done_flags && (*done_flags & TDS_DONE_ERROR) == 0) tds_dynamic_deallocated(tds->conn, tds->cur_dyn); break; default: break; } break; case TDS_DONEPROC_TOKEN: SET_RETURN(TDS_DONEPROC_RESULT, DONE); rc = tds_process_end(tds, marker, done_flags); switch (tds->current_op) { default: break; case TDS_OP_CURSOROPEN: *result_type = TDS_DONE_RESULT; tds->rows_affected = saved_rows_affected; break; case TDS_OP_CURSORCLOSE: tdsdump_log(TDS_DBG_FUNC, "TDS_OP_CURSORCLOSE\n"); if (tds->cur_cursor) { TDSCURSOR *cursor = tds->cur_cursor; cursor->srv_status &= ~TDS_CUR_ISTAT_OPEN; cursor->srv_status |= TDS_CUR_ISTAT_CLOSED|TDS_CUR_ISTAT_DECLARED; if (cursor->status.dealloc == TDS_CURSOR_STATE_SENT) { tds_cursor_deallocated(tds->conn, cursor); } } *result_type = TDS_NO_MORE_RESULTS; rc = TDS_NO_MORE_RESULTS; break; case TDS_OP_UNPREPARE: if (done_flags && (*done_flags & TDS_DONE_ERROR) == 0) tds_dynamic_deallocated(tds->conn, tds->cur_dyn); *result_type = TDS_NO_MORE_RESULTS; rc = TDS_NO_MORE_RESULTS; break; case TDS_OP_CURSOR: case TDS_OP_CURSORPREPARE: case TDS_OP_CURSOREXECUTE: case TDS_OP_CURSORPREPEXEC: case TDS_OP_CURSORUNPREPARE: case TDS_OP_CURSORFETCH: case TDS_OP_CURSOROPTION: case TDS_OP_PREPEXECRPC: *result_type = TDS_NO_MORE_RESULTS; rc = TDS_NO_MORE_RESULTS; break; } break; case TDS_DONEINPROC_TOKEN: switch(tds->current_op) { case TDS_OP_CURSOROPEN: case TDS_OP_CURSORFETCH: case TDS_OP_PREPARE: case TDS_OP_CURSORCLOSE: rc = tds_process_end(tds, marker, done_flags); if (tds->rows_affected != TDS_NO_COUNT) { saved_rows_affected = tds->rows_affected; } break; default: SET_RETURN(TDS_DONEINPROC_RESULT, DONE); rc = tds_process_end(tds, marker, done_flags); break; } break; case TDS_ERROR_TOKEN: case TDS_INFO_TOKEN: case TDS_EED_TOKEN: SET_RETURN(TDS_MSG_RESULT, MSG); rc = tds_process_default_tokens(tds, marker); break; case TDS_ENVCHANGE_TOKEN: SET_RETURN(TDS_MSG_RESULT, ENV); rc = tds_process_default_tokens(tds, marker); break; default: SET_RETURN(TDS_OTHERS_RESULT, OTHERS); rc = tds_process_default_tokens(tds, marker); break; } set_return_exit: if (TDS_FAILED(rc)) { tds_set_state(tds, rc == TDS_CANCELLED ? TDS_PENDING : TDS_DEAD); return rc; } cancel_seen |= tds->in_cancel; if (cancel_seen) { /* during cancel handle all tokens */ flag = TDS_HANDLE_ALL; } if ((return_flag & flag) != 0) { tds_set_state(tds, TDS_PENDING); return rc; } if (tds->state == TDS_IDLE || tds->state == TDS_SENDING) return cancel_seen ? TDS_CANCELLED : TDS_NO_MORE_RESULTS; if (tds->state == TDS_DEAD) { /* TODO free all results ?? */ return TDS_FAIL; } } } /** * Process results for simple query as "SET TEXTSIZE" or "USE dbname" * If the statement returns results, beware they are discarded. * * This function was written to avoid direct calls to tds_process_default_tokens * (which caused problems such as ignoring query errors). * Results are read until idle state or severe failure (do not stop for * statement failure). * @return see tds_process_tokens for results (TDS_NO_MORE_RESULTS is never returned) */ TDSRET tds_process_simple_query(TDSSOCKET * tds) { TDS_INT res_type; TDS_INT done_flags; TDSRET rc; TDSRET ret = TDS_SUCCESS; CHECK_TDS_EXTRA(tds); while ((rc = tds_process_tokens(tds, &res_type, &done_flags, TDS_RETURN_DONE)) == TDS_SUCCESS) { switch (res_type) { case TDS_DONE_RESULT: case TDS_DONEPROC_RESULT: case TDS_DONEINPROC_RESULT: if ((done_flags & TDS_DONE_ERROR) != 0) ret = TDS_FAIL; break; default: break; } } if (TDS_FAILED(rc)) ret = rc; return ret; } /** * Holds list of names */ struct namelist { /** string name */ char *name; /** next element in the list */ struct namelist *next; }; /** * Frees list of names * \param head list head to free */ static void tds_free_namelist(struct namelist *head) { struct namelist *cur = head, *prev; while (cur != NULL) { prev = cur; cur = cur->next; free(prev->name); free(prev); } } /** * Reads list of names (usually table names) * \tds * \param remainder bytes left to read * \param p_head list head to return * \param large true if name length from network are 2 byte (usually 1) */ static int tds_read_namelist(TDSSOCKET * tds, int remainder, struct namelist **p_head, int large) { struct namelist *head = NULL, *cur = NULL, *prev; int num_names = 0; /* * this is a little messy...TDS 5.0 gives the number of columns * upfront, while in TDS 4.2, you're expected to figure it out * by the size of the message. So, I use a link list to get the * colum names and then allocate the result structure, copy * and delete the linked list */ while (remainder > 0) { TDS_USMALLINT namelen; prev = cur; if (!(cur = tds_new(struct namelist, 1))) { tds_free_namelist(head); return -1; } cur->next = NULL; if (prev) prev->next = cur; else head = cur; if (large) { namelen = tds_get_usmallint(tds); remainder -= 2; } else { namelen = tds_get_byte(tds); --remainder; } if (tds_alloc_get_string(tds, &cur->name, namelen) < 0) { tds_free_namelist(head); return -1; } remainder -= namelen; if (IS_TDS7_PLUS(tds->conn)) remainder -= namelen; num_names++; } *p_head = head; return num_names; } /** * tds_process_col_name() is one half of the result set under TDS 4.2 * it contains all the column names, a TDS_COLFMT_TOKEN should * immediately follow this token with the datatype/size information * This is a 4.2 only function * \tds */ static TDSRET tds_process_col_name(TDSSOCKET * tds) { int hdrsize; int col, num_names = 0; struct namelist *head = NULL, *cur = NULL; TDSCOLUMN *curcol; TDSRESULTINFO *info; CHECK_TDS_EXTRA(tds); hdrsize = tds_get_usmallint(tds); if ((num_names = tds_read_namelist(tds, hdrsize, &head, 0)) < 0) return TDS_FAIL; /* free results/computes/params etc... */ tds_free_all_results(tds); tds->rows_affected = TDS_NO_COUNT; if ((info = tds_alloc_results(num_names)) == NULL) goto memory_error; tds->res_info = info; tds_set_current_results(tds, info); cur = head; for (col = 0; col < num_names; ++col) { curcol = info->columns[col]; if (!tds_dstr_copy(&curcol->column_name, cur->name)) goto memory_error; cur = cur->next; } tds_free_namelist(head); return TDS_SUCCESS; memory_error: tds_free_namelist(head); return TDS_FAIL; } /** * tds_process_col_fmt() is the other half of result set processing * under TDS 4.2. It follows tds_process_col_name(). It contains all the * column type and size information. * This is a 4.2 only function * \tds */ static TDSRET tds_process_col_fmt(TDSSOCKET * tds) { unsigned int col; TDSCOLUMN *curcol; TDSRESULTINFO *info; TDS_USMALLINT flags; CHECK_TDS_EXTRA(tds); tds_get_usmallint(tds); /* hdrsize */ /* TODO use current_results instead of res_info ?? */ info = tds->res_info; if (!info || info->num_cols < 0) return TDS_FAIL; for (col = 0; col < info->num_cols; col++) { curcol = info->columns[col]; /* In Sybase all 4 byte are used for usertype, while mssql place 2 byte as usertype and 2 byte as flags */ if (TDS_IS_MSSQL(tds)) { curcol->column_usertype = tds_get_smallint(tds); flags = tds_get_usmallint(tds); curcol->column_nullable = flags & 0x01; curcol->column_writeable = (flags & 0x08) > 0; curcol->column_identity = (flags & 0x10) > 0; } else { curcol->column_usertype = tds_get_int(tds); } /* on with our regularly scheduled code (mlilback, 11/7/01) */ TDS_GET_COLUMN_TYPE(curcol); tdsdump_log(TDS_DBG_INFO1, "processing result. type = %d(%s), varint_size %d\n", curcol->column_type, tds_prtype(curcol->column_type), curcol->column_varint_size); TDS_GET_COLUMN_INFO(tds, curcol); /* Adjust column size according to client's encoding */ curcol->on_server.column_size = curcol->column_size; adjust_character_column_size(tds, curcol); } return tds_alloc_row(info); } /** * Reads table names for TDS 7.1+. * TDS 7.1+ return table names as an array of names * (so database.schema.owner.name as separate names) * \tds * \param remainder bytes left to read * \param p_head pointer to list head to return * \return number of element returned or -1 on error */ static int tds71_read_table_names(TDSSOCKET *tds, int remainder, struct namelist **p_head) { struct namelist *head = NULL, *cur = NULL, *prev; int num_names = 0; /* * this is a little messy...TDS 5.0 gives the number of columns * upfront, while in TDS 4.2, you're expected to figure it out * by the size of the message. So, I use a link list to get the * colum names and then allocate the result structure, copy * and delete the linked list */ while (remainder > 0) { int elements, i; size_t len; char *partials[4], *p; prev = cur; if (!(cur = tds_new(struct namelist, 1))) { tds_free_namelist(head); return -1; } cur->name = NULL; cur->next = NULL; if (prev) prev->next = cur; else head = cur; elements = tds_get_byte(tds); --remainder; if (elements <= 0 || elements > 4) { tds_free_namelist(head); return -1; } /* read partials IDs and compute full length */ len = 0; for (i = 0; i < elements; ++i) { TDS_USMALLINT namelen = tds_get_usmallint(tds); remainder -= 2 + 2 * namelen; if (tds_alloc_get_string(tds, &partials[i], namelen) < 0) { while (i > 0) free(partials[--i]); tds_free_namelist(head); return -1; } len += tds_quote_id(tds, NULL, partials[i], -1) + 1; } /* allocate full name */ p = tds_new(char, len); if (!p) { i = elements; while (i > 0) free(partials[--i]); tds_free_namelist(head); return -1; } /* compose names */ cur->name = p; for (i = 0; i < elements; ++i) { p += tds_quote_id(tds, p, partials[i], -1); *p++ = '.'; free(partials[i]); } *--p = 0; num_names++; } *p_head = head; return num_names; } /** * Process list of table from network. * This token is only TDS 4.2 * \tds */ static TDSRET tds_process_tabname(TDSSOCKET *tds) { struct namelist *head, *cur; int num_names, hdrsize, i; char **names; unsigned char marker; TDSRET rc; hdrsize = tds_get_usmallint(tds); /* different structure for tds7.1 */ /* hdrsize check is required for tds7.1 revision 1 (mssql without SPs) */ /* TODO change tds_version ?? */ if (IS_TDS71_PLUS(tds->conn) && (!IS_TDS71(tds->conn) || !tds->conn->tds71rev1)) num_names = tds71_read_table_names(tds, hdrsize, &head); else num_names = tds_read_namelist(tds, hdrsize, &head, 1); if (num_names <= 0) return TDS_FAIL; /* put in an array */ names = tds_new(char*, num_names); if (!names) { tds_free_namelist(head); return TDS_FAIL; } for (cur = head, i = 0; i < num_names; ++i, cur = cur->next) names[i] = cur->name; rc = TDS_SUCCESS; marker = tds_get_byte(tds); if (marker != TDS_COLINFO_TOKEN) tds_unget_byte(tds); else rc = tds_process_colinfo(tds, names, num_names); free(names); tds_free_namelist(head); return rc; } /** * Reads column information. * This token is only TDS 4.2 * \tds * \param[in] names table names * \param[in] num_names number of table names */ static TDSRET tds_process_colinfo(TDSSOCKET * tds, char **names, int num_names) { unsigned int hdrsize, l; TDSCOLUMN *curcol; TDSRESULTINFO *info; unsigned int bytes_read = 0; unsigned char col_info[3]; CHECK_TDS_EXTRA(tds); hdrsize = tds_get_usmallint(tds); info = tds->current_results; while (bytes_read < hdrsize) { tds_get_n(tds, col_info, 3); bytes_read += 3; curcol = NULL; if (info && col_info[0] > 0 && col_info[0] <= info->num_cols) curcol = info->columns[col_info[0] - 1]; if (curcol) { curcol->column_writeable = (col_info[2] & 0x4) == 0; curcol->column_key = (col_info[2] & 0x8) > 0; curcol->column_hidden = (col_info[2] & 0x10) > 0; if (names && col_info[1] > 0 && col_info[1] <= num_names) if (!tds_dstr_copy(&curcol->table_name, names[col_info[1] - 1])) return TDS_FAIL; } /* read real column name */ if (col_info[2] & 0x20) { l = tds_get_byte(tds); if (curcol) { tds_dstr_get(tds, &curcol->table_column_name, l); if (IS_TDS7_PLUS(tds->conn)) l *= 2; } else { if (IS_TDS7_PLUS(tds->conn)) l *= 2; /* discard silently */ tds_get_n(tds, NULL, l); } bytes_read += l + 1; } } return TDS_SUCCESS; } /** * process output parameters of a stored * procedure. This differs from regular row/compute results in that there * is no total number of parameters given, they just show up singly. * \tds * \param[out] pinfo output parameter. * Should point to a not allocated structure */ static TDSRET tds_process_param_result(TDSSOCKET * tds, TDSPARAMINFO ** pinfo) { TDSCOLUMN *curparam; TDSPARAMINFO *info; TDSRET token, rc; tdsdump_log(TDS_DBG_FUNC, "tds_process_param_result(%p, %p)\n", tds, pinfo); CHECK_TDS_EXTRA(tds); if (*pinfo) CHECK_PARAMINFO_EXTRA(*pinfo); /* TODO check if current_results is a param result */ /* limited to 64K but possible types are always smaller (not TEXT/IMAGE) */ tds_get_smallint(tds); /* header size */ if ((info = tds_alloc_param_result(*pinfo)) == NULL) return TDS_FAIL; *pinfo = info; curparam = info->columns[info->num_cols - 1]; /* * FIXME check support for tds7+ (seem to use same format of tds5 for data...) * perhaps varint_size can be 2 or collation can be specified ?? */ rc = tds_get_data_info(tds, curparam, 1); if (TDS_FAILED(rc)) return rc; curparam->column_cur_size = curparam->column_size; /* needed ?? */ if (tds_alloc_param_data(curparam) == NULL) return TDS_FAIL; token = curparam->funcs->get_data(tds, curparam); if (TDS_UNLIKELY(tds_write_dump)) tdsdump_col(curparam); /* * Real output parameters will either be unnamed or will have a valid * parameter name beginning with '@'. Ignore any other Spurious parameters * such as those returned from calls to writetext in the proc. */ if (!tds_dstr_isempty(&curparam->column_name) && tds_dstr_cstr(&curparam->column_name)[0] != '@') tds_free_param_result(*pinfo); return token; } /** * Process parameters from networks. * Read all consecutives paramaters, not a single one. * Parameters are then stored in tds->param_info or tds->cur_dyn->res_info * depending if we are reading cursor results or normal parameters. * \tds */ static TDSRET tds_process_param_result_tokens(TDSSOCKET * tds) { int marker; TDSPARAMINFO **pinfo; TDSRET rc; CHECK_TDS_EXTRA(tds); if (tds->cur_dyn) pinfo = &(tds->cur_dyn->res_info); else pinfo = &(tds->param_info); while ((marker = tds_get_byte(tds)) == TDS_PARAM_TOKEN) { rc = tds_process_param_result(tds, pinfo); if (TDS_FAILED(rc)) return rc; } if (!marker) { tdsdump_log(TDS_DBG_FUNC, "error: tds_process_param_result() returned TDS_FAIL\n"); return TDS_FAIL; } tds_set_current_results(tds, *pinfo); tds_unget_byte(tds); return TDS_SUCCESS; } /** * tds_process_params_result_token() processes params on TDS5. * \tds */ static TDSRET tds_process_params_result_token(TDSSOCKET * tds) { unsigned int i; TDSPARAMINFO *info; CHECK_TDS_EXTRA(tds); /* TODO check if current_results is a param result */ info = tds->current_results; if (!info) return TDS_FAIL; for (i = 0; i < info->num_cols; i++) { TDSCOLUMN *curcol = info->columns[i]; TDSRET rc = curcol->funcs->get_data(tds, curcol); if (TDS_FAILED(rc)) return rc; } return TDS_SUCCESS; } /** * tds_process_compute_result() processes compute result sets. These functions * need work but since they get little use, nobody has complained! * It is very similar to normal result sets. * \tds */ static TDSRET tds_process_compute_result(TDSSOCKET * tds) { unsigned int col, num_cols; TDS_TINYINT by_cols = 0; TDS_SMALLINT *cur_by_col; TDS_SMALLINT compute_id = 0; TDSCOLUMN *curcol; TDSCOMPUTEINFO *info = NULL; unsigned int i; CHECK_TDS_EXTRA(tds); tds_get_smallint(tds); /* header size*/ /* * Compute statement id which this relates to. * You can have more than one compute clause in a SQL statement */ compute_id = tds_get_smallint(tds); num_cols = tds_get_byte(tds); tdsdump_log(TDS_DBG_INFO1, "tds_process_compute_result(): compute_id %d for %d columns\n", compute_id, num_cols); for (i=0; i < tds->num_comp_info; ++i) { if (tds->comp_info[i]->computeid == compute_id) { info = tds->comp_info[i]; break; } } if (NULL == info) { tdsdump_log(TDS_DBG_FUNC, "logic error: compute_id (%d) from server not found in tds->comp_info\n", compute_id); return TDS_FAIL; } tdsdump_log(TDS_DBG_FUNC, "found computeid %d in tds->comp_info\n", info->computeid); tds_set_current_results(tds, info); tdsdump_log(TDS_DBG_INFO1, "processing compute result. num_cols = %d\n", num_cols); /* * Iterate over compute columns returned, * e.g. COMPUTE SUM(x), AVG(x) would return num_cols = 2. */ for (col = 0; col < num_cols; col++) { tdsdump_log(TDS_DBG_INFO1, "processing compute column %d\n", col); curcol = info->columns[col]; curcol->column_operator = tds_get_byte(tds); curcol->column_operand = tds_get_byte(tds); /* If no name has been defined for the compute column, use "max", "avg" etc. */ if (tds_dstr_isempty(&curcol->column_name)) if (!tds_dstr_copy(&curcol->column_name, tds_pr_op(curcol->column_operator))) return TDS_FAIL; /* User defined data type of the column */ curcol->column_usertype = tds_get_int(tds); TDS_GET_COLUMN_TYPE(curcol); TDS_GET_COLUMN_INFO(tds, curcol); tdsdump_log(TDS_DBG_INFO1, "compute column_size is %d\n", curcol->column_size); /* Adjust column size according to client's encoding */ curcol->on_server.column_size = curcol->column_size; /* TODO check if this column can have collation information associated */ adjust_character_column_size(tds, curcol); /* skip locale */ if (!IS_TDS42(tds->conn)) tds_get_n(tds, NULL, tds_get_byte(tds)); } by_cols = tds_get_byte(tds); tdsdump_log(TDS_DBG_INFO1, "processing tds compute result, by_cols = %d\n", by_cols); if (by_cols) { if ((info->bycolumns = tds_new0(TDS_SMALLINT, by_cols)) == NULL) return TDS_FAIL; } info->by_cols = by_cols; cur_by_col = info->bycolumns; for (col = 0; col < by_cols; col++) { *cur_by_col = tds_get_byte(tds); cur_by_col++; } return tds_alloc_compute_row(info); } /** * Reads data information from wire * \tds * \param curcol column where to store information */ static TDSRET tds7_get_data_info(TDSSOCKET * tds, TDSCOLUMN * curcol) { CHECK_TDS_EXTRA(tds); CHECK_COLUMN_EXTRA(curcol); /* User defined data type of the column */ curcol->column_usertype = IS_TDS72_PLUS(tds->conn) ? tds_get_int(tds) : tds_get_smallint(tds); curcol->column_flags = tds_get_smallint(tds); /* Flags */ curcol->column_nullable = curcol->column_flags & 0x01; curcol->column_writeable = (curcol->column_flags & 0x08) > 0; curcol->column_identity = (curcol->column_flags & 0x10) > 0; TDS_GET_COLUMN_TYPE(curcol); /* sets "cardinal" type */ curcol->column_timestamp = (curcol->column_type == SYBBINARY && curcol->column_usertype == TDS_UT_TIMESTAMP); TDS_GET_COLUMN_INFO(tds, curcol); /* Adjust column size according to client's encoding */ curcol->on_server.column_size = curcol->column_size; /* NOTE adjustements must be done after curcol->char_conv initialization */ adjust_character_column_size(tds, curcol); /* * under 7.0 lengths are number of characters not * number of bytes...tds_get_string handles this */ tds_dstr_get(tds, &curcol->column_name, tds_get_byte(tds)); tdsdump_log(TDS_DBG_INFO1, "tds7_get_data_info: \n" "\tcolname = %s\n" "\ttype = %d (%s)\n" "\tserver's type = %d (%s)\n" "\tcolumn_varint_size = %d\n" "\tcolumn_size = %d (%d on server)\n", tds_dstr_cstr(&curcol->column_name), curcol->column_type, tds_prtype(curcol->column_type), curcol->on_server.column_type, tds_prtype(curcol->on_server.column_type), curcol->column_varint_size, curcol->column_size, curcol->on_server.column_size); CHECK_COLUMN_EXTRA(curcol); return TDS_SUCCESS; } /** * tds7_process_result() is the TDS 7.0 result set processing routine. It * is responsible for populating the tds->res_info structure. * This is a TDS 7.0 only function * \tds */ static TDSRET tds7_process_result(TDSSOCKET * tds) { int col, num_cols; TDSRET result; TDSRESULTINFO *info; CHECK_TDS_EXTRA(tds); tdsdump_log(TDS_DBG_INFO1, "processing TDS7 result metadata.\n"); /* read number of columns and allocate the columns structure */ num_cols = tds_get_smallint(tds); /* This can be a DUMMY results token from a cursor fetch */ if (num_cols < 0) { tdsdump_log(TDS_DBG_INFO1, "no meta data\n"); return TDS_SUCCESS; } tds_free_all_results(tds); tds->rows_affected = TDS_NO_COUNT; if ((info = tds_alloc_results(num_cols)) == NULL) return TDS_FAIL; tds_set_current_results(tds, info); if (tds->cur_cursor) { tds_free_results(tds->cur_cursor->res_info); tds->cur_cursor->res_info = info; tdsdump_log(TDS_DBG_INFO1, "set current_results to cursor->res_info\n"); } else { tds->res_info = info; tdsdump_log(TDS_DBG_INFO1, "set current_results (%d column%s) to tds->res_info\n", num_cols, (num_cols==1? "":"s")); } /* * loop through the columns populating COLINFO struct from * server response */ tdsdump_log(TDS_DBG_INFO1, "setting up %d columns\n", num_cols); for (col = 0; col < num_cols; col++) { TDSCOLUMN *curcol = info->columns[col]; result = tds7_get_data_info(tds, curcol); if (TDS_FAILED(result)) return result; } if (num_cols > 0) { static const char dashes[31] = "------------------------------"; tdsdump_log(TDS_DBG_INFO1, " %-20s %-15s %-15s %-7s\n", "name", "size/wsize", "type/wtype", "utype"); tdsdump_log(TDS_DBG_INFO1, " %-20s %15s %15s %7s\n", dashes+10, dashes+30-15, dashes+30-15, dashes+30-7); } for (col = 0; col < num_cols; col++) { TDSCOLUMN *curcol = info->columns[col]; tdsdump_log(TDS_DBG_INFO1, " %-20s %7d/%-7d %7d/%-7d %7d\n", tds_dstr_cstr(&curcol->column_name), curcol->column_size, curcol->on_server.column_size, curcol->column_type, curcol->on_server.column_type, curcol->column_usertype); } /* all done now allocate a row for tds_process_row to use */ result = tds_alloc_row(info); CHECK_TDS_EXTRA(tds); return result; } /** * Reads data metadata from wire * \param tds state information for the socket and the TDS protocol * \param curcol column where to store information * \param is_param true if metadata are for a parameter (false for normal * column) */ static TDSRET tds_get_data_info(TDSSOCKET * tds, TDSCOLUMN * curcol, int is_param) { CHECK_TDS_EXTRA(tds); CHECK_COLUMN_EXTRA(curcol); tdsdump_log(TDS_DBG_INFO1, "tds_get_data_info(%p, %p, %d) %s\n", tds, curcol, is_param, is_param? "[for parameter]" : ""); tds_dstr_get(tds, &curcol->column_name, tds_get_byte(tds)); curcol->column_flags = tds_get_byte(tds); /* Flags */ if (!is_param) { /* TODO check if all flags are the same for all TDS versions */ if (IS_TDS50(tds->conn)) curcol->column_hidden = curcol->column_flags & 0x1; curcol->column_key = (curcol->column_flags & 0x2) > 1; curcol->column_writeable = (curcol->column_flags & 0x10) > 1; curcol->column_nullable = (curcol->column_flags & 0x20) > 1; curcol->column_identity = (curcol->column_flags & 0x40) > 1; #if 0 /**************************************** * NumParts=BYTE; (introduced in TDS 7.2) * PartName=US_VARCHAR;(introduced in TDS 7.2) * TableName=NumParts, {PartName}-; * ColName= HYPERLINK \l "B_VARCHAR_Def" B_VARCHAR; * ColumnData=UserType, Flags, [TableName], // ColName; * NoMetaData='0xFF', '0xFF'; */ enum column_flag_bits_according_to_microsoft { case_sensitive = 0x0001 , nullable = 0x0002 , updateable = 0x0004 , might_be_updateable = 0x0008 , identity = 0x0010 , computed = 0x0020 , us_reserved_odbc = 0x0040 | 0x0080 , is_fixed_len_clr_type = 0x0100 , is_hidden_browse_pk = 0x0200 , is_browse_pk = 0x0400 , might_be_nullable = 0x0800 }; /* TODO: implement members in TDSCOLUMN */ if (IS_TDS72_PLUS(tds->conn)) { curcol->is_computed = (curcol->column_flags & (1 << 4)) > 1; curcol->us_reserved_odbc1 = (curcol->column_flags & (1 << 5)) > 1; curcol->us_reserved_odbc2 = (curcol->column_flags & (1 << 6)) > 1; curcol->is_fixed_len_clr_type = (curcol->column_flags & (1 << 7)) > 1; } #endif } if (IS_TDS72_PLUS(tds->conn)) { tds_get_n(tds, NULL, 2); #if 0 /* TODO: implement members in TDSCOLUMN, values untested */ curcol->us_reserved1 = (curcol->column_flags & 0x01); curcol->us_reserved2 = (curcol->column_flags & 0x02); curcol->us_reserved3 = (curcol->column_flags & 0x04); curcol->us_reserved4 = (curcol->column_flags & 0x08); curcol->is_hidden = (curcol->column_flags & 0x10); curcol->is_key = (curcol->column_flags & 0x20); curcol->is_nullable_unknown = (curcol->column_flags & 0x40); #endif } curcol->column_usertype = tds_get_int(tds); TDS_GET_COLUMN_TYPE(curcol); tdsdump_log(TDS_DBG_INFO1, "processing result. type = %d(%s), varint_size %d\n", curcol->column_type, tds_prtype(curcol->column_type), curcol->column_varint_size); TDS_GET_COLUMN_INFO(tds, curcol); tdsdump_log(TDS_DBG_INFO1, "processing result. column_size %d\n", curcol->column_size); /* Adjust column size according to client's encoding */ curcol->on_server.column_size = curcol->column_size; adjust_character_column_size(tds, curcol); return TDS_SUCCESS; } /** * tds5_process_result() is the TDS 5.0 result set processing routine. * It is responsible for populating the tds->res_info structure. * This is a TDS 5.0 only function * \tds */ static TDSRET tds5_process_result(TDSSOCKET * tds) { unsigned int col, num_cols; TDSCOLUMN *curcol; TDSRESULTINFO *info; TDSRET rc; CHECK_TDS_EXTRA(tds); tds_free_all_results(tds); tds->rows_affected = TDS_NO_COUNT; tds_get_usmallint(tds); /* header size */ /* read number of columns and allocate the columns structure */ num_cols = tds_get_usmallint(tds); if ((info = tds_alloc_results(num_cols)) == NULL) return TDS_FAIL; tds_set_current_results(tds, info); if (tds->cur_cursor) tds->cur_cursor->res_info = info; else tds->res_info = info; /* * loop through the columns populating COLINFO struct from * server response */ for (col = 0; col < info->num_cols; col++) { curcol = info->columns[col]; rc = tds_get_data_info(tds, curcol, 0); if (TDS_FAILED(rc)) return rc; /* skip locale information */ /* NOTE do not put into tds_get_data_info, param do not have locale information */ tds_get_n(tds, NULL, tds_get_byte(tds)); } return tds_alloc_row(info); } /** * tds5_process_result2() is the new TDS 5.0 result set processing routine. * It is responsible for populating the tds->res_info structure. * This is a TDS 5.0 only function * \tds */ static TDSRET tds5_process_result2(TDSSOCKET * tds) { unsigned int colnamelen; TDS_USMALLINT col, num_cols; TDSCOLUMN *curcol; TDSRESULTINFO *info; CHECK_TDS_EXTRA(tds); tdsdump_log(TDS_DBG_INFO1, "tds5_process_result2\n"); /* * free previous resultset */ tds_free_all_results(tds); tds->rows_affected = TDS_NO_COUNT; /* * read length of packet (4 bytes) */ tds_get_uint(tds); /* read number of columns and allocate the columns structure */ num_cols = tds_get_usmallint(tds); if ((info = tds_alloc_results(num_cols)) == NULL) return TDS_FAIL; tds_set_current_results(tds, info); if (tds->cur_cursor) tds->cur_cursor->res_info = info; else tds->res_info = info; tdsdump_log(TDS_DBG_INFO1, "num_cols=%d\n", num_cols); /* TODO reuse some code... */ /* * loop through the columns populating COLINFO struct from * server response */ for (col = 0; col < info->num_cols; col++) { curcol = info->columns[col]; /* label */ tds_dstr_get(tds, &curcol->column_name, tds_get_byte(tds)); /* TODO save informations somewhere */ /* database */ colnamelen = tds_get_byte(tds); tds_get_n(tds, NULL, colnamelen); /* * tds_get_n(tds, curcol->catalog_name, colnamelen); * curcol->catalog_name[colnamelen] = '\0'; */ /* owner */ colnamelen = tds_get_byte(tds); tds_get_n(tds, NULL, colnamelen); /* * tds_get_n(tds, curcol->schema_name, colnamelen); * curcol->schema_name[colnamelen] = '\0'; */ /* table */ /* TODO use with owner and database */ tds_dstr_get(tds, &curcol->table_name, tds_get_byte(tds)); /* table column name */ tds_dstr_get(tds, &curcol->table_column_name, tds_get_byte(tds)); /* if label is empty, use the table column name */ if (tds_dstr_isempty(&curcol->column_name)) if (!tds_dstr_dup(&curcol->column_name, &curcol->table_column_name)) return TDS_FAIL; /* flags (4 bytes) */ curcol->column_flags = tds_get_int(tds); curcol->column_hidden = curcol->column_flags & 0x1; curcol->column_key = (curcol->column_flags & 0x2) > 1; curcol->column_writeable = (curcol->column_flags & 0x10) > 1; curcol->column_nullable = (curcol->column_flags & 0x20) > 1; curcol->column_identity = (curcol->column_flags & 0x40) > 1; curcol->column_usertype = tds_get_int(tds); TDS_GET_COLUMN_TYPE(curcol); TDS_GET_COLUMN_INFO(tds, curcol); /* Adjust column size according to client's encoding */ curcol->on_server.column_size = curcol->column_size; adjust_character_column_size(tds, curcol); /* discard Locale */ tds_get_n(tds, NULL, tds_get_byte(tds)); /* * Dump all information on this column */ tdsdump_log(TDS_DBG_INFO1, "col %d:\n", col); tdsdump_log(TDS_DBG_INFO1, "\tcolumn_name=[%s]\n", tds_dstr_cstr(&curcol->column_name)); /* tdsdump_log(TDS_DBG_INFO1, "\tcolumn_name=[%s]\n", curcol->column_colname); tdsdump_log(TDS_DBG_INFO1, "\tcatalog=[%s] schema=[%s] table=[%s]\n", curcol->catalog_name, curcol->schema_name, curcol->table_name, curcol->column_colname); */ tdsdump_log(TDS_DBG_INFO1, "\tflags=%x utype=%d type=%d varint=%d\n", curcol->column_flags, curcol->column_usertype, curcol->column_type, curcol->column_varint_size); tdsdump_log(TDS_DBG_INFO1, "\tcolsize=%d prec=%d scale=%d\n", curcol->column_size, curcol->column_prec, curcol->column_scale); } return tds_alloc_row(info); } /** * tds_process_compute() processes compute rows and places them in the row * buffer. * \tds */ static TDSRET tds_process_compute(TDSSOCKET * tds) { unsigned int i; TDSCOLUMN *curcol; TDSCOMPUTEINFO *info; TDS_INT id; CHECK_TDS_EXTRA(tds); id = tds_get_smallint(tds); tdsdump_log(TDS_DBG_INFO1, "tds_process_compute() found compute id %d\n", id); for (i = 0;; ++i) { if (i >= tds->num_comp_info) { tdsdump_log(TDS_DBG_INFO1, "tds_process_compute() FAIL: id exceeds bound (%d)\n", tds->num_comp_info); return TDS_FAIL; } info = tds->comp_info[i]; if (info->computeid == id) break; } tds_set_current_results(tds, info); for (i = 0; i < info->num_cols; i++) { curcol = info->columns[i]; if (TDS_FAILED(curcol->funcs->get_data(tds, curcol))) { tdsdump_log(TDS_DBG_INFO1, "tds_process_compute() FAIL: get_data() failed\n"); return TDS_FAIL; } } return TDS_SUCCESS; } /** * tds_process_row() processes rows and places them in the row buffer. * \tds */ static TDSRET tds_process_row(TDSSOCKET * tds) { unsigned int i; TDSCOLUMN *curcol; TDSRESULTINFO *info; CHECK_TDS_EXTRA(tds); info = tds->current_results; if (!info || info->num_cols <= 0) return TDS_FAIL; for (i = 0; i < info->num_cols; i++) { tdsdump_log(TDS_DBG_INFO1, "tds_process_row(): reading column %d \n", i); curcol = info->columns[i]; if (TDS_FAILED(curcol->funcs->get_data(tds, curcol))) return TDS_FAIL; } return TDS_SUCCESS; } /** * tds_process_nbcrow() processes rows and places them in the row buffer. */ static TDSRET tds_process_nbcrow(TDSSOCKET * tds) { unsigned int i; TDSCOLUMN *curcol; TDSRESULTINFO *info; char *nbcbuf; CHECK_TDS_EXTRA(tds); info = tds->current_results; if (!info || info->num_cols <= 0) return TDS_FAIL; nbcbuf = (char *) alloca((info->num_cols + 7) / 8); tds_get_n(tds, nbcbuf, (info->num_cols + 7) / 8); for (i = 0; i < info->num_cols; i++) { curcol = info->columns[i]; tdsdump_log(TDS_DBG_INFO1, "tds_process_nbcrow(): reading column %d \n", i); if (nbcbuf[i / 8] & (1 << (i % 8))) { curcol->column_cur_size = -1; } else { if (TDS_FAILED(curcol->funcs->get_data(tds, curcol))) return TDS_FAIL; } } return TDS_SUCCESS; } static TDSRET tds_process_featureextack(TDSSOCKET * tds) { CHECK_TDS_EXTRA(tds); /* TODO do something with it */ for (;;) { TDS_UINT data_len; TDS_TINYINT feature_id; feature_id = tds_get_byte(tds); if (feature_id == 0xff) break; data_len = tds_get_uint(tds); tds_get_n(tds, NULL, data_len); } return TDS_SUCCESS; } /** * Attempt to close all deferred closes (dynamics and cursors). * \tds */ static void tds_process_pending_closes(TDSSOCKET *tds) { TDSDYNAMIC *dyn, *next_dyn; TDSCURSOR *cursor, *next_cursor; int all_closed = 1; /* avoid recursions */ tds->conn->pending_close = 0; /* scan all cursors to close */ cursor = tds->conn->cursors; if (cursor) ++cursor->ref_count; for (; cursor; cursor = next_cursor) { next_cursor = cursor->next; if (next_cursor) ++next_cursor->ref_count; if (cursor->defer_close) { cursor->status.dealloc = TDS_CURSOR_STATE_REQUESTED; if (TDS_FAILED(tds_cursor_close(tds, cursor)) || TDS_FAILED(tds_process_simple_query(tds))) { all_closed = 0; } else { cursor->defer_close = 0; tds_cursor_dealloc(tds, cursor); } } tds_release_cursor(&cursor); } /* scan all dynamic to close */ dyn = tds->conn->dyns; if (dyn) ++dyn->ref_count; for (; dyn; dyn = next_dyn) { next_dyn = dyn->next; if (next_dyn) ++next_dyn->ref_count; if (dyn->defer_close) { if (TDS_FAILED(tds_submit_unprepare(tds, dyn)) || TDS_FAILED(tds_process_simple_query(tds))) { all_closed = 0; } else { dyn->defer_close = 0; } } tds_release_dynamic(&dyn); } if (!all_closed) tds->conn->pending_close = 1; } /** * tds_process_end() processes any of the DONE, DONEPROC, or DONEINPROC * tokens. * \param tds state information for the socket and the TDS protocol * \param marker TDS token number * \param flags_parm filled with bit flags (see TDS_DONE_ constants). * Is NULL nothing is returned */ static TDSRET tds_process_end(TDSSOCKET * tds, int marker, int *flags_parm) { int more_results, was_cancelled, error, done_count_valid; int tmp; TDS_INT8 rows_affected; CHECK_TDS_EXTRA(tds); tmp = tds_get_usmallint(tds); tds_get_smallint(tds); /* state */ more_results = (tmp & TDS_DONE_MORE_RESULTS) != 0; was_cancelled = (tmp & TDS_DONE_CANCELLED) != 0; error = (tmp & TDS_DONE_ERROR) != 0; done_count_valid = (tmp & TDS_DONE_COUNT) != 0; tdsdump_log(TDS_DBG_FUNC, "tds_process_end: more_results = %d\n" "\t\twas_cancelled = %d\n" "\t\terror = %d\n" "\t\tdone_count_valid = %d\n", more_results, was_cancelled, error, done_count_valid); tds->in_row = false; if (tds->res_info) { tds->res_info->more_results = more_results; /* FIXME this should not happen !!! */ if (tds->current_results == NULL) tds_set_current_results(tds, tds->res_info); } if (flags_parm) *flags_parm = tmp; rows_affected = IS_TDS72_PLUS(tds->conn) ? tds_get_int8(tds) : tds_get_int(tds); tdsdump_log(TDS_DBG_FUNC, " rows_affected = %" PRId64 "\n", rows_affected); if (was_cancelled || (!more_results && !tds->in_cancel)) { tdsdump_log(TDS_DBG_FUNC, "tds_process_end() state set to TDS_IDLE\n"); /* reset of in_cancel should must done before setting IDLE */ tds->in_cancel = 0; if (tds->bulk_query) { tds->out_flag = TDS_BULK; tds_set_state(tds, TDS_SENDING); tds->bulk_query = 0; } else { tds_set_state(tds, TDS_IDLE); if (tds->conn->pending_close) tds_process_pending_closes(tds); } } if (IS_TDSDEAD(tds)) return TDS_FAIL; /* * rows affected is in the tds struct because a query may affect rows but * have no result set. */ if (done_count_valid) tds->rows_affected = rows_affected; else tds->rows_affected = TDS_NO_COUNT; if (IS_TDSDEAD(tds)) return TDS_FAIL; return was_cancelled ? TDS_CANCELLED : TDS_SUCCESS; } static TDSRET tds_process_env_routing(TDSSOCKET * tds) { unsigned len = tds_get_usmallint(tds); if (len) { /* protocol (byte, 0 for ip) * port (short, not 0) * us_varchar */ TDS_TINYINT protocol; TDS_USMALLINT port, address_len; if (len < 5) return TDS_FAIL; protocol = tds_get_byte(tds); port = tds_get_usmallint(tds); address_len = tds_get_usmallint(tds); len -= 5; if (address_len * 2 < len) return TDS_FAIL; if (protocol == 0 && port != 0 && tds->login) { tds->login->routing_port = port; tds_dstr_get(tds, &tds->login->routing_address, address_len); tds_get_n(tds, NULL, len - 2 * address_len); } else { tds_get_n(tds, NULL, len); } } tds_get_n(tds, NULL, tds_get_usmallint(tds)); return TDS_SUCCESS; } /** * tds_process_env_chg() * when ever certain things change on the server, such as database, character * set, language, or block size. A environment change message is generated * There is no action taken currently, but certain functions at the CLI level * that return the name of the current database will need to use this. * \tds */ static TDSRET tds_process_env_chg(TDSSOCKET * tds) { unsigned int size; TDS_TINYINT type; char *oldval = NULL; char *newval = NULL; char **dest; int new_block_size; int lcid; int memrc = 0; CHECK_TDS_EXTRA(tds); size = tds_get_usmallint(tds); if (TDS_UNLIKELY(size < 1)) { tdsdump_log(TDS_DBG_ERROR, "Got invalid size %u\n", size); tds_close_socket(tds); return TDS_FAIL; } /* * this came in a patch, apparently someone saw an env message * that was different from what we are handling? -- brian * changed back because it won't handle multibyte chars -- 7.0 */ /* tds_get_n(tds,NULL,size); */ type = tds_get_byte(tds); /* * handle collate default change (if you change db or during login) * this environment is not a string so need different handles */ if (type == TDS_ENV_SQLCOLLATION) { /* save new collation */ size = tds_get_byte(tds); tdsdump_log(TDS_DBG_ERROR, "tds_process_env_chg(): %d bytes of collation data received\n", size); tdsdump_dump_buf(TDS_DBG_NETWORK, "tds->conn->collation was", tds->conn->collation, 5); memset(tds->conn->collation, 0, 5); if (size < 5) { tds_get_n(tds, tds->conn->collation, size); } else { tds_get_n(tds, tds->conn->collation, 5); tds_get_n(tds, NULL, size - 5); lcid = TDS_GET_UA4LE(tds->conn->collation) & 0xffffflu; tds7_srv_charset_changed(tds->conn, tds->conn->collation[4], lcid); } tdsdump_dump_buf(TDS_DBG_NETWORK, "tds->conn->collation now", tds->conn->collation, 5); /* discard old one */ tds_get_n(tds, NULL, tds_get_byte(tds)); return TDS_SUCCESS; } if (type == TDS_ENV_BEGINTRANS) { /* TODO check size */ size = tds_get_byte(tds); tds_get_n(tds, tds->conn->tds72_transaction, 8); tds_get_n(tds, NULL, tds_get_byte(tds)); return TDS_SUCCESS; } if (type == TDS_ENV_COMMITTRANS || type == TDS_ENV_ROLLBACKTRANS) { memset(tds->conn->tds72_transaction, 0, 8); tds_get_n(tds, NULL, tds_get_byte(tds)); tds_get_n(tds, NULL, tds_get_byte(tds)); return TDS_SUCCESS; } if (IS_TDS71_PLUS(tds->conn) && type == TDS_ENV_ROUTING) return tds_process_env_routing(tds); /* discard byte values, not still supported */ /* TODO support them */ if (IS_TDS71_PLUS(tds->conn) && type > TDS_ENV_PACKSIZE) { /* discard rest of the packet */ tds_get_n(tds, NULL, size - 1); return TDS_SUCCESS; } /* fetch the new value */ memrc += tds_alloc_get_string(tds, &newval, tds_get_byte(tds)); /* fetch the old value */ memrc += tds_alloc_get_string(tds, &oldval, tds_get_byte(tds)); if (memrc != 0) { free(newval); free(oldval); return TDS_FAIL; } dest = NULL; switch (type) { case TDS_ENV_PACKSIZE: new_block_size = atoi(newval); if (new_block_size >= 512) { tdsdump_log(TDS_DBG_INFO1, "changing block size from %s to %d\n", oldval, new_block_size); /* * Is possible to have a shrink if server limits packet * size more than what we specified */ /* Reallocate buffer if possible (strange values from server or out of memory) use older buffer */ tds_realloc_socket(tds, new_block_size); } break; case TDS_ENV_DATABASE: dest = &tds->conn->env.database; break; case TDS_ENV_LANG: dest = &tds->conn->env.language; break; case TDS_ENV_CHARSET: tdsdump_log(TDS_DBG_FUNC, "server indicated charset change to \"%s\"\n", newval); dest = &tds->conn->env.charset; tds_srv_charset_changed(tds->conn, newval); break; } if (tds->env_chg_func) { (*(tds->env_chg_func)) (tds, type, oldval, newval); } free(oldval); if (newval) { if (dest) { free(*dest); *dest = newval; } else free(newval); } return TDS_SUCCESS; } /** * tds_process_info() is called for INFO, ERR, or EED tokens and is responsible * for calling the CLI's message handling routine * \returns TDS_SUCCESS if informational, TDS_FAIL if error. */ static TDSRET tds_process_info(TDSSOCKET * tds, int marker) { int rc; unsigned int len_sqlstate; int has_eed = 0; TDSMESSAGE msg; CHECK_TDS_EXTRA(tds); if (!tds->in_row) tds_free_all_results(tds); /* make sure message has been freed */ memset(&msg, 0, sizeof(TDSMESSAGE)); /* packet length */ tds_get_smallint(tds); /* message number */ msg.msgno = tds_get_int(tds); /* msg state */ msg.state = tds_get_byte(tds); /* msg level */ msg.severity = tds_get_byte(tds); /* determine if msg or error */ switch (marker) { case TDS_EED_TOKEN: if (msg.severity <= 10) msg.priv_msg_type = 0; else msg.priv_msg_type = 1; /* read SQL state */ len_sqlstate = tds_get_byte(tds); msg.sql_state = tds_new(char, len_sqlstate + 1); if (!msg.sql_state) { tds_free_msg(&msg); return TDS_FAIL; } tds_get_n(tds, msg.sql_state, len_sqlstate); msg.sql_state[len_sqlstate] = '\0'; /* do a better mapping using native errors */ if (strcmp(msg.sql_state, "ZZZZZ") == 0) TDS_ZERO_FREE(msg.sql_state); /* if has_eed = 1, extended error data follows */ has_eed = tds_get_byte(tds); /* junk status and transaction state */ tds_get_smallint(tds); break; case TDS_INFO_TOKEN: msg.priv_msg_type = 0; break; case TDS_ERROR_TOKEN: msg.priv_msg_type = 1; break; default: tdsdump_log(TDS_DBG_ERROR, "tds_process_info() called with unknown marker '%d'!\n", (int) marker); tds_free_msg(&msg); return TDS_FAIL; } tdsdump_log(TDS_DBG_ERROR, "tds_process_info() reading message %d from server\n", msg.msgno); rc = 0; /* the message */ rc += tds_alloc_get_string(tds, &msg.message, tds_get_usmallint(tds)); /* server name */ rc += tds_alloc_get_string(tds, &msg.server, tds_get_byte(tds)); if ((!msg.server || !msg.server[0]) && tds->login) { TDS_ZERO_FREE(msg.server); if (-1 == asprintf(&msg.server, "[%s]", tds_dstr_cstr(&tds->login->server_name))) { tdsdump_log(TDS_DBG_ERROR, "out of memory (%d), %s\n", errno, strerror(errno)); return TDS_FAIL; } } /* stored proc name if available */ rc += tds_alloc_get_string(tds, &msg.proc_name, tds_get_byte(tds)); /* line number in the sql statement where the problem occured */ msg.line_number = IS_TDS72_PLUS(tds->conn) ? tds_get_int(tds) : tds_get_smallint(tds); /* * If the server doesen't provide an sqlstate, map one via server native errors * I'm assuming there is not a protocol I'm missing to fetch these from the server? * I know sybase has an sqlstate column in it's sysmessages table, mssql doesn't and * TDS_EED_TOKEN is not being called for me. */ if (msg.sql_state == NULL) msg.sql_state = tds_alloc_lookup_sqlstate(tds, msg.msgno); /* In case extended error data is sent, we just try to discard it */ if (has_eed == 1) { int next_marker; for (;;) { switch (next_marker = tds_get_byte(tds)) { case TDS5_PARAMFMT_TOKEN: case TDS5_PARAMFMT2_TOKEN: case TDS5_PARAMS_TOKEN: if (TDS_FAILED(tds_process_default_tokens(tds, next_marker))) --rc; continue; } break; } tds_unget_byte(tds); } /* * call the msg_handler that was set by an upper layer * (dblib, ctlib or some other one). Call it with the pointer to * the "parent" structure. */ if (rc != 0) { tds_free_msg(&msg); return TDS_FAIL; } /* special case, */ if (marker == TDS_EED_TOKEN && tds->cur_dyn && !TDS_IS_MSSQL(tds) && msg.msgno == 2782) { /* we must emulate prepare */ tds->cur_dyn->emulated = 1; tds_dynamic_deallocated(tds->conn, tds->cur_dyn); } else if (marker == TDS_INFO_TOKEN && msg.msgno == 16954 && TDS_IS_MSSQL(tds) && tds->current_op == TDS_OP_CURSOROPEN && tds->cur_cursor) { /* here mssql say "Executing SQL directly; no cursor." opening cursor */ } else { if (tds_get_ctx(tds)->msg_handler) { tdsdump_log(TDS_DBG_ERROR, "tds_process_info() calling client msg handler\n"); tds_get_ctx(tds)->msg_handler(tds_get_ctx(tds), tds, &msg); } else if (msg.msgno) { tdsdump_log(TDS_DBG_WARN, "Msg %d, Severity %d, State %d, Server %s, Line %d\n%s\n", msg.msgno, msg.severity , msg.state, msg.server, msg.line_number, msg.message); } } if (!tds->conn->server) { tds->conn->server = msg.server; msg.server = NULL; } tds_free_msg(&msg); tdsdump_log(TDS_DBG_ERROR, "tds_process_info() returning TDS_SUCCESS\n"); return TDS_SUCCESS; } /** * Reads a string from wire in a new allocated buffer * \tds * \param string output string * \param len length of string to read * \returns 0 for success, -1 on error. */ static int tds_alloc_get_string(TDSSOCKET * tds, char **string, size_t len) { char *s; size_t out_len; CHECK_TDS_EXTRA(tds); /* assure sufficient space for every conversion */ s = tds_new(char, len * 4 + 1); out_len = tds_get_string(tds, len, s, len * 4); if (!s) { *string = NULL; return -1; } s = (char*) realloc(s, out_len + 1); s[out_len] = '\0'; *string = s; return 0; } /** * \remarks Process the incoming token stream until it finds * an end token (DONE, DONEPROC, DONEINPROC) with the cancel flag set. * At that point the connection should be ready to handle a new query. * \tds */ TDSRET tds_process_cancel(TDSSOCKET * tds) { CHECK_TDS_EXTRA(tds); /* silly cases, nothing to do */ if (!tds->in_cancel) return TDS_SUCCESS; /* TODO handle cancellation sending data */ if (tds->state != TDS_PENDING) return TDS_SUCCESS; /* TODO support TDS5 cancel, wait for cancel packet first, then wait for done */ for (;;) { TDS_INT result_type; switch (tds_process_tokens(tds, &result_type, NULL, 0)) { case TDS_FAIL: return TDS_FAIL; case TDS_CANCELLED: case TDS_SUCCESS: case TDS_NO_MORE_RESULTS: return TDS_SUCCESS; } } } /** * Finds a dynamic given string id * \return dynamic or NULL is not found * \param conn state information for the socket and the TDS protocol * \param id dynamic id to search */ TDSDYNAMIC * tds_lookup_dynamic(TDSCONNECTION * conn, const char *id) { TDSDYNAMIC *curr; CHECK_CONN_EXTRA(conn); for (curr = conn->dyns; curr != NULL; curr = curr->next) { if (!strcmp(curr->id, id)) return curr; } return NULL; } /** * tds_process_dynamic() * finds the element of the dyns array for the id * \tds * \return allocated dynamic or NULL on failure. */ static TDSDYNAMIC * tds_process_dynamic(TDSSOCKET * tds) { unsigned int token_sz; unsigned char type; TDS_TINYINT id_len, drain = 0; char id[TDS_MAX_DYNID_LEN + 1]; CHECK_TDS_EXTRA(tds); token_sz = tds_get_usmallint(tds); type = tds_get_byte(tds); tds_get_byte(tds); /* status */ /* handle only acknowledge */ if (type != TDS_DYN_ACK) { tdsdump_log(TDS_DBG_ERROR, "Unrecognized TDS5_DYN type %x\n", type); tds_get_n(tds, NULL, token_sz - 2); return NULL; } id_len = tds_get_byte(tds); if (id_len > TDS_MAX_DYNID_LEN) { drain = id_len - TDS_MAX_DYNID_LEN; id_len = TDS_MAX_DYNID_LEN; } id_len = tds_get_string(tds, id_len, id, TDS_MAX_DYNID_LEN); id[id_len] = '\0'; if (drain) { tds_get_n(tds, NULL, drain); } return tds_lookup_dynamic(tds->conn, id); } /** * Process results from dynamic. * \tds */ static TDSRET tds_process_dyn_result(TDSSOCKET * tds) { unsigned int col, num_cols; TDSCOLUMN *curcol; TDSPARAMINFO *info; TDSDYNAMIC *dyn; TDSRET rc; CHECK_TDS_EXTRA(tds); tds_get_usmallint(tds); /* header size */ num_cols = tds_get_usmallint(tds); /* read number of columns and allocate the columns structure */ if ((info = tds_alloc_results(num_cols)) == NULL) return TDS_FAIL; if (tds->cur_dyn) { dyn = tds->cur_dyn; tds_free_param_results(dyn->res_info); dyn->res_info = info; } else { tds_free_param_results(tds->param_info); tds->param_info = info; } tds_set_current_results(tds, info); for (col = 0; col < info->num_cols; col++) { curcol = info->columns[col]; rc = tds_get_data_info(tds, curcol, 1); if (TDS_FAILED(rc)) return rc; /* skip locale information */ tds_get_n(tds, NULL, tds_get_byte(tds)); } return tds_alloc_row(info); } /** * Process new TDS 5.0 token for describing output parameters * \tds */ static TDSRET tds5_process_dyn_result2(TDSSOCKET * tds) { unsigned int col, num_cols; TDSCOLUMN *curcol; TDSPARAMINFO *info; TDSDYNAMIC *dyn; CHECK_TDS_EXTRA(tds); tds_get_uint(tds); /* header size */ num_cols = tds_get_usmallint(tds); /* read number of columns and allocate the columns structure */ if ((info = tds_alloc_results(num_cols)) == NULL) return TDS_FAIL; if (tds->cur_dyn) { dyn = tds->cur_dyn; tds_free_param_results(dyn->res_info); dyn->res_info = info; } else { tds_free_param_results(tds->param_info); tds->param_info = info; } tds_set_current_results(tds, info); for (col = 0; col < info->num_cols; col++) { curcol = info->columns[col]; /* TODO reuse tds_get_data_info code, sligthly different */ /* column name */ tds_dstr_get(tds, &curcol->column_name, tds_get_byte(tds)); /* column status */ curcol->column_flags = tds_get_int(tds); curcol->column_nullable = (curcol->column_flags & 0x20) > 0; /* user type */ curcol->column_usertype = tds_get_int(tds); /* column type */ TDS_GET_COLUMN_TYPE(curcol); TDS_GET_COLUMN_INFO(tds, curcol); /* Adjust column size according to client's encoding */ curcol->on_server.column_size = curcol->column_size; adjust_character_column_size(tds, curcol); /* discard Locale */ tds_get_n(tds, NULL, tds_get_byte(tds)); tdsdump_log(TDS_DBG_INFO1, "elem %d:\n", col); tdsdump_log(TDS_DBG_INFO1, "\tcolumn_name=[%s]\n", tds_dstr_cstr(&curcol->column_name)); tdsdump_log(TDS_DBG_INFO1, "\tflags=%x utype=%d type=%d varint=%d\n", curcol->column_flags, curcol->column_usertype, curcol->column_type, curcol->column_varint_size); tdsdump_log(TDS_DBG_INFO1, "\tcolsize=%d prec=%d scale=%d\n", curcol->column_size, curcol->column_prec, curcol->column_scale); } return tds_alloc_row(info); } /** * tds_get_token_size() returns the size of a fixed length token * used by tds_process_cancel() to determine how to read past a token * \param marker token type. */ int tds_get_token_size(int marker) { /* TODO finish */ switch (marker) { case TDS_DONE_TOKEN: case TDS_DONEPROC_TOKEN: case TDS_DONEINPROC_TOKEN: return 8; case TDS_RETURNSTATUS_TOKEN: return 4; case TDS_PROCID_TOKEN: return 8; default: return 0; } } /** * tds_process_compute_names() processes compute result sets. * \tds */ static TDSRET tds_process_compute_names(TDSSOCKET * tds) { int hdrsize; int num_cols = 0; TDS_USMALLINT compute_id = 0; TDSCOMPUTEINFO *info; int col; struct namelist *head = NULL, *cur; CHECK_TDS_EXTRA(tds); hdrsize = tds_get_usmallint(tds); tdsdump_log(TDS_DBG_INFO1, "processing tds5 compute names. hdrsize = %d\n", hdrsize); /* * compute statement id which this relates * to. You can have more than one compute * statement in a SQL statement */ compute_id = tds_get_usmallint(tds); if ((num_cols = tds_read_namelist(tds, hdrsize - 2, &head, 0)) <= 0) return TDS_FAIL; tdsdump_log(TDS_DBG_INFO1, "processing tds5 compute names. num_cols = %d\n", num_cols); if ((tds->comp_info = tds_alloc_compute_results(tds, num_cols, 0)) == NULL) goto memory_error; tdsdump_log(TDS_DBG_INFO1, "processing tds5 compute names. num_comp_info = %d\n", tds->num_comp_info); info = tds->comp_info[tds->num_comp_info - 1]; tds_set_current_results(tds, info); info->computeid = compute_id; cur = head; for (col = 0; col < num_cols; col++) { TDSCOLUMN *curcol = info->columns[col]; if (!tds_dstr_copy(&curcol->column_name, cur->name)) goto memory_error; cur = cur->next; } tds_free_namelist(head); return TDS_SUCCESS; memory_error: tds_free_namelist(head); return TDS_FAIL; } /** * tds7_process_compute_result() processes compute result sets for TDS 7/8. * They is are very similar to normal result sets. * \tds */ static TDSRET tds7_process_compute_result(TDSSOCKET * tds) { unsigned int col, num_cols; TDS_TINYINT by_cols; TDS_SMALLINT *cur_by_col; TDS_USMALLINT compute_id; TDSCOLUMN *curcol; TDSCOMPUTEINFO *info; TDSRET rc; CHECK_TDS_EXTRA(tds); /* compute without result should never happens */ if (!tds->res_info) return TDS_FAIL; /* * number of compute columns returned - so * COMPUTE SUM(x), AVG(x)... would return * num_cols = 2 */ num_cols = tds_get_usmallint(tds); tdsdump_log(TDS_DBG_INFO1, "processing tds7 compute result. num_cols = %u\n", num_cols); /* * compute statement id which this relates * to. You can have more than one compute * statement in a SQL statement */ compute_id = tds_get_usmallint(tds); tdsdump_log(TDS_DBG_INFO1, "processing tds7 compute result. compute_id = %u\n", compute_id); /* * number of "by" columns in compute - so * COMPUTE SUM(x) BY a, b, c would return * by_cols = 3 */ by_cols = tds_get_byte(tds); tdsdump_log(TDS_DBG_INFO1, "processing tds7 compute result. by_cols = %d\n", by_cols); if ((tds->comp_info = tds_alloc_compute_results(tds, num_cols, by_cols)) == NULL) return TDS_FAIL; tdsdump_log(TDS_DBG_INFO1, "processing tds7 compute result. num_comp_info = %d\n", tds->num_comp_info); info = tds->comp_info[tds->num_comp_info - 1]; tds_set_current_results(tds, info); tdsdump_log(TDS_DBG_INFO1, "processing tds7 compute result. point 0\n"); info->computeid = compute_id; /* * the by columns are a list of the column * numbers in the select statement */ cur_by_col = info->bycolumns; for (col = 0; col < by_cols; col++) { *cur_by_col = tds_get_smallint(tds); cur_by_col++; } tdsdump_log(TDS_DBG_INFO1, "processing tds7 compute result. point 1\n"); for (col = 0; col < num_cols; col++) { tdsdump_log(TDS_DBG_INFO1, "processing tds7 compute result. point 2\n"); curcol = info->columns[col]; curcol->column_operator = tds_get_byte(tds); curcol->column_operand = tds_get_smallint(tds); rc = tds7_get_data_info(tds, curcol); if (TDS_FAILED(rc)) return rc; if (tds_dstr_isempty(&curcol->column_name)) if (!tds_dstr_copy(&curcol->column_name, tds_pr_op(curcol->column_operator))) return TDS_FAIL; } /* all done now allocate a row for tds_process_row to use */ tdsdump_log(TDS_DBG_INFO1, "processing tds7 compute result. point 5 \n"); return tds_alloc_compute_row(info); } /** * Reads cursor command results. * This contains status of cursors. * \tds */ static TDSRET tds_process_cursor_tokens(TDSSOCKET * tds) { TDS_USMALLINT hdrsize; TDS_INT cursor_id; TDS_TINYINT namelen; TDS_USMALLINT cursor_status; TDSCURSOR *cursor; CHECK_TDS_EXTRA(tds); hdrsize = tds_get_usmallint(tds); cursor_id = tds_get_int(tds); hdrsize -= sizeof(TDS_INT); if (cursor_id == 0){ namelen = tds_get_byte(tds); hdrsize -= 1; /* discard name */ tds_get_n(tds, NULL, namelen); hdrsize -= namelen; } tds_get_byte(tds); /* cursor command */ cursor_status = tds_get_usmallint(tds); hdrsize -= 3; if (hdrsize == sizeof(TDS_INT)) tds_get_int(tds); /* row count TODO useless ?? */ if (tds->cur_cursor) { cursor = tds->cur_cursor; cursor->cursor_id = cursor_id; cursor->srv_status = cursor_status; if ((cursor_status & TDS_CUR_ISTAT_DEALLOC) != 0) tds_cursor_deallocated(tds->conn, cursor); } return TDS_SUCCESS; } /** * Process option cmd results. * This token is available only on TDS 5.0 (Sybase). * \tds */ static TDSRET tds5_process_optioncmd(TDSSOCKET * tds) { TDS_INT command; TDS_TINYINT option; TDS_TINYINT argsize; TDS_INT arg; CHECK_TDS_EXTRA(tds); tdsdump_log(TDS_DBG_INFO1, "tds5_process_optioncmd()\n"); if (!IS_TDS50(tds->conn)) return TDS_FAIL; tds_get_usmallint(tds); /* length */ command = tds_get_byte(tds); option = tds_get_byte(tds); argsize = tds_get_byte(tds); switch (argsize) { case 0: arg = 0; break; case 1: arg = tds_get_byte(tds); break; case 4: arg = tds_get_int(tds); break; default: tdsdump_log(TDS_DBG_INFO1, "oops: cannot process option %d of size %d\n", option, argsize); /* ignore argument */ tds_get_n(tds, NULL, argsize); return TDS_FAIL; } tdsdump_log(TDS_DBG_INFO1, "received option %d value %d\n", option, arg); if (command != TDS_OPT_INFO) return TDS_FAIL; tds->option_value = arg; return TDS_SUCCESS; } /** * Returns string representation for a given operation * \param op operation code * \return string representation. Empty if not found. */ static const char * tds_pr_op(int op) { /** \cond HIDDEN_SYMBOLS */ #define TYPE(con, s) case con: return s; break /** \endcond */ switch (op) { TYPE(SYBAOPAVG, "avg"); TYPE(SYBAOPAVGU, "avg"); TYPE(SYBAOPCNT, "count"); TYPE(SYBAOPCNTU, "count"); TYPE(SYBAOPMAX, "max"); TYPE(SYBAOPMIN, "min"); TYPE(SYBAOPSUM, "sum"); TYPE(SYBAOPSUMU, "sum"); TYPE(SYBAOPCHECKSUM_AGG, "checksum_agg"); TYPE(SYBAOPCNT_BIG, "count"); TYPE(SYBAOPSTDEV, "stdevp"); TYPE(SYBAOPSTDEVP, "stdevp"); TYPE(SYBAOPVAR, "var"); TYPE(SYBAOPVARP, "varp"); default: break; } return ""; #undef TYPE } /** * Returns string representation of the given type. * \param type data type * \return type as string. Empty if not found. */ const char * tds_prtype(int type) { /** \cond HIDDEN_SYMBOLS */ #define TYPE(con, s) case con: return s; break /** \endcond */ switch (type) { TYPE(SYBAOPAVG, "avg"); TYPE(SYBAOPCNT, "count"); TYPE(SYBAOPMAX, "max"); TYPE(SYBAOPMIN, "min"); TYPE(SYBAOPSUM, "sum"); TYPE(SYBBINARY, "binary"); TYPE(SYBLONGBINARY, "longbinary"); TYPE(SYBBIT, "bit"); TYPE(SYBBITN, "bit-null"); TYPE(SYBCHAR, "char"); TYPE(SYBDATETIME4, "smalldatetime"); TYPE(SYBDATETIME, "datetime"); TYPE(SYBDATETIMN, "datetime-null"); TYPE(SYBDECIMAL, "decimal"); TYPE(SYBFLT8, "float"); TYPE(SYBFLTN, "float-null"); TYPE(SYBIMAGE, "image"); TYPE(SYBINT1, "tinyint"); TYPE(SYBINT2, "smallint"); TYPE(SYBINT4, "int"); TYPE(SYBINT8, "bigint"); TYPE(SYBUINT1, "unsigned tinyint"); TYPE(SYBUINT2, "unsigned smallint"); TYPE(SYBUINT4, "unsigned int"); TYPE(SYBUINT8, "unsigned bigint"); TYPE(SYBINTN, "integer-null"); TYPE(SYBMONEY4, "smallmoney"); TYPE(SYBMONEY, "money"); TYPE(SYBMONEYN, "money-null"); TYPE(SYBNTEXT, "UCS-2 text"); TYPE(SYBNVARCHAR, "UCS-2 varchar"); TYPE(SYBNUMERIC, "numeric"); TYPE(SYBREAL, "real"); TYPE(SYBTEXT, "text"); TYPE(SYBUNIQUE, "uniqueidentifier"); TYPE(SYBVARBINARY, "varbinary"); TYPE(SYBVARCHAR, "varchar"); TYPE(SYBVARIANT, "variant"); TYPE(SYBVOID, "void"); TYPE(XSYBBINARY, "xbinary"); TYPE(XSYBCHAR, "xchar"); TYPE(XSYBNCHAR, "x UCS-2 char"); TYPE(XSYBNVARCHAR, "x UCS-2 varchar"); TYPE(XSYBVARBINARY, "xvarbinary"); TYPE(XSYBVARCHAR, "xvarchar"); TYPE(SYBMSXML, "xml"); TYPE(SYBMSDATE, "date"); TYPE(SYBMSTIME, "time"); TYPE(SYBMSDATETIME2, "datetime2"); TYPE(SYBMSDATETIMEOFFSET, "datetimeoffset"); TYPE(SYBDATE, "date"); TYPE(SYBTIME, "time"); TYPE(SYB5BIGTIME, "bigtime"); TYPE(SYB5BIGDATETIME, "bigdatetime"); default: break; } return ""; #undef TYPE } /** * Returns string representation for a given token type * \param marker token type * \return string representation. Empty if not token not valid. */ static const char * tds_token_name(unsigned char marker) { switch (marker) { case TDS5_PARAMFMT2_TOKEN: return "TDS5_PARAMFMT2"; case TDS_ORDERBY2_TOKEN: return "ORDERBY2"; case TDS_ROWFMT2_TOKEN: return "ROWFMT2"; case TDS_LOGOUT_TOKEN: return "LOGOUT"; case TDS_RETURNSTATUS_TOKEN: return "RETURNSTATUS"; case TDS_PROCID_TOKEN: return "PROCID"; case TDS7_RESULT_TOKEN: return "TDS7_RESULT"; case TDS_CURINFO_TOKEN: return "TDS_CURINFO"; case TDS7_COMPUTE_RESULT_TOKEN: return "TDS7_COMPUTE_RESULT"; case TDS_COLNAME_TOKEN: return "COLNAME"; case TDS_COLFMT_TOKEN: return "COLFMT"; case TDS_DYNAMIC2_TOKEN: return "DYNAMIC2"; case TDS_TABNAME_TOKEN: return "TABNAME"; case TDS_COLINFO_TOKEN: return "COLINFO"; case TDS_COMPUTE_NAMES_TOKEN: return "COMPUTE_NAMES"; case TDS_COMPUTE_RESULT_TOKEN: return "COMPUTE_RESULT"; case TDS_ORDERBY_TOKEN: return "ORDERBY"; case TDS_ERROR_TOKEN: return "ERROR"; case TDS_INFO_TOKEN: return "INFO"; case TDS_PARAM_TOKEN: return "PARAM"; case TDS_LOGINACK_TOKEN: return "LOGINACK"; case TDS_CONTROL_FEATUREEXTACK_TOKEN: return "CONTROL/FEATUREEXTACK"; case TDS_ROW_TOKEN: return "ROW"; case TDS_NBC_ROW_TOKEN: return "NBC_ROW"; case TDS_CMP_ROW_TOKEN: return "CMP_ROW"; case TDS5_PARAMS_TOKEN: return "TDS5_PARAMS"; case TDS_CAPABILITY_TOKEN: return "CAPABILITY"; case TDS_ENVCHANGE_TOKEN: return "ENVCHANGE"; case TDS_SESSIONSTATE_TOKEN: return "SESSIONSTATE"; case TDS_EED_TOKEN: return "EED"; case TDS_DBRPC_TOKEN: return "DBRPC"; case TDS5_DYNAMIC_TOKEN: return "TDS5_DYNAMIC"; case TDS5_PARAMFMT_TOKEN: return "TDS5_PARAMFMT"; case TDS_AUTH_TOKEN: return "AUTH"; case TDS_RESULT_TOKEN: return "RESULT"; case TDS_DONE_TOKEN: return "DONE"; case TDS_DONEPROC_TOKEN: return "DONEPROC"; case TDS_DONEINPROC_TOKEN: return "DONEINPROC"; case TDS_MSG_TOKEN: return "MSG"; default: break; } return ""; } /** * Adjust column size according to client's encoding * \tds * \param curcol column to adjust */ static void adjust_character_column_size(TDSSOCKET * tds, TDSCOLUMN * curcol) { CHECK_TDS_EXTRA(tds); CHECK_COLUMN_EXTRA(curcol); if (is_unicode_type(curcol->on_server.column_type)) curcol->char_conv = tds->conn->char_convs[client2ucs2]; /* Sybase UNI(VAR)CHAR fields are transmitted via SYBLONGBINARY and in UTF-16 */ if (curcol->on_server.column_type == SYBLONGBINARY && ( curcol->column_usertype == USER_UNICHAR_TYPE || curcol->column_usertype == USER_UNIVARCHAR_TYPE)) { #ifdef WORDS_BIGENDIAN static const char sybase_utf[] = "UTF-16BE"; #else static const char sybase_utf[] = "UTF-16LE"; #endif curcol->char_conv = tds_iconv_get(tds->conn, tds->conn->char_convs[client2ucs2]->from.charset.name, sybase_utf); /* fallback to UCS-2LE */ /* FIXME should be useless. Does not works always */ if (!curcol->char_conv) curcol->char_conv = tds->conn->char_convs[client2ucs2]; } /* FIXME: and sybase ?? */ if (!curcol->char_conv && IS_TDS7_PLUS(tds->conn) && is_ascii_type(curcol->on_server.column_type)) curcol->char_conv = tds->conn->char_convs[client2server_chardata]; if (!USE_ICONV || !curcol->char_conv) return; curcol->on_server.column_size = curcol->column_size; curcol->column_size = determine_adjusted_size(curcol->char_conv, curcol->column_size); tdsdump_log(TDS_DBG_INFO1, "adjust_character_column_size:\n" "\tServer charset: %s\n" "\tServer column_size: %d\n" "\tClient charset: %s\n" "\tClient column_size: %d\n", curcol->char_conv->to.charset.name, curcol->on_server.column_size, curcol->char_conv->from.charset.name, curcol->column_size); } /** * Allow for maximum possible size of converted data, * while being careful about integer division truncation. * All character data pass through iconv. It doesn't matter if the server side * is Unicode or not; even Latin1 text need conversion if, * for example, the client is UTF-8. * \param char_conv conversion structure * \param size unconverted byte size * \return maximum size for converted string */ int determine_adjusted_size(const TDSICONV * char_conv, int size) { if (!char_conv) return size; /* avoid possible overflow */ if (size >= 0x10000000) return 0x7fffffff; size *= char_conv->from.charset.max_bytes_per_char; if (size % char_conv->to.charset.min_bytes_per_char) size += char_conv->to.charset.min_bytes_per_char; size /= char_conv->to.charset.min_bytes_per_char; return size; } /** @} */ freetds-1.00.82/src/tds/util.c100644 025423 025423 00000032446 12717145107 0011546/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #include #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #ifdef _WIN32 #include #endif #include #include #include /** * Set state of TDS connection, with logging and checking. * \param tds state information for the socket and the TDS protocol * \param state the new state of the connection, cf. TDS_STATE. * \return the new state, which might not be \a state. */ TDS_STATE tds_set_state(TDSSOCKET * tds, TDS_STATE state) { TDS_STATE prior_state; static const char state_names[][8] = { "IDLE", "WRITING", "SENDING", "PENDING", "READING", "DEAD" }; assert(state < TDS_VECTOR_SIZE(state_names)); assert(tds->state < TDS_VECTOR_SIZE(state_names)); prior_state = tds->state; if (state == prior_state) return state; switch(state) { case TDS_PENDING: if (prior_state == TDS_READING || prior_state == TDS_WRITING) { tds->state = TDS_PENDING; tds_mutex_unlock(&tds->wire_mtx); break; } tdsdump_log(TDS_DBG_ERROR, "logic error: cannot change query state from %s to %s\n", state_names[prior_state], state_names[state]); break; case TDS_READING: /* transition to READING are valid only from PENDING */ if (tds_mutex_trylock(&tds->wire_mtx)) return tds->state; if (tds->state != TDS_PENDING) { tds_mutex_unlock(&tds->wire_mtx); tdsdump_log(TDS_DBG_ERROR, "logic error: cannot change query state from %s to %s\n", state_names[prior_state], state_names[state]); break; } tds->state = state; break; case TDS_SENDING: if (prior_state != TDS_READING && prior_state != TDS_WRITING) { tdsdump_log(TDS_DBG_ERROR, "logic error: cannot change query state from %s to %s\n", state_names[prior_state], state_names[state]); break; } if (tds->state == TDS_READING) { /* TODO check this code, copied from tds_submit_prepare */ tds_free_all_results(tds); tds->rows_affected = TDS_NO_COUNT; tds_release_cursor(&tds->cur_cursor); tds_release_cur_dyn(tds); tds->current_op = TDS_OP_NONE; } tds_mutex_unlock(&tds->wire_mtx); tds->state = state; break; case TDS_IDLE: if (prior_state == TDS_DEAD && TDS_IS_SOCKET_INVALID(tds_get_s(tds))) { tdsdump_log(TDS_DBG_ERROR, "logic error: cannot change query state from %s to %s\n", state_names[prior_state], state_names[state]); break; } case TDS_DEAD: if (prior_state == TDS_READING || prior_state == TDS_WRITING) tds_mutex_unlock(&tds->wire_mtx); tds->state = state; break; case TDS_WRITING: CHECK_TDS_EXTRA(tds); if (tds_mutex_trylock(&tds->wire_mtx)) return tds->state; if (tds->state == TDS_DEAD) { tds_mutex_unlock(&tds->wire_mtx); tdsdump_log(TDS_DBG_ERROR, "logic error: cannot change query state from %s to %s\n", state_names[prior_state], state_names[state]); tdserror(tds_get_ctx(tds), tds, TDSEWRIT, 0); break; } else if (tds->state != TDS_IDLE && tds->state != TDS_SENDING) { tds_mutex_unlock(&tds->wire_mtx); tdsdump_log(TDS_DBG_ERROR, "logic error: cannot change query state from %s to %s\n", state_names[prior_state], state_names[state]); tdserror(tds_get_ctx(tds), tds, TDSERPND, 0); break; } if (tds->state == TDS_IDLE) { /* TODO check this code, copied from tds_submit_prepare */ tds_free_all_results(tds); tds->rows_affected = TDS_NO_COUNT; tds_release_cursor(&tds->cur_cursor); tds_release_cur_dyn(tds); tds->current_op = TDS_OP_NONE; } tds->state = state; break; default: assert(0); break; } state = tds->state; tdsdump_log(TDS_DBG_ERROR, "Changed query state from %s to %s\n", state_names[prior_state], state_names[state]); CHECK_TDS_EXTRA(tds); return state; } void tds_swap_bytes(void *buf, int bytes) { unsigned char tmp, *begin, *last; begin = (unsigned char *) buf; last = begin + bytes; while (begin < --last) { tmp = *last; *last = *begin; *begin++ = tmp; } } /* not used by FreeTDS, uncomment if needed */ #ifdef ENABLE_DEVELOPING unsigned int tds_gettime_ms(void) { #ifdef _WIN32 return GetTickCount(); #elif defined(HAVE_GETHRTIME) return (unsigned int) (gethrtime() / 1000000u); #elif defined(HAVE_CLOCK_GETTIME) && defined(TDS_GETTIMEMILLI_CONST) struct timespec ts; clock_gettime(TDS_GETTIMEMILLI_CONST, &ts); return (unsigned int) (ts.tv_sec * 1000u + ts.tv_nsec / 1000000u); #elif defined(HAVE_GETTIMEOFDAY) struct timeval tv; gettimeofday(&tv, NULL); return (unsigned int) (tv.tv_sec * 1000u + tv.tv_usec / 1000u); #else #error How to implement tds_gettime_ms ?? #endif } #endif /* * Call the client library's error handler */ #define EXINFO 1 #define EXUSER 2 #define EXNONFATAL 3 #define EXCONVERSION 4 #define EXSERVER 5 #define EXTIME 6 #define EXPROGRAM 7 #define EXRESOURCE 8 #define EXCOMM 9 #define EXFATAL 10 #define EXCONSISTENCY 11 typedef struct tds_error_message { TDSERRNO msgno; int severity; const char *msgtext; } TDS_ERROR_MESSAGE; static const TDS_ERROR_MESSAGE tds_error_messages[] = { { TDSEICONVIU, EXCONVERSION, "Buffer exhausted converting characters from client into server's character set" } , { TDSEICONVAVAIL, EXCONVERSION, "Character set conversion is not available between client character set '%.*s' and " "server character set '%.*s'" } , { TDSEICONVO, EXCONVERSION, "Error converting characters into server's character set. Some character(s) could " "not be converted" } , { TDSEICONVI, EXCONVERSION, "Some character(s) could not be converted into client's character set. " "Unconverted bytes were changed to question marks ('?')" } , { TDSEICONV2BIG, EXCONVERSION, "Some character(s) could not be converted into client's character set" } , { TDSEPORTINSTANCE, EXUSER, "Both port and instance specified" } , { TDSERPND, EXPROGRAM, "Attempt to initiate a new Adaptive Server operation with results pending" } , { TDSEBTOK, EXCOMM, "Bad token from the server: Datastream processing out of sync" } , { TDSECAP, EXCOMM, "DB-Library capabilities not accepted by the Server" } , { TDSECAPTYP, EXCOMM, "Unexpected capability type in CAPABILITY datastream" } , { TDSECLOS, EXCOMM, "Error in closing network connection" } , { TDSECONN, EXCOMM, "Unable to connect: Adaptive Server is unavailable or does not exist" } , { TDSEEUNR, EXCOMM, "Unsolicited event notification received" } , { TDSEFCON, EXCOMM, "Adaptive Server connection failed" } , { TDSENEG, EXCOMM, "Negotiated login attempt failed" } , { TDSEOOB, EXCOMM, "Error in sending out-of-band data to the server" } , { TDSEREAD, EXCOMM, "Read from the server failed" } , { TDSETIME, EXTIME, "Adaptive Server connection timed out" } , { TDSESEOF, EXCOMM, "Unexpected EOF from the server" } , { TDSEINTF, EXUSER, "Server name not found in configuration files." } , { TDSESOCK, EXCOMM, "Unable to open socket" } , { TDSESYNC, EXCOMM, "Read attempted while out of synchronization with Adaptive Server" } , { TDSEUHST, EXUSER, "Unknown host machine name." } , { TDSEUMSG, EXCOMM, "Unknown message-id in MSG datastream" } , { TDSEUSCT, EXCOMM, "Unable to set communications timer" } , { TDSEUTDS, EXCOMM, "Unrecognized TDS version received from the server" } , { TDSEWRIT, EXCOMM, "Write to the server failed" } , { TDSECONF, EXUSER, "Local configuration error. " "Check TDSDUMPCONFIG log for details." } /* last, with msgno == TDSEOK */ , { TDSEOK, EXCONSISTENCY, "unrecognized msgno" } }; static const char * retname(int retcode) { switch(retcode) { case TDS_INT_CONTINUE: return "TDS_INT_CONTINUE"; case TDS_INT_CANCEL: return "TDS_INT_CANCEL"; case TDS_INT_TIMEOUT: return "TDS_INT_TIMEOUT"; } assert(0); return "nonesuch"; } /** * \brief Call the client library's error handler (for library-generated errors only) * * The client library error handler may return: * TDS_INT_CANCEL -- Return TDS_FAIL to the calling function. For TDSETIME, closes the connection first. * TDS_INT_CONTINUE -- For TDSETIME only, retry the network read/write operation. Else invalid. * TDS_INT_TIMEOUT -- For TDSETIME only, send a TDSCANCEL packet. Else invalid. * * These are Sybase semantics, but they serve all purposes. * The application tells the library to quit, fail, retry, or attempt to cancel. In the event of a network timeout, * a failed operation necessarily means the connection becomes unusable, because no cancellation dialog was * concluded with the server. * * It is the client library's duty to call the error handler installed by the application, if any, and to interpret the * installed handler's return code. It may return to this function one of the above codes only. This function will not * check the return code because there's nothing that can be done here except abort. It is merely passed to the * calling function, which will (we hope) DTRT. * * \param tds_ctx points to a TDSCONTEXT structure * \param tds the connection structure, may be NULL if not connected * \param msgno an enumerated libtds msgno, cf. tds.h * \param errnum the OS errno, if it matters, else zero * * \returns client library function's return code */ int tdserror (const TDSCONTEXT * tds_ctx, TDSSOCKET * tds, int msgno, int errnum) { #if 0 static const char int_exit_text[] = "FreeTDS: libtds: exiting because client error handler returned %d for msgno %d\n"; static const char int_invalid_text[] = "%s (%d) received from client library error handler for nontimeout for error %d." " Treating as INT_EXIT\n"; #endif const TDS_ERROR_MESSAGE *err; TDSMESSAGE msg; int rc = TDS_INT_CANCEL; tdsdump_log(TDS_DBG_FUNC, "tdserror(%p, %p, %d, %d)\n", tds_ctx, tds, msgno, errnum); /* look up the error message */ for (err = tds_error_messages; err->msgno != TDSEOK; ++err) { if (err->msgno == msgno) break; } CHECK_CONTEXT_EXTRA(tds_ctx); if (tds) CHECK_TDS_EXTRA(tds); if (tds_ctx && tds_ctx->err_handler) { memset(&msg, 0, sizeof(TDSMESSAGE)); msg.msgno = msgno; msg.severity = err->severity; msg.state = -1; msg.server = "OpenClient"; msg.line_number = -1; msg.message = (TDS_CHAR*) err->msgtext; msg.sql_state = tds_alloc_client_sqlstate(msgno); msg.oserr = errnum; /* * Call client library handler. * The client library must return a valid code. It is not checked again here. */ rc = tds_ctx->err_handler(tds_ctx, tds, &msg); tdsdump_log(TDS_DBG_FUNC, "tdserror: client library returned %s(%d)\n", retname(rc), rc); TDS_ZERO_FREE(msg.sql_state); } else { const static char msg[] = "tdserror: client library not called because either " "tds_ctx (%p) or tds_ctx->err_handler is NULL\n"; tdsdump_log(TDS_DBG_ERROR, msg, tds_ctx); } assert(msgno == TDSETIME || rc != TDS_INT_TIMEOUT); /* client library should prevent */ assert(msgno == TDSETIME || rc != TDS_INT_CONTINUE); /* client library should prevent */ if (msgno != TDSETIME && rc != TDS_INT_CANCEL) { tdsdump_log(TDS_DBG_SEVERE, "exit: %s(%d) valid only for TDSETIME\n", retname(rc), rc); rc = TDS_INT_CANCEL; } if (rc == TDS_INT_TIMEOUT) { tds_send_cancel(tds); rc = TDS_INT_CONTINUE; } tdsdump_log(TDS_DBG_FUNC, "tdserror: returning %s(%d)\n", retname(rc), rc); return rc; } /** * Copy a string of length len to a new allocated buffer * This function does not read more than len bytes * Please note that some system implementation of strndup * do not assure they don't read past len bytes as they * use still strlen to check length to copy limiting * after strlen to size passed * Also this function is different from strndup as it assume * that len bytes are valid * String returned is NUL terminated * * \param s string to copy from * \param len length to copy * * \returns string copied or NULL if errors */ char * tds_strndup(const void *s, TDS_INTPTR len) { char *out; if (len < 0) return NULL; out = tds_new(char, len + 1); if (out) { memcpy(out, s, len); out[len] = 0; } return out; } freetds-1.00.82/src/tds/login.c100644 025423 025423 00000103533 13203773221 0011670/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns * Copyright (C) 2005-2015 Ziglio Frediano * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #ifdef _WIN32 #include #endif #include #include #include #include #include #include #include #include "replacements.h" static TDSRET tds_send_login(TDSSOCKET * tds, TDSLOGIN * login); static TDSRET tds71_do_login(TDSSOCKET * tds, TDSLOGIN * login); static TDSRET tds7_send_login(TDSSOCKET * tds, TDSLOGIN * login); static void tds7_crypt_pass(const unsigned char *clear_pass, size_t len, unsigned char *crypt_pass); void tds_set_version(TDSLOGIN * tds_login, TDS_TINYINT major_ver, TDS_TINYINT minor_ver) { tds_login->tds_version = ((TDS_USMALLINT) major_ver << 8) + minor_ver; } void tds_set_packet(TDSLOGIN * tds_login, int packet_size) { tds_login->block_size = packet_size; } void tds_set_port(TDSLOGIN * tds_login, int port) { tds_login->port = port; } bool tds_set_passwd(TDSLOGIN * tds_login, const char *password) { if (password) { tds_dstr_zero(&tds_login->password); return !!tds_dstr_copy(&tds_login->password, password); } return true; } void tds_set_bulk(TDSLOGIN * tds_login, TDS_TINYINT enabled) { tds_login->bulk_copy = enabled ? 1 : 0; } bool tds_set_user(TDSLOGIN * tds_login, const char *username) { return !!tds_dstr_copy(&tds_login->user_name, username); } bool tds_set_host(TDSLOGIN * tds_login, const char *hostname) { return !!tds_dstr_copy(&tds_login->client_host_name, hostname); } bool tds_set_app(TDSLOGIN * tds_login, const char *application) { return !!tds_dstr_copy(&tds_login->app_name, application); } /** * \brief Set the servername in a TDSLOGIN structure * * Normally copies \a server into \a tds_login. If \a server does not point to a plausible name, the environment * variables TDSQUERY and DSQUERY are used, in that order. If they don't exist, the "default default" servername * is "SYBASE" (although the utility of that choice is a bit murky). * * \param tds_login points to a TDSLOGIN structure * \param server the servername, or NULL, or a zero-length string * \todo open the log file earlier, so these messages can be seen. */ bool tds_set_server(TDSLOGIN * tds_login, const char *server) { #if 0 /* Doing this in tds_alloc_login instead */ static const char *names[] = { "TDSQUERY", "DSQUERY", "SYBASE" }; int i; for (i=0; i < TDS_VECTOR_SIZE(names) && (!server || strlen(server) == 0); i++) { const char *source; if (i + 1 == TDS_VECTOR_SIZE(names)) { server = names[i]; source = "compiled-in default"; } else { server = getenv(names[i]); source = names[i]; } if (server) { tdsdump_log(TDS_DBG_INFO1, "Setting TDSLOGIN::server_name to '%s' from %s.\n", server, source); } } #endif if (server) return !!tds_dstr_copy(&tds_login->server_name, server); return true; } bool tds_set_library(TDSLOGIN * tds_login, const char *library) { return !!tds_dstr_copy(&tds_login->library, library); } bool tds_set_client_charset(TDSLOGIN * tds_login, const char *charset) { return !!tds_dstr_copy(&tds_login->client_charset, charset); } bool tds_set_language(TDSLOGIN * tds_login, const char *language) { return !!tds_dstr_copy(&tds_login->language, language); } struct tds_save_msg { TDSMESSAGE msg; char type; }; struct tds_save_env { char *oldval; char *newval; int type; }; typedef struct tds_save_context { /* must be first !!! */ TDSCONTEXT ctx; unsigned num_msg; struct tds_save_msg msgs[10]; unsigned num_env; struct tds_save_env envs[10]; } TDSSAVECONTEXT; static void tds_save(TDSSAVECONTEXT *ctx, char type, TDSMESSAGE *msg) { struct tds_save_msg *dest_msg; if (ctx->num_msg >= TDS_VECTOR_SIZE(ctx->msgs)) return; dest_msg = &ctx->msgs[ctx->num_msg]; dest_msg->type = type; dest_msg->msg = *msg; #define COPY(name) if (msg->name) dest_msg->msg.name = strdup(msg->name); COPY(server); COPY(message); COPY(proc_name); COPY(sql_state); #undef COPY ++ctx->num_msg; } static int tds_save_msg(const TDSCONTEXT *ctx, TDSSOCKET *tds, TDSMESSAGE *msg) { tds_save((TDSSAVECONTEXT *) ctx, 0, msg); return 0; } static int tds_save_err(const TDSCONTEXT *ctx, TDSSOCKET *tds, TDSMESSAGE *msg) { tds_save((TDSSAVECONTEXT *) ctx, 1, msg); return TDS_INT_CANCEL; } static void tds_save_env(TDSSOCKET * tds, int type, char *oldval, char *newval) { TDSSAVECONTEXT *ctx; struct tds_save_env *env; if (tds_get_ctx(tds)->msg_handler != tds_save_msg) return; ctx = (TDSSAVECONTEXT *) tds_get_ctx(tds); if (ctx->num_env >= TDS_VECTOR_SIZE(ctx->envs)) return; env = &ctx->envs[ctx->num_env]; env->type = type; env->oldval = oldval ? strdup(oldval) : NULL; env->newval = newval ? strdup(newval) : NULL; ++ctx->num_env; } static void init_save_context(TDSSAVECONTEXT *ctx, const TDSCONTEXT *old_ctx) { memset(ctx, 0, sizeof(*ctx)); ctx->ctx.locale = old_ctx->locale; ctx->ctx.msg_handler = tds_save_msg; ctx->ctx.err_handler = tds_save_err; } static void replay_save_context(TDSSOCKET *tds, TDSSAVECONTEXT *ctx) { unsigned n; /* replay all recorded messages */ for (n = 0; n < ctx->num_msg; ++n) if (ctx->msgs[n].type == 0) { if (tds_get_ctx(tds)->msg_handler) tds_get_ctx(tds)->msg_handler(tds_get_ctx(tds), tds, &ctx->msgs[n].msg); } else { if (tds_get_ctx(tds)->err_handler) tds_get_ctx(tds)->err_handler(tds_get_ctx(tds), tds, &ctx->msgs[n].msg); } /* replay all recorded envs */ for (n = 0; n < ctx->num_env; ++n) if (tds->env_chg_func) tds->env_chg_func(tds, ctx->envs[n].type, ctx->envs[n].oldval, ctx->envs[n].newval); } static void reset_save_context(TDSSAVECONTEXT *ctx) { unsigned n; /* free all messages */ for (n = 0; n < ctx->num_msg; ++n) tds_free_msg(&ctx->msgs[n].msg); ctx->num_msg = 0; /* free all envs */ for (n = 0; n < ctx->num_env; ++n) { free(ctx->envs[n].oldval); free(ctx->envs[n].newval); } ctx->num_env = 0; } static void free_save_context(TDSSAVECONTEXT *ctx) { reset_save_context(ctx); } /** * Retrieve and set @@spid * \tds */ static TDSRET tds_set_spid(TDSSOCKET * tds) { TDS_INT result_type; TDS_INT done_flags; TDSRET rc; TDSCOLUMN *curcol; CHECK_TDS_EXTRA(tds); while ((rc = tds_process_tokens(tds, &result_type, &done_flags, TDS_RETURN_ROW|TDS_RETURN_DONE)) == TDS_SUCCESS) { switch (result_type) { case TDS_ROW_RESULT: if (!tds->res_info) return TDS_FAIL; if (tds->res_info->num_cols != 1) break; curcol = tds->res_info->columns[0]; switch (tds_get_conversion_type(curcol->column_type, curcol->column_size)) { case SYBINT2: tds->conn->spid = *((TDS_USMALLINT *) curcol->column_data); break; case SYBINT4: tds->conn->spid = *((TDS_UINT *) curcol->column_data); break; default: return TDS_FAIL; } break; case TDS_DONE_RESULT: if ((done_flags & TDS_DONE_ERROR) != 0) return TDS_FAIL; break; } } if (rc == TDS_NO_MORE_RESULTS) rc = TDS_SUCCESS; return rc; } /** * Do a connection to socket * @param tds connection structure. This should be a non-connected connection. * @return TDS_FAIL or TDS_SUCCESS if a connection was made to the server's port. * @return TDSERROR enumerated type if no TCP/IP connection could be formed. * @param login info for login * @remark Possible error conditions: * - TDSESOCK: socket(2) failed: insufficient local resources * - TDSECONN: connect(2) failed: invalid hostname or port (ETIMEDOUT, ECONNREFUSED, ENETUNREACH) * - TDSEFCON: connect(2) succeeded, login packet not acknowledged. * - TDS_FAIL: connect(2) succeeded, login failed. */ static int tds_connect(TDSSOCKET * tds, TDSLOGIN * login, int *p_oserr) { int erc = -TDSEFCON; int connect_timeout = 0; int db_selected = 0; struct addrinfo *addrs; int orig_port; bool rerouted = false; /* * A major version of 0 means try to guess the TDS version. * We try them in an order that should work. */ const static TDS_USMALLINT versions[] = { 0x703 , 0x702 , 0x701 , 0x700 , 0x500 , 0x402 }; if (!login->valid_configuration) { tdserror(tds_get_ctx(tds), tds, TDSECONF, 0); return TDS_FAIL; } if (TDS_MAJOR(login) == 0) { unsigned int i; TDSSAVECONTEXT save_ctx; const TDSCONTEXT *old_ctx = tds_get_ctx(tds); typedef void (*env_chg_func_t) (TDSSOCKET * tds, int type, char *oldval, char *newval); env_chg_func_t old_env_chg = tds->env_chg_func; /* the context of a socket is const; we have to modify it to suppress error messages during multiple tries. */ TDSCONTEXT *mod_ctx = (TDSCONTEXT *) tds_get_ctx(tds); err_handler_t err_handler = tds_get_ctx(tds)->err_handler; init_save_context(&save_ctx, old_ctx); tds_set_ctx(tds, &save_ctx.ctx); tds->env_chg_func = tds_save_env; mod_ctx->err_handler = NULL; for (i = 0; i < TDS_VECTOR_SIZE(versions); ++i) { login->tds_version = versions[i]; reset_save_context(&save_ctx); erc = tds_connect(tds, login, p_oserr); if (TDS_FAILED(erc)) { tds_close_socket(tds); } if (erc != -TDSEFCON) /* TDSEFCON indicates wrong TDS version */ break; } mod_ctx->err_handler = err_handler; tds->env_chg_func = old_env_chg; tds_set_ctx(tds, old_ctx); replay_save_context(tds, &save_ctx); free_save_context(&save_ctx); if (TDS_FAILED(erc)) tdserror(tds_get_ctx(tds), tds, -erc, *p_oserr); return erc; } /* * If a dump file has been specified, start logging */ if (!tds_dstr_isempty(&login->dump_file) && !tdsdump_isopen()) { if (login->debug_flags) tds_debug_flags = login->debug_flags; tdsdump_open(tds_dstr_cstr(&login->dump_file)); } tds->login = login; tds->conn->tds_version = login->tds_version; tds->conn->emul_little_endian = login->emul_little_endian; #ifdef WORDS_BIGENDIAN /* * Enable automatically little endian emulation. * TDS 7/8 only supports little endian. * This is done even for 4.2 to ensure that when we connect to a * MSSQL we use it and avoid to make additional checks for * broken 7.0 servers. * Note that 4.2 should not be used anymore for real jobs. */ if (IS_TDS7_PLUS(tds->conn) || IS_TDS42(tds->conn)) tds->conn->emul_little_endian = 1; #endif /* set up iconv if not already initialized*/ if (tds->conn->char_convs[client2ucs2]->to.cd == (iconv_t) -1) { if (!tds_dstr_isempty(&login->client_charset)) { if (TDS_FAILED(tds_iconv_open(tds->conn, tds_dstr_cstr(&login->client_charset), login->use_utf16))) return -TDSEMEM; } } connect_timeout = login->connect_timeout; /* Jeff's hack - begin */ tds->query_timeout = connect_timeout ? connect_timeout : login->query_timeout; /* end */ /* verify that ip_addr is not empty */ if (login->ip_addrs == NULL) { tdserror(tds_get_ctx(tds), tds, TDSEUHST, 0 ); tdsdump_log(TDS_DBG_ERROR, "IP address pointer is empty\n"); if (!tds_dstr_isempty(&login->server_name)) { tdsdump_log(TDS_DBG_ERROR, "Server %s not found!\n", tds_dstr_cstr(&login->server_name)); } else { tdsdump_log(TDS_DBG_ERROR, "No server specified!\n"); } return -TDSECONN; } tds->conn->capabilities = login->capabilities; reroute: erc = TDSEINTF; orig_port = login->port; for (addrs = login->ip_addrs; addrs != NULL; addrs = addrs->ai_next) { login->port = orig_port; if (!IS_TDS50(tds->conn) && !tds_dstr_isempty(&login->instance_name) && !login->port) login->port = tds7_get_instance_port(addrs, tds_dstr_cstr(&login->instance_name)); if (login->port >= 1) { if ((erc = tds_open_socket(tds, addrs, login->port, connect_timeout, p_oserr)) == TDSEOK) { login->connected_addr = addrs; break; } } else { erc = TDSECONN; } } if (erc != TDSEOK) { if (login->port < 1) tdsdump_log(TDS_DBG_ERROR, "invalid port number\n"); tdserror(tds_get_ctx(tds), tds, erc, *p_oserr); return -erc; } /* * Beyond this point, we're connected to the server. We know we have a valid TCP/IP address+socket pair. * Although network errors *might* happen, most problems from here on out will be TDS-level errors, * either TDS version problems or authentication problems. */ tds_set_state(tds, TDS_IDLE); tds->conn->spid = -1; /* discard possible previous authentication */ if (tds->conn->authentication) { tds->conn->authentication->free(tds->conn, tds->conn->authentication); tds->conn->authentication = NULL; } if (IS_TDS71_PLUS(tds->conn)) { erc = tds71_do_login(tds, login); db_selected = 1; } else if (IS_TDS7_PLUS(tds->conn)) { erc = tds7_send_login(tds, login); db_selected = 1; } else { tds->out_flag = TDS_LOGIN; erc = tds_send_login(tds, login); } if (TDS_FAILED(erc) || TDS_FAILED(tds_process_login_tokens(tds))) { tdsdump_log(TDS_DBG_ERROR, "login packet %s\n", TDS_SUCCEED(erc)? "accepted":"rejected"); tds_close_socket(tds); tdserror(tds_get_ctx(tds), tds, TDSEFCON, 0); /* "Adaptive Server connection failed" */ return -TDSEFCON; } /* need to do rerouting */ if (IS_TDS71_PLUS(tds->conn) && !rerouted && !tds_dstr_isempty(&login->routing_address) && login->routing_port) { TDSRET ret; tds_close_socket(tds); login->port = login->routing_port; ret = tds_lookup_host_set(tds_dstr_cstr(&login->routing_address), &login->ip_addrs); login->routing_port = 0; tds_dstr_free(&login->routing_address); if (TDS_FAILED(ret)) { tdserror(tds_get_ctx(tds), tds, TDSEFCON, 0); return -TDSEFCON; } rerouted = true; goto reroute; } #if ENABLE_ODBC_MARS /* initialize SID */ if (IS_TDS72_PLUS(tds->conn) && login->mars) { tds->conn->sessions[0] = NULL; tds->conn->mars = 1; tds->sid = -1; tds_init_write_buf(tds); } #endif if (login->text_size || (!db_selected && !tds_dstr_isempty(&login->database)) || tds->conn->spid == -1) { char *str; int len; len = 128 + tds_quote_id(tds, NULL, tds_dstr_cstr(&login->database),-1); if ((str = tds_new(char, len)) == NULL) return TDS_FAIL; str[0] = 0; if (login->text_size) { sprintf(str, "set textsize %d ", login->text_size); } if (tds->conn->spid == -1) { strcat(str, "select @@spid "); } /* Select proper database if specified. * SQL Anywhere does not support multiple databases and USE statement * so don't send the request to avoid connection failures */ if (!db_selected && !tds_dstr_isempty(&login->database) && (tds->conn->product_name == NULL || strcasecmp(tds->conn->product_name, "SQL Anywhere") != 0)) { strcat(str, "use "); tds_quote_id(tds, strchr(str, 0), tds_dstr_cstr(&login->database), -1); } erc = tds_submit_query(tds, str); free(str); if (TDS_FAILED(erc)) return erc; if (tds->conn->spid == -1) erc = tds_set_spid(tds); else erc = tds_process_simple_query(tds); if (TDS_FAILED(erc)) return erc; } tds->query_timeout = login->query_timeout; tds->login = NULL; return TDS_SUCCESS; } int tds_connect_and_login(TDSSOCKET * tds, TDSLOGIN * login) { int oserr = 0; return tds_connect(tds, login, &oserr); } static int tds_put_login_string(TDSSOCKET * tds, const char *buf, int n) { const int buf_len = buf ? (int)strlen(buf) : 0; return tds_put_buf(tds, (const unsigned char *) buf, n, buf_len); } static TDSRET tds_send_login(TDSSOCKET * tds, TDSLOGIN * login) { #ifdef WORDS_BIGENDIAN static const unsigned char be1[] = { 0x02, 0x00, 0x06, 0x04, 0x08, 0x01 }; static const unsigned char be2[] = { 0x00, 12, 16 }; #endif static const unsigned char le1[] = { 0x03, 0x01, 0x06, 0x0a, 0x09, 0x01 }; static const unsigned char le2[] = { 0x00, 13, 17 }; /* * capabilities are now part of the tds structure. * unsigned char capabilities[]= {0x01,0x07,0x03,109,127,0xFF,0xFF,0xFF,0xFE,0x02,0x07,0x00,0x00,0x0A,104,0x00,0x00,0x00}; */ /* * This is the original capabilities packet we were working with (sqsh) * unsigned char capabilities[]= {0x01,0x07,0x03,109,127,0xFF,0xFF,0xFF,0xFE,0x02,0x07,0x00,0x00,0x0A,104,0x00,0x00,0x00}; * original with 4.x messages * unsigned char capabilities[]= {0x01,0x07,0x03,109,127,0xFF,0xFF,0xFF,0xFE,0x02,0x07,0x00,0x00,0x00,120,192,0x00,0x0D}; * This is isql 11.0.3 * unsigned char capabilities[]= {0x01,0x07,0x00,96, 129,207, 0xFF,0xFE,62, 0x02,0x07,0x00,0x00,0x00,120,192,0x00,0x0D}; * like isql but with 5.0 messages * unsigned char capabilities[]= {0x01,0x07,0x00,96, 129,207, 0xFF,0xFE,62, 0x02,0x07,0x00,0x00,0x00,120,192,0x00,0x00}; */ unsigned char protocol_version[4]; unsigned char program_version[4]; int len; char blockstr[16]; /* override lservname field for ASA servers */ const char *lservname = getenv("ASA_DATABASE")? getenv("ASA_DATABASE") : tds_dstr_cstr(&login->server_name); if (strchr(tds_dstr_cstr(&login->user_name), '\\') != NULL) { tdsdump_log(TDS_DBG_ERROR, "NT login not support using TDS 4.x or 5.0\n"); return TDS_FAIL; } if (tds_dstr_isempty(&login->user_name)) { tdsdump_log(TDS_DBG_ERROR, "Kerberos login not support using TDS 4.x or 5.0\n"); return TDS_FAIL; } if (login->encryption_level != TDS_ENCRYPTION_OFF) { if (IS_TDS42(tds->conn)) { tdsdump_log(TDS_DBG_ERROR, "Encryption not support using TDS 4.x\n"); return TDS_FAIL; } tds->conn->authentication = tds5_negotiate_get_auth(tds); if (!tds->conn->authentication) return TDS_FAIL; } if (IS_TDS42(tds->conn)) { memcpy(protocol_version, "\004\002\000\000", 4); memcpy(program_version, "\004\002\000\000", 4); } else if (IS_TDS46(tds->conn)) { memcpy(protocol_version, "\004\006\000\000", 4); memcpy(program_version, "\004\002\000\000", 4); } else if (IS_TDS50(tds->conn)) { memcpy(protocol_version, "\005\000\000\000", 4); memcpy(program_version, "\005\000\000\000", 4); } else { tdsdump_log(TDS_DBG_SEVERE, "Unknown protocol version!\n"); return TDS_FAIL; } /* * the following code is adapted from Arno Pedusaar's * (psaar@fenar.ee) MS-SQL Client. His was a much better way to * do this, (well...mine was a kludge actually) so here's mostly his */ tds_put_login_string(tds, tds_dstr_cstr(&login->client_host_name), TDS_MAXNAME); /* client host name */ tds_put_login_string(tds, tds_dstr_cstr(&login->user_name), TDS_MAXNAME); /* account name */ /* account password */ if (login->encryption_level != TDS_ENCRYPTION_OFF) { tds_put_login_string(tds, NULL, TDS_MAXNAME); } else { tds_put_login_string(tds, tds_dstr_cstr(&login->password), TDS_MAXNAME); } sprintf(blockstr, "%d", (int) getpid()); tds_put_login_string(tds, blockstr, TDS_MAXNAME); /* host process */ #ifdef WORDS_BIGENDIAN if (tds->conn->emul_little_endian) { tds_put_n(tds, le1, 6); } else { tds_put_n(tds, be1, 6); } #else tds_put_n(tds, le1, 6); #endif tds_put_byte(tds, !login->bulk_copy); tds_put_n(tds, NULL, 2); if (IS_TDS42(tds->conn)) { tds_put_int(tds, 512); } else { tds_put_int(tds, 0); } tds_put_n(tds, NULL, 3); tds_put_login_string(tds, tds_dstr_cstr(&login->app_name), TDS_MAXNAME); tds_put_login_string(tds, lservname, TDS_MAXNAME); if (IS_TDS42(tds->conn)) { tds_put_login_string(tds, tds_dstr_cstr(&login->password), 255); } else if (login->encryption_level) { tds_put_n(tds, NULL, 256); } else { len = (int)tds_dstr_len(&login->password); if (len > 253) len = 0; tds_put_byte(tds, 0); tds_put_byte(tds, len); tds_put_n(tds, tds_dstr_cstr(&login->password), len); tds_put_n(tds, NULL, 253 - len); tds_put_byte(tds, len + 2); } tds_put_n(tds, protocol_version, 4); /* TDS version; { 0x04,0x02,0x00,0x00 } */ tds_put_login_string(tds, tds_dstr_cstr(&login->library), TDS_PROGNLEN); /* client program name */ if (IS_TDS42(tds->conn)) { tds_put_int(tds, 0); } else { tds_put_n(tds, program_version, 4); /* program version ? */ } #ifdef WORDS_BIGENDIAN if (tds->conn->emul_little_endian) { tds_put_n(tds, le2, 3); } else { tds_put_n(tds, be2, 3); } #else tds_put_n(tds, le2, 3); #endif tds_put_login_string(tds, tds_dstr_cstr(&login->language), TDS_MAXNAME); /* language */ tds_put_byte(tds, login->suppress_language); /* oldsecure(2), should be zero, used by old software */ tds_put_n(tds, NULL, 2); /* seclogin(1) bitmask */ tds_put_byte(tds, login->encryption_level ? TDS5_SEC_LOG_ENCRYPT2|TDS5_SEC_LOG_NONCE : 0); /* secbulk(1) * halogin(1) type of ha login * hasessionid(6) id of session to reconnect * secspare(2) not used */ tds_put_n(tds, NULL, 10); /* use empty charset to handle conversions on client */ tds_put_login_string(tds, "", TDS_MAXNAME); /* charset */ /* this is a flag, mean that server should use character set provided by client */ /* TODO notify charset change ?? what's correct meaning ?? -- freddy77 */ tds_put_byte(tds, 1); /* network packet size */ if (login->block_size < 65536u && login->block_size >= 512) sprintf(blockstr, "%d", login->block_size); else strcpy(blockstr, "512"); tds_put_login_string(tds, blockstr, TDS_PKTLEN); if (IS_TDS42(tds->conn)) { tds_put_n(tds, NULL, 8); } else if (IS_TDS46(tds->conn)) { tds_put_n(tds, NULL, 4); } else if (IS_TDS50(tds->conn)) { /* just padding to 8 bytes */ tds_put_n(tds, NULL, 4); tds_put_byte(tds, TDS_CAPABILITY_TOKEN); tds_put_smallint(tds, sizeof(tds->conn->capabilities)); tds_put_n(tds, &tds->conn->capabilities, sizeof(tds->conn->capabilities)); } return tds_flush_packet(tds); } /** * tds7_send_login() -- Send a TDS 7.0 login packet * TDS 7.0 login packet is vastly different and so gets its own function * \returns the return value is ignored by the caller. :-/ */ static TDSRET tds7_send_login(TDSSOCKET * tds, TDSLOGIN * login) { static const unsigned char client_progver[] = { 6, 0x83, 0xf2, 0xf8 }, connection_id[] = { 0x00, 0x00, 0x00, 0x00 }, collation[] = { 0x36, 0x04, 0x00, 0x00 }; enum { tds70Version = 0x70000000, tds71Version = 0x71000001, tds72Version = 0x72090002, tds73Version = 0x730B0003, tds74Version = 0x74000004, }; TDS_UCHAR sql_type_flag = 0x00; TDS_INT time_zone = -120; TDS_INT tds7version = tds70Version; TDS_INT block_size = 4096; unsigned char option_flag1 = TDS_SET_LANG_ON | TDS_USE_DB_NOTIFY | TDS_INIT_DB_FATAL; unsigned char option_flag2 = login->option_flag2; unsigned char option_flag3 = 0; unsigned char hwaddr[6]; size_t packet_size, current_pos; TDSRET rc; void *data = NULL; TDSDYNAMICSTREAM data_stream; TDSSTATICINSTREAM input; const char *user_name = tds_dstr_cstr(&login->user_name); unsigned char *pwd; /* FIXME: These are defined as size_t, but should be TDS_SMALLINT. */ size_t user_name_len = strlen(user_name); size_t auth_len = 0; /* fields */ enum { HOST_NAME, USER_NAME, PASSWORD, APP_NAME, SERVER_NAME, LIBRARY_NAME, LANGUAGE, DATABASE_NAME, DB_FILENAME, NEW_PASSWORD, NUM_DATA_FIELDS }; struct { const void *ptr; unsigned pos, len; } data_fields[NUM_DATA_FIELDS], *field; tds->out_flag = TDS7_LOGIN; current_pos = packet_size = IS_TDS72_PLUS(tds->conn) ? 86 + 8 : 86; /* ? */ /* check ntlm */ #ifdef HAVE_SSPI if (strchr(user_name, '\\') != NULL || user_name_len == 0) { tdsdump_log(TDS_DBG_INFO2, "using SSPI authentication for '%s' account\n", user_name); tds->conn->authentication = tds_sspi_get_auth(tds); if (!tds->conn->authentication) return TDS_FAIL; auth_len = tds->conn->authentication->packet_len; packet_size += auth_len; #else if (strchr(user_name, '\\') != NULL) { tdsdump_log(TDS_DBG_INFO2, "using NTLM authentication for '%s' account\n", user_name); tds->conn->authentication = tds_ntlm_get_auth(tds); if (!tds->conn->authentication) return TDS_FAIL; auth_len = tds->conn->authentication->packet_len; packet_size += auth_len; } else if (user_name_len == 0) { # ifdef ENABLE_KRB5 /* try kerberos */ tdsdump_log(TDS_DBG_INFO2, "using GSS authentication\n"); tds->conn->authentication = tds_gss_get_auth(tds); if (!tds->conn->authentication) return TDS_FAIL; auth_len = tds->conn->authentication->packet_len; packet_size += auth_len; # else tdsdump_log(TDS_DBG_ERROR, "requested GSS authentication but not compiled in\n"); return TDS_FAIL; # endif #endif } /* initialize ouput buffer for strings */ rc = tds_dynamic_stream_init(&data_stream, &data, 0); if (TDS_FAILED(rc)) return rc; #define SET_FIELD_DSTR(field, dstr) do { \ data_fields[field].ptr = tds_dstr_cstr(&(dstr)); \ data_fields[field].len = tds_dstr_len(&(dstr)); \ } while(0) /* setup data fields */ SET_FIELD_DSTR(HOST_NAME, login->client_host_name); if (tds->conn->authentication) { data_fields[USER_NAME].len = 0; data_fields[PASSWORD].len = 0; } else { SET_FIELD_DSTR(USER_NAME, login->user_name); SET_FIELD_DSTR(PASSWORD, login->password); } SET_FIELD_DSTR(APP_NAME, login->app_name); SET_FIELD_DSTR(SERVER_NAME, login->server_name); SET_FIELD_DSTR(LIBRARY_NAME, login->library); SET_FIELD_DSTR(LANGUAGE, login->language); SET_FIELD_DSTR(DATABASE_NAME, login->database); SET_FIELD_DSTR(DB_FILENAME, login->db_filename); data_fields[NEW_PASSWORD].len = 0; if (IS_TDS72_PLUS(tds->conn) && login->use_new_password) { option_flag3 |= TDS_CHANGE_PASSWORD; SET_FIELD_DSTR(NEW_PASSWORD, login->new_password); } /* convert data fields */ for (field = data_fields; field < data_fields + TDS_VECTOR_SIZE(data_fields); ++field) { size_t data_pos; data_pos = data_stream.size; field->pos = current_pos + data_pos; if (field->len) { tds_staticin_stream_init(&input, field->ptr, field->len); rc = tds_convert_stream(tds, tds->conn->char_convs[client2ucs2], to_server, &input.stream, &data_stream.stream); if (TDS_FAILED(rc)) { free(data); return TDS_FAIL; } } field->len = data_stream.size - data_pos; } pwd = (unsigned char *) data + data_fields[PASSWORD].pos - current_pos; tds7_crypt_pass(pwd, data_fields[PASSWORD].len, pwd); pwd = (unsigned char *) data + data_fields[NEW_PASSWORD].pos - current_pos; tds7_crypt_pass(pwd, data_fields[NEW_PASSWORD].len, pwd); packet_size += data_stream.size; #if !defined(TDS_DEBUG_LOGIN) tdsdump_log(TDS_DBG_INFO2, "quietly sending TDS 7+ login packet\n"); tdsdump_off(); #endif TDS_PUT_INT(tds, packet_size); switch (login->tds_version) { case 0x700: tds7version = tds70Version; break; case 0x701: tds7version = tds71Version; break; case 0x702: tds7version = tds72Version; break; case 0x703: tds7version = tds73Version; break; case 0x704: tds7version = tds74Version; break; default: assert(0 && 0x700 <= login->tds_version && login->tds_version <= 0x704); } tds_put_int(tds, tds7version); if (4096 <= login->block_size && login->block_size < 65536u) block_size = login->block_size; tds_put_int(tds, block_size); /* desired packet size being requested by client */ if (block_size > tds->out_buf_max) tds_realloc_socket(tds, block_size); tds_put_n(tds, client_progver, sizeof(client_progver)); /* client program version ? */ tds_put_int(tds, getpid()); /* process id of this process */ tds_put_n(tds, connection_id, sizeof(connection_id)); if (!login->bulk_copy) option_flag1 |= TDS_DUMPLOAD_OFF; tds_put_byte(tds, option_flag1); if (tds->conn->authentication) option_flag2 |= TDS_INTEGRATED_SECURITY_ON; tds_put_byte(tds, option_flag2); if (login->readonly_intent && IS_TDS71_PLUS(tds->conn)) sql_type_flag |= TDS_READONLY_INTENT; tds_put_byte(tds, sql_type_flag); if (IS_TDS73_PLUS(tds->conn)) option_flag3 |= TDS_UNKNOWN_COLLATION_HANDLING; tds_put_byte(tds, option_flag3); tds_put_int(tds, time_zone); tds_put_n(tds, collation, sizeof(collation)); #define PUT_STRING_FIELD_PTR(field) do { \ TDS_PUT_SMALLINT(tds, data_fields[field].pos); \ TDS_PUT_SMALLINT(tds, data_fields[field].len / 2u); \ } while(0) /* host name */ PUT_STRING_FIELD_PTR(HOST_NAME); if (tds->conn->authentication) { tds_put_smallint(tds, 0); tds_put_smallint(tds, 0); tds_put_smallint(tds, 0); tds_put_smallint(tds, 0); } else { /* username */ PUT_STRING_FIELD_PTR(USER_NAME); /* password */ PUT_STRING_FIELD_PTR(PASSWORD); } /* app name */ PUT_STRING_FIELD_PTR(APP_NAME); /* server name */ PUT_STRING_FIELD_PTR(SERVER_NAME); /* unknown */ tds_put_smallint(tds, 0); tds_put_smallint(tds, 0); /* library name */ PUT_STRING_FIELD_PTR(LIBRARY_NAME); /* language - kostya@warmcat.excom.spb.su */ PUT_STRING_FIELD_PTR(LANGUAGE); /* database name */ PUT_STRING_FIELD_PTR(DATABASE_NAME); /* MAC address */ tds_getmac(tds_get_s(tds), hwaddr); tds_put_n(tds, hwaddr, 6); /* authentication stuff */ TDS_PUT_SMALLINT(tds, current_pos + data_stream.size); TDS_PUT_SMALLINT(tds, auth_len); /* this matches numbers at end of packet */ /* db file */ PUT_STRING_FIELD_PTR(DB_FILENAME); if (IS_TDS72_PLUS(tds->conn)) { /* new password */ PUT_STRING_FIELD_PTR(NEW_PASSWORD); /* SSPI long */ tds_put_int(tds, 0); } tds_put_n(tds, data, data_stream.size); if (tds->conn->authentication) tds_put_n(tds, tds->conn->authentication->packet, auth_len); rc = tds_flush_packet(tds); tdsdump_on(); free(data); return rc; } /** * tds7_crypt_pass() -- 'encrypt' TDS 7.0 style passwords. * the calling function is responsible for ensuring crypt_pass is at least * 'len' characters */ static void tds7_crypt_pass(const unsigned char *clear_pass, size_t len, unsigned char *crypt_pass) { size_t i; for (i = 0; i < len; i++) crypt_pass[i] = ((clear_pass[i] << 4) | (clear_pass[i] >> 4)) ^ 0xA5; } static TDSRET tds71_do_login(TDSSOCKET * tds, TDSLOGIN* login) { int i, pkt_len; const char *instance_name = tds_dstr_isempty(&login->instance_name) ? "MSSQLServer" : tds_dstr_cstr(&login->instance_name); int instance_name_len = strlen(instance_name) + 1; TDS_CHAR crypt_flag; unsigned int start_pos = 21; TDSRET ret; #define START_POS 21 #define UI16BE(n) ((n) >> 8), ((n) & 0xffu) #define SET_UI16BE(i,n) TDS_PUT_UA2BE(&buf[i],n) TDS_UCHAR buf[] = { /* netlib version */ 0, UI16BE(START_POS), UI16BE(6), /* encryption */ 1, UI16BE(START_POS + 6), UI16BE(1), /* instance */ 2, UI16BE(START_POS + 6 + 1), UI16BE(0), /* process id */ 3, UI16BE(0), UI16BE(4), /* MARS enables */ 4, UI16BE(0), UI16BE(1), /* end */ 0xff }; static const TDS_UCHAR netlib8[] = { 8, 0, 1, 0x55, 0, 0 }; static const TDS_UCHAR netlib9[] = { 9, 0, 0, 0, 0, 0 }; TDS_UCHAR *p; SET_UI16BE(13, instance_name_len); if (!IS_TDS72_PLUS(tds->conn)) { SET_UI16BE(16, START_POS + 6 + 1 + instance_name_len); buf[20] = 0xff; } else { start_pos += 5; #undef START_POS #define START_POS 26 SET_UI16BE(1, START_POS); SET_UI16BE(6, START_POS + 6); SET_UI16BE(11, START_POS + 6 + 1); SET_UI16BE(16, START_POS + 6 + 1 + instance_name_len); SET_UI16BE(21, START_POS + 6 + 1 + instance_name_len + 4); } assert(start_pos >= 21 && start_pos <= sizeof(buf)); assert(buf[start_pos-1] == 0xff); /* * fix a problem with mssql2k which doesn't like * packet splitted during SSL handshake */ if (tds->out_buf_max < 4096) tds_realloc_socket(tds, 4096); /* do prelogin */ tds->out_flag = TDS71_PRELOGIN; tds_put_n(tds, buf, start_pos); /* netlib version */ tds_put_n(tds, IS_TDS72_PLUS(tds->conn) ? netlib9 : netlib8, 6); /* encryption */ #if !defined(HAVE_GNUTLS) && !defined(HAVE_OPENSSL) /* not supported */ tds_put_byte(tds, 2); #else tds_put_byte(tds, login->encryption_level >= TDS_ENCRYPTION_REQUIRE ? 1 : 0); #endif /* instance */ tds_put_n(tds, instance_name, instance_name_len); /* pid */ tds_put_int(tds, getpid()); /* MARS (1 enabled) */ if (IS_TDS72_PLUS(tds->conn)) #if ENABLE_ODBC_MARS tds_put_byte(tds, login->mars); login->mars = 0; #else tds_put_byte(tds, 0); #endif ret = tds_flush_packet(tds); if (TDS_FAILED(ret)) return ret; /* now process reply from server */ ret = tds_read_packet(tds); if (ret <= 0 || tds->in_flag != TDS_REPLY) return TDS_FAIL; pkt_len = tds->in_len - tds->in_pos; /* the only thing we care is flag */ p = tds->in_buf + tds->in_pos; /* default 2, no certificate, no encryption */ crypt_flag = 2; for (i = 0;; i += 5) { TDS_UCHAR type; int off, len; if (i >= pkt_len) return TDS_FAIL; type = p[i]; if (type == 0xff) break; /* check packet */ if (i+4 >= pkt_len) return TDS_FAIL; off = TDS_GET_UA2BE(&p[i+1]); len = TDS_GET_UA2BE(&p[i+3]); if (off > pkt_len || (off+len) > pkt_len) return TDS_FAIL; if (type == 1 && len >= 1) { crypt_flag = p[off]; } #if ENABLE_ODBC_MARS if (IS_TDS72_PLUS(tds->conn) && type == 4 && len >= 1) login->mars = p[off]; #endif } /* we readed all packet */ tds->in_pos += pkt_len; /* TODO some mssql version do not set last packet, update tds according */ tdsdump_log(TDS_DBG_INFO1, "detected flag %d\n", crypt_flag); /* if server do not has certificate do normal login */ if (crypt_flag == 2) { /* unless we wanted encryption and got none, then fail */ if (login->encryption_level >= TDS_ENCRYPTION_REQUIRE) return TDS_FAIL; return tds7_send_login(tds, login); } /* * if server has a certificate it require at least a crypted login * (even if data is not encrypted) */ /* here we have to do encryption ... */ ret = tds_ssl_init(tds); if (TDS_FAILED(ret)) return ret; /* server just encrypt the first packet */ if (crypt_flag == 0) tds->conn->encrypt_single_packet = 1; ret = tds7_send_login(tds, login); /* if flag is 0 it means that after login server continue not encrypted */ if (crypt_flag == 0 || TDS_FAILED(ret)) tds_ssl_deinit(tds->conn); return ret; } freetds-1.00.82/src/tds/read.c100644 025423 025423 00000020402 12717145107 0011471/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Brian Bruns * Copyright (C) 2005-2014 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /** * \file * \brief Grab data from TDS packets */ #include #if HAVE_ERRNO_H #include #endif /* HAVE_ERRNO_H */ #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #include #include #include #include #include #include #include static size_t read_and_convert(TDSSOCKET * tds, TDSICONV * char_conv, size_t * wire_size, char *outbuf, size_t outbytesleft); /** * \ingroup libtds * \defgroup network Network functions * Functions for reading or writing from network. */ /** * \addtogroup network * @{ */ /** * Return a single byte from the input buffer * \tds */ unsigned char tds_get_byte(TDSSOCKET * tds) { while (tds->in_pos >= tds->in_len) { if (tds_read_packet(tds) < 0) return 0; } return tds->in_buf[tds->in_pos++]; } /** * Unget will always work as long as you don't call it twice in a row. It * it may work if you call it multiple times as long as you don't backup * over the beginning of network packet boundary which can occur anywhere in * the token stream. * \tds */ void tds_unget_byte(TDSSOCKET * tds) { /* this is a one trick pony...don't call it twice */ tds->in_pos--; } /** * Reads a byte from the TDS stream without removing it * \tds */ unsigned char tds_peek(TDSSOCKET * tds) { unsigned char result = tds_get_byte(tds); if (tds->in_pos > 0) --tds->in_pos; return result; } /* tds_peek() */ /** * Get an int16 from the server. */ TDS_USMALLINT tds_get_usmallint(TDSSOCKET * tds) { TDS_USMALLINT bytes[1]; tds_get_n(tds, &bytes, 2); #if WORDS_BIGENDIAN if (tds->conn->emul_little_endian) return (TDS_USMALLINT) TDS_GET_A2LE(&bytes); #endif return (TDS_USMALLINT) TDS_GET_A2(&bytes); } /** * Get an int32 from the server. * \tds */ TDS_UINT tds_get_uint(TDSSOCKET * tds) { TDS_UINT bytes; tds_get_n(tds, &bytes, 4); #if WORDS_BIGENDIAN if (tds->conn->emul_little_endian) return TDS_GET_A4LE(&bytes); #endif return TDS_GET_A4(&bytes); } /** * Get an uint64 from the server. * \tds */ TDS_UINT8 tds_get_uint8(TDSSOCKET * tds) { TDS_UINT h; TDS_UINT l; TDS_UINT bytes[2]; tds_get_n(tds, bytes, 8); #if WORDS_BIGENDIAN if (tds->conn->emul_little_endian) { l = TDS_GET_A4LE(bytes); h = TDS_GET_A4LE(bytes+1); } else { h = TDS_GET_A4(bytes); l = TDS_GET_A4(bytes+1); } #else l = TDS_GET_A4(bytes); h = TDS_GET_A4(bytes+1); #endif return (((TDS_UINT8) h) << 32) | l; } /** * Fetch a string from the wire. * Output string is NOT null terminated. * If TDS version is 7 or 8 read unicode string and convert it. * This function should be use to read server default encoding strings like * columns name, table names, etc, not for data (use tds_get_char_data instead) * @return bytes written to \a dest * @param tds connection information * @param string_len length of string to read from wire * (in server characters, bytes for tds4-tds5, ucs2 for tds7+) * @param dest destination buffer, if NULL string is read and discarded * @param dest_size destination buffer size, in bytes */ size_t tds_get_string(TDSSOCKET * tds, size_t string_len, char *dest, size_t dest_size) { size_t wire_bytes = string_len; unsigned conv = client2server_chardata; if (IS_TDS7_PLUS(tds->conn)) { wire_bytes *= 2u; conv = client2ucs2; } if (dest == NULL) { tds_get_n(tds, NULL, wire_bytes); return string_len; } return read_and_convert(tds, tds->conn->char_convs[conv], &wire_bytes, dest, dest_size); } /** * Fetch character data the wire. * Output is NOT null terminated. * If \a char_conv is not NULL, convert data accordingly. * \param tds state information for the socket and the TDS protocol * \param row_buffer destination buffer in current_row. Can't be NULL * \param wire_size size to read from wire (in bytes) * \param curcol column information * \return TDS_SUCCESS or TDS_FAIL (probably memory error on text data) */ TDSRET tds_get_char_data(TDSSOCKET * tds, char *row_buffer, size_t wire_size, TDSCOLUMN * curcol) { size_t in_left; assert(curcol->char_conv); /* * row_buffer is a column buffer, allocated when the column's metadata are processed * and reused for each row. */ /* silly case, empty string */ if (wire_size == 0) { curcol->column_cur_size = 0; return TDS_SUCCESS; } in_left = curcol->column_size; curcol->column_cur_size = read_and_convert(tds, curcol->char_conv, &wire_size, row_buffer, in_left); if (TDS_UNLIKELY(wire_size > 0)) { tds_get_n(tds, NULL, wire_size); tdsdump_log(TDS_DBG_NETWORK, "error: tds_get_char_data: discarded %u on wire while reading %d into client. \n", (unsigned int) wire_size, curcol->column_cur_size); return TDS_FAIL; } return TDS_SUCCESS; } /** * Get N bytes from the buffer and return them in the already allocated space * given to us. We ASSUME that the person calling this function has done the * bounds checking for us since they know how many bytes they want here. * dest of NULL means we just want to eat the bytes. (tetherow@nol.org) */ void * tds_get_n(TDSSOCKET * tds, void *dest, size_t need) { for (;;) { unsigned int have = tds->in_len - tds->in_pos; if (need <= have) break; /* We need more than is in the buffer, copy what is there */ if (dest != NULL) { memcpy((char *) dest, tds->in_buf + tds->in_pos, have); dest = (char *) dest + have; } need -= have; if (TDS_UNLIKELY(tds_read_packet(tds) < 0)) return NULL; } if (need > 0) { /* get the remainder if there is any */ if (dest != NULL) { memcpy((char *) dest, tds->in_buf + tds->in_pos, need); } tds->in_pos += need; } return dest; } /** * For UTF-8 and similar, tds_iconv() may encounter a partial sequence when the chunk boundary * is not aligned with the character boundary. In that event, it will return an error, and * some number of bytes (less than a character) will remain in the tail end of temp[]. They are * moved to the beginning, ptemp is adjusted to point just behind them, and the next chunk is read. * \tds * \param char_conv conversion structure * \param[out] wire_size size readed from wire * \param outbuf buffer to write to * \param outbytesleft buffer length * \return bytes readed */ static size_t read_and_convert(TDSSOCKET * tds, TDSICONV * char_conv, size_t * wire_size, char *outbuf, size_t outbytesleft) { int res; TDSDATAINSTREAM r; TDSSTATICOUTSTREAM w; tds_datain_stream_init(&r, tds, *wire_size); tds_staticout_stream_init(&w, outbuf, outbytesleft); res = tds_convert_stream(tds, char_conv, to_client, &r.stream, &w.stream); *wire_size = r.wire_size; return (char *) w.stream.buffer - outbuf; } /** * Reads a string from wire and put in a DSTR. * On error we read the bytes from the wire anyway. * \tds * \param[out] s output string * \param[in] len string length (in characters) * \return string or NULL on error */ DSTR* tds_dstr_get(TDSSOCKET * tds, DSTR * s, size_t len) { size_t out_len; CHECK_TDS_EXTRA(tds); /* assure sufficient space for every conversion */ if (TDS_UNLIKELY(!tds_dstr_alloc(s, len * 4))) { tds_get_n(tds, NULL, len); return NULL; } out_len = tds_get_string(tds, len, tds_dstr_buf(s), len * 4); tds_dstr_setlen(s, out_len); return s; } /** @} */ freetds-1.00.82/src/tds/write.c100644 025423 025423 00000015411 12717145107 0011714/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Brian Bruns * Copyright (C) 2005 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #include #if HAVE_ERRNO_H #include #endif /* HAVE_ERRNO_H */ #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #include #include #include #include #include /** * \addtogroup network * @{ */ /* * CRE 01262002 making buf a void * means we can put any type without casting * much like read() and memcpy() */ int tds_put_n(TDSSOCKET * tds, const void *buf, size_t n) { size_t left; const unsigned char *bufp = (const unsigned char *) buf; for (; n;) { if (tds->out_buf_max <= tds->out_pos) { tds_write_packet(tds, 0x0); continue; } left = tds->out_buf_max - tds->out_pos; if (left > n) left = n; if (bufp) { memcpy(tds->out_buf + tds->out_pos, bufp, left); bufp += left; } else { memset(tds->out_buf + tds->out_pos, 0, left); } tds->out_pos += (unsigned int)left; n -= left; } return 0; } /** * Output a string to wire * automatic translate string to unicode if needed * \return bytes written to wire * \param tds state information for the socket and the TDS protocol * \param s string to write * \param len length of string in characters, or -1 for null terminated */ int tds_put_string(TDSSOCKET * tds, const char *s, int len) { int res; TDSSTATICINSTREAM r; TDSDATAOUTSTREAM w; if (len < 0) { TDS_ENCODING *client; client = &tds->conn->char_convs[client2ucs2]->from.charset; if (client->min_bytes_per_char == 1) { /* ascii or UTF-8 */ len = (int)strlen(s); } else if (client->min_bytes_per_char == 2) { /* UCS-2 or variant */ const char *p = s; while (p[0] || p[1]) p += 2; len = (int)(p - s); } else if (client->min_bytes_per_char == 4) { /* UCS-4 or variant */ const char *p = s; while (p[0] || p[1] || p[2] || p[3]) p += 4; len = (int)(p - s); } else { assert(client->min_bytes_per_char < 3); /* FIXME */ } } assert(len >= 0); /* valid test only if client and server share a character set. TODO conversions for Sybase */ if (!IS_TDS7_PLUS(tds->conn)) { tds_put_n(tds, s, len); return len; } tds_staticin_stream_init(&r, s, len); tds_dataout_stream_init(&w, tds); res = tds_convert_stream(tds, tds->conn->char_convs[client2ucs2], to_server, &r.stream, &w.stream); return w.written; } int tds_put_buf(TDSSOCKET * tds, const unsigned char *buf, int dsize, int ssize) { int cpsize; cpsize = ssize > dsize ? dsize : ssize; tds_put_n(tds, buf, cpsize); dsize -= cpsize; tds_put_n(tds, NULL, dsize); return tds_put_byte(tds, cpsize); } int tds_put_int8(TDSSOCKET * tds, TDS_INT8 i) { #if TDS_ADDITIONAL_SPACE < 8 #if WORDS_BIGENDIAN TDS_UINT h; if (tds->conn->emul_little_endian) { h = (TDS_UINT) i; tds_put_byte(tds, h & 0x000000FF); tds_put_byte(tds, (h & 0x0000FF00) >> 8); tds_put_byte(tds, (h & 0x00FF0000) >> 16); tds_put_byte(tds, (h & 0xFF000000) >> 24); h = (TDS_UINT) (i >> 32); tds_put_byte(tds, h & 0x000000FF); tds_put_byte(tds, (h & 0x0000FF00) >> 8); tds_put_byte(tds, (h & 0x00FF0000) >> 16); tds_put_byte(tds, (h & 0xFF000000) >> 24); return 0; } #endif return tds_put_n(tds, (const unsigned char *) &i, sizeof(TDS_INT8)); #else TDS_UCHAR *p; if (tds->out_pos >= tds->out_buf_max) tds_write_packet(tds, 0x0); p = &tds->out_buf[tds->out_pos]; #if WORDS_BIGENDIAN if (tds->conn->emul_little_endian) { TDS_PUT_UA4LE(p, (TDS_UINT) i); TDS_PUT_UA4LE(p+4, (TDS_UINT) (i >> 32)); } else { TDS_PUT_UA4(p, (TDS_UINT) (i >> 32)); TDS_PUT_UA4(p+4, (TDS_UINT) i); } #else TDS_PUT_UA4(p, (TDS_UINT) i); TDS_PUT_UA4(p+4, (TDS_UINT) (i >> 32)); #endif tds->out_pos += 8; return 0; #endif } int tds_put_int(TDSSOCKET * tds, TDS_INT i) { #if TDS_ADDITIONAL_SPACE < 4 #if WORDS_BIGENDIAN if (tds->conn->emul_little_endian) { tds_put_byte(tds, i & 0x000000FF); tds_put_byte(tds, (i & 0x0000FF00) >> 8); tds_put_byte(tds, (i & 0x00FF0000) >> 16); tds_put_byte(tds, (i & 0xFF000000) >> 24); return 0; } #endif return tds_put_n(tds, (const unsigned char *) &i, sizeof(TDS_INT)); #else TDS_UCHAR *p; if (tds->out_pos >= tds->out_buf_max) tds_write_packet(tds, 0x0); p = &tds->out_buf[tds->out_pos]; #if WORDS_BIGENDIAN if (tds->conn->emul_little_endian) TDS_PUT_UA4LE(p, i); else TDS_PUT_UA4(p, i); #else TDS_PUT_UA4(p, i); #endif tds->out_pos += 4; return 0; #endif } int tds_put_smallint(TDSSOCKET * tds, TDS_SMALLINT si) { #if TDS_ADDITIONAL_SPACE < 2 #if WORDS_BIGENDIAN if (tds->conn->emul_little_endian) { tds_put_byte(tds, si & 0x000000FF); tds_put_byte(tds, (si & 0x0000FF00) >> 8); return 0; } #endif return tds_put_n(tds, (const unsigned char *) &si, sizeof(TDS_SMALLINT)); #else TDS_UCHAR *p; if (tds->out_pos >= tds->out_buf_max) tds_write_packet(tds, 0x0); p = &tds->out_buf[tds->out_pos]; #if WORDS_BIGENDIAN if (tds->conn->emul_little_endian) TDS_PUT_UA2LE(p, si); else TDS_PUT_UA2(p, si); #else TDS_PUT_UA2(p, si); #endif tds->out_pos += 2; return 0; #endif } int tds_put_byte(TDSSOCKET * tds, unsigned char c) { if (tds->out_pos >= (unsigned int)tds->out_buf_max) tds_write_packet(tds, 0x0); tds->out_buf[tds->out_pos++] = c; return 0; } int tds_init_write_buf(TDSSOCKET * tds) { TDS_MARK_UNDEFINED(tds->out_buf, tds->out_buf_max); tds->out_pos = 8; return 0; } /** * Flush packet to server * @return TDS_FAIL or TDS_SUCCESS */ TDSRET tds_flush_packet(TDSSOCKET * tds) { TDSRET result = TDS_FAIL; /* GW added check for tds->s */ if (!IS_TDSDEAD(tds)) { #if TDS_ADDITIONAL_SPACE != 0 if (tds->out_pos > tds->out_buf_max) { result = tds_write_packet(tds, 0x00); if (TDS_FAILED(result)) return result; } #endif result = tds_write_packet(tds, 0x01); } return result; } /** @} */ freetds-1.00.82/src/tds/convert.c100644 025423 025423 00000244470 13160677622 0012260/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns * Copyright (C) 2010-2015 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #include #include #include #if HAVE_ERRNO_H #include #endif /* HAVE_ERRNO_H */ #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_STRINGS_H #include #endif /* HAVE_STRINGS_H */ #include #include #include #include "replacements.h" typedef unsigned short utf16_t; struct tds_time { int tm_year; /**< year (0=1900) */ int tm_mon; /**< month (0-11) */ int tm_mday; /**< month day (1-31) */ int tm_hour; /**< hours (0-23) */ int tm_min; /**< minutes (0-59) */ int tm_sec; /**< seconds (0-59) */ int tm_ns; /**< nanoseconds (0-999999999) */ }; static TDS_INT tds_convert_int(TDS_INT num, int desttype, CONV_RESULT * cr); static TDS_INT tds_convert_int1(const TDS_TINYINT * src, int desttype, CONV_RESULT * cr); static TDS_INT tds_convert_int2(const TDS_SMALLINT * src, int desttype, CONV_RESULT * cr); static TDS_INT tds_convert_uint2(const TDS_USMALLINT * src, int desttype, CONV_RESULT * cr); static TDS_INT tds_convert_int4(const TDS_INT* src, int desttype, CONV_RESULT * cr); static TDS_INT tds_convert_uint4(const TDS_UINT * src, int desttype, CONV_RESULT * cr); static TDS_INT tds_convert_int8(const TDS_INT8 * src, int desttype, CONV_RESULT * cr); static TDS_INT tds_convert_uint8(const TDS_UINT8 * src, int desttype, CONV_RESULT * cr); static int string_to_datetime(const char *datestr, TDS_UINT len, int desttype, CONV_RESULT * cr); static bool is_dd_mon_yyyy(char *t); static int store_dd_mon_yyy_date(char *datestr, struct tds_time *t); static const char *parse_numeric(const char *buf, const char *pend, bool * p_negative, size_t *p_digits, size_t *p_decimals); #define test_alloc(x) {if ((x)==NULL) return TDS_CONVERT_NOMEM;} #define IS_TINYINT(x) ( 0 <= (x) && (x) <= 0xff ) #define IS_SMALLINT(x) ( -32768 <= (x) && (x) <= 32767 ) #define IS_USMALLINT(x) ( 0 <= (x) && (x) <= 65535 ) /* * f77: I don't write -2147483648, some compiler seem to have some problem * with this constant although is a valid 32bit value */ #define TDS_INT_MIN (-2147483647l-1l) #define TDS_INT_MAX 2147483647l #define IS_INT(x) (TDS_INT_MIN <= (x) && (x) <= TDS_INT_MAX) #define TDS_UINT_MAX 4294967295lu #define IS_UINT(x) (0 <= (x) && (x) <= TDS_UINT_MAX) #define TDS_INT8_MAX ((((TDS_INT8) 0x7fffffffl) << 32) + (TDS_INT8) 0xfffffffflu) #define TDS_INT8_MIN (((TDS_INT8) (-0x7fffffffl-1)) << 32) #define IS_INT8(x) (TDS_INT8_MIN <= (x) && (x) <= TDS_INT8_MAX) #define TDS_UINT8_MAX ((((TDS_UINT8) 0xfffffffflu) << 32) + 0xfffffffflu) #define IS_UINT8(x) (0 <= (x) && (x) <= TDS_UINT8_MAX) #define TDS_ISDIGIT(c) ((c) >= '0' && (c) <= '9') #define BIGDATETIME_BIAS 693961 /** * \ingroup libtds * \defgroup convert Conversion * Conversions between datatypes. Supports, for example, dbconvert(). */ /** * \addtogroup convert * @{ */ /** * convert a number in string to a TDSNUMERIC * @return sizeof(TDS_NUMERIC) on success, TDS_CONVERT_* failure code on failure */ static int string_to_numeric(const char *instr, const char *pend, CONV_RESULT * cr); /** * convert a zero terminated string to NUMERIC * @return sizeof(TDS_NUMERIC) on success, TDS_CONVERT_* failure code on failure */ static int stringz_to_numeric(const char *instr, CONV_RESULT * cr); static TDS_INT string_to_int(const char *buf, const char *pend, TDS_INT * res); static TDS_INT string_to_int8(const char *buf, const char *pend, TDS_INT8 * res); static TDS_INT string_to_uint8(const char *buf, const char *pend, TDS_UINT8 * res); static TDS_INT string_to_float(const TDS_CHAR * src, TDS_UINT srclen, int desttype, CONV_RESULT * cr); static int store_hour(const char *, const char *, struct tds_time *); static int store_time(const char *, struct tds_time *); static int store_yymmdd_date(const char *, struct tds_time *); static int store_monthname(const char *, struct tds_time *); static int store_numeric_date(const char *, struct tds_time *); static int store_mday(const char *, struct tds_time *); static int store_year(int, struct tds_time *); /* static int days_this_year (int years); */ static bool is_timeformat(const char *); static bool is_numeric(const char *); static bool is_alphabetic(const char *); static bool is_ampm(const char *); #define is_monthname(s) (store_monthname(s, NULL) >= 0) static bool is_numeric_dateformat(const char *); #if 0 static TDS_UINT utf16len(const utf16_t * s); static const char *tds_prtype(int token); #endif const char tds_hex_digits[] = "0123456789abcdef"; /** * Copy a terminated string to result and return len or TDS_CONVERT_NOMEM */ static TDS_INT string_to_result(int desttype, const char *s, CONV_RESULT * cr) { size_t len = strlen(s); if (desttype != TDS_CONVERT_CHAR) { cr->c = tds_new(TDS_CHAR, len + 1); test_alloc(cr->c); memcpy(cr->c, s, len + 1); } else { memcpy(cr->cc.c, s, len < cr->cc.len ? len : cr->cc.len); } return (TDS_INT)len; } #define string_to_result(s, cr) \ string_to_result(desttype, s, cr) /** * Copy binary data to to result and return len or TDS_CONVERT_NOMEM */ static TDS_INT binary_to_result(int desttype, const void *data, size_t len, CONV_RESULT * cr) { if (desttype != TDS_CONVERT_BINARY) { cr->ib = tds_new(TDS_CHAR, len); test_alloc(cr->ib); memcpy(cr->ib, data, len); } else { memcpy(cr->cb.ib, data, len < cr->cb.len ? len : cr->cb.len); } return (TDS_INT)len; } #define CASE_ALL_CHAR \ SYBCHAR: case SYBVARCHAR: case SYBTEXT: case XSYBCHAR: case XSYBVARCHAR #define CASE_ALL_BINARY \ SYBBINARY: case SYBVARBINARY: case SYBIMAGE: case XSYBBINARY: case XSYBVARBINARY: \ case SYBLONGBINARY: case TDS_CONVERT_BINARY /* TODO implement me */ /* static TDS_INT tds_convert_ntext(int srctype,TDS_CHAR *src,TDS_UINT srclen, int desttype, CONV_RESULT *cr) { return TDS_CONVERT_NOAVAIL; } */ static TDS_INT tds_convert_binary(const TDS_UCHAR * src, TDS_INT srclen, int desttype, CONV_RESULT * cr) { int cplen; int s; char *c; switch (desttype) { case TDS_CONVERT_CHAR: cplen = srclen * 2; if ((TDS_UINT)cplen > cr->cc.len) cplen = cr->cc.len; c = cr->cc.c; for (s = 0; cplen >= 2; ++s, cplen -= 2) { *c++ = tds_hex_digits[src[s]>>4]; *c++ = tds_hex_digits[src[s]&0xF]; } if (cplen) *c = tds_hex_digits[src[s]>>4]; return srclen * 2; case CASE_ALL_CHAR: /* * NOTE: Do not prepend 0x to string. * The libraries all expect a bare string, without a 0x prefix. * Applications such as isql and query analyzer provide the "0x" prefix. */ /* 2 * source length + 1 for terminator */ cr->c = tds_new(TDS_CHAR, (srclen * 2) + 1); test_alloc(cr->c); c = cr->c; for (s = 0; s < srclen; s++) { *c++ = tds_hex_digits[src[s]>>4]; *c++ = tds_hex_digits[src[s]&0xF]; } *c = '\0'; return (srclen * 2); break; case SYBINT1: case SYBUINT1: case SYBINT2: case SYBUINT2: case SYBINT4: case SYBUINT4: case SYBINT8: case SYBUINT8: case SYBMONEY4: case SYBMONEY: case SYBREAL: case SYBFLT8: cplen = tds_get_size_by_type(desttype); if (srclen >= cplen) srclen = cplen; memcpy(cr, src, srclen); memset(((char*) cr) + srclen, 0, cplen - srclen); return cplen; break; /* conversions not allowed */ case SYBDATETIME4: case SYBDATETIME: case SYBDATETIMN: /* TODO should we do some test for these types or work as ints ?? */ case SYBDECIMAL: case SYBNUMERIC: case SYBBIT: case SYBBITN: default: break; } return TDS_CONVERT_NOAVAIL; } TDS_INT tds_char2hex(TDS_CHAR *dest, TDS_UINT destlen, const TDS_CHAR * src, TDS_UINT srclen) { unsigned int i; unsigned char hex1, c = 0; /* if srclen if odd we must add a "0" before ... */ i = 0; /* number where to start converting */ if (srclen & 1) { ++srclen; i = 1; --src; } for (; i < srclen; ++i) { hex1 = src[i]; if ('0' <= hex1 && hex1 <= '9') hex1 &= 0x0f; else { hex1 &= 0x20 ^ 0xff; /* mask off 0x20 to ensure upper case */ if ('A' <= hex1 && hex1 <= 'F') { hex1 -= ('A' - 10); } else { tdsdump_log(TDS_DBG_INFO1, "error_handler: attempt to convert data stopped by syntax error in source field \n"); return TDS_CONVERT_SYNTAX; } } assert(hex1 < 0x10); if ((i/2u) >= destlen) continue; if (i & 1) dest[i / 2u] = c | hex1; else c = hex1 << 4; } return srclen / 2u; } static TDS_INT tds_convert_char(const TDS_CHAR * src, TDS_UINT srclen, int desttype, CONV_RESULT * cr) { unsigned int i; TDS_INT8 mymoney; char mynumber[28]; TDS_INT tds_i; TDS_INT8 tds_i8; TDS_UINT8 tds_ui8; TDS_INT rc; bool negative; size_t digits, decimals; switch (desttype) { case TDS_CONVERT_CHAR: memcpy(cr->cc.c, src, srclen < cr->cc.len ? srclen : cr->cc.len); return srclen; case CASE_ALL_CHAR: cr->c = tds_new(TDS_CHAR, srclen + 1); test_alloc(cr->c); memcpy(cr->c, src, srclen); cr->c[srclen] = 0; return srclen; break; case SYBINT1: case SYBUINT1: if ((rc = string_to_int(src, src + srclen, &tds_i)) < 0) return rc; if (!IS_TINYINT(tds_i)) return TDS_CONVERT_OVERFLOW; cr->ti = tds_i; return sizeof(TDS_TINYINT); break; case SYBINT2: if ((rc = string_to_int(src, src + srclen, &tds_i)) < 0) return rc; if (!IS_SMALLINT(tds_i)) return TDS_CONVERT_OVERFLOW; cr->si = tds_i; return sizeof(TDS_SMALLINT); break; case SYBUINT2: if ((rc = string_to_int(src, src + srclen, &tds_i)) < 0) return rc; if (!IS_USMALLINT(tds_i)) return TDS_CONVERT_OVERFLOW; cr->usi = (TDS_USMALLINT) tds_i; return sizeof(TDS_USMALLINT); break; case SYBINT4: if ((rc = string_to_int(src, src + srclen, &tds_i)) < 0) return rc; cr->i = tds_i; return sizeof(TDS_INT); break; case SYBUINT4: if ((rc = string_to_int8(src, src + srclen, &tds_i8)) < 0) return rc; if (!IS_UINT(tds_i8)) return TDS_CONVERT_OVERFLOW; cr->ui = (TDS_UINT) tds_i8; return sizeof(TDS_UINT); break; case SYBINT8: if ((rc = string_to_int8(src, src + srclen, &tds_i8)) < 0) return rc; cr->bi = tds_i8; return sizeof(TDS_INT8); break; case SYBUINT8: if ((rc = string_to_uint8(src, src + srclen, &tds_ui8)) < 0) return rc; cr->ubi = tds_ui8; return sizeof(TDS_UINT8); break; case SYBFLT8: case SYBREAL: return string_to_float(src, srclen, desttype, cr); break; case SYBBIT: case SYBBITN: if ((rc = string_to_int(src, src + srclen, &tds_i)) < 0) return rc; cr->ti = tds_i ? 1 : 0; return sizeof(TDS_TINYINT); break; case SYBMONEY: case SYBMONEY4: src = parse_numeric(src, src + srclen, &negative, &digits, &decimals); if (!src) return TDS_CONVERT_SYNTAX; if (digits > 18) return TDS_CONVERT_OVERFLOW; i = 0; if (negative) mynumber[i++] = '-'; for (; digits; --digits) mynumber[i++] = *src++; src++; for (digits = 0; digits < 4 && digits < decimals; ++digits) mynumber[i++] = *src++; for (; digits < 4; ++digits) mynumber[i++] = '0'; /* convert number and check for overflow */ if (string_to_int8(mynumber, mynumber + i, &mymoney) < 0) return TDS_CONVERT_OVERFLOW; if (desttype == SYBMONEY) { cr->m.mny = mymoney; return sizeof(TDS_MONEY); } else { if (!IS_INT(mymoney)) return TDS_CONVERT_OVERFLOW; cr->m4.mny4 = (TDS_INT) mymoney; return sizeof(TDS_MONEY4); } break; case SYBDATETIME: case SYBDATETIME4: case SYBMSTIME: case SYBMSDATE: case SYBMSDATETIME2: case SYBMSDATETIMEOFFSET: case SYBTIME: case SYBDATE: case SYB5BIGTIME: case SYB5BIGDATETIME: return string_to_datetime(src, srclen, desttype, cr); break; case SYBNUMERIC: case SYBDECIMAL: return string_to_numeric(src, src + srclen, cr); break; case SYBUNIQUE:{ unsigned n = 0; char c; /* * format: XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX * or {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} * or XXXXXXXX-XXXX-XXXX-XXXXXXXXXXXXXXXX * or {XXXXXXXX-XXXX-XXXX-XXXXXXXXXXXXXXXX} * SQL seem to ignore the additional braces. */ if (srclen < (32 + 3)) return TDS_CONVERT_SYNTAX; if (src[0] == '{') { TDS_UINT last = (src[8+1 + 4+1 + 4+1 + 4 + 1] == '-') ? 32+4+1 : 32+3+1; if (srclen <= last || src[last] != '}') return TDS_CONVERT_SYNTAX; ++src; } /* * Test each character and get value. * sscanf works if the number terminates with less digits. */ for (i = 0; i < 32 + 3; ++i) { c = src[i]; switch (i) { case 8: if (c != '-') return TDS_CONVERT_SYNTAX; cr->u.Data1 = n; n = 0; break; case 8+1 + 4: if (c != '-') return TDS_CONVERT_SYNTAX; cr->u.Data2 = n; n = 0; break; case 8+1 + 4+1 + 4: if (c != '-') return TDS_CONVERT_SYNTAX; cr->u.Data3 = n; n = 0; break; case 8+1 + 4+1 + 4+1 + 4: /* skip last (optional) dash */ if (c == '-') { if (--srclen < 32 + 3) return TDS_CONVERT_SYNTAX; c = (++src)[i]; } /* fall through */ default: n = n << 4; if (c >= '0' && c <= '9') n += c - '0'; else { c &= 0x20 ^ 0xff; if (c >= 'A' && c <= 'F') n += c - ('A' - 10); else return TDS_CONVERT_SYNTAX; } if (i > (16 + 2) && !(i & 1)) { cr->u.Data4[(i >> 1) - 10] = n; n = 0; } } } } return sizeof(TDS_UNIQUE); default: return TDS_CONVERT_NOAVAIL; break; } /* end switch */ } /* tds_convert_char */ static TDS_INT tds_convert_bit(const TDS_CHAR * src, int desttype, CONV_RESULT * cr) { return tds_convert_int(src[0] ? 1 : 0, desttype, cr); } static TDS_INT tds_convert_int1(const TDS_TINYINT * src, int desttype, CONV_RESULT * cr) { return tds_convert_int(*src, desttype, cr); } static TDS_INT tds_convert_int2(const TDS_SMALLINT * src, int desttype, CONV_RESULT * cr) { return tds_convert_int(*src, desttype, cr); } static TDS_INT tds_convert_uint2(const TDS_USMALLINT * src, int desttype, CONV_RESULT * cr) { return tds_convert_int(*src, desttype, cr); } static TDS_INT tds_convert_int4(const TDS_INT * src, int desttype, CONV_RESULT * cr) { return tds_convert_int(*src, desttype, cr); } static TDS_INT tds_convert_uint4(const TDS_UINT * src, int desttype, CONV_RESULT * cr) { TDS_UINT8 num; num = *src; return tds_convert_uint8(&num, desttype, cr); } static TDS_INT tds_convert_int_numeric(unsigned char scale, unsigned char sign, TDS_UINT num, CONV_RESULT * cr) { unsigned char orig_prec = cr->n.precision, orig_scale = cr->n.scale; cr->n.precision = 10; cr->n.scale = scale; cr->n.array[0] = sign; cr->n.array[1] = 0; TDS_PUT_UA4BE(&(cr->n.array[2]), num); return tds_numeric_change_prec_scale(&(cr->n), orig_prec, orig_scale); } static TDS_INT tds_convert_int8_numeric(unsigned char scale, unsigned char sign, TDS_UINT8 num, CONV_RESULT * cr) { unsigned char orig_prec = cr->n.precision, orig_scale = cr->n.scale; cr->n.precision = 20; cr->n.scale = scale; cr->n.array[0] = sign; cr->n.array[1] = 0; TDS_PUT_UA4BE(&(cr->n.array[2]), (TDS_UINT) (num >> 32)); TDS_PUT_UA4BE(&(cr->n.array[6]), (TDS_UINT) num); return tds_numeric_change_prec_scale(&(cr->n), orig_prec, orig_scale); } static TDS_INT tds_convert_int(TDS_INT num, int desttype, CONV_RESULT * cr) { TDS_CHAR tmp_str[16]; switch (desttype) { case TDS_CONVERT_CHAR: case CASE_ALL_CHAR: sprintf(tmp_str, "%d", num); return string_to_result(tmp_str, cr); break; case SYBINT1: case SYBUINT1: if (!IS_TINYINT(num)) return TDS_CONVERT_OVERFLOW; cr->ti = (TDS_TINYINT) num; return sizeof(TDS_TINYINT); break; case SYBINT2: if (!IS_SMALLINT(num)) return TDS_CONVERT_OVERFLOW; cr->si = num; return sizeof(TDS_SMALLINT); break; case SYBUINT2: if (!IS_USMALLINT(num)) return TDS_CONVERT_OVERFLOW; cr->usi = (TDS_USMALLINT) num; return sizeof(TDS_USMALLINT); break; case SYBINT4: cr->i = num; return sizeof(TDS_INT); break; case SYBUINT4: if (num < 0) return TDS_CONVERT_OVERFLOW; cr->ui = (TDS_UINT) num; return sizeof(TDS_UINT); break; case SYBINT8: cr->bi = num; return sizeof(TDS_INT8); break; case SYBUINT8: if (num < 0) return TDS_CONVERT_OVERFLOW; cr->ubi = (TDS_UINT8) num; return sizeof(TDS_UINT8); break; case SYBBIT: case SYBBITN: cr->ti = num ? 1 : 0; return sizeof(TDS_TINYINT); break; case SYBFLT8: cr->f = num; return sizeof(TDS_FLOAT); break; case SYBREAL: cr->r = (TDS_REAL) num; return sizeof(TDS_REAL); break; case SYBMONEY4: if (num > 214748 || num < -214748) return TDS_CONVERT_OVERFLOW; cr->m4.mny4 = num * 10000; return sizeof(TDS_MONEY4); break; case SYBMONEY: cr->m.mny = (TDS_INT8) num *10000; return sizeof(TDS_MONEY); break; case SYBNUMERIC: case SYBDECIMAL: if (num < 0) return tds_convert_int_numeric(0, 1, (TDS_UINT) -num, cr); return tds_convert_int_numeric(0, 0, (TDS_UINT) num, cr); break; /* handled by upper layer */ case CASE_ALL_BINARY: /* conversions not allowed */ case SYBUNIQUE: case SYBDATETIME4: case SYBDATETIME: case SYBDATETIMN: default: break; } return TDS_CONVERT_NOAVAIL; } static TDS_INT tds_convert_int8(const TDS_INT8 *src, int desttype, CONV_RESULT * cr) { TDS_INT8 buf; TDS_CHAR tmp_str[24]; memcpy(&buf, src, sizeof(buf)); if (IS_INT(buf)) return tds_convert_int((TDS_INT) buf, desttype, cr); switch (desttype) { case TDS_CONVERT_CHAR: case CASE_ALL_CHAR: sprintf(tmp_str, "%" PRId64, buf); return string_to_result(tmp_str, cr); break; case SYBINT1: case SYBUINT1: case SYBINT2: case SYBUINT2: case SYBINT4: case SYBMONEY4: return TDS_CONVERT_OVERFLOW; break; case SYBUINT4: if (!IS_UINT(buf)) return TDS_CONVERT_OVERFLOW; cr->ui = (TDS_UINT) buf; return sizeof(TDS_UINT); break; case SYBINT8: cr->bi = buf; return sizeof(TDS_INT8); break; case SYBUINT8: if (buf < 0) return TDS_CONVERT_OVERFLOW; cr->ubi = (TDS_UINT8) buf; return sizeof(TDS_UINT8); break; case SYBBIT: case SYBBITN: /* this cannot be 0 as already tested above */ cr->ti = 1; return sizeof(TDS_TINYINT); break; case SYBFLT8: cr->f = (TDS_FLOAT) buf; return sizeof(TDS_FLOAT); break; case SYBREAL: cr->r = (TDS_REAL) buf; return sizeof(TDS_REAL); break; case SYBMONEY: if (buf > (TDS_INT8_MAX / 10000) || buf < (TDS_INT8_MIN / 10000)) return TDS_CONVERT_OVERFLOW; cr->m.mny = buf * 10000; return sizeof(TDS_MONEY); break; case SYBNUMERIC: case SYBDECIMAL: if (buf < 0) return tds_convert_int8_numeric(0, 1, -buf, cr); return tds_convert_int8_numeric(0, 0, buf, cr); break; /* conversions not allowed */ case SYBUNIQUE: case SYBDATETIME4: case SYBDATETIME: case SYBDATETIMN: default: break; } return TDS_CONVERT_NOAVAIL; } static TDS_INT tds_convert_uint8(const TDS_UINT8 *src, int desttype, CONV_RESULT * cr) { TDS_UINT8 buf; TDS_CHAR tmp_str[24]; memcpy(&buf, src, sizeof(buf)); /* IS_INT does not work here due to unsigned/signed conversions */ if (buf <= (TDS_UINT8) TDS_INT_MAX) return tds_convert_int((TDS_INT) buf, desttype, cr); switch (desttype) { case TDS_CONVERT_CHAR: case CASE_ALL_CHAR: sprintf(tmp_str, "%" PRIu64, buf); return string_to_result(tmp_str, cr); break; case SYBINT1: case SYBUINT1: case SYBINT2: case SYBUINT2: case SYBINT4: case SYBMONEY4: return TDS_CONVERT_OVERFLOW; break; case SYBUINT4: if (!IS_UINT(buf)) return TDS_CONVERT_OVERFLOW; cr->ui = (TDS_UINT) buf; return sizeof(TDS_UINT); break; case SYBINT8: if (buf > (TDS_UINT8) TDS_INT8_MAX) return TDS_CONVERT_OVERFLOW; cr->bi = (TDS_INT8) buf; return sizeof(TDS_INT8); break; case SYBUINT8: cr->ubi = buf; return sizeof(TDS_UINT8); break; case SYBBIT: case SYBBITN: /* this cannot be 0 as already tested above */ cr->ti = 1; return sizeof(TDS_TINYINT); break; case SYBFLT8: cr->f = (TDS_FLOAT) buf; return sizeof(TDS_FLOAT); break; case SYBREAL: cr->r = (TDS_REAL) buf; return sizeof(TDS_REAL); break; case SYBMONEY: if (buf > (TDS_INT8_MAX / 10000)) return TDS_CONVERT_OVERFLOW; cr->m.mny = buf * 10000; return sizeof(TDS_MONEY); break; case SYBNUMERIC: case SYBDECIMAL: return tds_convert_int8_numeric(0, 0, buf, cr); break; /* conversions not allowed */ case SYBUNIQUE: case SYBDATETIME4: case SYBDATETIME: case SYBDATETIMN: default: break; } return TDS_CONVERT_NOAVAIL; } static TDS_INT tds_convert_numeric(const TDS_NUMERIC * src, int desttype, CONV_RESULT * cr) { char tmpstr[MAXPRECISION]; TDS_INT i, ret; TDS_INT8 bi; switch (desttype) { case TDS_CONVERT_CHAR: case CASE_ALL_CHAR: if (tds_numeric_to_string(src, tmpstr) < 0) return TDS_CONVERT_FAIL; return string_to_result(tmpstr, cr); break; case SYBINT1: case SYBUINT1: cr->n = *src; ret = tds_numeric_change_prec_scale(&(cr->n), 3, 0); if (ret < 0) return ret; if (cr->n.array[1] || (cr->n.array[0] && cr->n.array[2])) return TDS_CONVERT_OVERFLOW; cr->ti = cr->n.array[2]; return sizeof(TDS_TINYINT); break; case SYBINT2: cr->n = *src; ret = tds_numeric_change_prec_scale(&(cr->n), 5, 0); if (ret < 0) return ret; if (cr->n.array[1]) return TDS_CONVERT_OVERFLOW; i = TDS_GET_UA2BE(&(cr->n.array[2])); if (cr->n.array[0]) i = -i; if (((i >> 15) ^ cr->n.array[0]) & 1) return TDS_CONVERT_OVERFLOW; cr->si = (TDS_SMALLINT) i; return sizeof(TDS_SMALLINT); break; case SYBUINT2: cr->n = *src; ret = tds_numeric_change_prec_scale(&(cr->n), 5, 0); if (ret < 0) return ret; if (cr->n.array[0] || cr->n.array[1]) return TDS_CONVERT_OVERFLOW; i = TDS_GET_UA2BE(&(cr->n.array[2])); cr->usi = (TDS_USMALLINT) i; return sizeof(TDS_USMALLINT); break; case SYBINT4: cr->n = *src; ret = tds_numeric_change_prec_scale(&(cr->n), 10, 0); if (ret < 0) return ret; if (cr->n.array[1]) return TDS_CONVERT_OVERFLOW; i = TDS_GET_UA4BE(&(cr->n.array[2])); if (cr->n.array[0]) i = -i; if (((i >> 31) ^ cr->n.array[0]) & 1) return TDS_CONVERT_OVERFLOW; cr->i = i; return sizeof(TDS_INT); break; case SYBUINT4: cr->n = *src; ret = tds_numeric_change_prec_scale(&(cr->n), 10, 0); if (ret < 0) return ret; if (cr->n.array[0] || cr->n.array[1]) return TDS_CONVERT_OVERFLOW; i = TDS_GET_UA4BE(&(cr->n.array[2])); cr->ui = i; return sizeof(TDS_UINT); break; case SYBINT8: cr->n = *src; ret = tds_numeric_change_prec_scale(&(cr->n), 20, 0); if (ret < 0) return ret; if (cr->n.array[1]) return TDS_CONVERT_OVERFLOW; bi = TDS_GET_UA4BE(&(cr->n.array[2])); bi = (bi << 32) + TDS_GET_UA4BE(&(cr->n.array[6])); if (cr->n.array[0]) bi = -bi; if (((bi >> 63) ^ cr->n.array[0]) & 1) return TDS_CONVERT_OVERFLOW; cr->bi = bi; return sizeof(TDS_INT8); break; case SYBUINT8: cr->n = *src; ret = tds_numeric_change_prec_scale(&(cr->n), 20, 0); if (ret < 0) return ret; if (cr->n.array[0] || cr->n.array[1]) return TDS_CONVERT_OVERFLOW; bi = TDS_GET_UA4BE(&(cr->n.array[2])); bi = (bi << 32) + TDS_GET_UA4BE(&(cr->n.array[6])); cr->ubi = bi; return sizeof(TDS_UINT8); break; case SYBBIT: case SYBBITN: cr->ti = 0; for (i = tds_numeric_bytes_per_prec[src->precision]; --i > 0;) if (src->array[i] != 0) { cr->ti = 1; break; } return sizeof(TDS_TINYINT); break; case SYBMONEY4: cr->n = *src; ret = tds_numeric_change_prec_scale(&(cr->n), 10, 4); if (ret < 0) return ret; if (cr->n.array[1]) return TDS_CONVERT_OVERFLOW; i = TDS_GET_UA4BE(&(cr->n.array[2])); if (cr->n.array[0]) i = -i; if (((i >> 31) ^ cr->n.array[0]) & 1) return TDS_CONVERT_OVERFLOW; cr->m4.mny4 = i; return sizeof(TDS_MONEY4); break; case SYBMONEY: cr->n = *src; ret = tds_numeric_change_prec_scale(&(cr->n), 20, 4); if (ret < 0) return ret; if (cr->n.array[1]) return TDS_CONVERT_OVERFLOW; bi = TDS_GET_UA4BE(&(cr->n.array[2])); bi = (bi << 32) + TDS_GET_UA4BE(&(cr->n.array[6])); if (cr->n.array[0]) bi = -bi; if (((bi >> 63) ^ cr->n.array[0]) & 1) return TDS_CONVERT_OVERFLOW; cr->m.mny = bi; return sizeof(TDS_MONEY); break; case SYBNUMERIC: case SYBDECIMAL: { unsigned char prec = cr->n.precision, scale = cr->n.scale; cr->n = *src; return tds_numeric_change_prec_scale(&(cr->n), prec, scale); } break; case SYBFLT8: if (tds_numeric_to_string(src, tmpstr) < 0) return TDS_CONVERT_FAIL; cr->f = atof(tmpstr); return 8; break; case SYBREAL: if (tds_numeric_to_string(src, tmpstr) < 0) return TDS_CONVERT_FAIL; cr->r = (TDS_REAL) atof(tmpstr); return 4; break; /* TODO conversions to money */ /* conversions not allowed */ case SYBUNIQUE: case SYBDATETIME4: case SYBDATETIME: case SYBDATETIMN: default: break; } return TDS_CONVERT_NOAVAIL; } static TDS_INT tds_convert_money4(const TDS_MONEY4 * src, int desttype, CONV_RESULT * cr) { TDS_MONEY4 mny; long dollars; char tmp_str[33]; char *p; mny = *src; switch (desttype) { case TDS_CONVERT_CHAR: case CASE_ALL_CHAR: /* * round to 2 decimal digits * rounding with dollars = (mny.mny4 + 5000) /10000 * can give arithmetic overflow so I use * dollars = (mny.mny4/50 + 1)/2 */ /* TODO round also all conversions to int and from money ?? */ p = tmp_str; if (mny.mny4 < 0) { *p++ = '-'; /* here (-mny.mny4 / 50 + 1 ) / 2 can cause overflow in -mny.mny4 */ dollars = -(mny.mny4 / 50 - 1 ) / 2; } else { dollars = (mny.mny4 / 50 + 1 ) / 2; } /* print only 2 decimal digits as server does */ sprintf(p, "%ld.%02lu", dollars / 100, dollars % 100); return string_to_result(tmp_str, cr); break; case SYBINT1: case SYBUINT1: dollars = mny.mny4 / 10000; if (!IS_TINYINT(dollars)) return TDS_CONVERT_OVERFLOW; cr->ti = (TDS_TINYINT) dollars; return sizeof(TDS_TINYINT); break; case SYBINT2: dollars = mny.mny4 / 10000; if (!IS_SMALLINT(dollars)) return TDS_CONVERT_OVERFLOW; cr->si = (TDS_SMALLINT) dollars; return sizeof(TDS_SMALLINT); break; case SYBUINT2: dollars = mny.mny4 / 10000; if (!IS_USMALLINT(dollars)) return TDS_CONVERT_OVERFLOW; cr->usi = (TDS_USMALLINT) dollars; return sizeof(TDS_USMALLINT); break; case SYBINT4: cr->i = mny.mny4 / 10000; return sizeof(TDS_INT); break; case SYBUINT4: dollars = mny.mny4 / 10000; if (!IS_UINT(dollars)) return TDS_CONVERT_OVERFLOW; cr->ui = dollars; return sizeof(TDS_UINT); break; case SYBINT8: cr->bi = mny.mny4 / 10000; return sizeof(TDS_INT8); break; case SYBUINT8: dollars = mny.mny4 / 10000; if (!IS_UINT8(dollars)) return TDS_CONVERT_OVERFLOW; cr->ubi = dollars; return sizeof(TDS_UINT8); break; case SYBBIT: case SYBBITN: cr->ti = mny.mny4 ? 1 : 0; return sizeof(TDS_TINYINT); break; case SYBFLT8: cr->f = ((TDS_FLOAT) mny.mny4) / 10000.0; return sizeof(TDS_FLOAT); break; case SYBREAL: cr->r = (TDS_REAL) (mny.mny4 / 10000.0); return sizeof(TDS_REAL); break; case SYBMONEY: cr->m.mny = (TDS_INT8) mny.mny4; return sizeof(TDS_MONEY); break; case SYBMONEY4: cr->m4 = mny; return sizeof(TDS_MONEY4); break; case SYBDECIMAL: case SYBNUMERIC: if (mny.mny4 < 0) return tds_convert_int_numeric(4, 1, (TDS_UINT) -mny.mny4, cr); return tds_convert_int_numeric(4, 0, (TDS_UINT) mny.mny4, cr); /* conversions not allowed */ case SYBUNIQUE: case SYBDATETIME4: case SYBDATETIME: case SYBDATETIMN: default: return TDS_CONVERT_NOAVAIL; break; } return TDS_CONVERT_FAIL; } static TDS_INT tds_convert_money(const TDS_MONEY * src, int desttype, CONV_RESULT * cr) { char *s; TDS_INT8 mymoney, dollars; char tmpstr[64]; tdsdump_log(TDS_DBG_FUNC, "tds_convert_money()\n"); mymoney = ((TDS_INT8) src->tdsoldmoney.mnyhigh << 32) | src->tdsoldmoney.mnylow; switch (desttype) { case TDS_CONVERT_CHAR: case CASE_ALL_CHAR: s = tds_money_to_string((const TDS_MONEY *) src, tmpstr); return string_to_result(s, cr); break; case SYBINT1: case SYBUINT1: if (mymoney <= -10000 || mymoney >= 256 * 10000) return TDS_CONVERT_OVERFLOW; /* TODO: round ?? */ cr->ti = (TDS_TINYINT) (((TDS_INT) mymoney) / 10000); return sizeof(TDS_TINYINT); break; case SYBINT2: if (mymoney <= -32769 * 10000 || mymoney >= 32768 * 10000) return TDS_CONVERT_OVERFLOW; cr->si = (TDS_SMALLINT) (((TDS_INT) mymoney) / 10000); return sizeof(TDS_SMALLINT); break; case SYBUINT2: if (mymoney <= -1 * 10000 || mymoney >= 65536 * 10000) return TDS_CONVERT_OVERFLOW; cr->usi = (TDS_USMALLINT) (((TDS_INT) mymoney) / 10000); return sizeof(TDS_USMALLINT); break; case SYBINT4: dollars = mymoney / 10000; if (!IS_INT(dollars)) return TDS_CONVERT_OVERFLOW; cr->i = (TDS_INT) dollars; return sizeof(TDS_INT); break; case SYBUINT4: dollars = mymoney / 10000; if (!IS_UINT(dollars)) return TDS_CONVERT_OVERFLOW; cr->ui = (TDS_UINT) dollars; return sizeof(TDS_UINT); break; case SYBINT8: cr->bi = mymoney / 10000; return sizeof(TDS_INT8); break; case SYBUINT8: dollars = mymoney / 10000; if (dollars < 0) return TDS_CONVERT_OVERFLOW; cr->ubi = (TDS_UINT8) dollars; return sizeof(TDS_UINT8); break; case SYBBIT: case SYBBITN: cr->ti = mymoney ? 1 : 0; return sizeof(TDS_TINYINT); break; case SYBFLT8: cr->f = ((TDS_FLOAT) mymoney) / 10000.0; return sizeof(TDS_FLOAT); break; case SYBREAL: cr->r = (TDS_REAL) (mymoney / 10000.0); return sizeof(TDS_REAL); break; case SYBMONEY4: if (!IS_INT(mymoney)) return TDS_CONVERT_OVERFLOW; cr->m4.mny4 = (TDS_INT) mymoney; return sizeof(TDS_MONEY4); break; case SYBMONEY: cr->m.mny = mymoney; return sizeof(TDS_MONEY); break; case SYBDECIMAL: case SYBNUMERIC: if (mymoney < 0) return tds_convert_int8_numeric(4, 1, -mymoney, cr); return tds_convert_int8_numeric(4, 0, mymoney, cr); break; /* conversions not allowed */ case SYBUNIQUE: case SYBDATETIME4: case SYBDATETIME: case SYBDATETIMN: default: break; } return TDS_CONVERT_NOAVAIL; } static TDS_INT tds_convert_datetimeall(const TDSCONTEXT * tds_ctx, int srctype, const TDS_DATETIMEALL * dta, int desttype, CONV_RESULT * cr) { char whole_date_string[64]; TDSDATEREC when; switch (desttype) { case TDS_CONVERT_CHAR: case CASE_ALL_CHAR: tds_datecrack(srctype, dta, &when); tds_strftime(whole_date_string, sizeof(whole_date_string), tds_ctx->locale->date_fmt, &when, dta->time_prec); return string_to_result(whole_date_string, cr); case SYBDATETIME: if (!IS_INT(dta->date)) return TDS_CONVERT_OVERFLOW; cr->dt.dtdays = (TDS_INT) dta->date; cr->dt.dttime = (TDS_INT) ((dta->time * 3u + 50000u) / 100000u); return sizeof(TDS_DATETIME); case SYBDATETIME4: if (!IS_USMALLINT(dta->date)) return TDS_CONVERT_OVERFLOW; cr->dt4.days = (TDS_USMALLINT) dta->date; cr->dt4.minutes = (TDS_USMALLINT) ((dta->time + 30u * 10000000u) / (60u * 10000000u)); return sizeof(TDS_DATETIME4); case SYBMSDATETIMEOFFSET: case SYBMSDATE: case SYBMSTIME: case SYBMSDATETIME2: cr->dta = *dta; return sizeof(TDS_DATETIMEALL); case SYBDATE: if (!IS_INT(dta->date)) return TDS_CONVERT_OVERFLOW; cr->date = (TDS_INT) dta->date; return sizeof(TDS_DATE); case SYBTIME: cr->time = (TDS_INT) ((dta->time * 3u + 50000u) / 100000u); return sizeof(TDS_TIME); case SYB5BIGTIME: cr->bigtime = dta->time / 10u; return sizeof(TDS_UINT8); case SYB5BIGDATETIME: cr->bigtime = dta->time / 10u + (dta->date + BIGDATETIME_BIAS) * ((TDS_UINT8) 86400u * 1000000u); return sizeof(TDS_UINT8); /* conversions not allowed */ case SYBUNIQUE: case SYBBIT: case SYBBITN: case SYBINT1: case SYBUINT1: case SYBINT2: case SYBUINT2: case SYBINT4: case SYBUINT4: case SYBINT8: case SYBUINT8: case SYBMONEY4: case SYBMONEY: case SYBNUMERIC: case SYBDECIMAL: default: break; } return TDS_CONVERT_NOAVAIL; } static TDS_INT tds_convert_datetime(const TDSCONTEXT * tds_ctx, const TDS_DATETIME * dt, int desttype, unsigned precision, CONV_RESULT * cr) { char whole_date_string[64]; TDSDATEREC when; switch (desttype) { case TDS_CONVERT_CHAR: case CASE_ALL_CHAR: tds_datecrack(SYBDATETIME, dt, &when); tds_strftime(whole_date_string, sizeof(whole_date_string), tds_ctx->locale->date_fmt, &when, 3); return string_to_result(whole_date_string, cr); case SYBDATETIME: cr->dt = *dt; return sizeof(TDS_DATETIME); case SYBDATETIME4: if (!IS_USMALLINT(dt->dtdays)) return TDS_CONVERT_OVERFLOW; cr->dt4.days = dt->dtdays; cr->dt4.minutes = (dt->dttime / 300) / 60; return sizeof(TDS_DATETIME4); case SYBDATE: cr->date = dt->dtdays; return sizeof(TDS_DATE); case SYBTIME: cr->time = dt->dttime; return sizeof(TDS_TIME); case SYBMSDATETIMEOFFSET: case SYBMSDATE: case SYBMSTIME: case SYBMSDATETIME2: memset(&cr->dta, 0, sizeof(cr->dta)); cr->dta.time_prec = precision; if (desttype == SYBMSDATETIMEOFFSET) cr->dta.has_offset = 1; if (desttype != SYBMSDATE) { cr->dta.has_time = 1; cr->dta.time_prec = 3; cr->dta.time = ((TDS_UINT8) dt->dttime) * 100000u / 3u; } if (desttype != SYBMSTIME) { cr->dta.has_date = 1; cr->dta.date = dt->dtdays; } return sizeof(TDS_DATETIMEALL); case SYB5BIGTIME: cr->bigtime = ((TDS_UINT8) dt->dttime) * 10000u / 3u; return sizeof(TDS_BIGTIME); case SYB5BIGDATETIME: cr->bigdatetime = ((TDS_UINT8) dt->dttime) * 10000u / 3u + (dt->dtdays + BIGDATETIME_BIAS) * ((TDS_UINT8) 86400u * 1000000u); return sizeof(TDS_BIGDATETIME); /* conversions not allowed */ case SYBUNIQUE: case SYBBIT: case SYBBITN: case SYBINT1: case SYBUINT1: case SYBINT2: case SYBUINT2: case SYBINT4: case SYBUINT4: case SYBINT8: case SYBUINT8: case SYBMONEY4: case SYBMONEY: case SYBNUMERIC: case SYBDECIMAL: default: break; } return TDS_CONVERT_NOAVAIL; } static TDS_INT tds_convert_datetime4(const TDSCONTEXT * tds_ctx, const TDS_DATETIME4 * dt4, int desttype, CONV_RESULT * cr) { TDS_DATETIME dt; if (desttype == SYBDATETIME4) { cr->dt4 = *dt4; return sizeof(TDS_DATETIME4); } /* convert to DATETIME and use tds_convert_datetime */ dt.dtdays = dt4->days; dt.dttime = dt4->minutes * (60u * 300u); return tds_convert_datetime(tds_ctx, &dt, desttype, 0, cr); } static TDS_INT tds_convert_time(const TDSCONTEXT * tds_ctx, const TDS_TIME * time, int desttype, CONV_RESULT * cr) { TDS_DATETIME dt; if (desttype == SYBTIME) { cr->time = *time; return sizeof(TDS_TIME); } /* convert to DATETIME and use tds_convert_datetime */ dt.dtdays = 0; dt.dttime = *time; return tds_convert_datetime(tds_ctx, &dt, desttype, 0, cr); } static TDS_INT tds_convert_date(const TDSCONTEXT * tds_ctx, const TDS_DATE * date, int desttype, CONV_RESULT * cr) { TDS_DATETIME dt; if (desttype == SYBDATE) { cr->date = *date; return sizeof(TDS_DATE); } /* convert to DATETIME and use tds_convert_datetime */ dt.dtdays = *date; dt.dttime = 0; return tds_convert_datetime(tds_ctx, &dt, desttype, 0, cr); } static TDS_INT tds_convert_bigtime(const TDSCONTEXT * tds_ctx, const TDS_BIGTIME * bigtime, int desttype, CONV_RESULT * cr) { TDS_DATETIMEALL dta; if (desttype == SYB5BIGTIME) { cr->bigtime = *bigtime; return sizeof(TDS_BIGTIME); } /* convert to DATETIMEALL and use tds_convert_datetimeall */ memset(&dta, 0, sizeof(dta)); dta.time_prec = 6; dta.has_time = 1; dta.time = *bigtime % ((TDS_UINT8) 86400u * 1000000u) * 10u; return tds_convert_datetimeall(tds_ctx, SYBMSTIME, &dta, desttype, cr); } static TDS_INT tds_convert_bigdatetime(const TDSCONTEXT * tds_ctx, const TDS_BIGDATETIME * bigdatetime, int desttype, CONV_RESULT * cr) { TDS_DATETIMEALL dta; TDS_UINT8 bdt; if (desttype == SYB5BIGDATETIME) { cr->bigdatetime = *bigdatetime; return sizeof(TDS_BIGDATETIME); } /* convert to DATETIMEALL and use tds_convert_datetimeall */ bdt = *bigdatetime; memset(&dta, 0, sizeof(dta)); dta.time_prec = 6; dta.has_time = 1; dta.time = bdt % ((TDS_UINT8) 86400u * 1000000u) * 10u; bdt /= (TDS_UINT8) 86400u * 1000000u; dta.has_date = 1; dta.date = bdt - BIGDATETIME_BIAS; return tds_convert_datetimeall(tds_ctx, SYBMSDATETIME2, &dta, desttype, cr); } static TDS_INT tds_convert_real(const TDS_REAL* src, int desttype, CONV_RESULT * cr) { TDS_REAL the_value; /* FIXME how many big should be this buffer ?? */ char tmp_str[128]; TDS_INT mymoney4; TDS_INT8 mymoney; the_value = *src; switch (desttype) { case TDS_CONVERT_CHAR: case CASE_ALL_CHAR: sprintf(tmp_str, "%.9g", the_value); return string_to_result(tmp_str, cr); break; case SYBINT1: case SYBUINT1: if (!IS_TINYINT(the_value)) return TDS_CONVERT_OVERFLOW; cr->ti = (TDS_TINYINT) the_value; return sizeof(TDS_TINYINT); break; case SYBINT2: if (!IS_SMALLINT(the_value)) return TDS_CONVERT_OVERFLOW; cr->si = (TDS_SMALLINT) the_value; return sizeof(TDS_SMALLINT); break; case SYBUINT2: if (!IS_USMALLINT(the_value)) return TDS_CONVERT_OVERFLOW; cr->usi = (TDS_USMALLINT) the_value; return sizeof(TDS_USMALLINT); break; case SYBINT4: if (!IS_INT(the_value)) return TDS_CONVERT_OVERFLOW; cr->i = (TDS_INT) the_value; return sizeof(TDS_INT); break; case SYBUINT4: if (!IS_UINT(the_value)) return TDS_CONVERT_OVERFLOW; cr->ui = (TDS_UINT) the_value; return sizeof(TDS_UINT); break; case SYBINT8: if (the_value > (TDS_REAL) TDS_INT8_MAX || the_value < (TDS_REAL) TDS_INT8_MIN) return TDS_CONVERT_OVERFLOW; cr->bi = (TDS_INT8) the_value; return sizeof(TDS_INT8); break; case SYBUINT8: if (the_value > (TDS_REAL) TDS_UINT8_MAX || the_value < 0) return TDS_CONVERT_OVERFLOW; cr->ubi = (TDS_UINT8) the_value; return sizeof(TDS_UINT8); break; case SYBBIT: case SYBBITN: cr->ti = the_value ? 1 : 0; return sizeof(TDS_TINYINT); break; case SYBFLT8: cr->f = the_value; return sizeof(TDS_FLOAT); break; case SYBREAL: cr->r = the_value; return sizeof(TDS_REAL); break; case SYBMONEY: if (the_value > (TDS_REAL) (TDS_INT8_MAX / 10000) || the_value < (TDS_REAL) (TDS_INT8_MIN / 10000)) return TDS_CONVERT_OVERFLOW; mymoney = (TDS_INT8) (the_value * 10000); cr->m.mny = mymoney; return sizeof(TDS_MONEY); break; case SYBMONEY4: if (the_value > (TDS_REAL) (TDS_INT_MAX / 10000) || the_value < (TDS_REAL) (TDS_INT_MIN / 10000)) return TDS_CONVERT_OVERFLOW; mymoney4 = (TDS_INT) (the_value * 10000); cr->m4.mny4 = mymoney4; return sizeof(TDS_MONEY4); break; case SYBNUMERIC: case SYBDECIMAL: sprintf(tmp_str, "%.*f", cr->n.scale, the_value); return stringz_to_numeric(tmp_str, cr); break; /* not allowed */ case SYBUNIQUE: case SYBDATETIME4: case SYBDATETIME: case SYBDATETIMN: default: break; } return TDS_CONVERT_NOAVAIL; } /* * TODO: emit SYBECLPR errors: "Data conversion resulted in loss of precision". * There are many places where this would be correct to do, but the test is tedious * (convert e.g. 1.5 -> SYBINT and test if output == input) and we don't have a good, * API-independent alternative to tds_client_msg(). Postponed until then. */ static TDS_INT tds_convert_flt8(const TDS_FLOAT* src, int desttype, CONV_RESULT * cr) { TDS_FLOAT the_value; char tmp_str[25]; memcpy(&the_value, src, 8); switch (desttype) { case TDS_CONVERT_CHAR: case CASE_ALL_CHAR: sprintf(tmp_str, "%.17g", the_value); return string_to_result(tmp_str, cr); break; case SYBINT1: case SYBUINT1: if (!IS_TINYINT(the_value)) return TDS_CONVERT_OVERFLOW; cr->ti = (TDS_TINYINT) the_value; return sizeof(TDS_TINYINT); break; case SYBINT2: if (!IS_SMALLINT(the_value)) return TDS_CONVERT_OVERFLOW; cr->si = (TDS_SMALLINT) the_value; return sizeof(TDS_SMALLINT); break; case SYBUINT2: if (!IS_USMALLINT(the_value)) return TDS_CONVERT_OVERFLOW; cr->usi = (TDS_USMALLINT) the_value; return sizeof(TDS_USMALLINT); break; case SYBINT4: if (!IS_INT(the_value)) return TDS_CONVERT_OVERFLOW; cr->i = (TDS_INT) the_value; return sizeof(TDS_INT); break; case SYBUINT4: if (!IS_UINT(the_value)) return TDS_CONVERT_OVERFLOW; cr->ui = (TDS_UINT) the_value; return sizeof(TDS_UINT); break; case SYBINT8: if (the_value > (TDS_FLOAT) TDS_INT8_MAX || the_value < (TDS_FLOAT) TDS_INT8_MIN) return TDS_CONVERT_OVERFLOW; cr->bi = (TDS_INT8) the_value; return sizeof(TDS_INT8); break; case SYBUINT8: if (the_value > (TDS_FLOAT) TDS_UINT8_MAX || the_value < 0) return TDS_CONVERT_OVERFLOW; cr->ubi = (TDS_UINT8) the_value; return sizeof(TDS_UINT8); break; case SYBBIT: case SYBBITN: cr->ti = the_value ? 1 : 0; return sizeof(TDS_TINYINT); break; case SYBMONEY: if (the_value > (TDS_FLOAT) (TDS_INT8_MAX / 10000) || the_value < (TDS_FLOAT) (TDS_INT8_MIN / 10000)) return TDS_CONVERT_OVERFLOW; cr->m.mny = (TDS_INT8) (the_value * 10000); return sizeof(TDS_MONEY); break; case SYBMONEY4: if (the_value > (TDS_FLOAT) (TDS_INT_MAX / 10000) || the_value < (TDS_FLOAT) (TDS_INT_MIN / 10000)) return TDS_CONVERT_OVERFLOW; cr->m4.mny4 = (TDS_INT) (the_value * 10000); return sizeof(TDS_MONEY4); break; case SYBREAL: /* TODO check overflow */ cr->r = (TDS_REAL)the_value; return sizeof(TDS_REAL); break; case SYBFLT8: cr->f = the_value; return sizeof(TDS_FLOAT); break; case SYBNUMERIC: case SYBDECIMAL: sprintf(tmp_str, "%.16g", the_value); return stringz_to_numeric(tmp_str, cr); break; /* not allowed */ case SYBUNIQUE: case SYBDATETIME4: case SYBDATETIME: case SYBDATETIMN: default: break; } return TDS_CONVERT_NOAVAIL; } static TDS_INT tds_convert_unique(const TDS_CHAR * src, int desttype, CONV_RESULT * cr) { /* * raw data is equivalent to structure and always aligned, * so this cast is portable */ const TDS_UNIQUE *u = (const TDS_UNIQUE *) src; char buf[37]; switch (desttype) { case TDS_CONVERT_CHAR: case CASE_ALL_CHAR: sprintf(buf, "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", (int) u->Data1, (int) u->Data2, (int) u->Data3, u->Data4[0], u->Data4[1], u->Data4[2], u->Data4[3], u->Data4[4], u->Data4[5], u->Data4[6], u->Data4[7]); return string_to_result(buf, cr); break; case SYBUNIQUE: /* * Here we can copy raw to structure because we adjust * byte order in tds_swap_datatype */ memcpy(&(cr->u), src, sizeof(TDS_UNIQUE)); return sizeof(TDS_UNIQUE); break; /* no not warning for not convertible types */ case SYBBIT: case SYBBITN: case SYBINT1: case SYBUINT1: case SYBINT2: case SYBUINT2: case SYBINT4: case SYBUINT4: case SYBINT8: case SYBUINT8: case SYBMONEY4: case SYBMONEY: case SYBDATETIME4: case SYBDATETIME: case SYBDATETIMN: case SYBREAL: case SYBFLT8: default: break; } return TDS_CONVERT_NOAVAIL; } static TDS_INT tds_convert_to_binary(int srctype, const TDS_CHAR * src, TDS_UINT srclen, int desttype, CONV_RESULT * cr) { size_t len; TDS_CHAR *ib; switch (srctype) { case CASE_ALL_BINARY: len = srclen; break; case SYBBIT: case SYBBITN: case SYBINT1: case SYBUINT1: len = 1; break; case SYBINT2: case SYBUINT2: len = 2; break; case SYBINT4: case SYBUINT4: len = 4; break; case SYBINT8: case SYBUINT8: len = sizeof(TDS_INT8); break; case SYBMONEY4: len = sizeof(TDS_MONEY4); break; case SYBMONEY: len = sizeof(TDS_MONEY); break; case SYBNUMERIC: case SYBDECIMAL: len = sizeof(TDS_NUMERIC); break; case SYBREAL: len = sizeof(TDS_REAL); break; case SYBFLT8: len = sizeof(TDS_FLOAT); break; case SYBDATETIME: len = sizeof(TDS_DATETIME); break; case SYBDATETIME4: len = sizeof(TDS_DATETIME4); break; case SYBTIME: len = sizeof(TDS_TIME); break; case SYBDATE: len = sizeof(TDS_DATE); break; case SYBMSTIME: case SYBMSDATE: case SYBMSDATETIME2: case SYBMSDATETIMEOFFSET: len = sizeof(TDS_DATETIMEALL); break; case SYB5BIGTIME: len = sizeof(TDS_BIGTIME); break; case SYB5BIGDATETIME: len = sizeof(TDS_BIGDATETIME); break; case SYBUNIQUE: len = sizeof(TDS_UNIQUE); break; case CASE_ALL_CHAR: /* skip leading "0x" or "0X" */ if (srclen >= 2 && src[0] == '0' && (src[1] == 'x' || src[1] == 'X')) { src += 2; srclen -= 2; } /* ignore trailing blanks and nulls */ /* FIXME is good to ignore null ?? */ while (srclen > 0 && (src[srclen - 1] == ' ' || src[srclen - 1] == '\0')) --srclen; /* a binary string output will be half the length of */ /* the string which represents it in hexadecimal */ ib = cr->cb.ib; if (desttype != TDS_CONVERT_BINARY) { cr->ib = tds_new(TDS_CHAR, (srclen + 2u) / 2u); test_alloc(cr->ib); ib = cr->ib; } return tds_char2hex(ib, desttype == TDS_CONVERT_BINARY ? cr->cb.len : 0xffffffffu, src, srclen); default: return TDS_CONVERT_NOAVAIL; } return binary_to_result(desttype, src, len, cr); } /** * tds_convert * convert a type to another. * If you convert to SYBDECIMAL/SYBNUMERIC you MUST initialize precision * and scale of cr. * Do not expect strings to be zero terminated. Databases support zero inside * string. Using strlen may result on data loss or even a segmentation fault. * Instead, use memcpy to copy destination using length returned. * This function does not handle NULL, srclen should be >0. Client libraries handle NULLs each in their own way. * @param tds_ctx context (used in conversion to data and to return messages) * @param srctype type of source * @param src pointer to source data to convert * @param srclen length in bytes of source (not counting terminator or strings) * @param desttype type of destination * @param cr structure to hold result * @return length of result or TDS_CONVERT_* failure code on failure. All TDS_CONVERT_* constants are <0. */ TDS_INT tds_convert(const TDSCONTEXT * tds_ctx, int srctype, const TDS_CHAR * src, TDS_UINT srclen, int desttype, CONV_RESULT * cr) { TDS_INT length = 0; assert(srclen >= 0 && srclen <= 2147483647u); if (srctype == SYBVARIANT) { TDSVARIANT *v = (TDSVARIANT*) src; srctype = v->type; src = v->data; srclen = v->data_len; } switch (desttype) { case CASE_ALL_BINARY: return tds_convert_to_binary(srctype, src, srclen, desttype, cr); } switch (srctype) { case CASE_ALL_CHAR: length = tds_convert_char(src, srclen, desttype, cr); break; case SYBMONEY4: length = tds_convert_money4((const TDS_MONEY4 *) src, desttype, cr); break; case SYBMONEY: length = tds_convert_money((const TDS_MONEY *) src, desttype, cr); break; case SYBNUMERIC: case SYBDECIMAL: length = tds_convert_numeric((const TDS_NUMERIC *) src, desttype, cr); break; case SYBBIT: case SYBBITN: length = tds_convert_bit(src, desttype, cr); break; case SYBINT1: case SYBUINT1: length = tds_convert_int1((const TDS_TINYINT *) src, desttype, cr); break; case SYBINT2: length = tds_convert_int2((const TDS_SMALLINT *) src, desttype, cr); break; case SYBUINT2: length = tds_convert_uint2((const TDS_USMALLINT *) src, desttype, cr); break; case SYBINT4: length = tds_convert_int4((const TDS_INT *) src, desttype, cr); break; case SYBUINT4: length = tds_convert_uint4((const TDS_UINT *) src, desttype, cr); break; case SYBINT8: length = tds_convert_int8((const TDS_INT8 *) src, desttype, cr); break; case SYBUINT8: length = tds_convert_uint8((const TDS_UINT8 *) src, desttype, cr); break; case SYBREAL: length = tds_convert_real((const TDS_REAL *) src, desttype, cr); break; case SYBFLT8: length = tds_convert_flt8((const TDS_FLOAT *) src, desttype, cr); break; case SYBMSTIME: case SYBMSDATE: case SYBMSDATETIME2: case SYBMSDATETIMEOFFSET: length = tds_convert_datetimeall(tds_ctx, srctype, (const TDS_DATETIMEALL *) src, desttype, cr); break; case SYBDATETIME: length = tds_convert_datetime(tds_ctx, (const TDS_DATETIME* ) src, desttype, 3, cr); break; case SYBDATETIME4: length = tds_convert_datetime4(tds_ctx, (const TDS_DATETIME4* ) src, desttype, cr); break; case SYBTIME: length = tds_convert_time(tds_ctx, (const TDS_TIME *) src, desttype, cr); break; case SYBDATE: length = tds_convert_date(tds_ctx, (const TDS_DATE *) src, desttype, cr); break; case SYB5BIGTIME: length = tds_convert_bigtime(tds_ctx, (const TDS_BIGTIME *) src, desttype, cr); break; case SYB5BIGDATETIME: length = tds_convert_bigdatetime(tds_ctx, (const TDS_BIGDATETIME *) src, desttype, cr); break; case CASE_ALL_BINARY: length = tds_convert_binary((const TDS_UCHAR *) src, srclen, desttype, cr); break; case SYBUNIQUE: length = tds_convert_unique(src, desttype, cr); break; case SYBNVARCHAR: case SYBNTEXT: default: return TDS_CONVERT_NOAVAIL; break; } /* fix MONEY case */ #if !defined(WORDS_BIGENDIAN) if (length > 0 && desttype == SYBMONEY) { cr->m.mny = ((TDS_UINT8) cr->m.mny) >> 32 | (cr->m.mny << 32); } #endif return length; } static int string_to_datetime(const char *instr, TDS_UINT len, int desttype, CONV_RESULT * cr) { enum states { GOING_IN_BLIND, PUT_NUMERIC_IN_CONTEXT, DOING_ALPHABETIC_DATE, STRING_GARBLED }; char *in; char *tok; char *lasts; char last_token[32]; int monthdone = 0; int yeardone = 0; int mdaydone = 0; struct tds_time t; unsigned int dt_time; TDS_INT dt_days; int i; int current_state; memset(&t, '\0', sizeof(t)); t.tm_mday = 1; in = tds_strndup(instr, len); test_alloc(in); tok = strtok_r(in, " ,", &lasts); current_state = GOING_IN_BLIND; while (tok != NULL) { tdsdump_log(TDS_DBG_INFO1, "string_to_datetime: current_state = %d\n", current_state); switch (current_state) { case GOING_IN_BLIND: /* If we have no idea of current context, then if we have */ /* encountered a purely alphabetic string, it MUST be an */ /* alphabetic month name or prefix... */ if (is_alphabetic(tok)) { tdsdump_log(TDS_DBG_INFO1, "string_to_datetime: is_alphabetic\n"); if (store_monthname(tok, &t) >= 0) { monthdone++; current_state = DOING_ALPHABETIC_DATE; } else { current_state = STRING_GARBLED; } } /* ...whereas if it is numeric, it could be a number of */ /* things... */ else if (is_numeric(tok)) { tdsdump_log(TDS_DBG_INFO1, "string_to_datetime: is_numeric\n"); switch (strlen(tok)) { /* in this context a 4 character numeric can */ /* ONLY be the year part of an alphabetic date */ case 4: store_year(atoi(tok), &t); yeardone++; current_state = DOING_ALPHABETIC_DATE; break; /* whereas these could be the hour part of a */ /* time specification ( 4 PM ) or the leading */ /* day part of an alphabetic date ( 15 Jan ) */ case 2: case 1: strcpy(last_token, tok); current_state = PUT_NUMERIC_IN_CONTEXT; break; /* this must be a [YY]YYMMDD date */ case 6: case 8: if (store_yymmdd_date(tok, &t)) current_state = GOING_IN_BLIND; else current_state = STRING_GARBLED; break; /* anything else is nonsense... */ default: current_state = STRING_GARBLED; break; } } /* it could be [M]M/[D]D/[YY]YY format */ else if (is_numeric_dateformat(tok)) { tdsdump_log(TDS_DBG_INFO1, "string_to_datetime: is_numeric_dateformat\n"); store_numeric_date(tok, &t); current_state = GOING_IN_BLIND; } else if (is_dd_mon_yyyy(tok)) { tdsdump_log(TDS_DBG_INFO1, "string_to_datetime: is_dd_mon_yyyy\n"); store_dd_mon_yyy_date(tok, &t); current_state = GOING_IN_BLIND; } else if (is_timeformat(tok)) { tdsdump_log(TDS_DBG_INFO1, "string_to_datetime: is_timeformat\n"); store_time(tok, &t); current_state = GOING_IN_BLIND; } else { tdsdump_log(TDS_DBG_INFO1, "string_to_datetime: string_garbled\n"); current_state = STRING_GARBLED; } break; /* end of GOING_IN_BLIND */ case DOING_ALPHABETIC_DATE: if (is_alphabetic(tok)) { if (!monthdone && store_monthname(tok, &t) >= 0) { monthdone++; if (monthdone && yeardone && mdaydone) current_state = GOING_IN_BLIND; else current_state = DOING_ALPHABETIC_DATE; } else { current_state = STRING_GARBLED; } } else if (is_numeric(tok)) { if (mdaydone && yeardone) current_state = STRING_GARBLED; else switch (strlen(tok)) { case 4: store_year(atoi(tok), &t); yeardone++; if (monthdone && yeardone && mdaydone) current_state = GOING_IN_BLIND; else current_state = DOING_ALPHABETIC_DATE; break; case 2: case 1: if (!mdaydone) { store_mday(tok, &t); mdaydone++; if (monthdone && yeardone && mdaydone) current_state = GOING_IN_BLIND; else current_state = DOING_ALPHABETIC_DATE; } else { store_year(atoi(tok), &t); yeardone++; if (monthdone && yeardone && mdaydone) current_state = GOING_IN_BLIND; else current_state = DOING_ALPHABETIC_DATE; } break; default: current_state = STRING_GARBLED; } } else { current_state = STRING_GARBLED; } break; /* end of DOING_ALPHABETIC_DATE */ case PUT_NUMERIC_IN_CONTEXT: if (is_alphabetic(tok)) { if (store_monthname(tok, &t) >= 0) { store_mday(last_token, &t); mdaydone++; monthdone++; if (monthdone && yeardone && mdaydone) current_state = GOING_IN_BLIND; else current_state = DOING_ALPHABETIC_DATE; } else if (is_ampm(tok)) { store_hour(last_token, tok, &t); current_state = GOING_IN_BLIND; } else { current_state = STRING_GARBLED; } } else if (is_numeric(tok)) { switch (strlen(tok)) { case 4: case 2: store_mday(last_token, &t); mdaydone++; store_year(atoi(tok), &t); yeardone++; if (monthdone && yeardone && mdaydone) current_state = GOING_IN_BLIND; else current_state = DOING_ALPHABETIC_DATE; break; default: current_state = STRING_GARBLED; } } else { current_state = STRING_GARBLED; } break; /* end of PUT_NUMERIC_IN_CONTEXT */ case STRING_GARBLED: tdsdump_log(TDS_DBG_INFO1, "error_handler: Attempt to convert data stopped by syntax error in source field \n"); free(in); return TDS_CONVERT_SYNTAX; } tok = strtok_r(NULL, " ,", &lasts); } i = (t.tm_mon - 13) / 12; dt_days = 1461 * (t.tm_year + 1900 + i) / 4 + (367 * (t.tm_mon - 1 - 12 * i)) / 12 - (3 * ((t.tm_year + 2000 + i) / 100)) / 4 + t.tm_mday - 693932; free(in); if (desttype == SYBDATE) { cr->date = dt_days; return sizeof(TDS_DATE); } dt_time = t.tm_hour * 60 + t.tm_min; /* TODO check for overflow */ if (desttype == SYBDATETIME4) { cr->dt4.days = dt_days; cr->dt4.minutes = dt_time; return sizeof(TDS_DATETIME4); } dt_time = dt_time * 60 + t.tm_sec; if (desttype == SYBDATETIME) { cr->dt.dtdays = dt_days; cr->dt.dttime = dt_time * 300 + (t.tm_ns / 1000000u * 300 + 150) / 1000; return sizeof(TDS_DATETIME); } if (desttype == SYBTIME) { cr->time = dt_time * 300 + (t.tm_ns / 1000000u * 300 + 150) / 1000; return sizeof(TDS_TIME); } if (desttype == SYB5BIGTIME) { cr->bigtime = dt_time * (TDS_UINT8) 1000000u + t.tm_ns / 1000u; return sizeof(TDS_BIGTIME); } if (desttype == SYB5BIGDATETIME) { cr->bigdatetime = (dt_days + BIGDATETIME_BIAS) * ((TDS_UINT8) 86400u * 1000000u) + dt_time * (TDS_UINT8) 1000000u + t.tm_ns / 1000u; return sizeof(TDS_BIGDATETIME); } cr->dta.has_offset = 0; cr->dta.offset = 0; cr->dta.has_date = 1; cr->dta.date = dt_days; cr->dta.has_time = 1; cr->dta.time_prec = 7; /* TODO correct value */ cr->dta.time = ((TDS_UINT8) dt_time) * 10000000u + t.tm_ns / 100u; return sizeof(TDS_DATETIMEALL); } static int stringz_to_numeric(const char *instr, CONV_RESULT * cr) { return string_to_numeric(instr, instr + strlen(instr), cr); } static int string_to_numeric(const char *instr, const char *pend, CONV_RESULT * cr) { char mynumber[(MAXPRECISION + 7) / 8 * 8 + 8]; /* num packaged 8 digit, see below for detail */ TDS_UINT packed_num[(MAXPRECISION + 7) / 8]; char *ptr; int i = 0; int j = 0; int bytes; bool negative; size_t digits, decimals; /* FIXME: application can pass invalid value for precision and scale ?? */ if (cr->n.precision > MAXPRECISION) return TDS_CONVERT_FAIL; if (cr->n.precision == 0) cr->n.precision = MAXPRECISION; /* assume max precision */ if (cr->n.scale > cr->n.precision) return TDS_CONVERT_FAIL; instr = parse_numeric(instr, pend, &negative, &digits, &decimals); if (!instr) return TDS_CONVERT_SYNTAX; cr->n.array[0] = negative ? 1 : 0; /* translate a number like 000ddddd.ffff to 00000000dddddffff00 */ /* * Having disposed of any sign and leading blanks, * vet the digit string, counting places before and after * the decimal point. Dispense with trailing blanks, if any. */ ptr = mynumber; for (i = 0; i < 8; ++i) *ptr++ = '0'; /* too many digits, error */ if (cr->n.precision - cr->n.scale < digits) return TDS_CONVERT_OVERFLOW; /* copy digits before the dot */ memcpy(ptr, instr, digits); ptr += digits; instr += digits + 1; /* copy digits after the dot */ if (decimals > cr->n.scale) decimals = cr->n.scale; memcpy(ptr, instr, decimals); /* fill up decimal digits */ memset(ptr + decimals, '0', cr->n.scale - decimals); ptr += cr->n.scale; /* * Packaged number explanation: * We package 8 decimal digits in one number. * Because 10^8 = 5^8 * 2^8 = 5^8 * 256, dividing 10^8 by 256 leaves no remainder. * We can thus split it into bytes in an optimized way. */ /* transform to packaged one */ j = -1; ptr -= 8; do { TDS_UINT n = *ptr++; for (i = 1; i < 8; ++i) n = n * 10u + *ptr++; /* fix packet number and store */ packed_num[++j] = n - ((TDS_UINT) '0' * 11111111lu); ptr -= 16; } while (ptr > mynumber); memset(cr->n.array + 1, 0, sizeof(cr->n.array) - 1); bytes = tds_numeric_bytes_per_prec[cr->n.precision]; while (j > 0 && !packed_num[j]) --j; for (;;) { bool is_zero = true; TDS_UINT carry = 0; i = j; if (!packed_num[j]) --j; do { TDS_UINT tmp = packed_num[i]; if (tmp) is_zero = false; /* divide for 256 for find another byte */ /* * carry * (25u*25u*25u*25u) = carry * 10^8 / 256u * using unsigned number is just an optimization * compiler can translate division to a shift and remainder * to a binary AND */ packed_num[i] = carry * (25u * 25u * 25u * 25u) + tmp / 256u; carry = tmp % 256u; } while(--i >= 0); if (is_zero) break; /* * source number is limited to 38 decimal digit * 10^39-1 < 2^128 (16 byte) so this cannot make an overflow */ cr->n.array[--bytes] = carry; } return sizeof(TDS_NUMERIC); } static bool is_numeric_dateformat(const char *t) { const char *instr; int slashes = 0; int hyphens = 0; int periods = 0; int digits = 0; for (instr = t; *instr; instr++) { if (!isdigit((unsigned char) *instr) && *instr != '/' && *instr != '-' && *instr != '.') return false; if (*instr == '/') slashes++; else if (*instr == '-') hyphens++; else if (*instr == '.') periods++; else digits++; } if (hyphens + slashes + periods != 2) return false; if (hyphens == 1 || slashes == 1 || periods == 1) return false; if (digits < 4 || digits > 8) return false; return true; } /* This function will check if an alphanumeric string */ /* holds a date in any of the following formats : */ /* DD-MON-YYYY */ /* DD-MON-YY */ /* DDMONYY */ /* DDMONYYYY */ static bool is_dd_mon_yyyy(char *t) { char *instr; char month[4]; instr = t; if (!isdigit((unsigned char) *instr)) return false; instr++; if (!isdigit((unsigned char) *instr)) return false; instr++; if (*instr == '-') { instr++; strlcpy(month, instr, 4); if (!is_monthname(month)) return false; instr += 3; if (*instr != '-') return false; instr++; if (!isdigit((unsigned char) *instr)) return false; instr++; if (!isdigit((unsigned char) *instr)) return false; instr++; if (*instr) { if (!isdigit((unsigned char) *instr)) return false; instr++; if (!isdigit((unsigned char) *instr)) return false; } } else { strlcpy(month, instr, 4); if (!is_monthname(month)) return false; instr += 3; if (!isdigit((unsigned char) *instr)) return false; instr++; if (!isdigit((unsigned char) *instr)) return false; instr++; if (*instr) { if (!isdigit((unsigned char) *instr)) return false; instr++; if (!isdigit((unsigned char) *instr)) return false; } } return true; } static bool is_ampm(const char *datestr) { if (strcasecmp(datestr, "am") == 0) return true; if (strcasecmp(datestr, "pm") == 0) return true; return false; } static bool is_alphabetic(const char *datestr) { const char *s; for (s = datestr; *s; s++) { if (!isalpha((unsigned char) *s)) return false; } return true; } static bool is_numeric(const char *datestr) { const char *s; for (s = datestr; *s; s++) { if (!isdigit((unsigned char) *s)) return false; } return true; } static bool is_timeformat(const char *datestr) { const char *s; for (s = datestr; *s; s++) { if (!isdigit((unsigned char) *s) && *s != ':' && *s != '.') break; } if (*s) return is_ampm(s); return true; } static int store_year(int year, struct tds_time *t) { if (year < 0) return 0; if (year < 100) { if (year > 49) t->tm_year = year; else t->tm_year = 100 + year; return (1); } if (year < 1753) return (0); if (year <= 9999) { t->tm_year = year - 1900; return (1); } return (0); } static int store_mday(const char *datestr, struct tds_time *t) { int mday = atoi(datestr); if (mday > 0 && mday < 32) { t->tm_mday = mday; return 1; } return 0; } static int store_numeric_date(const char *datestr, struct tds_time *t) { int TDS_MONTH = 0; int TDS_DAY = 0; int TDS_YEAR = 0; int state; char last_char = 0; const char *s; int month = 0, year = 0, mday = 0; /* Its YYYY-MM-DD format */ if (strlen(datestr) == 10 && *(datestr + 4) == '-' && *(datestr + 7) == '-') { TDS_YEAR = 0; TDS_MONTH = 1; TDS_DAY = 2; state = TDS_YEAR; } /* else we assume MDY */ else { TDS_MONTH = 0; TDS_DAY = 1; TDS_YEAR = 2; state = TDS_MONTH; } for (s = datestr; *s; s++) { if (!isdigit((unsigned char) *s) && isdigit((unsigned char) last_char)) { state++; } else { if (state == TDS_MONTH) month = (month * 10) + (*s - '0'); if (state == TDS_DAY) mday = (mday * 10) + (*s - '0'); if (state == TDS_YEAR) year = (year * 10) + (*s - '0'); } last_char = *s; } if (month > 0 && month < 13) t->tm_mon = month - 1; else return 0; if (mday > 0 && mday < 32) t->tm_mday = mday; else return 0; return store_year(year, t); } static int store_dd_mon_yyy_date(char *datestr, struct tds_time *t) { char dd[3]; int mday; char mon[4]; int year; tdsdump_log(TDS_DBG_INFO1, "store_dd_mon_yyy_date: %s\n", datestr); strlcpy(dd, datestr, 3); mday = atoi(dd); if (mday > 0 && mday < 32) t->tm_mday = mday; else return 0; if (datestr[2] == '-') { strlcpy(mon, &datestr[3], 4); if (store_monthname(mon, t) < 0) { tdsdump_log(TDS_DBG_INFO1, "store_dd_mon_yyy_date: store_monthname failed\n"); return 0; } year = atoi(&datestr[7]); tdsdump_log(TDS_DBG_INFO1, "store_dd_mon_yyy_date: year %d\n", year); return store_year(year, t); } else { strlcpy(mon, &datestr[2], 4); if (store_monthname(mon, t) < 0) { tdsdump_log(TDS_DBG_INFO1, "store_dd_mon_yyy_date: store_monthname failed\n"); return 0; } year = atoi(&datestr[5]); tdsdump_log(TDS_DBG_INFO1, "store_dd_mon_yyy_date: year %d\n", year); return store_year(year, t); } } /** * Test if a string is a month name and store correct month number * @return month number (0-11) or -1 if not match * @param datestr string to check * @param t where to store month (if NULL no store is done) */ static int store_monthname(const char *datestr, struct tds_time *t) { int ret; tdsdump_log(TDS_DBG_INFO1, "store_monthname: %ld %s\n", (long) strlen(datestr), datestr); if (strlen(datestr) == 3) { if (strcasecmp(datestr, "jan") == 0) ret = 0; else if (strcasecmp(datestr, "feb") == 0) ret = 1; else if (strcasecmp(datestr, "mar") == 0) ret = 2; else if (strcasecmp(datestr, "apr") == 0) ret = 3; else if (strcasecmp(datestr, "may") == 0) ret = 4; else if (strcasecmp(datestr, "jun") == 0) ret = 5; else if (strcasecmp(datestr, "jul") == 0) ret = 6; else if (strcasecmp(datestr, "aug") == 0) ret = 7; else if (strcasecmp(datestr, "sep") == 0) ret = 8; else if (strcasecmp(datestr, "oct") == 0) ret = 9; else if (strcasecmp(datestr, "nov") == 0) ret = 10; else if (strcasecmp(datestr, "dec") == 0) ret = 11; else return -1; } else { if (strcasecmp(datestr, "january") == 0) ret = 0; else if (strcasecmp(datestr, "february") == 0) ret = 1; else if (strcasecmp(datestr, "march") == 0) ret = 2; else if (strcasecmp(datestr, "april") == 0) ret = 3; else if (strcasecmp(datestr, "june") == 0) ret = 5; else if (strcasecmp(datestr, "july") == 0) ret = 6; else if (strcasecmp(datestr, "august") == 0) ret = 7; else if (strcasecmp(datestr, "september") == 0) ret = 8; else if (strcasecmp(datestr, "october") == 0) ret = 9; else if (strcasecmp(datestr, "november") == 0) ret = 10; else if (strcasecmp(datestr, "december") == 0) ret = 11; else return -1; } if (t) t->tm_mon = ret; return ret; } static int store_yymmdd_date(const char *datestr, struct tds_time *t) { int month = 0, year = 0, mday = 0; int wholedate; wholedate = atoi(datestr); year = wholedate / 10000; month = (wholedate - (year * 10000)) / 100; mday = (wholedate - (year * 10000) - (month * 100)); if (month > 0 && month < 13) t->tm_mon = month - 1; else return 0; if (mday > 0 && mday < 32) t->tm_mday = mday; else return 0; return (store_year(year, t)); } static int store_time(const char *datestr, struct tds_time *t) { enum { TDS_HOURS, TDS_MINUTES, TDS_SECONDS, TDS_FRACTIONS }; int state = TDS_HOURS; char last_sep = '\0'; const char *s; unsigned int hours = 0, minutes = 0, seconds = 0, nanosecs = 0; int ret = 1; unsigned ns_div = 1; for (s = datestr; *s && strchr("apmAPM", (int) *s) == NULL; s++) { if (*s == ':' || *s == '.') { last_sep = *s; state++; } else { if (*s < '0' || *s > '9') ret = 0; switch (state) { case TDS_HOURS: hours = (hours * 10u) + (*s - '0'); break; case TDS_MINUTES: minutes = (minutes * 10u) + (*s - '0'); break; case TDS_SECONDS: seconds = (seconds * 10u) + (*s - '0'); break; case TDS_FRACTIONS: if (ns_div < 1000000000u) { nanosecs = (nanosecs * 10u) + (*s - '0'); ns_div *= 10; } break; } } } if (*s) { if (strcasecmp(s, "am") == 0) { if (hours == 12) hours = 0; t->tm_hour = hours; } if (strcasecmp(s, "pm") == 0) { if (hours == 0) ret = 0; if (hours > 0u && hours < 12u) t->tm_hour = hours + 12; else t->tm_hour = hours; } } else { if (hours < 24u) t->tm_hour = hours; else ret = 0; } if (minutes < 60u) t->tm_min = minutes; else ret = 0; if (seconds < 60u) t->tm_sec = seconds; else ret = 0; tdsdump_log(TDS_DBG_FUNC, "store_time() nanosecs = %d\n", nanosecs); if (nanosecs) { if (nanosecs < ns_div && last_sep == '.') t->tm_ns = nanosecs * (1000000000u / ns_div); else if (nanosecs < 1000u) t->tm_ns = nanosecs * 1000000u; else ret = 0; } return (ret); } static int store_hour(const char *hour, const char *ampm, struct tds_time *t) { int ret = 1; int hours; hours = atoi(hour); if (hours >= 0 && hours < 24) { if (strcasecmp(ampm, "am") == 0) { if (hours == 12) hours = 0; t->tm_hour = hours; } if (strcasecmp(ampm, "pm") == 0) { if (hours == 0) ret = 0; if (hours > 0 && hours < 12) t->tm_hour = hours + 12; else t->tm_hour = hours; } } return ret; } /** * Get same type but nullable * @param srctype type requires * @return nullable type */ TDS_SERVER_TYPE tds_get_null_type(TDS_SERVER_TYPE srctype) { switch (srctype) { case SYBCHAR: return SYBVARCHAR; break; case SYBINT1: case SYBUINT1: case SYBINT2: case SYBINT4: case SYBINT8: /* TODO sure ?? */ case SYBUINT2: case SYBUINT4: case SYBUINT8: return SYBINTN; break; case SYBREAL: case SYBFLT8: return SYBFLTN; break; case SYBDATETIME: case SYBDATETIME4: return SYBDATETIMN; break; case SYBBIT: return SYBBITN; break; case SYBMONEY: case SYBMONEY4: return SYBMONEYN; break; case SYBTIME: return SYBTIMEN; break; case SYBDATE: return SYBDATEN; break; default: break; } return srctype; } /** * format a date string according to an "extended" strftime(3) formatting definition. * @param buf output buffer * @param maxsize size of buffer in bytes (space include terminator) * @param format format string passed to strftime(3), except that %z represents fraction of seconds. * @param dr date to convert * @param prec second fraction precision (0-7). * @return length of string returned, 0 for error */ size_t tds_strftime(char *buf, size_t maxsize, const char *format, const TDSDATEREC * dr, int prec) { struct tm tm; size_t length; char *our_format; char *pz = NULL; assert(buf); assert(format); assert(dr); assert(0 <= dr->decimicrosecond && dr->decimicrosecond < 10000000); if (prec < 0 || prec > 7) prec = 3; tm.tm_sec = dr->second; tm.tm_min = dr->minute; tm.tm_hour = dr->hour; tm.tm_mday = dr->day; tm.tm_mon = dr->month; tm.tm_year = dr->year - 1900; tm.tm_wday = dr->weekday; tm.tm_yday = dr->dayofyear; tm.tm_isdst = 0; #ifdef HAVE_STRUCT_TM_TM_ZONE tm.tm_zone = NULL; #elif defined(HAVE_STRUCT_TM___TM_ZONE) tm.__tm_zone = NULL; #endif /* more characters are required because we replace %z with up to 7 digits */ our_format = tds_new(char, strlen(format) + 1 + 5); if (!our_format) return 0; strcpy(our_format, format); /* * Look for "%z" in the format string. If found, replace it with dr->milliseconds. * For example, if milliseconds is 124, the format string * "%b %d %Y %H:%M:%S.%z" would become * "%b %d %Y %H:%M:%S.124". */ for (pz = our_format; (pz = strstr(pz, "%z")) != NULL; pz++) { /* Skip any escaped cases (%%z) */ if (pz > our_format && *(pz - 1) != '%') break; } if (pz) { if (prec || pz <= our_format || pz[-1] != '.') { char buf[12]; sprintf(buf, "%07d", dr->decimicrosecond); memcpy(pz, buf, prec); strcpy(pz + prec, format + (pz - our_format) + 2); } else { strcpy(pz - 1, format + (pz - our_format) + 2); } } length = strftime(buf, maxsize, our_format, &tm); free(our_format); return length; } #if 0 static TDS_UINT utf16len(const utf16_t * s) { const utf16_t *p = s; while (*p++) continue; return p - s; } #endif #include "tds_willconvert.h" /** * Test if a conversion is possible * @param srctype source type * @param desttype destination type * @return 0 if not convertible */ unsigned char tds_willconvert(int srctype, int desttype) { TDS_TINYINT cat_from, cat_to; TDS_UINT yn; tdsdump_log(TDS_DBG_FUNC, "tds_willconvert(%d, %d)\n", srctype, desttype); /* they must be from 0 to 255 */ if (((srctype|desttype) & ~0xff) != 0) return 0; cat_from = type2category[srctype]; cat_to = type2category[desttype]; yn = category_conversion[cat_from]; yn = (yn >> cat_to) & 1; tdsdump_log(TDS_DBG_FUNC, "tds_willconvert(%d, %d) returns %s\n", srctype, desttype, yn? "yes":"no"); return yn; } #if 0 select day(d) as day, datepart(dw, d) as weekday, datepart(week, d) as week, d as 'date' from #t order by d day weekday week date ----------- ----------- ----------- ---------- 1 5 1 2009-01-01 Thursday 2 6 1 2009-01-02 Friday 3 7 1 2009-01-03 Saturday 4 1 2 2009-01-04 Sunday 5 2 2 2009-01-05 6 3 2 2009-01-06 7 4 2 2009-01-07 8 5 2 2009-01-08 9 6 2 2009-01-09 10 7 2 2009-01-10 11 1 3 2009-01-11 12 2 3 2009-01-12 13 3 3 2009-01-13 14 4 3 2009-01-14 15 5 3 2009-01-15 16 6 3 2009-01-16 17 7 3 2009-01-17 18 1 4 2009-01-18 19 2 4 2009-01-19 20 3 4 2009-01-20 21 4 4 2009-01-21 22 5 4 2009-01-22 23 6 4 2009-01-23 24 7 4 2009-01-24 25 1 5 2009-01-25 26 2 5 2009-01-26 27 3 5 2009-01-27 28 4 5 2009-01-28 29 5 5 2009-01-29 30 6 5 2009-01-30 31 7 5 2009-01-31 #endif /** * Convert from db date format to a structured date format * @param datetype source date type. SYBDATETIME or SYBDATETIME4 * @param di source date * @param dr destination date * @return TDS_FAIL or TDS_SUCCESS */ TDSRET tds_datecrack(TDS_INT datetype, const void *di, TDSDATEREC * dr) { int dt_days; unsigned int dt_time; int years, months, days, ydays, wday, hours, mins, secs, dms, tzone = 0; int l, n, i, j; memset(dr, 0, sizeof(*dr)); if (datetype == SYBMSDATE || datetype == SYBMSTIME || datetype == SYBMSDATETIME2 || datetype == SYBMSDATETIMEOFFSET) { const TDS_DATETIMEALL *dta = (const TDS_DATETIMEALL *) di; dt_days = (datetype == SYBMSTIME) ? 0 : dta->date; if (datetype == SYBMSDATE) { dms = 0; secs = 0; dt_time = 0; } else { dms = dta->time % 10000000u; dt_time = (unsigned int) (dta->time / 10000000u); secs = dt_time % 60; dt_time = dt_time / 60; } if (datetype == SYBMSDATETIMEOFFSET) { --dt_days; dt_time = dt_time + 1440 + dta->offset; dt_days += dt_time / 1440; dt_time %= 1440; tzone = dta->offset; } } else if (datetype == SYBDATETIME) { const TDS_DATETIME *dt = (const TDS_DATETIME *) di; dt_time = dt->dttime; dms = ((dt_time % 300) * 1000 + 150) / 300 * 10000u; dt_time = dt_time / 300; secs = dt_time % 60; dt_time = dt_time / 60; dt_days = dt->dtdays; } else if (datetype == SYBDATETIME4) { const TDS_DATETIME4 *dt4 = (const TDS_DATETIME4 *) di; secs = 0; dms = 0; dt_days = dt4->days; dt_time = dt4->minutes; } else if (datetype == SYBDATE) { dt_days = *((const TDS_DATE *) di); dms = 0; secs = 0; dt_time = 0; } else if (datetype == SYBTIME) { dt_time = *((const TDS_TIME *) di); dms = ((dt_time % 300) * 1000 + 150) / 300 * 10000u; dt_time = dt_time / 300; secs = dt_time % 60; dt_time = dt_time / 60; dt_days = 0; } else if (datetype == SYB5BIGTIME) { TDS_UINT8 bigtime = *((const TDS_BIGTIME *) di); dt_days = 0; dms = bigtime % 1000000u * 10u; dt_time = (bigtime / 1000000u) % 86400u; secs = dt_time % 60; dt_time = dt_time / 60u; } else if (datetype == SYB5BIGDATETIME) { TDS_UINT8 bigdatetime = *((const TDS_BIGDATETIME*) di); dms = bigdatetime % 1000000u * 10u; bigdatetime /= 1000000u; secs = bigdatetime % 60u; bigdatetime /= 60u; dt_time = bigdatetime % (24u*60u); dt_days = bigdatetime / (24u*60u) - BIGDATETIME_BIAS; } else { return TDS_FAIL; } /* * -53690 is minimun (1753-1-1) (Gregorian calendar start in 1732) * 2958463 is maximun (9999-12-31) */ l = dt_days + (146038 + 146097*4); wday = (l + 4) % 7; n = (4 * l) / 146097; /* n century */ l = l - (146097 * n + 3) / 4; /* days from xx00-02-28 (y-m-d) */ i = (4000 * (l + 1)) / 1461001; /* years from xx00-02-28 */ l = l - (1461 * i) / 4; /* year days from xx00-02-28 */ ydays = l >= 306 ? l - 305 : l + 60; l += 31; j = (80 * l) / 2447; days = l - (2447 * j) / 80; l = j / 11; months = j + 1 - 12 * l; years = 100 * (n - 1) + i + l; if (l == 0 && (years & 3) == 0 && (years % 100 != 0 || years % 400 == 0)) ++ydays; hours = dt_time / 60; mins = dt_time % 60; dr->year = years; dr->month = months; dr->quarter = months / 3; dr->day = days; dr->dayofyear = ydays; dr->weekday = wday; dr->hour = hours; dr->minute = mins; dr->second = secs; dr->decimicrosecond = dms; dr->timezone = tzone; return TDS_SUCCESS; } /** * \brief convert a number in string to TDS_INT * * \return TDS_CONVERT_* or failure code on error * \remarks Sybase's char->int conversion tolerates embedded blanks, * such that "convert( int, ' - 13 ' )" works. * If we find blanks, we copy the string to a temporary buffer, * skipping the blanks. * We return the results of atoi() with a clean string. * * n.b. it is possible to embed all sorts of non-printable characters, but we * only check for spaces. at this time, no one on the project has tested anything else. */ static TDS_INT string_to_int(const char *buf, const char *pend, TDS_INT * res) { bool negative; unsigned int num; /* we use unsigned here for best overflow check */ size_t digits, decimals; buf = parse_numeric(buf, pend, &negative, &digits, &decimals); if (!buf) return TDS_CONVERT_SYNTAX; num = 0; for (; digits; --digits, ++buf) { /* add a digit to number and check for overflow */ /* NOTE I didn't forget a digit, I check overflow before multiply to prevent overflow */ if (num > 214748364u) return TDS_CONVERT_OVERFLOW; num = num * 10u + (*buf - '0'); } /* check for overflow and convert unsigned to signed */ if (negative) { if (num > 2147483648u) return TDS_CONVERT_OVERFLOW; *res = 0 - num; } else { if (num >= 2147483648u) return TDS_CONVERT_OVERFLOW; *res = num; } return sizeof(TDS_INT); } /** * \brief convert a number in string to TDS_INT8 * * \return TDS_CONVERT_* or failure code on error */ static TDS_INT /* copied from string_ti_int and modified */ parse_int8(const char *buf, const char *pend, TDS_UINT8 * res, bool * p_negative) { TDS_UINT8 num; size_t digits, decimals; buf = parse_numeric(buf, pend, p_negative, &digits, &decimals); if (!buf) return TDS_CONVERT_SYNTAX; num = 0; for (; digits; --digits, ++buf) { /* add a digit to number and check for overflow */ TDS_UINT8 prev = num; if (num > (((TDS_UINT8) 1u) << 63) / 5u) return TDS_CONVERT_OVERFLOW; num = num * 10u + (*buf - '0'); if (num < prev) return TDS_CONVERT_OVERFLOW; } *res = num; return sizeof(TDS_INT8); } /** * \brief convert a number in string to TDS_INT8 * * \return TDS_CONVERT_* or failure code on error */ static TDS_INT /* copied from string_ti_int and modified */ string_to_int8(const char *buf, const char *pend, TDS_INT8 * res) { TDS_UINT8 num; TDS_INT parse_res; bool negative; parse_res = parse_int8(buf, pend, &num, &negative); if (parse_res < 0) return parse_res; /* check for overflow and convert unsigned to signed */ if (negative) { if (num > (((TDS_UINT8) 1) << 63)) return TDS_CONVERT_OVERFLOW; *res = 0 - num; } else { if (num >= (((TDS_UINT8) 1) << 63)) return TDS_CONVERT_OVERFLOW; *res = num; } return sizeof(TDS_INT8); } /** * \brief convert a number in string to TDS_UINT8 * * \return TDS_CONVERT_* or failure code on error */ static TDS_INT /* copied from string_to_int8 and modified */ string_to_uint8(const char *buf, const char *pend, TDS_UINT8 * res) { TDS_UINT8 num; TDS_INT parse_res; bool negative; parse_res = parse_int8(buf, pend, &num, &negative); if (parse_res < 0) return parse_res; /* check for overflow */ if (negative && num) return TDS_CONVERT_OVERFLOW; *res = num; return sizeof(TDS_UINT8); } /** * Parse a string for numbers. * * Syntax can be something like " *[+-] *[0-9]*\.[0-9]* *". * * The function ignore all spaces. It strips leading zeroes which could * possibly lead to overflow. * The function returns a pointer to the integer part followed by *p_digits * digits followed by a dot followed by *p_decimals digits (dot and * fractional digits are optional, in this case *p_decimals is 0). * * @param buf start of string * @param pend pointer to string end * @param p_negative store if number is negative * @param p_digits store number of integer digits * @param p_decimals store number of fractional digits * @return pointer to first not zero digit. If NULL this indicate a syntax * error. */ static const char * parse_numeric(const char *buf, const char *pend, bool *p_negative, size_t *p_digits, size_t *p_decimals) { enum { blank = ' ' }; #define SKIP_IF(cond) while (p != pend && (cond)) ++p; const char *p, *start; bool negative = false; *p_decimals = 0; p = buf; /* ignore leading spaces */ SKIP_IF(*p == blank); if (p == pend) { *p_negative = false; *p_digits = 0; return p; } /* check for sign */ switch (*p) { case '-': negative = true; /* fall thru */ case '+': /* skip spaces between sign and number */ ++p; SKIP_IF(*p == blank); break; } *p_negative = negative; /* a digit must be present */ if (p == pend) return NULL; /* * skip leading zeroes * Not skipping them cause numbers like "000000000000" to * appear like overflow */ SKIP_IF(*p == '0'); start = p; SKIP_IF(TDS_ISDIGIT(*p)); *p_digits = p - start; /* parse decimal part */ if (p != pend && *p == '.') { const char *decimals_start = ++p; SKIP_IF(TDS_ISDIGIT(*p)); *p_decimals = p - decimals_start; } /* check for trailing spaces */ SKIP_IF(*p == blank); if (p != pend) return NULL; return start; } static TDS_INT string_to_float(const TDS_CHAR * src, TDS_UINT srclen, int desttype, CONV_RESULT * cr) { char tmpstr[128]; char *end; double res; /* ignore leading spaces */ while (srclen > 0 && src[0] == ' ') ++src, --srclen; /* ignore trailing blanks and nulls */ while (srclen > 0 && (src[srclen - 1] == ' ' || src[srclen - 1] == '\0')) --srclen; if (srclen >= sizeof(tmpstr)) return TDS_CONVERT_OVERFLOW; memcpy(tmpstr, src, srclen); tmpstr[srclen] = 0; errno = 0; res = strtod(tmpstr, &end); if (errno == ERANGE) return TDS_CONVERT_OVERFLOW; if (end != tmpstr + srclen) return TDS_CONVERT_SYNTAX; if (desttype == SYBREAL) { /* FIXME check overflows */ cr->r = (TDS_REAL)res; return sizeof(TDS_REAL); } cr->f = res; return sizeof(TDS_FLOAT); } /** @} */ freetds-1.00.82/src/tds/numeric.c100644 025423 025423 00000023675 12717145107 0012237/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-1999 Brian Bruns * Copyright (C) 2005-2015 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include #include /** * tds_numeric_bytes_per_prec is indexed by precision and will * tell us the number of bytes required to store the specified * precision (with the sign). * Support precision up to 77 digits */ const int tds_numeric_bytes_per_prec[] = { /* * precision can't be 0 but using a value > 0 assure no * core if for some bug it's 0... */ 1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 6, 6, 6, 7, 7, 8, 8, 9, 9, 9, 10, 10, 11, 11, 11, 12, 12, 13, 13, 14, 14, 14, 15, 15, 16, 16, 16, 17, 17, 18, 18, 19, 19, 19, 20, 20, 21, 21, 21, 22, 22, 23, 23, 24, 24, 24, 25, 25, 26, 26, 26, 27, 27, 28, 28, 28, 29, 29, 30, 30, 31, 31, 31, 32, 32, 33, 33, 33 }; TDS_COMPILE_CHECK(maxprecision, MAXPRECISION < TDS_VECTOR_SIZE(tds_numeric_bytes_per_prec) ); /* * money is a special case of numeric really...that why its here */ char * tds_money_to_string(const TDS_MONEY * money, char *s) { int frac; TDS_INT8 mymoney; TDS_UINT8 n; char *p; /* sometimes money it's only 4-byte aligned so always compute 64-bit */ mymoney = (((TDS_INT8) money->tdsoldmoney.mnyhigh) << 32) | money->tdsoldmoney.mnylow; p = s; if (mymoney < 0) { *p++ = '-'; /* we use unsigned cause this cause arithmetic problem for -2^63*/ n = -mymoney; } else { n = mymoney; } n = (n + 50) / 100; frac = (int) (n % 100); n /= 100; /* if machine is 64 bit you do not need to split n */ sprintf(p, "%" PRId64 ".%02d", n, frac); return s; } /** * @return <0 if error */ TDS_INT tds_numeric_to_string(const TDS_NUMERIC * numeric, char *s) { const unsigned char *number; unsigned int packet[sizeof(numeric->array) / 2]; unsigned int *pnum, *packet_start; unsigned int *const packet_end = packet + TDS_VECTOR_SIZE(packet); unsigned int packet10k[(MAXPRECISION + 3) / 4]; unsigned int *p; int num_bytes; unsigned int remainder, n, i, m; /* a bit of debug */ #if ENABLE_EXTRA_CHECKS memset(packet, 0x55, sizeof(packet)); memset(packet10k, 0x55, sizeof(packet10k)); #endif if (numeric->precision < 1 || numeric->precision > MAXPRECISION || numeric->scale > numeric->precision) return TDS_CONVERT_FAIL; /* set sign */ if (numeric->array[0] == 1) *s++ = '-'; /* put number in a 16bit array */ number = numeric->array; num_bytes = tds_numeric_bytes_per_prec[numeric->precision]; n = num_bytes - 1; pnum = packet_end; for (; n > 1; n -= 2) *--pnum = TDS_GET_UA2BE(&number[n - 1]); if (n == 1) *--pnum = number[n]; while (!*pnum) { ++pnum; if (pnum == packet_end) { *s++ = '0'; if (numeric->scale) { *s++ = '.'; i = numeric->scale; do { *s++ = '0'; } while (--i); } *s = 0; return 1; } } packet_start = pnum; /* transform 2^16 base number in 10^4 base number */ for (p = packet10k + TDS_VECTOR_SIZE(packet10k); packet_start != packet_end;) { pnum = packet_start; n = *pnum; remainder = n % 10000u; if (!(*pnum++ = (n / 10000u))) packet_start = pnum; for (; pnum != packet_end; ++pnum) { n = remainder * (256u * 256u) + *pnum; remainder = n % 10000u; *pnum = n / 10000u; } *--p = remainder; } /* transform to 10 base number and output */ i = 4 * (unsigned int)((packet10k + TDS_VECTOR_SIZE(packet10k)) - p); /* current digit */ /* skip leading zeroes */ n = 1000; remainder = *p; while (remainder < n) n /= 10, --i; if (i <= numeric->scale) { *s++ = '0'; *s++ = '.'; m = i; while (m < numeric->scale) *s++ = '0', ++m; } for (;;) { *s++ = (remainder / n) + '0'; --i; remainder %= n; n /= 10; if (!n) { n = 1000; if (++p == packet10k + TDS_VECTOR_SIZE(packet10k)) break; remainder = *p; } if (i == numeric->scale) *s++ = '.'; } *s = 0; return 1; } #define TDS_WORD TDS_UINT #define TDS_DWORD TDS_UINT8 #define TDS_WORD_DDIGIT 9 /* include to check limits */ #include "num_limits.h" static int tds_packet_check_overflow(TDS_WORD *packet, unsigned int packet_len, unsigned int prec) { unsigned int i, len, stop; const TDS_WORD *limit = &limits[limit_indexes[prec] + LIMIT_INDEXES_ADJUST * prec]; len = limit_indexes[prec+1] - limit_indexes[prec] + LIMIT_INDEXES_ADJUST; stop = prec / (sizeof(TDS_WORD) * 8); /* * Now a number is * ... P[3] P[2] P[1] P[0] * while upper limit + 1 is * zeroes limit[0 .. len-1] 0[0 .. stop-1] * we must assure that number < upper limit + 1 */ if (packet_len >= len + stop) { /* higher packets must be zero */ for (i = packet_len; --i >= len + stop; ) if (packet[i] > 0) return TDS_CONVERT_OVERFLOW; /* test limit */ for (;; --i, ++limit) { if (i <= stop) { /* last must be >= not > */ if (packet[i] >= *limit) return TDS_CONVERT_OVERFLOW; break; } if (packet[i] > *limit) return TDS_CONVERT_OVERFLOW; if (packet[i] < *limit) break; } } return 0; } TDS_INT tds_numeric_change_prec_scale(TDS_NUMERIC * numeric, unsigned char new_prec, unsigned char new_scale) { static const TDS_WORD factors[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000 }; TDS_WORD packet[(sizeof(numeric->array) - 1) / sizeof(TDS_WORD)]; unsigned int i, packet_len; int scale_diff, bytes; if (numeric->precision < 1 || numeric->precision > MAXPRECISION || numeric->scale > numeric->precision) return TDS_CONVERT_FAIL; if (new_prec < 1 || new_prec > MAXPRECISION || new_scale > new_prec) return TDS_CONVERT_FAIL; scale_diff = new_scale - numeric->scale; if (scale_diff == 0 && new_prec >= numeric->precision) { i = tds_numeric_bytes_per_prec[new_prec] - tds_numeric_bytes_per_prec[numeric->precision]; if (i > 0) { memmove(numeric->array + 1 + i, numeric->array + 1, sizeof(numeric->array) - 1 - i); memset(numeric->array + 1, 0, i); } numeric->precision = new_prec; return sizeof(TDS_NUMERIC); } /* package number */ bytes = tds_numeric_bytes_per_prec[numeric->precision] - 1; i = 0; do { /* * note that if bytes are smaller we have a small buffer * overflow in numeric->array however is not a problem * cause overflow occurs in numeric and number is fixed below */ packet[i] = TDS_GET_UA4BE(&numeric->array[bytes-3]); ++i; } while ( (bytes -= sizeof(TDS_WORD)) > 0); /* fix last packet */ if (bytes < 0) packet[i-1] &= 0xffffffffu >> (8 * -bytes); while (i > 1 && packet[i-1] == 0) --i; packet_len = i; if (scale_diff >= 0) { /* check overflow before multiply */ if (tds_packet_check_overflow(packet, packet_len, new_prec - scale_diff)) return TDS_CONVERT_OVERFLOW; if (scale_diff == 0) { i = tds_numeric_bytes_per_prec[numeric->precision] - tds_numeric_bytes_per_prec[new_prec]; if (i > 0) memmove(numeric->array + 1, numeric->array + 1 + i, sizeof(numeric->array) - 1 - i); numeric->precision = new_prec; return sizeof(TDS_NUMERIC); } /* multiply */ do { /* multiply by at maximun TDS_WORD_DDIGIT */ unsigned int n = scale_diff > TDS_WORD_DDIGIT ? TDS_WORD_DDIGIT : scale_diff; TDS_WORD factor = factors[n]; TDS_WORD carry = 0; scale_diff -= n; for (i = 0; i < packet_len; ++i) { TDS_DWORD n = packet[i] * ((TDS_DWORD) factor) + carry; packet[i] = (TDS_WORD) n; carry = n >> (8 * sizeof(TDS_WORD)); } /* here we can expand number safely cause we know that it can't overflow */ if (carry) packet[packet_len++] = carry; } while (scale_diff > 0); } else { /* check overflow */ if (new_prec - scale_diff < numeric->precision) if (tds_packet_check_overflow(packet, packet_len, new_prec - scale_diff)) return TDS_CONVERT_OVERFLOW; /* divide */ scale_diff = -scale_diff; do { unsigned int n = scale_diff > TDS_WORD_DDIGIT ? TDS_WORD_DDIGIT : scale_diff; TDS_WORD factor = factors[n]; TDS_WORD borrow = 0; scale_diff -= n; for (i = packet_len; i > 0; ) { #if defined(__GNUC__) && __GNUC__ >= 3 && defined(__i386__) --i; __asm__ ("divl %4": "=a"(packet[i]), "=d"(borrow): "0"(packet[i]), "1"(borrow), "r"(factor)); #elif defined(__WATCOMC__) && defined(DOS32X) TDS_WORD Int64div32(TDS_WORD* low,TDS_WORD high,TDS_WORD factor); #pragma aux Int64div32 = "mov eax, dword ptr[esi]" \ "div ecx" \ "mov dword ptr[esi], eax" \ parm [ESI] [EDX] [ECX] value [EDX] modify [EAX EDX]; borrow = Int64div32(&packet[i], borrow, factor); #else TDS_DWORD n = (((TDS_DWORD) borrow) << (8 * sizeof(TDS_WORD))) + packet[--i]; packet[i] = (TDS_WORD) (n / factor); borrow = n % factor; #endif } } while (scale_diff > 0); } /* back to our format */ numeric->precision = new_prec; numeric->scale = new_scale; bytes = tds_numeric_bytes_per_prec[numeric->precision] - 1; for (i = bytes / sizeof(TDS_WORD); i >= packet_len; --i) packet[i] = 0; for (i = 0; bytes >= sizeof(TDS_WORD); bytes -= sizeof(TDS_WORD), ++i) { TDS_PUT_UA4BE(&numeric->array[bytes-3], packet[i]); } if (bytes) { TDS_WORD remainder = packet[i]; do { numeric->array[bytes] = (TDS_UCHAR) remainder; remainder >>= 8; } while (--bytes); } return sizeof(TDS_NUMERIC); } freetds-1.00.82/src/tds/config.c100644 025423 025423 00000116152 13111516422 0012022/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #if HAVE_ERRNO_H #include #endif /* HAVE_ERRNO_H */ #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_LIMITS_H #include #endif #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #if HAVE_NETDB_H #include #endif /* HAVE_NETDB_H */ #if HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #if HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #if HAVE_NETINET_IN_H #include #endif /* HAVE_NETINET_IN_H */ #if HAVE_ARPA_INET_H #include #endif /* HAVE_ARPA_INET_H */ #ifdef _WIN32 #include #endif #include #include #include #include "replacements.h" static int tds_config_login(TDSLOGIN * connection, TDSLOGIN * login); static int tds_config_env_tdsdump(TDSLOGIN * login); static void tds_config_env_tdsver(TDSLOGIN * login); static void tds_config_env_tdsport(TDSLOGIN * login); static int tds_config_env_tdshost(TDSLOGIN * login); static int tds_read_conf_sections(FILE * in, const char *server, TDSLOGIN * login); static int tds_read_interfaces(const char *server, TDSLOGIN * login); static int parse_server_name_for_port(TDSLOGIN * connection, TDSLOGIN * login); static int tds_lookup_port(const char *portname); static void tds_config_encryption(const char * value, TDSLOGIN * login); static char *interf_file = NULL; #define TDS_ISSPACE(c) isspace((unsigned char ) (c)) #if !defined(_WIN32) && !defined(DOS32X) const char STD_DATETIME_FMT[] = "%b %e %Y %I:%M%p"; static const char pid_config_logpath[] = "/tmp/tdsconfig.log.%d"; static const char freetds_conf[] = "%s/etc/freetds.conf"; static const char location[] = "(from $FREETDS/etc)"; static const char pid_logpath[] = "/tmp/freetds.log.%d"; static const char interfaces_path[] = "/etc/freetds"; #else const char STD_DATETIME_FMT[] = "%b %d %Y %I:%M%p"; /* msvcr80.dll does not support %e */ static const char pid_config_logpath[] = "c:\\tdsconfig.log.%d"; static const char freetds_conf [] = "%s\\freetds.conf"; static const char location[] = "(from $FREETDS)"; static const char pid_logpath[] = "c:\\freetds.log.%d"; static const char interfaces_path[] = "c:\\"; #endif /** * \ingroup libtds * \defgroup config Configuration * Handle reading of configuration */ /** * \addtogroup config * @{ */ /** * tds_read_config_info() will fill the tds connection structure based on configuration * information gathered in the following order: * 1) Program specified in TDSLOGIN structure * 2) The environment variables TDSVER, TDSDUMP, TDSPORT, TDSQUERY, TDSHOST * 3) A config file with the following search order: * a) a readable file specified by environment variable FREETDSCONF * b) a readable file in ~/.freetds.conf * c) a readable file in $prefix/etc/freetds.conf * 3) ~/.interfaces if exists * 4) $SYBASE/interfaces if exists * 5) TDS_DEF_* default values * * .tdsrc and freetds.conf have been added to make the package easier to * integration with various Linux and *BSD distributions. */ TDSLOGIN * tds_read_config_info(TDSSOCKET * tds, TDSLOGIN * login, TDSLOCALE * locale) { TDSLOGIN *connection; char *s; char *path; pid_t pid; int opened = 0, found; struct addrinfo *addrs; /* allocate a new structure with hard coded and build-time defaults */ connection = tds_alloc_login(0); if (!connection || !tds_init_login(connection, locale)) { tds_free_login(connection); return NULL; } s = getenv("TDSDUMPCONFIG"); if (s) { if (*s) { opened = tdsdump_open(s); } else { pid = getpid(); if (asprintf(&path, pid_config_logpath, pid) >= 0) { if (*path) { opened = tdsdump_open(path); } free(path); } } } tdsdump_log(TDS_DBG_INFO1, "Getting connection information for [%s].\n", tds_dstr_cstr(&login->server_name)); /* (The server name is set in login.c.) */ /* Read the config files. */ tdsdump_log(TDS_DBG_INFO1, "Attempting to read conf files.\n"); found = tds_read_conf_file(connection, tds_dstr_cstr(&login->server_name)); if (!found) { if (parse_server_name_for_port(connection, login)) { found = tds_read_conf_file(connection, tds_dstr_cstr(&connection->server_name)); /* do it again to really override what found in freetds.conf */ if (found) { parse_server_name_for_port(connection, login); } else if (TDS_SUCCEED(tds_lookup_host_set(tds_dstr_cstr(&connection->server_name), &connection->ip_addrs))) { if (!tds_dstr_dup(&connection->server_host_name, &connection->server_name)) { tds_free_login(connection); return NULL; } found = 1; } } } if (!found) { /* fallback to interfaces file */ tdsdump_log(TDS_DBG_INFO1, "Failed in reading conf file. Trying interface files.\n"); if (!tds_read_interfaces(tds_dstr_cstr(&login->server_name), connection)) { tdsdump_log(TDS_DBG_INFO1, "Failed to find [%s] in configuration files; trying '%s' instead.\n", tds_dstr_cstr(&login->server_name), tds_dstr_cstr(&connection->server_name)); if (connection->ip_addrs == NULL) tdserror(tds_get_ctx(tds), tds, TDSEINTF, 0); } } /* Override config file settings with environment variables. */ tds_fix_login(connection); /* And finally apply anything from the login structure */ if (!tds_config_login(connection, login)) { tds_free_login(connection); return NULL; } if (opened) { char tmp[128]; tdsdump_log(TDS_DBG_INFO1, "Final connection parameters:\n"); tdsdump_log(TDS_DBG_INFO1, "\t%20s = %s\n", "server_name", tds_dstr_cstr(&connection->server_name)); tdsdump_log(TDS_DBG_INFO1, "\t%20s = %s\n", "server_host_name", tds_dstr_cstr(&connection->server_host_name)); for (addrs = connection->ip_addrs; addrs != NULL; addrs = addrs->ai_next) tdsdump_log(TDS_DBG_INFO1, "\t%20s = %s\n", "ip_addr", tds_addrinfo2str(addrs, tmp, sizeof(tmp))); if (connection->ip_addrs == NULL) tdsdump_log(TDS_DBG_INFO1, "\t%20s = %s\n", "ip_addr", ""); tdsdump_log(TDS_DBG_INFO1, "\t%20s = %s\n", "instance_name", tds_dstr_cstr(&connection->instance_name)); tdsdump_log(TDS_DBG_INFO1, "\t%20s = %d\n", "port", connection->port); tdsdump_log(TDS_DBG_INFO1, "\t%20s = %d\n", "major_version", TDS_MAJOR(connection)); tdsdump_log(TDS_DBG_INFO1, "\t%20s = %d\n", "minor_version", TDS_MINOR(connection)); tdsdump_log(TDS_DBG_INFO1, "\t%20s = %d\n", "block_size", connection->block_size); tdsdump_log(TDS_DBG_INFO1, "\t%20s = %s\n", "language", tds_dstr_cstr(&connection->language)); tdsdump_log(TDS_DBG_INFO1, "\t%20s = %s\n", "server_charset", tds_dstr_cstr(&connection->server_charset)); tdsdump_log(TDS_DBG_INFO1, "\t%20s = %d\n", "connect_timeout", connection->connect_timeout); tdsdump_log(TDS_DBG_INFO1, "\t%20s = %s\n", "client_host_name", tds_dstr_cstr(&connection->client_host_name)); tdsdump_log(TDS_DBG_INFO1, "\t%20s = %s\n", "client_charset", tds_dstr_cstr(&connection->client_charset)); tdsdump_log(TDS_DBG_INFO1, "\t%20s = %d\n", "use_utf16", connection->use_utf16); tdsdump_log(TDS_DBG_INFO1, "\t%20s = %s\n", "app_name", tds_dstr_cstr(&connection->app_name)); tdsdump_log(TDS_DBG_INFO1, "\t%20s = %s\n", "user_name", tds_dstr_cstr(&connection->user_name)); /* tdsdump_log(TDS_DBG_PASSWD, "\t%20s = %s\n", "password", tds_dstr_cstr(&connection->password)); (no such flag yet) */ tdsdump_log(TDS_DBG_INFO1, "\t%20s = %s\n", "library", tds_dstr_cstr(&connection->library)); tdsdump_log(TDS_DBG_INFO1, "\t%20s = %d\n", "bulk_copy", (int)connection->bulk_copy); tdsdump_log(TDS_DBG_INFO1, "\t%20s = %d\n", "suppress_language", (int)connection->suppress_language); tdsdump_log(TDS_DBG_INFO1, "\t%20s = %d\n", "encrypt level", (int)connection->encryption_level); tdsdump_log(TDS_DBG_INFO1, "\t%20s = %d\n", "query_timeout", connection->query_timeout); /* tdsdump_log(TDS_DBG_INFO1, "\t%20s = %s\n", "capabilities", tds_dstr_cstr(&connection->capabilities)); (not null terminated) */ tdsdump_log(TDS_DBG_INFO1, "\t%20s = %s\n", "database", tds_dstr_cstr(&connection->database)); tdsdump_log(TDS_DBG_INFO1, "\t%20s = %s\n", "dump_file", tds_dstr_cstr(&connection->dump_file)); tdsdump_log(TDS_DBG_INFO1, "\t%20s = %x\n", "debug_flags", connection->debug_flags); tdsdump_log(TDS_DBG_INFO1, "\t%20s = %d\n", "text_size", connection->text_size); tdsdump_log(TDS_DBG_INFO1, "\t%20s = %d\n", "emul_little_endian", connection->emul_little_endian); tdsdump_log(TDS_DBG_INFO1, "\t%20s = %s\n", "server_realm_name", tds_dstr_cstr(&connection->server_realm_name)); tdsdump_log(TDS_DBG_INFO1, "\t%20s = %s\n", "server_spn", tds_dstr_cstr(&connection->server_spn)); tdsdump_log(TDS_DBG_INFO1, "\t%20s = %s\n", "cafile", tds_dstr_cstr(&connection->cafile)); tdsdump_log(TDS_DBG_INFO1, "\t%20s = %s\n", "crlfile", tds_dstr_cstr(&connection->crlfile)); tdsdump_log(TDS_DBG_INFO1, "\t%20s = %d\n", "check_ssl_hostname", connection->check_ssl_hostname); tdsdump_log(TDS_DBG_INFO1, "\t%20s = %s\n", "db_filename", tds_dstr_cstr(&connection->db_filename)); tdsdump_log(TDS_DBG_INFO1, "\t%20s = %d\n", "readonly_intent", connection->readonly_intent); #ifdef HAVE_OPENSSL tdsdump_log(TDS_DBG_INFO1, "\t%20s = %s\n", "openssl_ciphers", tds_dstr_cstr(&connection->openssl_ciphers)); #endif tdsdump_close(); } /* * If a dump file has been specified, start logging */ if (!tds_dstr_isempty(&connection->dump_file) && !tdsdump_isopen()) { if (connection->debug_flags) tds_debug_flags = connection->debug_flags; tdsdump_open(tds_dstr_cstr(&connection->dump_file)); } return connection; } /** * Fix configuration after reading it. * Currently this read some environment variables and replace some options. */ void tds_fix_login(TDSLOGIN * login) { /* Now check the environment variables */ tds_config_env_tdsver(login); tds_config_env_tdsdump(login); tds_config_env_tdsport(login); tds_config_env_tdshost(login); } static int tds_try_conf_file(const char *path, const char *how, const char *server, TDSLOGIN * login) { int found = 0; FILE *in; if ((in = fopen(path, "r")) == NULL) { tdsdump_log(TDS_DBG_INFO1, "Could not open '%s' (%s).\n", path, how); return found; } tdsdump_log(TDS_DBG_INFO1, "Found conf file '%s' %s.\n", path, how); found = tds_read_conf_sections(in, server, login); if (found) { tdsdump_log(TDS_DBG_INFO1, "Success: [%s] defined in %s.\n", server, path); } else { tdsdump_log(TDS_DBG_INFO2, "[%s] not found.\n", server); } fclose(in); return found; } /** * Return filename from HOME directory * @return allocated string or NULL if error */ static char * tds_get_home_file(const char *file) { char *home, *path; home = tds_get_homedir(); if (!home) return NULL; if (asprintf(&path, "%s/%s", home, file) < 0) path = NULL; free(home); return path; } /** * Read configuration info for given server * return 0 on error * @param login where to store configuration * @param server section of file configuration that hold * configuration for a server */ int tds_read_conf_file(TDSLOGIN * login, const char *server) { char *path = NULL; char *eptr = NULL; int found = 0; if (interf_file) { found = tds_try_conf_file(interf_file, "set programmatically", server, login); } /* FREETDSCONF env var, pkleef@openlinksw.com 01/21/02 */ if (!found) { path = getenv("FREETDSCONF"); if (path) { found = tds_try_conf_file(path, "(from $FREETDSCONF)", server, login); } else { tdsdump_log(TDS_DBG_INFO2, "... $FREETDSCONF not set. Trying $FREETDS/etc.\n"); } } /* FREETDS env var, Bill Thompson 16/07/03 */ if (!found) { eptr = getenv("FREETDS"); if (eptr) { if (asprintf(&path, freetds_conf, eptr) >= 0) { found = tds_try_conf_file(path, location, server, login); free(path); } } else { tdsdump_log(TDS_DBG_INFO2, "... $FREETDS not set. Trying $HOME.\n"); } } if (!found) { path = tds_get_home_file(".freetds.conf"); if (path) { found = tds_try_conf_file(path, "(.freetds.conf)", server, login); free(path); } else { tdsdump_log(TDS_DBG_INFO2, "... Error getting ~/.freetds.conf. Trying %s.\n", FREETDS_SYSCONFFILE); } } if (!found) { found = tds_try_conf_file(FREETDS_SYSCONFFILE, "(default)", server, login); } return found; } static int tds_read_conf_sections(FILE * in, const char *server, TDSLOGIN * login) { DSTR default_instance = DSTR_INITIALIZER; int default_port; int found; tds_read_conf_section(in, "global", tds_parse_conf_section, login); if (!server[0]) return 0; rewind(in); if (!tds_dstr_dup(&default_instance, &login->instance_name)) return 0; default_port = login->port; found = tds_read_conf_section(in, server, tds_parse_conf_section, login); if (!login->valid_configuration) { tds_dstr_free(&default_instance); return 0; } /* * If both instance and port are specified and neither one came from the default, it's an error * TODO: If port/instance is specified in the non-default, it has priority over the default setting. * TODO: test this. */ if (!tds_dstr_isempty(&login->instance_name) && login->port && !(!tds_dstr_isempty(&default_instance) || default_port)) { tdsdump_log(TDS_DBG_ERROR, "error: cannot specify both port %d and instance %s.\n", login->port, tds_dstr_cstr(&login->instance_name)); /* tdserror(tds_get_ctx(tds), tds, TDSEPORTINSTANCE, 0); */ } tds_dstr_free(&default_instance); return found; } static const struct { char value[7]; unsigned char to_return; } boolean_values[] = { { "yes", 1 }, { "no", 0 }, { "on", 1 }, { "off", 0 }, { "true", 1 }, { "false", 0 } }; int tds_parse_boolean(const char *value, int default_value) { int p; for (p = 0; p < TDS_VECTOR_SIZE(boolean_values); ++p) { if (!strcasecmp(value, boolean_values[p].value)) return boolean_values[p].to_return; } return default_value; } int tds_config_boolean(const char *option, const char *value, TDSLOGIN *login) { int ret = tds_parse_boolean(value, -1); if (ret >= 0) return ret; tdsdump_log(TDS_DBG_ERROR, "UNRECOGNIZED option value '%s' for boolean setting '%s'!\n", value, option); login->valid_configuration = 0; return 0; } static void tds_config_encryption(const char * value, TDSLOGIN * login) { TDS_ENCRYPTION_LEVEL lvl = TDS_ENCRYPTION_OFF; if (!strcasecmp(value, TDS_STR_ENCRYPTION_OFF)) ; else if (!strcasecmp(value, TDS_STR_ENCRYPTION_REQUEST)) lvl = TDS_ENCRYPTION_REQUEST; else if (!strcasecmp(value, TDS_STR_ENCRYPTION_REQUIRE)) lvl = TDS_ENCRYPTION_REQUIRE; else { tdsdump_log(TDS_DBG_ERROR, "UNRECOGNIZED option value '%s' for '%s' setting!\n", value, TDS_STR_ENCRYPTION); tdsdump_log(TDS_DBG_ERROR, "Valid settings are: ('%s', '%s', '%s')\n", TDS_STR_ENCRYPTION_OFF, TDS_STR_ENCRYPTION_REQUEST, TDS_STR_ENCRYPTION_REQUIRE); lvl = TDS_ENCRYPTION_REQUIRE; /* Assuming "require" is safer than "no" */ login->valid_configuration = 0; } login->encryption_level = lvl; } /** * Read a section of configuration file (INI style file) * @param in configuration file * @param section section to read * @param tds_conf_parse callback that receive every entry in section * @param param parameter to pass to callback function */ int tds_read_conf_section(FILE * in, const char *section, TDSCONFPARSE tds_conf_parse, void *param) { char line[256], *value; #define option line char *s; char p; int i; int insection = 0; int found = 0; tdsdump_log(TDS_DBG_INFO1, "Looking for section %s.\n", section); while (fgets(line, sizeof(line), in)) { s = line; /* skip leading whitespace */ while (*s && TDS_ISSPACE(*s)) s++; /* skip it if it's a comment line */ if (*s == ';' || *s == '#') continue; /* read up to the = ignoring duplicate spaces */ p = 0; i = 0; while (*s && *s != '=') { if (!TDS_ISSPACE(*s)) { if (TDS_ISSPACE(p)) option[i++] = ' '; option[i++] = tolower((unsigned char) *s); } p = *s; s++; } /* skip if empty option */ if (!i) continue; /* skip the = */ if (*s) s++; /* terminate the option, must be done after skipping = */ option[i] = '\0'; /* skip leading whitespace */ while (*s && TDS_ISSPACE(*s)) s++; /* read up to a # ; or null ignoring duplicate spaces */ value = s; p = 0; i = 0; while (*s && *s != ';' && *s != '#') { if (!TDS_ISSPACE(*s)) { if (TDS_ISSPACE(p)) value[i++] = ' '; value[i++] = *s; } p = *s; s++; } value[i] = '\0'; if (option[0] == '[') { s = strchr(option, ']'); if (s) *s = '\0'; tdsdump_log(TDS_DBG_INFO1, "\tFound section %s.\n", &option[1]); if (!strcasecmp(section, &option[1])) { tdsdump_log(TDS_DBG_INFO1, "Got a match.\n"); insection = 1; found = 1; } else { insection = 0; } } else if (insection) { tds_conf_parse(option, value, param); } } tdsdump_log(TDS_DBG_INFO1, "\tReached EOF\n"); return found; #undef option } /* Also used to scan ODBC.INI entries */ void tds_parse_conf_section(const char *option, const char *value, void *param) { TDSLOGIN *login = (TDSLOGIN *) param; void *s = param; tdsdump_log(TDS_DBG_INFO1, "\t%s = '%s'\n", option, value); if (!strcmp(option, TDS_STR_VERSION)) { tds_config_verstr(value, login); } else if (!strcmp(option, TDS_STR_BLKSZ)) { int val = atoi(value); if (val >= 512 && val < 65536) login->block_size = val; } else if (!strcmp(option, TDS_STR_SWAPDT)) { /* this option is deprecated, just check value for compatibility */ tds_config_boolean(option, value, login); } else if (!strcmp(option, TDS_GSSAPI_DELEGATION)) { /* gssapi flag addition */ login->gssapi_use_delegation = tds_config_boolean(option, value, login); } else if (!strcmp(option, TDS_STR_DUMPFILE)) { s = tds_dstr_copy(&login->dump_file, value); } else if (!strcmp(option, TDS_STR_DEBUGFLAGS)) { char *end; long flags; flags = strtol(value, &end, 0); if (*value != '\0' && *end == '\0' && flags != LONG_MIN && flags != LONG_MAX) login->debug_flags = flags; } else if (!strcmp(option, TDS_STR_TIMEOUT) || !strcmp(option, TDS_STR_QUERY_TIMEOUT)) { if (atoi(value)) login->query_timeout = atoi(value); } else if (!strcmp(option, TDS_STR_CONNTIMEOUT)) { if (atoi(value)) login->connect_timeout = atoi(value); } else if (!strcmp(option, TDS_STR_HOST)) { char tmp[128]; struct addrinfo *addrs; if (TDS_FAILED(tds_lookup_host_set(value, &login->ip_addrs))) { tdsdump_log(TDS_DBG_WARN, "Found host entry %s however name resolution failed. \n", value); return; } tdsdump_log(TDS_DBG_INFO1, "Found host entry %s \n", value); s = tds_dstr_copy(&login->server_host_name, value); for (addrs = login->ip_addrs; addrs != NULL; addrs = addrs->ai_next) tdsdump_log(TDS_DBG_INFO1, "IP addr is %s.\n", tds_addrinfo2str(addrs, tmp, sizeof(tmp))); } else if (!strcmp(option, TDS_STR_PORT)) { if (atoi(value)) login->port = atoi(value); } else if (!strcmp(option, TDS_STR_EMUL_LE)) { login->emul_little_endian = tds_config_boolean(option, value, login); } else if (!strcmp(option, TDS_STR_TEXTSZ)) { if (atoi(value)) login->text_size = atoi(value); } else if (!strcmp(option, TDS_STR_CHARSET)) { s = tds_dstr_copy(&login->server_charset, value); tdsdump_log(TDS_DBG_INFO1, "%s is %s.\n", option, tds_dstr_cstr(&login->server_charset)); } else if (!strcmp(option, TDS_STR_CLCHARSET)) { s = tds_dstr_copy(&login->client_charset, value); tdsdump_log(TDS_DBG_INFO1, "tds_parse_conf_section: %s is %s.\n", option, tds_dstr_cstr(&login->client_charset)); } else if (!strcmp(option, TDS_STR_USE_UTF_16)) { login->use_utf16 = tds_config_boolean(option, value, login); } else if (!strcmp(option, TDS_STR_LANGUAGE)) { s = tds_dstr_copy(&login->language, value); } else if (!strcmp(option, TDS_STR_APPENDMODE)) { tds_g_append_mode = tds_config_boolean(option, value, login); } else if (!strcmp(option, TDS_STR_INSTANCE)) { s = tds_dstr_copy(&login->instance_name, value); } else if (!strcmp(option, TDS_STR_ENCRYPTION)) { tds_config_encryption(value, login); } else if (!strcmp(option, TDS_STR_ASA_DATABASE)) { s = tds_dstr_copy(&login->server_name, value); } else if (!strcmp(option, TDS_STR_USENTLMV2)) { login->use_ntlmv2 = tds_config_boolean(option, value, login); } else if (!strcmp(option, TDS_STR_USELANMAN)) { login->use_lanman = tds_config_boolean(option, value, login); } else if (!strcmp(option, TDS_STR_REALM)) { s = tds_dstr_copy(&login->server_realm_name, value); } else if (!strcmp(option, TDS_STR_SPN)) { s = tds_dstr_copy(&login->server_spn, value); } else if (!strcmp(option, TDS_STR_CAFILE)) { s = tds_dstr_copy(&login->cafile, value); } else if (!strcmp(option, TDS_STR_CRLFILE)) { s = tds_dstr_copy(&login->crlfile, value); } else if (!strcmp(option, TDS_STR_CHECKSSLHOSTNAME)) { login->check_ssl_hostname = tds_config_boolean(option, value, login); } else if (!strcmp(option, TDS_STR_DBFILENAME)) { s = tds_dstr_copy(&login->db_filename, value); } else if (!strcmp(option, TDS_STR_DATABASE)) { s = tds_dstr_copy(&login->database, value); } else if (!strcmp(option, TDS_STR_READONLY_INTENT)) { login->readonly_intent = tds_config_boolean(option, value, login); tdsdump_log(TDS_DBG_FUNC, "Setting ReadOnly Intent to '%s'.\n", value); } else if (!strcmp(option, TLS_STR_OPENSSL_CIPHERS)) { s = tds_dstr_copy(&login->openssl_ciphers, value); } else { tdsdump_log(TDS_DBG_INFO1, "UNRECOGNIZED option '%s' ... ignoring.\n", option); } if (!s) login->valid_configuration = 0; } static int tds_config_login(TDSLOGIN * connection, TDSLOGIN * login) { DSTR *res = &login->server_name; if (!tds_dstr_isempty(&login->server_name)) { if (1 || tds_dstr_isempty(&connection->server_name)) res = tds_dstr_dup(&connection->server_name, &login->server_name); } if (login->tds_version) connection->tds_version = login->tds_version; if (res && !tds_dstr_isempty(&login->language)) { res = tds_dstr_dup(&connection->language, &login->language); } if (res && !tds_dstr_isempty(&login->server_charset)) { res = tds_dstr_dup(&connection->server_charset, &login->server_charset); } if (res && !tds_dstr_isempty(&login->client_charset)) { res = tds_dstr_dup(&connection->client_charset, &login->client_charset); tdsdump_log(TDS_DBG_INFO1, "tds_config_login: %s is %s.\n", "client_charset", tds_dstr_cstr(&connection->client_charset)); } if (!login->use_utf16) connection->use_utf16 = login->use_utf16; if (res && !tds_dstr_isempty(&login->database)) { res = tds_dstr_dup(&connection->database, &login->database); tdsdump_log(TDS_DBG_INFO1, "tds_config_login: %s is %s.\n", "database_name", tds_dstr_cstr(&connection->database)); } if (res && !tds_dstr_isempty(&login->client_host_name)) { res = tds_dstr_dup(&connection->client_host_name, &login->client_host_name); } if (res && !tds_dstr_isempty(&login->app_name)) { res = tds_dstr_dup(&connection->app_name, &login->app_name); } if (res && !tds_dstr_isempty(&login->user_name)) { res = tds_dstr_dup(&connection->user_name, &login->user_name); } if (res && !tds_dstr_isempty(&login->password)) { /* for security reason clear memory */ tds_dstr_zero(&connection->password); res = tds_dstr_dup(&connection->password, &login->password); } if (res && !tds_dstr_isempty(&login->library)) { res = tds_dstr_dup(&connection->library, &login->library); } if (login->encryption_level) { connection->encryption_level = login->encryption_level; } if (login->suppress_language) { connection->suppress_language = 1; } if (!login->bulk_copy) { connection->bulk_copy = 0; } if (login->block_size) { connection->block_size = login->block_size; } if (login->port) connection->port = login->port; if (login->connect_timeout) connection->connect_timeout = login->connect_timeout; if (login->query_timeout) connection->query_timeout = login->query_timeout; if (!login->check_ssl_hostname) connection->check_ssl_hostname = login->check_ssl_hostname; if (res && !tds_dstr_isempty(&login->db_filename)) { res = tds_dstr_dup(&connection->db_filename, &login->db_filename); } if (res && !tds_dstr_isempty(&login->openssl_ciphers)) { res = tds_dstr_dup(&connection->openssl_ciphers, &login->openssl_ciphers); } /* copy other info not present in configuration file */ connection->capabilities = login->capabilities; if (login->readonly_intent) connection->readonly_intent = login->readonly_intent; connection->use_new_password = login->use_new_password; if (res) res = tds_dstr_dup(&connection->new_password, &login->new_password); return res != NULL; } static int tds_config_env_tdsdump(TDSLOGIN * login) { char *s; char *path; pid_t pid = 0; if ((s = getenv("TDSDUMP"))) { if (!strlen(s)) { pid = getpid(); if (asprintf(&path, pid_logpath, pid) < 0) return 0; if (!tds_dstr_set(&login->dump_file, path)) { free(path); return 0; } } else { if (!tds_dstr_copy(&login->dump_file, s)) return 0; } tdsdump_log(TDS_DBG_INFO1, "Setting 'dump_file' to '%s' from $TDSDUMP.\n", tds_dstr_cstr(&login->dump_file)); } return 1; } static void tds_config_env_tdsport(TDSLOGIN * login) { char *s; if ((s = getenv("TDSPORT"))) { login->port = tds_lookup_port(s); tds_dstr_empty(&login->instance_name); tdsdump_log(TDS_DBG_INFO1, "Setting 'port' to %s from $TDSPORT.\n", s); } return; } static void tds_config_env_tdsver(TDSLOGIN * login) { char *tdsver; if ((tdsver = getenv("TDSVER"))) { TDS_USMALLINT *pver = tds_config_verstr(tdsver, login); tdsdump_log(TDS_DBG_INFO1, "TDS version %sset to %s from $TDSVER.\n", (pver? "":"not "), tdsver); } return; } /* TDSHOST env var, pkleef@openlinksw.com 01/21/02 */ static int tds_config_env_tdshost(TDSLOGIN * login) { const char *tdshost; char tmp[128]; struct addrinfo *addrs; if (!(tdshost = getenv("TDSHOST"))) return 1; if (TDS_FAILED(tds_lookup_host_set(tdshost, &login->ip_addrs))) { tdsdump_log(TDS_DBG_WARN, "Name resolution failed for '%s' from $TDSHOST.\n", tdshost); return 0; } if (!tds_dstr_copy(&login->server_host_name, tdshost)) return 0; for (addrs = login->ip_addrs; addrs != NULL; addrs = addrs->ai_next) { tdsdump_log(TDS_DBG_INFO1, "Setting IP Address to %s (%s) from $TDSHOST.\n", tds_addrinfo2str(addrs, tmp, sizeof(tmp)), tdshost); } return 1; } #define TDS_FIND(k,b,c) tds_find(k, b, sizeof(b)/sizeof(b[0]), sizeof(b[0]), c) static void * tds_find(const void *key, const void *base, size_t nelem, size_t width, int (*compar)(const void *, const void *)) { size_t i; for (i=0; i < nelem; i++) { char *p = (char*)base + width * i; if (0 == compar(key, p)) { return p; } } return NULL; } struct tdsvername_t { const char name[6]; TDS_USMALLINT version; }; static int tds_vernanme_cmp(const void *key, const void *pelem) { return strcmp((const char *)key, ((const struct tdsvername_t *)pelem)->name); } /** * Set TDS version from given string * @param tdsver tds string version * @param login where to store information * @return as encoded hex value: high nybble major, low nybble minor. */ TDS_USMALLINT * tds_config_verstr(const char *tdsver, TDSLOGIN * login) { static const struct tdsvername_t tds_versions[] = { { "0", 0x000 } , {"auto", 0x000 } , { "4.2", 0x402 } , { "4.2", 0x402 } , { "46", 0x406 } , { "4.6", 0x406 } , { "50", 0x500 } , { "5.0", 0x500 } , { "70", 0x700 } , { "7.0", 0x700 } , { "80", 0x701 } , { "8.0", 0x701 } , { "7.1", 0x701 } , { "7.2", 0x702 } , { "7.3", 0x703 } , { "7.4", 0x704 } }; const struct tdsvername_t *pver; if (!login) { assert(login); return NULL; } if ((pver = (const struct tdsvername_t *) TDS_FIND(tdsver, tds_versions, tds_vernanme_cmp)) == NULL) { tdsdump_log(TDS_DBG_INFO1, "error: no such version: %s\n", tdsver); return NULL; } login->tds_version = pver->version; tdsdump_log(TDS_DBG_INFO1, "Setting tds version to %s (0x%0x).\n", tdsver, pver->version); return &login->tds_version; } /** * Set the full name of interface file * @param interf file name */ TDSRET tds_set_interfaces_file_loc(const char *interf) { /* Free it if already set */ if (interf_file != NULL) TDS_ZERO_FREE(interf_file); /* If no filename passed, leave it NULL */ if ((interf == NULL) || (interf[0] == '\0')) { return TDS_SUCCESS; } /* Set to new value */ if ((interf_file = strdup(interf)) == NULL) { return TDS_FAIL; } return TDS_SUCCESS; } /** * Get the IP address for a hostname. Store server's IP address * in the string 'ip' in dotted-decimal notation. (The "hostname" might itself * be a dotted-decimal address. * * If we can't determine the IP address then 'ip' will be set to empty * string. */ /* TODO callers seem to set always connection info... change it */ struct addrinfo * tds_lookup_host(const char *servername) /* (I) name of the server */ { struct addrinfo hints, *addr = NULL; assert(servername != NULL); memset(&hints, '\0', sizeof(hints)); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; #ifdef AI_ADDRCONFIG hints.ai_flags |= AI_ADDRCONFIG; #endif if (getaddrinfo(servername, NULL, &hints, &addr)) return NULL; return addr; } TDSRET tds_lookup_host_set(const char *servername, struct addrinfo **addr) { struct addrinfo *newaddr; assert(servername != NULL && addr != NULL); if ((newaddr = tds_lookup_host(servername)) != NULL) { if (*addr != NULL) freeaddrinfo(*addr); *addr = newaddr; return TDS_SUCCESS; } return TDS_FAIL; } /** * Given a portname lookup the port. * * If we can't determine the port number then return 0. */ static int tds_lookup_port(const char *portname) { int num = atoi(portname); if (!num) num = tds_getservice(portname); return num; } /* TODO same code in convert.c ?? */ static int hexdigit(int c) { if (c >= '0' && c <= '9') return c - '0'; /* ascii optimization, 'A' -> 'a', 'a' -> 'a' */ c |= 0x20; if (c >= 'a' && c <= 'f') return c - 'a' + 10; return 0; /* bad hex digit */ } static int hex2num(char *hex) { return hexdigit(hex[0]) * 16 + hexdigit(hex[1]); } /** * Open and read the file 'file' searching for a logical server * by the name of 'host'. If one is found then lookup * the IP address and port number and store them in 'login' * * \param dir name of base directory for interface file * \param file name of the interface file * \param host logical host to search for * \return 0 if not fount 1 if found */ static int search_interface_file(TDSLOGIN * login, const char *dir, const char *file, const char *host) { char *pathname; char line[255]; char tmp_ip[sizeof(line)]; char tmp_port[sizeof(line)]; char tmp_ver[sizeof(line)]; FILE *in; char *field; int found = 0; int server_found = 0; char *lasts; line[0] = '\0'; tmp_ip[0] = '\0'; tmp_port[0] = '\0'; tmp_ver[0] = '\0'; tdsdump_log(TDS_DBG_INFO1, "Searching interfaces file %s/%s.\n", dir, file); pathname = tds_new(char, strlen(dir) + strlen(file) + 10); if (!pathname) return 0; /* * create the full pathname to the interface file */ if (file[0] == '\0') { pathname[0] = '\0'; } else { if (dir[0] == '\0') { pathname[0] = '\0'; } else { strcpy(pathname, dir); strcat(pathname, TDS_SDIR_SEPARATOR); } strcat(pathname, file); } /* * parse the interfaces file and find the server and port */ if ((in = fopen(pathname, "r")) == NULL) { tdsdump_log(TDS_DBG_INFO1, "Couldn't open %s.\n", pathname); free(pathname); return 0; } tdsdump_log(TDS_DBG_INFO1, "Interfaces file %s opened.\n", pathname); while (fgets(line, sizeof(line) - 1, in)) { if (line[0] == '#') continue; /* comment */ if (!TDS_ISSPACE(line[0])) { field = strtok_r(line, "\n\t ", &lasts); if (!strcmp(field, host)) { found = 1; tdsdump_log(TDS_DBG_INFO1, "Found matching entry for host %s.\n", host); } else found = 0; } else if (found && TDS_ISSPACE(line[0])) { field = strtok_r(line, "\n\t ", &lasts); if (field != NULL && !strcmp(field, "query")) { field = strtok_r(NULL, "\n\t ", &lasts); /* tcp or tli */ if (!strcmp(field, "tli")) { tdsdump_log(TDS_DBG_INFO1, "TLI service.\n"); field = strtok_r(NULL, "\n\t ", &lasts); /* tcp */ field = strtok_r(NULL, "\n\t ", &lasts); /* device */ field = strtok_r(NULL, "\n\t ", &lasts); /* host/port */ if (strlen(field) >= 18) { sprintf(tmp_port, "%d", hex2num(&field[6]) * 256 + hex2num(&field[8])); sprintf(tmp_ip, "%d.%d.%d.%d", hex2num(&field[10]), hex2num(&field[12]), hex2num(&field[14]), hex2num(&field[16])); tdsdump_log(TDS_DBG_INFO1, "tmp_port = %s. tmp_ip = %s.\n", tmp_port, tmp_ip); } } else { field = strtok_r(NULL, "\n\t ", &lasts); /* ether */ strcpy(tmp_ver, field); field = strtok_r(NULL, "\n\t ", &lasts); /* host */ strcpy(tmp_ip, field); tdsdump_log(TDS_DBG_INFO1, "host field %s.\n", tmp_ip); field = strtok_r(NULL, "\n\t ", &lasts); /* port */ strcpy(tmp_port, field); } /* else */ server_found = 1; } /* if */ } /* else if */ } /* while */ fclose(in); free(pathname); /* * Look up the host and service */ if (server_found) { if (TDS_SUCCEED(tds_lookup_host_set(tmp_ip, &login->ip_addrs))) { struct addrinfo *addrs; if (!tds_dstr_copy(&login->server_host_name, tmp_ip)) return 0; for (addrs = login->ip_addrs; addrs != NULL; addrs = addrs->ai_next) { tdsdump_log(TDS_DBG_INFO1, "Resolved IP as '%s'.\n", tds_addrinfo2str(login->ip_addrs, line, sizeof(line))); } } else { tdsdump_log(TDS_DBG_WARN, "Name resolution failed for IP '%s'.\n", tmp_ip); } if (tmp_port[0]) login->port = tds_lookup_port(tmp_port); if (tmp_ver[0]) tds_config_verstr(tmp_ver, login); } return server_found; } /* search_interface_file() */ /** * Try to find the IP number and port for a (possibly) logical server name. * * @note This function uses only the interfaces file and is deprecated. */ static int tds_read_interfaces(const char *server, TDSLOGIN * login) { int found = 0; /* read $SYBASE/interfaces */ if (!server || !server[0]) { server = getenv("TDSQUERY"); if (!server || !server[0]) server = "SYBASE"; tdsdump_log(TDS_DBG_INFO1, "Setting server to %s from $TDSQUERY.\n", server); } tdsdump_log(TDS_DBG_INFO1, "Looking for server %s....\n", server); /* * Look for the server in the interf_file iff interf_file has been set. */ if (interf_file) { tdsdump_log(TDS_DBG_INFO1, "Looking for server in file %s.\n", interf_file); found = search_interface_file(login, "", interf_file, server); } /* * if we haven't found the server yet then look for a $HOME/.interfaces file */ if (!found) { char *path = tds_get_home_file(".interfaces"); if (path) { tdsdump_log(TDS_DBG_INFO1, "Looking for server in %s.\n", path); found = search_interface_file(login, "", path, server); free(path); } } /* * if we haven't found the server yet then look in $SYBBASE/interfaces file */ if (!found) { const char *sybase = getenv("SYBASE"); #ifdef __VMS /* We've got to be in unix syntax for later slash-joined concatenation. */ #include const char *unixspec = decc$translate_vms(sybase); if ( (int)unixspec != 0 && (int)unixspec != -1 ) sybase = unixspec; #endif if (!sybase || !sybase[0]) sybase = interfaces_path; tdsdump_log(TDS_DBG_INFO1, "Looking for server in %s/interfaces.\n", sybase); found = search_interface_file(login, sybase, "interfaces", server); } /* * If we still don't have the server and port then assume the user * typed an actual server host name. */ if (!found) { int ip_port; const char *env_port; /* * Make a guess about the port number */ if (login->port == 0) { /* * Not set in the [global] section of the * configure file, take a guess. */ ip_port = TDS_DEF_PORT; } else { /* * Preserve setting from the [global] section * of the configure file. */ ip_port = login->port; } if ((env_port = getenv("TDSPORT")) != NULL) { ip_port = tds_lookup_port(env_port); tdsdump_log(TDS_DBG_INFO1, "Setting 'ip_port' to %s from $TDSPORT.\n", env_port); } else tdsdump_log(TDS_DBG_INFO1, "Setting 'ip_port' to %d as a guess.\n", ip_port); /* * look up the host */ if (TDS_SUCCEED(tds_lookup_host_set(server, &login->ip_addrs))) if (!tds_dstr_copy(&login->server_host_name, server)) return 0; if (ip_port) login->port = ip_port; } return found; } /** * Check the server name to find port info first * Warning: connection-> & login-> are all modified when needed * \return 1 when found, else 0 */ static int parse_server_name_for_port(TDSLOGIN * connection, TDSLOGIN * login) { const char *pSep; const char *server; /* seek the ':' in login server_name */ server = tds_dstr_cstr(&login->server_name); /* IPv6 address can be quoted */ if (server[0] == '[') { pSep = strstr(server, "]:"); if (pSep) ++pSep; } else { pSep = strrchr(server, ':'); } if (pSep && pSep != server) { /* yes, i found it! */ /* modify connection-> && login->server_name & ->port */ login->port = connection->port = atoi(pSep + 1); tds_dstr_empty(&connection->instance_name); } else { /* handle instance name */ pSep = strrchr(server, '\\'); if (!pSep || pSep == server) return 0; if (!tds_dstr_copy(&connection->instance_name, pSep + 1)) return 0; connection->port = 0; } if (!tds_dstr_copyn(&connection->server_name, server, pSep - server)) return 0; return 1; } /** * Return a structure capturing the compile-time settings provided to the * configure script. */ const TDS_COMPILETIME_SETTINGS * tds_get_compiletime_settings(void) { static const TDS_COMPILETIME_SETTINGS settings = { TDS_VERSION_NO , FREETDS_SYSCONFDIR , "unknown" /* need fancy script in makefile */ # ifdef MSDBLIB , 1 # else , 0 # endif # ifdef TDS_SYBASE_COMPAT , 1 # else , 0 # endif # ifdef _REENTRANT , 1 # else , 0 # endif # ifdef HAVE_ICONV , 1 # else , 0 # endif # ifdef TDS42 , "4.2" # elif TDS46 , "4.6" # elif TDS50 , "5.0" # elif TDS70 , "7.0" # elif TDS71 , "7.1" # elif TDS72 , "7.2" # elif TDS73 , "7.3" # elif TDS74 , "7.4" # else , "auto" # endif # ifdef IODBC , 1 # else , 0 # endif # ifdef UNIXODBC , 1 # else , 0 # endif # ifdef HAVE_OPENSSL , 1 # else , 0 # endif # ifdef HAVE_GNUTLS , 1 # else , 0 # endif # if ENABLE_ODBC_MARS , 1 # else , 0 # endif }; assert(settings.tdsver); return &settings; } /** @} */ freetds-1.00.82/src/tds/query.c100644 025423 025423 00000306045 13205236221 0011724/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include #include #include #include #include #include "replacements.h" #include static void tds_put_params(TDSSOCKET * tds, TDSPARAMINFO * info, int flags); static void tds7_put_query_params(TDSSOCKET * tds, const char *query, size_t query_len); static void tds7_put_params_definition(TDSSOCKET * tds, const char *param_definition, size_t param_length); static TDSRET tds_put_data_info(TDSSOCKET * tds, TDSCOLUMN * curcol, int flags); static inline TDSRET tds_put_data(TDSSOCKET * tds, TDSCOLUMN * curcol); static char *tds7_build_param_def_from_query(TDSSOCKET * tds, const char* converted_query, size_t converted_query_len, TDSPARAMINFO * params, size_t *out_len); static char *tds7_build_param_def_from_params(TDSSOCKET * tds, const char* query, size_t query_len, TDSPARAMINFO * params, size_t *out_len); static TDSRET tds_put_param_as_string(TDSSOCKET * tds, TDSPARAMINFO * params, int n); static TDSRET tds_send_emulated_execute(TDSSOCKET * tds, const char *query, TDSPARAMINFO * params); static int tds_count_placeholders_ucs2le(const char *query, const char *query_end); #define TDS_PUT_DATA_USE_NAME 1 #define TDS_PUT_DATA_PREFIX_NAME 2 #define TDS_PUT_DATA_LONG_STATUS 4 #undef MIN #define MIN(a,b) (((a) < (b)) ? (a) : (b)) #undef MAX #define MAX(a,b) (((a) > (b)) ? (a) : (b)) /* All manner of client to server submittal functions */ /** * \ingroup libtds * \defgroup query Query * Function to handle query. */ /** * \addtogroup query * @{ */ /** * Accept an ASCII string, convert it to UCS2-LE * The input is null-terminated, but the output excludes the null. * \param buffer buffer where to store output * \param buf string to write * \return bytes written */ static size_t tds_ascii_to_ucs2(char *buffer, const char *buf) { char *s; assert(buffer && buf && *buf); /* This is an internal function. Call it correctly. */ for (s = buffer; *buf != '\0'; ++buf) { *s++ = *buf; *s++ = '\0'; } return s - buffer; } /** * Utility to convert a constant ascii string to ucs2 and send to server. * Used to send internal store procedure names to server. * \tds * \param s constanst string to send */ #define TDS_PUT_N_AS_UCS2(tds, s) do { \ char buffer[sizeof(s)*2-2]; \ tds_put_smallint(tds, sizeof(buffer)/2); \ tds_put_n(tds, buffer, tds_ascii_to_ucs2(buffer, s)); \ } while(0) /** * Convert a string in an allocated buffer * \param tds state information for the socket and the TDS protocol * \param char_conv information about the encodings involved * \param s input string * \param len input string length (in bytes), -1 for null terminated * \param out_len returned output length (in bytes) * \return string allocated (or input pointer if no conversion required) or NULL if error */ const char * tds_convert_string(TDSSOCKET * tds, TDSICONV * char_conv, const char *s, int len, size_t *out_len) { char *buf; const char *ib; char *ob; size_t il, ol; /* char_conv is only mostly const */ TDS_ERRNO_MESSAGE_FLAGS *suppress = (TDS_ERRNO_MESSAGE_FLAGS*) &char_conv->suppress; CHECK_TDS_EXTRA(tds); il = len < 0 ? strlen(s) : (size_t) len; if (char_conv->flags == TDS_ENCODING_MEMCPY) { *out_len = il; return s; } /* allocate needed buffer (+1 is to exclude 0 case) */ ol = il * char_conv->to.charset.max_bytes_per_char / char_conv->from.charset.min_bytes_per_char + 1; buf = tds_new(char, ol); if (!buf) return NULL; ib = s; ob = buf; memset(suppress, 0, sizeof(char_conv->suppress)); if (tds_iconv(tds, char_conv, to_server, &ib, &il, &ob, &ol) == (size_t)-1) { free(buf); return NULL; } *out_len = ob - buf; return buf; } #if ENABLE_EXTRA_CHECKS void tds_convert_string_free(const char *original, const char *converted) { if (original != converted) free((char *) converted); } #endif /** * Flush query packet. * Used at the end of packet write to really send packet to server. * \tds */ static TDSRET tds_query_flush_packet(TDSSOCKET *tds) { /* TODO depend on result ?? */ tds_set_state(tds, TDS_PENDING); return tds_flush_packet(tds); } /** * Set current dynamic. * \tds * \param dyn dynamic to set */ void tds_set_cur_dyn(TDSSOCKET *tds, TDSDYNAMIC *dyn) { if (dyn) ++dyn->ref_count; tds_release_cur_dyn(tds); tds->cur_dyn = dyn; } /** * tds_submit_query() sends a language string to the database server for * processing. TDS 4.2 is a plain text message with a packet type of 0x01, * TDS 7.0 is a unicode string with packet type 0x01, and TDS 5.0 uses a * TDS_LANGUAGE_TOKEN to encapsulate the query and a packet type of 0x0f. * \tds * \param query language query to submit * \return TDS_FAIL or TDS_SUCCESS */ TDSRET tds_submit_query(TDSSOCKET * tds, const char *query) { return tds_submit_query_params(tds, query, NULL, NULL); } /** * Substitute ?-style placeholders with named (\@param) ones. * Sybase does not support ?-style placeholders so convert them. * Also the function replace parameters names. * \param query query string * \param[in,out] query_len pointer to query length. * On input length of input query, on output length * of output query * \param params parameters to send to server * \returns new query or NULL on error */ static char * tds5_fix_dot_query(const char *query, size_t *query_len, TDSPARAMINFO * params) { int i; size_t len, pos; const char *e, *s; size_t size = *query_len + 30; char colname[32]; char *out; out = tds_new(char, size); if (!out) goto memory_error; pos = 0; s = query; for (i = 0;; ++i) { e = tds_next_placeholder(s); len = e ? e - s : strlen(s); if (pos + len + 12 >= size) { size = pos + len + 30; if (!TDS_RESIZE(out, size)) goto memory_error; } memcpy(out + pos, s, len); pos += len; if (!e) break; pos += sprintf(out + pos, "@P%d", i + 1); if (!params || i >= params->num_cols) goto memory_error; sprintf(colname, "@P%d", i + 1); if (!tds_dstr_copy(¶ms->columns[i]->column_name, colname)) goto memory_error; s = e + 1; } out[pos] = 0; *query_len = pos; return out; memory_error: free(out); return NULL; } /** * Write data to wire * \tds * \param curcol column where store column information * \return TDS_FAIL on error or TDS_SUCCESS */ static inline TDSRET tds_put_data(TDSSOCKET * tds, TDSCOLUMN * curcol) { return curcol->funcs->put_data(tds, curcol, 0); } /** * Start query packet of a given type * \tds * \param packet_type packet type * \param head extra information to put in a TDS7 header */ static TDSRET tds_start_query_head(TDSSOCKET *tds, unsigned char packet_type, TDSHEADERS * head) { tds->out_flag = packet_type; if (IS_TDS72_PLUS(tds->conn)) { int qn_len = 0; const char *converted_msgtext = NULL; const char *converted_options = NULL; size_t converted_msgtext_len = 0; size_t converted_options_len = 0; if (head && head->qn_msgtext && head->qn_options) { converted_msgtext = tds_convert_string(tds, tds->conn->char_convs[client2ucs2], head->qn_msgtext, (int)strlen(head->qn_msgtext), &converted_msgtext_len); if (!converted_msgtext) { tds_set_state(tds, TDS_IDLE); return TDS_FAIL; } converted_options = tds_convert_string(tds, tds->conn->char_convs[client2ucs2], head->qn_options, (int)strlen(head->qn_options), &converted_options_len); if (!converted_options) { tds_convert_string_free(head->qn_msgtext, converted_msgtext); tds_set_state(tds, TDS_IDLE); return TDS_FAIL; } qn_len = 6 + 2 + converted_msgtext_len + 2 + converted_options_len; if (head->qn_timeout != 0) qn_len += 4; } tds_put_int(tds, 4 + 18 + qn_len); /* total length */ tds_put_int(tds, 18); /* length: transaction descriptor */ tds_put_smallint(tds, 2); /* type: transaction descriptor */ tds_put_n(tds, tds->conn->tds72_transaction, 8); /* transaction */ tds_put_int(tds, 1); /* request count */ if (qn_len != 0) { tds_put_int(tds, qn_len); /* length: query notification */ tds_put_smallint(tds, 1); /* type: query notification */ tds_put_smallint(tds, converted_msgtext_len); /* notifyid */ tds_put_n(tds, converted_msgtext, converted_msgtext_len); tds_put_smallint(tds, converted_options_len); /* ssbdeployment */ tds_put_n(tds, converted_options, converted_options_len); if (head->qn_timeout != 0) tds_put_int(tds, head->qn_timeout); /* timeout */ tds_convert_string_free(head->qn_options, converted_options); tds_convert_string_free(head->qn_msgtext, converted_msgtext); } } return TDS_SUCCESS; } /** * Start query packet of a given type * \tds * \param packet_type packet type */ void tds_start_query(TDSSOCKET *tds, unsigned char packet_type) { /* no need to check return value here because tds_start_query_head() cannot fail when given a NULL head parameter */ tds_start_query_head(tds, packet_type, NULL); } /** * tds_submit_query_params() sends a language string to the database server for * processing. TDS 4.2 is a plain text message with a packet type of 0x01, * TDS 7.0 is a unicode string with packet type 0x01, and TDS 5.0 uses a * TDS_LANGUAGE_TOKEN to encapsulate the query and a packet type of 0x0f. * \tds * \param query language query to submit * \param params parameters of query * \return TDS_FAIL or TDS_SUCCESS */ TDSRET tds_submit_query_params(TDSSOCKET * tds, const char *query, TDSPARAMINFO * params, TDSHEADERS * head) { size_t query_len; int num_params = params ? params->num_cols : 0; CHECK_TDS_EXTRA(tds); if (params) CHECK_PARAMINFO_EXTRA(params); if (!query) return TDS_FAIL; if (tds_set_state(tds, TDS_WRITING) != TDS_WRITING) return TDS_FAIL; query_len = strlen(query); if (IS_TDS50(tds->conn)) { char *new_query = NULL; /* are there '?' style parameters ? */ if (tds_next_placeholder(query)) { if ((new_query = tds5_fix_dot_query(query, &query_len, params)) == NULL) { tds_set_state(tds, TDS_IDLE); return TDS_FAIL; } query = new_query; } tds->out_flag = TDS_NORMAL; tds_put_byte(tds, TDS_LANGUAGE_TOKEN); /* TODO ICONV use converted size, not input size and convert string */ TDS_PUT_INT(tds, query_len + 1); tds_put_byte(tds, params ? 1 : 0); /* 1 if there are params, 0 otherwise */ tds_put_n(tds, query, query_len); if (params) { /* add on parameters */ tds_put_params(tds, params, tds_dstr_isempty(¶ms->columns[0]->column_name) ? 0 : TDS_PUT_DATA_USE_NAME); } free(new_query); } else if (!IS_TDS7_PLUS(tds->conn) || !params || !params->num_cols) { if (tds_start_query_head(tds, TDS_QUERY, head) != TDS_SUCCESS) return TDS_FAIL; tds_put_string(tds, query, (int)query_len); } else { TDSCOLUMN *param; size_t definition_len; int count, i; char *param_definition; size_t converted_query_len; const char *converted_query; converted_query = tds_convert_string(tds, tds->conn->char_convs[client2ucs2], query, (int)query_len, &converted_query_len); if (!converted_query) { tds_set_state(tds, TDS_IDLE); return TDS_FAIL; } count = tds_count_placeholders_ucs2le(converted_query, converted_query + converted_query_len); if (!count) { param_definition = tds7_build_param_def_from_params(tds, converted_query, converted_query_len, params, &definition_len); } else { /* * TODO perhaps functions that calls tds7_build_param_def_from_query * should call also tds7_build_param_def_from_params ?? */ param_definition = tds7_build_param_def_from_query(tds, converted_query, converted_query_len, params, &definition_len); } if (!param_definition) { tds_convert_string_free(query, converted_query); tds_set_state(tds, TDS_IDLE); return TDS_FAIL; } if (tds_start_query_head(tds, TDS_RPC, head) != TDS_SUCCESS) { tds_convert_string_free(query, converted_query); free(param_definition); return TDS_FAIL; } /* procedure name */ if (IS_TDS71_PLUS(tds->conn)) { tds_put_smallint(tds, -1); tds_put_smallint(tds, TDS_SP_EXECUTESQL); } else { TDS_PUT_N_AS_UCS2(tds, "sp_executesql"); } tds_put_smallint(tds, 0); /* string with sql statement */ if (!count) { tds_put_byte(tds, 0); tds_put_byte(tds, 0); tds_put_byte(tds, SYBNTEXT); /* must be Ntype */ TDS_PUT_INT(tds, converted_query_len); if (IS_TDS71_PLUS(tds->conn)) tds_put_n(tds, tds->conn->collation, 5); TDS_PUT_INT(tds, converted_query_len); tds_put_n(tds, converted_query, converted_query_len); } else { tds7_put_query_params(tds, converted_query, converted_query_len); } tds_convert_string_free(query, converted_query); tds7_put_params_definition(tds, param_definition, definition_len); free(param_definition); for (i = 0; i < num_params; i++) { param = params->columns[i]; /* TODO check error */ tds_put_data_info(tds, param, 0); if (tds_put_data(tds, param) != TDS_SUCCESS) return TDS_FAIL; } tds->current_op = TDS_OP_EXECUTESQL; } return tds_query_flush_packet(tds); } /** * Format and submit a query * \tds * \param queryf query format. printf like expansion is performed on * this query. */ TDSRET tds_submit_queryf(TDSSOCKET * tds, const char *queryf, ...) { va_list ap; char *query = NULL; TDSRET rc = TDS_FAIL; CHECK_TDS_EXTRA(tds); va_start(ap, queryf); if (vasprintf(&query, queryf, ap) >= 0) { rc = tds_submit_query(tds, query); free(query); } va_end(ap); return rc; } /** * Skip a comment in a query * \param s start of the string (or part of it) * \returns pointer to end of comment */ const char * tds_skip_comment(const char *s) { const char *p = s; if (*p == '-' && p[1] == '-') { for (;*++p != '\0';) if (*p == '\n') return p; } else if (*p == '/' && p[1] == '*') { ++p; for(;*++p != '\0';) if (*p == '*' && p[1] == '/') return p + 2; } else ++p; return p; } /** * Skip quoting string (like 'sfsf', "dflkdj" or [dfkjd]) * \param s pointer to first quoting character. @verbatim Should be ', " or [. @endverbatim * \return character after quoting */ const char * tds_skip_quoted(const char *s) { const char *p = s; char quote = (*s == '[') ? ']' : *s; for (; *++p;) { if (*p == quote) { if (*++p != quote) return p; } } return p; } /** * Get position of next placeholder * \param start pointer to part of query to search * \return next placeholder or NULL if not found */ const char * tds_next_placeholder(const char *start) { const char *p = start; if (!p) return NULL; for (;;) { switch (*p) { case '\0': return NULL; case '\'': case '\"': case '[': p = tds_skip_quoted(p); break; case '-': case '/': p = tds_skip_comment(p); break; case '?': return p; default: ++p; break; } } } /** * Count the number of placeholders in query * \param query query string */ int tds_count_placeholders(const char *query) { const char *p = query - 1; int count = 0; for (;; ++count) { if (!(p = tds_next_placeholder(p + 1))) return count; } } /** * Skip a comment in a query * \param s start of the string (or part of it). Encoded in ucs2 * \param end end of string * \returns pointer to end of comment */ static const char * tds_skip_comment_ucs2le(const char *s, const char *end) { const char *p = s; if (p+4 <= end && memcmp(p, "-\0-", 4) == 0) { for (;(p+=2) < end;) if (p[0] == '\n' && p[1] == 0) return p + 2; } else if (p+4 <= end && memcmp(p, "/\0*", 4) == 0) { p += 2; end -= 2; for(;(p+=2) < end;) if (memcmp(p, "*\0/", 4) == 0) return p + 4; } else p += 2; return p; } /** * Return pointer to end of a quoted string. * At the beginning pointer should point to delimiter. * \param s start of string to skip encoded in ucs2 * \param end pointer to end of string */ static const char * tds_skip_quoted_ucs2le(const char *s, const char *end) { const char *p = s; char quote = (*s == '[') ? ']' : *s; assert(s[1] == 0 && s < end && (end - s) % 2 == 0); for (; (p += 2) != end;) { if (p[0] == quote && !p[1]) { p += 2; if (p == end || p[0] != quote || p[1]) return p; } } return p; } /** * Found the next placeholder (? or \@param) in a string. * String must be encoded in ucs2. * \param start start of the string (or part of it) * \param end end of string * \param named true if named parameters should be returned * \returns either start of next placeholder or end if not found */ static const char * tds_next_placeholder_ucs2le(const char *start, const char *end, int named) { const char *p = start; char prev = ' ', c; assert(p && start <= end && (end - start) % 2 == 0); for (; p != end;) { if (p[1]) { prev = ' '; p += 2; continue; } c = p[0]; switch (c) { case '\'': case '\"': case '[': p = tds_skip_quoted_ucs2le(p, end); break; case '-': case '/': p = tds_skip_comment_ucs2le(p, end); c = ' '; break; case '?': return p; case '@': if (named && !isalnum((unsigned char) prev)) return p; default: p += 2; break; } prev = c; } return end; } /** * Count number of placeholders (?) in a query * \param query query encoded in ucs2 * \param query_end end of query * \return number of placeholders found */ static int tds_count_placeholders_ucs2le(const char *query, const char *query_end) { const char *p = query - 2; int count = 0; for (;; ++count) { if ((p = tds_next_placeholder_ucs2le(p + 2, query_end, 0)) == query_end) return count; } } /** * Return declaration for column (like "varchar(20)") * \tds * \param curcol column * \param out buffer to hold declaration * \return TDS_FAIL or TDS_SUCCESS */ TDSRET tds_get_column_declaration(TDSSOCKET * tds, TDSCOLUMN * curcol, char *out) { const char *fmt = NULL; /* unsigned int is required by printf format, don't use size_t */ unsigned int max_len = IS_TDS7_PLUS(tds->conn) ? 8000 : 255; unsigned int size; CHECK_TDS_EXTRA(tds); CHECK_COLUMN_EXTRA(curcol); size = tds_fix_column_size(tds, curcol); switch (tds_get_conversion_type(curcol->on_server.column_type, curcol->on_server.column_size)) { case XSYBCHAR: case SYBCHAR: fmt = "CHAR(%u)"; break; case SYBVARCHAR: case XSYBVARCHAR: if (curcol->column_varint_size == 8) fmt = "VARCHAR(MAX)"; else fmt = "VARCHAR(%u)"; break; case SYBUINT1: case SYBINT1: fmt = "TINYINT"; break; case SYBINT2: fmt = "SMALLINT"; break; case SYBINT4: fmt = "INT"; break; case SYBINT8: /* TODO even for Sybase ?? */ fmt = "BIGINT"; break; case SYBFLT8: fmt = "FLOAT"; break; case SYBDATETIME: fmt = "DATETIME"; break; case SYBDATE: fmt = "DATE"; break; case SYBTIME: fmt = "TIME"; break; case SYBBIT: fmt = "BIT"; break; case SYBTEXT: fmt = "TEXT"; break; case SYBLONGBINARY: /* TODO correct ?? */ case SYBIMAGE: fmt = "IMAGE"; break; case SYBMONEY4: fmt = "SMALLMONEY"; break; case SYBMONEY: fmt = "MONEY"; break; case SYBDATETIME4: fmt = "SMALLDATETIME"; break; case SYBREAL: fmt = "REAL"; break; case SYBBINARY: case XSYBBINARY: fmt = "BINARY(%u)"; break; case SYBVARBINARY: case XSYBVARBINARY: if (curcol->column_varint_size == 8) fmt = "VARBINARY(MAX)"; else fmt = "VARBINARY(%u)"; break; case SYBNUMERIC: fmt = "NUMERIC(%d,%d)"; goto numeric_decimal; case SYBDECIMAL: fmt = "DECIMAL(%d,%d)"; numeric_decimal: sprintf(out, fmt, curcol->column_prec, curcol->column_scale); return TDS_SUCCESS; break; case SYBUNIQUE: if (IS_TDS7_PLUS(tds->conn)) fmt = "UNIQUEIDENTIFIER"; break; case SYBNTEXT: if (IS_TDS7_PLUS(tds->conn)) fmt = "NTEXT"; break; case SYBNVARCHAR: case XSYBNVARCHAR: if (curcol->column_varint_size == 8) { fmt = "NVARCHAR(MAX)"; } else if (IS_TDS7_PLUS(tds->conn)) { fmt = "NVARCHAR(%u)"; max_len = 4000; size /= 2u; } break; case XSYBNCHAR: if (IS_TDS7_PLUS(tds->conn)) { fmt = "NCHAR(%u)"; max_len = 4000; size /= 2u; } break; case SYBVARIANT: if (IS_TDS7_PLUS(tds->conn)) fmt = "SQL_VARIANT"; break; /* TODO support scale !! */ case SYBMSTIME: fmt = "TIME"; break; case SYBMSDATE: fmt = "DATE"; break; case SYBMSDATETIME2: fmt = "DATETIME2"; break; case SYBMSDATETIMEOFFSET: fmt = "DATETIMEOFFSET"; break; case SYB5BIGTIME: fmt = "BIGTIME"; break; case SYB5BIGDATETIME: fmt = "BIGDATETIME"; break; case SYBUINT2: fmt = "UNSIGNED SMALLINT"; break; case SYBUINT4: fmt = "UNSIGNED INT"; break; case SYBUINT8: fmt = "UNSIGNED BIGINT"; break; /* nullable types should not occur here... */ case SYBFLTN: case SYBMONEYN: case SYBDATETIMN: case SYBBITN: case SYBINTN: assert(0); /* TODO... */ case SYBVOID: case SYBSINT1: default: tdsdump_log(TDS_DBG_ERROR, "Unknown type %d\n", tds_get_conversion_type(curcol->on_server.column_type, curcol->on_server.column_size)); break; } if (fmt) { /* fill out */ sprintf(out, fmt, size > 0 ? (size > max_len ? max_len : size) : 1u); return TDS_SUCCESS; } out[0] = 0; return TDS_FAIL; } /** * Return string with parameters definition, useful for TDS7+ * Looks like "@P1 INT, @P2 VARCHAR(100)" * \param tds state information for the socket and the TDS protocol * \param converted_query query to send to server in ucs2 encoding * \param converted_query_len query length in bytes * \param params parameters to build declaration * \param out_len length output buffer in bytes * \return allocated and filled string or NULL on failure (coded in ucs2le charset ) */ /* TODO find a better name for this function */ static char * tds7_build_param_def_from_query(TDSSOCKET * tds, const char* converted_query, size_t converted_query_len, TDSPARAMINFO * params, size_t *out_len) { size_t len = 0, size = 512; char *param_str; char declaration[40]; int i, count; assert(IS_TDS7_PLUS(tds->conn)); assert(out_len); CHECK_TDS_EXTRA(tds); if (params) CHECK_PARAMINFO_EXTRA(params); count = tds_count_placeholders_ucs2le(converted_query, converted_query + converted_query_len); param_str = tds_new(char, 512); if (!param_str) return NULL; for (i = 0; i < count; ++i) { if (len > 0u) { param_str[len++] = ','; param_str[len++] = 0; } /* realloc on insufficient space */ while ((len + (2u * sizeof(declaration))) > size) { size += 512u; if (!TDS_RESIZE(param_str, size)) goto Cleanup; } /* get this parameter declaration */ sprintf(declaration, "@P%d ", i+1); if (params && i < params->num_cols) { if (TDS_FAILED(tds_get_column_declaration(tds, params->columns[i], declaration + strlen(declaration)))) goto Cleanup; } else { strcat(declaration, "varchar(4000)"); } /* convert it to ucs2 and append */ len += tds_ascii_to_ucs2(param_str + len, declaration); } *out_len = len; return param_str; Cleanup: free(param_str); return NULL; } /** * Return string with parameters definition, useful for TDS7+ * \param tds state information for the socket and the TDS protocol * \param query query to send to server encoded as ucs2 * \param query_len query length in bytes * \param params parameters to build declaration * \param out_len length output buffer in bytes * \return allocated and filled string or NULL on failure (coded in ucs2le charset ) */ /* TODO find a better name for this function */ static char * tds7_build_param_def_from_params(TDSSOCKET * tds, const char* query, size_t query_len, TDSPARAMINFO * params, size_t *out_len) { size_t size = 512; char *param_str; char declaration[40]; size_t l = 0; int i; struct tds_ids { const char *p; size_t len; } *ids = NULL; assert(IS_TDS7_PLUS(tds->conn)); assert(out_len); CHECK_TDS_EXTRA(tds); if (params) CHECK_PARAMINFO_EXTRA(params); param_str = tds_new(char, 512); if (!param_str) goto Cleanup; if (!params || !params->num_cols) goto no_params; /* try to detect missing names */ ids = tds_new0(struct tds_ids, params->num_cols); if (!ids) goto Cleanup; if (tds_dstr_isempty(¶ms->columns[0]->column_name)) { const char *s = query, *e, *id_end; const char *query_end = query + query_len; for (i = 0; i < params->num_cols; s = e + 2) { e = tds_next_placeholder_ucs2le(s, query_end, 1); if (e == query_end) break; if (e[0] != '@') continue; /* find end of param name */ for (id_end = e + 2; id_end != query_end; id_end += 2) if (!id_end[1] && (id_end[0] != '_' && id_end[1] != '#' && !isalnum((unsigned char) id_end[0]))) break; ids[i].p = e; ids[i].len = id_end - e; ++i; } } for (i = 0; i < params->num_cols; ++i) { const char *ib; char *ob; size_t il, ol; if (l > 0u) { param_str[l++] = ','; param_str[l++] = 0; } /* realloc on insufficient space */ il = ids[i].p ? ids[i].len : 2 * tds_dstr_len(¶ms->columns[i]->column_name); while ((l + (2u * sizeof(declaration)) + il) > size) { size += 512u; if (!TDS_RESIZE(param_str, size)) goto Cleanup; } /* this part of buffer can be not-ascii compatible, use all ucs2... */ if (ids[i].p) { memcpy(param_str + l, ids[i].p, ids[i].len); l += ids[i].len; } else { ib = tds_dstr_cstr(¶ms->columns[i]->column_name); il = tds_dstr_len(¶ms->columns[i]->column_name); ob = param_str + l; ol = size - l; memset(&tds->conn->char_convs[client2ucs2]->suppress, 0, sizeof(tds->conn->char_convs[client2ucs2]->suppress)); if (tds_iconv(tds, tds->conn->char_convs[client2ucs2], to_server, &ib, &il, &ob, &ol) == (size_t) - 1) goto Cleanup; l = size - ol; } param_str[l++] = ' '; param_str[l++] = 0; /* get this parameter declaration */ tds_get_column_declaration(tds, params->columns[i], declaration); if (!declaration[0]) goto Cleanup; /* convert it to ucs2 and append */ l += tds_ascii_to_ucs2(param_str + l, declaration); } free(ids); no_params: *out_len = l; return param_str; Cleanup: free(ids); free(param_str); return NULL; } /** * Output params types and query (required by sp_prepare/sp_executesql/sp_prepexec) * \param tds state information for the socket and the TDS protocol * \param query query (in ucs2le codings) * \param query_len query length in bytes */ static void tds7_put_query_params(TDSSOCKET * tds, const char *query, size_t query_len) { size_t len; int i, num_placeholders; const char *s, *e; char buf[24]; const char *const query_end = query + query_len; CHECK_TDS_EXTRA(tds); assert(IS_TDS7_PLUS(tds->conn)); /* we use all "@PX" for parameters */ num_placeholders = tds_count_placeholders_ucs2le(query, query_end); len = num_placeholders * 2; /* adjust for the length of X */ for (i = 10; i <= num_placeholders; i *= 10) { len += num_placeholders - i + 1; } /* string with sql statement */ /* replace placeholders with dummy parametes */ tds_put_byte(tds, 0); tds_put_byte(tds, 0); tds_put_byte(tds, SYBNTEXT); /* must be Ntype */ len = 2u * len + query_len; TDS_PUT_INT(tds, len); if (IS_TDS71_PLUS(tds->conn)) tds_put_n(tds, tds->conn->collation, 5); TDS_PUT_INT(tds, len); s = query; /* TODO do a test with "...?" and "...?)" */ for (i = 1;; ++i) { e = tds_next_placeholder_ucs2le(s, query_end, 0); assert(e && query <= e && e <= query_end); tds_put_n(tds, s, e - s); if (e == query_end) break; sprintf(buf, "@P%d", i); tds_put_string(tds, buf, -1); s = e + 2; } } /** * Send parameter definition to server * \tds * \param param_definition parameter definition string. Encoded in ucs2 * \param param_length parameter definition string length in bytes */ static void tds7_put_params_definition(TDSSOCKET * tds, const char *param_definition, size_t param_length) { CHECK_TDS_EXTRA(tds); /* string with parameters types */ tds_put_byte(tds, 0); tds_put_byte(tds, 0); tds_put_byte(tds, SYBNTEXT); /* must be Ntype */ /* put parameters definitions */ TDS_PUT_INT(tds, param_length); if (IS_TDS71_PLUS(tds->conn)) tds_put_n(tds, tds->conn->collation, 5); TDS_PUT_INT(tds, param_length ? param_length : -1); tds_put_n(tds, param_definition, param_length); } /** * tds_submit_prepare() creates a temporary stored procedure in the server. * Under TDS 4.2 dynamic statements are emulated building sql command * \param tds state information for the socket and the TDS protocol * \param query language query with given placeholders (?) * \param id string to identify the dynamic query. Pass NULL for automatic generation. * \param dyn_out will receive allocated TDSDYNAMIC*. Any older allocated dynamic won't be freed, Can be NULL. * \param params parameters to use. It can be NULL even if parameters are present. Used only for TDS7+ * \return TDS_FAIL or TDS_SUCCESS */ /* TODO parse all results ?? */ TDSRET tds_submit_prepare(TDSSOCKET * tds, const char *query, const char *id, TDSDYNAMIC ** dyn_out, TDSPARAMINFO * params) { int id_len, query_len; TDSRET rc = TDS_FAIL; TDSDYNAMIC *dyn; CHECK_TDS_EXTRA(tds); if (params) CHECK_PARAMINFO_EXTRA(params); if (!query || !dyn_out) return TDS_FAIL; if (tds_set_state(tds, TDS_WRITING) != TDS_WRITING) return TDS_FAIL; /* allocate a structure for this thing */ dyn = tds_alloc_dynamic(tds->conn, id); if (!dyn) return TDS_FAIL; tds_release_dynamic(dyn_out); *dyn_out = dyn; tds_release_cur_dyn(tds); /* TDS5 sometimes cannot accept prepare so we need to store query */ if (!IS_TDS7_PLUS(tds->conn)) { dyn->query = strdup(query); if (!dyn->query) goto failure; } if (!IS_TDS50(tds->conn) && !IS_TDS7_PLUS(tds->conn)) { dyn->emulated = 1; tds_dynamic_deallocated(tds->conn, dyn); tds_set_state(tds, TDS_IDLE); return TDS_SUCCESS; } query_len = (int)strlen(query); tds_set_cur_dyn(tds, dyn); if (IS_TDS7_PLUS(tds->conn)) { size_t definition_len = 0; char *param_definition = NULL; size_t converted_query_len; const char *converted_query; converted_query = tds_convert_string(tds, tds->conn->char_convs[client2ucs2], query, query_len, &converted_query_len); if (!converted_query) goto failure; param_definition = tds7_build_param_def_from_query(tds, converted_query, converted_query_len, params, &definition_len); if (!param_definition) { tds_convert_string_free(query, converted_query); goto failure; } tds_start_query(tds, TDS_RPC); /* procedure name */ if (IS_TDS71_PLUS(tds->conn)) { tds_put_smallint(tds, -1); tds_put_smallint(tds, TDS_SP_PREPARE); } else { TDS_PUT_N_AS_UCS2(tds, "sp_prepare"); } tds_put_smallint(tds, 0); /* return param handle (int) */ tds_put_byte(tds, 0); tds_put_byte(tds, 1); /* result */ tds_put_byte(tds, SYBINTN); tds_put_byte(tds, 4); tds_put_byte(tds, 0); tds7_put_params_definition(tds, param_definition, definition_len); tds7_put_query_params(tds, converted_query, converted_query_len); tds_convert_string_free(query, converted_query); free(param_definition); /* 1 param ?? why ? flags ?? */ tds_put_byte(tds, 0); tds_put_byte(tds, 0); tds_put_byte(tds, SYBINTN); tds_put_byte(tds, 4); tds_put_byte(tds, 4); tds_put_int(tds, 1); tds->current_op = TDS_OP_PREPARE; } else { int dynproc_capability = tds_capability_has_req(tds->conn, TDS_REQ_PROTO_DYNPROC); unsigned toklen; tds->out_flag = TDS_NORMAL; id_len = (int)strlen(dyn->id); tds_put_byte(tds, TDS5_DYNAMIC_TOKEN); toklen = 5 + id_len + query_len; if (dynproc_capability) toklen += id_len + 16; tds_put_smallint(tds, toklen); tds_put_byte(tds, TDS_DYN_PREPARE); tds_put_byte(tds, 0x00); tds_put_byte(tds, id_len); tds_put_n(tds, dyn->id, id_len); /* TODO ICONV convert string, do not put with tds_put_n */ /* TODO how to pass parameters type? like store procedures ? */ if (dynproc_capability) { tds_put_smallint(tds, query_len + id_len + 16); tds_put_n(tds, "create proc ", 12); tds_put_n(tds, dyn->id, id_len); tds_put_n(tds, " as ", 4); } else { tds_put_smallint(tds, query_len); } tds_put_n(tds, query, query_len); } rc = tds_query_flush_packet(tds); if (TDS_SUCCEED(rc)) return rc; failure: /* TODO correct if writing fail ?? */ tds_set_state(tds, TDS_IDLE); tds_release_dynamic(dyn_out); tds_dynamic_deallocated(tds->conn, dyn); return rc; } /** * Submit a prepared query with parameters * \param tds state information for the socket and the TDS protocol * \param query language query with given placeholders (?) * \param params parameters to send * \return TDS_FAIL or TDS_SUCCESS */ TDSRET tds_submit_execdirect(TDSSOCKET * tds, const char *query, TDSPARAMINFO * params, TDSHEADERS * head) { size_t query_len; TDSCOLUMN *param; TDSDYNAMIC *dyn; size_t id_len; CHECK_TDS_EXTRA(tds); CHECK_PARAMINFO_EXTRA(params); if (!query) return TDS_FAIL; query_len = strlen(query); if (IS_TDS7_PLUS(tds->conn)) { size_t definition_len = 0; int i; char *param_definition = NULL; size_t converted_query_len; const char *converted_query; if (tds_set_state(tds, TDS_WRITING) != TDS_WRITING) return TDS_FAIL; converted_query = tds_convert_string(tds, tds->conn->char_convs[client2ucs2], query, (int)query_len, &converted_query_len); if (!converted_query) { tds_set_state(tds, TDS_IDLE); return TDS_FAIL; } param_definition = tds7_build_param_def_from_query(tds, converted_query, converted_query_len, params, &definition_len); if (!param_definition) { tds_convert_string_free(query, converted_query); tds_set_state(tds, TDS_IDLE); return TDS_FAIL; } if (tds_start_query_head(tds, TDS_RPC, head) != TDS_SUCCESS) { tds_convert_string_free(query, converted_query); free(param_definition); return TDS_FAIL; } /* procedure name */ if (IS_TDS71_PLUS(tds->conn)) { tds_put_smallint(tds, -1); tds_put_smallint(tds, TDS_SP_EXECUTESQL); } else { TDS_PUT_N_AS_UCS2(tds, "sp_executesql"); } tds_put_smallint(tds, 0); tds7_put_query_params(tds, converted_query, converted_query_len); tds7_put_params_definition(tds, param_definition, definition_len); tds_convert_string_free(query, converted_query); free(param_definition); for (i = 0; i < params->num_cols; i++) { TDSRET ret; param = params->columns[i]; /* TODO check error */ tds_put_data_info(tds, param, 0); ret = tds_put_data(tds, param); if (TDS_FAILED(ret)) return ret; } tds->current_op = TDS_OP_EXECUTESQL; return tds_query_flush_packet(tds); } /* allocate a structure for this thing */ dyn = tds_alloc_dynamic(tds->conn, NULL); if (!dyn) return TDS_FAIL; /* check if no parameters */ if (params && !params->num_cols) params = NULL; /* TDS 4.2, emulate prepared statements */ /* * TODO Sybase seems to not support parameters in prepared execdirect * so use language or prepare and then exec */ if (!IS_TDS50(tds->conn) || params) { TDSRET ret = TDS_SUCCESS; if (!params) { ret = tds_submit_query(tds, query); } else { dyn->emulated = 1; dyn->params = params; dyn->query = strdup(query); if (!dyn->query) ret = TDS_FAIL; if (TDS_SUCCEED(ret)) if (tds_set_state(tds, TDS_WRITING) != TDS_WRITING) ret = TDS_FAIL; if (TDS_SUCCEED(ret)) { ret = tds_send_emulated_execute(tds, dyn->query, dyn->params); if (TDS_SUCCEED(ret)) ret = tds_query_flush_packet(tds); } /* do not free our parameters */ dyn->params = NULL; } tds_dynamic_deallocated(tds->conn, dyn); tds_release_dynamic(&dyn); return ret; } tds_release_cur_dyn(tds); tds->cur_dyn = dyn; if (tds_set_state(tds, TDS_WRITING) != TDS_WRITING) return TDS_FAIL; tds->out_flag = TDS_NORMAL; id_len = strlen(dyn->id); tds_put_byte(tds, TDS5_DYNAMIC_TOKEN); TDS_PUT_SMALLINT(tds, query_len + id_len * 2 + 21); tds_put_byte(tds, TDS_DYN_EXEC_IMMED); tds_put_byte(tds, params ? 0x01 : 0); TDS_PUT_BYTE(tds, id_len); tds_put_n(tds, dyn->id, id_len); /* TODO ICONV convert string, do not put with tds_put_n */ /* TODO how to pass parameters type? like store procedures ? */ TDS_PUT_SMALLINT(tds, query_len + id_len + 16); tds_put_n(tds, "create proc ", 12); tds_put_n(tds, dyn->id, (int)id_len); tds_put_n(tds, " as ", 4); tds_put_n(tds, query, (int)query_len); if (params) tds_put_params(tds, params, 0); return tds_flush_packet(tds); } /** * tds71_submit_prepexec() creates a temporary stored procedure in the server. * \param tds state information for the socket and the TDS protocol * \param query language query with given placeholders (?) * \param id string to identify the dynamic query. Pass NULL for automatic generation. * \param dyn_out will receive allocated TDSDYNAMIC*. Any older allocated dynamic won't be freed, Can be NULL. * \param params parameters to use. It can be NULL even if parameters are present. Used only for TDS7+ * \return TDS_FAIL or TDS_SUCCESS */ TDSRET tds71_submit_prepexec(TDSSOCKET * tds, const char *query, const char *id, TDSDYNAMIC ** dyn_out, TDSPARAMINFO * params) { int query_len; TDSRET rc = TDS_FAIL; TDSDYNAMIC *dyn; size_t definition_len = 0; char *param_definition = NULL; size_t converted_query_len; const char *converted_query; CHECK_TDS_EXTRA(tds); if (params) CHECK_PARAMINFO_EXTRA(params); if (!query || !dyn_out || !IS_TDS7_PLUS(tds->conn)) return TDS_FAIL; if (tds_set_state(tds, TDS_WRITING) != TDS_WRITING) return TDS_FAIL; /* allocate a structure for this thing */ dyn = tds_alloc_dynamic(tds->conn, id); if (!dyn) return TDS_FAIL; tds_release_dynamic(dyn_out); *dyn_out = dyn; tds_set_cur_dyn(tds, dyn); query_len = (int)strlen(query); converted_query = tds_convert_string(tds, tds->conn->char_convs[client2ucs2], query, query_len, &converted_query_len); if (!converted_query) goto failure; param_definition = tds7_build_param_def_from_query(tds, converted_query, converted_query_len, params, &definition_len); if (!param_definition) { tds_convert_string_free(query, converted_query); goto failure; } tds_start_query(tds, TDS_RPC); /* procedure name */ if (IS_TDS71_PLUS(tds->conn)) { tds_put_smallint(tds, -1); tds_put_smallint(tds, TDS_SP_PREPEXEC); } else { TDS_PUT_N_AS_UCS2(tds, "sp_prepexec"); } tds_put_smallint(tds, 0); /* return param handle (int) */ tds_put_byte(tds, 0); tds_put_byte(tds, 1); /* result */ tds_put_byte(tds, SYBINTN); tds_put_byte(tds, 4); tds_put_byte(tds, 0); tds7_put_params_definition(tds, param_definition, definition_len); tds7_put_query_params(tds, converted_query, converted_query_len); tds_convert_string_free(query, converted_query); free(param_definition); if (params) { int i; for (i = 0; i < params->num_cols; i++) { TDSCOLUMN *param = params->columns[i]; /* TODO check error */ tds_put_data_info(tds, param, 0); rc = tds_put_data(tds, param); if (TDS_FAILED(rc)) return rc; } } tds->current_op = TDS_OP_PREPEXEC; rc = tds_query_flush_packet(tds); if (TDS_SUCCEED(rc)) return rc; failure: /* TODO correct if writing fail ?? */ tds_set_state(tds, TDS_IDLE); tds_release_dynamic(dyn_out); tds_dynamic_deallocated(tds->conn, dyn); return rc; } /** * Get column size for wire */ size_t tds_fix_column_size(TDSSOCKET * tds, TDSCOLUMN * curcol) { size_t size = curcol->on_server.column_size, min; if (!size) { size = curcol->column_size; if (is_unicode_type(curcol->on_server.column_type)) size *= 2u; } switch (curcol->column_varint_size) { case 1: size = MAX(MIN(size, 255), 1); break; case 2: /* note that varchar(max)/varbinary(max) have a varint of 8 */ if (curcol->on_server.column_type == XSYBNVARCHAR || curcol->on_server.column_type == XSYBNCHAR) min = 2; else min = 1; size = MAX(MIN(size, 8000u), min); break; case 4: if (curcol->on_server.column_type == SYBNTEXT) size = 0x7ffffffeu; else size = 0x7fffffffu; break; default: break; } return size; } /** * Put data information to wire * \param tds state information for the socket and the TDS protocol * \param curcol column where to store information * \param flags bit flags on how to send data (use TDS_PUT_DATA_USE_NAME for use name information) * \return TDS_SUCCESS or TDS_FAIL */ static TDSRET tds_put_data_info(TDSSOCKET * tds, TDSCOLUMN * curcol, int flags) { int len; CHECK_TDS_EXTRA(tds); CHECK_COLUMN_EXTRA(curcol); if (flags & TDS_PUT_DATA_USE_NAME) { len = tds_dstr_len(&curcol->column_name); tdsdump_log(TDS_DBG_ERROR, "tds_put_data_info putting param_name \n"); if (IS_TDS7_PLUS(tds->conn)) { size_t converted_param_len; const char *converted_param; /* TODO use a fixed buffer to avoid error ? */ converted_param = tds_convert_string(tds, tds->conn->char_convs[client2ucs2], tds_dstr_cstr(&curcol->column_name), len, &converted_param_len); if (!converted_param) return TDS_FAIL; if (!(flags & TDS_PUT_DATA_PREFIX_NAME)) { TDS_PUT_BYTE(tds, converted_param_len / 2); } else { TDS_PUT_BYTE(tds, converted_param_len / 2 + 1); tds_put_n(tds, "@", 2); } tds_put_n(tds, converted_param, converted_param_len); tds_convert_string_free(tds_dstr_cstr(&curcol->column_name), converted_param); } else { /* TODO ICONV convert */ tds_put_byte(tds, len); /* param name len */ tds_put_n(tds, tds_dstr_cstr(&curcol->column_name), len); } } else { tds_put_byte(tds, 0x00); /* param name len */ } /* * TODO support other flags (use defaul null/no metadata) * bit 1 (2 as flag) in TDS7+ is "default value" bit * (what's the meaning of "default value" ?) */ tdsdump_log(TDS_DBG_ERROR, "tds_put_data_info putting status \n"); if (flags & TDS_PUT_DATA_LONG_STATUS) tds_put_int(tds, curcol->column_output); /* status (input) */ else tds_put_byte(tds, curcol->column_output); /* status (input) */ if (!IS_TDS7_PLUS(tds->conn)) tds_put_int(tds, curcol->column_usertype); /* usertype */ tds_put_byte(tds, curcol->on_server.column_type); if (curcol->funcs->put_info(tds, curcol) != TDS_SUCCESS) return TDS_FAIL; /* TODO needed in TDS4.2 ?? now is called only if TDS >= 5 */ if (!IS_TDS7_PLUS(tds->conn)) tds_put_byte(tds, 0x00); /* locale info length */ return TDS_SUCCESS; } /** * Calc information length in bytes (useful for calculating full packet length) * \param tds state information for the socket and the TDS protocol * \param curcol column where to store information * \param flags bit flags on how to send data (use TDS_PUT_DATA_USE_NAME for use name information) * \return data info length */ static int tds_put_data_info_length(TDSSOCKET * tds, TDSCOLUMN * curcol, int flags) { int len = 8; CHECK_TDS_EXTRA(tds); CHECK_COLUMN_EXTRA(curcol); #if ENABLE_EXTRA_CHECKS if (IS_TDS7_PLUS(tds->conn)) tdsdump_log(TDS_DBG_ERROR, "tds_put_data_info_length called with TDS7+\n"); #endif /* TODO ICONV convert string if needed (see also tds_put_data_info) */ if (flags & TDS_PUT_DATA_USE_NAME) len += tds_dstr_len(&curcol->column_name); return len + curcol->funcs->put_info_len(tds, curcol); } /** * Send dynamic request on TDS 7+ to be executed * \tds * \param dyn dynamic query to execute */ static void tds7_send_execute(TDSSOCKET * tds, TDSDYNAMIC * dyn) { TDSCOLUMN *param; TDSPARAMINFO *info; int i; /* procedure name */ /* NOTE do not call this procedure using integer name (TDS_SP_EXECUTE) on mssql2k, it doesn't work! */ TDS_PUT_N_AS_UCS2(tds, "sp_execute"); tds_put_smallint(tds, 0); /* flags */ /* id of prepared statement */ tds_put_byte(tds, 0); tds_put_byte(tds, 0); tds_put_byte(tds, SYBINTN); tds_put_byte(tds, 4); tds_put_byte(tds, 4); tds_put_int(tds, dyn->num_id); info = dyn->params; if (info) for (i = 0; i < info->num_cols; i++) { param = info->columns[i]; /* TODO check error */ tds_put_data_info(tds, param, 0); /* FIXME handle error */ tds_put_data(tds, param); } tds->current_op = TDS_OP_EXECUTE; } /** * tds_submit_execute() sends a previously prepared dynamic statement to the * server. * \param tds state information for the socket and the TDS protocol * \param dyn dynamic proc to execute. Must build from same tds. */ TDSRET tds_submit_execute(TDSSOCKET * tds, TDSDYNAMIC * dyn) { int id_len; CHECK_TDS_EXTRA(tds); /* TODO this dynamic should be in tds */ CHECK_DYNAMIC_EXTRA(dyn); tdsdump_log(TDS_DBG_FUNC, "tds_submit_execute()\n"); if (tds_set_state(tds, TDS_WRITING) != TDS_WRITING) return TDS_FAIL; tds_set_cur_dyn(tds, dyn); if (IS_TDS7_PLUS(tds->conn)) { /* check proper id */ if (dyn->num_id == 0) { tds_set_state(tds, TDS_IDLE); return TDS_FAIL; } /* RPC on sp_execute */ tds_start_query(tds, TDS_RPC); tds7_send_execute(tds, dyn); return tds_query_flush_packet(tds); } if (dyn->emulated) { TDSRET rc = tds_send_emulated_execute(tds, dyn->query, dyn->params); if (TDS_FAILED(rc)) return rc; return tds_query_flush_packet(tds); } /* query has been prepared successfully, discard original query */ if (dyn->query) TDS_ZERO_FREE(dyn->query); tds->out_flag = TDS_NORMAL; /* dynamic id */ id_len = (int)strlen(dyn->id); tds_put_byte(tds, TDS5_DYNAMIC_TOKEN); tds_put_smallint(tds, id_len + 5); tds_put_byte(tds, 0x02); tds_put_byte(tds, dyn->params ? 0x01 : 0); tds_put_byte(tds, id_len); tds_put_n(tds, dyn->id, id_len); tds_put_smallint(tds, 0); if (dyn->params) tds_put_params(tds, dyn->params, 0); /* send it */ return tds_query_flush_packet(tds); } /** * Send parameters to server. * \tds * \param info parameters to send * \param flags 0 or TDS_PUT_DATA_USE_NAME */ static void tds_put_params(TDSSOCKET * tds, TDSPARAMINFO * info, int flags) { int i, len; bool wide; CHECK_TDS_EXTRA(tds); CHECK_PARAMINFO_EXTRA(info); wide = !!tds_capability_has_req(tds->conn, TDS_REQ_WIDETABLE); /* column descriptions */ tds_put_byte(tds, wide ? TDS5_PARAMFMT2_TOKEN : TDS5_PARAMFMT_TOKEN); /* size */ len = 2; for (i = 0; i < info->num_cols; i++) len += tds_put_data_info_length(tds, info->columns[i], flags); if (wide) { tds_put_int(tds, len + 3 * info->num_cols); flags |= TDS_PUT_DATA_LONG_STATUS; } else { tds_put_smallint(tds, len); } /* number of parameters */ tds_put_smallint(tds, info->num_cols); /* column detail for each parameter */ for (i = 0; i < info->num_cols; i++) { /* FIXME add error handling */ tds_put_data_info(tds, info->columns[i], flags); } /* row data */ tds_put_byte(tds, TDS5_PARAMS_TOKEN); for (i = 0; i < info->num_cols; i++) { /* FIXME handle error */ tds_put_data(tds, info->columns[i]); } } /** * Check if dynamic request must be unprepared. * Depending on status and protocol version request should be unprepared * or not. * \tds * \param dyn dynamic request to check */ int tds_needs_unprepare(TDSCONNECTION * conn, TDSDYNAMIC * dyn) { CHECK_CONN_EXTRA(conn); CHECK_DYNAMIC_EXTRA(dyn); /* check if statement is prepared */ if (IS_TDS7_PLUS(conn) && !dyn->num_id) return 0; if (dyn->emulated || !dyn->id[0]) return 0; return 1; } /** * Unprepare dynamic on idle. * This let libTDS close the prepared statement when possible. * \tds * \param dyn dynamic request to close */ TDSRET tds_deferred_unprepare(TDSCONNECTION * conn, TDSDYNAMIC * dyn) { CHECK_CONN_EXTRA(conn); CHECK_DYNAMIC_EXTRA(dyn); if (!tds_needs_unprepare(conn, dyn)) { tds_dynamic_deallocated(conn, dyn); return TDS_SUCCESS; } dyn->defer_close = 1; conn->pending_close = 1; return TDS_SUCCESS; } /** * Send a unprepare request for a prepared query * \param tds state information for the socket and the TDS protocol * \param dyn dynamic query * \result TDS_SUCCESS or TDS_FAIL */ TDSRET tds_submit_unprepare(TDSSOCKET * tds, TDSDYNAMIC * dyn) { int id_len; CHECK_TDS_EXTRA(tds); /* TODO test dyn in tds */ CHECK_DYNAMIC_EXTRA(dyn); if (!dyn) return TDS_FAIL; tdsdump_log(TDS_DBG_FUNC, "tds_submit_unprepare() %s\n", dyn->id); if (tds_set_state(tds, TDS_WRITING) != TDS_WRITING) return TDS_FAIL; tds_set_cur_dyn(tds, dyn); if (IS_TDS7_PLUS(tds->conn)) { /* RPC on sp_execute */ tds_start_query(tds, TDS_RPC); /* procedure name */ if (IS_TDS71_PLUS(tds->conn)) { /* save some byte for mssql2k */ tds_put_smallint(tds, -1); tds_put_smallint(tds, TDS_SP_UNPREPARE); } else { TDS_PUT_N_AS_UCS2(tds, "sp_unprepare"); } tds_put_smallint(tds, 0); /* flags */ /* id of prepared statement */ tds_put_byte(tds, 0); tds_put_byte(tds, 0); tds_put_byte(tds, SYBINTN); tds_put_byte(tds, 4); tds_put_byte(tds, 4); tds_put_int(tds, dyn->num_id); tds->current_op = TDS_OP_UNPREPARE; return tds_query_flush_packet(tds); } if (dyn->emulated) { tds_start_query(tds, TDS_QUERY); /* just a dummy select to return some data */ tds_put_string(tds, "select 1 where 0=1", -1); return tds_query_flush_packet(tds); } tds->out_flag = TDS_NORMAL; /* dynamic id */ id_len = (int)strlen(dyn->id); tds_put_byte(tds, TDS5_DYNAMIC_TOKEN); tds_put_smallint(tds, id_len + 5); tds_put_byte(tds, TDS_DYN_DEALLOC); tds_put_byte(tds, 0x00); tds_put_byte(tds, id_len); tds_put_n(tds, dyn->id, id_len); tds_put_smallint(tds, 0); /* send it */ tds->current_op = TDS_OP_DYN_DEALLOC; return tds_query_flush_packet(tds); } /** * Send RPC as string query. * This function is used on old protocol which does not support RPC queries. * \tds * \param rpc_name name of RPC to invoke * \param params parameters to send to server * \returns TDS_FAIL or TDS_SUCCESS */ static TDSRET tds_send_emulated_rpc(TDSSOCKET * tds, const char *rpc_name, TDSPARAMINFO * params) { TDSCOLUMN *param; int i, n; int num_params = params ? params->num_cols : 0; const char *sep = " "; char buf[80]; /* create params and set */ for (i = 0, n = 0; i < num_params; ++i) { param = params->columns[i]; /* declare and set output parameters */ if (!param->column_output) continue; ++n; sprintf(buf, " DECLARE @P%d ", n); tds_get_column_declaration(tds, param, buf + strlen(buf)); sprintf(buf + strlen(buf), " SET @P%d=", n); tds_put_string(tds, buf, -1); tds_put_param_as_string(tds, params, i); } /* put exec statement */ tds_put_string(tds, " EXEC ", 6); tds_put_string(tds, rpc_name, -1); /* put arguments */ for (i = 0, n = 0; i < num_params; ++i) { param = params->columns[i]; tds_put_string(tds, sep, -1); if (!tds_dstr_isempty(¶m->column_name)) { tds_put_string(tds, tds_dstr_cstr(¶m->column_name), tds_dstr_len(¶m->column_name)); tds_put_string(tds, "=", 1); } if (param->column_output) { ++n; sprintf(buf, "@P%d OUTPUT", n); tds_put_string(tds, buf, -1); } else { tds_put_param_as_string(tds, params, i); } sep = ","; } return tds_query_flush_packet(tds); } /** * tds_submit_rpc() call a RPC from server. Output parameters will be stored in tds->param_info * \param tds state information for the socket and the TDS protocol * \param rpc_name name of RPC * \param params parameters informations. NULL for no parameters */ TDSRET tds_submit_rpc(TDSSOCKET * tds, const char *rpc_name, TDSPARAMINFO * params, TDSHEADERS * head) { TDSCOLUMN *param; int rpc_name_len, i; int num_params = params ? params->num_cols : 0; CHECK_TDS_EXTRA(tds); if (params) CHECK_PARAMINFO_EXTRA(params); assert(tds); assert(rpc_name); if (tds_set_state(tds, TDS_WRITING) != TDS_WRITING) return TDS_FAIL; /* distinguish from dynamic query */ tds_release_cur_dyn(tds); rpc_name_len = (int)strlen(rpc_name); if (IS_TDS7_PLUS(tds->conn)) { const char *converted_name; size_t converted_name_len; /* procedure name */ converted_name = tds_convert_string(tds, tds->conn->char_convs[client2ucs2], rpc_name, rpc_name_len, &converted_name_len); if (!converted_name) { tds_set_state(tds, TDS_IDLE); return TDS_FAIL; } if (tds_start_query_head(tds, TDS_RPC, head) != TDS_SUCCESS) { tds_convert_string_free(rpc_name, converted_name); return TDS_FAIL; } TDS_PUT_SMALLINT(tds, converted_name_len / 2); tds_put_n(tds, converted_name, (int)converted_name_len); tds_convert_string_free(rpc_name, converted_name); /* * TODO support flags * bit 0 (1 as flag) in TDS7/TDS5 is "recompile" * bit 1 (2 as flag) in TDS7+ is "no metadata" bit * (I don't know meaning of "no metadata") */ tds_put_smallint(tds, 0); for (i = 0; i < num_params; i++) { param = params->columns[i]; /* TODO check error */ tds_put_data_info(tds, param, TDS_PUT_DATA_USE_NAME); /* FIXME handle error */ tds_put_data(tds, param); } return tds_query_flush_packet(tds); } if (IS_TDS50(tds->conn)) { tds->out_flag = TDS_NORMAL; /* DBRPC */ tds_put_byte(tds, TDS_DBRPC_TOKEN); /* TODO ICONV convert rpc name */ tds_put_smallint(tds, rpc_name_len + 3); tds_put_byte(tds, rpc_name_len); tds_put_n(tds, rpc_name, rpc_name_len); /* TODO flags */ tds_put_smallint(tds, num_params ? 2 : 0); if (num_params) tds_put_params(tds, params, TDS_PUT_DATA_USE_NAME); /* send it */ return tds_query_flush_packet(tds); } /* emulate it for TDS4.x, send RPC for mssql */ if (tds->conn->tds_version < 0x500) return tds_send_emulated_rpc(tds, rpc_name, params); /* TODO continue, support for TDS4?? */ tds_set_state(tds, TDS_IDLE); return TDS_FAIL; } /** * tds_send_cancel() sends an empty packet (8 byte header only) * tds_process_cancel should be called directly after this. * \param tds state information for the socket and the TDS protocol * \remarks * tcp will either deliver the packet or time out. * (TIME_WAIT determines how long it waits between retries.) * * On sending the cancel, we may get EAGAIN. We then select(2) until we know * either 1) it succeeded or 2) it didn't. On failure, close the socket, * tell the app, and fail the function. * * On success, we read(2) and wait for a reply with select(2). If we get * one, great. If the client's timeout expires, we tell him, but all we can * do is wait some more or give up and close the connection. If he tells us * to cancel again, we wait some more. */ TDSRET tds_send_cancel(TDSSOCKET * tds) { #if ENABLE_ODBC_MARS CHECK_TDS_EXTRA(tds); tdsdump_log(TDS_DBG_FUNC, "tds_send_cancel: %sin_cancel and %sidle\n", (tds->in_cancel? "":"not "), (tds->state == TDS_IDLE? "":"not ")); /* one cancel is sufficient */ if (tds->in_cancel || tds->state == TDS_IDLE) { return TDS_SUCCESS; } tds->in_cancel = 1; if (tds_mutex_trylock(&tds->conn->list_mtx)) { /* TODO check */ /* signal other socket */ tds_wakeup_send(&tds->conn->wakeup, 1); return TDS_SUCCESS; } if (tds->conn->in_net_tds) { tds_mutex_unlock(&tds->conn->list_mtx); /* TODO check */ /* signal other socket */ tds_wakeup_send(&tds->conn->wakeup, 1); return TDS_SUCCESS; } tds_mutex_unlock(&tds->conn->list_mtx); /* problem: if we are in in_net and we got a signal ?? on timeout we and a cancel, directly in in_net if we hold the lock and we get a signal lock create a death lock if we use a recursive mutex and we can get the lock there are 2 cases - same thread, we could add a packet and signal, no try ok - first thread locking, we could add a packet but are we sure it get processed ??, no try ok if recursive mutex and we can't get another thread, wait if mutex is not recursive and we get the lock (try) - nobody locked, if in_net it could be same or another if mutex is not recursive and we can't get the lock - another thread is locking, sending signal require not exiting and global list (not protected by list_mtx) - same thread have lock, we can't wait nothing without deathlock, setting a flag in tds and signaling could help if a tds is waiting for data or is waiting for a condition or for a signal in poll pass cancel request on socket ?? */ tds->out_flag = TDS_CANCEL; tdsdump_log(TDS_DBG_FUNC, "tds_send_cancel: sending cancel packet\n"); return tds_flush_packet(tds); #else TDSRET rc; /* * if we are not able to get the lock signal other thread * this means that either: * - another thread is processing data * - we got called from a signal inside processing thread * - we got called from message handler */ if (tds_mutex_trylock(&tds->wire_mtx)) { /* TODO check */ if (!tds->in_cancel) tds->in_cancel = 1; /* signal other socket */ tds_wakeup_send(&tds->conn->wakeup, 1); return TDS_SUCCESS; } CHECK_TDS_EXTRA(tds); tdsdump_log(TDS_DBG_FUNC, "tds_send_cancel: %sin_cancel and %sidle\n", (tds->in_cancel? "":"not "), (tds->state == TDS_IDLE? "":"not ")); /* one cancel is sufficient */ if (tds->in_cancel || tds->state == TDS_IDLE) { tds_mutex_unlock(&tds->wire_mtx); return TDS_SUCCESS; } rc = tds_put_cancel(tds); tds_mutex_unlock(&tds->wire_mtx); return rc; #endif } /** * Quote a string properly. Output string is always NUL-terminated * \tds * \param buffer output buffer. If NULL function will just return * required bytes * \param quoting quote character * \param id string to quote * \param len length of string to quote * \returns size of output string */ static size_t tds_quote(TDSSOCKET * tds, char *buffer, char quoting, const char *id, size_t len) { size_t size; const char *src, *pend; char *dst; CHECK_TDS_EXTRA(tds); pend = id + len; /* quote */ src = id; if (!buffer) { size = 2u + len; for (; src != pend; ++src) if (*src == quoting) ++size; return size; } dst = buffer; *dst++ = (quoting == ']') ? '[' : quoting; for (; src != pend; ++src) { if (*src == quoting) *dst++ = quoting; *dst++ = *src; } *dst++ = quoting; *dst = 0; return dst - buffer; } /** * Quote an id * \param tds state information for the socket and the TDS protocol * \param buffer buffer to store quoted id. If NULL do not write anything * (useful to compute quote length) * \param id id to quote * \param idlen id length (< 0 for NUL terminated) * \result written chars (not including needed terminator) */ size_t tds_quote_id(TDSSOCKET * tds, char *buffer, const char *id, int idlen) { size_t i, len; CHECK_TDS_EXTRA(tds); len = idlen < 0 ? strlen(id) : (size_t) idlen; /* quote always for mssql */ if (TDS_IS_MSSQL(tds) || tds->conn->product_version >= TDS_SYB_VER(12, 5, 1)) return tds_quote(tds, buffer, ']', id, len); /* need quote ?? */ for (i = 0; i < len; ++i) { char c = id[i]; if (c >= 'a' && c <= 'z') continue; if (c >= 'A' && c <= 'Z') continue; if (i > 0 && c >= '0' && c <= '9') continue; if (c == '_') continue; return tds_quote(tds, buffer, '\"', id, len); } if (buffer) { memcpy(buffer, id, len); buffer[len] = '\0'; } return len; } /** * Quote a string * \param tds state information for the socket and the TDS protocol * \param buffer buffer to store quoted id. If NULL do not write anything * (useful to compute quote length) * \param str string to quote (not necessary null-terminated) * \param len length of string (-1 for null terminated) * \result written chars (not including needed terminator) */ size_t tds_quote_string(TDSSOCKET * tds, char *buffer, const char *str, int len) { return tds_quote(tds, buffer, '\'', str, len < 0 ? strlen(str) : (size_t) len); } /** * Set current cursor. * Current cursor is the one will receive output from server. * \tds * \param cursor cursor to set as current */ static inline void tds_set_cur_cursor(TDSSOCKET *tds, TDSCURSOR *cursor) { ++cursor->ref_count; if (tds->cur_cursor) tds_release_cursor(&tds->cur_cursor); tds->cur_cursor = cursor; } TDSRET tds_cursor_declare(TDSSOCKET * tds, TDSCURSOR * cursor, TDSPARAMINFO *params, int *something_to_send) { CHECK_TDS_EXTRA(tds); if (!cursor) return TDS_FAIL; tdsdump_log(TDS_DBG_INFO1, "tds_cursor_declare() cursor id = %d\n", cursor->cursor_id); if (IS_TDS7_PLUS(tds->conn)) { cursor->srv_status |= TDS_CUR_ISTAT_DECLARED; cursor->srv_status |= TDS_CUR_ISTAT_CLOSED; cursor->srv_status |= TDS_CUR_ISTAT_RDONLY; } if (IS_TDS50(tds->conn)) { if (!*something_to_send) { if (tds_set_state(tds, TDS_WRITING) != TDS_WRITING) return TDS_FAIL; tds->out_flag = TDS_NORMAL; } if (tds->state != TDS_WRITING || tds->out_flag != TDS_NORMAL) return TDS_FAIL; tds_put_byte(tds, TDS_CURDECLARE_TOKEN); /* length of the data stream that follows */ TDS_PUT_SMALLINT(tds, (6 + strlen(cursor->cursor_name) + strlen(cursor->query))); tdsdump_log(TDS_DBG_ERROR, "size = %u\n", (unsigned int) (6u + strlen(cursor->cursor_name) + strlen(cursor->query))); TDS_PUT_BYTE(tds, strlen(cursor->cursor_name)); tds_put_n(tds, cursor->cursor_name, (int)strlen(cursor->cursor_name)); tds_put_byte(tds, 1); /* cursor option is read only=1, unused=0 */ tds_put_byte(tds, 0); /* status unused=0 */ /* TODO iconv */ TDS_PUT_SMALLINT(tds, strlen(cursor->query)); tds_put_n(tds, cursor->query, (int)strlen(cursor->query)); tds_put_tinyint(tds, 0); /* number of columns = 0 , valid value applicable only for updatable cursor */ *something_to_send = 1; } return TDS_SUCCESS; } TDSRET tds_cursor_open(TDSSOCKET * tds, TDSCURSOR * cursor, TDSPARAMINFO *params, int *something_to_send) { CHECK_TDS_EXTRA(tds); if (!cursor) return TDS_FAIL; tdsdump_log(TDS_DBG_INFO1, "tds_cursor_open() cursor id = %d\n", cursor->cursor_id); if (!*something_to_send) { if (tds_set_state(tds, TDS_WRITING) != TDS_WRITING) return TDS_FAIL; } if (tds->state != TDS_WRITING) return TDS_FAIL; tds_set_cur_cursor(tds, cursor); if (IS_TDS50(tds->conn)) { tds->out_flag = TDS_NORMAL; tds_put_byte(tds, TDS_CUROPEN_TOKEN); TDS_PUT_SMALLINT(tds, 6 + strlen(cursor->cursor_name)); /* length of the data stream that follows */ /*tds_put_int(tds, cursor->cursor_id); *//* Only if cursor id is passed as zero, the cursor name need to be sent */ tds_put_int(tds, 0); TDS_PUT_BYTE(tds, strlen(cursor->cursor_name)); tds_put_n(tds, cursor->cursor_name, (int)strlen(cursor->cursor_name)); tds_put_byte(tds, 0); /* Cursor status : 0 for no arguments */ *something_to_send = 1; } if (IS_TDS7_PLUS(tds->conn)) { const char *converted_query; size_t definition_len = 0, converted_query_len; char *param_definition = NULL; int num_params = params ? params->num_cols : 0; /* cursor statement */ converted_query = tds_convert_string(tds, tds->conn->char_convs[client2ucs2], cursor->query, (int)strlen(cursor->query), &converted_query_len); if (!converted_query) { if (!*something_to_send) tds_set_state(tds, TDS_IDLE); return TDS_FAIL; } if (num_params) { param_definition = tds7_build_param_def_from_query(tds, converted_query, converted_query_len, params, &definition_len); if (!param_definition) { tds_convert_string_free(cursor->query, converted_query); if (!*something_to_send) tds_set_state(tds, TDS_IDLE); return TDS_FAIL; } } /* RPC call to sp_cursoropen */ tds_start_query(tds, TDS_RPC); /* procedure identifier by number */ if (IS_TDS71_PLUS(tds->conn)) { tds_put_smallint(tds, -1); tds_put_smallint(tds, TDS_SP_CURSOROPEN); } else { TDS_PUT_N_AS_UCS2(tds, "sp_cursoropen"); } tds_put_smallint(tds, 0); /* flags */ /* return cursor handle (int) */ tds_put_byte(tds, 0); /* no parameter name */ tds_put_byte(tds, 1); /* output parameter */ tds_put_byte(tds, SYBINTN); tds_put_byte(tds, 4); tds_put_byte(tds, 0); if (definition_len) { tds7_put_query_params(tds, converted_query, converted_query_len); } else { tds_put_byte(tds, 0); tds_put_byte(tds, 0); tds_put_byte(tds, SYBNTEXT); /* must be Ntype */ TDS_PUT_INT(tds, converted_query_len); if (IS_TDS71_PLUS(tds->conn)) tds_put_n(tds, tds->conn->collation, 5); TDS_PUT_INT(tds, converted_query_len); tds_put_n(tds, converted_query, (int)converted_query_len); } tds_convert_string_free(cursor->query, converted_query); /* type */ tds_put_byte(tds, 0); /* no parameter name */ tds_put_byte(tds, 1); /* output parameter */ tds_put_byte(tds, SYBINTN); tds_put_byte(tds, 4); tds_put_byte(tds, 4); tds_put_int(tds, definition_len ? cursor->type | 0x1000 : cursor->type); /* concurrency */ tds_put_byte(tds, 0); /* no parameter name */ tds_put_byte(tds, 1); /* output parameter */ tds_put_byte(tds, SYBINTN); tds_put_byte(tds, 4); tds_put_byte(tds, 4); tds_put_int(tds, cursor->concurrency); /* row count */ tds_put_byte(tds, 0); tds_put_byte(tds, 1); /* output parameter */ tds_put_byte(tds, SYBINTN); tds_put_byte(tds, 4); tds_put_byte(tds, 4); tds_put_int(tds, 0); if (definition_len) { int i; tds7_put_params_definition(tds, param_definition, definition_len); for (i = 0; i < num_params; i++) { TDSCOLUMN *param = params->columns[i]; /* TODO check error */ tds_put_data_info(tds, param, 0); /* FIXME handle error */ tds_put_data(tds, param); } } free(param_definition); *something_to_send = 1; tds->current_op = TDS_OP_CURSOROPEN; tdsdump_log(TDS_DBG_ERROR, "tds_cursor_open (): RPC call set up \n"); } tdsdump_log(TDS_DBG_ERROR, "tds_cursor_open (): cursor open completed\n"); return TDS_SUCCESS; } TDSRET tds_cursor_setrows(TDSSOCKET * tds, TDSCURSOR * cursor, int *something_to_send) { CHECK_TDS_EXTRA(tds); if (!cursor) return TDS_FAIL; tdsdump_log(TDS_DBG_INFO1, "tds_cursor_setrows() cursor id = %d\n", cursor->cursor_id); if (IS_TDS7_PLUS(tds->conn)) { cursor->srv_status &= ~TDS_CUR_ISTAT_DECLARED; cursor->srv_status |= TDS_CUR_ISTAT_CLOSED; cursor->srv_status |= TDS_CUR_ISTAT_ROWCNT; } if (IS_TDS50(tds->conn)) { if (!*something_to_send) { if (tds_set_state(tds, TDS_WRITING) != TDS_WRITING) return TDS_FAIL; tds->out_flag = TDS_NORMAL; } if (tds->state != TDS_WRITING || tds->out_flag != TDS_NORMAL) return TDS_FAIL; tds_set_cur_cursor(tds, cursor); tds_put_byte(tds, TDS_CURINFO_TOKEN); TDS_PUT_SMALLINT(tds, 12 + strlen(cursor->cursor_name)); /* length of data stream that follows */ /* tds_put_int(tds, tds->cursor->cursor_id); */ /* Cursor id */ tds_put_int(tds, 0); TDS_PUT_BYTE(tds, strlen(cursor->cursor_name)); tds_put_n(tds, cursor->cursor_name, (int)strlen(cursor->cursor_name)); tds_put_byte(tds, 1); /* Command TDS_CUR_CMD_SETCURROWS */ tds_put_byte(tds, 0x00); /* Status - TDS_CUR_ISTAT_ROWCNT 0x0020 */ tds_put_byte(tds, 0x20); /* Status - TDS_CUR_ISTAT_ROWCNT 0x0020 */ tds_put_int(tds, cursor->cursor_rows); /* row count to set */ *something_to_send = 1; } return TDS_SUCCESS; } static void tds7_put_cursor_fetch(TDSSOCKET * tds, TDS_INT cursor_id, TDS_TINYINT fetch_type, TDS_INT i_row, TDS_INT num_rows) { if (IS_TDS71_PLUS(tds->conn)) { tds_put_smallint(tds, -1); tds_put_smallint(tds, TDS_SP_CURSORFETCH); } else { TDS_PUT_N_AS_UCS2(tds, "sp_cursorfetch"); } /* This flag tells the SP only to */ /* output a dummy metadata token */ tds_put_smallint(tds, 2); /* input cursor handle (int) */ tds_put_byte(tds, 0); /* no parameter name */ tds_put_byte(tds, 0); /* input parameter */ tds_put_byte(tds, SYBINTN); tds_put_byte(tds, 4); tds_put_byte(tds, 4); tds_put_int(tds, cursor_id); /* fetch type - 2 = NEXT */ tds_put_byte(tds, 0); /* no parameter name */ tds_put_byte(tds, 0); /* input parameter */ tds_put_byte(tds, SYBINTN); tds_put_byte(tds, 4); tds_put_byte(tds, 4); tds_put_int(tds, fetch_type); /* row number */ tds_put_byte(tds, 0); /* no parameter name */ tds_put_byte(tds, 0); /* input parameter */ tds_put_byte(tds, SYBINTN); tds_put_byte(tds, 4); if ((fetch_type & 0x30) != 0) { tds_put_byte(tds, 4); tds_put_int(tds, i_row); } else { tds_put_byte(tds, 0); } /* number of rows to fetch */ tds_put_byte(tds, 0); /* no parameter name */ tds_put_byte(tds, 0); /* input parameter */ tds_put_byte(tds, SYBINTN); tds_put_byte(tds, 4); tds_put_byte(tds, 4); tds_put_int(tds, num_rows); } TDSRET tds_cursor_fetch(TDSSOCKET * tds, TDSCURSOR * cursor, TDS_CURSOR_FETCH fetch_type, TDS_INT i_row) { CHECK_TDS_EXTRA(tds); if (!cursor) return TDS_FAIL; tdsdump_log(TDS_DBG_INFO1, "tds_cursor_fetch() cursor id = %d\n", cursor->cursor_id); if (tds_set_state(tds, TDS_WRITING) != TDS_WRITING) return TDS_FAIL; tds_set_cur_cursor(tds, cursor); if (IS_TDS50(tds->conn)) { size_t len = strlen(cursor->cursor_name); size_t row_len = 0; tds->out_flag = TDS_NORMAL; tds_put_byte(tds, TDS_CURFETCH_TOKEN); if (len > (255-10)) len = (255-10); if (fetch_type == TDS_CURSOR_FETCH_ABSOLUTE || fetch_type == TDS_CURSOR_FETCH_RELATIVE) row_len = 4; /*tds_put_smallint(tds, 8); */ TDS_PUT_SMALLINT(tds, 6 + len + row_len); /* length of the data stream that follows */ /*tds_put_int(tds, cursor->cursor_id); *//* cursor id returned by the server */ tds_put_int(tds, 0); TDS_PUT_BYTE(tds, len); tds_put_n(tds, cursor->cursor_name, len); tds_put_tinyint(tds, fetch_type); /* optional argument to fetch row at absolute/relative position */ if (row_len) tds_put_int(tds, i_row); return tds_query_flush_packet(tds); } if (IS_TDS7_PLUS(tds->conn)) { /* RPC call to sp_cursorfetch */ static const unsigned char mssql_fetch[7] = { 0, 2, /* TDS_CURSOR_FETCH_NEXT */ 4, /* TDS_CURSOR_FETCH_PREV */ 1, /* TDS_CURSOR_FETCH_FIRST */ 8, /* TDS_CURSOR_FETCH_LAST */ 0x10, /* TDS_CURSOR_FETCH_ABSOLUTE */ 0x20 /* TDS_CURSOR_FETCH_RELATIVE */ }; tds_start_query(tds, TDS_RPC); /* TODO enum for 2 ... */ if (cursor->type == 2 && fetch_type == TDS_CURSOR_FETCH_ABSOLUTE) { /* strangely dynamic cursor do not support absolute so emulate it with first + relative */ tds7_put_cursor_fetch(tds, cursor->cursor_id, 1, 0, 0); /* TODO define constant */ tds_put_byte(tds, IS_TDS72_PLUS(tds->conn) ? 0xff : 0x80); tds7_put_cursor_fetch(tds, cursor->cursor_id, 0x20, i_row, cursor->cursor_rows); } else { /* TODO check fetch_type ?? */ tds7_put_cursor_fetch(tds, cursor->cursor_id, mssql_fetch[fetch_type], i_row, cursor->cursor_rows); } tds->current_op = TDS_OP_CURSORFETCH; return tds_query_flush_packet(tds); } tds_set_state(tds, TDS_IDLE); return TDS_SUCCESS; } TDSRET tds_cursor_get_cursor_info(TDSSOCKET *tds, TDSCURSOR *cursor, TDS_UINT *prow_number, TDS_UINT *prow_count) { int done_flags; TDSRET retcode; TDS_INT result_type; CHECK_TDS_EXTRA(tds); if (!cursor) return TDS_FAIL; tdsdump_log(TDS_DBG_INFO1, "tds_cursor_get_cursor_info() cursor id = %d\n", cursor->cursor_id); /* Assume not known */ assert(prow_number && prow_count); *prow_number = 0; *prow_count = 0; if (IS_TDS7_PLUS(tds->conn)) { /* Change state to querying */ if (tds_set_state(tds, TDS_WRITING) != TDS_WRITING) return TDS_FAIL; /* Remember the server has been sent a command for this cursor */ tds_set_cur_cursor(tds, cursor); /* General initialization of server command */ tds_start_query(tds, TDS_RPC); /* Create and send query to server */ if (IS_TDS71_PLUS(tds->conn)) { tds_put_smallint(tds, -1); tds_put_smallint(tds, TDS_SP_CURSORFETCH); } else { TDS_PUT_N_AS_UCS2(tds, "sp_cursorfetch"); } /* This flag tells the SP only to */ /* output a dummy metadata token */ tds_put_smallint(tds, 2); /* input cursor handle (int) */ tds_put_byte(tds, 0); /* no parameter name */ tds_put_byte(tds, 0); /* input parameter */ tds_put_byte(tds, SYBINTN); tds_put_byte(tds, 4); tds_put_byte(tds, 4); tds_put_int(tds, cursor->cursor_id); tds_put_byte(tds, 0); /* no parameter name */ tds_put_byte(tds, 0); /* input parameter */ tds_put_byte(tds, SYBINTN); tds_put_byte(tds, 4); tds_put_byte(tds, 4); tds_put_int(tds, 0x100); /* FETCH_INFO */ /* row number */ tds_put_byte(tds, 0); /* no parameter name */ tds_put_byte(tds, 1); /* output parameter */ tds_put_byte(tds, SYBINTN); tds_put_byte(tds, 4); tds_put_byte(tds, 0); /* number of rows fetched */ tds_put_byte(tds, 0); /* no parameter name */ tds_put_byte(tds, 1); /* output parameter */ tds_put_byte(tds, SYBINTN); tds_put_byte(tds, 4); tds_put_byte(tds, 0); /* Adjust current state */ tds->current_op = TDS_OP_NONE; if (TDS_FAILED(retcode=tds_query_flush_packet(tds))) return retcode; /* Process answer from server */ for (;;) { retcode = tds_process_tokens(tds, &result_type, &done_flags, TDS_RETURN_PROC); tdsdump_log(TDS_DBG_FUNC, "tds_cursor_get_cursor_info: tds_process_tokens returned %d\n", retcode); tdsdump_log(TDS_DBG_FUNC, " result_type=%d, TDS_DONE_COUNT=%x, TDS_DONE_ERROR=%x\n", result_type, (done_flags & TDS_DONE_COUNT), (done_flags & TDS_DONE_ERROR)); switch (retcode) { case TDS_NO_MORE_RESULTS: return TDS_SUCCESS; case TDS_SUCCESS: if (result_type==TDS_PARAM_RESULT) { /* Status is updated when TDS_STATUS_RESULT token arrives, before the params are processed */ if (tds->has_status && tds->ret_status==0) { TDSPARAMINFO *pinfo = tds->current_results; /* Make sure the params retuned have the correct type and size */ if (pinfo && pinfo->num_cols==2 && pinfo->columns[0]->column_type==SYBINTN && pinfo->columns[1]->column_type==SYBINTN && pinfo->columns[0]->column_size==4 && pinfo->columns[1]->column_size==4) { /* Take the values */ *prow_number = (TDS_UINT)(*(TDS_INT *) pinfo->columns[0]->column_data); *prow_count = (TDS_UINT)(*(TDS_INT *) pinfo->columns[1]->column_data); tdsdump_log(TDS_DBG_FUNC, "----------------> prow_number=%u, prow_count=%u\n", *prow_count, *prow_number); } } } break; default: return retcode; } } } return TDS_SUCCESS; } TDSRET tds_cursor_close(TDSSOCKET * tds, TDSCURSOR * cursor) { CHECK_TDS_EXTRA(tds); if (!cursor) return TDS_FAIL; tdsdump_log(TDS_DBG_INFO1, "tds_cursor_close() cursor id = %d\n", cursor->cursor_id); if (tds_set_state(tds, TDS_WRITING) != TDS_WRITING) return TDS_FAIL; tds_set_cur_cursor(tds, cursor); if (IS_TDS50(tds->conn)) { tds->out_flag = TDS_NORMAL; tds_put_byte(tds, TDS_CURCLOSE_TOKEN); tds_put_smallint(tds, 5); /* length of the data stream that follows */ tds_put_int(tds, cursor->cursor_id); /* cursor id returned by the server is available now */ if (cursor->status.dealloc == TDS_CURSOR_STATE_REQUESTED) { tds_put_byte(tds, 0x01); /* Close option: TDS_CUR_COPT_DEALLOC */ cursor->status.dealloc = TDS_CURSOR_STATE_SENT; } else tds_put_byte(tds, 0x00); /* Close option: TDS_CUR_COPT_UNUSED */ } if (IS_TDS7_PLUS(tds->conn)) { /* RPC call to sp_cursorclose */ tds_start_query(tds, TDS_RPC); if (IS_TDS71_PLUS(tds->conn)) { tds_put_smallint(tds, -1); tds_put_smallint(tds, TDS_SP_CURSORCLOSE); } else { TDS_PUT_N_AS_UCS2(tds, "sp_cursorclose"); } /* This flag tells the SP to output only a dummy metadata token */ tds_put_smallint(tds, 2); /* input cursor handle (int) */ tds_put_byte(tds, 0); /* no parameter name */ tds_put_byte(tds, 0); /* input parameter */ tds_put_byte(tds, SYBINTN); tds_put_byte(tds, 4); tds_put_byte(tds, 4); tds_put_int(tds, cursor->cursor_id); tds->current_op = TDS_OP_CURSORCLOSE; } return tds_query_flush_packet(tds); } TDSRET tds_cursor_setname(TDSSOCKET * tds, TDSCURSOR * cursor) { int len; CHECK_TDS_EXTRA(tds); if (!cursor) return TDS_FAIL; tdsdump_log(TDS_DBG_INFO1, "tds_cursor_setname() cursor id = %d\n", cursor->cursor_id); if (!IS_TDS7_PLUS(tds->conn)) return TDS_SUCCESS; if (tds_set_state(tds, TDS_WRITING) != TDS_WRITING) return TDS_FAIL; tds_set_cur_cursor(tds, cursor); /* RPC call to sp_cursoroption */ tds_start_query(tds, TDS_RPC); if (IS_TDS71_PLUS(tds->conn)) { tds_put_smallint(tds, -1); tds_put_smallint(tds, TDS_SP_CURSOROPTION); } else { TDS_PUT_N_AS_UCS2(tds, "sp_cursoroption"); } tds_put_smallint(tds, 0); /* input cursor handle (int) */ tds_put_byte(tds, 0); /* no parameter name */ tds_put_byte(tds, 0); /* input parameter */ tds_put_byte(tds, SYBINTN); tds_put_byte(tds, 4); tds_put_byte(tds, 4); tds_put_int(tds, cursor->cursor_id); /* code, 2 == set cursor name */ tds_put_byte(tds, 0); /* no parameter name */ tds_put_byte(tds, 0); /* input parameter */ tds_put_byte(tds, SYBINTN); tds_put_byte(tds, 4); tds_put_byte(tds, 4); tds_put_int(tds, 2); /* cursor name */ tds_put_byte(tds, 0); tds_put_byte(tds, 0); /* TODO convert ?? */ tds_put_byte(tds, XSYBVARCHAR); len = (int)strlen(cursor->cursor_name); tds_put_smallint(tds, len); if (IS_TDS71_PLUS(tds->conn)) tds_put_n(tds, tds->conn->collation, 5); tds_put_smallint(tds, len); tds_put_n(tds, cursor->cursor_name, len); tds->current_op = TDS_OP_CURSOROPTION; return tds_query_flush_packet(tds); } TDSRET tds_cursor_update(TDSSOCKET * tds, TDSCURSOR * cursor, TDS_CURSOR_OPERATION op, TDS_INT i_row, TDSPARAMINFO *params) { CHECK_TDS_EXTRA(tds); if (!cursor) return TDS_FAIL; tdsdump_log(TDS_DBG_INFO1, "tds_cursor_update() cursor id = %d\n", cursor->cursor_id); /* client must provide parameters for update */ if (op == TDS_CURSOR_UPDATE && (!params || params->num_cols <= 0)) return TDS_FAIL; if (tds_set_state(tds, TDS_WRITING) != TDS_WRITING) return TDS_FAIL; tds_set_cur_cursor(tds, cursor); if (IS_TDS50(tds->conn)) { tds->out_flag = TDS_NORMAL; /* FIXME finish*/ tds_set_state(tds, TDS_IDLE); return TDS_FAIL; } if (IS_TDS7_PLUS(tds->conn)) { /* RPC call to sp_cursorclose */ tds_start_query(tds, TDS_RPC); if (IS_TDS71_PLUS(tds->conn)) { tds_put_smallint(tds, -1); tds_put_smallint(tds, TDS_SP_CURSOR); } else { TDS_PUT_N_AS_UCS2(tds, "sp_cursor"); } tds_put_smallint(tds, 0); /* input cursor handle (int) */ tds_put_byte(tds, 0); /* no parameter name */ tds_put_byte(tds, 0); /* input parameter */ tds_put_byte(tds, SYBINTN); tds_put_byte(tds, 4); tds_put_byte(tds, 4); tds_put_int(tds, cursor->cursor_id); /* cursor operation */ tds_put_byte(tds, 0); /* no parameter name */ tds_put_byte(tds, 0); /* input parameter */ tds_put_byte(tds, SYBINTN); tds_put_byte(tds, 4); tds_put_byte(tds, 4); tds_put_int(tds, 32 | op); /* row number */ tds_put_byte(tds, 0); /* no parameter name */ tds_put_byte(tds, 0); /* input parameter */ tds_put_byte(tds, SYBINTN); tds_put_byte(tds, 4); tds_put_byte(tds, 4); tds_put_int(tds, i_row); /* update require table name */ if (op == TDS_CURSOR_UPDATE) { TDSCOLUMN *param; unsigned int n, num_params; const char *table_name = NULL; size_t converted_table_len = 0; const char *converted_table = NULL; /* empty table name */ tds_put_byte(tds, 0); tds_put_byte(tds, 0); tds_put_byte(tds, XSYBNVARCHAR); num_params = params->num_cols; for (n = 0; n < num_params; ++n) { param = params->columns[n]; if (!tds_dstr_isempty(¶m->table_name)) { table_name = tds_dstr_cstr(¶m->table_name); break; } } if (table_name) { converted_table = tds_convert_string(tds, tds->conn->char_convs[client2ucs2], table_name, (int)strlen(table_name), &converted_table_len); if (!converted_table) { /* FIXME not here, in the middle of a packet */ tds_set_state(tds, TDS_IDLE); return TDS_FAIL; } } TDS_PUT_SMALLINT(tds, converted_table_len); if (IS_TDS71_PLUS(tds->conn)) tds_put_n(tds, tds->conn->collation, 5); TDS_PUT_SMALLINT(tds, converted_table_len); tds_put_n(tds, converted_table, converted_table_len); tds_convert_string_free(table_name, converted_table); /* output columns to update */ for (n = 0; n < num_params; ++n) { param = params->columns[n]; /* TODO check error */ tds_put_data_info(tds, param, TDS_PUT_DATA_USE_NAME|TDS_PUT_DATA_PREFIX_NAME); /* FIXME handle error */ tds_put_data(tds, param); } } tds->current_op = TDS_OP_CURSOR; } return tds_query_flush_packet(tds); } /** * Check if a cursor is allocated into the server. * If not is allocated it assure is removed from the connection list * \tds * \return 0 if not allocated <>0 otherwise */ static int tds_cursor_check_allocated(TDSCONNECTION * conn, TDSCURSOR * cursor) { if (cursor->srv_status == TDS_CUR_ISTAT_UNUSED || (cursor->srv_status & TDS_CUR_ISTAT_DEALLOC) != 0 || (IS_TDS7_PLUS(conn) && (cursor->srv_status & TDS_CUR_ISTAT_CLOSED) != 0)) { tds_cursor_deallocated(conn, cursor); return 0; } return 1; } /** * Send a deallocation request to server */ TDSRET tds_cursor_dealloc(TDSSOCKET * tds, TDSCURSOR * cursor) { TDSRET res = TDS_SUCCESS; CHECK_TDS_EXTRA(tds); if (!cursor) return TDS_FAIL; if (!tds_cursor_check_allocated(tds->conn, cursor)) return TDS_SUCCESS; tdsdump_log(TDS_DBG_INFO1, "tds_cursor_dealloc() cursor id = %d\n", cursor->cursor_id); if (IS_TDS50(tds->conn)) { if (tds_set_state(tds, TDS_WRITING) != TDS_WRITING) return TDS_FAIL; tds_set_cur_cursor(tds, cursor); tds->out_flag = TDS_NORMAL; tds_put_byte(tds, TDS_CURCLOSE_TOKEN); tds_put_smallint(tds, 5); /* length of the data stream that follows */ tds_put_int(tds, cursor->cursor_id); /* cursor id returned by the server is available now */ tds_put_byte(tds, 0x01); /* Close option: TDS_CUR_COPT_DEALLOC */ res = tds_query_flush_packet(tds); } /* * in TDS 5 the cursor deallocate function involves * a server interaction. The cursor will be freed * when we receive acknowledgement of the cursor * deallocate from the server. for TDS 7 we do it * here... */ if (IS_TDS7_PLUS(tds->conn)) { if (cursor->status.dealloc == TDS_CURSOR_STATE_SENT || cursor->status.dealloc == TDS_CURSOR_STATE_REQUESTED) { tdsdump_log(TDS_DBG_ERROR, "tds_cursor_dealloc(): freeing cursor \n"); } } return res; } /** * Deallocate cursor on idle. * This let libTDS close the cursor when possible. * \tds * \param cursor cursor to close */ TDSRET tds_deferred_cursor_dealloc(TDSCONNECTION *conn, TDSCURSOR * cursor) { CHECK_CONN_EXTRA(conn); CHECK_CURSOR_EXTRA(cursor); /* do not mark if already deallocated */ if (!tds_cursor_check_allocated(conn, cursor)) return TDS_SUCCESS; cursor->defer_close = 1; conn->pending_close = 1; return TDS_SUCCESS; } /** * Send a string to server while quoting it. * \tds * \param s string start * \param end string end */ static void tds_quote_and_put(TDSSOCKET * tds, const char *s, const char *end) { char buf[256]; int i; CHECK_TDS_EXTRA(tds); for (i = 0; s != end; ++s) { buf[i++] = *s; if (*s == '\'') buf[i++] = '\''; if (i >= 254) { tds_put_string(tds, buf, i); i = 0; } } tds_put_string(tds, buf, i); } /** * Send a parameter to server. * Parameters are converted to string and sent to server. * \tds * \param params parameters structure * \param n number of parameter to send * \returns TDS_FAIL or TDS_SUCCESS */ static TDSRET tds_put_param_as_string(TDSSOCKET * tds, TDSPARAMINFO * params, int n) { TDSCOLUMN *curcol = params->columns[n]; CONV_RESULT cr; TDS_INT res; TDS_CHAR *src = (TDS_CHAR *) curcol->column_data; int src_len = curcol->column_cur_size; int i; char buf[256]; int quote = 0; TDS_CHAR *save_src; int converted = 0; CHECK_TDS_EXTRA(tds); CHECK_PARAMINFO_EXTRA(params); if (src_len < 0) { /* on TDS 4 TEXT/IMAGE cannot be NULL, use empty */ if (!IS_TDS50_PLUS(tds->conn) && is_blob_type(curcol->column_type)) tds_put_string(tds, "''", 2); else tds_put_string(tds, "NULL", 4); return TDS_SUCCESS; } if (is_blob_col(curcol)) src = ((TDSBLOB *)src)->textvalue; save_src = src; /* TODO I don't like copy&paste too much, see above -- freddy77 */ /* convert string if needed */ if (curcol->char_conv && curcol->char_conv->flags != TDS_ENCODING_MEMCPY) { size_t output_size; #if 0 /* TODO this case should be optimized */ /* we know converted bytes */ if (curcol->char_conv->client_charset.min_bytes_per_char == curcol->char_conv->client_charset.max_bytes_per_char && curcol->char_conv->server_charset.min_bytes_per_char == curcol->char_conv->server_charset.max_bytes_per_char) { converted_size = colsize * curcol->char_conv->server_charset.min_bytes_per_char / curcol->char_conv->client_charset.min_bytes_per_char; } else { #endif /* we need to convert data before */ /* TODO this can be a waste of memory... */ converted = 1; src = (TDS_CHAR*) tds_convert_string(tds, curcol->char_conv, src, src_len, &output_size); src_len = (int) output_size; if (!src) /* conversion error, exit with an error */ return TDS_FAIL; } /* we could try to use only tds_convert but is not good in all cases */ switch (curcol->column_type) { /* binary/char, do conversion in line */ case SYBBINARY: case SYBVARBINARY: case SYBIMAGE: case XSYBBINARY: case XSYBVARBINARY: tds_put_n(tds, "0x", 2); for (i=0; src_len; ++src, --src_len) { buf[i++] = tds_hex_digits[*src >> 4 & 0xF]; buf[i++] = tds_hex_digits[*src & 0xF]; if (i == 256) { tds_put_string(tds, buf, i); i = 0; } } tds_put_string(tds, buf, i); break; /* char, quote as necessary */ case SYBNVARCHAR: case SYBNTEXT: case XSYBNCHAR: case XSYBNVARCHAR: tds_put_string(tds, "N", 1); case SYBCHAR: case SYBVARCHAR: case SYBTEXT: case XSYBCHAR: case XSYBVARCHAR: tds_put_string(tds, "\'", 1); tds_quote_and_put(tds, src, src + src_len); tds_put_string(tds, "\'", 1); break; /* TODO date, use iso format */ case SYBDATETIME: case SYBDATETIME4: case SYBDATETIMN: case SYBMSTIME: case SYBMSDATE: case SYBMSDATETIME2: case SYBMSDATETIMEOFFSET: case SYBTIME: case SYBDATE: case SYB5BIGTIME: case SYB5BIGDATETIME: /* TODO use an ISO context */ case SYBUNIQUE: quote = 1; default: res = tds_convert(tds_get_ctx(tds), tds_get_conversion_type(curcol->column_type, curcol->column_size), src, src_len, SYBCHAR, &cr); if (res < 0) { if (converted) tds_convert_string_free(save_src, src); return TDS_FAIL; } if (quote) tds_put_string(tds, "\'", 1); tds_quote_and_put(tds, cr.c, cr.c + res); if (quote) tds_put_string(tds, "\'", 1); free(cr.c); } if (converted) tds_convert_string_free(save_src, src); return TDS_SUCCESS; } /** * Emulate prepared execute traslating to a normal language */ static TDSRET tds_send_emulated_execute(TDSSOCKET * tds, const char *query, TDSPARAMINFO * params) { int num_placeholders, i; const char *s, *e; CHECK_TDS_EXTRA(tds); assert(query); num_placeholders = tds_count_placeholders(query); if (num_placeholders && num_placeholders > params->num_cols) return TDS_FAIL; /* * NOTE: even for TDS5 we use this packet so to avoid computing * entire sql command */ tds_start_query(tds, TDS_QUERY); if (!num_placeholders) { tds_put_string(tds, query, -1); return TDS_SUCCESS; } s = query; for (i = 0;; ++i) { e = tds_next_placeholder(s); tds_put_string(tds, s, (int)(e ? e - s : -1)); if (!e) break; /* now translate parameter in string */ tds_put_param_as_string(tds, params, i); s = e + 1; } return TDS_SUCCESS; } enum { MUL_STARTED = 1 }; TDSRET tds_multiple_init(TDSSOCKET *tds, TDSMULTIPLE *multiple, TDS_MULTIPLE_TYPE type, TDSHEADERS * head) { unsigned char packet_type; multiple->type = type; multiple->flags = 0; if (tds_set_state(tds, TDS_WRITING) != TDS_WRITING) return TDS_FAIL; packet_type = TDS_QUERY; switch (type) { case TDS_MULTIPLE_QUERY: break; case TDS_MULTIPLE_EXECUTE: case TDS_MULTIPLE_RPC: if (IS_TDS7_PLUS(tds->conn)) packet_type = TDS_RPC; break; } if (tds_start_query_head(tds, packet_type, head) != TDS_SUCCESS) return TDS_FAIL; return TDS_SUCCESS; } TDSRET tds_multiple_done(TDSSOCKET *tds, TDSMULTIPLE *multiple) { assert(tds && multiple); return tds_query_flush_packet(tds); } TDSRET tds_multiple_query(TDSSOCKET *tds, TDSMULTIPLE *multiple, const char *query, TDSPARAMINFO * params) { assert(multiple->type == TDS_MULTIPLE_QUERY); if (multiple->flags & MUL_STARTED) tds_put_string(tds, " ", 1); multiple->flags |= MUL_STARTED; return tds_send_emulated_execute(tds, query, params); } TDSRET tds_multiple_execute(TDSSOCKET *tds, TDSMULTIPLE *multiple, TDSDYNAMIC * dyn) { assert(multiple->type == TDS_MULTIPLE_EXECUTE); if (IS_TDS7_PLUS(tds->conn)) { if (multiple->flags & MUL_STARTED) { /* TODO define constant */ tds_put_byte(tds, IS_TDS72_PLUS(tds->conn) ? 0xff : 0x80); } multiple->flags |= MUL_STARTED; tds7_send_execute(tds, dyn); return TDS_SUCCESS; } if (multiple->flags & MUL_STARTED) tds_put_string(tds, " ", 1); multiple->flags |= MUL_STARTED; return tds_send_emulated_execute(tds, dyn->query, dyn->params); } /** * Send option commands to server. * Option commands are used to change server options. * \tds * \param command command type. * \param option option to set/get. * \param param parameter value * \param param_size length of parameter value in bytes */ TDSRET tds_submit_optioncmd(TDSSOCKET * tds, TDS_OPTION_CMD command, TDS_OPTION option, TDS_OPTION_ARG *param, TDS_INT param_size) { char cmd[128]; CHECK_TDS_EXTRA(tds); tdsdump_log(TDS_DBG_FUNC, "tds_submit_optioncmd() \n"); if (IS_TDS50(tds->conn)) { TDSRET rc; if (tds_set_state(tds, TDS_WRITING) != TDS_WRITING) return TDS_FAIL; tds->out_flag = TDS_NORMAL; tds_put_byte(tds, TDS_OPTIONCMD_TOKEN); tds_put_smallint(tds, 3 + param_size); tds_put_byte(tds, command); tds_put_byte(tds, option); tds_put_byte(tds, param_size); if (param_size) tds_put_n(tds, param, param_size); tds_query_flush_packet(tds); rc = tds_process_simple_query(tds); if (TDS_FAILED(rc)) return rc; return TDS_SUCCESS; } if (!IS_TDS7_PLUS(tds->conn)) return TDS_SUCCESS; cmd[0] = 0; if (command == TDS_OPT_SET) { TDSRET rc; char datefmt[4]; switch (option) { case TDS_OPT_ANSINULL : sprintf(cmd, "SET ANSI_NULLS %s", param->ti ? "ON" : "OFF"); break; case TDS_OPT_ARITHABORTON : strcpy(cmd, "SET ARITHABORT ON"); break; case TDS_OPT_ARITHABORTOFF : strcpy(cmd, "SET ARITHABORT OFF"); break; case TDS_OPT_ARITHIGNOREON : strcpy(cmd, "SET ARITHIGNORE ON"); break; case TDS_OPT_ARITHIGNOREOFF : strcpy(cmd, "SET ARITHIGNORE OFF"); break; case TDS_OPT_CHAINXACTS : sprintf(cmd, "SET IMPLICIT_TRANSACTIONS %s", param->ti ? "ON" : "OFF"); break; case TDS_OPT_CURCLOSEONXACT : sprintf(cmd, "SET CURSOR_CLOSE_ON_COMMIT %s", param->ti ? "ON" : "OFF"); break; case TDS_OPT_NOCOUNT : sprintf(cmd, "SET NOCOUNT %s", param->ti ? "ON" : "OFF"); break; case TDS_OPT_QUOTED_IDENT : sprintf(cmd, "SET QUOTED_IDENTIFIER %s", param->ti ? "ON" : "OFF"); break; case TDS_OPT_TRUNCABORT : sprintf(cmd, "SET ANSI_WARNINGS %s", param->ti ? "OFF" : "ON"); break; case TDS_OPT_DATEFIRST : sprintf(cmd, "SET DATEFIRST %d", param->ti); break; case TDS_OPT_DATEFORMAT : switch (param->ti) { case TDS_OPT_FMTDMY: strcpy(datefmt,"dmy"); break; case TDS_OPT_FMTDYM: strcpy(datefmt,"dym"); break; case TDS_OPT_FMTMDY: strcpy(datefmt,"mdy"); break; case TDS_OPT_FMTMYD: strcpy(datefmt,"myd"); break; case TDS_OPT_FMTYDM: strcpy(datefmt,"ydm"); break; case TDS_OPT_FMTYMD: strcpy(datefmt,"ymd"); break; } sprintf(cmd, "SET DATEFORMAT %s", datefmt); break; case TDS_OPT_TEXTSIZE: sprintf(cmd, "SET TEXTSIZE %d", (int) param->i); break; /* TODO */ case TDS_OPT_STAT_TIME: case TDS_OPT_STAT_IO: case TDS_OPT_ROWCOUNT: case TDS_OPT_NATLANG: case TDS_OPT_ISOLATION: case TDS_OPT_AUTHON: case TDS_OPT_CHARSET: case TDS_OPT_SHOWPLAN: case TDS_OPT_NOEXEC: case TDS_OPT_PARSEONLY: case TDS_OPT_GETDATA: case TDS_OPT_FORCEPLAN: case TDS_OPT_FORMATONLY: case TDS_OPT_FIPSFLAG: case TDS_OPT_RESTREES: case TDS_OPT_IDENTITYON: case TDS_OPT_CURREAD: case TDS_OPT_CURWRITE: case TDS_OPT_IDENTITYOFF: case TDS_OPT_AUTHOFF: break; } tds_submit_query(tds, cmd); rc = tds_process_simple_query(tds); if (TDS_FAILED(rc)) return rc; } if (command == TDS_OPT_LIST) { int optionval = 0; TDS_INT resulttype; switch (option) { case TDS_OPT_ANSINULL : case TDS_OPT_ARITHABORTON : case TDS_OPT_ARITHABORTOFF : case TDS_OPT_ARITHIGNOREON : case TDS_OPT_ARITHIGNOREOFF : case TDS_OPT_CHAINXACTS : case TDS_OPT_CURCLOSEONXACT : case TDS_OPT_NOCOUNT : case TDS_OPT_QUOTED_IDENT : case TDS_OPT_TRUNCABORT : tdsdump_log(TDS_DBG_FUNC, "SELECT @@options\n"); strcpy(cmd, "SELECT @@options"); break; case TDS_OPT_DATEFIRST : strcpy(cmd, "SELECT @@datefirst"); break; case TDS_OPT_DATEFORMAT : strcpy(cmd, "SELECT DATEPART(dy,'01/02/03')"); break; case TDS_OPT_TEXTSIZE: strcpy(cmd, "SELECT @@textsize"); break; /* TODO */ case TDS_OPT_STAT_TIME: case TDS_OPT_STAT_IO: case TDS_OPT_ROWCOUNT: case TDS_OPT_NATLANG: case TDS_OPT_ISOLATION: case TDS_OPT_AUTHON: case TDS_OPT_CHARSET: case TDS_OPT_SHOWPLAN: case TDS_OPT_NOEXEC: case TDS_OPT_PARSEONLY: case TDS_OPT_GETDATA: case TDS_OPT_FORCEPLAN: case TDS_OPT_FORMATONLY: case TDS_OPT_FIPSFLAG: case TDS_OPT_RESTREES: case TDS_OPT_IDENTITYON: case TDS_OPT_CURREAD: case TDS_OPT_CURWRITE: case TDS_OPT_IDENTITYOFF: case TDS_OPT_AUTHOFF: default: tdsdump_log(TDS_DBG_FUNC, "what!\n"); } tds_submit_query(tds, cmd); while (tds_process_tokens(tds, &resulttype, NULL, TDS_TOKEN_RESULTS) == TDS_SUCCESS) { switch (resulttype) { case TDS_ROWFMT_RESULT: break; case TDS_ROW_RESULT: while (tds_process_tokens(tds, &resulttype, NULL, TDS_STOPAT_ROWFMT|TDS_RETURN_DONE|TDS_RETURN_ROW) == TDS_SUCCESS) { TDSCOLUMN *col; CONV_RESULT dres; int ctype; unsigned char* src; int srclen; if (resulttype != TDS_ROW_RESULT) break; if (!tds->current_results) continue; col = tds->current_results->columns[0]; ctype = tds_get_conversion_type(col->column_type, col->column_size); src = col->column_data; srclen = col->column_cur_size; tds_convert(tds_get_ctx(tds), ctype, (TDS_CHAR *) src, srclen, SYBINT4, &dres); optionval = dres.i; } break; default: break; } } tdsdump_log(TDS_DBG_FUNC, "optionval = %d\n", optionval); switch (option) { case TDS_OPT_CHAINXACTS : tds->option_value = (optionval & 0x02) > 0; break; case TDS_OPT_CURCLOSEONXACT : tds->option_value = (optionval & 0x04) > 0; break; case TDS_OPT_TRUNCABORT : tds->option_value = (optionval & 0x08) > 0; break; case TDS_OPT_ANSINULL : tds->option_value = (optionval & 0x20) > 0; break; case TDS_OPT_ARITHABORTON : tds->option_value = (optionval & 0x40) > 0; break; case TDS_OPT_ARITHABORTOFF : tds->option_value = (optionval & 0x40) > 0; break; case TDS_OPT_ARITHIGNOREON : tds->option_value = (optionval & 0x80) > 0; break; case TDS_OPT_ARITHIGNOREOFF : tds->option_value = (optionval & 0x80) > 0; break; case TDS_OPT_QUOTED_IDENT : tds->option_value = (optionval & 0x0100) > 0; break; case TDS_OPT_NOCOUNT : tds->option_value = (optionval & 0x0200) > 0; break; case TDS_OPT_TEXTSIZE: case TDS_OPT_DATEFIRST : tds->option_value = optionval; break; case TDS_OPT_DATEFORMAT : switch (optionval) { case 61: tds->option_value = TDS_OPT_FMTYDM; break; case 34: tds->option_value = TDS_OPT_FMTYMD; break; case 32: tds->option_value = TDS_OPT_FMTDMY; break; case 60: tds->option_value = TDS_OPT_FMTYDM; break; case 2: tds->option_value = TDS_OPT_FMTMDY; break; case 3: tds->option_value = TDS_OPT_FMTMYD; break; } break; /* TODO */ case TDS_OPT_STAT_TIME: case TDS_OPT_STAT_IO: case TDS_OPT_ROWCOUNT: case TDS_OPT_NATLANG: case TDS_OPT_ISOLATION: case TDS_OPT_AUTHON: case TDS_OPT_CHARSET: case TDS_OPT_SHOWPLAN: case TDS_OPT_NOEXEC: case TDS_OPT_PARSEONLY: case TDS_OPT_GETDATA: case TDS_OPT_FORCEPLAN: case TDS_OPT_FORMATONLY: case TDS_OPT_FIPSFLAG: case TDS_OPT_RESTREES: case TDS_OPT_IDENTITYON: case TDS_OPT_CURREAD: case TDS_OPT_CURWRITE: case TDS_OPT_IDENTITYOFF: case TDS_OPT_AUTHOFF: break; } tdsdump_log(TDS_DBG_FUNC, "tds_submit_optioncmd: returned option_value = %d\n", tds->option_value); } return TDS_SUCCESS; } /** * Send a rollback request. * TDS 7.2+ need this in order to handle transactions correctly if MARS is used. * \tds * \sa tds_submit_commit, tds_submit_rollback */ TDSRET tds_submit_begin_tran(TDSSOCKET *tds) { CHECK_TDS_EXTRA(tds); if (!IS_TDS72_PLUS(tds->conn)) return tds_submit_query(tds, "BEGIN TRANSACTION"); if (tds_set_state(tds, TDS_WRITING) != TDS_WRITING) return TDS_FAIL; tds_start_query(tds, TDS7_TRANS); /* begin transaction */ tds_put_smallint(tds, 5); tds_put_byte(tds, 0); /* new transaction level TODO */ tds_put_byte(tds, 0); /* new transaction name */ return tds_query_flush_packet(tds); } /** * Send a rollback request. * TDS 7.2+ need this in order to handle transactions correctly if MARS is used. * \tds * \param cont true to start a new transaction * \sa tds_submit_begin_tran, tds_submit_commit */ TDSRET tds_submit_rollback(TDSSOCKET *tds, int cont) { CHECK_TDS_EXTRA(tds); if (!IS_TDS72_PLUS(tds->conn)) return tds_submit_query(tds, cont ? "IF @@TRANCOUNT > 0 ROLLBACK BEGIN TRANSACTION" : "IF @@TRANCOUNT > 0 ROLLBACK"); if (tds_set_state(tds, TDS_WRITING) != TDS_WRITING) return TDS_FAIL; tds_start_query(tds, TDS7_TRANS); tds_put_smallint(tds, 8); /* rollback */ tds_put_byte(tds, 0); /* name */ if (cont) { tds_put_byte(tds, 1); tds_put_byte(tds, 0); /* new transaction level TODO */ tds_put_byte(tds, 0); /* new transaction name */ } else { tds_put_byte(tds, 0); /* do not continue */ } return tds_query_flush_packet(tds); } /** * Send a commit request. * TDS 7.2+ need this in order to handle transactions correctly if MARS is used. * \tds * \param cont true to start a new transaction * \sa tds_submit_rollback, tds_submit_begin_tran */ TDSRET tds_submit_commit(TDSSOCKET *tds, int cont) { CHECK_TDS_EXTRA(tds); if (!IS_TDS72_PLUS(tds->conn)) return tds_submit_query(tds, cont ? "IF @@TRANCOUNT > 0 COMMIT BEGIN TRANSACTION" : "IF @@TRANCOUNT > 0 COMMIT"); if (tds_set_state(tds, TDS_WRITING) != TDS_WRITING) return TDS_FAIL; tds_start_query(tds, TDS7_TRANS); tds_put_smallint(tds, 7); /* commit */ tds_put_byte(tds, 0); /* name */ if (cont) { tds_put_byte(tds, 1); tds_put_byte(tds, 0); /* new transaction level TODO */ tds_put_byte(tds, 0); /* new transaction name */ } else { tds_put_byte(tds, 0); /* do not continue */ } return tds_query_flush_packet(tds); } static const TDSCONTEXT empty_ctx = {0}; TDSRET tds_disconnect(TDSSOCKET * tds) { TDS_INT old_timeout; const TDSCONTEXT *old_ctx; CHECK_TDS_EXTRA(tds); tdsdump_log(TDS_DBG_FUNC, "tds_disconnect() \n"); if (!IS_TDS50(tds->conn)) return TDS_SUCCESS; old_timeout = tds->query_timeout; old_ctx = tds_get_ctx(tds); /* avoid to stall forever */ tds->query_timeout = 5; /* do not report errors to upper libraries */ tds_set_ctx(tds, &empty_ctx); if (tds_set_state(tds, TDS_WRITING) != TDS_WRITING) { tds->query_timeout = old_timeout; tds_set_ctx(tds, old_ctx); return TDS_FAIL; } tds->out_flag = TDS_NORMAL; tds_put_byte(tds, TDS_LOGOUT_TOKEN); tds_put_byte(tds, 0); tds_query_flush_packet(tds); return tds_process_simple_query(tds); } /* * TODO add function to return type suitable for param * ie: * sybvarchar -> sybvarchar / xsybvarchar * sybint4 -> sybintn */ /** @} */ freetds-1.00.82/src/tds/iconv.c100644 025423 025423 00000101473 12717145107 0011704/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns * Copyright (C) 2010 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /** * \file * \brief Handle character conversions to/from server */ #include #include #include #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_ERRNO_H #include #endif #include #include #if HAVE_ICONV #include #endif #define CHARSIZE(charset) ( ((charset)->min_bytes_per_char == (charset)->max_bytes_per_char )? \ (charset)->min_bytes_per_char : 0 ) static int collate2charset(int sql_collate, int lcid); static size_t skip_one_input_sequence(iconv_t cd, const TDS_ENCODING * charset, const char **input, size_t * input_size); static int tds_iconv_info_init(TDSICONV * char_conv, int client_canonic, int server_canonic); static int tds_iconv_init(void); static int tds_canonical_charset(const char *charset_name); static void _iconv_close(iconv_t * cd); static void tds_iconv_info_close(TDSICONV * char_conv); /** * \ingroup libtds * \defgroup conv Charset conversion * Convert between different charsets. */ #define TDS_ICONV_ENCODING_TABLES #include "encodings.h" /* this will contain real iconv names */ static const char *iconv_names[sizeof(canonic_charsets) / sizeof(canonic_charsets[0])]; static int iconv_initialized = 0; static const char *ucs2name; enum { POS_ISO1, POS_UTF8, POS_UCS2LE, POS_UCS2BE }; /** * Initialize charset searching for UTF-8, UCS-2 and ISO8859-1 */ static int tds_iconv_init(void) { int i; iconv_t cd; /* first entries should be constants */ assert(strcmp(canonic_charsets[POS_ISO1].name, "ISO-8859-1") == 0); assert(strcmp(canonic_charsets[POS_UTF8].name, "UTF-8") == 0); assert(strcmp(canonic_charsets[POS_UCS2LE].name, "UCS-2LE") == 0); assert(strcmp(canonic_charsets[POS_UCS2BE].name, "UCS-2BE") == 0); /* fast tests for GNU-iconv */ cd = tds_sys_iconv_open("ISO-8859-1", "UTF-8"); if (cd != (iconv_t) -1) { iconv_names[POS_ISO1] = "ISO-8859-1"; iconv_names[POS_UTF8] = "UTF-8"; tds_sys_iconv_close(cd); } else { /* search names for ISO8859-1 and UTF-8 */ for (i = 0; iconv_aliases[i].alias; ++i) { int j; if (iconv_aliases[i].canonic != POS_ISO1) continue; for (j = 0; iconv_aliases[j].alias; ++j) { if (iconv_aliases[j].canonic != POS_UTF8) continue; cd = tds_sys_iconv_open(iconv_aliases[i].alias, iconv_aliases[j].alias); if (cd != (iconv_t) -1) { iconv_names[POS_ISO1] = iconv_aliases[i].alias; iconv_names[POS_UTF8] = iconv_aliases[j].alias; tds_sys_iconv_close(cd); break; } } if (iconv_names[POS_ISO1]) break; } /* required characters not found !!! */ if (!iconv_names[POS_ISO1]) return 1; } /* now search for UCS-2 */ cd = tds_sys_iconv_open(iconv_names[POS_ISO1], "UCS-2LE"); if (cd != (iconv_t) -1) { iconv_names[POS_UCS2LE] = "UCS-2LE"; tds_sys_iconv_close(cd); } cd = tds_sys_iconv_open(iconv_names[POS_ISO1], "UCS-2BE"); if (cd != (iconv_t) -1) { iconv_names[POS_UCS2BE] = "UCS-2BE"; tds_sys_iconv_close(cd); } /* long search needed ?? */ if (!iconv_names[POS_UCS2LE] || !iconv_names[POS_UCS2BE]) { for (i = 0; iconv_aliases[i].alias; ++i) { if (strncmp(canonic_charsets[iconv_aliases[i].canonic].name, "UCS-2", 5) != 0) continue; cd = tds_sys_iconv_open(iconv_aliases[i].alias, iconv_names[POS_ISO1]); if (cd != (iconv_t) -1) { char ib[1]; char ob[4]; size_t il, ol; ICONV_CONST char *pib; char *pob; int byte_sequence = 0; /* try to convert 'A' and check result */ ib[0] = 0x41; pib = ib; pob = ob; il = 1; ol = 4; ob[0] = ob[1] = 0; if (tds_sys_iconv(cd, &pib, &il, &pob, &ol) != (size_t) - 1) { /* byte order sequence ?? */ if (ol == 0) { ob[0] = ob[2]; byte_sequence = 1; /* TODO save somewhere */ } /* save name without sequence (if present) */ if (ob[0]) il = POS_UCS2LE; else il = POS_UCS2BE; if (!iconv_names[il] || !byte_sequence) iconv_names[il] = iconv_aliases[i].alias; } tds_sys_iconv_close(cd); } } } /* we need a UCS-2 (big endian or little endian) */ if (!iconv_names[POS_UCS2LE] && !iconv_names[POS_UCS2BE]) return 2; ucs2name = iconv_names[POS_UCS2LE] ? iconv_names[POS_UCS2LE] : iconv_names[POS_UCS2BE]; for (i = 0; i < 4; ++i) tdsdump_log(TDS_DBG_INFO1, "local name for %s is %s\n", canonic_charsets[i].name, iconv_names[i] ? iconv_names[i] : "(null)"); /* success (it should always occurs) */ return 0; } /** * Get iconv name given canonic */ static const char * tds_set_iconv_name(int charset) { int i; iconv_t cd; assert(iconv_initialized); /* try using canonic name and UTF-8 and UCS2 */ cd = tds_sys_iconv_open(iconv_names[POS_UTF8], canonic_charsets[charset].name); if (cd != (iconv_t) -1) { iconv_names[charset] = canonic_charsets[charset].name; tds_sys_iconv_close(cd); return iconv_names[charset]; } cd = tds_sys_iconv_open(ucs2name, canonic_charsets[charset].name); if (cd != (iconv_t) -1) { iconv_names[charset] = canonic_charsets[charset].name; tds_sys_iconv_close(cd); return iconv_names[charset]; } /* try all alternatives */ for (i = 0; iconv_aliases[i].alias; ++i) { if (iconv_aliases[i].canonic != charset) continue; cd = tds_sys_iconv_open(iconv_names[POS_UTF8], iconv_aliases[i].alias); if (cd != (iconv_t) -1) { iconv_names[charset] = iconv_aliases[i].alias; tds_sys_iconv_close(cd); return iconv_names[charset]; } cd = tds_sys_iconv_open(ucs2name, iconv_aliases[i].alias); if (cd != (iconv_t) -1) { iconv_names[charset] = iconv_aliases[i].alias; tds_sys_iconv_close(cd); return iconv_names[charset]; } } /* charset not found, pretend it's ISO 8859-1 */ iconv_names[charset] = canonic_charsets[POS_ISO1].name; return NULL; } static void tds_iconv_reset(TDSICONV *conv) { /* * (min|max)_bytes_per_char can be used to divide * so init to safe values */ conv->to.charset.min_bytes_per_char = 1; conv->to.charset.max_bytes_per_char = 1; conv->from.charset.min_bytes_per_char = 1; conv->from.charset.max_bytes_per_char = 1; conv->to.charset.name = conv->from.charset.name = ""; conv->to.charset.canonic = conv->from.charset.canonic = 0; conv->to.cd = (iconv_t) -1; conv->from.cd = (iconv_t) -1; } /** * Allocate iconv stuff * \return 0 for success */ int tds_iconv_alloc(TDSCONNECTION * conn) { int i; TDSICONV *char_conv; assert(!conn->char_convs); if (!(conn->char_convs = tds_new(TDSICONV *, initial_char_conv_count + 1))) return 1; char_conv = tds_new0(TDSICONV, initial_char_conv_count); if (!char_conv) { TDS_ZERO_FREE(conn->char_convs); return 1; } conn->char_conv_count = initial_char_conv_count + 1; for (i = 0; i < initial_char_conv_count; ++i) { conn->char_convs[i] = &char_conv[i]; tds_iconv_reset(&char_conv[i]); } /* chardata is just a pointer to another iconv info */ conn->char_convs[initial_char_conv_count] = conn->char_convs[client2server_chardata]; return 0; } /** * \addtogroup conv * @{ * Set up the initial iconv conversion descriptors. * When the socket is allocated, three TDSICONV structures are attached to iconv. * They have fixed meanings: * \li 0. Client <-> UCS-2 (client2ucs2) * \li 1. Client <-> server single-byte charset (client2server_chardata) * * Other designs that use less data are possible, but these three conversion needs are * very often needed. By reserving them, we avoid searching the array for our most common purposes. * * To solve different iconv names and portability problems FreeTDS maintains * a list of aliases each charset. * * First we discover the names of our minimum required charsets (UTF-8, ISO8859-1 and UCS2). * Later, as and when it's needed, we try to discover others. * * There is one list of canonic names (GNU iconv names) and two sets of aliases * (one for other iconv implementations and another for Sybase). For every * canonic charset name we cache the iconv name found during discovery. */ TDSRET tds_iconv_open(TDSCONNECTION * conn, const char *charset, int use_utf16) { static const char UCS_2LE[] = "UCS-2LE"; int canonic; int canonic_charset = tds_canonical_charset(charset); int canonic_env_charset = conn->env.charset ? tds_canonical_charset(conn->env.charset) : -1; int fOK, ret; TDS_ENCODING *client = &conn->char_convs[client2ucs2]->from.charset; TDS_ENCODING *server = &conn->char_convs[client2ucs2]->to.charset; tdsdump_log(TDS_DBG_FUNC, "tds_iconv_open(%p, %s)\n", conn, charset); /* initialize */ if (!iconv_initialized) { if ((ret = tds_iconv_init()) > 0) { static const char names[][12] = { "ISO 8859-1", "UTF-8" }; assert(ret < 3); tdsdump_log(TDS_DBG_FUNC, "error: tds_iconv_init() returned %d; " "could not find a name for %s that your iconv accepts.\n" "use: \"configure --disable-libiconv\"", ret, names[ret-1]); return TDS_FAIL; } iconv_initialized = 1; } /* * Client <-> UCS-2 (client2ucs2) */ tdsdump_log(TDS_DBG_FUNC, "setting up conversions for client charset \"%s\"\n", charset); tdsdump_log(TDS_DBG_FUNC, "preparing iconv for \"%s\" <-> \"%s\" conversion\n", charset, UCS_2LE); fOK = 0; if (use_utf16) { canonic = TDS_CHARSET_UTF_16LE; fOK = tds_iconv_info_init(conn->char_convs[client2ucs2], canonic_charset, canonic); } if (!fOK) { canonic = TDS_CHARSET_UCS_2LE; fOK = tds_iconv_info_init(conn->char_convs[client2ucs2], canonic_charset, canonic); } if (!fOK) return TDS_FAIL; /* * How many UTF-8 bytes we need is a function of what the input character set is. * TODO This could definitely be more sophisticated, but it deals with the common case. */ if (client->min_bytes_per_char == 1 && client->max_bytes_per_char == 4 && server->max_bytes_per_char == 1) { /* ie client is UTF-8 and server is ISO-8859-1 or variant. */ client->max_bytes_per_char = 3; } /* * Client <-> server single-byte charset * TODO: the server hasn't reported its charset yet, so this logic can't work here. * not sure what to do about that yet. */ conn->char_convs[client2server_chardata]->flags = TDS_ENCODING_MEMCPY; if (canonic_env_charset >= 0) { tdsdump_log(TDS_DBG_FUNC, "preparing iconv for \"%s\" <-> \"%s\" conversion\n", charset, conn->env.charset); fOK = tds_iconv_info_init(conn->char_convs[client2server_chardata], canonic_charset, canonic_env_charset); if (!fOK) return TDS_FAIL; } else { conn->char_convs[client2server_chardata]->from.charset = canonic_charsets[canonic_charset]; conn->char_convs[client2server_chardata]->to.charset = canonic_charsets[canonic_charset]; } tdsdump_log(TDS_DBG_FUNC, "tds_iconv_open: done\n"); return TDS_SUCCESS; } /** * Open iconv descriptors to convert between character sets (both directions). * 1. Look up the canonical names of the character sets. * 2. Look up their widths. * 3. Ask iconv to open a conversion descriptor. * 4. Fail if any of the above offer any resistance. * \remarks The charset names written to \a iconv will be the canonical names, * not necessarily the names passed in. */ static int tds_iconv_info_init(TDSICONV * char_conv, int client_canonical, int server_canonical) { TDS_ENCODING *client = &char_conv->from.charset; TDS_ENCODING *server = &char_conv->to.charset; assert(char_conv->to.cd == (iconv_t) -1); assert(char_conv->from.cd == (iconv_t) -1); if (client_canonical < 0) { tdsdump_log(TDS_DBG_FUNC, "tds_iconv_info_init: client charset name \"%d\" invalid\n", client_canonical); return 0; } if (server_canonical < 0) { tdsdump_log(TDS_DBG_FUNC, "tds_iconv_info_init: server charset name \"%d\" invalid\n", server_canonical); return 0; } *client = canonic_charsets[client_canonical]; *server = canonic_charsets[server_canonical]; /* special case, same charset, no conversion */ if (client_canonical == server_canonical) { char_conv->to.cd = (iconv_t) -1; char_conv->from.cd = (iconv_t) -1; char_conv->flags = TDS_ENCODING_MEMCPY; return 1; } char_conv->flags = 0; /* get iconv names */ if (!iconv_names[client_canonical]) { if (!tds_set_iconv_name(client_canonical)) { tdsdump_log(TDS_DBG_FUNC, "Charset %d not supported by iconv, using \"%s\" instead\n", client_canonical, iconv_names[client_canonical]); } } if (!iconv_names[server_canonical]) { if (!tds_set_iconv_name(server_canonical)) { tdsdump_log(TDS_DBG_FUNC, "Charset %d not supported by iconv, using \"%s\" instead\n", server_canonical, iconv_names[server_canonical]); } } char_conv->to.cd = tds_sys_iconv_open(iconv_names[server_canonical], iconv_names[client_canonical]); if (char_conv->to.cd == (iconv_t) -1) { tdsdump_log(TDS_DBG_FUNC, "tds_iconv_info_init: cannot convert \"%s\"->\"%s\"\n", client->name, server->name); } char_conv->from.cd = tds_sys_iconv_open(iconv_names[client_canonical], iconv_names[server_canonical]); if (char_conv->from.cd == (iconv_t) -1) { tdsdump_log(TDS_DBG_FUNC, "tds_iconv_info_init: cannot convert \"%s\"->\"%s\"\n", server->name, client->name); } /* TODO, do some optimizations like UCS2 -> UTF8 min,max = 2,2 (UCS2) and 1,4 (UTF8) */ /* tdsdump_log(TDS_DBG_FUNC, "tds_iconv_info_init: converting \"%s\"->\"%s\"\n", client->name, server->name); */ return 1; } static void _iconv_close(iconv_t * cd) { static const iconv_t invalid = (iconv_t) -1; if (*cd != invalid) { tds_sys_iconv_close(*cd); *cd = invalid; } } static void tds_iconv_info_close(TDSICONV * char_conv) { _iconv_close(&char_conv->to.cd); _iconv_close(&char_conv->from.cd); } void tds_iconv_close(TDSCONNECTION * conn) { int i; for (i = 0; i < conn->char_conv_count; ++i) tds_iconv_info_close(conn->char_convs[i]); } #define CHUNK_ALLOC 4 void tds_iconv_free(TDSCONNECTION * conn) { int i; if (!conn->char_convs) return; tds_iconv_close(conn); free(conn->char_convs[0]); for (i = initial_char_conv_count + 1; i < conn->char_conv_count; i += CHUNK_ALLOC) free(conn->char_convs[i]); TDS_ZERO_FREE(conn->char_convs); conn->char_conv_count = 0; } static void tds_iconv_err(TDSSOCKET *tds, int err) { if (tds) tdserror(tds_get_ctx(tds), tds, err, 0); } /** * Wrapper around iconv(3). Same parameters, with slightly different behavior. * \param tds state information for the socket and the TDS protocol * \param io Enumerated value indicating whether the data are being sent to or received from the server. * \param conv information about the encodings involved, including the iconv(3) conversion descriptors. * \param inbuf address of pointer to the input buffer of data to be converted. * \param inbytesleft address of count of bytes in \a inbuf. * \param outbuf address of pointer to the output buffer. * \param outbytesleft address of count of bytes in \a outbuf. * \retval number of irreversible conversions performed. -1 on error, see iconv(3) documentation for * a description of the possible values of \e errno. * \remarks Unlike iconv(3), none of the arguments can be nor point to NULL. Like iconv(3), all pointers will * be updated. Success is signified by a nonnegative return code and \a *inbytesleft == 0. * If the conversion descriptor in \a iconv is -1 or NULL, \a inbuf is copied to \a outbuf, * and all parameters updated accordingly. * * If a character in \a inbuf cannot be converted because no such cbaracter exists in the * \a outbuf character set, we emit messages similar to the ones Sybase emits when it fails such a conversion. * The message varies depending on the direction of the data. * On a read error, we emit Msg 2403, Severity 16 (EX_INFO): * "WARNING! Some character(s) could not be converted into client's character set. * Unconverted bytes were changed to question marks ('?')." * On a write error we emit Msg 2402, Severity 16 (EX_USER): * "Error converting client characters into server's character set. Some character(s) could not be converted." * and return an error code. Client libraries relying on this routine should reflect an error back to the application. * * \todo Check for variable multibyte non-UTF-8 input character set. * \todo Use more robust error message generation. * \todo For reads, cope with \a outbuf encodings that don't have the equivalent of an ASCII '?'. * \todo Support alternative to '?' for the replacement character. */ size_t tds_iconv(TDSSOCKET * tds, TDSICONV * conv, TDS_ICONV_DIRECTION io, const char **inbuf, size_t * inbytesleft, char **outbuf, size_t * outbytesleft) { static const iconv_t invalid = (iconv_t) -1; TDSICONVDIR *from = NULL; TDSICONVDIR *to = NULL; iconv_t error_cd = invalid; char quest_mark[] = "?"; /* best to leave non-const; implementations vary */ ICONV_CONST char *pquest_mark = quest_mark; size_t lquest_mark; size_t irreversible; size_t one_character; int eilseq_raised = 0; int conv_errno; /* cast away const-ness */ TDS_ERRNO_MESSAGE_FLAGS *suppress = (TDS_ERRNO_MESSAGE_FLAGS*) &conv->suppress; assert(inbuf && inbytesleft && outbuf && outbytesleft); /* if empty there's nothing to return. * This fix case with some iconv implementation that does * not handle *inbuf == NULL and *inbytesleft == 0 as * empty strings */ if (*inbytesleft == 0) return 0; switch (io) { case to_server: from = &conv->from; to = &conv->to; break; case to_client: from = &conv->to; to = &conv->from; break; default: tdsdump_log(TDS_DBG_FUNC, "tds_iconv: unable to determine if %d means in or out. \n", io); assert(io == to_server || io == to_client); break; } /* silly case, memcpy */ if (conv->flags & TDS_ENCODING_MEMCPY || to->cd == invalid) { size_t len = *inbytesleft < *outbytesleft ? *inbytesleft : *outbytesleft; memcpy(*outbuf, *inbuf, len); errno = *inbytesleft > *outbytesleft ? E2BIG : 0; *inbytesleft -= len; *outbytesleft -= len; *inbuf += len; *outbuf += len; return 0; } /* * Call iconv() as many times as necessary, until we reach the end of input or exhaust output. */ for (;;) { conv_errno = 0; irreversible = tds_sys_iconv(to->cd, (ICONV_CONST char **) inbuf, inbytesleft, outbuf, outbytesleft); /* iconv success, return */ if (irreversible != (size_t) - 1) { /* here we detect end of conversion and try to reset shift state */ if (inbuf) { /* * if inbuf or *inbuf is NULL iconv reset the shift state. * Note that setting inbytesleft to NULL can cause core so don't do it! */ inbuf = NULL; continue; } break; } /* save errno, other function could change its value */ conv_errno = errno; if (conv_errno == EILSEQ) eilseq_raised = 1; if (conv_errno != EILSEQ || io != to_client || !inbuf) break; /* * Invalid input sequence encountered reading from server. * Skip one input sequence, adjusting pointers. */ one_character = skip_one_input_sequence(to->cd, &from->charset, inbuf, inbytesleft); if (!one_character) break; /* * To replace invalid input with '?', we have to convert a UTF-8 '?' into the output character set. * In unimaginably weird circumstances, this might be impossible. * We use UTF-8 instead of ASCII because some implementations * do not convert singlebyte <-> singlebyte. */ if (error_cd == invalid) { error_cd = tds_sys_iconv_open(to->charset.name, iconv_names[POS_UTF8]); if (error_cd == invalid) { break; /* what to do? */ } } lquest_mark = 1; pquest_mark = quest_mark; irreversible = tds_sys_iconv(error_cd, &pquest_mark, &lquest_mark, outbuf, outbytesleft); if (irreversible == (size_t) - 1) break; if (!*inbytesleft) break; } if (eilseq_raised && !suppress->eilseq) { /* invalid multibyte input sequence encountered */ if (io == to_client) { if (irreversible == (size_t) - 1) { tds_iconv_err(tds, TDSEICONV2BIG); } else { tds_iconv_err(tds, TDSEICONVI); conv_errno = 0; } } else { tds_iconv_err(tds, TDSEICONVO); } suppress->eilseq = 1; } switch (conv_errno) { case EINVAL: /* incomplete multibyte sequence is encountered */ if (suppress->einval) break; /* in chunk conversion this can mean we end a chunk inside a character */ tds_iconv_err(tds, TDSEICONVAVAIL); suppress->einval = 1; break; case E2BIG: /* output buffer has no more room */ if (suppress->e2big) break; tds_iconv_err(tds, TDSEICONVIU); suppress->e2big = 1; break; default: break; } if (error_cd != invalid) { tds_sys_iconv_close(error_cd); } errno = conv_errno; return irreversible; } /** * Get a iconv info structure, allocate and initialize if needed */ static TDSICONV * tds_iconv_get_info(TDSCONNECTION * conn, int canonic_client, int canonic_server) { TDSICONV *info; int i; /* search a charset from already allocated charsets */ for (i = conn->char_conv_count; --i >= initial_char_conv_count;) if (canonic_client == conn->char_convs[i]->from.charset.canonic && canonic_server == conn->char_convs[i]->to.charset.canonic) return conn->char_convs[i]; /* allocate a new iconv structure */ if (conn->char_conv_count % CHUNK_ALLOC == ((initial_char_conv_count + 1) % CHUNK_ALLOC)) { TDSICONV **p; TDSICONV *infos; infos = tds_new(TDSICONV, CHUNK_ALLOC); if (!infos) return NULL; p = (TDSICONV **) realloc(conn->char_convs, sizeof(TDSICONV *) * (conn->char_conv_count + CHUNK_ALLOC)); if (!p) { free(infos); return NULL; } conn->char_convs = p; memset(infos, 0, sizeof(TDSICONV) * CHUNK_ALLOC); for (i = 0; i < CHUNK_ALLOC; ++i) { conn->char_convs[i + conn->char_conv_count] = &infos[i]; tds_iconv_reset(&infos[i]); } } info = conn->char_convs[conn->char_conv_count++]; /* init */ if (tds_iconv_info_init(info, canonic_client, canonic_server)) return info; tds_iconv_info_close(info); --conn->char_conv_count; return NULL; } TDSICONV * tds_iconv_get(TDSCONNECTION * conn, const char *client_charset, const char *server_charset) { int canonic_client_charset_num = tds_canonical_charset(client_charset); int canonic_server_charset_num = tds_canonical_charset(server_charset); if (canonic_client_charset_num < 0) { tdsdump_log(TDS_DBG_FUNC, "tds_iconv_get: what is charset \"%s\"?\n", client_charset); return NULL; } if (canonic_server_charset_num < 0) { tdsdump_log(TDS_DBG_FUNC, "tds_iconv_get: what is charset \"%s\"?\n", server_charset); return NULL; } return tds_iconv_get_info(conn, canonic_client_charset_num, canonic_server_charset_num); } /* change singlebyte conversions according to server */ static void tds_srv_charset_changed_num(TDSCONNECTION * conn, int canonic_charset_num) { TDSICONV *char_conv = conn->char_convs[client2server_chardata]; if (IS_TDS7_PLUS(conn) && canonic_charset_num == TDS_CHARSET_ISO_8859_1) canonic_charset_num = TDS_CHARSET_CP1252; tdsdump_log(TDS_DBG_FUNC, "setting server single-byte charset to \"%s\"\n", canonic_charsets[canonic_charset_num].name); if (canonic_charset_num == char_conv->to.charset.canonic) return; /* find and set conversion */ char_conv = tds_iconv_get_info(conn, conn->char_convs[client2ucs2]->from.charset.canonic, canonic_charset_num); if (char_conv) conn->char_convs[client2server_chardata] = char_conv; } void tds_srv_charset_changed(TDSCONNECTION * conn, const char *charset) { int n = tds_canonical_charset(charset); /* ignore request to change to unknown charset */ if (n < 0) { tdsdump_log(TDS_DBG_FUNC, "tds_srv_charset_changed: what is charset \"%s\"?\n", charset); return; } tds_srv_charset_changed_num(conn, n); } /* change singlebyte conversions according to server */ void tds7_srv_charset_changed(TDSCONNECTION * conn, int sql_collate, int lcid) { tds_srv_charset_changed_num(conn, collate2charset(sql_collate, lcid)); } /** * Move the input sequence pointer to the next valid position. * Used when an input character cannot be converted. * \returns number of bytes to skip. */ /* FIXME possible buffer reading overflow ?? */ static size_t skip_one_input_sequence(iconv_t cd, const TDS_ENCODING * charset, const char **input, size_t * input_size) { unsigned charsize = CHARSIZE(charset); char ib[16]; char ob[16]; ICONV_CONST char *pib; char *pob; size_t il, ol, l; iconv_t cd2; /* usually fixed size and UTF-8 do not have state, so do not reset it */ if (charsize) { if (charsize > *input_size) return 0; *input += charsize; *input_size -= charsize; return charsize; } if (0 == strcmp(charset->name, "UTF-8")) { /* * Deal with UTF-8. * bytes | bits | representation * 1 | 7 | 0vvvvvvv * 2 | 11 | 110vvvvv 10vvvvvv * 3 | 16 | 1110vvvv 10vvvvvv 10vvvvvv * 4 | 21 | 11110vvv 10vvvvvv 10vvvvvv 10vvvvvv */ int c = **input; c = c & (c >> 1); do { ++charsize; } while ((c <<= 1) & 0x80); if (charsize > *input_size) return 0; *input += charsize; *input_size -= charsize; return charsize; } /* handle state encoding */ /* extract state from iconv */ pob = ib; ol = sizeof(ib); tds_sys_iconv(cd, NULL, NULL, &pob, &ol); /* init destination conversion */ /* TODO use largest fixed size for this platform */ cd2 = tds_sys_iconv_open("UCS-4", charset->name); if (cd2 == (iconv_t) -1) return 0; /* add part of input */ il = ol; if (il > *input_size) il = *input_size; l = sizeof(ib) - ol; memcpy(ib + l, *input, il); il += l; /* translate a single character */ pib = ib; pob = ob; /* TODO use size of largest fixed charset */ ol = 4; tds_sys_iconv(cd2, &pib, &il, &pob, &ol); /* adjust input */ l = (pib - ib) - l; *input += l; *input_size -= l; /* extract state */ pob = ib; ol = sizeof(ib); tds_sys_iconv(cd, NULL, NULL, &pob, &ol); /* set input state */ pib = ib; il = sizeof(ib) - ol; pob = ob; ol = sizeof(ob); tds_sys_iconv(cd, &pib, &il, &pob, &ol); tds_sys_iconv_close(cd2); return l; } static int lookup_canonic(const CHARACTER_SET_ALIAS aliases[], const char *charset_name) { int i; for (i = 0; aliases[i].alias; ++i) { if (0 == strcmp(charset_name, aliases[i].alias)) return aliases[i].canonic; } return -1; } /** * Determine canonical iconv character set. * \returns canonical position, or -1 if lookup failed. * \remarks Returned name can be used in bytes_per_char(), above. */ static int tds_canonical_charset(const char *charset_name) { int res; /* search in alternative */ res = lookup_canonic(iconv_aliases, charset_name); if (res >= 0) return res; /* search in sybase */ return lookup_canonic(sybase_aliases, charset_name); } /** * Determine canonical iconv character set name. * \returns canonical name, or NULL if lookup failed. * \remarks Returned name can be used in bytes_per_char(), above. */ const char * tds_canonical_charset_name(const char *charset_name) { int res; /* get numeric pos */ res = tds_canonical_charset(charset_name); if (res >= 0) return canonic_charsets[res].name; return charset_name; /* hope for the best */ } static int collate2charset(int sql_collate, int lcid) { /* * The table from the MSQLServer reference "Windows Collation Designators" * and from " NLS Information for Microsoft Windows XP" */ int cp = 0; switch (sql_collate) { case 30: /* SQL_Latin1_General_CP437_BIN */ case 31: /* SQL_Latin1_General_CP437_CS_AS */ case 32: /* SQL_Latin1_General_CP437_CI_AS */ case 33: /* SQL_Latin1_General_Pref_CP437_CI_AS */ case 34: /* SQL_Latin1_General_CP437_CI_AI */ return TDS_CHARSET_CP437; case 40: /* SQL_Latin1_General_CP850_BIN */ case 41: /* SQL_Latin1_General_CP850_CS_AS */ case 42: /* SQL_Latin1_General_CP850_CI_AS */ case 43: /* SQL_Latin1_General_Pref_CP850_CI_AS */ case 44: /* SQL_Latin1_General_CP850_CI_AI */ case 49: /* SQL_1xCompat_CP850_CI_AS */ case 55: /* SQL_AltDiction_CP850_CS_AS */ case 56: /* SQL_AltDiction_Pref_CP850_CI_AS */ case 57: /* SQL_AltDiction_CP850_CI_AI */ case 58: /* SQL_Scandinavian_Pref_CP850_CI_AS */ case 59: /* SQL_Scandinavian_CP850_CS_AS */ case 60: /* SQL_Scandinavian_CP850_CI_AS */ case 61: /* SQL_AltDiction_CP850_CI_AS */ return TDS_CHARSET_CP850; case 80: /* SQL_Latin1_General_1250_BIN */ case 81: /* SQL_Latin1_General_CP1250_CS_AS */ case 82: /* SQL_Latin1_General_CP1250_CI_AS */ return TDS_CHARSET_CP1250; case 105: /* SQL_Latin1_General_CP1251_CS_AS */ case 106: /* SQL_Latin1_General_CP1251_CI_AS */ return TDS_CHARSET_CP1251; case 113: /* SQL_Latin1_General_CP1253_CS_AS */ case 114: /* SQL_Latin1_General_CP1253_CI_AS */ case 120: /* SQL_MixDiction_CP1253_CS_AS */ case 121: /* SQL_AltDiction_CP1253_CS_AS */ case 122: /* SQL_AltDiction2_CP1253_CS_AS */ case 124: /* SQL_Latin1_General_CP1253_CI_AI */ return TDS_CHARSET_CP1253; case 137: /* SQL_Latin1_General_CP1255_CS_AS */ case 138: /* SQL_Latin1_General_CP1255_CI_AS */ return TDS_CHARSET_CP1255; case 145: /* SQL_Latin1_General_CP1256_CS_AS */ case 146: /* SQL_Latin1_General_CP1256_CI_AS */ return TDS_CHARSET_CP1256; case 153: /* SQL_Latin1_General_CP1257_CS_AS */ case 154: /* SQL_Latin1_General_CP1257_CI_AS */ return TDS_CHARSET_CP1257; } switch (lcid & 0xffff) { case 0x405: case 0x40e: /* 0x1040e */ case 0x415: case 0x418: case 0x41a: case 0x41b: case 0x41c: case 0x424: case 0x442: /* case 0x81a: seem wrong in XP table TODO check */ case 0x104e: /* ?? */ case 0x141a: cp = TDS_CHARSET_CP1250; break; case 0x402: case 0x419: case 0x422: case 0x423: case 0x42f: case 0x43f: case 0x440: case 0x444: case 0x450: case 0x81a: /* ?? */ case 0x82c: case 0x843: case 0xc1a: cp = TDS_CHARSET_CP1251; break; case 0x1007: case 0x1009: case 0x100a: case 0x100c: case 0x1407: case 0x1409: case 0x140a: case 0x140c: case 0x1809: case 0x180a: case 0x180c: case 0x1c09: case 0x1c0a: case 0x201a: case 0x2009: case 0x200a: case 0x2409: case 0x240a: case 0x2809: case 0x280a: case 0x2c09: case 0x2c0a: case 0x3009: case 0x300a: case 0x3409: case 0x340a: case 0x380a: case 0x3c0a: case 0x400a: case 0x403: case 0x406: case 0x417: case 0x42e: case 0x43b: case 0x452: case 0x462: case 0x47a: case 0x47c: case 0x47e: case 0x483: case 0x407: /* 0x10407 */ case 0x409: case 0x40a: case 0x40b: case 0x40c: case 0x40f: case 0x410: case 0x413: case 0x414: case 0x416: case 0x41d: case 0x421: case 0x42d: case 0x436: case 0x437: /* 0x10437 */ case 0x438: /*case 0x439: ??? Unicode only */ case 0x43e: case 0x440a: case 0x441: case 0x456: case 0x46d: case 0x485: case 0x480a: case 0x4c0a: case 0x500a: case 0x807: case 0x809: case 0x80a: case 0x80c: case 0x810: case 0x813: case 0x814: case 0x816: case 0x81d: case 0x83b: case 0x83e: case 0x85f: case 0xc07: case 0xc09: case 0xc0a: case 0xc0c: cp = TDS_CHARSET_CP1252; break; case 0x408: cp = TDS_CHARSET_CP1253; break; case 0x41f: case 0x42c: case 0x443: cp = TDS_CHARSET_CP1254; break; case 0x40d: cp = TDS_CHARSET_CP1255; break; case 0x1001: case 0x1401: case 0x1801: case 0x1c01: case 0x2001: case 0x2401: case 0x2801: case 0x2c01: case 0x3001: case 0x3401: case 0x3801: case 0x3c01: case 0x4001: case 0x401: case 0x480: case 0x420: case 0x429: case 0x48c: case 0x801: case 0xc01: cp = TDS_CHARSET_CP1256; break; case 0x425: case 0x426: case 0x427: case 0x827: /* ?? */ cp = TDS_CHARSET_CP1257; break; case 0x42a: cp = TDS_CHARSET_CP1258; break; case 0x41e: cp = TDS_CHARSET_CP874; break; case 0x411: /* 0x10411 */ cp = TDS_CHARSET_CP932; break; case 0x1004: case 0x804: /* 0x20804 */ cp = TDS_CHARSET_CP936; break; case 0x412: /* 0x10412 */ cp = TDS_CHARSET_CP949; break; case 0x1404: case 0x404: /* 0x30404 */ case 0xc04: cp = TDS_CHARSET_CP950; break; default: cp = TDS_CHARSET_CP1252; } return cp; } /** * Get iconv information from a LCID (to support different column encoding under MSSQL2K) */ TDSICONV * tds_iconv_from_collate(TDSCONNECTION * conn, TDS_UCHAR collate[5]) { const int sql_collate = collate[4]; const int lcid = collate[1] * 256 + collate[0]; int canonic_charset = collate2charset(sql_collate, lcid); /* same as client (usually this is true, so this improve performance) ? */ if (conn->char_convs[client2server_chardata]->to.charset.canonic == canonic_charset) return conn->char_convs[client2server_chardata]; return tds_iconv_get_info(conn, conn->char_convs[client2ucs2]->from.charset.canonic, canonic_charset); } /** @} */ freetds-1.00.82/src/tds/locale.c100644 025423 025423 00000006206 12717145107 0012023/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-1999 Brian Bruns * Copyright (C) 2005-2010 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #if HAVE_LOCALE_H #include #endif #include #include #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #include #include #include "replacements.h" static void tds_parse_locale(const char *option, const char *value, void *param); /** * Get locale information. * @return allocated structure with all information or NULL if error */ TDSLOCALE * tds_get_locale(void) { TDSLOCALE *locale; char *s; FILE *in; /* allocate a new structure with hard coded and build-time defaults */ locale = tds_alloc_locale(); if (!locale) return NULL; tdsdump_log(TDS_DBG_INFO1, "Attempting to read locales.conf file\n"); in = fopen(FREETDS_LOCALECONFFILE, "r"); if (in) { tds_read_conf_section(in, "default", tds_parse_locale, locale); #if HAVE_LOCALE_H s = setlocale(LC_ALL, NULL); #else s = getenv("LANG"); #endif if (s && s[0]) { int found; char buf[128]; const char *strip = "@._"; /* do not change environment !!! */ strlcpy(buf, s, sizeof(buf)); /* search full name */ rewind(in); found = tds_read_conf_section(in, buf, tds_parse_locale, locale); /* * Here we try to strip some part of language in order to * catch similar language * LANG is composed by * language[_sublanguage][.charset][@modified] * ie it_IT@euro or it_IT.UTF-8 so we strip in order * modifier, charset and sublanguage * ie it_IT@euro -> it_IT -> it */ for (;!found && *strip; ++strip) { s = strrchr(buf, *strip); if (!s) continue; *s = 0; rewind(in); found = tds_read_conf_section(in, buf, tds_parse_locale, locale); } } fclose(in); } return locale; } static void tds_parse_locale(const char *option, const char *value, void *param) { TDSLOCALE *locale = (TDSLOCALE *) param; if (!strcmp(option, TDS_STR_CHARSET)) { free(locale->server_charset); locale->server_charset = strdup(value); } else if (!strcmp(option, TDS_STR_LANGUAGE)) { free(locale->language); locale->language = strdup(value); } else if (!strcmp(option, TDS_STR_DATEFMT)) { free(locale->date_fmt); locale->date_fmt = strdup(value); } } freetds-1.00.82/src/tds/threadsafe.c100644 025423 025423 00000025546 12717145107 0012702/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Brian Bruns * Copyright (C) 2005-2015 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #include #if defined(HAVE_GETUID) && defined(HAVE_GETPWUID) #include #endif #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_NETDB_H #include #endif /* HAVE_NETDB_H */ #if HAVE_ERRNO_H #include #endif /* HAVE_ERRNO_H */ #if HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #if HAVE_NETINET_IN_H #include #endif /* HAVE_NETINET_IN_H */ #if HAVE_ARPA_INET_H #include #endif /* HAVE_ARPA_INET_H */ #if HAVE_ROKEN_H #include #endif /* HAVE_ROKEN_H */ #if defined(_WIN32) || defined(_WIN64) #include #include #endif #include #include #include "replacements.h" struct tm * tds_localtime_r(const time_t *timep, struct tm *result) { struct tm *tm; #if defined(_REENTRANT) && !defined(_WIN32) #if HAVE_FUNC_LOCALTIME_R_TM tm = localtime_r(timep, result); #else tm = NULL; if (!localtime_r(timep, result)) tm = result; #endif /* HAVE_FUNC_LOCALTIME_R_TM */ #else tm = localtime(timep); if (tm) { memcpy(result, tm, sizeof(*result)); tm = result; } #endif return tm; } char * tds_timestamp_str(char *str, int maxlen) { #if !defined(_WIN32) && !defined(_WIN64) struct tm *tm; struct tm res; time_t t; #if HAVE_GETTIMEOFDAY struct timeval tv; char usecs[10]; gettimeofday(&tv, NULL); t = tv.tv_sec; #else /* * XXX Need to get a better time resolution for * systems that don't have gettimeofday(). */ time(&t); #endif tm = tds_localtime_r(&t, &res); /** strftime(str, maxlen - 6, "%Y-%m-%d %H:%M:%S", tm); **/ strftime(str, maxlen - 6, "%H:%M:%S", tm); #if HAVE_GETTIMEOFDAY sprintf(usecs, ".%06lu", (long) tv.tv_usec); strcat(str, usecs); #endif #else /* _WIN32 */ SYSTEMTIME st; GetLocalTime(&st); _snprintf(str, maxlen - 1, "%02u:%02u:%02u.%03u", st.wHour, st.wMinute, st.wSecond, st.wMilliseconds); str[maxlen - 1] = 0; #endif return str; } /* * If reentrant code was not requested, we don't care reentrancy, so * just assume the standard BSD netdb interface is reentrant and use it. */ #ifndef _REENTRANT # undef NETDB_REENTRANT # define NETDB_REENTRANT 1 #endif /* _REENTRANT */ #if !defined(HAVE_GETADDRINFO) #if defined(NETDB_REENTRANT) struct hostent * tds_gethostbyname_r(const char *servername, struct hostent *result, char *buffer, int buflen, int *h_errnop) { return gethostbyname(servername); } #elif defined(HAVE_GETIPNODEBYNAME) || defined(HAVE_GETIPNODEBYADDR) /** * Copy a hostent structure to an allocated buffer * @return 0 on success, -1 otherwise */ static int tds_copy_hostent(struct hostent *he, struct hostent *result, char *buffer, int buflen) { #define CHECK_BUF(len) \ if (p + sizeof(struct hostent) - buffer > buflen) return -1; #define ALIGN_P do { p += TDS_ALIGN_SIZE - 1; p -= (p-buffer) % TDS_ALIGN_SIZE; } while(0) int n, i; char *p = buffer; struct hostent *he2; /* copy structure */ he2 = result; memcpy(he2, he, sizeof(struct hostent)); if (he->h_addr_list) { int len; char **addresses; /* count addresses */ for (n = 0; he->h_addr_list[n]; ++n) continue; /* copy addresses */ addresses = (char **) p; he2->h_addr_list = (char **) p; len = sizeof(char *) * (n + 1); CHECK_BUF(len); p += len; ALIGN_P; for (i = 0; i < n; ++i) { addresses[i] = p; CHECK_BUF(he->h_length); memcpy(p, he->h_addr_list[i], he->h_length); p += he->h_length; ALIGN_P; } addresses[n] = NULL; } /* copy name */ if (he->h_name) { n = strlen(he->h_name) + 1; he2->h_name = p; CHECK_BUF(n); memcpy(p, he->h_name, n); p += n; ALIGN_P; } if (he->h_aliases) { int len; char **aliases; /* count aliases */ for (n = 0; he->h_aliases[n]; ++n) continue; /* copy aliases */ aliases = (char **) p; he2->h_aliases = (char **) p; len = sizeof(char *) * (n + 1); CHECK_BUF(len); p += len; for (i = 0; i < n; ++i) { len = strlen(he->h_aliases[i]) + 1; aliases[i] = p; CHECK_BUF(len); memcpy(p, he->h_aliases[i], len); p += len; } aliases[n] = NULL; } return 0; } struct hostent * tds_gethostbyname_r(const char *servername, struct hostent *result, char *buffer, int buflen, int *h_errnop) { struct hostent *he = getipnodebyname(servername, AF_INET, 0, h_errnop); if (!he) return NULL; if (tds_copy_hostent(he, result, buffer, buflen)) { errno = ENOMEM; if (h_errnop) *h_errnop = NETDB_INTERNAL; freehostent(he); return NULL; } freehostent(he); return result; } #elif defined(HAVE_FUNC_GETHOSTBYNAME_R_6) struct hostent * tds_gethostbyname_r(const char *servername, struct hostent *result, char *buffer, int buflen, int *h_errnop) { if (gethostbyname_r(servername, result, buffer, buflen, &result, h_errnop)) return NULL; return result; } #elif defined(HAVE_FUNC_GETHOSTBYNAME_R_5) struct hostent * tds_gethostbyname_r(const char *servername, struct hostent *result, char *buffer, int buflen, int *h_errnop) { result = gethostbyname_r(servername, result, buffer, buflen, h_errnop); return result; } #elif defined(HAVE_FUNC_GETHOSTBYNAME_R_3) struct hostent * tds_gethostbyname_r(const char *servername, struct hostent *result, char *buffer, int buflen, int *h_errnop) { struct hostent_data *data = (struct hostent_data *) buffer; memset(buffer, 0, buflen); if (gethostbyname_r(servername, result, data)) { *h_errnop = 0; result = NULL; } return result; } #elif defined(TDS_NO_THREADSAFE) struct hostent * tds_gethostbyname_r(const char *servername, struct hostent *result, char *buffer, int buflen, int *h_errnop) { return gethostbyname(servername); } #else #error gethostbyname_r style unknown #endif #endif #if 0 #undef HAVE_GETADDRINFO #undef NETDB_REENTRANT #undef HAVE_FUNC_GETSERVBYNAME_R_6 #undef HAVE_FUNC_GETSERVBYNAME_R_5 #undef HAVE_FUNC_GETSERVBYNAME_R_4 #undef TDS_NO_THREADSAFE # if 0 # define HAVE_FUNC_GETSERVBYNAME_R_6 1 int test_getservbyname_r(const char *name, const char *proto, struct servent *result_buf, char *buffer, size_t buflen, struct servent **result); # define getservbyname_r test_getservbyname_r # elif 0 # define HAVE_FUNC_GETSERVBYNAME_R_5 1 struct servent * test_getservbyname_r(const char *name, const char *proto, struct servent *result_buf, char *buffer, size_t buflen); # define getservbyname_r test_getservbyname_r # else # define HAVE_FUNC_GETSERVBYNAME_R_4 1 struct servent_data { int dummy; }; int test_getservbyname_r(const char *name, const char *proto, struct servent *result_buf, struct servent_data *data); # define getservbyname_r test_getservbyname_r # endif #endif /** * Return service port given the name */ int tds_getservice(const char *name) { #if defined(HAVE_GETADDRINFO) /* new OSes should implement this in a proper way */ struct addrinfo hints, *res; int result; memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_PASSIVE; res = NULL; if (getaddrinfo(NULL, name, &hints, &res)) return 0; if (res->ai_family != AF_INET || !res->ai_addr) { freeaddrinfo(res); return 0; } result = ntohs(((struct sockaddr_in *) res->ai_addr)->sin_port); freeaddrinfo(res); return result; #elif defined(NETDB_REENTRANT) /* HP-UX/Windows */ struct servent *result = getservbyname(name, "tcp"); return result ? ntohs(result->s_port) : 0; #elif defined(HAVE_FUNC_GETSERVBYNAME_R_6) /* Linux variant */ struct servent *result = NULL; struct servent result_buf; char buffer[4096]; if (!getservbyname_r(name, "tcp", &result_buf, buffer, sizeof(buffer), &result)) return ntohs(result->s_port); return 0; #elif defined(HAVE_FUNC_GETSERVBYNAME_R_5) /* Solaris variant */ struct servent result; char buffer[4096]; if (getservbyname_r(name, "tcp", &result, buffer, sizeof(buffer))) return ntohs(result.s_port); return 0; #elif defined(HAVE_FUNC_GETSERVBYNAME_R_4) /* AIX/BSD variant */ struct servent result; struct servent_data data; if (!getservbyname_r(name, "tcp", &result, &data)) return ntohs(result.s_port); return 0; #elif defined(TDS_NO_THREADSAFE) struct servent *result = getservbyname(name, "tcp"); return result ? ntohs(result->s_port) : 0; #else #error getservbyname_r style unknown #endif } /** * Get user home directory * @return home directory or NULL if error. Should be freed with free */ char * tds_get_homedir(void) { #ifndef _WIN32 /* if is available getpwuid_r use it */ #if defined(HAVE_GETUID) && defined(HAVE_GETPWUID_R) struct passwd *pw, bpw; char buf[1024]; # if defined(HAVE_FUNC_GETPWUID_R_5) /* getpwuid_r can return 0 if uid is not found so check pw */ pw = NULL; if (getpwuid_r(getuid(), &bpw, buf, sizeof(buf), &pw) || !pw) return NULL; # elif defined(HAVE_FUNC_GETPWUID_R_4_PW) if (!(pw = getpwuid_r(getuid(), &bpw, buf, sizeof(buf)))) return NULL; # else /* !HAVE_FUNC_GETPWUID_R_4_PW */ if (getpwuid_r(getuid(), &bpw, buf, sizeof(buf))) return NULL; pw = &bpw; # endif return strdup(pw->pw_dir); /* if getpwuid is available use it for no reentrant (getpwuid is not reentrant) */ #elif defined(HAVE_GETUID) && defined(HAVE_GETPWUID) && !defined(_REENTRANT) struct passwd *pw; pw = getpwuid(getuid()); if (!pw) return NULL; return strdup(pw->pw_dir); #else char *home; home = getenv("HOME"); if (!home || !home[0]) return NULL; return strdup(home); #endif #else /* _WIN32 */ /* * For win32 we return application data cause we use "HOME" * only to store configuration files */ LPITEMIDLIST pidl; char path[MAX_PATH]; HRESULT hr; LPMALLOC pMalloc = NULL; char * res = NULL; hr = SHGetMalloc(&pMalloc); if (!FAILED(hr)) { hr = SHGetSpecialFolderLocation(NULL, CSIDL_APPDATA, &pidl); if (!FAILED(hr)) { if (SHGetPathFromIDList(pidl, path)) res = strdup(path); (*pMalloc->lpVtbl->Free)(pMalloc, pidl); } (*pMalloc->lpVtbl->Release)(pMalloc); } return res; #endif } freetds-1.00.82/src/tds/vstrbuild.c100644 025423 025423 00000010165 12717145107 0012601/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-1999 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include "replacements.h" struct string_linked_list { char *str; struct string_linked_list *next; }; /* * XXX The magic use of \xFF is bletcherous, but I can't think of anything * better right now. */ static char * norm_fmt(const char *fmt, int fmtlen) { char *newfmt; char *cp; char skip = 0; if (fmtlen == TDS_NULLTERM) { fmtlen = strlen(fmt); } if ((newfmt = tds_new(char, fmtlen + 1)) == NULL) return NULL; for (cp = newfmt; fmtlen > 0; fmtlen--, fmt++) { switch (*fmt) { case ',': case ' ': if (!skip) { *cp++ = '\377'; skip = 1; } break; default: skip = 0; *cp++ = *fmt; break; } } *cp = '\0'; return newfmt; } TDSRET tds_vstrbuild(char *buffer, int buflen, int *resultlen, const char *text, int textlen, const char *formats, int formatlen, va_list ap) { char *newformat; char *params; char *token; const char *sep = "\377"; char *lasts; int tokcount = 0; struct string_linked_list *head = NULL; struct string_linked_list *item = NULL; struct string_linked_list **tail = &head; int i; int state; char **string_array = NULL; int pnum = 0; int pdigit; char *paramp = NULL; TDSRET rc = TDS_FAIL; *resultlen = 0; if (textlen == TDS_NULLTERM) { textlen = (int)strlen(text); } if ((newformat = norm_fmt(formats, formatlen)) == NULL) { return TDS_FAIL; } if (vasprintf(¶ms, newformat, ap) < 0) { free(newformat); return TDS_FAIL; } free(newformat); for (token = strtok_r(params, sep, &lasts); token != NULL; token = strtok_r(NULL, sep, &lasts)) { if ((*tail = tds_new(struct string_linked_list, 1)) == NULL) { goto out; } (*tail)->str = token; (*tail)->next = NULL; tail = &((*tail)->next); tokcount++; } if ((string_array = tds_new(char *, tokcount + 1)) == NULL) { goto out; } for (item = head, i = 0; i < tokcount; item = item->next, i++) { if (item == NULL) { goto out; } string_array[i] = item->str; while (*(string_array[i]) == ' ') { string_array[i]++; } } #define COPYING 1 #define CALCPARAM 2 #define OUTPARAM 3 state = COPYING; while ((buflen > 0) && (textlen > 0)) { switch (state) { case COPYING: switch (*text) { case '%': state = CALCPARAM; text++; textlen--; pnum = 0; break; default: *buffer++ = *text++; buflen--; textlen--; (*resultlen)++; break; } break; case CALCPARAM: switch (*text) { case '!': if (pnum <= tokcount) { paramp = string_array[pnum - 1]; state = OUTPARAM; } text++; textlen--; break; default: pdigit = *text++ - '0'; if ((pdigit >= 0) && (pdigit <= 9)) { pnum *= 10; pnum += pdigit; } textlen--; break; } break; case OUTPARAM: switch (*paramp) { case 0: state = COPYING; break; default: *buffer++ = *paramp++; buflen--; (*resultlen)++; } break; default: /* unknown state */ goto out; break; } } rc = TDS_SUCCESS; out: free(string_array); for (item = head; item != NULL; item = head) { head = head->next; free(item); } free(params); return rc; } freetds-1.00.82/src/tds/tdsstring.c100644 025423 025423 00000010225 12717145107 0012601/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2004-2015 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include /** * \ingroup libtds * \defgroup dstring Dynamic string functions * Handle dynamic string. In this string are always valid * (you don't have NULL pointer, only empty strings) */ /* This is in a separate module because we use the pointer to discriminate allocated and not allocated */ const struct tds_dstr tds_str_empty = { 0, "" }; #define EMPTY ((struct tds_dstr*) &tds_str_empty) /** * \addtogroup dstring * @{ */ /** clear all string filling with zeroes (mainly for security reason) */ void tds_dstr_zero(DSTR * s) { memset((*s)->dstr_s, 0, (*s)->dstr_size); } /** free string */ void tds_dstr_free(DSTR * s) { if (*s != EMPTY) free(*s); *s = EMPTY; } /** * Set string to a given buffer of characters * @param s dynamic string * @param src source buffer * @param length length of source buffer * @return string copied or NULL on memory error */ DSTR* tds_dstr_copyn(DSTR * s, const char *src, size_t length) { if (!length) { if (*s != EMPTY) { free(*s); *s = EMPTY; } } else { struct tds_dstr *p = (struct tds_dstr *) malloc(length + TDS_OFFSET(struct tds_dstr, dstr_s) + 1); if (TDS_UNLIKELY(!p)) return NULL; memcpy(p->dstr_s, src, length); p->dstr_s[length] = 0; p->dstr_size = length; if (*s != EMPTY) free(*s); *s = p; } return s; } /** * set a string from another buffer. * The string will use the supplied buffer (it not copy the string), * so it should be a pointer returned by malloc. * @param s dynamic string * @param src source buffer * @return string copied or NULL on memory error */ DSTR* tds_dstr_set(DSTR * s, char *src) { DSTR *res = tds_dstr_copy(s, src); if (TDS_LIKELY(res != NULL)) free(src); return res; } /** * copy a string from another * @param s dynamic string * @param src source buffer * @return string copied or NULL on memory error */ DSTR* tds_dstr_copy(DSTR * s, const char *src) { return tds_dstr_copyn(s, src, strlen(src)); } /** * Duplicate a string from another dynamic string * @param s output string * @param src source string to copy * @return string copied or NULL on memory error */ DSTR* tds_dstr_dup(DSTR * s, const DSTR * src) { return tds_dstr_copyn(s, (*src)->dstr_s, (*src)->dstr_size); } /** * limit length of string, MUST be <= current length * @param s dynamic string * @param length new length */ DSTR* tds_dstr_setlen(DSTR *s, size_t length) { #if ENABLE_EXTRA_CHECKS assert((*s)->dstr_size >= length); #endif /* test required for empty strings */ if ((*s)->dstr_size >= length && *s != EMPTY) { (*s)->dstr_size = length; (*s)->dstr_s[length] = 0; } return s; } /** * allocate space for length char * @param s dynamic string * @param length new length * @return string allocated or NULL on memory error */ DSTR* tds_dstr_alloc(DSTR *s, size_t length) { struct tds_dstr *p = (struct tds_dstr *) malloc(length + TDS_OFFSET(struct tds_dstr, dstr_s) + 1); if (TDS_UNLIKELY(!p)) return NULL; if (*s != EMPTY) free(*s); p->dstr_s[0] = 0; p->dstr_size = length; *s = p; return s; } /** @} */ freetds-1.00.82/src/tds/getmac.c100644 025423 025423 00000003617 12522201763 0012022/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-2002 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #ifdef __linux__ #include #include #include #include #include #endif /* TODO get real MAC */ void tds_getmac(TDS_SYS_SOCKET s, unsigned char mac[6]) { /* implementation for Linux */ #ifdef __linux__ struct ifreq ifr; struct ifreq *IFR; struct ifconf ifc; char buf[1024]; int i; memset(mac, 0, 6); ifc.ifc_len = sizeof(buf); ifc.ifc_buf = buf; ioctl(s, SIOCGIFCONF, &ifc); IFR = ifc.ifc_req; for (i = ifc.ifc_len / (int)sizeof(struct ifreq); --i >= 0; ++IFR) { strcpy(ifr.ifr_name, IFR->ifr_name); if (ioctl(s, SIOCGIFFLAGS, &ifr) == 0) { if (!(ifr.ifr_flags & IFF_LOOPBACK)) { if (ioctl(s, SIOCGIFHWADDR, &ifr) == 0) { memcpy(mac, ifr.ifr_hwaddr.sa_data, 6); break; } } } } #else /* !defined(__linux__) */ memset(mac, 0, 6); #endif } freetds-1.00.82/src/tds/data.c100644 025423 025423 00000127653 13242511021 0011471/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2003-2011 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /** * \page new_type How to add a new type * \section intro Introduction * Adding a new type in FreeTDS is a quite complicated task involving * different tasks. * * To see an example you can look at * \commit{adb893f1381fd3ea40564c775e30dc8cdc81dcf2} * ("Implement big(date)time types") and parent changes in the source * repository. * * \section tds libTDS changes *
    *
  • protocol. First thing to do is add the type to the protocol. * A type usually have some mnemonic constant and a structure. * Declare them in \c include/freetds/proto.h file. Note that * here you should declare the structure the server use not * the structure to hold the data in libTDS. *
    Cfr \commit{a74a06e1f97f3137f6cf1bc7319dd7a2cfb52b1f}. * *
  • base information. Add the type to \c misc/types.csv file * (I use LibreOffice Calc to do it). This table maintain the * base information for a type. *
    Cfr \commit{680cb3371e042bb372cbc5e6feb4054e50d40c1a}. * *
  • data. There should be some code to handle this type to/from * the server. This code is implemented in \c include/freetds/data.h * and \c src/tds/data.c. You can either add a new set of functions * to handle this new type or add the type handling do another set * of types depending on how complicated is that type. * One thing you have to to at this step is determine how you store * that type in libTDS. This is quite important at upper level * libraries will have to use these structures or even present * these data to client code (like DB-Library usually do). * Due to the way FreeTDS works now you would get a linker error * in the ODBC part. You can either ignore the error and proceed * with libTDS, add the code to ODBC or disable temporarily ODBC. *
    Cfr \commit{680cb3371e042bb372cbc5e6feb4054e50d40c1a}. * *
  • enable the type from server. In order to receive the new type * from the server you have to tell the server that we support * that type. This can be either done changing the protocol (usually * Microsoft) or enabling some flags (capabilities for Sybase). *
    Cfr \commit{a498703ff9e309c656b19dd990f4cad0283a47c7}. * *
  • conversions. Conversions are not hard to write but usually * require quite a bit of coding. After extending CONV_RESULT * type in \c include/freetds/convert.h and adding the type to * the script that generate the conversion tables in * \c src/tds/tds_willconvert.pl you have to write the big part * in \c src/tds/covnert.c. You have to implement all kind of * conversions you declared in the previous file. Reuse the * functions that are there (for instance there are some * parser functions). Also if there are similar types it could * be helpful to convert first your type to a super type then * use the conversion for that type. For instance for SMALLINT * type (\c tds_convert_int2) the type is just readed and then * \c tds_convert_int is called which handle any int (actually * 32 bit integer). Same for data where the \c TDS_DATETIMEALL * structure is used. Note that conversions to binary (which * usually are implemented) are done in another function * (\c tds_convert_to_binary). *
    Cfr \commit{9ed52cb78f725607ac109c8c284ca7c4658d87a9}. * *
  • string definition. Add string for your type to * \c src/tds/token.c in \c tds_prtype. *
    Cfr \commit{ac0d3b46db7d98436cd76f906b7d455f7651faae}. * *
  • conversion tests. You probably will have done some mistake * with conversions but don't mind, there are some tests which * will help sorting this out. * \c src/tds/unittests/convert.c * try any possible combination of conversion to check if * all conversion are implemented (it does not check the * conversions themself). * \c src/tds/unittests/t0007.c test that your conversion * are working. Just add manually the conversions you want * to try. *
    Cfr \commit{abcc09c9a88acd0e9a45b46dab3ca44309917a02}. * *
  • parameter. Add type/parameter declaration in * \c tds_get_column_declaration in \c src/tds/query.c. * Also do any necessary step to initialize the parameter * to send to server. *
    Cfr \commit{54fdd3233e430c045cf5524ac385770738d9e92c}, * \commit{88cfea19d91245372779b8893a2d62b42696cd49}. * *
  • emulated prepared/rpc. If needed handle your type * in \c tds_put_param_as_string in \c src/tds/query.c. *
    Cfr \commit{017b7bf2fee0f09847e64546d27382d2f2b756f4}. * *
* * \section odbc ODBC changes * ODBC is the most complicated library to add a type to. * Usually its data are different from libTDS so you have to add additional * code for conversions which are not required by other libraries. *
    *
  • type information. Every type in ODBC have related information. * These information are set in \c src/odbc/odbc_data.c. * Depending on the changes you did for data in libTDS you should * handle the new type. *
    Cfr \commit{71e189e206dc9b6f6513e0aa0e4133a4f8dec110}. * *
  • type information test. Related to the previous change there * is \c src/odbc/unittests/describecol.c test. Add a test case * for new type. You should attempt to run same test also on * proprietary library if possible. *
    Cfr \commit{8a8ec16a6a514a5d6ac66c2470eff51f6a8d4a53}. * *
  • conversions from odbc. Define how the ODBC type should convert * to the server and implement the conversion. *
    Cfr \commit{29606cbf413c44e49ddfcfb8a93b8a6bd2565a84}, * \commit{87c84e20a594472a72990b12d4a1451b22e6714b}. * *
  • conversions to binary. Binary representation in ODBC are usually * different from server ones. If so implement the proper conversions. *
    Cfr \commit{56009f35d3e0def339a0c5cb98d006e5e710d523}. * *
  • conversions to characters. Same problem for character types. *
    Cfr \commit{25ff091880dabc32f28a73f09bf31c01314aca2f}. * *
  • conversion test. You probably want to test ODBC conversions. * This can be done changing \c src/odbc/unittests/data.c test and * \c src/odbc/unittests/genparams.c. *
    Cfr \commit{e69f7d564dac44884f7c5f0106cceafce4af168b}. *
* * \section ctlib CT-Library changes * This is quite easy as usual the conversion in libTDS are fine for * this library. *
    *
  • define type in \c include/cspublic.h *
  • implement conversion in \c src/ctlib/cs.h *
  • set corrent conversion from cs types to server in * \c src/ctlib/ct.c *
* Cfr \commit{c5e71e5ad4a557038ecedcec457e2531ab02a77b}. * * \section dblib DB-Library changes * A bit more complicated than CT-Library but not that much. *
    *
  • add type and binding type to \c include/sybdb.h *
  • add NULL handling in \c dbgetnull, \c dbsetnull * and \c default_null_representation in * \c src/dblib/dblib.c *
  • add binding to dbbindtype *
  • add support for conversion from/to server *
  • add printable size *
  • return correct type string *
* Cfr \commit{99dd126e0eb248dd3079b2a7cf97437fe3bcd163}. * * \section apps Applications changes * datacopy application requires some changes too to support new types * so add them to \c src/apps/datacopy.c. *
Cfr \commit{e59c48ac39c76abb036651f8ec238090eef321c9}. */ /** * @file * @brief Handle different data handling from network */ #include #include #include #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #define TDS_DONT_DEFINE_DEFAULT_FUNCTIONS #include #include #include #include #include #include #define USE_ICONV (tds->conn->use_iconv) static const TDSCOLUMNFUNCS *tds_get_column_funcs(TDSCONNECTION *conn, int type); #ifdef WORDS_BIGENDIAN static void tds_swap_datatype(int coltype, void *b); #endif static void tds_swap_numeric(TDS_NUMERIC *num); #undef MIN #define MIN(a,b) (((a) < (b)) ? (a) : (b)) #undef MAX #define MAX(a,b) (((a) > (b)) ? (a) : (b)) /** * Set type of column initializing all dependency * @param curcol column to set * @param type type to set */ void tds_set_column_type(TDSCONNECTION * conn, TDSCOLUMN * curcol, TDS_SERVER_TYPE type) { /* set type */ curcol->on_server.column_type = type; curcol->funcs = tds_get_column_funcs(conn, type); curcol->column_type = tds_get_cardinal_type(type, curcol->column_usertype); /* set size */ curcol->column_cur_size = -1; curcol->column_varint_size = tds_get_varint_size(conn, type); if (curcol->column_varint_size == 0) curcol->column_cur_size = curcol->on_server.column_size = curcol->column_size = tds_get_size_by_type(type); } /** * Set type of column initializing all dependency * \param tds state information for the socket and the TDS protocol * \param curcol column to set * \param type type to set */ void tds_set_param_type(TDSCONNECTION * conn, TDSCOLUMN * curcol, TDS_SERVER_TYPE type) { if (IS_TDS7_PLUS(conn)) { switch (type) { case SYBVARCHAR: type = XSYBVARCHAR; break; case SYBCHAR: type = XSYBCHAR; break; case SYBVARBINARY: type = XSYBVARBINARY; break; case SYBBINARY: type = XSYBBINARY; break; /* avoid warning on other types */ default: break; } } else if (IS_TDS50(conn)) { if (type == SYBINT8) type = SYB5INT8; } tds_set_column_type(conn, curcol, type); if (is_collate_type(type)) { curcol->char_conv = conn->char_convs[is_unicode_type(type) ? client2ucs2 : client2server_chardata]; memcpy(curcol->column_collation, conn->collation, sizeof(conn->collation)); } /* special case, GUID, varint != 0 but only a size */ /* TODO VARIANT, when supported */ switch (type) { case SYBUNIQUE: curcol->on_server.column_size = curcol->column_size = sizeof(TDS_UNIQUE); break; case SYBBITN: curcol->on_server.column_size = curcol->column_size = sizeof(TDS_TINYINT); break; /* mssql 2005 don't like SYBINT4 as parameter closing connection */ case SYBINT1: case SYBINT2: case SYBINT4: case SYBINT8: curcol->on_server.column_type = SYBINTN; curcol->column_varint_size = 1; curcol->column_cur_size = -1; break; case SYBMONEY4: case SYBMONEY: curcol->on_server.column_type = SYBMONEYN; curcol->column_varint_size = 1; curcol->column_cur_size = -1; break; case SYBDATETIME: case SYBDATETIME4: curcol->on_server.column_type = SYBDATETIMN; curcol->column_varint_size = 1; curcol->column_cur_size = -1; break; case SYBFLT8: case SYBREAL: curcol->on_server.column_type = SYBFLTN; curcol->column_varint_size = 1; curcol->column_cur_size = -1; break; case SYBNTEXT: if (IS_TDS72_PLUS(conn)) { curcol->column_varint_size = 8; curcol->on_server.column_type = XSYBNVARCHAR; } break; case SYBTEXT: if (IS_TDS72_PLUS(conn)) { curcol->column_varint_size = 8; curcol->on_server.column_type = XSYBVARCHAR; } break; case SYBIMAGE: if (IS_TDS72_PLUS(conn)) { curcol->column_varint_size = 8; curcol->on_server.column_type = XSYBVARBINARY; } break; case SYB5BIGTIME: case SYB5BIGDATETIME: curcol->column_prec = 6; curcol->column_scale = 6; break; default: break; } } TDS_SERVER_TYPE tds_get_cardinal_type(TDS_SERVER_TYPE datatype, int usertype) { switch (datatype) { case XSYBVARBINARY: return SYBVARBINARY; case XSYBBINARY: return SYBBINARY; case SYBNTEXT: return SYBTEXT; case XSYBNVARCHAR: case XSYBVARCHAR: return SYBVARCHAR; case XSYBNCHAR: case XSYBCHAR: return SYBCHAR; case SYB5INT8: return SYBINT8; case SYBLONGBINARY: switch (usertype) { case USER_UNICHAR_TYPE: case USER_UNIVARCHAR_TYPE: return SYBTEXT; } break; default: break; } return datatype; } TDSRET tds_generic_get_info(TDSSOCKET *tds, TDSCOLUMN *col) { switch (col->column_varint_size) { case 8: col->column_size = 0x7ffffffflu; break; case 5: case 4: col->column_size = tds_get_int(tds); if (col->column_size < 0) return TDS_FAIL; break; case 2: /* assure > 0 */ col->column_size = tds_get_smallint(tds); /* under TDS7.2 this means ?var???(MAX) */ if (col->column_size < 0 && IS_TDS72_PLUS(tds->conn)) { col->column_size = 0x3ffffffflu; col->column_varint_size = 8; } if (col->column_size < 0) return TDS_FAIL; break; case 1: col->column_size = tds_get_byte(tds); break; case 0: col->column_size = tds_get_size_by_type(col->column_type); break; } if (IS_TDS71_PLUS(tds->conn) && is_collate_type(col->on_server.column_type)) { /* based on true type as sent by server */ /* * first 2 bytes are windows code (such as 0x409 for english) * other 2 bytes ??? * last bytes is id in syscharsets */ tds_get_n(tds, col->column_collation, 5); col->char_conv = tds_iconv_from_collate(tds->conn, col->column_collation); } /* Only read table_name for blob columns (eg. not for SYBLONGBINARY) */ if (is_blob_type(col->on_server.column_type)) { /* discard this additional byte */ if (IS_TDS72_PLUS(tds->conn)) { unsigned char num_parts = tds_get_byte(tds); /* TODO do not discard first ones */ for (; num_parts; --num_parts) { tds_dstr_get(tds, &col->table_name, tds_get_usmallint(tds)); } } else { tds_dstr_get(tds, &col->table_name, tds_get_usmallint(tds)); } } else if (IS_TDS72_PLUS(tds->conn) && col->on_server.column_type == SYBMSXML) { unsigned char has_schema = tds_get_byte(tds); if (has_schema) { /* discard schema informations */ tds_get_string(tds, tds_get_byte(tds), NULL, 0); /* dbname */ tds_get_string(tds, tds_get_byte(tds), NULL, 0); /* schema owner */ tds_get_string(tds, tds_get_usmallint(tds), NULL, 0); /* schema collection */ } } return TDS_SUCCESS; } /* tds_generic_row_len support also variant and return size to hold blob */ TDS_COMPILE_CHECK(variant_size, sizeof(TDSBLOB) >= sizeof(TDSVARIANT)); TDS_INT tds_generic_row_len(TDSCOLUMN *col) { CHECK_COLUMN_EXTRA(col); if (is_blob_col(col)) return sizeof(TDSBLOB); return col->column_size; } static TDSRET tds_get_char_dynamic(TDSSOCKET *tds, TDSCOLUMN *curcol, void **pp, size_t allocated, TDSINSTREAM *r_stream) { TDSRET res; TDSDYNAMICSTREAM w; /* * Blobs don't use a column's fixed buffer because the official maximum size is 2 GB. * Instead, they're reallocated as necessary, based on the data's size. */ res = tds_dynamic_stream_init(&w, pp, allocated); if (TDS_FAILED(res)) return res; if (USE_ICONV && curcol->char_conv) res = tds_convert_stream(tds, curcol->char_conv, to_client, r_stream, &w.stream); else res = tds_copy_stream(tds, r_stream, &w.stream); curcol->column_cur_size = w.size; return res; } typedef struct tds_varmax_stream { TDSINSTREAM stream; TDSSOCKET *tds; TDS_INT chunk_left; } TDSVARMAXSTREAM; static int tds_varmax_stream_read(TDSINSTREAM *stream, void *ptr, size_t len) { TDSVARMAXSTREAM *s = (TDSVARMAXSTREAM *) stream; /* read chunk len if needed */ if (s->chunk_left == 0) { TDS_INT l = tds_get_int(s->tds); if (l <= 0) l = -1; s->chunk_left = l; } /* no more data ?? */ if (s->chunk_left < 0) return 0; /* read part of data */ if (len > s->chunk_left) len = s->chunk_left; s->chunk_left -= len; if (tds_get_n(s->tds, ptr, len)) return len; return -1; } static TDSRET tds72_get_varmax(TDSSOCKET * tds, TDSCOLUMN * curcol) { TDS_INT8 len; TDSVARMAXSTREAM r; size_t allocated = 0; void **pp = (void**) &(((TDSBLOB*) curcol->column_data)->textvalue); len = tds_get_int8(tds); /* NULL */ if (len == -1) { curcol->column_cur_size = -1; return TDS_SUCCESS; } /* try to allocate an initial buffer */ if (len > (TDS_INT8) (~((size_t) 0) >> 1)) return TDS_FAIL; if (len > 0) { TDS_ZERO_FREE(*pp); allocated = (size_t) len; if (is_unicode_type(curcol->on_server.column_type)) allocated /= 2; } r.stream.read = tds_varmax_stream_read; r.tds = tds; r.chunk_left = 0; return tds_get_char_dynamic(tds, curcol, pp, allocated, &r.stream); } TDS_COMPILE_CHECK(tds_variant_size, sizeof(((TDSVARIANT*)0)->data) == sizeof(((TDSBLOB*)0)->textvalue)); TDS_COMPILE_CHECK(tds_variant_offset,TDS_OFFSET(TDSVARIANT, data) == TDS_OFFSET(TDSBLOB, textvalue)); /* * This strange type has following structure * 0 len (int32) -- NULL * len (int32), type (int8), data -- ints, date, etc * len (int32), type (int8), 7 (int8), collation, column size (int16) -- [n]char, [n]varchar, binary, varbinary * BLOBS (text/image) not supported */ TDSRET tds_variant_get(TDSSOCKET * tds, TDSCOLUMN * curcol) { unsigned int colsize = tds_get_uint(tds); int varint; TDS_SERVER_TYPE type; TDS_UCHAR info_len; TDSVARIANT *v; TDSRET rc; /* NULL */ curcol->column_cur_size = -1; if (colsize < 2) { tds_get_n(tds, NULL, colsize); return TDS_SUCCESS; } type = (TDS_SERVER_TYPE) tds_get_byte(tds); info_len = tds_get_byte(tds); if (!is_tds_type_valid(type)) goto error_type; v = (TDSVARIANT*) curcol->column_data; v->type = type; colsize -= 2; if (info_len > colsize) goto error_type; if (is_collate_type(type)) { if (sizeof(v->collation) > info_len) goto error_type; tds_get_n(tds, v->collation, sizeof(v->collation)); colsize -= sizeof(v->collation); info_len -= sizeof(v->collation); curcol->char_conv = is_unicode_type(type) ? tds->conn->char_convs[client2ucs2] : tds_iconv_from_collate(tds->conn, v->collation); } /* special case for numeric */ if (is_numeric_type(type)) { TDS_NUMERIC *num; if (info_len != 2) goto error_type; if (v->data) TDS_ZERO_FREE(v->data); v->data_len = sizeof(TDS_NUMERIC); num = tds_new0(TDS_NUMERIC, 1); v->data = (TDS_CHAR *) num; num->precision = tds_get_byte(tds); num->scale = tds_get_byte(tds); colsize -= 2; /* check prec/scale, don't let server crash us */ if (num->precision < 1 || num->precision > MAXPRECISION || num->scale > num->precision) goto error_type; if (colsize > sizeof(num->array)) goto error_type; curcol->column_cur_size = colsize; tds_get_n(tds, num->array, colsize); if (IS_TDS7_PLUS(tds->conn)) tds_swap_numeric(num); return TDS_SUCCESS; } /* special case for MS date/time */ switch (type) { case SYBMSTIME: case SYBMSDATETIME2: case SYBMSDATETIMEOFFSET: if (info_len != 1) goto error_type; curcol->column_scale = curcol->column_prec = tds_get_byte(tds); if (curcol->column_prec > 7) goto error_type; colsize -= info_len; info_len = 0; /* fall through */ case SYBMSDATE: if (info_len != 0) goto error_type; /* dirty trick */ tds->in_buf[--tds->in_pos] = colsize; if (v->data) TDS_ZERO_FREE(v->data); v->data_len = sizeof(TDS_DATETIMEALL); v->data = tds_new0(TDS_CHAR, sizeof(TDS_DATETIMEALL)); curcol->column_type = type; curcol->column_data = (unsigned char *) v->data; /* trick, call get function */ rc = tds_msdatetime_get(tds, curcol); curcol->column_type = SYBVARIANT; curcol->column_data = (unsigned char *) v; return rc; default: break; } varint = (type == SYBUNIQUE) ? 0 : tds_get_varint_size(tds->conn, type); if (varint != info_len || varint > 2) goto error_type; switch (varint) { case 0: v->size = tds_get_size_by_type(type); break; case 1: v->size = tds_get_byte(tds); break; case 2: v->size = tds_get_smallint(tds); break; default: goto error_type; } colsize -= info_len; curcol->column_cur_size = colsize; if (v->data) TDS_ZERO_FREE(v->data); if (colsize) { TDSRET res; TDSDATAINSTREAM r; if (USE_ICONV && curcol->char_conv) v->type = tds_get_cardinal_type(type, 0); tds_datain_stream_init(&r, tds, colsize); res = tds_get_char_dynamic(tds, curcol, (void **) &v->data, colsize, &r.stream); if (TDS_FAILED(res)) return res; colsize = curcol->column_cur_size; #ifdef WORDS_BIGENDIAN if (tds->conn->emul_little_endian) tds_swap_datatype(tds_get_conversion_type(type, colsize), v->data); #endif } v->data_len = colsize; return TDS_SUCCESS; error_type: tds_get_n(tds, NULL, colsize); return TDS_FAIL; } /** * Read a data from wire * \param tds state information for the socket and the TDS protocol * \param curcol column where store column information * \return TDS_FAIL on error or TDS_SUCCESS */ TDSRET tds_generic_get(TDSSOCKET * tds, TDSCOLUMN * curcol) { unsigned char *dest; int len, colsize; int fillchar; TDSBLOB *blob = NULL; CHECK_TDS_EXTRA(tds); CHECK_COLUMN_EXTRA(curcol); tdsdump_log(TDS_DBG_INFO1, "tds_get_data: type %d, varint size %d\n", curcol->column_type, curcol->column_varint_size); switch (curcol->column_varint_size) { case 4: /* It's a BLOB... */ len = tds_get_byte(tds); blob = (TDSBLOB *) curcol->column_data; if (len == 16) { /* Jeff's hack */ tds_get_n(tds, blob->textptr, 16); tds_get_n(tds, blob->timestamp, 8); blob->valid_ptr = 1; if (IS_TDS72_PLUS(tds->conn) && memcmp(blob->textptr, "dummy textptr\0\0",16) == 0) blob->valid_ptr = 0; colsize = tds_get_int(tds); } else { colsize = -1; } break; case 5: colsize = tds_get_int(tds); if (colsize == 0) colsize = -1; break; case 8: return tds72_get_varmax(tds, curcol); case 2: colsize = tds_get_smallint(tds); break; case 1: colsize = tds_get_byte(tds); if (colsize == 0) colsize = -1; break; case 0: /* TODO this should be column_size */ colsize = tds_get_size_by_type(curcol->column_type); break; default: colsize = -1; break; } if (IS_TDSDEAD(tds)) return TDS_FAIL; tdsdump_log(TDS_DBG_INFO1, "tds_get_data(): wire column size is %d \n", colsize); /* set NULL flag in the row buffer */ if (colsize < 0) { curcol->column_cur_size = -1; return TDS_SUCCESS; } /* * We're now set to read the data from the wire. For varying types (e.g. char/varchar) * make sure that curcol->column_cur_size reflects the size of the read data, * after any charset conversion. tds_get_char_data() does that for you, * but of course tds_get_n() doesn't. * * colsize == wire_size, bytes to read * curcol->column_cur_size == sizeof destination buffer, room to write */ dest = curcol->column_data; if (is_blob_col(curcol)) { TDSDATAINSTREAM r; size_t allocated; TDSRET ret; blob = (TDSBLOB *) dest; /* cf. column_varint_size case 4, above */ /* empty string */ if (colsize == 0) { curcol->column_cur_size = 0; if (blob->textvalue) TDS_ZERO_FREE(blob->textvalue); return TDS_SUCCESS; } allocated = MAX(curcol->column_cur_size, 0); if (colsize > allocated) { TDS_ZERO_FREE(blob->textvalue); allocated = colsize; if (is_unicode_type(curcol->on_server.column_type)) allocated /= 2; } tds_datain_stream_init(&r, tds, colsize); ret = tds_get_char_dynamic(tds, curcol, (void **) &blob->textvalue, allocated, &r.stream); if (TDS_FAILED(ret) && TDS_UNLIKELY(r.wire_size > 0)) { tds_get_n(tds, NULL, r.wire_size); return ret; } return TDS_SUCCESS; } /* non-numeric and non-blob */ if (USE_ICONV && curcol->char_conv) { if (TDS_FAILED(tds_get_char_data(tds, (char *) dest, colsize, curcol))) return TDS_FAIL; } else { /* * special case, some servers seem to return more data in some conditions * (ASA 7 returning 4 byte nullable integer) */ int discard_len = 0; if (colsize > curcol->column_size) { discard_len = colsize - curcol->column_size; colsize = curcol->column_size; } if (tds_get_n(tds, dest, colsize) == NULL) return TDS_FAIL; if (discard_len > 0) tds_get_n(tds, NULL, discard_len); curcol->column_cur_size = colsize; } /* pad (UNI)CHAR and BINARY types */ fillchar = 0; switch (curcol->column_type) { /* extra handling for SYBLONGBINARY */ case SYBLONGBINARY: if (curcol->column_usertype != USER_UNICHAR_TYPE) break; case SYBCHAR: case XSYBCHAR: if (curcol->column_size != curcol->on_server.column_size) break; /* FIXME use client charset */ fillchar = ' '; case SYBBINARY: case XSYBBINARY: if (colsize < curcol->column_size) memset(dest + colsize, fillchar, curcol->column_size - colsize); colsize = curcol->column_size; break; default: break; } #ifdef WORDS_BIGENDIAN if (tds->conn->emul_little_endian) { tdsdump_log(TDS_DBG_INFO1, "swapping coltype %d\n", tds_get_conversion_type(curcol->column_type, colsize)); tds_swap_datatype(tds_get_conversion_type(curcol->column_type, colsize), dest); } #endif return TDS_SUCCESS; } /** * Put data information to wire * \param tds state information for the socket and the TDS protocol * \param col column where to store information * \return TDS_SUCCESS or TDS_FAIL */ TDSRET tds_generic_put_info(TDSSOCKET * tds, TDSCOLUMN * col) { size_t size; CHECK_TDS_EXTRA(tds); CHECK_COLUMN_EXTRA(col); size = tds_fix_column_size(tds, col); switch (col->column_varint_size) { case 0: break; case 1: tds_put_byte(tds, size); break; case 2: tds_put_smallint(tds, size); break; case 5: case 4: tds_put_int(tds, size); break; case 8: tds_put_smallint(tds, 0xffff); break; } /* TDS5 wants a table name for LOBs */ if (IS_TDS50(tds->conn) && (col->on_server.column_type == SYBIMAGE || col->on_server.column_type == SYBTEXT)) tds_put_smallint(tds, 0); /* TDS7.1 output collate information */ if (IS_TDS71_PLUS(tds->conn) && is_collate_type(col->on_server.column_type)) tds_put_n(tds, tds->conn->collation, 5); return TDS_SUCCESS; } unsigned tds_generic_put_info_len(TDSSOCKET * tds, TDSCOLUMN * col) { unsigned len = col->column_varint_size; CHECK_TDS_EXTRA(tds); CHECK_COLUMN_EXTRA(col); switch (col->column_varint_size) { case 5: len = 4; break; case 8: len = 2; break; } if (IS_TDS50(tds->conn) && (col->on_server.column_type == SYBIMAGE || col->on_server.column_type == SYBTEXT)) len += 2; /* TDS7.1 output collate information */ if (IS_TDS71_PLUS(tds->conn) && is_collate_type(col->on_server.column_type)) len += 5; return len; } /** * Write data to wire * \param tds state information for the socket and the TDS protocol * \param curcol column where store column information * \return TDS_FAIL on error or TDS_SUCCESS */ TDSRET tds_generic_put(TDSSOCKET * tds, TDSCOLUMN * curcol, int bcp7) { unsigned char *src; TDSBLOB *blob = NULL; size_t colsize, size; const char *s; int converted = 0; CHECK_TDS_EXTRA(tds); CHECK_COLUMN_EXTRA(curcol); tdsdump_log(TDS_DBG_INFO1, "tds_generic_put: colsize = %d\n", (int) curcol->column_cur_size); /* output NULL data */ if (curcol->column_cur_size < 0) { tdsdump_log(TDS_DBG_INFO1, "tds_generic_put: null param\n"); switch (curcol->column_varint_size) { case 5: tds_put_int(tds, 0); break; case 4: if ((bcp7 || !IS_TDS7_PLUS(tds->conn)) && is_blob_type(curcol->on_server.column_type)) tds_put_byte(tds, 0); else tds_put_int(tds, -1); break; case 2: tds_put_smallint(tds, -1); break; case 8: tds_put_int8(tds, -1); break; default: assert(curcol->column_varint_size); /* FIXME not good for SYBLONGBINARY/SYBLONGCHAR (still not supported) */ tds_put_byte(tds, 0); break; } return TDS_SUCCESS; } colsize = curcol->column_cur_size; size = tds_fix_column_size(tds, curcol); src = curcol->column_data; if (is_blob_col(curcol)) { blob = (TDSBLOB *) src; src = (unsigned char *) blob->textvalue; } s = (char *) src; /* convert string if needed */ if (!bcp7 && curcol->char_conv && curcol->char_conv->flags != TDS_ENCODING_MEMCPY && colsize) { size_t output_size; #if 0 /* TODO this case should be optimized */ /* we know converted bytes */ if (curcol->char_conv->client_charset.min_bytes_per_char == curcol->char_conv->client_charset.max_bytes_per_char && curcol->char_conv->server_charset.min_bytes_per_char == curcol->char_conv->server_charset.max_bytes_per_char) { converted_size = colsize * curcol->char_conv->server_charset.min_bytes_per_char / curcol->char_conv->client_charset.min_bytes_per_char; } else { #endif /* we need to convert data before */ /* TODO this can be a waste of memory... */ converted = 1; s = tds_convert_string(tds, curcol->char_conv, s, colsize, &output_size); colsize = (TDS_INT)output_size; if (!s) { /* on conversion error put a empty string */ /* TODO on memory failure we should compute converted size and use chunks */ colsize = 0; converted = -1; } } /* * TODO here we limit data sent with MIN, should mark somewhere * and inform client ?? * Test proprietary behavior */ if (IS_TDS7_PLUS(tds->conn)) { tdsdump_log(TDS_DBG_INFO1, "tds_generic_put: not null param varint_size = %d\n", curcol->column_varint_size); switch (curcol->column_varint_size) { case 8: /* this difference for BCP operation is due to * a bug in different server version that does * not accept a length here */ tds_put_int8(tds, bcp7 ? -2 : colsize); tds_put_int(tds, colsize); break; case 4: /* It's a BLOB... */ colsize = MIN(colsize, size); /* mssql require only size */ if (bcp7 && is_blob_type(curcol->on_server.column_type)) { static const unsigned char textptr[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; tds_put_byte(tds, 16); tds_put_n(tds, textptr, 16); tds_put_n(tds, textptr, 8); } tds_put_int(tds, colsize); break; case 2: colsize = MIN(colsize, size); tds_put_smallint(tds, colsize); break; case 1: colsize = MIN(colsize, size); tds_put_byte(tds, colsize); break; case 0: /* TODO should be column_size */ colsize = tds_get_size_by_type(curcol->on_server.column_type); break; } /* conversion error, exit with an error */ if (converted < 0) return TDS_FAIL; /* put real data */ if (blob) { tds_put_n(tds, s, colsize); } else { #ifdef WORDS_BIGENDIAN unsigned char buf[64]; if (tds->conn->emul_little_endian && !converted && colsize < 64) { tdsdump_log(TDS_DBG_INFO1, "swapping coltype %d\n", tds_get_conversion_type(curcol->column_type, colsize)); memcpy(buf, s, colsize); tds_swap_datatype(tds_get_conversion_type(curcol->column_type, colsize), buf); s = (char *) buf; } #endif tds_put_n(tds, s, colsize); } /* finish chunk for varchar/varbinary(max) */ if (curcol->column_varint_size == 8 && colsize) tds_put_int(tds, 0); } else { /* TODO ICONV handle charset conversions for data */ /* put size of data */ switch (curcol->column_varint_size) { case 5: /* It's a LONGBINARY */ colsize = MIN(colsize, 0x7fffffff); tds_put_int(tds, colsize); break; case 4: /* It's a BLOB... */ tds_put_byte(tds, 16); tds_put_n(tds, blob->textptr, 16); tds_put_n(tds, blob->timestamp, 8); colsize = MIN(colsize, 0x7fffffff); tds_put_int(tds, colsize); break; case 2: colsize = MIN(colsize, 8000); tds_put_smallint(tds, colsize); break; case 1: if (!colsize) { tds_put_byte(tds, 1); if (is_char_type(curcol->column_type)) tds_put_byte(tds, ' '); else tds_put_byte(tds, 0); if (converted > 0) tds_convert_string_free((char*)src, s); return TDS_SUCCESS; } colsize = MIN(colsize, 255); tds_put_byte(tds, colsize); break; case 0: /* TODO should be column_size */ colsize = tds_get_size_by_type(curcol->column_type); break; } /* conversion error, exit with an error */ if (converted < 0) return TDS_FAIL; /* put real data */ if (blob) { tds_put_n(tds, s, colsize); } else { #ifdef WORDS_BIGENDIAN unsigned char buf[64]; if (tds->conn->emul_little_endian && !converted && colsize < 64) { tdsdump_log(TDS_DBG_INFO1, "swapping coltype %d\n", tds_get_conversion_type(curcol->column_type, colsize)); memcpy(buf, s, colsize); tds_swap_datatype(tds_get_conversion_type(curcol->column_type, colsize), buf); s = (char *) buf; } #endif tds_put_n(tds, s, colsize); } } if (converted > 0) tds_convert_string_free((char*)src, s); return TDS_SUCCESS; } TDSRET tds_numeric_get_info(TDSSOCKET *tds, TDSCOLUMN *col) { col->column_size = tds_get_byte(tds); col->column_prec = tds_get_byte(tds); /* precision */ col->column_scale = tds_get_byte(tds); /* scale */ /* check prec/scale, don't let server crash us */ if (col->column_prec < 1 || col->column_prec > MAXPRECISION || col->column_scale > col->column_prec) return TDS_FAIL; return TDS_SUCCESS; } TDS_INT tds_numeric_row_len(TDSCOLUMN *col) { return sizeof(TDS_NUMERIC); } TDSRET tds_numeric_get(TDSSOCKET * tds, TDSCOLUMN * curcol) { int colsize; TDS_NUMERIC *num; CHECK_TDS_EXTRA(tds); CHECK_COLUMN_EXTRA(curcol); colsize = tds_get_byte(tds); /* set NULL flag in the row buffer */ if (colsize <= 0) { curcol->column_cur_size = -1; return TDS_SUCCESS; } /* * Since these can be passed around independent * of the original column they came from, we embed the TDS_NUMERIC datatype in the row buffer * instead of using the wire representation, even though it uses a few more bytes. */ num = (TDS_NUMERIC *) curcol->column_data; memset(num, '\0', sizeof(TDS_NUMERIC)); /* TODO perhaps it would be fine to change format ?? */ num->precision = curcol->column_prec; num->scale = curcol->column_scale; /* server is going to crash freetds ?? */ /* TODO close connection it server try to do so ?? */ if (colsize > sizeof(num->array)) return TDS_FAIL; tds_get_n(tds, num->array, colsize); if (IS_TDS7_PLUS(tds->conn)) tds_swap_numeric(num); /* corrected colsize for column_cur_size */ curcol->column_cur_size = sizeof(TDS_NUMERIC); return TDS_SUCCESS; } TDSRET tds_numeric_put_info(TDSSOCKET * tds, TDSCOLUMN * col) { CHECK_TDS_EXTRA(tds); CHECK_COLUMN_EXTRA(col); #if 1 tds_put_byte(tds, tds_numeric_bytes_per_prec[col->column_prec]); tds_put_byte(tds, col->column_prec); tds_put_byte(tds, col->column_scale); #else TDS_NUMERIC *num = (TDS_NUMERIC *) col->column_data; tds_put_byte(tds, tds_numeric_bytes_per_prec[num->precision]); tds_put_byte(tds, num->precision); tds_put_byte(tds, num->scale); #endif return TDS_SUCCESS; } unsigned tds_numeric_put_info_len(TDSSOCKET * tds, TDSCOLUMN * col) { CHECK_TDS_EXTRA(tds); CHECK_COLUMN_EXTRA(col); return 3; } TDSRET tds_numeric_put(TDSSOCKET *tds, TDSCOLUMN *col, int bcp7) { TDS_NUMERIC *num = (TDS_NUMERIC *) col->column_data, buf; unsigned char colsize; if (col->column_cur_size < 0) { tds_put_byte(tds, 0); return TDS_SUCCESS; } colsize = tds_numeric_bytes_per_prec[num->precision]; tds_put_byte(tds, colsize); buf = *num; if (IS_TDS7_PLUS(tds->conn)) tds_swap_numeric(&buf); tds_put_n(tds, buf.array, colsize); return TDS_SUCCESS; } TDSRET tds_variant_put_info(TDSSOCKET * tds, TDSCOLUMN * col) { /* TODO */ return TDS_FAIL; } TDSRET tds_variant_put(TDSSOCKET *tds, TDSCOLUMN *col, int bcp7) { /* TODO */ return TDS_FAIL; } TDSRET tds_msdatetime_get_info(TDSSOCKET * tds, TDSCOLUMN * col) { col->column_scale = col->column_prec = 0; if (col->column_type != SYBMSDATE) { col->column_scale = col->column_prec = tds_get_byte(tds); if (col->column_prec > 7) return TDS_FAIL; } col->on_server.column_size = col->column_size = sizeof(TDS_DATETIMEALL); return TDS_SUCCESS; } TDS_INT tds_msdatetime_row_len(TDSCOLUMN *col) { return sizeof(TDS_DATETIMEALL); } TDSRET tds_msdatetime_get(TDSSOCKET * tds, TDSCOLUMN * col) { TDS_DATETIMEALL *dt = (TDS_DATETIMEALL*) col->column_data; int size = tds_get_byte(tds); if (size == 0) { col->column_cur_size = -1; return TDS_SUCCESS; } memset(dt, 0, sizeof(*dt)); if (col->column_type == SYBMSDATETIMEOFFSET) size -= 2; if (col->column_type != SYBMSTIME) size -= 3; if (size < 0) return TDS_FAIL; dt->time_prec = col->column_prec; /* get time part */ if (col->column_type != SYBMSDATE) { TDS_UINT8 u8; int i; if (size < 3 || size > 5) return TDS_FAIL; u8 = 0; tds_get_n(tds, &u8, size); #ifdef WORDS_BIGENDIAN tds_swap_bytes(&u8, 8); #endif for (i = col->column_prec; i < 7; ++i) u8 *= 10; dt->time = u8; dt->has_time = 1; } else if (size != 0) return TDS_FAIL; /* get date part */ if (col->column_type != SYBMSTIME) { TDS_UINT ui; ui = 0; tds_get_n(tds, &ui, 3); #ifdef WORDS_BIGENDIAN tds_swap_bytes(&ui, 4); #endif dt->has_date = 1; dt->date = ui - 693595; } /* get time offset */ if (col->column_type == SYBMSDATETIMEOFFSET) { dt->offset = tds_get_smallint(tds); if (dt->offset > 840 || dt->offset < -840) return TDS_FAIL; dt->has_offset = 1; } col->column_cur_size = sizeof(TDS_DATETIMEALL); return TDS_SUCCESS; } TDSRET tds_msdatetime_put_info(TDSSOCKET * tds, TDSCOLUMN * col) { /* TODO precision */ if (col->on_server.column_type != SYBMSDATE) tds_put_byte(tds, 7); return TDS_SUCCESS; } TDSRET tds_msdatetime_put(TDSSOCKET *tds, TDSCOLUMN *col, int bcp7) { const TDS_DATETIMEALL *dta = (const TDS_DATETIMEALL *) col->column_data; unsigned char buf[12], *p; if (col->column_cur_size < 0) { tds_put_byte(tds, 0); return TDS_SUCCESS; } /* TODO precision */ p = buf + 1; if (col->on_server.column_type != SYBMSDATE) { TDS_PUT_UA4LE(p, (TDS_UINT) dta->time); p[4] = (unsigned char) (dta->time >> 32); p += 5; } if (col->on_server.column_type != SYBMSTIME) { TDS_UINT ui = dta->date + 693595; TDS_PUT_UA4LE(p, ui); p += 3; } if (col->on_server.column_type == SYBMSDATETIMEOFFSET) { TDS_PUT_UA2LE(p, dta->offset); p += 2; } buf[0] = p - buf - 1; tds_put_n(tds, buf, p - buf); return TDS_SUCCESS; } TDSRET tds_clrudt_get_info(TDSSOCKET * tds, TDSCOLUMN * col) { /* TODO save fields */ /* FIXME support RPC */ /* MAX_BYTE_SIZE */ tds_get_usmallint(tds); /* DB_NAME */ tds_get_string(tds, tds_get_byte(tds), NULL, 0); /* SCHEMA_NAME */ tds_get_string(tds, tds_get_byte(tds), NULL, 0); /* TYPE_NAME */ tds_get_string(tds, tds_get_byte(tds), NULL, 0); /* UDT_METADATA */ tds_get_string(tds, tds_get_usmallint(tds), NULL, 0); col->column_size = 0x7ffffffflu; return TDS_SUCCESS; } TDS_INT tds_clrudt_row_len(TDSCOLUMN *col) { /* TODO save other fields */ return sizeof(TDSBLOB); } TDSRET tds_clrudt_put_info(TDSSOCKET * tds, TDSCOLUMN * col) { /* FIXME support properly*/ tds_put_byte(tds, 0); /* db_name */ tds_put_byte(tds, 0); /* schema_name */ tds_put_byte(tds, 0); /* type_name */ return TDS_SUCCESS; } TDSRET tds_sybbigtime_get_info(TDSSOCKET * tds, TDSCOLUMN * col) { col->column_scale = col->column_prec = 6; tds_get_byte(tds); /* 8, size */ tds_get_byte(tds); /* 6, precision ?? */ col->on_server.column_size = col->column_size = sizeof(TDS_UINT8); return TDS_SUCCESS; } TDS_INT tds_sybbigtime_row_len(TDSCOLUMN *col) { return sizeof(TDS_UINT8); } TDSRET tds_sybbigtime_get(TDSSOCKET * tds, TDSCOLUMN * col) { TDS_UINT8 *dt = (TDS_UINT8 *) col->column_data; int size = tds_get_byte(tds); if (size == 0) { col->column_cur_size = -1; return TDS_SUCCESS; } col->column_cur_size = sizeof(TDS_UINT8); *dt = tds_get_int8(tds); return TDS_SUCCESS; } TDSRET tds_sybbigtime_put_info(TDSSOCKET * tds, TDSCOLUMN * col) { tds_put_byte(tds, 8); tds_put_byte(tds, 6); return TDS_SUCCESS; } unsigned tds_sybbigtime_put_info_len(TDSSOCKET * tds, TDSCOLUMN * col) { return 2; } TDSRET tds_sybbigtime_put(TDSSOCKET *tds, TDSCOLUMN *col, int bcp7) { const TDS_UINT8 *dt = (const TDS_UINT8 *) col->column_data; if (col->column_cur_size < 0) { tds_put_byte(tds, 0); return TDS_SUCCESS; } tds_put_byte(tds, 8); tds_put_int8(tds, *dt); return TDS_SUCCESS; } TDSRET tds_invalid_get_info(TDSSOCKET * tds, TDSCOLUMN * col) { return TDS_FAIL; } TDS_INT tds_invalid_row_len(TDSCOLUMN *col) { return 0; } TDSRET tds_invalid_get(TDSSOCKET * tds, TDSCOLUMN * col) { return TDS_FAIL; } TDSRET tds_invalid_put_info(TDSSOCKET * tds, TDSCOLUMN * col) { return TDS_FAIL; } unsigned tds_invalid_put_info_len(TDSSOCKET * tds, TDSCOLUMN * col) { return 0; } TDSRET tds_invalid_put(TDSSOCKET *tds, TDSCOLUMN *col, int bcp7) { return TDS_FAIL; } #if ENABLE_EXTRA_CHECKS int tds_generic_check(const TDSCOLUMN *col) { return 0; } int tds_sybbigtime_check(const TDSCOLUMN *col) { assert(col->column_type == col->on_server.column_type); assert(col->on_server.column_size == col->column_size); assert(!is_numeric_type(col->column_type)); assert(!is_fixed_type(col->column_type)); assert(!is_blob_type(col->column_type)); assert(!is_variable_type(col->column_type)); assert(is_nullable_type(col->column_type)); assert(col->column_varint_size == 1); assert(col->column_prec == 6); assert(col->column_scale == col->column_prec); return 1; } int tds_clrudt_check(const TDSCOLUMN *col) { return 0; } int tds_msdatetime_check(const TDSCOLUMN *col) { assert(col->column_type == col->on_server.column_type); assert(col->on_server.column_size == col->column_size); assert(!is_numeric_type(col->column_type)); if (col->column_type == SYBMSDATE) { assert(is_fixed_type(col->column_type)); } else { assert(!is_fixed_type(col->column_type)); } assert(!is_blob_type(col->column_type)); assert(!is_variable_type(col->column_type)); assert(is_nullable_type(col->column_type)); assert(col->column_varint_size == 1); assert(col->column_prec >= 0 && col->column_prec <= 7); assert(col->column_scale == col->column_prec); return 1; } int tds_variant_check(const TDSCOLUMN *col) { return 0; } int tds_numeric_check(const TDSCOLUMN *col) { assert(col->column_type == col->on_server.column_type); assert(col->on_server.column_size == col->column_size); assert(is_numeric_type(col->column_type)); assert(!is_fixed_type(col->column_type)); assert(!is_blob_type(col->column_type)); assert(!is_variable_type(col->column_type)); assert(col->column_varint_size == 1); assert(col->column_prec >= 1 && col->column_prec <= MAXPRECISION); assert(col->column_scale <= col->column_prec); return 1; } int tds_invalid_check(const TDSCOLUMN *col) { return 1; } #endif #define TDS_DECLARE_FUNCS(name) \ extern const TDSCOLUMNFUNCS tds_ ## name ## _funcs #include TDS_DECLARE_FUNCS(generic); TDS_DECLARE_FUNCS(numeric); TDS_DECLARE_FUNCS(variant); TDS_DECLARE_FUNCS(msdatetime); TDS_DECLARE_FUNCS(clrudt); TDS_DECLARE_FUNCS(sybbigtime); TDS_DECLARE_FUNCS(invalid); #include static const TDSCOLUMNFUNCS * tds_get_column_funcs(TDSCONNECTION *conn, int type) { switch (type) { case SYBNUMERIC: case SYBDECIMAL: return &tds_numeric_funcs; case SYBMSUDT: return &tds_clrudt_funcs; case SYBVARIANT: if (IS_TDS7_PLUS(conn)) return &tds_variant_funcs; break; case SYBMSDATE: case SYBMSTIME: case SYBMSDATETIME2: case SYBMSDATETIMEOFFSET: return &tds_msdatetime_funcs; case SYB5BIGTIME: case SYB5BIGDATETIME: return &tds_sybbigtime_funcs; } return &tds_generic_funcs; } #include "tds_types.h" #ifdef WORDS_BIGENDIAN static void tds_swap_datatype(int coltype, void *b) { unsigned char *buf = (unsigned char *) b; switch (coltype) { case SYBDATETIME4: tds_swap_bytes(&buf[2], 2); case SYBINT2: tds_swap_bytes(buf, 2); break; case SYBMONEY: case SYBDATETIME: tds_swap_bytes(&buf[4], 4); case SYBINT4: case SYBMONEY4: case SYBREAL: case SYBDATE: case SYBTIME: tds_swap_bytes(buf, 4); break; case SYBINT8: case SYBFLT8: case SYB5BIGTIME: case SYB5BIGDATETIME: tds_swap_bytes(buf, 8); break; case SYBUNIQUE: tds_swap_bytes(buf, 4); tds_swap_bytes(&buf[4], 2); tds_swap_bytes(&buf[6], 2); break; } } #endif /** * Converts numeric from Microsoft representation to internal one (Sybase). * \param num numeric data to convert */ static void tds_swap_numeric(TDS_NUMERIC *num) { /* swap the sign */ num->array[0] = (num->array[0] == 0) ? 1 : 0; /* swap the data */ tds_swap_bytes(&(num->array[1]), tds_numeric_bytes_per_prec[num->precision] - 1); } freetds-1.00.82/src/tds/net.c100644 025423 025423 00000073060 13176306423 0011354/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Brian Bruns * Copyright (C) 2004-2015 Ziglio Frediano * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #include #if HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #if HAVE_ERRNO_H #include #endif /* HAVE_ERRNO_H */ #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #if HAVE_NETINET_IN_H #include #endif /* HAVE_NETINET_IN_H */ #if HAVE_NETINET_TCP_H #include #endif /* HAVE_NETINET_TCP_H */ #if HAVE_ARPA_INET_H #include #endif /* HAVE_ARPA_INET_H */ #if HAVE_SYS_IOCTL_H #include #endif /* HAVE_SYS_IOCTL_H */ #if HAVE_SELECT_H #include #endif /* HAVE_SELECT_H */ #if HAVE_POLL_H #include #endif /* HAVE_POLL_H */ #if HAVE_FCNTL_H #include #endif /* HAVE_FCNTL_H */ #ifdef HAVE_SYS_EVENTFD_H #include #endif /* HAVE_SYS_EVENTFD_H */ #ifdef _WIN32 #include #include #include #endif #include #include #include #include "replacements.h" #include #include /* error is always returned */ #define TDSSELERR 0 #define TDSPOLLURG 0x8000u #if ENABLE_ODBC_MARS static void tds_check_cancel(TDSCONNECTION *conn); #endif /** * \addtogroup network * @{ */ #ifdef _WIN32 int tds_socket_init(void) { WSADATA wsadata; return WSAStartup(MAKEWORD(1, 1), &wsadata); } void tds_socket_done(void) { WSACleanup(); } #endif #if !defined(SOL_TCP) && (defined(IPPROTO_TCP) || defined(_WIN32)) /* fix incompatibility between MS headers */ # ifndef IPPROTO_TCP # define IPPROTO_TCP IPPROTO_TCP # endif # define SOL_TCP IPPROTO_TCP #endif /* Optimize the way we send packets */ #undef USE_CORK #undef USE_NODELAY /* On early Linux use TCP_CORK if available */ #if defined(__linux__) && defined(TCP_CORK) #define USE_CORK 1 /* On *BSD try to use TCP_CORK */ /* * NOPUSH flag do not behave in the same way * cf ML "FreeBSD 5.0 performance problems with TCP_NOPUSH" */ #elif (defined(__FreeBSD__) || defined(__GNU_FreeBSD__) || defined(__OpenBSD__)) && defined(TCP_CORK) #define USE_CORK 1 /* otherwise use NODELAY */ #elif defined(TCP_NODELAY) && defined(SOL_TCP) #define USE_NODELAY 1 /* under VMS we have to define TCP_NODELAY */ #elif defined(__VMS) #define TCP_NODELAY 1 #define USE_NODELAY 1 #endif /** * Set socket to non-blocking * @param sock socket to set * @return 0 on success or error code */ int tds_socket_set_nonblocking(TDS_SYS_SOCKET sock) { #if !defined(_WIN32) unsigned int ioctl_nonblocking = 1; #else u_long ioctl_nonblocking = 1; #endif if (IOCTLSOCKET(sock, FIONBIO, &ioctl_nonblocking) >= 0) return 0; return sock_errno; } static void tds_addrinfo_set_port(struct addrinfo *addr, unsigned int port) { assert(addr != NULL); switch(addr->ai_family) { case AF_INET: ((struct sockaddr_in *) addr->ai_addr)->sin_port = htons(port); break; #ifdef AF_INET6 case AF_INET6: ((struct sockaddr_in6 *) addr->ai_addr)->sin6_port = htons(port); break; #endif } } const char* tds_addrinfo2str(struct addrinfo *addr, char *name, int namemax) { #ifndef NI_NUMERICHOST #define NI_NUMERICHOST 0 #endif if (!name || namemax <= 0) return ""; if (getnameinfo(addr->ai_addr, addr->ai_addrlen, name, namemax, NULL, 0, NI_NUMERICHOST) == 0) return name; name[0] = 0; return name; } static TDSERRNO tds_connect_socket(TDSSOCKET *tds, struct addrinfo *addr, unsigned int port, int timeout, int *p_oserr) { SOCKLEN_T optlen; TDSCONNECTION *conn = tds->conn; char ipaddr[128]; int retval, len; tds_addrinfo_set_port(addr, port); tds_addrinfo2str(addr, ipaddr, sizeof(ipaddr)); if (TDS_IS_SOCKET_INVALID(conn->s)) return TDSECONN; *p_oserr = 0; tdsdump_log(TDS_DBG_INFO1, "Connecting to %s port %d (TDS version %d.%d)\n", ipaddr, port, TDS_MAJOR(conn), TDS_MINOR(conn)); #ifdef DOS32X /* the other connection doesn't work on WATTCP32 */ if (connect(conn->s, addr->ai_addr, addr->ai_addrlen) < 0) { *p_oserr = sock_errno; tdsdump_log(TDS_DBG_ERROR, "tds_open_socket(): %s:%d", ipaddr, port); return TDSECONN; } #else if (!timeout) { /* A timeout of zero means wait forever; 90,000 seconds will feel like forever. */ timeout = 90000; } if ((*p_oserr = tds_socket_set_nonblocking(conn->s)) != 0) { tds_connection_close(conn); return TDSEUSCT; /* close enough: "Unable to set communications timer" */ } retval = connect(conn->s, addr->ai_addr, addr->ai_addrlen); if (retval == 0) { tdsdump_log(TDS_DBG_INFO2, "connection established\n"); } else { int err = *p_oserr = sock_errno; char *errstr = sock_strerror(err); tdsdump_log(TDS_DBG_ERROR, "tds_open_socket: connect(2) returned \"%s\"\n", errstr); sock_strerror_free(errstr); #if DEBUGGING_CONNECTING_PROBLEM if (err != ECONNREFUSED && err != ENETUNREACH && err != TDSSOCK_EINPROGRESS) { tdsdump_dump_buf(TDS_DBG_ERROR, "Contents of sockaddr_in", addr->ai_addr, addr->ai_addrlen); tdsdump_log(TDS_DBG_ERROR, " sockaddr_in:\t" "%s = %x\n" "\t\t\t%s = %x\n" "\t\t\t%s = %s\n" , "sin_family", addr->ai_family , "port", port , "address", ipaddr ); } #endif if (err != TDSSOCK_EINPROGRESS) return TDSECONN; *p_oserr = TDSSOCK_ETIMEDOUT; if (tds_select(tds, TDSSELWRITE|TDSSELERR, timeout) == 0) return TDSECONN; } #endif /* not DOS32X */ /* check socket error */ optlen = sizeof(len); len = 0; if (tds_getsockopt(conn->s, SOL_SOCKET, SO_ERROR, (char *) &len, &optlen) != 0) { char *errstr = sock_strerror(*p_oserr = sock_errno); tdsdump_log(TDS_DBG_ERROR, "getsockopt(2) failed: %s\n", errstr); sock_strerror_free(errstr); return TDSECONN; } if (len != 0) { char *errstr = sock_strerror(*p_oserr = len); tdsdump_log(TDS_DBG_ERROR, "getsockopt(2) reported: %s\n", errstr); sock_strerror_free(errstr); return TDSECONN; } return TDSEOK; } TDSERRNO tds_open_socket(TDSSOCKET *tds, struct addrinfo *addr, unsigned int port, int timeout, int *p_oserr) { enum { TDS_SOCKET_KEEPALIVE_IDLE = 40, TDS_SOCKET_KEEPALIVE_INTERVAL = 2 }; TDSCONNECTION *conn = tds->conn; int len; TDSERRNO tds_error; #if defined(_WIN32) struct tcp_keepalive keepalive = { TRUE, TDS_SOCKET_KEEPALIVE_IDLE * 1000, TDS_SOCKET_KEEPALIVE_INTERVAL * 1000 }; DWORD written; #endif *p_oserr = 0; conn->s = socket(addr->ai_family, SOCK_STREAM, 0); if (TDS_IS_SOCKET_INVALID(conn->s)) { char *errstr = sock_strerror(*p_oserr = sock_errno); tdsdump_log(TDS_DBG_ERROR, "socket creation error: %s\n", errstr); sock_strerror_free(errstr); return TDSESOCK; } tds->state = TDS_IDLE; #ifdef SO_KEEPALIVE len = 1; setsockopt(conn->s, SOL_SOCKET, SO_KEEPALIVE, (const void *) &len, sizeof(len)); #endif #if defined(_WIN32) if (WSAIoctl(conn->s, SIO_KEEPALIVE_VALS, &keepalive, sizeof(keepalive), NULL, 0, &written, NULL, NULL) != 0) { char *errstr = sock_strerror(*p_oserr = sock_errno); tdsdump_log(TDS_DBG_ERROR, "error setting keepalive: %s\n", errstr); sock_strerror_free(errstr); } #elif defined(TCP_KEEPIDLE) && defined(TCP_KEEPINTVL) len = TDS_SOCKET_KEEPALIVE_IDLE; setsockopt(conn->s, SOL_TCP, TCP_KEEPIDLE, (const void *) &len, sizeof(len)); len = TDS_SOCKET_KEEPALIVE_INTERVAL; setsockopt(conn->s, SOL_TCP, TCP_KEEPINTVL, (const void *) &len, sizeof(len)); #endif #if defined(__APPLE__) && defined(SO_NOSIGPIPE) len = 1; if (setsockopt(conn->s, SOL_SOCKET, SO_NOSIGPIPE, (const void *) &len, sizeof(len))) { *p_oserr = sock_errno; tds_connection_close(conn); return TDSESOCK; } #endif len = 1; #if defined(USE_NODELAY) setsockopt(conn->s, SOL_TCP, TCP_NODELAY, (const void *) &len, sizeof(len)); #elif defined(USE_CORK) if (setsockopt(conn->s, SOL_TCP, TCP_CORK, (const void *) &len, sizeof(len)) < 0) setsockopt(conn->s, SOL_TCP, TCP_NODELAY, (const void *) &len, sizeof(len)); #else #error One should be defined #endif while ((tds_error = tds_connect_socket(tds, addr, port, timeout, p_oserr)) != TDSEOK) { addr = addr->ai_next; if (!addr) { tds_connection_close(conn); tdsdump_log(TDS_DBG_ERROR, "tds_open_socket() failed\n"); return tds_error; } } tdsdump_log(TDS_DBG_INFO2, "tds_open_socket() succeeded\n"); return TDSEOK; } /** * Close current socket. * For last socket close entire connection. * For MARS send FIN request. * This attempts a graceful disconnection, for ungraceful call * tds_connection_close. */ void tds_close_socket(TDSSOCKET * tds) { if (!IS_TDSDEAD(tds)) { #if ENABLE_ODBC_MARS TDSCONNECTION *conn = tds->conn; unsigned n = 0, count = 0; tds_mutex_lock(&conn->list_mtx); for (; n < conn->num_sessions; ++n) if (TDSSOCKET_VALID(conn->sessions[n])) ++count; if (count > 1) tds_append_fin(tds); tds_mutex_unlock(&conn->list_mtx); if (count <= 1) { tds_disconnect(tds); tds_connection_close(conn); } else { tds_set_state(tds, TDS_DEAD); } #else tds_disconnect(tds); if (CLOSESOCKET(tds_get_s(tds)) == -1) tdserror(tds_get_ctx(tds), tds, TDSECLOS, sock_errno); tds_set_s(tds, INVALID_SOCKET); tds_set_state(tds, TDS_DEAD); #endif } } void tds_connection_close(TDSCONNECTION *conn) { #if ENABLE_ODBC_MARS unsigned n = 0; #endif if (!TDS_IS_SOCKET_INVALID(conn->s)) { /* TODO check error ?? how to return it ?? */ CLOSESOCKET(conn->s); conn->s = INVALID_SOCKET; } #if ENABLE_ODBC_MARS tds_mutex_lock(&conn->list_mtx); for (; n < conn->num_sessions; ++n) if (TDSSOCKET_VALID(conn->sessions[n])) tds_set_state(conn->sessions[n], TDS_DEAD); tds_mutex_unlock(&conn->list_mtx); #else tds_set_state((TDSSOCKET* ) conn, TDS_DEAD); #endif } /** * Select on a socket until it's available or the timeout expires. * Meanwhile, call the interrupt function. * \return >0 ready descriptors * 0 timeout * <0 error (cf. errno). Caller should close socket and return failure. * This function does not call tdserror or close the socket because it can't know the context in which it's being called. */ int tds_select(TDSSOCKET * tds, unsigned tds_sel, int timeout_seconds) { int rc, seconds; unsigned int poll_seconds; assert(tds != NULL); assert(timeout_seconds >= 0); /* * The select loop. * If an interrupt handler is installed, we iterate once per second, * else we try once, timing out after timeout_seconds (0 == never). * If select(2) is interrupted by a signal (e.g. press ^C in sqsh), we timeout. * (The application can retry if desired by installing a signal handler.) * * We do not measure current time against end time, to avoid being tricked by ntpd(8) or similar. * Instead, we just count down. * * We exit on the first of these events: * 1. a descriptor is ready. (return to caller) * 2. select(2) returns an important error. (return to caller) * A timeout of zero says "wait forever". We do that by passing a NULL timeval pointer to select(2). */ poll_seconds = (tds_get_ctx(tds) && tds_get_ctx(tds)->int_handler)? 1 : timeout_seconds; for (seconds = timeout_seconds; timeout_seconds == 0 || seconds > 0; seconds -= poll_seconds) { struct pollfd fds[2]; int timeout = poll_seconds ? poll_seconds * 1000 : -1; if (TDS_IS_SOCKET_INVALID(tds_get_s(tds))) return -1; if ((tds_sel & TDSSELREAD) != 0 && tds->conn->tls_session && tds_ssl_pending(tds->conn)) return POLLIN; fds[0].fd = tds_get_s(tds); fds[0].events = tds_sel; fds[0].revents = 0; fds[1].fd = tds_wakeup_get_fd(&tds->conn->wakeup); fds[1].events = POLLIN; fds[1].revents = 0; rc = poll(fds, 2, timeout); if (rc > 0 ) { if (fds[0].revents & POLLERR) { set_sock_errno(TDSSOCK_ECONNRESET); return -1; } rc = fds[0].revents; if (fds[1].revents) { #if ENABLE_ODBC_MARS tds_check_cancel(tds->conn); #endif rc |= TDSPOLLURG; } return rc; } if (rc < 0) { char *errstr; switch (sock_errno) { case TDSSOCK_EINTR: /* FIXME this should be global maximun, not loop one */ seconds += poll_seconds; break; /* let interrupt handler be called */ default: /* documented: EFAULT, EBADF, EINVAL */ errstr = sock_strerror(sock_errno); tdsdump_log(TDS_DBG_ERROR, "error: poll(2) returned %d, \"%s\"\n", sock_errno, errstr); sock_strerror_free(errstr); return rc; } } assert(rc == 0 || (rc < 0 && sock_errno == TDSSOCK_EINTR)); if (tds_get_ctx(tds) && tds_get_ctx(tds)->int_handler) { /* interrupt handler installed */ /* * "If hndlintr() returns INT_CANCEL, DB-Library sends an attention token [TDS_BUFSTAT_ATTN] * to the server. This causes the server to discontinue command processing. * The server may send additional results that have already been computed. * When control returns to the mainline code, the mainline code should do * one of the following: * - Flush the results using dbcancel * - Process the results normally" */ int timeout_action = (*tds_get_ctx(tds)->int_handler) (tds_get_parent(tds)); switch (timeout_action) { case TDS_INT_CONTINUE: /* keep waiting */ continue; case TDS_INT_CANCEL: /* abort the current command batch */ /* FIXME tell tds_goodread() not to call tdserror() */ return 0; default: tdsdump_log(TDS_DBG_NETWORK, "tds_select: invalid interupt handler return code: %d\n", timeout_action); return -1; } } /* * We can reach here if no interrupt handler was installed and we either timed out or got EINTR. * We cannot be polling, so we are about to drop out of the loop. */ assert(poll_seconds == timeout_seconds); } return 0; } /** * Read from an OS socket * @TODO remove tds, save error somewhere, report error in another way * @returns 0 if blocking, <0 error >0 bytes read */ static int tds_socket_read(TDSCONNECTION * conn, TDSSOCKET *tds, unsigned char *buf, int buflen) { int len, err; #if ENABLE_EXTRA_CHECKS /* this simulate the fact that recv can return less bytes */ if (buflen >= 5) { static int cnt = 0; if (++cnt == 5) { cnt = 0; buflen -= 3; } } #endif /* read directly from socket*/ len = READSOCKET(conn->s, buf, buflen); if (len > 0) return len; err = sock_errno; if (len < 0 && TDSSOCK_WOULDBLOCK(err)) return 0; /* detect connection close */ tds_connection_close(conn); tdserror(conn->tds_ctx, tds, len == 0 ? TDSESEOF : TDSEREAD, len == 0 ? 0 : err); return -1; } /** * Write to an OS socket * @returns 0 if blocking, <0 error >0 bytes readed */ static int tds_socket_write(TDSCONNECTION *conn, TDSSOCKET *tds, const unsigned char *buf, int buflen) { int err, len; char *errstr; #if ENABLE_EXTRA_CHECKS /* this simulate the fact that send can return less bytes */ if (buflen >= 5) { static int cnt = 0; if (++cnt == 5) { cnt = 0; buflen -= 3; } } #endif #if defined(__APPLE__) && defined(SO_NOSIGPIPE) len = send(conn->s, buf, buflen, 0); #else len = WRITESOCKET(conn->s, buf, buflen); #endif if (len > 0) return len; err = sock_errno; if (0 == len || TDSSOCK_WOULDBLOCK(err)) return 0; assert(len < 0); /* detect connection close */ errstr = sock_strerror(err); tdsdump_log(TDS_DBG_NETWORK, "send(2) failed: %d (%s)\n", err, errstr); sock_strerror_free(errstr); tds_connection_close(conn); tdserror(conn->tds_ctx, tds, TDSEWRIT, err); return -1; } int tds_wakeup_init(TDSPOLLWAKEUP *wakeup) { TDS_SYS_SOCKET sv[2]; int ret; wakeup->s_signal = wakeup->s_signaled = INVALID_SOCKET; #if defined(__linux__) && HAVE_EVENTFD # ifdef EFD_CLOEXEC ret = eventfd(0, EFD_CLOEXEC|EFD_NONBLOCK); # else ret = -1; # endif /* Linux version up to 2.6.26 do not support flags, try without */ if (ret < 0 && (ret = eventfd(0, 0)) >= 0) { fcntl(ret, F_SETFD, fcntl(ret, F_GETFD, 0) | FD_CLOEXEC); fcntl(ret, F_SETFL, fcntl(ret, F_GETFL, 0) | O_NONBLOCK); } if (ret >= 0) { wakeup->s_signaled = ret; return 0; } #endif ret = socketpair(AF_UNIX, SOCK_STREAM, 0, sv); if (ret) return ret; wakeup->s_signal = sv[0]; wakeup->s_signaled = sv[1]; return 0; } void tds_wakeup_close(TDSPOLLWAKEUP *wakeup) { if (!TDS_IS_SOCKET_INVALID(wakeup->s_signal)) CLOSESOCKET(wakeup->s_signal); if (!TDS_IS_SOCKET_INVALID(wakeup->s_signaled)) CLOSESOCKET(wakeup->s_signaled); } void tds_wakeup_send(TDSPOLLWAKEUP *wakeup, char cancel) { #if defined(__linux__) && HAVE_EVENTFD if (wakeup->s_signal == -1) { TDS_UINT8 one = 1; (void) write(wakeup->s_signaled, &one, sizeof(one)); return; } #endif send(wakeup->s_signal, &cancel, sizeof(cancel), 0); } static int tds_connection_signaled(TDSCONNECTION *conn) { int len; char to_cancel[16]; #if defined(__linux__) && HAVE_EVENTFD if (conn->wakeup.s_signal == -1) return read(conn->wakeup.s_signaled, to_cancel, 8) > 0; #endif len = READSOCKET(conn->wakeup.s_signaled, to_cancel, sizeof(to_cancel)); do { /* no cancel found */ if (len <= 0) return 0; } while(!to_cancel[--len]); return 1; } #if ENABLE_ODBC_MARS static void tds_check_cancel(TDSCONNECTION *conn) { TDSSOCKET *tds; int rc; if (!tds_connection_signaled(conn)) return; do { unsigned n = 0; rc = TDS_SUCCESS; tds_mutex_lock(&conn->list_mtx); /* Here we scan all list searching for sessions that should send cancel packets */ for (; n < conn->num_sessions; ++n) if (TDSSOCKET_VALID(tds=conn->sessions[n]) && tds->in_cancel == 1) { /* send cancel */ tds->in_cancel = 2; tds_mutex_unlock(&conn->list_mtx); rc = tds_append_cancel(tds); tds_mutex_lock(&conn->list_mtx); if (rc != TDS_SUCCESS) break; } tds_mutex_unlock(&conn->list_mtx); /* for all failed */ /* this must be done outside loop cause it can alter list */ /* this must be done unlocked cause it can lock again */ if (rc != TDS_SUCCESS) tds_close_socket(tds); } while(rc != TDS_SUCCESS); } #endif /** * Loops until we have received some characters * return -1 on failure */ int tds_goodread(TDSSOCKET * tds, unsigned char *buf, int buflen) { if (tds == NULL || buf == NULL || buflen < 1) return -1; for (;;) { int len, err; /* FIXME this block writing from other sessions */ len = tds_select(tds, TDSSELREAD, tds->query_timeout); #if !ENABLE_ODBC_MARS if (len > 0 && (len & TDSPOLLURG)) { tds_connection_signaled(tds->conn); /* send cancel */ if (tds->in_cancel == 1) tds_put_cancel(tds); continue; } #endif if (len > 0) { len = tds_socket_read(tds->conn, tds, buf, buflen); if (len == 0) continue; return len; } /* error */ if (len < 0) { if (TDSSOCK_WOULDBLOCK(sock_errno)) /* shouldn't happen, but OK */ continue; err = sock_errno; tds_connection_close(tds->conn); tdserror(tds_get_ctx(tds), tds, TDSEREAD, err); return -1; } /* timeout */ switch (tdserror(tds_get_ctx(tds), tds, TDSETIME, sock_errno)) { case TDS_INT_CONTINUE: break; default: case TDS_INT_CANCEL: tds_close_socket(tds); return -1; } } } int tds_connection_read(TDSSOCKET * tds, unsigned char *buf, int buflen) { TDSCONNECTION *conn = tds->conn; if (conn->tls_session) return tds_ssl_read(conn, buf, buflen); #if ENABLE_ODBC_MARS return tds_socket_read(conn, tds, buf, buflen); #else return tds_goodread(tds, buf, buflen); #endif } /** * \param tds the famous socket * \param buffer data to send * \param buflen bytes in buffer * \param last 1 if this is the last packet, else 0 * \return length written (>0), <0 on failure */ int tds_goodwrite(TDSSOCKET * tds, const unsigned char *buffer, size_t buflen) { int len; size_t sent = 0; assert(tds && buffer); while (sent < buflen) { /* TODO if send buffer is full we block receive !!! */ len = tds_select(tds, TDSSELWRITE, tds->query_timeout); if (len > 0) { len = tds_socket_write(tds->conn, tds, buffer + sent, buflen - sent); if (len == 0) continue; if (len < 0) return len; sent += len; continue; } /* error */ if (len < 0) { int err = sock_errno; char *errstr; if (TDSSOCK_WOULDBLOCK(err)) /* shouldn't happen, but OK, retry */ continue; errstr = sock_strerror(err); tdsdump_log(TDS_DBG_NETWORK, "select(2) failed: %d (%s)\n", err, errstr); sock_strerror_free(errstr); tds_connection_close(tds->conn); tdserror(tds_get_ctx(tds), tds, TDSEWRIT, err); return -1; } /* timeout */ tdsdump_log(TDS_DBG_NETWORK, "tds_goodwrite(): timed out, asking client\n"); switch (tdserror(tds_get_ctx(tds), tds, TDSETIME, sock_errno)) { case TDS_INT_CONTINUE: break; default: case TDS_INT_CANCEL: tds_close_socket(tds); return -1; } } return (int) sent; } void tds_socket_flush(TDS_SYS_SOCKET sock) { #ifdef USE_CORK int opt; opt = 0; setsockopt(sock, SOL_TCP, TCP_CORK, (const void *) &opt, sizeof(opt)); opt = 1; setsockopt(sock, SOL_TCP, TCP_CORK, (const void *) &opt, sizeof(opt)); #endif } int tds_connection_write(TDSSOCKET *tds, const unsigned char *buf, int buflen, int final) { int sent; TDSCONNECTION *conn = tds->conn; #if !defined(_WIN32) && !defined(MSG_NOSIGNAL) && !defined(DOS32X) && (!defined(__APPLE__) || !defined(SO_NOSIGPIPE)) void (*oldsig) (int); oldsig = signal(SIGPIPE, SIG_IGN); if (oldsig == SIG_ERR) { tdsdump_log(TDS_DBG_WARN, "TDS: Warning: Couldn't set SIGPIPE signal to be ignored\n"); } #endif if (conn->tls_session) sent = tds_ssl_write(conn, buf, buflen); else #if ENABLE_ODBC_MARS sent = tds_socket_write(conn, tds, buf, buflen); #else sent = tds_goodwrite(tds, buf, buflen); #endif /* force packet flush */ if (final && sent >= buflen) tds_socket_flush(tds_get_s(tds)); #if !defined(_WIN32) && !defined(MSG_NOSIGNAL) && !defined(DOS32X) && (!defined(__APPLE__) || !defined(SO_NOSIGPIPE)) if (signal(SIGPIPE, oldsig) == SIG_ERR) { tdsdump_log(TDS_DBG_WARN, "TDS: Warning: Couldn't reset SIGPIPE signal to previous value\n"); } #endif return sent; } /** * Get port of all instances * @return default port number or 0 if error * @remark experimental, cf. MC-SQLR.pdf. */ int tds7_get_instance_ports(FILE *output, struct addrinfo *addr) { int num_try; struct pollfd fd; int retval; TDS_SYS_SOCKET s; char msg[16*1024]; int msg_len = 0; int port = 0; char ipaddr[128]; tds_addrinfo_set_port(addr, 1434); tds_addrinfo2str(addr, ipaddr, sizeof(ipaddr)); tdsdump_log(TDS_DBG_ERROR, "tds7_get_instance_ports(%s)\n", ipaddr); /* create an UDP socket */ if (TDS_IS_SOCKET_INVALID(s = socket(addr->ai_family, SOCK_DGRAM, 0))) { char *errstr = sock_strerror(sock_errno); tdsdump_log(TDS_DBG_ERROR, "socket creation error: %s\n", errstr); sock_strerror_free(errstr); return 0; } /* * on cluster environment is possible that reply packet came from * different IP so do not filter by ip with connect */ if (tds_socket_set_nonblocking(s) != 0) { CLOSESOCKET(s); return 0; } /* * Request the instance's port from the server. * There is no easy way to detect if port is closed so we always try to * get a reply from server 16 times. */ for (num_try = 0; num_try < 16 && msg_len == 0; ++num_try) { /* send the request */ msg[0] = 3; if (sendto(s, msg, 1, 0, addr->ai_addr, addr->ai_addrlen) < 0) break; fd.fd = s; fd.events = POLLIN; fd.revents = 0; retval = poll(&fd, 1, 1000); /* on interrupt ignore */ if (retval < 0 && sock_errno == TDSSOCK_EINTR) continue; if (retval == 0) { /* timed out */ #if 1 tdsdump_log(TDS_DBG_ERROR, "tds7_get_instance_port: timed out on try %d of 16\n", num_try); continue; #else int rc; tdsdump_log(TDS_DBG_INFO1, "timed out\n"); switch(rc = tdserror(NULL, NULL, TDSETIME, 0)) { case TDS_INT_CONTINUE: continue; /* try again */ default: tdsdump_log(TDS_DBG_ERROR, "error: client error handler returned %d\n", rc); case TDS_INT_CANCEL: CLOSESOCKET(s); return 0; } #endif } if (retval < 0) break; /* got data, read and parse */ if ((msg_len = recv(s, msg, sizeof(msg) - 1, 0)) > 3 && msg[0] == 5) { char *name, sep[2] = ";", *save; /* assure null terminated */ msg[msg_len] = 0; tdsdump_dump_buf(TDS_DBG_INFO1, "instance info", msg, msg_len); if (0) { /* To debug, print the whole string. */ char *p; for (*sep = '\n', p=msg+3; p < msg + msg_len; p++) { if( *p == ';' ) *p = *sep; } fputs(msg + 3, output); } /* * Parse and print message. */ name = strtok_r(msg+3, sep, &save); while (name && output) { int i; static const char *const names[] = { "ServerName", "InstanceName", "IsClustered", "Version", "tcp", "np", "via" }; for (i=0; name && i < TDS_VECTOR_SIZE(names); i++) { const char *value = strtok_r(NULL, sep, &save); if (strcmp(name, names[i]) != 0) fprintf(output, "error: expecting '%s', found '%s'\n", names[i], name); if (value) fprintf(output, "%15s %s\n", name, value); else break; name = strtok_r(NULL, sep, &save); if (name && strcmp(name, names[0]) == 0) break; } if (name) fprintf(output, "\n"); } } } CLOSESOCKET(s); tdsdump_log(TDS_DBG_ERROR, "default instance port is %d\n", port); return port; } /** * Get port of given instance * @return port number or 0 if error */ int tds7_get_instance_port(struct addrinfo *addr, const char *instance) { int num_try; struct pollfd fd; int retval; TDS_SYS_SOCKET s; char msg[1024]; int msg_len; int port = 0; char ipaddr[128]; tds_addrinfo_set_port(addr, 1434); tds_addrinfo2str(addr, ipaddr, sizeof(ipaddr)); tdsdump_log(TDS_DBG_ERROR, "tds7_get_instance_port(%s, %s)\n", ipaddr, instance); /* create an UDP socket */ if (TDS_IS_SOCKET_INVALID(s = socket(addr->ai_family, SOCK_DGRAM, 0))) { char *errstr = sock_strerror(sock_errno); tdsdump_log(TDS_DBG_ERROR, "socket creation error: %s\n", errstr); sock_strerror_free(errstr); return 0; } /* * on cluster environment is possible that reply packet came from * different IP so do not filter by ip with connect */ if (tds_socket_set_nonblocking(s) != 0) { CLOSESOCKET(s); return 0; } /* * Request the instance's port from the server. * There is no easy way to detect if port is closed so we always try to * get a reply from server 16 times. */ for (num_try = 0; num_try < 16; ++num_try) { /* send the request */ msg[0] = 4; strlcpy(msg + 1, instance, sizeof(msg) - 1); if (sendto(s, msg, (int)strlen(msg) + 1, 0, addr->ai_addr, addr->ai_addrlen) < 0) break; fd.fd = s; fd.events = POLLIN; fd.revents = 0; retval = poll(&fd, 1, 1000); /* on interrupt ignore */ if (retval < 0 && sock_errno == TDSSOCK_EINTR) continue; if (retval == 0) { /* timed out */ #if 1 tdsdump_log(TDS_DBG_ERROR, "tds7_get_instance_port: timed out on try %d of 16\n", num_try); continue; #else int rc; tdsdump_log(TDS_DBG_INFO1, "timed out\n"); switch(rc = tdserror(NULL, NULL, TDSETIME, 0)) { case TDS_INT_CONTINUE: continue; /* try again */ default: tdsdump_log(TDS_DBG_ERROR, "error: client error handler returned %d\n", rc); case TDS_INT_CANCEL: CLOSESOCKET(s); return 0; } #endif } if (retval < 0) break; /* TODO pass also connection and set instance/servername ?? */ /* got data, read and parse */ if ((msg_len = recv(s, msg, sizeof(msg) - 1, 0)) > 3 && msg[0] == 5) { char *p; long l = 0; int instance_ok = 0, port_ok = 0; /* assure null terminated */ msg[msg_len] = 0; tdsdump_dump_buf(TDS_DBG_INFO1, "instance info", msg, msg_len); /* * Parse message and check instance name and port. * We don't check servername cause it can be very different from the client's. */ for (p = msg + 3;;) { char *name, *value; name = p; p = strchr(p, ';'); if (!p) break; *p++ = 0; value = name; if (*name) { value = p; p = strchr(p, ';'); if (!p) break; *p++ = 0; } if (strcasecmp(name, "InstanceName") == 0) { if (strcasecmp(value, instance) != 0) break; instance_ok = 1; } else if (strcasecmp(name, "tcp") == 0) { l = strtol(value, &p, 10); if (l > 0 && l <= 0xffff && *p == 0) port_ok = 1; } } if (port_ok && instance_ok) { port = l; break; } } } CLOSESOCKET(s); tdsdump_log(TDS_DBG_ERROR, "instance port is %d\n", port); return port; } #if defined(_WIN32) static const char tds_unknown_wsaerror[] = "undocumented WSA error code"; char * tds_prwsaerror(int erc) { char *errstr = NULL; FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, NULL, erc, MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT), (LPTSTR)&errstr, 0, NULL); if (errstr) { size_t len = strlen(errstr); while (len > 0 && (errstr[len-1] == '\r' || errstr[len-1] == '\n')) errstr[len-1] = 0; return errstr; } return (char*) tds_unknown_wsaerror; } void tds_prwsaerror_free(char *s) { if (s != tds_unknown_wsaerror) LocalFree((HLOCAL) s); } #endif /** @} */ freetds-1.00.82/src/tds/tls.c100644 025423 025423 00000056512 13207744221 0011370/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Brian Bruns * Copyright (C) 2004-2015 Ziglio Frediano * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #if HAVE_ERRNO_H #include #endif /* HAVE_ERRNO_H */ #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_DIRENT_H #include #endif /* HAVE_DIRENT_H */ #if HAVE_SYS_STAT_H #include #endif /* HAVE_SYS_STAT_H */ #ifdef HAVE_SYS_SOCKET_H #include #endif #include #include #include #include #include "replacements.h" #include /** * \addtogroup network * @{ */ #if defined(HAVE_GNUTLS) || defined(HAVE_OPENSSL) #ifdef HAVE_GNUTLS #define SSL_RET ssize_t #define SSL_PULL_ARGS gnutls_transport_ptr_t ptr, void *data, size_t len #define SSL_PUSH_ARGS gnutls_transport_ptr_t ptr, const void *data, size_t len #define SSL_PTR ptr #else /* some compatibility layer */ #if OPENSSL_VERSION_NUMBER < 0x1010000FL static inline void BIO_set_init(BIO *b, int init) { b->init = init; } static inline void BIO_set_data(BIO *b, void *ptr) { b->ptr = ptr; } static inline void * BIO_get_data(const BIO *b) { return b->ptr; } #define TLS_client_method SSLv23_client_method #define TLS_ST_OK SSL_ST_OK #endif #define SSL_RET int #define SSL_PULL_ARGS BIO *bio, char *data, int len #define SSL_PUSH_ARGS BIO *bio, const char *data, int len #define SSL_PTR BIO_get_data(bio) #endif static SSL_RET tds_pull_func_login(SSL_PULL_ARGS) { TDSSOCKET *tds = (TDSSOCKET *) SSL_PTR; int have; tdsdump_log(TDS_DBG_FUNC, "in tds_pull_func_login\n"); /* here we are initializing (crypted inside TDS packets) */ /* if we have some data send it */ /* here MARS is not already initialized so test is correct */ /* TODO test even after initializing ?? */ if (tds->out_pos > 8) tds_flush_packet(tds); for(;;) { have = tds->in_len - tds->in_pos; assert(have >= 0); if (have > 0) break; if (tds_read_packet(tds) < 0) return -1; } if (len > have) len = have; memcpy(data, tds->in_buf + tds->in_pos, len); tds->in_pos += len; return len; } static SSL_RET tds_push_func_login(SSL_PUSH_ARGS) { TDSSOCKET *tds = (TDSSOCKET *) SSL_PTR; tdsdump_log(TDS_DBG_FUNC, "in tds_push_func_login\n"); /* initializing SSL, write crypted data inside normal TDS packets */ tds_put_n(tds, data, len); return len; } static SSL_RET tds_pull_func(SSL_PULL_ARGS) { TDSCONNECTION *conn = (TDSCONNECTION *) SSL_PTR; TDSSOCKET *tds; tdsdump_log(TDS_DBG_FUNC, "in tds_pull_func\n"); #if ENABLE_ODBC_MARS tds = conn->in_net_tds; assert(tds); #else tds = (TDSSOCKET *) conn; #endif /* already initialized (crypted TDS packets) */ /* read directly from socket */ /* TODO we block write on other sessions */ /* also we should already have tested for data on socket */ return tds_goodread(tds, (unsigned char*) data, len); } static SSL_RET tds_push_func(SSL_PUSH_ARGS) { TDSCONNECTION *conn = (TDSCONNECTION *) SSL_PTR; TDSSOCKET *tds; tdsdump_log(TDS_DBG_FUNC, "in tds_push_func\n"); /* write to socket directly */ #if ENABLE_ODBC_MARS tds = conn->in_net_tds; #else tds = (TDSSOCKET *) conn; #endif return tds_goodwrite(tds, (const unsigned char*) data, len); } static int tls_initialized = 0; static tds_mutex tls_mutex = TDS_MUTEX_INITIALIZER; #ifdef HAVE_GNUTLS static void tds_tls_log( int level, const char* s) { tdsdump_log(TDS_DBG_INFO1, "GNUTLS: level %d:\n %s", level, s); } #ifdef TDS_ATTRIBUTE_DESTRUCTOR static void __attribute__((destructor)) tds_tls_deinit(void) { if (tls_initialized) gnutls_global_deinit(); } #endif #if defined(_THREAD_SAFE) && defined(TDS_HAVE_PTHREAD_MUTEX) && !defined(GNUTLS_USE_NETTLE) GCRY_THREAD_OPTION_PTHREAD_IMPL; #define tds_gcry_init() gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread) #else #define tds_gcry_init() do {} while(0) #endif /* This piece of code is copied from GnuTLS new sources to handle IP in the certificate */ #if GNUTLS_VERSION_NUMBER < 0x030306 static int check_ip(gnutls_x509_crt_t cert, const void *ip, unsigned ip_size) { char temp[16]; size_t temp_size; unsigned i; int ret = 0; /* try matching against: * 1) a IPaddress alternative name (subjectAltName) extension * in the certificate */ /* Check through all included subjectAltName extensions, comparing * against all those of type IPAddress. */ for (i = 0; ret >= 0; ++i) { temp_size = sizeof(temp); ret = gnutls_x509_crt_get_subject_alt_name(cert, i, temp, &temp_size, NULL); if (ret == GNUTLS_SAN_IPADDRESS) { if (temp_size == ip_size && memcmp(temp, ip, ip_size) == 0) return 1; } else if (ret == GNUTLS_E_SHORT_MEMORY_BUFFER) { ret = 0; } } /* not found a matching IP */ return 0; } static int tds_check_ip(gnutls_x509_crt_t cert, const char *hostname) { int ret; union { struct in_addr v4; struct in6_addr v6; } ip; unsigned ip_size; /* check whether @hostname is an ip address */ if (strchr(hostname, ':') != NULL) { ip_size = 16; ret = inet_pton(AF_INET6, hostname, &ip.v6); } else { ip_size = 4; ret = inet_pton(AF_INET, hostname, &ip.v4); } if (ret != 0) ret = check_ip(cert, &ip, ip_size); /* There are several misconfigured servers, that place their IP * in the DNS field of subjectAlternativeName. Don't break these * configurations and verify the IP as it would have been a DNS name. */ return ret; } /* function for replacing old GnuTLS version */ static int tds_x509_crt_check_hostname(gnutls_x509_crt_t cert, const char *hostname) { int ret; ret = tds_check_ip(cert, hostname); if (ret) return ret; return gnutls_x509_crt_check_hostname(cert, hostname); } #define gnutls_x509_crt_check_hostname tds_x509_crt_check_hostname #endif #if GNUTLS_VERSION_MAJOR < 3 static int tds_certificate_set_x509_system_trust(gnutls_certificate_credentials_t cred) { static const char ca_directory[] = "/etc/ssl/certs"; DIR *dir; struct dirent *dent; #ifdef HAVE_READDIR_R struct dirent ent; #endif int rc; int ncerts; size_t ca_file_length; char *ca_file; dir = opendir(ca_directory); if (!dir) return 0; ca_file_length = strlen(ca_directory) + sizeof(dent->d_name) + 2; ca_file = alloca(ca_file_length); ncerts = 0; for (;;) { struct stat st; #ifdef HAVE_READDIR_R if (readdir_r(dir, &ent, &dent)) dent = NULL; #else dent = readdir(dir); #endif if (!dent) break; snprintf(ca_file, ca_file_length, "%s/%s", ca_directory, dent->d_name); if (stat(ca_file, &st) != 0) continue; if (!S_ISREG(st.st_mode)) continue; rc = gnutls_certificate_set_x509_trust_file(cred, ca_file, GNUTLS_X509_FMT_PEM); if (rc >= 0) ncerts += rc; } closedir(dir); return ncerts; } #define gnutls_certificate_set_x509_system_trust tds_certificate_set_x509_system_trust #endif static int tds_verify_certificate(gnutls_session_t session) { unsigned int status; int ret; TDSSOCKET *tds = (TDSSOCKET *) gnutls_transport_get_ptr(session); #ifdef ENABLE_DEVELOPING unsigned int list_size; const gnutls_datum_t *cert_list; #endif if (!tds->login) return GNUTLS_E_CERTIFICATE_ERROR; ret = gnutls_certificate_verify_peers2(session, &status); if (ret < 0) { tdsdump_log(TDS_DBG_ERROR, "Error verifying certificate: %s\n", gnutls_strerror(ret)); return GNUTLS_E_CERTIFICATE_ERROR; } #ifdef ENABLE_DEVELOPING cert_list = gnutls_certificate_get_peers(session, &list_size); if (cert_list) { gnutls_x509_crt_t cert; gnutls_datum_t cinfo; char buf[8192]; size_t size; gnutls_x509_crt_init(&cert); gnutls_x509_crt_import(cert, &cert_list[0], GNUTLS_X509_FMT_DER); /* This is the preferred way of printing short information about * a certificate. */ size = sizeof(buf); ret = gnutls_x509_crt_export(cert, GNUTLS_X509_FMT_PEM, buf, &size); if (ret == 0) { FILE *f = fopen("cert.dat", "wb"); if (f) { fwrite(buf, size, 1, f); fclose(f); } } ret = gnutls_x509_crt_print(cert, GNUTLS_CRT_PRINT_ONELINE, &cinfo); if (ret == 0) { tdsdump_log(TDS_DBG_INFO1, "Certificate info: %s\n", cinfo.data); gnutls_free(cinfo.data); } gnutls_x509_crt_deinit(cert); } #endif /* Certificate is not trusted */ if (status != 0) { tdsdump_log(TDS_DBG_ERROR, "Certificate status: %u\n", status); return GNUTLS_E_CERTIFICATE_ERROR; } /* check hostname */ if (tds->login->check_ssl_hostname) { const gnutls_datum_t *cert_list; unsigned int list_size; gnutls_x509_crt_t cert; cert_list = gnutls_certificate_get_peers(session, &list_size); if (!cert_list) { tdsdump_log(TDS_DBG_ERROR, "Error getting TLS session peers\n"); return GNUTLS_E_CERTIFICATE_ERROR; } gnutls_x509_crt_init(&cert); gnutls_x509_crt_import(cert, &cert_list[0], GNUTLS_X509_FMT_DER); ret = gnutls_x509_crt_check_hostname(cert, tds_dstr_cstr(&tds->login->server_host_name)); gnutls_x509_crt_deinit(cert); if (!ret) { tdsdump_log(TDS_DBG_ERROR, "Certificate hostname does not match\n"); return GNUTLS_E_CERTIFICATE_ERROR; } } /* notify gnutls to continue handshake normally */ return 0; } TDSRET tds_ssl_init(TDSSOCKET *tds) { gnutls_session_t session; gnutls_certificate_credentials_t xcred; int ret; const char *tls_msg; xcred = NULL; session = NULL; tls_msg = "initializing tls"; if (!tls_initialized) { ret = 0; tds_mutex_lock(&tls_mutex); if (!tls_initialized) { tds_gcry_init(); ret = gnutls_global_init(); if (ret == 0) tls_initialized = 1; } tds_mutex_unlock(&tls_mutex); if (ret != 0) goto cleanup; } if (tds_write_dump && tls_initialized < 2) { gnutls_global_set_log_level(11); gnutls_global_set_log_function(tds_tls_log); tls_initialized = 2; } tls_msg = "allocating credentials"; ret = gnutls_certificate_allocate_credentials(&xcred); if (ret != 0) goto cleanup; if (!tds_dstr_isempty(&tds->login->cafile)) { tls_msg = "loading CA file"; if (strcasecmp(tds_dstr_cstr(&tds->login->cafile), "system") == 0) ret = gnutls_certificate_set_x509_system_trust(xcred); else ret = gnutls_certificate_set_x509_trust_file(xcred, tds_dstr_cstr(&tds->login->cafile), GNUTLS_X509_FMT_PEM); if (ret <= 0) goto cleanup; if (!tds_dstr_isempty(&tds->login->crlfile)) { tls_msg = "loading CRL file"; ret = gnutls_certificate_set_x509_crl_file(xcred, tds_dstr_cstr(&tds->login->crlfile), GNUTLS_X509_FMT_PEM); if (ret <= 0) goto cleanup; } #ifdef HAVE_GNUTLS_CERTIFICATE_SET_VERIFY_FUNCTION gnutls_certificate_set_verify_function(xcred, tds_verify_certificate); #endif } /* Initialize TLS session */ tls_msg = "initializing session"; ret = gnutls_init(&session, GNUTLS_CLIENT); if (ret != 0) goto cleanup; gnutls_transport_set_ptr(session, tds); gnutls_transport_set_pull_function(session, tds_pull_func_login); gnutls_transport_set_push_function(session, tds_push_func_login); /* NOTE: there functions return int however they cannot fail */ /* use default priorities... */ gnutls_set_default_priority(session); /* ... but overwrite some */ ret = gnutls_priority_set_direct (session, "NORMAL:%COMPAT:-VERS-SSL3.0", NULL); if (ret != 0) goto cleanup; /* mssql does not like padding too much */ #ifdef HAVE_GNUTLS_RECORD_DISABLE_PADDING gnutls_record_disable_padding(session); #endif /* put the anonymous credentials to the current session */ tls_msg = "setting credential"; ret = gnutls_credentials_set(session, GNUTLS_CRD_CERTIFICATE, xcred); if (ret != 0) goto cleanup; /* Perform the TLS handshake */ tls_msg = "handshake"; ret = gnutls_handshake (session); if (ret != 0) goto cleanup; #ifndef HAVE_GNUTLS_CERTIFICATE_SET_VERIFY_FUNCTION if (!tds_dstr_isempty(&tds->login->cafile)) { ret = tds_verify_certificate(session); if (ret != 0) goto cleanup; } #endif tdsdump_log(TDS_DBG_INFO1, "handshake succeeded!!\n"); gnutls_transport_set_ptr(session, tds->conn); gnutls_transport_set_pull_function(session, tds_pull_func); gnutls_transport_set_push_function(session, tds_push_func); tds->conn->tls_session = session; tds->conn->tls_credentials = xcred; return TDS_SUCCESS; cleanup: if (session) gnutls_deinit(session); if (xcred) gnutls_certificate_free_credentials(xcred); tdsdump_log(TDS_DBG_ERROR, "%s failed: %s\n", tls_msg, gnutls_strerror (ret)); return TDS_FAIL; } void tds_ssl_deinit(TDSCONNECTION *conn) { if (conn->tls_session) { gnutls_deinit((gnutls_session_t) conn->tls_session); conn->tls_session = NULL; } if (conn->tls_credentials) { gnutls_certificate_free_credentials((gnutls_certificate_credentials_t) conn->tls_credentials); conn->tls_credentials = NULL; } } #else static long tds_ssl_ctrl_login(BIO *b, int cmd, long num, void *ptr) { TDSSOCKET *tds = (TDSSOCKET *) BIO_get_data(b); switch (cmd) { case BIO_CTRL_FLUSH: if (tds->out_pos > 8) tds_flush_packet(tds); return 1; } return 0; } static int tds_ssl_free(BIO *a) { /* nothing to do but required */ return 1; } #if OPENSSL_VERSION_NUMBER < 0x1010000FL static BIO_METHOD tds_method_login[1] = { { BIO_TYPE_MEM, "tds", tds_push_func_login, tds_pull_func_login, NULL, NULL, tds_ssl_ctrl_login, NULL, tds_ssl_free, NULL, }}; static BIO_METHOD tds_method[1] = { { BIO_TYPE_MEM, "tds", tds_push_func, tds_pull_func, NULL, NULL, NULL, NULL, tds_ssl_free, NULL, }}; static inline void tds_init_ssl_methods(void) { } #else static BIO_METHOD *tds_method_login; static BIO_METHOD *tds_method; static void tds_init_ssl_methods(void) { BIO_METHOD *meth; tds_method_login = meth = BIO_meth_new(BIO_TYPE_MEM, "tds"); BIO_meth_set_write(meth, tds_push_func_login); BIO_meth_set_read(meth, tds_pull_func_login); BIO_meth_set_ctrl(meth, tds_ssl_ctrl_login); BIO_meth_set_destroy(meth, tds_ssl_free); tds_method = meth = BIO_meth_new(BIO_TYPE_MEM, "tds"); BIO_meth_set_write(meth, tds_push_func); BIO_meth_set_read(meth, tds_pull_func); BIO_meth_set_destroy(meth, tds_ssl_free); } # ifdef TDS_ATTRIBUTE_DESTRUCTOR static void __attribute__((destructor)) tds_deinit_openssl_methods(void) { BIO_meth_free(tds_method_login); BIO_meth_free(tds_method); } # endif #endif static SSL_CTX * tds_init_openssl(void) { const SSL_METHOD *meth; if (!tls_initialized) { tds_mutex_lock(&tls_mutex); if (!tls_initialized) { SSL_library_init(); tds_init_ssl_methods(); tls_initialized = 1; } tds_mutex_unlock(&tls_mutex); } meth = TLS_client_method(); if (meth == NULL) return NULL; return SSL_CTX_new (meth); } static int check_wildcard(const char *host, const char *match) { const char *p, *w; size_t n, lh, lm; /* U-label (binary) */ for (p = match; *p; ++p) if ((unsigned char) *p >= 0x80) return strcmp(host, match) == 0; for (;;) { /* A-label (starts with xn--) */ if (strncasecmp(match, "xn--", 4) == 0) break; /* match must not be in domain and domain should contains 2 parts */ w = strchr(match, '*'); p = strchr(match, '.'); if (!w || !p /* no wildcard or domain */ || p[1] == '.' /* empty domain */ || w > p || strchr(p, '*') != NULL) /* wildcard in domain */ break; p = strchr(p+1, '.'); if (!p || p[1] == 0) /* not another domain */ break; /* check start */ n = w - match; /* prefix len */ if (n > 0 && strncasecmp(host, match, n) != 0) return 0; /* check end */ lh = strlen(host); lm = strlen(match); n = lm - n - 1; /* suffix len */ if (lm - 1 > lh || strcasecmp(host+lh-n, match+lm-n) != 0 || host[0] == '.') return 0; return 1; } return strcasecmp(host, match) == 0; } #if ENABLE_EXTRA_CHECKS static void tds_check_wildcard_test(void) { assert(check_wildcard("foo", "foo") == 1); assert(check_wildcard("FOO", "foo") == 1); assert(check_wildcard("foo", "FOO") == 1); assert(check_wildcard("\x90oo", "\x90OO") == 0); assert(check_wildcard("xn--foo", "xn--foo") == 1); assert(check_wildcard("xn--FOO", "XN--foo") == 1); assert(check_wildcard("xn--a.example.org", "xn--*.example.org") == 0); assert(check_wildcard("a.*", "a.*") == 1); assert(check_wildcard("a.b", "a.*") == 0); assert(check_wildcard("ab", "a*") == 0); assert(check_wildcard("a.example.", "*.example.") == 0); assert(check_wildcard("a.example.com", "*.example.com") == 1); assert(check_wildcard("a.b.example.com", "a.*.example.com") == 0); assert(check_wildcard("foo.example.com", "foo*.example.com") == 1); assert(check_wildcard("fou.example.com", "foo*.example.com") == 0); assert(check_wildcard("baz.example.com", "*baz.example.com") == 1); assert(check_wildcard("buzz.example.com", "b*z.example.com") == 1); assert(check_wildcard("bz.example.com", "b*z.example.com") == 1); assert(check_wildcard(".example.com", "*.example.com") == 0); assert(check_wildcard("example.com", "*.example.com") == 0); } #else #define tds_check_wildcard_test() do { } while(0) #endif static int check_name_match(ASN1_STRING *name, const char *hostname) { char *name_utf8 = NULL; int ret, name_len; name_len = ASN1_STRING_to_UTF8((unsigned char **) &name_utf8, name); if (name_len < 0) return 0; tdsdump_log(TDS_DBG_INFO1, "Got name %s\n", name_utf8); ret = 0; if (strlen(name_utf8) == name_len && check_wildcard(name_utf8, hostname)) ret = 1; OPENSSL_free(name_utf8); return ret; } static int check_alt_names(X509 *cert, const char *hostname) { STACK_OF(GENERAL_NAME) *alt_names; int i, num; int ret = 1; union { struct in_addr v4; struct in6_addr v6; } ip; unsigned ip_size = 0; /* check whether @hostname is an ip address */ if (strchr(hostname, ':') != NULL) { ip_size = 16; ret = inet_pton(AF_INET6, hostname, &ip.v6); } else { ip_size = 4; ret = inet_pton(AF_INET, hostname, &ip.v4); } if (ret == 0) return -1; ret = -1; alt_names = X509_get_ext_d2i(cert, NID_subject_alt_name, NULL, NULL); if (!alt_names) return ret; num = sk_GENERAL_NAME_num(alt_names); tdsdump_log(TDS_DBG_INFO1, "Alt names number %d\n", num); for (i = 0; i < num; ++i) { const char *altptr; size_t altlen; const GENERAL_NAME *name = sk_GENERAL_NAME_value(alt_names, i); if (!name) continue; altptr = (const char *) ASN1_STRING_data(name->d.ia5); altlen = (size_t) ASN1_STRING_length(name->d.ia5); if (name->type == GEN_DNS && ip_size == 0) { ret = 0; if (!check_name_match(name->d.dNSName, hostname)) continue; } else if (name->type == GEN_IPADD && ip_size != 0) { ret = 0; if (altlen != ip_size || memcmp(altptr, &ip, altlen) != 0) continue; } else { continue; } sk_GENERAL_NAME_pop_free(alt_names, GENERAL_NAME_free); return 1; } sk_GENERAL_NAME_pop_free(alt_names, GENERAL_NAME_free); return ret; } static int check_hostname(X509 *cert, const char *hostname) { int ret, i; X509_NAME *subject; ASN1_STRING *name; /* check by subject */ ret = check_alt_names(cert, hostname); if (ret >= 0) return ret; /* check by common name (old method) */ subject= X509_get_subject_name(cert); if (!subject) return 0; i = -1; while (X509_NAME_get_index_by_NID(subject, NID_commonName, i) >=0) i = X509_NAME_get_index_by_NID(subject, NID_commonName, i); if (i < 0) return 0; name = X509_NAME_ENTRY_get_data(X509_NAME_get_entry(subject, i)); if (!name) return 0; return check_name_match(name, hostname); } int tds_ssl_init(TDSSOCKET *tds) { #define DEFAULT_OPENSSL_CTX_OPTIONS (SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3) #define DEFAULT_OPENSSL_CIPHERS "HIGH:!SSLv2:!aNULL:-DH" SSL *con; SSL_CTX *ctx; BIO *b, *b2; int ret; const char *tls_msg; con = NULL; b = NULL; b2 = NULL; ret = 1; tds_check_wildcard_test(); tds_ssl_deinit(tds->conn); tls_msg = "initializing tls"; ctx = tds_init_openssl(); if (!ctx) goto cleanup; SSL_CTX_set_options(ctx, DEFAULT_OPENSSL_CTX_OPTIONS); if (!tds_dstr_isempty(&tds->login->cafile)) { tls_msg = "loading CA file"; if (strcasecmp(tds_dstr_cstr(&tds->login->cafile), "system") == 0) ret = SSL_CTX_set_default_verify_paths(ctx); else ret = SSL_CTX_load_verify_locations(ctx, tds_dstr_cstr(&tds->login->cafile), NULL); if (ret != 1) goto cleanup; if (!tds_dstr_isempty(&tds->login->crlfile)) { X509_STORE *store = SSL_CTX_get_cert_store(ctx); X509_LOOKUP *lookup; tls_msg = "loading CRL file"; if (!(lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file())) || (!X509_load_crl_file(lookup, tds_dstr_cstr(&tds->login->crlfile), X509_FILETYPE_PEM))) goto cleanup; X509_STORE_set_flags(store, X509_V_FLAG_CRL_CHECK | X509_V_FLAG_CRL_CHECK_ALL); } SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, NULL); } /* Initialize TLS session */ tls_msg = "initializing session"; con = SSL_new(ctx); if (!con) goto cleanup; tls_msg = "creating bio"; b = BIO_new(tds_method_login); if (!b) goto cleanup; b2 = BIO_new(tds_method); if (!b2) goto cleanup; BIO_set_init(b, 1); BIO_set_data(b, tds); BIO_set_conn_hostname(b, tds_dstr_cstr(&tds->login->server_host_name)); SSL_set_bio(con, b, b); b = NULL; /* use default priorities unless overridden by openssl ciphers setting in freetds.conf file... */ if (!tds_dstr_isempty(&tds->login->openssl_ciphers)) { tdsdump_log(TDS_DBG_INFO1, "setting custom openssl cipher to:%s\n", tds_dstr_cstr(&tds->login->openssl_ciphers)); SSL_set_cipher_list(con, tds_dstr_cstr(&tds->login->openssl_ciphers) ); } else { tdsdump_log(TDS_DBG_INFO1, "setting default openssl cipher to:%s\n", DEFAULT_OPENSSL_CIPHERS ); SSL_set_cipher_list(con, DEFAULT_OPENSSL_CIPHERS); } #ifdef SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS /* this disable a security improvement but allow connection... */ SSL_set_options(con, SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS); #endif /* Perform the TLS handshake */ tls_msg = "handshake"; SSL_set_connect_state(con); ret = SSL_connect(con) != 1 || SSL_get_state(con) != TLS_ST_OK; if (ret != 0) goto cleanup; /* check certificate hostname */ if (!tds_dstr_isempty(&tds->login->cafile) && tds->login->check_ssl_hostname) { X509 *cert; cert = SSL_get_peer_certificate(con); tls_msg = "checking hostname"; if (!cert || !check_hostname(cert, tds_dstr_cstr(&tds->login->server_host_name))) goto cleanup; } tdsdump_log(TDS_DBG_INFO1, "handshake succeeded!!\n"); BIO_set_init(b2, 1); BIO_set_data(b2, tds->conn); SSL_set_bio(con, b2, b2); tds->conn->tls_session = con; tds->conn->tls_ctx = ctx; return TDS_SUCCESS; cleanup: if (b2) BIO_free(b2); if (b) BIO_free(b); if (con) { SSL_shutdown(con); SSL_free(con); } SSL_CTX_free(ctx); tdsdump_log(TDS_DBG_ERROR, "%s failed\n", tls_msg); return TDS_FAIL; } void tds_ssl_deinit(TDSCONNECTION *conn) { if (conn->tls_session) { /* NOTE do not call SSL_shutdown here */ SSL_free(conn->tls_session); conn->tls_session = NULL; } if (conn->tls_ctx) { SSL_CTX_free(conn->tls_ctx); conn->tls_ctx = NULL; } } #endif #endif /** @} */ freetds-1.00.82/src/tds/log.c100644 025423 025423 00000025001 12717145107 0011337/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns * Copyright (C) 2006-2015 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #include #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #ifdef _WIN32 # include #endif #include #include #include /* for now all messages go to the log */ int tds_debug_flags = TDS_DBGFLAG_ALL | TDS_DBGFLAG_SOURCE; int tds_g_append_mode = 0; static char *g_dump_filename = NULL; /** Tell if TDS debug logging is turned on or off */ int tds_write_dump = 0; static FILE *g_dumpfile = NULL; /* file pointer for dump log */ static tds_mutex g_dump_mutex = TDS_MUTEX_INITIALIZER; static FILE* tdsdump_append(void); #ifdef TDS_ATTRIBUTE_DESTRUCTOR static void __attribute__((destructor)) tds_util_deinit(void) { tdsdump_close(); } #endif /** * Temporarily turn off logging. */ void tdsdump_off(void) { tds_mutex_lock(&g_dump_mutex); tds_write_dump = 0; tds_mutex_unlock(&g_dump_mutex); } /* tdsdump_off() */ /** * Turn logging back on. You must call tdsdump_open() before calling this routine. */ void tdsdump_on(void) { tds_mutex_lock(&g_dump_mutex); if (tdsdump_isopen()) tds_write_dump = 1; tds_mutex_unlock(&g_dump_mutex); } int tdsdump_isopen() { return g_dumpfile || g_dump_filename; } /** * Create and truncate a human readable dump file for the TDS * traffic. The name of the file is specified by the filename * parameter. If that is given as NULL or an empty string, * any existing log file will be closed. * * \return true if the file was opened, false if it couldn't be opened. */ int tdsdump_open(const char *filename) { int result; /* really should be a boolean, not an int */ tds_mutex_lock(&g_dump_mutex); /* same append file */ if (tds_g_append_mode && filename != NULL && g_dump_filename != NULL && strcmp(filename, g_dump_filename) == 0) { tds_mutex_unlock(&g_dump_mutex); return 1; } tds_write_dump = 0; /* free old one */ if (g_dumpfile != NULL && g_dumpfile != stdout && g_dumpfile != stderr) fclose(g_dumpfile); g_dumpfile = NULL; if (g_dump_filename) TDS_ZERO_FREE(g_dump_filename); /* required to close just log ?? */ if (filename == NULL || filename[0] == '\0') { tds_mutex_unlock(&g_dump_mutex); return 1; } result = 1; if (tds_g_append_mode) { g_dump_filename = strdup(filename); /* if mutex are available do not reopen file every time */ #ifdef TDS_HAVE_MUTEX g_dumpfile = tdsdump_append(); #endif } else if (!strcmp(filename, "stdout")) { g_dumpfile = stdout; } else if (!strcmp(filename, "stderr")) { g_dumpfile = stderr; } else if (NULL == (g_dumpfile = fopen(filename, "w"))) { result = 0; } if (result) tds_write_dump = 1; tds_mutex_unlock(&g_dump_mutex); if (result) { char today[64]; struct tm res; time_t t; time(&t); today[0] = 0; if (tds_localtime_r(&t, &res)) strftime(today, sizeof(today), "%Y-%m-%d %H:%M:%S", &res); tdsdump_log(TDS_DBG_INFO1, "Starting log file for FreeTDS %s\n" "\ton %s with debug flags 0x%x.\n", VERSION, today, tds_debug_flags); } return result; } /* tdsdump_open() */ static FILE* tdsdump_append(void) { if (!g_dump_filename) return NULL; if (!strcmp(g_dump_filename, "stdout")) { return stdout; } else if (!strcmp(g_dump_filename, "stderr")) { return stderr; } return fopen(g_dump_filename, "a"); } /** * Close the TDS dump log file. */ void tdsdump_close(void) { tds_mutex_lock(&g_dump_mutex); tds_write_dump = 0; if (g_dumpfile != NULL && g_dumpfile != stdout && g_dumpfile != stderr) fclose(g_dumpfile); g_dumpfile = NULL; if (g_dump_filename) TDS_ZERO_FREE(g_dump_filename); tds_mutex_unlock(&g_dump_mutex); } /* tdsdump_close() */ static void tdsdump_start(FILE *file, const char *fname, int line) { char buf[128], *pbuf; int started = 0; /* write always time before log */ if (tds_debug_flags & TDS_DBGFLAG_TIME) { fputs(tds_timestamp_str(buf, 127), file); started = 1; } pbuf = buf; if (tds_debug_flags & TDS_DBGFLAG_PID) { if (started) *pbuf++ = ' '; pbuf += sprintf(pbuf, "%d", (int) getpid()); started = 1; } if ((tds_debug_flags & TDS_DBGFLAG_SOURCE) && fname && line) { const char *p; p = strrchr(fname, '/'); if (p) fname = p + 1; p = strrchr(fname, '\\'); if (p) fname = p + 1; if (started) pbuf += sprintf(pbuf, " (%s:%d)", fname, line); else pbuf += sprintf(pbuf, "%s:%d", fname, line); started = 1; } if (started) *pbuf++ = ':'; *pbuf = 0; fputs(buf, file); } #undef tdsdump_dump_buf /** * Dump the contents of data into the log file in a human readable format. * \param file source file name * \param level_line line and level combined. This and file are automatically computed by * TDS_DBG_* macros. * \param msg message to print before dump * \param buf buffer to dump * \param length number of bytes in the buffer */ void tdsdump_dump_buf(const char* file, unsigned int level_line, const char *msg, const void *buf, size_t length) { size_t i, j; #define BYTES_PER_LINE 16 const unsigned char *data = (const unsigned char *) buf; const int debug_lvl = level_line & 15; const int line = level_line >> 4; char line_buf[BYTES_PER_LINE * 8 + 16], *p; FILE *dumpfile; if (((tds_debug_flags >> debug_lvl) & 1) == 0 || !tds_write_dump) return; if (!g_dumpfile && !g_dump_filename) return; tds_mutex_lock(&g_dump_mutex); dumpfile = g_dumpfile; #ifdef TDS_HAVE_MUTEX if (tds_g_append_mode && dumpfile == NULL) dumpfile = g_dumpfile = tdsdump_append(); #else if (tds_g_append_mode) dumpfile = tdsdump_append(); #endif if (dumpfile == NULL) { tds_mutex_unlock(&g_dump_mutex); return; } tdsdump_start(dumpfile, file, line); fprintf(dumpfile, "%s\n", msg); for (i = 0; i < length; i += BYTES_PER_LINE) { p = line_buf; /* * print the offset as a 4 digit hex number */ p += sprintf(p, "%04x", ((unsigned int) i) & 0xffffu); /* * print each byte in hex */ for (j = 0; j < BYTES_PER_LINE; j++) { if (j == BYTES_PER_LINE / 2) *p++ = '-'; else *p++ = ' '; if (j + i >= length) p += sprintf(p, " "); else p += sprintf(p, "%02x", data[i + j]); } /* * skip over to the ascii dump column */ p += sprintf(p, " |"); /* * print each byte in ascii */ for (j = i; j < length && (j - i) < BYTES_PER_LINE; j++) { if (j - i == BYTES_PER_LINE / 2) *p++ = ' '; p += sprintf(p, "%c", (isprint(data[j])) ? data[j] : '.'); } strcpy(p, "|\n"); fputs(line_buf, dumpfile); } fputs("\n", dumpfile); fflush(dumpfile); #ifndef TDS_HAVE_MUTEX if (tds_g_append_mode) { if (dumpfile != stdout && dumpfile != stderr) fclose(dumpfile); } #endif tds_mutex_unlock(&g_dump_mutex); } /* tdsdump_dump_buf() */ #define tdsdump_dump_buf TDSDUMP_BUF_FAST #undef tdsdump_log /** * Write a message to the debug log. * \param file name of the log file * \param level_line kind of detail to be included * \param fmt printf-like format string */ void tdsdump_log(const char* file, unsigned int level_line, const char *fmt, ...) { const int debug_lvl = level_line & 15; const int line = level_line >> 4; va_list ap; FILE *dumpfile; if (((tds_debug_flags >> debug_lvl) & 1) == 0 || !tds_write_dump) return; if (!g_dumpfile && !g_dump_filename) return; tds_mutex_lock(&g_dump_mutex); dumpfile = g_dumpfile; #ifdef TDS_HAVE_MUTEX if (tds_g_append_mode && dumpfile == NULL) dumpfile = g_dumpfile = tdsdump_append(); #else if (tds_g_append_mode) dumpfile = tdsdump_append(); #endif if (dumpfile == NULL) { tds_mutex_unlock(&g_dump_mutex); return; } tdsdump_start(dumpfile, file, line); va_start(ap, fmt); vfprintf(dumpfile, fmt, ap); va_end(ap); fflush(dumpfile); #ifndef TDS_HAVE_MUTEX if (tds_g_append_mode) { if (dumpfile != stdout && dumpfile != stderr) fclose(dumpfile); } #endif tds_mutex_unlock(&g_dump_mutex); } /* tdsdump_log() */ #define tdsdump_log TDSDUMP_LOG_FAST /** * Write a column value to the debug log. * \param col column to dump */ void tdsdump_col(const TDSCOLUMN *col) { const char* type_name; char* data; TDS_SMALLINT type; assert(col); assert(col->column_data); type_name = tds_prtype(col->column_type); type = tds_get_conversion_type(col->column_type, col->column_size); switch(type) { case SYBCHAR: case SYBVARCHAR: if (col->column_cur_size >= 0) { data = tds_new0(char, 1 + col->column_cur_size); if (!data) { tdsdump_log(TDS_DBG_FUNC, "no memory to log data for type %s\n", type_name); return; } memcpy(data, col->column_data, col->column_cur_size); tdsdump_log(TDS_DBG_FUNC, "type %s has value \"%s\"\n", type_name, data); free(data); } else { tdsdump_log(TDS_DBG_FUNC, "type %s has value NULL\n", type_name); } break; case SYBINT1: tdsdump_log(TDS_DBG_FUNC, "type %s has value %d\n", type_name, (int)*(TDS_TINYINT*)col->column_data); break; case SYBINT2: tdsdump_log(TDS_DBG_FUNC, "type %s has value %d\n", type_name, (int)*(TDS_SMALLINT*)col->column_data); break; case SYBINT4: tdsdump_log(TDS_DBG_FUNC, "type %s has value %d\n", type_name, (int)*(TDS_INT*)col->column_data); break; case SYBREAL: tdsdump_log(TDS_DBG_FUNC, "type %s has value %f\n", type_name, (double)*(TDS_REAL*)col->column_data); break; case SYBFLT8: tdsdump_log(TDS_DBG_FUNC, "type %s has value %f\n", type_name, (double)*(TDS_FLOAT*)col->column_data); break; default: tdsdump_log(TDS_DBG_FUNC, "cannot log data for type %s\n", type_name); break; } } freetds-1.00.82/src/tds/tds_checks.c100644 025423 025423 00000022510 12717145107 0012672/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2004-2011 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #undef NDEBUG #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include #include #include #if ENABLE_EXTRA_CHECKS static void tds_check_packet_extra(const TDSPACKET * packet) { assert(packet); for (; packet; packet = packet->next) { assert(packet->len <= packet->capacity); assert(packet->sid >= -1); } } void tds_check_tds_extra(const TDSSOCKET * tds) { const int invalid_state = 0; int i; TDSDYNAMIC *cur_dyn = NULL; TDSCURSOR *cur_cursor = NULL; assert(tds); /* test state and connection */ switch (tds->state) { case TDS_DEAD: case TDS_WRITING: case TDS_SENDING: case TDS_PENDING: case TDS_IDLE: case TDS_READING: break; default: assert(invalid_state); } assert(tds->conn); #if ENABLE_ODBC_MARS if (tds->state != TDS_DEAD) assert(!TDS_IS_SOCKET_INVALID(tds_get_s(tds))); #else assert(tds->state == TDS_DEAD || !TDS_IS_SOCKET_INVALID(tds_get_s(tds))); assert(tds->state != TDS_DEAD || TDS_IS_SOCKET_INVALID(tds_get_s(tds))); #endif /* test env */ tds_check_env_extra(&tds->conn->env); /* test buffers and positions */ tds_check_packet_extra(tds->send_packet); tds_check_packet_extra(tds->recv_packet); #if ENABLE_ODBC_MARS if (tds->conn->send_packets) assert(tds->conn->send_pos <= tds->conn->send_packets->len); if (tds->conn->recv_packet) assert(tds->conn->recv_pos <= tds->conn->recv_packet->len); #endif assert(tds->in_pos <= tds->in_len); assert(tds->in_len <= tds->recv_packet->capacity); /* TODO remove blocksize from env and use out_len ?? */ /* assert(tds->out_pos <= tds->out_len); */ /* assert(tds->out_len == 0 || tds->out_buf != NULL); */ assert(tds->send_packet->capacity >= tds->out_buf_max + TDS_ADDITIONAL_SPACE); assert(tds->out_buf >= tds->send_packet->buf); assert(tds->out_buf + tds->out_buf_max + TDS_ADDITIONAL_SPACE <= tds->send_packet->buf + tds->send_packet->capacity); assert(tds->out_pos <= tds->out_buf_max + TDS_ADDITIONAL_SPACE); assert(tds->in_buf == tds->recv_packet->buf || tds->in_buf == tds->recv_packet->buf + 16); assert(tds->recv_packet->capacity > 0); /* test res_info */ if (tds->res_info) tds_check_resultinfo_extra(tds->res_info); /* test num_comp_info, comp_info */ assert(tds->num_comp_info >= 0); for (i = 0; i < tds->num_comp_info; ++i) { assert(tds->comp_info); tds_check_resultinfo_extra(tds->comp_info[i]); } /* param_info */ if (tds->param_info) tds_check_resultinfo_extra(tds->param_info); /* test cursors */ for (cur_cursor = tds->conn->cursors; cur_cursor != NULL; cur_cursor = cur_cursor->next) tds_check_cursor_extra(cur_cursor); /* test dynamics */ for (cur_dyn = tds->conn->dyns; cur_dyn != NULL; cur_dyn = cur_dyn->next) tds_check_dynamic_extra(cur_dyn); /* test tds_ctx */ tds_check_context_extra(tds_get_ctx(tds)); /* TODO test char_conv_count, char_convs */ /* we can't have compute and no results */ assert(tds->num_comp_info == 0 || tds->res_info != NULL); /* we can't have normal and parameters results */ /* TODO too strict ?? */ /* assert(tds->param_info == NULL || tds->res_info == NULL); */ } void tds_check_context_extra(const TDSCONTEXT * ctx) { assert(ctx); } void tds_check_env_extra(const TDSENV * env) { assert(env); assert(env->block_size >= 0 && env->block_size <= 65536); } void tds_check_column_extra(const TDSCOLUMN * column) { int size; TDSCONNECTION conn; int varint_ok; int column_varint_size; assert(column); column_varint_size = column->column_varint_size; /* 8 is for varchar(max) or similar */ assert(column_varint_size == 8 || (column_varint_size <= 5 && column_varint_size != 3)); assert(column->column_scale <= column->column_prec); assert(column->column_prec <= MAXPRECISION); /* I don't like this that much... freddy77 */ if (column->column_type == 0) return; assert(column->funcs); assert(column->column_type > 0); /* specific checks, if true fully checked */ if (column->funcs->check(column)) return; /* check type and server type same or SQLNCHAR -> SQLCHAR */ #define SPECIAL(ttype, server_type, varint) \ if (column->column_type == ttype && column->on_server.column_type == server_type && column_varint_size == varint) {} else SPECIAL(SYBTEXT, XSYBVARCHAR, 8) SPECIAL(SYBTEXT, XSYBNVARCHAR, 8) SPECIAL(SYBIMAGE, XSYBVARBINARY, 8) assert(tds_get_cardinal_type(column->on_server.column_type, column->column_usertype) == column->column_type || (tds_get_conversion_type(column->on_server.column_type, column->column_size) == column->column_type && column_varint_size == 1 && is_fixed_type(column->column_type))); varint_ok = 0; if (column_varint_size == 8) { if (column->on_server.column_type == XSYBVARCHAR || column->on_server.column_type == XSYBVARBINARY || column->on_server.column_type == XSYBNVARCHAR) varint_ok = 1; } else if (is_blob_type(column->column_type)) { assert(column_varint_size >= 4); } else if (column->column_type == SYBVARIANT) { assert(column_varint_size == 4); } conn.tds_version = 0x500; varint_ok = varint_ok || tds_get_varint_size(&conn, column->on_server.column_type) == column_varint_size; conn.tds_version = 0x700; varint_ok = varint_ok || tds_get_varint_size(&conn, column->on_server.column_type) == column_varint_size; assert(varint_ok); assert(!is_numeric_type(column->column_type)); assert(column->column_cur_size <= column->column_size); /* check size of fixed type correct */ size = tds_get_size_by_type(column->column_type); /* these peculiar types are variable but have only a possible size */ if ((size > 0 && (column->column_type != SYBBITN && column->column_type != SYBDATEN && column->column_type != SYBTIMEN)) || column->column_type == SYBVOID) { /* check macro */ assert(is_fixed_type(column->column_type)); /* check current size */ assert(size == column->column_size); /* check cases where server need nullable types */ if (column->column_type != column->on_server.column_type && (column->column_type != SYBINT8 || column->on_server.column_type != SYB5INT8)) { assert(!is_fixed_type(column->on_server.column_type)); assert(column_varint_size == 1); assert(column->column_size == column->column_cur_size || column->column_cur_size == -1); } else { assert(column_varint_size == 0 || (column->column_type == SYBUNIQUE && column_varint_size == 1)); assert(column->column_size == column->column_cur_size || (column->column_type == SYBUNIQUE && column->column_cur_size == -1)); } assert(column->column_size == column->on_server.column_size); } else { assert(!is_fixed_type(column->column_type)); assert(is_char_type(column->column_type) || (column->on_server.column_size == column->column_size || column->on_server.column_size == 0)); assert(column_varint_size != 0); } /* check size of nullable types (ie intN) it's supported */ if (tds_get_conversion_type(column->column_type, 4) != column->column_type) { /* check macro */ assert(is_nullable_type(column->column_type)); /* check that size it's correct for this type of nullable */ assert(tds_get_conversion_type(column->column_type, column->column_size) != column->column_type); /* check current size */ assert(column->column_size >= column->column_cur_size || column->column_cur_size == -1); /* check same type and size on server */ assert(column->column_type == column->on_server.column_type); assert(column->column_size == column->on_server.column_size); } } void tds_check_resultinfo_extra(const TDSRESULTINFO * res_info) { int i; assert(res_info); assert(res_info->num_cols >= 0); assert(res_info->ref_count > 0); for (i = 0; i < res_info->num_cols; ++i) { assert(res_info->columns); tds_check_column_extra(res_info->columns[i]); assert(res_info->columns[i]->column_data != NULL || res_info->row_size == 0); } assert(res_info->row_size >= 0); assert(res_info->computeid >= 0); assert(res_info->by_cols >= 0); assert(res_info->by_cols == 0 || res_info->bycolumns); } void tds_check_cursor_extra(const TDSCURSOR * cursor) { assert(cursor); assert(cursor->ref_count > 0); if (cursor->res_info) tds_check_resultinfo_extra(cursor->res_info); } void tds_check_dynamic_extra(const TDSDYNAMIC * dyn) { assert(dyn); assert(dyn->ref_count > 0); if (dyn->res_info) tds_check_resultinfo_extra(dyn->res_info); if (dyn->params) tds_check_resultinfo_extra(dyn->params); assert(!dyn->emulated || dyn->query); } #endif /* ENABLE_EXTRA_CHECKS */ freetds-1.00.82/src/tds/dlist.c100644 025423 025423 00000002075 12717145107 0011703/* Dlist - dynamic list * Copyright (C) 2016 Frediano Ziglio * * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include #include #include #if ENABLE_EXTRA_CHECKS void dlist_ring_check(dlist_ring *ring) { const dlist_ring *item = ring; do { assert(item->prev->next == item); assert(item->next->prev == item); item = item->next; } while (item != ring); } #endif freetds-1.00.82/src/tds/bulk.c100644 025423 025423 00000101206 12717145107 0011515/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2008-2010 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /** * \file * \brief Handle bulk copy */ #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_ERRNO_H #include #endif /* HAVE_ERRNO_H */ #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #include #include #include #include #include #include #include #include "replacements.h" /** \cond HIDDEN_SYMBOLS */ #ifndef MAX #define MAX(a,b) ( (a) > (b) ? (a) : (b) ) #endif /** \endcond */ /** * Holds clause buffer */ typedef struct tds_pbcb { /** buffer */ char *pb; /** buffer length */ unsigned int cb; /** true is buffer came from malloc */ unsigned int from_malloc; } TDSPBCB; static TDSRET tds7_bcp_send_colmetadata(TDSSOCKET *tds, TDSBCPINFO *bcpinfo); static TDSRET tds_bcp_start_insert_stmt(TDSSOCKET *tds, TDSBCPINFO *bcpinfo); static int tds_bcp_add_fixed_columns(TDSBCPINFO *bcpinfo, tds_bcp_get_col_data get_col_data, tds_bcp_null_error null_error, int offset, unsigned char * rowbuffer, int start); static int tds_bcp_add_variable_columns(TDSBCPINFO *bcpinfo, tds_bcp_get_col_data get_col_data, tds_bcp_null_error null_error, int offset, TDS_UCHAR *rowbuffer, int start, int *pncols); static void tds_bcp_row_free(TDSRESULTINFO* result, unsigned char *row); /** * Initialize BCP information. * Query structure of the table to server. * \tds * \param bcpinfo BCP information to initialize. Structure should be allocate * and table name and direction should be already set. */ TDSRET tds_bcp_init(TDSSOCKET *tds, TDSBCPINFO *bcpinfo) { TDSRESULTINFO *resinfo; TDSRESULTINFO *bindinfo = NULL; TDSCOLUMN *curcol; TDS_INT result_type; int i; TDSRET rc; const char *fmt; /* FIXME don't leave state in processing state */ /* TODO quote tablename if needed */ if (bcpinfo->direction != TDS_BCP_QUERYOUT) fmt = "SET FMTONLY ON select * from %s SET FMTONLY OFF"; else fmt = "SET FMTONLY ON %s SET FMTONLY OFF"; if (TDS_FAILED(rc=tds_submit_queryf(tds, fmt, tds_dstr_cstr(&bcpinfo->tablename)))) /* TODO return an error ?? */ /* Attempt to use Bulk Copy with a non-existent Server table (might be why ...) */ return rc; /* TODO possibly stop at ROWFMT and copy before going to idle */ /* TODO check what happen if table is not present, cleanup on error */ while ((rc = tds_process_tokens(tds, &result_type, NULL, TDS_TOKEN_RESULTS)) == TDS_SUCCESS) continue; if (TDS_FAILED(rc)) return rc; /* copy the results info from the TDS socket */ if (!tds->res_info) return TDS_FAIL; resinfo = tds->res_info; if ((bindinfo = tds_alloc_results(resinfo->num_cols)) == NULL) { rc = TDS_FAIL; goto cleanup; } bindinfo->row_size = resinfo->row_size; /* Copy the column metadata */ rc = TDS_FAIL; for (i = 0; i < bindinfo->num_cols; i++) { curcol = bindinfo->columns[i]; /* * TODO use memcpy ?? * curcol and resinfo->columns[i] are both TDSCOLUMN. * Why not "curcol = resinfo->columns[i];"? Because the rest of TDSCOLUMN (below column_timestamp) * isn't being used. Perhaps this "upper" part of TDSCOLUMN should be a substructure. * Or, see if the "lower" part is unused (and zeroed out) at this point, and just do one assignment. */ curcol->funcs = resinfo->columns[i]->funcs; curcol->column_type = resinfo->columns[i]->column_type; curcol->column_usertype = resinfo->columns[i]->column_usertype; curcol->column_flags = resinfo->columns[i]->column_flags; if (curcol->column_varint_size == 0) curcol->column_cur_size = resinfo->columns[i]->column_cur_size; else curcol->column_cur_size = -1; curcol->column_size = resinfo->columns[i]->column_size; curcol->column_varint_size = resinfo->columns[i]->column_varint_size; curcol->column_prec = resinfo->columns[i]->column_prec; curcol->column_scale = resinfo->columns[i]->column_scale; curcol->on_server.column_type = resinfo->columns[i]->on_server.column_type; curcol->on_server.column_size = resinfo->columns[i]->on_server.column_size; curcol->char_conv = resinfo->columns[i]->char_conv; if (!tds_dstr_dup(&curcol->column_name, &resinfo->columns[i]->column_name)) goto cleanup; if (!tds_dstr_dup(&curcol->table_column_name, &resinfo->columns[i]->table_column_name)) goto cleanup; curcol->column_nullable = resinfo->columns[i]->column_nullable; curcol->column_identity = resinfo->columns[i]->column_identity; curcol->column_timestamp = resinfo->columns[i]->column_timestamp; memcpy(curcol->column_collation, resinfo->columns[i]->column_collation, 5); if (is_numeric_type(curcol->column_type)) { curcol->bcp_column_data = tds_alloc_bcp_column_data(sizeof(TDS_NUMERIC)); ((TDS_NUMERIC *) curcol->bcp_column_data->data)->precision = curcol->column_prec; ((TDS_NUMERIC *) curcol->bcp_column_data->data)->scale = curcol->column_scale; } else { curcol->bcp_column_data = tds_alloc_bcp_column_data(MAX(curcol->column_size,curcol->on_server.column_size)); } if (!curcol->bcp_column_data) goto cleanup; } if (!IS_TDS7_PLUS(tds->conn)) { bindinfo->current_row = tds_new(unsigned char, bindinfo->row_size); if (!bindinfo->current_row) goto cleanup; bindinfo->row_free = tds_bcp_row_free; } if (bcpinfo->identity_insert_on) { rc = tds_submit_queryf(tds, "set identity_insert %s on", tds_dstr_cstr(&bcpinfo->tablename)); if (TDS_FAILED(rc)) goto cleanup; /* TODO use tds_process_simple_query */ while ((rc = tds_process_tokens(tds, &result_type, NULL, TDS_TOKEN_RESULTS)) == TDS_SUCCESS) { } if (rc != TDS_NO_MORE_RESULTS) goto cleanup; } bcpinfo->bindinfo = bindinfo; bcpinfo->bind_count = 0; return TDS_SUCCESS; cleanup: tds_free_results(bindinfo); return rc; } /** * Help to build query to be sent to server. * Append column declaration to the query. * Only for TDS 7.0+. * \tds * \param[out] clause output string * \param bcpcol column to append * \param first true if column is the first * \return TDS_SUCCESS or TDS_FAIL. */ static TDSRET tds7_build_bulk_insert_stmt(TDSSOCKET * tds, TDSPBCB * clause, TDSCOLUMN * bcpcol, int first) { char column_type[40]; tdsdump_log(TDS_DBG_FUNC, "tds7_build_bulk_insert_stmt(%p, %p, %p, %d)\n", tds, clause, bcpcol, first); if (TDS_FAILED(tds_get_column_declaration(tds, bcpcol, column_type))) { tdserror(tds_get_ctx(tds), tds, TDSEBPROBADTYP, errno); tdsdump_log(TDS_DBG_FUNC, "error: cannot build bulk insert statement. unrecognized server datatype %d\n", bcpcol->on_server.column_type); return TDS_FAIL; } if (clause->cb < strlen(clause->pb) + tds_quote_id(tds, NULL, tds_dstr_cstr(&bcpcol->column_name), tds_dstr_len(&bcpcol->column_name)) + strlen(column_type) + ((first) ? 2u : 4u)) { char *temp = tds_new(char, 2 * clause->cb); if (!temp) { tdserror(tds_get_ctx(tds), tds, TDSEMEM, errno); return TDS_FAIL; } strcpy(temp, clause->pb); if (clause->from_malloc) free(clause->pb); clause->from_malloc = 1; clause->pb = temp; clause->cb *= 2; } if (!first) strcat(clause->pb, ", "); tds_quote_id(tds, strchr(clause->pb, 0), tds_dstr_cstr(&bcpcol->column_name), tds_dstr_len(&bcpcol->column_name)); strcat(clause->pb, " "); strcat(clause->pb, column_type); return TDS_SUCCESS; } /** * Prepare the query to be sent to server to request BCP information * \tds * \param bcpinfo BCP information */ static TDSRET tds_bcp_start_insert_stmt(TDSSOCKET * tds, TDSBCPINFO * bcpinfo) { char *query; if (IS_TDS7_PLUS(tds->conn)) { int i, firstcol, erc; char *hint; TDSCOLUMN *bcpcol; TDSPBCB colclause; char clause_buffer[4096] = { 0 }; colclause.pb = clause_buffer; colclause.cb = sizeof(clause_buffer); colclause.from_malloc = 0; /* TODO avoid asprintf, use always malloc-ed buffer */ firstcol = 1; for (i = 0; i < bcpinfo->bindinfo->num_cols; i++) { bcpcol = bcpinfo->bindinfo->columns[i]; if (bcpcol->column_timestamp) continue; if (!bcpinfo->identity_insert_on && bcpcol->column_identity) continue; tds7_build_bulk_insert_stmt(tds, &colclause, bcpcol, firstcol); firstcol = 0; } if (bcpinfo->hint) { if (asprintf(&hint, " with (%s)", bcpinfo->hint) < 0) hint = NULL; } else { hint = strdup(""); } if (!hint) { if (colclause.from_malloc) TDS_ZERO_FREE(colclause.pb); return TDS_FAIL; } erc = asprintf(&query, "insert bulk %s (%s)%s", tds_dstr_cstr(&bcpinfo->tablename), colclause.pb, hint); free(hint); if (colclause.from_malloc) TDS_ZERO_FREE(colclause.pb); /* just for good measure; not used beyond this point */ if (erc < 0) return TDS_FAIL; } else { /* NOTE: if we use "with nodescribe" for following inserts server do not send describe */ if (asprintf(&query, "insert bulk %s", tds_dstr_cstr(&bcpinfo->tablename)) < 0) return TDS_FAIL; } /* save the statement for later... */ bcpinfo->insert_stmt = query; return TDS_SUCCESS; } /** * Send one row of data to server * \tds * \param bcpinfo BCP information * \param get_col_data function to call to retrieve data to be sent * \param ignored function to call if we try to send NULL if not allowed (not used) * \param offset passed to get_col_data and null_error to specify the row to get * \return TDS_SUCCESS or TDS_FAIL. */ TDSRET tds_bcp_send_record(TDSSOCKET *tds, TDSBCPINFO *bcpinfo, tds_bcp_get_col_data get_col_data, tds_bcp_null_error ignored, int offset) { TDSCOLUMN *bindcol; int i; TDSRET rc; tdsdump_log(TDS_DBG_FUNC, "tds_bcp_send_bcp_record(%p, %p, %p, ignored, %d)\n", tds, bcpinfo, get_col_data, offset); if (tds->out_flag != TDS_BULK || tds_set_state(tds, TDS_WRITING) != TDS_WRITING) return TDS_FAIL; if (IS_TDS7_PLUS(tds->conn)) { tds_put_byte(tds, TDS_ROW_TOKEN); /* 0xd1 */ for (i = 0; i < bcpinfo->bindinfo->num_cols; i++) { TDS_INT save_size; unsigned char *save_data; TDSBLOB blob; bindcol = bcpinfo->bindinfo->columns[i]; /* * Don't send the (meta)data for timestamp columns or * identity columns unless indentity_insert is enabled. */ if ((!bcpinfo->identity_insert_on && bindcol->column_identity) || bindcol->column_timestamp) { continue; } rc = get_col_data(bcpinfo, bindcol, offset); if (TDS_FAILED(rc)) { tdsdump_log(TDS_DBG_INFO1, "get_col_data (column %d) failed\n", i + 1); goto cleanup; } tdsdump_log(TDS_DBG_INFO1, "gotten column %d length %d null %d\n", i + 1, bindcol->bcp_column_data->datalen, bindcol->bcp_column_data->is_null); save_size = bindcol->column_cur_size; save_data = bindcol->column_data; assert(bindcol->column_data == NULL); if (bindcol->bcp_column_data->is_null) { bindcol->column_cur_size = -1; } else if (is_blob_col(bindcol)) { bindcol->column_cur_size = bindcol->bcp_column_data->datalen; memset(&blob, 0, sizeof(blob)); blob.textvalue = (TDS_CHAR *) bindcol->bcp_column_data->data; bindcol->column_data = (unsigned char *) &blob; } else { bindcol->column_cur_size = bindcol->bcp_column_data->datalen; bindcol->column_data = bindcol->bcp_column_data->data; } rc = bindcol->funcs->put_data(tds, bindcol, 1); bindcol->column_cur_size = save_size; bindcol->column_data = save_data; if (TDS_FAILED(rc)) goto cleanup; } } /* IS_TDS7_PLUS */ else { int row_pos; int row_sz_pos; int blob_cols = 0; int var_cols_written = 0; TDS_INT old_record_size = bcpinfo->bindinfo->row_size; unsigned char *record = bcpinfo->bindinfo->current_row; memset(record, '\0', old_record_size); /* zero the rowbuffer */ /* * offset 0 = number of var columns * offset 1 = row number. zeroed (datasever assigns) */ row_pos = 2; rc = TDS_FAIL; if ((row_pos = tds_bcp_add_fixed_columns(bcpinfo, get_col_data, NULL, offset, record, row_pos)) < 0) goto cleanup; row_sz_pos = row_pos; /* potential variable columns to write */ if ((row_pos = tds_bcp_add_variable_columns(bcpinfo, get_col_data, NULL, offset, record, row_pos, &var_cols_written)) < 0) goto cleanup; if (var_cols_written) { TDS_PUT_UA2(&record[row_sz_pos], row_pos); record[0] = var_cols_written; } tdsdump_log(TDS_DBG_INFO1, "old_record_size = %d new size = %d \n", old_record_size, row_pos); tds_put_smallint(tds, row_pos); tds_put_n(tds, record, row_pos); /* row is done, now handle any text/image data */ blob_cols = 0; for (i = 0; i < bcpinfo->bindinfo->num_cols; i++) { bindcol = bcpinfo->bindinfo->columns[i]; if (is_blob_type(bindcol->column_type)) { rc = get_col_data(bcpinfo, bindcol, offset); if (TDS_FAILED(rc)) goto cleanup; /* unknown but zero */ tds_put_smallint(tds, 0); tds_put_byte(tds, bindcol->column_type); tds_put_byte(tds, 0xff - blob_cols); /* * offset of txptr we stashed during variable * column processing */ tds_put_smallint(tds, bindcol->column_textpos); tds_put_int(tds, bindcol->bcp_column_data->datalen); tds_put_n(tds, bindcol->bcp_column_data->data, bindcol->bcp_column_data->datalen); blob_cols++; } } } tds_set_state(tds, TDS_SENDING); return TDS_SUCCESS; cleanup: tds_set_state(tds, TDS_SENDING); return rc; } /** * Add fixed size columns to the row * \param bcpinfo BCP information * \param get_col_data function to call to retrieve data to be sent * \param ignored function to call if we try to send NULL if not allowed (not used) * \param offset passed to get_col_data and null_error to specify the row to get * \param rowbuffer row buffer to write to * \param start row buffer last end position * \returns new row length or -1 on error. */ static int tds_bcp_add_fixed_columns(TDSBCPINFO *bcpinfo, tds_bcp_get_col_data get_col_data, tds_bcp_null_error ignored, int offset, unsigned char * rowbuffer, int start) { TDS_NUMERIC *num; int row_pos = start; TDSCOLUMN *bcpcol; int cpbytes; int i, j; int bitleft = 0, bitpos; assert(bcpinfo); assert(rowbuffer); tdsdump_log(TDS_DBG_FUNC, "tds_bcp_add_fixed_columns(%p, %p, ignored, %d, %p, %d)\n", bcpinfo, get_col_data, offset, rowbuffer, start); for (i = 0; i < bcpinfo->bindinfo->num_cols; i++) { bcpcol = bcpinfo->bindinfo->columns[i]; if (is_nullable_type(bcpcol->column_type) || bcpcol->column_nullable) continue; tdsdump_log(TDS_DBG_FUNC, "tds_bcp_add_fixed_columns column %d is a fixed column\n", i + 1); if (TDS_FAILED(get_col_data(bcpinfo, bcpcol, offset))) { tdsdump_log(TDS_DBG_INFO1, "get_col_data (column %d) failed\n", i + 1); return -1; } #if USING_SYBEBCNN Let the server reject if no default is defined for the column. if (bcpcol->bcp_column_data->is_null) { /* No value or default value available and NULL not allowed. */ null_error(bcpinfo, i, offset); return -1; } #endif if (is_numeric_type(bcpcol->column_type)) { num = (TDS_NUMERIC *) bcpcol->bcp_column_data->data; cpbytes = tds_numeric_bytes_per_prec[num->precision]; memcpy(&rowbuffer[row_pos], num->array, cpbytes); } else if (bcpcol->column_type == SYBBIT) { /* all bit are collapsed together */ if (!bitleft) { bitpos = row_pos++; bitleft = 8; rowbuffer[bitpos] = 0; } if (bcpcol->bcp_column_data->data[0]) rowbuffer[bitpos] |= 256 >> bitleft; --bitleft; continue; } else { cpbytes = bcpcol->bcp_column_data->datalen > bcpcol->column_size ? bcpcol->column_size : bcpcol->bcp_column_data->datalen; memcpy(&rowbuffer[row_pos], bcpcol->bcp_column_data->data, cpbytes); /* CHAR data may need padding out to the database length with blanks */ /* TODO check binary !!! */ if (bcpcol->column_type == SYBCHAR && cpbytes < bcpcol->column_size) { for (j = cpbytes; j < bcpcol->column_size; j++) rowbuffer[row_pos + j] = ' '; } } row_pos += bcpcol->column_size; } return row_pos; } /** * Add variable size columns to the row * * \param bcpinfo BCP information already prepared * \param get_col_data function to call to retrieve data to be sent * \param null_error function to call if we try to send NULL if not allowed * \param offset passed to get_col_data and null_error to specify the row to get * \param rowbuffer The row image that will be sent to the server. * \param start Where to begin copying data into the rowbuffer. * \param pncols Address of output variable holding the count of columns added to the rowbuffer. * * \return length of (potentially modified) rowbuffer, or -1. */ static int tds_bcp_add_variable_columns(TDSBCPINFO *bcpinfo, tds_bcp_get_col_data get_col_data, tds_bcp_null_error null_error, int offset, TDS_UCHAR* rowbuffer, int start, int *pncols) { TDS_USMALLINT offsets[256]; unsigned int i, row_pos; unsigned int ncols = 0; assert(bcpinfo); assert(rowbuffer); assert(pncols); tdsdump_log(TDS_DBG_FUNC, "%4s %8s %18s %18s %8s\n", "col", "type", "is_nullable_type", "column_nullable", "is null" ); for (i = 0; i < bcpinfo->bindinfo->num_cols; i++) { TDSCOLUMN *bcpcol = bcpinfo->bindinfo->columns[i]; tdsdump_log(TDS_DBG_FUNC, "%4d %8d %18s %18s %8s\n", i, bcpcol->column_type, is_nullable_type(bcpcol->column_type)? "yes" : "no", bcpcol->column_nullable? "yes" : "no", bcpcol->bcp_column_data->is_null? "yes" : "no" ); } /* the first two bytes of the rowbuffer are reserved to hold the entire record length */ row_pos = start + 2; offsets[0] = row_pos; tdsdump_log(TDS_DBG_FUNC, "%4s %8s %8s %8s\n", "col", "ncols", "row_pos", "cpbytes"); for (i = 0; i < bcpinfo->bindinfo->num_cols; i++) { unsigned int cpbytes = 0; TDSCOLUMN *bcpcol = bcpinfo->bindinfo->columns[i]; /* * Is this column of "variable" type, i.e. NULLable * or naturally variable length e.g. VARCHAR */ if (!is_nullable_type(bcpcol->column_type) && !bcpcol->column_nullable) continue; tdsdump_log(TDS_DBG_FUNC, "%4d %8d %8d %8d\n", i, ncols, row_pos, cpbytes); if (TDS_FAILED(get_col_data(bcpinfo, bcpcol, offset))) return -1; #if USING_SYBEBCNN /* If it's a NOT NULL column, and we have no data, throw an error. */ No, the column could have a default defined. if (!(bcpcol->column_nullable) && bcpcol->bcp_column_data->is_null) { /* No value or default value available and NULL not allowed. */ null_error(bcpinfo, i, offset); return -1; } #endif /* move the column buffer into the rowbuffer */ if (!bcpcol->bcp_column_data->is_null) { if (is_blob_type(bcpcol->column_type)) { cpbytes = 16; bcpcol->column_textpos = row_pos; /* save for data write */ } else if (is_numeric_type(bcpcol->column_type)) { TDS_NUMERIC *num = (TDS_NUMERIC *) bcpcol->bcp_column_data->data; cpbytes = tds_numeric_bytes_per_prec[num->precision]; memcpy(&rowbuffer[row_pos], num->array, cpbytes); } else { cpbytes = bcpcol->bcp_column_data->datalen > bcpcol->column_size ? bcpcol->column_size : bcpcol->bcp_column_data->datalen; memcpy(&rowbuffer[row_pos], bcpcol->bcp_column_data->data, cpbytes); } } row_pos += cpbytes; offsets[++ncols] = row_pos; tdsdump_dump_buf(TDS_DBG_NETWORK, "BCP row buffer so far", rowbuffer, row_pos); } tdsdump_log(TDS_DBG_FUNC, "%4d %8d %8d\n", i, ncols, row_pos); /* * The rowbuffer ends with an offset table and, optionally, an adjustment table. * The offset table has 1-byte elements that describe the locations of the start of each column in * the rowbuffer. If the largest offset is greater than 255, another table -- the adjustment table -- * is inserted just before the offset table. It holds the high bytes. * * Both tables are laid out in reverse: * #elements, offset N+1, offset N, offset N-1, ... offset 0 * E.g. for 2 columns you have 4 data points: * 1. How many elements (4) * 2. Start of column 3 (non-existent, "one off the end") * 3. Start of column 2 * 4. Start of column 1 * The length of each column is computed by subtracting its start from the its successor's start. * * The algorithm below computes both tables. If the adjustment table isn't needed, the * effect is to overwrite it with the offset table. */ while (ncols && offsets[ncols] == offsets[ncols-1]) ncols--; /* trailing NULL columns are not sent and are not included in the offset table */ if (ncols) { TDS_UCHAR *poff = rowbuffer + row_pos; unsigned int pfx_top = offsets[ncols] / 256; tdsdump_log(TDS_DBG_FUNC, "ncols=%u poff=%p [%u]\n", ncols, poff, offsets[ncols]); *poff++ = ncols + 1; /* this is some kind of run-length-prefix encoding */ while (pfx_top) { unsigned int n_pfx = 1; for (i = 0; i <= ncols ; ++i) if ((offsets[i] / 256) < pfx_top) ++n_pfx; *poff++ = n_pfx; --pfx_top; } tdsdump_log(TDS_DBG_FUNC, "poff=%p\n", poff); for (i=0; i <= ncols; i++) *poff++ = offsets[ncols-i] & 0xFF; row_pos = (unsigned int)(poff - rowbuffer); } tdsdump_log(TDS_DBG_FUNC, "%4d %8d %8d\n", i, ncols, row_pos); tdsdump_dump_buf(TDS_DBG_NETWORK, "BCP row buffer", rowbuffer, row_pos); *pncols = ncols; return ncols == 0? start : row_pos; } /** * Send BCP metadata to server. * Only for TDS 7.0+. * \tds * \param bcpinfo BCP information * \return TDS_SUCCESS or TDS_FAIL. */ static TDSRET tds7_bcp_send_colmetadata(TDSSOCKET *tds, TDSBCPINFO *bcpinfo) { TDSCOLUMN *bcpcol; int i, num_cols; tdsdump_log(TDS_DBG_FUNC, "tds7_bcp_send_colmetadata(%p, %p)\n", tds, bcpinfo); assert(tds && bcpinfo); if (tds->out_flag != TDS_BULK || tds_set_state(tds, TDS_WRITING) != TDS_WRITING) return TDS_FAIL; /* * Deep joy! For TDS 7 we have to send a colmetadata message followed by row data */ tds_put_byte(tds, TDS7_RESULT_TOKEN); /* 0x81 */ num_cols = 0; for (i = 0; i < bcpinfo->bindinfo->num_cols; i++) { bcpcol = bcpinfo->bindinfo->columns[i]; if ((!bcpinfo->identity_insert_on && bcpcol->column_identity) || bcpcol->column_timestamp) { continue; } num_cols++; } tds_put_smallint(tds, num_cols); for (i = 0; i < bcpinfo->bindinfo->num_cols; i++) { size_t len; bcpcol = bcpinfo->bindinfo->columns[i]; /* * dont send the (meta)data for timestamp columns, or * identity columns (unless indentity_insert is enabled */ if ((!bcpinfo->identity_insert_on && bcpcol->column_identity) || bcpcol->column_timestamp) { continue; } if (IS_TDS72_PLUS(tds->conn)) tds_put_int(tds, bcpcol->column_usertype); else tds_put_smallint(tds, bcpcol->column_usertype); tds_put_smallint(tds, bcpcol->column_flags); tds_put_byte(tds, bcpcol->on_server.column_type); assert(bcpcol->funcs); bcpcol->funcs->put_info(tds, bcpcol); /* TODO put this in put_info. It seems that parameter format is * different from BCP format */ if (is_blob_type(bcpcol->on_server.column_type)) { /* FIXME support multibyte string */ len = tds_dstr_len(&bcpinfo->tablename); TDS_PUT_SMALLINT(tds, len); tds_put_string(tds, tds_dstr_cstr(&bcpinfo->tablename), len); } /* FIXME support multibyte string */ len = tds_dstr_len(&bcpcol->column_name); tds_put_byte(tds, len); tds_put_string(tds, tds_dstr_cstr(&bcpcol->column_name), len); } tds_set_state(tds, TDS_SENDING); return TDS_SUCCESS; } /** * Tell we finished sending BCP data to server * \tds * \param[out] rows_copied number of rows copied to server */ TDSRET tds_bcp_done(TDSSOCKET *tds, int *rows_copied) { TDSRET rc; tdsdump_log(TDS_DBG_FUNC, "tds_bcp_done(%p, %p)\n", tds, rows_copied); if (tds->out_flag != TDS_BULK || tds_set_state(tds, TDS_WRITING) != TDS_WRITING) return TDS_FAIL; tds_flush_packet(tds); tds_set_state(tds, TDS_PENDING); rc = tds_process_simple_query(tds); if (TDS_FAILED(rc)) return rc; if (rows_copied) *rows_copied = tds->rows_affected; return TDS_SUCCESS; } /** * Start sending BCP data to server. * Initialize stream to accept data. * \tds * \param bcpinfo BCP information already prepared */ TDSRET tds_bcp_start(TDSSOCKET *tds, TDSBCPINFO *bcpinfo) { TDSRET rc; tdsdump_log(TDS_DBG_FUNC, "tds_bcp_start(%p, %p)\n", tds, bcpinfo); rc = tds_submit_query(tds, bcpinfo->insert_stmt); if (TDS_FAILED(rc)) return rc; /* set we want to switch to bulk state */ tds->bulk_query = 1; /* * In TDS 5 we get the column information as a result set from the "insert bulk" command. * We're going to ignore it. */ rc = tds_process_simple_query(tds); if (TDS_FAILED(rc)) return rc; tds->out_flag = TDS_BULK; if (tds_set_state(tds, TDS_SENDING) != TDS_SENDING) return TDS_FAIL; if (IS_TDS7_PLUS(tds->conn)) tds7_bcp_send_colmetadata(tds, bcpinfo); return TDS_SUCCESS; } /** * Free row data allocated in the result set. */ static void tds_bcp_row_free(TDSRESULTINFO* result, unsigned char *row) { result->row_size = 0; TDS_ZERO_FREE(result->current_row); } /** * Start bulk copy to server * \tds * \param bcpinfo BCP information already prepared */ TDSRET tds_bcp_start_copy_in(TDSSOCKET *tds, TDSBCPINFO *bcpinfo) { TDSCOLUMN *bcpcol; int i; int fixed_col_len_tot = 0; int variable_col_len_tot = 0; int column_bcp_data_size = 0; int bcp_record_size = 0; TDSRET rc; TDS_INT var_cols; tdsdump_log(TDS_DBG_FUNC, "tds_bcp_start_copy_in(%p, %p)\n", tds, bcpinfo); rc = tds_bcp_start_insert_stmt(tds, bcpinfo); if (TDS_FAILED(rc)) return rc; rc = tds_bcp_start(tds, bcpinfo); if (TDS_FAILED(rc)) { /* TODO, in CTLib was _ctclient_msg(blkdesc->con, "blk_rowxfer", 2, 5, 1, 140, ""); */ return rc; } /* * Work out the number of "variable" columns. These are either nullable or of * varying length type e.g. varchar. */ var_cols = 0; if (IS_TDS50(tds->conn)) { for (i = 0; i < bcpinfo->bindinfo->num_cols; i++) { bcpcol = bcpinfo->bindinfo->columns[i]; /* * work out storage required for this datatype * blobs always require 16, numerics vary, the * rest can be taken from the server */ if (is_blob_type(bcpcol->on_server.column_type)) column_bcp_data_size = 16; else if (is_numeric_type(bcpcol->on_server.column_type)) column_bcp_data_size = tds_numeric_bytes_per_prec[bcpcol->column_prec]; else column_bcp_data_size = bcpcol->column_size; /* * now add that size into either fixed or variable * column totals... */ if (is_nullable_type(bcpcol->on_server.column_type) || bcpcol->column_nullable) { var_cols++; variable_col_len_tot += column_bcp_data_size; } else { fixed_col_len_tot += column_bcp_data_size; } } /* this formula taken from sybase manual... */ bcp_record_size = 4 + fixed_col_len_tot + variable_col_len_tot + ( (int)(variable_col_len_tot / 256 ) + 1 ) + (var_cols + 1) + 2; tdsdump_log(TDS_DBG_FUNC, "current_record_size = %d\n", bcpinfo->bindinfo->row_size); tdsdump_log(TDS_DBG_FUNC, "bcp_record_size = %d\n", bcp_record_size); if (bcp_record_size > bcpinfo->bindinfo->row_size) { if (!TDS_RESIZE(bcpinfo->bindinfo->current_row, bcp_record_size)) { tdsdump_log(TDS_DBG_FUNC, "could not realloc current_row\n"); return TDS_FAIL; } bcpinfo->bindinfo->row_free = tds_bcp_row_free; bcpinfo->bindinfo->row_size = bcp_record_size; } } return TDS_SUCCESS; } /** input stream to read a file */ typedef struct tds_file_stream { /** common fields, must be the first field */ TDSINSTREAM stream; /** file to read from */ FILE *f; /** terminator */ const char *terminator; /** terminator length in bytes */ size_t term_len; /** buffer for store bytes readed that could be the terminator */ char *left; size_t left_pos; } TDSFILESTREAM; /** \cond HIDDEN_SYMBOLS */ #if defined(_WIN32) && defined(HAVE__LOCK_FILE) && defined(HAVE__UNLOCK_FILE) #define TDS_HAVE_STDIO_LOCKED 1 #define flockfile(s) _lock_file(s) #define funlockfile(s) _unlock_file(s) #define getc_unlocked(s) _getc_nolock(s) #define feof_unlocked(s) _feof_nolock(s) #endif #ifndef TDS_HAVE_STDIO_LOCKED #undef getc_unlocked #undef feof_unlocked #undef flockfile #undef funlockfile #define getc_unlocked(s) getc(s) #define feof_unlocked(s) feof(s) #define flockfile(s) do { } while(0) #define funlockfile(s) do { } while(0) #endif /** \endcond */ /** * Reads a chunk of data from file stream checking for terminator * \param stream file stream * \param ptr buffer where to read data * \param len length of buffer */ static int tds_file_stream_read(TDSINSTREAM *stream, void *ptr, size_t len) { TDSFILESTREAM *s = (TDSFILESTREAM *) stream; int c; char *p = (char *) ptr; while (len) { if (memcmp(s->left, s->terminator - s->left_pos, s->term_len) == 0) return p - (char *) ptr; c = getc_unlocked(s->f); if (c == EOF) return -1; *p++ = s->left[s->left_pos]; --len; s->left[s->left_pos++] = c; s->left_pos %= s->term_len; } return p - (char *) ptr; } /** * Read a data file, passing the data through iconv(). * \retval TDS_SUCCESS success * \retval TDS_FAIL error reading the column * \retval TDS_NO_MORE_RESULTS end of file detected */ TDSRET tds_bcp_fread(TDSSOCKET * tds, TDSICONV * char_conv, FILE * stream, const char *terminator, size_t term_len, char **outbuf, size_t * outbytes) { TDSRET res; TDSFILESTREAM r; TDSDYNAMICSTREAM w; size_t readed; /* prepare streams */ r.stream.read = tds_file_stream_read; r.f = stream; r.term_len = term_len; r.left = tds_new0(char, term_len*3); r.left_pos = 0; if (!r.left) return TDS_FAIL; /* copy terminator twice, let terminator points to second copy */ memcpy(r.left + term_len, terminator, term_len); memcpy(r.left + term_len*2u, terminator, term_len); r.terminator = r.left + term_len*2u; /* read initial buffer to test with terminator */ readed = fread(r.left, 1, term_len, stream); if (readed != term_len) { free(r.left); if (readed == 0 && feof(stream)) return TDS_NO_MORE_RESULTS; return TDS_FAIL; } res = tds_dynamic_stream_init(&w, (void**) outbuf, 0); if (TDS_FAILED(res)) { free(r.left); return res; } /* convert/copy from input stream to output one */ flockfile(stream); if (char_conv == NULL) res = tds_copy_stream(tds, &r.stream, &w.stream); else res = tds_convert_stream(tds, char_conv, to_server, &r.stream, &w.stream); funlockfile(stream); free(r.left); if (TDS_FAILED(res)) return res; *outbytes = w.size; /* terminate buffer */ if (!w.stream.buf_len) return TDS_FAIL; ((char *) w.stream.buffer)[0] = 0; w.stream.write(&w.stream, 1); return res; } /** * Start writing writetext request. * This request start a bulk session. * \tds * \param objname table name * \param textptr TEXTPTR (see sql documentation) * \param timestamp data timestamp * \param with_log is log is enabled during insert * \param size bytes to be inserted */ TDSRET tds_writetext_start(TDSSOCKET *tds, const char *objname, const char *textptr, const char *timestamp, int with_log, TDS_UINT size) { TDSRET rc; /* TODO mssql does not like timestamp */ rc = tds_submit_queryf(tds, "writetext bulk %s 0x%s timestamp = 0x%s%s", objname, textptr, timestamp, with_log ? " with log" : ""); if (TDS_FAILED(rc)) return rc; /* set we want to switch to bulk state */ tds->bulk_query = 1; /* read the end token */ rc = tds_process_simple_query(tds); if (TDS_FAILED(rc)) return rc; tds->out_flag = TDS_BULK; if (tds_set_state(tds, TDS_WRITING) != TDS_WRITING) return TDS_FAIL; tds_put_int(tds, size); tds_set_state(tds, TDS_SENDING); return TDS_SUCCESS; } /** * Send some data in the writetext request started by tds_writetext_start. * You should write in total (with multiple calls to this function) all * bytes declared calling tds_writetext_start. * \tds * \param text data to write * \param size data size in bytes */ TDSRET tds_writetext_continue(TDSSOCKET *tds, const TDS_UCHAR *text, TDS_UINT size) { if (tds->out_flag != TDS_BULK || tds_set_state(tds, TDS_WRITING) != TDS_WRITING) return TDS_FAIL; /* TODO check size left */ tds_put_n(tds, text, size); tds_set_state(tds, TDS_SENDING); return TDS_SUCCESS; } /** * Finish sending writetext data. * \tds */ TDSRET tds_writetext_end(TDSSOCKET *tds) { if (tds->out_flag != TDS_BULK || tds_set_state(tds, TDS_WRITING) != TDS_WRITING) return TDS_FAIL; tds_flush_packet(tds); tds_set_state(tds, TDS_PENDING); return TDS_SUCCESS; } freetds-1.00.82/src/tds/packet.c100644 025423 025423 00000051031 13107261221 0012015/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2012 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #include #if HAVE_ERRNO_H #include #endif /* HAVE_ERRNO_H */ #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #if HAVE_POLL_H #include #endif /* HAVE_POLL_H */ #include #include #include #include "replacements.h" #include #include #undef MAX #define MAX(a,b) (((a) > (b)) ? (a) : (b)) /** * \addtogroup network * @{ */ #if ENABLE_ODBC_MARS static TDSRET tds_update_recv_wnd(TDSSOCKET *tds, TDS_UINT new_recv_wnd); static short tds_packet_write(TDSCONNECTION *conn); /* get packet from the cache */ static TDSPACKET * tds_get_packet(TDSCONNECTION *conn, unsigned len) { TDSPACKET *packet, *to_free = NULL; tds_mutex_lock(&conn->list_mtx); while ((packet = conn->packet_cache) != NULL) { --conn->num_cached_packets; conn->packet_cache = packet->next; /* return it */ if (packet->capacity >= len) { TDS_MARK_UNDEFINED(packet->buf, packet->capacity); packet->next = NULL; packet->len = 0; packet->sid = 0; break; } /* discard packet if too small */ packet->next = to_free; to_free = packet; } tds_mutex_unlock(&conn->list_mtx); if (to_free) tds_free_packets(to_free); if (!packet) packet = tds_alloc_packet(NULL, len); return packet; } /* append packets in cached list. must have the lock! */ static void tds_packet_cache_add(TDSCONNECTION *conn, TDSPACKET *packet) { TDSPACKET *last; unsigned count = 1; assert(conn && packet); tds_mutex_check_owned(&conn->list_mtx); if (conn->num_cached_packets >= 8) { tds_free_packets(packet); return; } for (last = packet; last->next; last = last->next) ++count; last->next = conn->packet_cache; conn->packet_cache = packet; conn->num_cached_packets += count; #if ENABLE_EXTRA_CHECKS count = 0; for (packet = conn->packet_cache; packet; packet = packet->next) ++count; assert(count == conn->num_cached_packets); #endif } /* read partial packet */ static void tds_packet_read(TDSCONNECTION *conn, TDSSOCKET *tds) { TDSPACKET *packet = conn->recv_packet; int len; /* allocate some space to read data */ if (!packet) { conn->recv_packet = packet = tds_get_packet(conn, MAX(conn->env.block_size + sizeof(TDS72_SMP_HEADER), 512)); if (!packet) goto Memory_Error; TDS_MARK_UNDEFINED(packet->buf, packet->capacity); conn->recv_pos = 0; packet->len = 8; } assert(conn->recv_pos < packet->len && packet->len <= packet->capacity); len = tds_connection_read(tds, packet->buf + conn->recv_pos, packet->len - conn->recv_pos); if (len < 0) goto Severe_Error; conn->recv_pos += len; assert(conn->recv_pos <= packet->len && packet->len <= packet->capacity); /* handle SMP */ if (conn->recv_pos > 0 && packet->buf[0] == TDS72_SMP) { TDS72_SMP_HEADER mars_header; short sid; TDSSOCKET *tds; TDS_UINT size; if (conn->recv_pos < 16) { packet->len = 16; return; } memcpy(&mars_header, packet->buf, sizeof(mars_header)); tdsdump_dump_buf(TDS_DBG_HEADER, "Received MARS header", &mars_header, sizeof(mars_header)); sid = TDS_GET_A2LE(&mars_header.sid); /* FIXME this is done even by caller !! */ tds = NULL; tds_mutex_lock(&conn->list_mtx); if (sid >= 0 && sid < conn->num_sessions) tds = conn->sessions[sid]; tds_mutex_unlock(&conn->list_mtx); packet->sid = sid; if (tds == BUSY_SOCKET) { if (mars_header.type != TDS_SMP_FIN) { tdsdump_log(TDS_DBG_ERROR, "Received MARS with no session (%d)\n", sid); goto Severe_Error; } /* check if was just a "zombie" socket */ tds_mutex_lock(&conn->list_mtx); conn->sessions[sid] = NULL; tds_mutex_unlock(&conn->list_mtx); /* reset packet to initial state to reuse it */ packet->len = 8; conn->recv_pos = 0; return; } if (!tds) { /* server sent a unknown packet, close connection */ goto Severe_Error; } tds->send_wnd = TDS_GET_A4LE(&mars_header.wnd); size = TDS_GET_A4LE(&mars_header.size); if (mars_header.type == TDS_SMP_ACK) { if (size != sizeof(mars_header)) goto Severe_Error; } else if (mars_header.type == TDS_SMP_DATA) { if (size < 0x18 || size > 0xffffu + sizeof(mars_header)) goto Severe_Error; /* avoid recursive SMP */ if (conn->recv_pos > 16 && packet->buf[16] == TDS72_SMP) goto Severe_Error; /* TODO is possible to put 2 TDS packet inside a single DATA ?? */ if (conn->recv_pos >= 20 && TDS_GET_A2BE(&packet->buf[18]) != size - 16) goto Severe_Error; tds->recv_seq = TDS_GET_A4LE(&mars_header.seq); /* * does not sent ACK here cause this would lead to memory waste * if session is not able to handle all that packets */ } else if (mars_header.type == TDS_SMP_FIN) { if (size != sizeof(mars_header)) goto Severe_Error; /* this socket shold now not start another session */ // tds_set_state(tds, TDS_DEAD); // tds->sid = -1; } else goto Severe_Error; if (mars_header.type != TDS_SMP_DATA) return; if (packet->len < size) { packet = tds_realloc_packet(packet, size); if (!packet) goto Memory_Error; conn->recv_packet = packet; } packet->len = size; return; } assert(conn->recv_pos <= packet->len && packet->len <= packet->capacity); /* normal packet */ if (conn->recv_pos >= 8) { len = TDS_GET_A2BE(&packet->buf[2]); if (len < 8) goto Severe_Error; if (packet->len < len) { packet = tds_realloc_packet(packet, len); if (!packet) goto Memory_Error; conn->recv_packet = packet; } packet->len = len; } return; Memory_Error: Severe_Error: tds_connection_close(conn); tds_free_packets(packet); conn->recv_packet = NULL; } static void tds_alloc_new_sid(TDSSOCKET *tds) { int sid = -1; TDSCONNECTION *conn = tds->conn; TDSSOCKET **s; tds_mutex_lock(&conn->list_mtx); tds->sid = -1; for (sid = 0; sid < conn->num_sessions; ++sid) if (!conn->sessions[sid]) break; if (sid == conn->num_sessions) { /* extend array */ s = (TDSSOCKET **) TDS_RESIZE(conn->sessions, sid+64); if (!s) goto error; memset(s + conn->num_sessions, 0, sizeof(*s) * 64); conn->num_sessions += 64; } conn->sessions[sid] = tds; tds->sid = sid; error: tds_mutex_unlock(&conn->list_mtx); } static TDSPACKET* tds_build_packet(TDSSOCKET *tds, unsigned char *buf, unsigned len) { unsigned start; TDS72_SMP_HEADER mars[2], *p; TDSPACKET *packet; p = mars; if (buf[0] != TDS72_SMP && tds->conn->mars) { /* allocate a new sid */ if (tds->sid == -1) { p->signature = TDS72_SMP; p->type = TDS_SMP_SYN; /* start session */ /* FIXME check !!! */ tds_alloc_new_sid(tds); tds->recv_seq = 0; tds->send_seq = 0; tds->recv_wnd = 4; tds->send_wnd = 4; TDS_PUT_A2LE(&p->sid, tds->sid); p->size = TDS_HOST4LE(0x10); p->seq = TDS_HOST4LE(0); TDS_PUT_A4LE(&p->wnd, tds->recv_wnd); p++; } if (tds->sid >= 0) { p->signature = TDS72_SMP; p->type = TDS_SMP_DATA; TDS_PUT_A2LE(&p->sid, tds->sid); TDS_PUT_A4LE(&p->size, len+16); TDS_PUT_A4LE(&p->seq, ++tds->send_seq); /* this is the acknowledge we give to server to stop sending !!! */ tds->recv_wnd = tds->recv_seq + 4; TDS_PUT_A4LE(&p->wnd, tds->recv_wnd); p++; } } start = (p - mars) * sizeof(mars[0]); packet = tds_get_packet(tds->conn, len + start); if (TDS_LIKELY(packet)) { packet->sid = tds->sid; memcpy(packet->buf, mars, start); memcpy(packet->buf + start, buf, len); packet->len = len + start; } return packet; } static void tds_append_packet(TDSPACKET **p_packet, TDSPACKET *packet) { while (*p_packet) p_packet = &((*p_packet)->next); *p_packet = packet; } int tds_append_cancel(TDSSOCKET *tds) { unsigned char buf[8]; TDSPACKET *packet; buf[0] = TDS_CANCEL; buf[1] = 1; TDS_PUT_A2BE(buf+2, 8); TDS_PUT_A4(buf+4, 0); if (IS_TDS7_PLUS(tds->conn) && !tds->login) buf[6] = 0x01; packet = tds_build_packet(tds, buf, 8); if (!packet) return TDS_FAIL; tds_mutex_lock(&tds->conn->list_mtx); tds_append_packet(&tds->conn->send_packets, packet); tds_mutex_unlock(&tds->conn->list_mtx); return TDS_SUCCESS; } static void tds_connection_network(TDSCONNECTION *conn, TDSSOCKET *tds, int send) { assert(!conn->in_net_tds); conn->in_net_tds = tds; tds_mutex_unlock(&conn->list_mtx); for (;;) { /* wait packets or update */ int rc = tds_select(tds, conn->send_packets ? TDSSELREAD|TDSSELWRITE : TDSSELREAD, tds->query_timeout); if (rc < 0) { /* FIXME better error report */ tds_connection_close(conn); break; } /* change notify */ /* TODO async */ if (!rc) { /* timeout */ tdsdump_log(TDS_DBG_INFO1, "timeout\n"); switch (rc = tdserror(tds_get_ctx(tds), tds, TDSETIME, sock_errno)) { case TDS_INT_CONTINUE: continue; default: case TDS_INT_CANCEL: tds_close_socket(tds); } break; } /* * we must write first to catch write errors as * write errors, not as read */ /* something to send */ if (conn->send_packets && (rc & POLLOUT) != 0) { TDSSOCKET *s; short sid = tds_packet_write(conn); if (sid == tds->sid) break; /* return to caller */ tds_mutex_lock(&conn->list_mtx); if (sid >= 0 && sid < conn->num_sessions) { s = conn->sessions[sid]; if (TDSSOCKET_VALID(s)) tds_cond_signal(&s->packet_cond); } tds_mutex_unlock(&conn->list_mtx); /* avoid using a possible closed connection */ continue; } /* received */ if (rc & POLLIN) { TDSPACKET *packet; TDSSOCKET *s; /* try to read a packet */ tds_packet_read(conn, tds); packet = conn->recv_packet; if (!packet || conn->recv_pos < packet->len) continue; conn->recv_packet = NULL; conn->recv_pos = 0; tdsdump_dump_buf(TDS_DBG_NETWORK, "Received packet", packet->buf, packet->len); tds_mutex_lock(&conn->list_mtx); if (packet->sid >= 0 && packet->sid < conn->num_sessions) { s = conn->sessions[packet->sid]; if (TDSSOCKET_VALID(s)) { /* append to correct session */ if (packet->buf[0] == TDS72_SMP && packet->buf[1] != TDS_SMP_DATA) tds_packet_cache_add(conn, packet); else tds_append_packet(&conn->packets, packet); packet = NULL; /* notify */ tds_cond_signal(&s->packet_cond); } } tds_mutex_unlock(&conn->list_mtx); tds_free_packets(packet); /* if we are receiving return the packet */ if (!send) break; } } tds_mutex_lock(&conn->list_mtx); conn->in_net_tds = NULL; } static int tds_connection_put_packet(TDSSOCKET *tds, TDSPACKET *packet) { TDSCONNECTION *conn = tds->conn; if (TDS_UNLIKELY(!packet)) { tds_close_socket(tds); return TDS_FAIL; } tds->out_pos = 0; tds_mutex_lock(&conn->list_mtx); for (;;) { int wait_res; if (IS_TDSDEAD(tds)) { tdsdump_log(TDS_DBG_NETWORK, "Write attempt when state is TDS_DEAD"); break; } /* limit packet sending looking at sequence/window */ if (tds->send_seq <= tds->send_wnd) { /* append packet */ tds_append_packet(&conn->send_packets, packet); packet = NULL; } /* network ok ? process network */ if (!conn->in_net_tds) { tds_connection_network(conn, tds, packet ? 0 : 1); if (packet) continue; /* FIXME we are not sure we sent the packet !!! */ break; } /* signal thread processing network to handle our packet */ /* TODO check result */ tds_wakeup_send(&conn->wakeup, 0); /* wait local condition */ wait_res = tds_cond_timedwait(&tds->packet_cond, &conn->list_mtx, tds->query_timeout); if (wait_res == ETIMEDOUT && tdserror(tds_get_ctx(tds), tds, TDSETIME, ETIMEDOUT) != TDS_INT_CONTINUE) { tds_mutex_unlock(&conn->list_mtx); tds_close_socket(tds); tds_free_packets(packet); return TDS_FAIL; } } tds_mutex_unlock(&conn->list_mtx); if (TDS_UNLIKELY(packet)) { tds_free_packets(packet); return TDS_FAIL; } if (IS_TDSDEAD(tds)) return TDS_FAIL; return TDS_SUCCESS; } #endif /* ENABLE_ODBC_MARS */ /** * Read in one 'packet' from the server. This is a wrapped outer packet of * the protocol (they bundle result packets into chunks and wrap them at * what appears to be 512 bytes regardless of how that breaks internal packet * up. (tetherow\@nol.org) * @return bytes read or -1 on failure */ int tds_read_packet(TDSSOCKET * tds) { #if ENABLE_ODBC_MARS TDSCONNECTION *conn = tds->conn; tds_mutex_lock(&conn->list_mtx); for (;;) { int wait_res; TDSPACKET **p_packet; if (IS_TDSDEAD(tds)) { tdsdump_log(TDS_DBG_NETWORK, "Read attempt when state is TDS_DEAD\n"); break; } /* if there is a packet for me return it */ for (p_packet = &conn->packets; *p_packet; p_packet = &(*p_packet)->next) if ((*p_packet)->sid == tds->sid) break; if (*p_packet) { size_t hdr_size; /* remove our packet from list */ TDSPACKET *packet = *p_packet; *p_packet = packet->next; tds_packet_cache_add(conn, tds->recv_packet); tds_mutex_unlock(&conn->list_mtx); packet->next = NULL; tds->recv_packet = packet; hdr_size = packet->buf[0] == TDS72_SMP ? sizeof(TDS72_SMP_HEADER) : 0; tds->in_buf = packet->buf + hdr_size; tds->in_len = packet->len - hdr_size; tds->in_pos = 8; tds->in_flag = tds->in_buf[0]; /* send acknowledge if needed */ if (tds->recv_seq + 2 >= tds->recv_wnd) tds_update_recv_wnd(tds, tds->recv_seq + 4); return tds->in_len; } /* network ok ? process network */ if (!conn->in_net_tds) { tds_connection_network(conn, tds, 0); continue; } /* wait local condition */ wait_res = tds_cond_timedwait(&tds->packet_cond, &conn->list_mtx, tds->query_timeout); if (wait_res == ETIMEDOUT && tdserror(tds_get_ctx(tds), tds, TDSETIME, ETIMEDOUT) != TDS_INT_CONTINUE) { tds_mutex_unlock(&conn->list_mtx); tds_close_socket(tds); return -1; } } tds_mutex_unlock(&conn->list_mtx); return -1; #else /* !ENABLE_ODBC_MARS */ unsigned char *pkt = tds->in_buf, *p, *end; if (IS_TDSDEAD(tds)) { tdsdump_log(TDS_DBG_NETWORK, "Read attempt when state is TDS_DEAD"); return -1; } tds->in_len = 0; tds->in_pos = 0; for (p = pkt, end = p+8; p < end;) { int len = tds_connection_read(tds, p, end - p); if (len <= 0) { tds_close_socket(tds); return -1; } p += len; if (p - pkt >= 4) { unsigned pktlen = TDS_GET_A2BE(pkt+2); /* packet must at least contains header */ if (TDS_UNLIKELY(pktlen < 8)) { tds_close_socket(tds); return -1; } if (TDS_UNLIKELY(pktlen > tds->recv_packet->capacity)) { TDSPACKET *packet = tds_realloc_packet(tds->recv_packet, pktlen); if (TDS_UNLIKELY(!packet)) { tds_close_socket(tds); return -1; } tds->recv_packet = packet; pkt = packet->buf; p = pkt + (p-tds->in_buf); tds->in_buf = pkt; } end = pkt + pktlen; } } /* set the received packet type flag */ tds->in_flag = pkt[0]; /* Set the length and pos (not sure what pos is used for now */ tds->in_len = p - pkt; tds->in_pos = 8; tdsdump_dump_buf(TDS_DBG_NETWORK, "Received packet", tds->in_buf, tds->in_len); return tds->in_len; #endif /* !ENABLE_ODBC_MARS */ } #if ENABLE_ODBC_MARS static TDSRET tds_update_recv_wnd(TDSSOCKET *tds, TDS_UINT new_recv_wnd) { TDS72_SMP_HEADER *mars; TDSPACKET *packet; if (!tds->conn->mars || tds->sid < 0) return TDS_SUCCESS; packet = tds_get_packet(tds->conn, sizeof(*mars)); if (!packet) return TDS_FAIL; /* TODO check result */ packet->len = sizeof(*mars); packet->sid = tds->sid; mars = (TDS72_SMP_HEADER *) packet->buf; mars->signature = TDS72_SMP; mars->type = TDS_SMP_ACK; TDS_PUT_A2LE(&mars->sid, tds->sid); mars->size = TDS_HOST4LE(16); TDS_PUT_A4LE(&mars->seq, tds->send_seq); tds->recv_wnd = new_recv_wnd; TDS_PUT_A4LE(&mars->wnd, tds->recv_wnd); tds_mutex_lock(&tds->conn->list_mtx); tds_append_packet(&tds->conn->send_packets, packet); tds_mutex_unlock(&tds->conn->list_mtx); return TDS_SUCCESS; } TDSRET tds_append_fin(TDSSOCKET *tds) { TDS72_SMP_HEADER mars; TDSPACKET *packet; if (!tds->conn->mars || tds->sid < 0) return TDS_SUCCESS; mars.signature = TDS72_SMP; mars.type = TDS_SMP_FIN; TDS_PUT_A2LE(&mars.sid, tds->sid); mars.size = TDS_HOST4LE(16); TDS_PUT_A4LE(&mars.seq, tds->send_seq); tds->recv_wnd = tds->recv_seq + 4; TDS_PUT_A4LE(&mars.wnd, tds->recv_wnd); /* do not use tds_get_packet as it require no lock ! */ packet = tds_alloc_packet(&mars, sizeof(mars)); if (!packet) return TDS_FAIL; /* TODO check result */ packet->sid = tds->sid; /* we already hold lock so do not lock */ tds_append_packet(&tds->conn->send_packets, packet); /* now is no more an active session */ tds->conn->sessions[tds->sid] = BUSY_SOCKET; tds_set_state(tds, TDS_DEAD); tds->sid = -1; return TDS_SUCCESS; } #endif /* ENABLE_ODBC_MARS */ TDSRET tds_write_packet(TDSSOCKET * tds, unsigned char final) { int res; unsigned int left = 0; #if TDS_ADDITIONAL_SPACE != 0 if (tds->out_pos > tds->out_buf_max) { left = tds->out_pos - tds->out_buf_max; tds->out_pos = tds->out_buf_max; } #endif /* we must assure server can accept our packet looking at * send_wnd and waiting for proper send_wnd if send_seq > send_wnd */ tds->out_buf[0] = tds->out_flag; tds->out_buf[1] = final; TDS_PUT_A2BE(tds->out_buf+2, tds->out_pos); TDS_PUT_A2BE(tds->out_buf+4, tds->conn->client_spid); TDS_PUT_A2(tds->out_buf+6, 0); if (IS_TDS7_PLUS(tds->conn) && !tds->login) tds->out_buf[6] = 0x01; #if ENABLE_ODBC_MARS res = tds_connection_put_packet(tds, tds_build_packet(tds, tds->out_buf, tds->out_pos)); #else /* !ENABLE_ODBC_MARS */ tdsdump_dump_buf(TDS_DBG_NETWORK, "Sending packet", tds->out_buf, tds->out_pos); /* GW added in check for write() returning <0 and SIGPIPE checking */ res = tds_connection_write(tds, tds->out_buf, tds->out_pos, final) <= 0 ? TDS_FAIL : TDS_SUCCESS; #endif /* !ENABLE_ODBC_MARS */ if (TDS_UNLIKELY(tds->conn->encrypt_single_packet)) { tds->conn->encrypt_single_packet = 0; tds_ssl_deinit(tds->conn); } #if TDS_ADDITIONAL_SPACE != 0 memcpy(tds->out_buf + 8, tds->out_buf + tds->out_buf_max, left); #endif tds->out_pos = left + 8; return res; } #if !ENABLE_ODBC_MARS int tds_put_cancel(TDSSOCKET * tds) { unsigned char out_buf[8]; int sent; out_buf[0] = TDS_CANCEL; /* out_flag */ out_buf[1] = 1; /* final */ out_buf[2] = 0; out_buf[3] = 8; TDS_PUT_A4(out_buf+4, 0); if (IS_TDS7_PLUS(tds->conn) && !tds->login) out_buf[6] = 0x01; tdsdump_dump_buf(TDS_DBG_NETWORK, "Sending packet", out_buf, 8); sent = tds_connection_write(tds, out_buf, 8, 1); if (sent > 0) tds->in_cancel = 2; /* GW added in check for write() returning <0 and SIGPIPE checking */ return sent <= 0 ? TDS_FAIL : TDS_SUCCESS; } #endif /* !ENABLE_ODBC_MARS */ #if ENABLE_ODBC_MARS static short tds_packet_write(TDSCONNECTION *conn) { int sent; int final; TDSPACKET *packet = conn->send_packets; assert(packet); if (conn->send_pos == 0) tdsdump_dump_buf(TDS_DBG_NETWORK, "Sending packet", packet->buf, packet->len); /* take into account other session packets */ if (packet->next != NULL) final = 0; /* take into account other packets for this session */ else if (packet->buf[0] != TDS72_SMP) final = packet->buf[1] & 1; else if (packet->len >= sizeof(TDS72_SMP_HEADER) + 2) final = packet->buf[sizeof(TDS72_SMP_HEADER) + 1] & 1; else final = 1; sent = tds_connection_write(conn->in_net_tds, packet->buf + conn->send_pos, packet->len - conn->send_pos, final); if (TDS_UNLIKELY(sent < 0)) { /* TODO tdserror called ?? */ tds_connection_close(conn); return -1; } /* update sent data */ conn->send_pos += sent; /* remove packet if sent all data */ if (conn->send_pos >= packet->len) { short sid = packet->sid; tds_mutex_lock(&conn->list_mtx); conn->send_packets = packet->next; packet->next = NULL; tds_packet_cache_add(conn, packet); tds_mutex_unlock(&conn->list_mtx); conn->send_pos = 0; return sid; } return -1; } #endif /* ENABLE_ODBC_MARS */ /** @} */ freetds-1.00.82/src/tds/stream.c100644 025423 025423 00000023551 12717145107 0012061/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2013 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /** * \file * \brief Handle stream of data */ #include #if HAVE_ERRNO_H #include #endif /* HAVE_ERRNO_H */ #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #include #include #include #include /** \cond HIDDEN_SYMBOLS */ #if ENABLE_EXTRA_CHECKS # define TEMP_INIT(s) const size_t temp_size = s; char* temp = tds_new(char, temp_size) # define TEMP_FREE free(temp); # define TEMP_SIZE temp_size #else # define TEMP_INIT(s) char temp[s] # define TEMP_FREE ; # define TEMP_SIZE sizeof(temp) #endif /** \endcond */ /** * Reads and writes from a stream converting characters * \tds * \param char_conv conversion structure * \param direction specify conversion to server or from server * \param istream input stream * \param ostream output stream * \return TDS_SUCCESS of TDS_FAIL */ TDSRET tds_convert_stream(TDSSOCKET * tds, TDSICONV * char_conv, TDS_ICONV_DIRECTION direction, TDSINSTREAM * istream, TDSOUTSTREAM *ostream) { TEMP_INIT(4096); /* * temp (above) is the "preconversion" buffer, the place where the UCS-2 data * are parked before converting them to ASCII. It has to have a size, * and there's no advantage to allocating dynamically. * This also avoids any memory allocation error. */ const char *ib; size_t bufleft = 0; TDSRET res = TDS_FAIL; /* cast away const for message suppression sub-structure */ TDS_ERRNO_MESSAGE_FLAGS *suppress = (TDS_ERRNO_MESSAGE_FLAGS*) &char_conv->suppress; memset(suppress, 0, sizeof(char_conv->suppress)); for (ib = temp; ostream->buf_len; ib = temp + bufleft) { char *ob; int len, conv_errno; size_t ol; assert(ib >= temp); /* read a chunk of data */ len = istream->read(istream, (char*) ib, TEMP_SIZE - bufleft); if (len < 0) break; if (len == 0 && bufleft == 0) { res = TDS_SUCCESS; break; } bufleft += len; /* Convert chunk */ ib = temp; /* always convert from start of buffer */ convert_more: ob = ostream->buffer; ol = ostream->buf_len; /* FIXME not for last */ suppress->einval = 1; /* EINVAL matters only on the last chunk. */ suppress->e2big = 1; ol = tds_iconv(tds, char_conv, direction, (const char **) &ib, &bufleft, &ob, &ol); conv_errno = errno; /* write converted chunk */ len = ostream->write(ostream, ob - ostream->buffer); if (TDS_UNLIKELY(len < 0)) break; if ((size_t) -1 == ol) { tdsdump_log(TDS_DBG_NETWORK, "Error: tds_convert_stream: tds_iconv returned errno %d, conv_errno %d\n", errno, conv_errno); if (conv_errno == E2BIG && ostream->buf_len && bufleft && len) goto convert_more; if (conv_errno != EILSEQ) { tdsdump_log(TDS_DBG_NETWORK, "Error: tds_convert_stream: " "Gave up converting %u bytes due to error %d.\n", (unsigned int) bufleft, errno); tdsdump_dump_buf(TDS_DBG_NETWORK, "Troublesome bytes:", ib, bufleft); } if (TDS_UNLIKELY(ib == temp)) { /* tds_iconv did not convert anything, avoid infinite loop */ tdsdump_log(TDS_DBG_NETWORK, "No conversion possible: some bytes left.\n"); res = TDS_FAIL; if (conv_errno == EINVAL && tds) tdserror(tds_get_ctx(tds), tds, TDSEICONVAVAIL, 0); if (conv_errno == E2BIG && tds) tdserror(tds_get_ctx(tds), tds, TDSEICONVIU, 0); errno = conv_errno; break; } if (bufleft) memmove(temp, ib, bufleft); } } TEMP_FREE; return res; } /** * Reads and writes from a stream to another * \tds * \param istream input stream * \param ostream output stream * \return TDS_SUCCESS or TDS_FAIL */ TDSRET tds_copy_stream(TDSSOCKET * tds, TDSINSTREAM * istream, TDSOUTSTREAM * ostream) { while (ostream->buf_len) { /* read a chunk of data */ int len = istream->read(istream, ostream->buffer, ostream->buf_len); if (len == 0) return TDS_SUCCESS; if (TDS_UNLIKELY(len < 0)) break; /* write chunk */ len = ostream->write(ostream, len); if (TDS_UNLIKELY(len < 0)) break; } return TDS_FAIL; } /** * Reads data from network for input stream */ static int tds_datain_stream_read(TDSINSTREAM *stream, void *ptr, size_t len) { TDSDATAINSTREAM *s = (TDSDATAINSTREAM *) stream; if (len > s->wire_size) len = s->wire_size; tds_get_n(s->tds, ptr, len); s->wire_size -= len; return len; } /** * Initialize a data input stream. * This stream read data from network. * \param stream input stream to initialize * \tds * \param wire_size byte to read */ void tds_datain_stream_init(TDSDATAINSTREAM * stream, TDSSOCKET * tds, size_t wire_size) { stream->stream.read = tds_datain_stream_read; stream->wire_size = wire_size; stream->tds = tds; } /** * Writes data to network for output stream */ static int tds_dataout_stream_write(TDSOUTSTREAM *stream, size_t len) { TDSDATAOUTSTREAM *s = (TDSDATAOUTSTREAM *) stream; TDSSOCKET *tds = s->tds; assert(len <= stream->buf_len); assert(stream->buffer == (char *) tds->out_buf + tds->out_pos); assert(stream->buf_len == tds->out_buf_max - tds->out_pos + TDS_ADDITIONAL_SPACE); tds->out_pos += len; /* this must be strictly test as equal means we send a full packet * and we could be just at the end of packet so server would * wait for another packet with flag != 0 */ if (tds->out_pos > tds->out_buf_max) tds_write_packet(tds, 0x0); stream->buffer = (char *) tds->out_buf + tds->out_pos; stream->buf_len = tds->out_buf_max - tds->out_pos + TDS_ADDITIONAL_SPACE; s->written += len; return len; } /** * Initialize a data output stream. * This stream writes data to network. * \param stream output stream to initialize * \tds */ void tds_dataout_stream_init(TDSDATAOUTSTREAM * stream, TDSSOCKET * tds) { #if TDS_ADDITIONAL_SPACE < 4 #error Not supported #endif /* * we use the extra space as we want possible space for converting * a character and cause we don't want to send an exactly entire * packet with 0 flag and then nothing */ size_t left = tds->out_buf_max - tds->out_pos + TDS_ADDITIONAL_SPACE; assert(left > 0); stream->stream.write = tds_dataout_stream_write; stream->stream.buffer = (char *) tds->out_buf + tds->out_pos; stream->stream.buf_len = left; stream->written = 0; stream->tds = tds; } /** * Reads data from a static allocated buffer */ static int tds_staticin_stream_read(TDSINSTREAM *stream, void *ptr, size_t len) { TDSSTATICINSTREAM *s = (TDSSTATICINSTREAM *) stream; size_t cp = (len <= s->buf_left) ? len : s->buf_left; memcpy(ptr, s->buffer, cp); s->buffer += cp; s->buf_left -= cp; return cp; } /** * Initialize an input stream for read from a static allocated buffer * \param stream stream to initialize * \param ptr buffer to read from * \param len buffer size in bytes */ void tds_staticin_stream_init(TDSSTATICINSTREAM * stream, const void *ptr, size_t len) { stream->stream.read = tds_staticin_stream_read; stream->buffer = (const char *) ptr; stream->buf_left = len; } /** * Writes data to a static allocated buffer */ static int tds_staticout_stream_write(TDSOUTSTREAM *stream, size_t len) { assert(stream->buf_len >= len); stream->buffer += len; stream->buf_len -= len; return len; } /** * Initialize an output stream for write into a static allocated buffer * \param stream stream to initialize * \param ptr buffer to write to * \param len buffer size in bytes */ void tds_staticout_stream_init(TDSSTATICOUTSTREAM * stream, void *ptr, size_t len) { stream->stream.write = tds_staticout_stream_write; stream->stream.buffer = (char *) ptr; stream->stream.buf_len = len; } /** * Writes data to a dynamic allocated buffer */ static int tds_dynamic_stream_write(TDSOUTSTREAM *stream, size_t len) { TDSDYNAMICSTREAM *s = (TDSDYNAMICSTREAM *) stream; size_t wanted; s->size += len; /* grow linearly till some limit then exponentially */ if (s->size + 256 > s->allocated) { wanted = s->size + (s->size < 4096 ? 1024 : s->size / 8u); if (TDS_UNLIKELY(!tds_realloc(s->buf, wanted))) return -1; s->allocated = wanted; } assert(s->allocated > s->size); stream->buffer = (char *) *s->buf + s->size; stream->buf_len = s->allocated - s->size; return len; } /** * Initialize a dynamic output stream. * This stream write data into a dynamic allocated buffer. * \param stream stream to initialize * \param ptr pointer to pointer to buffer to fill. Buffer * will be extended as needed * \param allocated bytes initialially allocated for the buffer. * Useful to reuse buffers * \return TDS_SUCCESS on success, TDS_FAIL otherwise */ TDSRET tds_dynamic_stream_init(TDSDYNAMICSTREAM * stream, void **ptr, size_t allocated) { const size_t initial_size = 1024; stream->stream.write = tds_dynamic_stream_write; stream->buf = ptr; if (allocated < initial_size) { free(*ptr); *ptr = NULL; allocated = initial_size; } if (!*ptr) { *ptr = malloc(allocated); if (TDS_UNLIKELY(!*ptr)) return TDS_FAIL; } stream->allocated = allocated; stream->size = 0; stream->stream.buffer = (char *) *ptr; stream->stream.buf_len = allocated; return TDS_SUCCESS; } freetds-1.00.82/src/tds/random.c100644 025423 025423 00000003424 12717145107 0012043/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-1999 Brian Bruns * Copyright (C) 2005-2015 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #include #ifdef HAVE_GNUTLS #include #include #ifndef HAVE_GNUTLS_RND #include #endif #elif defined(HAVE_OPENSSL) #include #endif void tds_random_buffer(unsigned char *out, int len) { int i; #if defined(HAVE_GNUTLS) && defined(HAVE_GNUTLS_RND) if (gnutls_rnd(GNUTLS_RND_RANDOM, out, len) >= 0) return; if (gnutls_rnd(GNUTLS_RND_NONCE, out, len) >= 0) return; #elif defined(HAVE_GNUTLS) void *p = gcry_random_bytes(len, GCRY_STRONG_RANDOM); if (p) { memcpy(out, p, len); free(p); return; } #elif defined(HAVE_OPENSSL) if (RAND_bytes(out, len) == 1) return; if (RAND_pseudo_bytes(out, len) >= 0) return; #endif /* TODO find a better random... */ for (i = 0; i < len; ++i) out[i] = rand() / (RAND_MAX / 256); } freetds-1.00.82/src/tds/sec_negotiate_gnutls.h100644 025423 025423 00000021130 12717145107 0014767/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2015 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #ifdef HAVE_GNUTLS_ABSTRACT_H # include #endif #if !defined(HAVE_NETTLE) || !defined(HAVE_GMP) || !defined(HAVE_GNUTLS_RND) # include #endif #ifndef HAVE_NETTLE # include #endif #ifdef HAVE_NETTLE # include # include # include #endif /** * \ingroup libtds * \defgroup auth Authentication * Functions for handling authentication. */ /** * \addtogroup auth * @{ */ #ifndef HAVE_GNUTLS #error HAVE_GNUTLS not defines, this file should not be included #endif /* emulate GMP if not present */ #ifndef HAVE_GMP #define HAVE_GMP 1 typedef struct { gcry_mpi_t num; } mpz_t[1]; #define mpz_powm(w,n,e,m) \ gcry_mpi_powm((w)->num, (n)->num, (e)->num, (m)->num); #define mpz_init(n) do { (n)->num = NULL; } while(0) #define mpz_clear(n) gcry_mpi_release((n)->num) #endif /* emulate Nettle is not present */ #ifndef HAVE_NETTLE #define HAVE_NETTLE 1 typedef void nettle_random_func(void *ctx, size_t len, uint8_t *out); static inline void nettle_mpz_set_str_256_u(mpz_t x, unsigned length, const uint8_t *s) { gcry_mpi_scan(&x->num, GCRYMPI_FMT_USG, s, length, NULL); } static inline void nettle_mpz_get_str_256(unsigned length, uint8_t *s, const mpz_t x) { gcry_mpi_print(GCRYMPI_FMT_USG, s, length, NULL, x->num); } struct asn1_der_iterator { const unsigned char *data, *data_end; unsigned long length; unsigned long type; }; enum asn1_iterator_result { ASN1_ITERATOR_ERROR, ASN1_ITERATOR_PRIMITIVE, ASN1_ITERATOR_CONSTRUCTED, ASN1_ITERATOR_END, }; enum { ASN1_SEQUENCE = ASN1_TAG_SEQUENCE, }; static enum asn1_iterator_result asn1_der_iterator_next(struct asn1_der_iterator *der) { unsigned char cls; unsigned long tag; int len; long l; if (asn1_get_tag_der(der->data, der->data_end - der->data, &cls, &len, &tag) != ASN1_SUCCESS) return ASN1_ITERATOR_ERROR; der->type = tag; der->data += len; l = asn1_get_length_der(der->data, der->data_end - der->data, &len); if (l < 0) return ASN1_ITERATOR_ERROR; der->data += len; der->length = l; if (cls == ASN1_CLASS_STRUCTURED) return ASN1_ITERATOR_CONSTRUCTED; return ASN1_ITERATOR_PRIMITIVE; } static enum asn1_iterator_result asn1_der_iterator_first(struct asn1_der_iterator *der, int size, const void *der_buf) { der->data = (const unsigned char *) der_buf; der->data_end = der->data + size; return asn1_der_iterator_next(der); } struct rsa_public_key { unsigned size; mpz_t n, e; }; static void rsa_public_key_init(struct rsa_public_key *key) { key->size = 0; mpz_init(key->n); mpz_init(key->e); } static void rsa_public_key_clear(struct rsa_public_key *key) { mpz_clear(key->n); mpz_clear(key->e); } static int rsa_public_key_from_der_iterator(struct rsa_public_key *key, unsigned key_bits, struct asn1_der_iterator *der) { enum asn1_iterator_result ret; ret = asn1_der_iterator_next(der); if (ret != ASN1_ITERATOR_PRIMITIVE || der->type != ASN1_TAG_INTEGER) return 0; gcry_mpi_scan(&key->n->num, GCRYMPI_FMT_USG, der->data, der->length, NULL); key->size = (gcry_mpi_get_nbits(key->n->num)+7)/8; der->data += der->length; ret = asn1_der_iterator_next(der); if (ret != ASN1_ITERATOR_PRIMITIVE || der->type != ASN1_TAG_INTEGER) return 0; gcry_mpi_scan(&key->e->num, GCRYMPI_FMT_USG, der->data, der->length, NULL); return 1; } static void sha1(uint8_t *hash, const void *data, size_t len) { gcry_md_hash_buffer(GCRY_MD_SHA1, hash, data, len); } #else static void sha1(uint8_t *hash, const void *data, size_t len) { struct sha1_ctx ctx; sha1_init(&ctx); sha1_update(&ctx, len, (const uint8_t *) data); sha1_digest(&ctx, 20, hash); } #endif static void rnd_func(void *ctx, size_t len, uint8_t * out) { tds_random_buffer(out, len); } #define dumpl(b,l) tdsdump_dump_buf(TDS_DBG_INFO1, #b, b, l) #ifndef dumpl #define dumpl(b,l) do {} while(0) #endif #define dump(b) dumpl(b, sizeof(b)) /* OAEP configuration parameters */ #define hash_func sha1 enum { hash_len = 20 }; /* sha1 length */ enum { key_size_max = 1024 }; /* max key in bytes */ static const char label[] = ""; static void memxor(uint8_t *dest, const uint8_t *src, size_t len) { size_t n; for (n = 0; n < len; ++n) dest[n] = dest[n] ^ src[n]; } static void mgf_mask(uint8_t *dest, size_t dest_len, const uint8_t *mask, size_t mask_len) { unsigned n = 0; uint8_t hash[hash_len]; uint8_t seed[mask_len + 4]; memcpy(seed, mask, mask_len); /* we always have some data and check is done internally */ for (;;) { TDS_PUT_UA4BE(seed+mask_len, n); hash_func(hash, seed, sizeof(seed)); if (dest_len <= hash_len) { memxor(dest, hash, dest_len); break; } memxor(dest, hash, hash_len); dest += hash_len; dest_len -= hash_len; ++n; } } static int oaep_encrypt(size_t key_size, void *random_ctx, nettle_random_func *random, size_t length, const uint8_t *message, mpz_t m) { /* EM: 0x00 ROS (HASH 0x00.. 0x01 message) */ struct { uint8_t all[1]; /* zero but used to access all data */ uint8_t ros[hash_len]; uint8_t db[key_size_max - hash_len - 1]; } em; const unsigned db_len = key_size - hash_len - 1; if (length + hash_len * 2 + 2 > key_size) /* Message too long for this key. */ return 0; /* create db */ memset(&em, 0, sizeof(em)); hash_func(em.db, label, strlen(label)); em.all[key_size - length - 1] = 0x1; memcpy(em.all+(key_size - length), message, length); dumpl(em.db, db_len); /* create ros */ random(random_ctx, hash_len, em.ros); dump(em.ros); /* mask db */ mgf_mask(em.db, db_len, em.ros, hash_len); dumpl(em.db, db_len); /* mask ros */ mgf_mask(em.ros, hash_len, em.db, db_len); dump(em.ros); nettle_mpz_set_str_256_u(m, key_size, em.all); return 1; } static int rsa_encrypt_oaep(const struct rsa_public_key *key, void *random_ctx, nettle_random_func *random, size_t length, const uint8_t *message, mpz_t gibberish) { if (!oaep_encrypt(key->size, random_ctx, random, length, message, gibberish)) return 0; mpz_powm(gibberish, gibberish, key->e, key->n); return 1; } static void* tds5_rsa_encrypt(const void *key, size_t key_len, const void *nonce, size_t nonce_len, const char *pwd, size_t *em_size) { int ret; mpz_t p; gnutls_datum_t pubkey_datum = { (unsigned char *) key, key_len }; struct asn1_der_iterator der; struct rsa_public_key pubkey; uint8_t *message; size_t message_len, pwd_len; uint8_t *em = NULL; unsigned char der_buf[2048]; size_t size = sizeof(der_buf); mpz_init(p); rsa_public_key_init(&pubkey); pwd_len = strlen(pwd); message_len = nonce_len + pwd_len; message = tds_new(uint8_t, message_len); if (!message) return NULL; memcpy(message, nonce, nonce_len); memcpy(message + nonce_len, pwd, pwd_len); /* use nettle directly */ /* parse PEM, get DER */ ret = gnutls_pem_base64_decode("RSA PUBLIC KEY", &pubkey_datum, der_buf, &size); if (ret) { tdsdump_log(TDS_DBG_ERROR, "Error %d decoding public key: %s\n", ret, gnutls_strerror(ret)); goto error; } /* get key with nettle using DER */ ret = asn1_der_iterator_first(&der, size, der_buf); if (ret != ASN1_ITERATOR_CONSTRUCTED || der.type != ASN1_SEQUENCE) { tdsdump_log(TDS_DBG_ERROR, "Invalid DER content\n"); goto error; } ret = rsa_public_key_from_der_iterator(&pubkey, key_size_max * 8, &der); if (!ret) { tdsdump_log(TDS_DBG_ERROR, "Invalid DER content\n"); goto error; } /* get password encrypted */ ret = rsa_encrypt_oaep(&pubkey, NULL, rnd_func, message_len, message, p); if (!ret) { tdsdump_log(TDS_DBG_ERROR, "Error encrypting message\n"); goto error; } em = tds_new(uint8_t, pubkey.size); *em_size = pubkey.size; if (!em) goto error; nettle_mpz_get_str_256(pubkey.size, em, p); tdsdump_dump_buf(TDS_DBG_INFO1, "em", em, pubkey.size); error: free(message); rsa_public_key_clear(&pubkey); mpz_clear(p); return em; } /** @} */ freetds-1.00.82/src/tds/sec_negotiate_openssl.h100644 025423 025423 00000004572 13051014221 0015131/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2015 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #include /** * \ingroup libtds * \defgroup auth Authentication * Functions for handling authentication. */ /** * \addtogroup auth * @{ */ #ifndef HAVE_OPENSSL #error HAVE_OPENSSL not defines, this file should not be included #endif static inline const BIGNUM* rsa_get_n(const RSA *rsa) { #if OPENSSL_VERSION_NUMBER >= 0x1010000FL const BIGNUM *n, *e, *d; RSA_get0_key(rsa, &n, &e, &d); return n; #else return rsa->n; #endif } static void* tds5_rsa_encrypt(const void *key, size_t key_len, const void *nonce, size_t nonce_len, const char *pwd, size_t *em_size) { RSA *rsa = NULL; BIO *keybio; TDS_UCHAR *message = NULL; size_t message_len, pwd_len; TDS_UCHAR *em = NULL; int result; keybio = BIO_new_mem_buf((void*) key, key_len); if (keybio == NULL) goto error; rsa = PEM_read_bio_RSAPublicKey(keybio, &rsa, NULL, NULL); if (!rsa) goto error; pwd_len = strlen(pwd); message_len = nonce_len + pwd_len; message = tds_new(TDS_UCHAR, message_len); if (!message) goto error; memcpy(message, nonce, nonce_len); memcpy(message + nonce_len, pwd, pwd_len); em = tds_new(TDS_UCHAR, BN_num_bytes(rsa_get_n(rsa))); if (!em) goto error; result = RSA_public_encrypt(message_len, message, em, rsa, RSA_PKCS1_OAEP_PADDING); if (result < 0) goto error; free(message); RSA_free(rsa); BIO_free(keybio); *em_size = result; return em; error: free(message); free(em); RSA_free(rsa); BIO_free(keybio); return NULL; } /** @} */ freetds-1.00.82/src/tds/sec_negotiate.c100644 025423 025423 00000012013 12717145107 0013366/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2015 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STDDEF_H #include #endif /* HAVE_STDDEF_H */ #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include #include #include "replacements.h" #ifdef HAVE_GNUTLS # include "sec_negotiate_gnutls.h" #elif defined(HAVE_OPENSSL) # include "sec_negotiate_openssl.h" #endif /** * \ingroup libtds * \defgroup auth Authentication * Functions for handling authentication. */ /** * \addtogroup auth * @{ */ #if defined(HAVE_GNUTLS) || defined(HAVE_OPENSSL) typedef struct tds5_negotiate { TDSAUTHENTICATION tds_auth; /** message type from server */ unsigned msg_type; } TDS5NEGOTIATE; static TDSRET tds5_negotiate_free(TDSCONNECTION * conn, TDSAUTHENTICATION * tds_auth) { TDS5NEGOTIATE *auth = (TDS5NEGOTIATE *) tds_auth; free(auth->tds_auth.packet); free(auth); return TDS_SUCCESS; } void tds5_negotiate_set_msg_type(TDSSOCKET * tds, TDSAUTHENTICATION * tds_auth, unsigned msg_type) { TDS5NEGOTIATE *auth = (TDS5NEGOTIATE *) tds_auth; if (tds_auth && tds_auth->free == tds5_negotiate_free) auth->msg_type = msg_type; } static void tds5_send_msg(TDSSOCKET *tds, TDS_USMALLINT msg_type) { tds_put_tinyint(tds, TDS_MSG_TOKEN); tds_put_tinyint(tds, 3); tds_put_tinyint(tds, 1); tds_put_smallint(tds, msg_type); } static TDSRET tds5_negotiate_handle_next(TDSSOCKET * tds, TDSAUTHENTICATION * tds_auth, size_t len) { TDS5NEGOTIATE *auth = (TDS5NEGOTIATE *) tds_auth; TDSPARAMINFO *info; void *rsa, *nonce = NULL; size_t rsa_len, nonce_len = 0; void *em; size_t em_size; TDSRET rc = TDS_FAIL; /* send next data for authentication */ if (!tds->login) goto error; /* we only support RSA authentication, we should have send 2/3 parameters: * 1- integer.. unknown actually 1 TODO * 2- binary, rsa public key in PEM format * 3- binary, nonce (optional) */ /* message not supported */ if (auth->msg_type != 0x1e) goto error; info = tds->param_info; if (!info || info->num_cols < 2) goto error; if (info->columns[1]->column_type != SYBLONGBINARY) goto error; if (info->num_cols >= 3 && info->columns[2]->column_type != SYBLONGBINARY) goto error; rsa = ((TDSBLOB*) info->columns[1]->column_data)->textvalue; rsa_len = info->columns[1]->column_size; if (info->num_cols >= 3) { nonce = ((TDSBLOB*) info->columns[2]->column_data)->textvalue; nonce_len = info->columns[2]->column_size; } em = tds5_rsa_encrypt(rsa, rsa_len, nonce, nonce_len, tds_dstr_cstr(&tds->login->password), &em_size); if (!em) goto error; tds->out_flag = TDS_NORMAL; /* password */ tds5_send_msg(tds, 0x1f); tds_put_n(tds, "\xec\x0e\x00\x01\x00\x00\x00\x00\x00\x00\x00\xe1\xff\xff\xff\x7f\x00", 0x11); tds_put_byte(tds, TDS5_PARAMS_TOKEN); tds_put_int(tds, em_size); tds_put_n(tds, em, em_size); /* remote password */ tds5_send_msg(tds, 0x20); tds_put_n(tds, "\xec\x17\x00\x02\x00\x00\x00\x00\x00\x00\x00\x27\xff\x00\x00\x00\x00\x00\x00\x00\xe1\xff\xff\xff\x7f\x00", 0x1a); tds_put_byte(tds, TDS5_PARAMS_TOKEN); tds_put_byte(tds, 0); tds_put_int(tds, em_size); tds_put_n(tds, em, em_size); free(em); rc = tds_flush_packet(tds); error: tds5_negotiate_free(tds->conn, tds_auth); tds->conn->authentication = NULL; return rc; } /** * Initialize Sybase negotiate handling * @param tds A pointer to the TDSSOCKET structure managing a client/server operation. * @return authentication info */ TDSAUTHENTICATION * tds5_negotiate_get_auth(TDSSOCKET * tds) { TDS5NEGOTIATE *auth; if (!tds->login) return NULL; auth = tds_new0(TDS5NEGOTIATE, 1); if (!auth) return NULL; auth->tds_auth.free = tds5_negotiate_free; auth->tds_auth.handle_next = tds5_negotiate_handle_next; return (TDSAUTHENTICATION *) auth; } #else /* not HAVE_GNUTLS or HAVE_OPENSSL */ void tds5_negotiate_set_msg_type(TDSSOCKET * tds, TDSAUTHENTICATION * tds_auth, unsigned msg_type) { } TDSAUTHENTICATION * tds5_negotiate_get_auth(TDSSOCKET * tds) { tdsdump_log(TDS_DBG_ERROR, "Sybase authentication not supported if GnuTLS or OpenSSL are not present\n"); return NULL; } #endif /** @} */ freetds-1.00.82/src/tds/challenge.c100644 025423 025423 00000050173 12717145107 0012510/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-1999 Brian Bruns * Copyright (C) 2005-2015 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STDDEF_H #include #endif /* HAVE_STDDEF_H */ #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include #include #include #include "md4.h" #include "md5.h" #include "hmac_md5.h" #include "des.h" #include "replacements.h" /** * \ingroup libtds * \defgroup auth Authentication * Functions for handling authentication. */ /** * \addtogroup auth * @{ */ /* * The following code is based on some psuedo-C code from ronald@innovation.ch */ typedef struct tds_answer { unsigned char lm_resp[24]; unsigned char nt_resp[24]; } TDSANSWER; typedef struct { TDS_TINYINT response_type; TDS_TINYINT max_response_type; TDS_SMALLINT reserved1; TDS_UINT reserved2; TDS_UINT8 timestamp; TDS_UCHAR challenge[8]; TDS_UINT unknown; /* target info block - variable length */ TDS_UCHAR target_info[4]; } names_blob_prefix_t; static TDSRET tds_answer_challenge(TDSSOCKET * tds, TDSLOGIN * login, const unsigned char *challenge, TDS_UINT * flags, const unsigned char *names_blob, TDS_INT names_blob_len, TDSANSWER * answer, unsigned char **ntlm_v2_response); static void tds_encrypt_answer(const unsigned char *hash, const unsigned char *challenge, unsigned char *answer); static void tds_convert_key(const unsigned char *key_56, DES_KEY * ks); static void convert_to_upper(char *buf, size_t len) { size_t i; for (i = 0; i < len; i++) buf[i] = toupper((unsigned char) buf[i]); } static size_t convert_to_usc2le_string(TDSSOCKET * tds, const char *s, size_t len, char *out) { const char *ib; char *ob; size_t il, ol; TDSICONV * char_conv = tds->conn->char_convs[client2ucs2]; /* char_conv is only mostly const */ TDS_ERRNO_MESSAGE_FLAGS *suppress = (TDS_ERRNO_MESSAGE_FLAGS *) & char_conv->suppress; if (char_conv->flags == TDS_ENCODING_MEMCPY) { memcpy(out, s, len); return len; } /* convert */ ib = s; il = len; ob = out; ol = len * 2; memset(suppress, 0, sizeof(char_conv->suppress)); if (tds_iconv(tds, char_conv, to_server, &ib, &il, &ob, &ol) == (size_t) - 1) return (size_t) -1; return ob - out; } static TDSRET make_ntlm_hash(TDSSOCKET * tds, const char *passwd, unsigned char ntlm_hash[16]) { MD4_CTX context; size_t passwd_len = 0; char passwd_usc2le[256]; size_t passwd_usc2le_len = 0; passwd_len = strlen(passwd); if (passwd_len > 128) passwd_len = 128; passwd_usc2le_len = convert_to_usc2le_string(tds, passwd, passwd_len, passwd_usc2le); if (passwd_usc2le_len == (size_t) -1) { memset((char *) passwd_usc2le, 0, sizeof(passwd_usc2le)); return TDS_FAIL; } /* compute NTLM hash */ MD4Init(&context); MD4Update(&context, (unsigned char *) passwd_usc2le, passwd_usc2le_len); MD4Final(&context, ntlm_hash); /* with security is best be pedantic */ memset((char *) passwd_usc2le, 0, passwd_usc2le_len); memset(&context, 0, sizeof(context)); return TDS_SUCCESS; } static TDSRET make_ntlm_v2_hash(TDSSOCKET * tds, const char *passwd, unsigned char ntlm_v2_hash[16]) { const char *user_name, *domain; size_t domain_len, user_name_len, len, buf_usc2le_len = 0; const char *p; unsigned char ntlm_hash[16]; char buf[128]; char buf_usc2le[512]; TDSRET res; user_name = tds_dstr_cstr(&tds->login->user_name); /* parse domain\username */ p = strchr(user_name, '\\'); domain = user_name; domain_len = p - user_name; user_name = p + 1; user_name_len = strlen(user_name); if (user_name_len > 128) user_name_len = 128; memcpy(buf, user_name, user_name_len); convert_to_upper(buf, user_name_len); len = convert_to_usc2le_string(tds, buf, user_name_len, buf_usc2le); if (len == (size_t) -1) return TDS_FAIL; buf_usc2le_len = len; if (domain_len > 128) domain_len = 128; /* Target is supposed to be case-sensitive */ len = convert_to_usc2le_string(tds, domain, domain_len, buf_usc2le + len); if (len == (size_t) -1) return TDS_FAIL; buf_usc2le_len += len; res = make_ntlm_hash(tds, passwd, ntlm_hash); hmac_md5(ntlm_hash, (const unsigned char *) buf_usc2le, buf_usc2le_len, ntlm_v2_hash); /* with security is best be pedantic */ memset(&ntlm_hash, 0, sizeof(ntlm_hash)); memset(buf, 0, sizeof(buf)); memset((char *) buf_usc2le, 0, buf_usc2le_len); return res; } /* * hash - The NTLMv2 Hash. * client_data - The client data (blob or client nonce). * challenge - The server challenge from the Type 2 message. */ static unsigned char * make_lm_v2_response(const unsigned char ntlm_v2_hash[16], const unsigned char *client_data, TDS_INT client_data_len, const unsigned char challenge[8]) { int mac_len = 16 + client_data_len; unsigned char *mac; mac = tds_new(unsigned char, mac_len); if (!mac) return NULL; memcpy(mac + 8, challenge, 8); memcpy(mac + 16, client_data, client_data_len); hmac_md5(ntlm_v2_hash, mac + 8, client_data_len + 8, mac); return mac; } static TDSRET tds_answer_challenge_ntlmv2(TDSSOCKET * tds, TDSLOGIN * login, const unsigned char *challenge, TDS_UINT * flags, const unsigned char *names_blob, TDS_INT names_blob_len, TDSANSWER * answer, unsigned char **ntlm_v2_response) { TDSRET res; const char *passwd = tds_dstr_cstr(&login->password); /* NTLMv2 */ unsigned char *lm_v2_response; unsigned char ntlm_v2_hash[16]; const names_blob_prefix_t *names_blob_prefix; if (!names_blob) return TDS_FAIL; res = make_ntlm_v2_hash(tds, passwd, ntlm_v2_hash); if (TDS_FAILED(res)) return res; /* LMv2 response */ /* Take client's challenge from names_blob */ names_blob_prefix = (const names_blob_prefix_t *) names_blob; lm_v2_response = make_lm_v2_response(ntlm_v2_hash, names_blob_prefix->challenge, 8, challenge); if (!lm_v2_response) return TDS_FAIL; memcpy(answer->lm_resp, lm_v2_response, 24); free(lm_v2_response); /* NTLMv2 response */ /* Size of lm_v2_response is 16 + names_blob_len */ *ntlm_v2_response = make_lm_v2_response(ntlm_v2_hash, names_blob, names_blob_len, challenge); if (!*ntlm_v2_response) return TDS_FAIL; memset(ntlm_v2_hash, 0, sizeof(ntlm_v2_hash)); /* local not supported */ *flags &= ~0x4000; return TDS_SUCCESS; } /** * Crypt a given password using schema required for NTLMv1 or NTLM2 authentication * @param passwd clear text domain password * @param challenge challenge data given by server * @param flags NTLM flags from server side * @param answer buffer where to store crypted password */ static TDSRET tds_answer_challenge(TDSSOCKET * tds, TDSLOGIN * login, const unsigned char *challenge, TDS_UINT * flags, const unsigned char *names_blob, TDS_INT names_blob_len, TDSANSWER * answer, unsigned char **ntlm_v2_response) { #define MAX_PW_SZ 14 const char *passwd = tds_dstr_cstr(&login->password); DES_KEY ks; unsigned char hash[24], ntlm2_challenge[16]; TDSRET res; memset(answer, 0, sizeof(TDSANSWER)); if (login->use_ntlmv2) { return tds_answer_challenge_ntlmv2(tds, login, challenge, flags, names_blob, names_blob_len, answer, ntlm_v2_response); } else if ((*flags & 0x80000) != 0) { /* NTLM2 */ MD5_CTX md5_ctx; tds_random_buffer(hash, 8); memset(hash + 8, 0, 16); memcpy(answer->lm_resp, hash, 24); MD5Init(&md5_ctx); MD5Update(&md5_ctx, challenge, 8); MD5Update(&md5_ctx, hash, 8); MD5Final(&md5_ctx, ntlm2_challenge); challenge = ntlm2_challenge; memset(&md5_ctx, 0, sizeof(md5_ctx)); } else if (login->use_lanman) { /* LM */ size_t len, i; unsigned char passwd_buf[MAX_PW_SZ]; static const des_cblock magic = { 0x4B, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25 }; /* convert password to upper and pad to 14 chars */ memset(passwd_buf, 0, MAX_PW_SZ); len = strlen(passwd); if (len > MAX_PW_SZ) len = MAX_PW_SZ; for (i = 0; i < len; i++) passwd_buf[i] = toupper((unsigned char) passwd[i]); /* hash the first 7 characters */ tds_convert_key(passwd_buf, &ks); tds_des_ecb_encrypt(&magic, sizeof(magic), &ks, (hash + 0)); /* hash the second 7 characters */ tds_convert_key(passwd_buf + 7, &ks); tds_des_ecb_encrypt(&magic, sizeof(magic), &ks, (hash + 8)); memset(hash + 16, 0, 5); tds_encrypt_answer(hash, challenge, answer->lm_resp); memset(passwd_buf, 0, sizeof(passwd_buf)); } else { memset(answer->lm_resp, 0, sizeof(answer->lm_resp)); } *flags = 0x8201; /* NTLM/NTLM2 response */ res = make_ntlm_hash(tds, passwd, hash); memset(hash + 16, 0, 5); tds_encrypt_answer(hash, challenge, answer->nt_resp); /* with security is best be pedantic */ memset(&ks, 0, sizeof(ks)); memset(hash, 0, sizeof(hash)); memset(ntlm2_challenge, 0, sizeof(ntlm2_challenge)); return res; } /* * takes a 21 byte array and treats it as 3 56-bit DES keys. The * 8 byte plaintext is encrypted with each key and the resulting 24 * bytes are stored in the results array. */ static void tds_encrypt_answer(const unsigned char *hash, const unsigned char *challenge, unsigned char *answer) { DES_KEY ks; tds_convert_key(hash, &ks); tds_des_ecb_encrypt(challenge, 8, &ks, answer); tds_convert_key(&hash[7], &ks); tds_des_ecb_encrypt(challenge, 8, &ks, &answer[8]); tds_convert_key(&hash[14], &ks); tds_des_ecb_encrypt(challenge, 8, &ks, &answer[16]); memset(&ks, 0, sizeof(ks)); } /* * turns a 56 bit key into the 64 bit, odd parity key and sets the key. * The key schedule ks is also set. */ static void tds_convert_key(const unsigned char *key_56, DES_KEY * ks) { des_cblock key; key[0] = key_56[0]; key[1] = ((key_56[0] << 7) & 0xFF) | (key_56[1] >> 1); key[2] = ((key_56[1] << 6) & 0xFF) | (key_56[2] >> 2); key[3] = ((key_56[2] << 5) & 0xFF) | (key_56[3] >> 3); key[4] = ((key_56[3] << 4) & 0xFF) | (key_56[4] >> 4); key[5] = ((key_56[4] << 3) & 0xFF) | (key_56[5] >> 5); key[6] = ((key_56[5] << 2) & 0xFF) | (key_56[6] >> 6); key[7] = (key_56[6] << 1) & 0xFF; tds_des_set_odd_parity(key); tds_des_set_key(ks, key, sizeof(key)); memset(&key, 0, sizeof(key)); } static TDSRET tds7_send_auth(TDSSOCKET * tds, const unsigned char *challenge, TDS_UINT flags, const unsigned char *names_blob, TDS_INT names_blob_len) { size_t current_pos; TDSANSWER answer; /* FIXME: stuff duplicate in tds7_send_login */ const char *domain; const char *user_name; const char *p; size_t user_name_len, host_name_len, domain_len; TDSRET rc; unsigned char *ntlm_v2_response = NULL; unsigned int ntlm_response_len = 24; const unsigned int lm_response_len = 24; TDSLOGIN *login = tds->login; /* check connection */ if (!login) return TDS_FAIL; /* parse a bit of config */ user_name = tds_dstr_cstr(&login->user_name); host_name_len = tds_dstr_len(&login->client_host_name); /* parse domain\username */ if ((p = strchr(user_name, '\\')) == NULL) return TDS_FAIL; domain = user_name; domain_len = p - user_name; user_name = p + 1; user_name_len = strlen(user_name); rc = tds_answer_challenge(tds, login, challenge, &flags, names_blob, names_blob_len, &answer, &ntlm_v2_response); if (TDS_FAILED(rc)) return rc; ntlm_response_len = ntlm_v2_response ? 16 + names_blob_len : 24; /* ntlm_response_len = 0; */ tds->out_flag = TDS7_AUTH; tds_put_n(tds, "NTLMSSP", 8); tds_put_int(tds, 3); /* sequence 3 */ /* FIXME *2 work only for single byte encodings */ current_pos = 64u + (domain_len + user_name_len + host_name_len) * 2u; /* LM/LMv2 Response */ tds_put_smallint(tds, lm_response_len); /* lan man resp length */ tds_put_smallint(tds, lm_response_len); /* lan man resp length */ TDS_PUT_INT(tds, current_pos); /* resp offset */ current_pos += lm_response_len; /* NTLM/NTLMv2 Response */ tds_put_smallint(tds, ntlm_response_len); /* nt resp length */ tds_put_smallint(tds, ntlm_response_len); /* nt resp length */ TDS_PUT_INT(tds, current_pos); /* nt resp offset */ current_pos = 64; /* Target Name - domain or server name */ TDS_PUT_SMALLINT(tds, domain_len * 2); TDS_PUT_SMALLINT(tds, domain_len * 2); TDS_PUT_INT(tds, current_pos); current_pos += domain_len * 2u; /* username */ TDS_PUT_SMALLINT(tds, user_name_len * 2); TDS_PUT_SMALLINT(tds, user_name_len * 2); TDS_PUT_INT(tds, current_pos); current_pos += user_name_len * 2u; /* Workstation Name */ TDS_PUT_SMALLINT(tds, host_name_len * 2); TDS_PUT_SMALLINT(tds, host_name_len * 2); TDS_PUT_INT(tds, current_pos); current_pos += host_name_len * 2u; /* Session Key (optional) */ tds_put_smallint(tds, 0); tds_put_smallint(tds, 0); TDS_PUT_INT(tds, current_pos + lm_response_len + ntlm_response_len); /* flags */ /* "challenge" is 8 bytes long */ /* tds_answer_challenge(tds_dstr_cstr(&login->password), challenge, &flags, &answer); */ tds_put_int(tds, flags); /* OS Version Structure (Optional) */ /* Data itself */ tds_put_string(tds, domain, (int)domain_len); tds_put_string(tds, user_name, (int)user_name_len); tds_put_string(tds, tds_dstr_cstr(&login->client_host_name), (int)host_name_len); /* data block */ tds_put_n(tds, answer.lm_resp, lm_response_len); if (ntlm_v2_response == NULL) { /* NTLMv1 */ tds_put_n(tds, answer.nt_resp, ntlm_response_len); } else { /* NTLMv2 */ tds_put_n(tds, ntlm_v2_response, ntlm_response_len); memset(ntlm_v2_response, 0, ntlm_response_len); free(ntlm_v2_response); } /* for security reason clear structure */ memset(&answer, 0, sizeof(TDSANSWER)); return tds_flush_packet(tds); } typedef struct tds_ntlm_auth { TDSAUTHENTICATION tds_auth; } TDSNTLMAUTH; static TDSRET tds_ntlm_free(TDSCONNECTION * conn, TDSAUTHENTICATION * tds_auth) { TDSNTLMAUTH *auth = (TDSNTLMAUTH *) tds_auth; free(auth->tds_auth.packet); free(auth); return TDS_SUCCESS; } static const unsigned char ntlm_id[] = "NTLMSSP"; /** * put a 8 byte filetime from a time_t * This takes GMT as input */ static void unix_to_nt_time(TDS_UINT8 * nt, struct timeval *tv) { /* C time start on 1970, nt time on 1600 */ #define TIME_FIXUP_CONSTANT (((TDS_UINT8) 134774U) * 86400U) TDS_UINT8 t2; t2 = tv->tv_sec; t2 += TIME_FIXUP_CONSTANT; t2 *= 1000u * 1000u * 10u; t2 += tv->tv_usec * 10u; *nt = t2; } static void fill_names_blob_prefix(names_blob_prefix_t * prefix) { struct timeval tv; TDS_UINT8 nttime = 0; gettimeofday(&tv, NULL); unix_to_nt_time(&nttime, &tv); prefix->response_type = 0x01; prefix->max_response_type = 0x01; prefix->reserved1 = 0x0000; prefix->reserved2 = 0x00000000; #ifdef WORDS_BIGENDIAN tds_swap_bytes(&nttime, 8); #endif prefix->timestamp = nttime; tds_random_buffer(prefix->challenge, sizeof(prefix->challenge)); prefix->unknown = 0x00000000; } static TDSRET tds_ntlm_handle_next(TDSSOCKET * tds, struct tds_authentication * auth, size_t len) { const int length = (int)len; unsigned char nonce[8]; TDS_UINT flags; int where; int data_block_offset; int names_blob_len = 0; unsigned char *names_blob = NULL; TDSRET rc; /* at least 32 bytes (till context) */ if (len < 32) return TDS_FAIL; tds_get_n(tds, nonce, 8); /* NTLMSSP\0 */ if (memcmp(nonce, ntlm_id, 8) != 0) return TDS_FAIL; if (tds_get_int(tds) != 2) /* sequence -> 2 */ return TDS_FAIL; tds_get_smallint(tds); /* domain len */ tds_get_smallint(tds); /* domain len */ data_block_offset = tds_get_int(tds); /* domain offset */ flags = tds_get_int(tds); /* flags */ tds_get_n(tds, nonce, 8); tdsdump_dump_buf(TDS_DBG_INFO1, "TDS_AUTH_TOKEN nonce", nonce, 8); where = 32; /*data_block_offset == 32 */ /* Version 1 -- The Context, Target Information, and OS Version structure are all omitted */ if (data_block_offset >= 48 && where + 16 <= length) { int target_info_len, target_info_offset; /* Version 2 -- The Context and Target Information fields are present, but the OS Version structure is not. */ tds_get_n(tds, NULL, 8); /* Context (two consecutive longs) */ target_info_len = tds_get_smallint(tds); /* Target Information len */ target_info_len = tds_get_smallint(tds); /* Target Information len */ target_info_offset = tds_get_int(tds); /* Target Information offset */ where += 16; if (data_block_offset >= 56 && where + 8 <= length) { /* Version 3 -- The Context, Target Information, and OS Version structure are all present. */ tds_get_n(tds, NULL, 8); /* OS Version Structure */ #if 0 /* if we have a version server handle NTLMv2 */ if (target_info_len > 0) flags &= ~0x80000; #endif where += 8; } /* read Target Info if possible */ if (target_info_len > 0 && target_info_offset >= where && target_info_offset + target_info_len <= length) { tds_get_n(tds, NULL, target_info_offset - where); where = target_info_offset; /* * the + 4 came from blob structure, after Target Info 4 * additional reserved bytes must be present * Search "davenport port" * (currently http://davenport.sourceforge.net/ntlm.html) */ names_blob_len = TDS_OFFSET(names_blob_prefix_t, target_info) + target_info_len + 4; /* read Target Info */ names_blob = tds_new0(unsigned char, names_blob_len); if (!names_blob) return TDS_FAIL; fill_names_blob_prefix((names_blob_prefix_t *) names_blob); tds_get_n(tds, names_blob + TDS_OFFSET(names_blob_prefix_t, target_info), target_info_len); where += target_info_len; } } /* discard anything left */ tds_get_n(tds, NULL, length - where); tdsdump_log(TDS_DBG_INFO1, "Draining %d bytes\n", (int) (len - where)); rc = tds7_send_auth(tds, nonce, flags, names_blob, names_blob_len); free(names_blob); return rc; } /** * Build a NTLMSPP packet to send to server * @param tds A pointer to the TDSSOCKET structure managing a client/server operation. * @return authentication info */ TDSAUTHENTICATION * tds_ntlm_get_auth(TDSSOCKET * tds) { const char *domain; const char *user_name; const char *p; TDS_UCHAR *packet; int host_name_len; int domain_len; int auth_len; struct tds_ntlm_auth *auth; if (!tds->login) return NULL; user_name = tds_dstr_cstr(&tds->login->user_name); host_name_len = (int)tds_dstr_len(&tds->login->client_host_name); /* check override of domain */ if ((p = strchr(user_name, '\\')) == NULL) return NULL; domain = user_name; domain_len = (int)(p - user_name); auth = tds_new0(struct tds_ntlm_auth, 1); if (!auth) return NULL; auth->tds_auth.free = tds_ntlm_free; auth->tds_auth.handle_next = tds_ntlm_handle_next; auth->tds_auth.packet_len = auth_len = 40 + host_name_len + domain_len; auth->tds_auth.packet = packet = tds_new(TDS_UCHAR, auth_len); if (!packet) { free(auth); return NULL; } /* built NTLMSSP authentication packet */ memcpy(packet, ntlm_id, 8); /* sequence 1 client -> server */ TDS_PUT_A4(packet + 8, TDS_HOST4LE(1)); /* flags */ TDS_PUT_A4(packet + 12, TDS_HOST4LE(0x08b201)); /* domain info */ TDS_PUT_A2LE(packet + 16, domain_len); TDS_PUT_A2LE(packet + 18, domain_len); TDS_PUT_A4LE(packet + 20, 40 + host_name_len); /* hostname info */ TDS_PUT_A2LE(packet + 24, host_name_len); TDS_PUT_A2LE(packet + 26, host_name_len); TDS_PUT_A4 (packet + 28, TDS_HOST4LE(40)); /* * here XP put version like 05 01 28 0a (5.1.2600), * similar to GetVersion result * and some unknown bytes like 00 00 00 0f */ TDS_PUT_A4(packet + 32, TDS_HOST4LE(0x0a280105)); TDS_PUT_A4(packet + 36, TDS_HOST4LE(0x0f000000)); /* hostname and domain */ memcpy(packet + 40, tds_dstr_cstr(&tds->login->client_host_name), host_name_len); memcpy(packet + 40 + host_name_len, domain, domain_len); return (TDSAUTHENTICATION *) auth; } /** @} */ freetds-1.00.82/src/tds/md4.c100644 025423 025423 00000014753 12717145107 0011256/* * Copyright (C) 2001 Nikos Mavroyanopoulos * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Library General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /* * The algorithm is due to Ron Rivest. This code is based on code * written by Colin Plumb in 1993. */ /* * This code implements the MD4 message-digest algorithm. */ /* * File from mhash library (mhash.sourceforge.net) */ #include #ifndef HAVE_NETTLE #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include "md4.h" #undef word32 #define word32 TDS_UINT #ifndef WORDS_BIGENDIAN #define byteReverse(buf, len) /* Nothing */ #else /* * Note: this code is harmless on little-endian machines. */ static void byteReverse(unsigned char *buf, unsigned longs) { do { *(word32 *) buf = TDS_GET_A4LE(buf); buf += 4; } while (--longs); } #endif #define rotl32(x,n) (((x) << ((word32)(n))) | ((x) >> (32 - (word32)(n)))) static void MD4Transform(TDS_UINT buf[4], TDS_UINT const in[16]); /* * Start MD4 accumulation. Set bit count to 0 and buffer to mysterious * initialization constants. */ void MD4Init(struct MD4Context *ctx) { ctx->buf[0] = 0x67452301; ctx->buf[1] = 0xefcdab89; ctx->buf[2] = 0x98badcfe; ctx->buf[3] = 0x10325476; ctx->bytes = 0; } /* * Update context to reflect the concatenation of another buffer full * of bytes. */ void MD4Update(struct MD4Context *ctx, unsigned char const *buf, size_t len) { register word32 t; t = ctx->bytes & 0x3f; /* Update bytecount */ ctx->bytes += len; /* Handle any leading odd-sized chunks */ if (t) { unsigned char *p = (unsigned char *) ctx->in + t; t = 64 - t; if (len < t) { memcpy(p, buf, len); return; } memcpy(p, buf, t); byteReverse(ctx->in, 16); MD4Transform(ctx->buf, (word32 *) ctx->in); buf += t; len -= t; } /* Process data in 64-byte chunks */ while (len >= 64) { memcpy(ctx->in, buf, 64); byteReverse(ctx->in, 16); MD4Transform(ctx->buf, (word32 *) ctx->in); buf += 64; len -= 64; } /* Handle any remaining bytes of data. */ memcpy(ctx->in, buf, len); } /* * Final wrapup - pad to 64-byte boundary with the bit pattern * 1 0* (64-bit count of bits processed, MSB-first) */ void MD4Final(struct MD4Context *ctx, unsigned char *digest) { unsigned int count; unsigned char *p; /* Compute number of bytes mod 64 */ count = ctx->bytes & 0x3F; /* Set the first char of padding to 0x80. This is safe since there is * always at least one byte free */ p = ctx->in + count; *p++ = 0x80; /* Bytes of padding needed to make 64 bytes */ count = 64 - 1 - count; /* Pad out to 56 mod 64 */ if (count < 8) { /* Two lots of padding: Pad the first block to 64 bytes */ memset(p, 0, count); byteReverse(ctx->in, 16); MD4Transform(ctx->buf, (word32 *) ctx->in); /* Now fill the next block with 56 bytes */ memset(ctx->in, 0, 56); } else { /* Pad block to 56 bytes */ memset(p, 0, count - 8); } byteReverse(ctx->in, 14); /* Append length in bits and transform */ ((word32 *) ctx->in)[14] = (word32) (ctx->bytes << 3); ((word32 *) ctx->in)[15] = (word32) (ctx->bytes >> 29); MD4Transform(ctx->buf, (word32 *) ctx->in); byteReverse((unsigned char *) ctx->buf, 4); if (digest != NULL) memcpy(digest, ctx->buf, 16); memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */ } /* The three core functions */ #define F(x, y, z) (((x) & (y)) | ((~x) & (z))) #define G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z))) #define H(x, y, z) ((x) ^ (y) ^ (z)) #define FF(a, b, c, d, x, s) { \ (a) += F ((b), (c), (d)) + (x); \ (a) = rotl32 ((a), (s)); \ } #define GG(a, b, c, d, x, s) { \ (a) += G ((b), (c), (d)) + (x) + (word32)0x5a827999; \ (a) = rotl32 ((a), (s)); \ } #define HH(a, b, c, d, x, s) { \ (a) += H ((b), (c), (d)) + (x) + (word32)0x6ed9eba1; \ (a) = rotl32 ((a), (s)); \ } /* * The core of the MD4 algorithm */ static void MD4Transform(word32 buf[4], word32 const in[16]) { register word32 a, b, c, d; a = buf[0]; b = buf[1]; c = buf[2]; d = buf[3]; FF(a, b, c, d, in[0], 3); /* 1 */ FF(d, a, b, c, in[1], 7); /* 2 */ FF(c, d, a, b, in[2], 11); /* 3 */ FF(b, c, d, a, in[3], 19); /* 4 */ FF(a, b, c, d, in[4], 3); /* 5 */ FF(d, a, b, c, in[5], 7); /* 6 */ FF(c, d, a, b, in[6], 11); /* 7 */ FF(b, c, d, a, in[7], 19); /* 8 */ FF(a, b, c, d, in[8], 3); /* 9 */ FF(d, a, b, c, in[9], 7); /* 10 */ FF(c, d, a, b, in[10], 11); /* 11 */ FF(b, c, d, a, in[11], 19); /* 12 */ FF(a, b, c, d, in[12], 3); /* 13 */ FF(d, a, b, c, in[13], 7); /* 14 */ FF(c, d, a, b, in[14], 11); /* 15 */ FF(b, c, d, a, in[15], 19); /* 16 */ GG(a, b, c, d, in[0], 3); /* 17 */ GG(d, a, b, c, in[4], 5); /* 18 */ GG(c, d, a, b, in[8], 9); /* 19 */ GG(b, c, d, a, in[12], 13); /* 20 */ GG(a, b, c, d, in[1], 3); /* 21 */ GG(d, a, b, c, in[5], 5); /* 22 */ GG(c, d, a, b, in[9], 9); /* 23 */ GG(b, c, d, a, in[13], 13); /* 24 */ GG(a, b, c, d, in[2], 3); /* 25 */ GG(d, a, b, c, in[6], 5); /* 26 */ GG(c, d, a, b, in[10], 9); /* 27 */ GG(b, c, d, a, in[14], 13); /* 28 */ GG(a, b, c, d, in[3], 3); /* 29 */ GG(d, a, b, c, in[7], 5); /* 30 */ GG(c, d, a, b, in[11], 9); /* 31 */ GG(b, c, d, a, in[15], 13); /* 32 */ HH(a, b, c, d, in[0], 3); /* 33 */ HH(d, a, b, c, in[8], 9); /* 34 */ HH(c, d, a, b, in[4], 11); /* 35 */ HH(b, c, d, a, in[12], 15); /* 36 */ HH(a, b, c, d, in[2], 3); /* 37 */ HH(d, a, b, c, in[10], 9); /* 38 */ HH(c, d, a, b, in[6], 11); /* 39 */ HH(b, c, d, a, in[14], 15); /* 40 */ HH(a, b, c, d, in[1], 3); /* 41 */ HH(d, a, b, c, in[9], 9); /* 42 */ HH(c, d, a, b, in[5], 11); /* 43 */ HH(b, c, d, a, in[13], 15); /* 44 */ HH(a, b, c, d, in[3], 3); /* 45 */ HH(d, a, b, c, in[11], 9); /* 46 */ HH(c, d, a, b, in[7], 11); /* 47 */ HH(b, c, d, a, in[15], 15); /* 48 */ buf[0] += a; buf[1] += b; buf[2] += c; buf[3] += d; } #endif freetds-1.00.82/src/tds/md5.c100644 025423 025423 00000017627 12717145107 0011262/* * This code implements the MD5 message-digest algorithm. * The algorithm is due to Ron Rivest. This code was * written by Colin Plumb in 1993, no copyright is claimed. * This code is in the public domain; do with it what you wish. * * Equivalent code is available from RSA Data Security, Inc. * This code has been tested against that, and is equivalent, * except that you don't need to include two pages of legalese * with every copy. * * To compute the message digest of a chunk of bytes, declare an * MD5Context structure, pass it to MD5Init, call MD5Update as * needed on buffers full of bytes, and then call MD5Final, which * will fill a supplied 16-byte array with the digest. */ /* * File from mhash library (mhash.sourceforge.net) */ #include #ifndef HAVE_NETTLE #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include "md5.h" #undef word32 #define word32 TDS_UINT #ifndef WORDS_BIGENDIAN #define byteReverse(buf, len) /* Nothing */ #else /* * Note: this code is harmless on little-endian machines. */ static void byteReverse(unsigned char *buf, unsigned longs) { do { *(word32 *) buf = TDS_GET_A4LE(buf); buf += 4; } while (--longs); } #endif static void MD5Transform(word32 buf[4], word32 const in[16]); /* * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious * initialization constants. */ void MD5Init(struct MD5Context *ctx) { ctx->buf[0] = 0x67452301; ctx->buf[1] = 0xefcdab89; ctx->buf[2] = 0x98badcfe; ctx->buf[3] = 0x10325476; ctx->bytes = 0; } /* * Update context to reflect the concatenation of another buffer full * of bytes. */ void MD5Update(struct MD5Context *ctx, unsigned char const *buf, size_t len) { register word32 t; t = ctx->bytes & 0x3f; /* Bytes already in shsInfo->data */ /* Update bytecount */ ctx->bytes += len; /* Handle any leading odd-sized chunks */ if (t) { unsigned char *p = (unsigned char *) ctx->in + t; t = 64 - t; if (len < t) { memcpy(p, buf, len); return; } memcpy(p, buf, t); byteReverse(ctx->in, 16); MD5Transform(ctx->buf, (word32 *) ctx->in); buf += t; len -= t; } /* Process data in 64-byte chunks */ while (len >= 64) { memcpy(ctx->in, buf, 64); byteReverse(ctx->in, 16); MD5Transform(ctx->buf, (word32 *) ctx->in); buf += 64; len -= 64; } /* Handle any remaining bytes of data. */ memcpy(ctx->in, buf, len); } /* * Final wrapup - pad to 64-byte boundary with the bit pattern * 1 0* (64-bit count of bits processed, MSB-first) */ void MD5Final(struct MD5Context *ctx, unsigned char* digest) { unsigned int count; unsigned char *p; /* Compute number of bytes mod 64 */ count = ctx->bytes & 0x3F; /* Set the first char of padding to 0x80. This is safe since there is always at least one byte free */ p = ctx->in + count; *p++ = 0x80; /* Bytes of padding needed to make 64 bytes */ count = 64 - 1 - count; /* Pad out to 56 mod 64 */ if (count < 8) { /* Two lots of padding: Pad the first block to 64 bytes */ memset(p, 0, count); byteReverse(ctx->in, 16); MD5Transform(ctx->buf, (word32 *) ctx->in); /* Now fill the next block with 56 bytes */ memset(ctx->in, 0, 56); } else { /* Pad block to 56 bytes */ memset(p, 0, count - 8); } byteReverse(ctx->in, 14); /* Append length in bits and transform */ ((word32 *) ctx->in)[14] = (word32) (ctx->bytes << 3); ((word32 *) ctx->in)[15] = (word32) (ctx->bytes >> 29); MD5Transform(ctx->buf, (word32 *) ctx->in); byteReverse((unsigned char *) ctx->buf, 4); if (digest!=NULL) memcpy(digest, ctx->buf, 16); memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */ } /* The four core functions - F1 is optimized somewhat */ /* #define F1(x, y, z) (x & y | ~x & z) */ #define F1(x, y, z) (z ^ (x & (y ^ z))) #define F2(x, y, z) F1(z, x, y) #define F3(x, y, z) (x ^ y ^ z) #define F4(x, y, z) (y ^ (x | ~z)) /* This is the central step in the MD5 algorithm. */ #define MD5STEP(f, w, x, y, z, data, s) \ ( w += f(x, y, z) + data, w = w<>(32-s), w += x ) /* * The core of the MD5 algorithm, this alters an existing MD5 hash to * reflect the addition of 16 longwords of new data. MD5Update blocks * the data and converts bytes into longwords for this routine. */ static void MD5Transform(word32 buf[4], word32 const in[16]) { register word32 a, b, c, d; a = buf[0]; b = buf[1]; c = buf[2]; d = buf[3]; MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7); MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12); MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17); MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22); MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7); MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12); MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17); MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22); MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7); MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12); MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17); MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22); MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7); MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12); MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17); MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22); MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5); MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9); MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14); MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20); MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5); MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9); MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14); MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20); MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5); MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9); MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14); MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20); MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5); MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9); MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14); MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20); MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4); MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11); MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16); MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23); MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4); MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11); MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16); MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23); MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4); MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11); MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16); MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23); MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4); MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11); MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16); MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23); MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6); MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10); MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15); MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21); MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6); MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10); MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15); MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21); MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6); MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10); MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15); MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21); MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6); MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10); MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15); MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21); buf[0] += a; buf[1] += b; buf[2] += c; buf[3] += d; } #endif freetds-1.00.82/src/tds/des.c100644 025423 025423 00000040772 12717145107 0011345/* * Copyright (C) 1998,1999,2000,2001 Nikos Mavroyanopoulos * * This library is free software; you can redistribute it and/or modify it * under the terms of the GNU Library General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /* Sofware DES functions * written 12 Dec 1986 by Phil Karn, KA9Q; large sections adapted from * the 1977 public-domain program by Jim Gillogly * Modified for additional speed - 6 December 1988 Phil Karn * Modified for parameterized key schedules - Jan 1991 Phil Karn * Callers now allocate a key schedule as follows: * kn = (char (*)[8])malloc(sizeof(char) * 8 * 16); * or * char kn[16][8]; */ /* modified in order to use the libmcrypt API by Nikos Mavroyanopoulos * All modifications are placed under the license of libmcrypt. */ #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include "des.h" void tds_des_set_odd_parity(des_cblock key) { int i; unsigned char parity; for (i = 0; i < 8; i++) { parity = key[i]; parity ^= parity >> 4; parity ^= parity >> 2; parity ^= parity >> 1; key[i] = (key[i] & 0xfe) | (parity & 1); } } #ifndef HAVE_NETTLE static void permute_ip(des_cblock inblock, DES_KEY * key, des_cblock outblock); static void permute_fp(des_cblock inblock, DES_KEY * key, des_cblock outblock); static void perminit_ip(DES_KEY * key); static void spinit(DES_KEY * key); static void perminit_fp(DES_KEY * key); static TDS_UINT f(DES_KEY * key, register TDS_UINT r, register unsigned char *subkey); /* Tables defined in the Data Encryption Standard documents */ /* initial permutation IP */ static const char ip[] = { 58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36, 28, 20, 12, 4, 62, 54, 46, 38, 30, 22, 14, 6, 64, 56, 48, 40, 32, 24, 16, 8, 57, 49, 41, 33, 25, 17, 9, 1, 59, 51, 43, 35, 27, 19, 11, 3, 61, 53, 45, 37, 29, 21, 13, 5, 63, 55, 47, 39, 31, 23, 15, 7 }; /* final permutation IP^-1 */ static const char fp[] = { 40, 8, 48, 16, 56, 24, 64, 32, 39, 7, 47, 15, 55, 23, 63, 31, 38, 6, 46, 14, 54, 22, 62, 30, 37, 5, 45, 13, 53, 21, 61, 29, 36, 4, 44, 12, 52, 20, 60, 28, 35, 3, 43, 11, 51, 19, 59, 27, 34, 2, 42, 10, 50, 18, 58, 26, 33, 1, 41, 9, 49, 17, 57, 25 }; /* expansion operation matrix * This is for reference only; it is unused in the code * as the f() function performs it implicitly for speed */ #ifdef notdef static char ei[] = { 32, 1, 2, 3, 4, 5, 4, 5, 6, 7, 8, 9, 8, 9, 10, 11, 12, 13, 12, 13, 14, 15, 16, 17, 16, 17, 18, 19, 20, 21, 20, 21, 22, 23, 24, 25, 24, 25, 26, 27, 28, 29, 28, 29, 30, 31, 32, 1 }; #endif /* permuted choice table (key) */ static const char pc1[] = { 57, 49, 41, 33, 25, 17, 9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60, 52, 44, 36, 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4 }; /* number left rotations of pc1 */ static const char totrot[] = { 1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28 }; /* permuted choice key (table) */ static const char pc2[] = { 14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21, 10, 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2, 41, 52, 31, 37, 47, 55, 30, 40, 51, 45, 33, 48, 44, 49, 39, 56, 34, 53, 46, 42, 50, 36, 29, 32 }; /* The (in)famous S-boxes */ static const char si[8][64] = { /* S1 */ {14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7, 0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8, 4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0, 15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13}, /* S2 */ {15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10, 3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5, 0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15, 13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9}, /* S3 */ {10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8, 13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1, 13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7, 1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12}, /* S4 */ {7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15, 13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9, 10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4, 3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14}, /* S5 */ {2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9, 14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6, 4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14, 11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3}, /* S6 */ {12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11, 10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8, 9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6, 4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13}, /* S7 */ {4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1, 13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6, 1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2, 6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12}, /* S8 */ {13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7, 1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2, 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8, 2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11}, }; #ifdef notdef /* 32-bit permutation function P used on the output of the S-boxes */ static const char p32i[] = { 16, 7, 20, 21, 29, 12, 28, 17, 1, 15, 23, 26, 5, 18, 31, 10, 2, 8, 24, 14, 32, 27, 3, 9, 19, 13, 30, 6, 22, 11, 4, 25 }; #endif #define P32I_INDEX_ROW(n,i,a,b,c,d) \ n==a ? 0+i : n==b ? 1+i : n==c ? 2+i : n==d ? 3+i #define P32I_INDEX(n) \ (P32I_INDEX_ROW(n, 0, 16, 7, 20, 21) :\ P32I_INDEX_ROW(n, 4, 29, 12, 28, 17) :\ P32I_INDEX_ROW(n, 8, 1, 15, 23, 26) :\ P32I_INDEX_ROW(n,12, 5, 18, 31, 10) :\ P32I_INDEX_ROW(n,16, 2, 8, 24, 14) :\ P32I_INDEX_ROW(n,20, 32, 27, 3, 9) :\ P32I_INDEX_ROW(n,24, 19, 13, 30, 6) :\ P32I_INDEX_ROW(n,28, 22, 11, 4, 25) : 0x7f) static const char pbox[32] = { P32I_INDEX( 1), P32I_INDEX( 2), P32I_INDEX( 3), P32I_INDEX( 4), P32I_INDEX( 5), P32I_INDEX( 6), P32I_INDEX( 7), P32I_INDEX( 8), P32I_INDEX( 9), P32I_INDEX(10), P32I_INDEX(11), P32I_INDEX(12), P32I_INDEX(13), P32I_INDEX(14), P32I_INDEX(15), P32I_INDEX(16), P32I_INDEX(17), P32I_INDEX(18), P32I_INDEX(19), P32I_INDEX(20), P32I_INDEX(21), P32I_INDEX(22), P32I_INDEX(23), P32I_INDEX(24), P32I_INDEX(25), P32I_INDEX(26), P32I_INDEX(27), P32I_INDEX(28), P32I_INDEX(29), P32I_INDEX(30), P32I_INDEX(31), P32I_INDEX(32), }; /* End of DES-defined tables */ /* Lookup tables initialized once only at startup by des_init() */ /* bit 0 is left-most in byte */ static const int bytebit[] = { 0200, 0100, 040, 020, 010, 04, 02, 01 }; static const int nibblebit[] = { 010, 04, 02, 01 }; /* Allocate space and initialize DES lookup arrays * mode == 0: standard Data Encryption Algorithm */ static int des_init(DES_KEY * key) { spinit(key); perminit_ip(key); perminit_fp(key); return 0; } /* Set key (initialize key schedule array) */ int tds_des_set_key(DES_KEY * dkey, const des_cblock user_key, int len) { char pc1m[56]; /* place to modify pc1 into */ char pcr[56]; /* place to rotate pc1 into */ register int i, j, l; int m; memset(dkey, '\0', sizeof(DES_KEY)); des_init(dkey); /* Clear key schedule */ for (j = 0; j < 56; j++) { /* convert pc1 to bits of key */ l = pc1[j] - 1; /* integer bit location */ m = l & 07; /* find bit */ pc1m[j] = (user_key[l >> 3] & /* find which key byte l is in */ bytebit[m]) /* and which bit of that byte */ ? 1 : 0; /* and store 1-bit result */ } for (i = 0; i < 16; i++) { /* key chunk for each iteration */ for (j = 0; j < 56; j++) /* rotate pc1 the right amount */ pcr[j] = pc1m[(l = j + totrot[i]) < (j < 28 ? 28 : 56) ? l : l - 28]; /* rotate left and right halves independently */ for (j = 0; j < 48; j++) { /* select bits individually */ /* check bit that goes to kn[j] */ if (pcr[pc2[j] - 1]) { /* mask it in if it's there */ l = j % 6; dkey->kn[i][j / 6] |= bytebit[l] >> 2; } } } return 0; } /* In-place encryption of 64-bit block */ void tds_des_encrypt(DES_KEY * key, des_cblock block) { register TDS_UINT left, right; register unsigned char *knp; TDS_UINT work[2]; /* Working data storage */ permute_ip(block, key, (unsigned char *) work); /* Initial Permutation */ left = TDS_GET_A4BE(&work[0]); right = TDS_GET_A4BE(&work[1]); /* Do the 16 rounds. * The rounds are numbered from 0 to 15. On even rounds * the right half is fed to f() and the result exclusive-ORs * the left half; on odd rounds the reverse is done. */ knp = &key->kn[0][0]; left ^= f(key, right, knp); knp += 8; right ^= f(key, left, knp); knp += 8; left ^= f(key, right, knp); knp += 8; right ^= f(key, left, knp); knp += 8; left ^= f(key, right, knp); knp += 8; right ^= f(key, left, knp); knp += 8; left ^= f(key, right, knp); knp += 8; right ^= f(key, left, knp); knp += 8; left ^= f(key, right, knp); knp += 8; right ^= f(key, left, knp); knp += 8; left ^= f(key, right, knp); knp += 8; right ^= f(key, left, knp); knp += 8; left ^= f(key, right, knp); knp += 8; right ^= f(key, left, knp); knp += 8; left ^= f(key, right, knp); knp += 8; right ^= f(key, left, knp); /* Left/right half swap, plus byte swap if little-endian */ TDS_PUT_A4BE(&work[0], right); TDS_PUT_A4BE(&work[1], left); permute_fp((unsigned char *) work, key, block); /* Inverse initial permutation */ } /* In-place decryption of 64-bit block. This function is the mirror * image of encryption; exactly the same steps are taken, but in * reverse order */ #if 0 void _mcrypt_decrypt(DES_KEY * key, unsigned char *block) { register TDS_UINT left, right; register unsigned char *knp; TDS_UINT work[2]; /* Working data storage */ permute_ip(block, key, (unsigned char *) work); /* Initial permutation */ /* Left/right half swap, plus byte swap if little-endian */ right = TDS_GET_A4BE(&work[0]); left = TDS_GET_A4BE(&work[1]); /* Do the 16 rounds in reverse order. * The rounds are numbered from 15 to 0. On even rounds * the right half is fed to f() and the result exclusive-ORs * the left half; on odd rounds the reverse is done. */ knp = &key->kn[15][0]; right ^= f(key, left, knp); knp -= 8; left ^= f(key, right, knp); knp -= 8; right ^= f(key, left, knp); knp -= 8; left ^= f(key, right, knp); knp -= 8; right ^= f(key, left, knp); knp -= 8; left ^= f(key, right, knp); knp -= 8; right ^= f(key, left, knp); knp -= 8; left ^= f(key, right, knp); knp -= 8; right ^= f(key, left, knp); knp -= 8; left ^= f(key, right, knp); knp -= 8; right ^= f(key, left, knp); knp -= 8; left ^= f(key, right, knp); knp -= 8; right ^= f(key, left, knp); knp -= 8; left ^= f(key, right, knp); knp -= 8; right ^= f(key, left, knp); knp -= 8; left ^= f(key, right, knp); TDS_PUT_A4BE(&work[0], left); TDS_PUT_A4BE(&work[1], right); permute_fp((unsigned char *) work, key, block); /* Inverse initial permutation */ } #endif /* Permute inblock with perm */ static void permute_ip(des_cblock inblock, DES_KEY * key, des_cblock outblock) { register unsigned char *ib, *ob; /* ptr to input or output block */ register unsigned char *p, *q; register int j; /* Clear output block */ memset(outblock, '\0', 8); ib = inblock; for (j = 0; j < 16; j += 2, ib++) { /* for each input nibble */ ob = outblock; p = key->iperm[j][(*ib >> 4) & 0xf]; q = key->iperm[j + 1][*ib & 0xf]; /* and each output byte, OR the masks together */ *ob++ |= *p++ | *q++; *ob++ |= *p++ | *q++; *ob++ |= *p++ | *q++; *ob++ |= *p++ | *q++; *ob++ |= *p++ | *q++; *ob++ |= *p++ | *q++; *ob++ |= *p++ | *q++; *ob++ |= *p++ | *q++; } } /* Permute inblock with perm */ static void permute_fp(des_cblock inblock, DES_KEY * key, des_cblock outblock) { register unsigned char *ib, *ob; /* ptr to input or output block */ register unsigned char *p, *q; register int j; /* Clear output block */ memset(outblock, '\0', 8); ib = inblock; for (j = 0; j < 16; j += 2, ib++) { /* for each input nibble */ ob = outblock; p = key->fperm[j][(*ib >> 4) & 0xf]; q = key->fperm[j + 1][*ib & 0xf]; /* and each output byte, OR the masks together */ *ob++ |= *p++ | *q++; *ob++ |= *p++ | *q++; *ob++ |= *p++ | *q++; *ob++ |= *p++ | *q++; *ob++ |= *p++ | *q++; *ob++ |= *p++ | *q++; *ob++ |= *p++ | *q++; *ob++ |= *p++ | *q++; } } /* The nonlinear function f(r,k), the heart of DES */ static TDS_UINT f(DES_KEY * key, register TDS_UINT r, register unsigned char *subkey) { register const TDS_UINT *spp; register TDS_UINT rval, rt; register int er; #ifdef TRACE printf("f(%08lx, %02x %02x %02x %02x %02x %02x %02x %02x) = ", r, subkey[0], subkey[1], subkey[2], subkey[3], subkey[4], subkey[5], subkey[6], subkey[7]); #endif /* Run E(R) ^ K through the combined S & P boxes. * This code takes advantage of a convenient regularity in * E, namely that each group of 6 bits in E(R) feeding * a single S-box is a contiguous segment of R. */ subkey += 7; /* Compute E(R) for each block of 6 bits, and run thru boxes */ er = ((int) r << 1) | ((r & 0x80000000) ? 1 : 0); spp = &key->sp[7][0]; rval = spp[(er ^ *subkey--) & 0x3f]; spp -= 64; rt = (TDS_UINT) r >> 3; rval |= spp[((int) rt ^ *subkey--) & 0x3f]; spp -= 64; rt >>= 4; rval |= spp[((int) rt ^ *subkey--) & 0x3f]; spp -= 64; rt >>= 4; rval |= spp[((int) rt ^ *subkey--) & 0x3f]; spp -= 64; rt >>= 4; rval |= spp[((int) rt ^ *subkey--) & 0x3f]; spp -= 64; rt >>= 4; rval |= spp[((int) rt ^ *subkey--) & 0x3f]; spp -= 64; rt >>= 4; rval |= spp[((int) rt ^ *subkey--) & 0x3f]; spp -= 64; rt >>= 4; rt |= (r & 1) << 5; rval |= spp[((int) rt ^ *subkey) & 0x3f]; #ifdef TRACE printf(" %08lx\n", rval); #endif return rval; } /* initialize a perm array */ static void perminit_ip(DES_KEY * key) { register int l, j, k; int i, m; /* Clear the permutation array */ memset(key->iperm, '\0', 16 * 16 * 8); for (i = 0; i < 16; i++) /* each input nibble position */ for (j = 0; j < 16; j++) /* each possible input nibble */ for (k = 0; k < 64; k++) { /* each output bit position */ l = ip[k] - 1; /* where does this bit come from */ if ((l >> 2) != i) /* does it come from input posn? */ continue; /* if not, bit k is 0 */ if (!(j & nibblebit[l & 3])) continue; /* any such bit in input? */ m = k & 07; /* which bit is this in the byte */ key->iperm[i][j][k >> 3] |= bytebit[m]; } } static void perminit_fp(DES_KEY * key) { register int l, j, k; int i, m; /* Clear the permutation array */ memset(key->fperm, '\0', 16 * 16 * 8); for (i = 0; i < 16; i++) /* each input nibble position */ for (j = 0; j < 16; j++) /* each possible input nibble */ for (k = 0; k < 64; k++) { /* each output bit position */ l = fp[k] - 1; /* where does this bit come from */ if ((l >> 2) != i) /* does it come from input posn? */ continue; /* if not, bit k is 0 */ if (!(j & nibblebit[l & 3])) continue; /* any such bit in input? */ m = k & 07; /* which bit is this in the byte */ key->fperm[i][j][k >> 3] |= bytebit[m]; } } /* Initialize the lookup table for the combined S and P boxes */ static void spinit(DES_KEY * key) { int i, s, j, rowcol; TDS_UINT val; for (s = 0; s < 8; s++) { /* For each S-box */ for (i = 0; i < 64; i++) { /* For each possible input */ val = 0; /* The row number is formed from the first and last * bits; the column number is from the middle 4 */ rowcol = (i & 32) | ((i & 1) ? 16 : 0) | ((i >> 1) & 0xf); for (j = 0; j < 4; j++) { /* For each output bit */ if (si[s][rowcol] & (8 >> j)) { val |= 1L << (31 - pbox[4 * s + j]); } } key->sp[s][i] = val; } } } #endif /* ECB MODE */ int tds_des_ecb_encrypt(const void *plaintext, int len, DES_KEY * akey, unsigned char *output) { int j; const unsigned char *plain = (const unsigned char *) plaintext; for (j = 0; j < len / 8; j++) { memcpy(&output[j * 8], &plain[j * 8], 8); tds_des_encrypt(akey, &output[j * 8]); } if (j == 0 && len != 0) return -1; /* no blocks were encrypted */ return 0; } freetds-1.00.82/src/tds/gssapi.c100644 025423 025423 00000026621 12717145107 0012055/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2007-2011 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #if HAVE_NETDB_H #include #endif /* HAVE_NETDB_H */ #if HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #if HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #if HAVE_NETINET_IN_H #include #endif /* HAVE_NETINET_IN_H */ #if HAVE_ARPA_INET_H #include #endif /* HAVE_ARPA_INET_H */ #if HAVE_COM_ERR_H #include #endif /* HAVE_COM_ERR_H */ #ifdef ENABLE_KRB5 #include #include #include #include "replacements.h" /** * \ingroup libtds * \defgroup auth Authentication * Functions for handling authentication. */ /** * \addtogroup auth * @{ */ typedef struct tds_gss_auth { TDSAUTHENTICATION tds_auth; gss_ctx_id_t gss_context; gss_name_t target_name; char *sname; OM_uint32 last_stat; } TDSGSSAUTH; static TDSRET tds_gss_free(TDSCONNECTION * conn, struct tds_authentication * tds_auth) { TDSGSSAUTH *auth = (TDSGSSAUTH *) tds_auth; OM_uint32 min_stat; if (auth->tds_auth.packet) { gss_buffer_desc send_tok; send_tok.value = (void *) auth->tds_auth.packet; send_tok.length = auth->tds_auth.packet_len; gss_release_buffer(&min_stat, &send_tok); } gss_release_name(&min_stat, &auth->target_name); free(auth->sname); if (auth->gss_context != GSS_C_NO_CONTEXT) gss_delete_sec_context(&min_stat, &auth->gss_context, GSS_C_NO_BUFFER); free(auth); return TDS_SUCCESS; } static TDSRET tds_gss_continue(TDSSOCKET * tds, struct tds_gss_auth *auth, gss_buffer_desc *token_ptr); static TDSRET tds_gss_handle_next(TDSSOCKET * tds, struct tds_authentication * auth, size_t len) { TDSRET res; gss_buffer_desc recv_tok; if (((struct tds_gss_auth *) auth)->last_stat != GSS_S_CONTINUE_NEEDED) return TDS_FAIL; if (auth->packet) { OM_uint32 min_stat; gss_buffer_desc send_tok; send_tok.value = (void *) auth->packet; send_tok.length = auth->packet_len; gss_release_buffer(&min_stat, &send_tok); auth->packet = NULL; } recv_tok.length = len; recv_tok.value = tds_new(char, len); if (!recv_tok.value) return TDS_FAIL; tds_get_n(tds, recv_tok.value, len); res = tds_gss_continue(tds, (struct tds_gss_auth *) auth, &recv_tok); free(recv_tok.value); if (TDS_FAILED(res)) return res; if (auth->packet_len) { tds->out_flag = TDS7_AUTH; tds_put_n(tds, auth->packet, auth->packet_len); return tds_flush_packet(tds); } return TDS_SUCCESS; } /** * Build a GSSAPI packet to send to server * @param tds A pointer to the TDSSOCKET structure managing a client/server operation. * @param packet GSSAPI packet build from function * @return size of packet */ TDSAUTHENTICATION * tds_gss_get_auth(TDSSOCKET * tds) { /* * TODO * There are some differences between this implementation and MS on * - MS use SPNEGO with 3 mechnisms (MS KRB5, KRB5, NTLMSSP) * - MS seems to use MUTUAL flag * - name type is "Service and Instance (2)" and not "Principal (1)" * check for memory leaks * check for errors in many functions * a bit more verbose * dinamically load library ?? */ gss_buffer_desc send_tok; OM_uint32 maj_stat, min_stat; /* same as GSS_KRB5_NT_PRINCIPAL_NAME but do not require .so library */ static gss_OID_desc nt_principal = { 10, (void*) "\x2a\x86\x48\x86\xf7\x12\x01\x02\x02\x01" }; const char *server_name; /* Storage for getaddrinfo calls */ struct addrinfo *addrs = NULL; struct tds_gss_auth *auth; if (!tds->login) return NULL; auth = tds_new0(struct tds_gss_auth, 1); if (!auth) return NULL; auth->tds_auth.free = tds_gss_free; auth->tds_auth.handle_next = tds_gss_handle_next; auth->gss_context = GSS_C_NO_CONTEXT; auth->last_stat = GSS_S_COMPLETE; server_name = tds_dstr_cstr(&tds->login->server_host_name); if (strchr(server_name, '.') == NULL) { struct addrinfo hints; memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_V4MAPPED|AI_ADDRCONFIG|AI_CANONNAME|AI_FQDN; if (!getaddrinfo(server_name, NULL, &hints, &addrs) && addrs->ai_canonname && strchr(addrs->ai_canonname, '.') != NULL) server_name = addrs->ai_canonname; } if (!tds_dstr_isempty(&tds->login->server_spn)) { auth->sname = strdup(tds_dstr_cstr(&tds->login->server_spn)); } else if (tds_dstr_isempty(&tds->login->server_realm_name)) { if (asprintf(&auth->sname, "MSSQLSvc/%s:%d", server_name, tds->login->port) < 0) auth->sname = NULL; } else { if (asprintf(&auth->sname, "MSSQLSvc/%s:%d@%s", server_name, tds->login->port, tds_dstr_cstr(&tds->login->server_realm_name)) < 0) auth->sname = NULL; } if (addrs) freeaddrinfo(addrs); if (auth->sname == NULL) { tds_gss_free(tds->conn, (TDSAUTHENTICATION *) auth); return NULL; } tdsdump_log(TDS_DBG_NETWORK, "using kerberos name %s\n", auth->sname); /* * Import the name into target_name. Use send_tok to save * local variable space. */ send_tok.value = auth->sname; send_tok.length = strlen(auth->sname); maj_stat = gss_import_name(&min_stat, &send_tok, &nt_principal, &auth->target_name); switch (maj_stat) { case GSS_S_COMPLETE: tdsdump_log(TDS_DBG_NETWORK, "gss_import_name: GSS_S_COMPLETE: gss_import_name completed successfully.\n"); if (TDS_FAILED(tds_gss_continue(tds, auth, GSS_C_NO_BUFFER))) { tds_gss_free(tds->conn, (TDSAUTHENTICATION *) auth); return NULL; } break; case GSS_S_BAD_NAMETYPE: tdsdump_log(TDS_DBG_NETWORK, "gss_import_name: GSS_S_BAD_NAMETYPE: The input_name_type was unrecognized.\n"); break; case GSS_S_BAD_NAME: tdsdump_log(TDS_DBG_NETWORK, "gss_import_name: GSS_S_BAD_NAME: The input_name parameter could not be interpreted as a name of the specified type.\n"); break; case GSS_S_BAD_MECH: tdsdump_log(TDS_DBG_NETWORK, "gss_import_name: GSS_S_BAD_MECH: The input name-type was GSS_C_NT_EXPORT_NAME, but the mechanism contained within the input-name is not supported.\n"); break; default: tdsdump_log(TDS_DBG_NETWORK, "gss_import_name: unexpected error %d.\n", maj_stat); break; } if (GSS_ERROR(maj_stat)) { tds_gss_free(tds->conn, (TDSAUTHENTICATION *) auth); return NULL; } return (TDSAUTHENTICATION *) auth; } #ifndef HAVE_ERROR_MESSAGE static const char * tds_error_message(OM_uint32 e) { const char *m = strerror(e); if (m == NULL) return ""; return m; } #define error_message tds_error_message #endif static TDSRET tds_gss_continue(TDSSOCKET * tds, struct tds_gss_auth *auth, gss_buffer_desc *token_ptr) { gss_buffer_desc send_tok; OM_uint32 maj_stat, min_stat = 0; OM_uint32 ret_flags; int gssapi_flags; const char *msg = "???"; gss_OID pmech = GSS_C_NULL_OID; auth->last_stat = GSS_S_COMPLETE; send_tok.value = NULL; send_tok.length = 0; /* * Perform the context-establishement loop. * * On each pass through the loop, token_ptr points to the token * to send to the server (or GSS_C_NO_BUFFER on the first pass). * Every generated token is stored in send_tok which is then * transmitted to the server; every received token is stored in * recv_tok, which token_ptr is then set to, to be processed by * the next call to gss_init_sec_context. * * GSS-API guarantees that send_tok's length will be non-zero * if and only if the server is expecting another token from us, * and that gss_init_sec_context returns GSS_S_CONTINUE_NEEDED if * and only if the server has another token to send us. */ /* * We always want to ask for the mutual, replay, and integ flags. * We may ask for delegation based on config in the tds.conf and other conf files. */ gssapi_flags = GSS_C_MUTUAL_FLAG | GSS_C_REPLAY_FLAG | GSS_C_INTEG_FLAG; if (tds->login->gssapi_use_delegation) gssapi_flags |= GSS_C_DELEG_FLAG; maj_stat = gss_init_sec_context(&min_stat, GSS_C_NO_CREDENTIAL, &auth->gss_context, auth->target_name, GSS_C_NULL_OID, gssapi_flags, 0, NULL, /* no channel bindings */ token_ptr, &pmech, &send_tok, &ret_flags, NULL); /* ignore time_rec */ tdsdump_log(TDS_DBG_NETWORK, "gss_init_sec_context: actual mechanism at 0x%p\n", pmech); if (pmech && pmech->elements) { tdsdump_dump_buf(TDS_DBG_NETWORK, "actual mechanism", pmech->elements, pmech->length); } auth->last_stat = maj_stat; switch (maj_stat) { case GSS_S_COMPLETE: msg = "GSS_S_COMPLETE: gss_init_sec_context completed successfully."; break; case GSS_S_CONTINUE_NEEDED: msg = "GSS_S_CONTINUE_NEEDED: gss_init_sec_context() routine must be called again."; break; case GSS_S_FAILURE: msg = "GSS_S_FAILURE: The routine failed for reasons that are not defined at the GSS level."; tdsdump_log(TDS_DBG_NETWORK, "gss_init_sec_context: min_stat %ld \"%s\"\n", (long) min_stat, error_message(min_stat)); break; case GSS_S_BAD_BINDINGS: msg = "GSS_S_BAD_BINDINGS: The channel bindings are not valid."; break; case GSS_S_BAD_MECH: msg = "GSS_S_BAD_MECH: The request security mechanism is not supported."; break; case GSS_S_BAD_NAME: msg = "GSS_S_BAD_NAME: The target_name parameter is not valid."; break; case GSS_S_BAD_SIG: msg = "GSS_S_BAD_SIG: The input token contains an incorrect integrity check value."; break; case GSS_S_CREDENTIALS_EXPIRED: msg = "GSS_S_CREDENTIALS_EXPIRED: The supplied credentials are no longer valid."; break; case GSS_S_DEFECTIVE_CREDENTIAL: msg = "GSS_S_DEFECTIVE_CREDENTIAL: Consistency checks performed on the credential failed."; break; case GSS_S_DEFECTIVE_TOKEN: msg = "GSS_S_DEFECTIVE_TOKEN: Consistency checks performed on the input token failed."; break; case GSS_S_DUPLICATE_TOKEN: msg = "GSS_S_DUPLICATE_TOKEN: The token is a duplicate of a token that has already been processed."; break; case GSS_S_NO_CONTEXT: msg = "GSS_S_NO_CONTEXT: The context handle provided by the caller does not refer to a valid security context."; break; case GSS_S_NO_CRED: msg = "GSS_S_NO_CRED: The supplied credential handle does not refer to a valid credential, the supplied credential is not"; break; case GSS_S_OLD_TOKEN: msg = "GSS_S_OLD_TOKEN: The token is too old to be checked for duplication against previous tokens which have already been processed."; break; } if (GSS_ERROR(maj_stat)) { gss_release_buffer(&min_stat, &send_tok); tdsdump_log(TDS_DBG_NETWORK, "gss_init_sec_context: %s\n", msg); return TDS_FAIL; } auth->tds_auth.packet = (TDS_UCHAR *) send_tok.value; auth->tds_auth.packet_len = send_tok.length; return TDS_SUCCESS; } #endif /** @} */ freetds-1.00.82/src/tds/hmac_md5.c100644 025423 025423 00000003537 12717145107 0012245/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2008 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include "md5.h" #include "hmac_md5.h" #include /** * Calculates the HMAC-MD5 hash of the given data using the specified * hashing key. * * @param key The hashing key. * @param data The data for which the hash will be calculated. * @param data_len data length. * @param digest The HMAC-MD5 hash of the given data. */ void hmac_md5(const unsigned char key[16], const unsigned char* data, size_t data_len, unsigned char* digest) { int i; MD5_CTX ctx; unsigned char k_ipad[64]; unsigned char k_opad[64]; /* compute ipad and opad */ memset(k_ipad, 0x36, sizeof(k_ipad)); memset(k_opad, 0x5c, sizeof(k_opad)); for (i=0; i<16; ++i) { k_ipad[i] ^= key[i]; k_opad[i] ^= key[i]; } MD5Init(&ctx); MD5Update(&ctx, k_ipad, 64); if (data_len != 0) MD5Update(&ctx, data, data_len); MD5Final(&ctx, digest); MD5Init(&ctx); MD5Update(&ctx, k_opad, 64); MD5Update(&ctx, digest, 16); MD5Final(&ctx, digest); } freetds-1.00.82/src/tds/sspi.c100644 025423 025423 00000017171 13046306221 0011535/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2010 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include /* enabled some additional definitions for getaddrinfo */ #define _WIN32_WINNT 0x601 /* fix possible bug in sspi.h header */ #define FreeCredentialHandle FreeCredentialsHandle #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_SSPI #define SECURITY_WIN32 #include #include #include #include #include #include #include #include #include "replacements.h" /** * \ingroup libtds * \defgroup auth Authentication * Functions for handling authentication. */ /** * \addtogroup auth * @{ */ typedef struct tds_sspi_auth { TDSAUTHENTICATION tds_auth; CredHandle cred; CtxtHandle cred_ctx; char *sname; } TDSSSPIAUTH; static HMODULE secdll = NULL; static PSecurityFunctionTableA sec_fn = NULL; static tds_mutex sec_mutex = TDS_MUTEX_INITIALIZER; static int tds_init_secdll(void) { int res = 0; if (sec_fn) return 1; tds_mutex_lock(&sec_mutex); for (;;) { if (!secdll) { secdll = LoadLibrary("secur32.dll"); if (!secdll) break; } if (!sec_fn) { INIT_SECURITY_INTERFACE_A pInitSecurityInterface; pInitSecurityInterface = (INIT_SECURITY_INTERFACE_A) GetProcAddress(secdll, "InitSecurityInterfaceA"); if (!pInitSecurityInterface) break; sec_fn = pInitSecurityInterface(); if (!sec_fn) break; } res = 1; break; } tds_mutex_unlock(&sec_mutex); return res; } static int tds_sspi_free(TDSCONNECTION * conn, struct tds_authentication * tds_auth) { TDSSSPIAUTH *auth = (TDSSSPIAUTH *) tds_auth; sec_fn->DeleteSecurityContext(&auth->cred_ctx); sec_fn->FreeCredentialsHandle(&auth->cred); sec_fn->FreeContextBuffer(auth->tds_auth.packet); free(auth->sname); free(auth); return TDS_SUCCESS; } static int tds_sspi_handle_next(TDSSOCKET * tds, struct tds_authentication * tds_auth, size_t len) { SecBuffer in_buf, out_buf; SecBufferDesc in_desc, out_desc; SECURITY_STATUS status; ULONG attrs; TimeStamp ts; TDS_UCHAR *auth_buf; TDSSSPIAUTH *auth = (TDSSSPIAUTH *) tds_auth; if (len < 1) return TDS_FAIL; auth_buf = tds_new(TDS_UCHAR, len); if (!auth_buf) return TDS_FAIL; tds_get_n(tds, auth_buf, (int)len); /* free previously allocated buffer */ if (auth->tds_auth.packet) { sec_fn->FreeContextBuffer(auth->tds_auth.packet); auth->tds_auth.packet = NULL; } in_desc.ulVersion = out_desc.ulVersion = SECBUFFER_VERSION; in_desc.cBuffers = out_desc.cBuffers = 1; in_desc.pBuffers = &in_buf; out_desc.pBuffers = &out_buf; in_buf.BufferType = SECBUFFER_TOKEN; in_buf.pvBuffer = auth_buf; in_buf.cbBuffer = (ULONG)len; out_buf.BufferType = SECBUFFER_TOKEN; out_buf.pvBuffer = NULL; out_buf.cbBuffer = 0; status = sec_fn->InitializeSecurityContext(&auth->cred, &auth->cred_ctx, auth->sname, ISC_REQ_CONFIDENTIALITY | ISC_REQ_REPLAY_DETECT | ISC_REQ_CONNECTION | ISC_REQ_ALLOCATE_MEMORY, 0, SECURITY_NETWORK_DREP, &in_desc, 0, &auth->cred_ctx, &out_desc, &attrs, &ts); free(auth_buf); auth->tds_auth.packet = out_buf.pvBuffer; switch (status) { case SEC_I_COMPLETE_AND_CONTINUE: sec_fn->CompleteAuthToken(&auth->cred_ctx, &out_desc); break; case SEC_I_CONTINUE_NEEDED: case SEC_E_OK: break; default: return TDS_FAIL; } if (out_buf.cbBuffer == 0) return TDS_SUCCESS; tds_put_n(tds, auth->tds_auth.packet, out_buf.cbBuffer); return tds_flush_packet(tds); } /** * Build a SSPI packet to send to server * @param tds A pointer to the TDSSOCKET structure managing a client/server operation. */ TDSAUTHENTICATION * tds_sspi_get_auth(TDSSOCKET * tds) { SecBuffer buf; SecBufferDesc desc; SECURITY_STATUS status; ULONG attrs; TimeStamp ts; SEC_WINNT_AUTH_IDENTITY identity; const char *p, *user_name, *server_name; struct addrinfo *addrs = NULL; TDSSSPIAUTH *auth; TDSLOGIN *login = tds->login; /* check login */ if (!login) return NULL; if (!tds_init_secdll()) return NULL; /* parse username/password informations */ memset(&identity, 0, sizeof(identity)); user_name = tds_dstr_cstr(&login->user_name); if ((p = strchr(user_name, '\\')) != NULL) { identity.Flags = SEC_WINNT_AUTH_IDENTITY_ANSI; identity.Password = (void *) tds_dstr_cstr(&login->password); identity.PasswordLength = tds_dstr_len(&login->password); identity.Domain = (void *) user_name; identity.DomainLength = p - user_name; user_name = p + 1; identity.User = (void *) user_name; identity.UserLength = strlen(user_name); } auth = tds_new0(TDSSSPIAUTH, 1); if (!auth || !tds->login) return NULL; auth->tds_auth.free = tds_sspi_free; auth->tds_auth.handle_next = tds_sspi_handle_next; /* using Negotiate system will use proper protocol (either NTLM or Kerberos) */ if (sec_fn->AcquireCredentialsHandle(NULL, (char *)"Negotiate", SECPKG_CRED_OUTBOUND, NULL, identity.Domain ? &identity : NULL, NULL, NULL, &auth->cred, &ts) != SEC_E_OK) { free(auth); return NULL; } desc.ulVersion = SECBUFFER_VERSION; desc.cBuffers = 1; desc.pBuffers = &buf; buf.BufferType = SECBUFFER_TOKEN; buf.pvBuffer = NULL; buf.cbBuffer = 0; /* build SPN */ server_name = tds_dstr_cstr(&login->server_host_name); if (strchr(server_name, '.') == NULL) { struct addrinfo hints; int res; memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_V4MAPPED|AI_ADDRCONFIG|AI_CANONNAME|AI_FQDN; res = getaddrinfo(server_name, NULL, &hints, &addrs); if (res) { /* some version of Windows does not support V4MAPPED * and ADDRCONFIG, try without them */ hints.ai_flags = AI_CANONNAME|AI_FQDN; res = getaddrinfo(server_name, NULL, &hints, &addrs); } if (!res && addrs->ai_canonname && strchr(addrs->ai_canonname, '.') != NULL) server_name = addrs->ai_canonname; } if (strchr(server_name, '.') != NULL) { if (asprintf(&auth->sname, "MSSQLSvc/%s:%d", server_name, login->port) < 0) { if (addrs) freeaddrinfo(addrs); sec_fn->FreeCredentialsHandle(&auth->cred); free(auth); return NULL; } tdsdump_log(TDS_DBG_NETWORK, "kerberos name %s\n", auth->sname); } if (addrs) freeaddrinfo(addrs); status = sec_fn->InitializeSecurityContext(&auth->cred, NULL, auth->sname, ISC_REQ_CONFIDENTIALITY | ISC_REQ_REPLAY_DETECT | ISC_REQ_CONNECTION | ISC_REQ_ALLOCATE_MEMORY, 0, SECURITY_NETWORK_DREP, NULL, 0, &auth->cred_ctx, &desc, &attrs, &ts); switch (status) { case SEC_I_COMPLETE_AND_CONTINUE: sec_fn->CompleteAuthToken(&auth->cred_ctx, &desc); break; case SEC_I_CONTINUE_NEEDED: case SEC_E_OK: break; default: tds_sspi_free(tds->conn, &auth->tds_auth); return NULL; } auth->tds_auth.packet_len = buf.cbBuffer; auth->tds_auth.packet = buf.pvBuffer; return &auth->tds_auth; } #endif /* HAVE_SSPI */ /** @} */ freetds-1.00.82/src/tds/CMakeLists.txt100644 025423 025423 00000003511 12717145107 0013154add_subdirectory(unittests) if(PERL_FOUND AND NOT EXISTS "${CMAKE_SOURCE_DIR}/configure") # get name of null device set(NULLNAME "/dev/null") if(CMAKE_SYSTEM_NAME STREQUAL "Windows") set(NULLNAME "NUL:") endif(CMAKE_SYSTEM_NAME STREQUAL "Windows") add_custom_command(OUTPUT tds_willconvert.h COMMAND ${PERL_EXECUTABLE} tds_willconvert.pl ../../include/freetds/proto.h > tds_willconvert.h MAIN_DEPENDENCY tds_willconvert.pl WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) add_custom_command(OUTPUT encodings.h COMMAND ${PERL_EXECUTABLE} encodings.pl . > encodings.h 2> ${NULLNAME} MAIN_DEPENDENCY encodings.pl DEPENDS alternative_character_sets.h WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) add_custom_command(OUTPUT num_limits.h COMMAND ${PERL_EXECUTABLE} num_limits.pl > num_limits.h MAIN_DEPENDENCY num_limits.pl WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) add_custom_command(OUTPUT tds_types.h COMMAND ${PERL_EXECUTABLE} types.pl ../../misc/types.csv ../../include/freetds/proto.h > tds_types.h MAIN_DEPENDENCY types.pl DEPENDS ../../misc/types.csv ../../include/freetds/proto.h WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) endif(PERL_FOUND AND NOT EXISTS "${CMAKE_SOURCE_DIR}/configure") if(WIN32) set(add_SRCS sspi.c md5.c) else(WIN32) set(add_SRCS challenge.c md4.c md5.c des.c gssapi.c hmac_md5.c) endif(WIN32) add_library(tds STATIC mem.c token.c util.c login.c read.c write.c convert.c numeric.c config.c query.c iconv.c locale.c threadsafe.c vstrbuild.c tdsstring.c getmac.c data.c net.c tls.c tds_checks.c log.c bulk.c packet.c stream.c random.c sec_negotiate_gnutls.h sec_negotiate_openssl.h sec_negotiate.c tds_willconvert.h encodings.h num_limits.h tds_types.h ${add_SRCS} ) if (NOT WIN32) set_target_properties(tds PROPERTIES COMPILE_FLAGS -fPIC) endif() freetds-1.00.82/src/tds/unittests/Makefile.am100644 025423 025423 00000003736 12717145107 0014523# $Id: Makefile.am,v 1.31 2011-10-31 13:58:41 freddy77 Exp $ TESTS = t0001$(EXEEXT) t0002$(EXEEXT) t0003$(EXEEXT)\ t0004$(EXEEXT) t0005$(EXEEXT) t0006$(EXEEXT)\ t0007$(EXEEXT) t0008$(EXEEXT) dynamic1$(EXEEXT)\ convert$(EXEEXT) dataread$(EXEEXT) utf8_1$(EXEEXT)\ utf8_2$(EXEEXT) utf8_3$(EXEEXT) numeric$(EXEEXT) \ iconv_fread$(EXEEXT) toodynamic$(EXEEXT) \ readconf$(EXEEXT) charconv$(EXEEXT) \ nulls$(EXEEXT) corrupt$(EXEEXT) # flags test commented, not necessary for 0.62 # TODO add flags test again when needed check_PROGRAMS = $(TESTS) t0001_SOURCES = t0001.c common.c common.h t0002_SOURCES = t0002.c common.c common.h t0003_SOURCES = t0003.c common.c common.h t0004_SOURCES = t0004.c common.c common.h t0005_SOURCES = t0005.c common.c common.h t0006_SOURCES = t0006.c common.c common.h t0007_SOURCES = t0007.c t0008_SOURCES = t0008.c dynamic1_SOURCES = dynamic1.c common.c common.h convert_SOURCES = convert.c dataread_SOURCES = dataread.c common.c common.h # flags_SOURCES = flags.c common.c common.h utf8_1_SOURCES = utf8_1.c common.c common.h utf8.c utf8_2_SOURCES = utf8_2.c common.c common.h utf8_3_SOURCES = utf8_3.c common.c common.h utf8.c if ENABLE_DEVELOPING noinst_PROGRAMS = collations collations_SOURCES = collations.c common.c common.h endif numeric_SOURCES = numeric.c iconv_fread_SOURCES = iconv_fread.c charconv_SOURCES = charconv.c toodynamic_SOURCES = toodynamic.c common.c common.h nulls_SOURCES = nulls.c common.c common.h if !HAVE_SSPI TESTS += challenge$(EXEEXT) challenge_SOURCES = challenge.c endif readconf_SOURCES = readconf.c corrupt_SOURCES = corrupt.c common.c common.h AM_CPPFLAGS = -I$(top_srcdir)/include -I$(srcdir)/.. -I../ -DFREETDS_TOPDIR=\"$(top_srcdir)\" if MINGW32 AM_LDFLAGS = -no-fast-install else AM_LDFLAGS = -no-install -L../.libs -R $(abs_builddir)/../.libs endif LIBS = ../libtds.la ../../replacements/libreplacements.la $(LTLIBICONV) $(NETWORK_LIBS) CLEANFILES = tdsdump.out EXTRA_DIST = challenge.c CMakeLists.txt readconf.in freetds-1.00.82/src/tds/unittests/Makefile.in100644 025423 025423 00000144310 13242511111 0014510# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @ENABLE_DEVELOPING_TRUE@noinst_PROGRAMS = collations$(EXEEXT) @HAVE_SSPI_FALSE@am__append_1 = challenge$(EXEEXT) subdir = src/tds/unittests ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = \ $(top_srcdir)/m4/ac_caolan_func_which_gethostbyname_r.m4 \ $(top_srcdir)/m4/ac_have_inaddr_none.m4 \ $(top_srcdir)/m4/ac_have_malloc_options.m4 \ $(top_srcdir)/m4/ac_nullzero.m4 \ $(top_srcdir)/m4/ac_raf_func_which_getservbyname_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_gethostbyaddr_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_getpwuid_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_localtime_r.m4 \ $(top_srcdir)/m4/acx_pthread.m4 \ $(top_srcdir)/m4/ax_cflags_gcc_option.m4 \ $(top_srcdir)/m4/check_openssl.m4 \ $(top_srcdir)/m4/gettimemilli.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/pushlibs.m4 \ $(top_srcdir)/m4/sprintf_i64_format.m4 \ $(top_srcdir)/m4/type_socklen_t.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = PROGRAMS = $(noinst_PROGRAMS) am__challenge_SOURCES_DIST = challenge.c @HAVE_SSPI_FALSE@am_challenge_OBJECTS = challenge.$(OBJEXT) challenge_OBJECTS = $(am_challenge_OBJECTS) challenge_LDADD = $(LDADD) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = am_charconv_OBJECTS = charconv.$(OBJEXT) charconv_OBJECTS = $(am_charconv_OBJECTS) charconv_LDADD = $(LDADD) am__collations_SOURCES_DIST = collations.c common.c common.h @ENABLE_DEVELOPING_TRUE@am_collations_OBJECTS = collations.$(OBJEXT) \ @ENABLE_DEVELOPING_TRUE@ common.$(OBJEXT) collations_OBJECTS = $(am_collations_OBJECTS) collations_LDADD = $(LDADD) am_convert_OBJECTS = convert.$(OBJEXT) convert_OBJECTS = $(am_convert_OBJECTS) convert_LDADD = $(LDADD) am_corrupt_OBJECTS = corrupt.$(OBJEXT) common.$(OBJEXT) corrupt_OBJECTS = $(am_corrupt_OBJECTS) corrupt_LDADD = $(LDADD) am_dataread_OBJECTS = dataread.$(OBJEXT) common.$(OBJEXT) dataread_OBJECTS = $(am_dataread_OBJECTS) dataread_LDADD = $(LDADD) am_dynamic1_OBJECTS = dynamic1.$(OBJEXT) common.$(OBJEXT) dynamic1_OBJECTS = $(am_dynamic1_OBJECTS) dynamic1_LDADD = $(LDADD) am_iconv_fread_OBJECTS = iconv_fread.$(OBJEXT) iconv_fread_OBJECTS = $(am_iconv_fread_OBJECTS) iconv_fread_LDADD = $(LDADD) am_nulls_OBJECTS = nulls.$(OBJEXT) common.$(OBJEXT) nulls_OBJECTS = $(am_nulls_OBJECTS) nulls_LDADD = $(LDADD) am_numeric_OBJECTS = numeric.$(OBJEXT) numeric_OBJECTS = $(am_numeric_OBJECTS) numeric_LDADD = $(LDADD) am_readconf_OBJECTS = readconf.$(OBJEXT) readconf_OBJECTS = $(am_readconf_OBJECTS) readconf_LDADD = $(LDADD) am_t0001_OBJECTS = t0001.$(OBJEXT) common.$(OBJEXT) t0001_OBJECTS = $(am_t0001_OBJECTS) t0001_LDADD = $(LDADD) am_t0002_OBJECTS = t0002.$(OBJEXT) common.$(OBJEXT) t0002_OBJECTS = $(am_t0002_OBJECTS) t0002_LDADD = $(LDADD) am_t0003_OBJECTS = t0003.$(OBJEXT) common.$(OBJEXT) t0003_OBJECTS = $(am_t0003_OBJECTS) t0003_LDADD = $(LDADD) am_t0004_OBJECTS = t0004.$(OBJEXT) common.$(OBJEXT) t0004_OBJECTS = $(am_t0004_OBJECTS) t0004_LDADD = $(LDADD) am_t0005_OBJECTS = t0005.$(OBJEXT) common.$(OBJEXT) t0005_OBJECTS = $(am_t0005_OBJECTS) t0005_LDADD = $(LDADD) am_t0006_OBJECTS = t0006.$(OBJEXT) common.$(OBJEXT) t0006_OBJECTS = $(am_t0006_OBJECTS) t0006_LDADD = $(LDADD) am_t0007_OBJECTS = t0007.$(OBJEXT) t0007_OBJECTS = $(am_t0007_OBJECTS) t0007_LDADD = $(LDADD) am_t0008_OBJECTS = t0008.$(OBJEXT) t0008_OBJECTS = $(am_t0008_OBJECTS) t0008_LDADD = $(LDADD) am_toodynamic_OBJECTS = toodynamic.$(OBJEXT) common.$(OBJEXT) toodynamic_OBJECTS = $(am_toodynamic_OBJECTS) toodynamic_LDADD = $(LDADD) am_utf8_1_OBJECTS = utf8_1.$(OBJEXT) common.$(OBJEXT) utf8.$(OBJEXT) utf8_1_OBJECTS = $(am_utf8_1_OBJECTS) utf8_1_LDADD = $(LDADD) am_utf8_2_OBJECTS = utf8_2.$(OBJEXT) common.$(OBJEXT) utf8_2_OBJECTS = $(am_utf8_2_OBJECTS) utf8_2_LDADD = $(LDADD) am_utf8_3_OBJECTS = utf8_3.$(OBJEXT) common.$(OBJEXT) utf8.$(OBJEXT) utf8_3_OBJECTS = $(am_utf8_3_OBJECTS) utf8_3_LDADD = $(LDADD) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(challenge_SOURCES) $(charconv_SOURCES) \ $(collations_SOURCES) $(convert_SOURCES) $(corrupt_SOURCES) \ $(dataread_SOURCES) $(dynamic1_SOURCES) $(iconv_fread_SOURCES) \ $(nulls_SOURCES) $(numeric_SOURCES) $(readconf_SOURCES) \ $(t0001_SOURCES) $(t0002_SOURCES) $(t0003_SOURCES) \ $(t0004_SOURCES) $(t0005_SOURCES) $(t0006_SOURCES) \ $(t0007_SOURCES) $(t0008_SOURCES) $(toodynamic_SOURCES) \ $(utf8_1_SOURCES) $(utf8_2_SOURCES) $(utf8_3_SOURCES) DIST_SOURCES = $(am__challenge_SOURCES_DIST) $(charconv_SOURCES) \ $(am__collations_SOURCES_DIST) $(convert_SOURCES) \ $(corrupt_SOURCES) $(dataread_SOURCES) $(dynamic1_SOURCES) \ $(iconv_fread_SOURCES) $(nulls_SOURCES) $(numeric_SOURCES) \ $(readconf_SOURCES) $(t0001_SOURCES) $(t0002_SOURCES) \ $(t0003_SOURCES) $(t0004_SOURCES) $(t0005_SOURCES) \ $(t0006_SOURCES) $(t0007_SOURCES) $(t0008_SOURCES) \ $(toodynamic_SOURCES) $(utf8_1_SOURCES) $(utf8_2_SOURCES) \ $(utf8_3_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__tty_colors_dummy = \ mgn= red= grn= lgn= blu= brg= std=; \ am__color_tests=no am__tty_colors = { \ $(am__tty_colors_dummy); \ if test "X$(AM_COLOR_TESTS)" = Xno; then \ am__color_tests=no; \ elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ am__color_tests=yes; \ elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ am__color_tests=yes; \ fi; \ if test $$am__color_tests = yes; then \ red=''; \ grn=''; \ lgn=''; \ blu=''; \ mgn=''; \ brg=''; \ std=''; \ fi; \ } am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__recheck_rx = ^[ ]*:recheck:[ ]* am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* # A command that, given a newline-separated list of test names on the # standard input, print the name of the tests that are to be re-run # upon "make recheck". am__list_recheck_tests = $(AWK) '{ \ recheck = 1; \ while ((rc = (getline line < ($$0 ".trs"))) != 0) \ { \ if (rc < 0) \ { \ if ((getline line2 < ($$0 ".log")) < 0) \ recheck = 0; \ break; \ } \ else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ { \ recheck = 0; \ break; \ } \ else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ { \ break; \ } \ }; \ if (recheck) \ print $$0; \ close ($$0 ".trs"); \ close ($$0 ".log"); \ }' # A command that, given a newline-separated list of test names on the # standard input, create the global log from their .trs and .log files. am__create_global_log = $(AWK) ' \ function fatal(msg) \ { \ print "fatal: making $@: " msg | "cat >&2"; \ exit 1; \ } \ function rst_section(header) \ { \ print header; \ len = length(header); \ for (i = 1; i <= len; i = i + 1) \ printf "="; \ printf "\n\n"; \ } \ { \ copy_in_global_log = 1; \ global_test_result = "RUN"; \ while ((rc = (getline line < ($$0 ".trs"))) != 0) \ { \ if (rc < 0) \ fatal("failed to read from " $$0 ".trs"); \ if (line ~ /$(am__global_test_result_rx)/) \ { \ sub("$(am__global_test_result_rx)", "", line); \ sub("[ ]*$$", "", line); \ global_test_result = line; \ } \ else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ copy_in_global_log = 0; \ }; \ if (copy_in_global_log) \ { \ rst_section(global_test_result ": " $$0); \ while ((rc = (getline line < ($$0 ".log"))) != 0) \ { \ if (rc < 0) \ fatal("failed to read from " $$0 ".log"); \ print line; \ }; \ printf "\n"; \ }; \ close ($$0 ".trs"); \ close ($$0 ".log"); \ }' # Restructured Text title. am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } # Solaris 10 'make', and several other traditional 'make' implementations, # pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it # by disabling -e (using the XSI extension "set +e") if it's set. am__sh_e_setup = case $$- in *e*) set +e;; esac # Default flags passed to test drivers. am__common_driver_flags = \ --color-tests "$$am__color_tests" \ --enable-hard-errors "$$am__enable_hard_errors" \ --expect-failure "$$am__expect_failure" # To be inserted before the command running the test. Creates the # directory for the log if needed. Stores in $dir the directory # containing $f, in $tst the test, in $log the log. Executes the # developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and # passes TESTS_ENVIRONMENT. Set up options for the wrapper that # will run the test scripts (or their associated LOG_COMPILER, if # thy have one). am__check_pre = \ $(am__sh_e_setup); \ $(am__vpath_adj_setup) $(am__vpath_adj) \ $(am__tty_colors); \ srcdir=$(srcdir); export srcdir; \ case "$@" in \ */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ *) am__odir=.;; \ esac; \ test "x$$am__odir" = x"." || test -d "$$am__odir" \ || $(MKDIR_P) "$$am__odir" || exit $$?; \ if test -f "./$$f"; then dir=./; \ elif test -f "$$f"; then dir=; \ else dir="$(srcdir)/"; fi; \ tst=$$dir$$f; log='$@'; \ if test -n '$(DISABLE_HARD_ERRORS)'; then \ am__enable_hard_errors=no; \ else \ am__enable_hard_errors=yes; \ fi; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ am__expect_failure=yes;; \ *) \ am__expect_failure=no;; \ esac; \ $(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) # A shell command to get the names of the tests scripts with any registered # extension removed (i.e., equivalently, the names of the test logs, with # the '.log' extension removed). The result is saved in the shell variable # '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, # we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", # since that might cause problem with VPATH rewrites for suffix-less tests. # See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. am__set_TESTS_bases = \ bases='$(TEST_LOGS)'; \ bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ bases=`echo $$bases` RECHECK_LOGS = $(TEST_LOGS) AM_RECURSIVE_TARGETS = check recheck TEST_SUITE_LOG = test-suite.log TEST_EXTENSIONS = @EXEEXT@ .test LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) am__set_b = \ case '$@' in \ */*) \ case '$*' in \ */*) b='$*';; \ *) b=`echo '$@' | sed 's/\.log$$//'`; \ esac;; \ *) \ b='$*';; \ esac am__test_logs1 = $(TESTS:=.log) am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) TEST_LOGS = $(am__test_logs2:.test.log=.log) TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ $(TEST_LOG_FLAGS) am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp \ $(top_srcdir)/mkinstalldirs $(top_srcdir)/test-driver DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BUILD_NUMBER = @BUILD_NUMBER@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOXYGEN = @DOXYGEN@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FREETDS_LIBGCC = @FREETDS_LIBGCC@ FREETDS_ODBC_MODULE = @FREETDS_ODBC_MODULE@ FREETDS_SYMBOLIC = @FREETDS_SYMBOLIC@ GCRYPT_CFLAGS = @GCRYPT_CFLAGS@ GCRYPT_LIBS = @GCRYPT_LIBS@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ HAVE_OPENSSL = @HAVE_OPENSSL@ HAVE_PERL_SOURCES = @HAVE_PERL_SOURCES@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBADD_DL = @LIBADD_DL@ LIBADD_DLD_LINK = @LIBADD_DLD_LINK@ LIBADD_DLOPEN = @LIBADD_DLOPEN@ LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@ LIBICONV = @LIBICONV@ LIBOBJS = @LIBOBJS@ LIBS = ../libtds.la ../../replacements/libreplacements.la $(LTLIBICONV) $(NETWORK_LIBS) LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBOBJS = @LTLIBOBJS@ LT_DLLOADERS = @LT_DLLOADERS@ LT_DLPREOPEN = @LT_DLPREOPEN@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ NETTLE_CFLAGS = @NETTLE_CFLAGS@ NETTLE_LIBS = @NETTLE_LIBS@ NETWORK_LIBS = @NETWORK_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ODBC = @ODBC@ ODBCINSTLIB = @ODBCINSTLIB@ ODBCLIB = @ODBCLIB@ ODBCNODMLIB = @ODBCNODMLIB@ ODBCNODMLIBAPP = @ODBCNODMLIBAPP@ ODBC_CONFIG = @ODBC_CONFIG@ ODBC_INC = @ODBC_INC@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ RC = @RC@ READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SUBVERSION = @SUBVERSION@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ dblib_define = @dblib_define@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ tds_sysdep_int16_type = @tds_sysdep_int16_type@ tds_sysdep_int32_type = @tds_sysdep_int32_type@ tds_sysdep_int64_type = @tds_sysdep_int64_type@ tds_sysdep_intptr_type = @tds_sysdep_intptr_type@ tds_sysdep_real32_type = @tds_sysdep_real32_type@ tds_sysdep_real64_type = @tds_sysdep_real64_type@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # $Id: Makefile.am,v 1.31 2011-10-31 13:58:41 freddy77 Exp $ TESTS = t0001$(EXEEXT) t0002$(EXEEXT) t0003$(EXEEXT) t0004$(EXEEXT) \ t0005$(EXEEXT) t0006$(EXEEXT) t0007$(EXEEXT) t0008$(EXEEXT) \ dynamic1$(EXEEXT) convert$(EXEEXT) dataread$(EXEEXT) \ utf8_1$(EXEEXT) utf8_2$(EXEEXT) utf8_3$(EXEEXT) \ numeric$(EXEEXT) iconv_fread$(EXEEXT) toodynamic$(EXEEXT) \ readconf$(EXEEXT) charconv$(EXEEXT) nulls$(EXEEXT) \ corrupt$(EXEEXT) $(am__append_1) # flags test commented, not necessary for 0.62 # TODO add flags test again when needed check_PROGRAMS = $(TESTS) t0001_SOURCES = t0001.c common.c common.h t0002_SOURCES = t0002.c common.c common.h t0003_SOURCES = t0003.c common.c common.h t0004_SOURCES = t0004.c common.c common.h t0005_SOURCES = t0005.c common.c common.h t0006_SOURCES = t0006.c common.c common.h t0007_SOURCES = t0007.c t0008_SOURCES = t0008.c dynamic1_SOURCES = dynamic1.c common.c common.h convert_SOURCES = convert.c dataread_SOURCES = dataread.c common.c common.h # flags_SOURCES = flags.c common.c common.h utf8_1_SOURCES = utf8_1.c common.c common.h utf8.c utf8_2_SOURCES = utf8_2.c common.c common.h utf8_3_SOURCES = utf8_3.c common.c common.h utf8.c @ENABLE_DEVELOPING_TRUE@collations_SOURCES = collations.c common.c common.h numeric_SOURCES = numeric.c iconv_fread_SOURCES = iconv_fread.c charconv_SOURCES = charconv.c toodynamic_SOURCES = toodynamic.c common.c common.h nulls_SOURCES = nulls.c common.c common.h @HAVE_SSPI_FALSE@challenge_SOURCES = challenge.c readconf_SOURCES = readconf.c corrupt_SOURCES = corrupt.c common.c common.h AM_CPPFLAGS = -I$(top_srcdir)/include -I$(srcdir)/.. -I../ -DFREETDS_TOPDIR=\"$(top_srcdir)\" @MINGW32_FALSE@AM_LDFLAGS = -no-install -L../.libs -R $(abs_builddir)/../.libs @MINGW32_TRUE@AM_LDFLAGS = -no-fast-install CLEANFILES = tdsdump.out EXTRA_DIST = challenge.c CMakeLists.txt readconf.in all: all-am .SUFFIXES: .SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/tds/unittests/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/tds/unittests/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-checkPROGRAMS: @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list clean-noinstPROGRAMS: @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list challenge$(EXEEXT): $(challenge_OBJECTS) $(challenge_DEPENDENCIES) $(EXTRA_challenge_DEPENDENCIES) @rm -f challenge$(EXEEXT) $(AM_V_CCLD)$(LINK) $(challenge_OBJECTS) $(challenge_LDADD) $(LIBS) charconv$(EXEEXT): $(charconv_OBJECTS) $(charconv_DEPENDENCIES) $(EXTRA_charconv_DEPENDENCIES) @rm -f charconv$(EXEEXT) $(AM_V_CCLD)$(LINK) $(charconv_OBJECTS) $(charconv_LDADD) $(LIBS) collations$(EXEEXT): $(collations_OBJECTS) $(collations_DEPENDENCIES) $(EXTRA_collations_DEPENDENCIES) @rm -f collations$(EXEEXT) $(AM_V_CCLD)$(LINK) $(collations_OBJECTS) $(collations_LDADD) $(LIBS) convert$(EXEEXT): $(convert_OBJECTS) $(convert_DEPENDENCIES) $(EXTRA_convert_DEPENDENCIES) @rm -f convert$(EXEEXT) $(AM_V_CCLD)$(LINK) $(convert_OBJECTS) $(convert_LDADD) $(LIBS) corrupt$(EXEEXT): $(corrupt_OBJECTS) $(corrupt_DEPENDENCIES) $(EXTRA_corrupt_DEPENDENCIES) @rm -f corrupt$(EXEEXT) $(AM_V_CCLD)$(LINK) $(corrupt_OBJECTS) $(corrupt_LDADD) $(LIBS) dataread$(EXEEXT): $(dataread_OBJECTS) $(dataread_DEPENDENCIES) $(EXTRA_dataread_DEPENDENCIES) @rm -f dataread$(EXEEXT) $(AM_V_CCLD)$(LINK) $(dataread_OBJECTS) $(dataread_LDADD) $(LIBS) dynamic1$(EXEEXT): $(dynamic1_OBJECTS) $(dynamic1_DEPENDENCIES) $(EXTRA_dynamic1_DEPENDENCIES) @rm -f dynamic1$(EXEEXT) $(AM_V_CCLD)$(LINK) $(dynamic1_OBJECTS) $(dynamic1_LDADD) $(LIBS) iconv_fread$(EXEEXT): $(iconv_fread_OBJECTS) $(iconv_fread_DEPENDENCIES) $(EXTRA_iconv_fread_DEPENDENCIES) @rm -f iconv_fread$(EXEEXT) $(AM_V_CCLD)$(LINK) $(iconv_fread_OBJECTS) $(iconv_fread_LDADD) $(LIBS) nulls$(EXEEXT): $(nulls_OBJECTS) $(nulls_DEPENDENCIES) $(EXTRA_nulls_DEPENDENCIES) @rm -f nulls$(EXEEXT) $(AM_V_CCLD)$(LINK) $(nulls_OBJECTS) $(nulls_LDADD) $(LIBS) numeric$(EXEEXT): $(numeric_OBJECTS) $(numeric_DEPENDENCIES) $(EXTRA_numeric_DEPENDENCIES) @rm -f numeric$(EXEEXT) $(AM_V_CCLD)$(LINK) $(numeric_OBJECTS) $(numeric_LDADD) $(LIBS) readconf$(EXEEXT): $(readconf_OBJECTS) $(readconf_DEPENDENCIES) $(EXTRA_readconf_DEPENDENCIES) @rm -f readconf$(EXEEXT) $(AM_V_CCLD)$(LINK) $(readconf_OBJECTS) $(readconf_LDADD) $(LIBS) t0001$(EXEEXT): $(t0001_OBJECTS) $(t0001_DEPENDENCIES) $(EXTRA_t0001_DEPENDENCIES) @rm -f t0001$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0001_OBJECTS) $(t0001_LDADD) $(LIBS) t0002$(EXEEXT): $(t0002_OBJECTS) $(t0002_DEPENDENCIES) $(EXTRA_t0002_DEPENDENCIES) @rm -f t0002$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0002_OBJECTS) $(t0002_LDADD) $(LIBS) t0003$(EXEEXT): $(t0003_OBJECTS) $(t0003_DEPENDENCIES) $(EXTRA_t0003_DEPENDENCIES) @rm -f t0003$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0003_OBJECTS) $(t0003_LDADD) $(LIBS) t0004$(EXEEXT): $(t0004_OBJECTS) $(t0004_DEPENDENCIES) $(EXTRA_t0004_DEPENDENCIES) @rm -f t0004$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0004_OBJECTS) $(t0004_LDADD) $(LIBS) t0005$(EXEEXT): $(t0005_OBJECTS) $(t0005_DEPENDENCIES) $(EXTRA_t0005_DEPENDENCIES) @rm -f t0005$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0005_OBJECTS) $(t0005_LDADD) $(LIBS) t0006$(EXEEXT): $(t0006_OBJECTS) $(t0006_DEPENDENCIES) $(EXTRA_t0006_DEPENDENCIES) @rm -f t0006$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0006_OBJECTS) $(t0006_LDADD) $(LIBS) t0007$(EXEEXT): $(t0007_OBJECTS) $(t0007_DEPENDENCIES) $(EXTRA_t0007_DEPENDENCIES) @rm -f t0007$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0007_OBJECTS) $(t0007_LDADD) $(LIBS) t0008$(EXEEXT): $(t0008_OBJECTS) $(t0008_DEPENDENCIES) $(EXTRA_t0008_DEPENDENCIES) @rm -f t0008$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0008_OBJECTS) $(t0008_LDADD) $(LIBS) toodynamic$(EXEEXT): $(toodynamic_OBJECTS) $(toodynamic_DEPENDENCIES) $(EXTRA_toodynamic_DEPENDENCIES) @rm -f toodynamic$(EXEEXT) $(AM_V_CCLD)$(LINK) $(toodynamic_OBJECTS) $(toodynamic_LDADD) $(LIBS) utf8_1$(EXEEXT): $(utf8_1_OBJECTS) $(utf8_1_DEPENDENCIES) $(EXTRA_utf8_1_DEPENDENCIES) @rm -f utf8_1$(EXEEXT) $(AM_V_CCLD)$(LINK) $(utf8_1_OBJECTS) $(utf8_1_LDADD) $(LIBS) utf8_2$(EXEEXT): $(utf8_2_OBJECTS) $(utf8_2_DEPENDENCIES) $(EXTRA_utf8_2_DEPENDENCIES) @rm -f utf8_2$(EXEEXT) $(AM_V_CCLD)$(LINK) $(utf8_2_OBJECTS) $(utf8_2_LDADD) $(LIBS) utf8_3$(EXEEXT): $(utf8_3_OBJECTS) $(utf8_3_DEPENDENCIES) $(EXTRA_utf8_3_DEPENDENCIES) @rm -f utf8_3$(EXEEXT) $(AM_V_CCLD)$(LINK) $(utf8_3_OBJECTS) $(utf8_3_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/challenge.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/charconv.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/collations.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/common.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/convert.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/corrupt.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dataread.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dynamic1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/iconv_fread.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nulls.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/numeric.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readconf.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0001.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0002.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0003.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0004.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0005.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0006.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0007.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0008.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/toodynamic.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utf8.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utf8_1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utf8_2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utf8_3.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags # Recover from deleted '.trs' file; this should ensure that # "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create # both 'foo.log' and 'foo.trs'. Break the recipe in two subshells # to avoid problems with "make -n". .log.trs: rm -f $< $@ $(MAKE) $(AM_MAKEFLAGS) $< # Leading 'am--fnord' is there to ensure the list of targets does not # expand to empty, as could happen e.g. with make check TESTS=''. am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) am--force-recheck: @: $(TEST_SUITE_LOG): $(TEST_LOGS) @$(am__set_TESTS_bases); \ am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ redo_bases=`for i in $$bases; do \ am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ done`; \ if test -n "$$redo_bases"; then \ redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ if $(am__make_dryrun); then :; else \ rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ fi; \ fi; \ if test -n "$$am__remaking_logs"; then \ echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ "recursion detected" >&2; \ elif test -n "$$redo_logs"; then \ am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ fi; \ if $(am__make_dryrun); then :; else \ st=0; \ errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ for i in $$redo_bases; do \ test -f $$i.trs && test -r $$i.trs \ || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ test -f $$i.log && test -r $$i.log \ || { echo "$$errmsg $$i.log" >&2; st=1; }; \ done; \ test $$st -eq 0 || exit 1; \ fi @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ ws='[ ]'; \ results=`for b in $$bases; do echo $$b.trs; done`; \ test -n "$$results" || results=/dev/null; \ all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ if test `expr $$fail + $$xpass + $$error` -eq 0; then \ success=true; \ else \ success=false; \ fi; \ br='==================='; br=$$br$$br$$br$$br; \ result_count () \ { \ if test x"$$1" = x"--maybe-color"; then \ maybe_colorize=yes; \ elif test x"$$1" = x"--no-color"; then \ maybe_colorize=no; \ else \ echo "$@: invalid 'result_count' usage" >&2; exit 4; \ fi; \ shift; \ desc=$$1 count=$$2; \ if test $$maybe_colorize = yes && test $$count -gt 0; then \ color_start=$$3 color_end=$$std; \ else \ color_start= color_end=; \ fi; \ echo "$${color_start}# $$desc $$count$${color_end}"; \ }; \ create_testsuite_report () \ { \ result_count $$1 "TOTAL:" $$all "$$brg"; \ result_count $$1 "PASS: " $$pass "$$grn"; \ result_count $$1 "SKIP: " $$skip "$$blu"; \ result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ result_count $$1 "FAIL: " $$fail "$$red"; \ result_count $$1 "XPASS:" $$xpass "$$red"; \ result_count $$1 "ERROR:" $$error "$$mgn"; \ }; \ { \ echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ $(am__rst_title); \ create_testsuite_report --no-color; \ echo; \ echo ".. contents:: :depth: 2"; \ echo; \ for b in $$bases; do echo $$b; done \ | $(am__create_global_log); \ } >$(TEST_SUITE_LOG).tmp || exit 1; \ mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ if $$success; then \ col="$$grn"; \ else \ col="$$red"; \ test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ fi; \ echo "$${col}$$br$${std}"; \ echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ echo "$${col}$$br$${std}"; \ create_testsuite_report --maybe-color; \ echo "$$col$$br$$std"; \ if $$success; then :; else \ echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ if test -n "$(PACKAGE_BUGREPORT)"; then \ echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ fi; \ echo "$$col$$br$$std"; \ fi; \ $$success || exit 1 check-TESTS: @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ log_list=`for i in $$bases; do echo $$i.log; done`; \ trs_list=`for i in $$bases; do echo $$i.trs; done`; \ log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ exit $$?; recheck: all $(check_PROGRAMS) @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ bases=`for i in $$bases; do echo $$i; done \ | $(am__list_recheck_tests)` || exit 1; \ log_list=`for i in $$bases; do echo $$i.log; done`; \ log_list=`echo $$log_list`; \ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ am__force_recheck=am--force-recheck \ TEST_LOGS="$$log_list"; \ exit $$? t0001.log: t0001$(EXEEXT) @p='t0001$(EXEEXT)'; \ b='t0001'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0002.log: t0002$(EXEEXT) @p='t0002$(EXEEXT)'; \ b='t0002'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0003.log: t0003$(EXEEXT) @p='t0003$(EXEEXT)'; \ b='t0003'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0004.log: t0004$(EXEEXT) @p='t0004$(EXEEXT)'; \ b='t0004'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0005.log: t0005$(EXEEXT) @p='t0005$(EXEEXT)'; \ b='t0005'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0006.log: t0006$(EXEEXT) @p='t0006$(EXEEXT)'; \ b='t0006'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0007.log: t0007$(EXEEXT) @p='t0007$(EXEEXT)'; \ b='t0007'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0008.log: t0008$(EXEEXT) @p='t0008$(EXEEXT)'; \ b='t0008'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) dynamic1.log: dynamic1$(EXEEXT) @p='dynamic1$(EXEEXT)'; \ b='dynamic1'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) convert.log: convert$(EXEEXT) @p='convert$(EXEEXT)'; \ b='convert'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) dataread.log: dataread$(EXEEXT) @p='dataread$(EXEEXT)'; \ b='dataread'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) utf8_1.log: utf8_1$(EXEEXT) @p='utf8_1$(EXEEXT)'; \ b='utf8_1'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) utf8_2.log: utf8_2$(EXEEXT) @p='utf8_2$(EXEEXT)'; \ b='utf8_2'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) utf8_3.log: utf8_3$(EXEEXT) @p='utf8_3$(EXEEXT)'; \ b='utf8_3'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) numeric.log: numeric$(EXEEXT) @p='numeric$(EXEEXT)'; \ b='numeric'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) iconv_fread.log: iconv_fread$(EXEEXT) @p='iconv_fread$(EXEEXT)'; \ b='iconv_fread'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) toodynamic.log: toodynamic$(EXEEXT) @p='toodynamic$(EXEEXT)'; \ b='toodynamic'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) readconf.log: readconf$(EXEEXT) @p='readconf$(EXEEXT)'; \ b='readconf'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) charconv.log: charconv$(EXEEXT) @p='charconv$(EXEEXT)'; \ b='charconv'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) nulls.log: nulls$(EXEEXT) @p='nulls$(EXEEXT)'; \ b='nulls'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) corrupt.log: corrupt$(EXEEXT) @p='corrupt$(EXEEXT)'; \ b='corrupt'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) challenge.log: challenge$(EXEEXT) @p='challenge$(EXEEXT)'; \ b='challenge'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) .test.log: @p='$<'; \ $(am__set_b); \ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) @am__EXEEXT_TRUE@.test$(EXEEXT).log: @am__EXEEXT_TRUE@ @p='$<'; \ @am__EXEEXT_TRUE@ $(am__set_b); \ @am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ @am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ @am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ @am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-am all-am: Makefile $(PROGRAMS) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ clean-noinstPROGRAMS mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: check-am install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am clean \ clean-checkPROGRAMS clean-generic clean-libtool \ clean-noinstPROGRAMS cscopelist-am ctags ctags-am distclean \ distclean-compile distclean-generic 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-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 recheck tags tags-am uninstall \ uninstall-am .PRECIOUS: Makefile # 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: freetds-1.00.82/src/tds/unittests/challenge.c100644 025423 025423 00000011221 12717145107 0014541/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2011 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /* * Purpose: test challenge code. */ #include "common.h" #include #include "md4.h" #include "md5.h" #include "hmac_md5.h" #include "des.h" static char * bin2ascii(char *dest, const void *data, size_t len) { char *s = dest; const unsigned char *src = (const unsigned char *) data; for (; len > 0; --len, s += 2) sprintf(s, "%02x", *src++); *s = 0; return dest; } static void md4(const char *src, const char *out) { MD4_CTX ctx; unsigned char digest[16]; char s_digest[34]; assert(strlen(out) == 32); MD4Init(&ctx); if (strlen(src) > 12) { MD4Update(&ctx, (const unsigned char *) src, 5); MD4Update(&ctx, (const unsigned char *) src+5, strlen(src) - 5); } else { MD4Update(&ctx, (const unsigned char *) src, strlen(src)); } MD4Final(&ctx, digest); if (strcasecmp(bin2ascii(s_digest, digest, 16), out) != 0) { fprintf(stderr, "Wrong md4(%s) -> %s expected %s\n", src, s_digest, out); exit(1); } } static void md4tests(void) { md4("", "31d6cfe0d16ae931b73c59d7e0c089c0"); md4("a", "bde52cb31de33e46245e05fbdbd6fb24"); md4("abc", "a448017aaf21d8525fc10ae87aa6729d"); md4("message digest", "d9130a8164549fe818874806e1c7014b"); md4("abcdefghijklmnopqrstuvwxyz", "d79e1c308aa5bbcdeea8ed63df412da9"); md4("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "043f8582f241db351ce627e153e7f0e4"); md4("12345678901234567890123456789012345678901234567890123456789012345678901234567890", "e33b4ddc9c38f2199c3e7b164fcc0536"); } static void md5(const char *src, const char *out) { MD5_CTX ctx; unsigned char digest[16]; char s_digest[34]; assert(strlen(out) == 32); MD5Init(&ctx); if (strlen(src) > 12) { MD5Update(&ctx, (const unsigned char *) src, 5); MD5Update(&ctx, (const unsigned char *) src+5, strlen(src) - 5); } else { MD5Update(&ctx, (const unsigned char *) src, strlen(src)); } MD5Final(&ctx, digest); if (strcasecmp(bin2ascii(s_digest, digest, 16), out) != 0) { fprintf(stderr, "Wrong md5(%s) -> %s expected %s\n", src, s_digest, out); exit(1); } } static void md5tests(void) { md5("", "d41d8cd98f00b204e9800998ecf8427e"); md5("The quick brown fox jumps over the lazy dog", "9e107d9d372bb6826bd81d3542a419d6"); md5("The quick brown fox jumps over the lazy dog.", "e4d909c290d0fb1ca068ffaddf22cbd0"); } static const char *hmac5_key = NULL; static void hmac5(const char *src, const char *out) { unsigned char digest[16]; char s_digest[34]; assert(strlen(out) == 32 && hmac5_key); hmac_md5((const unsigned char*) hmac5_key, (const unsigned char*) src, strlen(src), digest); if (strcasecmp(bin2ascii(s_digest, digest, 16), out) != 0) { fprintf(stderr, "Wrong hman md5(%s) -> %s expected %s\n", src, s_digest, out); exit(1); } } static void hmac5tests(void) { hmac5_key = "01234567890123456"; hmac5("", "c26c57d7ff1236db11d7419a490ad84d"); hmac5("message digest", "e4f89edbda3d3b6b7328a0a90f87ece8"); hmac5("abcdefghijklmnopqrstuvwxyz", "2c4eac474ec340df63ae93b8ffc33571"); } static void des(const char *src, const char *out) { static const des_cblock key = { 0x4B, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25 }; DES_KEY ks; unsigned char digest[128]; char s_digest[256]; size_t out_len; memset(digest, 0, sizeof(digest)); tds_des_set_key(&ks, key, sizeof(key)); tds_des_ecb_encrypt(src, strlen(src), &ks, digest); out_len = strlen(src) & ~7u; if (strcasecmp(bin2ascii(s_digest, digest, out_len), out) != 0) { fprintf(stderr, "Wrong des(%s) -> %s expected %s\n", src, s_digest, out); exit(1); } } static void destests(void) { des("", ""); des("The quick brown fox jumps over the lazy dog", "51551eab3ebab959553caaed64a3dd9c49f595a630c45cb7317332f8ade70308c4e97aeabbdc7f19"); des("test des encryption", "7ced9849bed3f7efc1686c89759bafa8"); } int main(void) { md4tests(); md5tests(); hmac5tests(); destests(); printf("All tests passed\n"); return 0; } freetds-1.00.82/src/tds/unittests/charconv.c100644 025423 025423 00000016433 12717145107 0014434/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2014 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /* * This test test tds_convert_stream which is supposed to be the main * character conversion routine * * Check that error are reported to error handler if found and tds * is not NULL. * * Check that conversions works with NULL tds. * * Check all types of errors (EILSEQ, EINVAL, E2BIG). * * Check that error are capture in middle and on end of stream. */ #include "common.h" #include #include #if HAVE_UNISTD_H #undef getpid #include #endif /* HAVE_UNISTD_H */ #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #include /* test tds_iconv_fread */ static char buf[4096+80]; static char buf_out[4096+80]; static int last_errno = 0; static TDSRET convert(TDSSOCKET *tds, TDSICONV *conv, TDS_ICONV_DIRECTION direction, const char *from, size_t from_len, char *dest, size_t *dest_len) { /* copy to make valgrind test fail on memory problems */ char *in = tds_new(char, from_len); char *out = tds_new(char, *dest_len); int res; TDSSTATICINSTREAM r; TDSSTATICOUTSTREAM w; assert(in && out); memcpy(in, from, from_len); tds_staticin_stream_init(&r, in, from_len); tds_staticout_stream_init(&w, out, *dest_len); last_errno = 0; res = tds_convert_stream(tds, conv, direction, &r.stream, &w.stream); last_errno = errno; memcpy(dest, out, *dest_len - w.stream.buf_len); *dest_len = *dest_len - w.stream.buf_len; free(in); free(out); return res; } enum Odd { ODD_NONE = 0, ODD_NORMAL, ODD_INVALID, ODD_INCOMPLETE, ODD_NUM_VALUES }; static const char *odd_names[] = { "None", "Normal", "Invalid", "Incomplete" }; static int add_odd(char *buf, int *pos, enum Odd type) { const unsigned char x = 0xa0; switch (type) { case ODD_NONE: return 0; case ODD_NORMAL: buf[*pos] = 0xC0 + (x >> 6); ++*pos; buf[*pos] = 0x80 + (x & 0x3f); ++*pos; return 0; case ODD_INVALID: buf[*pos] = 0xff; ++*pos; return EILSEQ; case ODD_INCOMPLETE: buf[*pos] = 0xC2; ++*pos; return EINVAL; default: assert(0); } return 0; } static void add_odd2(char *buf, int *pos, enum Odd type) { const unsigned char x = 0xa0; switch (type) { case ODD_NONE: return; case ODD_NORMAL: buf[*pos] = x; ++*pos; break; case ODD_INVALID: break; case ODD_INCOMPLETE: break; default: assert(0); } } static int captured_errno = 0; static int err_handler(const TDSCONTEXT * tds_ctx, TDSSOCKET * tds, TDSMESSAGE * msg) { int old_err = captured_errno; if (msg->msgno == TDSEICONVAVAIL) { captured_errno = EINVAL; } else if (strstr(msg->message, "could not be converted")) { captured_errno = EILSEQ; } else if (msg->msgno == TDSEICONVIU) { captured_errno = E2BIG; } else { fprintf(stderr, "Unexpected error: %s\n", msg->message); exit(1); } assert(old_err == 0 || old_err == captured_errno); return TDS_INT_CANCEL; } static TDSICONV * conv = NULL; static int pos_type = 0; static void test(TDSSOCKET *tds, enum Odd odd_type) { int i, l; captured_errno = 0; /* do not complete incomplete */ if (odd_type == ODD_INCOMPLETE && pos_type > 0) return; printf("test pos %d type %s\n", pos_type, odd_names[odd_type]); for (i = 0; i < 4096+20; ++i) { size_t out_len; TDSRET res; int err; if (i == 34) i = 4096-20; l = i; memset(buf, 'a', sizeof(buf)); switch (pos_type) { case 0: /* end */ err = add_odd(buf, &l, odd_type); break; case 1: /* start */ l = 0; err = add_odd(buf, &l, odd_type); if (l > i) continue; l = i; break; case 2: /* middle */ err = add_odd(buf, &l, odd_type); l = 4096+30; break; default: exit(1); return; } /* convert it */ out_len = sizeof(buf_out); res = convert(tds, conv, to_server, buf, l, buf_out, &out_len); printf("i %d res %d out_len %u errno %d captured_errno %d\n", i, (int) res, (unsigned int) out_len, last_errno, captured_errno); /* test */ l = i; memset(buf, 'a', sizeof(buf)); switch (pos_type) { case 0: /* end */ add_odd2(buf, &l, odd_type); break; case 1: /* start */ l = 0; add_odd2(buf, &l, odd_type); l = i; if (odd_type == ODD_NORMAL) l = i-1; if (odd_type == ODD_INVALID) l = 0; break; case 2: /* middle */ add_odd2(buf, &l, odd_type); l = 4096+30; if (odd_type == ODD_NORMAL) --l; if (odd_type == ODD_INVALID) l = i; break; } if (err) { assert(last_errno == err); assert(TDS_FAILED(res)); assert(!tds || captured_errno == last_errno); } else { assert(TDS_SUCCEED(res)); assert(captured_errno == 0); } if (out_len != l) { fprintf(stderr, "out %u bytes expected %d\n", (unsigned int) out_len, l); exit(1); } assert(memcmp(buf_out, buf, l) == 0); } } static void big_test(TDSSOCKET *tds) { int i, l; const int limit = 1025; captured_errno = 0; printf("E2BIG test\n"); for (i = 0; i < 4096+20; ++i) { size_t out_len; TDSRET res; int err; if (i == 32) i = 490; l = i; memset(buf, 0xa0, sizeof(buf)); /* convert it */ out_len = limit; res = convert(tds, conv, to_client, buf, l, buf_out, &out_len); printf("i %d res %d out_len %u errno %d captured_errno %d\n", i, (int) res, (unsigned int) out_len, last_errno, captured_errno); err = l * 2 > limit ? E2BIG : 0; if (err) { assert(last_errno == err); assert(TDS_FAILED(res)); assert(!tds || captured_errno == last_errno); } else { assert(TDS_SUCCEED(res)); assert(captured_errno == 0); } if (out_len != i*2 && i*2 <= limit) { fprintf(stderr, "out %u bytes expected %d\n", (unsigned int) out_len, i*2); exit(1); } } } int main(int argc, char **argv) { int i; TDSCONTEXT *ctx = tds_alloc_context(NULL); TDSSOCKET *tds = tds_alloc_socket(ctx, 512); const char *tdsdump; setbuf(stdout, NULL); setbuf(stderr, NULL); ctx->err_handler = err_handler; /* allow dumps, we don't have a connection here */ tdsdump = getenv("TDSDUMP"); if (tdsdump) tdsdump_open(tdsdump); if (!ctx || !tds) { fprintf(stderr, "Error creating socket!\n"); return 1; } tds_iconv_open(tds->conn, "ISO-8859-1", 0); conv = tds_iconv_get(tds->conn, "UTF-8", "ISO-8859-1"); if (conv == NULL) { fprintf(stderr, "Error creating conversion, giving up!\n"); return 1; } for (i = 0; i < ODD_NUM_VALUES*3*2; ++i) { int n = i; enum Odd odd_type = (enum Odd) (n % ODD_NUM_VALUES); n /= ODD_NUM_VALUES; pos_type = n % 3; n /= 3; test(n ? tds : NULL, odd_type); } /* not try E2BIG error */ big_test(NULL); big_test(tds); tds_free_socket(tds); tds_free_context(ctx); return 0; } freetds-1.00.82/src/tds/unittests/collations.c100644 025423 025423 00000016115 12522201763 0014770/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2015 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #undef NDEBUG #include "common.h" #include #include "md5.h" #undef NDEBUG #include #include #if HAVE_UNISTD_H #undef getpid #include #elif defined(_WIN32) # include # undef isatty # define isatty(fd) _isatty(fd) #endif /* HAVE_UNISTD_H */ static TDSSOCKET *tds; static void get_coll_md5(const char *name, char *digest) { MD5_CTX ctx; char *p = NULL, *sql = NULL; int ret; TDSRET rc; TDS_INT result_type; int done_flags, i; unsigned char dig[16]; ret = asprintf(&sql, "convert(nvarchar(1024), bin) collate %s", name); assert(ret >= 0); ret = asprintf(&p, "convert(varchar(4096), %s)", sql); assert(ret >= 0); free(sql); sql = NULL; ret = asprintf(&sql, "select convert(varbinary(8000), %s) from #all_chars order by id", p); assert(ret >= 0); free(p); p = NULL; rc = tds_submit_query(tds, sql); assert(rc == TDS_SUCCESS); free(sql); sql = NULL; MD5Init(&ctx); while ((rc = tds_process_tokens(tds, &result_type, &done_flags, TDS_RETURN_ROW)) == TDS_SUCCESS) { TDSCOLUMN *curcol; assert(result_type == TDS_ROW_RESULT); curcol = tds->current_results->columns[0]; assert(!is_blob_col(curcol)); assert(curcol->on_server.column_type == XSYBVARBINARY); MD5Update(&ctx, curcol->column_data, curcol->column_cur_size); } assert(rc == TDS_NO_MORE_RESULTS); memset(dig, 0, sizeof(dig)); MD5Final(&ctx, dig); for (i = 0; i < 16; ++i) sprintf(digest + i * 2, "%02x", dig[i]); } static void get_encoding_coll(TDS71_COLLATION *coll, char *digest, char *cp, const char *name) { int rc; int done_flags; TDS_INT result_type; char sql[512]; static TDS71_COLLATION old_coll = { 0, 0, 0}; static char old_digest[33]; sprintf(sql, "SELECT CAST(CAST('a' AS NVARCHAR(10)) COLLATE %s AS VARCHAR(10)) COLLATE %s", name, name); /* do a select and check all results */ rc = tds_submit_query(tds, sql); assert(rc == TDS_SUCCESS); assert(tds_process_tokens(tds, &result_type, NULL, TDS_TOKEN_RESULTS) == TDS_SUCCESS); if (result_type == TDS_DONE_RESULT) return; assert(result_type == TDS_ROWFMT_RESULT); assert(tds_process_tokens(tds, &result_type, NULL, TDS_TOKEN_RESULTS) == TDS_SUCCESS); assert(result_type == TDS_ROW_RESULT); while ((rc = tds_process_tokens(tds, &result_type, NULL, TDS_STOPAT_ROWFMT|TDS_STOPAT_DONE|TDS_RETURN_ROW|TDS_RETURN_COMPUTE)) == TDS_SUCCESS) { TDSCOLUMN *curcol; TDS_UCHAR *c; if (result_type != TDS_ROW_RESULT) break; curcol = tds->current_results->columns[0]; strcpy(cp, curcol->char_conv->to.charset.name); c = curcol->column_collation; coll->locale_id = c[0] + 256 * c[1]; coll->flags = c[2] + 256 * c[3]; coll->charset_id = c[4]; } if (rc != TDS_SUCCESS || result_type == TDS_ROW_RESULT || result_type == TDS_COMPUTE_RESULT) { fprintf(stderr, "tds_process_tokens() unexpected return\n"); exit(1); } while ((rc = tds_process_tokens(tds, &result_type, &done_flags, TDS_TOKEN_RESULTS)) == TDS_SUCCESS) { switch (result_type) { case TDS_NO_MORE_RESULTS: return; case TDS_DONE_RESULT: case TDS_DONEPROC_RESULT: case TDS_DONEINPROC_RESULT: if (!(done_flags & TDS_DONE_ERROR)) break; default: fprintf(stderr, "tds_proces_tokens() unexpected result_type\n"); exit(1); break; } } if (old_coll.locale_id && old_coll.locale_id == coll->locale_id && old_coll.charset_id == coll->charset_id) { memcpy(digest, old_digest, 33); } else { get_coll_md5(name, digest); } memcpy(old_digest, digest, 33); memcpy(&old_coll, coll, sizeof(*coll)); } static void test_column_encoding(void) { FILE *f = fopen("collations.txt", "r"); char line[1024]; assert(f); while (fgets(line, sizeof(line), f)) { TDS71_COLLATION coll; char cp[128], digest[33]; char *s = strtok(line, " \n"); if (!s[0]) continue; memset(&coll, 0, sizeof(coll)); cp[0] = 0; digest[0] = 0; get_encoding_coll(&coll, digest, cp, s); printf("%s %d %d %d %s %s\n", s, coll.locale_id, coll.flags, coll.charset_id, cp, digest); } fclose(f); } static void add_couple(unsigned n) { enum { CHUNK = 512 }; static char buf[CHUNK * 4+1]; static int cnt = 0; static int id = 0; char *sql = NULL; int ret; sprintf(buf + cnt * 4, "%02x%02x", n & 0xff, (n >> 8) & 0xff); /* time to insert the command into database ? */ if (++cnt != CHUNK) return; cnt = 0; ++id; ret = asprintf(&sql, "insert into #all_chars values(%d, convert(varbinary(2048), 0x%s))", id, buf); assert(ret >= 0); if (isatty(fileno(stdout))) { printf("\rInserting: %d", id); fflush(stdout); } ret = run_query(tds, sql); assert(ret == TDS_SUCCESS); free(sql); } static void add_plane0(void) { unsigned n; for (n = 0; n < 65536; ++n) add_couple(n); } static void add_couples(void) { unsigned n; for (n = 0; n <= 0xfffff; ++n) { add_couple( (n >> 10) + 0xd800 ); add_couple( (n & 0x3ff) + 0xdc00 ); } } static void prepare_all_chars(void) { int ret; ret = run_query(tds, "CREATE TABLE #all_chars(id int, bin varbinary(2048))"); assert(ret == TDS_SUCCESS); add_plane0(); add_couples(); printf("\n"); } static void extract_collations(void) { TDS_INT result_type; int done_flags; TDSRET rc; FILE *f; f = fopen("collations.txt", "w"); assert(f); rc = tds_submit_query(tds, "select name from ::fn_helpcollations() order by name"); assert(rc == TDS_SUCCESS); while ((rc = tds_process_tokens(tds, &result_type, &done_flags, TDS_RETURN_ROW)) == TDS_SUCCESS) { TDSCOLUMN *curcol; int len; assert(result_type == TDS_ROW_RESULT); curcol = tds->current_results->columns[0]; assert(!is_blob_col(curcol)); assert(curcol->column_type == SYBVARCHAR); len = curcol->column_cur_size; fprintf(f, "%*.*s\n", len, len, curcol->column_data); } assert(rc == TDS_NO_MORE_RESULTS); fclose(f); } int main(int argc, char **argv) { TDSLOGIN *login; int ret; int verbose = 0; /* use UTF-8 as our coding */ strcpy(CHARSET, "UTF-8"); ret = try_tds_login(&login, &tds, __FILE__, verbose); if (ret != TDS_SUCCESS) { fprintf(stderr, "try_tds_login() failed\n"); return 1; } if (IS_TDS71_PLUS(tds->conn)) { printf("Preparing table with all characters\n"); prepare_all_chars(); printf("Extracting collation list\n"); extract_collations(); printf("Testing encodings\n"); test_column_encoding(); } try_tds_logout(login, tds, verbose); return 0; } freetds-1.00.82/src/tds/unittests/common.c100644 025423 025423 00000007353 12717145107 0014122#define TDS_DONT_DEFINE_DEFAULT_FUNCTIONS #include "common.h" char USER[512]; char SERVER[512]; char PASSWORD[512]; char DATABASE[512]; /* TODO use another default ?? */ char CHARSET[512] = "ISO-8859-1"; int read_login_info(void); int read_login_info(void) { FILE *in = NULL; char line[512]; char *s1, *s2; s1 = getenv("TDSPWDFILE"); if (s1 && s1[0]) in = fopen(s1, "r"); if (!in) in = fopen("../../../PWD", "r"); if (!in) { fprintf(stderr, "Can not open PWD file\n\n"); return TDS_FAIL; } while (fgets(line, 512, in)) { s1 = strtok(line, "="); s2 = strtok(NULL, "\n"); if (!s1 || !s2) { continue; } if (!strcmp(s1, "UID")) { strcpy(USER, s2); } else if (!strcmp(s1, "SRV")) { strcpy(SERVER, s2); } else if (!strcmp(s1, "PWD")) { strcpy(PASSWORD, s2); } else if (!strcmp(s1, "DB")) { strcpy(DATABASE, s2); } } fclose(in); return TDS_SUCCESS; } TDSCONTEXT *test_context = NULL; int try_tds_login(TDSLOGIN ** login, TDSSOCKET ** tds, const char *appname, int verbose) { TDSLOGIN *connection; if (verbose) { fprintf(stdout, "Entered tds_try_login()\n"); } if (!login) { fprintf(stderr, "Invalid TDSLOGIN**\n"); return TDS_FAIL; } if (!tds) { fprintf(stderr, "Invalid TDSSOCKET**\n"); return TDS_FAIL; } if (verbose) { fprintf(stdout, "Trying read_login_info()\n"); } read_login_info(); if (verbose) { fprintf(stdout, "Setting login parameters\n"); } *login = tds_alloc_login(1); if (!*login) { fprintf(stderr, "tds_alloc_login() failed.\n"); return TDS_FAIL; } if (!tds_set_passwd(*login, PASSWORD) || !tds_set_user(*login, USER) || !tds_set_app(*login, appname) || !tds_set_host(*login, "myhost") || !tds_set_library(*login, "TDS-Library") || !tds_set_server(*login, SERVER) || !tds_set_client_charset(*login, CHARSET) || !tds_set_language(*login, "us_english")) { fprintf(stderr, "tds_alloc_login() failed.\n"); return TDS_FAIL; } if (verbose) { fprintf(stdout, "Connecting to database\n"); } test_context = tds_alloc_context(NULL); *tds = tds_alloc_socket(test_context, 512); tds_set_parent(*tds, NULL); connection = tds_read_config_info(*tds, *login, test_context->locale); if (!connection || tds_connect_and_login(*tds, connection) != TDS_SUCCESS) { if (connection) { tds_free_socket(*tds); *tds = NULL; tds_free_login(connection); } fprintf(stderr, "tds_connect_and_login() failed\n"); return TDS_FAIL; } tds_free_login(connection); return TDS_SUCCESS; } /* Note that this always suceeds */ int try_tds_logout(TDSLOGIN * login, TDSSOCKET * tds, int verbose) { if (verbose) { fprintf(stdout, "Entered tds_try_logout()\n"); } tds_close_socket(tds); tds_free_socket(tds); tds_free_login(login); tds_free_context(test_context); test_context = NULL; return TDS_SUCCESS; } /* Run query for which there should be no return results */ int run_query(TDSSOCKET * tds, const char *query) { int rc; int result_type; rc = tds_submit_query(tds, query); if (rc != TDS_SUCCESS) { fprintf(stderr, "tds_submit_query() failed for query '%s'\n", query); return TDS_FAIL; } while ((rc = tds_process_tokens(tds, &result_type, NULL, TDS_TOKEN_RESULTS)) == TDS_SUCCESS) { switch (result_type) { case TDS_DONE_RESULT: case TDS_DONEPROC_RESULT: case TDS_DONEINPROC_RESULT: /* ignore possible spurious result (TDS7+ send it) */ case TDS_STATUS_RESULT: break; default: fprintf(stderr, "Error: query should not return results\n"); return TDS_FAIL; } } if (rc == TDS_FAIL) { fprintf(stderr, "tds_process_tokens() returned TDS_FAIL for '%s'\n", query); return TDS_FAIL; } else if (rc != TDS_NO_MORE_RESULTS) { fprintf(stderr, "tds_process_tokens() unexpected return\n"); return TDS_FAIL; } return TDS_SUCCESS; } freetds-1.00.82/src/tds/unittests/common.h100644 025423 025423 00000001512 12717145107 0014116#ifndef COMMON_h #define COMMON_h #undef NDEBUG #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #define FREETDS_SRCDIR FREETDS_TOPDIR "/src/tds/unittests" extern char PASSWORD[512]; extern char USER[512]; extern char SERVER[512]; extern char DATABASE[512]; extern char CHARSET[512]; extern TDSCONTEXT *test_context; int try_tds_login(TDSLOGIN ** login, TDSSOCKET ** tds, const char *appname, int verbose); int try_tds_logout(TDSLOGIN * login, TDSSOCKET * tds, int verbose); int run_query(TDSSOCKET * tds, const char *query); extern int utf8_max_len; int get_unichar(const char **psrc); char *to_utf8(const char *src, char *dest); #endif freetds-1.00.82/src/tds/unittests/convert.c100644 025423 025423 00000023511 12717145107 0014304/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /* * Purpose: test conversions. If they work, test their performance. * To test performance, call this program with an iteration count (10 is probably fine). * The following shows performance converting to varchar: * $ make convert && ./convert 1 |grep iterations |grep 'varchar\.' |sort -n */ #include "common.h" #include #include #include "replacements.h" #include static int g_result = 0; static TDSCONTEXT *ctx; static void free_convert(int type, CONV_RESULT *cr) { switch (type) { case SYBCHAR: case SYBVARCHAR: case SYBTEXT: case XSYBCHAR: case XSYBVARCHAR: case SYBBINARY: case SYBVARBINARY: case SYBIMAGE: case XSYBBINARY: case XSYBVARBINARY: case SYBLONGBINARY: free(cr->c); break; } } int main(int argc, char **argv) { int srctype; int desttype; /* some default inputs */ static const int bit_input = 1; /* timing variables to compute performance */ struct timeval start, end; double starttime, endtime; int i, j, iterations = 0, result; TDS_CHAR *src = NULL; TDS_UINT srclen; CONV_RESULT cr; TDS_NUMERIC numeric; TDS_MONEY money; TDS_MONEY4 money4; TDS_DATETIME datetime; TDS_DATETIME4 datetime4; TDS_DATETIMEALL dta; TDS_DATE date; TDS_TIME time; TDS_BIGDATETIME bigdatetime; TDS_BIGTIME bigtime; TDS_TINYINT tds_tinyint; TDS_SMALLINT tds_smallint; TDS_INT tds_int; TDS_INT8 tds_int8; TDS_USMALLINT tds_usmallint; TDS_UINT tds_uint; TDS_UINT8 tds_uint8; TDS_REAL tds_real; TDS_FLOAT tds_float; TDS_UNIQUE tds_unique; if (argc > 1) { iterations = atoi(argv[1]); printf("Computing %d iterations\n", iterations); } setbuf(stdout, NULL); setbuf(stderr, NULL); ctx = tds_alloc_context(NULL); assert(ctx); if (ctx->locale && !ctx->locale->date_fmt) { /* set default in case there's no locale file */ ctx->locale->date_fmt = strdup(STD_DATETIME_FMT); } /* * Test every possible conversion pair */ for (i = 0; i < 0x10000; i++) { srctype = i >> 8; desttype = i & 0xff; srctype = (srctype + SYBCHAR) & 0xff; if (!tds_willconvert(srctype, desttype)) { /* pass a CONV_RESULT as input for make sure size and alignment is enough * for all types */ CONV_RESULT src; memset(&src, 0, sizeof(src)); result = tds_convert(ctx, srctype, (const TDS_CHAR *) &src, 4, desttype, &cr); if (result >= 0) free_convert(desttype, &cr); if (result != TDS_CONVERT_NOAVAIL) { printf("NOT EXPECTED: converted %d (%s, %d bytes) : %d (%s, %d bytes).\n", srctype, tds_prtype(srctype), srclen, desttype, tds_prtype(desttype), result); exit(1); } continue; /* don't attempt nonconvertible types */ } if (srctype == desttype) continue; /* don't attempt same types */ /* valid types should have a name ! */ assert(tds_prtype(srctype)[0] != 0); assert(tds_prtype(desttype)[0] != 0); cr.n.precision = 8; cr.n.scale = 2; switch (srctype) { case SYBCHAR: case SYBVARCHAR: case SYBTEXT: case SYBBINARY: case SYBVARBINARY: case SYBIMAGE: case SYBLONGBINARY: case XSYBBINARY: case XSYBVARBINARY: case XSYBCHAR: case XSYBVARCHAR: switch (desttype) { case SYBCHAR: case SYBVARCHAR: case SYBTEXT: case SYBDATETIME: case SYBDATETIME4: src = "Jan 1, 1999"; break; case SYBMSDATE: case SYBMSDATETIME2: case SYBMSDATETIMEOFFSET: case SYBDATE: src = "2012-11-27"; break; case SYBMSTIME: case SYBTIME: src = "15:27:12"; break; case SYB5BIGTIME: src = "15:27:12.327862"; break; case SYB5BIGDATETIME: src = "2015-09-12 21:48:12.638161"; break; case SYBBINARY: case SYBIMAGE: src = "0xbeef"; break; case SYBINT1: case SYBINT2: case SYBINT4: case SYBINT8: case SYBUINT1: case SYBUINT2: case SYBUINT4: case SYBUINT8: src = "255"; break; case SYBFLT8: case SYBREAL: case SYBNUMERIC: case SYBDECIMAL: case SYBMONEY: case SYBMONEY4: src = "1999.25"; cr.n.precision = 8; cr.n.scale = 2; break; case SYBUNIQUE: src = "A8C60F70-5BD4-3E02-B769-7CCCCA585DCC"; break; case SYBBIT: default: src = "1"; break; } assert(src); srclen = strlen(src); break; case SYBINT1: case SYBUINT1: src = (char *) &tds_tinyint; srclen = sizeof(tds_tinyint); break; case SYBINT2: src = (char *) &tds_smallint; srclen = sizeof(tds_smallint); break; case SYBINT4: src = (char *) &tds_int; srclen = sizeof(tds_int); break; case SYBINT8: src = (char *) &tds_int8; srclen = sizeof(tds_int8); break; case SYBUINT2: src = (char *) &tds_usmallint; srclen = sizeof(tds_usmallint); break; case SYBUINT4: src = (char *) &tds_uint; srclen = sizeof(tds_uint); break; case SYBUINT8: src = (char *) &tds_uint8; srclen = sizeof(tds_uint8); break; case SYBFLT8: tds_float = 3.14159; src = (char *) &tds_float; srclen = sizeof(tds_float); break; case SYBREAL: tds_real = (TDS_REAL) 3.14159; src = (char *) &tds_real; srclen = sizeof(tds_real); break; case SYBNUMERIC: case SYBDECIMAL: src = (char *) &numeric; srclen = sizeof(numeric); break; case SYBMONEY: src = (char *) &money; srclen = sizeof(money); break; case SYBMONEY4: src = (char *) &money4; srclen = sizeof(money4); break; case SYBBIT: case SYBBITN: src = (char *) &bit_input; srclen = sizeof(bit_input); break; case SYBDATETIME: src = (char *) &datetime; srclen = sizeof(datetime); break; case SYBDATETIME4: src = (char *) &datetime4; srclen = sizeof(datetime4); break; case SYBDATE: src = (char *) &date; srclen = sizeof(date); break; case SYBTIME: src = (char *) &time; srclen = sizeof(time); break; case SYB5BIGTIME: src = (char *) &bigtime; srclen = sizeof(bigtime); break; case SYB5BIGDATETIME: src = (char *) &bigdatetime; srclen = sizeof(bigdatetime); break; case SYBUNIQUE: src = (char *) &tds_unique; srclen = sizeof(tds_unique); break; case SYBMSTIME: case SYBMSDATE: case SYBMSDATETIME2: case SYBMSDATETIMEOFFSET: src = (char *) &dta; srclen = sizeof(dta); break; /***** not defined yet case SYBBOUNDARY: case SYBSENSITIVITY: fprintf (stderr, "type %d not supported\n", srctype ); continue; break; *****/ default: fprintf(stderr, "no such type %d (%s)\n", srctype, tds_prtype(srctype)); return -1; } /* * Now at last do the conversion */ result = tds_convert(ctx, srctype, src, srclen, desttype, &cr); if (result >= 0) free_convert(desttype, &cr); if (result < 0) { if (result == TDS_CONVERT_NOAVAIL) /* tds_willconvert returned true, but it lied. */ fprintf(stderr, "Conversion not yet implemented:\n\t"); fprintf(stderr, "failed (%d) to convert %d (%s, %d bytes) : %d (%s).\n", result, srctype, tds_prtype(srctype), srclen, desttype, tds_prtype(desttype)); if (result == TDS_CONVERT_NOAVAIL) exit(1); } printf("converted %d (%s, %d bytes) -> %d (%s, %d bytes).\n", srctype, tds_prtype(srctype), srclen, desttype, tds_prtype(desttype), result); /* * In the first iteration, start with varchar -> others. * By saving the output, we initialize subsequent inputs. */ switch (desttype) { case SYBNUMERIC: case SYBDECIMAL: numeric = cr.n; break; case SYBMONEY: money = cr.m; break; case SYBMONEY4: money4 = cr.m4; break; case SYBDATETIME: datetime = cr.dt; break; case SYBDATETIME4: datetime4 = cr.dt4; break; case SYBDATE: date = cr.date; break; case SYBTIME: time = cr.time; break; case SYBMSDATETIME2: dta = cr.dta; break; case SYB5BIGTIME: bigtime = cr.bigtime; break; case SYB5BIGDATETIME: bigdatetime = cr.bigdatetime; break; case SYBINT1: case SYBUINT1: tds_tinyint = cr.ti; break; case SYBINT2: tds_smallint = cr.si; break; case SYBINT4: tds_int = cr.i; break; case SYBINT8: tds_int8 = cr.bi; break; case SYBUINT2: tds_usmallint = cr.usi; break; case SYBUINT4: tds_uint = cr.ui; break; case SYBUINT8: tds_uint8 = cr.ubi; break; case SYBUNIQUE: tds_unique = cr.u; break; default: break; } /* * If an iteration count was passed on the command line (not by "make check") * run the conversion N times and print the conversions per second. */ result = gettimeofday(&start, NULL); starttime = (double) start.tv_sec + (double) start.tv_usec * 0.000001; for (j = 0; result >= 0 && j < iterations; j++) { result = tds_convert(ctx, srctype, src, srclen, desttype, &cr); if (result >= 0) free_convert(desttype, &cr); } if (result < 0) continue; result = gettimeofday(&end, NULL); endtime = (double) end.tv_sec + (double) end.tv_usec * 0.000001; if (endtime != starttime) { printf("%9.0f iterations/second converting %13s => %s.\n", j / (endtime - starttime), tds_prtype(srctype), tds_prtype(desttype)); } } tds_free_context(ctx); return g_result; } freetds-1.00.82/src/tds/unittests/corrupt.c100644 025423 025423 00000006250 12717145107 0014323/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2015 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /* * Check sending integer till they overlap a packet. * This is to check if an integer can spread in multiple * packets. The problem raise from internal implementation * and how is handled the overlapping. */ #include "common.h" #include static const char select_query[] = "\nselect 'test'"; static void unfinished_query_test(TDSSOCKET *tds) { int char_len; char *buf, *p; int i, len; union { TDS_USMALLINT si; TDS_UINT i; TDS_INT8 i8; char buf[8]; } conv; if (IS_TDS72_PLUS(tds->conn)) return; tds_init_write_buf(tds); /* try to build an invalid (unfinished) query split in two packets */ char_len = IS_TDS7_PLUS(tds->conn) ? 2 : 1; buf = tds_new0(char, tds->out_buf_max + 200); memset(buf, '-', tds->out_buf_max + 200); strcpy(buf + (tds->out_buf_max - 8) / char_len - strlen(select_query) + 1, select_query); memset(strchr(buf, 0), 0, 16); /* convert if needed */ len = strlen(buf); for (i = len; --i >= 0; ) { char c = buf[i]; buf[i * char_len + 0] = c; if (IS_TDS7_PLUS(tds->conn)) buf[i * char_len + 1] = 0; } len *= char_len; /* send the query using tds_put_int8, non allineati */ tds->out_flag = TDS_QUERY; if (tds_set_state(tds, TDS_WRITING) != TDS_WRITING) exit(1); p = buf; memcpy(conv.buf, p, 2); tds_put_smallint(tds, conv.si); p += 2; for (; p < buf + len; p += 8) { CHECK_TDS_EXTRA(tds); memcpy(conv.buf, p, 8); tds_put_int8(tds, conv.i8); } tds_flush_packet(tds); tds_set_state(tds, TDS_PENDING); /* check result was fine */ if (TDS_FAILED(tds_process_simple_query(tds))) { fprintf(stderr, "Error in prepared query\n"); exit(1); } free(buf); } int main(int argc, char **argv) { TDSLOGIN *login; TDSSOCKET *tds; int ret; int verbose = 0; TDS_INT8 i8; unsigned limit; fprintf(stdout, "%s: Testing login, logout\n", __FILE__); ret = try_tds_login(&login, &tds, __FILE__, verbose); if (ret != TDS_SUCCESS) { fprintf(stderr, "try_tds_login() failed\n"); return 1; } unfinished_query_test(tds); tds->out_flag = TDS_QUERY; if (tds_set_state(tds, TDS_WRITING) != TDS_WRITING) { return 1; } tds_put_n(tds, "aaa", 3); limit = tds->out_buf_max / 8 + 100; for (i8 = 0; i8 < limit; ++i8) { CHECK_TDS_EXTRA(tds); tds_put_int8(tds, i8); } tds_send_cancel(tds); tds_process_simple_query(tds); try_tds_logout(login, tds, verbose); return 0; } freetds-1.00.82/src/tds/unittests/dataread.c100644 025423 025423 00000015033 12522201763 0014364/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /* * Test data from server * The test do a select for a given type, convert to char and compare result */ #include "common.h" #include #include static int g_result = 0; static TDSLOGIN *login; static TDSSOCKET *tds; static void test0(const char *type, ...); static void test(const char *type, const char *value, const char *result) { test0(type, value, result, NULL); } static void exec_query(const char *query) { if (tds_submit_query(tds, query) != TDS_SUCCESS || tds_process_simple_query(tds) != TDS_SUCCESS) { fprintf(stderr, "executing query failed\n"); exit(1); } } static void test0(const char *type, ...) { char buf[512]; CONV_RESULT cr; int rc; TDS_INT result_type; int done_flags; va_list ap; struct { const char *value; const char *result; } data[10]; int num_data = 0, i_row; sprintf(buf, "CREATE TABLE #tmp(a %s)", type); exec_query(buf); va_start(ap, type); for (;;) { const char * value = va_arg(ap, const char *); const char * result; if (!value) break; result = va_arg(ap, const char *); if (!result) result = value; data[num_data].value = value; data[num_data].result = result; sprintf(buf, "INSERT INTO #tmp VALUES(CONVERT(%s,'%s'))", type, value); exec_query(buf); ++num_data; } va_end(ap); assert(num_data > 0); /* execute it */ rc = tds_submit_query(tds, "SELECT * FROM #tmp"); if (rc != TDS_SUCCESS) { fprintf(stderr, "tds_submit_query() failed\n"); exit(1); } if (tds_process_tokens(tds, &result_type, NULL, TDS_TOKEN_RESULTS) != TDS_SUCCESS) { fprintf(stderr, "tds_process_tokens() failed\n"); exit(1); } if (result_type != TDS_ROWFMT_RESULT) { fprintf(stderr, "expected row fmt() failed\n"); exit(1); } if (tds_process_tokens(tds, &result_type, NULL, TDS_TOKEN_RESULTS) != TDS_SUCCESS) { fprintf(stderr, "tds_process_tokens() failed\n"); exit(1); } if (result_type != TDS_ROW_RESULT) { fprintf(stderr, "expected row result() failed\n"); exit(1); } i_row = 0; while ((rc = tds_process_tokens(tds, &result_type, NULL, TDS_STOPAT_ROWFMT|TDS_RETURN_DONE|TDS_RETURN_ROW|TDS_RETURN_COMPUTE)) == TDS_SUCCESS && (result_type == TDS_ROW_RESULT || result_type == TDS_COMPUTE_RESULT)) { TDSCOLUMN *curcol = tds->current_results->columns[0]; TDS_CHAR *src = (TDS_CHAR *) curcol->column_data; int conv_type = tds_get_conversion_type(curcol->column_type, curcol->column_size); assert(i_row < num_data); if (is_blob_col(curcol) && curcol->column_type != SYBVARIANT) { TDSBLOB *blob = (TDSBLOB *) src; src = blob->textvalue; } if (tds_convert(test_context, conv_type, src, curcol->column_cur_size, SYBVARCHAR, &cr) < 0) { fprintf(stderr, "Error converting\n"); g_result = 1; } else { if (strcmp(data[i_row].result, cr.c) != 0) { fprintf(stderr, "Failed! Is \n%s\nShould be\n%s\n", cr.c, data[i_row].result); g_result = 1; } free(cr.c); } ++i_row; } if (rc != TDS_NO_MORE_RESULTS && rc != TDS_SUCCESS) { fprintf(stderr, "tds_process_tokens() unexpected return\n"); exit(1); } while ((rc = tds_process_tokens(tds, &result_type, &done_flags, TDS_TOKEN_RESULTS)) == TDS_SUCCESS) { switch (result_type) { case TDS_NO_MORE_RESULTS: return; case TDS_DONE_RESULT: case TDS_DONEPROC_RESULT: case TDS_DONEINPROC_RESULT: if (!(done_flags & TDS_DONE_ERROR)) break; default: fprintf(stderr, "tds_process_tokens() unexpected result_type\n"); exit(1); break; } } exec_query("DROP TABLE #tmp"); } int main(int argc, char **argv) { fprintf(stdout, "%s: Testing conversion from server\n", __FILE__); if (try_tds_login(&login, &tds, __FILE__, 0) != TDS_SUCCESS) { fprintf(stderr, "try_tds_login() failed\n"); return 1; } /* bit */ test("BIT", "0", NULL); test("BIT", "1", NULL); /* integers */ test("TINYINT", "234", NULL); test("SMALLINT", "-31789", NULL); test("INT", "16909060", NULL); /* floating point */ test("REAL", "1.25", NULL); test("FLOAT", "-49586.345", "-49586.345000000001"); /* money */ test("MONEY", "-123.3400", "-123.34"); test("MONEY", "-123.3450", "-123.35"); test("MONEY", "123.3450", "123.35"); /* very long money, this test int64 operations too */ test("MONEY", "123456789012345.67", NULL); /* test smaller money */ test("MONEY", "-922337203685477.5808", "-922337203685477.58"); test("SMALLMONEY", "89123.12", NULL); test("SMALLMONEY", "-123.3400", "-123.34"); test("SMALLMONEY", "-123.3450", "-123.35"); test("SMALLMONEY", "123.3450", "123.35"); /* test smallest smallmoney */ test("SMALLMONEY", "-214748.3648", "-214748.36"); /* char */ test("CHAR(10)", "pippo", "pippo "); test("VARCHAR(20)", "pippo", NULL); test0("TEXT", "a", NULL, "foofoo", NULL, "try with a relatively long value, we hope for the best", NULL, NULL); /* binary */ test("VARBINARY(6)", "foo", "666f6f"); test("BINARY(6)", "foo", "666f6f000000"); test0("IMAGE", "foo", "666f6f", "foofoofoofoo", "666f6f666f6f666f6f666f6f", NULL); /* numeric */ test("NUMERIC(10,2)", "12765.76", NULL); test("NUMERIC(18,4)", "12765.761234", "12765.7612"); /* date */ free(test_context->locale->date_fmt); test_context->locale->date_fmt = strdup("%Y-%m-%d %H:%M:%S"); test("DATETIME", "2003-04-21 17:50:03", NULL); test("SMALLDATETIME", "2003-04-21 17:50:03", "2003-04-21 17:50:00"); if (IS_TDS7_PLUS(tds->conn)) { test("UNIQUEIDENTIFIER", "12345678-1234-A234-9876-543298765432", NULL); test("NVARCHAR(20)", "Excellent test", NULL); test("NCHAR(20)", "Excellent test", "Excellent test "); test("NTEXT", "Excellent test", NULL); } if (IS_TDS71_PLUS(tds->conn)) { test("SQL_VARIANT", "test123", NULL); } try_tds_logout(login, tds, 0); return g_result; } freetds-1.00.82/src/tds/unittests/dynamic1.c100644 025423 025423 00000011362 12717145107 0014332/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "common.h" static int discard_result(TDSSOCKET * tds); static void fatal_error(const char *msg) { fprintf(stderr, "%s\n", msg); exit(1); } static void test(TDSSOCKET * tds, TDSDYNAMIC * dyn, TDS_INT n, const char *s) { TDSPARAMINFO *params; TDSCOLUMN *curcol; int len = (int)strlen(s); tds_free_input_params(dyn); if (!(params = tds_alloc_param_result(dyn->params))) fatal_error("out of memory!"); dyn->params = params; curcol = params->columns[0]; tds_set_param_type(tds->conn, curcol, SYBINT4); /* TODO test error */ tds_alloc_param_data(curcol); curcol->column_cur_size = sizeof(TDS_INT); memcpy(curcol->column_data, &n, sizeof(n)); if (!(params = tds_alloc_param_result(dyn->params))) fatal_error("out of memory!"); dyn->params = params; curcol = params->columns[1]; tds_set_param_type(tds->conn, curcol, SYBVARCHAR); curcol->column_size = 40; curcol->column_cur_size = len; tds_alloc_param_data(curcol); memcpy(curcol->column_data, s, len); if (tds_submit_execute(tds, dyn) != TDS_SUCCESS) fatal_error("tds_submit_execute() error"); if (discard_result(tds) != TDS_SUCCESS) fatal_error("tds_submit_execute() output error"); } int main(int argc, char **argv) { TDSLOGIN *login; TDSSOCKET *tds; int verbose = 0; TDSDYNAMIC *dyn = NULL; int rc; fprintf(stdout, "%s: Test dynamic queries\n", __FILE__); rc = try_tds_login(&login, &tds, __FILE__, verbose); if (rc != TDS_SUCCESS) fatal_error("try_tds_login() failed"); run_query(tds, "DROP TABLE #dynamic1"); if (run_query(tds, "CREATE TABLE #dynamic1 (i INT, c VARCHAR(40))") != TDS_SUCCESS) fatal_error("creating table error"); if (tds->cur_dyn) fatal_error("already a dynamic query??"); /* prepare to insert */ if (tds_submit_prepare(tds, "INSERT INTO #dynamic1(i,c) VALUES(?,?)", NULL, &dyn, NULL) != TDS_SUCCESS) fatal_error("tds_submit_prepare() error"); if (discard_result(tds) != TDS_SUCCESS) fatal_error("tds_submit_prepare() output error"); if (!dyn) fatal_error("dynamic not present??"); /* insert one record */ test(tds, dyn, 123, "dynamic"); /* some test */ if (run_query(tds, "DECLARE @n INT SELECT @n = COUNT(*) FROM #dynamic1 IF @n <> 1 SELECT 0") != TDS_SUCCESS) fatal_error("checking rows"); if (run_query(tds, "DECLARE @n INT SELECT @n = COUNT(*) FROM #dynamic1 WHERE i = 123 AND c = 'dynamic' IF @n <> 1 SELECT 0") != TDS_SUCCESS) fatal_error("checking rows 1"); /* insert one record */ test(tds, dyn, 654321, "a longer string"); /* some test */ if (run_query(tds, "DECLARE @n INT SELECT @n = COUNT(*) FROM #dynamic1 IF @n <> 2 SELECT 0") != TDS_SUCCESS) fatal_error("checking rows"); if (run_query(tds, "DECLARE @n INT SELECT @n = COUNT(*) FROM #dynamic1 WHERE i = 123 AND c = 'dynamic' IF @n <> 1 SELECT 0") != TDS_SUCCESS) fatal_error("checking rows 2"); if (run_query (tds, "DECLARE @n INT SELECT @n = COUNT(*) FROM #dynamic1 WHERE i = 654321 AND c = 'a longer string' IF @n <> 1 SELECT 0") != TDS_SUCCESS) fatal_error("checking rows 3"); if (run_query(tds, "DROP TABLE #dynamic1") != TDS_SUCCESS) fatal_error("dropping table error"); tds_release_dynamic(&dyn); try_tds_logout(login, tds, verbose); return 0; } static int discard_result(TDSSOCKET * tds) { int rc; int result_type; while ((rc = tds_process_tokens(tds, &result_type, NULL, TDS_TOKEN_RESULTS)) == TDS_SUCCESS) { switch (result_type) { case TDS_DONE_RESULT: case TDS_DONEPROC_RESULT: case TDS_DONEINPROC_RESULT: case TDS_DESCRIBE_RESULT: case TDS_STATUS_RESULT: case TDS_PARAM_RESULT: break; default: fprintf(stderr, "Error: query should not return results\n"); return TDS_FAIL; } } if (rc == TDS_FAIL) { fprintf(stderr, "tds_process_tokens() returned TDS_FAIL\n"); return TDS_FAIL; } else if (rc != TDS_NO_MORE_RESULTS) { fprintf(stderr, "tds_process_tokens() unexpected return\n"); return TDS_FAIL; } return TDS_SUCCESS; } freetds-1.00.82/src/tds/unittests/iconv_fread.c100644 025423 025423 00000005443 12717145107 0015107/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2006 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "common.h" #include #if HAVE_UNISTD_H #undef getpid #include #endif /* HAVE_UNISTD_H */ #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #include /* test tds_iconv_fread */ static char buf[4096+80]; int main(int argc, char **argv) { static const char out_file[] = "iconv_fread.out"; int i; FILE *f; TDSCONTEXT *ctx = tds_alloc_context(NULL); TDSSOCKET *tds = tds_alloc_socket(ctx, 512); TDSICONV * conv; const char *tdsdump; tdsdump = getenv("TDSDUMP"); if (tdsdump) tdsdump_open(tdsdump); if (!ctx || !tds) { fprintf(stderr, "Error creating socket!\n"); return 1; } tds_iconv_open(tds->conn, "ISO-8859-1", 0); conv = tds_iconv_get(tds->conn, "UTF-8", "ISO-8859-1"); if (conv == NULL) { fprintf(stderr, "Error creating conversion, giving up!\n"); return 1; } f = fopen(out_file, "w+b"); if (!f) { fprintf(stderr, "Error opening file!\n"); return 1; } for (i = 0; i < 4096+20; ++i) { char *out = NULL; size_t out_len = 0xdeadbeef; TDSRET res; const unsigned char x = 0x90; if (i == 32) i = 4096-20; /* write test string to file */ if (fseek(f, 0L, SEEK_SET)) { fprintf(stderr, "Error seeking!\n"); return 1; } memset(buf, 'a', i); buf[i] = 0xC0 + (x >> 6); buf[i+1] = 0x80 + (x & 0x3f); buf[i+2] = '!'; buf[i+3] = '!'; fwrite(buf, 1, i+4, f); if (fseek(f, 0L, SEEK_SET)) { fprintf(stderr, "Error seeking!\n"); return 1; } /* convert it */ res = tds_bcp_fread(NULL, conv, f, "!!", 2, &out, &out_len); printf("res %d out_len %u\n", (int) res, (unsigned int) out_len); /* test */ memset(buf, 'a', i); buf[i] = (char) x; assert(TDS_SUCCEED(res)); if (out_len != i+1) { fprintf(stderr, "out %u bytes expected %d\n", (unsigned int) out_len, i+1); return 1; } assert(memcmp(out, buf, i+1) == 0); free(out); } fclose(f); unlink(out_file); tds_free_socket(tds); tds_free_context(ctx); return 0; } freetds-1.00.82/src/tds/unittests/nulls.c100644 025423 025423 00000006527 12522201763 0013764/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2014 Mikhail Denisenko * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "common.h" int main(int argc, char **argv) { TDSLOGIN *login; TDSSOCKET *tds; int verbose = 1; int rc; int i; TDSCOLUMN *curcol; TDSRESULTINFO *resinfo; int result_type; printf("%s: Test null values\n", __FILE__); rc = try_tds_login(&login, &tds, __FILE__, verbose); if (rc != TDS_SUCCESS) { fprintf(stderr, "try_tds_login() failed\n"); return 1; } rc = tds_submit_query(tds, "SELECT NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL"); while ((rc = tds_process_tokens(tds, &result_type, NULL, TDS_RETURN_ROW|TDS_RETURN_COMPUTE)) == TDS_SUCCESS) { switch (result_type) { case TDS_ROW_RESULT: resinfo = tds->res_info; for (i = 0; i < 14; i++) { curcol = resinfo->columns[i]; if (curcol->column_cur_size != -1) { fprintf(stderr, "NULL value expected\n"); return 1; } } case TDS_COMPUTE_RESULT: break; default: fprintf(stderr, "tds_process_tokens() unexpected result\n"); break; } } if (rc == TDS_FAIL) { fprintf(stderr, "query failed\n"); return 1; } if (rc != TDS_NO_MORE_RESULTS) { fprintf(stderr, "tds_process_tokens() unexpected return\n"); } rc = tds_submit_query(tds, "SELECT 12, 'abc', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL"); while ((rc = tds_process_tokens(tds, &result_type, NULL, TDS_RETURN_ROW|TDS_RETURN_COMPUTE)) == TDS_SUCCESS) { switch (result_type) { case TDS_ROW_RESULT: resinfo = tds->res_info; curcol = resinfo->columns[0]; if (curcol->column_type != SYBINT4) { fprintf(stderr, "SYBINT value expected\n"); return 1; } if (*(TDS_INT*)curcol->column_data != 12) { fprintf(stderr, "invalid integer returned\n"); return 1; } curcol = resinfo->columns[1]; if (curcol->column_type != SYBVARCHAR) { fprintf(stderr, "SYBVARCHAR value expected\n"); return 1; } if (strcmp((char *) curcol->column_data, "abc") != 0) { fprintf(stderr, "invalid string returned\n"); return 1; } for (i = 2; i < 14; i++) { curcol = resinfo->columns[i]; if (curcol->column_cur_size != -1) { fprintf(stderr, "NULL value expected\n"); return 1; } } case TDS_COMPUTE_RESULT: break; default: fprintf(stderr, "tds_process_tokens() unexpected result\n"); break; } } if (rc == TDS_FAIL) { fprintf(stderr, "query failed\n"); return 1; } if (rc != TDS_NO_MORE_RESULTS) { fprintf(stderr, "tds_process_tokens() unexpected return\n"); } try_tds_logout(login, tds, verbose); return 0; } freetds-1.00.82/src/tds/unittests/numeric.c100644 025423 025423 00000007202 12717145107 0014265/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2005 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "common.h" #include #include /* test numeric scale */ static int g_result = 0; static TDSCONTEXT ctx; static void test0(const char *src, int prec, int scale, int prec2, unsigned char scale2) { int i; char buf[256]; char result[256]; char *p; CONV_RESULT cr; TDS_NUMERIC num; /* get initial number */ memset(&cr.n, 0, sizeof(cr.n)); cr.n.precision = prec; cr.n.scale = scale; if (tds_convert(&ctx, SYBVARCHAR, src, (TDS_UINT)strlen(src), SYBNUMERIC, &cr) < 0) { fprintf(stderr, "Error getting numeric %s(%d,%d)\n", src, prec, scale); exit(1); } num = cr.n; /* change scale with string */ tds_numeric_to_string(&num, buf); while ((p = strchr(buf, '.')) != NULL) memmove(p, p+1, strlen(p)); for (i = 0; i < (scale2 - scale); ++i) strcat(buf, "0"); for (i = 0; i < (scale - scale2); ++i) { assert(strlen(buf) > 1); buf[strlen(buf)-1] = 0; } if (scale2) { size_t len = strlen(buf); assert(len > scale2); memmove(buf + len - scale2 + 1, buf + len - scale2, scale2 + 1); buf[len-scale2] = '.'; } cr.n.precision = prec2; cr.n.scale = scale2; if (tds_convert(&ctx, SYBVARCHAR, src, (TDS_UINT)strlen(src), SYBNUMERIC, &cr) < 0) strcpy(buf, "error"); /* change scale with function */ if (tds_numeric_change_prec_scale(&num, prec2, scale2) < 0) strcpy(result, "error"); else tds_numeric_to_string(&num, result); if (strcmp(buf, result) != 0) { fprintf(stderr, "Failed! %s (%d,%d) -> (%d,%d)\n\tshould be %s\n\tis %s\n", src, prec, scale, prec2, scale2, buf, result); g_result = 1; exit(1); } else { printf("%s -> %s ok!\n", src, buf); } } static void test(const char *src, int prec, int scale, int scale2) { test0(src, prec, scale, prec, scale2); } int main(int argc, char **argv) { int i; memset(&ctx, 0, sizeof(ctx)); /* increase scale */ for (i = 0; i < 10; ++i) { test("1234", 18+i, 0, 2+i); test("1234.1234", 18+i, 5, 3+i); test("1234.1234", 22+i, 5+i, 12+i); } /* overflow */ test("1234", 4, 0, 2); for (i = 1; i < 12; ++i) test("1234", 3+i, 0, i); for (i = 2; i < 12; ++i) test("1234", 2+i, 0, i); /* decrease scale */ test("1234", 10, 4, 0); test("1234.765", 30, 20, 2); test0("765432.2", 30, 2, 20, 2); test0("765432.2", 30, 2, 40, 2); test0("765432.2", 30, 2, 6, 2); /* test big overflows */ test0("10000000000000000000000000", 30, 0, 10, 0); test0("1000000000000000000", 30, 0, 10, 0); test0("10000000000000000", 30, 10, 19, 0); test0("10000000000000000", 30, 10, 12, 0); #if 0 { int p1, s1, p2, s2; for (p1 = 1; p1 <= 77; ++p1) { printf("(%d,%d) -> (%d,%d)\n", p1, s1, p2, s2); for (s1 = 0; s1 < p1; ++s1) for (p2 = 1; p2 <= 77; ++p2) for (s2 = 0; s2 < p2; ++s2) test0("9", p1, s1, p2, s2); } } #endif if (!g_result) printf("All passed!\n"); return g_result; } freetds-1.00.82/src/tds/unittests/readconf.c100644 025423 025423 00000004317 12522201763 0014403/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2012 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "common.h" static FILE *f = NULL; static char *return_value = NULL; static void conf_parse(const char *option, const char *value, void *param) { const char *entry = (const char *) param; if (strcmp(option, entry) == 0) return_value = strdup(value); } static void test(const char *section, const char *entry, const char *expected) { int fail = 0; rewind(f); tds_read_conf_section(f, section, conf_parse, (void *) entry); if (!expected && return_value) { fprintf(stderr, "return value %s NOT expected\n", return_value); fail = 1; } else if (expected && !return_value) { fprintf(stderr, "expected value %s NOT found\n", expected); fail = 1; } else if (expected && return_value) { if (strcmp(expected, return_value) != 0) { fprintf(stderr, "expected value %s got %s\n", expected, return_value); fail = 1; } } free(return_value); return_value = NULL; if (fail) exit(1); } int main(int argc, char **argv) { const char *in_file = FREETDS_SRCDIR "/readconf.in"; f = fopen(in_file, "r"); if (!f) f = fopen("readconf.in", "r"); if (!f) { fprintf(stderr, "error opening test file\n"); exit(1); } /* option with no spaces */ test("section1", "opt1", "value1"); /* option name with spaces, different case in section name */ test("section2", "opt two", "value2"); test("section 3", "opt three", "value three"); fclose(f); return 0; } freetds-1.00.82/src/tds/unittests/t0001.c100644 025423 025423 00000002405 12522201763 0013362/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-1999 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /* * Just connect to server and disconnect */ #include "common.h" int main(int argc, char **argv) { TDSLOGIN *login; TDSSOCKET *tds; int ret; int verbose = 0; fprintf(stdout, "%s: Testing login, logout\n", __FILE__); ret = try_tds_login(&login, &tds, __FILE__, verbose); if (ret != TDS_SUCCESS) { fprintf(stderr, "try_tds_login() failed\n"); return 1; } try_tds_logout(login, tds, verbose); return 0; } freetds-1.00.82/src/tds/unittests/t0002.c100644 025423 025423 00000007066 12717145107 0013400/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-1999 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "common.h" #include #include static char * value_as_string(TDSSOCKET * tds, int col_idx) { static char result[256]; const int type = tds->res_info->columns[col_idx]->column_type; const void *value = tds->res_info->columns[col_idx]->column_data; switch (type) { case SYBVARCHAR: strlcpy(result, (const char *) value, sizeof(result)); break; case SYBINT4: sprintf(result, "%d", *(const int *) value); break; default: sprintf(result, "Unexpected column_type %d", type); break; } return result; } /* value_as_string() */ int main(int argc, char **argv) { TDSLOGIN *login; TDSSOCKET *tds; int verbose = 0; int num_cols = 2; TDS_INT result_type; int rc; int i, done_flags; fprintf(stdout, "%s: Test basic submit query, results\n", __FILE__); rc = try_tds_login(&login, &tds, __FILE__, verbose); if (rc != TDS_SUCCESS) { fprintf(stderr, "try_tds_login() failed\n"); return 1; } rc = tds_submit_query(tds, "select db_name() dbname, user_name() username"); if (rc != TDS_SUCCESS) { fprintf(stderr, "tds_submit_query() failed\n"); return 1; } while ((rc = tds_process_tokens(tds, &result_type, &done_flags, TDS_TOKEN_RESULTS)) == TDS_SUCCESS) { switch (result_type) { case TDS_ROWFMT_RESULT: if (tds->res_info->num_cols != num_cols) { fprintf(stderr, "Error: num_cols != %d in %s\n", num_cols, __FILE__); return 1; } if (tds->res_info->columns[0]->column_type != SYBVARCHAR || tds->res_info->columns[1]->column_type != SYBVARCHAR) { fprintf(stderr, "Wrong column_type in %s\n", __FILE__); return 1; } if (strcmp(tds_dstr_cstr(&tds->res_info->columns[0]->column_name), "dbname") || strcmp(tds_dstr_cstr(&tds->res_info->columns[1]->column_name), "username")) { fprintf(stderr, "Wrong column_name in %s\n", __FILE__); return 1; } break; case TDS_ROW_RESULT: while ((rc = tds_process_tokens(tds, &result_type, NULL, TDS_STOPAT_ROWFMT|TDS_RETURN_DONE|TDS_RETURN_ROW|TDS_RETURN_COMPUTE)) == TDS_SUCCESS) { if (result_type != TDS_ROW_RESULT || result_type != TDS_COMPUTE_RESULT) break; if (verbose) { for (i = 0; i < num_cols; i++) { printf("col %i is %s\n", i, value_as_string(tds, i)); } } } if (rc != TDS_SUCCESS) { fprintf(stderr, "tds_process_tokens() unexpected return\n"); } break; case TDS_DONE_RESULT: case TDS_DONEPROC_RESULT: case TDS_DONEINPROC_RESULT: if (!(done_flags & TDS_DONE_ERROR)) break; default: fprintf(stderr, "tds_process_tokens() unexpected result_type\n"); break; } } if (rc != TDS_NO_MORE_RESULTS) { fprintf(stderr, "tds_process_tokens() unexpected return\n"); } try_tds_logout(login, tds, verbose); return 0; } freetds-1.00.82/src/tds/unittests/t0003.c100644 025423 025423 00000003677 12717145107 0013405/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "common.h" int main(int argc, char **argv) { TDSLOGIN *login; TDSSOCKET *tds; int verbose = 0; int rc; fprintf(stdout, "%s: Testing DB change -- 'use tempdb'\n", __FILE__); rc = try_tds_login(&login, &tds, __FILE__, verbose); if (rc != TDS_SUCCESS) { fprintf(stderr, "try_tds_login() failed\n"); return 1; } rc = tds_submit_query(tds, "use tempdb"); if (rc != TDS_SUCCESS) { fprintf(stderr, "tds_submit_query() failed\n"); return 1; } /* warning: this mucks with some internals to get the env chg message */ if (tds_process_simple_query(tds) != TDS_SUCCESS) { fprintf(stderr, "query results failed\n"); return 1; } if (!tds || !tds->conn->env.database) { fprintf(stderr, "No database ??\n"); return 1; } /* Test currently disabled during TDSENV changes */ if (verbose) { fprintf(stdout, "database changed to %s\n", tds->conn->env.database); } if (strcmp(tds->conn->env.database, "tempdb")) { fprintf(stderr, "Wrong database, %s != tempdb\n", tds->conn->env.database); return 1; } try_tds_logout(login, tds, verbose); return 0; } freetds-1.00.82/src/tds/unittests/t0004.c100644 025423 025423 00000007017 12717145107 0013376/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-1999 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "common.h" #include static char * varchar_as_string(TDSSOCKET * tds, int col_idx) { static char result[256]; const void *value = tds->res_info->columns[col_idx]->column_data; strlcpy(result, (const char *) value, sizeof(result)); return result; } int main(int argc, char **argv) { TDSLOGIN *login; TDSSOCKET *tds; int verbose = 0; int rc, i; int result_type; int rows_returned = 0; const char *len200 = "01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"; char *long_query = (char*) malloc(5000); strcpy(long_query, "SELECT name FROM #longquerytest WHERE ("); for (i = 0; i < 20; ++i) sprintf(strchr(long_query, 0), "name = '%c%s' OR ", 'A'+i, len200); strcat(long_query, "name = 'correct')"); fprintf(stdout, "%s: Test large (>4096 bytes) queries\n", __FILE__); rc = try_tds_login(&login, &tds, __FILE__, verbose); if (rc != TDS_SUCCESS) { fprintf(stderr, "try_tds_login() failed\n"); return 1; } /* do not check error here, if TABLE is not create this give error */ rc = run_query(tds, "DROP TABLE #longquerytest"); rc = run_query(tds, "CREATE TABLE #longquerytest (name varchar(255))"); if (rc != TDS_SUCCESS) { return 1; } rc = run_query(tds, "INSERT #longquerytest (name) VALUES ('incorrect')"); if (rc != TDS_SUCCESS) { return 1; } rc = run_query(tds, "INSERT #longquerytest (name) VALUES ('correct')"); if (rc != TDS_SUCCESS) { return 1; } /* * The heart of the test */ if (verbose) { fprintf(stdout, "block size %d\n", tds->conn->env.block_size); } rc = tds_submit_query(tds, long_query); while ((rc = tds_process_tokens(tds, &result_type, NULL, TDS_RETURN_ROWFMT|TDS_RETURN_ROW)) == TDS_SUCCESS) { switch (result_type) { case TDS_ROWFMT_RESULT: if (tds->res_info->columns[0]->column_type != SYBVARCHAR) { fprintf(stderr, "Wrong column_type in %s\n", __FILE__); return 1; } break; case TDS_ROW_RESULT: ++rows_returned; if (verbose) { printf("col 0 is %s\n", varchar_as_string(tds, 0)); } break; default: break; } } if (rc == TDS_FAIL) { fprintf(stderr, "tds_process_tokens() returned TDS_FAIL for long query\n"); return 1; } else if (rc != TDS_NO_MORE_RESULTS) { fprintf(stderr, "tds_process_tokens() unexpected return\n"); } if (rows_returned != 1) { fprintf(stderr, "%d rows returned, 1 expected\n", rows_returned); return 1; } /* do not check error here, if TABLE is not create this give error */ rc = run_query(tds, "DROP TABLE #longquerytest"); try_tds_logout(login, tds, verbose); free(long_query); return 0; } freetds-1.00.82/src/tds/unittests/t0005.c100644 025423 025423 00000006762 12717145107 0013405/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-1999 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "common.h" #include static char *value_as_string(TDSSOCKET * tds, int col_idx); int main(int argc, char **argv) { TDSLOGIN *login; TDSSOCKET *tds; int verbose = 0; int rc; int i; int result_type; const char *len200 = "01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"; char large_sql[1000]; fprintf(stdout, "%s: Test large (>512 bytes) replies\n", __FILE__); rc = try_tds_login(&login, &tds, __FILE__, verbose); if (rc != TDS_SUCCESS) { fprintf(stderr, "try_tds_login() failed\n"); return 1; } /* do not test error, remove always table */ rc = run_query(tds, "DROP TABLE #test_table"); rc = run_query(tds, "CREATE TABLE #test_table (id int, name varchar(255))"); if (rc != TDS_SUCCESS) { return 1; } sprintf(large_sql, "INSERT #test_table (id, name) VALUES (0, 'A%s')", len200); rc = run_query(tds, large_sql); if (rc != TDS_SUCCESS) { return 1; } sprintf(large_sql, "INSERT #test_table (id, name) VALUES (1, 'B%s')", len200); rc = run_query(tds, large_sql); if (rc != TDS_SUCCESS) { return 1; } sprintf(large_sql, "INSERT #test_table (id, name) VALUES (2, 'C%s')", len200); rc = run_query(tds, large_sql); if (rc != TDS_SUCCESS) { return 1; } /* * The heart of the test */ rc = tds_submit_query(tds, "SELECT * FROM #test_table"); while ((rc = tds_process_tokens(tds, &result_type, NULL, TDS_RETURN_ROW)) == TDS_SUCCESS) { switch (result_type) { case TDS_ROW_RESULT: for (i = 0; i < tds->res_info->num_cols; i++) { if (verbose) { printf("col %i is %s\n", i, value_as_string(tds, i)); } } break; default: fprintf(stderr, "tds_process_tokens() returned unexpected result\n"); break; } } if (rc == TDS_FAIL) { fprintf(stderr, "tds_process_tokens() returned TDS_FAIL for SELECT\n"); return 1; } else if (rc != TDS_NO_MORE_RESULTS) { fprintf(stderr, "tds_process_tokens() unexpected return\n"); } /* do not test error, remove always table */ rc = run_query(tds, "DROP TABLE #test_table"); try_tds_logout(login, tds, verbose); return 0; } static char * value_as_string(TDSSOCKET * tds, int col_idx) { static char result[256]; const int type = tds->res_info->columns[col_idx]->column_type; const void *value = tds->res_info->columns[col_idx]->column_data; switch (type) { case SYBVARCHAR: strlcpy(result, (const char *) value, sizeof(result)); break; case SYBINT4: sprintf(result, "%d", *(const int *) value); break; default: sprintf(result, "Unexpected column_type %d", type); break; } return result; } freetds-1.00.82/src/tds/unittests/t0006.c100644 025423 025423 00000013054 12717145107 0013376/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "common.h" #include static TDSCONTEXT ctx; int main(int argc, char **argv) { TDSLOGIN *login; TDSSOCKET *tds; int verbose = 0; int rc; int row_count, i; /* variables for conversions */ TDSCOLUMN *curcol; TDSRESULTINFO *resinfo; unsigned char *src; CONV_RESULT cr; TDS_INT srctype, srclen; int src_id = 0; double src_val; double src_err; double tolerance = 0.000001; char sql[256]; int num_sybreal = 5; float sybreal[5]; int num_sybflt8 = 7; double sybflt8[7]; int result_type; memset(&ctx, 0, sizeof(ctx)); sybreal[0] = (float) 1.1; sybreal[1] = (float) 12345678; sybreal[2] = (float) 0.012345678; sybreal[3] = (float) 1.234567890e+20; sybreal[4] = (float) 1.234567890e-20; sybflt8[0] = 1.1; sybflt8[1] = 1234567890123456.0; sybflt8[2] = 0.01234567890123456; sybflt8[3] = 1.234567890123456e+20; sybflt8[4] = 1.234567890123456e-20; sybflt8[5] = 1.234567890123456e+200; sybflt8[6] = 1.234567890123456e-200; printf("%s: Test SYBREAL, SYBFLT8 values\n", __FILE__); rc = try_tds_login(&login, &tds, __FILE__, verbose); if (rc != TDS_SUCCESS) { fprintf(stderr, "try_tds_login() failed\n"); return 1; } /* * SYBREAL tests */ if (verbose) printf("Starting SYBREAL tests\n"); rc = run_query(tds, "DROP TABLE #test_table"); if (rc != TDS_SUCCESS) { return 1; } rc = run_query(tds, "CREATE TABLE #test_table (id int, val real)"); if (rc != TDS_SUCCESS) { return 1; } for (i = 0; i < num_sybreal; i++) { sprintf(sql, "INSERT #test_table (id, val) VALUES (%d, %.8g)", i, sybreal[i]); if (verbose) printf("%s\n", sql); rc = run_query(tds, sql); if (rc != TDS_SUCCESS) { return 1; } } rc = tds_submit_query(tds, "SELECT * FROM #test_table"); row_count = 0; while ((rc = tds_process_tokens(tds, &result_type, NULL, TDS_RETURN_ROW|TDS_RETURN_COMPUTE)) == TDS_SUCCESS) { switch (result_type) { case TDS_ROW_RESULT: resinfo = tds->res_info; for (i = 0; i < resinfo->num_cols; i++) { curcol = resinfo->columns[i]; src = curcol->column_data; if (verbose) { srctype = curcol->column_type; srclen = curcol->column_size; tds_convert(&ctx, srctype, (TDS_CHAR *) src, srclen, SYBCHAR, &cr); printf("col %i is %s\n", i, cr.c); } if (i == 0) { src_id = *(int *) src; } else { src_val = *(float *) src; src_err = src_val - sybreal[src_id]; if (src_err != 0.0) { src_err = src_err / src_val; } if (src_err < -tolerance || src_err > tolerance) { fprintf(stderr, "SYBREAL expected %.8g got %.8g\n", sybreal[src_id], src_val); fprintf(stderr, "Error was %.4g%%\n", 100 * src_err); return 1; } } } row_count++; case TDS_COMPUTE_RESULT: break; default: fprintf(stderr, "tds_process_tokens() unexpected result\n"); break; } } if (rc != TDS_NO_MORE_RESULTS) { fprintf(stderr, "tds_process_tokens() unexpected return\n"); } /* * SYBFLT8 tests */ if (verbose) printf("Starting SYBFLT8 tests\n"); rc = run_query(tds, "DROP TABLE #test_table"); if (rc != TDS_SUCCESS) { return 1; } rc = run_query(tds, "CREATE TABLE #test_table (id int, val float(48))"); if (rc != TDS_SUCCESS) { return 1; } for (i = 0; i < num_sybflt8; i++) { sprintf(sql, "INSERT #test_table (id, val) VALUES (%d, %.15g)", i, sybflt8[i]); if (verbose) printf("%s\n", sql); rc = run_query(tds, sql); if (rc != TDS_SUCCESS) { return 1; } } rc = tds_submit_query(tds, "SELECT * FROM #test_table"); while ((rc = tds_process_tokens(tds, &result_type, NULL, TDS_RETURN_ROW|TDS_RETURN_COMPUTE)) == TDS_SUCCESS) { switch (result_type) { case TDS_ROW_RESULT: resinfo = tds->res_info; for (i = 0; i < resinfo->num_cols; i++) { curcol = resinfo->columns[i]; src = curcol->column_data; if (verbose) { srctype = curcol->column_type; srclen = curcol->column_size; tds_convert(&ctx, srctype, (TDS_CHAR *) src, srclen, SYBCHAR, &cr); printf("col %i is %s\n", i, cr.c); } if (i == 0) { src_id = *(int *) src; } else { memcpy(&src_val, src, 8); src_err = src_val - sybflt8[src_id]; if (src_err != 0.0) { src_err = src_err / src_val; } if (src_err < -tolerance || src_err > tolerance) { fprintf(stderr, "SYBFLT8 expected %.16g got %.16g\n", sybflt8[src_id], src_val); fprintf(stderr, "Error was %.4g%%\n", 100 * src_err); return 1; } } } case TDS_COMPUTE_RESULT: break; default: fprintf(stderr, "tds_process_tokens() returned unexpected result\n"); break; } } if (rc != TDS_NO_MORE_RESULTS) { fprintf(stderr, "tds_process_tokens() unexpected return\n"); } try_tds_logout(login, tds, verbose); return 0; } freetds-1.00.82/src/tds/unittests/t0007.c100644 025423 025423 00000033055 12717145107 0013402/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-1999 Brian Bruns * Copyright (C) 2015 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /** * This test exercise manually conversions from types. * Does not require any connection. */ #include "common.h" #include static TDSCONTEXT ctx; static void test0(const char *src, int len, int midtype, int dsttype, const char *result, int line) { int i, res; char buf[256]; CONV_RESULT cr, cr_mid; int srctype = SYBVARCHAR; char *copy; copy = tds_new(char, len); memcpy(copy, src, len); src = copy; if (midtype) { res = tds_convert(&ctx, SYBVARCHAR, src, len, midtype, &cr_mid); if (res < 0) { fprintf(stderr, "Unexpected failure converting %*.*s\n", len, len, src); exit(1); } src = (const char *) &cr_mid; len = res; srctype = midtype; } res = tds_convert(&ctx, srctype, src, len, dsttype, &cr); if (res < 0) strcpy(buf, "error"); else { buf[0] = 0; switch (dsttype) { case SYBINT1: case SYBUINT1: sprintf(buf, "%d", cr.ti); break; case SYBINT2: sprintf(buf, "%d", cr.si); break; case SYBUINT2: sprintf(buf, "%u", cr.usi); break; case SYBINT4: sprintf(buf, "%d", cr.i); break; case SYBUINT4: sprintf(buf, "%u", cr.ui); break; case SYBINT8: sprintf(buf, "0x%08x%08x", (unsigned int) ((cr.bi >> 32) & 0xfffffffflu), (unsigned int) (cr.bi & 0xfffffffflu)); break; case SYB5BIGTIME: case SYB5BIGDATETIME: case SYBUINT8: sprintf(buf, "0x%08x%08x", (unsigned int) ((cr.ubi >> 32) & 0xfffffffflu), (unsigned int) (cr.ubi & 0xfffffffflu)); break; case SYBUNIQUE: sprintf(buf, "%08X-%04X-%04X-%02X%02X%02X%02X" "%02X%02X%02X%02X", cr.u.Data1, cr.u.Data2, cr.u.Data3, cr.u.Data4[0], cr.u.Data4[1], cr.u.Data4[2], cr.u.Data4[3], cr.u.Data4[4], cr.u.Data4[5], cr.u.Data4[6], cr.u.Data4[7]); break; case SYBBINARY: sprintf(buf, "len=%d", res); for (i = 0; i < res; ++i) sprintf(strchr(buf, 0), " %02X", (TDS_UCHAR) cr.ib[i]); free(cr.ib); break; case SYBCHAR: sprintf(buf, "len=%d %s", res, cr.c); free(cr.c); break; case SYBDATETIME: sprintf(buf, "%ld %ld", (long int) cr.dt.dtdays, (long int) cr.dt.dttime); break; case SYBDATE: sprintf(buf, "%ld", (long int) cr.date); break; case SYBTIME: sprintf(buf, "%ld", (long int) cr.time); break; } } printf("%s\n", buf); if (strcmp(buf, result) != 0) { fprintf(stderr, "Expected '%s' got '%s' at line %d\n", result, buf, line); exit(1); } free(copy); } #define test(s,d,r) test0(s,strlen(s),0,d,r,__LINE__) #define test2(s,m,d,r) test0(s,strlen(s),m,d,r,__LINE__) static int int_types[] = { SYBINT1, SYBUINT1, SYBINT2, SYBUINT2, SYBINT4, SYBUINT4, SYBINT8, SYBUINT8, SYBMONEY4, SYBMONEY, SYBNUMERIC, -1 }; static const char * int_values[] = { "0", "127", "255", "128", "256", "32767", "65535", "32768", "65536", "214748", "214749", "2147483647", "4294967295", "2147483648", "4294967296", "922337203685477", "922337203685478", "9223372036854775807", "18446744073709551615", "9223372036854775808", "18446744073709551616", "-128", "-129", "-32768", "-32769", "-214748", "-214749", "-2147483648", "-2147483649", "-922337203685477", "-922337203685478", "-9223372036854775808", "-9223372036854775809", NULL }; int main(int argc, char **argv) { int *type1, *type2; const char **value; int big_endian = 1; if (((char *) &big_endian)[0] == 1) big_endian = 0; memset(&ctx, 0, sizeof(ctx)); if ((ctx.locale = tds_get_locale()) == NULL) return 1; /* date */ free(ctx.locale->date_fmt); ctx.locale->date_fmt = strdup("%Y-%m-%d %H:%M:%S.%z"); /* test some conversion */ printf("some checks...\n"); test("1234", SYBINT4, "1234"); test("1234", SYBUINT4, "1234"); test("123", SYBINT1, "123"); test("123", SYBUINT1, "123"); test(" - 1234 ", SYBINT2, "-1234"); test(" - 1234 a", SYBINT2, "error"); test("", SYBINT4, "0"); test(" ", SYBINT4, "0"); test(" 123", SYBINT4, "123"); test(" 123 ", SYBINT4, "123"); test(" + 123 ", SYBINT4, "123"); test(" + 123 ", SYBUINT4, "123"); test(" - 0 ", SYBINT4, "0"); test(" - 0 ", SYBUINT4, "0"); test("+", SYBINT4, "error"); test(" +", SYBINT4, "error"); test("+ ", SYBINT4, "error"); test(" + ", SYBINT4, "error"); test("-", SYBINT4, "error"); test(" -", SYBINT4, "error"); test("- ", SYBINT4, "error"); test(" - ", SYBINT4, "error"); test(" - 1234 ", SYBINT8, "0xfffffffffffffb2e"); test("1234x", SYBINT8, "error"); test(" - 1234 a", SYBINT8, "error"); test("", SYBINT8, "0x0000000000000000"); test(" ", SYBINT8, "0x0000000000000000"); test(" 123", SYBINT8, "0x000000000000007b"); test(" 123 ", SYBINT8, "0x000000000000007b"); test(" + 123 ", SYBINT8, "0x000000000000007b"); test(" 123", SYBUINT8, "0x000000000000007b"); test(" 123 ", SYBUINT8, "0x000000000000007b"); test(" + 123 ", SYBUINT8, "0x000000000000007b"); test("+", SYBINT8, "error"); test(" +", SYBINT8, "error"); test("+ ", SYBINT8, "error"); test(" + ", SYBINT8, "error"); test("-", SYBINT8, "error"); test(" -", SYBINT8, "error"); test("- ", SYBINT8, "error"); test(" - ", SYBINT8, "error"); /* test for overflow */ /* for SYBUINT8 a test with all different digit near limit is required */ printf("overflow checks...\n"); test("9223372036854775807", SYBINT8, "0x7fffffffffffffff"); test("9223372036854775807", SYBUINT8, "0x7fffffffffffffff"); test("9223372036854775808", SYBINT8, "error"); test("-9223372036854775808", SYBINT8, "0x8000000000000000"); test("9223372036854775808", SYBUINT8, "0x8000000000000000"); test("18446744073709551610", SYBUINT8, "0xfffffffffffffffa"); test("18446744073709551611", SYBUINT8, "0xfffffffffffffffb"); test("18446744073709551612", SYBUINT8, "0xfffffffffffffffc"); test("18446744073709551613", SYBUINT8, "0xfffffffffffffffd"); test("18446744073709551614", SYBUINT8, "0xfffffffffffffffe"); test("18446744073709551615", SYBUINT8, "0xffffffffffffffff"); test("18446744073709551616", SYBUINT8, "error"); test("18446744073709551617", SYBUINT8, "error"); test("18446744073709551618", SYBUINT8, "error"); test("18446744073709551619", SYBUINT8, "error"); test("18446744073709551620", SYBUINT8, "error"); test("20496382304121724025", SYBUINT8, "error"); test("20496382308118429681", SYBUINT8, "error"); test("-1", SYBUINT8, "error"); test("-9223372036854775809", SYBINT8, "error"); test("2147483647", SYBINT4, "2147483647"); test("2147483648", SYBINT4, "error"); test("2147483647", SYBUINT4, "2147483647"); test("4294967295", SYBUINT4, "4294967295"); test("4294967296", SYBUINT4, "error"); test("-2147483648", SYBINT4, "-2147483648"); test("-2147483648", SYBUINT4, "error"); test("-2147483649", SYBINT4, "error"); test("32767", SYBINT2, "32767"); test("32767", SYBUINT2, "32767"); test("65535", SYBUINT2, "65535"); test("65536", SYBUINT2, "error"); test("32768", SYBINT2, "error"); test("-32768", SYBINT2, "-32768"); test("-32769", SYBINT2, "error"); test("255", SYBINT1, "255"); test("256", SYBINT1, "error"); test("255", SYBUINT1, "255"); test("256", SYBUINT1, "error"); test("0", SYBINT1, "0"); test("-1", SYBINT1, "error"); test("0", SYBUINT1, "0"); test("-1", SYBUINT1, "error"); /* * test overflow on very big numbers * i use increment of 10^9 to be sure lower 32bit be correct * in a case */ printf("overflow on big number checks...\n"); test("62147483647", SYBINT4, "error"); test("63147483647", SYBINT4, "error"); test("64147483647", SYBINT4, "error"); test("65147483647", SYBINT4, "error"); test("53248632876323876761", SYBINT8, "error"); test("56248632876323876761", SYBINT8, "error"); test("59248632876323876761", SYBINT8, "error"); test("12248632876323876761", SYBINT8, "error"); /* money */ test2("1234.11111111111111111111111111111111111111111111111111111111111111111111111111111111111111", SYBMONEY, SYBCHAR, "len=7 1234.11"); /* some test for unique */ printf("unique type...\n"); test("12345678-1234-1234-9876543298765432", SYBUNIQUE, "12345678-1234-1234-9876543298765432"); test("{12345678-1234-1E34-9876ab3298765432}", SYBUNIQUE, "12345678-1234-1E34-9876AB3298765432"); test(" 12345678-1234-1234-9876543298765432", SYBUNIQUE, "error"); test(" {12345678-1234-1234-9876543298765432}", SYBUNIQUE, "error"); test("12345678-1234-G234-9876543298765432", SYBUNIQUE, "error"); test("12345678-1234-a234-9876543298765432", SYBUNIQUE, "12345678-1234-A234-9876543298765432"); test("123a5678-1234-a234-98765-43298765432", SYBUNIQUE, "error"); test("123-5678-1234-a234-9876543298765432", SYBUNIQUE, "error"); printf("binary test...\n"); test("0x1234", SYBBINARY, "len=2 12 34"); test("0xaBFd ", SYBBINARY, "len=2 AB FD"); test("AbfD ", SYBBINARY, "len=2 AB FD"); test("0x000", SYBBINARY, "len=2 00 00"); test("0x0", SYBBINARY, "len=1 00"); test("0x100", SYBBINARY, "len=2 01 00"); test("0x1", SYBBINARY, "len=1 01"); test("Jan 01 2006", SYBDATETIME, "38716 0"); test("January 01 2006", SYBDATETIME, "38716 0"); test("March 05 2005", SYBDATETIME, "38414 0"); test("may 13 2001", SYBDATETIME, "37022 0"); test("02 Jan 2006", SYBDATETIME, "38717 0"); test("2 Jan 2006", SYBDATETIME, "38717 0"); test("02Jan2006", SYBDATETIME, "38717 0"); test("20060102", SYBDATETIME, "38717 0"); test("060102", SYBDATETIME, "38717 0"); test("2006-01-02", SYBDATE, "38717"); test("12:34:56.337", SYBTIME, "13588901"); test2("2006-01-02", SYBDATE, SYBDATE, "38717"); test2("12:34:56.337", SYBTIME, SYBTIME, "13588901"); test2("2006-01-02 12:34:56.337", SYBDATETIME, SYBDATE, "38717"); test2("2006-01-02 12:34:56.337", SYBDATETIME, SYBTIME, "13588901"); test("2006-01-02 12:34:56.337321", SYB5BIGTIME, "0x0000000a8bdf41a9"); test("2006-01-23 12:34:56.337321", SYB5BIGDATETIME, "0x00e0e7c784d661a9"); test("2006-01-02 12:34:56.337321", SYB5BIGDATETIME, "0x00e0e621122b81a9"); test2("2006-01-02 12:34:56.337765", SYB5BIGDATETIME, SYBCHAR, "len=26 2006-01-02 12:34:56.337765"); test("2006-01-02 12:34:56.337765", SYB5BIGDATETIME, "0x00e0e621122b8365"); test2("2006-01-02 12:34:56.337", SYBMSDATETIME2, SYBDATE, "38717"); test2("2006-01-02 12:34:56.337", SYBMSDATETIME2, SYBTIME, "13588901"); test2("2006-01-02 12:34:56.337", SYBMSDATETIME2, SYBCHAR, "len=27 2006-01-02 12:34:56.3370000"); #if 0 /* FIXME should fail conversion ?? */ test2("2006-01-02", SYBDATE, SYBTIME, "0"); test2("12:34:56.337", SYBTIME, SYBDATE, "0"); #endif test2("2006-01-02", SYBDATE, SYBCHAR, "len=23 2006-01-02 00:00:00.000"); test2("12:34:56.337", SYBTIME, SYBCHAR, "len=23 1900-01-01 12:34:56.337"); test2("123", SYBINT1, SYBBINARY, "len=1 7B"); if (big_endian) { test2("12345", SYBINT2, SYBBINARY, "len=2 30 39"); test2("123456789", SYBINT4, SYBBINARY, "len=4 07 5B CD 15"); test2("123456789", SYBUINT8, SYBBINARY, "len=8 00 00 00 00 07 5B CD 15"); test2("123456789", SYBINT8, SYBBINARY, "len=8 00 00 00 00 07 5B CD 15"); test2("-123456789", SYBINT8, SYBBINARY, "len=8 FF FF FF FF F8 A4 32 EB"); } else { test2("12345", SYBINT2, SYBBINARY, "len=2 39 30"); test2("123456789", SYBINT4, SYBBINARY, "len=4 15 CD 5B 07"); test2("123456789", SYBUINT8, SYBBINARY, "len=8 15 CD 5B 07 00 00 00 00"); test2("123456789", SYBINT8, SYBBINARY, "len=8 15 CD 5B 07 00 00 00 00"); test2("-123456789", SYBINT8, SYBBINARY, "len=8 EB 32 A4 F8 FF FF FF FF"); } /* now try many int conversion operations */ for (value = int_values; *value; ++value) for (type1 = int_types; *type1 >= 0; ++type1) for (type2 = int_types; *type2 >= 0; ++type2) { char buf[64], expected[64]; CONV_RESULT cr_src, cr_dst; TDS_INT len_src, len_dst; /* try conversion from char (already tested above) */ cr_src.n.precision = 20; cr_src.n.scale = 0; len_src = tds_convert(&ctx, SYBVARCHAR, *value, strlen(*value), *type1, &cr_src); cr_dst.n.precision = 20; cr_dst.n.scale = 0; len_dst = tds_convert(&ctx, SYBVARCHAR, *value, strlen(*value), *type2, &cr_dst); if (len_src <= 0 || len_dst <= 0) continue; cr_dst.n.precision = 20; cr_dst.n.scale = 0; if (tds_convert(&ctx, *type1, (const TDS_CHAR *) &cr_src.i, len_src, *type2, &cr_dst) <= 0) { fprintf(stderr, "conversion from %s to %s of %s should succeed\n", tds_prtype(*type1), tds_prtype(*type2), *value); return 1; } memcpy(&cr_src, &cr_dst, sizeof(cr_dst)); cr_dst.cc.c = buf; cr_dst.cc.len = sizeof(buf)-4; len_dst = tds_convert(&ctx, *type2, (const TDS_CHAR *) &cr_src.i, len_dst, TDS_CONVERT_CHAR, &cr_dst); if (len_dst <= 0) { fprintf(stderr, "conversion from %s to string should succeed\n", tds_prtype(*type1)); return 1; } buf[len_dst] = 0; if (*type2 == SYBMONEY4 || *type2 == SYBMONEY) sprintf(expected, "%s.00", *value); else strcpy(expected, *value); if (strcmp(buf, expected) != 0) { fprintf(stderr, "conversion from %s to %s of %s got wrong value '%s'\n", tds_prtype(*type1), tds_prtype(*type2), *value, buf); return 1; } } tds_free_locale(ctx.locale); return 0; } freetds-1.00.82/src/tds/unittests/t0008.c100644 025423 025423 00000010100 12717145107 0013365/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-1999 Brian Bruns * Copyright (C) 2015 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "common.h" #include static int g_result = 0; static TDSCONTEXT ctx; static void test(const char *src, const char *intro, const char *cont, int prec, int scale, int n2s, int line) { int i; char buf[256]; char result[256]; CONV_RESULT cr; /* build result string from intro and cont */ strcpy(result, intro); if (*cont) { for (i = 0; i < sizeof(cr.n.array); ++i) strcat(result, " 00"); memcpy(result + strlen(intro) + 1, cont, strlen(cont)); } memset(&cr.n, 0, sizeof(cr.n)); cr.n.precision = prec; cr.n.scale = scale; if (tds_convert(&ctx, SYBVARCHAR, src, strlen(src), SYBNUMERIC, &cr) < 0) strcpy(buf, "error"); else { sprintf(buf, "prec=%d scale=%d", cr.n.precision, cr.n.scale); for (i = 0; i < sizeof(cr.n.array); ++i) sprintf(strchr(buf, 0), " %02X", cr.n.array[i]); } printf("%s\n", buf); if (strcmp(buf, result) != 0) { fprintf(stderr, "line %d: Failed! Should be\n\t%s\n", line, result); g_result = 1; } if (!n2s || strcmp(buf, "error") == 0) return; tds_numeric_to_string(&cr.n, buf); printf("%s\n", buf); if (strcmp(buf, src) != 0) { fprintf(stderr, "line %d: Failed! Should be\n\t%s\n", line, src); g_result = 1; } } #define test(a,b,c,d,e,f) test(a,b,c,d,e,f,__LINE__) int main(int argc, char **argv) { /* very long string for test buffer overflow */ int i; char long_test[201]; memset(&ctx, 0, sizeof(ctx)); printf("test some valid values..\n"); test(" 1234", "prec=18 scale=0", "00 00 00 00 00 00 00 04 D2", 18, 0, 0); test("1234567890", "prec=18 scale=0", "00 00 00 00 00 49 96 02 D2", 18, 0, 1); test("123456789012345678", "prec=18 scale=0", "00 01 B6 9B 4B A6 30 F3 4E", 18, 0, 1); test("999999999999999999", "prec=18 scale=0", "00 0D E0 B6 B3 A7 63 FF FF", 18, 0, 1); printf("test overflow..\n"); test("123456789012345678901234567890", "error", "", 18, 0, 0); long_test[0] = 0; for (i = 0; i < 20; ++i) strcat(long_test, "1234567890"); test(long_test, "error", "", 18, 0, 0); memcpy(long_test, "1234.", 5); test(long_test, "prec=18 scale=0", "00 00 00 00 00 00 00 04 D2", 18, 0, 0); test("123456789012345678901234567890", "prec=38 scale=0", "00 00 00 00 01 8E E9 0F F6 C3 73 E0 EE 4E 3F 0A D2", 38, 0, 1); test("1234567890123456789012345678901234567890123456789012345678901234567890-00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00", "error", "", 38, 0, 1); test("99999999999999999999999999999999999999", "prec=38 scale=0", "00 4B 3B 4C A8 5A 86 C4 7A 09 8A 22 3F FF FF FF FF", 38, 0, 1); test("100000000000000000000000000000000000000", "error", "", 38, 0, 1); test(" 1234", "prec=18 scale=1", "00 00 00 00 00 00 00 30 34", 18, 1, 0); test("1234.56", "prec=18 scale=2", "00 00 00 00 00 00 01 E2 40", 18, 2, 1); test("0.00123", "prec=18 scale=5", "00 00 00 00 00 00 00 00 7B", 18, 5, 1); test("0.0123", "prec=18 scale=4", "00 00 00 00 00 00 00 00 7B", 18, 4, 1); test("0.123", "prec=18 scale=3", "00 00 00 00 00 00 00 00 7B", 18, 3, 1); test("1.23", "prec=18 scale=2", "00 00 00 00 00 00 00 00 7B", 18, 2, 1); test("12.3", "prec=18 scale=1", "00 00 00 00 00 00 00 00 7B", 18, 1, 1); test("0.0000", "prec=18 scale=4", "00", 18, 4, 1); test("0", "prec=18 scale=0", "00", 18, 0, 1); return g_result; } freetds-1.00.82/src/tds/unittests/toodynamic.c100644 025423 025423 00000005731 12717145107 0014776/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2008 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "common.h" /* * Test creating a lot of dynamics. This can cause some problems cause * generated IDs are reused on a base of 2^16 */ static void fatal_error(const char *msg) { fprintf(stderr, "%s\n", msg); exit(1); } int main(int argc, char **argv) { TDSLOGIN *login; TDSSOCKET *tds; int verbose = 0; TDSDYNAMIC *dyn = NULL; int rc; unsigned int n; fprintf(stdout, "%s: Test creating a lot of dynamic queries\n", __FILE__); rc = try_tds_login(&login, &tds, __FILE__, verbose); if (rc != TDS_SUCCESS) fatal_error("try_tds_login() failed"); run_query(tds, "DROP TABLE #test"); if (run_query(tds, "CREATE TABLE #test (i INT, c VARCHAR(40))") != TDS_SUCCESS) fatal_error("creating table error"); if (tds->cur_dyn) fatal_error("already a dynamic query??"); /* prepare to insert */ if (tds_submit_prepare(tds, "UPDATE #test SET c = 'test' WHERE i = ?", NULL, &dyn, NULL) != TDS_SUCCESS) fatal_error("tds_submit_prepare() error"); if (tds_process_simple_query(tds) != TDS_SUCCESS) fatal_error("tds_process_simple_query() error"); if (!dyn) fatal_error("dynamic not present??"); /* waste some ids */ for (n = 0; n < 65525; ++n) { TDSDYNAMIC *dyn; dyn = tds_alloc_dynamic(tds->conn, NULL); if (!dyn) fatal_error("create dynamic"); tds_dynamic_deallocated(tds->conn, dyn); tds_release_dynamic(&dyn); } /* this should not cause duplicate IDs or erros*/ for (n = 0; n < 20; ++n) { TDSDYNAMIC *dyn2 = NULL; if (tds_submit_prepare(tds, "INSERT INTO #test(i,c) VALUES(?,?)", NULL, &dyn2, NULL) != TDS_SUCCESS) fatal_error("tds_submit_prepare() error"); if (dyn == dyn2) fatal_error("got duplicated dynamic"); if (tds_process_simple_query(tds) != TDS_SUCCESS) fatal_error("tds_process_simple_query() error"); if (!dyn2) fatal_error("dynamic not present??"); if (tds_submit_unprepare(tds, dyn2) != TDS_SUCCESS || tds_process_simple_query(tds) != TDS_SUCCESS) fatal_error("unprepare error"); tds_dynamic_deallocated(tds->conn, dyn2); tds_release_dynamic(&dyn2); } tds_dynamic_deallocated(tds->conn, dyn); tds_release_dynamic(&dyn); try_tds_logout(login, tds, verbose); return 0; } freetds-1.00.82/src/tds/unittests/utf8_1.c100644 025423 025423 00000013374 12717145107 0013740/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Brian Bruns * Copyright (C) 2010 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "common.h" #include #include static TDSSOCKET *tds; /* Some no-ASCII strings (XML coding) */ static const char english[] = "English"; static const char spanish[] = "Español"; static const char french[] = "Français"; static const char portuguese[] = "Português"; static const char russian[] = "Русский"; static const char arabic[] = "العربية"; static const char chinese[] = "简体中文"; static const char japanese[] = "日本語"; static const char hebrew[] = "עברית"; static const char *strings[] = { english, spanish, french, portuguese, russian, arabic, chinese, japanese, hebrew, NULL, /* will be replaced with large data */ NULL, /* will be replaced with large data */ NULL, /* will be replaced with large data */ NULL, /* will be replaced with large data */ NULL }; static void query(const char *sql) { if (run_query(tds, sql) != TDS_SUCCESS) { fprintf(stderr, "error executing query: %s\n", sql); exit(1); } } static void test(const char *type, const char *test_name) { char buf[256]; char tmp[256]; int i; const char **s; int rc; TDS_INT result_type; int done_flags; sprintf(buf, "CREATE TABLE #tmp (i INT, t %s)", type); query(buf); /* insert all test strings in table */ for (i = 0, s = strings; *s; ++s, ++i) { sprintf(buf, "insert into #tmp values(%d, N'%s')", i, to_utf8(*s, tmp)); query(buf); } /* do a select and check all results */ rc = tds_submit_query(tds, "select t from #tmp order by i"); if (rc != TDS_SUCCESS) { fprintf(stderr, "tds_submit_query() failed\n"); exit(1); } if (tds_process_tokens(tds, &result_type, NULL, TDS_TOKEN_RESULTS) != TDS_SUCCESS) { fprintf(stderr, "tds_process_tokens() failed\n"); exit(1); } if (result_type != TDS_ROWFMT_RESULT) { fprintf(stderr, "expected row fmt() failed\n"); exit(1); } if (tds_process_tokens(tds, &result_type, NULL, TDS_TOKEN_RESULTS) != TDS_SUCCESS) { fprintf(stderr, "tds_process_tokens() failed\n"); exit(1); } if (result_type != TDS_ROW_RESULT) { fprintf(stderr, "expected row result() failed\n"); exit(1); } i = 0; while ((rc = tds_process_tokens(tds, &result_type, NULL, TDS_RETURN_ROWFMT|TDS_RETURN_ROW|TDS_RETURN_COMPUTE)) == TDS_SUCCESS) { switch (result_type) { case TDS_ROW_RESULT: { TDSCOLUMN *curcol = tds->current_results->columns[0]; char *src = (char *) curcol->column_data; if (is_blob_col(curcol)) { TDSBLOB *blob = (TDSBLOB *) src; src = blob->textvalue; } strcpy(buf, to_utf8(strings[i], tmp)); if (strlen(buf) != curcol->column_cur_size || strncmp(buf, src, curcol->column_cur_size) != 0) { int l = curcol->column_cur_size; if (l > 200) l = 200; strncpy(tmp, src, l); tmp[l] = 0; fprintf(stderr, "Wrong result in test %s\n Got: '%s' len %d\n Expected: '%s' len %u\n", test_name, tmp, curcol->column_cur_size, buf, (unsigned int) strlen(buf)); exit(1); } ++i; } break; default: fprintf(stderr, "Unexpected result\n"); exit(1); break; } } if (rc != TDS_NO_MORE_RESULTS) { fprintf(stderr, "tds_process_tokens() unexpected return\n"); exit(1); } while ((rc = tds_process_tokens(tds, &result_type, &done_flags, TDS_TOKEN_RESULTS)) == TDS_SUCCESS) { switch (result_type) { case TDS_NO_MORE_RESULTS: return; case TDS_DONE_RESULT: case TDS_DONEPROC_RESULT: case TDS_DONEINPROC_RESULT: if (!(done_flags & TDS_DONE_ERROR)) break; default: fprintf(stderr, "tds_process_tokens() unexpected result_type\n"); exit(1); break; } } query("DROP TABLE #tmp"); /* do sone select to test results */ /* * for (s = strings; *s; ++s) { * printf("%s\n", to_utf8(*s, tmp)); * } */ } int main(int argc, char **argv) { TDSLOGIN *login; int ret; int verbose = 0; /* use UTF-8 as our coding */ strcpy(CHARSET, "UTF-8"); ret = try_tds_login(&login, &tds, __FILE__, verbose); if (ret != TDS_SUCCESS) { fprintf(stderr, "try_tds_login() failed\n"); return 1; } if (IS_TDS7_PLUS(tds->conn)) { char type[32]; char buf[1024]; int i, len; strcpy(buf, "aaa"); len = 0; for (i = 0; strlen(buf) < 980 && len < 200; ++i) { char tmp[256]; strcat(buf, japanese); len += strlen(to_utf8(japanese, tmp)); } strings[sizeof(strings) / sizeof(strings[0]) - 5] = buf + 3; strings[sizeof(strings) / sizeof(strings[0]) - 4] = buf + 2; strings[sizeof(strings) / sizeof(strings[0]) - 3] = buf + 1; strings[sizeof(strings) / sizeof(strings[0]) - 2] = buf; test("NVARCHAR(500)", "NVARCHAR with large size"); sprintf(type, "NVARCHAR(%d)", utf8_max_len); test(type, "NVARCHAR with sufficient size"); test("NTEXT", "TEXT"); /* TODO test parameters */ } try_tds_logout(login, tds, verbose); return 0; } freetds-1.00.82/src/tds/unittests/utf8.c100644 025423 025423 00000003513 12522201763 0013505/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2010 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #undef NDEBUG #define TDS_DONT_DEFINE_DEFAULT_FUNCTIONS #include "common.h" #include #include int utf8_max_len = 0; int get_unichar(const char **psrc) { const char *src = *psrc; int n; if (!*src) return -1; if (src[0] == '&' && src[1] == '#') { char *end; int radix = 10; if (toupper(src[2]) == 'X') { radix = 16; ++src; } n = strtol(src+2, &end, radix); assert(*end == ';' && n > 0 && n < 0x10000); src = end + 1; } else { n = (unsigned char) *src++; } *psrc = src; return n; } char * to_utf8(const char *src, char *dest) { unsigned char *p = (unsigned char *) dest; int len = 0, n; while ((n=get_unichar(&src)) > 0) { if (n >= 0x2000) { *p++ = 0xe0 | (n >> 12); *p++ = 0x80 | ((n >> 6) & 0x3f); *p++ = 0x80 | (n & 0x3f); } else if (n >= 0x80) { *p++ = 0xc0 | (n >> 6); *p++ = 0x80 | (n & 0x3f); } else { *p++ = (unsigned char) n; } ++len; } if (len > utf8_max_len) utf8_max_len = len; *p = 0; return dest; } freetds-1.00.82/src/tds/unittests/utf8_2.c100644 025423 025423 00000014563 12717145107 0013742/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2003, 2004 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "common.h" #include #include /* try conversion from utf8 to iso8859-1 */ static TDSSOCKET *tds; static int g_result = 0; static int einval_error = 0; static int eilseq_error = 0; static int einval_count = 0; static int eilseq_count = 0; static int e2big_count = 0; static char test_name[128]; static int invalid_char = -1; static void test(int n, int type) { int rc; TDS_INT result_type; char buf[1024], tmp[1024]; TDSCOLUMN *curcol; char *src; int done_flags; int i; char prefix[32], suffix[32]; sprintf(test_name, "test %d len %d", type, n); /* do a select and check all results */ prefix[0] = 0; suffix[0] = 0; tmp[0] = 0; switch (type) { case 0: strcpy(suffix, "C280C290"); break; case 1: /* try two invalid in different part */ strcpy(prefix, "C480C290"); strcpy(suffix, "C480C290"); break; } for (i = 0; i < n; ++i) sprintf(strchr(tmp, 0), "%02X", 0x30 + (i % 10)); sprintf(buf, "select convert(varchar(255), 0x%s%s%s)", prefix, tmp, suffix); rc = tds_submit_query(tds, buf); if (rc != TDS_SUCCESS) { fprintf(stderr, "tds_submit_query() failed\n"); exit(1); } if (tds_process_tokens(tds, &result_type, NULL, TDS_TOKEN_RESULTS) != TDS_SUCCESS) { fprintf(stderr, "tds_process_tokens() failed\n"); exit(1); } if (result_type != TDS_ROWFMT_RESULT) { fprintf(stderr, "expected row fmt() failed\n"); exit(1); } if (tds_process_tokens(tds, &result_type, NULL, TDS_TOKEN_RESULTS) != TDS_SUCCESS) { fprintf(stderr, "tds_process_tokens() failed\n"); exit(1); } if (result_type != TDS_ROW_RESULT) { fprintf(stderr, "expected row result() failed\n"); exit(1); } /* force tds to convert from utf8 to iso8859-1 (even on Sybase) */ tds_srv_charset_changed(tds->conn, "UTF-8"); tds->current_results->columns[0]->char_conv = tds->conn->char_convs[client2server_chardata]; rc = tds_process_tokens(tds, &result_type, NULL, TDS_STOPAT_ROWFMT|TDS_RETURN_DONE|TDS_RETURN_ROW|TDS_RETURN_COMPUTE); if (rc != TDS_SUCCESS) { fprintf(stderr, "tds_process_tokens() failed\n"); exit(1); } curcol = tds->current_results->columns[0]; src = (char*) curcol->column_data; if (is_blob_col(curcol)) { TDSBLOB *blob = (TDSBLOB *) src; src = blob->textvalue; } prefix[0] = 0; suffix[0] = 0; tmp[0] = 0; switch (type) { case 0: strcpy(suffix, "\x80\x90"); break; case 1: /* try two invalid in different part */ strcpy(prefix, "?\x90"); strcpy(suffix, "?\x90"); /* some platforms replace invalid sequence with a fixed char */ if (invalid_char < 0) invalid_char = (unsigned char) src[0]; prefix[0] = (char) invalid_char; suffix[0] = (char) invalid_char; break; } for (i = 0; i < n; ++i) sprintf(strchr(tmp, 0), "%c", "0123456789"[i % 10]); sprintf(buf, "%s%s%s", prefix, tmp, suffix); if (strlen(buf) != curcol->column_cur_size || strncmp(buf, src, curcol->column_cur_size) != 0) { int l = curcol->column_cur_size; if (l > 1000) l = 1000; strncpy(tmp, src, l); tmp[l] = 0; fprintf(stderr, "Wrong result in %s\n Got: '%s' len %d\n Expected: '%s' len %u\n", test_name, tmp, curcol->column_cur_size, buf, (unsigned int) strlen(buf)); exit(1); } rc = tds_process_tokens(tds, &result_type, NULL, TDS_STOPAT_ROWFMT|TDS_RETURN_DONE|TDS_RETURN_ROW|TDS_RETURN_COMPUTE); if (rc != TDS_SUCCESS || result_type == TDS_ROW_RESULT) { fprintf(stderr, "tds_process_tokens() unexpected return\n"); exit(1); } while ((rc = tds_process_tokens(tds, &result_type, &done_flags, TDS_TOKEN_RESULTS)) == TDS_SUCCESS) { switch (result_type) { case TDS_NO_MORE_RESULTS: break; case TDS_DONE_RESULT: case TDS_DONEPROC_RESULT: case TDS_DONEINPROC_RESULT: if (!(done_flags & TDS_DONE_ERROR)) break; default: fprintf(stderr, "tds_process_tokens() unexpected result_type\n"); exit(1); break; } } } static int err_handler(const TDSCONTEXT * tds_ctx, TDSSOCKET * tds, TDSMESSAGE * msg) { int error = 0; if (strstr(msg->message, "EINVAL")) { ++einval_count; if (einval_error) error = 1; } else if (strstr(msg->message, "could not be converted")) { ++eilseq_count; if (eilseq_error) error = 1; } else if (strstr(msg->message, "E2BIG")) { ++e2big_count; error = 1; } else { error = 1; } if (error) { fprintf(stderr, "Unexpected in %s error: %s\n", test_name, msg->message); g_result = 1; } return TDS_INT_CANCEL; } int main(int argc, char **argv) { TDSLOGIN *login; int ret; int verbose = 0; int i; typedef int (*perr)(const TDSCONTEXT *, TDSSOCKET *, TDSMESSAGE *); const perr * my_err; /* use ISO8859-1 as our coding */ strcpy(CHARSET, "ISO8859-1"); ret = try_tds_login(&login, &tds, __FILE__, verbose); if (ret != TDS_SUCCESS) { fprintf(stderr, "try_tds_login() failed\n"); return 1; } /* override a const in a safe way */ my_err = &tds_get_ctx(tds)->err_handler; *((perr*)my_err) = err_handler; /* prepend some characters to check part of sequence error */ einval_error = 1; eilseq_error = 1; /* do not stop on first error so we check conversion correct */ for (i = 0; i <= 192; ++i) test(i, 0); /* try creating a double conversion warning */ eilseq_error = 0; einval_error = 0; /* we already tested this error above */ for (i = 0; i <= 192; ++i) { eilseq_count = 0; test(i, 1); if (eilseq_count > 1) { fprintf(stderr, "Two warnings returned instead of one in %s\n", test_name); g_result = 1; break; } if (eilseq_count < 1 && invalid_char == '?') { fprintf(stderr, "No warning returned in %s\n", test_name); g_result = 1; } } try_tds_logout(login, tds, verbose); return g_result; } freetds-1.00.82/src/tds/unittests/utf8_3.c100644 025423 025423 00000007472 12717145107 0013744/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns * Copyright (C) 2010 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "common.h" #include #include #include #include static TDSSOCKET *tds; static void test(const char *buf) { char query[1024]; char tmp[129 * 3]; int i; int rc; TDS_INT result_type; int done_flags; to_utf8(buf, tmp); sprintf(query, "SELECT 1 AS [%s]", tmp); /* do a select and check all results */ rc = tds_submit_query(tds, query); if (rc != TDS_SUCCESS) { fprintf(stderr, "tds_submit_query() failed\n"); exit(1); } if (tds_process_tokens(tds, &result_type, NULL, TDS_TOKEN_RESULTS) != TDS_SUCCESS) { fprintf(stderr, "tds_process_tokens() failed\n"); exit(1); } if (result_type != TDS_ROWFMT_RESULT) { fprintf(stderr, "expected row fmt() failed\n"); exit(1); } if (tds_process_tokens(tds, &result_type, NULL, TDS_TOKEN_RESULTS) != TDS_SUCCESS) { fprintf(stderr, "tds_process_tokens() failed\n"); exit(1); } if (result_type != TDS_ROW_RESULT) { fprintf(stderr, "expected row result() failed\n"); exit(1); } i = 0; while ((rc = tds_process_tokens(tds, &result_type, NULL, TDS_STOPAT_ROWFMT|TDS_STOPAT_DONE|TDS_RETURN_ROW|TDS_RETURN_COMPUTE)) == TDS_SUCCESS) { TDSCOLUMN *curcol; if (result_type != TDS_ROW_RESULT) break; curcol = tds->current_results->columns[0]; if (strcmp(tmp, tds_dstr_cstr(&curcol->column_name)) != 0) { strlcpy(query, tds_dstr_cstr(&curcol->column_name), sizeof(query)); fprintf(stderr, "Wrong result Got: '%s' len %u\n Expected: '%s' len %u\n", query, (unsigned) tds_dstr_len(&curcol->column_name), tmp, (unsigned int) strlen(tmp)); exit(1); } ++i; } if (rc != TDS_SUCCESS || result_type == TDS_ROW_RESULT || result_type == TDS_COMPUTE_RESULT) { fprintf(stderr, "tds_process_tokens() unexpected return\n"); exit(1); } while ((rc = tds_process_tokens(tds, &result_type, &done_flags, TDS_TOKEN_RESULTS)) == TDS_SUCCESS) { switch (result_type) { case TDS_NO_MORE_RESULTS: return; case TDS_DONE_RESULT: case TDS_DONEPROC_RESULT: case TDS_DONEINPROC_RESULT: if (!(done_flags & TDS_DONE_ERROR)) break; default: fprintf(stderr, "tds_proces_tokens() unexpected result_type\n"); exit(1); break; } } } int main(int argc, char **argv) { TDSLOGIN *login; int ret; int verbose = 0; /* use UTF-8 as our coding */ strcpy(CHARSET, "UTF-8"); ret = try_tds_login(&login, &tds, __FILE__, verbose); if (ret != TDS_SUCCESS) { fprintf(stderr, "try_tds_login() failed\n"); return 1; } if (IS_TDS7_PLUS(tds->conn)) { char buf[129 * 8]; int i; /* build a string of length 128 */ strcpy(buf, ""); for (i = 1; i <= 128; ++i) { sprintf(strchr(buf, 0), "&#x%04x;", 0x4000 + i); } /* do all test */ for (i = 1;;) { printf("Testing len %d\n", i); test(buf + 8 * (128 - i)); if (i == 128) break; ++i; if (i > 12) i += 3; if (i >= 128) i = 128; } } try_tds_logout(login, tds, verbose); return 0; } freetds-1.00.82/src/tds/unittests/CMakeLists.txt100644 025423 025423 00000001352 12717145107 0015217include_directories(..) add_library(t_common STATIC common.c common.h utf8.c) if(NOT WIN32) set(unix_TESTS challenge) endif(NOT WIN32) foreach(target t0001 t0002 t0003 t0004 t0005 t0006 t0007 t0008 dynamic1 convert dataread utf8_1 utf8_2 utf8_3 numeric iconv_fread toodynamic readconf collations corrupt ${unix_TESTS}) add_executable(t_${target} EXCLUDE_FROM_ALL ${target}.c) set_target_properties(t_${target} PROPERTIES OUTPUT_NAME ${target}) target_link_libraries(t_${target} t_common tds replacements ${lib_NETWORK} ${lib_BASE}) if(NOT ${target} STREQUAL "collations") add_test(NAME t_${target} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${target}) endif() add_dependencies(check t_${target}) endforeach(target) freetds-1.00.82/src/tds/unittests/readconf.in100644 025423 025423 00000000145 12522201763 0014562[section1] opt1=value1 [SECTION2] opt two=value2 [Section 3] opt three = value three freetds-1.00.82/src/ctlib/Makefile.am100644 025423 025423 00000001144 13203773221 0012746# $Id: Makefile.am,v 1.29 2011-06-08 09:25:53 freddy77 Exp $ SUBDIRS = . unittests AM_CPPFLAGS = -I$(top_srcdir)/include lib_LTLIBRARIES = libct.la libct_la_SOURCES= ct.c cs.c blk.c ctutil.c if MINGW32 libct_la_SOURCES += winmain.c endif # version bumped for 0.64, I hope we'll bump it less in the future -- freddy77 libct_la_LDFLAGS = -version-info 4:0:0 $(FREETDS_SYMBOLIC) if !MACOSX libct_la_LDFLAGS += -export-symbols-regex '^(cs_|ct_|blk_).*' endif libct_la_LIBADD = ../tds/libtds.la ../replacements/libreplacements.la $(FREETDS_LIBGCC) $(LTLIBICONV) EXTRA_DIST = ctlib.def CMakeLists.txt winmain.c freetds-1.00.82/src/ctlib/Makefile.in100644 025423 025423 00000066447 13242511111 0012767# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @MINGW32_TRUE@am__append_1 = winmain.c @MACOSX_FALSE@am__append_2 = -export-symbols-regex '^(cs_|ct_|blk_).*' subdir = src/ctlib ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = \ $(top_srcdir)/m4/ac_caolan_func_which_gethostbyname_r.m4 \ $(top_srcdir)/m4/ac_have_inaddr_none.m4 \ $(top_srcdir)/m4/ac_have_malloc_options.m4 \ $(top_srcdir)/m4/ac_nullzero.m4 \ $(top_srcdir)/m4/ac_raf_func_which_getservbyname_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_gethostbyaddr_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_getpwuid_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_localtime_r.m4 \ $(top_srcdir)/m4/acx_pthread.m4 \ $(top_srcdir)/m4/ax_cflags_gcc_option.m4 \ $(top_srcdir)/m4/check_openssl.m4 \ $(top_srcdir)/m4/gettimemilli.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/pushlibs.m4 \ $(top_srcdir)/m4/sprintf_i64_format.m4 \ $(top_srcdir)/m4/type_socklen_t.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(libdir)" LTLIBRARIES = $(lib_LTLIBRARIES) am__DEPENDENCIES_1 = libct_la_DEPENDENCIES = ../tds/libtds.la \ ../replacements/libreplacements.la $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) am__libct_la_SOURCES_DIST = ct.c cs.c blk.c ctutil.c winmain.c @MINGW32_TRUE@am__objects_1 = winmain.lo am_libct_la_OBJECTS = ct.lo cs.lo blk.lo ctutil.lo $(am__objects_1) libct_la_OBJECTS = $(am_libct_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = libct_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(libct_la_LDFLAGS) $(LDFLAGS) -o $@ AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libct_la_SOURCES) DIST_SOURCES = $(am__libct_la_SOURCES_DIST) RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp \ $(top_srcdir)/mkinstalldirs DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BUILD_NUMBER = @BUILD_NUMBER@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOXYGEN = @DOXYGEN@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FREETDS_LIBGCC = @FREETDS_LIBGCC@ FREETDS_ODBC_MODULE = @FREETDS_ODBC_MODULE@ FREETDS_SYMBOLIC = @FREETDS_SYMBOLIC@ GCRYPT_CFLAGS = @GCRYPT_CFLAGS@ GCRYPT_LIBS = @GCRYPT_LIBS@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ HAVE_OPENSSL = @HAVE_OPENSSL@ HAVE_PERL_SOURCES = @HAVE_PERL_SOURCES@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBADD_DL = @LIBADD_DL@ LIBADD_DLD_LINK = @LIBADD_DLD_LINK@ LIBADD_DLOPEN = @LIBADD_DLOPEN@ LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@ LIBICONV = @LIBICONV@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBOBJS = @LTLIBOBJS@ LT_DLLOADERS = @LT_DLLOADERS@ LT_DLPREOPEN = @LT_DLPREOPEN@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ NETTLE_CFLAGS = @NETTLE_CFLAGS@ NETTLE_LIBS = @NETTLE_LIBS@ NETWORK_LIBS = @NETWORK_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ODBC = @ODBC@ ODBCINSTLIB = @ODBCINSTLIB@ ODBCLIB = @ODBCLIB@ ODBCNODMLIB = @ODBCNODMLIB@ ODBCNODMLIBAPP = @ODBCNODMLIBAPP@ ODBC_CONFIG = @ODBC_CONFIG@ ODBC_INC = @ODBC_INC@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ RC = @RC@ READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SUBVERSION = @SUBVERSION@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ dblib_define = @dblib_define@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ tds_sysdep_int16_type = @tds_sysdep_int16_type@ tds_sysdep_int32_type = @tds_sysdep_int32_type@ tds_sysdep_int64_type = @tds_sysdep_int64_type@ tds_sysdep_intptr_type = @tds_sysdep_intptr_type@ tds_sysdep_real32_type = @tds_sysdep_real32_type@ tds_sysdep_real64_type = @tds_sysdep_real64_type@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # $Id: Makefile.am,v 1.29 2011-06-08 09:25:53 freddy77 Exp $ SUBDIRS = . unittests AM_CPPFLAGS = -I$(top_srcdir)/include lib_LTLIBRARIES = libct.la libct_la_SOURCES = ct.c cs.c blk.c ctutil.c $(am__append_1) # version bumped for 0.64, I hope we'll bump it less in the future -- freddy77 libct_la_LDFLAGS = -version-info 4:0:0 $(FREETDS_SYMBOLIC) \ $(am__append_2) libct_la_LIBADD = ../tds/libtds.la ../replacements/libreplacements.la $(FREETDS_LIBGCC) $(LTLIBICONV) EXTRA_DIST = ctlib.def CMakeLists.txt winmain.c all: all-recursive .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/ctlib/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/ctlib/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libct.la: $(libct_la_OBJECTS) $(libct_la_DEPENDENCIES) $(EXTRA_libct_la_DEPENDENCIES) $(AM_V_CCLD)$(libct_la_LINK) -rpath $(libdir) $(libct_la_OBJECTS) $(libct_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/blk.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cs.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ct.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ctutil.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/winmain.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile $(LTLIBRARIES) installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(libdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ mostlyclean-am distclean: distclean-recursive -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-libLTLIBRARIES install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-libLTLIBRARIES .MAKE: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-generic clean-libLTLIBRARIES \ clean-libtool cscopelist-am ctags ctags-am distclean \ distclean-compile distclean-generic 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-libLTLIBRARIES install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs installdirs-am 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-libLTLIBRARIES .PRECIOUS: Makefile # 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: freetds-1.00.82/src/ctlib/ct.c100644 025423 025423 00000363220 13175043421 0011472/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001 Brian Bruns * Copyright (C) 2002, 2003, 2004, 2005 James K. Lowden * Copyright (C) 2011-2015 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include "ctpublic.h" #include "ctlib.h" #include #include #include #include "replacements.h" static const char * ct_describe_cmd_state(CS_INT state); /** * Read a row of data * @return 0 on success */ static int _ct_fetch_cursor(CS_COMMAND * cmd, CS_INT type, CS_INT offset, CS_INT option, CS_INT * rows_read); static int _ct_fetchable_results(CS_COMMAND * cmd); static TDSRET _ct_process_return_status(TDSSOCKET * tds); static int _ct_fill_param(CS_INT cmd_type, CS_PARAM * param, CS_DATAFMT * datafmt, CS_VOID * data, CS_INT * datalen, CS_SMALLINT * indicator, CS_BYTE byvalue); void _ctclient_msg(CS_CONNECTION * con, const char *funcname, int layer, int origin, int severity, int number, const char *fmt, ...); int _ct_bind_data(CS_CONTEXT *ctx, TDSRESULTINFO * resinfo, TDSRESULTINFO *bindinfo, CS_INT offset); static void _ct_initialise_cmd(CS_COMMAND *cmd); static CS_RETCODE _ct_cancel_cleanup(CS_COMMAND * cmd); static CS_INT _ct_map_compute_op(CS_INT comp_op); /* Added for CT_DIAG */ /* Code changes starts here - CT_DIAG - 01 */ static CS_INT ct_diag_storeclientmsg(CS_CONTEXT * context, CS_CONNECTION * conn, CS_CLIENTMSG * message); static CS_INT ct_diag_storeservermsg(CS_CONTEXT * context, CS_CONNECTION * conn, CS_SERVERMSG * message); static CS_INT ct_diag_countmsg(CS_CONTEXT * context, CS_INT type, CS_INT * count); static CS_INT ct_diag_getclientmsg(CS_CONTEXT * context, CS_INT idx, CS_CLIENTMSG * message); static CS_INT ct_diag_getservermsg(CS_CONTEXT * context, CS_INT idx, CS_SERVERMSG * message); /* Code changes ends here - CT_DIAG - 01 */ /* Added code for RPC functionality -SUHA */ /* RPC Code changes starts here */ static void rpc_clear(CSREMOTE_PROC * rpc); static void param_clear(CSREMOTE_PROC_PARAM * pparam); static TDSPARAMINFO *paraminfoalloc(TDSSOCKET * tds, CS_PARAM * first_param); static CS_DYNAMIC * _ct_allocate_dynamic(CS_CONNECTION * con, char *id, int idlen); static CS_INT _ct_deallocate_dynamic(CS_CONNECTION * con, CS_DYNAMIC *dyn); static CS_DYNAMIC * _ct_locate_dynamic(CS_CONNECTION * con, char *id, int idlen); /* RPC Code changes ends here */ static const char * _ct_get_layer(int layer) { tdsdump_log(TDS_DBG_FUNC, "_ct_get_layer(%d)\n", layer); switch (layer) { case 1: return "user api layer"; break; case 2: return "blk layer"; break; default: break; } return "unrecognized layer"; } static const char * _ct_get_origin(int origin) { tdsdump_log(TDS_DBG_FUNC, "_ct_get_origin(%d)\n", origin); switch (origin) { case 1: return "external error"; break; case 2: return "internal CT-Library error"; break; case 4: return "common library error"; break; case 5: return "intl library error"; break; case 6: return "user error"; break; case 7: return "internal BLK-Library error"; break; default: break; } return "unrecognized origin"; } static const char * _ct_get_user_api_layer_error(int error) { tdsdump_log(TDS_DBG_FUNC, "_ct_get_user_api_layer_error(%d)\n", error); switch (error) { case 137: return "A bind count of %1! is not consistent with the count supplied for existing binds. " "The current bind count is %2!."; break; case 138: return "Use direction CS_BLK_IN or CS_BLK_OUT for a bulk copy operation."; break; case 139: return "The parameter tblname cannot be NULL."; break; case 140: return "Failed when processing results from server."; break; case 141: return "Parameter %1! has an illegal value of %2!"; break; case 142: return "No value or default value available and NULL not allowed. col = %1! row = %2! ."; break; case 143: return "parameter name(s) must be supplied for LANGUAGE command."; break; case 16843163: return "This routine cannot be called when the command structure is idle."; break; default: break; } return "unrecognized error"; } static char * _ct_get_msgstr(const char *funcname, int layer, int origin, int severity, int number) { char *m; tdsdump_log(TDS_DBG_FUNC, "_ct_get_msgstr(%s, %d, %d, %d, %d)\n", funcname, layer, origin, severity, number); if (asprintf(&m, "%s: %s: %s: %s", funcname, _ct_get_layer(layer), _ct_get_origin(origin), _ct_get_user_api_layer_error(number) ) < 0) { return NULL; } return m; } void _ctclient_msg(CS_CONNECTION * con, const char *funcname, int layer, int origin, int severity, int number, const char *fmt, ...) { CS_CONTEXT *ctx = con->ctx; va_list ap; CS_CLIENTMSG cm; char *msgstr; tdsdump_log(TDS_DBG_FUNC, "_ctclient_msg(%p, %s, %d, %d, %d, %d, %s)\n", con, funcname, layer, origin, severity, number, fmt); va_start(ap, fmt); if (ctx->_clientmsg_cb) { cm.severity = severity; cm.msgnumber = (((layer << 24) & 0xFF000000) | ((origin << 16) & 0x00FF0000) | ((severity << 8) & 0x0000FF00) | ((number) & 0x000000FF)); msgstr = _ct_get_msgstr(funcname, layer, origin, severity, number); tds_vstrbuild(cm.msgstring, CS_MAX_MSG, &(cm.msgstringlen), msgstr, CS_NULLTERM, fmt, CS_NULLTERM, ap); cm.msgstring[cm.msgstringlen] = '\0'; free(msgstr); cm.osnumber = 0; cm.osstring[0] = '\0'; cm.osstringlen = 0; cm.status = 0; /* cm.sqlstate */ cm.sqlstatelen = 0; ctx->_clientmsg_cb(ctx, con, &cm); } va_end(ap); } static CS_RETCODE ct_set_command_state(CS_COMMAND *cmd, CS_INT state) { tdsdump_log(TDS_DBG_FUNC, "setting command state to %s (from %s)\n", ct_describe_cmd_state(state), ct_describe_cmd_state(cmd->command_state)); cmd->command_state = state; return CS_SUCCEED; } static const char * ct_describe_cmd_state(CS_INT state) { tdsdump_log(TDS_DBG_FUNC, "ct_describe_cmd_state(%d)\n", state); switch (state) { case _CS_COMMAND_IDLE: return "IDLE"; case _CS_COMMAND_BUILDING: return "BUILDING"; case _CS_COMMAND_READY: return "READY"; case _CS_COMMAND_SENT: return "SENT"; } return "???"; } CS_RETCODE ct_exit(CS_CONTEXT * ctx, CS_INT unused) { tdsdump_log(TDS_DBG_FUNC, "ct_exit(%p, %d)\n", ctx, unused); return CS_SUCCEED; } CS_RETCODE ct_init(CS_CONTEXT * ctx, CS_INT version) { /* uncomment the next line to get pre-login trace */ /* tdsdump_open("/tmp/tds2.log"); */ tdsdump_log(TDS_DBG_FUNC, "ct_init(%p, %d)\n", ctx, version); ctx->tds_ctx->msg_handler = _ct_handle_server_message; ctx->tds_ctx->err_handler = _ct_handle_client_message; return CS_SUCCEED; } CS_RETCODE ct_con_alloc(CS_CONTEXT * ctx, CS_CONNECTION ** con) { TDSLOGIN *login; tdsdump_log(TDS_DBG_FUNC, "ct_con_alloc(%p, %p)\n", ctx, con); login = tds_alloc_login(1); if (!login) return CS_FAIL; /* set default values */ if (!tds_set_library(login, "CT-Library")) { tds_free_login(login); return CS_FAIL; } *con = tds_new0(CS_CONNECTION, 1); if (!*con) { tds_free_login(login); return CS_FAIL; } (*con)->tds_login = login; (*con)->server_addr = NULL; /* so we know who we belong to */ (*con)->ctx = ctx; /* tds_set_client_charset((*con)->tds_login, "iso_1"); */ /* tds_set_packet((*con)->tds_login, TDS_DEF_BLKSZ); */ return CS_SUCCEED; } CS_RETCODE ct_callback(CS_CONTEXT * ctx, CS_CONNECTION * con, CS_INT action, CS_INT type, CS_VOID * func) { int (*funcptr) (void *, void *, void *) = (int (*)(void *, void *, void *)) func; tdsdump_log(TDS_DBG_FUNC, "ct_callback(%p, %p, %d, %d, %p)\n", ctx, con, action, type, func); tdsdump_log(TDS_DBG_FUNC, "ct_callback() action = %s\n", CS_GET ? "CS_GET" : "CS_SET"); /* one of these has to be defined */ if (!ctx && !con) return CS_FAIL; if (action == CS_GET) { switch (type) { case CS_CLIENTMSG_CB: *(void **) func = (CS_VOID *) (con ? con->_clientmsg_cb : ctx->_clientmsg_cb); return CS_SUCCEED; case CS_SERVERMSG_CB: *(void **) func = (CS_VOID *) (con ? con->_servermsg_cb : ctx->_servermsg_cb); return CS_SUCCEED; default: fprintf(stderr, "Unknown callback %d\n", type); *(void **) func = NULL; return CS_SUCCEED; } } /* CS_SET */ switch (type) { case CS_CLIENTMSG_CB: if (con) con->_clientmsg_cb = (CS_CLIENTMSG_FUNC) funcptr; else ctx->_clientmsg_cb = (CS_CLIENTMSG_FUNC) funcptr; break; case CS_SERVERMSG_CB: if (con) con->_servermsg_cb = (CS_SERVERMSG_FUNC) funcptr; else ctx->_servermsg_cb = (CS_SERVERMSG_FUNC) funcptr; break; } return CS_SUCCEED; } CS_RETCODE ct_con_props(CS_CONNECTION * con, CS_INT action, CS_INT property, CS_VOID * buffer, CS_INT buflen, CS_INT * out_len) { CS_INT intval, maxcp; TDSSOCKET *tds; TDSLOGIN *tds_login; tdsdump_log(TDS_DBG_FUNC, "ct_con_props(%p, %d, %d, %p, %d, %p)\n", con, action, property, buffer, buflen, out_len); tdsdump_log(TDS_DBG_FUNC, "ct_con_props() action = %s property = %d\n", CS_GET ? "CS_GET" : "CS_SET", property); tds = con->tds_socket; tds_login = con->tds_login; if (action == CS_SET) { char *set_buffer = NULL; bool copy_ret = true; if (property == CS_USERNAME || property == CS_PASSWORD || property == CS_APPNAME || property == CS_HOSTNAME || property == CS_SERVERADDR) { if (buflen == CS_NULLTERM) { set_buffer = strdup((char *) buffer); } else if (buflen == CS_UNUSED) { return CS_SUCCEED; } else { set_buffer = tds_strndup(buffer, buflen); } } /* * XXX "login" properties shouldn't be set after * login. I don't know if it should fail silently * or return an error. */ switch (property) { case CS_USERNAME: copy_ret = tds_set_user(tds_login, set_buffer); break; case CS_PASSWORD: copy_ret = tds_set_passwd(tds_login, set_buffer); break; case CS_APPNAME: copy_ret = tds_set_app(tds_login, set_buffer); break; case CS_HOSTNAME: copy_ret = tds_set_host(tds_login, set_buffer); break; case CS_PORT: tds_set_port(tds_login, *((int *) buffer)); break; case CS_SERVERADDR: { /* Format of this property: "[hostname] [port]" */ char *host, *port, *lasts = NULL; int portno; host= strtok_r(set_buffer, " ", &lasts); port= strtok_r(NULL, " ", &lasts); if (!host || !port) { free(set_buffer); return CS_FAIL; } portno = (int)strtol(port, NULL, 10); if (portno < 1 || portno >= 65536) { free(set_buffer); return CS_FAIL; } con->server_addr = strdup(host); tds_set_port(tds_login, portno); break; } case CS_LOC_PROP: /* sybase docs say that this structure must be copied, not referenced */ if (!buffer) return CS_FAIL; if (con->locale) _cs_locale_free(con->locale); con->locale = _cs_locale_copy((CS_LOCALE *) buffer); if (!con->locale) return CS_FAIL; break; case CS_USERDATA: free(con->userdata); con->userdata = (void *) malloc(buflen + 1); tdsdump_log(TDS_DBG_INFO2, "setting userdata orig %p new %p\n", buffer, con->userdata); con->userdata_len = buflen; memcpy(con->userdata, buffer, buflen); break; case CS_BULK_LOGIN: memcpy(&intval, buffer, sizeof(intval)); if (intval) tds_set_bulk(tds_login, 1); else tds_set_bulk(tds_login, 0); break; case CS_PACKETSIZE: memcpy(&intval, buffer, sizeof(intval)); tds_set_packet(tds_login, (short) intval); break; case CS_TDS_VERSION: /* * FIXME * (a) We don't support all versions in tds/login.c - * I tried to pick reasonable versions. * (b) Might need support outside of tds/login.c * (c) It's a "negotiated" property so probably * needs tds_process_env_chg() support * (d) Minor - we don't check against context * which should limit the acceptable values */ if (*(int *) buffer == CS_TDS_40) { tds_set_version(tds_login, 4, 2); } else if (*(int *) buffer == CS_TDS_42) { tds_set_version(tds_login, 4, 2); } else if (*(int *) buffer == CS_TDS_46) { tds_set_version(tds_login, 4, 6); } else if (*(int *) buffer == CS_TDS_495) { tds_set_version(tds_login, 4, 6); } else if (*(int *) buffer == CS_TDS_50) { tds_set_version(tds_login, 5, 0); } else if (*(int *) buffer == CS_TDS_70) { tds_set_version(tds_login, 7, 0); } else if (*(int *) buffer == CS_TDS_71) { tds_set_version(tds_login, 7, 1); } else if (*(int *) buffer == CS_TDS_72) { tds_set_version(tds_login, 7, 2); } else if (*(int *) buffer == CS_TDS_73) { tds_set_version(tds_login, 7, 3); } else if (*(int *) buffer == CS_TDS_74) { tds_set_version(tds_login, 7, 4); } else { return CS_FAIL; } break; default: tdsdump_log(TDS_DBG_ERROR, "Unknown property %d\n", property); break; } free(set_buffer); if (!copy_ret) return CS_FAIL; } else if (action == CS_GET) { DSTR *s; switch (property) { case CS_USERNAME: s = &tds_login->user_name; goto str_copy; case CS_PASSWORD: s = &tds_login->password; goto str_copy; case CS_APPNAME: s = &tds_login->app_name; goto str_copy; case CS_HOSTNAME: s = &tds_login->client_host_name; goto str_copy; case CS_SERVERNAME: s = &tds_login->server_name; str_copy: if (out_len) *out_len = tds_dstr_len(s); strlcpy((char *) buffer, tds_dstr_cstr(s), buflen); break; case CS_LOC_PROP: if (buflen != CS_UNUSED || !con->locale || !buffer) return CS_FAIL; if (!_cs_locale_copy_inplace((CS_LOCALE *) buffer, con->locale)) return CS_FAIL; break; case CS_USERDATA: tdsdump_log(TDS_DBG_INFO2, "fetching userdata %p\n", con->userdata); maxcp = con->userdata_len; if (out_len) *out_len = maxcp; if (maxcp > buflen) maxcp = buflen; memcpy(buffer, con->userdata, maxcp); break; case CS_CON_STATUS: intval = 0; if (!(IS_TDSDEAD(tds))) intval |= CS_CONSTAT_CONNECTED; if (tds && tds->state == TDS_DEAD) intval |= CS_CONSTAT_DEAD; memcpy(buffer, &intval, sizeof(intval)); break; case CS_BULK_LOGIN: if (tds_login->bulk_copy) intval = CS_FALSE; else intval = CS_TRUE; memcpy(buffer, &intval, sizeof(intval)); break; case CS_PACKETSIZE: if (tds) intval = tds->conn->env.block_size; else intval = tds_login->block_size; memcpy(buffer, &intval, sizeof(intval)); if (out_len) *out_len = sizeof(intval); break; case CS_TDS_VERSION: switch (tds->conn->tds_version) { case 0x400: (*(int *) buffer = CS_TDS_40); break; case 0x402: (*(int *) buffer = CS_TDS_42); break; case 0x406: (*(int *) buffer = CS_TDS_46); break; case 0x400 + 95: (*(int *) buffer = CS_TDS_495); break; case 0x500: (*(int *) buffer = CS_TDS_50); break; case 0x700: (*(int *) buffer = CS_TDS_70); break; case 0x701: (*(int *) buffer = CS_TDS_71); break; case 0x702: (*(int *) buffer = CS_TDS_72); break; case 0x703: (*(int *) buffer = CS_TDS_73); break; case 0x704: (*(int *) buffer = CS_TDS_74); break; default: return CS_FAIL; } break; case CS_PARENT_HANDLE: *(CS_CONTEXT **) buffer = con->ctx; break; default: tdsdump_log(TDS_DBG_ERROR, "Unknown property %d\n", property); break; } } return CS_SUCCEED; } CS_RETCODE ct_connect(CS_CONNECTION * con, CS_CHAR * servername, CS_INT snamelen) { char *server; int needfree = 0; CS_CONTEXT *ctx; TDSLOGIN *login; bool copy_ret; tdsdump_log(TDS_DBG_FUNC, "ct_connect(%p, %s, %d)\n", con, servername ? servername : "NULL", snamelen); if (con->server_addr) { server = ""; } else if (snamelen == 0 || snamelen == CS_UNUSED) { server = NULL; } else if (snamelen == CS_NULLTERM) { server = (char *) servername; } else { server = tds_strndup(servername, snamelen); needfree++; } copy_ret = tds_set_server(con->tds_login, server); if (needfree) free(server); if (!copy_ret) return CS_FAIL; ctx = con->ctx; if (!(con->tds_socket = tds_alloc_socket(ctx->tds_ctx, 512))) return CS_FAIL; tds_set_parent(con->tds_socket, (void *) con); if (!(login = tds_read_config_info(con->tds_socket, con->tds_login, ctx->tds_ctx->locale))) { tds_free_socket(con->tds_socket); con->tds_socket = NULL; return CS_FAIL; } if (con->server_addr) { if (TDS_FAILED(tds_lookup_host_set(con->server_addr, &login->ip_addrs))) goto Cleanup; if (!tds_dstr_copy(&login->server_host_name, con->server_addr)) goto Cleanup; } /* override locale settings with CS_CONNECTION settings, if any */ if (con->locale) { if (con->locale->charset) { if (!tds_dstr_copy(&login->server_charset, con->locale->charset)) goto Cleanup; } if (con->locale->language) { if (!tds_dstr_copy(&login->language, con->locale->language)) goto Cleanup; } if (con->locale->time && tds_get_ctx(con->tds_socket)) { TDSLOCALE *locale = tds_get_ctx(con->tds_socket)->locale; free(locale->date_fmt); /* TODO convert format from CTLib to libTDS */ locale->date_fmt = strdup(con->locale->time); if (!locale->date_fmt) goto Cleanup; } /* TODO how to handle this? if (con->locale->collate) { } */ } if (TDS_FAILED(tds_connect_and_login(con->tds_socket, login))) goto Cleanup; tds_free_login(login); tdsdump_log(TDS_DBG_FUNC, "leaving ct_connect() returning %d\n", CS_SUCCEED); return CS_SUCCEED; Cleanup: tds_free_socket(con->tds_socket); con->tds_socket = NULL; tds_free_login(login); tdsdump_log(TDS_DBG_FUNC, "leaving ct_connect() returning %d\n", CS_FAIL); return CS_FAIL; } CS_RETCODE ct_cmd_alloc(CS_CONNECTION * con, CS_COMMAND ** pcmd) { CS_COMMAND *pcommand, *cmd; tdsdump_log(TDS_DBG_FUNC, "ct_cmd_alloc(%p, %p)\n", con, pcmd); if (!con) return CS_FAIL; *pcmd = cmd = tds_new0(CS_COMMAND, 1); if (!cmd) return CS_FAIL; /* so we know who we belong to */ cmd->con = con; /* initialise command state */ ct_set_command_state(cmd, _CS_COMMAND_IDLE); if ( con->cmds == NULL ) { tdsdump_log(TDS_DBG_FUNC, "ct_cmd_alloc() : allocating command list to head\n"); con->cmds = cmd; } else { for (pcommand = con->cmds; pcommand->next != NULL; pcommand = pcommand->next) continue; pcommand->next = cmd; } return CS_SUCCEED; } CS_RETCODE ct_command(CS_COMMAND * cmd, CS_INT type, const CS_VOID * buffer, CS_INT buflen, CS_INT option) { int query_len, current_query_len; tdsdump_log(TDS_DBG_FUNC, "ct_command(%p, %d, %p, %d, %d)\n", cmd, type, buffer, buflen, option); if (cmd == NULL) return CS_FAIL; /* * Unless we are in the process of building a CS_LANG_CMD command, * clear everything, ready to start anew */ if (cmd->command_state != _CS_COMMAND_BUILDING) { _ct_initialise_cmd(cmd); ct_set_command_state(cmd, _CS_COMMAND_IDLE); } switch (type) { case CS_LANG_CMD: switch (option) { case CS_MORE: /* The text in buffer is only part of the language command to be executed. */ case CS_END: /* The text in buffer is the last part of the language command to be executed. */ case CS_UNUSED: /* Equivalent to CS_END. */ if (buflen == CS_NULLTERM) { query_len = strlen((const char *) buffer); } else { query_len = buflen; } /* small fix for no crash */ if (query_len == CS_UNUSED) { cmd->query = NULL; return CS_FAIL; } switch (cmd->command_state) { case _CS_COMMAND_IDLE: cmd->query = tds_strndup(buffer, query_len); if (option == CS_MORE) { ct_set_command_state(cmd, _CS_COMMAND_BUILDING); } else { ct_set_command_state(cmd, _CS_COMMAND_READY); } break; case _CS_COMMAND_BUILDING: current_query_len = strlen(cmd->query); cmd->query = (CS_CHAR *) realloc(cmd->query, current_query_len + query_len + 1); strncat(cmd->query, (const char *) buffer, query_len); cmd->query[current_query_len + query_len] = '\0'; if (option == CS_MORE) { ct_set_command_state(cmd, _CS_COMMAND_BUILDING); } else { ct_set_command_state(cmd, _CS_COMMAND_READY); } break; } break; default: return CS_FAIL; } break; case CS_RPC_CMD: /* Code changed for RPC functionality -SUHA */ /* RPC code changes starts here */ cmd->rpc = tds_new0(CSREMOTE_PROC, 1); if (cmd->rpc == NULL) return CS_FAIL; if (buflen == CS_NULLTERM) { cmd->rpc->name = strdup((const char*) buffer); if (cmd->rpc->name == NULL) return CS_FAIL; } else if (buflen > 0) { cmd->rpc->name = tds_strndup(buffer, buflen); if (cmd->rpc->name == NULL) return CS_FAIL; } else { return CS_FAIL; } cmd->rpc->param_list = NULL; tdsdump_log(TDS_DBG_INFO1, "ct_command() added rpcname \"%s\"\n", cmd->rpc->name); /* FIXME: I don't know the value for RECOMPILE, NORECOMPILE options. Hence assigning zero */ switch (option) { case CS_RECOMPILE: /* Recompile the stored procedure before executing it. */ cmd->rpc->options = 0; break; case CS_NO_RECOMPILE: /* Do not recompile the stored procedure before executing it. */ cmd->rpc->options = 0; break; case CS_UNUSED: /* Equivalent to CS_NO_RECOMPILE. */ cmd->rpc->options = 0; break; default: return CS_FAIL; } ct_set_command_state(cmd, _CS_COMMAND_READY); break; /* RPC code changes ends here */ case CS_SEND_DATA_CMD: switch (option) { case CS_COLUMN_DATA: /* The data will be used for a text or image column update. */ cmd->send_data_started = 0; break; case CS_BULK_DATA: /* For internal Sybase use only. The data will be used for a bulk copy operation. */ default: return CS_FAIL; } ct_set_command_state(cmd, _CS_COMMAND_READY); break; case CS_SEND_BULK_CMD: switch (option) { case CS_BULK_INIT: /* For internal Sybase use only. Initialize a bulk copy operation. */ case CS_BULK_CONT: /* For internal Sybase use only. Continue a bulk copy operation. */ default: return CS_FAIL; } ct_set_command_state(cmd, _CS_COMMAND_READY); break; default: return CS_FAIL; } cmd->command_type = type; return CS_SUCCEED; } static void _ct_initialise_cmd(CS_COMMAND *cmd) { free(cmd->query); cmd->query = NULL; tdsdump_log(TDS_DBG_FUNC, "_ct_initialise_cmd(%p)\n", cmd); if (cmd->input_params) { param_clear(cmd->input_params); cmd->input_params = NULL; } ct_set_command_state(cmd, _CS_COMMAND_IDLE); rpc_clear(cmd->rpc); cmd->rpc = NULL; } CS_RETCODE ct_send(CS_COMMAND * cmd) { TDSSOCKET *tds; TDSRET ret; TDSPARAMINFO *pparam_info; tdsdump_log(TDS_DBG_FUNC, "ct_send(%p)\n", cmd); if (!cmd || !cmd->con || !cmd->con->tds_socket) return CS_FAIL; tdsdump_log(TDS_DBG_FUNC, "ct_send() command_type = %d\n", cmd->command_type); tds = cmd->con->tds_socket; if (cmd->cancel_state == _CS_CANCEL_PENDING) { _ct_cancel_cleanup(cmd); return CS_CANCELED; } if (cmd->command_state == _CS_COMMAND_IDLE) { tdsdump_log(TDS_DBG_FUNC, "ct_send() command_state = IDLE\n"); _ctclient_msg(cmd->con, "ct_send", 1, 1, 1, 16843163, ""); return CS_FAIL; } cmd->results_state = _CS_RES_NONE; if (cmd->command_type == CS_DYNAMIC_CMD) { CS_DYNAMIC *dyn = cmd->dyn; TDSDYNAMIC *tdsdyn; if (dyn == NULL) return CS_FAIL; switch (cmd->dynamic_cmd) { case CS_PREPARE: if (TDS_FAILED(tds_submit_prepare(tds, dyn->stmt, dyn->id, &dyn->tdsdyn, NULL))) return CS_FAIL; ct_set_command_state(cmd, _CS_COMMAND_SENT); return CS_SUCCEED; break; case CS_EXECUTE: tdsdyn = dyn->tdsdyn; if (!tdsdyn) { tdsdump_log(TDS_DBG_INFO1, "ct_send(CS_EXECUTE) no tdsdyn!\n"); return CS_FAIL; } pparam_info = paraminfoalloc(tds, dyn->param_list); if (!pparam_info && dyn->param_list) return CS_FAIL; tds_free_input_params(tdsdyn); tdsdyn->params = pparam_info; if (TDS_FAILED(tds_submit_execute(tds, tdsdyn))) return CS_FAIL; ct_set_command_state(cmd, _CS_COMMAND_SENT); return CS_SUCCEED; break; case CS_DESCRIBE_INPUT: tdsdump_log(TDS_DBG_INFO1, "ct_send(CS_DESCRIBE_INPUT)\n"); ct_set_command_state(cmd, _CS_COMMAND_SENT); cmd->results_state = _CS_RES_DESCRIBE_RESULT; if (tds->cur_dyn) tds_set_current_results(tds, tds->cur_dyn->res_info); else tds_set_current_results(tds, tds->param_info); break; case CS_DESCRIBE_OUTPUT: tdsdump_log(TDS_DBG_INFO1, "ct_send(CS_DESCRIBE_OUTPUT)\n"); ct_set_command_state(cmd, _CS_COMMAND_SENT); cmd->results_state = _CS_RES_DESCRIBE_RESULT; tds_set_current_results(tds, tds->res_info); break; case CS_DEALLOC: tdsdyn = dyn->tdsdyn; if (!tdsdyn) { tdsdump_log(TDS_DBG_INFO1, "ct_send(CS_DEALLOC) no tdsdyn!\n"); return CS_FAIL; } if (TDS_FAILED(tds_submit_unprepare(tds, tdsdyn))) return CS_FAIL; ct_set_command_state(cmd, _CS_COMMAND_SENT); return CS_SUCCEED; break; default: return CS_FAIL; } } if (cmd->command_type == CS_RPC_CMD) { CSREMOTE_PROC *rpc = cmd->rpc; /* sanity */ if (cmd->rpc == NULL /* ct_command should allocate pointer */ || rpc->name == NULL) { /* can't be ready without a name */ return CS_FAIL; } pparam_info = paraminfoalloc(tds, rpc->param_list); ret = tds_submit_rpc(tds, rpc->name, pparam_info, NULL); tds_free_param_results(pparam_info); ct_set_command_state(cmd, _CS_COMMAND_SENT); if (TDS_FAILED(ret)) return CS_FAIL; return CS_SUCCEED; } /* RPC Code changes ends here */ if (cmd->command_type == CS_LANG_CMD) { ret = TDS_FAIL; if (cmd->input_params) { pparam_info = paraminfoalloc(tds, cmd->input_params); ret = tds_submit_query_params(tds, cmd->query, pparam_info, NULL); tds_free_param_results(pparam_info); } else { ret = tds_submit_query(tds, cmd->query); } ct_set_command_state(cmd, _CS_COMMAND_SENT); if (TDS_FAILED(ret)) { tdsdump_log(TDS_DBG_WARN, "ct_send() failed\n"); return CS_FAIL; } tdsdump_log(TDS_DBG_INFO2, "ct_send() succeeded\n"); return CS_SUCCEED; } /* Code added for CURSOR support */ if (cmd->command_type == CS_CUR_CMD) { TDSCURSOR *cursor; /* sanity */ /* * ct_cursor declare should allocate cursor pointer * cursor stmt cannot be NULL * cursor name cannot be NULL */ int something_to_send = 0; tdsdump_log(TDS_DBG_FUNC, "ct_send() : CS_CUR_CMD\n"); cursor = cmd->cursor; if (!cursor) { tdsdump_log(TDS_DBG_FUNC, "ct_send() : cursor not present\n"); return CS_FAIL; } if (cursor->query == NULL ) { tdsdump_log(TDS_DBG_FUNC, "ct_send() : cursor->query is null\n"); return CS_FAIL; } if ( cursor->cursor_name == NULL ) { tdsdump_log(TDS_DBG_FUNC, "ct_send() : cursor->name is null\n"); return CS_FAIL; } if (cursor->status.declare == _CS_CURS_TYPE_REQUESTED) { ret = tds_cursor_declare(tds, cursor, NULL, &something_to_send); if (TDS_SUCCEED(ret)){ cursor->status.declare = TDS_CURSOR_STATE_SENT; /* Cursor is declared */ if (something_to_send == 0) { cmd->results_state = _CS_RES_END_RESULTS; } } else { tdsdump_log(TDS_DBG_WARN, "ct_send(): cursor declare failed \n"); return CS_FAIL; } } if (cursor->status.cursor_row == _CS_CURS_TYPE_REQUESTED && cursor->status.declare == _CS_CURS_TYPE_SENT) { ret = tds_cursor_setrows(tds, cursor, &something_to_send); if (TDS_SUCCEED(ret)){ cursor->status.cursor_row = TDS_CURSOR_STATE_SENT; /* Cursor rows set */ if (something_to_send == 0) { cmd->results_state = _CS_RES_END_RESULTS; } } else { tdsdump_log(TDS_DBG_WARN, "ct_send(): cursor set rows failed\n"); return CS_FAIL; } } if (cursor->status.open == _CS_CURS_TYPE_REQUESTED && cursor->status.declare == _CS_CURS_TYPE_SENT) { ret = tds_cursor_open(tds, cursor, NULL, &something_to_send); if (TDS_SUCCEED(ret)){ cursor->status.open = TDS_CURSOR_STATE_SENT; cmd->results_state = _CS_RES_INIT; } else { tdsdump_log(TDS_DBG_WARN, "ct_send(): cursor open failed\n"); return CS_FAIL; } } if (something_to_send) { tdsdump_log(TDS_DBG_WARN, "ct_send(): sending cursor commands\n"); tds_flush_packet(tds); tds_set_state(tds, TDS_PENDING); something_to_send = 0; ct_set_command_state(cmd, _CS_COMMAND_SENT); return CS_SUCCEED; } if (cursor->status.close == _CS_CURS_TYPE_REQUESTED){ if (cursor->status.dealloc == TDS_CURSOR_STATE_REQUESTED) { /* FIXME what happen if tds_cursor_dealloc return TDS_FAIL ?? */ ret = tds_cursor_close(tds, cursor); tds_release_cursor(&cmd->cursor); cursor = NULL; } else { ret = tds_cursor_close(tds, cursor); cursor->status.close = TDS_CURSOR_STATE_SENT; } } if (cursor && cursor->status.dealloc == _CS_CURS_TYPE_REQUESTED) { /* FIXME what happen if tds_cursor_dealloc return TDS_FAIL ?? */ ret = tds_cursor_dealloc(tds, cursor); tds_release_cursor(&cmd->cursor); tds_free_all_results(tds); } if (TDS_SUCCEED(ret)) cmd->results_state = _CS_RES_INIT; ct_set_command_state(cmd, _CS_COMMAND_SENT); return CS_SUCCEED; } if (cmd->command_type == CS_SEND_DATA_CMD) { tds_writetext_end(tds); ct_set_command_state(cmd, _CS_COMMAND_SENT); } return CS_SUCCEED; } CS_RETCODE ct_results(CS_COMMAND * cmd, CS_INT * result_type) { TDSSOCKET *tds; CS_CONTEXT *context; TDSRET tdsret; CS_INT res_type; CS_INT done_flags; TDS_INT8 rows_affected; unsigned process_flags; tdsdump_log(TDS_DBG_FUNC, "ct_results(%p, %p)\n", cmd, result_type); if (cmd->cancel_state == _CS_CANCEL_PENDING) { _ct_cancel_cleanup(cmd); return CS_CANCELED; } if (!cmd->con || !cmd->con->tds_socket) return CS_FAIL; cmd->bind_count = CS_UNUSED; context = cmd->con->ctx; tds = cmd->con->tds_socket; cmd->row_prefetched = 0; /* * depending on the current results state, we may * not need to call tds_process_tokens... */ switch (cmd->results_state) { case _CS_RES_CMD_SUCCEED: *result_type = CS_CMD_SUCCEED; cmd->results_state = _CS_RES_CMD_DONE; return CS_SUCCEED; case _CS_RES_CMD_DONE: *result_type = CS_CMD_DONE; cmd->results_state = _CS_RES_INIT; return CS_SUCCEED; case _CS_RES_END_RESULTS: *result_type = CS_CMD_DONE; cmd->results_state = _CS_RES_INIT; return CS_END_RESULTS; case _CS_RES_DESCRIBE_RESULT: *result_type = CS_DESCRIBE_RESULT; cmd->results_state = _CS_RES_CMD_DONE; return CS_SUCCEED; case _CS_RES_NONE: /* first time in after ct_send */ cmd->results_state = _CS_RES_INIT; tds->rows_affected = TDS_NO_COUNT; break; case _CS_RES_INIT: tds->rows_affected = TDS_NO_COUNT; break; default: break; } rows_affected = tds->rows_affected; /* * see what "result" tokens we have. a "result" in ct-lib terms also * includes row data. Some result types always get reported back to * the calling program, others are only reported back if the relevant * config flag is set. */ process_flags = TDS_TOKEN_RESULTS; for (;;) { tdsret = tds_process_tokens(tds, &res_type, &done_flags, process_flags); tdsdump_log(TDS_DBG_FUNC, "ct_results() process_result_tokens returned %d (type %d) \n", tdsret, res_type); switch (tdsret) { case TDS_SUCCESS: cmd->curr_result_type = res_type; switch (res_type) { case CS_COMPUTEFMT_RESULT: /* * set results state to indicate that we * have a result set (empty for the moment) * If the CS_EXPOSE_FMTS property has been * set in ct_config(), we need to return an * appropraite format result, otherwise just * carry on and get the next token..... */ cmd->results_state = _CS_RES_RESULTSET_EMPTY; if (context->config.cs_expose_formats) { *result_type = res_type; return CS_SUCCEED; } break; case CS_ROWFMT_RESULT: cmd->curr_result_type = CS_ROW_RESULT; cmd->results_state = _CS_RES_RESULTSET_EMPTY; rows_affected = tds->rows_affected = TDS_NO_COUNT; if (cmd->command_type == CS_CUR_CMD || cmd->command_type == CS_DYNAMIC_CMD) break; /* don't process DONE tokens */ process_flags = TDS_RETURN_ROWFMT|TDS_RETURN_COMPUTEFMT|TDS_STOPAT_DONE|TDS_STOPAT_ROW| TDS_STOPAT_COMPUTE|TDS_RETURN_PROC; break; case CS_ROW_RESULT: /* * we've hit a data row. pass back that fact * to the calling program. set results state * to show that the result set has rows... */ cmd->results_state = _CS_RES_RESULTSET_ROWS; if (cmd->command_type == CS_CUR_CMD) { *result_type = CS_CURSOR_RESULT; } else { *result_type = CS_ROW_RESULT; } return CS_SUCCEED; break; case CS_COMPUTE_RESULT: /* * we've hit a compute data row. We have to get hold of this * data now, as it's necessary to tie this data back to its * result format...the user may call ct_res_info() & friends * after getting back a compute "result". * * but first, if we've hit this compute row without having * hit a data row first, we need to return a CS_ROW_RESULT * before letting them have the compute row... */ if (cmd->results_state == _CS_RES_RESULTSET_EMPTY) { *result_type = CS_ROW_RESULT; tds_set_current_results(tds, tds->res_info); cmd->results_state = _CS_RES_RESULTSET_ROWS; return CS_SUCCEED; } tdsret = tds_process_tokens(tds, &res_type, NULL, TDS_STOPAT_ROWFMT|TDS_RETURN_DONE|TDS_RETURN_ROW|TDS_RETURN_COMPUTE); /* set results state to show that the result set has rows... */ cmd->results_state = _CS_RES_RESULTSET_ROWS; *result_type = res_type; if (tdsret == TDS_SUCCESS && (res_type == TDS_ROW_RESULT || res_type == TDS_COMPUTE_RESULT)) { if (res_type == TDS_COMPUTE_RESULT) { cmd->row_prefetched = 1; return CS_SUCCEED; } else { /* this couldn't really happen, but... */ return CS_FAIL; } } else return CS_FAIL; break; case TDS_DONE_RESULT: /* * A done token signifies the end of a logical * command. There are three possibilities... * 1. Simple command with no result set, i.e. * update, delete, insert * 2. Command with result set but no rows * 3. Command with result set and rows * in these cases we need to: * 1. return CS_CMD_FAIL/SUCCED depending on * the status returned in done_flags * 2. "manufacture" a CS_ROW_RESULT return, * and set the results state to DONE * 3. return with CS_CMD_DONE and reset the * results_state */ tdsdump_log(TDS_DBG_FUNC, "ct_results() results state = %d\n",cmd->results_state); tdsdump_log(TDS_DBG_FUNC, "ct_results() command type = %d\n",cmd->command_type); tdsdump_log(TDS_DBG_FUNC, "ct_results() dynamic cmd = %d\n",cmd->dynamic_cmd); if ((cmd->command_type == CS_DYNAMIC_CMD) && (cmd->dynamic_cmd == CS_PREPARE || cmd->dynamic_cmd == CS_DEALLOC)) { *result_type = CS_CMD_SUCCEED; cmd->results_state = _CS_RES_CMD_DONE; return CS_SUCCEED; } if (tds->rows_affected != TDS_NO_COUNT) rows_affected = tds->rows_affected; tds->rows_affected = rows_affected; switch (cmd->results_state) { case _CS_RES_INIT: case _CS_RES_STATUS: if (done_flags & TDS_DONE_ERROR) *result_type = CS_CMD_FAIL; else *result_type = CS_CMD_SUCCEED; cmd->results_state = _CS_RES_CMD_DONE; break; case _CS_RES_RESULTSET_EMPTY: if (cmd->command_type == CS_CUR_CMD) { *result_type = CS_CURSOR_RESULT; } else { *result_type = CS_ROW_RESULT; } cmd->results_state = _CS_RES_RESULTSET_ROWS; break; case _CS_RES_RESULTSET_ROWS: *result_type = CS_CMD_DONE; cmd->results_state = _CS_RES_INIT; break; } return CS_SUCCEED; break; case TDS_DONEINPROC_RESULT: /* * A doneinproc token may signify the end of a * logical command if the command had a result * set. Otherwise it is ignored.... */ if (tds->rows_affected != TDS_NO_COUNT) rows_affected = tds->rows_affected; tds->rows_affected = rows_affected; switch (cmd->results_state) { case _CS_RES_INIT: /* command had no result set */ break; case _CS_RES_RESULTSET_EMPTY: if (cmd->command_type == CS_CUR_CMD) { *result_type = CS_CURSOR_RESULT; cmd->results_state = _CS_RES_CMD_DONE; } else { *result_type = CS_ROW_RESULT; cmd->results_state = _CS_RES_RESULTSET_ROWS; } return CS_SUCCEED; break; case _CS_RES_RESULTSET_ROWS: *result_type = CS_CMD_DONE; cmd->results_state = _CS_RES_INIT; return CS_SUCCEED; break; } break; case TDS_DONEPROC_RESULT: /* * A DONEPROC result means the end of a logical * command only if it was one of the commands * directly sent from ct_send, not as a result * of a nested stored procedure call. We know * if this is the case if a STATUS_RESULT was * received immediately prior to the DONE_PROC */ if (tds->rows_affected != TDS_NO_COUNT) rows_affected = tds->rows_affected; tds->rows_affected = rows_affected; if (done_flags & TDS_DONE_ERROR) *result_type = CS_CMD_FAIL; else *result_type = CS_CMD_SUCCEED; cmd->results_state = _CS_RES_CMD_DONE; return CS_SUCCEED; break; case TDS_PARAM_RESULT: cmd->row_prefetched = 1; *result_type = res_type; return CS_SUCCEED; break; case TDS_STATUS_RESULT: _ct_process_return_status(tds); cmd->row_prefetched = 1; *result_type = res_type; cmd->results_state = _CS_RES_STATUS; return CS_SUCCEED; break; case TDS_DESCRIBE_RESULT: if (cmd->dynamic_cmd == CS_DESCRIBE_INPUT || cmd->dynamic_cmd == CS_DESCRIBE_OUTPUT) { *result_type = res_type; return CS_SUCCEED; } break; default: *result_type = res_type; return CS_SUCCEED; break; } break; case TDS_NO_MORE_RESULTS: /* some commands can be re-sent once completed */ /* so mark the command state as 'ready'... */ if (cmd->command_type == CS_LANG_CMD || cmd->command_type == CS_RPC_CMD || cmd->command_type == CS_CUR_CMD || cmd->command_type == CS_DYNAMIC_CMD) { ct_set_command_state(cmd, _CS_COMMAND_READY); } /* if we have just completed processing a dynamic deallocate */ /* get rid of our dynamic statement structure... */ if (cmd->command_type == CS_DYNAMIC_CMD && cmd->dynamic_cmd == CS_DEALLOC) { _ct_deallocate_dynamic(cmd->con, cmd->dyn); cmd->dyn = NULL; } return CS_END_RESULTS; break; case TDS_CANCELLED: cmd->cancel_state = _CS_CANCEL_NOCANCEL; return CS_CANCELED; break; default: return CS_FAIL; break; } /* switch (tdsret) */ } /* for (;;) */ } CS_RETCODE ct_bind(CS_COMMAND * cmd, CS_INT item, CS_DATAFMT * datafmt, CS_VOID * buffer, CS_INT * copied, CS_SMALLINT * indicator) { TDSCOLUMN *colinfo; TDSRESULTINFO *resinfo; TDSSOCKET *tds; CS_CONNECTION *con = cmd->con; CS_INT bind_count; tdsdump_log(TDS_DBG_FUNC, "ct_bind(%p, %d, %p, %p, %p, %p)\n", cmd, item, datafmt, buffer, copied, indicator); tdsdump_log(TDS_DBG_FUNC, "ct_bind() datafmt count = %d column_number = %d\n", datafmt->count, item); if (!con || !con->tds_socket) return CS_FAIL; tds = con->tds_socket; resinfo = tds->current_results; /* check item value */ if (!resinfo || item <= 0 || item > resinfo->num_cols) return CS_FAIL; colinfo = resinfo->columns[item - 1]; /* * Check whether the request is for array binding, and ensure that the user * supplies the same datafmt->count to the subsequent ct_bind calls */ bind_count = (datafmt->count == 0) ? 1 : datafmt->count; /* first bind for this result set */ if (cmd->bind_count == CS_UNUSED) { cmd->bind_count = bind_count; } else { /* all subsequent binds for this result set - the bind counts must be the same */ if (cmd->bind_count != bind_count) { _ctclient_msg(con, "ct_bind", 1, 1, 1, 137, "%d, %d", bind_count, cmd->bind_count); return CS_FAIL; } } /* bind the column_varaddr to the address of the buffer */ colinfo = resinfo->columns[item - 1]; colinfo->column_varaddr = (char *) buffer; colinfo->column_bindtype = datafmt->datatype; colinfo->column_bindfmt = datafmt->format; colinfo->column_bindlen = datafmt->maxlength; if (indicator) { colinfo->column_nullbind = indicator; } if (copied) { colinfo->column_lenbind = copied; } return CS_SUCCEED; } CS_RETCODE ct_fetch(CS_COMMAND * cmd, CS_INT type, CS_INT offset, CS_INT option, CS_INT * prows_read) { TDS_INT ret_type; TDSRET ret; TDS_INT marker; TDS_INT temp_count; TDSSOCKET *tds; CS_INT rows_read_dummy; tdsdump_log(TDS_DBG_FUNC, "ct_fetch(%p, %d, %d, %d, %p)\n", cmd, type, offset, option, prows_read); if (!cmd->con || !cmd->con->tds_socket) return CS_FAIL; if (cmd->command_state == _CS_COMMAND_IDLE) { _ctclient_msg(cmd->con, "ct_fetch", 1, 1, 1, 16843163, ""); return CS_FAIL; } if (cmd->cancel_state == _CS_CANCEL_PENDING) { _ct_cancel_cleanup(cmd); return CS_CANCELED; } if( prows_read == NULL ) prows_read = &rows_read_dummy; tds = cmd->con->tds_socket; /* * Call a special function for fetches from a cursor because * the processing is too incompatible to patch into a single function */ if (cmd->command_type == CS_CUR_CMD) { return _ct_fetch_cursor(cmd, type, offset, option, prows_read); } *prows_read = 0; if ( cmd->bind_count == CS_UNUSED ) cmd->bind_count = 1; /* compute rows and parameter results have been pre-fetched by ct_results() */ if (cmd->row_prefetched) { cmd->row_prefetched = 0; cmd->get_data_item = 0; cmd->get_data_bytes_returned = 0; if (_ct_bind_data(cmd->con->ctx, tds->current_results, tds->current_results, 0)) return CS_ROW_FAIL; *prows_read = 1; return CS_SUCCEED; } if (cmd->results_state == _CS_RES_CMD_DONE) return CS_END_DATA; if (cmd->curr_result_type == CS_COMPUTE_RESULT) return CS_END_DATA; if (cmd->curr_result_type == CS_CMD_FAIL) return CS_CMD_FAIL; marker = tds_peek(tds); if ((cmd->curr_result_type == CS_ROW_RESULT && marker != TDS_ROW_TOKEN && marker != TDS_NBC_ROW_TOKEN) || (cmd->curr_result_type == CS_STATUS_RESULT && marker != TDS_RETURNSTATUS_TOKEN) ) return CS_END_DATA; /* Array Binding Code changes start here */ for (temp_count = 0; temp_count < cmd->bind_count; temp_count++) { ret = tds_process_tokens(tds, &ret_type, NULL, TDS_STOPAT_ROWFMT|TDS_STOPAT_DONE|TDS_RETURN_ROW|TDS_RETURN_COMPUTE); tdsdump_log(TDS_DBG_FUNC, "inside ct_fetch() process_row_tokens returned %d\n", ret); switch (ret) { case TDS_SUCCESS: if (ret_type == TDS_ROW_RESULT || ret_type == TDS_COMPUTE_RESULT) { cmd->get_data_item = 0; cmd->get_data_bytes_returned = 0; if (_ct_bind_data(cmd->con->ctx, tds->current_results, tds->current_results, temp_count)) return CS_ROW_FAIL; (*prows_read)++; break; } case TDS_NO_MORE_RESULTS: return CS_END_DATA; break; case TDS_CANCELLED: cmd->cancel_state = _CS_CANCEL_NOCANCEL; return CS_CANCELED; break; default: return CS_FAIL; break; } /* have we reached the end of the rows ? */ marker = tds_peek(tds); if (cmd->curr_result_type == CS_ROW_RESULT && marker != TDS_ROW_TOKEN && marker != TDS_NBC_ROW_TOKEN) break; } /* Array Binding Code changes end here */ return CS_SUCCEED; } static CS_RETCODE _ct_fetch_cursor(CS_COMMAND * cmd, CS_INT type, CS_INT offset, CS_INT option, CS_INT * rows_read) { TDSSOCKET * tds; TDSCURSOR *cursor; TDS_INT restype; TDSRET ret; TDS_INT temp_count; TDS_INT done_flags; TDS_INT rows_this_fetch = 0; tdsdump_log(TDS_DBG_FUNC, "_ct_fetch_cursor(%p, %d, %d, %d, %p)\n", cmd, type, offset, option, rows_read); if (!cmd->con || !cmd->con->tds_socket) return CS_FAIL; tds = cmd->con->tds_socket; if (rows_read) *rows_read = 0; /* taking a copy of the cmd->bind_count value. */ temp_count = cmd->bind_count; if ( cmd->bind_count == CS_UNUSED ) cmd->bind_count = 1; cursor = cmd->cursor; if (!cursor) { tdsdump_log(TDS_DBG_FUNC, "ct_fetch_cursor() : cursor not present\n"); return CS_FAIL; } /* currently we are placing this restriction on cursor fetches. */ /* the alternatives are too awful to contemplate at the moment */ /* i.e. buffering all the rows from the fetch internally... */ if (cmd->bind_count < cursor->cursor_rows) { tdsdump_log(TDS_DBG_WARN, "_ct_fetch_cursor(): bind count must equal cursor rows \n"); return CS_FAIL; } if (TDS_FAILED(tds_cursor_fetch(tds, cursor, TDS_CURSOR_FETCH_NEXT, 0))) { tdsdump_log(TDS_DBG_WARN, "ct_fetch(): cursor fetch failed\n"); return CS_FAIL; } cursor->status.fetch = TDS_CURSOR_STATE_SENT; while ((tds_process_tokens(tds, &restype, &done_flags, TDS_TOKEN_RESULTS)) == TDS_SUCCESS) { switch (restype) { case CS_ROWFMT_RESULT: break; case CS_ROW_RESULT: for (temp_count = 0; temp_count < cmd->bind_count; temp_count++) { ret = tds_process_tokens(tds, &restype, NULL, TDS_STOPAT_ROWFMT|TDS_STOPAT_DONE|TDS_RETURN_ROW|TDS_RETURN_COMPUTE); tdsdump_log(TDS_DBG_FUNC, "_ct_fetch_cursor() tds_process_tokens returned %d\n", ret); if (ret == TDS_SUCCESS && (restype == TDS_ROW_RESULT || restype == TDS_COMPUTE_RESULT)) { cmd->get_data_item = 0; cmd->get_data_bytes_returned = 0; if (restype == TDS_ROW_RESULT) { if (_ct_bind_data(cmd->con->ctx, tds->current_results, tds->current_results, temp_count)) return CS_ROW_FAIL; if (rows_read) *rows_read = *rows_read + 1; rows_this_fetch++; } } else { if (TDS_FAILED(ret)) return CS_FAIL; break; } } break; case TDS_DONE_RESULT: break; } } if (rows_this_fetch) return CS_SUCCEED; cmd->results_state = _CS_RES_CMD_SUCCEED; return CS_END_DATA; } int _ct_bind_data(CS_CONTEXT *ctx, TDSRESULTINFO * resinfo, TDSRESULTINFO *bindinfo, CS_INT offset) { TDSCOLUMN *curcol, *bindcol; unsigned char *src, *dest, *temp_add; int i, result = 0; CS_DATAFMT srcfmt, destfmt; TDS_INT datalen_dummy, *pdatalen; TDS_SMALLINT nullind_dummy, *nullind; tdsdump_log(TDS_DBG_FUNC, "_ct_bind_data(%p, %p, %p, %d)\n", ctx, resinfo, bindinfo, offset); for (i = 0; i < resinfo->num_cols; i++) { CS_RETCODE ret; curcol = resinfo->columns[i]; bindcol = bindinfo->columns[i]; tdsdump_log(TDS_DBG_FUNC, "_ct_bind_data(): column %d is type %d and has length %d\n", i, curcol->column_type, curcol->column_cur_size); if (curcol->column_hidden) continue; /* * Retrieve the initial bound column_varaddress and increment it if offset specified */ temp_add = (unsigned char *) bindcol->column_varaddr; dest = temp_add ? temp_add + (offset * bindcol->column_bindlen) : NULL; nullind = &nullind_dummy; if (bindcol->column_nullbind) { nullind = bindcol->column_nullbind; assert(nullind); nullind += offset; } pdatalen = &datalen_dummy; if (bindcol->column_lenbind) { pdatalen = bindcol->column_lenbind; assert(pdatalen); pdatalen += offset; } if (dest) { if (curcol->column_cur_size < 0) { *nullind = -1; *pdatalen = 0; } else { CONV_RESULT convert_buffer; src = curcol->column_data; if (is_blob_col(curcol)) src = (unsigned char *) ((TDSBLOB *) src)->textvalue; srcfmt.datatype = _cs_convert_not_client(ctx, curcol, &convert_buffer, &src); if (srcfmt.datatype == CS_ILLEGAL_TYPE) srcfmt.datatype = _ct_get_client_type(curcol); if (srcfmt.datatype == CS_ILLEGAL_TYPE) { result = 1; continue; } srcfmt.maxlength = curcol->column_cur_size; destfmt.datatype = bindcol->column_bindtype; destfmt.maxlength = bindcol->column_bindlen; destfmt.format = bindcol->column_bindfmt; /* if convert return FAIL mark error but process other columns */ if ((ret = cs_convert(ctx, &srcfmt, src, &destfmt, dest, pdatalen) != CS_SUCCEED)) { tdsdump_log(TDS_DBG_FUNC, "cs_convert-result = %d\n", ret); result = 1; tdsdump_log(TDS_DBG_INFO1, "error: converted only %d bytes for type %d \n", *pdatalen, srcfmt.datatype); } *nullind = 0; } } else { *pdatalen = 0; } } return result; } CS_RETCODE ct_cmd_drop(CS_COMMAND * cmd) { CS_CONNECTION *con; tdsdump_log(TDS_DBG_FUNC, "ct_cmd_drop(%p)\n", cmd); if (cmd) { free(cmd->query); if (cmd->input_params) param_clear(cmd->input_params); free(cmd->userdata); if (cmd->rpc) { if (cmd->rpc->param_list) param_clear(cmd->rpc->param_list); free(cmd->rpc->name); free(cmd->rpc); } free(cmd->iodesc); /* now remove this command from the list of commands in the connection */ con = cmd->con; if (con) { CS_COMMAND **pvictim; for (pvictim = &con->cmds; *pvictim != cmd; ) { if (*pvictim == NULL) { tdsdump_log(TDS_DBG_FUNC, "ct_cmd_drop() : cannot find command entry in list \n"); return CS_FAIL; } pvictim = &(*pvictim)->next; } /* remove from list */ *pvictim = cmd->next; cmd->next = NULL; } free(cmd); } return CS_SUCCEED; } CS_RETCODE ct_close(CS_CONNECTION * con, CS_INT option) { tdsdump_log(TDS_DBG_FUNC, "ct_close(%p, %d)\n", con, option); tds_close_socket(con->tds_socket); tds_free_socket(con->tds_socket); con->tds_socket = NULL; return CS_SUCCEED; } CS_RETCODE ct_con_drop(CS_CONNECTION * con) { CS_COMMAND *cmd, *next_cmd; tdsdump_log(TDS_DBG_FUNC, "ct_con_drop(%p)\n", con); if (con) { free(con->userdata); if (con->tds_login) tds_free_login(con->tds_login); while ((cmd = con->cmds) != NULL) { next_cmd = cmd->next; cmd->con = NULL; cmd->dyn = NULL; cmd->next = NULL; con->cmds = next_cmd; } while (con->dynlist) _ct_deallocate_dynamic(con, con->dynlist); if (con->locale) _cs_locale_free(con->locale); tds_free_socket(con->tds_socket); con->tds_socket = NULL; free(con->server_addr); free(con); } return CS_SUCCEED; } int _ct_get_client_type(TDSCOLUMN *col) { tdsdump_log(TDS_DBG_FUNC, "_ct_get_client_type(type %d, user %d, size %d)\n", col->column_type, col->column_usertype, col->column_size); switch (col->column_type) { case SYBBIT: case SYBBITN: return CS_BIT_TYPE; break; case SYBCHAR: case SYBVARCHAR: return CS_CHAR_TYPE; break; case SYBINT8: return CS_BIGINT_TYPE; break; case SYBINT4: return CS_INT_TYPE; break; case SYBINT2: return CS_SMALLINT_TYPE; break; case SYBINT1: return CS_TINYINT_TYPE; break; case SYBINTN: switch (col->column_size) { case 8: return CS_BIGINT_TYPE; case 4: return CS_INT_TYPE; case 2: return CS_SMALLINT_TYPE; case 1: return CS_TINYINT_TYPE; default: fprintf(stderr, "Unknown size %d for SYBINTN\n", col->column_size); } break; case SYBREAL: return CS_REAL_TYPE; break; case SYBFLT8: return CS_FLOAT_TYPE; break; case SYBFLTN: if (col->column_size == 4) { return CS_REAL_TYPE; } else if (col->column_size == 8) { return CS_FLOAT_TYPE; } fprintf(stderr, "Error! unknown float size of %d\n", col->column_size); break; case SYBMONEY: return CS_MONEY_TYPE; break; case SYBMONEY4: return CS_MONEY4_TYPE; break; case SYBMONEYN: if (col->column_size == 4) { return CS_MONEY4_TYPE; } else if (col->column_size == 8) { return CS_MONEY_TYPE; } fprintf(stderr, "Error! unknown money size of %d\n", col->column_size); break; case SYBDATETIME: return CS_DATETIME_TYPE; break; case SYBDATETIME4: return CS_DATETIME4_TYPE; break; case SYBDATETIMN: if (col->column_size == 4) { return CS_DATETIME4_TYPE; } else if (col->column_size == 8) { return CS_DATETIME_TYPE; } fprintf(stderr, "Error! unknown date size of %d\n", col->column_size); break; case SYBNUMERIC: return CS_NUMERIC_TYPE; break; case SYBDECIMAL: return CS_DECIMAL_TYPE; break; case SYBBINARY: case SYBVARBINARY: return CS_BINARY_TYPE; break; case SYBIMAGE: return CS_IMAGE_TYPE; break; case SYBTEXT: return CS_TEXT_TYPE; break; case SYBUNIQUE: return CS_UNIQUE_TYPE; break; case SYBLONGBINARY: if (col->column_usertype == USER_UNICHAR_TYPE || col->column_usertype == USER_UNIVARCHAR_TYPE) return CS_UNICHAR_TYPE; return CS_LONGBINARY_TYPE; break; case SYBUINT1: return CS_TINYINT_TYPE; break; case SYBUINT2: return CS_USMALLINT_TYPE; break; case SYBUINT4: return CS_UINT_TYPE; break; case SYBUINT8: return CS_UBIGINT_TYPE; break; case SYBDATE: return CS_DATE_TYPE; break; case SYBTIME: return CS_TIME_TYPE; break; case SYB5BIGTIME: return CS_BIGTIME_TYPE; break; case SYB5BIGDATETIME: return CS_BIGDATETIME_TYPE; break; } return _cs_convert_not_client(NULL, col, NULL, NULL); } TDS_SERVER_TYPE _ct_get_server_type(TDSSOCKET *tds, int datatype) { tdsdump_log(TDS_DBG_FUNC, "_ct_get_server_type(%d)\n", datatype); switch (datatype) { case CS_IMAGE_TYPE: return SYBIMAGE; case CS_BINARY_TYPE: return SYBBINARY; case CS_BIT_TYPE: return SYBBIT; case CS_CHAR_TYPE: return SYBCHAR; case CS_VARCHAR_TYPE: return SYBVARCHAR; case CS_LONG_TYPE: case CS_UBIGINT_TYPE: if (!tds || tds_capability_has_req(tds->conn, TDS_REQ_DATA_UINT8)) return SYBUINT8; return SYBINT8; case CS_UINT_TYPE: if (!tds || tds_capability_has_req(tds->conn, TDS_REQ_DATA_UINT4)) return SYBUINT4; return SYBINT4; case CS_USMALLINT_TYPE: if (!tds || tds_capability_has_req(tds->conn, TDS_REQ_DATA_UINT2)) return SYBUINT2; return SYBINT2; case CS_BIGINT_TYPE: return SYBINT8; case CS_INT_TYPE: return SYBINT4; case CS_SMALLINT_TYPE: return SYBINT2; case CS_TINYINT_TYPE: return SYBINT1; case CS_REAL_TYPE: return SYBREAL; case CS_FLOAT_TYPE: return SYBFLT8; case CS_MONEY_TYPE: return SYBMONEY; case CS_MONEY4_TYPE: return SYBMONEY4; case CS_DATETIME_TYPE: return SYBDATETIME; case CS_DATETIME4_TYPE: return SYBDATETIME4; case CS_NUMERIC_TYPE: return SYBNUMERIC; case CS_DECIMAL_TYPE: return SYBDECIMAL; case CS_VARBINARY_TYPE: return SYBVARBINARY; case CS_TEXT_TYPE: return SYBTEXT; case CS_UNIQUE_TYPE: return SYBUNIQUE; case CS_LONGBINARY_TYPE: return SYBLONGBINARY; case CS_UNICHAR_TYPE: return SYBVARCHAR; case CS_DATE_TYPE: if (!tds || tds_capability_has_req(tds->conn, TDS_REQ_DATA_DATE)) return SYBDATE; return SYBDATETIME; case CS_TIME_TYPE: if (!tds || tds_capability_has_req(tds->conn, TDS_REQ_DATA_TIME)) return SYBTIME; return SYBDATETIME; case CS_BIGDATETIME_TYPE: if (!tds || tds_capability_has_req(tds->conn, TDS_REQ_DATA_BIGDATETIME)) return SYB5BIGDATETIME; return SYBDATETIME; case CS_BIGTIME_TYPE: if (!tds || tds_capability_has_req(tds->conn, TDS_REQ_DATA_BIGTIME)) return SYB5BIGTIME; return SYBDATETIME; default: return TDS_INVALID_TYPE; break; } } CS_RETCODE ct_cancel(CS_CONNECTION * conn, CS_COMMAND * cmd, CS_INT type) { CS_RETCODE ret; CS_COMMAND *cmds; CS_COMMAND *conn_cmd; CS_CONNECTION *cmd_conn; tdsdump_log(TDS_DBG_FUNC, "ct_cancel(%p, %p, %d)\n", conn, cmd, type); /* * Comments taken from Sybase ct-library reference manual * ------------------------------------------------------ * * "To cancel current results, an application calls ct_cancel * with type as CT_CANCEL CURRENT. This is equivalent to * calling ct_fetch until it returns CS_END_DATA" * * "For CS_CANCEL_CURRENT cancels, cmd must be supplied" * "For CS_CANCEL_CURRENT cancels, connection must be NULL" */ if (type == CS_CANCEL_CURRENT) { tdsdump_log(TDS_DBG_FUNC, "CS_CANCEL_CURRENT\n"); if (conn || !cmd) return CS_FAIL; if (!_ct_fetchable_results(cmd)) { tdsdump_log(TDS_DBG_FUNC, "ct_cancel() no fetchable results - return()\n"); return CS_SUCCEED; } tdsdump_log(TDS_DBG_FUNC, "ct_cancel() - fetching results()\n"); do { ret = ct_fetch(cmd, CS_UNUSED, CS_UNUSED, CS_UNUSED, NULL); } while ((ret == CS_SUCCEED) || (ret == CS_ROW_FAIL)); if (cmd->con && cmd->con->tds_socket) tds_free_all_results(cmd->con->tds_socket); if (ret == CS_END_DATA) { return CS_SUCCEED; } return CS_FAIL; } /* * Comments taken from Sybase ct-library reference manual * ------------------------------------------------------ * * "To cancel the current command and all results generated * by it, call ct_cancel with type as CS_CANCEL_ATTN or * CS_CANCEL_ALL. Both of these calls tell client library * to : * * Send an attention to the server * * discard any results already generated by the command * Both types of cancel return CS_SUCCEED immediately, w/o * sending an attention, if no command is in progress. * If an application has not yet called ct_send to send an * initiated command, a CS_CANCEL_ATTN has no effect. * * If a command has been sent and ct_results has not been * called, a ct_cancel (CS_CANCEL_ATTN) has no effect." * * "For CS_CANCEL_ATTN cancels, one of connection or cmd * must be NULL. if cmd is supplied and connection is NULL * the cancel operation applies only to the command pend- * ing for this command structure. If cmd is NULL and * connection is supplied, the cancel operation applies to * all commands pending for this connection. */ if (type == CS_CANCEL_ATTN) { if ((conn && cmd) || (!conn && !cmd)) { return CS_FAIL; } if (cmd) { tdsdump_log(TDS_DBG_FUNC, "CS_CANCEL_ATTN with cmd\n"); cmd_conn = cmd->con; switch (cmd->command_state) { case _CS_COMMAND_IDLE: case _CS_COMMAND_READY: tdsdump_log(TDS_DBG_FUNC, "ct_cancel() command state READY/IDLE\n"); break; case _CS_COMMAND_SENT: tdsdump_log(TDS_DBG_FUNC, "ct_cancel() command state SENT results_state %d\n", cmd->results_state); if (cmd->results_state != _CS_RES_NONE) { tdsdump_log(TDS_DBG_FUNC, "ct_cancel() sending a cancel \n"); tds_send_cancel(cmd_conn->tds_socket); cmd->cancel_state = _CS_CANCEL_PENDING; } break; } } if (conn) { tdsdump_log(TDS_DBG_FUNC, "CS_CANCEL_ATTN with connection\n"); for (cmds = conn->cmds; cmds != NULL; cmds = cmds->next) { conn_cmd = cmds; switch (conn_cmd->command_state) { case _CS_COMMAND_IDLE: case _CS_COMMAND_READY: tdsdump_log(TDS_DBG_FUNC, "ct_cancel() command state READY/IDLE\n"); break; case _CS_COMMAND_SENT: tdsdump_log(TDS_DBG_FUNC, "ct_cancel() command state SENT\n"); if (conn_cmd->results_state != _CS_RES_NONE) { tdsdump_log(TDS_DBG_FUNC, "ct_cancel() sending a cancel \n"); tds_send_cancel(conn->tds_socket); conn_cmd->cancel_state = _CS_CANCEL_PENDING; } break; } } } return CS_SUCCEED; } /* * Comments taken from Sybase ct-library reference manual * ------------------------------------------------------ * * "To cancel the current command and all results generated * by it, call ct_cancel with type as CS_CANCEL_ATTN or * CS_CANCEL_ALL. Both of these calls tell client library * to : * * Send an attention to the server * * discard any results already generated by the command * Both types of cancel return CS_SUCCEED immediately, w/o * sending an attention, if no command is in progress. * * If an application has not yet called ct_send to send an * initiated command, a CS_CANCEL_ALL cancel discards the * initiated command without sending an attention to the * server. * * CS_CANCEL_ALL leaves the command structure in a 'clean' * state, available for use in another operation. * * "For CS_CANCEL_ALL cancels, one of connection or cmd * must be NULL. if cmd is supplied and connection is NULL * the cancel operation applies only to the command pend- * ing for this command structure. If cmd is NULL and * connection is supplied, the cancel operation applies to * all commands pending for this connection. */ if (type == CS_CANCEL_ALL) { if ((conn && cmd) || (!conn && !cmd)) { return CS_FAIL; } if (cmd) { tdsdump_log(TDS_DBG_FUNC, "CS_CANCEL_ALL with cmd\n"); cmd_conn = cmd->con; switch (cmd->command_state) { case _CS_COMMAND_IDLE: case _CS_COMMAND_BUILDING: case _CS_COMMAND_READY: tdsdump_log(TDS_DBG_FUNC, "ct_cancel() command state READY/IDLE\n"); _ct_initialise_cmd(cmd); break; case _CS_COMMAND_SENT: tdsdump_log(TDS_DBG_FUNC, "ct_cancel() command state SENT\n"); tdsdump_log(TDS_DBG_FUNC, "ct_cancel() sending a cancel \n"); tds_send_cancel(cmd_conn->tds_socket); tds_process_cancel(cmd_conn->tds_socket); _ct_initialise_cmd(cmd); cmd->cancel_state = _CS_CANCEL_PENDING; break; } } if (conn) { tdsdump_log(TDS_DBG_FUNC, "CS_CANCEL_ALL with connection\n"); for (cmds = conn->cmds; cmds != NULL; cmds = cmds->next) { tdsdump_log(TDS_DBG_FUNC, "ct_cancel() cancelling a command for a connection\n"); conn_cmd = cmds; switch (conn_cmd->command_state) { case _CS_COMMAND_IDLE: case _CS_COMMAND_BUILDING: case _CS_COMMAND_READY: tdsdump_log(TDS_DBG_FUNC, "ct_cancel() command state SENT\n"); _ct_initialise_cmd(conn_cmd); break; case _CS_COMMAND_SENT: tdsdump_log(TDS_DBG_FUNC, "ct_cancel() command state SENT\n"); tdsdump_log(TDS_DBG_FUNC, "ct_cancel() sending a cancel \n"); tds_send_cancel(conn->tds_socket); tds_process_cancel(conn->tds_socket); _ct_initialise_cmd(conn_cmd); conn_cmd->cancel_state = _CS_CANCEL_PENDING; break; } } } return CS_SUCCEED; } return CS_FAIL; } static CS_RETCODE _ct_cancel_cleanup(CS_COMMAND * cmd) { CS_CONNECTION * con; tdsdump_log(TDS_DBG_FUNC, "_ct_cancel_cleanup(%p)\n", cmd); con = cmd->con; if (con && !IS_TDSDEAD(con->tds_socket)) tds_process_cancel(con->tds_socket); cmd->cancel_state = _CS_CANCEL_NOCANCEL; return CS_SUCCEED; } CS_RETCODE ct_describe(CS_COMMAND * cmd, CS_INT item, CS_DATAFMT * datafmt) { TDSSOCKET *tds; TDSRESULTINFO *resinfo; TDSCOLUMN *curcol; tdsdump_log(TDS_DBG_FUNC, "ct_describe(%p, %d, %p)\n", cmd, item, datafmt); if (!cmd->con || !cmd->con->tds_socket) return CS_FAIL; tds = cmd->con->tds_socket; resinfo = tds->current_results;; if (item < 1 || item > resinfo->num_cols) return CS_FAIL; curcol = resinfo->columns[item - 1]; /* name is always null terminated */ strlcpy(datafmt->name, tds_dstr_cstr(&curcol->column_name), sizeof(datafmt->name)); datafmt->namelen = strlen(datafmt->name); /* need to turn the SYBxxx into a CS_xxx_TYPE */ datafmt->datatype = _ct_get_client_type(curcol); if (datafmt->datatype == CS_ILLEGAL_TYPE) return CS_FAIL; tdsdump_log(TDS_DBG_INFO1, "ct_describe() datafmt->datatype = %d server type %d\n", datafmt->datatype, curcol->column_type); if (is_numeric_type(curcol->column_type)) datafmt->maxlength = sizeof(CS_NUMERIC); else datafmt->maxlength = curcol->column_size; datafmt->usertype = curcol->column_usertype; datafmt->precision = curcol->column_prec; datafmt->scale = curcol->column_scale; /* * There are other options that can be returned, but these are the * only two being noted via the TDS layer. */ datafmt->status = 0; if (curcol->column_nullable) datafmt->status |= CS_CANBENULL; if (curcol->column_identity) datafmt->status |= CS_IDENTITY; if (curcol->column_writeable) datafmt->status |= CS_UPDATABLE; if (curcol->column_key) datafmt->status |= CS_KEY; if (curcol->column_hidden) datafmt->status |= CS_HIDDEN; if (curcol->column_timestamp) datafmt->status |= CS_TIMESTAMP; datafmt->count = 1; datafmt->locale = NULL; return CS_SUCCEED; } CS_RETCODE ct_res_info(CS_COMMAND * cmd, CS_INT type, CS_VOID * buffer, CS_INT buflen, CS_INT * out_len) { TDSSOCKET *tds; TDSRESULTINFO *resinfo; TDSCOLUMN *curcol; CS_INT int_val; int i; tdsdump_log(TDS_DBG_FUNC, "ct_res_info(%p, %d, %p, %d, %p)\n", cmd, type, buffer, buflen, out_len); if (!cmd->con || !cmd->con->tds_socket) return CS_FAIL; tds = cmd->con->tds_socket; resinfo = tds->current_results; switch (type) { case CS_NUMDATA: int_val = 0; if (resinfo) { for (i = 0; i < resinfo->num_cols; i++) { curcol = resinfo->columns[i]; if (!curcol->column_hidden) { int_val++; } } } tdsdump_log(TDS_DBG_FUNC, "ct_res_info(): Number of columns is %d\n", int_val); memcpy(buffer, &int_val, sizeof(CS_INT)); break; case CS_ROW_COUNT: if (cmd->results_state == _CS_RES_STATUS) return CS_FAIL; /* 64 -> 32 bit conversion saturate to the maximum */ int_val = tds->rows_affected > 0x7fffffff ? 0x7fffffff : (CS_INT) tds->rows_affected; tdsdump_log(TDS_DBG_FUNC, "ct_res_info(): Number of rows is %d\n", int_val); memcpy(buffer, &int_val, sizeof(CS_INT)); break; default: fprintf(stderr, "Unknown type in ct_res_info: %d\n", type); return CS_FAIL; break; } return CS_SUCCEED; } CS_RETCODE ct_config(CS_CONTEXT * ctx, CS_INT action, CS_INT property, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen) { CS_RETCODE ret = CS_SUCCEED; CS_INT *buf = (CS_INT *) buffer; tdsdump_log(TDS_DBG_FUNC, "ct_config(%p, %d, %d, %p, %d, %p)\n", ctx, action, property, buffer, buflen, outlen); tdsdump_log(TDS_DBG_FUNC, "ct_config() action = %s property = %d\n", CS_GET ? "CS_GET" : CS_SET ? "CS_SET" : CS_SUPPORTED ? "CS_SUPPORTED" : "CS_CLEAR", property); switch (property) { case CS_EXPOSE_FMTS: switch (action) { case CS_SUPPORTED: *buf = CS_TRUE; break; case CS_SET: if (*buf != CS_TRUE && *buf != CS_FALSE) ret = CS_FAIL; else ctx->config.cs_expose_formats = *buf; break; case CS_GET: if (buf) *buf = ctx->config.cs_expose_formats; else ret = CS_FAIL; break; case CS_CLEAR: ctx->config.cs_expose_formats = CS_FALSE; break; default: ret = CS_FAIL; } break; case CS_VER_STRING: { ret = CS_FAIL; switch (action) { case CS_GET: { if (buffer && buflen > 0 && outlen) { const TDS_COMPILETIME_SETTINGS *settings= tds_get_compiletime_settings(); *outlen= snprintf((char*)buffer, buflen, "%s (%s, default tds version=%s)", settings->freetds_version, (settings->threadsafe ? "threadsafe" : "non-threadsafe"), settings->tdsver ); ((char*)buffer)[buflen - 1]= 0; if (*outlen < 0) *outlen = strlen((char*) buffer); ret = CS_SUCCEED; } break; default: ret = CS_FAIL; break; } } } break; case CS_VERSION: ret = CS_FAIL; switch (action) { case CS_GET: { if (buffer && buflen > 0 && outlen) { const TDS_COMPILETIME_SETTINGS *settings= tds_get_compiletime_settings(); *outlen= snprintf((char*) buffer, buflen, "%s", settings->freetds_version); ((char*)buffer)[buflen - 1]= 0; if (*outlen < 0) *outlen = strlen((char*) buffer); ret = CS_SUCCEED; } break; default: ret = CS_FAIL; break; } } break; default: ret = CS_SUCCEED; break; } return ret; } CS_RETCODE ct_cmd_props(CS_COMMAND * cmd, CS_INT action, CS_INT property, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen) { TDSCURSOR *cursor; int maxcp; tdsdump_log(TDS_DBG_FUNC, "ct_cmd_props(%p, %d, %d, %p, %d, %p)\n", cmd, action, property, buffer, buflen, outlen); if (!cmd->con || !cmd->con->tds_socket) return CS_FAIL; tdsdump_log(TDS_DBG_FUNC, "ct_cmd_props() action = %s property = %d\n", CS_GET ? "CS_GET" : "CS_SET", property); if (action == CS_SET) { switch (property) { case CS_USERDATA: free(cmd->userdata); cmd->userdata = (void *) malloc(buflen + 1); tdsdump_log(TDS_DBG_INFO2, "setting userdata orig %p new %p\n", buffer, cmd->userdata); cmd->userdata_len = buflen; memcpy(cmd->userdata, buffer, buflen); break; default: break; } } if (action == CS_GET) { switch (property) { case CS_PARENT_HANDLE: *(CS_CONNECTION **) buffer = cmd->con; break; case CS_CUR_STATUS: case CS_CUR_ID: case CS_CUR_NAME: case CS_CUR_ROWCOUNT: cursor = cmd->cursor; if (!cursor) { tdsdump_log(TDS_DBG_FUNC, "ct_cmd_props() : cannot find cursor\n"); if (property == CS_CUR_STATUS) { *(CS_INT *)buffer = (CS_INT) CS_CURSTAT_NONE; if (outlen) *outlen = sizeof(CS_INT); return CS_SUCCEED; } else { return CS_FAIL; } } if (property == CS_CUR_STATUS) { *(CS_INT *)buffer = cursor->srv_status; if (outlen) *outlen = sizeof(CS_INT); } if (property == CS_CUR_ID) { *(CS_INT *)buffer = cursor->cursor_id; if (outlen) *outlen = sizeof(CS_INT); } if (property == CS_CUR_NAME) { size_t len = strlen(cursor->cursor_name); if ((CS_INT) len >= buflen) return CS_FAIL; strcpy((char*) buffer, cursor->cursor_name); if (outlen) *outlen = len; } if (property == CS_CUR_ROWCOUNT) { *(CS_INT *)buffer = cursor->cursor_rows; if (outlen) *outlen = sizeof(CS_INT); } break; case CS_USERDATA: tdsdump_log(TDS_DBG_INFO2, "fetching userdata %p\n", cmd->userdata); maxcp = cmd->userdata_len; if (outlen) *outlen = maxcp; if (maxcp > buflen) maxcp = buflen; memcpy(buffer, cmd->userdata, maxcp); break; default: break; } } return CS_SUCCEED; } CS_RETCODE ct_compute_info(CS_COMMAND * cmd, CS_INT type, CS_INT colnum, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen) { TDSSOCKET *tds; TDSRESULTINFO *resinfo; TDSCOLUMN *curcol; CS_INT int_val; CS_SMALLINT *dest_by_col_ptr; TDS_SMALLINT *src_by_col_ptr; int i; tdsdump_log(TDS_DBG_FUNC, "ct_compute_info(%p, %d, %d, %p, %d, %p)\n", cmd, type, colnum, buffer, buflen, outlen); tdsdump_log(TDS_DBG_FUNC, "ct_compute_info() type = %d, colnum = %d\n", type, colnum); if (!cmd->con || !cmd->con->tds_socket) return CS_FAIL; tds = cmd->con->tds_socket; resinfo = tds->current_results; switch (type) { case CS_BYLIST_LEN: if (!resinfo) { int_val = 0; } else { int_val = resinfo->by_cols; } memcpy(buffer, &int_val, sizeof(CS_INT)); if (outlen) *outlen = sizeof(CS_INT); break; case CS_COMP_BYLIST: if (buflen < (CS_INT) (resinfo->by_cols * sizeof(CS_SMALLINT))) { return CS_FAIL; } else { dest_by_col_ptr = (CS_SMALLINT *) buffer; src_by_col_ptr = resinfo->bycolumns; for (i = 0; i < resinfo->by_cols; i++) { *dest_by_col_ptr = *src_by_col_ptr; dest_by_col_ptr++; src_by_col_ptr++; } if (outlen) *outlen = (resinfo->by_cols * sizeof(CS_SMALLINT)); } break; case CS_COMP_COLID: if (!resinfo) { int_val = 0; } else { curcol = resinfo->columns[colnum - 1]; int_val = curcol->column_operand; } memcpy(buffer, &int_val, sizeof(CS_INT)); if (outlen) *outlen = sizeof(CS_INT); break; case CS_COMP_ID: if (!resinfo) { int_val = 0; } else { int_val = resinfo->computeid; } memcpy(buffer, &int_val, sizeof(CS_INT)); if (outlen) *outlen = sizeof(CS_INT); break; case CS_COMP_OP: if (!resinfo) { int_val = 0; } else { curcol = resinfo->columns[colnum - 1]; int_val = _ct_map_compute_op(curcol->column_operator); } memcpy(buffer, &int_val, sizeof(CS_INT)); if (outlen) *outlen = sizeof(CS_INT); break; default: fprintf(stderr, "Unknown type in ct_compute_info: %d\n", type); return CS_FAIL; break; } return CS_SUCCEED; } CS_RETCODE ct_get_data(CS_COMMAND * cmd, CS_INT item, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen) { TDSRESULTINFO *resinfo; TDSCOLUMN *curcol; unsigned char *src; TDS_INT srclen; tdsdump_log(TDS_DBG_FUNC, "ct_get_data(%p, %d, %p, %d, %p)\n", cmd, item, buffer, buflen, outlen); tdsdump_log(TDS_DBG_FUNC, "ct_get_data() item = %d buflen = %d\n", item, buflen); /* basic validations... */ if (!cmd || !cmd->con || !cmd->con->tds_socket || !(resinfo = cmd->con->tds_socket->current_results)) return CS_FAIL; if (item < 1 || item > resinfo->num_cols) return CS_FAIL; if (buffer == NULL) return CS_FAIL; if (buflen == CS_UNUSED) return CS_FAIL; if (cmd->cancel_state == _CS_CANCEL_PENDING) { _ct_cancel_cleanup(cmd); return CS_CANCELED; } /* This is a new column we are being asked to return */ if (item != cmd->get_data_item) { TDSBLOB *blob = NULL; size_t table_namelen, column_namelen; /* allocare needed descriptor if needed */ free(cmd->iodesc); cmd->iodesc = tds_new0(CS_IODESC, 1); if (!cmd->iodesc) return CS_FAIL; /* reset these values */ cmd->get_data_item = item; cmd->get_data_bytes_returned = 0; /* get at the source data and length */ curcol = resinfo->columns[item - 1]; src = curcol->column_data; if (is_blob_col(curcol)) { blob = (TDSBLOB *) src; src = (unsigned char *) blob->textvalue; } /* now populate the io_desc structure for this data item */ cmd->iodesc->iotype = CS_IODATA; cmd->iodesc->datatype = curcol->column_type; cmd->iodesc->locale = cmd->con->locale; cmd->iodesc->usertype = curcol->column_usertype; cmd->iodesc->total_txtlen = curcol->column_cur_size; cmd->iodesc->offset = 0; cmd->iodesc->log_on_update = CS_FALSE; /* TODO quote needed ?? */ /* avoid possible buffer overflow */ table_namelen = tds_dstr_len(&curcol->table_name); if (table_namelen + 2 > sizeof(cmd->iodesc->name)) table_namelen = sizeof(cmd->iodesc->name) - 2; column_namelen = tds_dstr_len(&curcol->column_name); if (table_namelen + column_namelen + 2 > sizeof(cmd->iodesc->name)) column_namelen = sizeof(cmd->iodesc->name) - 2 - table_namelen; sprintf(cmd->iodesc->name, "%*.*s.%*.*s", (int) table_namelen, (int) table_namelen, tds_dstr_cstr(&curcol->table_name), (int) column_namelen, (int) column_namelen, tds_dstr_cstr(&curcol->column_name)); cmd->iodesc->namelen = strlen(cmd->iodesc->name); if (blob && blob->valid_ptr) { memcpy(cmd->iodesc->timestamp, blob->timestamp, CS_TS_SIZE); cmd->iodesc->timestamplen = CS_TS_SIZE; memcpy(cmd->iodesc->textptr, blob->textptr, CS_TP_SIZE); cmd->iodesc->textptrlen = CS_TP_SIZE; } } else { /* get at the source data */ curcol = resinfo->columns[item - 1]; src = curcol->column_data; if (is_blob_col(curcol)) src = (unsigned char *) ((TDSBLOB *) src)->textvalue; } /* * and adjust the data and length based on * what we may have already returned */ srclen = curcol->column_cur_size; if (srclen < 0) srclen = 0; src += cmd->get_data_bytes_returned; srclen -= cmd->get_data_bytes_returned; /* if we have enough buffer to cope with all the data */ if (buflen >= srclen) { memcpy(buffer, src, srclen); cmd->get_data_bytes_returned += srclen; if (outlen) *outlen = srclen; if (item < resinfo->num_cols) return CS_END_ITEM; return CS_END_DATA; } memcpy(buffer, src, buflen); cmd->get_data_bytes_returned += buflen; if (outlen) *outlen = buflen; return CS_SUCCEED; } CS_RETCODE ct_send_data(CS_COMMAND * cmd, CS_VOID * buffer, CS_INT buflen) { TDSSOCKET *tds; char textptr_string[35]; /* 16 * 2 + 2 (0x) + 1 */ char timestamp_string[19]; /* 8 * 2 + 2 (0x) + 1 */ char *c; int s; char hex2[3]; tdsdump_log(TDS_DBG_FUNC, "ct_send_data(%p, %p, %d)\n", cmd, buffer, buflen); if (!cmd->con || !cmd->con->tds_socket) return CS_FAIL; tds = cmd->con->tds_socket; /* basic validations */ if (cmd->command_type != CS_SEND_DATA_CMD) return CS_FAIL; if (!cmd->iodesc || !cmd->iodesc->textptrlen) return CS_FAIL; /* first ct_send_data for this column */ if (!cmd->send_data_started) { /* turn the timestamp and textptr into character format */ c = textptr_string; for (s = 0; s < cmd->iodesc->textptrlen; s++) { sprintf(hex2, "%02x", cmd->iodesc->textptr[s]); *c++ = hex2[0]; *c++ = hex2[1]; } *c = '\0'; c = timestamp_string; for (s = 0; s < cmd->iodesc->timestamplen; s++) { sprintf(hex2, "%02x", cmd->iodesc->timestamp[s]); *c++ = hex2[0]; *c++ = hex2[1]; } *c = '\0'; /* submit the writetext command */ if (TDS_FAILED(tds_writetext_start(tds, cmd->iodesc->name, textptr_string, timestamp_string, (cmd->iodesc->log_on_update == CS_TRUE), cmd->iodesc->total_txtlen))) return CS_FAIL; cmd->send_data_started = 1; } if (TDS_FAILED(tds_writetext_continue(tds, (const TDS_UCHAR*) buffer, buflen))) return CS_FAIL; return CS_SUCCEED; } CS_RETCODE ct_data_info(CS_COMMAND * cmd, CS_INT action, CS_INT colnum, CS_IODESC * iodesc) { TDSSOCKET *tds; TDSRESULTINFO *resinfo; tdsdump_log(TDS_DBG_FUNC, "ct_data_info(%p, %d, %d, %p)\n", cmd, action, colnum, iodesc); if (!cmd->con || !cmd->con->tds_socket) return CS_FAIL; tds = cmd->con->tds_socket; resinfo = tds->current_results; switch (action) { case CS_SET: if (iodesc->timestamplen < 0 || iodesc->timestamplen > CS_TS_SIZE) return CS_FAIL; if (iodesc->textptrlen < 0 || iodesc->textptrlen > CS_TP_SIZE) return CS_FAIL; free(cmd->iodesc); cmd->iodesc = tds_new0(CS_IODESC, 1); cmd->iodesc->iotype = CS_IODATA; cmd->iodesc->datatype = iodesc->datatype; cmd->iodesc->locale = cmd->con->locale; cmd->iodesc->usertype = iodesc->usertype; cmd->iodesc->total_txtlen = iodesc->total_txtlen; cmd->iodesc->offset = iodesc->offset; cmd->iodesc->log_on_update = iodesc->log_on_update; strcpy(cmd->iodesc->name, iodesc->name); cmd->iodesc->namelen = iodesc->namelen; memcpy(cmd->iodesc->timestamp, iodesc->timestamp, iodesc->timestamplen); cmd->iodesc->timestamplen = iodesc->timestamplen; memcpy(cmd->iodesc->textptr, iodesc->textptr, iodesc->textptrlen); cmd->iodesc->textptrlen = iodesc->textptrlen; break; case CS_GET: if (colnum < 1 || colnum > resinfo->num_cols) return CS_FAIL; if (colnum != cmd->get_data_item) return CS_FAIL; iodesc->iotype = cmd->iodesc->iotype; iodesc->datatype = cmd->iodesc->datatype; iodesc->locale = cmd->iodesc->locale; iodesc->usertype = cmd->iodesc->usertype; iodesc->total_txtlen = cmd->iodesc->total_txtlen; iodesc->offset = cmd->iodesc->offset; iodesc->log_on_update = CS_FALSE; strcpy(iodesc->name, cmd->iodesc->name); iodesc->namelen = cmd->iodesc->namelen; memcpy(iodesc->timestamp, cmd->iodesc->timestamp, cmd->iodesc->timestamplen); iodesc->timestamplen = cmd->iodesc->timestamplen; memcpy(iodesc->textptr, cmd->iodesc->textptr, cmd->iodesc->textptrlen); iodesc->textptrlen = cmd->iodesc->textptrlen; break; default: return CS_FAIL; } return CS_SUCCEED; } CS_RETCODE ct_capability(CS_CONNECTION * con, CS_INT action, CS_INT type, CS_INT capability, CS_VOID * value) { TDSLOGIN *login; int idx = 0; unsigned char bitmask = 0; TDS_CAPABILITY_TYPE *cap = NULL; tdsdump_log(TDS_DBG_FUNC, "ct_capability(%p, %d, %d, %d, %p)\n", con, action, type, capability, value); login = (TDSLOGIN *) con->tds_login; #define CONV_CAP(ct,tds) case ct: idx=tds; break; if (type == CS_CAP_RESPONSE) { cap = &login->capabilities.types[1]; switch (capability) { CONV_CAP(CS_DATA_NOBOUNDARY, TDS_RES_DATA_NOBOUNDARY); CONV_CAP(CS_RES_NOTDSDEBUG, TDS_RES_NOTDSDEBUG); CONV_CAP(CS_RES_NOSTRIPBLANKS, TDS_RES_NOSTRIPBLANKS); CONV_CAP(CS_DATA_NOINT8, TDS_RES_DATA_NOINT8); CONV_CAP(CS_DATA_NOINTN, TDS_RES_DATA_INTN); CONV_CAP(CS_DATA_NODATETIMEN, TDS_RES_DATA_NODATETIMEN); CONV_CAP(CS_DATA_NOMONEYN, TDS_RES_DATA_NOMONEYN); CONV_CAP(CS_CON_NOOOB, TDS_RES_CON_NOOOB); CONV_CAP(CS_CON_NOINBAND, TDS_RES_CON_NOINBAND); CONV_CAP(CS_PROTO_NOTEXT, TDS_RES_PROTO_NOTEXT); CONV_CAP(CS_PROTO_NOBULK, TDS_RES_PROTO_NOBULK); CONV_CAP(CS_DATA_NOSENSITIVITY, TDS_RES_DATA_NOSENSITIVITY); CONV_CAP(CS_DATA_NOFLT4, TDS_RES_DATA_NOFLT4); CONV_CAP(CS_DATA_NOFLT8, TDS_RES_DATA_NOFLT8); CONV_CAP(CS_DATA_NONUM, TDS_RES_DATA_NONUM); CONV_CAP(CS_DATA_NOTEXT, TDS_RES_DATA_NOTEXT); CONV_CAP(CS_DATA_NOIMAGE, TDS_RES_DATA_NOIMAGE); CONV_CAP(CS_DATA_NODEC, TDS_RES_DATA_NODEC); CONV_CAP(CS_DATA_NOLCHAR, TDS_RES_DATA_NOLCHAR); CONV_CAP(CS_DATA_NOLBIN, TDS_RES_DATA_NOLBIN); CONV_CAP(CS_DATA_NOCHAR, TDS_RES_DATA_NOCHAR); CONV_CAP(CS_DATA_NOVCHAR, TDS_RES_DATA_NOVCHAR); CONV_CAP(CS_DATA_NOBIN, TDS_RES_DATA_NOBIN); CONV_CAP(CS_DATA_NOVBIN, TDS_RES_DATA_NOVBIN); CONV_CAP(CS_DATA_NOMNY8, TDS_RES_DATA_NOMNY8); CONV_CAP(CS_DATA_NOMNY4, TDS_RES_DATA_NOMNY4); CONV_CAP(CS_DATA_NODATE8, TDS_RES_DATA_NODATE8); CONV_CAP(CS_DATA_NODATE4, TDS_RES_DATA_NODATE4); CONV_CAP(CS_RES_NOMSG, TDS_RES_NOMSG); CONV_CAP(CS_RES_NOEED, TDS_RES_NOEED); CONV_CAP(CS_RES_NOPARAM, TDS_RES_NOPARAM); CONV_CAP(CS_DATA_NOINT1, TDS_RES_DATA_NOINT1); CONV_CAP(CS_DATA_NOINT2, TDS_RES_DATA_NOINT2); CONV_CAP(CS_DATA_NOINT4, TDS_RES_DATA_NOINT4); CONV_CAP(CS_DATA_NOBIT, TDS_RES_DATA_NOBIT); } /* end capability */ } /* End handling CS_CAP_RESPONSE (returned) */ /* * Begin handling CS_CAP_REQUEST * These capabilities describe the types of requests that a server can support. */ if (type == CS_CAP_REQUEST) { if (action == CS_SET) { tdsdump_log(TDS_DBG_SEVERE, "ct_capability -- attempt to set a read-only capability (type %d, action %d)\n", type, action); return CS_FAIL; } cap = &login->capabilities.types[0]; switch (capability) { CONV_CAP(CS_PROTO_DYNPROC, TDS_REQ_PROTO_DYNPROC); CONV_CAP(CS_DATA_FLTN, TDS_REQ_DATA_FLTN); CONV_CAP(CS_DATA_BITN, TDS_REQ_DATA_BITN); CONV_CAP(CS_DATA_INT8, TDS_REQ_DATA_INT8); CONV_CAP(CS_DATA_VOID, TDS_REQ_DATA_VOID); CONV_CAP(CS_CON_INBAND, TDS_REQ_CON_INBAND); CONV_CAP(CS_CON_LOGICAL, TDS_REQ_CON_LOGICAL); CONV_CAP(CS_PROTO_TEXT, TDS_REQ_PROTO_TEXT); CONV_CAP(CS_PROTO_BULK, TDS_REQ_PROTO_BULK); CONV_CAP(CS_REQ_URGNOTIF, TDS_REQ_URGEVT); CONV_CAP(CS_DATA_SENSITIVITY, TDS_REQ_DATA_SENSITIVITY); CONV_CAP(CS_DATA_BOUNDARY, TDS_REQ_DATA_BOUNDARY); CONV_CAP(CS_PROTO_DYNAMIC, TDS_REQ_PROTO_DYNAMIC); CONV_CAP(CS_DATA_MONEYN, TDS_REQ_DATA_MONEYN); CONV_CAP(CS_CSR_PREV, TDS_REQ_CSR_PREV); CONV_CAP(CS_CSR_FIRST, TDS_REQ_CSR_FIRST); CONV_CAP(CS_CSR_LAST, TDS_REQ_CSR_LAST); CONV_CAP(CS_CSR_ABS, TDS_REQ_CSR_ABS); CONV_CAP(CS_CSR_REL, TDS_REQ_CSR_REL); CONV_CAP(CS_CSR_MULTI, TDS_REQ_CSR_MULTI); CONV_CAP(CS_CON_OOB, TDS_REQ_CON_OOB); CONV_CAP(CS_DATA_NUM, TDS_REQ_DATA_NUM); CONV_CAP(CS_DATA_TEXT, TDS_REQ_DATA_TEXT); CONV_CAP(CS_DATA_IMAGE, TDS_REQ_DATA_IMAGE); CONV_CAP(CS_DATA_DEC, TDS_REQ_DATA_DEC); CONV_CAP(CS_DATA_LCHAR, TDS_REQ_DATA_LCHAR); CONV_CAP(CS_DATA_LBIN, TDS_REQ_DATA_LBIN); CONV_CAP(CS_DATA_INTN, TDS_REQ_DATA_INTN); CONV_CAP(CS_DATA_DATETIMEN, TDS_REQ_DATA_DATETIMEN); CONV_CAP(CS_DATA_BIN, TDS_REQ_DATA_BIN); CONV_CAP(CS_DATA_VBIN, TDS_REQ_DATA_VBIN); CONV_CAP(CS_DATA_MNY8, TDS_REQ_DATA_MNY8); CONV_CAP(CS_DATA_MNY4, TDS_REQ_DATA_MNY4); CONV_CAP(CS_DATA_DATE8, TDS_REQ_DATA_DATE8); CONV_CAP(CS_DATA_DATE4, TDS_REQ_DATA_DATE4); CONV_CAP(CS_DATA_FLT4, TDS_REQ_DATA_FLT4); CONV_CAP(CS_DATA_FLT8, TDS_REQ_DATA_FLT8); CONV_CAP(CS_REQ_MSG, TDS_REQ_MSG); CONV_CAP(CS_REQ_PARAM, TDS_REQ_PARAM); CONV_CAP(CS_DATA_INT1, TDS_REQ_DATA_INT1); CONV_CAP(CS_DATA_INT2, TDS_REQ_DATA_INT2); CONV_CAP(CS_DATA_INT4, TDS_REQ_DATA_INT4); CONV_CAP(CS_DATA_BIT, TDS_REQ_DATA_BIT); CONV_CAP(CS_DATA_CHAR, TDS_REQ_DATA_CHAR); CONV_CAP(CS_DATA_VCHAR, TDS_REQ_DATA_VCHAR); CONV_CAP(CS_REQ_LANG, TDS_REQ_LANG); CONV_CAP(CS_REQ_RPC, TDS_REQ_RPC); CONV_CAP(CS_REQ_NOTIF, TDS_REQ_EVT); CONV_CAP(CS_REQ_MSTMT, TDS_REQ_MSTMT); CONV_CAP(CS_REQ_BCP, TDS_REQ_BCP); CONV_CAP(CS_REQ_CURSOR, TDS_REQ_CURSOR); CONV_CAP(CS_REQ_DYN, TDS_REQ_DYNF); } /* end capability */ } /* End handling CS_CAP_REQUEST */ #undef CONV_CAP if (cap == NULL) { tdsdump_log(TDS_DBG_SEVERE, "ct_capability -- unknown capability type\n"); return CS_FAIL; } if (idx == 0) { tdsdump_log(TDS_DBG_SEVERE, "ct_capability -- attempt to set/get a non-existant capability\n"); return CS_FAIL; } bitmask = 1 << (idx&7); idx = sizeof(cap->values) - 1 - (idx>>3); assert(0 <= idx && idx <= sizeof(cap->values)); switch (action) { case CS_SET: /* Having established the offset and the bitmask, we can now turn the capability on or off */ switch (*(CS_BOOL *) value) { case CS_TRUE: cap->values[idx] |= bitmask; break; case CS_FALSE: cap->values[idx] &= ~bitmask; break; default: tdsdump_log(TDS_DBG_SEVERE, "ct_capability -- unknown value\n"); return CS_FAIL; } break; case CS_GET: *(CS_BOOL *) value = (cap->values[idx] & bitmask) ? CS_TRUE : CS_FALSE; break; default: tdsdump_log(TDS_DBG_SEVERE, "ct_capability -- unknown action\n"); return CS_FAIL; } return CS_SUCCEED; } /* end ct_capability */ CS_RETCODE ct_dynamic(CS_COMMAND * cmd, CS_INT type, CS_CHAR * id, CS_INT idlen, CS_CHAR * buffer, CS_INT buflen) { int query_len; CS_CONNECTION *con; CS_DYNAMIC *dyn; tdsdump_log(TDS_DBG_FUNC, "ct_dynamic(%p, %d, %p, %d, %p, %d)\n", cmd, type, id, idlen, buffer, buflen); if (!cmd->con) return CS_FAIL; con = cmd->con; switch (type) { case CS_PREPARE: dyn = _ct_allocate_dynamic(con, id, idlen); if (dyn == NULL) { return CS_FAIL; } /* now the query */ if (buflen == CS_NULLTERM) { query_len = strlen(buffer); } else { query_len = buflen; } dyn->stmt = tds_strndup(buffer, query_len); cmd->dyn = dyn; break; case CS_DEALLOC: cmd->dyn = _ct_locate_dynamic(con, id, idlen); if (cmd->dyn == NULL) return CS_FAIL; break; case CS_DESCRIBE_INPUT: case CS_DESCRIBE_OUTPUT: cmd->dyn = _ct_locate_dynamic(con, id, idlen); if (cmd->dyn == NULL) return CS_FAIL; break; case CS_EXECUTE: cmd->dyn = _ct_locate_dynamic(con, id, idlen); if (cmd->dyn == NULL) return CS_FAIL; tdsdump_log(TDS_DBG_FUNC, "ct_dynamic() calling param_clear\n"); param_clear(cmd->dyn->param_list); cmd->dyn->param_list = NULL; break; default: return CS_FAIL; } cmd->command_type = CS_DYNAMIC_CMD; cmd->dynamic_cmd = type; ct_set_command_state(cmd, _CS_COMMAND_READY); return CS_SUCCEED; } CS_RETCODE ct_param(CS_COMMAND * cmd, CS_DATAFMT * datafmt, CS_VOID * data, CS_INT datalen, CS_SMALLINT indicator) { CSREMOTE_PROC *rpc; CS_DYNAMIC *dyn; CS_PARAM **pparam; CS_PARAM *param; tdsdump_log(TDS_DBG_FUNC, "ct_param(%p, %p, %p, %d, %hd)\n", cmd, datafmt, data, datalen, indicator); tdsdump_log(TDS_DBG_INFO1, "ct_param() data addr = %p data length = %d\n", data, datalen); if (cmd == NULL) return CS_FAIL; switch (cmd->command_type) { case CS_RPC_CMD: if (cmd->rpc == NULL) { fprintf(stdout, "RPC is NULL ct_param\n"); return CS_FAIL; } param = tds_new0(CSREMOTE_PROC_PARAM, 1); if (!param) return CS_FAIL; if (CS_SUCCEED != _ct_fill_param(cmd->command_type, param, datafmt, data, &datalen, &indicator, 1)) { tdsdump_log(TDS_DBG_INFO1, "ct_param() failed to add rpc param\n"); tdsdump_log(TDS_DBG_INFO1, "ct_param() failed to add input value\n"); free(param); return CS_FAIL; } rpc = cmd->rpc; pparam = &rpc->param_list; while (*pparam) { pparam = &(*pparam)->next; } *pparam = param; tdsdump_log(TDS_DBG_INFO1, " ct_param() added rpc parameter %s \n", (*param).name); return CS_SUCCEED; break; case CS_LANG_CMD: /* only accept CS_INPUTVALUE as the status */ if (CS_INPUTVALUE != datafmt->status) { tdsdump_log(TDS_DBG_ERROR, "illegal datafmt->status(%d) passed to ct_param()\n", datafmt->status); return CS_FAIL; } param = tds_new0(CSREMOTE_PROC_PARAM, 1); if (CS_SUCCEED != _ct_fill_param(cmd->command_type, param, datafmt, data, &datalen, &indicator, 1)) { free(param); return CS_FAIL; } if (NULL == cmd->input_params) cmd->input_params = param; else { pparam = &cmd->input_params; while ((*pparam)->next) pparam = &(*pparam)->next; (*pparam)->next = param; } tdsdump_log(TDS_DBG_INFO1, "ct_param() added input value\n"); return CS_SUCCEED; break; case CS_DYNAMIC_CMD: if (cmd->dyn == NULL) { tdsdump_log(TDS_DBG_INFO1, "cmd->dyn is NULL ct_param\n"); return CS_FAIL; } param = tds_new0(CS_DYNAMIC_PARAM, 1); if (!param) return CS_FAIL; if (CS_SUCCEED != _ct_fill_param(cmd->command_type, param, datafmt, data, &datalen, &indicator, 1)) { tdsdump_log(TDS_DBG_INFO1, "ct_param() failed to add CS_DYNAMIC param\n"); free(param); return CS_FAIL; } dyn = cmd->dyn; pparam = &dyn->param_list; while (*pparam) { pparam = &(*pparam)->next; } *pparam = param; return CS_SUCCEED; break; } return CS_FAIL; } CS_RETCODE ct_setparam(CS_COMMAND * cmd, CS_DATAFMT * datafmt, CS_VOID * data, CS_INT * datalen, CS_SMALLINT * indicator) { CSREMOTE_PROC *rpc; CS_PARAM **pparam; CS_PARAM *param; CS_DYNAMIC *dyn; tdsdump_log(TDS_DBG_FUNC, "ct_setparam(%p, %p, %p, %p, %p)\n", cmd, datafmt, data, datalen, indicator); tdsdump_log(TDS_DBG_FUNC, "ct_setparam() command type = %d, data type = %d\n", cmd->command_type, datafmt->datatype); /* Code changed for RPC functionality - SUHA */ /* RPC code changes starts here */ if (cmd == NULL) return CS_FAIL; switch (cmd->command_type) { case CS_RPC_CMD: if (cmd->rpc == NULL) { fprintf(stdout, "RPC is NULL ct_param\n"); return CS_FAIL; } param = tds_new0(CSREMOTE_PROC_PARAM, 1); if (CS_SUCCEED != _ct_fill_param(cmd->command_type, param, datafmt, data, datalen, indicator, 0)) { tdsdump_log(TDS_DBG_INFO1, "ct_setparam() failed to add rpc param\n"); tdsdump_log(TDS_DBG_INFO1, "ct_setparam() failed to add input value\n"); free(param); return CS_FAIL; } rpc = cmd->rpc; pparam = &rpc->param_list; tdsdump_log(TDS_DBG_INFO1, " ct_setparam() reached here\n"); if (*pparam != NULL) { while ((*pparam)->next != NULL) { pparam = &(*pparam)->next; } pparam = &(*pparam)->next; } *pparam = param; param->next = NULL; tdsdump_log(TDS_DBG_INFO1, " ct_setparam() added parameter %s \n", (*param).name); return CS_SUCCEED; break; case CS_DYNAMIC_CMD : if (cmd->dyn == NULL) { fprintf(stdout, "cmd->dyn is NULL ct_param\n"); return CS_FAIL; } param = tds_new0(CS_DYNAMIC_PARAM, 1); if (CS_SUCCEED != _ct_fill_param(cmd->command_type, param, datafmt, data, datalen, indicator, 0)) { tdsdump_log(TDS_DBG_INFO1, "ct_setparam() failed to add dynamic param\n"); free(param); return CS_FAIL; } dyn = cmd->dyn; pparam = &dyn->param_list; if (*pparam != NULL) { while ((*pparam)->next != NULL) { pparam = &(*pparam)->next; } pparam = &(*pparam)->next; } *pparam = param; param->next = NULL; tdsdump_log(TDS_DBG_INFO1, "ct_setparam() added dynamic parameter\n"); return CS_SUCCEED; break; case CS_LANG_CMD: /* only accept CS_INPUTVALUE as the status */ if (CS_INPUTVALUE != datafmt->status) { tdsdump_log(TDS_DBG_ERROR, "illegal datafmt->status(%d) passed to ct_setparam()\n", datafmt->status); return CS_FAIL; } param = tds_new0(CSREMOTE_PROC_PARAM, 1); if (CS_SUCCEED != _ct_fill_param(cmd->command_type, param, datafmt, data, datalen, indicator, 0)) { tdsdump_log(TDS_DBG_INFO1, "ct_setparam() failed to add language param\n"); free(param); return CS_FAIL; } if (NULL == cmd->input_params) cmd->input_params = param; else { pparam = &cmd->input_params; while ((*pparam)->next) pparam = &(*pparam)->next; (*pparam)->next = param; } tdsdump_log(TDS_DBG_INFO1, "ct_setparam() added language parameter\n"); return CS_SUCCEED; break; } return CS_FAIL; } CS_RETCODE ct_options(CS_CONNECTION * con, CS_INT action, CS_INT option, CS_VOID * param, CS_INT paramlen, CS_INT * outlen) { TDS_OPTION_CMD tds_command; TDS_OPTION tds_option = 0; TDS_OPTION_ARG tds_argument; TDS_INT tds_argsize = 0; TDSSOCKET *tds; const char *action_string = NULL; int i; /* boolean options can all be treated the same way */ static const struct TDS_BOOL_OPTION_MAP { CS_INT option; TDS_OPTION tds_option; } tds_bool_option_map[] = { { CS_OPT_ANSINULL, TDS_OPT_ANSINULL } , { CS_OPT_CHAINXACTS, TDS_OPT_CHAINXACTS } , { CS_OPT_CURCLOSEONXACT, TDS_OPT_CURCLOSEONXACT } , { CS_OPT_FIPSFLAG, TDS_OPT_FIPSFLAG } , { CS_OPT_FORCEPLAN, TDS_OPT_FORCEPLAN } , { CS_OPT_FORMATONLY, TDS_OPT_FORMATONLY } , { CS_OPT_GETDATA, TDS_OPT_GETDATA } , { CS_OPT_NOCOUNT, TDS_OPT_NOCOUNT } , { CS_OPT_NOEXEC, TDS_OPT_NOEXEC } , { CS_OPT_PARSEONLY, TDS_OPT_PARSEONLY } , { CS_OPT_QUOTED_IDENT, TDS_OPT_QUOTED_IDENT } , { CS_OPT_RESTREES, TDS_OPT_RESTREES } , { CS_OPT_SHOWPLAN, TDS_OPT_SHOWPLAN } , { CS_OPT_STATS_IO, TDS_OPT_STAT_IO } , { CS_OPT_STATS_TIME, TDS_OPT_STAT_TIME } , { CS_OPT_ARITHIGNORE, TDS_OPT_ARITHIGNOREON } , { CS_OPT_ARITHABORT, TDS_OPT_ARITHABORTON } }; tdsdump_log(TDS_DBG_FUNC, "ct_options(%p, %d, %d, %p, %d, %p)\n", con, action, option, param, paramlen, outlen); if (param == NULL) return CS_FAIL; if (!con || (tds=con->tds_socket) == NULL) return CS_FAIL; /* * Set the tds command */ switch (action) { case CS_GET: tds_command = TDS_OPT_LIST; /* will be acknowledged by TDS_OPT_INFO */ action_string = "CS_GET"; tds_argsize = 0; break; case CS_SET: tds_command = TDS_OPT_SET; action_string = "CS_SET"; break; case CS_CLEAR: tds_command = TDS_OPT_DEFAULT; action_string = "CS_CLEAR"; tds_argsize = 0; break; default: tdsdump_log(TDS_DBG_FUNC, "ct_options: invalid action = %d\n", action); return CS_FAIL; } assert(tds_command && action_string); tdsdump_log(TDS_DBG_FUNC, "ct_options: %s, option = %d\n", action_string, option); /* * Set the tds option * The following TDS options apparently cannot be set with this function. * TDS_OPT_CHARSET * TDS_OPT_CURREAD * TDS_OPT_IDENTITYOFF * TDS_OPT_IDENTITYON * TDS_OPT_CURWRITE * TDS_OPT_NATLANG * TDS_OPT_ROWCOUNT */ /* * First, take care of the easy cases, the booleans. */ for (i = 0; i < TDS_VECTOR_SIZE(tds_bool_option_map); i++) { if (tds_bool_option_map[i].option != option) continue; tds_option = tds_bool_option_map[i].tds_option; if (action == CS_SET) { switch (*(CS_BOOL *) param) { case CS_TRUE: tds_argument.ti = 1; break; case CS_FALSE: tds_argument.ti = 0; break; default: return CS_FAIL; } tds_argsize = 1; } if (action == CS_GET) { tds_argsize = 0; } goto SEND_OPTION; } /* * Non-booleans are more complicated. */ switch (option) { case CS_OPT_ANSIPERM: case CS_OPT_STR_RTRUNC: /* no documented tds option */ switch (*(CS_BOOL *) param) { case CS_TRUE: case CS_FALSE: break; /* end valid choices */ default: if (action == CS_SET) return CS_FAIL; } break; case CS_OPT_AUTHOFF: tds_option = TDS_OPT_AUTHOFF; tds_argument.c = (TDS_CHAR *) param; tds_argsize = (action == CS_SET) ? paramlen : 0; break; case CS_OPT_AUTHON: tds_option = TDS_OPT_AUTHON; tds_argument.c = (TDS_CHAR *) param; tds_argsize = (action == CS_SET) ? paramlen : 0; break; case CS_OPT_DATEFIRST: tds_option = TDS_OPT_DATEFIRST; switch (*(CS_INT *) param) { case CS_OPT_SUNDAY: tds_argument.ti = TDS_OPT_SUNDAY; break; case CS_OPT_MONDAY: tds_argument.ti = TDS_OPT_MONDAY; break; case CS_OPT_TUESDAY: tds_argument.ti = TDS_OPT_TUESDAY; break; case CS_OPT_WEDNESDAY: tds_argument.ti = TDS_OPT_WEDNESDAY; break; case CS_OPT_THURSDAY: tds_argument.ti = TDS_OPT_THURSDAY; break; case CS_OPT_FRIDAY: tds_argument.ti = TDS_OPT_FRIDAY; break; case CS_OPT_SATURDAY: tds_argument.ti = TDS_OPT_SATURDAY; break; default: if (action == CS_SET) return CS_FAIL; } tds_argsize = (action == CS_SET) ? 1 : 0; break; case CS_OPT_DATEFORMAT: tds_option = TDS_OPT_DATEFORMAT; switch (*(CS_INT *) param) { case CS_OPT_FMTMDY: tds_argument.ti = TDS_OPT_FMTMDY; break; case CS_OPT_FMTDMY: tds_argument.ti = TDS_OPT_FMTDMY; break; case CS_OPT_FMTYMD: tds_argument.ti = TDS_OPT_FMTYMD; break; case CS_OPT_FMTYDM: tds_argument.ti = TDS_OPT_FMTYDM; break; case CS_OPT_FMTMYD: tds_argument.ti = TDS_OPT_FMTMYD; break; case CS_OPT_FMTDYM: tds_argument.ti = TDS_OPT_FMTDYM; break; default: if (action == CS_SET) return CS_FAIL; } tds_argsize = (action == CS_SET) ? 1 : 0; break; case CS_OPT_ISOLATION: tds_option = TDS_OPT_ISOLATION; switch (*(char *) param) { case CS_OPT_LEVEL0: /* CS_OPT_LEVEL0 requires SQL Server version 11.0 or later or Adaptive Server. */ tds_argument.ti = TDS_OPT_LEVEL0; break; case CS_OPT_LEVEL1: tds_argument.ti = TDS_OPT_LEVEL1; break; case CS_OPT_LEVEL2: tds_argument.ti = TDS_OPT_LEVEL2; break; case CS_OPT_LEVEL3: tds_argument.ti = TDS_OPT_LEVEL3; break; default: if (action == CS_SET) return CS_FAIL; } tds_argsize = (action == CS_SET) ? 1 : 0; break; case CS_OPT_TEXTSIZE: tds_option = TDS_OPT_TEXTSIZE; tds_argument.i = *(CS_INT *) param; tds_argsize = (action == CS_SET) ? sizeof(tds_argument.i) : 0; break; case CS_OPT_TRUNCIGNORE: tds_option = TDS_OPT_TRUNCABORT; /* note inverted sense */ switch (*(CS_BOOL *) param) { case CS_TRUE: case CS_FALSE: break; default: if (action == CS_SET) return CS_FAIL; } tds_argument.ti = !*(CS_BOOL *) param; tds_argsize = (action == CS_SET) ? 1 : 0; break; default: return CS_FAIL; /* invalid option */ } SEND_OPTION: tdsdump_log(TDS_DBG_FUNC, "\ttds_submit_optioncmd will be action(%s) option(%d) arg(%x) arglen(%d)\n", action_string, tds_option, tds_argsize == 1 ? tds_argument.ti : (tds_argsize == 4 ? tds_argument.i : 0), tds_argsize); if (TDS_FAILED(tds_submit_optioncmd(tds, tds_command, tds_option, &tds_argument, tds_argsize))) { return CS_FAIL; } if (action == CS_GET) { switch (option) { case CS_OPT_ANSINULL : case CS_OPT_CHAINXACTS : case CS_OPT_CURCLOSEONXACT : case CS_OPT_NOCOUNT : case CS_OPT_QUOTED_IDENT : *(CS_BOOL *)param = tds->option_value; break; case CS_OPT_DATEFIRST: switch (tds->option_value) { case TDS_OPT_SUNDAY: *(CS_INT *)param = CS_OPT_SUNDAY; break; case TDS_OPT_MONDAY: *(CS_INT *)param = CS_OPT_MONDAY; break; case TDS_OPT_TUESDAY: *(CS_INT *)param = CS_OPT_TUESDAY; break; case TDS_OPT_WEDNESDAY: *(CS_INT *)param = CS_OPT_WEDNESDAY; break; case TDS_OPT_THURSDAY: *(CS_INT *)param = CS_OPT_THURSDAY; break; case TDS_OPT_FRIDAY: *(CS_INT *)param = CS_OPT_FRIDAY; break; case TDS_OPT_SATURDAY: *(CS_INT *)param = CS_OPT_SATURDAY; break; default: return CS_FAIL; } break; case CS_OPT_DATEFORMAT: switch (tds->option_value) { case TDS_OPT_FMTDMY: *(CS_INT *)param = CS_OPT_FMTDMY; break; case TDS_OPT_FMTDYM: *(CS_INT *)param = CS_OPT_FMTDYM; break; case TDS_OPT_FMTMDY: *(CS_INT *)param = CS_OPT_FMTMDY; break; case TDS_OPT_FMTMYD: *(CS_INT *)param = CS_OPT_FMTMYD; break; case TDS_OPT_FMTYMD: *(CS_INT *)param = CS_OPT_FMTYMD; break; case TDS_OPT_FMTYDM: *(CS_INT *)param = CS_OPT_FMTYDM; break; default: return CS_FAIL; } break; case CS_OPT_ARITHABORT : case CS_OPT_ARITHIGNORE : *(CS_BOOL *)param = tds->option_value; break; case CS_OPT_TRUNCIGNORE : break; } } return CS_SUCCEED; } /* end ct_options() */ CS_RETCODE ct_poll(CS_CONTEXT * ctx, CS_CONNECTION * connection, CS_INT milliseconds, CS_CONNECTION ** compconn, CS_COMMAND ** compcmd, CS_INT * compid, CS_INT * compstatus) { tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED ct_poll()\n"); tdsdump_log(TDS_DBG_FUNC, "ct_poll(%p, %p, %d, %p, %p, %p, %p)\n", ctx, connection, milliseconds, compconn, compcmd, compid, compstatus); return CS_FAIL; } CS_RETCODE ct_cursor(CS_COMMAND * cmd, CS_INT type, CS_CHAR * name, CS_INT namelen, CS_CHAR * text, CS_INT tlen, CS_INT option) { TDSSOCKET *tds; TDSCURSOR *cursor; tdsdump_log(TDS_DBG_FUNC, "ct_cursor(%p, %d, %p, %d, %p, %d, %d)\n", cmd, type, name, namelen, text, tlen, option); if (!cmd->con || !cmd->con->tds_socket) return CS_FAIL; tds = cmd->con->tds_socket; cmd->command_type = CS_CUR_CMD; tdsdump_log(TDS_DBG_FUNC, "ct_cursor() : type = %d \n", type); switch (type) { case CS_CURSOR_DECLARE: cursor = tds_alloc_cursor(tds, name, namelen == CS_NULLTERM ? strlen(name) : namelen, text, tlen == CS_NULLTERM ? strlen(text) : tlen); if (!cursor) return CS_FAIL; cursor->cursor_rows = 1; cursor->options = option; cursor->status.declare = TDS_CURSOR_STATE_REQUESTED; cursor->status.cursor_row = TDS_CURSOR_STATE_UNACTIONED; cursor->status.open = TDS_CURSOR_STATE_UNACTIONED; cursor->status.fetch = TDS_CURSOR_STATE_UNACTIONED; cursor->status.close = TDS_CURSOR_STATE_UNACTIONED; cursor->status.dealloc = TDS_CURSOR_STATE_UNACTIONED; tds_release_cursor(&cmd->cursor); cmd->cursor = cursor; ct_set_command_state(cmd, _CS_COMMAND_READY); return CS_SUCCEED; break; case CS_CURSOR_ROWS: cursor = cmd->cursor; if (!cursor) { tdsdump_log(TDS_DBG_FUNC, "ct_cursor() : cursor not present\n"); return CS_FAIL; } if (cursor->status.declare == _CS_CURS_TYPE_REQUESTED || cursor->status.declare == _CS_CURS_TYPE_SENT) { cursor->cursor_rows = option; cursor->status.cursor_row = TDS_CURSOR_STATE_REQUESTED; ct_set_command_state(cmd, _CS_COMMAND_READY); return CS_SUCCEED; } else { cursor->status.cursor_row = TDS_CURSOR_STATE_UNACTIONED; tdsdump_log(TDS_DBG_FUNC, "ct_cursor() : cursor not declared\n"); return CS_FAIL; } break; case CS_CURSOR_OPEN: cursor = cmd->cursor; if (!cursor) { tdsdump_log(TDS_DBG_FUNC, "ct_cursor() : cursor not present\n"); return CS_FAIL; } if (cursor->status.declare == _CS_CURS_TYPE_REQUESTED || cursor->status.declare == _CS_CURS_TYPE_SENT ) { cursor->status.open = TDS_CURSOR_STATE_REQUESTED; return CS_SUCCEED; ct_set_command_state(cmd, _CS_COMMAND_READY); } else { cursor->status.open = TDS_CURSOR_STATE_UNACTIONED; tdsdump_log(TDS_DBG_FUNC, "ct_cursor() : cursor not declared\n"); return CS_FAIL; } break; case CS_CURSOR_CLOSE: cursor = cmd->cursor; if (!cursor) { tdsdump_log(TDS_DBG_FUNC, "ct_cursor() : cursor not present\n"); return CS_FAIL; } cursor->status.cursor_row = TDS_CURSOR_STATE_UNACTIONED; cursor->status.open = TDS_CURSOR_STATE_UNACTIONED; cursor->status.fetch = TDS_CURSOR_STATE_UNACTIONED; cursor->status.close = TDS_CURSOR_STATE_REQUESTED; if (option == CS_DEALLOC) { cursor->status.dealloc = TDS_CURSOR_STATE_REQUESTED; } ct_set_command_state(cmd, _CS_COMMAND_READY); return CS_SUCCEED; case CS_CURSOR_DEALLOC: cursor = cmd->cursor; if (!cursor) { tdsdump_log(TDS_DBG_FUNC, "ct_cursor() : cursor not present\n"); return CS_FAIL; } cursor->status.dealloc = TDS_CURSOR_STATE_REQUESTED; ct_set_command_state(cmd, _CS_COMMAND_READY); return CS_SUCCEED; case CS_IMPLICIT_CURSOR: tdsdump_log(TDS_DBG_INFO1, "CS_IMPLICIT_CURSOR: Option not implemented\n"); return CS_FAIL; case CS_CURSOR_OPTION: tdsdump_log(TDS_DBG_INFO1, "CS_CURSOR_OPTION: Option not implemented\n"); return CS_FAIL; case CS_CURSOR_UPDATE: tdsdump_log(TDS_DBG_INFO1, "CS_CURSOR_UPDATE: Option not implemented\n"); return CS_FAIL; case CS_CURSOR_DELETE: tdsdump_log(TDS_DBG_INFO1, "CS_CURSOR_DELETE: Option not implemented\n"); return CS_FAIL; } return CS_FAIL; } static int _ct_fetchable_results(CS_COMMAND * cmd) { tdsdump_log(TDS_DBG_FUNC, "_ct_fetchable_results(%p)\n", cmd); switch (cmd->curr_result_type) { case CS_COMPUTE_RESULT: case CS_CURSOR_RESULT: case CS_PARAM_RESULT: case CS_ROW_RESULT: case CS_STATUS_RESULT: return 1; } return 0; } static TDSRET _ct_process_return_status(TDSSOCKET * tds) { TDSRESULTINFO *info; TDSCOLUMN *curcol; TDS_INT saved_status; TDSRET rc; enum { num_cols = 1 }; tdsdump_log(TDS_DBG_FUNC, "_ct_process_return_status(%p)\n", tds); assert(tds); saved_status = tds->ret_status; tds_free_all_results(tds); /* allocate the columns structure */ tds->res_info = tds_alloc_results(num_cols); tds_set_current_results(tds, tds->res_info); if (!tds->res_info) return TDS_FAIL; info = tds->res_info; curcol = info->columns[0]; tds_set_column_type(tds->conn, curcol, SYBINT4); tdsdump_log(TDS_DBG_INFO1, "generating return status row. type = %d(%s), varint_size %d\n", curcol->column_type, tds_prtype(curcol->column_type), curcol->column_varint_size); rc = tds_alloc_row(info); if (TDS_FAILED(rc)) return rc; assert(curcol->column_data != NULL); *(TDS_INT *) curcol->column_data = saved_status; return TDS_SUCCESS; } /* Code added for RPC functionality - SUHA */ /* RPC code changes starts here */ static const unsigned char * paramrowalloc(TDSPARAMINFO * params, TDSCOLUMN * curcol, int param_num, void *value, int size) { const void *row = tds_alloc_param_data(curcol); tdsdump_log(TDS_DBG_INFO1, "paramrowalloc, size = %d, data = %p, row_size = %d\n", size, curcol->column_data, params->row_size); if (!row) return NULL; if (value) { /* TODO check for BLOB and numeric */ if (size > curcol->column_size) { tdsdump_log(TDS_DBG_FUNC, "paramrowalloc(): RESIZE %d to %d\n", size, curcol->column_size); size = curcol->column_size; } /* TODO blobs */ if (!is_blob_col(curcol)) memcpy(curcol->column_data, value, size); else { TDSBLOB *blob = (TDSBLOB *) curcol->column_data; blob->textvalue = tds_new(TDS_CHAR, size); tdsdump_log(TDS_DBG_FUNC, "blob parameter supported, size %d textvalue pointer is %p\n", size, blob->textvalue); if (!blob->textvalue) return NULL; memcpy(blob->textvalue, value, size); } curcol->column_cur_size = size; } else { tdsdump_log(TDS_DBG_FUNC, "paramrowalloc(): setting parameter #%d to NULL\n", param_num); curcol->column_cur_size = -1; } return (const unsigned char*) row; } /** * Allocate memory and copy the rpc information into a TDSPARAMINFO structure. */ static TDSPARAMINFO * paraminfoalloc(TDSSOCKET * tds, CS_PARAM * first_param) { int i; CS_PARAM *p; TDSCOLUMN *pcol; TDSPARAMINFO *params = NULL, *new_params; int temp_type; TDS_SERVER_TYPE tds_type; tdsdump_log(TDS_DBG_FUNC, "paraminfoalloc(%p, %p)\n", tds, first_param); /* sanity */ if (first_param == NULL) return NULL; for (i = 0, p = first_param; p != NULL; p = p->next, i++) { const unsigned char *prow; CS_BYTE *temp_value = NULL; CS_INT temp_datalen = 0; if (!(new_params = tds_alloc_param_result(params))) goto memory_error; params = new_params; /* * The parameteter data has been passed by reference * i.e. using ct_setparam rather than ct_param */ temp_type = p->datatype; tds_type = _ct_get_server_type(tds, p->datatype); if (tds_type == TDS_INVALID_TYPE) goto type_error; if (p->param_by_value == 0) { /* * there are three ways to indicate null parameters * 1) *ind == -1 * 2) *datalen == 0 * 3) value, datalen and ind as NULL. Here value == NULL is * sufficient */ if (*(p->ind) != -1 && p->value != NULL && *(p->datalen) != 0) { /* datafmt.datalen is ignored for fixed length types */ if (is_fixed_type(tds_type)) { temp_datalen = tds_get_size_by_type(tds_type); } else { temp_datalen = (*(p->datalen) == CS_UNUSED) ? 0 : *(p->datalen); } temp_value = p->value; } } else { temp_value = p->value; temp_datalen = *(p->datalen); } if (temp_type == CS_VARCHAR_TYPE || temp_type == CS_VARBINARY_TYPE) { CS_VARCHAR *vc = (CS_VARCHAR *) temp_value; if (vc) { temp_datalen = vc->len; temp_value = (CS_BYTE *) vc->str; } } pcol = params->columns[i]; /* meta data */ if (p->name) if (!tds_dstr_copy(&pcol->column_name, p->name)) goto memory_error; tds_set_param_type(tds->conn, pcol, tds_type); if (temp_datalen == CS_NULLTERM && temp_value) temp_datalen = strlen((const char*) temp_value); pcol->column_prec = p->precision; pcol->column_scale = p->scale; if (pcol->column_varint_size) { if (p->maxlen < 0) { tds_free_param_results(params); return NULL; } pcol->on_server.column_size = pcol->column_size = p->maxlen; pcol->column_cur_size = temp_value ? temp_datalen : -1; if (temp_datalen > 0 && temp_datalen > p->maxlen) pcol->on_server.column_size = pcol->column_size = temp_datalen; } else { pcol->column_cur_size = pcol->column_size; } if (p->status == CS_RETURN) pcol->column_output = 1; else pcol->column_output = 0; /* actual data */ tdsdump_log(TDS_DBG_FUNC, "paraminfoalloc: status = %d, maxlen %d \n", p->status, p->maxlen); tdsdump_log(TDS_DBG_FUNC, "paraminfoalloc: name = %s, varint size %d " "column_type %d size %d, %d column_cur_size %d column_output = %d\n", tds_dstr_cstr(&pcol->column_name), pcol->column_varint_size, pcol->column_type, pcol->on_server.column_size, pcol->column_size, pcol->column_cur_size, pcol->column_output); prow = paramrowalloc(params, pcol, i, temp_value, temp_datalen); if (!prow) goto memory_error; } return params; memory_error: tdsdump_log(TDS_DBG_SEVERE, "out of memory for rpc!"); type_error: tds_free_param_results(params); return NULL; } static void rpc_clear(CSREMOTE_PROC * rpc) { tdsdump_log(TDS_DBG_FUNC, "rpc_clear(%p)\n", rpc); if (rpc == NULL) return; param_clear(rpc->param_list); free(rpc->name); free(rpc); } /** * recursively erase the parameter list */ static void param_clear(CS_PARAM * pparam) { tdsdump_log(TDS_DBG_FUNC, "param_clear(%p)\n", pparam); if (pparam == NULL) return; if (pparam->next) { param_clear(pparam->next); pparam->next = NULL; } /* free self after clearing children */ free(pparam->name); if (pparam->param_by_value) free(pparam->value); /* * DO NOT free datalen or ind, they are just pointer * to client data or private structure */ free(pparam); } /* RPC Code changes ends here */ static int _ct_fill_param(CS_INT cmd_type, CS_PARAM *param, CS_DATAFMT *datafmt, CS_VOID *data, CS_INT *datalen, CS_SMALLINT *indicator, CS_BYTE byvalue) { TDS_SERVER_TYPE desttype; tdsdump_log(TDS_DBG_FUNC, "_ct_fill_param(%d, %p, %p, %p, %p, %p, %x)\n", cmd_type, param, datafmt, data, datalen, indicator, byvalue); if (cmd_type == CS_DYNAMIC_CMD) { param->name = NULL; } else { if (datafmt->namelen == CS_NULLTERM) { param->name = strdup(datafmt->name); if (param->name == NULL) return CS_FAIL; } else if (datafmt->namelen > 0) { param->name = tds_strndup(datafmt->name, datafmt->namelen); if (param->name == NULL) return CS_FAIL; } else { param->name = NULL; } } param->status = datafmt->status; tdsdump_log(TDS_DBG_INFO1, " _ct_fill_param() status = %d \n", param->status); /* * translate datafmt.datatype, e.g. CS_SMALLINT_TYPE * to Server type, e.g. SYBINT2 */ desttype = _ct_get_server_type(NULL, datafmt->datatype); if (desttype == TDS_INVALID_TYPE) return CS_FAIL; param->datatype = datafmt->datatype; if (is_numeric_type(desttype)) { param->scale = datafmt->scale; param->precision = datafmt->precision; if (param->scale < 0 || param->precision < 0 || param->precision > MAXPRECISION || param->scale > param->precision) return CS_FAIL; } param->maxlen = datafmt->maxlength; if (is_fixed_type(desttype)) { param->maxlen = tds_get_size_by_type(desttype); } param->param_by_value = byvalue; if (byvalue) { param->datalen = ¶m->datalen_value; *(param->datalen) = *datalen; param->ind = ¶m->indicator_value; *(param->ind) = *indicator; /* * There are two ways to indicate a parameter with a null value: * - Pass indicator as -1. In this case, data and datalen are ignored. * - Pass data as NULL and datalen as 0 or CS_UNUSED */ if (*indicator == -1 || (data == NULL && (*datalen == 0 || *datalen == CS_UNUSED))) { param->value = NULL; *(param->datalen) = 0; } else { /* datafmt.datalen is ignored for fixed length types */ if (is_fixed_type(desttype)) { *(param->datalen) = tds_get_size_by_type(desttype); } else { *(param->datalen) = (*datalen == CS_UNUSED) ? 0 : *datalen; } if (data) { if (*(param->datalen) == CS_NULLTERM) { tdsdump_log(TDS_DBG_INFO1, " _ct_fill_param() about to strdup string %u bytes long\n", (unsigned int) strlen((const char*) data)); *(param->datalen) = strlen((const char*) data); } else if (*(param->datalen) < 0) { return CS_FAIL; } param->value = tds_new(CS_BYTE, *(param->datalen) ? *(param->datalen) : 1); if (param->value == NULL) return CS_FAIL; memcpy(param->value, data, *(param->datalen)); param->param_by_value = 1; } else { param->value = NULL; *(param->datalen) = 0; } } } else { /* not by value, i.e. by reference */ param->datalen = datalen; param->ind = indicator; param->value = (CS_BYTE*) data; } return CS_SUCCEED; } /* Code added for ct_diag implementation */ /* Code changes start here - CT_DIAG - 02*/ CS_RETCODE ct_diag(CS_CONNECTION * conn, CS_INT operation, CS_INT type, CS_INT idx, CS_VOID * buffer) { tdsdump_log(TDS_DBG_FUNC, "ct_diag(%p, %d, %d, %d, %p)\n", conn, operation, type, idx, buffer); switch (operation) { case CS_INIT: if (conn->ctx->cs_errhandletype == _CS_ERRHAND_CB) { /* contrary to the manual page you don't seem to */ /* be able to turn on inline message handling */ /* using cs_diag, once a callback is installed! */ return CS_FAIL; } conn->ctx->cs_errhandletype = _CS_ERRHAND_INLINE; if (conn->ctx->cs_diag_msglimit_client == 0) conn->ctx->cs_diag_msglimit_client = CS_NO_LIMIT; if (conn->ctx->cs_diag_msglimit_server == 0) conn->ctx->cs_diag_msglimit_server = CS_NO_LIMIT; if (conn->ctx->cs_diag_msglimit_total == 0) conn->ctx->cs_diag_msglimit_total = CS_NO_LIMIT; conn->ctx->_clientmsg_cb = (CS_CLIENTMSG_FUNC) ct_diag_storeclientmsg; conn->ctx->_servermsg_cb = (CS_SERVERMSG_FUNC) ct_diag_storeservermsg; break; case CS_MSGLIMIT: if (conn->ctx->cs_errhandletype != _CS_ERRHAND_INLINE) return CS_FAIL; if (type == CS_CLIENTMSG_TYPE) conn->ctx->cs_diag_msglimit_client = *(CS_INT *) buffer; if (type == CS_SERVERMSG_TYPE) conn->ctx->cs_diag_msglimit_server = *(CS_INT *) buffer; if (type == CS_ALLMSG_TYPE) conn->ctx->cs_diag_msglimit_total = *(CS_INT *) buffer; break; case CS_CLEAR: if (conn->ctx->cs_errhandletype != _CS_ERRHAND_INLINE) return CS_FAIL; return _ct_diag_clearmsg(conn->ctx, type); break; case CS_GET: if (conn->ctx->cs_errhandletype != _CS_ERRHAND_INLINE) return CS_FAIL; if (buffer == NULL) return CS_FAIL; if (type == CS_CLIENTMSG_TYPE) { if (idx == 0 || (conn->ctx->cs_diag_msglimit_client != CS_NO_LIMIT && idx > conn->ctx->cs_diag_msglimit_client)) return CS_FAIL; return (ct_diag_getclientmsg(conn->ctx, idx, (CS_CLIENTMSG *) buffer)); } if (type == CS_SERVERMSG_TYPE) { if (idx == 0 || (conn->ctx->cs_diag_msglimit_server != CS_NO_LIMIT && idx > conn->ctx->cs_diag_msglimit_server)) return CS_FAIL; return (ct_diag_getservermsg(conn->ctx, idx, (CS_SERVERMSG *) buffer)); } break; case CS_STATUS: if (conn->ctx->cs_errhandletype != _CS_ERRHAND_INLINE) return CS_FAIL; if (buffer == NULL) return CS_FAIL; return (ct_diag_countmsg(conn->ctx, type, (CS_INT *) buffer)); break; } return CS_SUCCEED; } static CS_INT ct_diag_storeclientmsg(CS_CONTEXT * context, CS_CONNECTION * conn, CS_CLIENTMSG * message) { struct cs_diag_msg_client **curptr; struct cs_diag_msg_svr **scurptr; CS_INT msg_count = 0; tdsdump_log(TDS_DBG_FUNC, "ct_diag_storeclientmsg(%p, %p, %p)\n", context, conn, message); curptr = &(conn->ctx->clientstore); scurptr = &(conn->ctx->svrstore); /* if we already have a list of messages, go to the end of the list... */ while (*curptr != NULL) { msg_count++; curptr = &((*curptr)->next); } /* messages over and above the agreed limit */ /* are simply discarded... */ if (conn->ctx->cs_diag_msglimit_client != CS_NO_LIMIT && msg_count >= conn->ctx->cs_diag_msglimit_client) { return CS_FAIL; } /* messages over and above the agreed TOTAL limit */ /* are simply discarded */ if (conn->ctx->cs_diag_msglimit_total != CS_NO_LIMIT) { while (*scurptr != NULL) { msg_count++; scurptr = &((*scurptr)->next); } if (msg_count >= conn->ctx->cs_diag_msglimit_total) { return CS_FAIL; } } *curptr = tds_new(struct cs_diag_msg_client, 1); if (*curptr == NULL) { return CS_FAIL; } else { (*curptr)->next = NULL; (*curptr)->clientmsg = tds_new(CS_CLIENTMSG, 1); if ((*curptr)->clientmsg == NULL) { return CS_FAIL; } else { memcpy((*curptr)->clientmsg, message, sizeof(CS_CLIENTMSG)); } } return CS_SUCCEED; } static CS_INT ct_diag_storeservermsg(CS_CONTEXT * context, CS_CONNECTION * conn, CS_SERVERMSG * message) { struct cs_diag_msg_svr **curptr; struct cs_diag_msg_client **ccurptr; CS_INT msg_count = 0; tdsdump_log(TDS_DBG_FUNC, "ct_diag_storeservermsg(%p, %p, %p)\n", context, conn, message); curptr = &(conn->ctx->svrstore); ccurptr = &(conn->ctx->clientstore); /* if we already have a list of messages, go to the end of the list... */ while (*curptr != NULL) { msg_count++; curptr = &((*curptr)->next); } /* messages over and above the agreed limit */ /* are simply discarded... */ if (conn->ctx->cs_diag_msglimit_server != CS_NO_LIMIT && msg_count >= conn->ctx->cs_diag_msglimit_server) { return CS_FAIL; } /* messages over and above the agreed TOTAL limit */ /* are simply discarded... */ if (conn->ctx->cs_diag_msglimit_total != CS_NO_LIMIT) { while (*ccurptr != NULL) { msg_count++; ccurptr = &((*ccurptr)->next); } if (msg_count >= conn->ctx->cs_diag_msglimit_total) { return CS_FAIL; } } *curptr = tds_new(struct cs_diag_msg_svr, 1); if (*curptr == NULL) { return CS_FAIL; } else { (*curptr)->next = NULL; (*curptr)->servermsg = tds_new(CS_SERVERMSG, 1); if ((*curptr)->servermsg == NULL) { return CS_FAIL; } else { memcpy((*curptr)->servermsg, message, sizeof(CS_SERVERMSG)); } } return CS_SUCCEED; } static CS_INT ct_diag_getclientmsg(CS_CONTEXT * context, CS_INT idx, CS_CLIENTMSG * message) { struct cs_diag_msg_client *curptr; CS_INT msg_count = 0, msg_found = 0; tdsdump_log(TDS_DBG_FUNC, "ct_diag_getclientmsg(%p, %d, %p)\n", context, idx, message); curptr = context->clientstore; /* if we already have a list of messages, go to the end of the list... */ while (curptr != NULL) { msg_count++; if (msg_count == idx) { msg_found++; break; } curptr = curptr->next; } if (msg_found) { memcpy(message, curptr->clientmsg, sizeof(CS_CLIENTMSG)); return CS_SUCCEED; } return CS_NOMSG; } static CS_INT ct_diag_getservermsg(CS_CONTEXT * context, CS_INT idx, CS_SERVERMSG * message) { struct cs_diag_msg_svr *curptr; CS_INT msg_count = 0, msg_found = 0; tdsdump_log(TDS_DBG_FUNC, "ct_diag_getservermsg(%p, %d, %p)\n", context, idx, message); curptr = context->svrstore; /* if we already have a list of messages, go to the end of the list... */ while (curptr != NULL) { msg_count++; if (msg_count == idx) { msg_found++; break; } curptr = curptr->next; } if (msg_found) { memcpy(message, curptr->servermsg, sizeof(CS_SERVERMSG)); return CS_SUCCEED; } else { return CS_NOMSG; } } CS_INT _ct_diag_clearmsg(CS_CONTEXT * context, CS_INT type) { struct cs_diag_msg_client *curptr, *freeptr; struct cs_diag_msg_svr *scurptr, *sfreeptr; tdsdump_log(TDS_DBG_FUNC, "_ct_diag_clearmsg(%p, %d)\n", context, type); if (type == CS_CLIENTMSG_TYPE || type == CS_ALLMSG_TYPE) { curptr = context->clientstore; context->clientstore = NULL; while (curptr != NULL) { freeptr = curptr; curptr = freeptr->next; free(freeptr->clientmsg); free(freeptr); } } if (type == CS_SERVERMSG_TYPE || type == CS_ALLMSG_TYPE) { scurptr = context->svrstore; context->svrstore = NULL; while (scurptr != NULL) { sfreeptr = scurptr; scurptr = sfreeptr->next; free(sfreeptr->servermsg); free(sfreeptr); } } return CS_SUCCEED; } static CS_INT ct_diag_countmsg(CS_CONTEXT * context, CS_INT type, CS_INT * count) { struct cs_diag_msg_client *curptr; struct cs_diag_msg_svr *scurptr; CS_INT msg_count = 0; tdsdump_log(TDS_DBG_FUNC, "ct_diag_countmsg(%p, %d, %p)\n", context, type, count); if (type == CS_CLIENTMSG_TYPE || type == CS_ALLMSG_TYPE) { curptr = context->clientstore; while (curptr != NULL) { msg_count++; curptr = curptr->next; } } if (type == CS_SERVERMSG_TYPE || type == CS_ALLMSG_TYPE) { scurptr = context->svrstore; while (scurptr != NULL) { msg_count++; scurptr = scurptr->next; } } *count = msg_count; return CS_SUCCEED; } /* Code changes ends here - CT_DIAG - 02*/ static CS_DYNAMIC * _ct_allocate_dynamic(CS_CONNECTION * con, char *id, int idlen) { CS_DYNAMIC *dyn; CS_DYNAMIC **pdyn; int id_len; tdsdump_log(TDS_DBG_FUNC, "_ct_allocate_dynamic(%p, %p, %d)\n", con, id, idlen); dyn = tds_new0(CS_DYNAMIC, 1); if (idlen == CS_NULLTERM) id_len = strlen(id); else id_len = idlen; if (dyn != NULL) { dyn->id = tds_strndup(id, id_len); if (con->dynlist == NULL) { tdsdump_log(TDS_DBG_INFO1, "_ct_allocate_dynamic() attaching dynamic command to head\n"); con->dynlist = dyn; } else { pdyn = &con->dynlist; while (*pdyn) { pdyn = &(*pdyn)->next; } *pdyn = dyn; } } return (dyn); } static CS_DYNAMIC * _ct_locate_dynamic(CS_CONNECTION * con, char *id, int idlen) { CS_DYNAMIC *dyn; int id_len; tdsdump_log(TDS_DBG_FUNC, "_ct_locate_dynamic(%p, %p, %d)\n", con, id, idlen); if (idlen == CS_NULLTERM) id_len = strlen(id); else id_len = idlen; tdsdump_log(TDS_DBG_INFO1, "_ct_locate_dynamic() looking for %s\n", (char *) id); for (dyn = con->dynlist; dyn != NULL; dyn = dyn->next) { tdsdump_log(TDS_DBG_INFO1, "_ct_locate_dynamic() matching with %s\n", (char *) dyn->id); if (strncmp(dyn->id, id, id_len) == 0) break; } return (dyn); } static CS_INT _ct_deallocate_dynamic(CS_CONNECTION * con, CS_DYNAMIC *dyn) { CS_DYNAMIC **pvictim; tdsdump_log(TDS_DBG_FUNC, "_ct_deallocate_dynamic(%p, %p)\n", con, dyn); if (!dyn) return CS_SUCCEED; pvictim = &con->dynlist; for (; *pvictim != dyn;) { if (*pvictim == NULL) { tdsdump_log(TDS_DBG_FUNC, "ct_deallocate_dynamic() : cannot find entry in list\n"); return CS_FAIL; } pvictim = &(*pvictim)->next; } /* detach node */ tdsdump_log(TDS_DBG_FUNC, "ct_deallocate_dynamic() : relinking list\n"); *pvictim = dyn->next; dyn->next = NULL; tdsdump_log(TDS_DBG_FUNC, "ct_deallocate_dynamic() : relinked list\n"); /* free dynamic */ tds_release_dynamic(&dyn->tdsdyn); free(dyn->id); free(dyn->stmt); param_clear(dyn->param_list); free(dyn); return CS_SUCCEED; } static CS_INT _ct_map_compute_op(CS_INT comp_op) { switch (comp_op) { case SYBAOPCNT: case SYBAOPCNTU: case SYBAOPCNT_BIG: return CS_OP_COUNT; case SYBAOPSUM: case SYBAOPSUMU: return CS_OP_SUM; case SYBAOPAVG: case SYBAOPAVGU: return CS_OP_AVG; case SYBAOPMIN: return CS_OP_MIN; case SYBAOPMAX: return CS_OP_MAX; } return comp_op; } freetds-1.00.82/src/ctlib/cs.c100644 025423 025423 00000102507 13161421220 0011460/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns * Copyright (C) 2015 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include "cspublic.h" #include "ctlib.h" #include "replacements.h" #undef cs_dt_crack static CS_INT cs_diag_storemsg(CS_CONTEXT *context, CS_CLIENTMSG *message); static CS_INT cs_diag_clearmsg(CS_CONTEXT *context, CS_INT type); static CS_INT cs_diag_getmsg(CS_CONTEXT *context, CS_INT idx, CS_CLIENTMSG *message); static CS_INT cs_diag_countmsg(CS_CONTEXT *context, CS_INT *count); const char * cs_prretcode(int retcode) { static char unknown[24]; tdsdump_log(TDS_DBG_FUNC, "cs_prretcode(%d)\n", retcode); switch(retcode) { case CS_SUCCEED: return "CS_SUCCEED"; case CS_FAIL: return "CS_FAIL"; case CS_MEM_ERROR: return "CS_MEM_ERROR"; case CS_PENDING: return "CS_PENDING"; case CS_QUIET: return "CS_QUIET"; case CS_BUSY: return "CS_BUSY"; case CS_INTERRUPT: return "CS_INTERRUPT"; case CS_BLK_HAS_TEXT: return "CS_BLK_HAS_TEXT"; case CS_CONTINUE: return "CS_CONTINUE"; case CS_FATAL: return "CS_FATAL"; case CS_RET_HAFAILOVER: return "CS_RET_HAFAILOVER"; case CS_UNSUPPORTED: return "CS_UNSUPPORTED"; case CS_CANCELED: return "CS_CANCELED"; case CS_ROW_FAIL: return "CS_ROW_FAIL"; case CS_END_DATA: return "CS_END_DATA"; case CS_END_RESULTS: return "CS_END_RESULTS"; case CS_END_ITEM: return "CS_END_ITEM"; case CS_NOMSG: return "CS_NOMSG"; case CS_TIMED_OUT: return "CS_TIMED_OUT"; default: sprintf(unknown, "oops: %u ??", retcode); } return unknown; } static const char * _cs_get_layer(int layer) { tdsdump_log(TDS_DBG_FUNC, "_cs_get_layer(%d)\n", layer); switch (layer) { case 2: return "cslib user api layer"; break; default: break; } return "unrecognized layer"; } static const char * _cs_get_origin(int origin) { tdsdump_log(TDS_DBG_FUNC, "_cs_get_origin(%d)\n", origin); switch (origin) { case 1: return "external error"; break; case 2: return "internal CS-Library error"; break; case 4: return "common library error"; break; case 5: return "intl library error"; break; default: break; } return "unrecognized origin"; } static const char * _cs_get_user_api_layer_error(int error) { tdsdump_log(TDS_DBG_FUNC, "_cs_get_user_api_layer_error(%d)\n", error); switch (error) { case 3: return "Memory allocation failure."; break; case 16: return "Conversion between %1! and %2! datatypes is not supported."; break; case 20: return "The conversion/operation resulted in overflow."; break; case 24: return "The conversion/operation was stopped due to a syntax error in the source field."; break; default: break; } return "unrecognized error"; } static char * _cs_get_msgstr(const char *funcname, int layer, int origin, int severity, int number) { char *m; tdsdump_log(TDS_DBG_FUNC, "_cs_get_msgstr(%s, %d, %d, %d, %d)\n", funcname, layer, origin, severity, number); if (asprintf(&m, "%s: %s: %s: %s", funcname, _cs_get_layer(layer), _cs_get_origin(origin), (layer == 2) ? _cs_get_user_api_layer_error(number) : "unrecognized error") < 0) { return NULL; } return m; } static void _csclient_msg(CS_CONTEXT * ctx, const char *funcname, int layer, int origin, int severity, int number, const char *fmt, ...) { va_list ap; CS_CLIENTMSG cm; char *msgstr; tdsdump_log(TDS_DBG_FUNC, "_csclient_msg(%p, %s, %d, %d, %d, %d, %s)\n", ctx, funcname, layer, origin, severity, number, fmt); va_start(ap, fmt); if (ctx->_cslibmsg_cb) { cm.severity = severity; cm.msgnumber = (((layer << 24) & 0xFF000000) | ((origin << 16) & 0x00FF0000) | ((severity << 8) & 0x0000FF00) | ((number) & 0x000000FF)); msgstr = _cs_get_msgstr(funcname, layer, origin, severity, number); tds_vstrbuild(cm.msgstring, CS_MAX_MSG, &(cm.msgstringlen), msgstr, CS_NULLTERM, fmt, CS_NULLTERM, ap); cm.msgstring[cm.msgstringlen] = '\0'; free(msgstr); cm.osnumber = 0; cm.osstring[0] = '\0'; cm.osstringlen = 0; cm.status = 0; /* cm.sqlstate */ cm.sqlstatelen = 0; ctx->_cslibmsg_cb(ctx, &cm); } va_end(ap); } /** * Allocate new CS_LOCALE and initialize it * returns NULL on out of memory errors */ static CS_LOCALE * _cs_locale_alloc(void) { tdsdump_log(TDS_DBG_FUNC, "_cs_locale_alloc()\n"); return tds_new0(CS_LOCALE, 1); } static void _cs_locale_free_contents(CS_LOCALE *locale) { tdsdump_log(TDS_DBG_FUNC, "_cs_locale_free_contents(%p)\n", locale); /* free strings */ free(locale->language); locale->language = NULL; free(locale->charset); locale->charset = NULL; free(locale->time); locale->time = NULL; free(locale->collate); locale->collate = NULL; } void _cs_locale_free(CS_LOCALE *locale) { tdsdump_log(TDS_DBG_FUNC, "_cs_locale_free(%p)\n", locale); /* free contents */ _cs_locale_free_contents(locale); /* free the data structure */ free(locale); } /* returns 0 on out of memory errors, 1 for OK */ int _cs_locale_copy_inplace(CS_LOCALE *new_locale, CS_LOCALE *orig) { tdsdump_log(TDS_DBG_FUNC, "_cs_locale_copy_inplace(%p, %p)\n", new_locale, orig); _cs_locale_free_contents(new_locale); if (orig->language) { new_locale->language = strdup(orig->language); if (!new_locale->language) goto Cleanup; } if (orig->charset) { new_locale->charset = strdup(orig->charset); if (!new_locale->charset) goto Cleanup; } if (orig->time) { new_locale->time = strdup(orig->time); if (!new_locale->time) goto Cleanup; } if (orig->collate) { new_locale->collate = strdup(orig->collate); if (!new_locale->collate) goto Cleanup; } return 1; Cleanup: _cs_locale_free_contents(new_locale); return 0; } /* returns NULL on out of memory errors */ CS_LOCALE * _cs_locale_copy(CS_LOCALE *orig) { CS_LOCALE *new_locale; tdsdump_log(TDS_DBG_FUNC, "_cs_locale_copy(%p)\n", orig); new_locale = _cs_locale_alloc(); if (!new_locale) return NULL; if (orig->language) { new_locale->language = strdup(orig->language); if (!new_locale->language) goto Cleanup; } if (orig->charset) { new_locale->charset = strdup(orig->charset); if (!new_locale->charset) goto Cleanup; } if (orig->time) { new_locale->time = strdup(orig->time); if (!new_locale->time) goto Cleanup; } if (orig->collate) { new_locale->collate = strdup(orig->collate); if (!new_locale->collate) goto Cleanup; } return new_locale; Cleanup: _cs_locale_free(new_locale); return NULL; } CS_RETCODE cs_ctx_alloc(CS_INT version, CS_CONTEXT ** ctx) { TDSCONTEXT *tds_ctx; tdsdump_log(TDS_DBG_FUNC, "cs_ctx_alloc(%d, %p)\n", version, ctx); *ctx = tds_new0(CS_CONTEXT, 1); tds_ctx = tds_alloc_context(*ctx); if (!tds_ctx) { free(*ctx); return CS_FAIL; } (*ctx)->tds_ctx = tds_ctx; if (tds_ctx->locale && !tds_ctx->locale->date_fmt) { /* set default in case there's no locale file */ tds_ctx->locale->date_fmt = strdup(STD_DATETIME_FMT); } return CS_SUCCEED; } CS_RETCODE cs_ctx_global(CS_INT version, CS_CONTEXT ** ctx) { static CS_CONTEXT *global_cs_ctx = NULL; tdsdump_log(TDS_DBG_FUNC, "cs_ctx_global(%d, %p)\n", version, ctx); if (global_cs_ctx != NULL) { *ctx = global_cs_ctx; return CS_SUCCEED; } if (cs_ctx_alloc(version, ctx) != CS_SUCCEED) { return CS_FAIL; } global_cs_ctx = *ctx; return CS_SUCCEED; } CS_RETCODE cs_ctx_drop(CS_CONTEXT * ctx) { tdsdump_log(TDS_DBG_FUNC, "cs_ctx_drop(%p)\n", ctx); if (ctx) { _ct_diag_clearmsg(ctx, CS_ALLMSG_TYPE); free(ctx->userdata); if (ctx->tds_ctx) tds_free_context(ctx->tds_ctx); free(ctx); } return CS_SUCCEED; } CS_RETCODE cs_config(CS_CONTEXT * ctx, CS_INT action, CS_INT property, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen) { CS_INT maxcp; /* declared for - CS_USERDATA changes - swapna*/ tdsdump_log(TDS_DBG_FUNC, "cs_config(%p, %d, %d, %p, %d, %p)\n", ctx, action, property, buffer, buflen, outlen); if (action == CS_GET) { if (buffer == NULL) { return CS_SUCCEED; } switch (property) { case CS_MESSAGE_CB: *(void **) buffer = (void*) ctx->_cslibmsg_cb; return CS_SUCCEED; case CS_USERDATA: maxcp = ctx->userdata_len; if (outlen) *outlen = maxcp; if (maxcp > buflen) maxcp = buflen; memcpy(buffer, ctx->userdata, maxcp); return CS_SUCCEED; case CS_EXTRA_INF: case CS_LOC_PROP: case CS_VERSION: return CS_FAIL; break; } } if (action == CS_SET) { switch (property) { case CS_MESSAGE_CB: if ( ctx->cs_errhandletype == _CS_ERRHAND_INLINE) { cs_diag_clearmsg(ctx, CS_UNUSED); } ctx->_cslibmsg_cb = (CS_CSLIBMSG_FUNC) buffer; ctx->cs_errhandletype = _CS_ERRHAND_CB; return CS_SUCCEED; case CS_USERDATA: free(ctx->userdata); if (buflen == CS_NULLTERM) { maxcp = strlen((char*) buffer) + 1; } else { maxcp = buflen; } ctx->userdata = (void *) malloc(maxcp); if ( ctx->userdata == NULL) { return CS_FAIL; } ctx->userdata_len = maxcp; if (buffer) { memcpy(ctx->userdata, buffer, maxcp); } else { return CS_FAIL; } return CS_SUCCEED; case CS_EXTRA_INF: case CS_LOC_PROP: case CS_VERSION: return CS_FAIL; break; } } if (action == CS_CLEAR) { switch (property) { case CS_MESSAGE_CB: if ( ctx->cs_errhandletype == _CS_ERRHAND_INLINE) { cs_diag_clearmsg(ctx, CS_UNUSED); } ctx->_cslibmsg_cb = NULL; ctx->cs_errhandletype = 0; return CS_SUCCEED; case CS_USERDATA: free(ctx->userdata); ctx->userdata = NULL; return CS_SUCCEED; case CS_EXTRA_INF: case CS_LOC_PROP: case CS_VERSION: return CS_FAIL; break; } } return CS_FAIL; } CS_RETCODE cs_convert(CS_CONTEXT * ctx, CS_DATAFMT * srcfmt, CS_VOID * srcdata, CS_DATAFMT * destfmt, CS_VOID * destdata, CS_INT * resultlen) { TDS_SERVER_TYPE src_type, desttype; int src_len, destlen, len, i = 0; CONV_RESULT cres; unsigned char *dest; CS_RETCODE ret; CS_INT dummy; CS_VARCHAR *destvc = NULL; tdsdump_log(TDS_DBG_FUNC, "cs_convert(%p, %p, %p, %p, %p, %p)\n", ctx, srcfmt, srcdata, destfmt, destdata, resultlen); /* If destination is NULL we have a problem */ if (destdata == NULL) { /* TODO: add error message */ tdsdump_log(TDS_DBG_FUNC, "error: destdata is null\n"); return CS_FAIL; } /* If destfmt is NULL we have a problem */ if (destfmt == NULL) { /* TODO: add error message */ tdsdump_log(TDS_DBG_FUNC, "error: destfmt is null\n"); return CS_FAIL; } if (resultlen == NULL) resultlen = &dummy; /* If source is indicated to be NULL, set dest to low values */ if (srcdata == NULL) { /* TODO: implement cs_setnull */ tdsdump_log(TDS_DBG_FUNC, "srcdata is null\n"); memset(destdata, '\0', destfmt->maxlength); *resultlen = 0; return CS_SUCCEED; } src_type = _ct_get_server_type(NULL, srcfmt->datatype); if (src_type == TDS_INVALID_TYPE) return CS_FAIL; src_len = srcfmt->maxlength; if (srcfmt->datatype == CS_VARCHAR_TYPE || srcfmt->datatype == CS_VARBINARY_TYPE) { CS_VARCHAR *vc = (CS_VARCHAR *) srcdata; src_len = vc->len; srcdata = vc->str; } desttype = _ct_get_server_type(NULL, destfmt->datatype); if (desttype == TDS_INVALID_TYPE) return CS_FAIL; destlen = destfmt->maxlength; if (destfmt->datatype == CS_VARCHAR_TYPE || destfmt->datatype == CS_VARBINARY_TYPE) { destvc = (CS_VARCHAR *) destdata; destlen = sizeof(destvc->str); destdata = destvc->str; } else if (is_numeric_type(desttype)) { destlen = sizeof(TDS_NUMERIC); } tdsdump_log(TDS_DBG_FUNC, "converting type %d (%d bytes) to type = %d (%d bytes)\n", src_type, src_len, desttype, destlen); if (!is_fixed_type(desttype) && (destlen <= 0)) { return CS_FAIL; } dest = (unsigned char *) destdata; /* many times we are asked to convert a data type to itself */ if (src_type == desttype) { int minlen = src_len < destlen? src_len : destlen; tdsdump_log(TDS_DBG_FUNC, "cs_convert() srctype == desttype\n"); switch (desttype) { case SYBLONGBINARY: case SYBBINARY: case SYBVARBINARY: case SYBIMAGE: memcpy(dest, srcdata, src_len); *resultlen = src_len; if (src_len > destlen) { tdsdump_log(TDS_DBG_FUNC, "error: src_len > destlen\n"); ret = CS_FAIL; } else { switch (destfmt->format) { case CS_FMT_PADNULL: memset(dest + src_len, '\0', destlen - src_len); *resultlen = destlen; /* fall through */ case CS_FMT_UNUSED: ret = CS_SUCCEED; break; default: ret = CS_FAIL; break; } } if (destvc) { destvc->len = minlen; *resultlen = sizeof(*destvc); } break; case SYBCHAR: case SYBVARCHAR: case SYBTEXT: tdsdump_log(TDS_DBG_FUNC, "cs_convert() desttype = character\n"); memcpy(dest, srcdata, minlen); *resultlen = minlen; if (src_len > destlen) { tdsdump_log(TDS_DBG_FUNC, "error: src_len > destlen\n"); ret = CS_FAIL; } else { switch (destfmt->format) { case CS_FMT_NULLTERM: if (src_len == destlen) { *resultlen = src_len; tdsdump_log(TDS_DBG_FUNC, "error: no room for null terminator\n"); ret = CS_FAIL; } else { dest[src_len] = '\0'; *resultlen = src_len + 1; ret = CS_SUCCEED; } break; case CS_FMT_PADBLANK: memset(dest + src_len, ' ', destlen - src_len); *resultlen = destlen; ret = CS_SUCCEED; break; case CS_FMT_PADNULL: memset(dest + src_len, '\0', destlen - src_len); *resultlen = destlen; ret = CS_SUCCEED; break; case CS_FMT_UNUSED: ret = CS_SUCCEED; break; default: tdsdump_log(TDS_DBG_FUNC, "no destination format specified!\n"); ret = CS_FAIL; break; } } if (destvc) { destvc->len = minlen; *resultlen = sizeof(*destvc); } break; case SYBINT1: case SYBUINT1: case SYBINT2: case SYBUINT2: case SYBINT4: case SYBUINT4: case SYBINT8: case SYBUINT8: case SYBFLT8: case SYBREAL: case SYBBIT: case SYBMONEY: case SYBMONEY4: case SYBDATETIME: case SYBDATETIME4: case SYBTIME: case SYBDATE: case SYB5BIGDATETIME: case SYB5BIGTIME: *resultlen = tds_get_size_by_type(src_type); if (*resultlen > 0) memcpy(dest, srcdata, *resultlen); ret = CS_SUCCEED; break; case SYBNUMERIC: case SYBDECIMAL: src_len = tds_numeric_bytes_per_prec[((TDS_NUMERIC *) srcdata)->precision] + 2; case SYBBITN: case SYBUNIQUE: memcpy(dest, srcdata, minlen); *resultlen = minlen; if (src_len > destlen) { tdsdump_log(TDS_DBG_FUNC, "error: src_len > destlen\n"); ret = CS_FAIL; } else { ret = CS_SUCCEED; } break; default: tdsdump_log(TDS_DBG_FUNC, "error: unrecognized type\n"); ret = CS_FAIL; break; } tdsdump_log(TDS_DBG_FUNC, "cs_convert() returning %s\n", cs_prretcode(ret)); return ret; } assert(src_type != desttype); /* set the output precision/scale for conversions to numeric type */ if (is_numeric_type(desttype)) { cres.n.precision = destfmt->precision; cres.n.scale = destfmt->scale; if (destfmt->precision == CS_SRC_VALUE) cres.n.precision = srcfmt->precision; if (destfmt->scale == CS_SRC_VALUE) cres.n.scale = srcfmt->scale; } tdsdump_log(TDS_DBG_FUNC, "cs_convert() calling tds_convert\n"); len = tds_convert(ctx->tds_ctx, src_type, (TDS_CHAR*) srcdata, src_len, desttype, &cres); tdsdump_log(TDS_DBG_FUNC, "cs_convert() tds_convert returned %d\n", len); switch (len) { case TDS_CONVERT_NOAVAIL: _csclient_msg(ctx, "cs_convert", 2, 1, 1, 16, "%d, %d", src_type, desttype); return CS_FAIL; break; case TDS_CONVERT_SYNTAX: _csclient_msg(ctx, "cs_convert", 2, 4, 1, 24, ""); return CS_FAIL; break; case TDS_CONVERT_NOMEM: _csclient_msg(ctx, "cs_convert", 2, 4, 1, 3, ""); return CS_FAIL; break; case TDS_CONVERT_OVERFLOW: _csclient_msg(ctx, "cs_convert", 2, 4, 1, 20, ""); return CS_FAIL; break; case TDS_CONVERT_FAIL: return CS_FAIL; break; default: if (len < 0) { return CS_FAIL; } break; } switch (desttype) { case SYBBINARY: case SYBVARBINARY: case SYBIMAGE: ret = CS_SUCCEED; if (len > destlen) { tdsdump_log(TDS_DBG_FUNC, "error_handler: Data-conversion resulted in overflow\n"); ret = CS_FAIL; len = destlen; } memcpy(dest, cres.ib, len); free(cres.ib); *resultlen = destlen; if (destvc) { destvc->len = len; *resultlen = sizeof(*destvc); } for (i = len; i < destlen; i++) dest[i] = '\0'; break; case SYBBIT: case SYBBITN: /* fall trough, act same way of TINYINT */ case SYBINT1: case SYBUINT1: case SYBINT2: case SYBUINT2: case SYBINT4: case SYBUINT4: case SYBINT8: case SYBUINT8: case SYBFLT8: case SYBREAL: case SYBMONEY: case SYBMONEY4: case SYBDATETIME: case SYBDATETIME4: case SYBTIME: case SYBDATE: case SYBUNIQUE: case SYB5BIGDATETIME: case SYB5BIGTIME: *resultlen = tds_get_size_by_type(desttype); memcpy(dest, &(cres.ti), *resultlen); ret = CS_SUCCEED; break; case SYBNUMERIC: case SYBDECIMAL: src_len = tds_numeric_bytes_per_prec[cres.n.precision] + 2; memcpy(dest, &(cres.n), src_len); *resultlen = src_len; ret = CS_SUCCEED; break; case SYBCHAR: case SYBVARCHAR: case SYBTEXT: ret = CS_SUCCEED; if (len > destlen) { tdsdump_log(TDS_DBG_FUNC, "Data-conversion resulted in overflow\n"); len = destlen; ret = CS_FAIL; } switch (destfmt->format) { case CS_FMT_NULLTERM: tdsdump_log(TDS_DBG_FUNC, "cs_convert() FMT_NULLTERM\n"); if (len == destlen) { tdsdump_log(TDS_DBG_FUNC, "not enough room for data + a null terminator - error\n"); ret = CS_FAIL; /* not enough room for data + a null terminator - error */ } else { memcpy(dest, cres.c, len); dest[len] = 0; *resultlen = len + 1; } break; case CS_FMT_PADBLANK: tdsdump_log(TDS_DBG_FUNC, "cs_convert() FMT_PADBLANK\n"); /* strcpy here can lead to a small buffer overflow */ memcpy(dest, cres.c, len); for (i = len; i < destlen; i++) dest[i] = ' '; *resultlen = destlen; break; case CS_FMT_PADNULL: tdsdump_log(TDS_DBG_FUNC, "cs_convert() FMT_PADNULL\n"); /* strcpy here can lead to a small buffer overflow */ memcpy(dest, cres.c, len); for (i = len; i < destlen; i++) dest[i] = '\0'; *resultlen = destlen; break; case CS_FMT_UNUSED: tdsdump_log(TDS_DBG_FUNC, "cs_convert() FMT_UNUSED\n"); memcpy(dest, cres.c, len); *resultlen = len; break; default: ret = CS_FAIL; break; } if (destvc) { destvc->len = len; *resultlen = sizeof(*destvc); } free(cres.c); break; default: ret = CS_FAIL; break; } tdsdump_log(TDS_DBG_FUNC, "cs_convert() returning %s\n", cs_prretcode(ret)); return (ret); } CS_RETCODE cs_dt_crack_v2(CS_CONTEXT * ctx, CS_INT datetype, CS_VOID * dateval, CS_DATEREC * daterec) { TDSDATEREC dr; TDS_INT tds_type; bool extended = false; tdsdump_log(TDS_DBG_FUNC, "cs_dt_crack_v2(%p, %d, %p, %p)\n", ctx, datetype, dateval, daterec); switch (datetype) { case CS_DATETIME_TYPE: tds_type = SYBDATETIME; break; case CS_DATETIME4_TYPE: tds_type = SYBDATETIME4; break; case CS_DATE_TYPE: tds_type = SYBDATE; break; case CS_TIME_TYPE: tds_type = SYBTIME; break; case CS_BIGDATETIME_TYPE: tds_type = SYB5BIGDATETIME; extended = true; break; case CS_BIGTIME_TYPE: tds_type = SYB5BIGTIME; extended = true; break; default: return CS_FAIL; } tds_datecrack(tds_type, dateval, &dr); /* Sybase CT-Library does not set these fields for CS_BIGTIME_TYPE */ if (tds_type != SYB5BIGTIME) { daterec->dateyear = dr.year; daterec->datemonth = dr.month; daterec->datedmonth = dr.day; daterec->datedyear = dr.dayofyear; daterec->datedweek = dr.weekday; } daterec->datehour = dr.hour; daterec->dateminute = dr.minute; daterec->datesecond = dr.second; daterec->datemsecond = dr.decimicrosecond / 10000u; daterec->datetzone = 0; if (extended) { daterec->datesecfrac = dr.decimicrosecond / 10u; daterec->datesecprec = 1000000; } return CS_SUCCEED; } CS_RETCODE cs_dt_crack(CS_CONTEXT * ctx, CS_INT datetype, CS_VOID * dateval, CS_DATEREC * daterec) { tdsdump_log(TDS_DBG_FUNC, "cs_dt_crack(%p, %d, %p, %p)\n", ctx, datetype, dateval, daterec); if (datetype != CS_BIGDATETIME_TYPE && datetype != CS_BIGTIME_TYPE) return cs_dt_crack_v2(ctx, datetype, dateval, daterec); return CS_FAIL; } CS_RETCODE cs_loc_alloc(CS_CONTEXT * ctx, CS_LOCALE ** locptr) { CS_LOCALE *tds_csloc; tdsdump_log(TDS_DBG_FUNC, "cs_loc_alloc(%p, %p)\n", ctx, locptr); tds_csloc = _cs_locale_alloc(); if (!tds_csloc) return CS_FAIL; *locptr = tds_csloc; return CS_SUCCEED; } CS_RETCODE cs_loc_drop(CS_CONTEXT * ctx, CS_LOCALE * locale) { tdsdump_log(TDS_DBG_FUNC, "cs_loc_drop(%p, %p)\n", ctx, locale); if (!locale) return CS_FAIL; _cs_locale_free(locale); return CS_SUCCEED; } CS_RETCODE cs_locale(CS_CONTEXT * ctx, CS_INT action, CS_LOCALE * locale, CS_INT type, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen) { CS_RETCODE code = CS_FAIL; tdsdump_log(TDS_DBG_FUNC, "cs_locale(%p, %d, %p, %d, %p, %d, %p)\n", ctx, action, locale, type, buffer, buflen, outlen); if (action == CS_SET) { switch (type) { case CS_LC_ALL: /* what to do here if there is locale data? */ if (!buffer) { code = CS_SUCCEED; } break; case CS_SYB_CHARSET: if (buflen == CS_NULLTERM) { buflen = strlen((char *)buffer); } free(locale->charset); locale->charset = tds_strndup(buffer, buflen); if (!locale->charset) break; code = CS_SUCCEED; break; case CS_SYB_LANG: if (buflen == CS_NULLTERM) { buflen = strlen((char *)buffer); } free(locale->language); locale->language = tds_strndup(buffer, buflen); if (!locale->language) break; code = CS_SUCCEED; break; case CS_SYB_LANG_CHARSET: { int i; char *b = (char *)buffer; if (buflen == CS_NULLTERM) { buflen = strlen(b); } /* find '.' character */ for (i = 0; i < buflen; ++i) { if (b[i] == '.') { break; } } /* not found */ if (i == buflen) { break; } if (i) { free(locale->language); locale->language = tds_strndup(b, i); if (!locale->language) break; } if (i != (buflen - 1)) { free(locale->charset); locale->charset = tds_strndup(b + i + 1, buflen - i - 1); if (!locale->charset) break; } code = CS_SUCCEED; break; } /* TODO commented out until the code works end-to-end case CS_SYB_SORTORDER: if (buflen == CS_NULLTERM) { buflen = strlen((char *)buffer); } free(locale->collate); locale->collate = tds_strndup(buffer, buflen); if (!locale->collate) break; code = CS_SUCCEED; break; */ } } else if (action == CS_GET) { int tlen; switch (type) { case CS_SYB_CHARSET: tlen = (locale->charset ? strlen(locale->charset) : 0) + 1; if (buflen < tlen) { if (outlen) *outlen = tlen; break; } if (locale->charset) strcpy((char *)buffer, locale->charset); else ((char *)buffer)[0] = '\0'; code = CS_SUCCEED; break; case CS_SYB_LANG: tlen = (locale->language ? strlen(locale->language) : 0) + 1; if (buflen < tlen) { if (outlen) *outlen = tlen; break; } if (locale->language) strcpy((char *)buffer, locale->language); else ((char *)buffer)[0] = '\0'; code = CS_SUCCEED; break; case CS_SYB_LANG_CHARSET: { int clen; tlen = (locale->language ? strlen(locale->language) : 0) + 1; clen = (locale->charset ? strlen(locale->charset) : 0) + 1; if (buflen < (tlen + clen)) { if (outlen) *outlen = tlen + clen; break; } if (locale->language) strcpy((char *)buffer, locale->language); else ((char *)buffer)[0] = '\0'; strcat((char *)buffer, "."); if (locale->charset) { tlen = strlen((char *)buffer); strcpy((char *)buffer + tlen, locale->charset); } code = CS_SUCCEED; break; } case CS_SYB_SORTORDER: tlen = (locale->collate ? strlen(locale->collate) : 0) + 1; if (buflen < tlen) { if (outlen) *outlen = tlen; break; } if (locale->collate) strcpy((char *)buffer, locale->collate); else ((char *)buffer)[0] = '\0'; code = CS_SUCCEED; break; } } return code; } CS_RETCODE cs_dt_info(CS_CONTEXT * ctx, CS_INT action, CS_LOCALE * locale, CS_INT type, CS_INT item, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen) { tdsdump_log(TDS_DBG_FUNC, "cs_dt_info(%p, %d, %p, %d, %d, %p, %d, %p)\n", ctx, action, locale, type, item, buffer, buflen, outlen); if (action == CS_SET) { switch (type) { case CS_DT_CONVFMT: break; } } return CS_SUCCEED; } CS_RETCODE cs_strbuild(CS_CONTEXT * ctx, CS_CHAR * buffer, CS_INT buflen, CS_INT * resultlen, CS_CHAR * text, CS_INT textlen, CS_CHAR * formats, CS_INT formatlen, ...) { va_list ap; TDSRET rc; tdsdump_log(TDS_DBG_FUNC, "cs_strbuild(%p, %p, %d, %p, %p, %d, %p, %d)\n", ctx, buffer, buflen, resultlen, text, textlen, formats, formatlen); va_start(ap, formatlen); rc = tds_vstrbuild(buffer, buflen, resultlen, text, textlen, formats, formatlen, ap); va_end(ap); return TDS_SUCCEED(rc) ? CS_SUCCEED : CS_FAIL; } CS_RETCODE cs_calc(CS_CONTEXT * ctx, CS_INT op, CS_INT datatype, CS_VOID * var1, CS_VOID * var2, CS_VOID * dest) { tdsdump_log(TDS_DBG_FUNC, "cs_calc(%p, %d, %d, %p, %p, %p)\n", ctx, op, datatype, var1, var2, dest); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED cs_calc()\n"); return CS_FAIL; } CS_RETCODE cs_cmp(CS_CONTEXT * ctx, CS_INT datatype, CS_VOID * var1, CS_VOID * var2, CS_INT * result) { tdsdump_log(TDS_DBG_FUNC, "cs_cmp(%p, %d, %p, %p, %p)\n", ctx, datatype, var1, var2, result); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED cs_cmp()\n"); return CS_FAIL; } CS_RETCODE cs_conv_mult(CS_CONTEXT * ctx, CS_LOCALE * srcloc, CS_LOCALE * destloc, CS_INT * conv_multiplier) { tdsdump_log(TDS_DBG_FUNC, "cs_conv_mult(%p, %p, %p, %p)\n", ctx, srcloc, destloc, conv_multiplier); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED cs_conv_mult()\n"); return CS_FAIL; } CS_RETCODE cs_diag(CS_CONTEXT * ctx, CS_INT operation, CS_INT type, CS_INT idx, CS_VOID * buffer) { tdsdump_log(TDS_DBG_FUNC, "cs_diag(%p, %d, %d, %d, %p)\n", ctx, operation, type, idx, buffer); switch (operation) { case CS_INIT: if ( ctx->cs_errhandletype == _CS_ERRHAND_CB) { /* contrary to the manual page you don't seem to */ /* be able to turn on inline message handling */ /* using cs_diag, once a callback is installed! */ return CS_FAIL; } ctx->cs_errhandletype = _CS_ERRHAND_INLINE; ctx->cs_diag_msglimit = CS_NO_LIMIT; ctx->_cslibmsg_cb = (CS_CSLIBMSG_FUNC) cs_diag_storemsg; break; case CS_MSGLIMIT: if ( ctx->cs_errhandletype != _CS_ERRHAND_INLINE) { return CS_FAIL; } ctx->cs_diag_msglimit = *(CS_INT *)buffer; break; case CS_CLEAR: if ( ctx->cs_errhandletype != _CS_ERRHAND_INLINE) { return CS_FAIL; } return (cs_diag_clearmsg(ctx, type)); break; case CS_GET: if ( ctx->cs_errhandletype != _CS_ERRHAND_INLINE) { return CS_FAIL; } if (buffer == NULL) return CS_FAIL; if (idx == 0 || (ctx->cs_diag_msglimit != CS_NO_LIMIT && idx > ctx->cs_diag_msglimit) ) return CS_FAIL; return (cs_diag_getmsg(ctx, idx, (CS_CLIENTMSG *)buffer)); break; case CS_STATUS: if ( ctx->cs_errhandletype != _CS_ERRHAND_INLINE) { return CS_FAIL; } if (buffer == NULL) return CS_FAIL; return (cs_diag_countmsg(ctx, (CS_INT *)buffer)); break; } return CS_SUCCEED; } CS_RETCODE cs_manage_convert(CS_CONTEXT * ctx, CS_INT action, CS_INT srctype, CS_CHAR * srcname, CS_INT srcnamelen, CS_INT desttype, CS_CHAR * destname, CS_INT destnamelen, CS_INT * conv_multiplier, CS_CONV_FUNC * func) { tdsdump_log(TDS_DBG_FUNC, "cs_manage_convert(%p, %d, %d, %p, %d, %d, %p, %d, %p, %p)\n", ctx, action, srctype, srcname, srcnamelen, desttype, destname, destnamelen, conv_multiplier, func); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED cs_manage_convert()\n"); return CS_FAIL; } CS_RETCODE cs_objects(CS_CONTEXT * ctx, CS_INT action, CS_OBJNAME * objname, CS_OBJDATA * objdata) { tdsdump_log(TDS_DBG_FUNC, "cs_objects(%p, %d, %p, %p)\n", ctx, action, objname, objdata); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED cs_objects()\n"); return CS_FAIL; } CS_RETCODE cs_set_convert(CS_CONTEXT * ctx, CS_INT action, CS_INT srctype, CS_INT desttype, CS_CONV_FUNC * func) { tdsdump_log(TDS_DBG_FUNC, "cs_set_convert(%p, %d, %d, %d, %p)\n", ctx, action, srctype, desttype, func); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED cs_set_convert()\n"); return CS_FAIL; } CS_RETCODE cs_setnull(CS_CONTEXT * ctx, CS_DATAFMT * datafmt, CS_VOID * buffer, CS_INT buflen) { tdsdump_log(TDS_DBG_FUNC, "cs_setnull(%p, %p, %p, %d)\n", ctx, datafmt, buffer, buflen); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED cs_setnull()\n"); return CS_FAIL; } CS_RETCODE cs_strcmp(CS_CONTEXT * ctx, CS_LOCALE * locale, CS_INT type, CS_CHAR * str1, CS_INT len1, CS_CHAR * str2, CS_INT len2, CS_INT * result) { tdsdump_log(TDS_DBG_FUNC, "cs_strcmp(%p, %p, %d, %p, %d, %p, %d, %p)\n", ctx, locale, type, str1, len1, str2, len2, result); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED cs_strcmp()\n"); return CS_FAIL; } CS_RETCODE cs_time(CS_CONTEXT * ctx, CS_LOCALE * locale, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen, CS_DATEREC * daterec) { tdsdump_log(TDS_DBG_FUNC, "cs_time(%p, %p, %p, %d, %p, %p)\n", ctx, locale, buffer, buflen, outlen, daterec); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED cs_time()\n"); return CS_FAIL; } CS_RETCODE cs_will_convert(CS_CONTEXT * ctx, CS_INT srctype, CS_INT desttype, CS_BOOL * result) { tdsdump_log(TDS_DBG_FUNC, "cs_will_convert(%p, %d, %d, %p)\n", ctx, srctype, desttype, result); *result = (tds_willconvert(srctype, desttype) ? CS_TRUE : CS_FALSE); return CS_SUCCEED; } static CS_INT cs_diag_storemsg(CS_CONTEXT *context, CS_CLIENTMSG *message) { struct cs_diag_msg **curptr; CS_INT msg_count = 0; tdsdump_log(TDS_DBG_FUNC, "cs_diag_storemsg(%p, %p)\n", context, message); curptr = &(context->msgstore); /* if we already have a list of messages, */ /* go to the end of the list... */ while (*curptr != NULL) { msg_count++; curptr = &((*curptr)->next); } /* messages over and above the agreed limit */ /* are simply discarded... */ if (context->cs_diag_msglimit != CS_NO_LIMIT && msg_count >= context->cs_diag_msglimit) { return CS_FAIL; } *curptr = tds_new(struct cs_diag_msg, 1); if (*curptr == NULL) { return CS_FAIL; } else { (*curptr)->next = NULL; (*curptr)->msg = tds_new(CS_CLIENTMSG, 1); if ((*curptr)->msg == NULL) { return CS_FAIL; } else { memcpy((*curptr)->msg, message, sizeof(CS_CLIENTMSG)); } } return CS_SUCCEED; } static CS_INT cs_diag_getmsg(CS_CONTEXT *context, CS_INT idx, CS_CLIENTMSG *message) { struct cs_diag_msg *curptr; CS_INT msg_count = 0, msg_found = 0; tdsdump_log(TDS_DBG_FUNC, "cs_diag_getmsg(%p, %d, %p)\n", context, idx, message); curptr = context->msgstore; /* if we already have a list of messages, */ /* go to the end of the list... */ while (curptr != NULL) { msg_count++; if (msg_count == idx) { msg_found++; break; } curptr = curptr->next; } if (msg_found) { memcpy(message, curptr->msg, sizeof(CS_CLIENTMSG)); return CS_SUCCEED; } else { return CS_NOMSG; } } static CS_INT cs_diag_clearmsg(CS_CONTEXT *context, CS_INT type) { struct cs_diag_msg *curptr, *freeptr; tdsdump_log(TDS_DBG_FUNC, "cs_diag_clearmsg(%p, %d)\n", context, type); curptr = context->msgstore; context->msgstore = NULL; while (curptr != NULL ) { freeptr = curptr; curptr = freeptr->next; free(freeptr->msg); free(freeptr); } return CS_SUCCEED; } static CS_INT cs_diag_countmsg(CS_CONTEXT *context, CS_INT *count) { struct cs_diag_msg *curptr; CS_INT msg_count = 0; tdsdump_log(TDS_DBG_FUNC, "cs_diag_countmsg(%p, %p)\n", context, count); curptr = context->msgstore; while (curptr != NULL) { msg_count++; curptr = curptr->next; } *count = msg_count; return CS_SUCCEED; } /** * Try to convert to a type we can handle */ int _cs_convert_not_client(CS_CONTEXT *ctx, TDSCOLUMN *curcol, CONV_RESULT *convert_buffer, unsigned char **p_src) { int ct_type; TDS_SERVER_TYPE desttype; switch (curcol->column_type) { case SYBMSDATE: desttype = SYBDATE; ct_type = CS_DATE_TYPE; break; case SYBMSTIME: desttype = SYB5BIGTIME; ct_type = CS_BIGTIME_TYPE; break; case SYBMSDATETIME2: case SYBMSDATETIMEOFFSET: desttype = SYB5BIGDATETIME; ct_type = CS_BIGDATETIME_TYPE; break; default: return CS_ILLEGAL_TYPE; } if (convert_buffer) { int len = tds_convert(ctx->tds_ctx, curcol->column_type, (TDS_CHAR *) *p_src, curcol->column_cur_size, desttype, convert_buffer); if (len < 0) return CS_ILLEGAL_TYPE; // TODO _csclient_msg ?? *p_src = (unsigned char *) convert_buffer; } return ct_type; } freetds-1.00.82/src/ctlib/blk.c100644 025423 025423 00000046147 13161421220 0011632/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-2004, 2005, 2010 Brian Bruns, Bill Thompson * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include "bkpublic.h" #include "ctpublic.h" #include "ctlib.h" #include "replacements.h" static void _blk_null_error(TDSBCPINFO *bcpinfo, int index, int offset); static TDSRET _blk_get_col_data(TDSBCPINFO *bulk, TDSCOLUMN *bcpcol, int offset); static CS_RETCODE _blk_rowxfer_in(CS_BLKDESC * blkdesc, CS_INT rows_to_xfer, CS_INT * rows_xferred); static CS_RETCODE _blk_rowxfer_out(CS_BLKDESC * blkdesc, CS_INT rows_to_xfer, CS_INT * rows_xferred); #define CONN(bulk) ((CS_CONNECTION *) (bulk)->bcpinfo.parent) TDS_COMPILE_CHECK(same_size, sizeof(CS_BLKDESC) == sizeof(TDSBCPINFO)); TDS_COMPILE_CHECK(nested_type, TDS_OFFSET(CS_BLKDESC, bcpinfo) == 0); CS_RETCODE blk_alloc(CS_CONNECTION * connection, CS_INT version, CS_BLKDESC ** blk_pointer) { CS_BLKDESC *blkdesc; tdsdump_log(TDS_DBG_FUNC, "blk_alloc(%p, %d, %p)\n", connection, version, blk_pointer); blkdesc = (CS_BLKDESC *) tds_alloc_bcpinfo(); if (!blkdesc) return CS_FAIL; /* so we know who we belong to */ blkdesc->bcpinfo.parent = connection; *blk_pointer = blkdesc; return CS_SUCCEED; } CS_RETCODE blk_bind(CS_BLKDESC * blkdesc, CS_INT item, CS_DATAFMT * datafmt, CS_VOID * buffer, CS_INT * datalen, CS_SMALLINT * indicator) { TDSCOLUMN *colinfo; CS_CONNECTION *con; CS_INT bind_count; int i; tdsdump_log(TDS_DBG_FUNC, "blk_bind(%p, %d, %p, %p, %p, %p)\n", blkdesc, item, datafmt, buffer, datalen, indicator); if (!blkdesc) { return CS_FAIL; } con = CONN(blkdesc); if (item == CS_UNUSED) { /* clear all bindings */ if (datafmt == NULL && buffer == NULL && datalen == NULL && indicator == NULL ) { blkdesc->bcpinfo.bind_count = CS_UNUSED; for (i = 0; i < blkdesc->bcpinfo.bindinfo->num_cols; i++ ) { colinfo = blkdesc->bcpinfo.bindinfo->columns[i]; colinfo->column_varaddr = NULL; colinfo->column_bindtype = 0; colinfo->column_bindfmt = 0; colinfo->column_bindlen = 0; colinfo->column_nullbind = NULL; colinfo->column_lenbind = NULL; } } return CS_SUCCEED; } /* check item value */ if (item < 1 || item > blkdesc->bcpinfo.bindinfo->num_cols) { _ctclient_msg(con, "blk_bind", 2, 5, 1, 141, "%s, %d", "colnum", item); return CS_FAIL; } /* clear bindings for this column */ if (datafmt == NULL && buffer == NULL && datalen == NULL && indicator == NULL ) { colinfo = blkdesc->bcpinfo.bindinfo->columns[item - 1]; colinfo->column_varaddr = NULL; colinfo->column_bindtype = 0; colinfo->column_bindfmt = 0; colinfo->column_bindlen = 0; colinfo->column_nullbind = NULL; colinfo->column_lenbind = NULL; return CS_SUCCEED; } /* * check whether the request is for array binding and ensure that user * supplies the same datafmt->count to the subsequent ct_bind calls */ bind_count = (datafmt->count == 0) ? 1 : datafmt->count; /* first bind for this result set */ if (blkdesc->bcpinfo.bind_count == CS_UNUSED) { blkdesc->bcpinfo.bind_count = bind_count; } else { /* all subsequent binds for this result set - the bind counts must be the same */ if (blkdesc->bcpinfo.bind_count != bind_count) { _ctclient_msg(con, "blk_bind", 1, 1, 1, 137, "%d, %d", bind_count, blkdesc->bcpinfo.bind_count); return CS_FAIL; } } /* bind the column_varaddr to the address of the buffer */ colinfo = blkdesc->bcpinfo.bindinfo->columns[item - 1]; colinfo->column_varaddr = (char *) buffer; colinfo->column_bindtype = datafmt->datatype; colinfo->column_bindfmt = datafmt->format; colinfo->column_bindlen = datafmt->maxlength; if (indicator) { colinfo->column_nullbind = indicator; } if (datalen) { colinfo->column_lenbind = datalen; } return CS_SUCCEED; } CS_RETCODE blk_colval(SRV_PROC * srvproc, CS_BLKDESC * blkdescp, CS_BLK_ROW * rowp, CS_INT colnum, CS_VOID * valuep, CS_INT valuelen, CS_INT * outlenp) { tdsdump_log(TDS_DBG_FUNC, "blk_colval(%p, %p, %p, %d, %p, %d, %p)\n", srvproc, blkdescp, rowp, colnum, valuep, valuelen, outlenp); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED blk_colval()\n"); return CS_FAIL; } CS_RETCODE blk_default(CS_BLKDESC * blkdesc, CS_INT colnum, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen) { tdsdump_log(TDS_DBG_FUNC, "blk_default(%p, %d, %p, %d, %p)\n", blkdesc, colnum, buffer, buflen, outlen); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED blk_default()\n"); return CS_FAIL; } CS_RETCODE blk_describe(CS_BLKDESC * blkdesc, CS_INT item, CS_DATAFMT * datafmt) { TDSCOLUMN *curcol; tdsdump_log(TDS_DBG_FUNC, "blk_describe(%p, %d, %p)\n", blkdesc, item, datafmt); if (item < 1 || item > blkdesc->bcpinfo.bindinfo->num_cols) { _ctclient_msg(CONN(blkdesc), "blk_describe", 2, 5, 1, 141, "%s, %d", "colnum", item); return CS_FAIL; } curcol = blkdesc->bcpinfo.bindinfo->columns[item - 1]; /* name is always null terminated */ strlcpy(datafmt->name, tds_dstr_cstr(&curcol->column_name), sizeof(datafmt->name)); datafmt->namelen = strlen(datafmt->name); /* need to turn the SYBxxx into a CS_xxx_TYPE */ datafmt->datatype = _ct_get_client_type(curcol); if (datafmt->datatype == CS_ILLEGAL_TYPE) return CS_FAIL; tdsdump_log(TDS_DBG_INFO1, "blk_describe() datafmt->datatype = %d server type %d\n", datafmt->datatype, curcol->column_type); /* FIXME is ok this value for numeric/decimal? */ datafmt->maxlength = curcol->column_size; datafmt->usertype = curcol->column_usertype; datafmt->precision = curcol->column_prec; datafmt->scale = curcol->column_scale; /* * There are other options that can be returned, but these are the * only two being noted via the TDS layer. */ datafmt->status = 0; if (curcol->column_nullable) datafmt->status |= CS_CANBENULL; if (curcol->column_identity) datafmt->status |= CS_IDENTITY; datafmt->count = 1; datafmt->locale = NULL; return CS_SUCCEED; } CS_RETCODE blk_done(CS_BLKDESC * blkdesc, CS_INT type, CS_INT * outrow) { TDSSOCKET *tds; int rows_copied; tdsdump_log(TDS_DBG_FUNC, "blk_done(%p, %d, %p)\n", blkdesc, type, outrow); tds = CONN(blkdesc)->tds_socket; switch (type) { case CS_BLK_BATCH: if (TDS_FAILED(tds_bcp_done(tds, &rows_copied))) { _ctclient_msg(CONN(blkdesc), "blk_done", 2, 5, 1, 140, ""); return CS_FAIL; } if (outrow) *outrow = rows_copied; if (TDS_FAILED(tds_bcp_start(tds, &blkdesc->bcpinfo))) { _ctclient_msg(CONN(blkdesc), "blk_done", 2, 5, 1, 140, ""); return CS_FAIL; } break; case CS_BLK_ALL: if (TDS_FAILED(tds_bcp_done(tds, &rows_copied))) { _ctclient_msg(CONN(blkdesc), "blk_done", 2, 5, 1, 140, ""); return CS_FAIL; } if (outrow) *outrow = rows_copied; /* free allocated storage in blkdesc & initialise flags, etc. */ tds_deinit_bcpinfo(&blkdesc->bcpinfo); blkdesc->bcpinfo.direction = 0; blkdesc->bcpinfo.bind_count = CS_UNUSED; blkdesc->bcpinfo.xfer_init = 0; break; } return CS_SUCCEED; } CS_RETCODE blk_drop(CS_BLKDESC * blkdesc) { tdsdump_log(TDS_DBG_FUNC, "blk_drop(%p)\n", blkdesc); /* this is possible as CS_BLKDESC contains just bcpinfo field */ tds_free_bcpinfo(&blkdesc->bcpinfo); return CS_SUCCEED; } CS_RETCODE blk_getrow(SRV_PROC * srvproc, CS_BLKDESC * blkdescp, CS_BLK_ROW * rowp) { tdsdump_log(TDS_DBG_FUNC, "blk_getrow(%p, %p, %p)\n", srvproc, blkdescp, rowp); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED blk_getrow()\n"); return CS_FAIL; } CS_RETCODE blk_gettext(SRV_PROC * srvproc, CS_BLKDESC * blkdescp, CS_BLK_ROW * rowp, CS_INT bufsize, CS_INT * outlenp) { tdsdump_log(TDS_DBG_FUNC, "blk_gettext(%p, %p, %p, %d, %p)\n", srvproc, blkdescp, rowp, bufsize, outlenp); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED blk_gettext()\n"); return CS_FAIL; } CS_RETCODE blk_init(CS_BLKDESC * blkdesc, CS_INT direction, CS_CHAR * tablename, CS_INT tnamelen) { tdsdump_log(TDS_DBG_FUNC, "blk_init(%p, %d, %p, %d)\n", blkdesc, direction, tablename, tnamelen); if (!blkdesc) { return CS_FAIL; } if (direction != CS_BLK_IN && direction != CS_BLK_OUT ) { _ctclient_msg(CONN(blkdesc), "blk_init", 2, 6, 1, 138, ""); return CS_FAIL; } if (!tablename) { _ctclient_msg(CONN(blkdesc), "blk_init", 2, 6, 1, 139, ""); return CS_FAIL; } if (tnamelen == CS_NULLTERM) tnamelen = strlen(tablename); /* free allocated storage in blkdesc & initialise flags, etc. */ tds_deinit_bcpinfo(&blkdesc->bcpinfo); /* string can be no-nul terminated so copy with memcpy */ if (!tds_dstr_copyn(&blkdesc->bcpinfo.tablename, tablename, tnamelen)) { return CS_FAIL; } blkdesc->bcpinfo.direction = direction; blkdesc->bcpinfo.bind_count = CS_UNUSED; blkdesc->bcpinfo.xfer_init = 0; if (TDS_FAILED(tds_bcp_init(CONN(blkdesc)->tds_socket, &blkdesc->bcpinfo))) { _ctclient_msg(CONN(blkdesc), "blk_init", 2, 5, 1, 140, ""); return CS_FAIL; } blkdesc->bcpinfo.bind_count = CS_UNUSED; return CS_SUCCEED; } CS_RETCODE blk_props(CS_BLKDESC * blkdesc, CS_INT action, CS_INT property, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen) { int retval, intval; tdsdump_log(TDS_DBG_FUNC, "blk_props(%p, %d, %d, %p, %d, %p)\n", blkdesc, action, property, buffer, buflen, outlen); switch (property) { case BLK_IDENTITY: switch (action) { case CS_SET: if (buffer) { memcpy(&intval, buffer, sizeof(intval)); if (intval == CS_TRUE) blkdesc->bcpinfo.identity_insert_on = 1; if (intval == CS_FALSE) blkdesc->bcpinfo.identity_insert_on = 0; } return CS_SUCCEED; break; case CS_GET: retval = blkdesc->bcpinfo.identity_insert_on == 1 ? CS_TRUE : CS_FALSE ; if (buffer) { memcpy (buffer, &retval, sizeof(retval)); if (outlen) *outlen = sizeof(retval); } return CS_SUCCEED; break; default: _ctclient_msg(CONN(blkdesc), "blk_props", 2, 5, 1, 141, "%s, %d", "action", action); break; } break; default: _ctclient_msg(CONN(blkdesc), "blk_props", 2, 5, 1, 141, "%s, %d", "property", property); break; } return CS_FAIL; } CS_RETCODE blk_rowalloc(SRV_PROC * srvproc, CS_BLK_ROW ** row) { tdsdump_log(TDS_DBG_FUNC, "blk_rowalloc(%p, %p)\n", srvproc, row); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED blk_rowalloc()\n"); return CS_FAIL; } CS_RETCODE blk_rowdrop(SRV_PROC * srvproc, CS_BLK_ROW * row) { tdsdump_log(TDS_DBG_FUNC, "blk_rowdrop(%p, %p)\n", srvproc, row); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED blk_rowdrop()\n"); return CS_FAIL; } CS_RETCODE blk_rowxfer(CS_BLKDESC * blkdesc) { tdsdump_log(TDS_DBG_FUNC, "blk_rowxfer(%p)\n", blkdesc); return blk_rowxfer_mult(blkdesc, NULL); } CS_RETCODE blk_rowxfer_mult(CS_BLKDESC * blkdesc, CS_INT * row_count) { CS_INT rows_to_xfer = 0; CS_INT rows_xferred = 0; CS_RETCODE ret; tdsdump_log(TDS_DBG_FUNC, "blk_rowxfer_mult(%p, %p)\n", blkdesc, row_count); if (!row_count || *row_count == 0 ) rows_to_xfer = blkdesc->bcpinfo.bind_count; else rows_to_xfer = *row_count; if (blkdesc->bcpinfo.direction == CS_BLK_IN) { ret = _blk_rowxfer_in(blkdesc, rows_to_xfer, &rows_xferred); } else { ret = _blk_rowxfer_out(blkdesc, rows_to_xfer, &rows_xferred); } if (row_count) *row_count = rows_xferred; return ret; } CS_RETCODE blk_sendrow(CS_BLKDESC * blkdesc, CS_BLK_ROW * row) { tdsdump_log(TDS_DBG_FUNC, "blk_sendrow(%p, %p)\n", blkdesc, row); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED blk_sendrow()\n"); return CS_FAIL; } CS_RETCODE blk_sendtext(CS_BLKDESC * blkdesc, CS_BLK_ROW * row, CS_BYTE * buffer, CS_INT buflen) { tdsdump_log(TDS_DBG_FUNC, "blk_sendtext(%p, %p, %p, %d)\n", blkdesc, row, buffer, buflen); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED blk_sendtext()\n"); return CS_FAIL; } CS_RETCODE blk_srvinit(SRV_PROC * srvproc, CS_BLKDESC * blkdescp) { tdsdump_log(TDS_DBG_FUNC, "blk_srvinit(%p, %p)\n", srvproc, blkdescp); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED blk_srvinit()\n"); return CS_FAIL; } CS_RETCODE blk_textxfer(CS_BLKDESC * blkdesc, CS_BYTE * buffer, CS_INT buflen, CS_INT * outlen) { tdsdump_log(TDS_DBG_FUNC, "blk_textxfer(%p, %p, %d, %p)\n", blkdesc, buffer, buflen, outlen); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED blk_textxfer()\n"); return CS_FAIL; } static CS_RETCODE _blk_rowxfer_out(CS_BLKDESC * blkdesc, CS_INT rows_to_xfer, CS_INT * rows_xferred) { TDSSOCKET *tds; TDS_INT result_type; TDSRET ret; TDS_INT temp_count; tdsdump_log(TDS_DBG_FUNC, "_blk_rowxfer_out(%p, %d, %p)\n", blkdesc, rows_to_xfer, rows_xferred); if (!blkdesc || !CONN(blkdesc)) return CS_FAIL; tds = CONN(blkdesc)->tds_socket; /* * the first time blk_xfer called after blk_init() * do the query and get to the row data... */ if (blkdesc->bcpinfo.xfer_init == 0) { if (TDS_FAILED(tds_submit_queryf(tds, "select * from %s", tds_dstr_cstr(&blkdesc->bcpinfo.tablename)))) { _ctclient_msg(CONN(blkdesc), "blk_rowxfer", 2, 5, 1, 140, ""); return CS_FAIL; } while ((ret = tds_process_tokens(tds, &result_type, NULL, TDS_TOKEN_RESULTS)) == TDS_SUCCESS) { if (result_type == TDS_ROW_RESULT) break; } if (ret != TDS_SUCCESS || result_type != TDS_ROW_RESULT) { _ctclient_msg(CONN(blkdesc), "blk_rowxfer", 2, 5, 1, 140, ""); return CS_FAIL; } blkdesc->bcpinfo.xfer_init = 1; } if (rows_xferred) *rows_xferred = 0; for (temp_count = 0; temp_count < rows_to_xfer; temp_count++) { ret = tds_process_tokens(tds, &result_type, NULL, TDS_STOPAT_ROWFMT|TDS_STOPAT_DONE|TDS_RETURN_ROW|TDS_RETURN_COMPUTE); tdsdump_log(TDS_DBG_FUNC, "blk_rowxfer_out() process_row_tokens returned %d\n", ret); switch (ret) { case TDS_SUCCESS: if (result_type == TDS_ROW_RESULT || result_type == TDS_COMPUTE_RESULT) { if (result_type == TDS_ROW_RESULT) { if (_ct_bind_data( CONN(blkdesc)->ctx, tds->current_results, blkdesc->bcpinfo.bindinfo, temp_count)) return CS_ROW_FAIL; if (rows_xferred) *rows_xferred = *rows_xferred + 1; } break; } case TDS_NO_MORE_RESULTS: return CS_END_DATA; break; default: _ctclient_msg(CONN(blkdesc), "blk_rowxfer", 2, 5, 1, 140, ""); return CS_FAIL; break; } } return CS_SUCCEED; } static CS_RETCODE _blk_rowxfer_in(CS_BLKDESC * blkdesc, CS_INT rows_to_xfer, CS_INT * rows_xferred) { TDSSOCKET *tds; TDS_INT each_row; tdsdump_log(TDS_DBG_FUNC, "_blk_rowxfer_in(%p, %d, %p)\n", blkdesc, rows_to_xfer, rows_xferred); if (!blkdesc) return CS_FAIL; tds = CONN(blkdesc)->tds_socket; /* * the first time blk_xfer called after blk_init() * do the query and get to the row data... */ if (blkdesc->bcpinfo.xfer_init == 0) { /* * first call the start_copy function, which will * retrieve details of the database table columns */ if (TDS_FAILED(tds_bcp_start_copy_in(tds, &blkdesc->bcpinfo))) { _ctclient_msg(CONN(blkdesc), "blk_rowxfer", 2, 5, 1, 140, ""); return CS_FAIL; } blkdesc->bcpinfo.xfer_init = 1; } for (each_row = 0; each_row < rows_to_xfer; each_row++ ) { if (tds_bcp_send_record(tds, &blkdesc->bcpinfo, _blk_get_col_data, _blk_null_error, each_row) == TDS_SUCCESS) { /* FIXME */ } } return CS_SUCCEED; } static void _blk_null_error(TDSBCPINFO *bcpinfo, int index, int offset) { CS_BLKDESC *blkdesc = (CS_BLKDESC *) bcpinfo; tdsdump_log(TDS_DBG_FUNC, "_blk_null_error(%p, %d, %d)\n", bcpinfo, index, offset); _ctclient_msg(CONN(blkdesc), "blk_rowxfer", 2, 7, 1, 142, "%d, %d", index + 1, offset + 1); } static TDSRET _blk_get_col_data(TDSBCPINFO *bulk, TDSCOLUMN *bindcol, int offset) { int result = 0; CS_INT null_column = 0; unsigned char *src = NULL; CS_INT srctype = 0; CS_INT srclen = 0; CS_INT destlen = 0; CS_SMALLINT *nullind = NULL; CS_INT *datalen = NULL; CS_BLKDESC *blkdesc = (CS_BLKDESC *) bulk; CS_CONTEXT *ctx = CONN(blkdesc)->ctx; CS_DATAFMT srcfmt, destfmt; tdsdump_log(TDS_DBG_FUNC, "_blk_get_col_data(%p, %p, %d)\n", bulk, bindcol, offset); /* * Retrieve the initial bound column_varaddress * and increment it if offset specified */ src = (unsigned char *) bindcol->column_varaddr; if (!src) { tdsdump_log(TDS_DBG_ERROR, "error source field not addressable\n"); return TDS_FAIL; } src += offset * bindcol->column_bindlen; if (bindcol->column_nullbind) { nullind = bindcol->column_nullbind; nullind += offset; } if (bindcol->column_lenbind) { datalen = bindcol->column_lenbind; datalen += offset; } srctype = bindcol->column_bindtype; /* passes to cs_convert */ tdsdump_log(TDS_DBG_INFO1, "blk_get_col_data srctype = %d \n", srctype); tdsdump_log(TDS_DBG_INFO1, "blk_get_col_data datalen = %d \n", *datalen); if (*datalen) { if (*datalen == CS_UNUSED) { switch (srctype) { case CS_LONG_TYPE: srclen = 8; break; case CS_FLOAT_TYPE: srclen = 8; break; case CS_MONEY_TYPE: srclen = 8; break; case CS_DATETIME_TYPE: srclen = 8; break; case CS_INT_TYPE: srclen = 4; break; case CS_UINT_TYPE: srclen = 4; break; case CS_REAL_TYPE: srclen = 4; break; case CS_MONEY4_TYPE: srclen = 4; break; case CS_DATETIME4_TYPE: srclen = 4; break; case CS_SMALLINT_TYPE: srclen = 2; break; case CS_USMALLINT_TYPE: srclen = 2; break; case CS_TINYINT_TYPE: srclen = 1; break; case CS_BIT_TYPE: srclen = 1; break; case CS_BIGINT_TYPE: srclen = 8; break; case CS_UBIGINT_TYPE: srclen = 8; break; case CS_UNIQUE_TYPE: srclen = 16; break; default: printf("error not fixed length type (%d) and datalen not specified\n", bindcol->column_bindtype); return CS_FAIL; } } else { srclen = *datalen; } } if (srclen == 0) { if (nullind && *nullind == -1) null_column = 1; } if (!null_column) { CONV_RESULT convert_buffer; srcfmt.datatype = srctype; srcfmt.maxlength = srclen; destfmt.datatype = _cs_convert_not_client(ctx, bindcol, &convert_buffer, &src); if (destfmt.datatype == CS_ILLEGAL_TYPE) destfmt.datatype = _ct_get_client_type(bindcol); if (destfmt.datatype == CS_ILLEGAL_TYPE) return CS_FAIL; destfmt.maxlength = bindcol->column_size; destfmt.precision = bindcol->column_prec; destfmt.scale = bindcol->column_scale; destfmt.format = CS_FMT_UNUSED; /* if convert return FAIL mark error but process other columns */ if ((result = cs_convert(ctx, &srcfmt, (CS_VOID *) src, &destfmt, (CS_VOID *) bindcol->bcp_column_data->data, &destlen)) != CS_SUCCEED) { tdsdump_log(TDS_DBG_INFO1, "convert failed for %d \n", srcfmt.datatype); return CS_FAIL; } } bindcol->bcp_column_data->datalen = destlen; bindcol->bcp_column_data->is_null = null_column; return TDS_SUCCESS; } freetds-1.00.82/src/ctlib/ctutil.c100644 025423 025423 00000014556 12717145107 0012402/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Brian Bruns * Copyright (C) 2011 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include "cspublic.h" #include "ctlib.h" #include #include "replacements.h" /* #include "fortify.h" */ /* * test include consistency * I don't think all compiler are able to compile this code... if not comment it */ #if ENABLE_EXTRA_CHECKS #define TEST_EQUAL(t,a,b) TDS_COMPILE_CHECK(t,a==b) TEST_EQUAL(t03,CS_NULLTERM,TDS_NULLTERM); TEST_EQUAL(t04,CS_CMD_SUCCEED,TDS_CMD_SUCCEED); TEST_EQUAL(t05,CS_CMD_FAIL,TDS_CMD_FAIL); TEST_EQUAL(t06,CS_CMD_DONE,TDS_CMD_DONE); TEST_EQUAL(t07,CS_NO_COUNT,TDS_NO_COUNT); TEST_EQUAL(t08,CS_COMPUTE_RESULT,TDS_COMPUTE_RESULT); TEST_EQUAL(t09,CS_PARAM_RESULT,TDS_PARAM_RESULT); TEST_EQUAL(t10,CS_ROW_RESULT,TDS_ROW_RESULT); TEST_EQUAL(t11,CS_STATUS_RESULT,TDS_STATUS_RESULT); TEST_EQUAL(t12,CS_COMPUTEFMT_RESULT,TDS_COMPUTEFMT_RESULT); TEST_EQUAL(t13,CS_ROWFMT_RESULT,TDS_ROWFMT_RESULT); TEST_EQUAL(t14,CS_MSG_RESULT,TDS_MSG_RESULT); TEST_EQUAL(t15,CS_DESCRIBE_RESULT,TDS_DESCRIBE_RESULT); #define TEST_ATTRIBUTE(t,sa,fa,sb,fb) \ TDS_COMPILE_CHECK(t,sizeof(((sa*)0)->fa) == sizeof(((sb*)0)->fb) && TDS_OFFSET(sa,fa) == TDS_OFFSET(sb,fb)) TEST_ATTRIBUTE(t21,TDS_MONEY4,mny4,CS_MONEY4,mny4); TEST_ATTRIBUTE(t22,TDS_OLD_MONEY,mnyhigh,CS_MONEY,mnyhigh); TEST_ATTRIBUTE(t23,TDS_OLD_MONEY,mnylow,CS_MONEY,mnylow); TEST_ATTRIBUTE(t24,TDS_DATETIME,dtdays,CS_DATETIME,dtdays); TEST_ATTRIBUTE(t25,TDS_DATETIME,dttime,CS_DATETIME,dttime); TEST_ATTRIBUTE(t26,TDS_DATETIME4,days,CS_DATETIME4,days); TEST_ATTRIBUTE(t27,TDS_DATETIME4,minutes,CS_DATETIME4,minutes); TEST_ATTRIBUTE(t28,TDS_NUMERIC,precision,CS_NUMERIC,precision); TEST_ATTRIBUTE(t29,TDS_NUMERIC,scale,CS_NUMERIC,scale); TEST_ATTRIBUTE(t30,TDS_NUMERIC,array,CS_NUMERIC,array); TEST_ATTRIBUTE(t30,TDS_NUMERIC,precision,CS_DECIMAL,precision); TEST_ATTRIBUTE(t31,TDS_NUMERIC,scale,CS_DECIMAL,scale); TEST_ATTRIBUTE(t32,TDS_NUMERIC,array,CS_DECIMAL,array); #endif /* * error handler * This callback function should be invoked only from libtds through tds_ctx->err_handler. */ int _ct_handle_client_message(const TDSCONTEXT * ctx_tds, TDSSOCKET * tds, TDSMESSAGE * msg) { CS_CLIENTMSG errmsg; CS_CONNECTION *con = NULL; CS_CONTEXT *ctx = NULL; int ret = (int) CS_SUCCEED; tdsdump_log(TDS_DBG_FUNC, "_ct_handle_client_message(%p, %p, %p)\n", ctx_tds, tds, msg); if (tds && tds_get_parent(tds)) { con = (CS_CONNECTION *) tds_get_parent(tds); } memset(&errmsg, '\0', sizeof(errmsg)); errmsg.msgnumber = msg->msgno; strlcpy(errmsg.msgstring, msg->message, sizeof(errmsg.msgstring)); errmsg.msgstringlen = strlen(errmsg.msgstring); errmsg.osstring[0] = '\0'; errmsg.osstringlen = 0; /* if there is no connection, attempt to call the context handler */ if (!con) { ctx = (CS_CONTEXT *) ctx_tds->parent; if (ctx->_clientmsg_cb) ret = ctx->_clientmsg_cb(ctx, con, &errmsg); } else if (con->_clientmsg_cb) ret = con->_clientmsg_cb(con->ctx, con, &errmsg); else if (con->ctx->_clientmsg_cb) ret = con->ctx->_clientmsg_cb(con->ctx, con, &errmsg); /* * The return code from the error handler is either CS_SUCCEED or CS_FAIL. * This function was called by libtds with some kind of communications failure, and there are * no cases in which "succeed" could mean anything: In most cases, the function is going to fail * no matter what. * * Timeouts are a different matter; it's up to the client to decide whether to continue * waiting or to abort the operation and close the socket. ct-lib applications do their * own cancel processing -- they can call ct_cancel from within the error handler -- so * they don't need to return TDS_INT_TIMEOUT. They can, however, return TDS_INT_CONTINUE * or TDS_INT_CANCEL. We map the client's return code to those. * * Only for timeout errors does TDS_INT_CANCEL cause libtds to break the connection. */ if (msg->msgno == TDSETIME) { switch (ret) { case CS_SUCCEED: return TDS_INT_CONTINUE; case CS_FAIL: return TDS_INT_CANCEL; } } return TDS_INT_CANCEL; } /* message handler */ TDSRET _ct_handle_server_message(const TDSCONTEXT * ctx_tds, TDSSOCKET * tds, TDSMESSAGE * msg) { CS_SERVERMSG errmsg; CS_CONNECTION *con = NULL; CS_CONTEXT *ctx = NULL; CS_RETCODE ret = CS_SUCCEED; tdsdump_log(TDS_DBG_FUNC, "_ct_handle_server_message(%p, %p, %p)\n", ctx_tds, tds, msg); if (tds && tds_get_parent(tds)) con = (CS_CONNECTION *) tds_get_parent(tds); memset(&errmsg, '\0', sizeof(errmsg)); errmsg.msgnumber = msg->msgno; strlcpy(errmsg.text, msg->message, sizeof(errmsg.text)); errmsg.textlen = strlen(errmsg.text); errmsg.sqlstate[0] = 0; if (msg->sql_state) strlcpy((char *) errmsg.sqlstate, msg->sql_state, sizeof(errmsg.sqlstate)); errmsg.sqlstatelen = strlen((char *) errmsg.sqlstate); errmsg.state = msg->state; errmsg.severity = msg->severity; errmsg.line = msg->line_number; if (msg->server) { errmsg.svrnlen = strlen(msg->server); strlcpy(errmsg.svrname, msg->server, CS_MAX_NAME); } if (msg->proc_name) { errmsg.proclen = strlen(msg->proc_name); strlcpy(errmsg.proc, msg->proc_name, CS_MAX_NAME); } /* if there is no connection, attempt to call the context handler */ if (!con) { ctx = (CS_CONTEXT *) ctx_tds->parent; if (ctx->_servermsg_cb) ret = ctx->_servermsg_cb(ctx, con, &errmsg); } else if (con->_servermsg_cb) { ret = con->_servermsg_cb(con->ctx, con, &errmsg); } else if (con->ctx->_servermsg_cb) { ret = con->ctx->_servermsg_cb(con->ctx, con, &errmsg); } return ret == CS_SUCCEED ? TDS_SUCCESS : TDS_FAIL; } freetds-1.00.82/src/ctlib/winmain.c100644 025423 025423 00000000041 12717145107 0012520#include "../../win32/initnet.c" freetds-1.00.82/src/ctlib/ctlib.def100644 025423 025423 00000001744 12522201763 0012475EXPORTS blk_alloc blk_bind blk_colval blk_default blk_describe blk_done blk_drop blk_getrow blk_gettext blk_init blk_props blk_rowalloc blk_rowdrop blk_rowxfer blk_rowxfer_mult blk_sendrow blk_sendtext blk_srvinit blk_textxfer cs_calc cs_cmp cs_config cs_convert cs_conv_mult cs_ctx_alloc cs_ctx_drop cs_ctx_global cs_diag cs_dt_crack cs_dt_info cs_locale cs_loc_alloc cs_loc_drop cs_manage_convert cs_objects cs_prretcode cs_set_convert cs_setnull cs_strbuild cs_strcmp cs_time cs_will_convert ct_bind ct_callback ct_cancel ct_capability ct_close ct_cmd_alloc ct_cmd_drop ct_cmd_props ct_command ct_compute_info ct_con_alloc ct_con_drop ct_config ct_connect ct_con_props ct_cursor ct_data_info ct_describe ct_diag ct_dynamic ct_exit ct_fetch ct_get_data ct_init ct_options ct_param ct_poll ct_res_info ct_results ct_send ct_send_data ct_setparam freetds-1.00.82/src/ctlib/CMakeLists.txt100644 025423 025423 00000001677 12717145107 0013472add_subdirectory(unittests) set(static_lib_name ct) if(WIN32) add_definitions(-DDLL_EXPORT) set(win_SRCS winmain.c ctlib.def) set(static_lib_name libct) endif() add_library(ct SHARED ct.c cs.c blk.c ctutil.c ${win_SRCS} ) target_link_libraries(ct tds replacements ${lib_NETWORK} ${lib_BASE}) add_library(ct-static STATIC ct.c cs.c blk.c ctutil.c ) # See http://www.cmake.org/Wiki/CMake_FAQ#How_do_I_make_my_shared_and_static_libraries_have_the_same_root_name.2C_but_different_suffixes.3F SET_TARGET_PROPERTIES(ct-static PROPERTIES OUTPUT_NAME ${static_lib_name}) SET_TARGET_PROPERTIES(ct PROPERTIES CLEAN_DIRECT_OUTPUT 1) SET_TARGET_PROPERTIES(ct-static PROPERTIES CLEAN_DIRECT_OUTPUT 1) target_link_libraries(ct-static tds replacements ${lib_NETWORK} ${lib_BASE}) if(NOT WIN32) set_target_properties(ct PROPERTIES SOVERSION "4.0.0") endif() if(MINGW OR CYGWIN) set_target_properties(ct PROPERTIES LINK_FLAGS "--static") endif(MINGW OR CYGWIN) freetds-1.00.82/src/ctlib/unittests/Makefile.am100644 025423 025423 00000004723 12717145107 0015023# $Id: Makefile.am,v 1.33 2011-06-08 09:25:53 freddy77 Exp $ TESTS = t0001$(EXEEXT) t0002$(EXEEXT) t0003$(EXEEXT) t0004$(EXEEXT) \ t0005$(EXEEXT) t0006$(EXEEXT) t0007$(EXEEXT) t0008$(EXEEXT) \ t0009$(EXEEXT) connect_fail$(EXEEXT) ct_options$(EXEEXT) \ lang_ct_param$(EXEEXT) array_bind$(EXEEXT) cs_diag$(EXEEXT) \ get_send_data$(EXEEXT) rpc_ct_param$(EXEEXT) rpc_ct_setparam$(EXEEXT) \ ct_diagclient$(EXEEXT) ct_diagserver$(EXEEXT) ct_diagall$(EXEEXT) \ cs_config$(EXEEXT) cancel$(EXEEXT) blk_in$(EXEEXT) \ blk_out$(EXEEXT) ct_cursor$(EXEEXT) ct_cursors$(EXEEXT) \ ct_dynamic$(EXEEXT) blk_in2$(EXEEXT) datafmt$(EXEEXT) \ rpc_fail$(EXEEXT) row_count$(EXEEXT) check_PROGRAMS = $(TESTS) t0001_SOURCES = t0001.c common.c common.h t0002_SOURCES = t0002.c common.c common.h t0003_SOURCES = t0003.c common.c common.h t0004_SOURCES = t0004.c common.c common.h t0005_SOURCES = t0005.c common.c common.h t0006_SOURCES = t0006.c t0007_SOURCES = t0007.c common.c common.h t0008_SOURCES = t0008.c common.c common.h t0009_SOURCES = t0009.c common.c common.h connect_fail_SOURCES = connect_fail.c common.c common.h ct_options_SOURCES = ct_options.c common.c common.h lang_ct_param_SOURCES = lang_ct_param.c common.c common.h array_bind_SOURCES = array_bind.c common.c common.h cs_diag_SOURCES = cs_diag.c common.c common.h get_send_data_SOURCES = get_send_data.c common.c common.h rpc_ct_param_SOURCES = rpc_ct_param.c common.c common.h rpc_ct_setparam_SOURCES = rpc_ct_setparam.c common.c common.h ct_diagclient_SOURCES = ct_diagclient.c common.c common.h ct_diagserver_SOURCES = ct_diagserver.c common.c common.h ct_diagall_SOURCES = ct_diagall.c common.c common.h cs_config_SOURCES = cs_config.c common.c common.h cancel_SOURCES = cancel.c common.c common.h blk_in_SOURCES = blk_in.h blk_in.c common.c common.h blk_out_SOURCES = blk_out.c common.c common.h ct_cursor_SOURCES = ct_cursor.c common.c common.h ct_cursors_SOURCES = ct_cursors.c common.c common.h ct_dynamic_SOURCES = ct_dynamic.c common.c common.h blk_in2_SOURCES = blk_in2.c common.c common.h datafmt_SOURCES = datafmt.c common.c common.h rpc_fail_SOURCES = rpc_fail.c common.c common.h row_count_SOURCES = row_count.c common.c common.h AM_CPPFLAGS = -I$(top_srcdir)/include if MINGW32 AM_LDFLAGS = -no-fast-install else AM_LDFLAGS = -no-install -L../.libs -R $(abs_builddir)/../.libs endif LIBS = ../libct.la ../../replacements/libreplacements.la $(LTLIBICONV) CLEANFILES = tdsdump.out EXTRA_DIST = CMakeLists.txt freetds-1.00.82/src/ctlib/unittests/Makefile.in100644 025423 025423 00000161511 13242511111 0015015# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # $Id: Makefile.am,v 1.33 2011-06-08 09:25:53 freddy77 Exp $ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/ctlib/unittests ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = \ $(top_srcdir)/m4/ac_caolan_func_which_gethostbyname_r.m4 \ $(top_srcdir)/m4/ac_have_inaddr_none.m4 \ $(top_srcdir)/m4/ac_have_malloc_options.m4 \ $(top_srcdir)/m4/ac_nullzero.m4 \ $(top_srcdir)/m4/ac_raf_func_which_getservbyname_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_gethostbyaddr_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_getpwuid_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_localtime_r.m4 \ $(top_srcdir)/m4/acx_pthread.m4 \ $(top_srcdir)/m4/ax_cflags_gcc_option.m4 \ $(top_srcdir)/m4/check_openssl.m4 \ $(top_srcdir)/m4/gettimemilli.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/pushlibs.m4 \ $(top_srcdir)/m4/sprintf_i64_format.m4 \ $(top_srcdir)/m4/type_socklen_t.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am_array_bind_OBJECTS = array_bind.$(OBJEXT) common.$(OBJEXT) array_bind_OBJECTS = $(am_array_bind_OBJECTS) array_bind_LDADD = $(LDADD) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = am_blk_in_OBJECTS = blk_in.$(OBJEXT) common.$(OBJEXT) blk_in_OBJECTS = $(am_blk_in_OBJECTS) blk_in_LDADD = $(LDADD) am_blk_in2_OBJECTS = blk_in2.$(OBJEXT) common.$(OBJEXT) blk_in2_OBJECTS = $(am_blk_in2_OBJECTS) blk_in2_LDADD = $(LDADD) am_blk_out_OBJECTS = blk_out.$(OBJEXT) common.$(OBJEXT) blk_out_OBJECTS = $(am_blk_out_OBJECTS) blk_out_LDADD = $(LDADD) am_cancel_OBJECTS = cancel.$(OBJEXT) common.$(OBJEXT) cancel_OBJECTS = $(am_cancel_OBJECTS) cancel_LDADD = $(LDADD) am_connect_fail_OBJECTS = connect_fail.$(OBJEXT) common.$(OBJEXT) connect_fail_OBJECTS = $(am_connect_fail_OBJECTS) connect_fail_LDADD = $(LDADD) am_cs_config_OBJECTS = cs_config.$(OBJEXT) common.$(OBJEXT) cs_config_OBJECTS = $(am_cs_config_OBJECTS) cs_config_LDADD = $(LDADD) am_cs_diag_OBJECTS = cs_diag.$(OBJEXT) common.$(OBJEXT) cs_diag_OBJECTS = $(am_cs_diag_OBJECTS) cs_diag_LDADD = $(LDADD) am_ct_cursor_OBJECTS = ct_cursor.$(OBJEXT) common.$(OBJEXT) ct_cursor_OBJECTS = $(am_ct_cursor_OBJECTS) ct_cursor_LDADD = $(LDADD) am_ct_cursors_OBJECTS = ct_cursors.$(OBJEXT) common.$(OBJEXT) ct_cursors_OBJECTS = $(am_ct_cursors_OBJECTS) ct_cursors_LDADD = $(LDADD) am_ct_diagall_OBJECTS = ct_diagall.$(OBJEXT) common.$(OBJEXT) ct_diagall_OBJECTS = $(am_ct_diagall_OBJECTS) ct_diagall_LDADD = $(LDADD) am_ct_diagclient_OBJECTS = ct_diagclient.$(OBJEXT) common.$(OBJEXT) ct_diagclient_OBJECTS = $(am_ct_diagclient_OBJECTS) ct_diagclient_LDADD = $(LDADD) am_ct_diagserver_OBJECTS = ct_diagserver.$(OBJEXT) common.$(OBJEXT) ct_diagserver_OBJECTS = $(am_ct_diagserver_OBJECTS) ct_diagserver_LDADD = $(LDADD) am_ct_dynamic_OBJECTS = ct_dynamic.$(OBJEXT) common.$(OBJEXT) ct_dynamic_OBJECTS = $(am_ct_dynamic_OBJECTS) ct_dynamic_LDADD = $(LDADD) am_ct_options_OBJECTS = ct_options.$(OBJEXT) common.$(OBJEXT) ct_options_OBJECTS = $(am_ct_options_OBJECTS) ct_options_LDADD = $(LDADD) am_datafmt_OBJECTS = datafmt.$(OBJEXT) common.$(OBJEXT) datafmt_OBJECTS = $(am_datafmt_OBJECTS) datafmt_LDADD = $(LDADD) am_get_send_data_OBJECTS = get_send_data.$(OBJEXT) common.$(OBJEXT) get_send_data_OBJECTS = $(am_get_send_data_OBJECTS) get_send_data_LDADD = $(LDADD) am_lang_ct_param_OBJECTS = lang_ct_param.$(OBJEXT) common.$(OBJEXT) lang_ct_param_OBJECTS = $(am_lang_ct_param_OBJECTS) lang_ct_param_LDADD = $(LDADD) am_row_count_OBJECTS = row_count.$(OBJEXT) common.$(OBJEXT) row_count_OBJECTS = $(am_row_count_OBJECTS) row_count_LDADD = $(LDADD) am_rpc_ct_param_OBJECTS = rpc_ct_param.$(OBJEXT) common.$(OBJEXT) rpc_ct_param_OBJECTS = $(am_rpc_ct_param_OBJECTS) rpc_ct_param_LDADD = $(LDADD) am_rpc_ct_setparam_OBJECTS = rpc_ct_setparam.$(OBJEXT) \ common.$(OBJEXT) rpc_ct_setparam_OBJECTS = $(am_rpc_ct_setparam_OBJECTS) rpc_ct_setparam_LDADD = $(LDADD) am_rpc_fail_OBJECTS = rpc_fail.$(OBJEXT) common.$(OBJEXT) rpc_fail_OBJECTS = $(am_rpc_fail_OBJECTS) rpc_fail_LDADD = $(LDADD) am_t0001_OBJECTS = t0001.$(OBJEXT) common.$(OBJEXT) t0001_OBJECTS = $(am_t0001_OBJECTS) t0001_LDADD = $(LDADD) am_t0002_OBJECTS = t0002.$(OBJEXT) common.$(OBJEXT) t0002_OBJECTS = $(am_t0002_OBJECTS) t0002_LDADD = $(LDADD) am_t0003_OBJECTS = t0003.$(OBJEXT) common.$(OBJEXT) t0003_OBJECTS = $(am_t0003_OBJECTS) t0003_LDADD = $(LDADD) am_t0004_OBJECTS = t0004.$(OBJEXT) common.$(OBJEXT) t0004_OBJECTS = $(am_t0004_OBJECTS) t0004_LDADD = $(LDADD) am_t0005_OBJECTS = t0005.$(OBJEXT) common.$(OBJEXT) t0005_OBJECTS = $(am_t0005_OBJECTS) t0005_LDADD = $(LDADD) am_t0006_OBJECTS = t0006.$(OBJEXT) t0006_OBJECTS = $(am_t0006_OBJECTS) t0006_LDADD = $(LDADD) am_t0007_OBJECTS = t0007.$(OBJEXT) common.$(OBJEXT) t0007_OBJECTS = $(am_t0007_OBJECTS) t0007_LDADD = $(LDADD) am_t0008_OBJECTS = t0008.$(OBJEXT) common.$(OBJEXT) t0008_OBJECTS = $(am_t0008_OBJECTS) t0008_LDADD = $(LDADD) am_t0009_OBJECTS = t0009.$(OBJEXT) common.$(OBJEXT) t0009_OBJECTS = $(am_t0009_OBJECTS) t0009_LDADD = $(LDADD) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(array_bind_SOURCES) $(blk_in_SOURCES) $(blk_in2_SOURCES) \ $(blk_out_SOURCES) $(cancel_SOURCES) $(connect_fail_SOURCES) \ $(cs_config_SOURCES) $(cs_diag_SOURCES) $(ct_cursor_SOURCES) \ $(ct_cursors_SOURCES) $(ct_diagall_SOURCES) \ $(ct_diagclient_SOURCES) $(ct_diagserver_SOURCES) \ $(ct_dynamic_SOURCES) $(ct_options_SOURCES) $(datafmt_SOURCES) \ $(get_send_data_SOURCES) $(lang_ct_param_SOURCES) \ $(row_count_SOURCES) $(rpc_ct_param_SOURCES) \ $(rpc_ct_setparam_SOURCES) $(rpc_fail_SOURCES) \ $(t0001_SOURCES) $(t0002_SOURCES) $(t0003_SOURCES) \ $(t0004_SOURCES) $(t0005_SOURCES) $(t0006_SOURCES) \ $(t0007_SOURCES) $(t0008_SOURCES) $(t0009_SOURCES) DIST_SOURCES = $(array_bind_SOURCES) $(blk_in_SOURCES) \ $(blk_in2_SOURCES) $(blk_out_SOURCES) $(cancel_SOURCES) \ $(connect_fail_SOURCES) $(cs_config_SOURCES) \ $(cs_diag_SOURCES) $(ct_cursor_SOURCES) $(ct_cursors_SOURCES) \ $(ct_diagall_SOURCES) $(ct_diagclient_SOURCES) \ $(ct_diagserver_SOURCES) $(ct_dynamic_SOURCES) \ $(ct_options_SOURCES) $(datafmt_SOURCES) \ $(get_send_data_SOURCES) $(lang_ct_param_SOURCES) \ $(row_count_SOURCES) $(rpc_ct_param_SOURCES) \ $(rpc_ct_setparam_SOURCES) $(rpc_fail_SOURCES) \ $(t0001_SOURCES) $(t0002_SOURCES) $(t0003_SOURCES) \ $(t0004_SOURCES) $(t0005_SOURCES) $(t0006_SOURCES) \ $(t0007_SOURCES) $(t0008_SOURCES) $(t0009_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__tty_colors_dummy = \ mgn= red= grn= lgn= blu= brg= std=; \ am__color_tests=no am__tty_colors = { \ $(am__tty_colors_dummy); \ if test "X$(AM_COLOR_TESTS)" = Xno; then \ am__color_tests=no; \ elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ am__color_tests=yes; \ elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ am__color_tests=yes; \ fi; \ if test $$am__color_tests = yes; then \ red=''; \ grn=''; \ lgn=''; \ blu=''; \ mgn=''; \ brg=''; \ std=''; \ fi; \ } am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__recheck_rx = ^[ ]*:recheck:[ ]* am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* # A command that, given a newline-separated list of test names on the # standard input, print the name of the tests that are to be re-run # upon "make recheck". am__list_recheck_tests = $(AWK) '{ \ recheck = 1; \ while ((rc = (getline line < ($$0 ".trs"))) != 0) \ { \ if (rc < 0) \ { \ if ((getline line2 < ($$0 ".log")) < 0) \ recheck = 0; \ break; \ } \ else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ { \ recheck = 0; \ break; \ } \ else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ { \ break; \ } \ }; \ if (recheck) \ print $$0; \ close ($$0 ".trs"); \ close ($$0 ".log"); \ }' # A command that, given a newline-separated list of test names on the # standard input, create the global log from their .trs and .log files. am__create_global_log = $(AWK) ' \ function fatal(msg) \ { \ print "fatal: making $@: " msg | "cat >&2"; \ exit 1; \ } \ function rst_section(header) \ { \ print header; \ len = length(header); \ for (i = 1; i <= len; i = i + 1) \ printf "="; \ printf "\n\n"; \ } \ { \ copy_in_global_log = 1; \ global_test_result = "RUN"; \ while ((rc = (getline line < ($$0 ".trs"))) != 0) \ { \ if (rc < 0) \ fatal("failed to read from " $$0 ".trs"); \ if (line ~ /$(am__global_test_result_rx)/) \ { \ sub("$(am__global_test_result_rx)", "", line); \ sub("[ ]*$$", "", line); \ global_test_result = line; \ } \ else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ copy_in_global_log = 0; \ }; \ if (copy_in_global_log) \ { \ rst_section(global_test_result ": " $$0); \ while ((rc = (getline line < ($$0 ".log"))) != 0) \ { \ if (rc < 0) \ fatal("failed to read from " $$0 ".log"); \ print line; \ }; \ printf "\n"; \ }; \ close ($$0 ".trs"); \ close ($$0 ".log"); \ }' # Restructured Text title. am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } # Solaris 10 'make', and several other traditional 'make' implementations, # pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it # by disabling -e (using the XSI extension "set +e") if it's set. am__sh_e_setup = case $$- in *e*) set +e;; esac # Default flags passed to test drivers. am__common_driver_flags = \ --color-tests "$$am__color_tests" \ --enable-hard-errors "$$am__enable_hard_errors" \ --expect-failure "$$am__expect_failure" # To be inserted before the command running the test. Creates the # directory for the log if needed. Stores in $dir the directory # containing $f, in $tst the test, in $log the log. Executes the # developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and # passes TESTS_ENVIRONMENT. Set up options for the wrapper that # will run the test scripts (or their associated LOG_COMPILER, if # thy have one). am__check_pre = \ $(am__sh_e_setup); \ $(am__vpath_adj_setup) $(am__vpath_adj) \ $(am__tty_colors); \ srcdir=$(srcdir); export srcdir; \ case "$@" in \ */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ *) am__odir=.;; \ esac; \ test "x$$am__odir" = x"." || test -d "$$am__odir" \ || $(MKDIR_P) "$$am__odir" || exit $$?; \ if test -f "./$$f"; then dir=./; \ elif test -f "$$f"; then dir=; \ else dir="$(srcdir)/"; fi; \ tst=$$dir$$f; log='$@'; \ if test -n '$(DISABLE_HARD_ERRORS)'; then \ am__enable_hard_errors=no; \ else \ am__enable_hard_errors=yes; \ fi; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ am__expect_failure=yes;; \ *) \ am__expect_failure=no;; \ esac; \ $(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) # A shell command to get the names of the tests scripts with any registered # extension removed (i.e., equivalently, the names of the test logs, with # the '.log' extension removed). The result is saved in the shell variable # '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, # we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", # since that might cause problem with VPATH rewrites for suffix-less tests. # See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. am__set_TESTS_bases = \ bases='$(TEST_LOGS)'; \ bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ bases=`echo $$bases` RECHECK_LOGS = $(TEST_LOGS) AM_RECURSIVE_TARGETS = check recheck TEST_SUITE_LOG = test-suite.log TEST_EXTENSIONS = @EXEEXT@ .test LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) am__set_b = \ case '$@' in \ */*) \ case '$*' in \ */*) b='$*';; \ *) b=`echo '$@' | sed 's/\.log$$//'`; \ esac;; \ *) \ b='$*';; \ esac am__test_logs1 = $(TESTS:=.log) am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) TEST_LOGS = $(am__test_logs2:.test.log=.log) TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ $(TEST_LOG_FLAGS) am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp \ $(top_srcdir)/mkinstalldirs $(top_srcdir)/test-driver DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BUILD_NUMBER = @BUILD_NUMBER@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOXYGEN = @DOXYGEN@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FREETDS_LIBGCC = @FREETDS_LIBGCC@ FREETDS_ODBC_MODULE = @FREETDS_ODBC_MODULE@ FREETDS_SYMBOLIC = @FREETDS_SYMBOLIC@ GCRYPT_CFLAGS = @GCRYPT_CFLAGS@ GCRYPT_LIBS = @GCRYPT_LIBS@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ HAVE_OPENSSL = @HAVE_OPENSSL@ HAVE_PERL_SOURCES = @HAVE_PERL_SOURCES@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBADD_DL = @LIBADD_DL@ LIBADD_DLD_LINK = @LIBADD_DLD_LINK@ LIBADD_DLOPEN = @LIBADD_DLOPEN@ LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@ LIBICONV = @LIBICONV@ LIBOBJS = @LIBOBJS@ LIBS = ../libct.la ../../replacements/libreplacements.la $(LTLIBICONV) LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBOBJS = @LTLIBOBJS@ LT_DLLOADERS = @LT_DLLOADERS@ LT_DLPREOPEN = @LT_DLPREOPEN@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ NETTLE_CFLAGS = @NETTLE_CFLAGS@ NETTLE_LIBS = @NETTLE_LIBS@ NETWORK_LIBS = @NETWORK_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ODBC = @ODBC@ ODBCINSTLIB = @ODBCINSTLIB@ ODBCLIB = @ODBCLIB@ ODBCNODMLIB = @ODBCNODMLIB@ ODBCNODMLIBAPP = @ODBCNODMLIBAPP@ ODBC_CONFIG = @ODBC_CONFIG@ ODBC_INC = @ODBC_INC@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ RC = @RC@ READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SUBVERSION = @SUBVERSION@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ dblib_define = @dblib_define@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ tds_sysdep_int16_type = @tds_sysdep_int16_type@ tds_sysdep_int32_type = @tds_sysdep_int32_type@ tds_sysdep_int64_type = @tds_sysdep_int64_type@ tds_sysdep_intptr_type = @tds_sysdep_intptr_type@ tds_sysdep_real32_type = @tds_sysdep_real32_type@ tds_sysdep_real64_type = @tds_sysdep_real64_type@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ TESTS = t0001$(EXEEXT) t0002$(EXEEXT) t0003$(EXEEXT) t0004$(EXEEXT) \ t0005$(EXEEXT) t0006$(EXEEXT) t0007$(EXEEXT) t0008$(EXEEXT) \ t0009$(EXEEXT) connect_fail$(EXEEXT) ct_options$(EXEEXT) \ lang_ct_param$(EXEEXT) array_bind$(EXEEXT) cs_diag$(EXEEXT) \ get_send_data$(EXEEXT) rpc_ct_param$(EXEEXT) rpc_ct_setparam$(EXEEXT) \ ct_diagclient$(EXEEXT) ct_diagserver$(EXEEXT) ct_diagall$(EXEEXT) \ cs_config$(EXEEXT) cancel$(EXEEXT) blk_in$(EXEEXT) \ blk_out$(EXEEXT) ct_cursor$(EXEEXT) ct_cursors$(EXEEXT) \ ct_dynamic$(EXEEXT) blk_in2$(EXEEXT) datafmt$(EXEEXT) \ rpc_fail$(EXEEXT) row_count$(EXEEXT) check_PROGRAMS = $(TESTS) t0001_SOURCES = t0001.c common.c common.h t0002_SOURCES = t0002.c common.c common.h t0003_SOURCES = t0003.c common.c common.h t0004_SOURCES = t0004.c common.c common.h t0005_SOURCES = t0005.c common.c common.h t0006_SOURCES = t0006.c t0007_SOURCES = t0007.c common.c common.h t0008_SOURCES = t0008.c common.c common.h t0009_SOURCES = t0009.c common.c common.h connect_fail_SOURCES = connect_fail.c common.c common.h ct_options_SOURCES = ct_options.c common.c common.h lang_ct_param_SOURCES = lang_ct_param.c common.c common.h array_bind_SOURCES = array_bind.c common.c common.h cs_diag_SOURCES = cs_diag.c common.c common.h get_send_data_SOURCES = get_send_data.c common.c common.h rpc_ct_param_SOURCES = rpc_ct_param.c common.c common.h rpc_ct_setparam_SOURCES = rpc_ct_setparam.c common.c common.h ct_diagclient_SOURCES = ct_diagclient.c common.c common.h ct_diagserver_SOURCES = ct_diagserver.c common.c common.h ct_diagall_SOURCES = ct_diagall.c common.c common.h cs_config_SOURCES = cs_config.c common.c common.h cancel_SOURCES = cancel.c common.c common.h blk_in_SOURCES = blk_in.h blk_in.c common.c common.h blk_out_SOURCES = blk_out.c common.c common.h ct_cursor_SOURCES = ct_cursor.c common.c common.h ct_cursors_SOURCES = ct_cursors.c common.c common.h ct_dynamic_SOURCES = ct_dynamic.c common.c common.h blk_in2_SOURCES = blk_in2.c common.c common.h datafmt_SOURCES = datafmt.c common.c common.h rpc_fail_SOURCES = rpc_fail.c common.c common.h row_count_SOURCES = row_count.c common.c common.h AM_CPPFLAGS = -I$(top_srcdir)/include @MINGW32_FALSE@AM_LDFLAGS = -no-install -L../.libs -R $(abs_builddir)/../.libs @MINGW32_TRUE@AM_LDFLAGS = -no-fast-install CLEANFILES = tdsdump.out EXTRA_DIST = CMakeLists.txt all: all-am .SUFFIXES: .SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/ctlib/unittests/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/ctlib/unittests/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-checkPROGRAMS: @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list array_bind$(EXEEXT): $(array_bind_OBJECTS) $(array_bind_DEPENDENCIES) $(EXTRA_array_bind_DEPENDENCIES) @rm -f array_bind$(EXEEXT) $(AM_V_CCLD)$(LINK) $(array_bind_OBJECTS) $(array_bind_LDADD) $(LIBS) blk_in$(EXEEXT): $(blk_in_OBJECTS) $(blk_in_DEPENDENCIES) $(EXTRA_blk_in_DEPENDENCIES) @rm -f blk_in$(EXEEXT) $(AM_V_CCLD)$(LINK) $(blk_in_OBJECTS) $(blk_in_LDADD) $(LIBS) blk_in2$(EXEEXT): $(blk_in2_OBJECTS) $(blk_in2_DEPENDENCIES) $(EXTRA_blk_in2_DEPENDENCIES) @rm -f blk_in2$(EXEEXT) $(AM_V_CCLD)$(LINK) $(blk_in2_OBJECTS) $(blk_in2_LDADD) $(LIBS) blk_out$(EXEEXT): $(blk_out_OBJECTS) $(blk_out_DEPENDENCIES) $(EXTRA_blk_out_DEPENDENCIES) @rm -f blk_out$(EXEEXT) $(AM_V_CCLD)$(LINK) $(blk_out_OBJECTS) $(blk_out_LDADD) $(LIBS) cancel$(EXEEXT): $(cancel_OBJECTS) $(cancel_DEPENDENCIES) $(EXTRA_cancel_DEPENDENCIES) @rm -f cancel$(EXEEXT) $(AM_V_CCLD)$(LINK) $(cancel_OBJECTS) $(cancel_LDADD) $(LIBS) connect_fail$(EXEEXT): $(connect_fail_OBJECTS) $(connect_fail_DEPENDENCIES) $(EXTRA_connect_fail_DEPENDENCIES) @rm -f connect_fail$(EXEEXT) $(AM_V_CCLD)$(LINK) $(connect_fail_OBJECTS) $(connect_fail_LDADD) $(LIBS) cs_config$(EXEEXT): $(cs_config_OBJECTS) $(cs_config_DEPENDENCIES) $(EXTRA_cs_config_DEPENDENCIES) @rm -f cs_config$(EXEEXT) $(AM_V_CCLD)$(LINK) $(cs_config_OBJECTS) $(cs_config_LDADD) $(LIBS) cs_diag$(EXEEXT): $(cs_diag_OBJECTS) $(cs_diag_DEPENDENCIES) $(EXTRA_cs_diag_DEPENDENCIES) @rm -f cs_diag$(EXEEXT) $(AM_V_CCLD)$(LINK) $(cs_diag_OBJECTS) $(cs_diag_LDADD) $(LIBS) ct_cursor$(EXEEXT): $(ct_cursor_OBJECTS) $(ct_cursor_DEPENDENCIES) $(EXTRA_ct_cursor_DEPENDENCIES) @rm -f ct_cursor$(EXEEXT) $(AM_V_CCLD)$(LINK) $(ct_cursor_OBJECTS) $(ct_cursor_LDADD) $(LIBS) ct_cursors$(EXEEXT): $(ct_cursors_OBJECTS) $(ct_cursors_DEPENDENCIES) $(EXTRA_ct_cursors_DEPENDENCIES) @rm -f ct_cursors$(EXEEXT) $(AM_V_CCLD)$(LINK) $(ct_cursors_OBJECTS) $(ct_cursors_LDADD) $(LIBS) ct_diagall$(EXEEXT): $(ct_diagall_OBJECTS) $(ct_diagall_DEPENDENCIES) $(EXTRA_ct_diagall_DEPENDENCIES) @rm -f ct_diagall$(EXEEXT) $(AM_V_CCLD)$(LINK) $(ct_diagall_OBJECTS) $(ct_diagall_LDADD) $(LIBS) ct_diagclient$(EXEEXT): $(ct_diagclient_OBJECTS) $(ct_diagclient_DEPENDENCIES) $(EXTRA_ct_diagclient_DEPENDENCIES) @rm -f ct_diagclient$(EXEEXT) $(AM_V_CCLD)$(LINK) $(ct_diagclient_OBJECTS) $(ct_diagclient_LDADD) $(LIBS) ct_diagserver$(EXEEXT): $(ct_diagserver_OBJECTS) $(ct_diagserver_DEPENDENCIES) $(EXTRA_ct_diagserver_DEPENDENCIES) @rm -f ct_diagserver$(EXEEXT) $(AM_V_CCLD)$(LINK) $(ct_diagserver_OBJECTS) $(ct_diagserver_LDADD) $(LIBS) ct_dynamic$(EXEEXT): $(ct_dynamic_OBJECTS) $(ct_dynamic_DEPENDENCIES) $(EXTRA_ct_dynamic_DEPENDENCIES) @rm -f ct_dynamic$(EXEEXT) $(AM_V_CCLD)$(LINK) $(ct_dynamic_OBJECTS) $(ct_dynamic_LDADD) $(LIBS) ct_options$(EXEEXT): $(ct_options_OBJECTS) $(ct_options_DEPENDENCIES) $(EXTRA_ct_options_DEPENDENCIES) @rm -f ct_options$(EXEEXT) $(AM_V_CCLD)$(LINK) $(ct_options_OBJECTS) $(ct_options_LDADD) $(LIBS) datafmt$(EXEEXT): $(datafmt_OBJECTS) $(datafmt_DEPENDENCIES) $(EXTRA_datafmt_DEPENDENCIES) @rm -f datafmt$(EXEEXT) $(AM_V_CCLD)$(LINK) $(datafmt_OBJECTS) $(datafmt_LDADD) $(LIBS) get_send_data$(EXEEXT): $(get_send_data_OBJECTS) $(get_send_data_DEPENDENCIES) $(EXTRA_get_send_data_DEPENDENCIES) @rm -f get_send_data$(EXEEXT) $(AM_V_CCLD)$(LINK) $(get_send_data_OBJECTS) $(get_send_data_LDADD) $(LIBS) lang_ct_param$(EXEEXT): $(lang_ct_param_OBJECTS) $(lang_ct_param_DEPENDENCIES) $(EXTRA_lang_ct_param_DEPENDENCIES) @rm -f lang_ct_param$(EXEEXT) $(AM_V_CCLD)$(LINK) $(lang_ct_param_OBJECTS) $(lang_ct_param_LDADD) $(LIBS) row_count$(EXEEXT): $(row_count_OBJECTS) $(row_count_DEPENDENCIES) $(EXTRA_row_count_DEPENDENCIES) @rm -f row_count$(EXEEXT) $(AM_V_CCLD)$(LINK) $(row_count_OBJECTS) $(row_count_LDADD) $(LIBS) rpc_ct_param$(EXEEXT): $(rpc_ct_param_OBJECTS) $(rpc_ct_param_DEPENDENCIES) $(EXTRA_rpc_ct_param_DEPENDENCIES) @rm -f rpc_ct_param$(EXEEXT) $(AM_V_CCLD)$(LINK) $(rpc_ct_param_OBJECTS) $(rpc_ct_param_LDADD) $(LIBS) rpc_ct_setparam$(EXEEXT): $(rpc_ct_setparam_OBJECTS) $(rpc_ct_setparam_DEPENDENCIES) $(EXTRA_rpc_ct_setparam_DEPENDENCIES) @rm -f rpc_ct_setparam$(EXEEXT) $(AM_V_CCLD)$(LINK) $(rpc_ct_setparam_OBJECTS) $(rpc_ct_setparam_LDADD) $(LIBS) rpc_fail$(EXEEXT): $(rpc_fail_OBJECTS) $(rpc_fail_DEPENDENCIES) $(EXTRA_rpc_fail_DEPENDENCIES) @rm -f rpc_fail$(EXEEXT) $(AM_V_CCLD)$(LINK) $(rpc_fail_OBJECTS) $(rpc_fail_LDADD) $(LIBS) t0001$(EXEEXT): $(t0001_OBJECTS) $(t0001_DEPENDENCIES) $(EXTRA_t0001_DEPENDENCIES) @rm -f t0001$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0001_OBJECTS) $(t0001_LDADD) $(LIBS) t0002$(EXEEXT): $(t0002_OBJECTS) $(t0002_DEPENDENCIES) $(EXTRA_t0002_DEPENDENCIES) @rm -f t0002$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0002_OBJECTS) $(t0002_LDADD) $(LIBS) t0003$(EXEEXT): $(t0003_OBJECTS) $(t0003_DEPENDENCIES) $(EXTRA_t0003_DEPENDENCIES) @rm -f t0003$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0003_OBJECTS) $(t0003_LDADD) $(LIBS) t0004$(EXEEXT): $(t0004_OBJECTS) $(t0004_DEPENDENCIES) $(EXTRA_t0004_DEPENDENCIES) @rm -f t0004$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0004_OBJECTS) $(t0004_LDADD) $(LIBS) t0005$(EXEEXT): $(t0005_OBJECTS) $(t0005_DEPENDENCIES) $(EXTRA_t0005_DEPENDENCIES) @rm -f t0005$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0005_OBJECTS) $(t0005_LDADD) $(LIBS) t0006$(EXEEXT): $(t0006_OBJECTS) $(t0006_DEPENDENCIES) $(EXTRA_t0006_DEPENDENCIES) @rm -f t0006$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0006_OBJECTS) $(t0006_LDADD) $(LIBS) t0007$(EXEEXT): $(t0007_OBJECTS) $(t0007_DEPENDENCIES) $(EXTRA_t0007_DEPENDENCIES) @rm -f t0007$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0007_OBJECTS) $(t0007_LDADD) $(LIBS) t0008$(EXEEXT): $(t0008_OBJECTS) $(t0008_DEPENDENCIES) $(EXTRA_t0008_DEPENDENCIES) @rm -f t0008$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0008_OBJECTS) $(t0008_LDADD) $(LIBS) t0009$(EXEEXT): $(t0009_OBJECTS) $(t0009_DEPENDENCIES) $(EXTRA_t0009_DEPENDENCIES) @rm -f t0009$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0009_OBJECTS) $(t0009_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/array_bind.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/blk_in.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/blk_in2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/blk_out.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cancel.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/common.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/connect_fail.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cs_config.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cs_diag.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ct_cursor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ct_cursors.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ct_diagall.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ct_diagclient.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ct_diagserver.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ct_dynamic.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ct_options.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/datafmt.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/get_send_data.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lang_ct_param.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/row_count.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rpc_ct_param.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rpc_ct_setparam.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rpc_fail.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0001.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0002.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0003.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0004.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0005.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0006.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0007.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0008.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0009.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags # Recover from deleted '.trs' file; this should ensure that # "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create # both 'foo.log' and 'foo.trs'. Break the recipe in two subshells # to avoid problems with "make -n". .log.trs: rm -f $< $@ $(MAKE) $(AM_MAKEFLAGS) $< # Leading 'am--fnord' is there to ensure the list of targets does not # expand to empty, as could happen e.g. with make check TESTS=''. am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) am--force-recheck: @: $(TEST_SUITE_LOG): $(TEST_LOGS) @$(am__set_TESTS_bases); \ am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ redo_bases=`for i in $$bases; do \ am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ done`; \ if test -n "$$redo_bases"; then \ redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ if $(am__make_dryrun); then :; else \ rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ fi; \ fi; \ if test -n "$$am__remaking_logs"; then \ echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ "recursion detected" >&2; \ elif test -n "$$redo_logs"; then \ am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ fi; \ if $(am__make_dryrun); then :; else \ st=0; \ errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ for i in $$redo_bases; do \ test -f $$i.trs && test -r $$i.trs \ || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ test -f $$i.log && test -r $$i.log \ || { echo "$$errmsg $$i.log" >&2; st=1; }; \ done; \ test $$st -eq 0 || exit 1; \ fi @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ ws='[ ]'; \ results=`for b in $$bases; do echo $$b.trs; done`; \ test -n "$$results" || results=/dev/null; \ all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ if test `expr $$fail + $$xpass + $$error` -eq 0; then \ success=true; \ else \ success=false; \ fi; \ br='==================='; br=$$br$$br$$br$$br; \ result_count () \ { \ if test x"$$1" = x"--maybe-color"; then \ maybe_colorize=yes; \ elif test x"$$1" = x"--no-color"; then \ maybe_colorize=no; \ else \ echo "$@: invalid 'result_count' usage" >&2; exit 4; \ fi; \ shift; \ desc=$$1 count=$$2; \ if test $$maybe_colorize = yes && test $$count -gt 0; then \ color_start=$$3 color_end=$$std; \ else \ color_start= color_end=; \ fi; \ echo "$${color_start}# $$desc $$count$${color_end}"; \ }; \ create_testsuite_report () \ { \ result_count $$1 "TOTAL:" $$all "$$brg"; \ result_count $$1 "PASS: " $$pass "$$grn"; \ result_count $$1 "SKIP: " $$skip "$$blu"; \ result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ result_count $$1 "FAIL: " $$fail "$$red"; \ result_count $$1 "XPASS:" $$xpass "$$red"; \ result_count $$1 "ERROR:" $$error "$$mgn"; \ }; \ { \ echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ $(am__rst_title); \ create_testsuite_report --no-color; \ echo; \ echo ".. contents:: :depth: 2"; \ echo; \ for b in $$bases; do echo $$b; done \ | $(am__create_global_log); \ } >$(TEST_SUITE_LOG).tmp || exit 1; \ mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ if $$success; then \ col="$$grn"; \ else \ col="$$red"; \ test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ fi; \ echo "$${col}$$br$${std}"; \ echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ echo "$${col}$$br$${std}"; \ create_testsuite_report --maybe-color; \ echo "$$col$$br$$std"; \ if $$success; then :; else \ echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ if test -n "$(PACKAGE_BUGREPORT)"; then \ echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ fi; \ echo "$$col$$br$$std"; \ fi; \ $$success || exit 1 check-TESTS: @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ log_list=`for i in $$bases; do echo $$i.log; done`; \ trs_list=`for i in $$bases; do echo $$i.trs; done`; \ log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ exit $$?; recheck: all $(check_PROGRAMS) @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ bases=`for i in $$bases; do echo $$i; done \ | $(am__list_recheck_tests)` || exit 1; \ log_list=`for i in $$bases; do echo $$i.log; done`; \ log_list=`echo $$log_list`; \ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ am__force_recheck=am--force-recheck \ TEST_LOGS="$$log_list"; \ exit $$? t0001.log: t0001$(EXEEXT) @p='t0001$(EXEEXT)'; \ b='t0001'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0002.log: t0002$(EXEEXT) @p='t0002$(EXEEXT)'; \ b='t0002'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0003.log: t0003$(EXEEXT) @p='t0003$(EXEEXT)'; \ b='t0003'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0004.log: t0004$(EXEEXT) @p='t0004$(EXEEXT)'; \ b='t0004'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0005.log: t0005$(EXEEXT) @p='t0005$(EXEEXT)'; \ b='t0005'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0006.log: t0006$(EXEEXT) @p='t0006$(EXEEXT)'; \ b='t0006'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0007.log: t0007$(EXEEXT) @p='t0007$(EXEEXT)'; \ b='t0007'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0008.log: t0008$(EXEEXT) @p='t0008$(EXEEXT)'; \ b='t0008'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0009.log: t0009$(EXEEXT) @p='t0009$(EXEEXT)'; \ b='t0009'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) connect_fail.log: connect_fail$(EXEEXT) @p='connect_fail$(EXEEXT)'; \ b='connect_fail'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) ct_options.log: ct_options$(EXEEXT) @p='ct_options$(EXEEXT)'; \ b='ct_options'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) lang_ct_param.log: lang_ct_param$(EXEEXT) @p='lang_ct_param$(EXEEXT)'; \ b='lang_ct_param'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) array_bind.log: array_bind$(EXEEXT) @p='array_bind$(EXEEXT)'; \ b='array_bind'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) cs_diag.log: cs_diag$(EXEEXT) @p='cs_diag$(EXEEXT)'; \ b='cs_diag'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) get_send_data.log: get_send_data$(EXEEXT) @p='get_send_data$(EXEEXT)'; \ b='get_send_data'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) rpc_ct_param.log: rpc_ct_param$(EXEEXT) @p='rpc_ct_param$(EXEEXT)'; \ b='rpc_ct_param'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) rpc_ct_setparam.log: rpc_ct_setparam$(EXEEXT) @p='rpc_ct_setparam$(EXEEXT)'; \ b='rpc_ct_setparam'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) ct_diagclient.log: ct_diagclient$(EXEEXT) @p='ct_diagclient$(EXEEXT)'; \ b='ct_diagclient'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) ct_diagserver.log: ct_diagserver$(EXEEXT) @p='ct_diagserver$(EXEEXT)'; \ b='ct_diagserver'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) ct_diagall.log: ct_diagall$(EXEEXT) @p='ct_diagall$(EXEEXT)'; \ b='ct_diagall'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) cs_config.log: cs_config$(EXEEXT) @p='cs_config$(EXEEXT)'; \ b='cs_config'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) cancel.log: cancel$(EXEEXT) @p='cancel$(EXEEXT)'; \ b='cancel'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) blk_in.log: blk_in$(EXEEXT) @p='blk_in$(EXEEXT)'; \ b='blk_in'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) blk_out.log: blk_out$(EXEEXT) @p='blk_out$(EXEEXT)'; \ b='blk_out'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) ct_cursor.log: ct_cursor$(EXEEXT) @p='ct_cursor$(EXEEXT)'; \ b='ct_cursor'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) ct_cursors.log: ct_cursors$(EXEEXT) @p='ct_cursors$(EXEEXT)'; \ b='ct_cursors'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) ct_dynamic.log: ct_dynamic$(EXEEXT) @p='ct_dynamic$(EXEEXT)'; \ b='ct_dynamic'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) blk_in2.log: blk_in2$(EXEEXT) @p='blk_in2$(EXEEXT)'; \ b='blk_in2'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) datafmt.log: datafmt$(EXEEXT) @p='datafmt$(EXEEXT)'; \ b='datafmt'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) rpc_fail.log: rpc_fail$(EXEEXT) @p='rpc_fail$(EXEEXT)'; \ b='rpc_fail'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) row_count.log: row_count$(EXEEXT) @p='row_count$(EXEEXT)'; \ b='row_count'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) .test.log: @p='$<'; \ $(am__set_b); \ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) @am__EXEEXT_TRUE@.test$(EXEEXT).log: @am__EXEEXT_TRUE@ @p='$<'; \ @am__EXEEXT_TRUE@ $(am__set_b); \ @am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ @am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ @am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ @am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-am all-am: Makefile installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: check-am install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am clean \ clean-checkPROGRAMS clean-generic clean-libtool cscopelist-am \ ctags ctags-am distclean distclean-compile distclean-generic \ 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-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 \ recheck tags tags-am uninstall uninstall-am .PRECIOUS: Makefile # 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: freetds-1.00.82/src/ctlib/unittests/array_bind.c100644 025423 025423 00000011706 12717145107 0015244#include #include #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include "common.h" /* Testing: array binding of result set */ int main(int argc, char *argv[]) { CS_CONTEXT *ctx; CS_CONNECTION *conn; CS_COMMAND *cmd; int verbose = 0; CS_RETCODE ret; CS_RETCODE results_ret; CS_INT result_type; CS_INT num_cols; CS_DATAFMT datafmt; CS_INT datalength[2]; CS_SMALLINT ind[2]; CS_INT count, row_count = 0; CS_INT cv; CS_CHAR select[1024]; CS_INT col1[2]; CS_CHAR col2[2][5]; CS_CHAR col3[2][32]; fprintf(stdout, "%s: Retrieve data using array binding \n", __FILE__); if (verbose) { fprintf(stdout, "Trying login\n"); } ret = try_ctlogin(&ctx, &conn, &cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Login failed\n"); return 1; } ret = run_command(cmd, "CREATE TABLE #ctlibarray (col1 int not null, col2 char(4) not null, col3 datetime not null)"); if (ret != CS_SUCCEED) return 1; ret = run_command(cmd, "insert into #ctlibarray values (1, 'AAAA', 'Jan 1 2002 10:00:00AM')"); if (ret != CS_SUCCEED) return 1; ret = run_command(cmd, "insert into #ctlibarray values (2, 'BBBB', 'Jan 2 2002 10:00:00AM')"); if (ret != CS_SUCCEED) return 1; ret = run_command(cmd, "insert into #ctlibarray values (3, 'CCCC', 'Jan 3 2002 10:00:00AM')"); if (ret != CS_SUCCEED) return 1; ret = run_command(cmd, "insert into #ctlibarray values (8, 'DDDD', 'Jan 4 2002 10:00:00AM')"); if (ret != CS_SUCCEED) return 1; ret = run_command(cmd, "insert into #ctlibarray values (9, 'EEEE', 'Jan 5 2002 10:00:00AM')"); if (ret != CS_SUCCEED) return 1; strcpy(select, "select col1, col2, col3 from #ctlibarray order by col1 "); ret = ct_command(cmd, CS_LANG_CMD, select, CS_NULLTERM, CS_UNUSED); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_command(%s) failed\n", select); return 1; } ret = ct_send(cmd); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_send() failed\n"); return 1; } while ((results_ret = ct_results(cmd, &result_type)) == CS_SUCCEED) { switch ((int) result_type) { case CS_CMD_SUCCEED: break; case CS_CMD_DONE: break; case CS_CMD_FAIL: fprintf(stderr, "ct_results() result_type CS_CMD_FAIL.\n"); return 1; case CS_ROW_RESULT: ret = ct_res_info(cmd, CS_NUMDATA, &num_cols, CS_UNUSED, NULL); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_res_info() failed"); return 1; } if (num_cols != 3) { fprintf(stderr, "num_cols %d != 3", num_cols); return 1; } ret = ct_describe(cmd, 1, &datafmt); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_describe() failed"); return 1; } datafmt.format = CS_FMT_UNUSED; if (datafmt.maxlength > 1024) { datafmt.maxlength = 1024; } datafmt.count = 2; ret = ct_bind(cmd, 1, &datafmt, &col1[0], datalength, ind); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_bind() failed\n"); return 1; } ret = ct_describe(cmd, 2, &datafmt); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_describe() failed"); return 1; } datafmt.format = CS_FMT_NULLTERM; datafmt.maxlength = 5; datafmt.count = 2; ret = ct_bind(cmd, 2, &datafmt, &col2[0], datalength, ind); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_bind() failed\n"); return 1; } ret = ct_describe(cmd, 3, &datafmt); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_describe() failed"); return 1; } datafmt.datatype = CS_CHAR_TYPE; datafmt.format = CS_FMT_NULLTERM; datafmt.maxlength = 32; datafmt.count = 2; ret = ct_bind(cmd, 3, &datafmt, &col3[0], datalength, ind); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_bind() failed\n"); return 1; } count = 0; while (((ret = ct_fetch(cmd, CS_UNUSED, CS_UNUSED, CS_UNUSED, &count)) == CS_SUCCEED) || (ret == CS_ROW_FAIL)) { row_count += count; if (ret == CS_ROW_FAIL) { fprintf(stderr, "ct_fetch() CS_ROW_FAIL on row %d.\n", row_count); return 1; } else { /* ret == CS_SUCCEED */ fprintf(stdout, "ct_fetch returned %d rows\n", count); for (cv = 0; cv < count; cv++) fprintf(stdout, "col1 = %d col2= '%s', col3 = '%s'\n", col1[cv], col2[cv], col3[cv]); } count = 0; } switch ((int) ret) { case CS_END_DATA: break; case CS_FAIL: fprintf(stderr, "ct_fetch() returned CS_FAIL.\n"); return 1; default: fprintf(stderr, "ct_fetch() unexpected return.\n"); return 1; } break; default: fprintf(stderr, "ct_results() unexpected result_type.\n"); return 1; } } switch ((int) results_ret) { case CS_END_RESULTS: break; case CS_FAIL: fprintf(stderr, "ct_results() failed.\n"); return 1; break; default: fprintf(stderr, "ct_results() unexpected return.\n"); return 1; } if (verbose) { fprintf(stdout, "Trying logout\n"); } ret = try_ctlogout(ctx, conn, cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Logout failed\n"); return 1; } return 0; } freetds-1.00.82/src/ctlib/unittests/common.c100644 025423 025423 00000023517 12717145107 0014425#include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_UNISTD_H #include #endif #ifndef DBNTWIN32 #include "replacements.h" #endif #include #include "common.h" #ifdef TDS_STATIC_CAST #include "ctlib.h" #endif char USER[512]; char SERVER[512]; char PASSWORD[512]; char DATABASE[512]; COMMON_PWD common_pwd = {0}; static char *DIRNAME = NULL; static const char *BASENAME = NULL; static const char *PWD = "../../../PWD"; int cslibmsg_cb_invoked = 0; int clientmsg_cb_invoked = 0; int servermsg_cb_invoked = 0; static CS_RETCODE continue_logging_in(CS_CONTEXT ** ctx, CS_CONNECTION ** conn, CS_COMMAND ** cmd, int verbose); #if defined(__MINGW32__) || defined(_MSC_VER) static char * tds_dirname(char* path) { char *p, *p2; for (p = path + strlen(path); --p > path && (*p == '/' || *p == '\\');) *p = '\0'; p = strrchr(path, '/'); if (!p) p = path; p2 = strrchr(p, '\\'); if (p2) p = p2; *p = 0; return path; } #define dirname tds_dirname #endif CS_RETCODE read_login_info(void) { FILE *in = NULL; char line[512]; char *s1, *s2; if (common_pwd.initialized) { strcpy(USER, common_pwd.USER); strcpy(PASSWORD, common_pwd.PASSWORD); strcpy(SERVER, common_pwd.SERVER); strcpy(DATABASE, common_pwd.DATABASE); return CS_SUCCEED; } s1 = getenv("TDSPWDFILE"); if (s1 && s1[0]) in = fopen(s1, "r"); if (!in) in = fopen(PWD, "r"); if (!in) { fprintf(stderr, "Can not open PWD file \"%s\"\n\n", PWD); return CS_FAIL; } while (fgets(line, 512, in)) { s1 = strtok(line, "="); s2 = strtok(NULL, "\n"); if (!s1 || !s2) { continue; } if (!strcmp(s1, "UID")) { strcpy(USER, s2); } else if (!strcmp(s1, "SRV")) { strcpy(SERVER, s2); } else if (!strcmp(s1, "PWD")) { strcpy(PASSWORD, s2); } else if (!strcmp(s1, "DB")) { strcpy(DATABASE, s2); } } fclose(in); return CS_SUCCEED; } static CS_RETCODE establish_login(int argc, char **argv) { extern char *optarg; extern int optind; COMMON_PWD options = {0}; #if !defined(__MINGW32__) && !defined(_MSC_VER) int ch; #endif BASENAME = basename((char *)argv[0]); DIRNAME = dirname((char *)argv[0]); #if !defined(__MINGW32__) && !defined(_MSC_VER) /* process command line options (handy for manual testing) */ while ((ch = getopt(argc, argv, "U:P:S:D:f:m:v")) != -1) { switch (ch) { case 'U': strcpy(options.USER, optarg); break; case 'P': strcpy(options.PASSWORD, optarg); break; case 'S': strcpy(options.SERVER, optarg); break; case 'D': strcpy(options.DATABASE, optarg); break; case 'f': /* override default PWD file */ PWD = strdup(optarg); break; case 'm': common_pwd.maxlength = strtol(optarg, NULL, 10); case 'v': common_pwd.fverbose = 1; break; case '?': default: fprintf(stderr, "usage: %s [-v] [-f PWD]\n" " [-U username] [-P password]\n" " [-S servername] [-D database]\n" , BASENAME); exit(1); } } #endif read_login_info(); /* override PWD file with command-line options */ if (*options.USER) strcpy(USER, options.USER); if (*options.PASSWORD) strcpy(PASSWORD, options.PASSWORD); if (*options.SERVER) strcpy(SERVER, options.SERVER); if (*options.DATABASE) strcpy(DATABASE, options.DATABASE); return (*USER && *SERVER && *DATABASE)? CS_SUCCEED : CS_FAIL; } CS_RETCODE try_ctlogin_with_options(int argc, char **argv, CS_CONTEXT ** ctx, CS_CONNECTION ** conn, CS_COMMAND ** cmd, int verbose) { CS_RETCODE ret; if ((ret = establish_login(argc, argv)) != CS_SUCCEED) { if (verbose) { fprintf(stderr, "read_login_info() failed!\n"); } return ret; } return continue_logging_in(ctx, conn, cmd, verbose); } /* old way: because I'm too lazy to change every unit test */ CS_RETCODE try_ctlogin(CS_CONTEXT ** ctx, CS_CONNECTION ** conn, CS_COMMAND ** cmd, int verbose) { CS_RETCODE ret; if ((ret = read_login_info()) != CS_SUCCEED) { if (verbose) { fprintf(stderr, "read_login_info() failed!\n"); } return ret; } return continue_logging_in(ctx, conn, cmd, verbose); } CS_RETCODE continue_logging_in(CS_CONTEXT ** ctx, CS_CONNECTION ** conn, CS_COMMAND ** cmd, int verbose) { CS_RETCODE ret; char query[30]; #ifdef TDS_STATIC_CAST TDSCONTEXT *tds_ctx; #endif ret = cs_ctx_alloc(CS_VERSION_100, ctx); if (ret != CS_SUCCEED) { if (verbose) { fprintf(stderr, "Context Alloc failed!\n"); } return ret; } #ifdef TDS_STATIC_CAST /* Force default date format, some tests rely on it */ tds_ctx = (TDSCONTEXT *) (*ctx)->tds_ctx; if (tds_ctx && tds_ctx->locale && tds_ctx->locale->date_fmt) { free(tds_ctx->locale->date_fmt); tds_ctx->locale->date_fmt = strdup("%b %d %Y %I:%M%p"); } #endif ret = ct_init(*ctx, CS_VERSION_100); if (ret != CS_SUCCEED) { if (verbose) { fprintf(stderr, "Library Init failed!\n"); } return ret; } if ((ret = ct_callback(*ctx, NULL, CS_SET, CS_CLIENTMSG_CB, (CS_VOID*) clientmsg_cb)) != CS_SUCCEED) { fprintf(stderr, "ct_callback() failed\n"); return ret; } if ((ret = ct_callback(*ctx, NULL, CS_SET, CS_SERVERMSG_CB, servermsg_cb)) != CS_SUCCEED) { fprintf(stderr, "ct_callback() failed\n"); return ret; } ret = ct_con_alloc(*ctx, conn); if (ret != CS_SUCCEED) { if (verbose) { fprintf(stderr, "Connect Alloc failed!\n"); } return ret; } ret = ct_con_props(*conn, CS_SET, CS_USERNAME, USER, CS_NULLTERM, NULL); if (ret != CS_SUCCEED) { if (verbose) { fprintf(stderr, "ct_con_props() SET USERNAME failed!\n"); } return ret; } ret = ct_con_props(*conn, CS_SET, CS_PASSWORD, PASSWORD, CS_NULLTERM, NULL); if (ret != CS_SUCCEED) { if (verbose) { fprintf(stderr, "ct_con_props() SET PASSWORD failed!\n"); } return ret; } printf("connecting as %s to %s.%s\n", USER, SERVER, DATABASE); ret = ct_connect(*conn, SERVER, CS_NULLTERM); if (ret != CS_SUCCEED) { if (verbose) { fprintf(stderr, "Connection failed!\n"); } ct_con_drop(*conn); *conn = NULL; cs_ctx_drop(*ctx); *ctx = NULL; return ret; } ret = ct_cmd_alloc(*conn, cmd); if (ret != CS_SUCCEED) { if (verbose) { fprintf(stderr, "Command Alloc failed!\n"); } ct_con_drop(*conn); *conn = NULL; cs_ctx_drop(*ctx); *ctx = NULL; return ret; } strcpy(query, "use "); strncat(query, DATABASE, 20); ret = run_command(*cmd, query); if (ret != CS_SUCCEED) return ret; return CS_SUCCEED; } CS_RETCODE try_ctlogout(CS_CONTEXT * ctx, CS_CONNECTION * conn, CS_COMMAND * cmd, int verbose) { CS_RETCODE ret; ret = ct_cancel(conn, NULL, CS_CANCEL_ALL); if (ret != CS_SUCCEED) { if (verbose) { fprintf(stderr, "ct_cancel() failed!\n"); } return ret; } ct_cmd_drop(cmd); ct_close(conn, CS_UNUSED); ct_con_drop(conn); ct_exit(ctx, CS_UNUSED); cs_ctx_drop(ctx); return CS_SUCCEED; } /* Run commands from which we expect no results returned */ CS_RETCODE run_command(CS_COMMAND * cmd, const char *sql) { CS_RETCODE ret, results_ret; CS_INT result_type; if (cmd == NULL) { return CS_FAIL; } ret = ct_command(cmd, CS_LANG_CMD, sql, CS_NULLTERM, CS_UNUSED); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_command() failed\n"); return ret; } ret = ct_send(cmd); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_send() failed\n"); return ret; } while ((results_ret = ct_results(cmd, &result_type)) == CS_SUCCEED) { switch ((int) result_type) { case CS_CMD_SUCCEED: break; case CS_CMD_DONE: break; case CS_CMD_FAIL: fprintf(stderr, "ct_results() result_type CS_CMD_FAIL.\n"); /* return CS_FAIL; */ break; default: fprintf(stderr, "ct_results() unexpected result_type.\n"); return CS_FAIL; } } switch ((int) results_ret) { case CS_END_RESULTS: break; case CS_FAIL: fprintf(stderr, "ct_results() failed.\n"); return CS_FAIL; break; default: fprintf(stderr, "ct_results() unexpected return.\n"); return CS_FAIL; } return CS_SUCCEED; } CS_INT cslibmsg_cb(CS_CONTEXT * connection, CS_CLIENTMSG * errmsg) { cslibmsg_cb_invoked++; fprintf(stderr, "\nCS-Library Message:\n"); fprintf(stderr, "number %d layer %d origin %d severity %d number %d\n", errmsg->msgnumber, CS_LAYER(errmsg->msgnumber), CS_ORIGIN(errmsg->msgnumber), CS_SEVERITY(errmsg->msgnumber), CS_NUMBER(errmsg->msgnumber)); fprintf(stderr, "msgstring: %s\n", errmsg->msgstring); fprintf(stderr, "osstring: %s\n", (errmsg->osstringlen > 0) ? errmsg->osstring : "(null)"); return CS_SUCCEED; } CS_RETCODE clientmsg_cb(CS_CONTEXT * context, CS_CONNECTION * connection, CS_CLIENTMSG * errmsg) { clientmsg_cb_invoked++; fprintf(stderr, "\nOpen Client Message:\n"); fprintf(stderr, "number %d layer %d origin %d severity %d number %d\n", errmsg->msgnumber, CS_LAYER(errmsg->msgnumber), CS_ORIGIN(errmsg->msgnumber), CS_SEVERITY(errmsg->msgnumber), CS_NUMBER(errmsg->msgnumber)); fprintf(stderr, "msgstring: %s\n", errmsg->msgstring); fprintf(stderr, "osstring: %s\n", (errmsg->osstringlen > 0) ? errmsg->osstring : "(null)"); return CS_SUCCEED; } CS_RETCODE servermsg_cb(CS_CONTEXT * context, CS_CONNECTION * connection, CS_SERVERMSG * srvmsg) { servermsg_cb_invoked++; if (srvmsg->msgnumber == 5701 || srvmsg->msgnumber == 5703) { fprintf(stderr, "%s\n", srvmsg->text); return CS_SUCCEED; } fprintf(stderr, "%s Message %d severity %d state %d line %d:\n", srvmsg->svrnlen > 0? srvmsg->svrname : "Server", srvmsg->msgnumber, srvmsg->severity, srvmsg->state, srvmsg->line); if (srvmsg->proclen > 0) fprintf(stderr, "proc %s: ", srvmsg->proc); fprintf(stderr, "\t\"%s\"\n", srvmsg->text); return CS_SUCCEED; } const char * res_type_str(CS_RETCODE ret) { static char str[64]; #define S(s) case s: return #s; switch ((int) ret) { S(CS_ROW_RESULT) S(CS_PARAM_RESULT) S(CS_STATUS_RESULT) S(CS_MSG_RESULT) S(CS_CMD_SUCCEED) S(CS_CMD_DONE) S(CS_CMD_FAIL) S(CS_COMPUTE_RESULT) #undef S } sprintf(str, "?? (%d)", (int) ret); return str; } freetds-1.00.82/src/ctlib/unittests/common.h100644 025423 025423 00000002516 12717145107 0014426 #ifndef COMMON_h #define COMMON_h static char rcsid_common_h[] = "$Id: common.h,v 1.11 2008-07-06 16:44:24 jklowden Exp $"; static void *no_unused_common_h_warn[] = { rcsid_common_h, no_unused_common_h_warn }; extern char SERVER[512]; extern char DATABASE[512]; extern char USER[512]; extern char PASSWORD[512]; typedef struct { int initialized; char SERVER[512]; char DATABASE[512]; char USER[512]; char PASSWORD[512]; char fverbose; int maxlength; } COMMON_PWD; extern COMMON_PWD common_pwd; CS_RETCODE read_login_info(void); extern int cslibmsg_cb_invoked; extern int clientmsg_cb_invoked; extern int servermsg_cb_invoked; CS_RETCODE try_ctlogin(CS_CONTEXT ** ctx, CS_CONNECTION ** conn, CS_COMMAND ** cmd, int verbose); CS_RETCODE try_ctlogin_with_options(int argc, char **argv, CS_CONTEXT ** ctx, CS_CONNECTION ** conn, CS_COMMAND ** cmd, int verbose); CS_RETCODE try_ctlogout(CS_CONTEXT * ctx, CS_CONNECTION * conn, CS_COMMAND * cmd, int verbose); CS_RETCODE run_command(CS_COMMAND * cmd, const char *sql); CS_RETCODE cslibmsg_cb(CS_CONTEXT * connection, CS_CLIENTMSG * errmsg); CS_RETCODE clientmsg_cb(CS_CONTEXT * context, CS_CONNECTION * connection, CS_CLIENTMSG * errmsg); CS_RETCODE servermsg_cb(CS_CONTEXT * context, CS_CONNECTION * connection, CS_SERVERMSG * srvmsg); const char *res_type_str(CS_RETCODE ret); #endif freetds-1.00.82/src/ctlib/unittests/blk_in.h100644 025423 025423 00000006625 12522201763 0014374char create_table_sql[] = "CREATE TABLE all_types_bcp_unittest (\n" " not_null_bit bit NOT NULL\n" "\n" " , not_null_char char(10) NOT NULL\n" " , not_null_varchar varchar(10) NOT NULL\n" "\n" " , not_null_datetime datetime NOT NULL\n" " , not_null_smalldatetime smalldatetime NOT NULL\n" "\n" " , not_null_money money NOT NULL\n" " , not_null_smallmoney smallmoney NOT NULL\n" "\n" " , not_null_float float NOT NULL\n" " , not_null_real real NOT NULL\n" "\n" " , not_null_decimal decimal(5,2) NOT NULL\n" " , not_null_numeric numeric(5,2) NOT NULL\n" "\n" " , not_null_int int NOT NULL\n" " , not_null_smallint smallint NOT NULL\n" " , not_null_tinyint tinyint NOT NULL\n" "\n" " , nullable_char char(10) NULL\n" " , nullable_varchar varchar(10) NULL\n" "\n" " , nullable_datetime datetime NULL\n" " , nullable_smalldatetime smalldatetime NULL\n" "\n" " , nullable_money money NULL\n" " , nullable_smallmoney smallmoney NULL\n" "\n" " , nullable_float float NULL\n" " , nullable_real real NULL\n" "\n" " , nullable_decimal decimal(5,2) NULL\n" " , nullable_numeric numeric(5,2) NULL\n" "\n" " , nullable_int int NULL\n" " , nullable_smallint smallint NULL\n" " , nullable_tinyint tinyint NULL\n" "\n" " /* Excludes: \n" " * binary\n" " * image\n" " * uniqueidentifier\n" " * varbinary\n" " * text\n" " * timestamp\n" " * nchar\n" " * ntext\n" " * nvarchar\n" " */\n" ")\n" "\n" "INSERT all_types_bcp_unittest \n" "VALUES ( 1 -- not_null_bit\n" "\n" " , 'a' -- not_null_char\n" " , 'a' -- not_null_varchar\n" "\n" " , 'Dec 17 2003 3:44PM' -- not_null_datetime\n" " , 'Dec 17 2003 3:44PM' -- not_null_smalldatetime\n" "\n" " , 12.34 -- not_null_money\n" " , 12.34 -- not_null_smallmoney\n" "\n" " , 12.34 -- not_null_float\n" " , 12.34 -- not_null_real\n" "\n" " , 12.34 -- not_null_decimal\n" " , 12.34 -- not_null_numeric\n" "\n" " , 1234 -- not_null_int\n" " , 1234 -- not_null_smallint\n" " , 123 -- not_null_tinyint\n" "\n" " , 'a' -- nullable_char\n" " , 'a' -- nullable_varchar\n" "\n" " , 'Dec 17 2003 3:44PM' -- nullable_datetime\n" " , 'Dec 17 2003 3:44PM' -- nullable_smalldatetime\n" "\n" " , 12.34 -- nullable_money\n" " , 12.34 -- nullable_smallmoney\n" "\n" " , 12.34 -- nullable_float\n" " , 12.34 -- nullable_real\n" "\n" " , 12.34 -- nullable_decimal\n" " , 12.34 -- nullable_numeric\n" "\n" " , 1234 -- nullable_int\n" " , 1234 -- nullable_smallint\n" " , 123 -- nullable_tinyint\n" ")\n" "INSERT all_types_bcp_unittest\n" " ( not_null_bit \n" "\n" " , not_null_char \n" " , not_null_varchar \n" "\n" " , not_null_datetime \n" " , not_null_smalldatetime \n" "\n" " , not_null_money \n" " , not_null_smallmoney \n" "\n" " , not_null_float \n" " , not_null_real \n" "\n" " , not_null_decimal \n" " , not_null_numeric \n" "\n" " , not_null_int \n" " , not_null_smallint \n" " , not_null_tinyint \n" " ) \n" "VALUES (\n" " 1 -- not_null_bit\n" "\n" " , 'a' -- not_null_char\n" " , 'a' -- not_null_varchar\n" "\n" " , 'Dec 17 2003 3:44PM' -- not_null_datetime\n" " , 'Dec 17 2003 3:44PM' -- not_null_smalldatetime\n" "\n" " , 12.34 -- not_null_money\n" " , 12.34 -- not_null_smallmoney\n" "\n" " , 12.34 -- not_null_float\n" " , 12.34 -- not_null_real\n" "\n" " , 12.34 -- not_null_decimal\n" " , 12.34 -- not_null_numeric\n" "\n" " , 1234 -- not_null_int\n" " , 1234 -- not_null_smallint\n" " , 123 -- not_null_tinyint\n" ")\n"; freetds-1.00.82/src/ctlib/unittests/blk_in.c100644 025423 025423 00000020523 12522201763 0014360#include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_SYS_STAT_H #include #endif /* HAVE_SYS_STAT_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include "common.h" #include "blk_in.h" static CS_RETCODE do_bind(CS_BLKDESC * blkdesc, int colnum, CS_INT host_format, CS_INT host_type, CS_INT host_maxlen, void *var_addr, CS_INT *var_len_addr, CS_SMALLINT *var_ind_addr ); static char command[512]; /* * Static data for insertion */ int not_null_bit = 1; CS_INT l_not_null_bit = 4; CS_SMALLINT i_not_null_bit = 0; char not_null_char[] = "a char"; CS_INT l_not_null_char = 6; CS_SMALLINT i_not_null_char = 0; char not_null_varchar[] = "a varchar"; CS_INT l_not_null_varchar = 9; CS_SMALLINT i_not_null_varchar = 0; char not_null_datetime[] = "Dec 17 2003 3:44PM"; CS_INT l_not_null_datetime = 19; CS_SMALLINT i_not_null_datetime = 0; char not_null_smalldatetime[] = "Dec 17 2003 3:44PM"; CS_INT l_not_null_smalldatetime = 19; CS_SMALLINT i_not_null_smalldatetime = 0; char not_null_money[] = "12.34"; CS_INT l_not_null_money = 5; CS_SMALLINT i_not_null_money = 0; char not_null_smallmoney[] = "12.34"; CS_INT l_not_null_smallmoney = 5; CS_SMALLINT i_not_null_smallmoney = 0; char not_null_float[] = "12.34"; CS_INT l_not_null_float = 5; CS_SMALLINT i_not_null_float = 0; char not_null_real[] = "12.34"; CS_INT l_not_null_real = 5; CS_SMALLINT i_not_null_real = 0; char not_null_decimal[] = "12.34"; CS_INT l_not_null_decimal = 5; CS_SMALLINT i_not_null_decimal = 0; char not_null_numeric[] = "12.34"; CS_INT l_not_null_numeric = 5; CS_SMALLINT i_not_null_numeric = 0; int not_null_int = 1234; CS_INT l_not_null_int = 4; CS_SMALLINT i_not_null_int = 0; int not_null_smallint = 1234; CS_INT l_not_null_smallint = 4; CS_SMALLINT i_not_null_smallint = 0; int not_null_tinyint = 123; CS_INT l_not_null_tinyint = 4; CS_SMALLINT i_not_null_tinyint = 0; CS_INT l_null_char = 0; CS_SMALLINT i_null_char = -1; CS_INT l_null_varchar = 0; CS_SMALLINT i_null_varchar = -1; CS_INT l_null_datetime = 0; CS_SMALLINT i_null_datetime = -1; CS_INT l_null_smalldatetime = 0; CS_SMALLINT i_null_smalldatetime = -1; CS_INT l_null_money = 0; CS_SMALLINT i_null_money = -1; CS_INT l_null_smallmoney = 0; CS_SMALLINT i_null_smallmoney = -1; CS_INT l_null_float = 0; CS_SMALLINT i_null_float = -1; CS_INT l_null_real = 0; CS_SMALLINT i_null_real = -1; CS_INT l_null_decimal = 0; CS_SMALLINT i_null_decimal = -1; CS_INT l_null_numeric = 0; CS_SMALLINT i_null_numeric = -1; CS_INT l_null_int = 0; CS_SMALLINT i_null_int = -1; CS_INT l_null_smallint = 0; CS_SMALLINT i_null_smallint = -1; CS_INT l_null_tinyint = 0; CS_SMALLINT i_null_tinyint = -1; static void do_binds(CS_BLKDESC * blkdesc) { enum { prefixlen = 0 }; enum { termlen = 0 }; enum NullValue { IsNull, IsNotNull }; /* non nulls */ do_bind(blkdesc, 1, CS_FMT_UNUSED, CS_INT_TYPE, 4, ¬_null_bit, &l_not_null_bit, &i_not_null_bit); do_bind(blkdesc, 2, CS_FMT_NULLTERM, CS_CHAR_TYPE, 7, not_null_char, &l_not_null_char, &i_not_null_char); do_bind(blkdesc, 3, CS_FMT_NULLTERM, CS_CHAR_TYPE, 10, not_null_varchar, &l_not_null_varchar, &i_not_null_varchar); do_bind(blkdesc, 4, CS_FMT_NULLTERM, CS_CHAR_TYPE, 20, not_null_datetime, &l_not_null_datetime, &i_not_null_datetime); do_bind(blkdesc, 5, CS_FMT_NULLTERM, CS_CHAR_TYPE, 20, not_null_smalldatetime, &l_not_null_smalldatetime, &i_not_null_smalldatetime); do_bind(blkdesc, 6, CS_FMT_NULLTERM, CS_CHAR_TYPE, 6, not_null_money, &l_not_null_money, &i_not_null_money); do_bind(blkdesc, 7, CS_FMT_NULLTERM, CS_CHAR_TYPE, 6, not_null_smallmoney, &l_not_null_smallmoney, &i_not_null_smallmoney); do_bind(blkdesc, 8, CS_FMT_NULLTERM, CS_CHAR_TYPE, 6, not_null_float, &l_not_null_float, &i_not_null_float); do_bind(blkdesc, 9, CS_FMT_NULLTERM, CS_CHAR_TYPE, 6, not_null_real, &l_not_null_real, &i_not_null_real); do_bind(blkdesc, 10, CS_FMT_NULLTERM, CS_CHAR_TYPE, 6, not_null_decimal, &l_not_null_decimal, &i_not_null_decimal); do_bind(blkdesc, 11, CS_FMT_NULLTERM, CS_CHAR_TYPE, 6, not_null_numeric, &l_not_null_numeric, &i_not_null_numeric); do_bind(blkdesc, 12, CS_FMT_UNUSED, CS_INT_TYPE, 4, ¬_null_int, &l_not_null_int, &i_not_null_int); do_bind(blkdesc, 13, CS_FMT_UNUSED, CS_INT_TYPE, 4, ¬_null_smallint, &l_not_null_smallint, &i_not_null_smallint); do_bind(blkdesc, 14, CS_FMT_UNUSED, CS_INT_TYPE, 4, ¬_null_tinyint, &l_not_null_tinyint, &i_not_null_tinyint); /* nulls */ do_bind(blkdesc, 15, CS_FMT_NULLTERM, CS_CHAR_TYPE, 7, not_null_char, &l_null_char, &i_null_char); do_bind(blkdesc, 16, CS_FMT_NULLTERM, CS_CHAR_TYPE, 10, not_null_varchar, &l_null_varchar, &i_null_varchar); do_bind(blkdesc, 17, CS_FMT_NULLTERM, CS_CHAR_TYPE, 20, not_null_datetime, &l_null_datetime, &i_null_datetime); do_bind(blkdesc, 18, CS_FMT_NULLTERM, CS_CHAR_TYPE, 20, not_null_smalldatetime, &l_null_smalldatetime, &i_null_smalldatetime); do_bind(blkdesc, 19, CS_FMT_NULLTERM, CS_CHAR_TYPE, 6, not_null_money, &l_null_money, &i_null_money); do_bind(blkdesc, 20, CS_FMT_NULLTERM, CS_CHAR_TYPE, 6, not_null_smallmoney, &l_null_smallmoney, &i_null_smallmoney); do_bind(blkdesc, 21, CS_FMT_NULLTERM, CS_CHAR_TYPE, 6, not_null_float, &l_null_float, &i_null_float); do_bind(blkdesc, 22, CS_FMT_NULLTERM, CS_CHAR_TYPE, 6, not_null_real, &l_null_real, &i_null_real); do_bind(blkdesc, 23, CS_FMT_NULLTERM, CS_CHAR_TYPE, 6, not_null_decimal, &l_null_decimal, &i_null_decimal); do_bind(blkdesc, 24, CS_FMT_NULLTERM, CS_CHAR_TYPE, 6, not_null_numeric, &l_null_numeric, &i_null_numeric); do_bind(blkdesc, 25, CS_FMT_UNUSED, CS_INT_TYPE, 4, ¬_null_int, &l_null_int, &i_null_int); do_bind(blkdesc, 26, CS_FMT_UNUSED, CS_INT_TYPE, 4, ¬_null_smallint, &l_null_smallint, &i_null_smallint); do_bind(blkdesc, 27, CS_FMT_UNUSED, CS_INT_TYPE, 4, ¬_null_tinyint, &l_null_tinyint, &i_null_tinyint); } static CS_RETCODE do_bind(CS_BLKDESC * blkdesc, int colnum, CS_INT host_format, CS_INT host_type, CS_INT host_maxlen, void *var_addr, CS_INT *var_len_addr, CS_SMALLINT *var_ind_addr ) { CS_DATAFMT datafmt; CS_RETCODE ret; ret = blk_describe(blkdesc, colnum, &datafmt); if (ret != CS_SUCCEED) { fprintf(stderr, "blk_describe(%d) failed", colnum); return ret; } datafmt.format = host_format; datafmt.datatype = host_type; datafmt.maxlength = host_maxlen; datafmt.count = 1; ret = blk_bind(blkdesc, colnum, &datafmt, var_addr, var_len_addr, var_ind_addr ); if (ret != CS_SUCCEED) { fprintf(stderr, "blk_bind() failed\n"); return ret; } return ret; } int main(int argc, char **argv) { CS_CONTEXT *ctx; CS_CONNECTION *conn; CS_COMMAND *cmd; CS_BLKDESC *blkdesc; int verbose = 0; int count = 0; int ret; int i; const char *table_name = "all_types_bcp_unittest"; fprintf(stdout, "%s: Retrieve data using array binding \n", __FILE__); if (verbose) { fprintf(stdout, "Trying login\n"); } ret = try_ctlogin(&ctx, &conn, &cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Login failed\n"); return 1; } sprintf(command,"if exists (select 1 from sysobjects where type = 'U' and name = '%s') drop table %s", table_name, table_name); ret = run_command(cmd, command); if (ret != CS_SUCCEED) return 1; ret = run_command(cmd, create_table_sql); if (ret != CS_SUCCEED) return 1; ret = blk_alloc(conn, BLK_VERSION_100, &blkdesc); if (ret != CS_SUCCEED) { fprintf(stderr, "blk_alloc() failed\n"); return 1; } ret = blk_init(blkdesc, CS_BLK_IN, (char *) table_name, CS_NULLTERM ); if (ret != CS_SUCCEED) { fprintf(stderr, "blk_init() failed\n"); return 1; } do_binds(blkdesc); fprintf(stdout, "Sending same row 10 times... \n"); for (i=0; i<10; i++) { if((ret = blk_rowxfer(blkdesc)) != CS_SUCCEED) { fprintf(stderr, "blk_rowxfer() failed\n"); return 1; } } ret = blk_done(blkdesc, CS_BLK_ALL, &count); if (ret != CS_SUCCEED) { fprintf(stderr, "blk_done() failed\n"); return 1; } blk_drop(blkdesc); printf("%d rows copied.\n", count); printf("done\n"); ret = try_ctlogout(ctx, conn, cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Logout failed\n"); return 1; } return 0; } freetds-1.00.82/src/ctlib/unittests/blk_in2.c100644 025423 025423 00000005076 12522201763 0014450/* * Test from MATSUMOTO, Tadashi * Cfr "blk_init fails by the even number times execution" on ML, 2007-03-09 * This mix bulk and cancel * $Id: blk_in2.c,v 1.2 2011-05-16 08:51:40 freddy77 Exp $ */ #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_SYS_STAT_H #include #endif /* HAVE_SYS_STAT_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include "common.h" static const char create_table_sql[] = "CREATE TABLE hogexxx (col varchar(100))"; static CS_RETCODE hoge_blkin(CS_CONNECTION * con, CS_BLKDESC * blk, char *table, char *data) { CS_DATAFMT meta = { "" }; CS_INT length = 5; CS_INT row = 0; if (CS_SUCCEED != ct_cancel(con, NULL, CS_CANCEL_ALL)) return CS_FAIL; if (CS_SUCCEED != blk_init(blk, CS_BLK_IN, table, CS_NULLTERM)) return CS_FAIL; meta.count = 1; meta.datatype = CS_CHAR_TYPE; meta.format = CS_FMT_PADBLANK; meta.maxlength = 5; if (CS_SUCCEED != blk_bind(blk, (int) 1, &meta, data, &length, NULL)) return CS_FAIL; if (CS_SUCCEED != blk_rowxfer(blk)) return CS_FAIL; if (CS_SUCCEED != blk_done(blk, CS_BLK_ALL, &row)) return CS_FAIL; return CS_SUCCEED; } int main(int argc, char **argv) { CS_CONTEXT *ctx; CS_CONNECTION *conn; CS_COMMAND *cmd; CS_BLKDESC *blkdesc; int verbose = 0; int ret = 0; int i; char command[512]; static char table_name[20] = "hogexxx"; fprintf(stdout, "%s: Inserting data using bulk cancelling\n", __FILE__); if (verbose) { fprintf(stdout, "Trying login\n"); } ret = try_ctlogin(&ctx, &conn, &cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Login failed\n"); return 1; } sprintf(command, "if exists (select 1 from sysobjects where type = 'U' and name = '%s') drop table %s", table_name, table_name); ret = run_command(cmd, command); if (ret != CS_SUCCEED) return 1; ret = run_command(cmd, create_table_sql); if (ret != CS_SUCCEED) return 1; ret = blk_alloc(conn, BLK_VERSION_100, &blkdesc); if (ret != CS_SUCCEED) { fprintf(stderr, "blk_alloc() failed\n"); return 1; } for (i = 0; i < 10; i++) { /* compute some data */ memset(command, ' ', sizeof(command)); memset(command, 'a' + i, (i * 37) % 11); ret = hoge_blkin(conn, blkdesc, table_name, command); if (ret != CS_SUCCEED) return 1; } blk_drop(blkdesc); /* TODO test correct insert */ printf("done\n"); ret = try_ctlogout(ctx, conn, cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Logout failed\n"); return 1; } return 0; } freetds-1.00.82/src/ctlib/unittests/blk_out.c100644 025423 025423 00000010244 12522201763 0014560#include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include #include "common.h" static char software_version[] = "$Id: blk_out.c,v 1.6 2011-05-16 08:51:40 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; /* Testing: array binding of result set */ int main(int argc, char *argv[]) { CS_CONTEXT *ctx; CS_CONNECTION *conn; CS_COMMAND *cmd; CS_BLKDESC *blkdesc; int verbose = 0; CS_RETCODE ret; CS_DATAFMT datafmt; CS_INT count = 0; CS_INT col1[2]; CS_CHAR col2[2][5]; CS_CHAR col3[2][32]; CS_INT lencol1[2]; CS_SMALLINT indcol1[2]; CS_INT lencol2[2]; CS_SMALLINT indcol2[2]; CS_INT lencol3[2]; CS_SMALLINT indcol3[2]; int i; fprintf(stdout, "%s: Retrieve data using array binding \n", __FILE__); if (verbose) { fprintf(stdout, "Trying login\n"); } ret = try_ctlogin(&ctx, &conn, &cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Login failed\n"); return 1; } /* do not test error */ ret = run_command(cmd, "IF OBJECT_ID('tempdb..#ctlibarray') IS NOT NULL DROP TABLE #ctlibarray"); ret = run_command(cmd, "CREATE TABLE #ctlibarray (col1 int null, col2 char(4) not null, col3 datetime not null)"); if (ret != CS_SUCCEED) return 1; ret = run_command(cmd, "insert into #ctlibarray values (1, 'AAAA', 'Jan 1 2002 10:00:00AM')"); if (ret != CS_SUCCEED) return 1; ret = run_command(cmd, "insert into #ctlibarray values (2, 'BBBB', 'Jan 2 2002 10:00:00AM')"); if (ret != CS_SUCCEED) return 1; ret = run_command(cmd, "insert into #ctlibarray values (3, 'CCCC', 'Jan 3 2002 10:00:00AM')"); if (ret != CS_SUCCEED) return 1; ret = run_command(cmd, "insert into #ctlibarray values (8, 'DDDD', 'Jan 4 2002 10:00:00AM')"); if (ret != CS_SUCCEED) return 1; ret = run_command(cmd, "insert into #ctlibarray values (NULL, 'EEEE', 'Jan 5 2002 10:00:00AM')"); if (ret != CS_SUCCEED) return 1; ret = blk_alloc(conn, BLK_VERSION_100, &blkdesc); if (ret != CS_SUCCEED) { fprintf(stderr, "blk_alloc() failed\n"); return 1; } ret = blk_init(blkdesc, CS_BLK_OUT, "#ctlibarray", CS_NULLTERM ); if (ret != CS_SUCCEED) { fprintf(stderr, "blk_init() failed\n"); return 1; } ret = blk_describe(blkdesc, 1, &datafmt); if (ret != CS_SUCCEED) { fprintf(stderr, "blk_describe(1) failed"); return 1; } datafmt.format = CS_FMT_UNUSED; if (datafmt.maxlength > 1024) { datafmt.maxlength = 1024; } datafmt.count = 2; ret = blk_bind(blkdesc, 1, &datafmt, &col1[0], &lencol1[0], &indcol1[0]); if (ret != CS_SUCCEED) { fprintf(stderr, "blk_bind() failed\n"); return 1; } ret = blk_describe(blkdesc, 2, &datafmt); if (ret != CS_SUCCEED) { fprintf(stderr, "blk_describe(2) failed"); return 1; } datafmt.format = CS_FMT_NULLTERM; datafmt.maxlength = 5; datafmt.count = 2; ret = blk_bind(blkdesc, 2, &datafmt, col2[0], &lencol2[0], &indcol2[0]); if (ret != CS_SUCCEED) { fprintf(stderr, "blk_bind() failed\n"); return 1; } ret = blk_describe(blkdesc, 3, &datafmt); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_describe() failed"); return 1; } datafmt.datatype = CS_CHAR_TYPE; datafmt.format = CS_FMT_NULLTERM; datafmt.maxlength = 32; datafmt.count = 2; ret = blk_bind(blkdesc, 3, &datafmt, col3[0], &lencol3[0], &indcol3[0]); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_bind() failed\n"); return 1; } while((ret = blk_rowxfer_mult(blkdesc, &count)) == CS_SUCCEED) { for(i = 0; i < count; i++) { printf("retrieved %d (%d,%d) %s (%d,%d) %s (%d,%d)\n", col1[i], lencol1[i], indcol1[i], col2[i], lencol2[i], indcol2[i], col3[i], lencol3[i], indcol3[i] ); } } switch (ret) { case CS_END_DATA: for(i = 0; i < count; i++) { printf("retrieved %d (%d,%d) %s (%d,%d) %s (%d,%d)\n", col1[i], lencol1[i], indcol1[i], col2[i], lencol2[i], indcol2[i], col3[i], lencol3[i], indcol3[i] ); } break; case CS_FAIL: case CS_ROW_FAIL: fprintf(stderr, "blk_rowxfer_mult() failed\n"); return 1; } blk_drop(blkdesc); ret = try_ctlogout(ctx, conn, cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Logout failed\n"); return 1; } return 0; } freetds-1.00.82/src/ctlib/unittests/cancel.c100644 025423 025423 00000011622 12522201763 0014347#include #include #include #include #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #include #include #include "common.h" #if defined(HAVE_ALARM) && defined(HAVE_SETITIMER) /* protos */ int do_fetch(CS_COMMAND * cmd, int *cnt); void catch_alrm(int); /* Globals */ static volatile CS_COMMAND *g_cmd = NULL; void catch_alrm(int sig_num) { signal(SIGALRM, catch_alrm); fprintf(stdout, "- SIGALRM\n"); /* Cancel current command */ if (g_cmd) ct_cancel(NULL, (CS_COMMAND *) g_cmd, CS_CANCEL_ATTN); fflush(stdout); } /* Testing: Test asynchronous ct_cancel() */ int main(int argc, char **argv) { CS_CONTEXT *ctx; CS_CONNECTION *conn; CS_COMMAND *cmd; int i, verbose = 0, cnt = 0; CS_RETCODE ret; CS_INT result_type; struct itimerval timer; char query[1024]; unsigned clock = 200000; fprintf(stdout, "%s: Check asynchronous called ct_cancel()\n", __FILE__); if (verbose) { fprintf(stdout, "Trying login\n"); } ret = try_ctlogin(&ctx, &conn, &cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Login failed\n"); return 1; } /* Create needed tables */ ret = run_command(cmd, "CREATE TABLE #t0010 (id int, col1 varchar(255))"); if (ret != CS_SUCCEED) return 1; for (i = 0; i < 10; i++) { sprintf(query, "INSERT #t0010 (id, col1) values (%d, 'This is field no %d')", i, i); ret = run_command(cmd, query); if (ret != CS_SUCCEED) return 1; } /* Set SIGALRM signal handler */ signal(SIGALRM, catch_alrm); for (;;) { /* TODO better to use alarm AFTER ct_send ?? */ /* Set timer */ timer.it_interval.tv_sec = 0; timer.it_interval.tv_usec = clock; timer.it_value.tv_sec = 0; timer.it_value.tv_usec = clock; if (0 != setitimer(ITIMER_REAL, &timer, NULL)) { fprintf(stderr, "Could not set realtime timer.\n"); return 1; } /* Issue a command returning many rows */ ret = ct_command(cmd, CS_LANG_CMD, "SELECT * FROM #t0010 t1, #t0010 t2, #t0010 t3, #t0010 t4", CS_NULLTERM, CS_UNUSED); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_command() failed.\n"); return 1; } ret = ct_send(cmd); if (ret != CS_SUCCEED) { fprintf(stderr, "first ct_send() failed.\n"); return 1; } /* Save a global reference for the interrupt handler */ g_cmd = cmd; while ((ret = ct_results(cmd, &result_type)) == CS_SUCCEED) { printf("More results?...\n"); if (result_type == CS_STATUS_RESULT) continue; switch ((int) result_type) { case CS_ROW_RESULT: printf("do_fetch() returned: %d\n", do_fetch(cmd, &cnt)); break; } } /* We should not have received all rows, as the alarm signal cancelled it... */ if (cnt < 10000) break; if (clock <= 5000) { fprintf(stderr, "All rows read, this may not occur.\n"); return 1; } g_cmd = NULL; clock /= 2; } /* Remove timer */ timer.it_interval.tv_sec = 0; timer.it_interval.tv_usec = 0; timer.it_value.tv_sec = 0; timer.it_value.tv_usec = 0; if (0 != setitimer(ITIMER_REAL, &timer, NULL)) { fprintf(stderr, "Could not remove realtime timer.\n"); return 1; } /* * Issue another command, this will be executed after a ct_cancel, * to test if wire state is consistent */ ret = ct_command(cmd, CS_LANG_CMD, "SELECT * FROM #t0010 t1, #t0010 t2, #t0010 t3", CS_NULLTERM, CS_UNUSED); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_command() failed.\n"); return 1; } ret = ct_send(cmd); if (ret != CS_SUCCEED) { fprintf(stderr, "second ct_send() failed.\n"); return 1; } while ((ret = ct_results(cmd, &result_type)) == CS_SUCCEED) { printf("More results?...\n"); if (result_type == CS_STATUS_RESULT) continue; switch ((int) result_type) { case CS_ROW_RESULT: printf("do_fetch() returned: %d\n", do_fetch(cmd, &cnt)); break; } } if (1000 != cnt) { /* This time, all rows must have been received */ fprintf(stderr, "Incorrect number of rows read.\n"); return 1; } if (verbose) { fprintf(stdout, "Trying logout\n"); } ret = try_ctlogout(ctx, conn, cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Logout failed\n"); return 1; } printf("%s: asynchronous cancel test: PASSED\n", __FILE__); return 0; } int do_fetch(CS_COMMAND * cmd, int *cnt) { CS_INT count, row_count = 0; CS_RETCODE ret; while ((ret = ct_fetch(cmd, CS_UNUSED, CS_UNUSED, CS_UNUSED, &count)) == CS_SUCCEED) { /* printf ("ct_fetch() == CS_SUCCEED\n"); */ row_count += count; } (*cnt) = row_count; if (ret == CS_ROW_FAIL) { fprintf(stderr, "ct_fetch() CS_ROW_FAIL on row %d.\n", row_count); return 1; } else if (ret == CS_END_DATA) { printf("do_fetch retrieved %d rows\n", row_count); return 0; } else if (ret == CS_CMD_FAIL) { printf("do_fetch(): command aborted after receiving %d rows\n", row_count); return 0; } else { fprintf(stderr, "ct_fetch() unexpected return %d on row %d.\n", ret, row_count); return 1; } } #else int main(void) { return 0; } #endif freetds-1.00.82/src/ctlib/unittests/connect_fail.c100644 025423 025423 00000003364 12522201763 0015552#include #include #include #include "common.h" static char software_version[] = "$Id: connect_fail.c,v 1.5 2011-05-16 08:51:40 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; int main(int argc, char **argv) { CS_CONTEXT *ctx; CS_CONNECTION *conn; int ret = 1; read_login_info(); if (cs_ctx_alloc(CS_VERSION_100, &ctx) != CS_SUCCEED) { fprintf(stderr, "Context Alloc failed!\n"); return ret; } if (ct_init(ctx, CS_VERSION_100) != CS_SUCCEED) { fprintf(stderr, "Library Init failed!\n"); return ret; } if (ct_con_alloc(ctx, &conn) != CS_SUCCEED) { fprintf(stderr, "Connect Alloc failed!\n"); return ret; } if (ct_con_props(conn, CS_SET, CS_USERNAME, (CS_VOID*) "sa", CS_NULLTERM, NULL) != CS_SUCCEED) { fprintf(stderr, "ct_con_props() SET USERNAME failed!\n"); return ret; } if (ct_con_props(conn, CS_SET, CS_PASSWORD, (CS_VOID*) "invalid", CS_NULLTERM, NULL) != CS_SUCCEED) { fprintf(stderr, "ct_con_props() SET PASSWORD failed!\n"); return ret; } if (ct_connect(conn, SERVER, CS_NULLTERM) != CS_FAIL) { fprintf(stderr, "Connection succeeded??\n"); return ret; } if (ct_cancel(conn, NULL, CS_CANCEL_ALL) != CS_SUCCEED) { fprintf(stderr, "ct_cancel() failed!\n"); return ret; } if (ct_close(conn, CS_UNUSED) != CS_SUCCEED) { fprintf(stderr, "ct_close() failed!\n"); return ret; } if (ct_con_drop(conn) != CS_SUCCEED) { fprintf(stderr, "ct_con_drop() failed!\n"); return ret; } if (ct_exit(ctx, CS_UNUSED) != CS_SUCCEED) { fprintf(stderr, "ct_exit() failed!\n"); return ret; } if (cs_ctx_drop(ctx) != CS_SUCCEED) { fprintf(stderr, "cs_ctx_drop() failed!\n"); return ret; } fprintf(stdout, "Test succeeded\n"); return 0; } freetds-1.00.82/src/ctlib/unittests/cs_config.c100644 025423 025423 00000006032 12522201763 0015053#include #include #ifdef HAVE_STRING_H #include #endif #include #include #include "common.h" static char software_version[] = "$Id: cs_config.c,v 1.6 2011-05-16 08:51:40 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; int main(int argc, char **argv) { int verbose = 1; CS_CONTEXT *ctx; CS_CHAR string_in[16], string_out[16]; CS_INT int_in, int_out; CS_INT ret_len; if (verbose) { fprintf(stdout, "Trying cs_config with CS_USERDATA\n\n"); } if (cs_ctx_alloc(CS_VERSION_100, &ctx) != CS_SUCCEED) { fprintf(stderr, "cs_ctx_alloc() for first context failed\n"); } if (ct_init(ctx, CS_VERSION_100) != CS_SUCCEED) { fprintf(stderr, "ct_init() for first context failed\n"); } fprintf(stdout, "Testing CS_SET/GET USERDATA with char array\n"); strcpy(string_in,"FreeTDS"); if (cs_config(ctx, CS_SET, CS_USERDATA, (CS_VOID *)string_in, CS_NULLTERM, NULL) != CS_SUCCEED) { fprintf(stderr, "cs_config() set failed\n"); return 1; } if (cs_config(ctx, CS_GET, CS_USERDATA, (CS_VOID *)string_out, 16, &ret_len) != CS_SUCCEED) { fprintf(stderr, "cs_config() get failed\n"); return 1; } if (strcmp(string_in, string_out)) { fprintf(stdout, "returned value >%s< not as stored >%s<\n", (char *)string_out, (char *)string_in); return 1; } if (ret_len != (strlen(string_in) + 1)) { fprintf(stdout, "returned length >%d< not as expected >%u<\n", ret_len, (unsigned int) (strlen(string_in) + 1)); return 1; } fprintf(stdout, "Testing CS_SET/GET USERDATA with char array\n"); strcpy(string_in,"FreeTDS"); if (cs_config(ctx, CS_SET, CS_USERDATA, (CS_VOID *)string_in, CS_NULLTERM, NULL) != CS_SUCCEED) { fprintf(stderr, "cs_config() set failed\n"); return 1; } strcpy(string_out,"XXXXXXXXXXXXXXX"); if (cs_config(ctx, CS_GET, CS_USERDATA, (CS_VOID *)string_out, 4, &ret_len) != CS_SUCCEED) { fprintf(stderr, "cs_config() get failed\n"); return 1; } if (strcmp(string_out, "FreeXXXXXXXXXXX")) { fprintf(stdout, "returned value >%s< not as expected >%s<\n", (char *)string_out, "FreeXXXXXXXXXXX"); return 1; } if (ret_len != (strlen(string_in) + 1)) { fprintf(stdout, "returned length >%d< not as expected >%u<\n", ret_len, (unsigned int) (strlen(string_in) + 1)); return 1; } fprintf(stdout, "Testing CS_SET/GET USERDATA with int\n"); int_in = 255; if (cs_config(ctx, CS_SET, CS_USERDATA, (CS_VOID *)&int_in, sizeof(int), NULL) != CS_SUCCEED) { fprintf(stderr, "cs_config() set failed\n"); return 1; } if (cs_config(ctx, CS_GET, CS_USERDATA, (CS_VOID *)&int_out, sizeof(int), &ret_len) != CS_SUCCEED) { fprintf(stderr, "cs_config() get failed\n"); return 1; } if (int_in != int_out) { fprintf(stdout, "returned value >%d< not as stored >%d<\n", int_out, int_in); return 1; } if (ret_len != (sizeof(int))) { fprintf(stdout, "returned length >%d< not as expected >%u<\n", ret_len, (unsigned int) sizeof(int)); return 1; } cs_ctx_drop(ctx); return 0; } freetds-1.00.82/src/ctlib/unittests/cs_diag.c100644 025423 025423 00000005546 12522201763 0014523#include #include #include #include #include "common.h" static char software_version[] = "$Id: cs_diag.c,v 1.5 2011-05-16 08:51:40 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; /* * ct_send SQL |select name = @@servername| * ct_bind variable * ct_fetch and print results */ int main(int argc, char **argv) { int verbose = 1; CS_CONTEXT *ctx; CS_RETCODE ret; CS_DATAFMT srcfmt; CS_INT src = 32768; CS_DATAFMT dstfmt; CS_SMALLINT dst; CS_DATETIME dst_date; int i; CS_INT num_msgs; CS_CLIENTMSG client_message; fprintf(stdout, "%s: Testing context callbacks\n", __FILE__); srcfmt.datatype = CS_INT_TYPE; srcfmt.maxlength = sizeof(CS_INT); srcfmt.locale = NULL; dstfmt.datatype = CS_SMALLINT_TYPE; dstfmt.maxlength = sizeof(CS_SMALLINT); dstfmt.locale = NULL; if (verbose) { fprintf(stdout, "Trying clientmsg_cb with context\n"); } if (cs_ctx_alloc(CS_VERSION_100, &ctx) != CS_SUCCEED) { fprintf(stderr, "cs_ctx_alloc() failed\n"); } if (ct_init(ctx, CS_VERSION_100) != CS_SUCCEED) { fprintf(stderr, "ct_init() failed\n"); } if (cs_diag(ctx, CS_INIT, CS_UNUSED, CS_UNUSED, NULL) != CS_SUCCEED) { fprintf(stderr, "cs_diag(CS_INIT) failed\n"); return 1; } if (cs_convert(ctx, &srcfmt, &src, &dstfmt, &dst, NULL) == CS_SUCCEED) { fprintf(stderr, "cs_convert() succeeded when failure was expected\n"); return 1; } dstfmt.datatype = CS_DATETIME_TYPE; dstfmt.maxlength = sizeof(CS_DATETIME); dstfmt.locale = NULL; if (cs_convert(ctx, &srcfmt, &src, &dstfmt, &dst_date, NULL) == CS_SUCCEED) { fprintf(stderr, "cs_convert() succeeded when failure was expected\n"); return 1; } if (cs_diag(ctx, CS_STATUS, CS_CLIENTMSG_TYPE, CS_UNUSED, &num_msgs) != CS_SUCCEED) { fprintf(stderr, "cs_diag(CS_STATUS) failed\n"); return 1; } for (i = 0; i < num_msgs; i++ ) { if (cs_diag(ctx, CS_GET, CS_CLIENTMSG_TYPE, i + 1, &client_message) != CS_SUCCEED) { fprintf(stderr, "cs_diag(CS_GET) failed\n"); return 1; } cslibmsg_cb(NULL, &client_message); } if ((ret = cs_diag(ctx, CS_GET, CS_CLIENTMSG_TYPE, i + 1, &client_message)) != CS_NOMSG) { fprintf(stderr, "cs_diag(CS_GET) did not fail with CS_NOMSG\n"); return 1; } if (cs_diag(ctx, CS_CLEAR, CS_CLIENTMSG_TYPE, CS_UNUSED, NULL) != CS_SUCCEED) { fprintf(stderr, "cs_diag(CS_CLEAR) failed\n"); return 1; } if (cs_diag(ctx, CS_STATUS, CS_CLIENTMSG_TYPE, CS_UNUSED, &num_msgs) != CS_SUCCEED) { fprintf(stderr, "cs_diag(CS_STATUS) failed\n"); return 1; } if (num_msgs != 0) { fprintf(stderr, "cs_diag(CS_CLEAR) failed there are still %d messages on queue\n", num_msgs); return 1; } if (ct_exit(ctx, CS_UNUSED) != CS_SUCCEED) { fprintf(stderr, "ct_exit() failed\n"); } if (cs_ctx_drop(ctx) != CS_SUCCEED) { fprintf(stderr, "cx_ctx_drop() failed\n"); } return 0; } freetds-1.00.82/src/ctlib/unittests/ct_cursor.c100644 025423 025423 00000036515 12717145107 0015142#include #include #ifdef HAVE_STRING_H #include #endif #include #include "common.h" static int update_second_table(CS_COMMAND * cmd2, char *value); int main(int argc, char **argv) { CS_CONTEXT *ctx; CS_CONNECTION *conn; CS_COMMAND *cmd; CS_COMMAND *cmd2; CS_RETCODE ret; CS_RETCODE results_ret; CS_INT result_type; CS_INT count, row_count = 0; CS_DATAFMT datafmt; CS_SMALLINT ind; int verbose = 1; CS_CHAR name[3]; CS_CHAR col1[6]; CS_INT datalength; CS_CHAR text[128]; CS_INT num_cols, i, j; CS_INT props_value; fprintf(stdout, "%s: Testing ct_cursor()\n", __FILE__); if (verbose) { fprintf(stdout, "Trying login\n"); } ret = try_ctlogin(&ctx, &conn, &cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Login failed\n"); return 1; } ret = ct_cmd_alloc(conn, &cmd2); if (ret != CS_SUCCEED) { if (verbose) { fprintf(stderr, "Command Alloc failed!\n"); } return ret; } ret = run_command(cmd, "CREATE TABLE #test_table (col1 char(4))"); if (ret != CS_SUCCEED) return 1; ret = run_command(cmd, "INSERT #test_table (col1) VALUES ('AAA')"); if (ret != CS_SUCCEED) return 1; ret = run_command(cmd, "INSERT #test_table (col1) VALUES ('BBB')"); if (ret != CS_SUCCEED) return 1; ret = run_command(cmd, "INSERT #test_table (col1) VALUES ('CCC')"); if (ret != CS_SUCCEED) return 1; ret = run_command(cmd2, "CREATE TABLE #test_table2 (col1 char(4))"); if (ret != CS_SUCCEED) return 1; ret = run_command(cmd2, "INSERT #test_table2 (col1) VALUES ('---')"); if (ret != CS_SUCCEED) return 1; if (verbose) { fprintf(stdout, "Trying declare, rows , open in one SEND\n"); } strcpy(text, "select col1 from #test_table where 1 = 1"); strcpy(name, "c1"); ret = ct_cursor(cmd, CS_CURSOR_DECLARE, name, CS_NULLTERM, text, CS_NULLTERM, CS_UNUSED); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_cursor declare failed\n"); return 1; } ret = ct_cursor(cmd, CS_CURSOR_ROWS, name, CS_NULLTERM, NULL, CS_UNUSED, (CS_INT) 1); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_cursor set cursor rows failed"); return 1; } ret = ct_cursor(cmd, CS_CURSOR_OPEN, name, CS_NULLTERM, text, CS_NULLTERM, CS_UNUSED); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_cursor open failed\n"); return 1; } ret = ct_send(cmd); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_send failed\n"); } while ((results_ret = ct_results(cmd, &result_type)) == CS_SUCCEED) { switch ((int) result_type) { case CS_CMD_SUCCEED: case CS_CMD_DONE: case CS_CMD_FAIL: case CS_STATUS_RESULT: break; case CS_CURSOR_RESULT: ret = ct_cmd_props(cmd, CS_GET, CS_CUR_STATUS, &props_value, sizeof(CS_INT), NULL); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_cmd_props() failed\n"); return 1; } if (props_value & CS_CURSTAT_DECLARED) { fprintf(stderr, "ct_cmd_props claims cursor is in DECLARED state when it should be OPEN\n"); return 1; } if (!(props_value & CS_CURSTAT_OPEN)) { fprintf(stderr, "ct_cmd_props claims cursor is not in OPEN state when it should be \n"); return 1; } if (props_value & CS_CURSTAT_CLOSED) { fprintf(stderr, "ct_cmd_props claims cursor is in CLOSED state when it should be OPEN\n"); return 1; } ret = ct_res_info(cmd, CS_NUMDATA, &num_cols, CS_UNUSED, NULL); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_res_info() failed"); return 1; } if (num_cols != 1) { fprintf(stderr, "unexpected num of columns = %d \n", num_cols); return 1; } for (i = 0; i < num_cols; i++) { /* here we can finally test for the return status column */ ret = ct_describe(cmd, i + 1, &datafmt); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_describe() failed for column %d\n", i); return 1; } if (datafmt.status & CS_RETURN) { fprintf(stdout, "ct_describe() column %d \n", i); } datafmt.datatype = CS_CHAR_TYPE; datafmt.format = CS_FMT_NULLTERM; datafmt.maxlength = 6; datafmt.count = 1; datafmt.locale = NULL; ret = ct_bind(cmd, 1, &datafmt, col1, &datalength, &ind); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_bind() failed\n"); return 1; } } row_count = 0; while (((ret = ct_fetch(cmd, CS_UNUSED, CS_UNUSED, CS_UNUSED, &count)) == CS_SUCCEED) || (ret == CS_ROW_FAIL)) { if (row_count == 0) { for (j = 0; j < num_cols; j++) { fprintf(stdout, "\n%s\n", datafmt.name); } fprintf(stdout, "------\n\n"); } for (j = 0; j < num_cols; j++) { fprintf(stdout, "%s\n\n", col1); row_count++; } ret = update_second_table(cmd2, col1); if (ret) return ret; } switch ((int) ret) { case CS_END_DATA: break; case CS_ROW_FAIL: fprintf(stderr, "ct_fetch() CS_ROW_FAIL on row %d.\n", row_count); return 1; case CS_FAIL: fprintf(stderr, "ct_fetch() returned CS_FAIL.\n"); return 1; default: fprintf(stderr, "ct_fetch() unexpected return. %d\n", ret); return 1; } break; case CS_COMPUTE_RESULT: fprintf(stderr, "ct_results() unexpected CS_COMPUTE_RESULT.\n"); return 1; default: fprintf(stderr, "ct_results() unexpected result_type.\n"); return 1; } } ret = ct_cursor(cmd, CS_CURSOR_CLOSE, name, CS_NULLTERM, NULL, CS_UNUSED, CS_DEALLOC); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_cursor(close) failed\n"); return ret; } if ((ret = ct_send(cmd)) != CS_SUCCEED) { fprintf(stderr, "BILL ct_send() failed\n"); return ret; } while ((results_ret = ct_results(cmd, &result_type)) == CS_SUCCEED) { if (result_type == CS_CMD_FAIL) { fprintf(stderr, "ct_results(2) result_type CS_CMD_FAIL.\n"); return 1; } } if (results_ret != CS_END_RESULTS) { fprintf(stderr, "ct_results() returned BAD.\n"); return 1; } ret = ct_cmd_props(cmd, CS_GET, CS_CUR_STATUS, &props_value, sizeof(CS_INT), NULL); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_cmd_props() failed"); return 1; } if (props_value != CS_CURSTAT_NONE) { fprintf(stderr, "ct_cmd_props() CS_CUR_STATUS != CS_CURSTAT_NONE \n"); return 1; } if (verbose) { fprintf(stdout, "Trying declare, rows, open one at a time \n"); } strcpy(text, "select col1 from #test_table where 2 = 2"); ret = ct_cursor(cmd, CS_CURSOR_DECLARE, name, 3, text, CS_NULLTERM, CS_UNUSED); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_cursor declare failed\n"); return 1; } ret = ct_send(cmd); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_send failed\n"); } while ((results_ret = ct_results(cmd, &result_type)) == CS_SUCCEED) { if (result_type == CS_CMD_FAIL) { fprintf(stderr, "ct_results(4) result_type CS_CMD_FAIL.\n"); return 1; } } if (results_ret != CS_END_RESULTS) { fprintf(stderr, "ct_results() returned BAD.\n"); return 1; } ret = ct_cursor(cmd, CS_CURSOR_ROWS, name, 3, NULL, CS_UNUSED, (CS_INT) 1); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_cursor set cursor rows failed"); return 1; } ret = ct_send(cmd); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_send failed\n"); } while ((results_ret = ct_results(cmd, &result_type)) == CS_SUCCEED) { if (result_type == CS_CMD_FAIL) { fprintf(stderr, "ct_results(5) result_type CS_CMD_FAIL.\n"); return 1; } } if (results_ret != CS_END_RESULTS) { fprintf(stderr, "ct_results() returned BAD.\n"); return 1; } ret = ct_cursor(cmd, CS_CURSOR_OPEN, name, 3, text, 26, CS_UNUSED); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_cursor open failed\n"); return 1; } ret = ct_send(cmd); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_send failed\n"); } while ((results_ret = ct_results(cmd, &result_type)) == CS_SUCCEED) { switch ((int) result_type) { case CS_CMD_SUCCEED: break; case CS_CMD_DONE: break; case CS_CMD_FAIL: fprintf(stderr, "ct_results(6) result_type CS_CMD_FAIL.\n"); break; case CS_STATUS_RESULT: fprintf(stdout, "ct_results: CS_STATUS_RESULT detected for sp_who\n"); case CS_CURSOR_RESULT: ret = ct_res_info(cmd, CS_NUMDATA, &num_cols, CS_UNUSED, NULL); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_res_info() failed"); return 1; } if (num_cols != 1) { fprintf(stderr, "unexpected num of columns = %d \n", num_cols); return 1; } for (i = 0; i < num_cols; i++) { /* here we can finally test for the return status column */ ret = ct_describe(cmd, i + 1, &datafmt); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_describe() failed for column %d\n", i); return 1; } if (datafmt.status & CS_RETURN) { fprintf(stdout, "ct_describe() column %d \n", i); } datafmt.datatype = CS_CHAR_TYPE; datafmt.format = CS_FMT_NULLTERM; datafmt.maxlength = 6; datafmt.count = 1; datafmt.locale = NULL; ret = ct_bind(cmd, 1, &datafmt, col1, &datalength, &ind); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_bind() failed\n"); return 1; } } row_count = 0; while (((ret = ct_fetch(cmd, CS_UNUSED, CS_UNUSED, CS_UNUSED, &count)) == CS_SUCCEED) || (ret == CS_ROW_FAIL)) { if (row_count == 0) { for (j = 0; j < num_cols; j++) { fprintf(stdout, "\n%s\n", datafmt.name); } fprintf(stdout, "------\n\n"); } for (j = 0; j < num_cols; j++) { fprintf(stdout, "%s\n\n", col1); row_count++; } } switch ((int) ret) { case CS_END_DATA: break; case CS_ROW_FAIL: fprintf(stderr, "ct_fetch() CS_ROW_FAIL on row %d.\n", row_count); return 1; case CS_FAIL: fprintf(stderr, "ct_fetch() returned CS_FAIL.\n"); return 1; default: fprintf(stderr, "ct_fetch() unexpected return. %d\n", ret); return 1; } break; case CS_COMPUTE_RESULT: fprintf(stderr, "ct_results() unexpected CS_COMPUTE_RESULT.\n"); return 1; default: fprintf(stderr, "ct_results() unexpected result_type.\n"); return 1; } } ret = ct_cursor(cmd, CS_CURSOR_CLOSE, name, 3, NULL, CS_UNUSED, CS_UNUSED); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_cursor(close) failed\n"); return ret; } if ((ret = ct_send(cmd)) != CS_SUCCEED) { fprintf(stderr, "ct_send() failed\n"); return ret; } while ((results_ret = ct_results(cmd, &result_type)) == CS_SUCCEED) { if (result_type == CS_CMD_FAIL) { fprintf(stderr, "ct_results(7) result_type CS_CMD_FAIL.\n"); return 1; } } if (results_ret != CS_END_RESULTS) { fprintf(stderr, "ct_results() returned BAD.\n"); return 1; } ret = ct_cursor(cmd, CS_CURSOR_DEALLOC, name, 3, NULL, CS_UNUSED, CS_UNUSED); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_cursor(dealloc) failed\n"); return ret; } if ((ret = ct_send(cmd)) != CS_SUCCEED) { fprintf(stderr, "ct_send() failed\n"); return ret; } while ((results_ret = ct_results(cmd, &result_type)) == CS_SUCCEED) { if (result_type == CS_CMD_FAIL) { fprintf(stderr, "ct_results(8) result_type CS_CMD_FAIL.\n"); return 1; } } if (results_ret != CS_END_RESULTS) { fprintf(stderr, "ct_results() returned BAD.\n"); return 1; } if (verbose) { fprintf(stdout, "Running normal select command after cursor operations\n"); } ret = ct_command(cmd, CS_LANG_CMD, "select col1 from #test_table", CS_NULLTERM, CS_UNUSED); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_command() failed\n"); return 1; } ret = ct_send(cmd); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_send() failed\n"); return 1; } while ((results_ret = ct_results(cmd, &result_type)) == CS_SUCCEED) { switch ((int) result_type) { case CS_CMD_SUCCEED: break; case CS_CMD_DONE: break; case CS_CMD_FAIL: fprintf(stderr, "ct_results() result_type CS_CMD_FAIL.\n"); return 1; case CS_ROW_RESULT: datafmt.datatype = CS_CHAR_TYPE; datafmt.format = CS_FMT_NULLTERM; datafmt.maxlength = 6; datafmt.count = 1; datafmt.locale = NULL; ret = ct_bind(cmd, 1, &datafmt, col1, &datalength, &ind); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_bind() failed\n"); return 1; } while (((ret = ct_fetch(cmd, CS_UNUSED, CS_UNUSED, CS_UNUSED, &count)) == CS_SUCCEED) || (ret == CS_ROW_FAIL)) { row_count += count; if (ret == CS_ROW_FAIL) { fprintf(stderr, "ct_fetch() CS_ROW_FAIL on row %d.\n", row_count); return 1; } else if (ret == CS_SUCCEED) { ; } else { break; } } switch ((int) ret) { case CS_END_DATA: break; case CS_FAIL: fprintf(stderr, "ct_fetch() returned CS_FAIL.\n"); return 1; default: fprintf(stderr, "ct_fetch() unexpected return.%d\n", ret); return 1; } break; case CS_COMPUTE_RESULT: fprintf(stderr, "ct_results() unexpected CS_COMPUTE_RESULT.\n"); return 1; default: fprintf(stderr, "ct_results() unexpected result_type. %d\n", result_type); return 1; } } switch ((int) results_ret) { case CS_END_RESULTS: break; case CS_FAIL: fprintf(stderr, "ct_results() failed.\n"); return 1; break; default: fprintf(stderr, "ct_results() unexpected return.\n"); return 1; } if (verbose) { fprintf(stdout, "Trying logout\n"); } ct_cmd_drop(cmd2); ret = try_ctlogout(ctx, conn, cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Logout failed\n"); return 2; } if (verbose) { fprintf(stdout, "Test suceeded\n"); } return 0; } static int update_second_table(CS_COMMAND * cmd2, char *value) { CS_RETCODE ret; CS_RETCODE results_ret; CS_INT result_type; CS_INT count, row_count = 0; CS_DATAFMT datafmt; CS_SMALLINT ind; CS_CHAR col1[6]; CS_INT datalength; CS_CHAR text[128]; sprintf(text, "update #test_table2 set col1 = '%s' ", value); ret = run_command(cmd2, text); if (ret != CS_SUCCEED) return 1; ret = ct_command(cmd2, CS_LANG_CMD, "select col1 from #test_table2", CS_NULLTERM, CS_UNUSED); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_command() failed\n"); return 1; } ret = ct_send(cmd2); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_send() failed\n"); return 1; } while ((results_ret = ct_results(cmd2, &result_type)) == CS_SUCCEED) { switch ((int) result_type) { case CS_CMD_SUCCEED: break; case CS_CMD_DONE: break; case CS_CMD_FAIL: fprintf(stderr, "ct_results() result_type CS_CMD_FAIL.\n"); return 1; case CS_ROW_RESULT: datafmt.datatype = CS_CHAR_TYPE; datafmt.format = CS_FMT_NULLTERM; datafmt.maxlength = 6; datafmt.count = 1; datafmt.locale = NULL; ret = ct_bind(cmd2, 1, &datafmt, col1, &datalength, &ind); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_bind() failed\n"); return 1; } while (((ret = ct_fetch(cmd2, CS_UNUSED, CS_UNUSED, CS_UNUSED, &count)) == CS_SUCCEED) || (ret == CS_ROW_FAIL)) { row_count += count; if (ret == CS_ROW_FAIL) { fprintf(stderr, "ct_fetch() CS_ROW_FAIL on row %d.\n", row_count); return 1; } else if (ret == CS_SUCCEED) { ; } else { break; } } switch ((int) ret) { case CS_END_DATA: break; case CS_FAIL: fprintf(stderr, "ct_fetch() returned CS_FAIL.\n"); return 1; default: fprintf(stderr, "ct_fetch() unexpected return.%d\n", ret); return 1; } break; case CS_COMPUTE_RESULT: fprintf(stderr, "ct_results() unexpected CS_COMPUTE_RESULT.\n"); return 1; default: fprintf(stderr, "ct_results() unexpected result_type. %d\n", result_type); return 1; } } switch ((int) results_ret) { case CS_END_RESULTS: break; case CS_FAIL: fprintf(stderr, "ct_results() failed.\n"); return 1; break; default: fprintf(stderr, "ct_results() unexpected return.\n"); return 1; } return 0; } freetds-1.00.82/src/ctlib/unittests/ct_cursors.c100644 025423 025423 00000023364 12717145107 0015323#include #include #ifdef HAVE_STRING_H #include #endif #include #include "common.h" int main(int argc, char **argv) { CS_CONTEXT *ctx; CS_CONNECTION *conn; CS_COMMAND *cmd; CS_COMMAND *cmd2; CS_COMMAND *cmd3; CS_RETCODE ret; CS_RETCODE ret2; CS_RETCODE results_ret; CS_INT result_type; CS_INT count, count2, row_count = 0; CS_DATAFMT datafmt; CS_DATAFMT datafmt2; CS_SMALLINT ind; int verbose = 1; CS_CHAR *name = "c1"; CS_CHAR *name2 = "c2"; CS_CHAR col1[6]; CS_CHAR col2[6]; CS_INT datalength; CS_CHAR text[128]; CS_INT num_cols, i; memset(col1, 0, sizeof(col1)); memset(col2, 0, sizeof(col2)); fprintf(stdout, "%s: use multiple cursors on the same connection\n", __FILE__); if (verbose) { fprintf(stdout, "Trying login\n"); } ret = try_ctlogin(&ctx, &conn, &cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Login failed\n"); return 1; } ret = ct_cmd_alloc(conn, &cmd2); if (ret != CS_SUCCEED) { if (verbose) { fprintf(stderr, "Command Alloc failed!\n"); } return ret; } ret = ct_cmd_alloc(conn, &cmd3); if (ret != CS_SUCCEED) { if (verbose) { fprintf(stderr, "Command Alloc failed!\n"); } return ret; } ret = run_command(cmd, "CREATE TABLE #test_table (col1 char(4))"); if (ret != CS_SUCCEED) return 1; ret = run_command(cmd, "INSERT #test_table (col1) VALUES ('AAA')"); if (ret != CS_SUCCEED) return 1; ret = run_command(cmd, "INSERT #test_table (col1) VALUES ('BBB')"); if (ret != CS_SUCCEED) return 1; ret = run_command(cmd, "INSERT #test_table (col1) VALUES ('CCC')"); if (ret != CS_SUCCEED) return 1; ret = run_command(cmd, "CREATE TABLE #test_table2 (col1 char(4))"); if (ret != CS_SUCCEED) return 1; ret = run_command(cmd, "INSERT #test_table2 (col1) VALUES ('XXX')"); if (ret != CS_SUCCEED) return 1; ret = run_command(cmd, "INSERT #test_table2 (col1) VALUES ('YYY')"); if (ret != CS_SUCCEED) return 1; ret = run_command(cmd, "INSERT #test_table2 (col1) VALUES ('ZZZ')"); if (ret != CS_SUCCEED) return 1; if (verbose) { fprintf(stdout, "opening first cursor on connection\n"); } strcpy(text, "select col1 from #test_table order by col1"); ret = ct_cursor(cmd, CS_CURSOR_DECLARE, name, CS_NULLTERM, text, CS_NULLTERM, CS_UNUSED); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_cursor declare failed\n"); return 1; } ret = ct_cursor(cmd, CS_CURSOR_ROWS, name, CS_NULLTERM, NULL, CS_UNUSED, (CS_INT) 1); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_cursor set cursor rows failed"); return 1; } ret = ct_cursor(cmd, CS_CURSOR_OPEN, name, CS_NULLTERM, text, CS_NULLTERM, CS_UNUSED); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_cursor open failed\n"); return 1; } ret = ct_send(cmd); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_send failed\n"); return 1; } while ((results_ret = ct_results(cmd, &result_type)) == CS_SUCCEED) { switch ((int) result_type) { case CS_CMD_FAIL: fprintf(stderr, "ct_results failed\n"); return 1; case CS_CMD_SUCCEED: case CS_CMD_DONE: case CS_STATUS_RESULT: break; case CS_CURSOR_RESULT: ret = ct_res_info(cmd, CS_NUMDATA, &num_cols, CS_UNUSED, NULL); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_res_info() failed"); return 1; } if (num_cols != 1) { fprintf(stderr, "unexpected num of columns = %d \n", num_cols); return 1; } for (i = 0; i < num_cols; i++) { /* here we can finally test for the return status column */ ret = ct_describe(cmd, i + 1, &datafmt); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_describe() failed for column %d\n", i); return 1; } if (datafmt.status & CS_RETURN) { fprintf(stdout, "ct_describe() column %d \n", i); } datafmt.datatype = CS_CHAR_TYPE; datafmt.format = CS_FMT_NULLTERM; datafmt.maxlength = 6; datafmt.count = 1; datafmt.locale = NULL; ret = ct_bind(cmd, 1, &datafmt, col1, &datalength, &ind); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_bind() failed\n"); return 1; } } break; case CS_COMPUTE_RESULT: fprintf(stderr, "ct_results() unexpected CS_COMPUTE_RESULT.\n"); return 1; default: fprintf(stderr, "ct_results() unexpected result_type.\n"); return 1; } } if (verbose) { fprintf(stdout, "opening second cursor on connection\n"); } strcpy(text, "select col1 from #test_table2 order by col1"); ret = ct_cursor(cmd2, CS_CURSOR_DECLARE, name2, CS_NULLTERM, text, CS_NULLTERM, CS_UNUSED); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_cursor declare failed\n"); return 1; } ret = ct_cursor(cmd2, CS_CURSOR_ROWS, name2, CS_NULLTERM, NULL, CS_UNUSED, (CS_INT) 1); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_cursor set cursor rows failed"); return 1; } ret = ct_cursor(cmd2, CS_CURSOR_OPEN, name2, CS_NULLTERM, text, CS_NULLTERM, CS_UNUSED); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_cursor open failed\n"); return 1; } ret = ct_send(cmd2); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_send failed\n"); return 1; } while ((results_ret = ct_results(cmd2, &result_type)) == CS_SUCCEED) { switch ((int) result_type) { case CS_CMD_FAIL: fprintf(stderr, "ct_results failed\n"); return 1; case CS_CMD_SUCCEED: case CS_CMD_DONE: case CS_STATUS_RESULT: break; case CS_CURSOR_RESULT: ret = ct_res_info(cmd2, CS_NUMDATA, &num_cols, CS_UNUSED, NULL); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_res_info() failed"); return 1; } if (num_cols != 1) { fprintf(stderr, "unexpected num of columns = %d \n", num_cols); return 1; } for (i = 0; i < num_cols; i++) { /* here we can finally test for the return status column */ ret = ct_describe(cmd2, i + 1, &datafmt2); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_describe() failed for column %d\n", i); return 1; } if (datafmt2.status & CS_RETURN) { fprintf(stdout, "ct_describe() column %d \n", i); } datafmt2.datatype = CS_CHAR_TYPE; datafmt2.format = CS_FMT_NULLTERM; datafmt2.maxlength = 6; datafmt2.count = 1; datafmt2.locale = NULL; ret = ct_bind(cmd2, 1, &datafmt2, col2, &datalength, &ind); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_bind() failed\n"); return 1; } } break; case CS_COMPUTE_RESULT: fprintf(stderr, "ct_results() unexpected CS_COMPUTE_RESULT.\n"); return 1; default: fprintf(stderr, "ct_results() unexpected result_type.\n"); return 1; } } row_count = 0; while (((ret = ct_fetch(cmd, CS_UNUSED, CS_UNUSED, CS_UNUSED, &count)) == CS_SUCCEED) || (ret == CS_ROW_FAIL)) { ret2 = ct_fetch(cmd2, CS_UNUSED, CS_UNUSED, CS_UNUSED, &count2); if (ret == CS_SUCCEED && ret2 == CS_SUCCEED) { printf("%s\t\t\t%s\n", col1, col2); } } switch ((int) ret) { case CS_END_DATA: break; case CS_ROW_FAIL: fprintf(stderr, "ct_fetch() CS_ROW_FAIL on row %d.\n", row_count); return 1; case CS_FAIL: fprintf(stderr, "ct_fetch() returned CS_FAIL.\n"); return 1; default: fprintf(stderr, "ct_fetch() unexpected return.\n"); return 1; } if (verbose) { fprintf(stdout, "closing first cursor on connection\n"); } ret = ct_cursor(cmd, CS_CURSOR_CLOSE, name, CS_NULLTERM, NULL, CS_UNUSED, CS_UNUSED); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_cursor(close) failed\n"); return ret; } if ((ret = ct_send(cmd)) != CS_SUCCEED) { fprintf(stderr, "BILL ct_send() failed\n"); return ret; } while ((results_ret = ct_results(cmd, &result_type)) == CS_SUCCEED) { if (result_type == CS_CMD_FAIL) { fprintf(stderr, "ct_results(2) result_type CS_CMD_FAIL.\n"); return 1; } } if (results_ret != CS_END_RESULTS) { fprintf(stderr, "ct_results() returned BAD.\n"); return 1; } ret = ct_cursor(cmd, CS_CURSOR_DEALLOC, name, CS_NULLTERM, NULL, CS_UNUSED, CS_UNUSED); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_cursor(dealloc) failed\n"); return ret; } if ((ret = ct_send(cmd)) != CS_SUCCEED) { fprintf(stderr, "ct_send() failed\n"); return ret; } while ((results_ret = ct_results(cmd, &result_type)) == CS_SUCCEED) { if (result_type == CS_CMD_FAIL) { fprintf(stderr, "ct_results(3) result_type CS_CMD_FAIL.\n"); return 1; } } if (results_ret != CS_END_RESULTS) { fprintf(stderr, "ct_results() returned BAD.\n"); return 1; } if (verbose) { fprintf(stdout, "closing second cursor on connection\n"); } ret = ct_cursor(cmd2, CS_CURSOR_CLOSE, name2, CS_NULLTERM, NULL, CS_UNUSED, CS_UNUSED); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_cursor(close) failed\n"); return ret; } if ((ret = ct_send(cmd2)) != CS_SUCCEED) { fprintf(stderr, "BILL ct_send() failed\n"); return ret; } while ((results_ret = ct_results(cmd2, &result_type)) == CS_SUCCEED) { if (result_type == CS_CMD_FAIL) { fprintf(stderr, "ct_results(2) result_type CS_CMD_FAIL.\n"); return 1; } } if (results_ret != CS_END_RESULTS) { fprintf(stderr, "ct_results() returned BAD.\n"); return 1; } ret = ct_cursor(cmd2, CS_CURSOR_DEALLOC, name2, CS_NULLTERM, NULL, CS_UNUSED, CS_UNUSED); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_cursor(dealloc) failed\n"); return ret; } if ((ret = ct_send(cmd2)) != CS_SUCCEED) { fprintf(stderr, "ct_send() failed\n"); return ret; } while ((results_ret = ct_results(cmd2, &result_type)) == CS_SUCCEED) { if (result_type == CS_CMD_FAIL) { fprintf(stderr, "ct_results(3) result_type CS_CMD_FAIL.\n"); return 1; } } if (results_ret != CS_END_RESULTS) { fprintf(stderr, "ct_results() returned BAD.\n"); return 1; } ct_cmd_drop(cmd2); ct_cmd_drop(cmd3); if (verbose) { fprintf(stdout, "Trying logout\n"); } ret = try_ctlogout(ctx, conn, cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Logout failed\n"); return 2; } if (verbose) { fprintf(stdout, "Test succeded\n"); } return 0; } freetds-1.00.82/src/ctlib/unittests/ct_diagall.c100644 025423 025423 00000014625 12717145107 0015220#include #include #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include "common.h" /* Testing: Client and server Messages */ int main(int argc, char *argv[]) { CS_CONTEXT *ctx; CS_CONNECTION *conn; CS_COMMAND *cmd; int verbose = 0; CS_RETCODE ret; CS_RETCODE results_ret; CS_INT result_type; CS_INT num_cols; CS_DATAFMT datafmt; CS_INT datalength[2]; CS_SMALLINT ind[2]; CS_INT count, row_count = 0; CS_INT cv; int i; CS_CHAR select[1024]; CS_INT col1[2]; CS_CHAR col2[2][5]; CS_INT num_msgs, totmsgs; CS_CLIENTMSG client_message; CS_SERVERMSG server_message; fprintf(stdout, "%s: Retrieve data using array binding \n", __FILE__); if (verbose) { fprintf(stdout, "Trying login\n"); } ret = try_ctlogin(&ctx, &conn, &cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Login failed\n"); return 1; } if (ct_diag(conn, CS_INIT, CS_UNUSED, CS_UNUSED, NULL) != CS_SUCCEED) { fprintf(stderr, "ct_diag(CS_INIT) failed\n"); return 1; } totmsgs = 5; if (ct_diag(conn, CS_MSGLIMIT, CS_ALLMSG_TYPE, CS_UNUSED, &totmsgs) != CS_SUCCEED) { fprintf(stderr, "ct_diag(CS_MSGLIMIT) failed\n"); return 1; } fprintf(stdout, "Maximum message limit is set to: %d\n", totmsgs); ret = run_command(cmd, "CREATE TABLE #ctlibarray (col1 int not null, col2 char(4) not null, col3 datetime not null)"); if (ret != CS_SUCCEED) return 1; ret = run_command(cmd, "insert into #ctlibarray values (1, 'AAAA', 'Jan 1 2002 10:00:00AM')"); if (ret != CS_SUCCEED) return 1; ret = run_command(cmd, "insert into #ctlibarray values (2, 'BBBB', 'Jan 2 2002 10:00:00AM')"); if (ret != CS_SUCCEED) return 1; strcpy(select, "select col1, col2 from #ctlibarray order by col1 "); ret = ct_command(cmd, CS_LANG_CMD, select, CS_NULLTERM, CS_UNUSED); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_command(%s) failed\n", select); return 1; } ret = ct_send(cmd); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_send() failed\n"); return 1; } while ((results_ret = ct_results(cmd, &result_type)) == CS_SUCCEED) { switch ((int) result_type) { case CS_CMD_SUCCEED: break; case CS_CMD_DONE: break; case CS_CMD_FAIL: fprintf(stderr, "ct_results() result_type CS_CMD_FAIL.\n"); return 1; case CS_ROW_RESULT: ret = ct_res_info(cmd, CS_NUMDATA, &num_cols, CS_UNUSED, NULL); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_res_info() failed"); return 1; } if (num_cols != 2) { fprintf(stderr, "num_cols %d != 2", num_cols); return 1; } ret = ct_describe(cmd, 1, &datafmt); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_describe() failed"); return 1; } datafmt.format = CS_FMT_UNUSED; if (datafmt.maxlength > 1024) { datafmt.maxlength = 1024; } datafmt.count = 2; ret = ct_bind(cmd, 1, &datafmt, &col1[0], datalength, ind); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_bind() failed\n"); return 1; } ret = ct_describe(cmd, 2, &datafmt); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_describe() failed"); return 1; } datafmt.format = CS_FMT_NULLTERM; datafmt.maxlength = 5; datafmt.count = 4; ret = ct_bind(cmd, 2, &datafmt, &col2[0], datalength, ind); if (ret != CS_SUCCEED) { datafmt.format = CS_FMT_NULLTERM; datafmt.maxlength = 5; datafmt.count = 2; ret = ct_bind(cmd, 2, &datafmt, &col2[0], datalength, ind); } if (ret != CS_SUCCEED) { return 1; } count = 0; while (((ret = ct_fetch(cmd, CS_UNUSED, CS_UNUSED, CS_UNUSED, &count)) == CS_SUCCEED) || (ret == CS_ROW_FAIL)) { row_count += count; if (ret == CS_ROW_FAIL) { fprintf(stderr, "ct_fetch() CS_ROW_FAIL on row %d.\n", row_count); return 1; } else { /* ret == CS_SUCCEED */ fprintf(stdout, "ct_fetch returned %d rows\n", count); for (cv = 0; cv < count; cv++) fprintf(stdout, "col1 = %d col2= '%s'\n", col1[cv], col2[cv]); } count = 0; } switch ((int) ret) { case CS_END_DATA: break; case CS_FAIL: fprintf(stderr, "ct_fetch() returned CS_FAIL.\n"); return 1; default: fprintf(stderr, "ct_fetch() unexpected return.\n"); return 1; } break; default: fprintf(stderr, "ct_results() unexpected result_type.\n"); return 1; } } switch ((int) results_ret) { case CS_END_RESULTS: break; case CS_FAIL: fprintf(stderr, "ct_results() failed.\n"); return 1; break; default: fprintf(stderr, "ct_results() unexpected return.\n"); return 1; } ret = run_command(cmd, "DROP TABLE #ctlibarray3"); ret = run_command(cmd, "DROP TABLE #ctlibarray4"); ret = run_command(cmd, "DROP TABLE #ctlibarray5"); if (ct_diag(conn, CS_STATUS, CS_ALLMSG_TYPE, CS_UNUSED, &num_msgs) != CS_SUCCEED) { fprintf(stderr, "ct_diag(CS_STATUS) failed\n"); return 1; } fprintf(stdout, "Total number of client/server messages = %d \n", num_msgs); if (ct_diag(conn, CS_STATUS, CS_CLIENTMSG_TYPE, CS_UNUSED, &num_msgs) != CS_SUCCEED) { fprintf(stderr, "ct_diag(CS_STATUS) failed\n"); return 1; } fprintf(stdout, "Number of client messages returned: %d\n", num_msgs); for (i = 0; i < num_msgs; i++) { if (ct_diag(conn, CS_GET, CS_CLIENTMSG_TYPE, i + 1, &client_message) != CS_SUCCEED) { fprintf(stderr, "cs_diag(CS_GET) failed\n"); return 1; } clientmsg_cb(ctx, conn, &client_message); } if (ct_diag(conn, CS_STATUS, CS_SERVERMSG_TYPE, CS_UNUSED, &num_msgs) != CS_SUCCEED) { fprintf(stderr, "ct_diag(CS_STATUS) failed\n"); return 1; } fprintf(stdout, "Number of server messages returned: %d\n", num_msgs); for (i = 0; i < num_msgs; i++) { if (ct_diag(conn, CS_GET, CS_SERVERMSG_TYPE, i + 1, &server_message) != CS_SUCCEED) { fprintf(stderr, "cs_diag(CS_GET) failed\n"); return 1; } servermsg_cb(ctx, conn, &server_message); } if (ct_diag(conn, CS_CLEAR, CS_ALLMSG_TYPE, CS_UNUSED, NULL) != CS_SUCCEED) { fprintf(stderr, "cs_diag(CS_CLEAR) failed\n"); return 1; } if (ct_diag(conn, CS_STATUS, CS_ALLMSG_TYPE, CS_UNUSED, &num_msgs) != CS_SUCCEED) { fprintf(stderr, "cs_diag(CS_STATUS) failed\n"); return 1; } if (num_msgs != 0) { fprintf(stderr, "cs_diag(CS_CLEAR) failed there are still %d messages on queue\n", num_msgs); return 1; } if (verbose) { fprintf(stdout, "Trying logout\n"); } ret = try_ctlogout(ctx, conn, cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Logout failed\n"); return 1; } return 0; } freetds-1.00.82/src/ctlib/unittests/ct_diagclient.c100644 025423 025423 00000013341 12717145107 0015720#include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include "common.h" /* Testing: Client Messages */ int main(int argc, char *argv[]) { CS_CONTEXT *ctx; CS_CONNECTION *conn; CS_COMMAND *cmd; int verbose = 0; CS_RETCODE ret; CS_RETCODE results_ret; CS_INT result_type; CS_INT num_cols; CS_DATAFMT datafmt; CS_INT datalength[2]; CS_SMALLINT ind[2]; CS_INT count, row_count = 0; CS_INT cv; int i; CS_CHAR select[1024]; CS_INT col1[2]; CS_CHAR col2[2][5]; CS_INT num_msgs, totmsgs; CS_CLIENTMSG client_message; int result = 1; fprintf(stdout, "%s: Retrieve data using array binding \n", __FILE__); if (verbose) { fprintf(stdout, "Trying login\n"); } ret = try_ctlogin(&ctx, &conn, &cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Login failed\n"); return 1; } if (ct_diag(conn, CS_INIT, CS_UNUSED, CS_UNUSED, NULL) != CS_SUCCEED) { fprintf(stderr, "ct_diag(CS_INIT) failed\n"); return 1; } totmsgs = 1; if (ct_diag(conn, CS_MSGLIMIT, CS_CLIENTMSG_TYPE, CS_UNUSED, &totmsgs) != CS_SUCCEED) { fprintf(stderr, "ct_diag(CS_MSGLIMIT) failed\n"); return 1; } fprintf(stdout, "Maximum message limit is set to: %d\n", totmsgs); ret = run_command(cmd, "CREATE TABLE #ctlibarray (col1 int not null, col2 char(4) not null, col3 datetime not null)"); if (ret != CS_SUCCEED) return 1; ret = run_command(cmd, "insert into #ctlibarray values (1, 'AAAA', 'Jan 1 2002 10:00:00AM')"); if (ret != CS_SUCCEED) return 1; ret = run_command(cmd, "insert into #ctlibarray values (2, 'BBBB', 'Jan 2 2002 10:00:00AM')"); if (ret != CS_SUCCEED) return 1; strcpy(select, "select col1, col2 from #ctlibarray order by col1 "); ret = ct_command(cmd, CS_LANG_CMD, select, CS_NULLTERM, CS_UNUSED); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_command(%s) failed\n", select); return 1; } ret = ct_send(cmd); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_send() failed\n"); return 1; } while ((results_ret = ct_results(cmd, &result_type)) == CS_SUCCEED) { switch ((int) result_type) { case CS_CMD_SUCCEED: break; case CS_CMD_DONE: break; case CS_CMD_FAIL: fprintf(stderr, "ct_results() result_type CS_CMD_FAIL.\n"); return 1; case CS_ROW_RESULT: ret = ct_res_info(cmd, CS_NUMDATA, &num_cols, CS_UNUSED, NULL); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_res_info() failed"); return 1; } if (num_cols != 2) { fprintf(stderr, "num_cols %d != 2", num_cols); return 1; } ret = ct_describe(cmd, 1, &datafmt); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_describe() failed"); return 1; } datafmt.format = CS_FMT_UNUSED; if (datafmt.maxlength > 1024) { datafmt.maxlength = 1024; } datafmt.count = 2; ret = ct_bind(cmd, 1, &datafmt, &col1[0], datalength, ind); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_bind() failed\n"); return 1; } ret = ct_describe(cmd, 2, &datafmt); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_describe() failed"); return 1; } datafmt.format = CS_FMT_NULLTERM; datafmt.maxlength = 5; datafmt.count = 4; ret = ct_bind(cmd, 2, &datafmt, &col2[0], datalength, ind); if (ret != CS_SUCCEED) { if (ct_diag(conn, CS_STATUS, CS_CLIENTMSG_TYPE, CS_UNUSED, &num_msgs) != CS_SUCCEED) { fprintf(stderr, "ct_diag(CS_STATUS) failed\n"); return 1; } fprintf(stdout, "Number of client messages returned: %d\n", num_msgs); for (i = 0; i < num_msgs; i++) { if (ct_diag(conn, CS_GET, CS_CLIENTMSG_TYPE, i + 1, &client_message) != CS_SUCCEED) { fprintf(stderr, "cs_diag(CS_GET) failed\n"); return 1; } clientmsg_cb(ctx, conn, &client_message); } if (ct_diag(conn, CS_CLEAR, CS_CLIENTMSG_TYPE, CS_UNUSED, NULL) != CS_SUCCEED) { fprintf(stderr, "cs_diag(CS_CLEAR) failed\n"); return 1; } if (ct_diag(conn, CS_STATUS, CS_CLIENTMSG_TYPE, CS_UNUSED, &num_msgs) != CS_SUCCEED) { fprintf(stderr, "cs_diag(CS_STATUS) failed\n"); return 1; } if (num_msgs != 0) { fprintf(stderr, "cs_diag(CS_CLEAR) failed there are still %d messages on queue\n", num_msgs); return 1; } /* we catch error, good */ result = 0; } else { fprintf(stderr, "ct_bind() succeeded while it shouldn't\n"); return 1; } datafmt.count = 2; ret = ct_bind(cmd, 2, &datafmt, &col2[0], datalength, ind); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_bind() failed\n"); return 1; } count = 0; while (((ret = ct_fetch(cmd, CS_UNUSED, CS_UNUSED, CS_UNUSED, &count)) == CS_SUCCEED) || (ret == CS_ROW_FAIL)) { row_count += count; if (ret == CS_ROW_FAIL) { fprintf(stderr, "ct_fetch() CS_ROW_FAIL on row %d.\n", row_count); return 1; } else { /* ret == CS_SUCCEED */ fprintf(stdout, "ct_fetch returned %d rows\n", count); for (cv = 0; cv < count; cv++) fprintf(stdout, "col1 = %d col2= '%s'\n", col1[cv], col2[cv]); } count = 0; } switch ((int) ret) { case CS_END_DATA: break; case CS_FAIL: fprintf(stderr, "ct_fetch() returned CS_FAIL.\n"); return 1; default: fprintf(stderr, "ct_fetch() unexpected return.\n"); return 1; } break; default: fprintf(stderr, "ct_results() unexpected result_type.\n"); return 1; } } switch ((int) results_ret) { case CS_END_RESULTS: break; case CS_FAIL: fprintf(stderr, "ct_results() failed.\n"); return 1; break; default: fprintf(stderr, "ct_results() unexpected return.\n"); return 1; } if (verbose) { fprintf(stdout, "Trying logout\n"); } ret = try_ctlogout(ctx, conn, cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Logout failed\n"); return 1; } return result; } freetds-1.00.82/src/ctlib/unittests/ct_diagserver.c100644 025423 025423 00000004143 12522201763 0015743#include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include "common.h" static char software_version[] = "$Id: ct_diagserver.c,v 1.5 2011-05-16 08:51:40 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; /* Testing: Server messages limit */ int main(int argc, char *argv[]) { CS_CONTEXT *ctx; CS_CONNECTION *conn; CS_COMMAND *cmd; int verbose = 0; CS_RETCODE ret; int i; CS_INT num_msgs, totMsgs; CS_SERVERMSG server_message; if (verbose) { fprintf(stdout, "Trying login\n"); } ret = try_ctlogin(&ctx, &conn, &cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Login failed\n"); return 1; } if (ct_diag(conn, CS_INIT, CS_UNUSED, CS_UNUSED, NULL) != CS_SUCCEED) { fprintf(stderr, "ct_diag(CS_INIT) failed\n"); return 1; } totMsgs = 4; if (ct_diag(conn, CS_MSGLIMIT, CS_SERVERMSG_TYPE, CS_UNUSED, &totMsgs) != CS_SUCCEED) { fprintf(stderr, "ct_diag(CS_STATUS) failed\n"); return 1; } fprintf(stdout, "Maximum message limit is set to %d.\n", totMsgs); if (ct_diag(conn, CS_STATUS, CS_SERVERMSG_TYPE, CS_UNUSED, &num_msgs) != CS_SUCCEED) { fprintf(stderr, "ct_diag(CS_STATUS) failed\n"); return 1; } fprintf(stdout, "Number of messages returned: %d\n", num_msgs); for (i = 0; i < num_msgs; i++) { if (ct_diag(conn, CS_GET, CS_SERVERMSG_TYPE, i + 1, &server_message) != CS_SUCCEED) { fprintf(stderr, "cs_diag(CS_GET) failed\n"); return 1; } servermsg_cb(ctx, conn, &server_message); } if (ct_diag(conn, CS_CLEAR, CS_SERVERMSG_TYPE, CS_UNUSED, NULL) != CS_SUCCEED) { fprintf(stderr, "cs_diag(CS_CLEAR) failed\n"); return 1; } if (ct_diag(conn, CS_STATUS, CS_SERVERMSG_TYPE, CS_UNUSED, &num_msgs) != CS_SUCCEED) { fprintf(stderr, "cs_diag(CS_STATUS) failed\n"); return 1; } if (num_msgs != 0) { fprintf(stderr, "cs_diag(CS_CLEAR) failed there are still %d messages on queue\n", num_msgs); return 1; } ret = try_ctlogout(ctx, conn, cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Logout failed\n"); return 1; } return 0; } freetds-1.00.82/src/ctlib/unittests/ct_dynamic.c100644 025423 025423 00000027065 12717145107 0015251#include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include "common.h" static CS_RETCODE ex_servermsg_cb(CS_CONTEXT * context, CS_CONNECTION * connection, CS_SERVERMSG * errmsg); static CS_RETCODE ex_clientmsg_cb(CS_CONTEXT * context, CS_CONNECTION * connection, CS_CLIENTMSG * errmsg); static int verbose = 0; static CS_CONTEXT *ctx; static CS_CONNECTION *conn; static CS_COMMAND *cmd; static CS_COMMAND *cmd2; static void cleanup(void) { CS_RETCODE ret; if (verbose) { printf("Trying logout\n"); } if (cmd2) ct_cmd_drop(cmd2); ret = try_ctlogout(ctx, conn, cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Logout failed\n"); exit(1); } } static void chk(int check, const char *fmt, ...) { va_list ap; if (check) return; va_start(ap, fmt); vfprintf(stderr, fmt, ap); va_end(ap); cleanup(); exit(1); } int main(int argc, char *argv[]) { int errCode = 1; CS_RETCODE ret; CS_RETCODE results_ret; CS_CHAR cmdbuf[4096]; CS_CHAR name[257]; CS_INT datalength; CS_SMALLINT ind; CS_INT count; CS_INT num_cols; CS_INT row_count = 0; CS_DATAFMT datafmt; CS_DATAFMT descfmt; CS_INT intvar; CS_INT intvarsize; CS_SMALLINT intvarind; CS_INT res_type; int i; if (argc > 1 && (0 == strcmp(argv[1], "-v"))) verbose = 1; printf("%s: use ct_dynamic to prepare and execute a statement\n", __FILE__); if (verbose) { printf("Trying login\n"); } ret = try_ctlogin(&ctx, &conn, &cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Login failed\n"); return 1; } ct_callback(ctx, NULL, CS_SET, CS_CLIENTMSG_CB, (CS_VOID *) ex_clientmsg_cb); ct_callback(ctx, NULL, CS_SET, CS_SERVERMSG_CB, (CS_VOID *) ex_servermsg_cb); ret = ct_cmd_alloc(conn, &cmd2); chk(ret == CS_SUCCEED, "cmd2_alloc failed\n"); /* do not test error */ ret = run_command(cmd, "IF OBJECT_ID('tempdb..#ct_dynamic') IS NOT NULL DROP table #ct_dynamic"); strcpy(cmdbuf, "create table #ct_dynamic (id numeric identity not null, \ name varchar(30), age int, cost money, bdate datetime, fval float) "); ret = run_command(cmd, cmdbuf); chk(ret == CS_SUCCEED, "create table failed\n"); strcpy(cmdbuf, "insert into #ct_dynamic ( name , age , cost , bdate , fval ) "); strcat(cmdbuf, "values ('Bill', 44, 2000.00, 'May 21 1960', 60.97 ) "); ret = run_command(cmd, cmdbuf); chk(ret == CS_SUCCEED, "insert table failed\n"); strcpy(cmdbuf, "insert into #ct_dynamic ( name , age , cost , bdate , fval ) "); strcat(cmdbuf, "values ('Freddy', 32, 1000.00, 'Jan 21 1972', 70.97 ) "); ret = run_command(cmd, cmdbuf); chk(ret == CS_SUCCEED, "insert table failed\n"); strcpy(cmdbuf, "insert into #ct_dynamic ( name , age , cost , bdate , fval ) "); strcat(cmdbuf, "values ('James', 42, 5000.00, 'May 21 1962', 80.97 ) "); ret = run_command(cmd, cmdbuf); chk(ret == CS_SUCCEED, "insert table failed\n"); strcpy(cmdbuf, "select name from #ct_dynamic where age = ?"); ret = ct_dynamic(cmd, CS_PREPARE, "age", CS_NULLTERM, cmdbuf, CS_NULLTERM); chk(ret == CS_SUCCEED, "ct_dynamic failed\n"); chk(ct_send(cmd) == CS_SUCCEED, "ct_send(CS_PREPARE) failed\n"); while ((ret = ct_results(cmd, &res_type)) == CS_SUCCEED) { switch ((int) res_type) { case CS_CMD_SUCCEED: case CS_CMD_DONE: break; case CS_CMD_FAIL: break; default: goto ERR; } } chk(ret == CS_END_RESULTS, "ct_results() unexpected return.\n", (int) ret); ret = ct_dynamic(cmd, CS_DESCRIBE_INPUT, "age", CS_NULLTERM, NULL, CS_UNUSED); chk(ret == CS_SUCCEED, "ct_dynamic failed\n"); chk(ct_send(cmd) == CS_SUCCEED, "ct_send(CS_DESCRIBE_INPUT) failed\n"); while ((ret = ct_results(cmd, &res_type)) == CS_SUCCEED) { switch ((int) res_type) { case CS_DESCRIBE_RESULT: ret = ct_res_info(cmd, CS_NUMDATA, &num_cols, CS_UNUSED, NULL); chk(ret == CS_SUCCEED, "ct_res_info() failed"); for (i = 1; i <= num_cols; i++) { ret = ct_describe(cmd, i, &descfmt); chk(ret == CS_SUCCEED, "ct_describe() failed"); fprintf(stderr, "CS_DESCRIBE_INPUT parameter %d :\n", i); if (descfmt.namelen == 0) fprintf(stderr, "\t\tNo name...\n"); else fprintf(stderr, "\t\tName = %*.*s\n", descfmt.namelen, descfmt.namelen, descfmt.name); fprintf(stderr, "\t\tType = %d\n", descfmt.datatype); fprintf(stderr, "\t\tLength = %d\n", descfmt.maxlength); } break; case CS_CMD_SUCCEED: case CS_CMD_DONE: break; case CS_CMD_FAIL: break; default: goto ERR; } } ret = ct_dynamic(cmd, CS_DESCRIBE_OUTPUT, "age", CS_NULLTERM, NULL, CS_UNUSED); chk(ret == CS_SUCCEED, "ct_dynamic failed\n"); chk(ct_send(cmd) == CS_SUCCEED, "ct_send(CS_DESCRIBE_OUTPUT) failed\n"); while ((ret = ct_results(cmd, &res_type)) == CS_SUCCEED) { switch ((int) res_type) { case CS_DESCRIBE_RESULT: ret = ct_res_info(cmd, CS_NUMDATA, &num_cols, CS_UNUSED, NULL); chk(ret == CS_SUCCEED, "ct_res_info() failed"); chk(num_cols == 1, "CS_DESCRIBE_OUTPUT showed %d columns , expected 1\n", num_cols); for (i = 1; i <= num_cols; i++) { ret = ct_describe(cmd, i, &descfmt); chk(ret == CS_SUCCEED, "ct_describe() failed"); if (descfmt.namelen == 0) fprintf(stderr, "\t\tNo name...\n"); else fprintf(stderr, "\t\tName = %*.*s\n", descfmt.namelen, descfmt.namelen, descfmt.name); fprintf(stderr, "\t\tType = %d\n", descfmt.datatype); fprintf(stderr, "\t\tLength = %d\n", descfmt.maxlength); } break; case CS_CMD_SUCCEED: case CS_CMD_DONE: break; case CS_CMD_FAIL: break; default: goto ERR; } } /* execute dynamic on a second command to check it still works */ ret = ct_dynamic(cmd2, CS_EXECUTE, "age", CS_NULLTERM, NULL, CS_UNUSED); chk(ret == CS_SUCCEED, "ct_dynamic failed\n"); intvar = 44; intvarsize = 4; intvarind = 0; datafmt.name[0] = 0; datafmt.namelen = 0; datafmt.datatype = CS_INT_TYPE; datafmt.status = CS_INPUTVALUE; ret = ct_setparam(cmd2, &datafmt, (CS_VOID *) & intvar, &intvarsize, &intvarind); chk(ret == CS_SUCCEED, "ct_setparam(int) failed\n"); chk(ct_send(cmd2) == CS_SUCCEED, "ct_send(CS_EXECUTE) failed\n"); while ((results_ret = ct_results(cmd2, &res_type)) == CS_SUCCEED) { chk(res_type != CS_CMD_FAIL, "1: ct_results() result_type CS_CMD_FAIL.\n"); chk(res_type != CS_COMPUTE_RESULT, "ct_results() unexpected CS_COMPUTE_RESULT.\n"); switch ((int) res_type) { case CS_CMD_SUCCEED: break; case CS_CMD_DONE: break; case CS_ROW_RESULT: datafmt.datatype = CS_CHAR_TYPE; datafmt.format = CS_FMT_NULLTERM; datafmt.maxlength = 256; datafmt.count = 1; datafmt.locale = NULL; ret = ct_bind(cmd2, 1, &datafmt, name, &datalength, &ind); chk(ret == CS_SUCCEED, "ct_bind() failed\n"); while (((ret = ct_fetch(cmd2, CS_UNUSED, CS_UNUSED, CS_UNUSED, &count)) == CS_SUCCEED) || (ret == CS_ROW_FAIL)) { row_count += count; chk(ret != CS_ROW_FAIL, "ct_fetch() CS_ROW_FAIL on row %d.\n", row_count); if (ret == CS_SUCCEED) { chk(!strcmp(name, "Bill"), "fetched value '%s' expected 'Bill'\n", name); } else { break; } } chk(ret == CS_END_DATA, "ct_fetch() unexpected return %d.\n", (int) ret); break; default: fprintf(stderr, "ct_results() unexpected result_type.\n"); return 1; } } chk(results_ret == CS_END_RESULTS, "ct_results() unexpected return.\n", (int) results_ret); intvar = 32; chk(ct_send(cmd2) == CS_SUCCEED, "ct_send(CS_EXECUTE) failed\n"); while ((results_ret = ct_results(cmd2, &res_type)) == CS_SUCCEED) { chk(res_type != CS_CMD_FAIL, "2: ct_results() result_type CS_CMD_FAIL.\n"); chk(res_type != CS_COMPUTE_RESULT, "ct_results() unexpected CS_COMPUTE_RESULT.\n"); switch ((int) res_type) { case CS_CMD_SUCCEED: break; case CS_CMD_DONE: break; case CS_ROW_RESULT: datafmt.datatype = CS_CHAR_TYPE; datafmt.format = CS_FMT_NULLTERM; datafmt.maxlength = 256; datafmt.count = 1; datafmt.locale = NULL; ret = ct_bind(cmd2, 1, &datafmt, name, &datalength, &ind); chk(ret == CS_SUCCEED, "ct_bind() failed\n"); while (((ret = ct_fetch(cmd2, CS_UNUSED, CS_UNUSED, CS_UNUSED, &count)) == CS_SUCCEED) || (ret == CS_ROW_FAIL)) { row_count += count; chk(ret != CS_ROW_FAIL, "ct_fetch() CS_ROW_FAIL on row %d.\n", row_count); if (ret == CS_SUCCEED) { chk(!strcmp(name, "Freddy"), "fetched value '%s' expected 'Freddy'\n", name); } else { break; } } chk(ret == CS_END_DATA, "ct_fetch() unexpected return %d.\n", (int) ret); break; default: fprintf(stderr, "ct_results() unexpected result_type.\n"); return 1; } } chk(results_ret == CS_END_RESULTS, "ct_results() unexpected return.\n", (int) results_ret); ret = ct_dynamic(cmd, CS_DEALLOC, "age", CS_NULLTERM, NULL, CS_UNUSED); chk(ret == CS_SUCCEED, "ct_dynamic failed\n"); chk(ct_send(cmd) == CS_SUCCEED, "ct_send(CS_DEALLOC) failed\n"); while ((ret = ct_results(cmd, &res_type)) == CS_SUCCEED) { switch ((int) res_type) { case CS_CMD_SUCCEED: case CS_CMD_DONE: break; case CS_CMD_FAIL: break; default: goto ERR; } } chk(ret == CS_END_RESULTS, "ct_results() unexpected return.\n", (int) ret); /* * check we can prepare again dynamic with same name after deallocation */ strcpy(cmdbuf, "select name from #ct_dynamic where age = ?"); ret = ct_dynamic(cmd, CS_PREPARE, "age", CS_NULLTERM, cmdbuf, CS_NULLTERM); chk(ret == CS_SUCCEED, "ct_dynamic failed\n"); chk(ct_send(cmd) == CS_SUCCEED, "ct_send(CS_PREPARE) failed\n"); while ((ret = ct_results(cmd, &res_type)) == CS_SUCCEED) { switch ((int) res_type) { case CS_CMD_SUCCEED: case CS_CMD_DONE: break; case CS_CMD_FAIL: break; default: goto ERR; } } chk(ret == CS_END_RESULTS, "ct_results() unexpected return.\n", (int) ret); ct_dynamic(cmd, CS_DEALLOC, "invalid", CS_NULLTERM, NULL, CS_UNUSED); ct_send(cmd); while ((ret = ct_results(cmd, &res_type)) == CS_SUCCEED) chk(res_type != CS_ROW_RESULT, "Rows not expected\n"); chk(ret == CS_END_RESULTS, "ct_results() unexpected return.\n", (int) ret); ret = ct_dynamic(cmd2, CS_EXECUTE, "age", CS_NULLTERM, NULL, CS_UNUSED); chk(ret == CS_SUCCEED, "ct_dynamic failed\n"); intvar = 32; intvarsize = 4; intvarind = 0; datafmt.name[0] = 0; datafmt.namelen = 0; datafmt.datatype = CS_INT_TYPE; datafmt.status = CS_INPUTVALUE; ret = ct_setparam(cmd2, &datafmt, (CS_VOID *) & intvar, &intvarsize, &intvarind); chk(ct_send(cmd2) == CS_SUCCEED, "ct_send(CS_EXECUTE) failed\n"); /* all tests succeeded */ errCode = 0; ERR: cleanup(); return errCode; } static CS_RETCODE ex_clientmsg_cb(CS_CONTEXT * context, CS_CONNECTION * connection, CS_CLIENTMSG * errmsg) { printf("\nOpen Client Message:\n"); printf("Message number: LAYER = (%d) ORIGIN = (%d) ", CS_LAYER(errmsg->msgnumber), CS_ORIGIN(errmsg->msgnumber)); printf("SEVERITY = (%d) NUMBER = (%d)\n", CS_SEVERITY(errmsg->msgnumber), CS_NUMBER(errmsg->msgnumber)); printf("Message String: %s\n", errmsg->msgstring); if (errmsg->osstringlen > 0) { printf("Operating System Error: %s\n", errmsg->osstring); } fflush(stdout); return CS_SUCCEED; } static CS_RETCODE ex_servermsg_cb(CS_CONTEXT * context, CS_CONNECTION * connection, CS_SERVERMSG * srvmsg) { printf("\nServer message:\n"); printf("Message number: %d, Severity %d, ", srvmsg->msgnumber, srvmsg->severity); printf("State %d, Line %d\n", srvmsg->state, srvmsg->line); if (srvmsg->svrnlen > 0) { printf("Server '%s'\n", srvmsg->svrname); } if (srvmsg->proclen > 0) { printf(" Procedure '%s'\n", srvmsg->proc); } printf("Message String: %s\n", srvmsg->text); fflush(stdout); return CS_SUCCEED; } freetds-1.00.82/src/ctlib/unittests/ct_options.c100644 025423 025423 00000006545 12522201763 0015313#include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include "common.h" static char software_version[] = "$Id: ct_options.c,v 1.5 2011-05-16 08:51:40 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; /* Testing: Set and get options with ct_options */ int main(int argc, char *argv[]) { int verbose = 0; CS_CONTEXT *ctx; CS_CONNECTION *conn; CS_COMMAND *cmd; CS_RETCODE ret; CS_INT datefirst = 0; CS_INT dateformat = 0; CS_BOOL truefalse = 999; if (verbose) { fprintf(stdout, "Trying login\n"); } if (argc >= 5) { common_pwd.initialized = argc; strcpy(common_pwd.SERVER, argv[1]); strcpy(common_pwd.DATABASE, argv[2]); strcpy(common_pwd.USER, argv[3]); strcpy(common_pwd.PASSWORD, argv[4]); } ret = try_ctlogin(&ctx, &conn, &cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Login failed\n"); return 1; } fprintf(stdout, "%s: Set/Retrieve DATEFIRST\n", __FILE__); /* DATEFIRST */ datefirst = CS_OPT_WEDNESDAY; if (ct_options(conn, CS_SET, CS_OPT_DATEFIRST, &datefirst, CS_UNUSED, NULL) != CS_SUCCEED) { fprintf(stderr, "ct_options() failed\n"); return 1; } datefirst = 999; if (ct_options(conn, CS_GET, CS_OPT_DATEFIRST, &datefirst, CS_UNUSED, NULL) != CS_SUCCEED) { fprintf(stderr, "ct_options() failed\n"); return 1; } if (datefirst != CS_OPT_WEDNESDAY) { fprintf(stderr, "ct_options(DATEFIRST) didn't work retrieved %d expected %d\n", datefirst, CS_OPT_WEDNESDAY); return 1; } fprintf(stdout, "%s: Set/Retrieve DATEFORMAT\n", __FILE__); /* DATEFORMAT */ dateformat = CS_OPT_FMTMYD; if (ct_options(conn, CS_SET, CS_OPT_DATEFORMAT, &dateformat, CS_UNUSED, NULL) != CS_SUCCEED) { fprintf(stderr, "ct_options() failed\n"); return 1; } dateformat = 999; if (ct_options(conn, CS_GET, CS_OPT_DATEFORMAT, &dateformat, CS_UNUSED, NULL) != CS_SUCCEED) { fprintf(stderr, "ct_options() failed\n"); return 1; } if (dateformat != CS_OPT_FMTMYD) { fprintf(stderr, "ct_options(DATEFORMAT) didn't work retrieved %d expected %d\n", dateformat, CS_OPT_FMTMYD); return 1; } fprintf(stdout, "%s: Set/Retrieve ANSINULL\n", __FILE__); /* ANSI NULLS */ truefalse = CS_TRUE; if (ct_options(conn, CS_SET, CS_OPT_ANSINULL, &truefalse, CS_UNUSED, NULL) != CS_SUCCEED) { fprintf(stderr, "ct_options() failed\n"); return 1; } truefalse = 999; if (ct_options(conn, CS_GET, CS_OPT_ANSINULL, &truefalse, CS_UNUSED, NULL) != CS_SUCCEED) { fprintf(stderr, "ct_options() failed\n"); return 1; } if (truefalse != CS_TRUE) { fprintf(stderr, "ct_options(ANSINULL) didn't work\n"); return 1; } fprintf(stdout, "%s: Set/Retrieve CHAINXACTS\n", __FILE__); /* CHAINED XACT */ truefalse = CS_TRUE; if (ct_options(conn, CS_SET, CS_OPT_CHAINXACTS, &truefalse, CS_UNUSED, NULL) != CS_SUCCEED) { fprintf(stderr, "ct_options() failed\n"); return 1; } truefalse = 999; if (ct_options(conn, CS_GET, CS_OPT_CHAINXACTS, &truefalse, CS_UNUSED, NULL) != CS_SUCCEED) { fprintf(stderr, "ct_options() failed\n"); return 1; } if (truefalse != CS_TRUE) { fprintf(stderr, "ct_options(CHAINXACTS) didn't work\n"); return 1; } if (verbose) { fprintf(stdout, "Trying logout\n"); } ret = try_ctlogout(ctx, conn, cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Logout failed\n"); return 1; } return 0; } freetds-1.00.82/src/ctlib/unittests/datafmt.c100644 025423 025423 00000010030 12717145107 0014537#include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include #include "common.h" /* Testing: data truncation behavior of ct_fetch */ int main(int argc, char *argv[]) { CS_CONTEXT *ctx; CS_CONNECTION *conn; CS_COMMAND *cmd; int verbose = 0; CS_RETCODE ret; CS_RETCODE results_ret; CS_INT result_type; CS_INT num_cols; CS_DATAFMT datafmt; CS_INT copied = 0; CS_SMALLINT ind = 0; CS_INT count, row_count = 0; CS_CHAR select[1024]; char *addr = NULL; fprintf(stdout, "%s: test data truncation behavior of ct_fetch \n", __FILE__); if (verbose) { fprintf(stdout, "Trying login\n"); } ret = try_ctlogin_with_options(argc, argv, &ctx, &conn, &cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Login failed\n"); return 1; } verbose += common_pwd.fverbose; strcpy(select, "select name from systypes where datalength(name) > 2*9 order by datalength(name)"); printf("%s\n", select); ret = ct_command(cmd, CS_LANG_CMD, select, CS_NULLTERM, CS_UNUSED); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_command(%s) failed\n", select); return 1; } ret = ct_send(cmd); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_send() failed\n"); return 1; } while ((results_ret = ct_results(cmd, &result_type)) == CS_SUCCEED) { switch ((int) result_type) { case CS_CMD_SUCCEED: break; case CS_CMD_DONE: break; case CS_CMD_FAIL: fprintf(stderr, "ct_results() result_type CS_CMD_FAIL.\n"); free(addr); return 1; case CS_ROW_RESULT: ret = ct_res_info(cmd, CS_NUMDATA, &num_cols, CS_UNUSED, NULL); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_res_info() failed"); free(addr); return 1; } fprintf(stderr, "%d column%s\n", num_cols, num_cols==1? "":"s"); ret = ct_describe(cmd, 1, &datafmt); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_describe() failed\n"); free(addr); return 1; } fprintf(stderr, "type = %d\n", datafmt.datatype); fprintf(stderr, "maxlength = %d\n", datafmt.maxlength); if (datafmt.datatype == CS_CHAR_TYPE) { fprintf(stderr, "CS_CHAR_TYPE\n"); datafmt.format = CS_FMT_NULLTERM; addr = (char *) malloc(datafmt.maxlength); } fprintf(stderr, "binding column 1 (%s)\n", datafmt.name); /* set maxlength to something short to test truncation behavior */ if (common_pwd.maxlength) datafmt.maxlength = common_pwd.maxlength; ret = ct_bind(cmd, 1, &datafmt, addr, &copied, &ind); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_bind() failed\n"); free(addr); return 1; } fprintf(stderr, "fetching rows with datafmt.maxlength = %d\n", datafmt.maxlength); while ((ret = ct_fetch(cmd, CS_UNUSED, CS_UNUSED, CS_UNUSED, &count)) != CS_END_DATA) { fprintf(stderr, "ct_fetch() row %d returned %d.\n", row_count, (int) ret); addr[copied] = '\0'; fprintf(stderr, "copied %d bytes: [%s]\n", copied, addr); row_count += count; switch (ret) { case CS_SUCCEED: fprintf(stdout, "ct_fetch returned %d row%s\n", count, count==1? "":"s"); break; case CS_ROW_FAIL: fprintf(stderr, "error: ct_fetch() returned CS_ROW_FAIL on row %d.\n", row_count); free(addr); return 1; case CS_CANCELED: fprintf(stderr, "error: ct_fetch() returned CS_CANCELED??\n"); free(addr); return 1; case CS_FAIL: fprintf(stderr, "error: ct_fetch() returned CS_FAIL.\n"); free(addr); return 1; default: fprintf(stderr, "error: ct_fetch() unexpected return.\n"); free(addr); return 1; } } break; } } switch ((int) results_ret) { case CS_END_RESULTS: break; case CS_FAIL: fprintf(stderr, "ct_results() failed.\n"); free(addr); return 1; break; default: fprintf(stderr, "ct_results() unexpected return.\n"); free(addr); return 1; } if (verbose) { fprintf(stdout, "Trying logout\n"); } ret = try_ctlogout(ctx, conn, cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Logout failed\n"); free(addr); return 1; } free(addr); return 0; } freetds-1.00.82/src/ctlib/unittests/get_send_data.c100644 025423 025423 00000014624 12717145107 0015715#include #include #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include "common.h" static CS_CONNECTION *conn = NULL; /* Testing: Retrieve CS_TEXT_TYPE using ct_bind() */ int main(int argc, char **argv) { CS_CONTEXT *ctx; CS_COMMAND *cmd; int i, verbose = 0; CS_RETCODE ret; CS_RETCODE ret2; CS_RETCODE results_ret; CS_INT result_type; CS_INT num_cols; CS_DATAFMT datafmt; CS_INT datalength; CS_SMALLINT ind; CS_INT count, row_count = 0; CS_INT id; CS_CHAR name[600]; CS_CHAR *nameptr; CS_INT getlen; char large_sql[1024]; char len600[601]; char len800[801]; char temp[11]; char *textptr; CS_IODESC iodesc; int tds_version; len600[0] = 0; name[0] = 0; for (i = 0; i < 60; i++) { sprintf(temp, "_abcde_%03d", (i + 1) * 10); strcat(len600, temp); } len600[600] = '\0'; len800[0] = 0; for (i = 0; i < 80; i++) { sprintf(temp, "_zzzzz_%03d", (i + 1) * 10); strcat(len800, temp); } len800[800] = '\0'; fprintf(stdout, "%s: Retrieve CS_TEXT_TYPE using ct_bind()\n", __FILE__); if (verbose) { fprintf(stdout, "Trying login\n"); } ret = try_ctlogin(&ctx, &conn, &cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Login failed\n"); return 1; } ret = ct_con_props(conn, CS_GET, CS_TDS_VERSION, &tds_version, CS_UNUSED, NULL); if (ret == CS_SUCCEED) { if (tds_version >= CS_TDS_72) { printf("Protocol TDS7.2+ detected, test not supported\n"); try_ctlogout(ctx, conn, cmd, verbose); return 0; } } ret = run_command(cmd, "CREATE TABLE #test_table (id int, name text)"); if (ret != CS_SUCCEED) return 1; sprintf(large_sql, "INSERT #test_table (id, name) VALUES (2, '%s')", len600); ret = run_command(cmd, large_sql); if (ret != CS_SUCCEED) return 1; ret = ct_command(cmd, CS_LANG_CMD, "SELECT id, name FROM #test_table", CS_NULLTERM, CS_UNUSED); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_command() failed\n"); return 1; } ret = ct_send(cmd); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_send() failed\n"); return 1; } while ((results_ret = ct_results(cmd, &result_type)) == CS_SUCCEED) { switch ((int) result_type) { case CS_CMD_SUCCEED: break; case CS_CMD_DONE: break; case CS_CMD_FAIL: fprintf(stderr, "ct_results() result_type CS_CMD_FAIL.\n"); return 1; case CS_ROW_RESULT: ret = ct_res_info(cmd, CS_NUMDATA, &num_cols, CS_UNUSED, NULL); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_res_info() failed"); return 1; } if (num_cols != 2) { fprintf(stderr, "num_cols %d != 2", num_cols); return 1; } ret = ct_describe(cmd, 1, &datafmt); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_describe() failed"); return 1; } datafmt.format = CS_FMT_UNUSED; if (datafmt.maxlength > 1024) { datafmt.maxlength = 1024; } ret = ct_bind(cmd, 1, &datafmt, &id, &datalength, &ind); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_bind() failed\n"); return 1; } while (((ret = ct_fetch(cmd, CS_UNUSED, CS_UNUSED, CS_UNUSED, &count)) == CS_SUCCEED) || (ret == CS_ROW_FAIL)) { row_count += count; if (ret == CS_ROW_FAIL) { fprintf(stderr, "ct_fetch() CS_ROW_FAIL on row %d.\n", row_count); return 1; } else { /* ret == CS_SUCCEED */ if (verbose) { fprintf(stdout, "id = '%d'\n", id); } nameptr = name; while ((ret2 = ct_get_data(cmd, 2 , nameptr, 200, &getlen )) == CS_SUCCEED) { nameptr += getlen; } if (ret2 != CS_END_DATA) { fprintf(stderr, "ct_get_data() failed\n"); return 1; } if (memcmp(name, len600, 600)) { fprintf(stderr, "Bad return data\n"); return 1; } fprintf(stdout, "%s: Trying ct_data_info on text column\n", __FILE__); if (ct_data_info(cmd, CS_GET, 2, &iodesc) != CS_SUCCEED) { fprintf(stderr, "ct_data_info() failed\n"); return 1; } else { fprintf(stdout, "datatype = %d\n", iodesc.datatype); fprintf(stdout, "usertype = %d\n", iodesc.usertype); fprintf(stdout, "text len = %d\n", iodesc.total_txtlen); fprintf(stdout, "name = %*.*s\n", iodesc.namelen, iodesc.namelen, iodesc.name); } } } switch ((int) ret) { case CS_END_DATA: break; case CS_FAIL: fprintf(stderr, "ct_fetch() returned CS_FAIL.\n"); return 1; default: fprintf(stderr, "ct_fetch() unexpected return.\n"); return 1; } break; case CS_COMPUTE_RESULT: fprintf(stderr, "ct_results() unexpected CS_COMPUTE_RESULT.\n"); return 1; default: fprintf(stderr, "ct_results() unexpected result_type.\n"); return 1; } } switch ((int) results_ret) { case CS_END_RESULTS: break; case CS_FAIL: fprintf(stderr, "ct_results() failed.\n"); return 1; break; default: fprintf(stderr, "ct_results() unexpected return.\n"); return 1; } if ((ret = ct_command(cmd, CS_SEND_DATA_CMD, NULL, CS_UNUSED, CS_COLUMN_DATA)) != CS_SUCCEED) { fprintf(stderr, "ct_command(CS_SEND_DATA_CMD) failed.\n"); return 1; } iodesc.total_txtlen = 800; iodesc.log_on_update = CS_TRUE; if (ct_data_info(cmd, CS_SET, CS_UNUSED, &iodesc) != CS_SUCCEED) { fprintf(stderr, "ct_data_info() failed\n"); return 1; } for ( i = 0 ; i < 800 ; i += 200 ) { textptr = &len800[i]; ret = ct_send_data(cmd, textptr, (CS_INT) 200); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_send_data failed\n"); return 1; } } ret = ct_send(cmd); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_send failed\n"); return 1; } while ((results_ret = ct_results(cmd, &result_type)) == CS_SUCCEED) { switch ((int) result_type) { case CS_CMD_SUCCEED: break; case CS_CMD_DONE: break; case CS_CMD_FAIL: fprintf(stderr, "ct_results() result_type CS_CMD_FAIL.\n"); return 1; case CS_ROW_RESULT: break; case CS_PARAM_RESULT: break; case CS_COMPUTE_RESULT: fprintf(stderr, "ct_results() unexpected CS_COMPUTE_RESULT.\n"); return 1; default: fprintf(stderr, "ct_results() unexpected result_type.\n"); return 1; } } switch ((int) results_ret) { case CS_END_RESULTS: break; case CS_FAIL: fprintf(stderr, "ct_results() failed.\n"); return 1; break; default: fprintf(stderr, "ct_results() unexpected return.\n"); return 1; } if (verbose) { fprintf(stdout, "Trying logout\n"); } ret = try_ctlogout(ctx, conn, cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Logout failed\n"); return 1; } return 0; } freetds-1.00.82/src/ctlib/unittests/lang_ct_param.c100644 025423 025423 00000022416 12717145107 0015721#include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include "common.h" static const char *query = "insert into #ctparam_lang (name,name2,age,cost,bdate,fval) values (@in1, @in2, @in3, @moneyval, @dateval, @floatval)"; CS_RETCODE ex_servermsg_cb(CS_CONTEXT * context, CS_CONNECTION * connection, CS_SERVERMSG * errmsg); CS_RETCODE ex_clientmsg_cb(CS_CONTEXT * context, CS_CONNECTION * connection, CS_CLIENTMSG * errmsg); static int insert_test(CS_CONNECTION *conn, CS_COMMAND *cmd, int useNames); /* Testing: binding of data via ct_param */ int main(int argc, char *argv[]) { int errCode = 0; CS_CONTEXT *ctx; CS_CONNECTION *conn; CS_COMMAND *cmd; int verbose = 0; CS_RETCODE ret; CS_CHAR cmdbuf[4096]; if (argc > 1 && (0 == strcmp(argv[1], "-v"))) verbose = 1; printf("%s: submit language query with variables using ct_param\n", __FILE__); if (verbose) { fprintf(stdout, "Trying login\n"); } ret = try_ctlogin(&ctx, &conn, &cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Login failed\n"); return 1; } ct_callback(ctx, NULL, CS_SET, CS_CLIENTMSG_CB, (CS_VOID *) ex_clientmsg_cb); ct_callback(ctx, NULL, CS_SET, CS_SERVERMSG_CB, (CS_VOID *) ex_servermsg_cb); strcpy(cmdbuf, "create table #ctparam_lang (id numeric identity not null, \ name varchar(30), name2 varchar(20), age int, cost money, bdate datetime, fval float) "); ret = run_command(cmd, cmdbuf); if (ret != CS_SUCCEED) { fprintf(stderr, "create table failed\n"); errCode = 1; goto ERR; } /* test by name */ errCode = insert_test(conn, cmd, 1); /* if worked, test by position */ if (0 == errCode) errCode = insert_test(conn, cmd, 0); query = "insert into #ctparam_lang (name,name2,age,cost,bdate,fval) values (?, ?, ?, ?, ?, ?)"; if (0 == errCode) errCode = insert_test(conn, cmd, 0); if (verbose && (0 == errCode)) fprintf(stdout, "lang_ct_param tests successful\n"); ERR: if (verbose) { fprintf(stdout, "Trying logout\n"); } ret = try_ctlogout(ctx, conn, cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Logout failed\n"); return 1; } return errCode; } static int insert_test(CS_CONNECTION *conn, CS_COMMAND *cmd, int useNames) { CS_CONTEXT *ctx; CS_RETCODE ret; CS_INT res_type; CS_DATAFMT datafmt; CS_DATAFMT srcfmt; CS_DATAFMT destfmt; CS_INT intvar; CS_FLOAT floatvar; CS_MONEY moneyvar; CS_DATEREC datevar; char moneystring[10]; char dummy_name[30]; char dummy_name2[20]; CS_INT destlen; CS_INT rowsAffected = -1; int rows_found; /* clear table */ run_command(cmd, "delete #ctparam_lang"); /* * Assign values to the variables used for parameter passing. */ intvar = 2; floatvar = 0.12; strcpy(dummy_name, "joe blow"); strcpy(dummy_name2, ""); strcpy(moneystring, "300.90"); /* * Clear and setup the CS_DATAFMT structures used to convert datatypes. */ memset(&srcfmt, 0, sizeof(CS_DATAFMT)); srcfmt.datatype = CS_CHAR_TYPE; srcfmt.maxlength = strlen(moneystring); srcfmt.precision = 5; srcfmt.scale = 2; srcfmt.locale = NULL; memset(&destfmt, 0, sizeof(CS_DATAFMT)); destfmt.datatype = CS_MONEY_TYPE; destfmt.maxlength = sizeof(CS_MONEY); destfmt.precision = 5; destfmt.scale = 2; destfmt.locale = NULL; /* * Convert the string representing the money value * to a CS_MONEY variable. Since this routine does not have the * context handle, we use the property functions to get it. */ if ((ret = ct_cmd_props(cmd, CS_GET, CS_PARENT_HANDLE, &conn, CS_UNUSED, NULL)) != CS_SUCCEED) { fprintf(stderr, "ct_cmd_props() failed\n"); return 1; } if ((ret = ct_con_props(conn, CS_GET, CS_PARENT_HANDLE, &ctx, CS_UNUSED, NULL)) != CS_SUCCEED) { fprintf(stderr, "ct_con_props() failed\n"); return 1; } ret = cs_convert(ctx, &srcfmt, (CS_VOID *) moneystring, &destfmt, &moneyvar, &destlen); if (ret != CS_SUCCEED) { fprintf(stderr, "cs_convert() failed\n"); return 1; } /* * create the command */ if ((ret = ct_command(cmd, CS_LANG_CMD, query, strlen(query), CS_UNUSED)) != CS_SUCCEED) { fprintf(stderr, "ct_command(CS_LANG_CMD) failed\n"); return 1; } /* * Clear and setup the CS_DATAFMT structure, then pass * each of the parameters for the query. */ memset(&datafmt, 0, sizeof(datafmt)); if (useNames) strcpy(datafmt.name, "@in1"); else datafmt.name[0] = 0; datafmt.maxlength = 255; datafmt.namelen = CS_NULLTERM; datafmt.datatype = CS_CHAR_TYPE; datafmt.status = CS_INPUTVALUE; /* * The character string variable is filled in by the RPC so pass NULL * for the data 0 for data length, and -1 for the indicator arguments. */ ret = ct_param(cmd, &datafmt, dummy_name, strlen(dummy_name), 0); if (CS_SUCCEED != ret) { fprintf(stderr, "ct_param(char) failed\n"); return 1; } if (useNames) strcpy(datafmt.name, "@in2"); else datafmt.name[0] = 0; datafmt.maxlength = 255; datafmt.namelen = CS_NULLTERM; datafmt.datatype = CS_CHAR_TYPE; datafmt.status = CS_INPUTVALUE; ret = ct_param(cmd, &datafmt, dummy_name2, strlen(dummy_name2), 0); if (CS_SUCCEED != ret) { fprintf(stderr, "ct_param(char) failed\n"); return 1; } if (useNames) strcpy(datafmt.name, "@in3"); else datafmt.name[0] = 0; datafmt.namelen = CS_NULLTERM; datafmt.datatype = CS_INT_TYPE; datafmt.status = CS_INPUTVALUE; ret = ct_param(cmd, &datafmt, (CS_VOID *) & intvar, CS_SIZEOF(CS_INT), 0); if (CS_SUCCEED != ret) { fprintf(stderr, "ct_param(int) failed\n"); return 1; } if (useNames) strcpy(datafmt.name, "@moneyval"); else datafmt.name[0] = 0; datafmt.namelen = CS_NULLTERM; datafmt.datatype = CS_MONEY_TYPE; datafmt.status = CS_INPUTVALUE; ret = ct_param(cmd, &datafmt, (CS_VOID *) & moneyvar, CS_SIZEOF(CS_MONEY), 0); if (CS_SUCCEED != ret) { fprintf(stderr, "ct_param(money) failed\n"); return 1; } if (useNames) strcpy(datafmt.name, "@dateval"); else datafmt.name[0] = 0; datafmt.namelen = CS_NULLTERM; datafmt.datatype = CS_DATETIME_TYPE; datafmt.status = CS_INPUTVALUE; memset(&datevar, 0, sizeof(CS_DATEREC)); datevar.dateyear = 2003; datevar.datemonth = 2; datevar.datedmonth = 1; ret = ct_param(cmd, &datafmt, &datevar, 0, 0); if (CS_SUCCEED != ret) { fprintf(stderr, "ct_param(datetime) failed"); return 1; } if (useNames) strcpy(datafmt.name, "@floatval"); else datafmt.name[0] = 0; datafmt.namelen = CS_NULLTERM; datafmt.datatype = CS_FLOAT_TYPE; datafmt.status = CS_INPUTVALUE; ret = ct_param(cmd, &datafmt, &floatvar, 0, 0); if (CS_SUCCEED != ret) { fprintf(stderr, "ct_param(float) failed"); return 1; } /* * Send the command to the server */ if (ct_send(cmd) != CS_SUCCEED) { fprintf(stderr, "ct_send(CS_LANG_CMD) failed\n"); return 1; } /* * Process the results. */ while ((ret = ct_results(cmd, &res_type)) == CS_SUCCEED) { switch ((int) res_type) { case CS_CMD_SUCCEED: case CS_CMD_DONE: { CS_INT rowsAffected=0; ct_res_info(cmd, CS_ROW_COUNT, &rowsAffected, CS_UNUSED, NULL); if (1 != rowsAffected) fprintf(stderr, "insert touched %d rows instead of 1\n", rowsAffected); else rows_found = 1; } break; case CS_CMD_FAIL: /* * The server encountered an error while * processing our command. */ fprintf(stderr, "ct_results returned CS_CMD_FAIL.\n"); break; case CS_STATUS_RESULT: /* * The server encountered an error while * processing our command. */ fprintf(stderr, "ct_results returned CS_STATUS_RESULT.\n"); break; default: /* * We got something unexpected. */ fprintf(stderr, "ct_results returned unexpected result type %d\n", res_type); return 1; } } if (ret != CS_END_RESULTS) { fprintf(stderr, "ct_results returned unexpected result %d.\n", (int) ret); exit(1); } if (!rows_found) { fprintf(stderr, "expected 1 rows inserted, inserted %d.\n", (int) rowsAffected); exit(1); } /* test row inserted */ ret = run_command(cmd, "if not exists(select * from #ctparam_lang where name = 'joe blow' and name2 is not null and age = 2) select 1"); if (ret != CS_SUCCEED) { fprintf(stderr, "check row inserted failed\n"); exit(1); } return 0; } CS_RETCODE ex_clientmsg_cb(CS_CONTEXT * context, CS_CONNECTION * connection, CS_CLIENTMSG * errmsg) { fprintf(stdout, "\nOpen Client Message:\n"); fprintf(stdout, "Message number: LAYER = (%d) ORIGIN = (%d) ", CS_LAYER(errmsg->msgnumber), CS_ORIGIN(errmsg->msgnumber)); fprintf(stdout, "SEVERITY = (%d) NUMBER = (%d)\n", CS_SEVERITY(errmsg->msgnumber), CS_NUMBER(errmsg->msgnumber)); fprintf(stdout, "Message String: %s\n", errmsg->msgstring); if (errmsg->osstringlen > 0) { fprintf(stdout, "Operating System Error: %s\n", errmsg->osstring); } fflush(stdout); return CS_SUCCEED; } CS_RETCODE ex_servermsg_cb(CS_CONTEXT * context, CS_CONNECTION * connection, CS_SERVERMSG * srvmsg) { fprintf(stdout, "\nServer message:\n"); fprintf(stdout, "Message number: %d, Severity %d, ", srvmsg->msgnumber, srvmsg->severity); fprintf(stdout, "State %d, Line %d\n", srvmsg->state, srvmsg->line); if (srvmsg->svrnlen > 0) { fprintf(stdout, "Server '%s'\n", srvmsg->svrname); } if (srvmsg->proclen > 0) { fprintf(stdout, " Procedure '%s'\n", srvmsg->proc); } fprintf(stdout, "Message String: %s\n", srvmsg->text); fflush(stdout); return CS_SUCCEED; } freetds-1.00.82/src/ctlib/unittests/row_count.c100644 025423 025423 00000023355 12717145107 0015154/* * Tests rows count * * These are the results using Sybase CT-Library. This test check that ct_results returns the same results. * * * "insert into #tmp1 values(1) " * "insert into #tmp1 values(2) " * "insert into #tmp1 values(3) " * "select * from #tmp1 " * * Open Client Message: * number 16843050 layer 1 origin 1 severity 1 number 42 * msgstring: ct_res_info(ROWCOUNT): user api layer: external error: This routine cannot be called after ct_results() returns a result type of CS_ROW_RESULT. * osstring: (null) * ct_results returned CS_ROW_RESULT type and -1 rows * All done processing rows. * ct_results returned CS_CMD_DONE type and 3 rows * * Open Client Message: * number 16843051 layer 1 origin 1 severity 1 number 43 * msgstring: ct_res_info(ROWCOUNT): user api layer: external error: This routine cannot be called after ct_results() returns a result type of CS_STATUS_RESULT. * osstring: (null) * ct_results returned CS_STATUS_RESULT type and -1 rows * All done processing rows. * ct_results returned CS_CMD_SUCCEED type and -1 rows * ct_results returned CS_CMD_DONE type and -1 rows * * * "insert into #tmp1 values(1) " * "insert into #tmp1 values(2) " * "insert into #tmp1 values(3) " * "select * from #tmp1 " * "insert into #tmp1 values(4) " * "delete from #tmp1 where i <= 2 " * * Open Client Message: * number 16843050 layer 1 origin 1 severity 1 number 42 * msgstring: ct_res_info(ROWCOUNT): user api layer: external error: This routine cannot be called after ct_results() returns a result type of CS_ROW_RESULT. * osstring: (null) * ct_results returned CS_ROW_RESULT type and -1 rows * All done processing rows. * ct_results returned CS_CMD_DONE type and 3 rows * * Open Client Message: * number 16843051 layer 1 origin 1 severity 1 number 43 * msgstring: ct_res_info(ROWCOUNT): user api layer: external error: This routine cannot be called after ct_results() returns a result type of CS_STATUS_RESULT. * osstring: (null) * ct_results returned CS_STATUS_RESULT type and -1 rows * All done processing rows. * ct_results returned CS_CMD_SUCCEED type and 2 rows * ct_results returned CS_CMD_DONE type and 2 rows */ #undef NDEBUG #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include "common.h" #include "replacements.h" static CS_CONTEXT *ctx; static CS_CONNECTION *conn; static CS_COMMAND *cmd; static CS_RETCODE ex_clientmsg_cb(CS_CONTEXT * context, CS_CONNECTION * connection, CS_CLIENTMSG * errmsg); static CS_RETCODE ex_servermsg_cb(CS_CONTEXT * context, CS_CONNECTION * connection, CS_SERVERMSG * errmsg); static CS_INT ex_display_results(CS_COMMAND * cmd, char *results); static int test(int final_rows, int no_rows); int main(int argc, char *argv[]) { CS_RETCODE ret; printf("%s: check row count returned\n", __FILE__); ret = try_ctlogin(&ctx, &conn, &cmd, 0); if (ret != CS_SUCCEED) { fprintf(stderr, "Login failed\n"); return 1; } ct_callback(ctx, NULL, CS_SET, CS_CLIENTMSG_CB, (CS_VOID *) ex_clientmsg_cb); ct_callback(ctx, NULL, CS_SET, CS_SERVERMSG_CB, (CS_VOID *) ex_servermsg_cb); /* do not test error */ run_command(cmd, "DROP PROCEDURE sample_rpc"); run_command(cmd, "drop table #tmp1"); /* test with rows from select */ if (test(0, 0) || test(1, 0)) return 1; /* test with empty select */ if (test(0, 1) || test(1, 1)) return 1; ret = try_ctlogout(ctx, conn, cmd, 0); if (ret != CS_SUCCEED) { fprintf(stderr, "Logout failed\n"); return 1; } return 0; } static int test(int final_rows, int no_rows) { CS_RETCODE ret; CS_CHAR cmdbuf[4096]; char results[1024]; run_command(cmd, "create table #tmp1 (i int not null)"); results[0] = 0; strcpy(cmdbuf, "create proc sample_rpc as "); strcat(results, "CS_ROW_RESULT -1\n"); strcat(cmdbuf, "insert into #tmp1 values(1) " "insert into #tmp1 values(2) " "insert into #tmp1 values(3) " ); if (no_rows) { strcat(cmdbuf, "select * from #tmp1 where i > 10 "); strcat(results, "CS_CMD_DONE 0\n"); } else { strcat(cmdbuf, "select * from #tmp1 "); strcat(results, "CS_CMD_DONE 3\n"); } strcat(results, "CS_STATUS_RESULT -1\n"); if (final_rows) { strcat(cmdbuf, "insert into #tmp1 values(4) " "delete from #tmp1 where i <= 2 " ); strcat(results, "CS_CMD_SUCCEED 2\n" "CS_CMD_DONE 2\n"); } else { strcat(results, "CS_CMD_SUCCEED -1\n" "CS_CMD_DONE -1\n"); } printf("testing query:\n----\n%s\n----\n", cmdbuf); ret = run_command(cmd, cmdbuf); if (ret != CS_SUCCEED) { fprintf(stderr, "create proc failed\n"); return 1; } printf("----------\n"); if ((ret = ct_command(cmd, CS_RPC_CMD, "sample_rpc", CS_NULLTERM, CS_NO_RECOMPILE)) != CS_SUCCEED) { fprintf(stderr, "ct_command(CS_RPC_CMD) failed"); return 1; } if (ct_send(cmd) != CS_SUCCEED) { fprintf(stderr, "ct_send(RPC) failed"); return 1; } ex_display_results(cmd, results); /* cleanup */ run_command(cmd, "DROP PROCEDURE sample_rpc"); run_command(cmd, "drop table #tmp1"); return 0; } static CS_INT ex_display_results(CS_COMMAND * cmd, char *results) { CS_RETCODE ret; CS_INT res_type; CS_INT num_cols; CS_INT row_count = 0; CS_INT rows_read; CS_SMALLINT msg_id; /* * Process the results of the RPC. */ while ((ret = ct_results(cmd, &res_type)) == CS_SUCCEED) { char res[32]; int rows, pos; CS_INT rowsAffected = -1; ct_res_info(cmd, CS_ROW_COUNT, &rowsAffected, CS_UNUSED, NULL); printf("ct_results returned %s type and %d rows\n", res_type_str(res_type), (int) rowsAffected); /* check expected results are the same as got ones */ pos = -1; assert(sscanf(results, "%30s %d %n", res, &rows, &pos) >= 2 && pos > 0); results += pos; if (strcmp(res_type_str(res_type), res) != 0 || rowsAffected != rows) { fprintf(stderr, "Expected ct_results %s rows %d\n", res, rows); exit(1); } switch (res_type) { case CS_ROW_RESULT: case CS_PARAM_RESULT: case CS_STATUS_RESULT: /* * All three of these result types are fetchable. * Since the result model for rpcs and rows have * been unified in the New Client-Library, we * will use the same routine to display them */ /* * Find out how many columns there are in this result set. */ ret = ct_res_info(cmd, CS_NUMDATA, &num_cols, CS_UNUSED, NULL); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_res_info(CS_NUMDATA) failed"); return 1; } /* * Make sure we have at least one column */ if (num_cols <= 0) { fprintf(stderr, "ct_res_info(CS_NUMDATA) returned zero columns"); return 1; } while (((ret = ct_fetch(cmd, CS_UNUSED, CS_UNUSED, CS_UNUSED, &rows_read)) == CS_SUCCEED) || (ret == CS_ROW_FAIL)) { /* * Increment our row count by the number of rows just fetched. */ row_count = row_count + rows_read; /* * Check if we hit a recoverable error. */ if (ret == CS_ROW_FAIL) { fprintf(stdout, "Error on row %d.\n", row_count); fflush(stdout); } } /* * We're done processing rows. Let's check the final return * value of ct_fetch(). */ switch ((int) ret) { case CS_END_DATA: /* * Everything went fine. */ printf("All done processing rows.\n"); fflush(stdout); break; case CS_FAIL: /* * Something terrible happened. */ fprintf(stderr, "ct_fetch returned CS_FAIL\n"); return 1; break; default: /* * We got an unexpected return value. */ fprintf(stderr, "ct_fetch returned %d\n", ret); return 1; break; } break; case CS_MSG_RESULT: ret = ct_res_info(cmd, CS_MSGTYPE, (CS_VOID *) & msg_id, CS_UNUSED, NULL); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_res_info(msg_id) failed"); return 1; } printf("ct_result returned CS_MSG_RESULT where msg id = %d.\n", msg_id); fflush(stdout); break; case CS_CMD_SUCCEED: case CS_CMD_DONE: case CS_CMD_FAIL: break; default: /* * We got something unexpected. */ fprintf(stderr, "ct_results returned unexpected result type."); return CS_FAIL; } } /* * We're done processing results. Let's check the * return value of ct_results() to see if everything * went ok. */ switch ((int) ret) { case CS_END_RESULTS: /* * Everything went fine. */ break; case CS_FAIL: /* * Something failed happened. */ fprintf(stderr, "ct_results failed."); break; default: /* * We got an unexpected return value. */ fprintf(stderr, "ct_results returned unexpected result type."); break; } return CS_SUCCEED; } static CS_RETCODE ex_clientmsg_cb(CS_CONTEXT * context, CS_CONNECTION * connection, CS_CLIENTMSG * errmsg) { printf("\nOpen Client Message:\n"); printf("Message number: LAYER = (%ld) ORIGIN = (%ld) ", (long) CS_LAYER(errmsg->msgnumber), (long) CS_ORIGIN(errmsg->msgnumber)); printf("SEVERITY = (%ld) NUMBER = (%ld)\n", (long) CS_SEVERITY(errmsg->msgnumber), (long) CS_NUMBER(errmsg->msgnumber)); printf("Message String: %s\n", errmsg->msgstring); if (errmsg->osstringlen > 0) { printf("Operating System Error: %s\n", errmsg->osstring); } fflush(stdout); return CS_SUCCEED; } static CS_RETCODE ex_servermsg_cb(CS_CONTEXT * context, CS_CONNECTION * connection, CS_SERVERMSG * srvmsg) { printf("\nServer message:\n"); printf("Message number: %ld, Severity %ld, ", (long) srvmsg->msgnumber, (long) srvmsg->severity); printf("State %ld, Line %ld\n", (long) srvmsg->state, (long) srvmsg->line); if (srvmsg->svrnlen > 0) { printf("Server '%s'\n", srvmsg->svrname); } if (srvmsg->proclen > 0) { printf(" Procedure '%s'\n", srvmsg->proc); } printf("Message String: %s\n", srvmsg->text); fflush(stdout); return CS_SUCCEED; } freetds-1.00.82/src/ctlib/unittests/rpc_ct_param.c100644 025423 025423 00000041023 12522201763 0015552#include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STRING_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include "common.h" #define MAX(X,Y) (((X) > (Y)) ? (X) : (Y)) #define MIN(X,Y) (((X) < (Y)) ? (X) : (Y)) static char software_version[] = "$Id: rpc_ct_param.c,v 1.10 2011-05-16 08:51:40 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; CS_RETCODE ex_clientmsg_cb(CS_CONTEXT * context, CS_CONNECTION * connection, CS_CLIENTMSG * errmsg); CS_RETCODE ex_servermsg_cb(CS_CONTEXT * context, CS_CONNECTION * connection, CS_SERVERMSG * errmsg); static CS_INT ex_display_dlen(CS_DATAFMT * column); static CS_RETCODE ex_display_header(CS_INT numcols, CS_DATAFMT columns[]); typedef struct _ex_column_data { CS_SMALLINT indicator; CS_CHAR *value; CS_INT valuelen; } EX_COLUMN_DATA; /* Testing: array binding of result set */ int main(int argc, char *argv[]) { CS_CONTEXT *ctx; CS_CONNECTION *conn; CS_COMMAND *cmd; int verbose = 0; CS_RETCODE ret; CS_INT res_type; CS_INT num_cols; CS_CHAR cmdbuf[4096]; CS_DATAFMT datafmt; CS_DATAFMT srcfmt; CS_DATAFMT destfmt; CS_INT intvar; CS_SMALLINT smallintvar; CS_FLOAT floatvar; CS_MONEY moneyvar; CS_BINARY binaryvar; char moneystring[10]; char rpc_name[15]; CS_INT destlen; CS_INT i; CS_INT j; CS_INT row_count = 0; CS_INT rows_read; CS_INT disp_len; EX_COLUMN_DATA *coldata; CS_DATAFMT *outdatafmt; CS_SMALLINT msg_id; fprintf(stdout, "%s: submit a stored procedure using ct_param \n", __FILE__); if (verbose) { fprintf(stdout, "Trying login\n"); } ret = try_ctlogin(&ctx, &conn, &cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Login failed\n"); return 1; } ct_callback(ctx, NULL, CS_SET, CS_CLIENTMSG_CB, (CS_VOID *) ex_clientmsg_cb); ct_callback(ctx, NULL, CS_SET, CS_SERVERMSG_CB, (CS_VOID *) ex_servermsg_cb); /* do not test error */ ret = run_command(cmd, "IF EXISTS(SELECT * FROM SYSOBJECTS WHERE name = 'sample_rpc' AND type = 'P') DROP PROCEDURE sample_rpc"); strcpy(cmdbuf, "create proc sample_rpc (@intparam int, \ @sintparam smallint output, @floatparam float output, \ @moneyparam money output, \ @dateparam datetime output, @charparam char(20) output, @empty varchar(20) output, \ @binaryparam binary(20) output) \ as "); strcat(cmdbuf, "select @intparam, @sintparam, @floatparam, @moneyparam, \ @dateparam, @charparam, @binaryparam \ select @sintparam = @sintparam + @intparam \ select @floatparam = @floatparam + @intparam \ select @moneyparam = @moneyparam + convert(money, @intparam) \ select @dateparam = getdate() \ select @charparam = \'The char parameters\' \ select @empty = \'\' \ select @binaryparam = @binaryparam \ print \'This is the message printed out by sample_rpc.\'"); ret = run_command(cmd, cmdbuf); if (ret != CS_SUCCEED) { fprintf(stderr, "create proc failed\n"); return 1; } /* * Assign values to the variables used for parameter passing. */ intvar = 2; smallintvar = 234; floatvar = 0.12; binaryvar = (CS_BINARY) 0xff; strcpy(rpc_name, "sample_rpc"); strcpy(moneystring, "300.90"); /* * Clear and setup the CS_DATAFMT structures used to convert datatypes. */ memset(&srcfmt, 0, sizeof(CS_DATAFMT)); srcfmt.datatype = CS_CHAR_TYPE; srcfmt.maxlength = strlen(moneystring); srcfmt.precision = 5; srcfmt.scale = 2; srcfmt.locale = NULL; memset(&destfmt, 0, sizeof(CS_DATAFMT)); destfmt.datatype = CS_MONEY_TYPE; destfmt.maxlength = sizeof(CS_MONEY); destfmt.precision = 5; destfmt.scale = 2; destfmt.locale = NULL; /* * Convert the string representing the money value * to a CS_MONEY variable. Since this routine does not have the * context handle, we use the property functions to get it. */ if ((ret = ct_cmd_props(cmd, CS_GET, CS_PARENT_HANDLE, &conn, CS_UNUSED, NULL)) != CS_SUCCEED) { fprintf(stderr, "ct_cmd_props() failed"); return 1; } if ((ret = ct_con_props(conn, CS_GET, CS_PARENT_HANDLE, &ctx, CS_UNUSED, NULL)) != CS_SUCCEED) { fprintf(stderr, "ct_con_props() failed"); return 1; } ret = cs_convert(ctx, &srcfmt, (CS_VOID *) moneystring, &destfmt, &moneyvar, &destlen); if (ret != CS_SUCCEED) { fprintf(stderr, "cs_convert() failed"); return 1; } /* * Send the RPC command for our stored procedure. */ if ((ret = ct_command(cmd, CS_RPC_CMD, rpc_name, CS_NULLTERM, CS_NO_RECOMPILE)) != CS_SUCCEED) { fprintf(stderr, "ct_command(CS_RPC_CMD) failed"); return 1; } /* * Clear and setup the CS_DATAFMT structure, then pass * each of the parameters for the RPC. */ memset(&datafmt, 0, sizeof(datafmt)); strcpy(datafmt.name, "@intparam"); datafmt.namelen = CS_NULLTERM; datafmt.datatype = CS_INT_TYPE; datafmt.maxlength = CS_UNUSED; datafmt.status = CS_INPUTVALUE; datafmt.locale = NULL; if ((ret = ct_param(cmd, &datafmt, (CS_VOID *) & intvar, CS_SIZEOF(CS_INT), 0)) != CS_SUCCEED) { fprintf(stderr, "ct_param(int) failed"); return 1; } strcpy(datafmt.name, "@sintparam"); datafmt.namelen = CS_NULLTERM; datafmt.datatype = CS_SMALLINT_TYPE; datafmt.maxlength = 255; datafmt.status = CS_RETURN; datafmt.locale = NULL; if ((ret = ct_param(cmd, &datafmt, (CS_VOID *) & smallintvar, CS_SIZEOF(CS_SMALLINT), 0)) != CS_SUCCEED) { fprintf(stderr, "ct_param(smallint) failed"); return 1; } strcpy(datafmt.name, "@floatparam"); datafmt.namelen = CS_NULLTERM; datafmt.datatype = CS_FLOAT_TYPE; datafmt.maxlength = 255; datafmt.status = CS_RETURN; datafmt.locale = NULL; if ((ret = ct_param(cmd, &datafmt, (CS_VOID *) & floatvar, CS_SIZEOF(CS_FLOAT), 0)) != CS_SUCCEED) { fprintf(stderr, "ct_param(float) failed"); return 1; } strcpy(datafmt.name, "@moneyparam"); datafmt.namelen = CS_NULLTERM; datafmt.datatype = CS_MONEY_TYPE; datafmt.maxlength = 255; datafmt.status = CS_RETURN; datafmt.locale = NULL; if ((ret = ct_param(cmd, &datafmt, (CS_VOID *) & moneyvar, CS_SIZEOF(CS_MONEY), 0)) != CS_SUCCEED) { fprintf(stderr, "ct_param(money) failed"); return 1; } strcpy(datafmt.name, "@dateparam"); datafmt.namelen = CS_NULLTERM; datafmt.datatype = CS_DATETIME4_TYPE; datafmt.maxlength = 255; datafmt.status = CS_RETURN; datafmt.locale = NULL; /* * The datetime variable is filled in by the RPC so pass NULL for * the data, 0 for data length, and -1 for the indicator arguments. */ if ((ret = ct_param(cmd, &datafmt, NULL, 0, -1)) != CS_SUCCEED) { fprintf(stderr, "ct_param(datetime4) failed"); return 1; } strcpy(datafmt.name, "@charparam"); datafmt.namelen = CS_NULLTERM; datafmt.datatype = CS_CHAR_TYPE; datafmt.maxlength = 60; datafmt.status = CS_RETURN; datafmt.locale = NULL; /* * The character string variable is filled in by the RPC so pass NULL * for the data 0 for data length, and -1 for the indicator arguments. */ if ((ret = ct_param(cmd, &datafmt, NULL, 0, -1)) != CS_SUCCEED) { fprintf(stderr, "ct_param(char) failed"); return 1; } strcpy(datafmt.name, "@empty"); datafmt.namelen = CS_NULLTERM; datafmt.datatype = CS_VARCHAR_TYPE; datafmt.maxlength = 60; datafmt.status = CS_RETURN; datafmt.locale = NULL; /* * The character string variable is filled in by the RPC so pass NULL * for the data 0 for data length, and -1 for the indicator arguments. */ if ((ret = ct_param(cmd, &datafmt, NULL, 0, -1)) != CS_SUCCEED) { fprintf(stderr, "ct_param(char) failed"); return 1; } strcpy(datafmt.name, "@binaryparam"); datafmt.namelen = CS_NULLTERM; datafmt.datatype = CS_BINARY_TYPE; datafmt.maxlength = 255; datafmt.status = CS_RETURN; datafmt.locale = NULL; if ((ret = ct_param(cmd, &datafmt, (CS_VOID *) & binaryvar, CS_SIZEOF(CS_BINARY), 0)) != CS_SUCCEED) { fprintf(stderr, "ct_param(binary) failed"); return 1; } /* * Send the command to the server */ if (ct_send(cmd) != CS_SUCCEED) { fprintf(stderr, "ct_send(RPC) failed"); return 1; } /* * Process the results of the RPC. */ while ((ret = ct_results(cmd, &res_type)) == CS_SUCCEED) { switch ((int) res_type) { case CS_ROW_RESULT: case CS_PARAM_RESULT: case CS_STATUS_RESULT: /* * Print the result header based on the result type. */ switch ((int) res_type) { case CS_ROW_RESULT: fprintf(stdout, "\nROW RESULTS\n"); break; case CS_PARAM_RESULT: fprintf(stdout, "\nPARAMETER RESULTS\n"); break; case CS_STATUS_RESULT: fprintf(stdout, "\nSTATUS RESULTS\n"); break; } fflush(stdout); /* * All three of these result types are fetchable. * Since the result model for rpcs and rows have * been unified in the New Client-Library, we * will use the same routine to display them */ /* * Find out how many columns there are in this result set. */ ret = ct_res_info(cmd, CS_NUMDATA, &num_cols, CS_UNUSED, NULL); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_res_info(CS_NUMDATA) failed"); return 1; } /* * Make sure we have at least one column */ if (num_cols <= 0) { fprintf(stderr, "ct_res_info(CS_NUMDATA) returned zero columns"); return 1; } /* * Our program variable, called 'coldata', is an array of * EX_COLUMN_DATA structures. Each array element represents * one column. Each array element will re-used for each row. * * First, allocate memory for the data element to process. */ coldata = (EX_COLUMN_DATA *) malloc(num_cols * sizeof(EX_COLUMN_DATA)); if (coldata == NULL) { fprintf(stderr, "malloc coldata failed \n"); return 1; } outdatafmt = (CS_DATAFMT *) malloc(num_cols * sizeof(CS_DATAFMT)); if (outdatafmt == NULL) { fprintf(stderr, "malloc outdatafmt failed \n"); return 1; } for (i = 0; i < num_cols; i++) { ret = ct_describe(cmd, (i + 1), &outdatafmt[i]); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_describe failed \n"); return 1; } outdatafmt[i].maxlength = ex_display_dlen(&outdatafmt[i]) + 1; outdatafmt[i].datatype = CS_CHAR_TYPE; outdatafmt[i].format = CS_FMT_NULLTERM; coldata[i].value = (CS_CHAR *) malloc(outdatafmt[i].maxlength); if (coldata[i].value == NULL) { fprintf(stderr, "malloc coldata.value failed \n"); return 1; } coldata[i].value[0] = 0; ret = ct_bind(cmd, (i + 1), &outdatafmt[i], coldata[i].value, &coldata[i].valuelen, & coldata[i].indicator); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_bind failed \n"); return 1; } } if (ret != CS_SUCCEED) { for (j = 0; j < i; j++) { free(coldata[j].value); } free(coldata); free(outdatafmt); return 1; } ex_display_header(num_cols, outdatafmt); while (((ret = ct_fetch(cmd, CS_UNUSED, CS_UNUSED, CS_UNUSED, &rows_read)) == CS_SUCCEED) || (ret == CS_ROW_FAIL)) { /* * Increment our row count by the number of rows just fetched. */ row_count = row_count + rows_read; /* * Check if we hit a recoverable error. */ if (ret == CS_ROW_FAIL) { fprintf(stdout, "Error on row %d.\n", row_count); fflush(stdout); } /* * We have a row. Loop through the columns displaying the * column values. */ for (i = 0; i < num_cols; i++) { /* * Display the column value */ fprintf(stdout, "%s", coldata[i].value); fflush(stdout); /* * If not last column, Print out spaces between this * column and next one. */ if (i != num_cols - 1) { disp_len = ex_display_dlen(&outdatafmt[i]); disp_len -= coldata[i].valuelen - 1; for (j = 0; j < disp_len; j++) { fputc(' ', stdout); } } } fprintf(stdout, "\n"); fflush(stdout); } /* * Free allocated space. */ for (i = 0; i < num_cols; i++) { free(coldata[i].value); } free(coldata); free(outdatafmt); /* * We're done processing rows. Let's check the final return * value of ct_fetch(). */ switch ((int) ret) { case CS_END_DATA: /* * Everything went fine. */ fprintf(stdout, "All done processing rows.\n"); fflush(stdout); break; case CS_FAIL: /* * Something terrible happened. */ fprintf(stderr, "ct_fetch returned CS_FAIL\n"); return 1; break; default: /* * We got an unexpected return value. */ fprintf(stderr, "ct_fetch returned %d\n", ret); return 1; break; } break; case CS_MSG_RESULT: ret = ct_res_info(cmd, CS_MSGTYPE, (CS_VOID *) & msg_id, CS_UNUSED, NULL); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_res_info(msg_id) failed"); return 1; } fprintf(stdout, "ct_result returned CS_MSG_RESULT where msg id = %d.\n", msg_id); fflush(stdout); break; case CS_CMD_SUCCEED: /* * This means no rows were returned. */ break; case CS_CMD_DONE: /* * Done with result set. */ break; case CS_CMD_FAIL: /* * The server encountered an error while * processing our command. */ fprintf(stderr, "ct_results returned CS_CMD_FAIL."); break; default: /* * We got something unexpected. */ fprintf(stderr, "ct_results returned unexpected result type."); return CS_FAIL; } } /* * We're done processing results. Let's check the * return value of ct_results() to see if everything * went ok. */ switch ((int) ret) { case CS_END_RESULTS: /* * Everything went fine. */ break; case CS_FAIL: /* * Something failed happened. */ fprintf(stderr, "ct_results failed."); break; default: /* * We got an unexpected return value. */ fprintf(stderr, "ct_results returned unexpected result type."); break; } run_command(cmd, "DROP PROCEDURE sample_rpc"); if (verbose) { fprintf(stdout, "Trying logout\n"); } ret = try_ctlogout(ctx, conn, cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Logout failed\n"); return 1; } return 0; } static CS_INT ex_display_dlen(CS_DATAFMT * column) { CS_INT len; switch ((int) column->datatype) { case CS_CHAR_TYPE: case CS_VARCHAR_TYPE: case CS_TEXT_TYPE: case CS_IMAGE_TYPE: len = MIN(column->maxlength, 1024); break; case CS_BINARY_TYPE: case CS_VARBINARY_TYPE: len = MIN((2 * column->maxlength) + 2, 1024); break; case CS_BIT_TYPE: case CS_TINYINT_TYPE: len = 3; break; case CS_SMALLINT_TYPE: len = 6; break; case CS_INT_TYPE: len = 11; break; case CS_REAL_TYPE: case CS_FLOAT_TYPE: len = 20; break; case CS_MONEY_TYPE: case CS_MONEY4_TYPE: len = 24; break; case CS_DATETIME_TYPE: case CS_DATETIME4_TYPE: len = 30; break; case CS_NUMERIC_TYPE: case CS_DECIMAL_TYPE: len = (CS_MAX_PREC + 2); break; default: len = 12; break; } return MAX((CS_INT) (strlen(column->name) + 1), len); } static CS_RETCODE ex_display_header(CS_INT numcols, CS_DATAFMT columns[]) { CS_INT i; CS_INT l; CS_INT j; CS_INT disp_len; fputc('\n', stdout); for (i = 0; i < numcols; i++) { disp_len = ex_display_dlen(&columns[i]); fprintf(stdout, "%s", columns[i].name); fflush(stdout); l = disp_len - strlen(columns[i].name); for (j = 0; j < l; j++) { fputc(' ', stdout); fflush(stdout); } } fputc('\n', stdout); fflush(stdout); for (i = 0; i < numcols; i++) { disp_len = ex_display_dlen(&columns[i]); l = disp_len - 1; for (j = 0; j < l; j++) { fputc('-', stdout); } fputc(' ', stdout); } fputc('\n', stdout); return CS_SUCCEED; } CS_RETCODE ex_clientmsg_cb(CS_CONTEXT * context, CS_CONNECTION * connection, CS_CLIENTMSG * errmsg) { fprintf(stdout, "\nOpen Client Message:\n"); fprintf(stdout, "Message number: LAYER = (%ld) ORIGIN = (%ld) ", (long)CS_LAYER(errmsg->msgnumber), (long)CS_ORIGIN(errmsg->msgnumber)); fprintf(stdout, "SEVERITY = (%ld) NUMBER = (%ld)\n", (long)CS_SEVERITY(errmsg->msgnumber), (long)CS_NUMBER(errmsg->msgnumber)); fprintf(stdout, "Message String: %s\n", errmsg->msgstring); if (errmsg->osstringlen > 0) { fprintf(stdout, "Operating System Error: %s\n", errmsg->osstring); } fflush(stdout); return CS_SUCCEED; } CS_RETCODE ex_servermsg_cb(CS_CONTEXT * context, CS_CONNECTION * connection, CS_SERVERMSG * srvmsg) { fprintf(stdout, "\nServer message:\n"); fprintf(stdout, "Message number: %ld, Severity %ld, ", (long) srvmsg->msgnumber, (long) srvmsg->severity); fprintf(stdout, "State %ld, Line %ld\n", (long) srvmsg->state, (long) srvmsg->line); if (srvmsg->svrnlen > 0) { fprintf(stdout, "Server '%s'\n", srvmsg->svrname); } if (srvmsg->proclen > 0) { fprintf(stdout, " Procedure '%s'\n", srvmsg->proc); } fprintf(stdout, "Message String: %s\n", srvmsg->text); fflush(stdout); return CS_SUCCEED; } freetds-1.00.82/src/ctlib/unittests/rpc_ct_setparam.c100644 025423 025423 00000041647 12522201763 0016302#include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include "common.h" #define MAX(X,Y) (((X) > (Y)) ? (X) : (Y)) #define MIN(X,Y) (((X) < (Y)) ? (X) : (Y)) static char software_version[] = "$Id: rpc_ct_setparam.c,v 1.11 2011-05-16 08:51:40 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; CS_RETCODE ex_clientmsg_cb(CS_CONTEXT * context, CS_CONNECTION * connection, CS_CLIENTMSG * errmsg); CS_RETCODE ex_servermsg_cb(CS_CONTEXT * context, CS_CONNECTION * connection, CS_SERVERMSG * errmsg); static CS_RETCODE ex_display_header(CS_INT numcols, CS_DATAFMT columns[]); static CS_INT ex_display_dlen(CS_DATAFMT *column); static CS_INT ex_display_results(CS_COMMAND * cmd); typedef struct _ex_column_data { CS_SMALLINT indicator; CS_CHAR *value; CS_INT valuelen; } EX_COLUMN_DATA; /* Testing: array binding of result set */ int main(int argc, char *argv[]) { CS_CONTEXT *ctx; CS_CONNECTION *conn; CS_COMMAND *cmd; int verbose = 0; CS_RETCODE ret; CS_INT datalength; CS_SMALLINT nullind; CS_SMALLINT notnullind; CS_CHAR cmdbuf[4096]; CS_DATAFMT datafmt; CS_DATAFMT srcfmt; CS_DATAFMT destfmt; CS_INT intvar; CS_SMALLINT smallintvar; CS_FLOAT floatvar; CS_MONEY moneyvar; CS_BINARY binaryvar; char moneystring[10]; char rpc_name[15]; CS_INT destlen; fprintf(stdout, "%s: submit a stored procedure using ct_setparam \n", __FILE__); if (verbose) { fprintf(stdout, "Trying login\n"); } ret = try_ctlogin(&ctx, &conn, &cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Login failed\n"); return 1; } ct_callback(ctx, NULL, CS_SET, CS_CLIENTMSG_CB, (CS_VOID *) ex_clientmsg_cb); ct_callback(ctx, NULL, CS_SET, CS_SERVERMSG_CB, (CS_VOID *) ex_servermsg_cb); /* do not test error */ ret = run_command(cmd, "IF EXISTS(SELECT * FROM SYSOBJECTS WHERE name = 'sample_rpc' AND type = 'P') DROP PROCEDURE sample_rpc"); strcpy(cmdbuf, "create proc sample_rpc (@intparam int, \ @sintparam smallint output, @floatparam float output, \ @moneyparam money output, \ @dateparam datetime output, @charparam char(20) output, \ @binaryparam varbinary(2000) output) \ as "); strcat(cmdbuf, "select @intparam, @sintparam, @floatparam, @moneyparam, \ @dateparam, @charparam, @binaryparam \ select @sintparam = @sintparam + @intparam \ select @floatparam = @floatparam + @intparam \ select @moneyparam = @moneyparam + convert(money, @intparam) \ select @dateparam = getdate() \ select @charparam = \'The char parameters\' \ select @binaryparam = @binaryparam \ print \'This is the message printed out by sample_rpc.\'"); ret = run_command(cmd, cmdbuf); if (ret != CS_SUCCEED) { fprintf(stderr, "create proc failed\n"); return 1; } /* * Assign values to the variables used for parameter passing. */ intvar = 2; smallintvar = 234; floatvar = 0.12; binaryvar = (CS_BINARY) 0xff; strcpy(rpc_name, "sample_rpc"); strcpy(moneystring, "300.90"); /* * Clear and setup the CS_DATAFMT structures used to convert datatypes. */ memset(&srcfmt, 0, sizeof(CS_DATAFMT)); srcfmt.datatype = CS_CHAR_TYPE; srcfmt.maxlength = strlen(moneystring); srcfmt.precision = 5; srcfmt.scale = 2; srcfmt.locale = NULL; memset(&destfmt, 0, sizeof(CS_DATAFMT)); destfmt.datatype = CS_MONEY_TYPE; destfmt.maxlength = sizeof(CS_MONEY); destfmt.precision = 5; destfmt.scale = 2; destfmt.locale = NULL; /* * Convert the string representing the money value * to a CS_MONEY variable. Since this routine does not have the * context handle, we use the property functions to get it. */ if ((ret = ct_cmd_props(cmd, CS_GET, CS_PARENT_HANDLE, &conn, CS_UNUSED, NULL)) != CS_SUCCEED) { fprintf(stderr, "ct_cmd_props() failed"); return 1; } if ((ret = ct_con_props(conn, CS_GET, CS_PARENT_HANDLE, &ctx, CS_UNUSED, NULL)) != CS_SUCCEED) { fprintf(stderr, "ct_con_props() failed"); return 1; } ret = cs_convert(ctx, &srcfmt, (CS_VOID *) moneystring, &destfmt, &moneyvar, &destlen); if (ret != CS_SUCCEED) { fprintf(stderr, "cs_convert() failed"); return 1; } /* * Send the RPC command for our stored procedure. */ if ((ret = ct_command(cmd, CS_RPC_CMD, rpc_name, CS_NULLTERM, CS_NO_RECOMPILE)) != CS_SUCCEED) { fprintf(stderr, "ct_command(CS_RPC_CMD) failed"); return 1; } nullind = -1; notnullind = 0; /* * Clear and setup the CS_DATAFMT structure, then pass * each of the parameters for the RPC. */ memset(&datafmt, 0, sizeof(datafmt)); strcpy(datafmt.name, "@intparam"); datafmt.namelen = CS_NULLTERM; datafmt.datatype = CS_INT_TYPE; datafmt.maxlength = CS_UNUSED; datafmt.status = CS_INPUTVALUE; datafmt.locale = NULL; datalength = CS_SIZEOF(CS_INT); if ((ret = ct_setparam(cmd, &datafmt, (CS_VOID *) & intvar, &datalength, ¬nullind)) != CS_SUCCEED) { fprintf(stderr, "ct_setparam(int) failed"); return 1; } strcpy(datafmt.name, "@sintparam"); datafmt.namelen = CS_NULLTERM; datafmt.datatype = CS_SMALLINT_TYPE; datafmt.maxlength = 255; datafmt.status = CS_RETURN; datafmt.locale = NULL; datalength = CS_SIZEOF(CS_SMALLINT); if ((ret = ct_setparam(cmd, &datafmt, (CS_VOID *) & smallintvar, &datalength, ¬nullind)) != CS_SUCCEED) { fprintf(stderr, "ct_setparam(smallint) failed"); return 1; } strcpy(datafmt.name, "@floatparam"); datafmt.namelen = CS_NULLTERM; datafmt.datatype = CS_FLOAT_TYPE; datafmt.maxlength = 255; datafmt.status = CS_RETURN; datafmt.locale = NULL; datalength = CS_SIZEOF(CS_FLOAT); if ((ret = ct_setparam(cmd, &datafmt, (CS_VOID *) & floatvar, &datalength, ¬nullind)) != CS_SUCCEED) { fprintf(stderr, "ct_setparam(float) failed"); return 1; } strcpy(datafmt.name, "@moneyparam"); datafmt.namelen = CS_NULLTERM; datafmt.datatype = CS_MONEY_TYPE; datafmt.maxlength = 255; datafmt.status = CS_RETURN; datafmt.locale = NULL; datalength = CS_SIZEOF(CS_MONEY); if ((ret = ct_setparam(cmd, &datafmt, (CS_VOID *) & moneyvar, &datalength, ¬nullind)) != CS_SUCCEED) { fprintf(stderr, "ct_setparam(money) failed"); return 1; } strcpy(datafmt.name, "@dateparam"); datafmt.namelen = CS_NULLTERM; datafmt.datatype = CS_DATETIME4_TYPE; datafmt.maxlength = 255; datafmt.status = CS_RETURN; datafmt.locale = NULL; /* * The datetime variable is filled in by the RPC so pass NULL for * the data, 0 for data length, and -1 for the indicator arguments. */ datalength = 0; if ((ret = ct_setparam(cmd, &datafmt, NULL, &datalength, &nullind)) != CS_SUCCEED) { fprintf(stderr, "ct_setparam(datetime4) failed"); return 1; } strcpy(datafmt.name, "@charparam"); datafmt.namelen = CS_NULLTERM; datafmt.datatype = CS_CHAR_TYPE; datafmt.maxlength = 60; datafmt.status = CS_RETURN; datafmt.locale = NULL; datalength = 0; /* * The character string variable is filled in by the RPC so pass NULL * for the data 0 for data length, and -1 for the indicator arguments. */ if ((ret = ct_setparam(cmd, &datafmt, NULL, &datalength, &nullind)) != CS_SUCCEED) { fprintf(stderr, "ct_setparam(char) failed"); return 1; } strcpy(datafmt.name, "@binaryparam"); datafmt.namelen = CS_NULLTERM; datafmt.datatype = CS_LONGBINARY_TYPE; datafmt.maxlength = 2000; datafmt.status = CS_RETURN; datafmt.locale = NULL; datalength = CS_SIZEOF(CS_BINARY); nullind = -1; if ((ret = ct_setparam(cmd, &datafmt, (CS_VOID *) & binaryvar, &datalength, ¬nullind)) != CS_SUCCEED) { fprintf(stderr, "ct_setparam(binary) failed"); return 1; } /* * Send the command to the server */ if (ct_send(cmd) != CS_SUCCEED) { fprintf(stderr, "ct_send(RPC) failed"); return 1; } ret = ex_display_results(cmd); if (ret != CS_SUCCEED) { fprintf(stderr, "ex_display_results failed\n"); return 1; } intvar = 3; if (ct_send(cmd) != CS_SUCCEED) { fprintf(stderr, "ct_send(RPC) failed"); return 1; } ret = ex_display_results(cmd); if (ret != CS_SUCCEED) { fprintf(stderr, "ex_display_results failed\n"); return 1; } run_command(cmd, "DROP PROCEDURE sample_rpc"); if (verbose) { fprintf(stdout, "Trying logout\n"); } ret = try_ctlogout(ctx, conn, cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Logout failed\n"); return 1; } return 0; } static CS_INT ex_display_results(CS_COMMAND * cmd) { CS_RETCODE ret; CS_INT res_type; CS_INT num_cols; EX_COLUMN_DATA *coldata; CS_DATAFMT *outdatafmt; CS_INT row_count = 0; CS_INT rows_read; CS_INT disp_len; CS_SMALLINT msg_id; int i, j; /* * Process the results of the RPC. */ while ((ret = ct_results(cmd, &res_type)) == CS_SUCCEED) { switch ((int) res_type) { case CS_ROW_RESULT: case CS_PARAM_RESULT: case CS_STATUS_RESULT: /* * Print the result header based on the result type. */ switch ((int) res_type) { case CS_ROW_RESULT: fprintf(stdout, "\nROW RESULTS\n"); break; case CS_PARAM_RESULT: fprintf(stdout, "\nPARAMETER RESULTS\n"); break; case CS_STATUS_RESULT: fprintf(stdout, "\nSTATUS RESULTS\n"); break; } fflush(stdout); /* * All three of these result types are fetchable. * Since the result model for rpcs and rows have * been unified in the New Client-Library, we * will use the same routine to display them */ /* * Find out how many columns there are in this result set. */ ret = ct_res_info(cmd, CS_NUMDATA, &num_cols, CS_UNUSED, NULL); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_res_info(CS_NUMDATA) failed"); return 1; } /* * Make sure we have at least one column */ if (num_cols <= 0) { fprintf(stderr, "ct_res_info(CS_NUMDATA) returned zero columns"); return 1; } /* * Our program variable, called 'coldata', is an array of * EX_COLUMN_DATA structures. Each array element represents * one column. Each array element will re-used for each row. * * First, allocate memory for the data element to process. */ coldata = (EX_COLUMN_DATA *) malloc(num_cols * sizeof(EX_COLUMN_DATA)); if (coldata == NULL) { fprintf(stderr, "malloc coldata failed \n"); return 1; } outdatafmt = (CS_DATAFMT *) malloc(num_cols * sizeof(CS_DATAFMT)); if (outdatafmt == NULL) { fprintf(stderr, "malloc outdatafmt failed \n"); return 1; } for (i = 0; i < num_cols; i++) { ret = ct_describe(cmd, (i + 1), &outdatafmt[i]); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_describe failed \n"); return 1; } outdatafmt[i].maxlength = ex_display_dlen(&outdatafmt[i]) + 1; outdatafmt[i].datatype = CS_CHAR_TYPE; outdatafmt[i].format = CS_FMT_NULLTERM; coldata[i].value = (CS_CHAR *) malloc(outdatafmt[i].maxlength); coldata[i].value[0] = 0; if (coldata[i].value == NULL) { fprintf(stderr, "malloc coldata.value failed \n"); return 1; } ret = ct_bind(cmd, (i + 1), &outdatafmt[i], coldata[i].value, &coldata[i].valuelen, & coldata[i].indicator); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_bind failed \n"); return 1; } } if (ret != CS_SUCCEED) { for (j = 0; j < i; j++) { free(coldata[j].value); } free(coldata); free(outdatafmt); return 1; } ex_display_header(num_cols, outdatafmt); while (((ret = ct_fetch(cmd, CS_UNUSED, CS_UNUSED, CS_UNUSED, &rows_read)) == CS_SUCCEED) || (ret == CS_ROW_FAIL)) { /* * Increment our row count by the number of rows just fetched. */ row_count = row_count + rows_read; /* * Check if we hit a recoverable error. */ if (ret == CS_ROW_FAIL) { fprintf(stdout, "Error on row %d.\n", row_count); fflush(stdout); } /* * We have a row. Loop through the columns displaying the * column values. */ for (i = 0; i < num_cols; i++) { /* * Display the column value */ fprintf(stdout, "%s", coldata[i].value); fflush(stdout); /* * If not last column, Print out spaces between this * column and next one. */ if (i != num_cols - 1) { disp_len = ex_display_dlen(&outdatafmt[i]); disp_len -= coldata[i].valuelen - 1; for (j = 0; j < disp_len; j++) { fputc(' ', stdout); } } } fprintf(stdout, "\n"); fflush(stdout); } /* * Free allocated space. */ for (i = 0; i < num_cols; i++) { free(coldata[i].value); } free(coldata); free(outdatafmt); /* * We're done processing rows. Let's check the final return * value of ct_fetch(). */ switch ((int) ret) { case CS_END_DATA: /* * Everything went fine. */ fprintf(stdout, "All done processing rows.\n"); fflush(stdout); break; case CS_FAIL: /* * Something terrible happened. */ fprintf(stderr, "ct_fetch returned CS_FAIL\n"); return 1; break; default: /* * We got an unexpected return value. */ fprintf(stderr, "ct_fetch returned %d\n", ret); return 1; break; } break; case CS_MSG_RESULT: ret = ct_res_info(cmd, CS_MSGTYPE, (CS_VOID *) & msg_id, CS_UNUSED, NULL); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_res_info(msg_id) failed"); return 1; } fprintf(stdout, "ct_result returned CS_MSG_RESULT where msg id = %d.\n", msg_id); fflush(stdout); break; case CS_CMD_SUCCEED: /* * This means no rows were returned. */ break; case CS_CMD_DONE: /* * Done with result set. */ break; case CS_CMD_FAIL: /* * The server encountered an error while * processing our command. */ fprintf(stderr, "ct_results returned CS_CMD_FAIL."); break; default: /* * We got something unexpected. */ fprintf(stderr, "ct_results returned unexpected result type."); return CS_FAIL; } } /* * We're done processing results. Let's check the * return value of ct_results() to see if everything * went ok. */ switch ((int) ret) { case CS_END_RESULTS: /* * Everything went fine. */ break; case CS_FAIL: /* * Something failed happened. */ fprintf(stderr, "ct_results failed."); break; default: /* * We got an unexpected return value. */ fprintf(stderr, "ct_results returned unexpected result type."); break; } return CS_SUCCEED; } static CS_INT ex_display_dlen(CS_DATAFMT *column) { CS_INT len; switch ((int) column->datatype) { case CS_CHAR_TYPE: case CS_VARCHAR_TYPE: case CS_TEXT_TYPE: case CS_IMAGE_TYPE: len = MIN(column->maxlength, 1024); break; case CS_BINARY_TYPE: case CS_VARBINARY_TYPE: len = MIN((2 * column->maxlength) + 2, 1024); break; case CS_BIT_TYPE: case CS_TINYINT_TYPE: len = 3; break; case CS_SMALLINT_TYPE: len = 6; break; case CS_INT_TYPE: len = 11; break; case CS_REAL_TYPE: case CS_FLOAT_TYPE: len = 20; break; case CS_MONEY_TYPE: case CS_MONEY4_TYPE: len = 24; break; case CS_DATETIME_TYPE: case CS_DATETIME4_TYPE: len = 30; break; case CS_NUMERIC_TYPE: case CS_DECIMAL_TYPE: len = (CS_MAX_PREC + 2); break; default: len = 12; break; } return MAX((CS_INT) (strlen(column->name) + 1), len); } static CS_RETCODE ex_display_header(CS_INT numcols, CS_DATAFMT columns[]) { CS_INT i; CS_INT l; CS_INT j; CS_INT disp_len; fputc('\n', stdout); for (i = 0; i < numcols; i++) { disp_len = ex_display_dlen(&columns[i]); fprintf(stdout, "%s", columns[i].name); fflush(stdout); l = disp_len - strlen(columns[i].name); for (j = 0; j < l; j++) { fputc(' ', stdout); fflush(stdout); } } fputc('\n', stdout); fflush(stdout); for (i = 0; i < numcols; i++) { disp_len = ex_display_dlen(&columns[i]); l = disp_len - 1; for (j = 0; j < l; j++) { fputc('-', stdout); } fputc(' ', stdout); } fputc('\n', stdout); return CS_SUCCEED; } CS_RETCODE ex_clientmsg_cb(CS_CONTEXT * context, CS_CONNECTION * connection, CS_CLIENTMSG * errmsg) { fprintf(stdout, "\nOpen Client Message:\n"); fprintf(stdout, "Message number: LAYER = (%ld) ORIGIN = (%ld) ", (long) CS_LAYER(errmsg->msgnumber), (long) CS_ORIGIN(errmsg->msgnumber)); fprintf(stdout, "SEVERITY = (%ld) NUMBER = (%ld)\n", (long) CS_SEVERITY(errmsg->msgnumber), (long) CS_NUMBER(errmsg->msgnumber)); fprintf(stdout, "Message String: %s\n", errmsg->msgstring); if (errmsg->osstringlen > 0) { fprintf(stdout, "Operating System Error: %s\n", errmsg->osstring); } fflush(stdout); return CS_SUCCEED; } CS_RETCODE ex_servermsg_cb(CS_CONTEXT * context, CS_CONNECTION * connection, CS_SERVERMSG * srvmsg) { fprintf(stdout, "\nServer message:\n"); fprintf(stdout, "Message number: %ld, Severity %ld, ", (long) srvmsg->msgnumber, (long) srvmsg->severity); fprintf(stdout, "State %ld, Line %ld\n", (long) srvmsg->state, (long) srvmsg->line); if (srvmsg->svrnlen > 0) { fprintf(stdout, "Server '%s'\n", srvmsg->svrname); } if (srvmsg->proclen > 0) { fprintf(stdout, " Procedure '%s'\n", srvmsg->proc); } fprintf(stdout, "Message String: %s\n", srvmsg->text); fflush(stdout); return CS_SUCCEED; } freetds-1.00.82/src/ctlib/unittests/rpc_fail.c100644 025423 025423 00000005263 12553405021 0014702#include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STRING_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include "common.h" static const char *printable_ret(CS_RETCODE ret) { #define CASE(x) case x: return #x; switch (ret) { CASE(CS_STATUS_RESULT) CASE(CS_ROW_RESULT) CASE(CS_PARAM_RESULT) CASE(CS_CMD_SUCCEED) CASE(CS_MSG_RESULT) CASE(CS_CMD_DONE) CASE(CS_CMD_FAIL) default: return "Unknown"; } } int main(int argc, char *argv[]) { CS_CONTEXT *ctx; CS_CONNECTION *conn; CS_COMMAND *cmd; int verbose = 0; CS_RETCODE ret; CS_INT res_type; CS_SMALLINT msg_id; int got_failure = 0; int got_done = 0; CS_INT rows_read; printf("%s: submit a not existing stored procedure\n", __FILE__); ret = try_ctlogin(&ctx, &conn, &cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Login failed\n"); return 1; } if ((ret = ct_command(cmd, CS_RPC_CMD, "IDoNotExist", CS_NULLTERM, CS_NO_RECOMPILE)) != CS_SUCCEED) { fprintf(stderr, "ct_command(CS_RPC_CMD) failed"); return 1; } if (ct_send(cmd) != CS_SUCCEED) { fprintf(stderr, "ct_send(RPC) failed"); return 1; } while ((ret = ct_results(cmd, &res_type)) == CS_SUCCEED) { printf("ct_results returned %s\n", printable_ret(res_type)); switch ((int) res_type) { case CS_STATUS_RESULT: while (ct_fetch(cmd, CS_UNUSED, CS_UNUSED, CS_UNUSED, &rows_read) == CS_SUCCEED) continue; break; case CS_CMD_SUCCEED: fprintf(stderr, "a success was not expected from ct_results.\n"); return 1; case CS_ROW_RESULT: case CS_PARAM_RESULT: fprintf(stderr, "Only status results are expected\n"); return 1; case CS_MSG_RESULT: ret = ct_res_info(cmd, CS_MSGTYPE, (CS_VOID *) & msg_id, CS_UNUSED, NULL); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_res_info(msg_id) failed"); return 1; } printf("ct_result returned CS_MSG_RESULT where msg id = %d.\n", msg_id); break; case CS_CMD_DONE: got_done = 1; break; case CS_CMD_FAIL: got_failure = 1; break; default: fprintf(stderr, "ct_results returned unexpected result type.\n"); return 1; } } if (!got_failure) { fprintf(stderr, "a failure was expected from ct_results.\n"); return 1; } if (!got_done) { fprintf(stderr, "a done result was expected from ct_results.\n"); return 1; } switch ((int) ret) { case CS_END_RESULTS: break; case CS_FAIL: fprintf(stderr, "ct_results failed."); return 1; default: fprintf(stderr, "ct_results returned unexpected result type."); return 1; } ret = try_ctlogout(ctx, conn, cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Logout failed\n"); return 1; } return 0; } freetds-1.00.82/src/ctlib/unittests/t0001.c100644 025423 025423 00000001554 12522201763 0013671#include #include #include #include "common.h" static char software_version[] = "$Id: t0001.c,v 1.7 2011-05-16 08:51:40 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; int main(int argc, char **argv) { CS_CONTEXT *ctx; CS_CONNECTION *conn; CS_COMMAND *cmd; CS_RETCODE ret; int verbose = 0; fprintf(stdout, "%s: Testing login, logout\n", __FILE__); if (verbose) { fprintf(stdout, "Trying login\n"); } ret = try_ctlogin(&ctx, &conn, &cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Login failed\n"); return 1; } if (verbose) { fprintf(stdout, "Trying logout\n"); } ret = try_ctlogout(ctx, conn, cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Logout failed\n"); return 2; } if (verbose) { fprintf(stdout, "Test succeeded\n"); } return 0; } freetds-1.00.82/src/ctlib/unittests/t0002.c100644 025423 025423 00000016350 12717145107 0013677#include #include #include #include #include "common.h" static int sp_who(CS_COMMAND *cmd); /* * ct_send SQL |select name = @@servername| * ct_bind variable * ct_fetch and print results */ int main(int argc, char **argv) { CS_CONTEXT *ctx; CS_CONNECTION *conn; CS_COMMAND *cmd; int verbose = 0; CS_RETCODE ret; CS_RETCODE results_ret; CS_DATAFMT datafmt; CS_INT datalength; CS_SMALLINT ind; CS_INT count, row_count = 0; CS_INT result_type; CS_CHAR name[256]; fprintf(stdout, "%s: Testing bind & select\n", __FILE__); if (verbose) { fprintf(stdout, "Trying login\n"); } ret = try_ctlogin(&ctx, &conn, &cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Login failed\n"); return 1; } ret = ct_command(cmd, CS_LANG_CMD, "select name = @@servername", CS_NULLTERM, CS_UNUSED); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_command() failed\n"); return 1; } ret = ct_send(cmd); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_send() failed\n"); return 1; } while ((results_ret = ct_results(cmd, &result_type)) == CS_SUCCEED) { switch ((int) result_type) { case CS_CMD_SUCCEED: break; case CS_CMD_DONE: break; case CS_CMD_FAIL: fprintf(stderr, "ct_results() result_type CS_CMD_FAIL.\n"); return 1; case CS_ROW_RESULT: datafmt.datatype = CS_CHAR_TYPE; datafmt.format = CS_FMT_NULLTERM; datafmt.maxlength = 256; datafmt.count = 1; datafmt.locale = NULL; ret = ct_bind(cmd, 1, &datafmt, name, &datalength, &ind); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_bind() failed\n"); return 1; } while (((ret = ct_fetch(cmd, CS_UNUSED, CS_UNUSED, CS_UNUSED, &count)) == CS_SUCCEED) || (ret == CS_ROW_FAIL)) { row_count += count; if (ret == CS_ROW_FAIL) { fprintf(stderr, "ct_fetch() CS_ROW_FAIL on row %d.\n", row_count); return 1; } else if (ret == CS_SUCCEED) { if (verbose) { fprintf(stdout, "server name = %s\n", name); } } else { break; } } switch ((int) ret) { case CS_END_DATA: break; case CS_FAIL: fprintf(stderr, "ct_fetch() returned CS_FAIL.\n"); return 1; default: fprintf(stderr, "ct_fetch() unexpected return.\n"); return 1; } break; case CS_COMPUTE_RESULT: fprintf(stderr, "ct_results() unexpected CS_COMPUTE_RESULT.\n"); return 1; default: fprintf(stderr, "ct_results() unexpected result_type.\n"); return 1; } } switch ((int) results_ret) { case CS_END_RESULTS: break; case CS_FAIL: fprintf(stderr, "ct_results() failed.\n"); return 1; break; default: fprintf(stderr, "ct_results() unexpected return.\n"); return 1; } /* * test parameter return code processing with sp_who */ sp_who(cmd); if (verbose) { fprintf(stdout, "Trying logout\n"); } ret = try_ctlogout(ctx, conn, cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Logout failed\n"); return 1; } return 0; } int sp_who(CS_COMMAND *cmd) { enum {maxcol=10, colsize=260}; struct _col { CS_DATAFMT datafmt; CS_INT datalength; CS_SMALLINT ind; CS_CHAR data[colsize]; } col[maxcol]; CS_INT num_cols; CS_INT count, row_count = 0; CS_INT result_type; CS_RETCODE ret; CS_RETCODE results_ret; int i; int is_status_result=0; ret = ct_command(cmd, CS_LANG_CMD, "exec sp_who", CS_NULLTERM, CS_UNUSED); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_command: \"exec sp_who\" failed with %d\n", ret); return 1; } ret = ct_send(cmd); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_send: \"exec sp_who\" failed with %d\n", ret); return 1; } while ((results_ret = ct_results(cmd, &result_type)) == CS_SUCCEED) { is_status_result = 0; switch ((int) result_type) { case CS_CMD_SUCCEED: break; case CS_CMD_DONE: break; case CS_CMD_FAIL: fprintf(stderr, "ct_results() result_type CS_CMD_FAIL.\n"); return 1; case CS_STATUS_RESULT: fprintf(stdout, "ct_results: CS_STATUS_RESULT detected for sp_who\n"); is_status_result = 1; /* fall through */ case CS_ROW_RESULT: ret = ct_res_info(cmd, CS_NUMDATA, &num_cols, CS_UNUSED, NULL); if (ret != CS_SUCCEED || num_cols > maxcol) { fprintf(stderr, "ct_res_info() failed\n"); return 1; } if (num_cols <= 0) { fprintf(stderr, "ct_res_info() return strange values\n"); return 1; } if (is_status_result && num_cols != 1) { fprintf(stderr, "CS_STATUS_RESULT return more than 1 column\n"); return 1; } for (i=0; i < num_cols; i++) { /* here we can finally test for the return status column */ ret = ct_describe(cmd, i+1, &col[i].datafmt); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_describe() failed for column %d\n", i); return 1; } if (col[i].datafmt.status & CS_RETURN) { fprintf(stdout, "ct_describe() indicates a return code in column %d for sp_who\n", i); /* * other possible values: * CS_CANBENULL * CS_HIDDEN * CS_IDENTITY * CS_KEY * CS_VERSION_KEY * CS_TIMESTAMP * CS_UPDATABLE * CS_UPDATECOL */ } col[i].datafmt.datatype = CS_CHAR_TYPE; col[i].datafmt.format = CS_FMT_NULLTERM; col[i].datafmt.maxlength = colsize; col[i].datafmt.count = 1; col[i].datafmt.locale = NULL; ret = ct_bind(cmd, i+1, &col[i].datafmt, &col[i].data, &col[i].datalength, &col[i].ind); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_bind() failed\n"); return 1; } } row_count = 0; while ((ret = ct_fetch(cmd, CS_UNUSED, CS_UNUSED, CS_UNUSED, &count)) == CS_SUCCEED) { if( row_count == 0) { /* titles */ for (i=0; i < num_cols; i++) { char fmt[40]; if (col[i].datafmt.namelen == 0) { printf("unnamed%d ",i+1); continue; } sprintf(fmt, "%%-%d.%ds ", col[i].datafmt.namelen, col[i].datafmt.maxlength); printf(fmt, col[i].datafmt.name); } printf("\n"); } for (i=0; i < num_cols; i++) { /* data */ char fmt[40]; if (col[i].ind) continue; sprintf(fmt, "%%-%d.%ds ", col[i].datalength, col[i].datafmt.maxlength); printf(fmt, col[i].data); if (is_status_result && strcmp(col[i].data,"0")) { fprintf(stderr, "CS_STATUS_RESULT should return 0 as result\n"); return 1; } } printf("\n"); row_count += count; } if (is_status_result && row_count != 1) { fprintf(stderr, "CS_STATUS_RESULT should return a row\n"); return 1; } switch ((int) ret) { case CS_END_DATA: fprintf(stdout, "ct_results fetched %d rows.\n", row_count); break; case CS_ROW_FAIL: fprintf(stderr, "ct_fetch() CS_ROW_FAIL on row %d.\n", row_count); return 1; case CS_FAIL: fprintf(stderr, "ct_fetch() returned CS_FAIL.\n"); return 1; default: fprintf(stderr, "ct_fetch() unexpected return.\n"); return 1; } break; case CS_COMPUTE_RESULT: fprintf(stderr, "ct_results() unexpected CS_COMPUTE_RESULT.\n"); return 1; default: fprintf(stderr, "ct_results() unexpected result_type.\n"); return 1; } } switch ((int) results_ret) { case CS_END_RESULTS: break; case CS_FAIL: fprintf(stderr, "ct_results() failed.\n"); return 1; break; default: fprintf(stderr, "ct_results() unexpected return.\n"); return 1; } return 0; } freetds-1.00.82/src/ctlib/unittests/t0003.c100644 025423 025423 00000010256 12522201763 0013672#include #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include "common.h" static char software_version[] = "$Id: t0003.c,v 1.11 2011-05-16 08:51:40 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; /* Testing: Retrieve CS_TEXT_TYPE using ct_bind() */ int main(int argc, char **argv) { CS_CONTEXT *ctx; CS_CONNECTION *conn; CS_COMMAND *cmd; int i, verbose = 0; CS_RETCODE ret; CS_RETCODE results_ret; CS_INT result_type; CS_INT num_cols; CS_DATAFMT datafmt; CS_INT datalength; CS_SMALLINT ind; CS_INT count, row_count = 0; CS_CHAR name[1024]; char large_sql[1024]; char len600[601]; char temp[11]; len600[0] = 0; name[0] = 0; for (i = 0; i < 60; i++) { sprintf(temp, "_abcde_%03d", (i + 1) * 10); strcat(len600, temp); } len600[600] = '\0'; fprintf(stdout, "%s: Retrieve CS_TEXT_TYPE using ct_bind()\n", __FILE__); if (verbose) { fprintf(stdout, "Trying login\n"); } ret = try_ctlogin(&ctx, &conn, &cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Login failed\n"); return 1; } ret = run_command(cmd, "CREATE TABLE #test_table (id int, name text)"); if (ret != CS_SUCCEED) return 1; /* ret = run_command(cmd, "INSERT #test_table (id, name) VALUES (1, 'name1')"); if (ret != CS_SUCCEED) return 1; */ sprintf(large_sql, "INSERT #test_table (id, name) VALUES (2, '%s')", len600); ret = run_command(cmd, large_sql); if (ret != CS_SUCCEED) return 1; ret = ct_command(cmd, CS_LANG_CMD, "SELECT name FROM #test_table", CS_NULLTERM, CS_UNUSED); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_command() failed\n"); return 1; } ret = ct_send(cmd); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_send() failed\n"); return 1; } while ((results_ret = ct_results(cmd, &result_type)) == CS_SUCCEED) { switch ((int) result_type) { case CS_CMD_SUCCEED: break; case CS_CMD_DONE: break; case CS_CMD_FAIL: fprintf(stderr, "ct_results() result_type CS_CMD_FAIL.\n"); return 1; case CS_ROW_RESULT: ret = ct_res_info(cmd, CS_NUMDATA, &num_cols, CS_UNUSED, NULL); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_res_info() failed"); return 1; } if (num_cols != 1) { fprintf(stderr, "num_cols %d != 1", num_cols); return 1; } ret = ct_describe(cmd, 1, &datafmt); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_describe() failed"); return 1; } datafmt.format = CS_FMT_NULLTERM; if (datafmt.maxlength > 1024) { datafmt.maxlength = 1024; } ret = ct_bind(cmd, 1, &datafmt, name, &datalength, &ind); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_bind() failed\n"); return 1; } while (((ret = ct_fetch(cmd, CS_UNUSED, CS_UNUSED, CS_UNUSED, &count)) == CS_SUCCEED) || (ret == CS_ROW_FAIL)) { row_count += count; if (ret == CS_ROW_FAIL) { fprintf(stderr, "ct_fetch() CS_ROW_FAIL on row %d.\n", row_count); return 1; } else { /* ret == CS_SUCCEED */ if (verbose) { fprintf(stdout, "name = '%s'\n", name); } if (strcmp(name, len600)) { fprintf(stderr, "Bad return:\n'%s'\n! =\n'%s'\n", name, len600); return 1; } if (datalength != strlen(name) + 1) { fprintf(stderr, "Bad count:\n'%ld'\n! =\n'%d'\n", (long) strlen(name) + 1, count); return 1; } } } switch ((int) ret) { case CS_END_DATA: break; case CS_FAIL: fprintf(stderr, "ct_fetch() returned CS_FAIL.\n"); return 1; default: fprintf(stderr, "ct_fetch() unexpected return.\n"); return 1; } break; case CS_COMPUTE_RESULT: fprintf(stderr, "ct_results() unexpected CS_COMPUTE_RESULT.\n"); return 1; default: fprintf(stderr, "ct_results() unexpected result_type.\n"); return 1; } } switch ((int) results_ret) { case CS_END_RESULTS: break; case CS_FAIL: fprintf(stderr, "ct_results() failed.\n"); return 1; break; default: fprintf(stderr, "ct_results() unexpected return.\n"); return 1; } if (verbose) { fprintf(stdout, "Trying logout\n"); } ret = try_ctlogout(ctx, conn, cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Logout failed\n"); return 1; } return 0; } freetds-1.00.82/src/ctlib/unittests/t0004.c100644 025423 025423 00000010202 12522201763 0013662#include #include #include #include "common.h" static char software_version[] = "$Id: t0004.c,v 1.10 2011-05-16 08:51:40 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; /* protos */ int do_fetch(CS_COMMAND * cmd); CS_RETCODE do_results(CS_COMMAND * cmd, CS_INT * results); /* defines */ #define NUMROWS 5 /* Testing: Test order of ct_results() */ int main(int argc, char **argv) { CS_CONTEXT *ctx; CS_CONNECTION *conn; CS_COMMAND *cmd; int i, verbose = 0; CS_RETCODE ret; CS_RETCODE results_ret; char query[1024]; CS_INT insert_results[] = { CS_CMD_SUCCEED, CS_CMD_DONE }; CS_INT update_results[] = { CS_CMD_SUCCEED, CS_CMD_DONE }; CS_INT select_results[] = { CS_ROW_RESULT, CS_CMD_DONE }; fprintf(stdout, "%s: Check ordering of returns from cs_results()\n", __FILE__); if (verbose) { fprintf(stdout, "Trying login\n"); } ret = try_ctlogin(&ctx, &conn, &cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Login failed\n"); return 1; } ret = run_command(cmd, "CREATE TABLE #t0004 (id int)"); if (ret != CS_SUCCEED) return 1; for (i = 0; i < NUMROWS; i++) { sprintf(query, "INSERT #t0004 (id) VALUES (%d)", i); ret = ct_command(cmd, CS_LANG_CMD, query, CS_NULLTERM, CS_UNUSED); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_command() failed\n"); return 1; } ret = ct_send(cmd); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_send() failed\n"); return 1; } results_ret = do_results(cmd, insert_results); switch ((int) results_ret) { case CS_END_RESULTS: break; case CS_FAIL: fprintf(stderr, "ct_results() failed.\n"); return 1; break; default: fprintf(stderr, "ct_results() unexpected return.\n"); return 1; } } ret = ct_command(cmd, CS_LANG_CMD, "UPDATE #t0004 SET id = id + 1", CS_NULLTERM, CS_UNUSED); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_command() failed\n"); return 1; } ret = ct_send(cmd); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_send() failed\n"); return 1; } results_ret = do_results(cmd, update_results); switch ((int) results_ret) { case CS_END_RESULTS: break; case CS_FAIL: fprintf(stderr, "ct_results() failed.\n"); return 1; break; default: fprintf(stderr, "ct_results() unexpected return.\n"); return 1; } /* single row select */ ret = ct_command(cmd, CS_LANG_CMD, "SELECT * FROM #t0004 WHERE id = 1", CS_NULLTERM, CS_UNUSED); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_command() failed\n"); return 1; } ret = ct_send(cmd); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_send() failed\n"); return 1; } results_ret = do_results(cmd, select_results); switch ((int) results_ret) { case CS_END_RESULTS: break; case CS_FAIL: fprintf(stderr, "ct_results() failed.\n"); return 1; break; default: fprintf(stderr, "ct_results() unexpected return.\n"); return 1; } if (verbose) { fprintf(stdout, "Trying logout\n"); } ret = try_ctlogout(ctx, conn, cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Logout failed\n"); return 1; } return 0; } int do_fetch(CS_COMMAND * cmd) { CS_INT count, row_count = 0; CS_RETCODE ret; while ((ret = ct_fetch(cmd, CS_UNUSED, CS_UNUSED, CS_UNUSED, &count)) == CS_SUCCEED) { row_count += count; } if (ret == CS_ROW_FAIL) { fprintf(stderr, "ct_fetch() CS_ROW_FAIL on row %d.\n", row_count); return 1; } else if (ret == CS_END_DATA) { return 0; } else { fprintf(stderr, "ct_fetch() unexpected return %d on row %d.\n", ret, row_count); return 1; } } CS_RETCODE do_results(CS_COMMAND * cmd, CS_INT * results) { int result_num; CS_RETCODE results_ret, result_type; result_num = 0; while ((results_ret = ct_results(cmd, &result_type)) == CS_SUCCEED) { printf("result_ret %d result_type %d\n", results_ret, result_type); if (result_type == CS_STATUS_RESULT) continue; if (result_type != results[result_num]) { fprintf(stderr, "ct_results() expected %d received %d\n", results[result_num], result_type); return CS_FAIL; } switch ((int) result_type) { case CS_ROW_RESULT: if (do_fetch(cmd)) { return CS_FAIL; } break; } result_num++; } return results_ret; } freetds-1.00.82/src/ctlib/unittests/t0005.c100644 025423 025423 00000001376 12717145107 0013704/* try login and logout multiple times in a row */ #include #include #include #include "common.h" int main(int argc, char **argv) { CS_CONTEXT *ctx; CS_CONNECTION *conn; CS_COMMAND *cmd; CS_RETCODE ret; int verbose = 0; int i; printf("%s: Testing login, logout\n", __FILE__); for (i =0; i < 100; ++i) { if (verbose) printf("Trying login\n"); ret = try_ctlogin(&ctx, &conn, &cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Login failed\n"); return 1; } if (verbose) printf("Trying logout\n"); ret = try_ctlogout(ctx, conn, cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Logout failed\n"); return 2; } } if (verbose) printf("Test succeeded\n"); return 0; } freetds-1.00.82/src/ctlib/unittests/t0006.c100644 025423 025423 00000025776 12522201763 0013712#include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include CS_CONTEXT *ctx; static int allSuccess = 1; typedef const char *STR; static int DoTest( /* source information */ CS_INT fromtype, void *fromdata, CS_INT fromlen, /* to information */ CS_INT totype, CS_INT tomaxlen, /* expected result */ CS_RETCODE tores, void *todata, CS_INT tolen, /* fields in string format */ STR sdecl, STR sfromtype, STR sfromdata, STR sfromlen, STR stotype, STR stomaxlen, STR stores, STR stodata, STR stolen, /* source line number for error reporting */ int line) { CS_DATAFMT destfmt, srcfmt; CS_INT reslen; CS_RETCODE retcode; int i; char buffer[1024]; const char *err = ""; assert(tolen >= 0); memset(&destfmt, 0, sizeof(destfmt)); destfmt.datatype = totype; destfmt.maxlength = tomaxlen; memset(&srcfmt, 0, sizeof(srcfmt)); srcfmt.datatype = fromtype; srcfmt.maxlength = fromlen; /* * FIXME this fix some thing but if error cs_convert should return * CS_UNUSED; note that this is defined 5.. a valid result ... */ reslen = 0; /* * TODO: add special case for CS_CHAR_TYPE and give different * flags and len */ /* do convert */ memset(buffer, 23, sizeof(buffer)); retcode = cs_convert(ctx, &srcfmt, fromdata, &destfmt, buffer, &reslen); /* test result of convert */ if (tores != retcode) { err = "result"; goto Failed; } /* test result len */ if (reslen != tolen) { err = "result length"; goto Failed; } /* test buffer */ if (todata && memcmp(todata, buffer, tolen) != 0) { int n; for (n = 0; n < tolen; ++n) printf("%02x ", ((unsigned char*)todata)[n]); printf("\n"); for (n = 0; n < tolen; ++n) printf("%02x ", ((unsigned char*)buffer)[n]); printf("\n"); err = "result data"; goto Failed; } /* test other part of buffer */ if (todata) memset(buffer, 23, tolen); for (i = 0; i < sizeof(buffer); ++i) if (buffer[i] != 23) { err = "buffer left"; goto Failed; } /* success */ return 0; Failed: fprintf(stderr, "Test %s failed (ret=%d len=%d)\n", err, (int) retcode, (int) reslen); fprintf(stderr, "line: %d\n DO_TEST(%s,\n" "\t %s,%s,%s,\n" "\t %s,%s,\n" "\t %s,%s,%s);\n", line, sdecl, sfromtype, sfromdata, sfromlen, stotype, stomaxlen, stores, stodata, stolen); allSuccess = 0; return 1; } #define DO_TEST(decl,fromtype,fromdata,fromlen,totype,tomaxlen,tores,todata,tolen) { \ decl; \ DoTest(fromtype,fromdata,fromlen,totype,tomaxlen,tores,todata,tolen,\ #decl,#fromtype,#fromdata,#fromlen,#totype,#tomaxlen,#tores,#todata,#tolen,\ __LINE__);\ } int main(int argc, char **argv) { CS_RETCODE ret; #ifdef tds_sysdep_int64_type volatile tds_sysdep_int64_type one = 1; #endif int verbose = 1; fprintf(stdout, "%s: Testing conversion\n", __FILE__); ret = cs_ctx_alloc(CS_VERSION_100, &ctx); if (ret != CS_SUCCEED) { fprintf(stderr, "Init failed\n"); return 1; } /* TODO For each conversion test different values of fromlen and tolen */ /* * * INT to everybody */ DO_TEST(CS_INT test = 12345; CS_INT test2 = 12345, CS_INT_TYPE, &test, sizeof(test), CS_INT_TYPE, sizeof(test2), CS_SUCCEED, &test2, sizeof(test2)); DO_TEST(CS_INT test = 12345; CS_INT test2 = 12345, CS_INT_TYPE, &test, sizeof(test), CS_INT_TYPE, sizeof(test2) * 2, CS_SUCCEED, &test2, sizeof(test2)); /* FIXME: correct ?? */ DO_TEST(CS_INT test = 12345; CS_INT test2 = 12345, CS_INT_TYPE, &test, sizeof(test), CS_INT_TYPE, sizeof(CS_SMALLINT), CS_SUCCEED, &test2, sizeof(test2)); DO_TEST(CS_INT test = 1234; CS_SMALLINT test2 = 1234, CS_INT_TYPE, &test, sizeof(test), CS_SMALLINT_TYPE, 1, CS_SUCCEED, &test2, sizeof(test2)); /* biggest and smallest SMALLINT */ DO_TEST(CS_INT test = 32767; CS_SMALLINT test2 = 32767, CS_INT_TYPE, &test, sizeof(test), CS_SMALLINT_TYPE, sizeof(test2), CS_SUCCEED, &test2, sizeof(test2)); DO_TEST(CS_INT test = -32768; CS_SMALLINT test2 = -32768, CS_INT_TYPE, &test, sizeof(test), CS_SMALLINT_TYPE, sizeof(test2), CS_SUCCEED, &test2, sizeof(test2)); /* overflow */ DO_TEST(CS_INT test = 32768; CS_SMALLINT test2 = 12345, CS_INT_TYPE, &test, sizeof(test), CS_SMALLINT_TYPE, sizeof(test2), CS_FAIL, NULL, 0); DO_TEST(CS_INT test = -32769; CS_SMALLINT test2 = 12345, CS_INT_TYPE, &test, sizeof(test), CS_SMALLINT_TYPE, sizeof(test2), CS_FAIL, NULL, 0); /* biggest and smallest TINYINT */ DO_TEST(CS_INT test = 255; CS_TINYINT test2 = 255, CS_INT_TYPE, &test, sizeof(test), CS_TINYINT_TYPE, sizeof(test2), CS_SUCCEED, &test2, sizeof(test2)); DO_TEST(CS_INT test = 0; CS_TINYINT test2 = 0, CS_INT_TYPE, &test, sizeof(test), CS_TINYINT_TYPE, sizeof(test2), CS_SUCCEED, &test2, sizeof(test2)); /* overflow */ DO_TEST(CS_INT test = 256; CS_TINYINT test2 = 1, CS_INT_TYPE, &test, sizeof(test), CS_TINYINT_TYPE, sizeof(test2), CS_FAIL, NULL, 0); DO_TEST(CS_INT test = -1; CS_TINYINT test2 = 1, CS_INT_TYPE, &test, sizeof(test), CS_TINYINT_TYPE, sizeof(test2), CS_FAIL, NULL, 0); /* biggest and smallest BIT */ DO_TEST(CS_INT test = 1; CS_BYTE test2 = 1, CS_INT_TYPE, &test, sizeof(test), CS_BIT_TYPE, sizeof(test2), CS_SUCCEED, &test2, sizeof(test2)); DO_TEST(CS_INT test = 0; CS_BYTE test2 = 0, CS_INT_TYPE, &test, sizeof(test), CS_BIT_TYPE, sizeof(test2), CS_SUCCEED, &test2, sizeof(test2)); /* overflow FIXME: or 1 if != 0 ?? */ DO_TEST(CS_INT test = 2; CS_BYTE test2 = 1, CS_INT_TYPE, &test, sizeof(test), CS_BIT_TYPE, sizeof(test2), CS_SUCCEED, &test2, sizeof(test2)); DO_TEST(CS_INT test = -1; CS_BYTE test2 = 1, CS_INT_TYPE, &test, sizeof(test), CS_BIT_TYPE, sizeof(test2), CS_SUCCEED, &test2, sizeof(test2)); DO_TEST(CS_INT test = 1234; CS_REAL test2 = 1234.0, CS_INT_TYPE, &test, sizeof(test), CS_REAL_TYPE, sizeof(test2), CS_SUCCEED, &test2, sizeof(test2)); DO_TEST(CS_INT test = -8765; CS_REAL test2 = -8765.0, CS_INT_TYPE, &test, sizeof(test), CS_REAL_TYPE, sizeof(test2), CS_SUCCEED, &test2, sizeof(test2)); DO_TEST(CS_INT test = 1234; CS_FLOAT test2 = 1234.0, CS_INT_TYPE, &test, sizeof(test), CS_FLOAT_TYPE, sizeof(test2), CS_SUCCEED, &test2, sizeof(test2)); DO_TEST(CS_INT test = -8765; CS_FLOAT test2 = -8765.0, CS_INT_TYPE, &test, sizeof(test), CS_FLOAT_TYPE, sizeof(test2), CS_SUCCEED, &test2, sizeof(test2)); DO_TEST(CS_INT test = 1234678; CS_MONEY4 test2 = { 1234678} , CS_INT_TYPE, &test, sizeof(test), CS_MONEY4_TYPE, sizeof(test2), CS_FAIL, NULL, 0); DO_TEST(CS_INT test = -8765; CS_MONEY4 test2 = { -8765 * 10000} , CS_INT_TYPE, &test, sizeof(test), CS_MONEY4_TYPE, sizeof(test2), CS_SUCCEED, &test2, sizeof(test2)); /* strange money formatting */ DO_TEST(CS_CHAR test[] = ""; CS_MONEY4 test2 = { 0} , CS_CHAR_TYPE, test, strlen(test), CS_MONEY4_TYPE, sizeof(test2), CS_SUCCEED, &test2, sizeof(test2)); DO_TEST(CS_CHAR test[] = "."; CS_MONEY4 test2 = { 0} , CS_CHAR_TYPE, test, strlen(test), CS_MONEY4_TYPE, sizeof(test2), CS_SUCCEED, &test2, sizeof(test2)); DO_TEST(CS_CHAR test[] = ".12"; CS_MONEY4 test2 = { 1200} , CS_CHAR_TYPE, test, strlen(test), CS_MONEY4_TYPE, sizeof(test2), CS_SUCCEED, &test2, sizeof(test2)); DO_TEST(CS_CHAR test[] = "++++-123"; CS_MONEY4 test2 = { -123 * 10000} , CS_CHAR_TYPE, test, strlen(test), CS_MONEY4_TYPE, sizeof(test2), CS_FAIL, NULL, 0); DO_TEST(CS_CHAR test[] = " -123"; CS_MONEY4 test2 = { -123 * 10000} , CS_CHAR_TYPE, test, strlen(test), CS_MONEY4_TYPE, sizeof(test2), CS_SUCCEED, &test2, sizeof(test2)); DO_TEST(CS_CHAR test[] = " +123"; CS_MONEY4 test2 = { 123 * 10000} , CS_CHAR_TYPE, test, strlen(test), CS_MONEY4_TYPE, sizeof(test2), CS_SUCCEED, &test2, sizeof(test2)); DO_TEST(CS_CHAR test[] = "+123.1234"; CS_MONEY4 test2 = { 1231234} , CS_CHAR_TYPE, test, strlen(test), CS_MONEY4_TYPE, sizeof(test2), CS_SUCCEED, &test2, sizeof(test2)); DO_TEST(CS_CHAR test[] = "+123.123411"; CS_MONEY4 test2 = { 1231234} , CS_CHAR_TYPE, test, strlen(test), CS_MONEY4_TYPE, sizeof(test2), CS_SUCCEED, &test2, sizeof(test2)); DO_TEST(CS_CHAR test[] = "+123.12.3411"; CS_MONEY4 test2 = { 1231234} , CS_CHAR_TYPE, test, strlen(test), CS_MONEY4_TYPE, sizeof(test2), CS_FAIL, NULL, 0); DO_TEST(CS_CHAR test[] = "pippo"; CS_MONEY4 test2 = { 0} , CS_CHAR_TYPE, test, strlen(test), CS_MONEY4_TYPE, sizeof(test2), CS_FAIL, NULL, 0); /* not terminated money */ DO_TEST(CS_CHAR test[] = "-1234567"; CS_MONEY4 test2 = { -1230000} , CS_CHAR_TYPE, test, 4, CS_MONEY4_TYPE, sizeof(test2), CS_SUCCEED, &test2, sizeof(test2)); #ifdef tds_sysdep_int64_type DO_TEST(CS_INT test = 1234678; CS_MONEY test2; test2.mnyhigh = ((one * 1234678) * 10000) >> 32; test2.mnylow = (CS_UINT) ((one * 1234678) * 10000), CS_INT_TYPE, &test, sizeof(test), CS_MONEY_TYPE, sizeof(test2), CS_SUCCEED, &test2, sizeof(test2)); DO_TEST(CS_INT test = -8765; CS_MONEY test2; test2.mnyhigh = ((one * -8765) * 10000) >> 32; test2.mnylow = (CS_UINT) ((one * -8765) * 10000), CS_INT_TYPE, &test, sizeof(test), CS_MONEY_TYPE, sizeof(test2), CS_SUCCEED, &test2, sizeof(test2)); #endif DO_TEST(CS_INT test = 12345; CS_CHAR test2[] = "12345", CS_INT_TYPE, &test, sizeof(test), CS_CHAR_TYPE, sizeof(test2), CS_SUCCEED, test2, sizeof(test2) - 1); { CS_VARCHAR test2 = { 5, "12345"}; memset(test2.str+5, 23, 251); DO_TEST(CS_INT test = 12345, CS_INT_TYPE,&test,sizeof(test), CS_VARCHAR_TYPE,sizeof(test2), CS_SUCCEED,&test2,sizeof(test2)); } DO_TEST(CS_CHAR test[] = "12345"; CS_INT test2 = 12345, CS_CHAR_TYPE, test, 5, CS_INT_TYPE, sizeof(test2), CS_SUCCEED, &test2, sizeof(test2)); /* unterminated number */ DO_TEST(CS_CHAR test[] = " - 12345"; CS_INT test2 = -12, CS_CHAR_TYPE, test, 5, CS_INT_TYPE, sizeof(test2), CS_SUCCEED, &test2, sizeof(test2)); /* to binary */ DO_TEST(CS_CHAR test[] = "abc"; CS_CHAR test2[] = "abc", CS_BINARY_TYPE, test, 3, CS_BINARY_TYPE, 3, CS_SUCCEED, test2, 3); #if 0 DO_TEST(CS_CHAR test[] = "abcdef"; CS_CHAR test2[] = "ab", CS_BINARY_TYPE, test, 6, CS_BINARY_TYPE, 2, CS_FAIL, test2, 2); DO_TEST(CS_CHAR test[] = "abc"; CS_CHAR test2[] = "ab", CS_BINARY_TYPE, test, 3, CS_BINARY_TYPE, 2, CS_FAIL, test2, 2); #endif DO_TEST(CS_CHAR test[] = "616263"; CS_CHAR test2[] = "abc", CS_CHAR_TYPE, test, 6, CS_BINARY_TYPE, 3, CS_SUCCEED, test2, 3); DO_TEST(CS_CHAR test[] = "616263646566"; CS_CHAR test2[] = "abc", CS_CHAR_TYPE, test, 12, CS_BINARY_TYPE, 3, CS_FAIL, test2, 3); /* to char */ DO_TEST(CS_INT test = 1234567; CS_CHAR test2[] = "1234567", CS_INT_TYPE, &test, sizeof(test), CS_CHAR_TYPE, 7, CS_SUCCEED, test2, 7); DO_TEST(CS_CHAR test[] = "abc"; CS_CHAR test2[] = "ab", CS_CHAR_TYPE, test, 3, CS_CHAR_TYPE, 2, CS_FAIL, test2, 2); DO_TEST(CS_CHAR test[] = "abc"; CS_CHAR test2[] = "616263", CS_BINARY_TYPE, test, 3, CS_CHAR_TYPE, 6, CS_SUCCEED, test2, 6); DO_TEST(CS_CHAR test[] = "abcdef"; CS_CHAR test2[] = "616263", CS_BINARY_TYPE, test, 6, CS_CHAR_TYPE, 6, CS_FAIL, test2, 6); ret = cs_ctx_drop(ctx); if (ret != CS_SUCCEED) { fprintf(stderr, "Drop failed\n"); return 2; } if (verbose && allSuccess) { fprintf(stdout, "Test succeded\n"); } return allSuccess ? 0 : 1; } freetds-1.00.82/src/ctlib/unittests/t0007.c100644 025423 025423 00000014227 12522201763 0013700#include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include "common.h" static char software_version[] = "$Id: t0007.c,v 1.11 2011-05-16 08:51:40 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; /* Testing: Retrieve CS_TEXT_TYPE using ct_bind() */ int main(int argc, char **argv) { CS_CONTEXT *ctx; CS_CONNECTION *conn; CS_COMMAND *cmd; int verbose = 0; CS_RETCODE ret; CS_RETCODE results_ret; CS_INT result_type; CS_INT num_cols; CS_DATAFMT datafmt[4]; CS_INT datalength[4]; CS_SMALLINT ind[4]; CS_INT count, row_count = 0; CS_CHAR name[4][1024]; name[0][0] = 0; name[1][0] = 0; name[2][0] = 0; name[3][0] = 0; fprintf(stdout, "%s: Retrieve CS_CHAR_TYPE using ct_bind()\n", __FILE__); if (verbose) { fprintf(stdout, "Trying login\n"); } ret = try_ctlogin(&ctx, &conn, &cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Login failed\n"); return 1; } ret = ct_command(cmd, CS_LANG_CMD, "SELECT CONVERT(VARCHAR(7),'1234') AS test, CONVERT(VARCHAR(7),'') AS test2, CONVERT(VARCHAR(7),NULL) AS test3, CONVERT(NUMERIC(38,2), 123.45) as test4", CS_NULLTERM, CS_UNUSED); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_command() failed\n"); return 1; } ret = ct_send(cmd); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_send() failed\n"); return 1; } while ((results_ret = ct_results(cmd, &result_type)) == CS_SUCCEED) { switch ((int) result_type) { case CS_CMD_SUCCEED: break; case CS_CMD_DONE: break; case CS_CMD_FAIL: fprintf(stderr, "ct_results() result_type CS_CMD_FAIL.\n"); return 1; case CS_ROW_RESULT: ret = ct_res_info(cmd, CS_NUMDATA, &num_cols, CS_UNUSED, NULL); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_res_info() failed"); return 1; } if (num_cols != 4) { fprintf(stderr, "num_cols %d != 4", num_cols); return 1; } if (ct_describe(cmd, 1, &datafmt[0]) != CS_SUCCEED) { fprintf(stderr, "ct_describe() failed"); return 1; } datafmt[0].format = CS_FMT_NULLTERM; ++datafmt[0].maxlength; if (datafmt[0].maxlength > 1024) { datafmt[0].maxlength = 1024; } if (ct_describe(cmd, 2, &datafmt[1]) != CS_SUCCEED) { fprintf(stderr, "ct_describe() failed"); return 1; } datafmt[1].format = CS_FMT_NULLTERM; ++datafmt[1].maxlength; if (datafmt[1].maxlength > 1024) { datafmt[1].maxlength = 1024; } if (ct_describe(cmd, 3, &datafmt[2]) != CS_SUCCEED) { fprintf(stderr, "ct_describe() failed\n"); return 1; } datafmt[2].format = CS_FMT_NULLTERM; ++datafmt[2].maxlength; if (datafmt[2].maxlength > 1024) { datafmt[2].maxlength = 1024; } if (ct_describe(cmd, 4, &datafmt[3]) != CS_SUCCEED) { fprintf(stderr, "ct_describe() failed\n"); return 1; } datafmt[3].format = CS_FMT_NULLTERM; if (datafmt[3].maxlength != sizeof(CS_NUMERIC)) { fprintf(stderr, "wrong maxlength for numeric\n"); return 1; } ++datafmt[3].maxlength; if (datafmt[3].maxlength > 1024) { datafmt[3].maxlength = 1024; } if (ct_bind(cmd, 1, &datafmt[0], name[0], &datalength[0], &ind[0]) != CS_SUCCEED) { fprintf(stderr, "ct_bind() failed\n"); return 1; } if (ct_bind(cmd, 2, &datafmt[1], name[1], &datalength[1], &ind[1]) != CS_SUCCEED) { fprintf(stderr, "ct_bind() failed\n"); return 1; } if (ct_bind(cmd, 3, &datafmt[2], name[2], &datalength[2], &ind[2]) != CS_SUCCEED) { fprintf(stderr, "ct_bind() failed\n"); return 1; } if (ct_bind(cmd, 4, &datafmt[3], name[3], &datalength[3], &ind[3]) != CS_SUCCEED) { fprintf(stderr, "ct_bind() failed\n"); return 1; } while (((ret = ct_fetch(cmd, CS_UNUSED, CS_UNUSED, CS_UNUSED, &count)) == CS_SUCCEED) || (ret == CS_ROW_FAIL)) { row_count += count; if (ret == CS_ROW_FAIL) { fprintf(stderr, "ct_fetch() CS_ROW_FAIL on row %d.\n", row_count); return 1; } else { /* ret == CS_SUCCEED */ if (verbose) { fprintf(stdout, "name = '%s'\n", name[0]); } if (ind[0] != 0) { fprintf(stderr, "Returned NULL\n"); return 1; } if (strcmp(name[0], "1234")) { fprintf(stderr, "Bad return:\n'%s'\n! =\n'%s'\n", name[0], "1234"); return 1; } if (datalength[0] != strlen(name[0]) + 1) { fprintf(stderr, "Bad length:\n'%ld'\n! =\n'%d'\n", (long) strlen(name[0]) + 1, datalength[0]); return 1; } if (ind[1] != 0) { fprintf(stderr, "Returned NULL\n"); return 1; } /* empty are retunerd as a single space in TDS4.x and TDS5 */ if (strcmp(name[1], "") && strcmp(name[1], " ")) { fprintf(stderr, "Bad return:\n'%s'\n! =\n'%s'\n", name[1], ""); return 1; } if (datalength[1] != strlen(name[1]) + 1) { fprintf(stderr, "Col 2 bad length:\n'%ld'\n! =\n'%d'\n", (long) strlen(name[1]) + 1, datalength[1]); return 1; } if (ind[2] == 0) { fprintf(stderr, "Col 3 returned not NULL (ind %d len %d)\n", (int) ind[2], (int) datalength[2]); return 1; } if (strcmp(name[2], "")) { fprintf(stderr, "Col 3 bad return:\n'%s'\n! =\n'%s'\n", name[2], ""); return 1; } if (datalength[2] != 0) { fprintf(stderr, "Col 3 bad length:\n'%ld'\n! =\n'%d'\n", (long) 0, datalength[2]); return 1; } } } switch ((int) ret) { case CS_END_DATA: break; case CS_FAIL: fprintf(stderr, "ct_fetch() returned CS_FAIL.\n"); return 1; default: fprintf(stderr, "ct_fetch() unexpected return.\n"); return 1; } break; case CS_COMPUTE_RESULT: fprintf(stderr, "ct_results() unexpected CS_COMPUTE_RESULT.\n"); return 1; default: fprintf(stderr, "ct_results() unexpected result_type.\n"); return 1; } } switch ((int) results_ret) { case CS_END_RESULTS: break; case CS_FAIL: fprintf(stderr, "ct_results() failed.\n"); return 1; break; default: fprintf(stderr, "ct_results() unexpected return.\n"); return 1; } if (verbose) { fprintf(stdout, "Trying logout\n"); } ret = try_ctlogout(ctx, conn, cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Logout failed\n"); return 1; } return 0; } freetds-1.00.82/src/ctlib/unittests/t0008.c100644 025423 025423 00000007400 12522201763 0013674#include #include #include #include #include "common.h" static char software_version[] = "$Id: t0008.c,v 1.10 2011-05-16 08:51:40 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; /* * ct_send SQL |select name = @@servername| * ct_bind variable * ct_fetch and print results */ int main(int argc, char **argv) { int verbose = 1; CS_CONTEXT *ctx; CS_CONNECTION *conn; CS_COMMAND *cmd; CS_RETCODE ret; CS_DATAFMT srcfmt; CS_INT src = 32768; CS_DATAFMT dstfmt; CS_SMALLINT dst; fprintf(stdout, "%s: Testing context callbacks\n", __FILE__); srcfmt.datatype = CS_INT_TYPE; srcfmt.maxlength = sizeof(CS_INT); srcfmt.locale = NULL; #if 0 dstfmt.datatype = CS_SMALLINT_TYPE; #else dstfmt.datatype = CS_DATETIME_TYPE; #endif dstfmt.maxlength = sizeof(CS_SMALLINT); dstfmt.locale = NULL; if (verbose) { fprintf(stdout, "Trying clientmsg_cb with context\n"); } if (cs_ctx_alloc(CS_VERSION_100, &ctx) != CS_SUCCEED) { fprintf(stderr, "cs_ctx_alloc() failed\n"); } if (ct_init(ctx, CS_VERSION_100) != CS_SUCCEED) { fprintf(stderr, "ct_init() failed\n"); } if (ct_callback(ctx, NULL, CS_SET, CS_CLIENTMSG_CB, (CS_VOID*) clientmsg_cb) != CS_SUCCEED) { fprintf(stderr, "ct_callback() failed\n"); return 1; } clientmsg_cb_invoked = 0; if (cs_convert(ctx, &srcfmt, &src, &dstfmt, &dst, NULL) == CS_SUCCEED) { fprintf(stderr, "cs_convert() succeeded when failure was expected\n"); return 1; } if (clientmsg_cb_invoked != 0) { fprintf(stderr, "clientmsg_cb was invoked!\n"); return 1; } if (verbose) { fprintf(stdout, "Trying cslibmsg_cb\n"); } if (cs_config(ctx, CS_SET, CS_MESSAGE_CB, (CS_VOID*) cslibmsg_cb, CS_UNUSED, NULL) != CS_SUCCEED) { fprintf(stderr, "cs_config() failed\n"); return 1; } cslibmsg_cb_invoked = 0; if (cs_convert(ctx, &srcfmt, &src, &dstfmt, &dst, NULL) == CS_SUCCEED) { fprintf(stderr, "cs_convert() succeeded when failure was expected\n"); return 1; } if (cslibmsg_cb_invoked == 0) { fprintf(stderr, "cslibmsg_cb was not invoked!\n"); return 1; } if (ct_exit(ctx, CS_UNUSED) != CS_SUCCEED) { fprintf(stderr, "ct_exit() failed\n"); } if (cs_ctx_drop(ctx) != CS_SUCCEED) { fprintf(stderr, "cx_ctx_drop() failed\n"); } if (verbose) { fprintf(stdout, "Trying login\n"); } ret = try_ctlogin(&ctx, &conn, &cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Login failed\n"); return 1; } if (verbose) { fprintf(stdout, "Trying clientmsg_cb with connection\n"); } ret = ct_callback(NULL, conn, CS_SET, CS_CLIENTMSG_CB, (CS_VOID *) clientmsg_cb); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_callback() failed\n"); return 1; } clientmsg_cb_invoked = 0; ret = run_command(cmd, "."); if (ret != CS_SUCCEED) { fprintf(stderr, "run_command() failed\n"); return 1; } if (clientmsg_cb_invoked) { fprintf(stderr, "clientmsg_cb was invoked!\n"); return 1; } if (verbose) { fprintf(stdout, "Trying servermsg_cb with connection\n"); } ret = ct_callback(NULL, conn, CS_SET, CS_SERVERMSG_CB, (CS_VOID *) servermsg_cb); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_callback() failed\n"); return 1; } servermsg_cb_invoked = 0; #if 0 ret = run_command(cmd, "raiserror 99999 'This is a test'"); ret = run_command(cmd, "raiserror('This is a test', 17, 1)"); #else ret = run_command(cmd, "print 'This is a test'"); #endif if (ret != CS_SUCCEED) { fprintf(stderr, "run_command() failed\n"); return 1; } if (servermsg_cb_invoked == 0) { fprintf(stderr, "servermsg_cb was not invoked!\n"); return 1; } if (verbose) { fprintf(stdout, "Trying logout\n"); } ret = try_ctlogout(ctx, conn, cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Logout failed\n"); return 1; } return 0; } freetds-1.00.82/src/ctlib/unittests/t0009.c100644 025423 025423 00000021264 12717145107 0013706#include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include "common.h" static CS_RETCODE ex_servermsg_cb(CS_CONTEXT * context, CS_CONNECTION * connection, CS_SERVERMSG * errmsg); static int compute_supported = 1; /* Testing: Retrieve compute results */ int main(int argc, char *argv[]) { CS_CONTEXT *ctx; CS_CONNECTION *conn; CS_COMMAND *cmd; int verbose = 0; CS_RETCODE ret; CS_RETCODE results_ret; CS_INT result_type; CS_INT num_cols, compute_id; CS_DATAFMT datafmt; CS_INT datalength; CS_SMALLINT ind; CS_INT count, row_count = 0; CS_CHAR select[1024]; CS_INT col1; CS_CHAR col2[2]; CS_CHAR col3[32]; CS_INT compute_col1; CS_CHAR compute_col3[32]; unsigned rows[3] = { 0, 0, 0 }; fprintf(stdout, "%s: Retrieve compute results processing\n", __FILE__); if (verbose) { fprintf(stdout, "Trying login\n"); } ret = try_ctlogin(&ctx, &conn, &cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Login failed\n"); return 1; } ret = run_command(cmd, "CREATE TABLE #ctlib0009 (col1 int not null, col2 char(1) not null, col3 datetime not null)"); if (ret != CS_SUCCEED) return 1; ret = run_command(cmd, "insert into #ctlib0009 values (1, 'A', 'Jan 1 2002 10:00:00AM')"); if (ret != CS_SUCCEED) return 1; ret = run_command(cmd, "insert into #ctlib0009 values (2, 'A', 'Jan 2 2002 10:00:00AM')"); if (ret != CS_SUCCEED) return 1; ret = run_command(cmd, "insert into #ctlib0009 values (3, 'A', 'Jan 3 2002 10:00:00AM')"); if (ret != CS_SUCCEED) return 1; ret = run_command(cmd, "insert into #ctlib0009 values (8, 'B', 'Jan 4 2002 10:00:00AM')"); if (ret != CS_SUCCEED) return 1; ret = run_command(cmd, "insert into #ctlib0009 values (9, 'B', 'Jan 5 2002 10:00:00AM')"); if (ret != CS_SUCCEED) return 1; strcpy(select, "select col1, col2, col3 from #ctlib0009 order by col2 "); strcat(select, "compute sum(col1) by col2 "); strcat(select, "compute max(col3)"); ret = ct_command(cmd, CS_LANG_CMD, select, CS_NULLTERM, CS_UNUSED); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_command(%s) failed\n", select); return 1; } ret = ct_send(cmd); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_send() failed\n"); return 1; } ct_callback(ctx, NULL, CS_SET, CS_SERVERMSG_CB, (CS_VOID *) ex_servermsg_cb); while ((results_ret = ct_results(cmd, &result_type)) == CS_SUCCEED) { printf("ct_results returned %s type\n", res_type_str(result_type)); switch ((int) result_type) { case CS_CMD_SUCCEED: break; case CS_CMD_DONE: break; case CS_CMD_FAIL: if (!compute_supported) { try_ctlogout(ctx, conn, cmd, verbose); return 0; } fprintf(stderr, "ct_results() result_type CS_CMD_FAIL.\n"); return 1; case CS_ROW_RESULT: ret = ct_res_info(cmd, CS_NUMDATA, &num_cols, CS_UNUSED, NULL); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_res_info() failed"); return 1; } if (num_cols != 3) { fprintf(stderr, "num_cols %d != 3", num_cols); return 1; } ret = ct_describe(cmd, 1, &datafmt); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_describe() failed"); return 1; } datafmt.format = CS_FMT_UNUSED; if (datafmt.maxlength > 1024) { datafmt.maxlength = 1024; } ret = ct_bind(cmd, 1, &datafmt, &col1, &datalength, &ind); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_bind() failed\n"); return 1; } ret = ct_describe(cmd, 2, &datafmt); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_describe() failed"); return 1; } datafmt.format = CS_FMT_NULLTERM; datafmt.maxlength = 2; ret = ct_bind(cmd, 2, &datafmt, col2, &datalength, &ind); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_bind() failed\n"); return 1; } ret = ct_describe(cmd, 3, &datafmt); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_describe() failed"); return 1; } datafmt.datatype = CS_CHAR_TYPE; datafmt.format = CS_FMT_NULLTERM; datafmt.maxlength = 32; ret = ct_bind(cmd, 3, &datafmt, col3, &datalength, &ind); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_bind() failed\n"); return 1; } while (((ret = ct_fetch(cmd, CS_UNUSED, CS_UNUSED, CS_UNUSED, &count)) == CS_SUCCEED) || (ret == CS_ROW_FAIL)) { row_count += count; if (ret == CS_ROW_FAIL) { fprintf(stderr, "ct_fetch() CS_ROW_FAIL on row %d.\n", row_count); return 1; } else { /* ret == CS_SUCCEED */ fprintf(stdout, "col1 = %d col2= '%s', col3 = '%s'\n", col1, col2, col3); ++rows[0]; } } switch ((int) ret) { case CS_END_DATA: break; case CS_FAIL: fprintf(stderr, "ct_fetch() returned CS_FAIL.\n"); return 1; default: fprintf(stderr, "ct_fetch() unexpected return.\n"); return 1; } break; case CS_COMPUTE_RESULT: printf("testing compute_result\n"); ret = ct_compute_info(cmd, CS_COMP_ID, CS_UNUSED, &compute_id, CS_UNUSED, NULL); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_compute_info() failed"); return 1; } if (compute_id != 1 && compute_id != 2) { fprintf(stderr, "invalid compute_id value"); return 1; } if (compute_id == 1) { ret = ct_res_info(cmd, CS_NUMDATA, &num_cols, CS_UNUSED, NULL); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_res_info() failed"); return 1; } if (num_cols != 1) { fprintf(stderr, "compute_id %d num_cols %d != 1", compute_id, num_cols); return 1; } ret = ct_describe(cmd, 1, &datafmt); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_describe() failed"); return 1; } datafmt.format = CS_FMT_UNUSED; if (datafmt.maxlength > 1024) { datafmt.maxlength = 1024; } compute_col1 = -1; ret = ct_bind(cmd, 1, &datafmt, &compute_col1, &datalength, &ind); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_bind() failed\n"); return 1; } } if (compute_id == 2) { ret = ct_res_info(cmd, CS_NUMDATA, &num_cols, CS_UNUSED, NULL); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_res_info() failed"); return 1; } if (num_cols != 1) { fprintf(stderr, "compute_id %d num_cols %d != 1", compute_id, num_cols); return 1; } ret = ct_describe(cmd, 1, &datafmt); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_describe() failed"); return 1; } datafmt.datatype = CS_CHAR_TYPE; datafmt.format = CS_FMT_NULLTERM; datafmt.maxlength = 32; compute_col3[0] = 0; ret = ct_bind(cmd, 1, &datafmt, compute_col3, &datalength, &ind); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_bind() failed\n"); return 1; } } while (((ret = ct_fetch(cmd, CS_UNUSED, CS_UNUSED, CS_UNUSED, &count)) == CS_SUCCEED) || (ret == CS_ROW_FAIL)) { row_count += count; if (ret == CS_ROW_FAIL) { fprintf(stderr, "ct_fetch() CS_ROW_FAIL on row %d.\n", row_count); return 1; } else { /* ret == CS_SUCCEED */ if (compute_id == 1) { fprintf(stdout, "compute_col1 = %d \n", compute_col1); if (compute_col1 != 6 && compute_col1 != 17) { fprintf(stderr, "(should be 6 or 17)\n"); return 1; } } if (compute_id == 2) { fprintf(stdout, "compute_col3 = '%s'\n", compute_col3); if (strcmp("Jan 5 2002 10:00:00AM", compute_col3) && strcmp("Jan 05 2002 10:00AM", compute_col3) && strcmp("Jan 5 2002 10:00AM", compute_col3)) { fprintf(stderr, "(should be \"Jan 5 2002 10:00:00AM\")\n"); return 1; } } ++rows[compute_id]; } } switch ((int) ret) { case CS_END_DATA: break; case CS_FAIL: fprintf(stderr, "ct_fetch() returned CS_FAIL.\n"); return 1; default: fprintf(stderr, "ct_fetch() unexpected return.\n"); return 1; } break; default: fprintf(stderr, "ct_results() unexpected result_type.\n"); return 1; } } switch ((int) results_ret) { case CS_END_RESULTS: break; case CS_FAIL: fprintf(stderr, "ct_results() failed.\n"); return 1; break; default: fprintf(stderr, "ct_results() unexpected return.\n"); return 1; } if (rows[0] != 5 || rows[1] != 2 || rows[2] != 1) { fprintf(stderr, "wrong number of rows: normal %u compute_1 %u compute_2 %u, expected 5 2 1\n", rows[0], rows[1], rows[2]); return 1; } if (verbose) { fprintf(stdout, "Trying logout\n"); } ret = try_ctlogout(ctx, conn, cmd, verbose); if (ret != CS_SUCCEED) { fprintf(stderr, "Logout failed\n"); return 1; } return 0; } static CS_RETCODE ex_servermsg_cb(CS_CONTEXT * context, CS_CONNECTION * connection, CS_SERVERMSG * srvmsg) { if (strstr(srvmsg->text, "compute")) { compute_supported = 0; printf("Server does not support compute\n"); return CS_SUCCEED; } return servermsg_cb(context, connection, srvmsg); } freetds-1.00.82/src/ctlib/unittests/CMakeLists.txt100644 025423 025423 00000001304 12607665421 0015523add_library(c_common STATIC common.c common.h) foreach(target t0001 t0002 t0003 t0004 t0005 t0006 t0007 t0008 t0009 connect_fail ct_options lang_ct_param array_bind cs_diag get_send_data rpc_ct_param rpc_ct_setparam ct_diagclient ct_diagserver ct_diagall cs_config cancel blk_in blk_out ct_cursor ct_cursors ct_dynamic blk_in2 datafmt) add_executable(c_${target} EXCLUDE_FROM_ALL ${target}.c) set_target_properties(c_${target} PROPERTIES OUTPUT_NAME ${target}) target_link_libraries(c_${target} c_common ct replacements ${lib_NETWORK} ${lib_BASE}) add_test(NAME c_${target} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${target}) add_dependencies(check c_${target}) endforeach(target) freetds-1.00.82/src/dblib/Makefile.am100644 025423 025423 00000001334 13203773221 0012726# $Id: Makefile.am,v 1.39 2011-12-05 02:26:31 jklowden Exp $ SUBDIRS = . unittests AM_CPPFLAGS = -I$(top_srcdir)/include lib_LTLIBRARIES = libsybdb.la libsybdb_la_SOURCES= dblib.c dbutil.c rpc.c bcp.c xact.c dbpivot.c if SYBASE_COMPAT libsybdb_la_SOURCES += dbopen.c endif if MINGW32 libsybdb_la_SOURCES += winmain.c endif EXTRA_DIST = dbopen.c buffering.h CMakeLists.txt winmain.c dblib.def # bumped for dbanydatecrack libsybdb_la_LDFLAGS= -version-info 6:0:1 $(FREETDS_SYMBOLIC) if !MACOSX libsybdb_la_LDFLAGS += -export-symbols-regex '^(db|bcp_|tdsdump_open|tdsdbopen|.*_xact|close_commit|open_commit|.?asprintf).*' endif libsybdb_la_LIBADD= ../tds/libtds.la ../replacements/libreplacements.la $(FREETDS_LIBGCC) $(LTLIBICONV) freetds-1.00.82/src/dblib/Makefile.in100644 025423 025423 00000067450 13242511111 0012741# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @SYBASE_COMPAT_TRUE@am__append_1 = dbopen.c @MINGW32_TRUE@am__append_2 = winmain.c @MACOSX_FALSE@am__append_3 = -export-symbols-regex '^(db|bcp_|tdsdump_open|tdsdbopen|.*_xact|close_commit|open_commit|.?asprintf).*' subdir = src/dblib ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = \ $(top_srcdir)/m4/ac_caolan_func_which_gethostbyname_r.m4 \ $(top_srcdir)/m4/ac_have_inaddr_none.m4 \ $(top_srcdir)/m4/ac_have_malloc_options.m4 \ $(top_srcdir)/m4/ac_nullzero.m4 \ $(top_srcdir)/m4/ac_raf_func_which_getservbyname_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_gethostbyaddr_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_getpwuid_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_localtime_r.m4 \ $(top_srcdir)/m4/acx_pthread.m4 \ $(top_srcdir)/m4/ax_cflags_gcc_option.m4 \ $(top_srcdir)/m4/check_openssl.m4 \ $(top_srcdir)/m4/gettimemilli.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/pushlibs.m4 \ $(top_srcdir)/m4/sprintf_i64_format.m4 \ $(top_srcdir)/m4/type_socklen_t.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(libdir)" LTLIBRARIES = $(lib_LTLIBRARIES) am__DEPENDENCIES_1 = libsybdb_la_DEPENDENCIES = ../tds/libtds.la \ ../replacements/libreplacements.la $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) am__libsybdb_la_SOURCES_DIST = dblib.c dbutil.c rpc.c bcp.c xact.c \ dbpivot.c dbopen.c winmain.c @SYBASE_COMPAT_TRUE@am__objects_1 = dbopen.lo @MINGW32_TRUE@am__objects_2 = winmain.lo am_libsybdb_la_OBJECTS = dblib.lo dbutil.lo rpc.lo bcp.lo xact.lo \ dbpivot.lo $(am__objects_1) $(am__objects_2) libsybdb_la_OBJECTS = $(am_libsybdb_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = libsybdb_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(libsybdb_la_LDFLAGS) $(LDFLAGS) -o $@ AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libsybdb_la_SOURCES) DIST_SOURCES = $(am__libsybdb_la_SOURCES_DIST) RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp \ $(top_srcdir)/mkinstalldirs DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BUILD_NUMBER = @BUILD_NUMBER@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOXYGEN = @DOXYGEN@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FREETDS_LIBGCC = @FREETDS_LIBGCC@ FREETDS_ODBC_MODULE = @FREETDS_ODBC_MODULE@ FREETDS_SYMBOLIC = @FREETDS_SYMBOLIC@ GCRYPT_CFLAGS = @GCRYPT_CFLAGS@ GCRYPT_LIBS = @GCRYPT_LIBS@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ HAVE_OPENSSL = @HAVE_OPENSSL@ HAVE_PERL_SOURCES = @HAVE_PERL_SOURCES@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBADD_DL = @LIBADD_DL@ LIBADD_DLD_LINK = @LIBADD_DLD_LINK@ LIBADD_DLOPEN = @LIBADD_DLOPEN@ LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@ LIBICONV = @LIBICONV@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBOBJS = @LTLIBOBJS@ LT_DLLOADERS = @LT_DLLOADERS@ LT_DLPREOPEN = @LT_DLPREOPEN@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ NETTLE_CFLAGS = @NETTLE_CFLAGS@ NETTLE_LIBS = @NETTLE_LIBS@ NETWORK_LIBS = @NETWORK_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ODBC = @ODBC@ ODBCINSTLIB = @ODBCINSTLIB@ ODBCLIB = @ODBCLIB@ ODBCNODMLIB = @ODBCNODMLIB@ ODBCNODMLIBAPP = @ODBCNODMLIBAPP@ ODBC_CONFIG = @ODBC_CONFIG@ ODBC_INC = @ODBC_INC@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ RC = @RC@ READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SUBVERSION = @SUBVERSION@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ dblib_define = @dblib_define@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ tds_sysdep_int16_type = @tds_sysdep_int16_type@ tds_sysdep_int32_type = @tds_sysdep_int32_type@ tds_sysdep_int64_type = @tds_sysdep_int64_type@ tds_sysdep_intptr_type = @tds_sysdep_intptr_type@ tds_sysdep_real32_type = @tds_sysdep_real32_type@ tds_sysdep_real64_type = @tds_sysdep_real64_type@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # $Id: Makefile.am,v 1.39 2011-12-05 02:26:31 jklowden Exp $ SUBDIRS = . unittests AM_CPPFLAGS = -I$(top_srcdir)/include lib_LTLIBRARIES = libsybdb.la libsybdb_la_SOURCES = dblib.c dbutil.c rpc.c bcp.c xact.c dbpivot.c \ $(am__append_1) $(am__append_2) EXTRA_DIST = dbopen.c buffering.h CMakeLists.txt winmain.c dblib.def # bumped for dbanydatecrack libsybdb_la_LDFLAGS = -version-info 6:0:1 $(FREETDS_SYMBOLIC) \ $(am__append_3) libsybdb_la_LIBADD = ../tds/libtds.la ../replacements/libreplacements.la $(FREETDS_LIBGCC) $(LTLIBICONV) all: all-recursive .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/dblib/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/dblib/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libsybdb.la: $(libsybdb_la_OBJECTS) $(libsybdb_la_DEPENDENCIES) $(EXTRA_libsybdb_la_DEPENDENCIES) $(AM_V_CCLD)$(libsybdb_la_LINK) -rpath $(libdir) $(libsybdb_la_OBJECTS) $(libsybdb_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bcp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dblib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbopen.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbpivot.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbutil.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rpc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/winmain.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xact.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile $(LTLIBRARIES) installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(libdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ mostlyclean-am distclean: distclean-recursive -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-libLTLIBRARIES install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-libLTLIBRARIES .MAKE: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-generic clean-libLTLIBRARIES \ clean-libtool cscopelist-am ctags ctags-am distclean \ distclean-compile distclean-generic 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-libLTLIBRARIES install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs installdirs-am 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-libLTLIBRARIES .PRECIOUS: Makefile # 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: freetds-1.00.82/src/dblib/dblib.c100644 025423 025423 00000754266 13204244023 0012127/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns * Copyright (C) 2006-2015 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #if HAVE_ERRNO_H # include #endif /* HAVE_ERRNO_H */ /** * \ingroup dblib_core * \remarks Either SYBDBLIB or MSDBLIB (not both) must be defined. * This affects how certain application-addressable * strucures are defined. */ #include #include #include #include #include #include #include #include #include #include static RETCODE _dbresults(DBPROCESS * dbproc); static BYTE *_dbcoldata(TDSCOLUMN *colinfo); static int _get_printable_size(TDSCOLUMN * colinfo); static char *_dbprdate(char *timestr); static int _dbnullable(DBPROCESS * dbproc, int column); static const char *tds_prdatatype(int datatype_token); static int default_err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr); void copy_data_to_host_var(DBPROCESS *, TDS_SERVER_TYPE, const BYTE *, int, BYTE *, DBINT, int, DBINT *); RETCODE dbgetnull(DBPROCESS *dbproc, int bindtype, int varlen, BYTE* varaddr); /** * \file dblib.c * Main implementation file for \c db-lib. */ /** * \file bcp.c * Implementation of \c db-lib bulk copy functions. */ /** * \defgroup dblib_api The db-lib API * Functions callable by \c db-lib client programs * * The \c db_lib interface is implemented by both Sybase and Microsoft. FreeTDS seeks to implement * first the intersection of the functions defined by the vendors. */ /** * \ingroup dblib_api * \defgroup dblib_core Primary functions * Core functions needed by most db-lib programs. */ /** * \ingroup dblib_api * \defgroup dblib_rpc Remote Procedure functions * Functions used with stored procedures. * Especially useful for OUTPUT parameters, because modern Microsoft servers do not * return output parameter data to the client unless the procedure was invoked * with dbrpcsend(). */ /** * \ingroup dblib_api * \defgroup dblib_bcp Bulk copy functions * Functions to bulk-copy (a/k/a \em bcp) data to/from the database. */ /** * \ingroup dblib_bcp * \defgroup dblib_bcp_internal Internal bcp functions * Static functions internal to the bcp library. */ /** * \ingroup dblib_api * \defgroup dblib_money Money functions * Functions to manipulate the MONEY datatype. */ /** * \ingroup dblib_api * \defgroup dblib_datetime Datetime functions * Functions to manipulate DBDATETIME structures. Defined by Sybase only. * These are not implemented: * - dbdate4cmp() * - dbdate4zero() * - dbdatechar() * - dbdatename() * - dbdateorder() * - dbdatepart() * - dbdatezero() * - dbdayname() */ /** * \ingroup dblib_api * \defgroup dblib_internal Internals * Functions called within \c db-lib for self-help. * These functions are of interest only to people hacking on the FreeTDS db-lib implementation. */ /** * \ingroup dblib_api * \defgroup dblib_unimplemented Unimplemented * Functions thus far not implemented in the FreeTDS db-lib implementation. * While some of these are simply awaiting someone with time and skill (and inclination) * it might be noted here that the old browse functions (e.g. dbcolbrowse()) * are on the never-to-do list. * They were defined by Sybase and were superseded long ago, although they're still * present in Microsoft's implementation. * They were never popular and today better alternatives are available. * For completeness, they are: * - dbcolbrowse() * - dbcolsource() * - dbfreequal() * - dbqual() * - dbtabbrowse() * - dbtabcount() * - dbtabname() * - dbtabsource() * - dbtsnewlen() * - dbtsnewval() * - dbtsput() */ /* info/err message handler functions (or rather pointers to them) */ MHANDLEFUNC _dblib_msg_handler = NULL; EHANDLEFUNC _dblib_err_handler = default_err_handler; /** \internal * \dblib_internal * \remarks A db-lib connection has an implicit TDS context. */ typedef struct dblib_context { /** reference count, time dbinit called */ int ref_count; /** libTDS context */ TDSCONTEXT *tds_ctx; /** libTDS context reference counter */ int tds_ctx_ref_count; /* save all connection in a list */ TDSSOCKET **connection_list; int connection_list_size; int connection_list_size_represented; char *recftos_filename; int recftos_filenum; int login_timeout; /**< not used unless positive */ int query_timeout; /**< not used unless positive */ } DBLIBCONTEXT; static DBLIBCONTEXT g_dblib_ctx; static tds_mutex dblib_mutex = TDS_MUTEX_INITIALIZER; static int g_dblib_version = #ifdef TDS42 DBVERSION_42; #elif TDS50 DBVERSION_100; #elif TDS46 DBVERSION_46; #elif TDS70 DBVERSION_70; #elif TDS71 DBVERSION_71; #elif TDS72 DBVERSION_72; #elif TDS73 DBVERSION_73; #elif TDS74 DBVERSION_74; #else DBVERSION_UNKNOWN; #endif static int dblib_add_connection(DBLIBCONTEXT * ctx, TDSSOCKET * tds) { int i = 0; const int list_size = ctx->connection_list_size_represented; tdsdump_log(TDS_DBG_FUNC, "dblib_add_connection(%p, %p)\n", ctx, tds); while (i < list_size && ctx->connection_list[i]) i++; if (i == list_size) { fprintf(stderr, "Max connections reached, increase value of TDS_MAX_CONN\n"); return 1; } else { ctx->connection_list[i] = tds; return 0; } } static void dblib_del_connection(DBLIBCONTEXT * ctx, TDSSOCKET * tds) { int i = 0; const int list_size = ctx->connection_list_size; tdsdump_log(TDS_DBG_FUNC, "dblib_del_connection(%p, %p)\n", ctx, tds); while (i < list_size && ctx->connection_list[i] != tds) i++; if (i == list_size) { /* connection wasn't on the free list...now what */ } else { /* remove it */ ctx->connection_list[i] = NULL; } } static TDSCONTEXT* dblib_get_tds_ctx(void) { tdsdump_log(TDS_DBG_FUNC, "dblib_get_tds_ctx(void)\n"); tds_mutex_lock(&dblib_mutex); ++g_dblib_ctx.tds_ctx_ref_count; if (g_dblib_ctx.tds_ctx == NULL) { g_dblib_ctx.tds_ctx = tds_alloc_context(&g_dblib_ctx); /* * Set the functions in the TDS layer to point to the correct handler functions */ g_dblib_ctx.tds_ctx->msg_handler = _dblib_handle_info_message; g_dblib_ctx.tds_ctx->err_handler = _dblib_handle_err_message; g_dblib_ctx.tds_ctx->int_handler = _dblib_check_and_handle_interrupt; if (g_dblib_ctx.tds_ctx->locale && !g_dblib_ctx.tds_ctx->locale->date_fmt) { /* set default in case there's no locale file */ const static char date_format[] = #ifndef _WIN32 "%b %e %Y %I:%M:%S:%z%p"; #else "%b %d %Y %I:%M:%S:%z%p"; #endif g_dblib_ctx.tds_ctx->locale->date_fmt = strdup(date_format); } } tds_mutex_unlock(&dblib_mutex); return g_dblib_ctx.tds_ctx; } static void dblib_release_tds_ctx(int count) { tdsdump_log(TDS_DBG_FUNC, "dblib_release_tds_ctx(%d)\n", count); tds_mutex_lock(&dblib_mutex); g_dblib_ctx.tds_ctx_ref_count -= count; if (g_dblib_ctx.tds_ctx_ref_count <= 0) { tds_free_context(g_dblib_ctx.tds_ctx); g_dblib_ctx.tds_ctx = NULL; } tds_mutex_unlock(&dblib_mutex); } #include "buffering.h" static void db_env_chg(TDSSOCKET * tds, int type, char *oldval, char *newval) { DBPROCESS *dbproc; assert(oldval != NULL && newval != NULL); if (strlen(oldval) == 1 && *oldval == 1) oldval = "(0x1)"; tdsdump_log(TDS_DBG_FUNC, "db_env_chg(%p, %d, %s, %s)\n", tds, type, oldval, newval); if (!tds || !tds_get_parent(tds)) return; dbproc = (DBPROCESS *) tds_get_parent(tds); dbproc->envchange_rcv |= (1 << (type - 1)); switch (type) { case TDS_ENV_DATABASE: strlcpy(dbproc->dbcurdb, newval, sizeof(dbproc->dbcurdb)); break; case TDS_ENV_CHARSET: strlcpy(dbproc->servcharset, newval, sizeof(dbproc->servcharset)); break; default: break; } return; } /** \internal * \ingroup dblib_internal * \brief Sanity checks for column-oriented functions. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param pcolinfo address of pointer to a TDSCOLUMN structure. * \remarks Makes sure dbproc and the requested column are valid. * Calls dbperror() if not. * \returns appropriate error or SUCCEED */ static TDSCOLUMN* dbcolptr(DBPROCESS* dbproc, int column) { if (!dbproc) { dbperror(dbproc, SYBENULL, 0); return NULL; } if (IS_TDSDEAD(dbproc->tds_socket)) { dbperror(dbproc, SYBEDDNE, 0); return NULL; } if (!dbproc->tds_socket->res_info) return NULL; if (column < 1 || column > dbproc->tds_socket->res_info->num_cols) { dbperror(dbproc, SYBECNOR, 0); return NULL; } return dbproc->tds_socket->res_info->columns[column - 1]; } static TDSCOLUMN* dbacolptr(DBPROCESS* dbproc, int computeid, int column, int is_bind) { int i; TDSSOCKET *tds; TDSCOMPUTEINFO *info; if (!dbproc) { dbperror(dbproc, SYBENULL, 0); return NULL; } tds = dbproc->tds_socket; if (IS_TDSDEAD(tds)) { dbperror(dbproc, SYBEDDNE, 0); return NULL; } for (i = 0;; ++i) { if (i >= tds->num_comp_info) { /* Attempt to bind user variable to a non-existent compute row */ if (is_bind) dbperror(dbproc, SYBEBNCR, 0); return NULL; } info = tds->comp_info[i]; if (info->computeid == computeid) break; } /* Fail if either the compute id or the column number is invalid. */ if (column < 1 || column > info->num_cols) { dbperror(dbproc, is_bind ? SYBEABNC : SYBECNOR, 0); return NULL; } return info->columns[column - 1]; } /* * Default null substitution values * Binding Type Null Substitution Value * TINYBIND 0 * SMALLBIND 0 * INTBIND 0 * CHARBIND Empty string (padded with blanks) * STRINGBIND Empty string (padded with blanks, null-terminated) * NTBSTRINGBIND Empty string (null-terminated) * VARYCHARBIND Empty string * BINARYBIND Empty array (padded with zeros) * VARYBINBIND Empty array * DATETIMEBIND 8 bytes of zeros * SMALLDATETIMEBIND 8 bytes of zeros * MONEYBIND $0.00 * SMALLMONEYBIND $0.00 * FLT8BIND 0.0 * REALBIND 0.0 * DECIMALBIND 0.0 (with default scale and precision) * NUMERICBIND 0.0 (with default scale and precision) * BOUNDARYBIND Empty string (null-terminated) * SENSITIVITYBIND Empty string (null-terminated) */ static const DBBIT null_BIT = 0; static const DBTINYINT null_TINYINT = 0; static const DBSMALLINT null_SMALLINT = 0; static const DBINT null_INT = 0; static const DBBIGINT null_BIGINT = 0; static const DBFLT8 null_FLT8 = 0; static const DBREAL null_REAL = 0; static const DBCHAR null_CHAR = '\0'; static const DBVARYCHAR null_VARYCHAR = { 0, {0} }; static const DBBINARY null_BINARY = 0; static const DBDATETIME null_DATETIME = { 0, 0 }; static const DBDATETIME4 null_SMALLDATETIME = { 0, 0 }; static const DBMONEY null_MONEY = { 0, 0 }; static const DBMONEY4 null_SMALLMONEY = {0}; static const DBNUMERIC null_NUMERIC = { 0, 0, {0} }; static const TDS_DATETIMEALL null_DATETIMEALL = { 0, 0, 0, 0 }; static NULLREP default_null_representations[MAXBINDTYPES] = { /* CHARBIND 0 */ { NULL, 0 } /* STRINGBIND 1 */ , { NULL, 0 } /* NTBSTRINGBIND 2 */ , { (BYTE*) &null_CHAR, sizeof(null_CHAR) } /* VARYCHARBIND 3 */ , { (BYTE*) &null_VARYCHAR, sizeof(null_VARYCHAR) } /* VARYBINBIND 4 */ , { (BYTE*) &null_VARYCHAR, sizeof(null_VARYCHAR) } /* no such bind 5 */ , { NULL, 0 } /* TINYBIND 6 */ , { &null_TINYINT, sizeof(null_TINYINT) } /* SMALLBIND 7 */ , { (BYTE*) &null_SMALLINT, sizeof(null_SMALLINT) } /* INTBIND 8 */ , { (BYTE*) &null_INT, sizeof(null_INT) } /* FLT8BIND 9 */ , { (BYTE*) &null_FLT8, sizeof(null_FLT8) } /* REALBIND 10 */ , { (BYTE*) &null_REAL, sizeof(null_REAL) } /* DATETIMEBIND 11 */ , { (BYTE*) &null_DATETIME, sizeof(null_DATETIME) } /* SMALLDATETIMEBIND 12 */ , { (BYTE*) &null_SMALLDATETIME, sizeof(null_SMALLDATETIME) } /* MONEYBIND 13 */ , { (BYTE*) &null_MONEY, sizeof(null_MONEY) } /* SMALLMONEYBIND 14 */ , { (BYTE*) &null_SMALLMONEY, sizeof(null_SMALLMONEY) } /* BINARYBIND 15 */ , { NULL, 0 } /* BITBIND 16 */ , { &null_BIT, sizeof(null_BIT) } /* NUMERICBIND 17 */ , { (BYTE*) &null_NUMERIC, sizeof(null_NUMERIC) } /* DECIMALBIND 18 */ , { (BYTE*) &null_NUMERIC, sizeof(null_NUMERIC) } /* SRCNUMERICBIND 19 */ , { (BYTE*) &null_NUMERIC, sizeof(null_NUMERIC) } /* SRCDECIMALBIND 20 */ , { (BYTE*) &null_NUMERIC, sizeof(null_NUMERIC) } /* DATEBIND 21 */ , { (BYTE*) &null_INT, sizeof(null_INT) } /* TIMEBIND 22 */ , { (BYTE*) &null_INT, sizeof(null_INT) } /* BIGDATETIMEBIND 23 */ , { (BYTE*) &null_BIGINT, sizeof(null_BIGINT) } /* BIGTIMEBIND 24 */ , { (BYTE*) &null_BIGINT, sizeof(null_BIGINT) } /* 25 */ , { NULL, 0 } /* 26 */ , { NULL, 0 } /* 27 */ , { NULL, 0 } /* 28 */ , { NULL, 0 } /* 29 */ , { NULL, 0 } /* BIGINTBIND 30 */ , { (BYTE*) &null_BIGINT, sizeof(null_BIGINT) } /* DATETIME2BIND 31 */ , { (BYTE*) &null_DATETIMEALL, sizeof(null_DATETIMEALL) } /* MAXBINDTYPES 32 */ }; static int dbbindtype(int datatype) { switch (datatype) { case SYBIMAGE: case SYBVARBINARY: case SYBBINARY: return BINARYBIND; case SYBBIT: return BITBIND; case SYBTEXT: case SYBVARCHAR: case SYBCHAR: return NTBSTRINGBIND; case SYBDATETIME: return DATETIMEBIND; case SYBDATETIME4: return SMALLDATETIMEBIND; case SYBDATE: return DATEBIND; case SYBTIME: return TIMEBIND; case SYB5BIGDATETIME: return BIGDATETIMEBIND; case SYB5BIGTIME: return BIGTIMEBIND; case SYBDECIMAL: return DECIMALBIND; case SYBNUMERIC: return NUMERICBIND; case SYBFLT8: return FLT8BIND; case SYBREAL: return REALBIND; case SYBINT1: return TINYBIND; case SYBINT2: return SMALLBIND; case SYBINT4: return INTBIND; case SYBINT8: return BIGINTBIND; case SYBMONEY: return MONEYBIND; case SYBMONEY4: return SMALLMONEYBIND; case SYBMSDATE: case SYBMSTIME: case SYBMSDATETIME2: case SYBMSDATETIMEOFFSET: return DATETIME2BIND; default: assert(0 == "no such datatype"); } return 0; } /** \internal * dbbind() says: "Note that if varlen is 0, no padding takes place" * dbgetnull() will not pad varaddr unless varlen is positive. * Vartype Program Type Padding Terminator * ------------------- -------------- -------------- ---------- * CHARBIND DBCHAR blanks none * STRINGBIND DBCHAR blanks \0 * NTBSTRINGBIND DBCHAR none \0 * VARYCHARBIND DBVARYCHAR none none * BOUNDARYBIND DBCHAR none \0 * SENSITIVITYBIND DBCHAR none \0 */ RETCODE dbgetnull(DBPROCESS *dbproc, int bindtype, int varlen, BYTE* varaddr) { NULLREP *pnullrep = default_null_representations + bindtype; tdsdump_log(TDS_DBG_FUNC, "dbgetnull(%p, %d, %d, %p)\n", dbproc, bindtype, varlen, varaddr); CHECK_PARAMETER(varaddr, SYBENULL, FAIL); CHECK_PARAMETER(0 <= bindtype && bindtype < MAXBINDTYPES, SYBEBTYP, FAIL); /* dbproc can be NULL */ if (NULL != dbproc) { assert(dbproc->nullreps); pnullrep = dbproc->nullreps + bindtype; } /* * Fixed types: ignore varlen * Other types: ignore varlen if <= 0, else varlen must be >= pnullrep->len. */ switch (bindtype) { case DATETIMEBIND: case DATETIME2BIND: case DECIMALBIND: case SRCDECIMALBIND: case FLT8BIND: case INTBIND: case MONEYBIND: case NUMERICBIND: case SRCNUMERICBIND: case REALBIND: case SMALLBIND: case SMALLDATETIMEBIND: case SMALLMONEYBIND: case TINYBIND: case BIGINTBIND: case BITBIND: case TIMEBIND: case DATEBIND: case BIGDATETIMEBIND: case BIGTIMEBIND: memcpy(varaddr, pnullrep->bindval, pnullrep->len); return SUCCEED; case CHARBIND: case STRINGBIND: case NTBSTRINGBIND: case BINARYBIND: case VARYCHARBIND: case VARYBINBIND: if (pnullrep->bindval && (varlen <= 0 || (size_t)varlen >= pnullrep->len)) { memcpy(varaddr, pnullrep->bindval, pnullrep->len); } break; default: dbperror(dbproc, SYBEBTYP, 0); return FAIL; } /* * For variable-length types, nonpositive varlen indicates * buffer is "big enough" but also not to pad. * Apply terminator (if applicable) and go home. */ if (varlen <= 0) { varlen = pnullrep->len; switch (bindtype) { case STRINGBIND: case NTBSTRINGBIND: ++varlen; break; #if 0 case BOUNDARYBIND: case SENSITIVITYBIND: #endif } } if (varlen < (long)pnullrep->len) { tdsdump_log(TDS_DBG_FUNC, "dbgetnull: error: not setting varaddr(%p) because %d < %lu\n", varaddr, varlen, (unsigned long int) pnullrep->len); return FAIL; } tdsdump_log(TDS_DBG_FUNC, "varaddr(%p) varlen %d < %lu?\n", varaddr, varlen, (unsigned long int) pnullrep->len); assert(varlen >= 0); /* * CHARBIND Empty string (padded with blanks) * STRINGBIND Empty string (padded with blanks, null-terminated) * NTBSTRINGBIND Empty string (unpadded, null-terminated) * BINARYBIND Empty array (padded with zeros) */ varaddr += pnullrep->len; varlen -= (int)pnullrep->len; if (varlen > 0) { switch (bindtype) { case CHARBIND: memset(varaddr, ' ', varlen); break; case STRINGBIND: memset(varaddr, ' ', varlen); varaddr[varlen-1] = '\0'; break; case NTBSTRINGBIND: varaddr[0] = '\0'; break; case BINARYBIND: memset(varaddr, 0, varlen); break; case VARYCHARBIND: case VARYBINBIND: break; default: assert(!"unknown bindtype"); } } return SUCCEED; } /** * \ingroup dblib_core * \brief Initialize db-lib. * * \remarks Call this function before trying to use db-lib in any way. * Allocates various internal structures and reads \c locales.conf (if any) to determine the default * date format. * \retval SUCCEED normal. * \retval FAIL cannot allocate an array of \c TDS_MAX_CONN \c TDSSOCKET pointers. */ RETCODE dbinit(void) { _dblib_err_handler = default_err_handler; tds_mutex_lock(&dblib_mutex); tdsdump_log(TDS_DBG_FUNC, "dbinit(void)\n"); if (++g_dblib_ctx.ref_count != 1) { tds_mutex_unlock(&dblib_mutex); return SUCCEED; } /* * DBLIBCONTEXT stores a list of current connections so they may be closed with dbexit() */ g_dblib_ctx.connection_list = tds_new0(TDSSOCKET *, TDS_MAX_CONN); if (g_dblib_ctx.connection_list == NULL) { tdsdump_log(TDS_DBG_FUNC, "dbinit: out of memory\n"); tds_mutex_unlock(&dblib_mutex); return FAIL; } g_dblib_ctx.connection_list_size = TDS_MAX_CONN; g_dblib_ctx.connection_list_size_represented = TDS_MAX_CONN; g_dblib_ctx.login_timeout = -1; g_dblib_ctx.query_timeout = -1; tds_mutex_unlock(&dblib_mutex); dblib_get_tds_ctx(); return SUCCEED; } /** * \ingroup dblib_core * \brief Allocate a \c LOGINREC structure. * * \remarks A \c LOGINREC structure is passed to \c dbopen() to create a connection to the database. * Does not communicate to the server; interacts strictly with library. * \retval NULL the \c LOGINREC cannot be allocated. * \retval LOGINREC* to valid memory, otherwise. */ LOGINREC * dblogin(void) { LOGINREC *loginrec; tdsdump_log(TDS_DBG_FUNC, "dblogin(void)\n"); if ((loginrec = tds_new(LOGINREC, 1)) == NULL) { dbperror(NULL, SYBEMEM, errno); return NULL; } if ((loginrec->tds_login = tds_alloc_login(1)) == NULL) { dbperror(NULL, SYBEMEM, errno); free(loginrec); return NULL; } /* set default values for loginrec */ if (!tds_set_library(loginrec->tds_login, "DB-Library")) { dbperror(NULL, SYBEMEM, errno); free(loginrec); return NULL; } return loginrec; } /** * \ingroup dblib_core * \brief free the \c LOGINREC * */ void dbloginfree(LOGINREC * login) { tdsdump_log(TDS_DBG_FUNC, "dbloginfree(%p)\n", login); if (login) { tds_free_login(login->tds_login); TDS_ZERO_FREE(login); } } /** \internal * \ingroup dblib_internal * \brief Set the value of a string in a \c LOGINREC structure. * * Called by various macros to populate \a login. * \param login the \c LOGINREC* to modify. * \param value the value to set it to. * \param which the field to set. * \retval SUCCEED the value was set. * \retval FAIL \c DBSETHID or other invalid \a which was tried. */ RETCODE dbsetlname(LOGINREC * login, const char *value, int which) { bool copy_ret; const char *value_nonull = value ? value : ""; tdsdump_log(TDS_DBG_FUNC, "dbsetlname(%p, %s, %d)\n", login, value, which); if (login == NULL) { dbperror(NULL, SYBEASNL, 0); return FAIL; } if (TDS_MAX_LOGIN_STR_SZ < strlen(value_nonull)) { dbperror(NULL, SYBENTLL, 0); return FAIL; } switch (which) { case DBSETHOST: copy_ret = tds_set_host(login->tds_login, value_nonull); break; case DBSETUSER: copy_ret = tds_set_user(login->tds_login, value_nonull); break; case DBSETPWD: copy_ret = tds_set_passwd(login->tds_login, value_nonull); break; case DBSETAPP: copy_ret = tds_set_app(login->tds_login, value_nonull); break; case DBSETCHARSET: /* TODO NULL == no conversion desired */ copy_ret = tds_set_client_charset(login->tds_login, value_nonull); break; case DBSETNATLANG: copy_ret = tds_set_language(login->tds_login, value_nonull); break; case DBSETDBNAME: copy_ret = !!tds_dstr_copy(&login->tds_login->database, value_nonull); break; default: dbperror(NULL, SYBEASUL, 0); /* Attempt to set unknown LOGINREC field */ return FAIL; break; } if (!copy_ret) return FAIL; return SUCCEED; } /** \internal * \ingroup dblib_internal * \brief Set an integer value in a \c LOGINREC structure. * * Called by various macros to populate \a login. * \param login the \c LOGINREC* to modify. * \param value the value to set it to. * \param which the field to set. * \retval SUCCEED the value was set. * \retval FAIL anything other than \c DBSETPACKET was passed for \a which. */ RETCODE dbsetllong(LOGINREC * login, long value, int which) { tdsdump_log(TDS_DBG_FUNC, "dbsetllong(%p, %ld, %d)\n", login, value, which); if( login == NULL ) { dbperror(NULL, SYBEASNL, 0); return FAIL; } switch (which) { case DBSETPACKET: if (0 <= value && value <= 999999) { tds_set_packet(login->tds_login, value); return SUCCEED; } dbperror(0, SYBEBADPK, 0, (int) value, (int) login->tds_login->block_size); return FAIL; break; default: tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED dbsetllong() which = %d\n", which); return FAIL; break; } } #if defined(DBLIB_UNIMPLEMENTED) /** \internal * \ingroup dblib_internal * \brief Set an integer value in a \c LOGINREC structure. * * Called by various macros to populate \a login. * \param login the \c LOGINREC* to modify. * \param value the value to set it to. * \param which the field to set. * \retval SUCCEED the value was set. * \retval FAIL anything other than \c DBSETHIER was passed for \a which. */ RETCODE dbsetlshort(LOGINREC * login, int value, int which) { tdsdump_log(TDS_DBG_FUNC, "dbsetlshort(%p, %d, %d)\n", login, value, which); if( login == NULL ) { dbperror(NULL, SYBEASNL, 0); return FAIL; } switch (which) { case DBSETHIER: default: tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED dbsetlshort() which = %d\n", which); return FAIL; break; } } #endif /** \internal * \ingroup dblib_internal * \brief Set a boolean value in a \c LOGINREC structure. * * Called by various macros to populate \a login. * \param login the \c LOGINREC* to modify. * \param value the value to set it to. * \param which the field to set. * \remark Only DBSETBCP is implemented. * \retval SUCCEED the value was set. * \retval FAIL invalid value passed for \a which. * \todo DBSETNOSHORT, DBSETENCRYPT, DBSETLABELED */ RETCODE dbsetlbool(LOGINREC * login, int value, int which) { tdsdump_log(TDS_DBG_FUNC, "dbsetlbool(%p, %d, %d)\n", login, value, which); if( login == NULL ) { dbperror(NULL, SYBEASNL, 0); return FAIL; } switch (which) { case DBSETBCP: tds_set_bulk(login->tds_login, (TDS_TINYINT) value); return SUCCEED; break; case DBSETUTF16: login->tds_login->use_utf16 = (value != 0); return SUCCEED; case DBSETNTLMV2: login->tds_login->use_ntlmv2 = (value != 0); return SUCCEED; case DBSETREADONLY: login->tds_login->readonly_intent = (value != 0); return SUCCEED; case DBSETENCRYPT: case DBSETLABELED: default: tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED dbsetlbool() which = %d\n", which); return FAIL; break; } } /** * \ingroup dblib_core * \brief Set TDS version for future connections * */ RETCODE dbsetlversion (LOGINREC * login, BYTE version) { tdsdump_log(TDS_DBG_FUNC, "dbsetlversion(%p, %x)\n", login, version); if( login == NULL ) { dbperror(NULL, SYBEASNL, 0); return FAIL; } assert(login->tds_login != NULL); switch (version) { case DBVER42: login->tds_login->tds_version = 0x402; return SUCCEED; case DBVER60: login->tds_login->tds_version = 0x700; return SUCCEED; case DBVERSION_100: tds_set_version(login->tds_login, 5, 0); return SUCCEED; case DBVERSION_71: tds_set_version(login->tds_login, 7, 1); return SUCCEED; case DBVERSION_72: tds_set_version(login->tds_login, 7, 2); return SUCCEED; case DBVERSION_73: tds_set_version(login->tds_login, 7, 3); return SUCCEED; case DBVERSION_74: tds_set_version(login->tds_login, 7, 4); return SUCCEED; } return FAIL; } static void dbstring_free(DBSTRING ** dbstrp) { DBSTRING *curr, *next; /* tdsdump_log(TDS_DBG_FUNC, "dbstring_free(%p)\n", dbstrp); */ if (!dbstrp) return; curr = *dbstrp; *dbstrp = NULL; for (; curr; ) { next = curr->strnext; free(curr->strtext); free(curr); curr = next; } } static RETCODE dbstring_concat(DBSTRING ** dbstrp, const char *p) { DBSTRING **strp = dbstrp; /* tdsdump_log(TDS_DBG_FUNC, "dbstring_concat(%p, %s)\n", *dbstrp, p); */ while (*strp != NULL) { strp = &((*strp)->strnext); } if ((*strp = tds_new(DBSTRING, 1)) == NULL) { dbperror(NULL, SYBEMEM, errno); return FAIL; } (*strp)->strtotlen = (DBINT)strlen(p); if (((*strp)->strtext = tds_new(BYTE, (*strp)->strtotlen)) == NULL) { TDS_ZERO_FREE(*strp); dbperror(NULL, SYBEMEM, errno); return FAIL; } memcpy((*strp)->strtext, p, (*strp)->strtotlen); (*strp)->strnext = NULL; return SUCCEED; } static RETCODE dbstring_assign(DBSTRING ** dbstrp, const char *p) { /* tdsdump_log(TDS_DBG_FUNC, "dbstring_assign(%p, %s)\n", *dbstrp, p); */ dbstring_free(dbstrp); return dbstring_concat(dbstrp, p); } static DBINT dbstring_length(DBSTRING * dbstr) { DBINT len = 0; DBSTRING *next; /* tdsdump_log(TDS_DBG_FUNC, "dbstring_length(%p)\n", dbstr); */ for (next = dbstr; next != NULL; next = next->strnext) { len += next->strtotlen; } return len; } static int dbstring_getchar(DBSTRING * dbstr, int i) { /* tdsdump_log(TDS_DBG_FUNC, "dbstring_getchar(%p, %d)\n", dbstr, i); */ if (dbstr == NULL) { return -1; } if (i < 0) { return -1; } if (i < dbstr->strtotlen) { return dbstr->strtext[i]; } return dbstring_getchar(dbstr->strnext, i - dbstr->strtotlen); } static char * dbstring_get(DBSTRING * dbstr) { DBSTRING *next; int len; char *ret; char *cp; /* tdsdump_log(TDS_DBG_FUNC, "dbstring_get(%p)\n", dbstr); */ if (dbstr == NULL) { return NULL; } len = dbstring_length(dbstr); if ((ret = tds_new(char, len + 1)) == NULL) { dbperror(NULL, SYBEMEM, errno); return NULL; } cp = ret; for (next = dbstr; next != NULL; next = next->strnext) { memcpy(cp, next->strtext, next->strtotlen); cp += next->strtotlen; } *cp = '\0'; return ret; } static const char *const opttext[DBNUMOPTIONS] = { "parseonly", "estimate", "showplan", "noexec", "arithignore", "nocount", "arithabort", "textlimit", "browse", "offsets", "statistics", "errlvl", "confirm", "spid", "buffer", "noautofree", "rowcount", "textsize", "language", "dateformat", "prpad", "prcolsep", "prlinelen", "prlinesep", "lfconvert", "datefirst", "chained", "fipsflagger", "transaction isolation level", "auth", "identity_insert", "no_identity_column", "cnv_date2char_short", "client cursors", "set time", "quoted_identifier" }; static DBOPTION * init_dboptions(void) { DBOPTION *dbopts; int i; if ((dbopts = tds_new0(DBOPTION, DBNUMOPTIONS)) == NULL) { dbperror(NULL, SYBEMEM, errno); return NULL; } for (i = 0; i < DBNUMOPTIONS; i++) { dbopts[i].text = opttext[i]; dbopts[i].param = NULL; dbopts[i].factive = FALSE; } dbstring_assign(&(dbopts[DBPRPAD].param), " "); dbstring_assign(&(dbopts[DBPRCOLSEP].param), " "); dbstring_assign(&(dbopts[DBPRLINELEN].param), "80"); dbstring_assign(&(dbopts[DBPRLINESEP].param), "\n"); dbstring_assign(&(dbopts[DBCLIENTCURSORS].param), " "); dbstring_assign(&(dbopts[DBSETTIME].param), " "); return dbopts; } /** \internal * \ingroup dblib_internal * \brief Form a connection with the server. * * Called by the \c dbopen() macro, normally. If FreeTDS was configured with \c --enable-msdblib, this * function is called by (exported) \c dbopen() function. \c tdsdbopen is so-named to avoid * namespace conflicts with other database libraries that use the same function name. * \param login \c LOGINREC* carrying the account information. * \param server name of the dataserver to connect to. * \return valid pointer on successful login. * \retval NULL insufficient memory, unable to connect for any reason. * \sa dbopen() * \todo use \c asprintf() to avoid buffer overflow. * \todo separate error messages for \em no-such-server and \em no-such-user. */ DBPROCESS * tdsdbopen(LOGINREC * login, const char *server, int msdblib) { DBPROCESS *dbproc = NULL; TDSLOGIN *connection; char *tdsdump = getenv("TDSDUMP"); if (tdsdump && *tdsdump) { tdsdump_open(tdsdump); tdsdump_log(TDS_DBG_FUNC, "tdsdbopen(%p, %s, [%s])\n", login, server? server : "0x0", msdblib? "microsoft" : "sybase"); } /* * Sybase supports the DSQUERY environment variable and falls back to "SYBASE" if server is NULL. * Microsoft uses a NULL or "" server to indicate a local server. * FIXME: support local server for win32. */ if (!server && !msdblib) { if ((server = getenv("TDSQUERY")) == NULL) if ((server = getenv("DSQUERY")) == NULL) server = "SYBASE"; tdsdump_log(TDS_DBG_FUNC, "tdsdbopen: servername set to %s\n", server); } if ((dbproc = tds_new0(DBPROCESS, 1)) == NULL) { dbperror(NULL, SYBEMEM, errno); return NULL; } dbproc->msdblib = msdblib; dbproc->dbopts = init_dboptions(); if (dbproc->dbopts == NULL) { free(dbproc); return NULL; } tdsdump_log(TDS_DBG_FUNC, "tdsdbopen: dbproc->dbopts = %p\n", dbproc->dbopts); dbproc->dboptcmd = NULL; dbproc->avail_flag = TRUE; dbproc->command_state = DBCMDNONE; if (!tds_set_server(login->tds_login, server)) { dbperror(NULL, SYBEMEM, 0); free(dbproc); return NULL; } tdsdump_log(TDS_DBG_FUNC, "tdsdbopen: tds_set_server(%p, \"%s\")\n", login->tds_login, server); if ((dbproc->tds_socket = tds_alloc_socket(dblib_get_tds_ctx(), 512)) == NULL ){ dbperror(NULL, SYBEMEM, 0); free(dbproc); return NULL; } tds_set_parent(dbproc->tds_socket, dbproc); dbproc->tds_socket->env_chg_func = db_env_chg; dbproc->envchange_rcv = 0; dbproc->dbcurdb[0] = '\0'; dbproc->servcharset[0] = '\0'; tdsdump_log(TDS_DBG_FUNC, "tdsdbopen: About to call tds_read_config_info...\n"); connection = tds_read_config_info(dbproc->tds_socket, login->tds_login, g_dblib_ctx.tds_ctx->locale); if (!connection) { dbclose(dbproc); return NULL; } connection->option_flag2 &= ~TDS_ODBC_ON; /* we're not an ODBC driver */ tds_fix_login(connection); /* initialize from Environment variables */ dbproc->chkintr = NULL; dbproc->hndlintr = NULL; tds_mutex_lock(&dblib_mutex); /* override connection timeout if dbsetlogintime() was called */ if (g_dblib_ctx.login_timeout > 0) { connection->connect_timeout = g_dblib_ctx.login_timeout; } /* override query timeout if dbsettime() was called */ if (g_dblib_ctx.query_timeout > 0) { connection->query_timeout = g_dblib_ctx.query_timeout; } tds_mutex_unlock(&dblib_mutex); tdsdump_log(TDS_DBG_FUNC, "tdsdbopen: Calling tds_connect_and_login(%p, %p)\n", dbproc->tds_socket, connection); if (TDS_FAILED(tds_connect_and_login(dbproc->tds_socket, connection))) { tdsdump_log(TDS_DBG_ERROR, "tdsdbopen: tds_connect_and_login failed for \"%s\"!\n", tds_dstr_cstr(&connection->server_name)); tds_free_login(connection); dbclose(dbproc); return NULL; } tds_free_login(connection); dbproc->dbbuf = NULL; dbproc->dbbufsz = 0; tds_mutex_lock(&dblib_mutex); dblib_add_connection(&g_dblib_ctx, dbproc->tds_socket); tds_mutex_unlock(&dblib_mutex); /* set the DBBUFFER capacity to nil */ buffer_set_capacity(dbproc, 0); tds_mutex_lock(&dblib_mutex); if (g_dblib_ctx.recftos_filename != NULL) { char *temp_filename = NULL; const int len = asprintf(&temp_filename, "%s.%d", g_dblib_ctx.recftos_filename, g_dblib_ctx.recftos_filenum); if (len >= 0) { dbproc->ftos = fopen(temp_filename, "w"); if (dbproc->ftos != NULL) { fprintf(dbproc->ftos, "/* dbopen() at %s */\n", _dbprdate(temp_filename)); fflush(dbproc->ftos); g_dblib_ctx.recftos_filenum++; } free(temp_filename); } } memcpy(dbproc->nullreps, default_null_representations, sizeof(default_null_representations)); tds_mutex_unlock(&dblib_mutex); tdsdump_log(TDS_DBG_FUNC, "tdsdbopen: Returning dbproc = %p\n", dbproc); return dbproc; } /** * \ingroup dblib_core * \brief \c printf-like way to form SQL to send to the server. * * Forms a command string and writes to the command buffer with dbcmd(). * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param fmt man vasprintf for details. * \retval SUCCEED success. * \retval FAIL insufficient memory, or dbcmd() failed. * \sa dbcmd(), dbfreebuf(), dbgetchar(), dbopen(), dbstrcpy(), dbstrlen(). */ RETCODE dbfcmd(DBPROCESS * dbproc, const char *fmt, ...) { va_list ap; char *s; int len; RETCODE ret; tdsdump_log(TDS_DBG_FUNC, "dbfcmd(%p, %s, ...)\n", dbproc, fmt); CHECK_CONN(FAIL); CHECK_NULP(fmt, "dbfcmd", 2, FAIL); va_start(ap, fmt); len = vasprintf(&s, fmt, ap); va_end(ap); if (len < 0) { dbperror(dbproc, SYBEMEM, errno); return FAIL; } ret = dbcmd(dbproc, s); free(s); return ret; } /** * \ingroup dblib_core * \brief \c Append SQL to the command buffer. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param cmdstring SQL to append to the command buffer. * \retval SUCCEED success. * \retval FAIL insufficient memory. * \remarks set command state to \c DBCMDPEND unless the command state is DBCMDSENT, in which case * it frees the command buffer. This latter may or may not be the Right Thing to do. * \sa dbfcmd(), dbfreebuf(), dbgetchar(), dbopen(), dbstrcpy(), dbstrlen(). */ RETCODE dbcmd(DBPROCESS * dbproc, const char cmdstring[]) { size_t cmd_len, buf_len, newsz; tdsdump_log(TDS_DBG_FUNC, "dbcmd(%p, %s)\n", dbproc, cmdstring); CHECK_CONN(FAIL); CHECK_NULP(cmdstring, "dbcmd", 2, FAIL); dbproc->avail_flag = FALSE; tdsdump_log(TDS_DBG_FUNC, "dbcmd() bufsz = %d\n", dbproc->dbbufsz); if (dbproc->command_state == DBCMDSENT) { if (!dbproc->noautofree) { dbfreebuf(dbproc); } } buf_len = (dbproc->dbbufsz == 0) ? 0 : dbproc->dbbufsz - 1; cmd_len = strlen(cmdstring); newsz = buf_len + cmd_len + 1; if (newsz > 0x7fffffffu || !TDS_RESIZE(dbproc->dbbuf, newsz)) { dbperror(dbproc, SYBEMEM, errno); return FAIL; } memcpy(dbproc->dbbuf + buf_len, cmdstring, cmd_len); dbproc->dbbuf[newsz - 1] = 0; dbproc->dbbufsz = (int) newsz; dbproc->command_state = DBCMDPEND; return SUCCEED; } /** * \ingroup dblib_core * \brief send the SQL command to the server and wait for an answer. * * Please be patient. This function waits for the server to respond. \c dbsqlexec is equivalent * to dbsqlsend() followed by dbsqlok(). * \param dbproc contains all information needed by db-lib to manage communications with the server. * \retval SUCCEED query was processed without errors. * \retval FAIL was returned by dbsqlsend() or dbsqlok(). * \sa dbcmd(), dbfcmd(), dbnextrow(), dbresults(), dbretstatus(), dbsettime(), dbsqlok(), dbsqlsend() */ RETCODE dbsqlexec(DBPROCESS * dbproc) { RETCODE rc = FAIL; tdsdump_log(TDS_DBG_FUNC, "dbsqlexec(%p)\n", dbproc); CHECK_CONN(FAIL); if (SUCCEED == (rc = dbsqlsend(dbproc))) { rc = dbsqlok(dbproc); } return rc; } /** * \ingroup dblib_core * \brief Change current database. * * Analagous to the unix command \c cd, dbuse() makes \a name the default database. Waits for an answer * from the server. * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param name database to use. * \retval SUCCEED query was processed without errors. * \retval FAIL query was not processed * \sa dbchange(), dbname(). */ RETCODE dbuse(DBPROCESS * dbproc, const char *name) { RETCODE rc; char *query; tdsdump_log(TDS_DBG_FUNC, "dbuse(%p, %s)\n", dbproc, name); CHECK_CONN(FAIL); CHECK_NULP(name, "dbuse", 2, FAIL); if (!dbproc->tds_socket) return FAIL; /* quote name */ query = tds_new(char, tds_quote_id(dbproc->tds_socket, NULL, name, -1) + 6); if (!query) { dbperror(dbproc, SYBEMEM, errno); return FAIL; } strcpy(query, "use "); /* TODO PHP suggest to quote by yourself with []... what should I do ?? quote or not ?? */ if (name[0] == '[' && name[strlen(name)-1] == ']') strcat(query, name); else tds_quote_id(dbproc->tds_socket, query + 4, name, -1); rc = SUCCEED; if ((dbcmd(dbproc, query) == FAIL) || (dbsqlexec(dbproc) == FAIL) || (dbresults(dbproc) == FAIL) || (dbcanquery(dbproc) == FAIL)) rc = FAIL; free(query); return rc; } /** * \ingroup dblib_core * \brief Close a connection to the server and free associated resources. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \sa dbexit(), dbopen(). */ void dbclose(DBPROCESS * dbproc) { TDSSOCKET *tds; int i; char timestr[256]; tdsdump_log(TDS_DBG_FUNC, "dbclose(%p)\n", dbproc); CHECK_PARAMETER(dbproc, SYBENULL, ); tds = dbproc->tds_socket; if (tds) { /* * this MUST be done before socket destruction * it is possible that a TDSSOCKET is allocated on same position */ tds_mutex_lock(&dblib_mutex); dblib_del_connection(&g_dblib_ctx, dbproc->tds_socket); tds_mutex_unlock(&dblib_mutex); tds_close_socket(tds); tds_free_socket(tds); dblib_release_tds_ctx(1); } buffer_free(&(dbproc->row_buf)); if (dbproc->ftos != NULL) { fprintf(dbproc->ftos, "/* dbclose() at %s */\n", _dbprdate(timestr)); fclose(dbproc->ftos); } tds_free_bcpinfo(dbproc->bcpinfo); if (dbproc->hostfileinfo) { free(dbproc->hostfileinfo->hostfile); free(dbproc->hostfileinfo->errorfile); if (dbproc->hostfileinfo->host_columns) { for (i = 0; i < dbproc->hostfileinfo->host_colcount; i++) { free(dbproc->hostfileinfo->host_columns[i]->terminator); free(dbproc->hostfileinfo->host_columns[i]); } free(dbproc->hostfileinfo->host_columns); } } for (i = 0; i < DBNUMOPTIONS; i++) { dbstring_free(&(dbproc->dbopts[i].param)); } free(dbproc->dbopts); dbstring_free(&(dbproc->dboptcmd)); for (i=0; i < MAXBINDTYPES; i++) { if (dbproc->nullreps[i].bindval != default_null_representations[i].bindval) free((BYTE*)dbproc->nullreps[i].bindval); } dbfreebuf(dbproc); free(dbproc); } /** * \ingroup dblib_core * \brief Close server connections and free all related structures. * * \sa dbclose(), dbinit(), dbopen(). * \todo breaks if ctlib/dblib used in same process. */ void dbexit() { TDSSOCKET *tds; DBPROCESS *dbproc; int i, list_size, count = 1; tdsdump_log(TDS_DBG_FUNC, "dbexit(void)\n"); tds_mutex_lock(&dblib_mutex); if (--g_dblib_ctx.ref_count != 0) { tds_mutex_unlock(&dblib_mutex); return; } list_size = g_dblib_ctx.connection_list_size; for (i = 0; i < list_size; i++) { tds = g_dblib_ctx.connection_list[i]; g_dblib_ctx.connection_list[i] = NULL; if (tds) { ++count; dbproc = (DBPROCESS *) tds_get_parent(tds); tds_close_socket(tds); tds_free_socket(tds); if (dbproc) { /* avoid locking in dbclose */ dbproc->tds_socket = NULL; dbclose(dbproc); } } } if (g_dblib_ctx.connection_list) { TDS_ZERO_FREE(g_dblib_ctx.connection_list); g_dblib_ctx.connection_list_size = 0; } tds_mutex_unlock(&dblib_mutex); dblib_release_tds_ctx(count); } typedef char prbuf_t[24]; static const char * prdbresults_state(int retcode, prbuf_t buf) { switch(retcode) { case _DB_RES_INIT: return "_DB_RES_INIT"; case _DB_RES_RESULTSET_EMPTY: return "_DB_RES_RESULTSET_EMPTY"; case _DB_RES_RESULTSET_ROWS: return "_DB_RES_RESULTSET_ROWS"; case _DB_RES_NEXT_RESULT: return "_DB_RES_NEXT_RESULT"; case _DB_RES_NO_MORE_RESULTS: return "_DB_RES_NO_MORE_RESULTS"; case _DB_RES_SUCCEED: return "_DB_RES_SUCCEED"; default: sprintf(buf, "oops: %u ??", retcode); } return buf; } static const char * prdbretcode(RETCODE retcode, prbuf_t buf) { switch(retcode) { case REG_ROW: return "REG_ROW/MORE_ROWS"; case NO_MORE_ROWS: return "NO_MORE_ROWS"; case BUF_FULL: return "BUF_FULL"; case NO_MORE_RESULTS: return "NO_MORE_RESULTS"; case SUCCEED: return "SUCCEED"; case FAIL: return "FAIL"; default: sprintf(buf, "oops: %u ??", retcode); } return buf; } static const char * prretcode(int retcode, prbuf_t buf) { switch(retcode) { case TDS_SUCCESS: return "TDS_SUCCESS"; case TDS_FAIL: return "TDS_FAIL"; case TDS_NO_MORE_RESULTS: return "TDS_NO_MORE_RESULTS"; case TDS_CANCELLED: return "TDS_CANCELLED"; default: sprintf(buf, "oops: %u ??", retcode); } return buf; } static const char * prresult_type(int result_type, prbuf_t buf) { switch(result_type) { case TDS_ROW_RESULT: return "TDS_ROW_RESULT"; case TDS_PARAM_RESULT: return "TDS_PARAM_RESULT"; case TDS_STATUS_RESULT: return "TDS_STATUS_RESULT"; case TDS_MSG_RESULT: return "TDS_MSG_RESULT"; case TDS_COMPUTE_RESULT: return "TDS_COMPUTE_RESULT"; case TDS_CMD_DONE: return "TDS_CMD_DONE"; case TDS_CMD_SUCCEED: return "TDS_CMD_SUCCEED"; case TDS_CMD_FAIL: return "TDS_CMD_FAIL"; case TDS_ROWFMT_RESULT: return "TDS_ROWFMT_RESULT"; case TDS_COMPUTEFMT_RESULT: return "TDS_COMPUTEFMT_RESULT"; case TDS_DESCRIBE_RESULT: return "TDS_DESCRIBE_RESULT"; case TDS_DONE_RESULT: return "TDS_DONE_RESULT"; case TDS_DONEPROC_RESULT: return "TDS_DONEPROC_RESULT"; case TDS_DONEINPROC_RESULT: return "TDS_DONEINPROC_RESULT"; case TDS_OTHERS_RESULT: return "TDS_OTHERS_RESULT"; default: sprintf(buf, "oops: %u ??", result_type); } return buf; } /** * \ingroup dblib_core * \brief Set up query results. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \retval SUCCEED Some results are available. * \retval FAIL query was not processed successfully by the server * \retval NO_MORE_RESULTS query produced no results. * * \remarks Call dbresults() after calling dbsqlexec() or dbsqlok(), or dbrpcsend() returns SUCCEED. Unless * one of them fails, dbresults will return either SUCCEED or NO_MORE_RESULTS. * * The meaning of \em results is very specific and not very intuitive. Results are created by either * - a SELECT statement * - a stored procedure * * When dbresults returns SUCCEED, therefore, it indicates the server processed the query successfully and * that one or more of these is present: * - metadata -- dbnumcols() returns 1 or more * - data -- dbnextrow() returns SUCCEED * - return status -- dbhasretstat() returns TRUE * - output parameters -- dbnumrets() returns 1 or more * * If none of the above are present, dbresults() returns NO_MORE_RESULTS. * * SUCCEED does not imply that DBROWS() will return TRUE or even that dbnumcols() will return nonzero. * A general algorithm for reading results will call dbresults() until it return NO_MORE_RESULTS (or FAIL). * An application should check for all the above kinds of results within the dbresults() loop. * * \sa dbsqlexec(), dbsqlok(), dbrpcsend(), dbcancel(), DBROWS(), dbnextrow(), dbnumcols(), dbhasretstat(), dbretstatus(), dbnumrets() */ RETCODE dbresults(DBPROCESS * dbproc) { RETCODE erc = _dbresults(dbproc); prbuf_t buf; tdsdump_log(TDS_DBG_FUNC, "dbresults returning %d (%s)\n", erc, prdbretcode(erc, buf)); return erc; } static RETCODE _dbresults(DBPROCESS * dbproc) { TDSSOCKET *tds; int result_type = 0, done_flags; prbuf_t prbuf1, prbuf2; tdsdump_log(TDS_DBG_FUNC, "dbresults(%p)\n", dbproc); CHECK_CONN(FAIL); tds = dbproc->tds_socket; tdsdump_log(TDS_DBG_FUNC, "dbresults: dbresults_state is %d (%s)\n", dbproc->dbresults_state, prdbresults_state(dbproc->dbresults_state, prbuf1)); switch ( dbproc->dbresults_state ) { case _DB_RES_SUCCEED: dbproc->dbresults_state = _DB_RES_NEXT_RESULT; return SUCCEED; break; case _DB_RES_RESULTSET_ROWS: dbperror(dbproc, SYBERPND, 0); /* dbresults called while rows outstanding.... */ return FAIL; break; case _DB_RES_NO_MORE_RESULTS: return NO_MORE_RESULTS; break; default: break; } for (;;) { TDSRET retcode = tds_process_tokens(tds, &result_type, &done_flags, TDS_TOKEN_RESULTS); tdsdump_log(TDS_DBG_FUNC, "dbresults() tds_process_tokens returned %d (%s),\n\t\t\tresult_type %s\n", retcode, prretcode(retcode, prbuf1), prresult_type(result_type, prbuf2)); switch (retcode) { case TDS_SUCCESS: switch (result_type) { case TDS_ROWFMT_RESULT: buffer_free(&dbproc->row_buf); buffer_alloc(dbproc); dbproc->dbresults_state = _DB_RES_RESULTSET_EMPTY; break; case TDS_COMPUTEFMT_RESULT: break; case TDS_ROW_RESULT: case TDS_COMPUTE_RESULT: dbproc->dbresults_state = _DB_RES_RESULTSET_ROWS; return SUCCEED; break; case TDS_DONE_RESULT: case TDS_DONEPROC_RESULT: tdsdump_log(TDS_DBG_FUNC, "dbresults(): dbresults_state is %d (%s)\n", dbproc->dbresults_state, prdbresults_state(dbproc->dbresults_state, prbuf1)); /* A done token signifies the end of a logical command. * There are three possibilities: * 1. Simple command with no result set, i.e. update, delete, insert * 2. Command with result set but no rows * 3. Command with result set and rows */ switch (dbproc->dbresults_state) { case _DB_RES_INIT: case _DB_RES_NEXT_RESULT: dbproc->dbresults_state = _DB_RES_NEXT_RESULT; if (done_flags & TDS_DONE_ERROR) return FAIL; if (result_type == TDS_DONE_RESULT) return SUCCEED; break; case _DB_RES_RESULTSET_EMPTY: case _DB_RES_RESULTSET_ROWS: dbproc->dbresults_state = _DB_RES_NEXT_RESULT; return SUCCEED; break; default: assert(0); break; } break; case TDS_DONEINPROC_RESULT: /* * Return SUCCEED on a command within a stored procedure * only if the command returned a result set. */ switch (dbproc->dbresults_state) { case _DB_RES_INIT: case _DB_RES_NEXT_RESULT: dbproc->dbresults_state = _DB_RES_NEXT_RESULT; break; case _DB_RES_RESULTSET_EMPTY : case _DB_RES_RESULTSET_ROWS : dbproc->dbresults_state = _DB_RES_NEXT_RESULT; return SUCCEED; break; case _DB_RES_NO_MORE_RESULTS: case _DB_RES_SUCCEED: break; } break; case TDS_STATUS_RESULT: case TDS_MSG_RESULT: case TDS_DESCRIBE_RESULT: case TDS_PARAM_RESULT: default: break; } break; case TDS_NO_MORE_RESULTS: dbproc->dbresults_state = _DB_RES_NO_MORE_RESULTS; return NO_MORE_RESULTS; break; default: assert(TDS_FAILED(retcode)); dbproc->dbresults_state = _DB_RES_INIT; return FAIL; break; } } } /** * \ingroup dblib_core * \brief Return number of regular columns in a result set. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \sa dbcollen(), dbcolname(), dbnumalts(). */ int dbnumcols(DBPROCESS * dbproc) { tdsdump_log(TDS_DBG_FUNC, "dbnumcols(%p)\n", dbproc); CHECK_PARAMETER(dbproc, SYBENULL, 0); if (dbproc && dbproc->tds_socket && dbproc->tds_socket->res_info) return dbproc->tds_socket->res_info->num_cols; return 0; } /** * \ingroup dblib_core * \brief Return name of a regular result column. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param column Nth in the result set, starting with 1. * \return pointer to ASCII null-terminated string, the name of the column. * \retval NULL \a column is not in range. * \sa dbcollen(), dbcoltype(), dbdata(), dbdatlen(), dbnumcols(). * \bug Relies on ASCII column names, post iconv conversion. * Will not work as described for UTF-8 or UCS-2 clients. * But maybe it shouldn't. */ char * dbcolname(DBPROCESS * dbproc, int column) { TDSCOLUMN *colinfo; tdsdump_log(TDS_DBG_FUNC, "dbcolname(%p, %d)\n", dbproc, column); colinfo = dbcolptr(dbproc, column); if (!colinfo) return NULL; return tds_dstr_buf(&colinfo->column_name); } /** * \ingroup dblib_core * \brief Read a row from the row buffer. * * When row buffering is enabled (DBBUFFER option is on), the client can use dbgetrow() to re-read a row previously fetched * with dbnextrow(). The effect is to move the row pointer -- analogous to fseek() -- back to \a row. * Calls to dbnextrow() read from \a row + 1 until the buffer is exhausted, at which point it resumes * its normal behavior, except that as each row is fetched from the server, it is added to the row * buffer (in addition to being returned to the client). When the buffer is filled, dbnextrow() returns * \c FAIL until the buffer is at least partially emptied with dbclrbuf(). * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param row Nth row to read, starting with 1. * \retval REG_ROW returned row is a regular row. * \returns computeid when returned row is a compute row. * \retval NO_MORE_ROWS no such row in the row buffer. Current row is unchanged. * \retval FAIL unsuccessful; row buffer may be full. * \sa dbaltbind(), dbbind(), dbclrbuf(), DBCURROW(), DBFIRSTROW(), DBLASTROW(), dbnextrow(), dbsetrow(). */ RETCODE dbgetrow(DBPROCESS * dbproc, DBINT row) { RETCODE result = FAIL; const int idx = buffer_row2idx(&dbproc->row_buf, row); tdsdump_log(TDS_DBG_FUNC, "dbgetrow(%p, %d)\n", dbproc, row); CHECK_CONN(FAIL); if (-1 == idx) return NO_MORE_ROWS; dbproc->row_buf.current = idx; buffer_transfer_bound_data(&dbproc->row_buf, TDS_ROW_RESULT, 0, dbproc, idx); result = REG_ROW; return result; } /** * \ingroup dblib_core * \brief Define substitution values to be used when binding null values. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param bindtype type of binding to which the substitute value will apply. * \param bindlen size of the substitute value you are supplying, in bytes. * Ignored except for CHARBIND and BINARYBIND. * \param bindval pointer to a buffer containing the substitute value. * \retval SUCCEED query was processed without errors. * \retval FAIL query was not processed * \sa dbaltbind(), dbbind(), dbconvert(), dbnullbind(). */ RETCODE dbsetnull(DBPROCESS * dbproc, int bindtype, int bindlen, BYTE *bindval) { BYTE *pval; tdsdump_log(TDS_DBG_FUNC, "dbsetnull(%p, %d, %d, %p)\n", dbproc, bindtype, bindlen, bindval); CHECK_CONN(FAIL); CHECK_PARAMETER(bindval, SYBENBVP, FAIL); switch (bindtype) { case DATETIMEBIND: case DECIMALBIND: case SRCDECIMALBIND: case FLT8BIND: case INTBIND: case MONEYBIND: case NUMERICBIND: case SRCNUMERICBIND: case REALBIND: case SMALLBIND: case SMALLDATETIMEBIND: case SMALLMONEYBIND: case TINYBIND: case BIGINTBIND: case DATEBIND: case TIMEBIND: case BIGDATETIMEBIND: case BIGTIMEBIND: bindlen = (int)default_null_representations[bindtype].len; break; case CHARBIND: case BINARYBIND: CHECK_PARAMETER(bindlen >= 0, SYBEBBL, FAIL); break; case NTBSTRINGBIND: bindlen = (int)strlen((char *) bindval); break; case STRINGBIND: bindlen = (int)strlen((char *) bindval); break; case VARYBINBIND: bindlen = ((DBVARYBIN*) bindval)->len; break; case VARYCHARBIND: bindlen = ((DBVARYCHAR*) bindval)->len; break; #if 0 case SENSITIVITYBIND: case BOUNDARYBIND: #endif default: dbperror(dbproc, SYBEBTYP, 0); return FAIL; } if ((pval = tds_new(BYTE, bindlen)) == NULL) { dbperror(dbproc, SYBEMEM, errno); return FAIL; } /* free any prior allocation */ if (dbproc->nullreps[bindtype].bindval != default_null_representations[bindtype].bindval) free((BYTE*)dbproc->nullreps[bindtype].bindval); memcpy(pval, bindval, bindlen); dbproc->nullreps[bindtype].bindval = pval; dbproc->nullreps[bindtype].len = bindlen; tdsdump_dump_buf(TDS_DBG_NETWORK, "null representation set ", pval, bindlen); return SUCCEED; } /** * \ingroup dblib_core * \brief Make a buffered row "current" without fetching it into bound variables. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \retval MORE_ROWS row found * \retval NO_MORE_ROWS row not found * \retval FAIL \a dbproc is dead or not enabled * \sa dbaltbind(), dbbind(), dbcanquery(), dbclrbuf(), dbgetrow(), dbnextrow(), dbprrow(). */ STATUS dbsetrow(DBPROCESS * dbproc, DBINT row) { const int idx = buffer_row2idx(&dbproc->row_buf, row); tdsdump_log(TDS_DBG_FUNC, "dbsetrow(%p, %d)\n", dbproc, row); CHECK_CONN(FAIL); if (-1 == idx) return NO_MORE_ROWS; dbproc->row_buf.current = idx; /* FIXME: should determine REG_ROW or compute_id; */ return REG_ROW; } /** * \ingroup dblib_core * \brief Read result row into the row buffer and into any bound host variables. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \retval REG_ROW regular row has been read. * \returns computeid when a compute row is read. * \retval BUF_FULL reading next row would cause the buffer to be exceeded (and buffering is turned on). * No row was read from the server * \sa dbaltbind(), dbbind(), dbcanquery(), dbclrbuf(), dbgetrow(), dbprrow(), dbsetrow(). */ struct pivot_t; STATUS dbnextrow(DBPROCESS * dbproc) { TDSRESULTINFO *resinfo; TDSSOCKET *tds; STATUS result = FAIL; TDS_INT res_type; TDS_INT computeid; int idx; /* row buffer index. Unless DBUFFER is on, idx will always be 0. */ struct pivot_t *pivot; prbuf_t prbuf; tdsdump_log(TDS_DBG_FUNC, "dbnextrow(%p)\n", dbproc); CHECK_CONN(FAIL); tds = dbproc->tds_socket; resinfo = tds->res_info; tdsdump_log(TDS_DBG_FUNC, "dbnextrow() dbresults_state = %d (%s)\n", dbproc->dbresults_state, prdbresults_state(dbproc->dbresults_state, prbuf)); if (!resinfo || dbproc->dbresults_state != _DB_RES_RESULTSET_ROWS) { /* no result set or result set empty (no rows) */ tdsdump_log(TDS_DBG_FUNC, "leaving dbnextrow() returning %d (NO_MORE_ROWS)\n", NO_MORE_ROWS); return dbproc->row_type = NO_MORE_ROWS; } /* * Try to get the dbproc->row_buf.current item from the buffered rows, if any. * Else read from the stream, unless the buffer is exhausted. * If no rows are read, DBROWTYPE() will report NO_MORE_ROWS. */ dbproc->row_type = NO_MORE_ROWS; computeid = REG_ROW; if (-1 != (idx = buffer_current_index(dbproc))) { /* * Cool, the item we want is already there */ result = dbproc->row_type = REG_ROW; res_type = TDS_ROW_RESULT; } else if (buffer_is_full(&dbproc->row_buf)) { result = BUF_FULL; res_type = TDS_ROWFMT_RESULT; } else if ((pivot = dbrows_pivoted(dbproc)) != NULL) { tdsdump_log(TDS_DBG_FUNC, "returning pivoted row\n"); return dbnextrow_pivoted(dbproc, pivot); } else { const int mask = TDS_STOPAT_ROWFMT|TDS_RETURN_DONE|TDS_RETURN_ROW|TDS_RETURN_COMPUTE; TDS_INT8 row_count = TDS_NO_COUNT; bool rows_set = false; buffer_save_row(dbproc); /* Get the row from the TDS stream. */ again: switch (tds_process_tokens(tds, &res_type, NULL, mask)) { case TDS_SUCCESS: if (res_type == TDS_ROW_RESULT || res_type == TDS_COMPUTE_RESULT) { if (res_type == TDS_COMPUTE_RESULT) computeid = tds->current_results->computeid; /* Add the row to the row buffer, whose capacity is always at least 1 */ resinfo = tds->current_results; idx = buffer_add_row(dbproc, resinfo); assert(idx != -1); result = dbproc->row_type = (res_type == TDS_ROW_RESULT)? REG_ROW : computeid; #if 0 /* TODO */ tds_process_tokens(tds, &res_type, NULL, TDS_TOKEN_TRAILING); #endif break; } /* allows to process trailing tokens */ if (res_type == TDS_DONEINPROC_RESULT) { if (!rows_set) row_count = tds->rows_affected; rows_set = true; goto again; } /* fall through */ case TDS_NO_MORE_RESULTS: dbproc->dbresults_state = _DB_RES_NEXT_RESULT; result = NO_MORE_ROWS; break; default: tdsdump_log(TDS_DBG_FUNC, "unexpected: leaving dbnextrow() returning FAIL\n"); return FAIL; break; } if (rows_set) tds->rows_affected = row_count; } if (res_type == TDS_ROW_RESULT || res_type == TDS_COMPUTE_RESULT) { /* * Transfer the data from the row buffer to the bound variables. */ buffer_transfer_bound_data(&dbproc->row_buf, res_type, computeid, dbproc, idx); } if (res_type == TDS_COMPUTE_RESULT) { tdsdump_log(TDS_DBG_FUNC, "leaving dbnextrow() returning compute_id %d\n", result); } else { tdsdump_log(TDS_DBG_FUNC, "leaving dbnextrow() returning %s\n", prdbretcode(result, prbuf)); } return result; } /* dbnextrow() */ static TDS_SERVER_TYPE dblib_bound_type(int bindtype) { switch (bindtype) { case CHARBIND: case STRINGBIND: case NTBSTRINGBIND: return SYBCHAR; break; case FLT8BIND: return SYBFLT8; break; case REALBIND: return SYBREAL; break; case INTBIND: return SYBINT4; break; case SMALLBIND: return SYBINT2; break; case TINYBIND: return SYBINT1; break; case BIGINTBIND: return SYBINT8; break; case DATETIMEBIND: return SYBDATETIME; break; case SMALLDATETIMEBIND: return SYBDATETIME4; break; case DATEBIND: return SYBDATE; break; case TIMEBIND: return SYBTIME; break; case BIGDATETIMEBIND: return SYB5BIGDATETIME; break; case BIGTIMEBIND: return SYB5BIGTIME; break; case MONEYBIND: return SYBMONEY; break; case SMALLMONEYBIND: return SYBMONEY4; break; case BINARYBIND: return SYBBINARY; break; case VARYBINBIND: return SYBVARBINARY; break; case VARYCHARBIND: return SYBVARCHAR; break; case BITBIND: return SYBBIT; break; case NUMERICBIND: case SRCNUMERICBIND: case DECIMALBIND: case SRCDECIMALBIND: return SYBNUMERIC; break; case DATETIME2BIND: return SYBMSDATETIMEOFFSET; break; default: return TDS_INVALID_TYPE; } } /** * \ingroup dblib_core * \brief Convert one datatype to another. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param srctype datatype of the data to convert. * \param src buffer to convert * \param srclen length of \a src * \param desttype target datatype * \param dest output buffer * \param destlen size of \a dest * \returns On success, the count of output bytes in \a dest, else -1. On failure, it will call any user-supplied error handler. * \remarks Causes of failure: * - No such conversion unavailable. * - Character data output was truncated, or numerical data overflowed or lost precision. * - In converting character data to one of the numeric types, the string could not be interpreted as a number. * * Conversion functions are handled in the TDS layer. * * The main reason for this is that \c ct-lib and \c ODBC (and presumably \c DBI) need * to be able to do conversions between datatypes. This is possible because * the format of complex data (dates, money, numeric, decimal) is defined by * its representation on the wire; thus what we call \c DBMONEY is exactly its * format on the wire. CLIs that need a different representation (ODBC?) * need to convert from this format anyway, so the code would already be in * place. * * Each datatype is also defined by its Server-type so all CLIs should be * able to map native types to server types as well. * * tds_convert() copies from src to dest and returns the output data length, * period. All padding and termination is the responsibility of the API library * and is done post-conversion. The peculiar rule in dbconvert() is that * a \a destlen of -1 and a \a desttype of \c SYBCHAR means the output buffer * should be null-terminated. * * \sa dbaltbind(), dbaltbind_ps(), dbbind(), dbbind_ps(), dbconvert_ps(), dberrhandle(), dbsetnull(), dbsetversion(), dbwillconvert(). * \todo What happens if client does not reset values? * \todo Microsoft and Sybase define this function differently. */ DBINT dbconvert_ps(DBPROCESS * dbproc, int db_srctype, const BYTE * src, DBINT srclen, int db_desttype, BYTE * dest, DBINT destlen, DBTYPEINFO * typeinfo) { CONV_RESULT dres; DBINT ret; int i; int len; TDS_SERVER_TYPE srctype, desttype; tdsdump_log(TDS_DBG_FUNC, "dbconvert_ps(%p, %s, %p, %d, %s, %p, %d, %p)\n", dbproc, tds_prdatatype(db_srctype), src, srclen, tds_prdatatype(db_desttype), dest, destlen, typeinfo); /* dbproc and src can be NULLs */ CHECK_PARAMETER(dest, SYBEACNV, -1); DBPERROR_RETURN(!is_tds_type_valid(db_srctype), SYBEUDTY); srctype = (TDS_SERVER_TYPE) db_srctype; DBPERROR_RETURN(!is_tds_type_valid(db_desttype), SYBEUDTY); desttype = (TDS_SERVER_TYPE) db_desttype; if (is_numeric_type(desttype)) { TDS_NUMERIC *d = &dres.n; if (typeinfo == NULL) { if (is_numeric_type(srctype)) { DBNUMERIC *s = (DBNUMERIC *) src; d->precision = s->precision; d->scale = s->scale; } else { d->precision = 18; d->scale = 0; } } else { d->precision = typeinfo->precision; d->scale = typeinfo->scale; } } if (0 == destlen) return 0; if (src == NULL || srclen == 0) { int bind = dbbindtype(desttype); int size = tds_get_size_by_type(desttype); if (bind == NTBSTRINGBIND) { if (destlen > 0) { size = destlen; bind = CHARBIND; } else { size = 1; bind = NTBSTRINGBIND; } } else if (bind == BINARYBIND) { if (destlen > 0) size = destlen; else size = 0; } dbgetnull(dbproc, bind, size, dest); return size; } /* srclen of -1 means the source data is definitely NULL terminated */ if (srclen == -1) srclen = (int)strlen((const char *) src); /* often times we are asked to convert a data type to itself */ if (srctype == desttype && !is_numeric_type(desttype)) { ret = -2; /* to make sure we always set it */ tdsdump_log(TDS_DBG_INFO1, "dbconvert_ps() srctype == desttype\n"); switch (desttype) { case SYBBINARY: case SYBVARBINARY: case SYBIMAGE: if (srclen > destlen && destlen >= 0) { dbperror(dbproc, SYBECOFL, 0); ret = -1; } else { memcpy(dest, src, srclen); if (srclen < destlen) memset(dest + srclen, 0, destlen - srclen); ret = srclen; } break; case SYBCHAR: case SYBVARCHAR: case SYBTEXT: /* srclen of -1 means the source data is definitely NULL terminated */ if (srclen == -1) srclen = (int)strlen((const char *) src); switch (destlen) { case 0: /* nothing to copy */ ret = 0; break; case -1: /* rtrim and null terminate */ while (srclen && src[srclen - 1] == ' ') { --srclen; } /* fall thru */ case -2: /* just null terminate */ memcpy(dest, src, srclen); dest[srclen] = '\0'; ret = srclen; break; default: assert(destlen > 0); if (destlen < 0 || srclen > destlen) { dbperror(dbproc, SYBECOFL, 0); ret = -1; } else { memcpy(dest, src, srclen); for (i = srclen; i < destlen; i++) dest[i] = ' '; ret = srclen; } break; } break; case SYBINT1: case SYBINT2: case SYBINT4: case SYBINT8: case SYBFLT8: case SYBREAL: case SYBBIT: case SYBBITN: case SYBMONEY: case SYBMONEY4: case SYBDATETIME: case SYBDATETIME4: case SYBDATE: case SYBTIME: case SYB5BIGDATETIME: case SYB5BIGTIME: case SYBUNIQUE: ret = tds_get_size_by_type(desttype); memcpy(dest, src, ret); break; case SYBMSDATE: case SYBMSTIME: case SYBMSDATETIME2: case SYBMSDATETIMEOFFSET: ret = sizeof(TDS_DATETIMEALL); memcpy(dest, src, ret); break; default: ret = -1; break; } assert(ret > -2); return ret; } /* end srctype == desttype */ /* * Character types need no conversion. Just move the data. */ if (is_similar_type(srctype, desttype)) { if (src && dest && srclen > 0 && destlen >= srclen) { memcpy(dest, src, srclen); return srclen; } } tdsdump_log(TDS_DBG_INFO1, "dbconvert_ps() calling tds_convert\n"); len = tds_convert(g_dblib_ctx.tds_ctx, srctype, (const TDS_CHAR *) src, srclen, desttype, &dres); tdsdump_log(TDS_DBG_INFO1, "dbconvert_ps() called tds_convert returned %d\n", len); if (len < 0) { _dblib_convert_err(dbproc, len); return -1; } switch (desttype) { case SYBBINARY: case SYBVARBINARY: case SYBIMAGE: if (len > destlen && destlen >= 0) { dbperror(dbproc, SYBECOFL, 0); ret = -1; } else { memcpy(dest, dres.ib, len); if (len < destlen) memset(dest + len, 0, destlen - len); ret = len; } free(dres.ib); break; case SYBINT1: case SYBINT2: case SYBINT4: case SYBINT8: case SYBFLT8: case SYBREAL: case SYBBIT: case SYBBITN: case SYBMONEY: case SYBMONEY4: case SYBDATETIME: case SYBDATETIME4: case SYBTIME: case SYBDATE: case SYB5BIGDATETIME: case SYB5BIGTIME: case SYBUNIQUE: case SYBMSDATE: case SYBMSTIME: case SYBMSDATETIME2: case SYBMSDATETIMEOFFSET: case SYBNUMERIC: case SYBDECIMAL: memcpy(dest, &(dres.ti), len); ret = len; break; case SYBCHAR: case SYBVARCHAR: case SYBTEXT: tdsdump_log(TDS_DBG_INFO1, "dbconvert_ps() outputting %d bytes character data destlen = %d \n", len, destlen); if (destlen < -2) destlen = 0; /* failure condition */ switch (destlen) { case 0: ret = -1; break; case -1: /* rtrim and null terminate */ for (i = len - 1; i >= 0 && dres.c[i] == ' '; --i) { len = i; } memcpy(dest, dres.c, len); dest[len] = '\0'; ret = len; break; case -2: /* just null terminate */ memcpy(dest, dres.c, len); dest[len] = 0; ret = len; break; default: assert(destlen > 0); if (destlen < 0 || len > destlen) { dbperror(dbproc, SYBECOFL, 0); ret = -1; tdsdump_log(TDS_DBG_INFO1, "%d bytes type %d -> %d, destlen %d < %d required\n", srclen, srctype, desttype, destlen, len); break; } /* else pad with blanks */ memcpy(dest, dres.c, len); for (i = len; i < destlen; i++) dest[i] = ' '; ret = len; break; } free(dres.c); break; default: tdsdump_log(TDS_DBG_INFO1, "error: dbconvert_ps(): unrecognized desttype %d \n", desttype); ret = -1; break; } return (ret); } /** * \ingroup dblib_core * \brief cf. dbconvert_ps(), above * * \em Sybase: Convert numeric types. * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param srctype datatype of the data to convert. * \param src buffer to convert * \param srclen length of \a src * \param desttype target datatype * \param dest output buffer * \param destlen size of \a dest * \param typeinfo address of a \c DBTYPEINFO structure that governs the precision & scale of the output, may be \c NULL. * \sa dbaltbind(), dbaltbind_ps(), dbbind(), dbbind_ps(), dbconvert_ps(), dberrhandle(), dbsetnull(), dbsetversion(), dbwillconvert(). */ DBINT dbconvert(DBPROCESS * dbproc, int srctype, const BYTE * src, DBINT srclen, int desttype, BYTE * dest, DBINT destlen) { DBTYPEINFO ti, *pti = NULL; tdsdump_log(TDS_DBG_FUNC, "dbconvert(%p)\n", dbproc); /* dbproc can be NULL*/ DBPERROR_RETURN(!is_tds_type_valid(desttype), SYBEUDTY); if (is_numeric_type(desttype)) { DBNUMERIC *num; /* FIXME what happen if client do not reset values ??? */ if (dbproc->msdblib) { num = (DBNUMERIC *) dest; ti.precision = num->precision; ti.scale = num->scale; pti = &ti; } else { /* for Sybase passing NULL as DBTYPEINFO is fine */ } } return dbconvert_ps(dbproc, srctype, src, srclen, desttype, dest, destlen, pti); } /** * \ingroup dblib_core * \brief Tie a host variable to a resultset column. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param column Nth column, starting at 1. * \param vartype datatype of the host variable that will receive the data * \param varlen size of host variable pointed to \a varaddr * \param varaddr address of host variable * \retval SUCCEED everything worked. * \retval FAIL no such \a column or no such conversion possible, or target buffer too small. * \sa */ RETCODE dbbind(DBPROCESS * dbproc, int column, int vartype, DBINT varlen, BYTE * varaddr) { TDSCOLUMN *colinfo = NULL; TDSRESULTINFO* results; TDS_SERVER_TYPE srctype, desttype; tdsdump_log(TDS_DBG_FUNC, "dbbind(%p, %d, %d, %d, %p)\n", dbproc, column, vartype, varlen, varaddr); CHECK_CONN(FAIL); CHECK_PARAMETER(varaddr, SYBEABNV, FAIL); results = dbproc->tds_socket->res_info; if (results == NULL || results->num_cols < column || column < 1) { dbperror(dbproc, SYBEABNC, 0); return FAIL; } if (varlen < 0) { switch (vartype) { case CHARBIND: case STRINGBIND: case NTBSTRINGBIND: case VARYCHARBIND: case VARYBINBIND: /* * No message for this error. Documentation doesn't define varlen < 0, but * experimentation with Sybase db-lib shows it's accepted as if zero. */ tdsdump_log(TDS_DBG_FUNC, "dbbind: setting varlen (%d) to 0\n", varlen); varlen = 0; break; } } if (0 == varlen) { /* "Note that if varlen is 0, no padding takes place." */ switch (vartype) { case CHARBIND: case STRINGBIND: case NTBSTRINGBIND: varlen = -1; break; default: break; /* dbconvert: "The destlen is ignored for all fixed-length, non-NULL data types." */ } } dbproc->avail_flag = FALSE; colinfo = dbproc->tds_socket->res_info->columns[column - 1]; srctype = tds_get_conversion_type(colinfo->column_type, colinfo->column_size); desttype = dblib_bound_type(vartype); if (desttype == TDS_INVALID_TYPE) { dbperror(dbproc, SYBEBTYP, 0); return FAIL; } if (!dbwillconvert(srctype, desttype)) { dbperror(dbproc, SYBEABMT, 0); return FAIL; } colinfo->column_varaddr = (char *) varaddr; colinfo->column_bindtype = vartype; colinfo->column_bindlen = varlen; return SUCCEED; } /* dbbind() */ /** * \ingroup dblib_core * \brief set name and location of the \c interfaces file FreeTDS should use to look up a servername. * * Does not affect lookups or location of \c freetds.conf. * \param filename name of \c interfaces * \sa dbopen() */ void dbsetifile(char *filename) { tdsdump_log(TDS_DBG_FUNC, "dbsetifile(%s)\n", filename? filename : "0x00"); if (filename == NULL) { dbperror(NULL, SYBENULP, 0); return; } tds_set_interfaces_file_loc(filename); } /** * \ingroup dblib_core * \brief Tie a null-indicator to a regular result column. * * * When a row is fetched, the indicator variable tells the state of the column's data. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param column Nth column in the result set, starting with 1. * \param indicator address of host variable. * \retval SUCCEED variable accepted. * \retval FAIL \a indicator is NULL or \a column is out of range. * \remarks Contents of \a indicator are set with \c dbnextrow(). Possible values are: * - 0 \a column bound successfully * - -1 \a column is NULL. * - >0 true length of data, had \a column not been truncated due to insufficient space in the columns bound host variable . * \sa dbanullbind(), dbbind(), dbdata(), dbdatlen(), dbnextrow(). */ RETCODE dbnullbind(DBPROCESS * dbproc, int column, DBINT * indicator) { TDSCOLUMN *colinfo; tdsdump_log(TDS_DBG_FUNC, "dbnullbind(%p, %d, %p)\n", dbproc, column, indicator); colinfo = dbcolptr(dbproc, column); if (!colinfo) return FAIL; /* dbcolptr sent SYBECNOR, Column number out of range */ colinfo->column_nullbind = (TDS_SMALLINT *)indicator; return SUCCEED; } /** * \ingroup dblib_core * \brief Tie a null-indicator to a compute result column. * * * When a row is fetched, the indicator variable tells the state of the column's data. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param computeid identifies which one of potientially many compute rows is meant. The first compute * clause has \a computeid == 1. * \param column Nth column in the result set, starting with 1. * \param indicator address of host variable. * \retval SUCCEED variable accepted. * \retval FAIL \a indicator is NULL or \a column is out of range. * \remarks Contents of \a indicator are set with \c dbnextrow(). Possible values are: * - 0 \a column bound successfully * - -1 \a column is NULL. * - >0 true length of data, had \a column not been truncated due to insufficient space in the columns bound host variable . * \sa dbadata(), dbadlen(), dbaltbind(), dbnextrow(), dbnullbind(). * \todo Never fails, but only because failure conditions aren't checked. */ RETCODE dbanullbind(DBPROCESS * dbproc, int computeid, int column, DBINT * indicator) { TDSCOLUMN *curcol; tdsdump_log(TDS_DBG_FUNC, "dbanullbind(%p, %d, %d, %p)\n", dbproc, computeid, column, indicator); curcol = dbacolptr(dbproc, computeid, column, 1); if (!curcol) return FAIL; /* * XXX Need to check for possibly problems before assuming * everything is okay */ curcol->column_nullbind = (TDS_SMALLINT *)indicator; return SUCCEED; } /** * \ingroup dblib_core * \brief Indicates whether or not the count returned by dbcount is real (Microsoft-compatibility feature). * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \returns TRUE if the count returned by dbcount is real or FALSE if the count returned by dbcount is not real. * \sa DBCOUNT(), dbcount(). */ BOOL dbiscount(DBPROCESS * dbproc) { tdsdump_log(TDS_DBG_FUNC, "dbiscount(%p)\n", dbproc); CHECK_PARAMETER(dbproc, SYBENULL, -1); return dbproc->tds_socket && dbproc->tds_socket->rows_affected != TDS_NO_COUNT; } /** * \ingroup dblib_core * \brief Get count of rows processed * * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \returns * - for insert/update/delete, count of rows affected. * - for select, count of rows returned, after all rows have been fetched. * \sa DBCOUNT(), dbnextrow(), dbresults(). */ DBINT dbcount(DBPROCESS * dbproc) { tdsdump_log(TDS_DBG_FUNC, "dbcount(%p)\n", dbproc); CHECK_PARAMETER(dbproc, SYBENULL, -1); if (!dbproc || !dbproc->tds_socket || dbproc->tds_socket->rows_affected == TDS_NO_COUNT) return -1; return (DBINT)dbproc->tds_socket->rows_affected; } /** * \ingroup dblib_core * \brief Clear \a n rows from the row buffer. * * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param n number of rows to remove, >= 0. * \sa dbgetrow(), dbnextrow(), dbsetopt(). */ void dbclrbuf(DBPROCESS * dbproc, DBINT n) { tdsdump_log(TDS_DBG_FUNC, "dbclrbuf(%p, %d)\n", dbproc, n); CHECK_PARAMETER(dbproc, SYBENULL, ); if (n <= 0) return; if (dbproc->dbopts[DBBUFFER].factive) { DBPROC_ROWBUF * buf = &(dbproc->row_buf); int count = buffer_count(buf); if (n >= count) n = count - 1; buffer_delete_rows(&(dbproc->row_buf), n); } } /** * \ingroup dblib_core * \brief Test whether or not a datatype can be converted to another datatype * * \param srctype type converting from * \param desttype type converting to * \remarks dbwillconvert() lies sometimes. Some datatypes \em should be convertible but aren't yet in our implementation. * Legal unimplemented conversions return \em TRUE. * \retval TRUE convertible, or should be. * \retval FAIL not convertible. * \sa dbaltbind(), dbbind(), dbconvert(), dbconvert_ps(), \c src/dblib/unittests/convert().c(). */ DBBOOL dbwillconvert(int srctype, int desttype) { tdsdump_log(TDS_DBG_FUNC, "dbwillconvert(%s, %s)\n", tds_prdatatype(srctype), tds_prdatatype(desttype)); return tds_willconvert(srctype, desttype) ? TRUE : FALSE; } /** * \ingroup dblib_core * \brief Get the datatype of a regular result set column. * * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param column Nth in the result set, starting from 1. * \returns \c SYB* datetype token value, or zero if \a column out of range * \sa dbcollen(), dbcolname(), dbdata(), dbdatlen(), dbnumcols(), dbprtype(), dbvarylen(). */ int dbcoltype(DBPROCESS * dbproc, int column) { TDSCOLUMN *colinfo; tdsdump_log(TDS_DBG_FUNC, "dbcoltype(%p, %d)\n", dbproc, column); colinfo = dbcolptr(dbproc, column); if (!colinfo) return -1; switch (colinfo->column_type) { case SYBVARCHAR: return SYBCHAR; case SYBVARBINARY: return SYBBINARY; } return tds_get_conversion_type(colinfo->column_type, colinfo->column_size); } /** * \ingroup dblib_core * \brief Get user-defined datatype of a regular result column. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param column Nth in the result set, starting from 1. * \returns \c SYB* datetype token value, or -1 if \a column out of range * \sa dbaltutype(), dbcoltype(). */ int dbcolutype(DBPROCESS * dbproc, int column) { TDSCOLUMN *colinfo; tdsdump_log(TDS_DBG_FUNC, "dbcolutype(%p, %d)\n", dbproc, column); colinfo = dbcolptr(dbproc, column); if (!colinfo) return -1; return colinfo->column_usertype; } /** * \ingroup dblib_core * \brief Get precision and scale information for a regular result column. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param column Nth in the result set, starting from 1. * \return Pointer to a DBTYPEINFO structure . NULL \a column is out of range. * \sa dbcollen(), dbcolname(), dbcoltype(), dbdata(), dbdatlen(), dbnumcols(), dbprtype(), dbvarylen(). */ DBTYPEINFO * dbcoltypeinfo(DBPROCESS * dbproc, int column) { /* moved typeinfo from static into dbproc structure to make thread safe. (mlilback 11/7/01) */ TDSCOLUMN *colinfo; tdsdump_log(TDS_DBG_FUNC, "dbcoltypeinfo(%p, %d)\n", dbproc, column); colinfo = dbcolptr(dbproc, column); if (!colinfo) return NULL; dbproc->typeinfo.precision = colinfo->column_prec; dbproc->typeinfo.scale = colinfo->column_scale; return &dbproc->typeinfo; } /** * \brief Get a bunch of column attributes with a single call (Microsoft-compatibility feature). * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param type must be CI_REGULAR or CI_ALTERNATE (CI_CURSOR is defined by the vendor, but is not yet implemented). * \param column Nth in the result set, starting from 1. * \param computeid (ignored) * \param pdbcol address of structure to be populated by this function. * \return SUCCEED or FAIL. * \sa dbcolbrowse(), dbqual(), dbtabbrowse(), dbtabcount(), dbtabname(), dbtabsource(), dbtsnewlen(), dbtsnewval(), dbtsput(). * \todo Support cursor rows. */ RETCODE dbcolinfo (DBPROCESS *dbproc, CI_TYPE type, DBINT column, DBINT computeid, DBCOL *pdbcol ) { DBTYPEINFO *ps; TDSCOMPUTEINFO *info; TDSCOLUMN *colinfo; int i; tdsdump_log(TDS_DBG_FUNC, "dbcolinfo(%p, %d, %d, %d, %p)\n", dbproc, type, column, computeid, pdbcol); colinfo = dbcolptr(dbproc, column); if (!colinfo) return FAIL; CHECK_NULP(pdbcol, "dbcolinfo", 5, FAIL); if (type == CI_REGULAR) { strlcpy(pdbcol->Name, dbcolname(dbproc, column), sizeof(pdbcol->Name)); strlcpy(pdbcol->ActualName, dbcolname(dbproc, column), sizeof(pdbcol->ActualName)); pdbcol->Type = dbcoltype(dbproc, column); pdbcol->UserType = dbcolutype(dbproc, column); pdbcol->MaxLength = dbcollen(dbproc, column); pdbcol->Null = _dbnullable(dbproc, column); pdbcol->VarLength = dbvarylen(dbproc, column); ps = dbcoltypeinfo(dbproc, column); if( ps ) { pdbcol->Precision = ps->precision; pdbcol->Scale = ps->scale; } pdbcol->Updatable = colinfo->column_writeable ? TRUE : FALSE; pdbcol->Identity = colinfo->column_identity ? TRUE : FALSE; return SUCCEED; } if (type == CI_ALTERNATE) { if (computeid == 0) return FAIL; for (i = 0;; ++i) { if (i >= dbproc->tds_socket->num_comp_info) return FAIL; info = dbproc->tds_socket->comp_info[i]; if (info->computeid == computeid) break; } /* if either the compute id or the column number are invalid, return -1 */ if (column < 1 || column > info->num_cols) return FAIL; colinfo = info->columns[column - 1]; strlcpy(pdbcol->Name, tds_dstr_cstr(&colinfo->column_name), sizeof(pdbcol->Name)); strlcpy(pdbcol->ActualName, tds_dstr_cstr(&colinfo->column_name), sizeof(pdbcol->ActualName)); pdbcol->Type = dbalttype(dbproc, computeid, column); pdbcol->UserType = dbaltutype(dbproc, computeid, column); pdbcol->MaxLength = dbaltlen(dbproc, computeid, column); if (colinfo->column_nullable) pdbcol->Null = TRUE; else pdbcol->Null = FALSE; pdbcol->VarLength = FALSE; if (colinfo->column_nullable || is_nullable_type(colinfo->column_type)) pdbcol->VarLength = TRUE; pdbcol->Precision = colinfo->column_prec; pdbcol->Scale = colinfo->column_scale; pdbcol->Updatable = colinfo->column_writeable ? TRUE : FALSE ; pdbcol->Identity = colinfo->column_identity ? TRUE : FALSE ; return SUCCEED; } return FAIL; } /** * \ingroup dblib_core * \brief Get base database column name for a result set column. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param column Nth in the result set, starting from 1. * \return pointer to ASCII null-terminated string, the name of the column. On error, NULL. * \sa dbcolbrowse(), dbqual(), dbtabbrowse(), dbtabcount(), dbtabname(), dbtabsource(), dbtsnewlen(), dbtsnewval(), dbtsput(). */ char * dbcolsource(DBPROCESS * dbproc, int column) { TDSCOLUMN *colinfo; tdsdump_log(TDS_DBG_FUNC, "dbcolsource(%p, %d)\n", dbproc, column); colinfo = dbcolptr(dbproc, column); if (!colinfo) return NULL; return tds_dstr_buf(tds_dstr_isempty(&colinfo->table_column_name) ? &colinfo->column_name : &colinfo->table_column_name); } /** * \ingroup dblib_core * \brief Get size of a regular result column. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param column Nth in the result set, starting from 1. * \return size of the column (not of data in any particular row). On error, -1. * \sa dbcolname(), dbcoltype(), dbdata(), dbdatlen(), dbnumcols(). */ DBINT dbcollen(DBPROCESS * dbproc, int column) { TDSCOLUMN *colinfo; tdsdump_log(TDS_DBG_FUNC, "dbcollen(%p, %d)\n", dbproc, column); colinfo = dbcolptr(dbproc, column); if (!colinfo) return -1; return colinfo->column_size; } /** * \ingroup dblib_core * \brief Get size of a result column needed to print column. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param column Nth in the result set, starting from 1. * \return size of the column in characters (not of data in any particular row). On error, -1. * \sa dbcolname(), dbcoltype(), dbdata(), dbdatlen(), dbnumcols(). */ DBINT dbprcollen(DBPROCESS * dbproc, int column) { TDSCOLUMN *colinfo; tdsdump_log(TDS_DBG_FUNC, "dbprcollen(%p, %d)\n", dbproc, column); colinfo = dbcolptr(dbproc, column); if (!colinfo) return 0; return _get_printable_size(colinfo); } /* dbvarylen(), pkleef@openlinksw.com 01/21/02 */ /** * \ingroup dblib_core * \brief Determine whether a column can vary in size. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param column Nth in the result set, starting from 1. * \retval TRUE datatype of column can vary in size, or is nullable. * \retval FALSE datatype of column is fixed and is not nullable. * \sa dbcollen(), dbcolname(), dbcoltype(), dbdata(), dbdatlen(), dbnumcols(), dbprtype(). */ DBINT dbvarylen(DBPROCESS * dbproc, int column) { TDSCOLUMN *colinfo; tdsdump_log(TDS_DBG_FUNC, "dbvarylen(%p, %d)\n", dbproc, column); colinfo = dbcolptr(dbproc, column); if (!colinfo) return FALSE; if (colinfo->column_nullable) return TRUE; switch (colinfo->column_type) { /* variable length fields */ case SYBNVARCHAR: case SYBVARBINARY: case SYBVARCHAR: return TRUE; /* types that can be null */ case SYBBITN: case SYBDATETIMN: case SYBDECIMAL: case SYBFLTN: case SYBINTN: case SYBMONEYN: case SYBNUMERIC: return TRUE; /* blob types */ case SYBIMAGE: case SYBNTEXT: case SYBTEXT: return TRUE; } return FALSE; } /** * \ingroup dblib_core * \brief Get size of current row's data in a regular result column. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param column Nth in the result set, starting from 1. * \return size of the data, in bytes. * \sa dbcollen(), dbcolname(), dbcoltype(), dbdata(), dbnumcols(). */ DBINT dbdatlen(DBPROCESS * dbproc, int column) { DBINT len; TDSCOLUMN *colinfo; tdsdump_log(TDS_DBG_FUNC, "dbdatlen(%p, %d)\n", dbproc, column); colinfo = dbcolptr(dbproc, column); if (!colinfo) return -1; len = (colinfo->column_cur_size < 0)? 0 : colinfo->column_cur_size; tdsdump_log(TDS_DBG_FUNC, "dbdatlen() type = %d, len= %d\n", colinfo->column_type, len); return len; } /** * \ingroup dblib_core * \brief Get address of data in a regular result column. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param column Nth in the result set, starting from 1. * \return pointer the data, or NULL if data are NULL, or if \a column is out of range. * \sa dbbind(), dbcollen(), dbcolname(), dbcoltype(), dbdatlen(), dbnumcols(). */ BYTE * dbdata(DBPROCESS * dbproc, int column) { tdsdump_log(TDS_DBG_FUNC, "dbdata(%p, %d)\n", dbproc, column); return _dbcoldata(dbcolptr(dbproc, column)); } /** \internal * \ingroup dblib_internal * \brief Return data from a column * * \param colinfo contains information on a result column. * \return pointer to the data, or NULL if data are NULL * \sa dbdata(), dbretdata() */ static BYTE * _dbcoldata(TDSCOLUMN *colinfo) { BYTE *res; const static BYTE empty[1] = { 0 }; if (!colinfo || colinfo->column_cur_size < 0) return NULL; res = colinfo->column_data; if (is_blob_col(colinfo)) res = (BYTE *) ((TDSBLOB *) res)->textvalue; if (!res) return (BYTE *) empty; return res; } /** * \ingroup dblib_core * \brief Cancel the current command batch. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \retval SUCCEED always. * \sa dbcanquery(), dbnextrow(), dbresults(), dbsetinterrupt(), dbsqlexec(), dbsqlok(), dbsqlsend(). * \todo Check for failure and return accordingly. */ RETCODE dbcancel(DBPROCESS * dbproc) { TDSSOCKET *tds; tdsdump_log(TDS_DBG_FUNC, "dbcancel(%p)\n", dbproc); CHECK_CONN(FAIL); tds = dbproc->tds_socket; tds_send_cancel(tds); tds_process_cancel(tds); return SUCCEED; } /** * \ingroup dblib_core * \brief Determine size buffer required to hold the results returned by dbsprhead(), dbsprline(), and dbspr1row(). * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \return size of buffer requirement, in bytes. * \remarks An esoteric function. * \sa dbprhead(), dbprrow(), dbspr1row(), dbsprhead(), dbsprline(). */ DBINT dbspr1rowlen(DBPROCESS * dbproc) { TDSSOCKET *tds; int col, len = 0; tdsdump_log(TDS_DBG_FUNC, "dbspr1rowlen(%p)\n", dbproc); CHECK_PARAMETER(dbproc, SYBENULL, 0); CHECK_PARAMETER(dbproc->tds_socket, SYBEDDNE, 0); tds = dbproc->tds_socket; for (col = 0; col < tds->res_info->num_cols; col++) { TDSCOLUMN *colinfo = tds->res_info->columns[col]; int collen = _get_printable_size(colinfo); int namlen = tds_dstr_len(&colinfo->column_name); len += collen > namlen ? collen : namlen; if (col > 0) /* allow for the space between columns */ len += dbstring_length(dbproc->dbopts[DBPRCOLSEP].param); } return ++len; /* allow for the nul */ } /** * \ingroup dblib_core * \brief Print a regular result row to a buffer. * * Fills a buffer with one data row, represented as a null-terminated ASCII string. Helpful for debugging. * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param buffer \em output: Address of a buffer to hold ASCII null-terminated string. * \param buf_len size of \a buffer, in bytes. * \retval SUCCEED on success. * \retval FAIL trouble encountered. * \sa dbclropt(), dbisopt(), dbprhead(), dbprrow(), dbspr1rowlen(), dbsprhead(), dbsprline(). */ RETCODE dbspr1row(DBPROCESS * dbproc, char *buffer, DBINT buf_len) { TDSSOCKET *tds; TDSDATEREC when; int i, c, col; DBINT len; tdsdump_log(TDS_DBG_FUNC, "dbspr1row(%p, %s, %d)\n", dbproc, buffer, buf_len); CHECK_CONN(FAIL); CHECK_NULP(buffer, "dbspr1row", 2, FAIL); if (!dbproc->tds_socket) return FAIL; tds = dbproc->tds_socket; for (col = 0; col < tds->res_info->num_cols; col++) { int padlen, collen, namlen; TDSCOLUMN *colinfo = tds->res_info->columns[col]; if (colinfo->column_cur_size < 0) { len = 4; if (buf_len <= len) { return FAIL; } strcpy(buffer, "NULL"); } else { TDS_SERVER_TYPE desttype, srctype; desttype = dblib_bound_type(STRINGBIND); srctype = tds_get_conversion_type(colinfo->column_type, colinfo->column_size); if (is_datetime_type(srctype)) { tds_datecrack(srctype, dbdata(dbproc, col + 1), &when); len = (int)tds_strftime(buffer, buf_len, STD_DATETIME_FMT, &when, 3); } else { len = dbconvert(dbproc, srctype, dbdata(dbproc, col + 1), dbdatlen(dbproc, col + 1), desttype, (BYTE *) buffer, buf_len); } if (len == -1) { return FAIL; } } buffer += len; buf_len -= len; collen = _get_printable_size(colinfo); namlen = tds_dstr_len(&colinfo->column_name); padlen = (collen > namlen ? collen : namlen) - len; if ((c = dbstring_getchar(dbproc->dbopts[DBPRPAD].param, 0)) == -1) { c = ' '; } for (; padlen > 0; padlen--) { if (buf_len < 1) { return FAIL; } *buffer++ = c; buf_len--; } if ((col + 1) < tds->res_info->num_cols) { i = 0; while ((c = dbstring_getchar(dbproc->dbopts[DBPRCOLSEP].param, i)) != -1) { if (buf_len < 1) { return FAIL; } *buffer++ = c; buf_len--; i++; } } } if (buf_len < 1) { return FAIL; } *buffer = '\0'; return SUCCEED; } /** * \ingroup dblib_core * \brief Print a result set to stdout. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \sa dbbind(), dbnextrow(), dbprhead(), dbresults(), dbspr1row(), dbsprhead(), dbsprline(). */ RETCODE dbprrow(DBPROCESS * dbproc) { TDSCOLUMN *colinfo; TDSRESULTINFO *resinfo; TDSSOCKET *tds; int i, col, collen, namlen, len; char dest[8192]; int desttype, srctype; TDSDATEREC when; STATUS status; int padlen; int c; int selcol; int linechar; int op; const char *opname; /* these are for compute rows */ DBINT computeid, num_cols, colid; TDS_SMALLINT *col_printlens = NULL; tdsdump_log(TDS_DBG_FUNC, "dbprrow(%p)\n", dbproc); CHECK_CONN(FAIL); tds = dbproc->tds_socket; while ((status = dbnextrow(dbproc)) != NO_MORE_ROWS) { if (status == FAIL) { free(col_printlens); return FAIL; } if (status == REG_ROW) { resinfo = tds->res_info; if (col_printlens == NULL) { if ((col_printlens = tds_new0(TDS_SMALLINT, resinfo->num_cols)) == NULL) { dbperror(dbproc, SYBEMEM, errno); return FAIL; } } for (col = 0; col < resinfo->num_cols; col++) { colinfo = resinfo->columns[col]; if (colinfo->column_cur_size < 0) { len = 4; strcpy(dest, "NULL"); } else { desttype = dblib_bound_type(STRINGBIND); srctype = tds_get_conversion_type(colinfo->column_type, colinfo->column_size); if (is_datetime_type(srctype)) { tds_datecrack(srctype, dbdata(dbproc, col + 1), &when); len = (int)tds_strftime(dest, sizeof(dest), STD_DATETIME_FMT, &when, 3); } else { len = dbconvert(dbproc, srctype, dbdata(dbproc, col + 1), dbdatlen(dbproc, col + 1), desttype, (BYTE *) dest, sizeof(dest)); } } printf("%.*s", len, dest); collen = _get_printable_size(colinfo); namlen = tds_dstr_len(&colinfo->column_name); padlen = (collen > namlen ? collen : namlen) - len; c = dbstring_getchar(dbproc->dbopts[DBPRPAD].param, 0); for (; c > -1 && padlen > 0; padlen--) { putchar(c); } if ((col + 1) < resinfo->num_cols) { i = 0; while ((c = dbstring_getchar(dbproc->dbopts[DBPRCOLSEP].param, i++)) != -1) { putchar(c); } } col_printlens[col] = collen; } i = 0; while ((c = dbstring_getchar(dbproc->dbopts[DBPRLINESEP].param, i++)) != -1) { putchar(c); } } else { computeid = status; for (i = 0;; ++i) { if (i >= tds->num_comp_info) { free(col_printlens); return FAIL; } resinfo = tds->comp_info[i]; if (resinfo->computeid == computeid) break; } num_cols = dbnumalts(dbproc, computeid); tdsdump_log(TDS_DBG_FUNC, "dbprrow num compute cols = %d\n", num_cols); i = 0; while ((c = dbstring_getchar(dbproc->dbopts[DBPRLINESEP].param, i++)) != -1) { putchar(c); } for (selcol = col = 1; col <= num_cols; col++) { tdsdump_log(TDS_DBG_FUNC, "dbprrow calling dbaltcolid(%d,%d)\n", computeid, col); colid = dbaltcolid(dbproc, computeid, col); /* * The pad character is pointed to by dbopts[DBPRPAD].param. If that pointer * is NULL -- meaning padding is turned off -- dbstring_getchar returns -1. */ while (selcol < colid) { for (i = 0; i < col_printlens[selcol - 1]; i++) { if ((c = dbstring_getchar(dbproc->dbopts[DBPRPAD].param, 0)) >= 0) putchar(c); } selcol++; i = 0; while ((c = dbstring_getchar(dbproc->dbopts[DBPRCOLSEP].param, i++)) != -1) { putchar(c); } } op = dbaltop(dbproc, computeid, col); opname = dbprtype(op); printf("%s", opname); for (i = 0; i < ((long) col_printlens[selcol - 1] - (long) strlen(opname)); i++) { if ((c = dbstring_getchar(dbproc->dbopts[DBPRPAD].param, 0)) >= 0) putchar(c); } selcol++; if ((colid + 1) < num_cols) { i = 0; while ((c = dbstring_getchar(dbproc->dbopts[DBPRCOLSEP].param, i++)) != -1) { putchar(c); } } } i = 0; while ((c = dbstring_getchar(dbproc->dbopts[DBPRLINESEP].param, i++)) != -1) { putchar(c); } for (selcol = col = 1; col <= num_cols; col++) { tdsdump_log(TDS_DBG_FUNC, "dbprrow calling dbaltcolid(%d,%d)\n", computeid, col); colid = dbaltcolid(dbproc, computeid, col); while (selcol < colid) { for (i = 0; i < col_printlens[selcol - 1]; i++) { putchar(' '); } selcol++; i = 0; while ((c = dbstring_getchar(dbproc->dbopts[DBPRCOLSEP].param, i++)) != -1) { putchar(c); } } if (resinfo->by_cols > 0) { linechar = '-'; } else { linechar = '='; } for (i = 0; i < col_printlens[colid - 1]; i++) putchar(linechar); selcol++; if ((colid + 1) < num_cols) { i = 0; while ((c = dbstring_getchar(dbproc->dbopts[DBPRCOLSEP].param, i++)) != -1) { putchar(c); } } } i = 0; while ((c = dbstring_getchar(dbproc->dbopts[DBPRLINESEP].param, i++)) != -1) { putchar(c); } for (selcol = col = 1; col <= num_cols; col++) { colinfo = resinfo->columns[col - 1]; desttype = dblib_bound_type(STRINGBIND); srctype = dbalttype(dbproc, computeid, col); if (is_datetime_type(srctype)) { tds_datecrack(srctype, dbadata(dbproc, computeid, col), &when); len = (int)tds_strftime(dest, sizeof(dest), STD_DATETIME_FMT, &when, 3); } else { len = dbconvert(dbproc, srctype, dbadata(dbproc, computeid, col), -1, desttype, (BYTE *) dest, sizeof(dest)); } tdsdump_log(TDS_DBG_FUNC, "dbprrow calling dbaltcolid(%d,%d)\n", computeid, col); colid = dbaltcolid(dbproc, computeid, col); tdsdump_log(TDS_DBG_FUNC, "dbprrow select column = %d\n", colid); while (selcol < colid) { for (i = 0; i < col_printlens[selcol - 1]; i++) { putchar(' '); } selcol++; i = 0; while ((c = dbstring_getchar(dbproc->dbopts[DBPRCOLSEP].param, i++)) != -1) { putchar(c); } } printf("%.*s", len, dest); collen = _get_printable_size(colinfo); namlen = tds_dstr_len(&colinfo->column_name); padlen = (collen > namlen ? collen : namlen) - len; if ((c = dbstring_getchar(dbproc->dbopts[DBPRPAD].param, 0)) == -1) { c = ' '; } for (; padlen > 0; padlen--) { putchar(c); } selcol++; if ((colid + 1) < num_cols) { i = 0; while ((c = dbstring_getchar(dbproc->dbopts[DBPRCOLSEP].param, i++)) != -1) { putchar(c); } } } i = 0; while ((c = dbstring_getchar(dbproc->dbopts[DBPRLINESEP].param, i++)) != -1) { putchar(c); } } } free(col_printlens); return SUCCEED; } static int _get_printable_size(TDSCOLUMN * colinfo) { switch (tds_get_conversion_type(colinfo->column_type, colinfo->column_size)) { case SYBINT1: return 3; case SYBINT2: return 6; case SYBINT4: return 11; case SYBINT8: return 21; case SYBVARCHAR: case SYBCHAR: case SYBTEXT: case SYBNTEXT: case SYBNVARCHAR: case SYBLONGCHAR: return colinfo->column_size; case SYBBINARY: case SYBIMAGE: case SYBLONGBINARY: case SYBVARBINARY: return colinfo->column_size * 2u; case SYBFLT8: case SYBREAL: return 11; /* FIX ME -- we do not track precision */ case SYBMONEY: case SYBMONEY4: return 12; case SYB5BIGDATETIME: case SYBDATETIME: case SYBDATETIME4: return 26; case SYBTIME: case SYB5BIGTIME: return 15; case SYBDATE: return 10; case SYBUNIQUE: return 36; case SYBBIT: return 1; /* FIX ME -- not all types present */ default: return 0; } } /** * \ingroup dblib_core * \brief Get formatted string for underlining dbsprhead() column names. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param buffer output buffer * \param buf_len size of \a buffer * \param line_char character to use to represent underlining. * \retval SUCCEED \a buffer filled. * \retval FAIL insufficient space in \a buffer, usually. * \sa dbprhead(), dbprrow(), dbspr1row(), dbspr1rowlen(), dbsprhead(). */ RETCODE dbsprline(DBPROCESS * dbproc, char *buffer, DBINT buf_len, DBCHAR line_char) { TDSCOLUMN *colinfo; TDSRESULTINFO *resinfo; TDSSOCKET *tds; int i, col, len, collen, namlen; int c; tdsdump_log(TDS_DBG_FUNC, "dbsprline(%p, %s, %d, '%c')\n", dbproc, buffer, buf_len, line_char); CHECK_CONN(FAIL); CHECK_NULP(buffer, "dbsprline", 2, FAIL); tds = dbproc->tds_socket; resinfo = tds->res_info; for (col = 0; col < resinfo->num_cols; col++) { colinfo = resinfo->columns[col]; collen = _get_printable_size(colinfo); namlen = tds_dstr_len(&colinfo->column_name); len = collen > namlen ? collen : namlen; for (i = 0; i < len; i++) { if (buf_len < 1) { return FAIL; } *buffer++ = line_char; buf_len--; } if ((col + 1) < resinfo->num_cols) { i = 0; while ((c = dbstring_getchar(dbproc->dbopts[DBPRCOLSEP].param, i)) != -1) { if (buf_len < 1) { return FAIL; } *buffer++ = c; buf_len--; i++; } } } if (buf_len < 1) { return FAIL; } *buffer = '\0'; return SUCCEED; } /** * \ingroup dblib_core * \brief Print result set headings to a buffer. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param buffer output buffer * \param buf_len size of \a buffer * \retval SUCCEED \a buffer filled. * \retval FAIL insufficient spaace in \a buffer, usually. * \sa dbprhead(), dbprrow(), dbsetopt(), dbspr1row(), dbspr1rowlen(), dbsprline(). */ RETCODE dbsprhead(DBPROCESS * dbproc, char *buffer, DBINT buf_len) { TDSCOLUMN *colinfo; TDSRESULTINFO *resinfo; TDSSOCKET *tds; int i, col, collen, namlen; int padlen; int c; tdsdump_log(TDS_DBG_FUNC, "dbsprhead(%p, %p, %d)\n", dbproc, buffer, buf_len); CHECK_CONN(FAIL); CHECK_NULP(buffer, "dbsprhead", 2, FAIL); tds = dbproc->tds_socket; resinfo = tds->res_info; for (col = 0; col < resinfo->num_cols; col++) { colinfo = resinfo->columns[col]; collen = _get_printable_size(colinfo); namlen = tds_dstr_len(&colinfo->column_name); padlen = (collen > namlen ? collen : namlen) - namlen; if (buf_len < namlen) { return FAIL; } memcpy(buffer, tds_dstr_cstr(&colinfo->column_name), namlen); buffer += namlen; buf_len -= namlen; if ((c = dbstring_getchar(dbproc->dbopts[DBPRPAD].param, 0)) == -1) { c = ' '; } for (; padlen > 0; padlen--) { if (buf_len < 1) { return FAIL; } *buffer++ = c; buf_len--; } if ((col + 1) < resinfo->num_cols) { i = 0; while ((c = dbstring_getchar(dbproc->dbopts[DBPRCOLSEP].param, i)) != -1) { if (buf_len < 1) { return FAIL; } *buffer++ = c; buf_len--; i++; } } } if (buf_len < 1) { return FAIL; } *buffer = '\0'; return SUCCEED; } /** * \ingroup dblib_core * \brief Print result set headings to stdout. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \sa */ void dbprhead(DBPROCESS * dbproc) { TDSCOLUMN *colinfo; TDSRESULTINFO *resinfo; TDSSOCKET *tds; int i, col, len, collen, namlen; int padlen; int c; tdsdump_log(TDS_DBG_FUNC, "dbprhead(%p)\n", dbproc); CHECK_PARAMETER(dbproc, SYBENULL, ); tds = dbproc->tds_socket; resinfo = tds->res_info; if (resinfo == NULL) { return; } for (col = 0; col < resinfo->num_cols; col++) { colinfo = resinfo->columns[col]; collen = _get_printable_size(colinfo); namlen = tds_dstr_len(&colinfo->column_name); padlen = (collen > namlen ? collen : namlen) - namlen; printf("%s", tds_dstr_cstr(&colinfo->column_name)); c = dbstring_getchar(dbproc->dbopts[DBPRPAD].param, 0); if (c == -1) { c = ' '; } for (; padlen > 0; padlen--) { putchar(c); } if ((col + 1) < resinfo->num_cols) { i = 0; while ((c = dbstring_getchar(dbproc->dbopts[DBPRCOLSEP].param, i)) != -1) { putchar(c); i++; } } } i = 0; while ((c = dbstring_getchar(dbproc->dbopts[DBPRLINESEP].param, i)) != -1) { putchar(c); i++; } for (col = 0; col < resinfo->num_cols; col++) { colinfo = resinfo->columns[col]; collen = _get_printable_size(colinfo); namlen = tds_dstr_len(&colinfo->column_name); len = collen > namlen ? collen : namlen; for (i = 0; i < len; i++) putchar('-'); if ((col + 1) < resinfo->num_cols) { i = 0; while ((c = dbstring_getchar(dbproc->dbopts[DBPRCOLSEP].param, i)) != -1) { putchar(c); i++; } } } i = 0; while ((c = dbstring_getchar(dbproc->dbopts[DBPRLINESEP].param, i)) != -1) { putchar(c); i++; } } /** \internal * \ingroup dblib_internal * \brief Indicate whether a query returned rows. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \sa DBROWS(), DBCMDROW(), dbnextrow(), dbresults(), DBROWTYPE(). */ RETCODE dbrows(DBPROCESS * dbproc) { TDSSOCKET *tds; tdsdump_log(TDS_DBG_FUNC, "dbrows(%p)\n", dbproc); CHECK_CONN(FAIL); if (!(tds=dbproc->tds_socket)) return FAIL; return (tds->res_info && tds->res_info->rows_exist)? SUCCEED : FAIL; } #if defined(DBLIB_UNIMPLEMENTED) /** * \ingroup dblib_core * \brief Set the default character set for an application. * * \param language ASCII null-terminated string. * \sa dbsetdeflang(), dbsetdefcharset(), dblogin(), dbopen(). * \retval SUCCEED Always. * \todo Unimplemented. */ RETCODE dbsetdeflang(char *language) { tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED dbsetdeflang(%s)\n", language); CHECK_PARAMETER_NOPROC(language, SYBENULP); return SUCCEED; } #endif /** * \ingroup dblib_core * \brief Get TDS packet size for the connection. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \return TDS packet size, in bytes. * \sa DBSETLPACKET() */ int dbgetpacket(DBPROCESS * dbproc) { TDSSOCKET *tds; tdsdump_log(TDS_DBG_FUNC, "dbgetpacket(%p)\n", dbproc); CHECK_PARAMETER(dbproc, SYBENULL, TDS_DEF_BLKSZ); tds = dbproc->tds_socket; if (!tds) { return TDS_DEF_BLKSZ; } else { return tds->conn->env.block_size; } } /** * \ingroup dblib_core * \brief Set maximum simultaneous connections db-lib will open to the server. * * \param maxprocs Limit for process. * \retval SUCCEED Always. * \sa dbgetmaxprocs(), dbopen() */ RETCODE dbsetmaxprocs(int maxprocs) { int i, j; TDSSOCKET **old_list; tdsdump_log(TDS_DBG_FUNC, "UNTESTED dbsetmaxprocs(%d)\n", maxprocs); /* not too few elements */ if (maxprocs <= 0) return FAIL; tds_mutex_lock(&dblib_mutex); old_list = g_dblib_ctx.connection_list; /* "compress" array */ for (i = 0; i < g_dblib_ctx.connection_list_size; ++i) { /* if empty replace with first no-empty */ if (old_list[i]) continue; for (j = i + 1; j < g_dblib_ctx.connection_list_size; ++j) if (old_list[j]) { old_list[i] = old_list[j]; old_list[j] = NULL; break; } if (j >= g_dblib_ctx.connection_list_size) break; } /* do not restrict too much, i here contains minimun size */ if (maxprocs < i) maxprocs = i; /* * Don't reallocate less memory. * If maxprocs is less than was initially allocated, just reduce the represented list size. * If larger, reallocate and copy. * We probably should check for valid connections beyond the new max. */ if (maxprocs <= g_dblib_ctx.connection_list_size) { g_dblib_ctx.connection_list_size_represented = maxprocs; tds_mutex_unlock(&dblib_mutex); return SUCCEED; } g_dblib_ctx.connection_list = tds_new0(TDSSOCKET *, maxprocs); if (g_dblib_ctx.connection_list == NULL) { g_dblib_ctx.connection_list = old_list; tds_mutex_unlock(&dblib_mutex); dbperror(NULL, SYBEMEM, errno); return FAIL; } for (i = 0; i < g_dblib_ctx.connection_list_size; i++) { g_dblib_ctx.connection_list[i] = old_list[i]; } g_dblib_ctx.connection_list_size = maxprocs; g_dblib_ctx.connection_list_size_represented = maxprocs; tds_mutex_unlock(&dblib_mutex); return SUCCEED; } /** * \ingroup dblib_core * \brief get maximum simultaneous connections db-lib will open to the server. * * \return Current maximum. * \sa dbsetmaxprocs(), dbopen() */ int dbgetmaxprocs(void) { int r; tdsdump_log(TDS_DBG_FUNC, "dbgetmaxprocs(void)\n"); tds_mutex_lock(&dblib_mutex); r = g_dblib_ctx.connection_list_size_represented; tds_mutex_unlock(&dblib_mutex); return r; } /** * \ingroup dblib_core * \brief Set maximum seconds db-lib waits for a server response to query. * * \param seconds New limit for application. * \retval SUCCEED Always. * \sa dberrhandle(), DBGETTIME(), dbsetlogintime(), dbsqlexec(), dbsqlok(), dbsqlsend(). */ RETCODE dbsettime(int seconds) { TDSSOCKET **tds; int i; DBPROCESS *dbproc; tdsdump_log(TDS_DBG_FUNC, "dbsettime(%d)\n", seconds); tds_mutex_lock(&dblib_mutex); g_dblib_ctx.query_timeout = seconds; tds = g_dblib_ctx.connection_list; for (i = 0; i < TDS_MAX_CONN; i++) { if (tds[i]) { dbproc = (DBPROCESS *) tds_get_parent(tds[i]); if (!dbisopt(dbproc, DBSETTIME, 0)) tds[i]->query_timeout = seconds; } } tds_mutex_unlock(&dblib_mutex); return SUCCEED; } /** * \ingroup dblib_core * \brief Get maximum seconds db-lib waits for a server response to query. * * \retval query timeout limit, in seconds * \sa dberrhandle(), DBSETTIME(), dbsetlogintime(), dbsqlexec(), dbsqlok(), dbsqlsend(). */ int dbgettime(void) { tdsdump_log(TDS_DBG_FUNC, "dbgettime()\n"); return g_dblib_ctx.query_timeout; } /** * \ingroup dblib_core * \brief Set maximum seconds db-lib waits for a server response to a login attempt. * * \param seconds New limit for application. * \retval SUCCEED Always. * \sa dberrhandle(), dbsettime() */ RETCODE dbsetlogintime(int seconds) { tdsdump_log(TDS_DBG_FUNC, "dbsetlogintime(%d)\n", seconds); tds_mutex_lock(&dblib_mutex); g_dblib_ctx.login_timeout = seconds; tds_mutex_unlock(&dblib_mutex); return SUCCEED; } /** \internal * \ingroup dblib_internal * \brief See if the current command can return rows. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \retval SUCCEED Yes, it can. * \retval FAIL No, it can't. * \remarks Use DBCMDROW() macro instead. * \sa DBCMDROW(), dbnextrow(), dbresults(), DBROWS(), DBROWTYPE(). */ RETCODE dbcmdrow(DBPROCESS * dbproc) { TDSSOCKET *tds; tdsdump_log(TDS_DBG_FUNC, "dbcmdrow(%p)\n", dbproc); CHECK_CONN(FAIL); tds = dbproc->tds_socket; if (tds->res_info) return SUCCEED; return FAIL; } /** * \ingroup dblib_core * \brief Get column ID of a compute column. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param computeid of \c COMPUTE clause to which we're referring. * \param column Nth column in \a computeid, starting from 1. * \return Nth column in the base result set, on which \a column was computed. * \sa dbadata(), dbadlen(), dbaltlen(), dbgetrow(), dbnextrow(), dbnumalts(), dbprtype(). */ int dbaltcolid(DBPROCESS * dbproc, int computeid, int column) { TDSCOLUMN *curcol; tdsdump_log(TDS_DBG_FUNC, "dbaltcolid(%p, %d, %d)\n", dbproc, computeid, column); CHECK_PARAMETER(dbproc, SYBENULL, -1); curcol = dbacolptr(dbproc, computeid, column, 0); if (!curcol) return -1; return curcol->column_operand; } /** * \ingroup dblib_core * \brief Get size of data in a compute column. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param computeid of \c COMPUTE clause to which we're referring. * \param column Nth column in \a computeid, starting from 1. * \return size of the data, in bytes. * \retval -1 no such \a column or \a computeid. * \retval 0 data are NULL. * \sa dbadata(), dbaltlen(), dbalttype(), dbgetrow(), dbnextrow(), dbnumalts(). */ DBINT dbadlen(DBPROCESS * dbproc, int computeid, int column) { TDSCOLUMN *colinfo; DBINT len; tdsdump_log(TDS_DBG_FUNC, "dbadlen(%p, %d, %d)\n", dbproc, computeid, column); CHECK_PARAMETER(dbproc, SYBENULL, -1); colinfo = dbacolptr(dbproc, computeid, column, 0); if (!colinfo) return -1; len = colinfo->column_cur_size < 0? 0 : colinfo->column_cur_size; tdsdump_log(TDS_DBG_FUNC, "leaving dbadlen() type = %d, returning %d\n", colinfo->column_type, len); return len; } /** * \ingroup dblib_core * \brief Get datatype for a compute column. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param computeid of \c COMPUTE clause to which we're referring. * \param column Nth column in \a computeid, starting from 1. * \return \c SYB* dataype token. * \retval -1 no such \a column or \a computeid. * \sa dbadata(), dbadlen(), dbaltlen(), dbnextrow(), dbnumalts(), dbprtype(). */ int dbalttype(DBPROCESS * dbproc, int computeid, int column) { TDSCOLUMN *colinfo; tdsdump_log(TDS_DBG_FUNC, "dbalttype(%p, %d, %d)\n", dbproc, computeid, column); CHECK_PARAMETER(dbproc, SYBENULL, -1); colinfo = dbacolptr(dbproc, computeid, column, 0); if (!colinfo) return -1; switch (colinfo->column_type) { case SYBVARCHAR: return SYBCHAR; case SYBVARBINARY: return SYBBINARY; } return tds_get_conversion_type(colinfo->column_type, colinfo->column_size); } /** * \ingroup dblib_core * \brief Bind a compute column to a program variable. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param computeid of \c COMPUTE clause to which we're referring. * \param column Nth column in \a computeid, starting from 1. * \param vartype datatype of the host variable that will receive the data * \param varlen size of host variable pointed to \a varaddr * \param varaddr address of host variable * \retval SUCCEED everything worked. * \retval FAIL no such \a computeid or \a column, or no such conversion possible, or target buffer too small. * \sa dbadata(), dbaltbind_ps(), dbanullbind(), dbbind(), dbbind_ps(), dbconvert(), * dbconvert_ps(), dbnullbind(), dbsetnull(), dbsetversion(), dbwillconvert(). */ RETCODE dbaltbind(DBPROCESS * dbproc, int computeid, int column, int vartype, DBINT varlen, BYTE * varaddr) { TDS_SERVER_TYPE srctype, desttype; TDSCOLUMN *colinfo = NULL; tdsdump_log(TDS_DBG_FUNC, "dbaltbind(%p, %d, %d, %d, %d, %p)\n", dbproc, computeid, column, vartype, varlen, varaddr); CHECK_PARAMETER(dbproc, SYBENULL, FAIL); colinfo = dbacolptr(dbproc, computeid, column, 1); if (!colinfo) return FAIL; CHECK_PARAMETER(varaddr, SYBEABNV, FAIL); dbproc->avail_flag = FALSE; srctype = tds_get_conversion_type(colinfo->column_type, colinfo->column_size); desttype = dblib_bound_type(vartype); if (desttype == TDS_INVALID_TYPE) { dbperror(dbproc, SYBEBTYP, 0); return FAIL; } if (!dbwillconvert(srctype, desttype)) { dbperror(dbproc, SYBEAAMT, 0); return FAIL; } colinfo->column_varaddr = (char *) varaddr; colinfo->column_bindtype = vartype; colinfo->column_bindlen = varlen; return SUCCEED; } /** * \ingroup dblib_core * \brief Get address of compute column data. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param computeid of \c COMPUTE clause to which we're referring. * \param column Nth column in \a computeid, starting from 1. * \return pointer to columns's data buffer. * \retval NULL no such \a computeid or \a column. * \sa dbadlen(), dbaltbind(), dbaltlen(), dbalttype(), dbgetrow(), dbnextrow(), dbnumalts(). */ BYTE * dbadata(DBPROCESS * dbproc, int computeid, int column) { TDSCOLUMN *colinfo; tdsdump_log(TDS_DBG_FUNC, "dbadata(%p, %d, %d)\n", dbproc, computeid, column); CHECK_PARAMETER(dbproc, SYBENULL, 0); colinfo = dbacolptr(dbproc, computeid, column, 0); if (!colinfo) return NULL; if (is_blob_col(colinfo)) { return (BYTE *) ((TDSBLOB *) colinfo->column_data)->textvalue; } return (BYTE *) colinfo->column_data; } /** * \ingroup dblib_core * \brief Get aggregation operator for a compute column. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param computeid of \c COMPUTE clause to which we're referring. * \param column Nth column in \a computeid, starting from 1. * \return token value for the type of the compute column's aggregation operator. * \retval -1 no such \a computeid or \a column. * \sa dbadata(), dbadlen(), dbaltlen(), dbnextrow(), dbnumalts(), dbprtype(). */ int dbaltop(DBPROCESS * dbproc, int computeid, int column) { TDSCOLUMN *curcol; tdsdump_log(TDS_DBG_FUNC, "dbaltop(%p, %d, %d)\n", dbproc, computeid, column); CHECK_PARAMETER(dbproc, SYBENULL, -1); if ((curcol=dbacolptr(dbproc, computeid, column, 0)) == NULL) return -1; return curcol->column_operator; } /** * \ingroup dblib_core * \brief Set db-lib or server option. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param option option to set. * \param char_param value to set \a option to, if it wants a null-teminated ASCII string. * \param int_param value to set \a option to, if it wants an integer value. * \retval SUCCEED everything worked. * \retval FAIL no such \a option, or insufficient memory, or unimplemented. * \remarks Many are unimplemented. * \sa dbclropt(), dbisopt(). * \todo Implement more options. */ RETCODE dbsetopt(DBPROCESS * dbproc, int option, const char *char_param, int int_param) { char *cmd; RETCODE rc; int i; tdsdump_log(TDS_DBG_FUNC, "dbsetopt(%p, %d, %s, %d)\n", dbproc, option, char_param, int_param); CHECK_CONN(FAIL); CHECK_NULP(char_param, "dbsetopt", 3, FAIL); if ((option < 0) || (option >= DBNUMOPTIONS)) { dbperror(dbproc, SYBEUNOP, 0); return FAIL; } dbproc->dbopts[option].factive = 1; switch (option) { case DBARITHABORT: case DBARITHIGNORE: case DBCHAINXACTS: case DBFIPSFLAG: case DBISOLATION: case DBNOCOUNT: case DBNOEXEC: case DBPARSEONLY: case DBSHOWPLAN: case DBSTORPROCID: case DBQUOTEDIDENT: /* server options (on/off) */ if (asprintf(&cmd, "set %s on\n", dbproc->dbopts[option].text) < 0) { return FAIL; } rc = dbstring_concat(&(dbproc->dboptcmd), cmd); free(cmd); return rc; break; case DBNATLANG: case DBDATEFIRST: case DBDATEFORMAT: /* server options (char_param) */ if (asprintf(&cmd, "set %s %s\n", dbproc->dbopts[option].text, char_param) < 0) { return FAIL; } rc = dbstring_concat(&(dbproc->dboptcmd), cmd); free(cmd); return rc; break; case DBOFFSET: /* server option */ /* requires param * "select", "from", "table", "order", "compute", * "statement", "procedure", "execute", or "param" */ break; case DBROWCOUNT: /* server option */ /* requires param "0" to "2147483647" */ break; case DBSTAT: /* server option */ /* requires param "io" or "time" */ break; case DBTEXTLIMIT: /* dblib option */ /* requires param "0" to "2147483647" */ /* dblib do not return more than this length from text/image */ /* TODO required for PHP */ break; case DBTEXTSIZE: /* server option */ /* requires param "0" to "2147483647" */ /* limit text/image from network */ if (!char_param) char_param = "0"; i = atoi(char_param); if (i < 0 || i > 2147483647) return FAIL; if (asprintf(&cmd, "set textsize %d\n", i) < 0) return FAIL; rc = dbstring_concat(&(dbproc->dboptcmd), cmd); free(cmd); return rc; case DBAUTH: /* ??? */ break; case DBNOAUTOFREE: /* dblib option */ break; case DBBUFFER: /* * Requires param "2" to "2147483647" * (0 or 1 is an error, < 0 yields the default 100) */ { int nrows; /* 100 is the default, according to Microsoft */ if( !char_param ) char_param = "100"; nrows = atoi(char_param); nrows = (nrows < 0 )? 100 : nrows; if( 1 < nrows && nrows <= 2147483647 ) { buffer_set_capacity(dbproc, nrows); return SUCCEED; } } break; case DBPRCOLSEP: case DBPRLINELEN: case DBPRLINESEP: rc = dbstring_assign(&(dbproc->dbopts[option].param), char_param); return rc; case DBPRPAD: /* * "If the character is not specified, the ASCII space character is used." * A NULL pointer to the pad character signifies that padding is turned off. */ if (int_param) { rc = dbstring_assign(&(dbproc->dbopts[option].param), char_param? char_param : " "); } else { rc = dbstring_assign(&(dbproc->dbopts[option].param), NULL); } return rc; break; case DBSETTIME: if (char_param) { i = atoi(char_param); if (0 < i) { rc = dbstring_assign(&(dbproc->dbopts[option].param), char_param); if (rc == SUCCEED) { dbproc->tds_socket->query_timeout = i; } return rc; } } break; default: break; } tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED dbsetopt(option = %d)\n", option); return FAIL; } /** * \ingroup dblib_core * \brief Set interrupt handler for db-lib to use while blocked against a read from the server. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param chkintr * \param hndlintr * \sa dbcancel(), dbgetuserdata(), dbsetuserdata(), dbsetbusy(), dbsetidle(). */ void dbsetinterrupt(DBPROCESS * dbproc, DB_DBCHKINTR_FUNC chkintr, DB_DBHNDLINTR_FUNC hndlintr) { tdsdump_log(TDS_DBG_FUNC, "dbsetinterrupt(%p, %p, %p)\n", dbproc, chkintr, hndlintr); CHECK_PARAMETER(dbproc, SYBENULL, ); dbproc->chkintr = chkintr; dbproc->hndlintr = hndlintr; } /** * \ingroup dblib_rpc * \brief Determine if query generated a return status number. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \retval TRUE fetch return status with dbretstatus(). * \retval FALSE no return status. * \sa dbnextrow(), dbresults(), dbretdata(), dbretstatus(), dbrpcinit(), dbrpcparam(), dbrpcsend(). */ DBBOOL dbhasretstat(DBPROCESS * dbproc) { TDSSOCKET *tds; tdsdump_log(TDS_DBG_FUNC, "dbhasretstat(%p)\n", dbproc); CHECK_PARAMETER(dbproc, SYBENULL, FALSE); tds = dbproc->tds_socket; if (tds->has_status) { return TRUE; } else { return FALSE; } } /** * \ingroup dblib_rpc * \brief Fetch status value returned by query or remote procedure call. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \return return value * \sa dbhasretstat(), dbnextrow(), dbresults(), dbretdata(), dbrpcinit(), dbrpcparam(), dbrpcsend(). */ DBINT dbretstatus(DBPROCESS * dbproc) { tdsdump_log(TDS_DBG_FUNC, "dbretstatus(%p)\n", dbproc); CHECK_PARAMETER(dbproc, SYBENULL, 0); return dbproc->tds_socket->ret_status; } /** * \ingroup dblib_rpc * \brief Get count of output parameters filled by a stored procedure. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \return How many, possibly zero. * \remarks This name sounds funny. * \sa */ int dbnumrets(DBPROCESS * dbproc) { TDSSOCKET *tds; TDS_INT result_type; tdsdump_log(TDS_DBG_FUNC, "dbnumrets(%p)\n", dbproc); CHECK_PARAMETER(dbproc, SYBENULL, 0); tds = dbproc->tds_socket; tdsdump_log(TDS_DBG_FUNC, "dbnumrets() finds %d columns\n", (tds->param_info? tds->param_info->num_cols : 0)); /* try to fetch output parameters and return status, if we have not already done so */ if (!tds->param_info) tds_process_tokens(tds, &result_type, NULL, TDS_TOKEN_TRAILING); if (!tds->param_info) return 0; return tds->param_info->num_cols; } /** * \ingroup dblib_rpc * \brief Get name of an output parameter filled by a stored procedure. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param retnum Nth parameter between \c 1 and the return value from \c dbnumrets(). * \returns ASCII null-terminated string, \c NULL if no such \a retnum. * \sa dbnextrow(), dbnumrets(), dbresults(), dbretdata(), dbretlen(), dbrettype(), dbrpcinit(), dbrpcparam(). */ char * dbretname(DBPROCESS * dbproc, int retnum) { TDSPARAMINFO *param_info; tdsdump_log(TDS_DBG_FUNC, "dbretname(%p, %d)\n", dbproc, retnum); CHECK_PARAMETER(dbproc, SYBENULL, NULL); if (!dbproc->tds_socket) return NULL; dbnumrets(dbproc); param_info = dbproc->tds_socket->param_info; if (!param_info || !param_info->columns || retnum < 1 || retnum > param_info->num_cols) return NULL; return tds_dstr_buf(¶m_info->columns[retnum - 1]->column_name); } /** * \ingroup dblib_rpc * \brief Get value of an output parameter filled by a stored procedure. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param retnum Nth parameter between \c 1 and the return value from \c dbnumrets(). * \returns Address of a return parameter value, or \c NULL if no such \a retnum. * \sa dbnextrow(), dbnumrets(), dbresults(), dbretlen(), dbretname(), dbrettype(), dbrpcinit(), dbrpcparam(). * \todo Handle blobs. */ BYTE * dbretdata(DBPROCESS * dbproc, int retnum) { TDSPARAMINFO *param_info; tdsdump_log(TDS_DBG_FUNC, "dbretdata(%p, %d)\n", dbproc, retnum); CHECK_PARAMETER(dbproc, SYBENULL, NULL); dbnumrets(dbproc); param_info = dbproc->tds_socket->param_info; if (!param_info || !param_info->columns || retnum < 1 || retnum > param_info->num_cols) return NULL; return _dbcoldata(param_info->columns[retnum - 1]); } /** * \ingroup dblib_rpc * \brief Get size of an output parameter filled by a stored procedure. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param retnum Nth parameter between \c 1 and the return value from \c dbnumrets(). * \returns Size of a return parameter value, or \c NULL if no such \a retnum. * \sa dbnextrow(), dbnumrets(), dbresults(), dbretdata(), dbretname(), dbrettype(), dbrpcinit(), dbrpcparam(). */ int dbretlen(DBPROCESS * dbproc, int retnum) { TDSCOLUMN *column; TDSPARAMINFO *param_info; TDSSOCKET *tds; tdsdump_log(TDS_DBG_FUNC, "dbretlen(%p, %d)\n", dbproc, retnum); CHECK_PARAMETER(dbproc, SYBENULL, -1); dbnumrets(dbproc); tds = dbproc->tds_socket; param_info = tds->param_info; if (!param_info || !param_info->columns || retnum < 1 || retnum > param_info->num_cols) return -1; column = param_info->columns[retnum - 1]; if (column->column_cur_size < 0) return 0; return column->column_cur_size; } /** * \ingroup dblib_core * \brief Wait for results of a query from the server. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \retval SUCCEED everything worked, fetch results with \c dbnextresults(). * \retval FAIL SQL syntax error, typically. * \sa dbcmd(), dbfcmd(), DBIORDESC(), DBIOWDESC(), dbmoretext(), dbnextrow(), dbpoll(), DBRBUF(), dbresults(), dbretstatus(), dbrpcsend(), dbsettime(), dbsqlexec(), dbsqlsend(), dbwritetext(). */ RETCODE dbsqlok(DBPROCESS * dbproc) { TDSSOCKET *tds; TDS_INT result_type; RETCODE return_code = SUCCEED; prbuf_t prretbuf; tdsdump_log(TDS_DBG_FUNC, "dbsqlok(%p)\n", dbproc); CHECK_CONN(FAIL); tds = dbproc->tds_socket; /* * dbsqlok has been called after dbmoretext() * This is the trigger to send the text data. */ if (dbproc->text_sent) { tds_flush_packet(tds); dbproc->text_sent = 0; } /* * See what the next packet from the server is. * We want to skip any messages which are not processable. * We're looking for a result token or a done token. */ for (;;) { TDSRET tds_code; int done_flags = 0; /* * If we hit an end token -- e.g. if the command * submitted returned no data (like an insert) -- then * we process the end token to extract the status code. */ tdsdump_log(TDS_DBG_FUNC, "dbsqlok() not done, calling tds_process_tokens()\n"); tds_code = tds_process_tokens(tds, &result_type, &done_flags, TDS_TOKEN_RESULTS); /* * The error flag may be set for any intervening DONEINPROC packet, in particular * by a RAISERROR statement. Microsoft db-lib returns FAIL in that case. */ if (done_flags & TDS_DONE_ERROR) { return_code = FAIL; } switch (tds_code) { case TDS_NO_MORE_RESULTS: return SUCCEED; break; case TDS_SUCCESS: switch (result_type) { case TDS_ROWFMT_RESULT: buffer_free(&dbproc->row_buf); buffer_alloc(dbproc); case TDS_COMPUTEFMT_RESULT: dbproc->dbresults_state = _DB_RES_RESULTSET_EMPTY; case TDS_COMPUTE_RESULT: case TDS_ROW_RESULT: tdsdump_log(TDS_DBG_FUNC, "dbsqlok() found result token\n"); return SUCCEED; break; case TDS_DONEINPROC_RESULT: break; case TDS_DONE_RESULT: case TDS_DONEPROC_RESULT: tdsdump_log(TDS_DBG_FUNC, "dbsqlok() end status is %s\n", prdbretcode(return_code, prretbuf)); #if 1 if (done_flags & TDS_DONE_ERROR) { if (done_flags & TDS_DONE_MORE_RESULTS) { dbproc->dbresults_state = _DB_RES_NEXT_RESULT; } else { dbproc->dbresults_state = _DB_RES_NO_MORE_RESULTS; } } else { tdsdump_log(TDS_DBG_FUNC, "dbsqlok() end status was success\n"); dbproc->dbresults_state = _DB_RES_SUCCEED; } return return_code; break; #else int retcode = (done_flags & TDS_DONE_ERROR)? FAIL : SUCCEED; dbproc->dbresults_state = (done_flags & TDS_DONE_MORE_RESULTS)? _DB_RES_NEXT_RESULT : _DB_RES_NO_MORE_RESULTS; tdsdump_log(TDS_DBG_FUNC, "dbsqlok: returning %s with %s (%#x)\n", prdbretcode(retcode), prdbresults_state(dbproc->dbresults_state), done_flags); if (retcode == SUCCEED && (done_flags & TDS_DONE_MORE_RESULTS)) continue; return retcode; #endif default: tdsdump_log(TDS_DBG_FUNC, "%s %d: logic error: tds_process_tokens result_type %d\n", __FILE__, __LINE__, result_type); break; } break; default: assert(TDS_FAILED(tds_code)); return FAIL; break; } } return SUCCEED; } /** * \ingroup dblib_core * \brief Get count of columns in a compute row. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param computeid of \c COMPUTE clause to which we're referring. * \return number of columns, else -1 if no such \a computeid. * \sa dbadata(), dbadlen(), dbaltlen(), dbalttype(), dbgetrow(), dbnextrow(), dbnumcols(). */ int dbnumalts(DBPROCESS * dbproc, int computeid) { TDSSOCKET *tds; TDSCOMPUTEINFO *info; TDS_SMALLINT compute_id; int i; tdsdump_log(TDS_DBG_FUNC, "dbnumalts(%p, %d)\n", dbproc, computeid); CHECK_PARAMETER(dbproc, SYBENULL, -1); tds = dbproc->tds_socket; compute_id = computeid; for (i = 0;; ++i) { if (i >= tds->num_comp_info) return -1; info = tds->comp_info[i]; if (info->computeid == compute_id) break; } return info->num_cols; } /** * \ingroup dblib_core * \brief Get count of \c COMPUTE clauses for a result set. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \return number of compute clauses for the current query, possibly zero. * \sa dbnumalts(), dbresults(). */ int dbnumcompute(DBPROCESS * dbproc) { TDSSOCKET *tds; tdsdump_log(TDS_DBG_FUNC, "dbnumcompute(%p)\n", dbproc); CHECK_PARAMETER(dbproc, SYBENULL, -1); tds = dbproc->tds_socket; return tds->num_comp_info; } /** * \ingroup dblib_core * \brief Get \c bylist for a compute row. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param computeid of \c COMPUTE clause to which we're referring. * \param size \em output: size of \c bylist buffer whose address is returned, possibly zero. * \return address of \c bylist for \a computeid. * \retval NULL no such \a computeid. * \remarks Do not free returned pointer. * \sa dbadata(), dbadlen(), dbaltlen(), dbalttype(), dbcolname(), dbgetrow(), dbnextrow(). */ BYTE * dbbylist(DBPROCESS * dbproc, int computeid, int *size) { TDSSOCKET *tds; TDSCOMPUTEINFO *info; int i; const TDS_SMALLINT byte_flag = -0x8000; tdsdump_log(TDS_DBG_FUNC, "dbbylist(%p, %d, %p)\n", dbproc, computeid, size); CHECK_PARAMETER(dbproc, SYBENULL, NULL); tds = dbproc->tds_socket; for (i = 0;; ++i) { if (i >= tds->num_comp_info) { if (size) *size = 0; return NULL; } info = tds->comp_info[i]; if (info->computeid == computeid) break; } if (size) *size = info->by_cols; /* * libtds stores this information using TDS_SMALLINT so we * have to convert it. We can do this because libtds just * stores these data. */ if (info->by_cols > 0 && info->bycolumns[0] != byte_flag) { int n; TDS_TINYINT *p = (TDS_TINYINT*) malloc(sizeof(info->bycolumns[0]) + info->by_cols); if (!p) { dbperror(dbproc, SYBEMEM, errno); return NULL; } for (n = 0; n < info->by_cols; ++n) p[sizeof(info->bycolumns[0]) + n] = info->bycolumns[n] > 255 ? 255 : info->bycolumns[n]; *((TDS_SMALLINT *)p) = byte_flag; free(info->bycolumns); info->bycolumns = (TDS_SMALLINT *) p; } return (BYTE *) (&info->bycolumns[1]); } /** \internal * \ingroup dblib_internal * \brief Check if \a dbproc is an ex-parrot. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \retval TRUE process has been marked \em dead. * \retval FALSE process is OK. * \remarks dbdead() does not communicate with the server. * Unless a previously db-lib marked \a dbproc \em dead, dbdead() returns \c FALSE. * \sa dberrhandle(). */ DBBOOL dbdead(DBPROCESS * dbproc) { tdsdump_log(TDS_DBG_FUNC, "dbdead(%p) [%s]\n", dbproc, dbproc? IS_TDSDEAD(dbproc->tds_socket)? "dead":"alive" : "quite dead"); if( NULL == dbproc ) return TRUE; if (IS_TDSDEAD(dbproc->tds_socket)) return TRUE; else return FALSE; } /** \internal * \ingroup dblib_internal * \brief default error handler for db-lib (handles library-generated errors) * * The default error handler doesn't print anything. If you want to see your messages printed, * install an error handler. If you think that should be an optional compile- or run-time default, * submit a patch. It could be done. * * \sa DBDEAD(), dberrhandle(). */ /* Thus saith Sybase: * "If the user does not supply an error handler (or passes a NULL pointer to * dberrhandle), DB-Library will exhibit its default error-handling * behavior: It will abort the program if the error has made the affected * DBPROCESS unusable (the user can call DBDEAD to determine whether * or not a DBPROCESS has become unusable). If the error has not made the * DBPROCESS unusable, DB-Library will simply return an error code to its caller." * * It is not the error handler, however, that aborts anything. It is db-lib, cf. dbperror(). */ static int default_err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr) { tdsdump_log(TDS_DBG_FUNC, "default_err_handler %p, %d, %d, %d, %p, %p", dbproc, severity, dberr, oserr, dberrstr, oserrstr); if (DBDEAD(dbproc) && (!dbproc || !dbproc->msdblib)) { return INT_EXIT; } if (!dbproc || !dbproc->msdblib) { /* i.e. Sybase behavior */ switch(dberr) { case SYBETIME: return INT_EXIT; default: break; } } return INT_CANCEL; } /** * \ingroup dblib_core * \brief Set an error handler, for messages from db-lib. * * \param handler pointer to callback function that will handle errors. * Pass NULL to restore the default handler. * \return address of prior handler, or NULL if none was previously installed. * \sa DBDEAD(), dbmsghandle(). */ EHANDLEFUNC dberrhandle(EHANDLEFUNC handler) { EHANDLEFUNC old_handler = _dblib_err_handler; tdsdump_log(TDS_DBG_FUNC, "dberrhandle(%p)\n", handler); _dblib_err_handler = handler? handler : default_err_handler; return (old_handler == default_err_handler)? NULL : old_handler; } /** * \ingroup dblib_core * \brief Set a message handler, for messages from the server. * * \param handler address of the function that will process the messages. * \sa DBDEAD(), dberrhandle(). */ MHANDLEFUNC dbmsghandle(MHANDLEFUNC handler) { MHANDLEFUNC retFun = _dblib_msg_handler; tdsdump_log(TDS_DBG_FUNC, "dbmsghandle(%p)\n", handler); _dblib_msg_handler = handler; return retFun; } #if defined(DBLIB_UNIMPLEMENTED) /** * \ingroup dblib_money * \brief Add two DBMONEY values. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param m1 first operand. * \param m2 other operand. * \param sum \em output: result of computation. * \retval SUCCEED Always. * \sa dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus(). * \todo Unimplemented. */ RETCODE dbmnyadd(DBPROCESS * dbproc, DBMONEY * m1, DBMONEY * m2, DBMONEY * sum) { tdsdump_log(TDS_DBG_FUNC, "dbmnyadd(%p, %p, %p, %p)\n", dbproc, m1, m2, sum); CHECK_CONN(FAIL); CHECK_NULP(m1, "dbmnyadd", 2, FAIL); CHECK_NULP(m2, "dbmnyadd", 3, FAIL); CHECK_NULP(sum, "dbmnyadd", 4, FAIL); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED dbmnyadd()\n"); return SUCCEED; } /** * \ingroup dblib_money * \brief Subtract two DBMONEY values. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param m1 first operand. * \param m2 other operand, subtracted from \a m1. * \param difference \em output: result of computation. * \retval SUCCEED Always. * \sa dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus(). * \todo Unimplemented. */ RETCODE dbmnysub(DBPROCESS * dbproc, DBMONEY * m1, DBMONEY * m2, DBMONEY * difference) { tdsdump_log(TDS_DBG_FUNC, "dbmnysub(%p, %p, %p, %p)\n", dbproc, m1, m2, difference); CHECK_CONN(FAIL); CHECK_NULP(m1, "dbmnysub", 2, FAIL); CHECK_NULP(m2, "dbmnysub", 3, FAIL); CHECK_NULP(difference, "dbmnysub", 4, FAIL); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED dbmnysyb()\n"); return SUCCEED; } /** * \ingroup dblib_money * \brief Multiply two DBMONEY values. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param m1 first operand. * \param m2 other operand. * \param prod \em output: result of computation. * \retval SUCCEED Always. * \sa dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus(). * \todo Unimplemented. */ RETCODE dbmnymul(DBPROCESS * dbproc, DBMONEY * m1, DBMONEY * m2, DBMONEY * prod) { tdsdump_log(TDS_DBG_FUNC, "dbmnymul(%p, %p, %p, %p)\n", dbproc, m1, m2, prod); CHECK_CONN(FAIL); CHECK_NULP(m1, "dbmnymul", 2, FAIL); CHECK_NULP(m2, "dbmnymul", 3, FAIL); CHECK_NULP(prod, "dbmnymul", 4, FAIL); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED dbmnymul()\n"); return SUCCEED; } /** * \ingroup dblib_money * \brief Divide two DBMONEY values. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param m1 dividend. * \param m2 divisor. * \param quotient \em output: result of computation. * \retval SUCCEED Always. * \sa dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus(). * \todo Unimplemented. */ RETCODE dbmnydivide(DBPROCESS * dbproc, DBMONEY * m1, DBMONEY * m2, DBMONEY * quotient) { tdsdump_log(TDS_DBG_FUNC, "dbmnydivide(%p, %p, %p, %p)\n", dbproc, m1, m2, quotient); CHECK_CONN(FAIL); CHECK_NULP(m1, "dbmnydivide", 2, FAIL); CHECK_NULP(m2, "dbmnydivide", 3, FAIL); CHECK_NULP(quotient, "dbmnydivide", 4, FAIL); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED dbmnydivide()\n"); return SUCCEED; } #endif /** * \ingroup dblib_money * \brief Compare two DBMONEY values. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param m1 some money. * \param m2 some other money. * \retval 0 m1 == m2. * \retval -1 m1 < m2. * \retval 1 m1 > m2. * \sa dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus(). */ int dbmnycmp(DBPROCESS * dbproc, DBMONEY * m1, DBMONEY * m2) { tdsdump_log(TDS_DBG_FUNC, "dbmnycmp(%p, %p, %p)\n", dbproc, m1, m2); CHECK_PARAMETER(dbproc, SYBENULL, 0); CHECK_NULP(m1, "dbmnycmp", 2, 0); CHECK_NULP(m2, "dbmnycmp", 3, 0); if (m1->mnyhigh < m2->mnyhigh) { return -1; } if (m1->mnyhigh > m2->mnyhigh) { return 1; } if (m1->mnylow < m2->mnylow) { return -1; } if (m1->mnylow > m2->mnylow) { return 1; } return 0; } #if defined(DBLIB_UNIMPLEMENTED) /** * \ingroup dblib_money * \brief Multiply a DBMONEY value by a positive integer, and add an amount. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param amount starting amount of money, also holds output. * \param multiplier amount to multiply \a amount by. * \param addend amount to add to \a amount, after multiplying by \a multiplier. * \retval SUCCEED Always. * \remarks This function is goofy. * \sa dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus(). * \todo Unimplemented. */ RETCODE dbmnyscale(DBPROCESS * dbproc, DBMONEY * amount, int multiplier, int addend) { tdsdump_log(TDS_DBG_FUNC, "dbmnyscale(%p, %p, %d, %d)\n", dbproc, amount, multiplier, addend); CHECK_CONN(FAIL); CHECK_NULP(amount, "dbmnyscale", 2, FAIL); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED dbmnyscale()\n"); return SUCCEED; } #endif /** * \ingroup dblib_money * \brief Set a DBMONEY value to zero. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param dest address of a DBMONEY structure. * \retval SUCCEED unless \a amount is NULL. * \sa dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus(). */ RETCODE dbmnyzero(DBPROCESS * dbproc, DBMONEY * dest) { tdsdump_log(TDS_DBG_FUNC, "dbmnyzero(%p, %p)\n", dbproc, dest); CHECK_CONN(FAIL); CHECK_NULP(dest, "dbmnyzero", 2, FAIL); dest->mnylow = 0; dest->mnyhigh = 0; return SUCCEED; } /** * \ingroup dblib_money * \brief Get maximum positive DBMONEY value supported. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param amount address of a DBMONEY structure. * \retval SUCCEED Always. * \sa dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus(). */ RETCODE dbmnymaxpos(DBPROCESS * dbproc, DBMONEY * amount) { tdsdump_log(TDS_DBG_FUNC, "dbmnymaxpos(%p, %p)\n", dbproc, amount); CHECK_CONN(FAIL); CHECK_NULP(amount, "dbmnymaxpos", 2, FAIL); amount->mnylow = 0xFFFFFFFFlu; amount->mnyhigh = 0x7FFFFFFFl; return SUCCEED; } /** * \ingroup dblib_money * \brief Get maximum negative DBMONEY value supported. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param amount address of a DBMONEY structure. * \retval SUCCEED Always. * \sa dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus(). */ RETCODE dbmnymaxneg(DBPROCESS * dbproc, DBMONEY * amount) { tdsdump_log(TDS_DBG_FUNC, "dbmnymaxneg(%p, %p)\n", dbproc, amount); CHECK_CONN(FAIL); CHECK_NULP(amount, "dbmnymaxneg", 2, FAIL); amount->mnylow = 0; amount->mnyhigh = -0x80000000l; return SUCCEED; } #if defined(DBLIB_UNIMPLEMENTED) /** * \ingroup dblib_money * \brief Get the least significant digit of a DBMONEY value, represented as a character. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param mnyptr \em input the money amount, \em and \em output: \a mnyptr divided by 10. * \param digit the character value (between '0' and '9') of the rightmost digit in \a mnyptr. * \param zero \em output: \c TRUE if \a mnyptr is zero on output, else \c FALSE. * \retval SUCCEED Always. * \sa dbconvert(), dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus(). * \remarks Unimplemented and likely to remain so. We'd be amused to learn anyone wants this function. * \todo Unimplemented. */ RETCODE dbmnyndigit(DBPROCESS * dbproc, DBMONEY * mnyptr, DBCHAR * digit, DBBOOL * zero) { tdsdump_log(TDS_DBG_FUNC, "dbmnyndigit(%p, %p, %s, %p)\n", dbproc, mnyptr, digit, zero); CHECK_CONN(FAIL); CHECK_NULP(mnyptr, "dbmnyndigit", 2, FAIL); CHECK_NULP(digit, "dbmnyndigit", 3, FAIL); CHECK_NULP(zero, "dbmnyndigit", 4, FAIL); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED dbmnyndigit()\n"); return SUCCEED; } /** * \ingroup dblib_money * \brief Prepare a DBMONEY value for use with dbmnyndigit(). * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param amount address of a DBMONEY structure. * \param trim number of digits to trim from \a amount. * \param negative \em output: \c TRUE if \a amount < 0. * \retval SUCCEED Always. * \sa dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus(). * \todo Unimplemented. */ RETCODE dbmnyinit(DBPROCESS * dbproc, DBMONEY * amount, int trim, DBBOOL * negative) { tdsdump_log(TDS_DBG_FUNC, "dbmnyinit(%p, %p, %d, %p)\n", dbproc, amount, trim, negative); CHECK_CONN(FAIL); CHECK_NULP(amount, "dbmnyinit", 2, FAIL); CHECK_NULP(negative, "dbmnyinit", 4, FAIL); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED dbmnyinit()\n"); return SUCCEED; } /** * \ingroup dblib_money * \brief Divide a DBMONEY value by a positive integer. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param amount address of a DBMONEY structure. * \param divisor of \a amount. * \param remainder \em output: modulo of integer division. * \retval SUCCEED Always. * \sa dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus(). * \todo Unimplemented. */ RETCODE dbmnydown(DBPROCESS * dbproc, DBMONEY * amount, int divisor, int *remainder) { tdsdump_log(TDS_DBG_FUNC, "dbmnydown(%p, %p, %d, %p)\n", dbproc, amount, divisor, remainder); CHECK_CONN(FAIL); CHECK_NULP(amount, "dbmnydown", 2, FAIL); CHECK_NULP(remainder, "dbmnydown", 4, FAIL); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED dbmnydown()\n"); return SUCCEED; } #endif /** * \ingroup dblib_money * \brief Add $0.0001 to a DBMONEY value. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param amount address of a DBMONEY structure. * \retval SUCCEED or FAIL if overflow or amount NULL. * \sa dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus(). */ RETCODE dbmnyinc(DBPROCESS * dbproc, DBMONEY * amount) { tdsdump_log(TDS_DBG_FUNC, "dbmnyinc(%p, %p)\n", dbproc, amount); CHECK_CONN(FAIL); CHECK_NULP(amount, "dbmnyinc", 2, FAIL); if (amount->mnylow != 0xFFFFFFFFlu) { ++amount->mnylow; return SUCCEED; } if (amount->mnyhigh == 0x7FFFFFFFl) return FAIL; amount->mnylow = 0; ++amount->mnyhigh; return SUCCEED; } /** * \ingroup dblib_money * \brief Subtract $0.0001 from a DBMONEY value. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param amount address of a DBMONEY structure. * \retval SUCCEED or FAIL if overflow or amount NULL. * \sa dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus(). */ RETCODE dbmnydec(DBPROCESS * dbproc, DBMONEY * amount) { tdsdump_log(TDS_DBG_FUNC, "dbmnydec(%p, %p)\n", dbproc, amount); CHECK_CONN(FAIL); CHECK_NULP(amount, "dbmnydec", 2, FAIL); if (amount->mnylow != 0) { --amount->mnylow; return SUCCEED; } if (amount->mnyhigh == -0x80000000l) return FAIL; amount->mnylow = 0xFFFFFFFFlu; --amount->mnyhigh; return SUCCEED; } /** * \ingroup dblib_money * \brief Negate a DBMONEY value. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param src address of a DBMONEY structure. * \param dest \em output: result of negation. * \retval SUCCEED or FAIL if overflow or src/dest NULL. * \sa dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus(). */ RETCODE dbmnyminus(DBPROCESS * dbproc, DBMONEY * src, DBMONEY * dest) { tdsdump_log(TDS_DBG_FUNC, "dbmnyminus(%p, %p, %p)\n", dbproc, src, dest); CHECK_CONN(FAIL); CHECK_NULP(src, "dbmnyminus", 2, FAIL); CHECK_NULP(dest, "dbmnyminus", 3, FAIL); if (src->mnyhigh == -0x80000000l && src->mnylow == 0) return FAIL; dest->mnyhigh = -src->mnyhigh; dest->mnylow = (~src->mnylow) + 1u; return SUCCEED; } /** * \ingroup dblib_money * \brief Negate a DBMONEY4 value. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param src address of a DBMONEY4 structure. * \param dest \em output: result of negation. * \retval SUCCEED usually. * \retval FAIL on overflow. * \sa dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus(). */ RETCODE dbmny4minus(DBPROCESS * dbproc, DBMONEY4 * src, DBMONEY4 * dest) { DBMONEY4 zero; tdsdump_log(TDS_DBG_FUNC, "dbmny4minus(%p, %p, %p)\n", dbproc, src, dest); CHECK_CONN(FAIL); CHECK_NULP(src, "dbmny4minus", 2, FAIL); CHECK_NULP(dest, "dbmny4minus", 3, FAIL); dbmny4zero(dbproc, &zero); return (dbmny4sub(dbproc, &zero, src, dest)); } /** * \ingroup dblib_money * \brief Zero a DBMONEY4 value. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param dest address of a DBMONEY structure. * \retval SUCCEED usually. * \retval FAIL \a dest is NULL. * \sa dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus(). */ RETCODE dbmny4zero(DBPROCESS * dbproc, DBMONEY4 * dest) { tdsdump_log(TDS_DBG_FUNC, "dbmny4zero(%p, %p)\n", dbproc, dest); CHECK_CONN(FAIL); CHECK_NULP(dest, "dbmny4zero", 2, FAIL); dest->mny4 = 0; return SUCCEED; } /** * \ingroup dblib_money * \brief Add two DBMONEY4 values. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param m1 first operand. * \param m2 other operand. * \param sum \em output: result of computation. * \retval SUCCEED usually. * \retval FAIL on overflow. * \sa dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus(). */ RETCODE dbmny4add(DBPROCESS * dbproc, DBMONEY4 * m1, DBMONEY4 * m2, DBMONEY4 * sum) { tdsdump_log(TDS_DBG_FUNC, "dbmny4add(%p, %p, %p, %p)\n", dbproc, m1, m2, sum); CHECK_CONN(FAIL); CHECK_NULP(m1, "dbmny4add", 2, FAIL); CHECK_NULP(m2, "dbmny4add", 3, FAIL); CHECK_NULP(sum, "dbmny4add", 4, FAIL); sum->mny4 = m1->mny4 + m2->mny4; if (((m1->mny4 < 0) && (m2->mny4 < 0) && (sum->mny4 >= 0)) || ((m1->mny4 > 0) && (m2->mny4 > 0) && (sum->mny4 <= 0))) { /* overflow */ sum->mny4 = 0; return FAIL; } return SUCCEED; } /** * \ingroup dblib_money * \brief Subtract two DBMONEY4 values. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param m1 first operand. * \param m2 other operand, subtracted from \a m1. * \param diff \em output: result of computation. * \retval SUCCEED usually. * \retval FAIL on overflow. * \sa dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus(). */ RETCODE dbmny4sub(DBPROCESS * dbproc, DBMONEY4 * m1, DBMONEY4 * m2, DBMONEY4 * diff) { tdsdump_log(TDS_DBG_FUNC, "dbmny4sub(%p, %p, %p, %p)\n", dbproc, m1, m2, diff); CHECK_CONN(FAIL); CHECK_NULP(m1, "dbmny4sub", 2, FAIL); CHECK_NULP(m2, "dbmny4sub", 3, FAIL); CHECK_NULP(diff, "dbmny4sub", 4, FAIL); diff->mny4 = m1->mny4 - m2->mny4; if (((m1->mny4 <= 0) && (m2->mny4 > 0) && (diff->mny4 > 0)) || ((m1->mny4 >= 0) && (m2->mny4 < 0) && (diff->mny4 < 0))) { /* overflow */ diff->mny4 = 0; return FAIL; } return SUCCEED; } #if defined(DBLIB_UNIMPLEMENTED) /** * \ingroup dblib_money * \brief Multiply two DBMONEY4 values. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param m1 first operand. * \param m2 other operand. * \param prod \em output: result of computation. * \retval SUCCEED usually. * \retval FAIL a parameter is NULL. * \sa dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus(). * \todo Unimplemented. */ RETCODE dbmny4mul(DBPROCESS * dbproc, DBMONEY4 * m1, DBMONEY4 * m2, DBMONEY4 * prod) { tdsdump_log(TDS_DBG_FUNC, "dbmny4mul(%p, %p, %p, %p)\n", dbproc, m1, m2, prod); CHECK_CONN(FAIL); CHECK_NULP(m1, "dbmny4mul", 2, FAIL); CHECK_NULP(m2, "dbmny4mul", 3, FAIL); CHECK_NULP(prod, "dbmny4mul", 4, FAIL); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED dbmny4mul()\n"); return FAIL; } /** * \ingroup dblib_money * \brief Divide two DBMONEY4 values. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param m1 dividend. * \param m2 divisor. * \param quotient \em output: result of computation. * \retval SUCCEED usually. * \retval FAIL a parameter is NULL. * \sa dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus(). * \todo Unimplemented. */ RETCODE dbmny4divide(DBPROCESS * dbproc, DBMONEY4 * m1, DBMONEY4 * m2, DBMONEY4 * quotient) { tdsdump_log(TDS_DBG_FUNC, "dbmny4divide(%p, %p, %p, %p)\n", dbproc, m1, m2, quotient); CHECK_CONN(FAIL); CHECK_NULP(m1, "dbmny4divide", 2, FAIL); CHECK_NULP(m2, "dbmny4divide", 3, FAIL); CHECK_NULP(quotient, "dbmny4divide", 4, FAIL); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED dbmny4divide()\n"); return FAIL; } #endif /** * \ingroup dblib_money * \brief Compare two DBMONEY4 values. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param m1 some money. * \param m2 some other money. * \retval 0 m1 == m2. * \retval -1 m1 < m2. * \retval 1 m1 > m2. * \sa dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus(). */ int dbmny4cmp(DBPROCESS * dbproc, DBMONEY4 * m1, DBMONEY4 * m2) { tdsdump_log(TDS_DBG_FUNC, "dbmny4cmp(%p, %p, %p)\n", dbproc, m1, m2); CHECK_PARAMETER(dbproc, SYBENULL, 0); CHECK_NULP(m1, "dbmny4cmp", 2, 0); CHECK_NULP(m2, "dbmny4cmp", 3, 0); if (m1->mny4 < m2->mny4) { return -1; } if (m1->mny4 > m2->mny4) { return 1; } return 0; } /** * \ingroup dblib_money * \brief Copy a DBMONEY4 value. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param src address of a DBMONEY4 structure. * \param dest \em output: new money. * \retval SUCCEED or FAIL if src/dest NULL. * \sa dbmnycopy(), dbmnyminus(), dbmny4minus(). */ RETCODE dbmny4copy(DBPROCESS * dbproc, DBMONEY4 * src, DBMONEY4 * dest) { tdsdump_log(TDS_DBG_FUNC, "dbmny4copy(%p, %p, %p)\n", dbproc, src, dest); CHECK_CONN(FAIL); CHECK_NULP(src, "dbmny4copy", 2, FAIL); CHECK_NULP(dest, "dbmny4copy", 3, FAIL); dest->mny4 = src->mny4; return SUCCEED; } /** * \ingroup dblib_datetime * \brief Compare DBDATETIME values, similar to strcmp(3). * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param d1 a \c DBDATETIME structure address * \param d2 another \c DBDATETIME structure address * \retval 0 d1 = d2. * \retval -1 d1 < d2. * \retval 1 d1 > d2. * \sa dbdate4cmp(), dbmnycmp(), dbmny4cmp(). */ int dbdatecmp(DBPROCESS * dbproc, DBDATETIME * d1, DBDATETIME * d2) { tdsdump_log(TDS_DBG_FUNC, "dbdatecmp(%p, %p, %p)\n", dbproc, d1, d2); CHECK_CONN(FAIL); CHECK_NULP(d1, "dbdatecmp", 2, 0); CHECK_NULP(d2, "dbdatecmp", 3, 0); if (d1->dtdays == d2->dtdays) { if (d1->dttime == d2->dttime) return 0; return d1->dttime > d2->dttime ? 1 : -1; } /* date 1 is before 1900 */ if (d1->dtdays > 2958463) { if (d2->dtdays > 2958463) /* date 2 is before 1900 */ return d1->dtdays > d2->dtdays ? 1 : -1; return -1; } /* date 1 is after 1900 */ if (d2->dtdays < 2958463) /* date 2 is after 1900 */ return d1->dtdays > d2->dtdays ? 1 : -1; return 1; } static RETCODE dblib_datecrack(DBPROCESS * dbproc, BOOL nano_precision, DBDATEREC * output, int type, const void * data) { TDSDATEREC dr; struct tds_sybase_dbdaterec *di = (struct tds_sybase_dbdaterec*) output; tdsdump_log(TDS_DBG_FUNC, "dblib_datecrack(%p, %d, %p, %d, %p)\n", dbproc, nano_precision, output, type, data); CHECK_NULP(output, "dbdatecrack", 2, FAIL); CHECK_PARAMETER(data, SYBENDTP, FAIL); if (TDS_FAILED(tds_datecrack(type, data, &dr))) return FAIL; di->dateyear = dr.year; di->quarter = dr.quarter; di->datemonth = dr.month; di->datedmonth = dr.day; di->datedyear = dr.dayofyear; di->datedweek = dr.weekday; di->datehour = dr.hour; di->dateminute = dr.minute; di->datesecond = dr.second; di->datetzone = dr.timezone; if (nano_precision) /* here we are writing to nanosecond field */ di->datemsecond = dr.decimicrosecond * 100u; else di->datemsecond = dr.decimicrosecond / 10000u; /* Revert to compiled-in default if dbproc can't be used to find the runtime override. */ if (dbproc ? dbproc->msdblib : dblib_msdblib) { ++di->quarter; ++di->datemonth; ++di->datedweek; } return SUCCEED; } /** * \ingroup dblib_core * \brief Break a DBDATETIME value into useful pieces. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param di \em output: structure to contain the exploded parts of \a datetime. * \param datetime \em input: \c DBDATETIME to be converted. * \retval SUCCEED always. * \remarks The members of \a di have different names, depending on whether \c --with-msdblib was configured. * * If DBPROCESS is NULL, dbdatecrack() uses the compiled in default * value of MSDBLIB as of when libsybdb was compiled, irrespective of its value when the * application is compiled. This can lead to incorrect results because Sybase and Microsoft use different * ranges -- [0,11] vs. [1,12] -- for the month. * * \sa dbconvert(), dbdata(), dbdatechar(), dbdatename(), dbdatepart(), tdsdbopen(). */ RETCODE dbdatecrack(DBPROCESS * dbproc, DBDATEREC * di, DBDATETIME * datetime) { return dblib_datecrack(dbproc, FALSE, di, SYBDATETIME, datetime); } /** * \ingroup dblib_core * \brief Break any kind of date or time value into useful pieces. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param di \em output: structure to contain the exploded parts of \a datetime. * \param type \em input: \c type of date/time value returned by dbcoltype(). * \param data \em input: \c date/time value to be converted. * \retval SUCCEED always. * \remarks The members of \a di have different names, depending on whether \c --with-msdblib was configured. * * This is an extension to dbdatecrack(), see it for more information. * * \sa dbdatecrack(), dbconvert(), dbdata(), dbdatechar(), dbdatename(), dbdatepart(), tdsdbopen(). */ RETCODE dbanydatecrack(DBPROCESS * dbproc, DBDATEREC2 * di, int type, const void *data) { return dblib_datecrack(dbproc, TRUE, (DBDATEREC *) di, type, data); } #if defined(DBLIB_UNIMPLEMENTED) /** * \ingroup dblib_core * \brief Clear remote passwords from the LOGINREC structure. * * \param login structure to pass to dbopen(). * \sa dblogin(), dbopen(), dbrpwset(), DBSETLAPP(), DBSETLHOST(), DBSETLPWD(), DBSETLUSER(). * \remarks Useful for remote stored procedure calls, but not in high demand from FreeTDS. * \todo Unimplemented. */ void dbrpwclr(LOGINREC * login) { tdsdump_log(TDS_DBG_FUNC, "dbrpwclr(%p)\n", login); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED dbrpwclr()\n"); } /** * \ingroup dblib_core * \brief Add a remote password to the LOGINREC structure. * * \param login structure to pass to dbopen(). * \param srvname server for which \a password should be used. * \param password you guessed it, let's hope no else does. * \param pwlen count of \a password, in bytes. * \remarks Useful for remote stored procedure calls, but not in high demand from FreeTDS. * \sa dblogin(), dbopen(), dbrpwclr(), DBSETLAPP(), DBSETLHOST(), DBSETLPWD(), DBSETLUSER(). * \todo Unimplemented. */ RETCODE dbrpwset(LOGINREC * login, char *srvname, char *password, int pwlen) { tdsdump_log(TDS_DBG_FUNC, "dbrpwset(%p, %s, %s, %d)\n", login, srvname, password, pwlen); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED dbrpwset()\n"); return SUCCEED; } #endif /** * \ingroup dblib_core * \brief Get server process ID for a \c DBPROCESS. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \return \em "spid", the server's process ID. * \sa dbopen(). */ int dbspid(DBPROCESS * dbproc) { tdsdump_log(TDS_DBG_FUNC, "dbspid(%p)\n", dbproc); CHECK_CONN(-1); return dbproc->tds_socket->conn->spid; } /** * \ingroup dblib_core * \brief Associate client-allocated (and defined) data with a \c DBPROCESS. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param ptr address of client-defined data. * \remarks \a ptr is the location of user data that \c db-lib will associate with \a dbproc. * The client allocates the buffer addressed by \a ptr. \c db-lib never examines or uses the information; * it just stashes the pointer for later retrieval by the application with \c dbgetuserdata(). * \sa dbgetuserdata(). */ void dbsetuserdata(DBPROCESS * dbproc, BYTE * ptr) { tdsdump_log(TDS_DBG_FUNC, "dbsetuserdata(%p, %p)\n", dbproc, ptr); CHECK_PARAMETER(dbproc, SYBENULL, ); dbproc->user_data = ptr; } /** * \ingroup dblib_core * \brief Get address of user-allocated data from a \c DBPROCESS. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \return address of user-defined data that \c db-lib associated with \a dbproc when the client called dbsetuserdata(). * \retval undefined (probably \c NULL) dbsetuserdata() was not previously called. * \sa dbsetuserdata(). */ BYTE * dbgetuserdata(DBPROCESS * dbproc) { tdsdump_log(TDS_DBG_FUNC, "dbgetuserdata(%p)\n", dbproc); CHECK_PARAMETER(dbproc, SYBENULL, NULL); return dbproc->user_data; } /** * \ingroup dblib_core * \brief Specify a db-lib version level. * * \param version anything, really. * \retval SUCCEED Always. * \remarks No effect on behavior of \c db-lib in \c FreeTDS. * \sa */ RETCODE dbsetversion(DBINT version) { tdsdump_log(TDS_DBG_FUNC, "dbsetversion(%d)\n", version); switch (version ) { case DBVERSION_42: case DBVERSION_46: case DBVERSION_100: case DBVERSION_70: case DBVERSION_71: case DBVERSION_72: case DBVERSION_73: g_dblib_version = version; return SUCCEED; default: break; } dbperror(NULL, SYBEIVERS, 0); return FAIL; } /** * \ingroup dblib_money * \brief Copy a DBMONEY value. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param src address of a DBMONEY structure. * \param dest \em output: new money. * \retval SUCCEED always, unless \a src or \a dest is \c NULL. * \sa */ RETCODE dbmnycopy(DBPROCESS * dbproc, DBMONEY * src, DBMONEY * dest) { tdsdump_log(TDS_DBG_FUNC, "dbmnycopy(%p, %p, %p)\n", dbproc, src, dest); CHECK_CONN(FAIL); CHECK_NULP(src, "dbmnycopy", 2, FAIL); CHECK_NULP(dest, "dbmnycopy", 3, FAIL); dest->mnylow = src->mnylow; dest->mnyhigh = src->mnyhigh; return SUCCEED; } /** * \ingroup dblib_core * \brief Cancel the query currently being retrieved, discarding all pending rows. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \sa */ RETCODE dbcanquery(DBPROCESS * dbproc) { TDSRET rc; TDS_INT result_type; tdsdump_log(TDS_DBG_FUNC, "dbcanquery(%p)\n", dbproc); CHECK_CONN(FAIL); if (IS_TDSDEAD(dbproc->tds_socket)) return FAIL; /* Just throw away all pending rows from the last query */ rc = tds_process_tokens(dbproc->tds_socket, &result_type, NULL, TDS_STOPAT_ROWFMT|TDS_RETURN_DONE); if (TDS_FAILED(rc)) return FAIL; dbproc->dbresults_state = _DB_RES_NEXT_RESULT; return SUCCEED; } /** * \ingroup dblib_core * \brief Erase the command buffer, in case \c DBNOAUTOFREE was set with dbsetopt(). * * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \sa dbcmd(), dbfcmd(), dbgetchar(), dbsqlexec(), dbsqlsend(), dbsetopt(), dbstrcpy(), dbstrlen(). */ void dbfreebuf(DBPROCESS * dbproc) { tdsdump_log(TDS_DBG_FUNC, "dbfreebuf(%p)\n", dbproc); CHECK_PARAMETER(dbproc, SYBENULL, ); if (dbproc->dbbuf) TDS_ZERO_FREE(dbproc->dbbuf); dbproc->dbbufsz = 0; } /** * \ingroup dblib_core * \brief Reset an option. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param option to be turned off. * \param param clearing some options requires a parameter, believe it or not. * \retval SUCCEED \a option and \a parameter seem sane. * \retval FAIL no such \a option. * \remarks Only the following options are recognized: - DBARITHABORT - DBARITHIGNORE - DBCHAINXACTS - DBFIPSFLAG - DBISOLATION - DBNOCOUNT - DBNOEXEC - DBPARSEONLY - DBSHOWPLAN - DBSTORPROCID - DBQUOTEDIDENT - DBSETTIME * \sa dbisopt(), dbsetopt(). */ RETCODE dbclropt(DBPROCESS * dbproc, int option, const char param[]) { char *cmd; tdsdump_log(TDS_DBG_FUNC, "dbclropt(%p, %d, %s)\n", dbproc, option, param); CHECK_CONN(FAIL); if (option != DBSETTIME) { CHECK_NULP(param, "dbclropt", 3, FAIL); } if ((option < 0) || (option >= DBNUMOPTIONS)) { return FAIL; } dbproc->dbopts[option].factive = 0; switch (option) { case DBARITHABORT: case DBARITHIGNORE: case DBCHAINXACTS: case DBFIPSFLAG: case DBISOLATION: case DBNOCOUNT: case DBNOEXEC: case DBPARSEONLY: case DBSHOWPLAN: case DBSTORPROCID: case DBQUOTEDIDENT: /* server options (on/off) */ if (asprintf(&cmd, "set %s off\n", dbproc->dbopts[option].text) < 0) { return FAIL; } dbstring_concat(&(dbproc->dboptcmd), cmd); free(cmd); break; case DBBUFFER: buffer_set_capacity(dbproc, 1); /* frees row_buf->rows */ return SUCCEED; break; case DBSETTIME: tds_mutex_lock(&dblib_mutex); /* * Use global value of query timeout set by dbsettime() if any, * otherwise set it to zero just like tds_init_socket() does. */ if (g_dblib_ctx.query_timeout > 0) { dbproc->tds_socket->query_timeout = g_dblib_ctx.query_timeout; } else { dbproc->tds_socket->query_timeout = 0; } tds_mutex_unlock(&dblib_mutex); return SUCCEED; break; default: break; } tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED dbclropt(option = %d)\n", option); return FAIL; } /** * \ingroup dblib_core * \brief Get value of an option * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param option the option * \param param a parameter to \a option. * \sa dbclropt(), dbsetopt(). */ DBBOOL dbisopt(DBPROCESS * dbproc, int option, const char param[]) { tdsdump_log(TDS_DBG_FUNC, "dbisopt(%p, %d, %s)\n", dbproc, option, param); CHECK_PARAMETER(dbproc, SYBENULL, FALSE); /* sometimes param can be NULL */ if ((option < 0) || (option >= DBNUMOPTIONS)) { return FALSE; } return dbproc->dbopts[option].factive; } /** \internal * \ingroup dblib_internal * \brief Get number of the row currently being read. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \return ostensibly the row number, or 0 if no rows have been read yet. * \retval 0 Always. * \sa DBCURROW(), dbclrbuf(), DBFIRSTROW(), dbgetrow(), DBLASTROW(), dbnextrow(), dbsetopt(),. * \todo Unimplemented. */ DBINT dbcurrow(DBPROCESS * dbproc) { tdsdump_log(TDS_DBG_FUNC, "dbcurrow(%p)\n", dbproc); CHECK_PARAMETER(dbproc, SYBENULL, 0); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED dbcurrow()\n"); return 0; } /** \internal * \ingroup dblib_internal * \brief Get returned row's type. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \sa DBROWTYPE(). */ STATUS dbrowtype(DBPROCESS * dbproc) { tdsdump_log(TDS_DBG_FUNC, "dbrowtype(%p)\n", dbproc); CHECK_PARAMETER(dbproc, SYBENULL, NO_MORE_ROWS); return dbproc->row_type; } /** \internal * \ingroup dblib_internal * \brief Get number of the row just returned. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \sa DBCURROW(). * \todo Unimplemented. */ int dbcurcmd(DBPROCESS * dbproc) { tdsdump_log(TDS_DBG_FUNC, "dbcurcmd(%p)\n", dbproc); CHECK_PARAMETER(dbproc, SYBENULL, 0); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED dbcurcmd()\n"); return 0; } /** * \ingroup dblib_core * \brief See if more commands are to be processed. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \sa DBMORECMDS(). DBCMDROW(), dbresults(), DBROWS(), DBROWTYPE(). */ RETCODE dbmorecmds(DBPROCESS * dbproc) { tdsdump_log(TDS_DBG_FUNC, "dbmorecmds(%p)\n", dbproc); CHECK_CONN(FAIL); if (dbproc->tds_socket->res_info == NULL) { return FAIL; } if (dbproc->tds_socket->res_info->more_results == 0) { tdsdump_log(TDS_DBG_FUNC, "more_results == 0; returns FAIL\n"); return FAIL; } assert(dbproc->tds_socket->res_info->more_results == 1); tdsdump_log(TDS_DBG_FUNC, "more_results == 1; returns SUCCEED\n"); return SUCCEED; } /** * \ingroup dblib_rpc * \brief Get datatype of a stored procedure's return parameter. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param retnum Nth return parameter, between 1 and \c dbnumrets(). * \return SYB* datatype token, or -1 if \a retnum is out of range. * \sa dbnextrow(), dbnumrets(), dbprtype(), dbresults(), dbretdata(), dbretlen(), dbretname(), dbrpcinit(), dbrpcparam(). */ int dbrettype(DBPROCESS * dbproc, int retnum) { TDSCOLUMN *colinfo; tdsdump_log(TDS_DBG_FUNC, "dbrettype(%p, %d)\n", dbproc, retnum); CHECK_PARAMETER(dbproc, SYBENULL, -1); assert(dbproc->tds_socket); assert(dbproc->tds_socket->param_info); if (retnum < 1 || retnum > dbproc->tds_socket->param_info->num_cols) return -1; colinfo = dbproc->tds_socket->param_info->columns[retnum - 1]; return tds_get_conversion_type(colinfo->column_type, colinfo->column_size); } /** * \ingroup dblib_core * \brief Get size of the command buffer, in bytes. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \sa dbcmd(), dbfcmd(), dbfreebuf(), dbgetchar(), dbstrcpy(). */ int dbstrlen(DBPROCESS * dbproc) { tdsdump_log(TDS_DBG_FUNC, "dbstrlen(%p)\n", dbproc); CHECK_PARAMETER(dbproc, SYBENULL, 0); return dbproc->dbbufsz; } /** * \ingroup dblib_core * \brief Get address of a position in the command buffer. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param pos offset within the command buffer, starting at \em 0. * \remarks A bit overspecialized, this one. * \sa dbcmd(), dbfcmd(), dbfreebuf(), dbstrcpy(), dbstrlen(), */ char * dbgetchar(DBPROCESS * dbproc, int pos) { tdsdump_log(TDS_DBG_FUNC, "dbgetchar(%p, %d)\n", dbproc, pos); CHECK_PARAMETER(dbproc, SYBENULL, NULL); tdsdump_log(TDS_DBG_FUNC, "dbgetchar() bufsz = %d, pos = %d\n", dbproc->dbbufsz, pos); if (dbproc->dbbufsz > 0) { if (pos >= 0 && pos < (dbproc->dbbufsz - 1)) return (char *) &dbproc->dbbuf[pos]; else return NULL; } else return NULL; } /** * \ingroup dblib_core * \brief Get a copy of a chunk of the command buffer. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param start position in the command buffer to start copying from, starting from \em 0. * If start is past the end of the command buffer, dbstrcpy() inserts a null terminator at dest[0]. * \param numbytes number of bytes to copy. - If -1, dbstrcpy() copies the whole command buffer. - If 0 dbstrcpy() writes a \c NULL to dest[0]. - If the command buffer contains fewer than \a numbytes (taking \a start into account) dbstrcpy() copies the rest of it. * \param dest \em output: the buffer to write to. Make sure it's big enough. * \retval SUCCEED the inputs were valid and \a dest was affected. * \retval FAIL \a start < 0 or \a numbytes < -1. * \sa dbcmd(), dbfcmd(), dbfreebuf(), dbgetchar(), dbstrlen(). */ RETCODE dbstrcpy(DBPROCESS * dbproc, int start, int numbytes, char *dest) { tdsdump_log(TDS_DBG_FUNC, "dbstrcpy(%p, %d, %d, %s)\n", dbproc, start, numbytes, dest); CHECK_CONN(FAIL); CHECK_NULP(dest, "dbstrcpy", 4, FAIL); if (start < 0) { dbperror(dbproc, SYBENSIP, 0); return FAIL; } if (numbytes < -1) { dbperror(dbproc, SYBEBNUM, 0); return FAIL; } dest[0] = 0; /* start with empty string being returned */ if (dbproc->dbbufsz > 0 && start < dbproc->dbbufsz) { if (numbytes == -1) numbytes = dbproc->dbbufsz - start; if (start + numbytes > dbproc->dbbufsz) numbytes = dbproc->dbbufsz - start; memcpy(dest, (char *) &dbproc->dbbuf[start], numbytes); dest[numbytes] = '\0'; } return SUCCEED; } /** * \ingroup dblib_core * \brief safely quotes character values in SQL text. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param src input string. * \param srclen length of \a src in bytes, or -1 to indicate it's null-terminated. * \param dest \em output: client-provided output buffer. * \param destlen size of \a dest in bytes, or -1 to indicate it's "big enough" and the data should be null-terminated. * \param quotetype - \c DBSINGLE Doubles all single quotes ('). - \c DBDOUBLE Doubles all double quotes ("). - \c DBBOTH Doubles all single and double quotes. * \retval SUCCEED everything worked. * \retval FAIL no such \a quotetype, or insufficient room in \a dest. * \sa dbcmd(), dbfcmd(). */ RETCODE dbsafestr(DBPROCESS * dbproc, const char *src, DBINT srclen, char *dest, DBINT destlen, int quotetype) { int i, j = 0; int squote = FALSE, dquote = FALSE; tdsdump_log(TDS_DBG_FUNC, "dbsafestr(%p, %s, %d, %s, %d, %d)\n", dbproc, src, srclen, dest, destlen, quotetype); CHECK_NULP(src, "dbsafestr", 2, FAIL); CHECK_NULP(dest, "dbsafestr", 4, FAIL); /* check parameters */ if (srclen < -1 || destlen < -1) return FAIL; if (srclen == -1) srclen = (int)strlen(src); if (quotetype == DBSINGLE || quotetype == DBBOTH) squote = TRUE; if (quotetype == DBDOUBLE || quotetype == DBBOTH) dquote = TRUE; /* return FAIL if invalid quotetype */ if (!dquote && !squote) return FAIL; for (i = 0; i < srclen; i++) { /* dbsafestr returns fail if the deststr is not big enough */ /* need one char + one for terminator */ if (destlen >= 0 && j >= destlen) return FAIL; if (squote && src[i] == '\'') dest[j++] = '\''; else if (dquote && src[i] == '\"') dest[j++] = '\"'; if (destlen >= 0 && j >= destlen) return FAIL; dest[j++] = src[i]; } if (destlen >= 0 && j >= destlen) return FAIL; dest[j] = '\0'; return SUCCEED; } /** * \ingroup dblib_core * \brief Print a token value's name to a buffer * * \param token server SYB* value, e.g. SYBINT. * \return ASCII null-terminated string. * \sa dbaltop(), dbalttype(), dbcoltype(), dbrettype(). */ const char * dbprtype(int token) { tdsdump_log(TDS_DBG_FUNC, "dbprtype(%d)\n", token); return tds_prtype(token); } /** * \ingroup dblib_core * \brief describe table column attributes with a single call (Freetds-only API function modelled on dbcolinfo) * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param column Nth in the result set, starting from 1. * \param pdbcol address of structure to be populated by this function. * \return SUCCEED or FAIL. * \sa dbcolinfo(). */ RETCODE dbtablecolinfo (DBPROCESS *dbproc, DBINT column, DBCOL *pdbcol ) { TDSCOLUMN *colinfo; tdsdump_log(TDS_DBG_FUNC, "dbtablecolinfo(%p, %d, %p)\n", dbproc, column, pdbcol); CHECK_CONN(FAIL); CHECK_NULP(pdbcol, "dbtablecolinfo", 3, FAIL); DBPERROR_RETURN(pdbcol->SizeOfStruct != sizeof(DBCOL) && pdbcol->SizeOfStruct != sizeof(DBCOL2), SYBECOLSIZE); colinfo = dbcolptr(dbproc, column); if (!colinfo) return FAIL; strlcpy(pdbcol->Name, tds_dstr_cstr(&colinfo->column_name), sizeof(pdbcol->Name)); strlcpy(pdbcol->ActualName, tds_dstr_cstr(&colinfo->column_name), sizeof(pdbcol->ActualName)); pdbcol->Type = tds_get_conversion_type(colinfo->column_type, colinfo->column_size); pdbcol->UserType = colinfo->column_usertype; pdbcol->MaxLength = colinfo->column_size; if (colinfo->column_nullable) pdbcol->Null = TRUE; else pdbcol->Null = FALSE; pdbcol->VarLength = FALSE; if (colinfo->column_nullable || is_nullable_type(colinfo->column_type)) pdbcol->VarLength = TRUE; pdbcol->Precision = colinfo->column_prec; pdbcol->Scale = colinfo->column_scale; pdbcol->Updatable = colinfo->column_writeable ? TRUE : FALSE; pdbcol->Identity = colinfo->column_identity ? TRUE : FALSE; if (pdbcol->SizeOfStruct >= sizeof(DBCOL2)) { DBCOL2 *col = (DBCOL2 *) pdbcol; TDSRET rc; col->ServerType = colinfo->on_server.column_type; col->ServerMaxLength = colinfo->on_server.column_size; rc = tds_get_column_declaration(dbproc->tds_socket, colinfo, col->ServerTypeDeclaration); if (TDS_FAILED(rc)) return FAIL; } return SUCCEED; } /** * \ingroup dblib_core * \brief Get text timestamp for a column in the current row. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param column number of the column in the \c SELECT statement, starting at 1. * \return timestamp for \a column, may be NULL. * \sa dbtxptr(), dbwritetext(). */ DBBINARY * dbtxtimestamp(DBPROCESS * dbproc, int column) { TDSCOLUMN *colinfo; TDSBLOB *blob; tdsdump_log(TDS_DBG_FUNC, "dbtxtimestamp(%p, %d)\n", dbproc, column); colinfo = dbcolptr(dbproc, column); if (!colinfo || !is_blob_col(colinfo)) return NULL; blob = (TDSBLOB *) colinfo->column_data; /* test if valid */ if (!blob->valid_ptr) return NULL; return (DBBINARY *) blob->timestamp; } /** * \ingroup dblib_core * \brief Get text pointer for a column in the current row. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param column number of the column in the \c SELECT statement, starting at 1. * \return text pointer for \a column, may be NULL. * \sa dbtxtimestamp(), dbwritetext(). */ DBBINARY * dbtxptr(DBPROCESS * dbproc, int column) { TDSCOLUMN *colinfo; TDSBLOB *blob; tdsdump_log(TDS_DBG_FUNC, "dbtxptr(%p, %d)\n", dbproc, column); colinfo = dbcolptr(dbproc, column); if (!colinfo || !is_blob_col(colinfo)) return NULL; blob = (TDSBLOB *) colinfo->column_data; /* test if valid */ if (!blob->valid_ptr) return NULL; return (DBBINARY *) blob->textptr; } /** * \ingroup dblib_core * \brief Send text or image data to the server. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param objname table name * \param textptr text pointer to be modified, obtained from dbtxptr(). * \param textptrlen \em Ignored. Supposed to be \c DBTXPLEN. * \param timestamp text timestamp to be modified, obtained from dbtxtimestamp() or dbtxtsnewval(), may be \c NULL. * \param log \c TRUE if the operation is to be recorded in the transaction log. * \param size overall size of the data (in total, not just for this call), in bytes. A guideline, must not overstate the case. * \param text the chunk of data to write. * \retval SUCCEED everything worked. * \retval FAIL not sent, possibly because \a timestamp is invalid or was changed in the database since it was fetched. * \sa dbmoretext(), dbtxptr(), dbtxtimestamp(), dbwritetext(), dbtxtsput(). */ RETCODE dbwritetext(DBPROCESS * dbproc, char *objname, DBBINARY * textptr, DBTINYINT textptrlen, DBBINARY * timestamp, DBBOOL log, DBINT size, BYTE * text) { char textptr_string[35]; /* 16 * 2 + 2 (0x) + 1 */ char timestamp_string[19]; /* 8 * 2 + 2 (0x) + 1 */ TDS_INT result_type; tdsdump_log(TDS_DBG_FUNC, "dbwritetext(%p, %s, %p, %d, %p, %d)\n", dbproc, objname, textptr, textptrlen, timestamp, log); CHECK_CONN(FAIL); CHECK_NULP(objname, "dbwritetext", 2, FAIL); CHECK_NULP(textptr, "dbwritetext", 3, FAIL); CHECK_NULP(timestamp, "dbwritetext", 5, FAIL); CHECK_PARAMETER(size, SYBEZTXT, FAIL); if (IS_TDSDEAD(dbproc->tds_socket)) return FAIL; if (textptrlen > DBTXPLEN) return FAIL; dbconvert(dbproc, SYBBINARY, (BYTE *) textptr, textptrlen, SYBCHAR, (BYTE *) textptr_string, -1); dbconvert(dbproc, SYBBINARY, (BYTE *) timestamp, 8, SYBCHAR, (BYTE *) timestamp_string, -1); dbproc->dbresults_state = _DB_RES_INIT; if (dbproc->tds_socket->state == TDS_PENDING) { const TDSRET ret = tds_process_tokens(dbproc->tds_socket, &result_type, NULL, TDS_TOKEN_TRAILING); if (ret != TDS_NO_MORE_RESULTS) { dbperror(dbproc, SYBERPND, 0); dbproc->command_state = DBCMDSENT; return FAIL; } } if (TDS_FAILED(tds_writetext_start(dbproc->tds_socket, objname, textptr_string, timestamp_string, (log == TRUE), size))) return FAIL; if (!text) { dbproc->text_size = size; dbproc->text_sent = 0; return SUCCEED; } tds_writetext_continue(dbproc->tds_socket, text, size); tds_writetext_end(dbproc->tds_socket); dbproc->text_sent = 0; if (dbsqlok(dbproc) == SUCCEED && dbresults(dbproc) == SUCCEED) return SUCCEED; return FAIL; } /** * \ingroup dblib_core * \brief Fetch part of a text or image value from the server. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param buf \em output: buffer into which text will be placed. * \param bufsize size of \a buf, in bytes. * \return - \c >0 count of bytes placed in \a buf. - \c 0 end of row. - \c -1 \em error, no result set ready for \a dbproc. - \c NO_MORE_ROWS all rows read, no further data. * \sa dbmoretext(), dbnextrow(), dbwritetext(). */ STATUS dbreadtext(DBPROCESS * dbproc, void *buf, DBINT bufsize) { TDSSOCKET *tds; TDSCOLUMN *curcol; int cpbytes, bytes_avail; TDS_INT result_type; TDSRESULTINFO *resinfo; tdsdump_log(TDS_DBG_FUNC, "dbreadtext(%p, %p, %d)\n", dbproc, buf, bufsize); CHECK_PARAMETER(dbproc, SYBENULL, -1); CHECK_NULP(buf, "dbreadtext", 2, -1); tds = dbproc->tds_socket; if (!tds || !tds->res_info || !tds->res_info->columns[0]) return -1; resinfo = tds->res_info; curcol = resinfo->columns[0]; /* * if the current position is beyond the end of the text * set pos to 0 and return 0 to denote the end of the * text */ if (curcol->column_textpos && curcol->column_textpos >= curcol->column_cur_size) { curcol->column_textpos = 0; return 0; } /* * if pos is 0 (first time through or last call exhausted the text) * then read another row */ if (curcol->column_textpos == 0) { const int mask = TDS_STOPAT_ROWFMT|TDS_STOPAT_DONE|TDS_RETURN_ROW|TDS_RETURN_COMPUTE; buffer_save_row(dbproc); switch (tds_process_tokens(dbproc->tds_socket, &result_type, NULL, mask)) { case TDS_SUCCESS: if (result_type == TDS_ROW_RESULT || result_type == TDS_COMPUTE_RESULT) break; case TDS_NO_MORE_RESULTS: return NO_MORE_ROWS; default: return -1; } } /* find the number of bytes to return */ bytes_avail = curcol->column_cur_size - curcol->column_textpos; cpbytes = bytes_avail > bufsize ? bufsize : bytes_avail; memcpy(buf, &((TDSBLOB *) curcol->column_data)->textvalue[curcol->column_textpos], cpbytes); curcol->column_textpos += cpbytes; return cpbytes; } /** * \ingroup dblib_core * \brief Send chunk of a text/image value to the server. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param size count of bytes to send. * \param text textpointer, obtained from dbtxptr. * \retval SUCCEED always. * \sa dbtxptr(), dbtxtimestamp(), dbwritetext(). * \todo Check return value of called functions and return \c FAIL if appropriate. */ RETCODE dbmoretext(DBPROCESS * dbproc, DBINT size, const BYTE text[]) { tdsdump_log(TDS_DBG_FUNC, "dbmoretext(%p, %d, %p)\n", dbproc, size, text); CHECK_CONN(FAIL); CHECK_NULP(text, "dbmoretext", 3, FAIL); assert(dbproc->text_size >= dbproc->text_sent); /* TODO this test should be inside tds_writetext_continue, currently not */ if (size < 0 || size > dbproc->text_size - dbproc->text_sent) return FAIL; if (size) { if (TDS_FAILED(tds_writetext_continue(dbproc->tds_socket, text, size))) return FAIL; dbproc->text_sent += size; if (dbproc->text_sent == dbproc->text_size) { tds_writetext_end(dbproc->tds_socket); dbproc->text_sent = 0; } } return SUCCEED; } /** * \ingroup dblib_core * \brief Record to a file all SQL commands sent to the server * * \param filename name of file to write to. * \remarks Files are named \em filename.n, where n is an integer, starting with 0, and incremented with each callto dbopen(). * \sa dbopen(), TDSDUMP environment variable(). */ void dbrecftos(const char filename[]) { char *f; tdsdump_log(TDS_DBG_FUNC, "dbrecftos(%s)\n", filename); if (filename == NULL) { dbperror(NULL, SYBENULP, 0); return; } f = strdup(filename); if (!f) { dbperror(NULL, SYBEMEM, 0); return; } tds_mutex_lock(&dblib_mutex); free(g_dblib_ctx.recftos_filename); g_dblib_ctx.recftos_filename = f; g_dblib_ctx.recftos_filenum = 0; tds_mutex_unlock(&dblib_mutex); } /** \internal * \ingroup dblib_internal * \brief Get the TDS version in use for \a dbproc. * * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \return a \c DBTDS* token. * \remarks The integer values of the constants are counterintuitive. * \sa DBTDS(). */ int dbtds(DBPROCESS * dbproc) { tdsdump_log(TDS_DBG_FUNC, "dbtds(%p)\n", dbproc); CHECK_PARAMETER(dbproc, SYBENULL, -1); if (dbproc->tds_socket) { switch (dbproc->tds_socket->conn->tds_version) { case 0x402: return DBTDS_4_2; case 0x406: return DBTDS_4_6; case 0x500: return DBTDS_5_0; case 0x700: return DBTDS_7_0; case 0x701: return DBTDS_7_1; case 0x702: return DBTDS_7_2; case 0x703: return DBTDS_7_3; case 0x704: return DBTDS_7_4; default: return DBTDS_UNKNOWN; } } return -1; } /** * \ingroup dblib_core * \brief See which version of db-lib is in use. * * \return null-terminated ASCII string representing the version of db-lib. * \remarks FreeTDS returns the CVS version string of dblib.c. * \sa */ const char * dbversion() { tdsdump_log(TDS_DBG_FUNC, "dbversion(void)\n"); return TDS_VERSION_NO; } #if defined(DBLIB_UNIMPLEMENTED) /** * \ingroup dblib_core * \brief Set the default character set. * * \param charset null-terminated ASCII string, matching a row in master..syscharsets. * \sa dbsetdeflang(), dbsetdefcharset(), dblogin(), dbopen(). * \todo Unimplemented. */ RETCODE dbsetdefcharset(char *charset) { tdsdump_log(TDS_DBG_FUNC, "dbsetdefcharset(%s)\n", charset); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED dbsetdefcharset()\n"); return SUCCEED; } /** * \ingroup dblib_core * \brief Ready execution of a registered procedure. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param procedure_name to call. * \param namelen size of \a procedure_name, in bytes. * \sa dbregparam(), dbregexec(), dbregwatch(), dbreglist(), dbregwatchlist * \todo Unimplemented. */ RETCODE dbreginit(DBPROCESS * dbproc, DBCHAR * procedure_name, DBSMALLINT namelen) { tdsdump_log(TDS_DBG_FUNC, "dbreginit(%p, %s, %d)\n", dbproc, procedure_name, namelen); CHECK_CONN(FAIL); CHECK_NULP(procedure_name, "dbreginit", 2, FAIL); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED dbreginit()\n"); return SUCCEED; } /** * \ingroup dblib_core * \brief Get names of Open Server registered procedures. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \sa dbregparam(), dbregexec(), dbregwatch(), dbreglist(), dbregwatchlist(). * \todo Unimplemented. */ RETCODE dbreglist(DBPROCESS * dbproc) { tdsdump_log(TDS_DBG_FUNC, "dbreglist(%p)\n", dbproc); CHECK_CONN(FAIL); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED dbreglist()\n"); return SUCCEED; } /** * \ingroup dblib_core * \brief Describe parameter of registered procedure . * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param param_name * \param type \c SYB* datatype. * \param datalen size of \a data. * \param data address of buffer holding value for the parameter. * \sa dbreginit(), dbregexec(), dbnpdefine(), dbnpcreate(), dbregwatch(). * \todo Unimplemented. */ RETCODE dbregparam(DBPROCESS * dbproc, char *param_name, int type, DBINT datalen, BYTE * data) { tdsdump_log(TDS_DBG_FUNC, "dbregparam(%p, %s, %d, %d, %p)\n", dbproc, param_name, type, datalen, data); CHECK_CONN(FAIL); CHECK_NULP(param_name, "dbregparam", 2, FAIL); CHECK_NULP(data, "dbregparam", 5, FAIL); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED dbregparam()\n"); return SUCCEED; } /** * \ingroup dblib_core * \brief Execute a registered procedure. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param options * \sa dbreginit(), dbregparam(), dbregwatch(), dbregnowatch * \todo Unimplemented. */ RETCODE dbregexec(DBPROCESS * dbproc, DBUSMALLINT options) { tdsdump_log(TDS_DBG_FUNC, "dbregexec(%p, %d)\n", dbproc, options); CHECK_CONN(FAIL); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED dbregexec()\n"); return SUCCEED; } #endif /** * \ingroup dblib_datetime * \brief Get name of a month, in some human language. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param language \em ignored. * \param monthnum number of the month, starting with 1. * \param shortform set to \c TRUE for a three letter output ("Jan" - "Dec"), else zero. * \return address of null-terminated ASCII string, or \c NULL on error. * \sa db12hour(), dbdateorder(), dbdayname(), DBSETLNATLANG(), dbsetopt(). */ const char * dbmonthname(DBPROCESS * dbproc, char *language, int monthnum, DBBOOL shortform) { static const char shortmon[][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; static const char longmon[][12] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; tdsdump_log(TDS_DBG_FUNC, "dbmonthname(%p, %s, %d, %d)\n", dbproc, language, monthnum, shortform); CHECK_PARAMETER(dbproc, SYBENULL, NULL); CHECK_NULP(language, "dbmonthname", 2, NULL); if (monthnum < 1 || monthnum > 12) return NULL; return (shortform) ? shortmon[monthnum - 1] : longmon[monthnum - 1]; } /** * \ingroup dblib_core * \brief See if a command caused the current database to change. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \return name of new database, if changed, as a null-terminated ASCII string, else \c NULL. * \sa dbname(), dbresults(), dbsqlexec(), dbsqlsend(), dbuse(). */ char * dbchange(DBPROCESS * dbproc) { tdsdump_log(TDS_DBG_FUNC, "dbchange(%p)\n", dbproc); CHECK_PARAMETER(dbproc, SYBENULL, NULL); if (dbproc->envchange_rcv & (1 << (TDS_ENV_DATABASE - 1))) { return dbproc->dbcurdb; } return NULL; } /** * \ingroup dblib_core * \brief Get name of current database. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \return current database name, as null-terminated ASCII string. * \sa dbchange(), dbuse(). */ char * dbname(DBPROCESS * dbproc) { tdsdump_log(TDS_DBG_FUNC, "dbname(%p)\n", dbproc); CHECK_PARAMETER(dbproc, SYBENULL, NULL); return dbproc->dbcurdb; } /** * \ingroup dblib_core * \brief Get \c syscharset name of the server character set. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \return name of server's charset, as null-terminated ASCII string. * \sa dbcharsetconv(), dbgetcharset(), DBSETLCHARSET(). */ char * dbservcharset(DBPROCESS * dbproc) { tdsdump_log(TDS_DBG_FUNC, "dbservcharset(%p)\n", dbproc); CHECK_PARAMETER(dbproc, SYBENULL, NULL); return dbproc->servcharset; } /** * \ingroup dblib_core * \brief Transmit the command buffer to the server. \em Non-blocking, does not wait for a response. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \retval SUCCEED SQL sent. * \retval FAIL protocol problem, unless dbsqlsend() when it's not supposed to be (in which case a db-lib error message will be emitted). * \sa dbcmd(), dbfcmd(), DBIORDESC(), DBIOWDESC(), dbnextrow(), dbpoll(), dbresults(), dbsettime(), dbsqlexec(), dbsqlok(). */ RETCODE dbsqlsend(DBPROCESS * dbproc) { TDSSOCKET *tds; char *cmdstr; TDSRET rc; TDS_INT result_type; char timestr[256]; tdsdump_log(TDS_DBG_FUNC, "dbsqlsend(%p)\n", dbproc); CHECK_CONN(FAIL); tds = dbproc->tds_socket; if (tds->state == TDS_PENDING) { if (tds_process_tokens(tds, &result_type, NULL, TDS_TOKEN_TRAILING) != TDS_NO_MORE_RESULTS) { dbperror(dbproc, SYBERPND, 0); dbproc->command_state = DBCMDSENT; return FAIL; } } if (dbproc->dboptcmd) { if ((cmdstr = dbstring_get(dbproc->dboptcmd)) == NULL) { dbperror(dbproc, SYBEASEC, 0); /* Attempt to send an empty command buffer to the server */ return FAIL; } rc = tds_submit_query(dbproc->tds_socket, cmdstr); free(cmdstr); dbstring_free(&(dbproc->dboptcmd)); if (TDS_FAILED(rc)) { return FAIL; } dbproc->avail_flag = FALSE; dbproc->envchange_rcv = 0; dbproc->dbresults_state = _DB_RES_INIT; while ((rc = tds_process_tokens(tds, &result_type, NULL, TDS_TOKEN_RESULTS)) == TDS_SUCCESS); if (rc != TDS_NO_MORE_RESULTS) { return FAIL; } } dbproc->more_results = TRUE; if (dbproc->ftos != NULL) { fprintf(dbproc->ftos, "%s\n", dbproc->dbbuf); fprintf(dbproc->ftos, "go /* %s */\n", _dbprdate(timestr)); fflush(dbproc->ftos); } if (TDS_FAILED(tds_submit_query(dbproc->tds_socket, (char *) dbproc->dbbuf))) { return FAIL; } dbproc->avail_flag = FALSE; dbproc->envchange_rcv = 0; dbproc->dbresults_state = _DB_RES_INIT; dbproc->command_state = DBCMDSENT; return SUCCEED; } /** * \ingroup dblib_core * \brief Get user-defined datatype of a compute column. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param computeid of \c COMPUTE clause to which we're referring. * \param column Nth column in \a computeid, starting from 1. * \returns user-defined datatype of compute column, else -1. * \sa dbalttype(), dbcolutype(). */ DBINT dbaltutype(DBPROCESS * dbproc, int computeid, int column) { TDSCOLUMN *colinfo; tdsdump_log(TDS_DBG_FUNC, "dbaltutype(%p, %d, %d)\n", dbproc, computeid, column); CHECK_PARAMETER(dbproc, SYBENULL, -1); colinfo = dbacolptr(dbproc, computeid, column, 0); if (!colinfo) return -1; return colinfo->column_usertype; } /** * \ingroup dblib_core * \brief Get size of data in compute column. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param computeid of \c COMPUTE clause to which we're referring. * \param column Nth column in \a computeid, starting from 1. * \sa dbadata(), dbadlen(), dbalttype(), dbgetrow(), dbnextrow(), dbnumalts(). */ DBINT dbaltlen(DBPROCESS * dbproc, int computeid, int column) { TDSCOLUMN *colinfo; tdsdump_log(TDS_DBG_FUNC, "dbaltlen(%p, %d, %d)\n", dbproc, computeid, column); colinfo = dbacolptr(dbproc, computeid, column, 0); if (!colinfo) return -1; return colinfo->column_size; } /** * \ingroup dblib_core * \brief See if a server response has arrived. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param milliseconds how long to wait for the server before returning: - \c 0 return immediately. - \c -1 do not return until the server responds or a system interrupt occurs. * \param ready_dbproc \em output: DBPROCESS for which a response arrived, of \c NULL. * \param return_reason \em output: - \c DBRESULT server responded. - \c DBNOTIFICATION registered procedure notification has arrived. dbpoll() the registered handler, if any, before it returns. - \c DBTIMEOUT \a milliseconds elapsed before the server responded. - \c DBINTERRUPT operating-system interrupt occurred before the server responded. * \retval SUCCEED everything worked. * \retval FAIL a server connection died. * \sa DBIORDESC(), DBRBUF(), dbresults(), dbreghandle(), dbsqlok(). * \todo Unimplemented. */ #if defined(DBLIB_UNIMPLEMENTED) RETCODE dbpoll(DBPROCESS * dbproc, long milliseconds, DBPROCESS ** ready_dbproc, int *return_reason) { tdsdump_log(TDS_DBG_FUNC, "dbpoll(%p, %ld, %p, %p)\n", dbproc, milliseconds, ready_dbproc, return_reason); CHECK_CONN(FAIL); CHECK_NULP(ready_dbproc, "dbpoll", 3, FAIL); CHECK_NULP(return_reason, "dbpoll", 4, FAIL); tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED dbpoll()\n"); return SUCCEED; } #endif /** \internal * \ingroup dblib_internal * \brief Get number of the first row in the row buffer. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \sa DBFIRSTROW(), dbclrbuf(), DBCURROW(), dbgetrow(), DBLASTROW(), dbnextrow(), dbsetopt(). */ DBINT dbfirstrow(DBPROCESS * dbproc) { tdsdump_log(TDS_DBG_FUNC, "dbfirstrow(%p)\n", dbproc); CHECK_CONN(0); return buffer_idx2row(&dbproc->row_buf, dbproc->row_buf.tail); } /** \internal * \ingroup dblib_internal * \brief Get number of the last row in the row buffer. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \sa DBLASTROW(), dbclrbuf(), DBCURROW(), DBFIRSTROW(), dbgetrow(), dbnextrow(), dbsetopt(). */ DBINT dblastrow(DBPROCESS * dbproc) { int idx; tdsdump_log(TDS_DBG_FUNC, "dblastrow(%p)\n", dbproc); CHECK_PARAMETER(dbproc, SYBENULL, 0); idx = dbproc->row_buf.head; if (dbproc->row_buf.head != dbproc->row_buf.tail) { if (--idx < 0) idx = dbproc->row_buf.capacity - 1; } assert(idx >= 0); return buffer_idx2row(&dbproc->row_buf, idx); } /** \internal * \ingroup dblib_internal * \brief Get file descriptor of the socket used by a \c DBPROCESS to read data coming from the server. (!) * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \sa dbcmd(), DBIORDESC(), DBIOWDESC(), dbnextrow(), dbpoll(), DBRBUF(), dbresults(), dbsqlok(), dbsqlsend(). */ int dbiordesc(DBPROCESS * dbproc) { tdsdump_log(TDS_DBG_FUNC, "dbiordesc(%p)\n", dbproc); CHECK_PARAMETER(dbproc, SYBENULL, -1); return (int) tds_get_s(dbproc->tds_socket); } /** \internal * \ingroup dblib_internal * \brief Get file descriptor of the socket used by a \c DBPROCESS to write data coming to the server. (!) * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \sa dbcmd(), DBIORDESC(), DBIOWDESC(), dbnextrow(), dbpoll(), DBRBUF(), dbresults(), dbsqlok(), dbsqlsend(). */ int dbiowdesc(DBPROCESS * dbproc) { tdsdump_log(TDS_DBG_FUNC, "dbiowdesc(%p)\n", dbproc); CHECK_PARAMETER(dbproc, SYBENULL, -1); return (int) tds_get_s(dbproc->tds_socket); } DBBOOL dbisavail(DBPROCESS * dbproc) { tdsdump_log(TDS_DBG_FUNC, "dbisavail(%p)\n", dbproc); CHECK_PARAMETER(dbproc, SYBENULL, FALSE); return dbproc->avail_flag; } /** \internal * \ingroup dblib_internal * \brief Mark a \c DBPROCESS as "available". * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \remarks Basically bogus. \c FreeTDS behaves the way Sybase's implementation does, but so what? Many \c db-lib functions set the \c DBPROCESS to "not available", but only dbsetavail() resets it to "available". * \sa DBISAVAIL(). DBSETAVAIL(). */ void dbsetavail(DBPROCESS * dbproc) { tdsdump_log(TDS_DBG_FUNC, "dbsetavail(%p)\n", dbproc); CHECK_PARAMETER(dbproc, SYBENULL, ); dbproc->avail_flag = TRUE; } /** * \ingroup dblib_core * \brief Build a printable string from text containing placeholders for variables. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param charbuf \em output: buffer that will contain the ASCII null-terminated string built by \c dbstrbuild(). * \param bufsize size of \a charbuf, in bytes. * \param text null-terminated ASCII string, with \em placeholders for variables. \em A Placeholder is a * three-byte string, made up of: - '%' a percent sign - 0-9 an integer (designates the argument number to use, starting with 1.) - '!' an exclamation point * \param formats null-terminated ASCII sprintf-style string. Has one format specifier for each placeholder in \a text. * \remarks Following \a formats are the arguments, the values to substitute for the placeholders. * \sa dbconvert(), dbdatename(), dbdatepart(). */ RETCODE dbstrbuild(DBPROCESS * dbproc, char *charbuf, int bufsize, char *text, char *formats, ...) { va_list ap; TDSRET rc; int resultlen; tdsdump_log(TDS_DBG_FUNC, "dbstrbuild(%p, %s, %d, %s, %s, ...)\n", dbproc, charbuf, bufsize, text, formats); CHECK_NULP(charbuf, "dbstrbuild", 2, FAIL); CHECK_NULP(text, "dbstrbuild", 4, FAIL); CHECK_NULP(formats, "dbstrbuild", 5, FAIL); va_start(ap, formats); rc = tds_vstrbuild(charbuf, bufsize, &resultlen, text, TDS_NULLTERM, formats, TDS_NULLTERM, ap); charbuf[resultlen] = '\0'; va_end(ap); return TDS_SUCCEED(rc) ? SUCCEED : FAIL; } static char * _dbprdate(char *timestr) { time_t currtime = time(NULL); assert(timestr); strcpy(timestr, asctime(gmtime(&currtime))); timestr[strlen(timestr) - 1] = '\0'; /* remove newline */ return timestr; } static DBINT _dbnullable(DBPROCESS * dbproc, int column) { TDSCOLUMN *colinfo; TDSRESULTINFO *resinfo; assert(dbproc && dbproc->tds_socket); resinfo = dbproc->tds_socket->res_info; if (!resinfo || column < 1 || column > resinfo->num_cols) return FALSE; colinfo = resinfo->columns[column - 1]; if (colinfo->column_nullable) return TRUE; return FALSE; } /** Returns type in string. Used for debugging purpose */ static const char * tds_prdatatype(int datatype_token) { switch ((TDS_SERVER_TYPE) datatype_token) { case SYBCHAR: return "SYBCHAR"; case SYBVARCHAR: return "SYBVARCHAR"; case SYBINTN: return "SYBINTN"; case SYBINT1: return "SYBINT1"; case SYBINT2: return "SYBINT2"; case SYBINT4: return "SYBINT4"; case SYBINT8: return "SYBINT8"; case SYBFLT8: return "SYBFLT8"; case SYBDATETIME: return "SYBDATETIME"; case SYBBIT: return "SYBBIT"; case SYBTEXT: return "SYBTEXT"; case SYBNTEXT: return "SYBNTEXT"; case SYBIMAGE: return "SYBIMAGE"; case SYBMONEY4: return "SYBMONEY4"; case SYBMONEY: return "SYBMONEY"; case SYBDATETIME4: return "SYBDATETIME4"; case SYBREAL: return "SYBREAL"; case SYBBINARY: return "SYBBINARY"; case SYBVOID: return "SYBVOID"; case SYBVARBINARY: return "SYBVARBINARY"; case SYBNVARCHAR: return "SYBNVARCHAR"; case SYBBITN: return "SYBBITN"; case SYBNUMERIC: return "SYBNUMERIC"; case SYBDECIMAL: return "SYBDECIMAL"; case SYBFLTN: return "SYBFLTN"; case SYBMONEYN: return "SYBMONEYN"; case SYBDATETIMN: return "SYBDATETIMN"; case XSYBCHAR: return "XSYBCHAR"; case XSYBVARCHAR: return "XSYBVARCHAR"; case XSYBNVARCHAR: return "XSYBNVARCHAR"; case XSYBNCHAR: return "XSYBNCHAR"; case XSYBVARBINARY: return "XSYBVARBINARY"; case XSYBBINARY: return "XSYBBINARY"; case SYBLONGBINARY: return "SYBLONGBINARY"; case SYBSINT1: return "SYBSINT1"; case SYBUINT2: return "SYBUINT2"; case SYBUINT4: return "SYBUINT4"; case SYBUINT8: return "SYBUINT8"; case SYBUNIQUE: return "SYBUNIQUE"; case SYBVARIANT: return "SYBVARIANT"; case SYBMSXML: return "SYBMSXML"; case SYBMSDATE: return "SYBMSDATE"; case SYBMSTIME: return "SYBMSTIME"; case SYBMSDATETIME2: return "SYBMSDATETIME2"; case SYBMSDATETIMEOFFSET: return "SYBMSDATETIMEOFFSET"; case SYBDATE: return "SYBDATE"; case SYBTIME: return "SYBTIME"; case SYB5BIGDATETIME: return "SYBBIGDATETIME"; case SYB5BIGTIME: return "SYBBIGTIME"; case SYBMSUDT: return "SYBMSUDT"; case SYBUINT1: return "SYBUINT1"; case SYBDATEN: return "SYBDATEN"; case SYB5INT8: return "SYB5INT8"; case SYBINTERVAL: return "SYBINTERVAL"; case SYBTIMEN: return "SYBTIMEN"; case SYBUINTN: return "SYBUINTN"; case SYBUNITEXT: return "SYBUNITEXT"; case SYBXML: return "SYBXML"; } return "(unknown)"; } #if 1 void copy_data_to_host_var(DBPROCESS * dbproc, TDS_SERVER_TYPE srctype, const BYTE * src, DBINT srclen, BYTE * dest, DBINT destlen, int bindtype, DBINT *indicator) { CONV_RESULT dres; DBINT ret; int i, len; DBINT indicator_value = 0; int limited_dest_space = 0; TDS_SERVER_TYPE desttype = dblib_bound_type(bindtype); tdsdump_log(TDS_DBG_FUNC, "copy_data_to_host_var(%d [%s] len %d => %d [%s] len %d)\n", srctype, tds_prdatatype(srctype), srclen, desttype, tds_prdatatype(desttype), destlen); CHECK_NULP(src, "copy_data_to_host_var", 3, ); CHECK_NULP(dest, "copy_data_to_host_var", 6, ); if (desttype == TDS_INVALID_TYPE) return; /* indicator can be NULL */ assert(srclen >= 0); if (destlen > 0) { limited_dest_space = 1; } /* oft times we are asked to convert a data type to itself */ if (desttype == SYBNUMERIC) { DBNUMERIC *num = NULL; /* num->scale is unsigned */ /* only MS, use always source */ if (bindtype == SRCNUMERICBIND || bindtype == SRCDECIMALBIND) { if (is_numeric_type(srctype)) num = (DBNUMERIC*) src; else num = (DBNUMERIC*) dest; } else if (dbproc->msdblib) { /* MS by default use only destination informations */ num = (DBNUMERIC*) dest; } else { /* Sybase, dbbind means source or default */ /* TODO if dbbind_ps is used is more complicated */ if (is_numeric_type(srctype)) num = (DBNUMERIC*) src; } if (!num) { dres.n.precision = 18; dres.n.scale = 0; } else { dres.n.precision = num->precision; dres.n.scale = num->scale; } } else if ((srctype == desttype) || (is_similar_type(srctype, desttype))) { tdsdump_log(TDS_DBG_INFO1, "copy_data_to_host_var() srctype == desttype\n"); switch (desttype) { case SYBBINARY: case SYBIMAGE: if (srclen > destlen && destlen >= 0) { dbperror(dbproc, SYBECOFL, 0); } else { memcpy(dest, src, srclen); if (srclen < destlen) memset(dest + srclen, 0, destlen - srclen); } break; case SYBCHAR: case SYBVARCHAR: case SYBTEXT: switch (bindtype) { case NTBSTRINGBIND: /* strip trailing blanks, null term */ while (srclen && src[srclen - 1] == ' ') { --srclen; } if (limited_dest_space) { if (srclen + 1 > destlen) { dbperror(dbproc, SYBECOFL, 0); indicator_value = srclen + 1; srclen = destlen - 1; } } memcpy(dest, src, srclen); dest[srclen] = '\0'; break; case STRINGBIND: /* pad with blanks, NUL term */ if (limited_dest_space) { if (srclen + 1 > destlen) { dbperror(dbproc, SYBECOFL, 0); indicator_value = srclen + 1; srclen = destlen - 1; } } else { destlen = srclen; } memcpy(dest, src, srclen); for (i = srclen; i < destlen - 1; i++) dest[i] = ' '; dest[i] = '\0'; break; case CHARBIND: /* pad with blanks, NO NUL term */ if (limited_dest_space) { if (srclen > destlen) { dbperror(dbproc, SYBECOFL, 0); indicator_value = srclen; srclen = destlen; } } else { destlen = srclen; } memcpy(dest, src, srclen); for (i = srclen; i < destlen; i++) dest[i] = ' '; break; case VARYCHARBIND: /* strip trailing blanks, NO NUL term */ if (limited_dest_space) { if (srclen > destlen) { dbperror(dbproc, SYBECOFL, 0); indicator_value = srclen; srclen = destlen; } } memcpy(((DBVARYCHAR *)dest)->str, src, srclen); ((DBVARYCHAR *)dest)->len = srclen; break; } break; case SYBINT1: case SYBINT2: case SYBINT4: case SYBINT8: case SYBFLT8: case SYBREAL: case SYBBIT: case SYBBITN: case SYBMONEY: case SYBMONEY4: case SYBDATETIME: case SYBDATETIME4: case SYBDATE: case SYBTIME: case SYB5BIGDATETIME: case SYB5BIGTIME: case SYBUNIQUE: ret = tds_get_size_by_type(desttype); memcpy(dest, src, ret); break; case SYBMSDATE: case SYBMSTIME: case SYBMSDATETIME2: case SYBMSDATETIMEOFFSET: ret = sizeof(TDS_DATETIMEALL); memcpy(dest, src, ret); break; default: break; } if (indicator) *indicator = indicator_value; return; } /* end srctype == desttype */ len = tds_convert(g_dblib_ctx.tds_ctx, srctype, (const TDS_CHAR *) src, srclen, desttype, &dres); tdsdump_log(TDS_DBG_INFO1, "copy_data_to_host_var(): tds_convert returned %d\n", len); if (len < 0) { _dblib_convert_err(dbproc, len); return; } switch (desttype) { case SYBVARBINARY: case SYBBINARY: case SYBIMAGE: if (bindtype == VARYBINBIND) { if (limited_dest_space) { if (len > sizeof(((DBVARYBIN *)dest)->array)) { dbperror(dbproc, SYBECOFL, 0); indicator_value = len; len = sizeof(((DBVARYBIN *)dest)->array); } } memcpy(((DBVARYBIN *)dest)->array, dres.c, len); ((DBVARYBIN *)dest)->len = len; } else { if (len > destlen && destlen >= 0) { dbperror(dbproc, SYBECOFL, 0); } else { memcpy(dest, dres.ib, len); if (len < destlen) memset(dest + len, 0, destlen - len); } } TDS_ZERO_FREE(dres.ib); break; case SYBINT1: case SYBINT2: case SYBINT4: case SYBINT8: case SYBFLT8: case SYBREAL: case SYBBIT: case SYBBITN: case SYBMONEY: case SYBMONEY4: case SYBDATETIME: case SYBDATETIME4: case SYBDATE: case SYBTIME: case SYBNUMERIC: case SYBDECIMAL: case SYBUNIQUE: case SYBMSDATE: case SYBMSTIME: case SYB5BIGDATETIME: case SYB5BIGTIME: case SYBMSDATETIME2: case SYBMSDATETIMEOFFSET: memcpy(dest, &(dres.ti), len); break; case SYBCHAR: case SYBVARCHAR: case SYBTEXT: tdsdump_log(TDS_DBG_INFO1, "copy_data_to_host_var() outputs %d bytes char data destlen = %d \n", len, destlen); switch (bindtype) { case NTBSTRINGBIND: /* strip trailing blanks, null term */ while (len && dres.c[len - 1] == ' ') { --len; } if (limited_dest_space) { if (len + 1 > destlen) { dbperror(dbproc, SYBECOFL, 0); len = destlen - 1; } } memcpy(dest, dres.c, len); dest[len] = '\0'; break; case STRINGBIND: /* pad with blanks, null term */ if (limited_dest_space) { if (len + 1 > destlen) { dbperror(dbproc, SYBECOFL, 0); len = destlen - 1; } } else { destlen = len; } memcpy(dest, dres.c, len); for (i = len; i < destlen - 1; i++) dest[i] = ' '; dest[i] = '\0'; break; case CHARBIND: /* pad with blanks, NO null term */ if (limited_dest_space) { if (len > destlen) { dbperror(dbproc, SYBECOFL, 0); indicator_value = len; len = destlen; } } else { destlen = len; } memcpy(dest, dres.c, len); for (i = len; i < destlen; i++) dest[i] = ' '; break; case VARYCHARBIND: /* strip trailing blanks, NO null term */ if (limited_dest_space) { if (len > sizeof(((DBVARYCHAR *)dest)->str)) { dbperror(dbproc, SYBECOFL, 0); indicator_value = len; len = sizeof(((DBVARYCHAR *)dest)->str); } } memcpy(((DBVARYCHAR *)dest)->str, dres.c, len); ((DBVARYCHAR *)dest)->len = len; break; } free(dres.c); break; default: tdsdump_log(TDS_DBG_INFO1, "error: copy_data_to_host_var(): unrecognized desttype %d \n", desttype); break; } if (indicator) *indicator = indicator_value; return; } #endif /** \internal * \ingroup dblib_internal * \remarks member msgno Vendor-defined message number * \remarks member severity Is passed to the error handler * \remarks member msgtext Text of message */ typedef struct _dblib_error_message { DBINT msgno; int severity; const char *msgtext; } DBLIB_ERROR_MESSAGE; /* * The msgtext member holds up to two strings. The first one is the message text, which may contain placeholders. * The second one, if it exists, is the format string for dbstrbuild(). Messages containing no placeholders still need * an extra NULL to indicate a zero-length format string. */ static const DBLIB_ERROR_MESSAGE dblib_error_messages[] = { { SYBEVERDOWN, EXINFO, "TDS version downgraded to 7.1!\0" } , { SYBEICONVIU, EXCONVERSION, "Some character(s) could not be converted into client's character set\0" } , { SYBEICONVAVAIL, EXCONVERSION, "Character set conversion is not available between client character set '%1!' and " "server character set '%2!'\0%s %s" } , { SYBEICONVO, EXCONVERSION, "Error converting characters into server's character set. Some character(s) could " "not be converted\0" } , { SYBEICONVI, EXCONVERSION, "Some character(s) could not be converted into client's character set. Unconverted " "bytes were changed to question marks ('?')\0" } , { SYBEICONV2BIG, EXCONVERSION, "Buffer overflow converting characters from client into server's character set\0" } , { SYBEPORT, EXUSER, "Both port and instance specified\0" } , { SYBETDSVER, EXUSER, "Cannot bcp with TDSVER < 5.0\0" } , { SYBEAAMT, EXPROGRAM, "User attempted a dbaltbind with mismatched column and variable types\0" } , { SYBEABMT, EXPROGRAM, "User attempted a dbbind with mismatched column and variable types\0" } , { SYBEABNC, EXPROGRAM, "Attempt to bind to a non-existent column\0" } , { SYBEABNP, EXPROGRAM, "Attempt to bind using NULL pointers\0" } , { SYBEABNV, EXPROGRAM, "Attempt to bind to a NULL program variable\0" } , { SYBEACNV, EXCONVERSION, "Attempt to do data-conversion with NULL destination variable.\0" } , { SYBEADST, EXCONSISTENCY, "International Release: Error in attempting to determine the size of a pair of " "translation tables\0" } , { SYBEAICF, EXCONSISTENCY, "International Release: Error in attempting to install custom format\0" } , { SYBEALTT, EXCONSISTENCY, "International Release: Error in attempting to load a pair of translation tables\0" } , { SYBEAOLF, EXRESOURCE, "International Release: Error in attempting to open a localization file\0" } , { SYBEAPCT, EXCONSISTENCY, "International Release: Error in attempting to perform a character set translation\0" } , { SYBEAPUT, EXPROGRAM, "Attempt to print unknown token\0" } , { SYBEARDI, EXRESOURCE, "International Release: Error in attempting to read datetime information from a " "localization file\0" } , { SYBEARDL, EXRESOURCE, "International Release: Error in attempting to read the dblib.loc localization file\0" } , { SYBEASEC, EXPROGRAM, "Attempt to send an empty command buffer to the server\0" } , { SYBEASNL, EXPROGRAM, "Attempt to set fields in a null LOGINREC\0" } , { SYBEASTL, EXPROGRAM, "Synchronous I/O attempted at AST level\0" } , { SYBEASUL, EXPROGRAM, "Attempt to set unknown LOGINREC field\0" } , { SYBEAUTN, EXPROGRAM, "Attempt to update the timestamp of a table that has no timestamp column\0" } , { SYBEBADPK, EXINFO, "Packet size of %1! not supported -- size of %2! used instead!\0%d %d" } , { SYBEBBCI, EXINFO, "Batch successfully bulk copied to the server\0" } , { SYBEBBL, EXPROGRAM, "Bad bindlen parameter passed to dbsetnull\0" } , { SYBEBCBC, EXPROGRAM, "bcp_columns must be called before bcp_colfmt and bcp_colfmt_ps\0" } , { SYBEBCBNPR, EXPROGRAM, "bcp_bind: if varaddr is NULL, prefixlen must be 0 " "and no terminator should be specified\0" } , { SYBEBCBNTYP, EXPROGRAM, "bcp_bind: if varaddr is NULL and varlen greater than 0, the table column type " "must be SYBTEXT or SYBIMAGE and the program variable type must be SYBTEXT, SYBCHAR, " "SYBIMAGE or SYBBINARY\0" } , { SYBEBCBPREF, EXPROGRAM, "Illegal prefix length. Legal values are 0, 1, 2 or 4\0" } , { SYBEBCFO, EXUSER, "bcp host files must contain at least one column\0" } , { SYBEBCHLEN, EXPROGRAM, "host_collen should be greater than or equal to -1\0" } , { SYBEBCIS, EXCONSISTENCY, "Attempt to bulk copy an illegally-sized column value to the server\0" } , { SYBEBCIT, EXPROGRAM, "It is illegal to use BCP terminators with program variables other than SYBCHAR, " "SYBBINARY, SYBTEXT, or SYBIMAGE\0" } , { SYBEBCITBLEN, EXPROGRAM, "bcp_init: tblname parameter is too long\0" } , { SYBEBCITBNM, EXPROGRAM, "bcp_init: tblname parameter cannot be NULL\0" } , { SYBEBCMTXT, EXPROGRAM, "bcp_moretext may be used only when there is at least one text or image column in " "the server table\0" } , { SYBEBCNL, EXNONFATAL, "Negative length-prefix found in BCP data-file\0" } , { SYBEBCNN, EXUSER, "Attempt to bulk copy a NULL value into a Server column " "which does not accept null values\0" } , { SYBEBCNT, EXUSER, "Attempt to use Bulk Copy with a non-existent Server table\0" } , { SYBEBCOR, EXCONSISTENCY, "Attempt to bulk copy an oversized row to the server\0" } , { SYBEBCPB, EXPROGRAM, "bcp_bind, bcp_moretext and bcp_sendrow may not be used after bcp_init has been " "passed a non-NULL input file name\0" } , { SYBEBCPCTYP, EXPROGRAM, "bcp_colfmt: If table_colnum is 0, host_type cannot be 0\0" } , { SYBEBCPI, EXPROGRAM, "bcp_init must be called before any other bcp routines\0" } , { SYBEBCPN, EXPROGRAM, "bcp_bind, bcp_collen, bcp_colptr, bcp_moretext and bcp_sendrow may be used only " "after bcp_init has been called with the copy direction set to DB_IN\0" } , { SYBEBCPREC, EXNONFATAL, "Column %1!: Illegal precision value encountered\0%d" } , { SYBEBCPREF, EXPROGRAM, "Illegal prefix length. Legal values are -1, 0, 1, 2 or 4\0" } , { SYBEBCRE, EXNONFATAL, "I/O error while reading bcp datafile\0" } , { SYBEBCRO, EXINFO, "The BCP hostfile '%1!' contains only %2! rows. It was impossible to read the " "requested %3! rows\0%s %d %d" } , { SYBEBCSA, EXUSER, "The BCP hostfile '%1!' contains only %2! rows. " "Skipping all of these rows is not allowed\0%s %d" } , { SYBEBCSET, EXCONSISTENCY, "Unknown character-set encountered\0" } , { SYBEBCSI, EXPROGRAM, "Host-file columns may be skipped only when copying into the Server\0" } , { SYBEBCSNDROW, EXPROGRAM, "bcp_sendrow may not be called unless all text data for the previous row has been " "sent using bcp_moretext\0" } , { SYBEBCSNTYP, EXPROGRAM, "column number %1!: if varaddr is NULL and varlen greater than 0, the table column " "type must be SYBTEXT or SYBIMAGE and the program variable type must be SYBTEXT, " "SYBCHAR, SYBIMAGE or SYBBINARY\0%d" } , { SYBEBCUC, EXRESOURCE, "bcp: Unable to close host datafile\0" } , { SYBEBCUO, EXRESOURCE, "bcp: Unable to open host datafile\0" } , { SYBEBCVH, EXPROGRAM, "bcp_exec may be called only after bcp_init has been passed a valid host file\0" } , { SYBEBCVLEN, EXPROGRAM, "varlen should be greater than or equal to -1\0" } , { SYBEBCWE, EXNONFATAL, "I/O error while writing bcp datafile\0" } , { SYBEBDIO, EXPROGRAM, "Bad bulk copy direction. Must be either IN or OUT\0" } , { SYBEBEOF, EXNONFATAL, "Unexpected EOF encountered in bcp datafile\0" } , { SYBEBIHC, EXPROGRAM, "Incorrect host-column number found in bcp format file\0" } , { SYBEBIVI, EXPROGRAM, "bcp_columns, bcp_colfmt and bcp_colfmt_ps may be used only after bcp_init has been " "passed a valid input file\0" } , { SYBEBNCR, EXPROGRAM, "Attempt to bind user variable to a non-existent compute row\0" } , { SYBEBNUM, EXPROGRAM, "Bad numbytes parameter passed to dbstrcpy\0" } , { SYBEBPKS, EXPROGRAM, "In DBSETLPACKET, the packet size parameter must be between 0 and 999999\0" } , { SYBEBPREC, EXPROGRAM, "Illegal precision specified\0" } , { SYBEBPROBADDEF, EXCONSISTENCY, "bcp protocol error: illegal default column id received\0" } , { SYBEBPROCOL, EXCONSISTENCY, "bcp protocol error: returned column count differs from the actual number of " "columns received\0" } , { SYBEBPRODEF, EXCONSISTENCY, "bcp protocol error: expected default information and got none\0" } , { SYBEBPRODEFID, EXCONSISTENCY, "bcp protocol error: default column id and actual column id are not same\0" } , { SYBEBPRODEFTYP, EXCONSISTENCY, "bcp protocol error: default value datatype differs from column datatype\0" } , { SYBEBPROEXTDEF, EXCONSISTENCY, "bcp protocol error: more than one row of default information received\0" } , { SYBEBPROEXTRES, EXCONSISTENCY, "bcp protocol error: unexpected set of results received\0" } , { SYBEBPRONODEF, EXCONSISTENCY, "bcp protocol error: default value received for column that does not have default\0" } , { SYBEBPRONUMDEF, EXCONSISTENCY, "bcp protocol error: expected number of defaults differs from the actual number of " "defaults received\0" } , { SYBEBRFF, EXRESOURCE, "I/O error while reading bcp format file\0" } , { SYBEBSCALE, EXPROGRAM, "Illegal scale specified\0" } , { SYBEBTMT, EXPROGRAM, "Attempt to send too much text data via the bcp_moretext call\0" } , { SYBEBTOK, EXCOMM, "Bad token from the server: Datastream processing out of sync\0" } , { SYBEBTYP, EXPROGRAM, "Unknown bind type passed to DB-Library function\0" } , { SYBEBTYPSRV, EXPROGRAM, "Datatype is not supported by the server\0" } , { SYBEBUCE, EXRESOURCE, "bcp: Unable to close error file\0" } , { SYBEBUCF, EXPROGRAM, "bcp: Unable to close format file\0" } , { SYBEBUDF, EXPROGRAM, "bcp: Unrecognized datatype found in format file\0" } , { SYBEBUFF, EXPROGRAM, "bcp: Unable to create format file\0" } , { SYBEBUFL, EXCONSISTENCY, "DB-Library internal error-send buffer length corrupted\0" } , { SYBEBUOE, EXRESOURCE, "bcp: Unable to open error file\0" } , { SYBEBUOF, EXPROGRAM, "bcp: Unable to open format file\0" } , { SYBEBWEF, EXNONFATAL, "I/O error while writing bcp error file\0" } , { SYBEBWFF, EXRESOURCE, "I/O error while writing bcp format file\0" } , { SYBECAP, EXCOMM, "DB-Library capabilities not accepted by the Server\0" } , { SYBECAPTYP, EXCOMM, "Unexpected capability type in CAPABILITY datastream\0" } , { SYBECDNS, EXCONSISTENCY, "Datastream indicates that a compute column is derived from a non-existent select " "list member\0" } , { SYBECDOMAIN, EXCONVERSION, "Source field value is not within the domain of legal values\0" } , { SYBECINTERNAL, EXCONVERSION, "Internal Conversion error\0" } , { SYBECLOS, EXCOMM, "Error in closing network connection\0" } , { SYBECLPR, EXCONVERSION, "Data conversion resulted in loss of precision\0" } , { SYBECNOR, EXPROGRAM, "Column number out of range\0" } , { SYBECNOV, EXCONVERSION, "Attempt to set variable to NULL resulted in overflow\0" } , { SYBECOFL, EXCONVERSION, "Data conversion resulted in overflow\0" } , { SYBECONN, EXCOMM, "Unable to connect: Adaptive Server is unavailable or does not exist\0" } , { SYBECRNC, EXPROGRAM, "The current row is not a result of compute clause %1!, so it is illegal to attempt " "to extract that data from this row\0%d" } , { SYBECRSAGR, EXPROGRAM, "Aggregate functions are not allowed in a cursor statement\0" } , { SYBECRSBROL, EXPROGRAM, "Backward scrolling cannot be used in a forward scrolling cursor\0" } , { SYBECRSBSKEY, EXPROGRAM, "Keyset cannot be scrolled backward in mixed cursors with a previous fetch type\0" } , { SYBECRSBUFR, EXPROGRAM, "Row buffering should not be turned on when using cursor APIs\0" } , { SYBECRSDIS, EXPROGRAM, "Cursor statement contains one of the disallowed phrases compute, union, for " "browse, or select into\0" } , { SYBECRSFLAST, EXPROGRAM, "Fetch type LAST requires fully keyset driven cursors\0" } , { SYBECRSFRAND, EXPROGRAM, "Fetch types RANDOM and RELATIVE can only be used within the keyset of keyset " "driven cursors\0" } , { SYBECRSFROWN, EXPROGRAM, "Row number to be fetched is outside valid range\0" } , { SYBECRSFTYPE, EXRESOURCE, "Unknown fetch type\0" } , { SYBECRSINV, EXPROGRAM, "Invalid cursor statement\0" } , { SYBECRSINVALID, EXRESOURCE, "The cursor handle is invalid\0" } , { SYBECRSMROWS, EXRESOURCE, "Multiple rows are returned, only one is expected while retrieving dbname\0" } , { SYBECRSNOBIND, EXPROGRAM, "Cursor bind must be called prior to dbcursor invocation\0" } , { SYBECRSNOCOUNT, EXPROGRAM, "The DBNOCOUNT option should not be turned on " "when doing updates or deletes with dbcursor\0" } , { SYBECRSNOFREE, EXPROGRAM, "The DBNOAUTOFREE option should not be turned on when using cursor APIs\0" } , { SYBECRSNOIND, EXPROGRAM, "One of the tables involved in the cursor statement does not have a unique index\0" } , { SYBECRSNOKEYS, EXRESOURCE, "The entire keyset must be defined for KEYSET type cursors\0" } , { SYBECRSNOLEN, EXRESOURCE, "No unique index found\0" } , { SYBECRSNOPTCC, EXRESOURCE, "No OPTCC was found\0" } , { SYBECRSNORDER, EXRESOURCE, "The order of clauses must be from, where, and order by\0" } , { SYBECRSNORES, EXPROGRAM, "Cursor statement generated no results\0" } , { SYBECRSNROWS, EXRESOURCE, "No rows returned, at least one is expected\0" } , { SYBECRSNOTABLE, EXRESOURCE, "Table name is NULL\0" } , { SYBECRSNOUPD, EXPROGRAM, "Update or delete operation did not affect any rows\0" } , { SYBECRSNOWHERE, EXPROGRAM, "A WHERE clause is not allowed in a cursor update or insert\0" } , { SYBECRSNUNIQUE, EXRESOURCE, "No unique keys associated with this view\0" } , { SYBECRSORD, EXPROGRAM, "Only fully keyset driven cursors can have order by, group by, or having phrases\0" } , { SYBECRSRO, EXPROGRAM, "Data locking or modifications cannot be made in a READONLY cursor\0" } , { SYBECRSSET, EXPROGRAM, "A SET clause is required for a cursor update or insert\0" } , { SYBECRSTAB, EXPROGRAM, "Table name must be determined in operations involving data locking or modifications\0" } , { SYBECRSVAR, EXRESOURCE, "There is no valid address associated with this bind\0" } , { SYBECRSVIEW, EXPROGRAM, "A view cannot be joined with another table or a view in a cursor statement\0" } , { SYBECRSVIIND, EXPROGRAM, "The view used in the cursor statement does not include all the unique index " "columns of the underlying tables\0" } , { SYBECRSUPDNB, EXPROGRAM, "Update or insert operations cannot use bind variables when binding type is NOBIND\0" } , { SYBECRSUPDTAB, EXPROGRAM, "Update or insert operations using bind variables require single table cursors\0" } , { SYBECSYN, EXCONVERSION, "Attempt to convert data stopped by syntax error in source field\0" } , { SYBECUFL, EXCONVERSION, "Data conversion resulted in underflow\0" } , { SYBECWLL, EXPROGRAM, "Attempt to set column width less than 1\0" } , { SYBEDBPS, EXRESOURCE, "Maximum number of DBPROCESSes already allocated\0" } , { SYBEDDNE, EXINFO, "DBPROCESS is dead or not enabled\0" } , { SYBEDIVZ, EXUSER, "Attempt to divide by $0.00 in function %1!\0%s" } , { SYBEDNTI, EXPROGRAM, "Attempt to use dbtxtsput to put a new text timestamp into a column whose datatype " "is neither SYBTEXT nor SYBIMAGE\0" } , { SYBEDPOR, EXPROGRAM, "Out-of-range datepart constant\0" } , { SYBEDVOR, EXPROGRAM, "Day values must be between 1 and 7\0" } , { SYBEECAN, EXINFO, "Attempted to cancel unrequested event notification\0" } , { SYBEEINI, EXINFO, "Must call dbreginit before dbregexec\0" } , { SYBEETD, EXPROGRAM, "Failure to send the expected amount of TEXT or IMAGE data via dbmoretext\0" } , { SYBEEUNR, EXCOMM, "Unsolicited event notification received\0" } , { SYBEEVOP, EXINFO, "Called dbregwatch with a bad options parameter\0" } , { SYBEEVST, EXINFO, "Must initiate a transaction before calling dbregparam\0" } , { SYBEFCON, EXCOMM, "Adaptive Server connection failed\0" } , { SYBEFRES, EXFATAL, "Challenge-Response function failed\0" } , { SYBEFSHD, EXRESOURCE, "Error in attempting to find the Sybase home directory\0" } , { SYBEFUNC, EXPROGRAM, "Functionality not supported at the specified version level\0" } , { SYBEICN, EXPROGRAM, "Invalid computeid or compute column number\0" } , { SYBEIDCL, EXCONSISTENCY, "Illegal datetime column length returned by Adaptive Server. Legal datetime lengths " "are 4 and 8 bytes\0" } , { SYBEIDECCL, EXCONSISTENCY, "Invalid decimal column length returned by the server\0" } , { SYBEIFCL, EXCONSISTENCY, "Illegal floating-point column length returned by Adaptive Server. Legal " "floating-point lengths are 4 and 8 bytes\0" } , { SYBEIFNB, EXPROGRAM, "Illegal field number passed to bcp_control\0" } , { SYBEIICL, EXCONSISTENCY, "Illegal integer column length returned by Adaptive Server. Legal integer lengths " "are 1, 2, and 4 bytes\0" } , { SYBEIMCL, EXCONSISTENCY, "Illegal money column length returned by Adaptive Server. Legal money lengths are 4 " "and 8 bytes\0" } , { SYBEINLN, EXUSER, "Interface file: unexpected end-of-line\0" } , { SYBEINTF, EXUSER, "Server name not found in configuration files\0" } , { SYBEINUMCL, EXCONSISTENCY, "Invalid numeric column length returned by the server\0" } , { SYBEIPV, EXINFO, "%1! is an illegal value for the %2! parameter of %3!\0%d %s %s" } , { SYBEISOI, EXCONSISTENCY, "International Release: Invalid sort-order information found\0" } , { SYBEISRVPREC, EXCONSISTENCY, "Illegal precision value returned by the server\0" } , { SYBEISRVSCL, EXCONSISTENCY, "Illegal scale value returned by the server\0" } , { SYBEITIM, EXPROGRAM, "Illegal timeout value specified\0" } , { SYBEIVERS, EXPROGRAM, "Illegal version level specified\0" } , { SYBEKBCI, EXINFO, "1000 rows sent to the server\0" } , { SYBEKBCO, EXINFO, "1000 rows successfully bulk copied to host file\0" } , { SYBEMEM, EXRESOURCE, "Unable to allocate sufficient memory\0" } , { SYBEMOV, EXUSER, "Money arithmetic resulted in overflow in function %1!\0%s" } , { SYBEMPLL, EXUSER, "Attempt to set maximum number of DBPROCESSes lower than 1\0" } , { SYBEMVOR, EXPROGRAM, "Month values must be between 1 and 12\0" } , { SYBENBUF, EXINFO, "Called dbsendpassthru with a NULL buf parameter\0" } , { SYBENBVP, EXPROGRAM, "Cannot pass dbsetnull a NULL bindval pointer\0" } , { SYBENDC, EXPROGRAM, "Cannot have negative component in date in numeric form\0" } , { SYBENDTP, EXPROGRAM, "Called dbdatecrack with NULL datetime parameter\0" } , { SYBENEG, EXCOMM, "Negotiated login attempt failed\0" } , { SYBENHAN, EXINFO, "Called dbrecvpassthru with a NULL handle parameter\0" } , { SYBENMOB, EXPROGRAM, "No such member of order by clause\0" } , { SYBENOEV, EXINFO, "DBPOLL can not be called when registered procedure notifications have been disabled\0" } , { SYBENPRM, EXPROGRAM, "NULL parameter not allowed for this dboption\0" } , { SYBENSIP, EXPROGRAM, "Negative starting index passed to dbstrcpy\0" } , { SYBENTLL, EXUSER, "Name too long for LOGINREC field\0" } , { SYBENTTN, EXPROGRAM, "Attempt to use dbtxtsput to put a new text timestamp into a non-existent data row\0" } , { SYBENULL, EXINFO, "NULL DBPROCESS pointer passed to DB-Library\0" } , { SYBENULP, EXPROGRAM, "Called %1! with parameter %2! NULL\0%s %d" } , { SYBENXID, EXNONFATAL, "The Server did not grant us a distributed-transaction ID\0" } , { SYBEONCE, EXPROGRAM, "Function can be called only once\0" } , { SYBEOOB, EXCOMM, "Error in sending out-of-band data to the server\0" } , { SYBEOPIN, EXNONFATAL, "Could not open interface file\0" } , { SYBEOPNA, EXNONFATAL, "Option is not available with current server\0" } , { SYBEOREN, EXINFO, "International Release: Warning: an out-of-range error-number was encountered in " "dblib.loc. The maximum permissible error-number is defined as DBERRCOUNT in sybdb.h\0" } , { SYBEORPF, EXUSER, "Attempt to set remote password would overflow " "the login record's remote password field\0" } , { SYBEPOLL, EXINFO, "There is already an active dbpoll\0" } , { SYBEPRTF, EXINFO, "dbtracestring may only be called from a printfunc\0" } , { SYBEPWD, EXUSER, "Login incorrect\0" } , { SYBERDCN, EXCONVERSION, "Requested data conversion does not exist\0" } , { SYBERDNR, EXPROGRAM, "Attempt to retrieve data from a non-existent row\0" } , { SYBEREAD, EXCOMM, "Read from the server failed\0" } , { SYBERESP, EXPROGRAM, "Response function address passed to dbresponse must be non-NULL\0" } , { SYBERPCS, EXINFO, "Must call dbrpcinit before dbrpcparam or dbrpcsend\0" } , { SYBERPIL, EXPROGRAM, "It is illegal to pass -1 to dbrpcparam for the datalen of parameters which are of " "type SYBCHAR, SYBVARCHAR, SYBBINARY, or SYBVARBINARY\0" } , { SYBERPNA, EXNONFATAL, "The RPC facility is available only when using a server whose version number is 4.0 " "or later\0" } , { SYBERPND, EXPROGRAM, "Attempt to initiate a new Adaptive Server operation with results pending\0" } , { SYBERPNULL, EXPROGRAM, "value parameter for dbrpcparam can be NULL, only if the datalen parameter is 0\0" } , { SYBERPTXTIM, EXPROGRAM, "RPC parameters cannot be of type text or image\0" } , { SYBERPUL, EXPROGRAM, "When passing a SYBINTN, SYBDATETIMN, SYBMONEYN, or SYBFLTN parameter via " "dbrpcparam, it is necessary to specify the parameter's maximum or actual length so " "that DB-Library can recognize it as a SYINT1, SYBINT2, SYBINT4, SYBMONEY, SYBMONEY4, " "and so on\0" } , { SYBERTCC, EXPROGRAM, "dbreadtext may not be used to receive the results of a query that contains a " "COMPUTE clause\0" } , { SYBERTSC, EXPROGRAM, "dbreadtext may be used only to receive the results of a query that contains a " "single result column\0" } , { SYBERXID, EXNONFATAL, "The Server did not recognize our distributed-transaction ID\0" } , { SYBESECURE, EXPROGRAM, "Secure SQL Server function not supported in this version\0" } , { SYBESEFA, EXPROGRAM, "DBSETNOTIFS cannot be called if connections are present\0" } , { SYBESEOF, EXCOMM, "Unexpected EOF from the server\0" } , { SYBESFOV, EXPROGRAM, "International Release: dbsafestr overflowed its destination buffer\0" } , { SYBESMSG, EXSERVER, "General Adaptive Server error: Check messages from the server\0" } , { SYBESOCK, EXCOMM, "Unable to open socket\0" } , { SYBESPID, EXPROGRAM, "Called dbspid with a NULL dbproc\0" } , { SYBESYNC, EXCOMM, "Read attempted while out of synchronization with Adaptive Server\0" } , { SYBETEXS, EXINFO, "Called dbmoretext with a bad size parameter\0" } , { SYBETIME, EXTIME, "Adaptive Server connection timed out\0" } , { SYBETMCF, EXPROGRAM, "Attempt to install too many custom formats via dbfmtinstall\0" } , { SYBETMTD, EXPROGRAM, "Attempt to send too much TEXT data via the dbmoretext call\0" } , { SYBETPAR, EXPROGRAM, "No SYBTEXT or SYBIMAGE parameters were defined\0" } , { SYBETPTN, EXUSER, "Syntax error: only two periods are permitted in table names\0" } , { SYBETRAC, EXINFO, "Attempted to turn off a trace flag that was not on\0" } , { SYBETRAN, EXINFO, "DBPROCESS is being used for another transaction\0" } , { SYBETRAS, EXINFO, "DB-Library internal error - trace structure not found\0" } , { SYBETRSN, EXINFO, "Bad numbytes parameter passed to dbtracestring\0" } , { SYBETSIT, EXINFO, "Attempt to call dbtsput with an invalid timestamp\0" } , { SYBETTS, EXUSER, "The table which bulk copy is attempting to copy to a host file is shorter than the " "number of rows which bulk copy was instructed to skip\0" } , { SYBETYPE, EXINFO, "Invalid argument type given to Hyper/DB-Library\0" } , { SYBEUCPT, EXUSER, "Unrecognized custom-format parameter-type encountered in dbstrbuild\0" } , { SYBEUCRR, EXCONSISTENCY, "Internal software error: Unknown connection result reported by dbpasswd\0" } , { SYBEUDTY, EXCONSISTENCY, "Unknown datatype encountered\0" } , { SYBEUFDS, EXUSER, "Unrecognized format encountered in dbstrbuild\0" } , { SYBEUFDT, EXCONSISTENCY, "Unknown fixed-length datatype encountered\0" } , { SYBEUHST, EXUSER, "Unknown host machine name\0" } , { SYBEUMSG, EXCOMM, "Unknown message-id in MSG datastream\0" } , { SYBEUNAM, EXFATAL, "Unable to get current user name from operating system\0" } , { SYBEUNOP, EXNONFATAL, "Unknown option passed to dbsetopt\0" } , { SYBEUNT, EXUSER, "Unknown network type found in interface file\0" } , { SYBEURCI, EXRESOURCE, "International Release: Unable to read copyright information from the DB-Library " "localization file\0" } , { SYBEUREI, EXRESOURCE, "International Release: Unable to read error information from the DB-Library " "localization file\0" } , { SYBEUREM, EXRESOURCE, "International Release: Unable to read error mnemonic from the DB-Library " "localization file\0" } , { SYBEURES, EXRESOURCE, "International Release: Unable to read error string from the DB-Library " "localization file. 401 Error severities\0" } , { SYBEURMI, EXRESOURCE, "International Release: Unable to read money-format information from the DB-Library " "localization file\0" } , { SYBEUSCT, EXCOMM, "Unable to set communications timer\0" } , { SYBEUTDS, EXCOMM, "Unrecognized TDS version received from the server\0" } , { SYBEUVBF, EXPROGRAM, "Attempt to read an unknown version of bcp format file\0" } , { SYBEUVDT, EXCONSISTENCY, "Unknown variable-length datatype encountered\0" } , { SYBEVDPT, EXUSER, "For bulk copy, all variable-length data must have either a length-prefix or a " "terminator specified\0" } , { SYBEWAID, EXCONSISTENCY, "DB-Library internal error: ALTFMT following ALTNAME has wrong id\0" } , { SYBEWRIT, EXCOMM, "Write to the server failed\0" } , { SYBEXOCI, EXNONFATAL, "International Release: A character-set translation overflowed its destination " "buffer while using bcp to copy data from a host-file to the server\0" } , { SYBEXTDN, EXPROGRAM, "Warning: the xlt_todisp parameter to dbfree_xlate was NULL. The space associated " "with the xlt_tosrv parameter has been freed\0" } , { SYBEXTN, EXPROGRAM, "The xlt_tosrv and xlt_todisp parameters to dbfree_xlate were NULL\0" } , { SYBEXTSN, EXPROGRAM, "Warning: the xlt_tosrv parameter to dbfree_xlate was NULL. The space associated " "with the xlt_todisp parameter has been freed\0" } , { SYBEZTXT, EXINFO, "Attempt to send zero length TEXT or IMAGE to dataserver via dbwritetext\0" } , { SYBECOLSIZE, EXINFO, "Invalid column information structure size\0" } }; /** \internal * \ingroup dblib_internal * \brief Call client-installed error handler * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param msgno identifies the error message to be passed to the client's handler. * \param errnum identifies the OS error (errno), if any. Use 0 if not applicable. * \returns the handler's return code, subject to correction and adjustment for vendor style: * - INT_CANCEL The db-lib function that encountered the error will return FAIL. * - INT_TIMEOUT The db-lib function will cancel the operation and return FAIL. \a dbproc remains useable. * - INT_CONTINUE The db-lib function will retry the operation. * \remarks * The client-installed handler may also return INT_EXIT. If Sybase semantics are used, this function notifies * the user and calls exit(3). If Microsoft semantics are used, this function returns INT_CANCEL. * * If the client-installed handler returns something other than these four INT_* values, or returns timeout-related * value for anything but SYBETIME, it's treated here as INT_EXIT (see above). * * Instead of sprinkling error text all over db-lib, we consolidate it here, * where it can be translated (one day), and where it can be mapped to the TDS error number. * The libraries don't use consistent error numbers or messages, so when libtds has to emit * an error message, it can't include the text. It can pass its error number to a client-library * function, which will interpret it, add the text, call the application's installed handler * (if any) and return the handler's return code back to the caller. * * The call stack may look something like this: * * -# application * -# db-lib function (encounters error) * -# dbperror * -# error handler (installed by application) * * The error handling in this case is unambiguous: the caller invokes this function, the client's handler returns its * instruction, which the caller receives. Quite often the caller will get INT_CANCEL, in which case it should put its * house in order and return FAIL. * * The call stack may otherwise look something like this: * * -# application * -# db-lib function * -# libtds function (encounters error) * -# _dblib_handle_err_message * -# dbperror * -# error handler (installed by application) * * Because different client libraries specify their handler semantics differently, * and because libtds doesn't know which client library is in charge of any given connection, it cannot interpret the * raw return code from a db-lib error handler. For these reasons, * libtds calls _dblib_handle_err_message, which translates between libtds and db-lib semantics. * \sa dberrhandle(), _dblib_handle_err_message(). */ int dbperror (DBPROCESS *dbproc, DBINT msgno, long errnum, ...) { static const char int_exit_text[] = "FreeTDS: db-lib: exiting because client error handler returned %s for msgno %d\n"; static const char int_invalid_text[] = "%s (%d) received from client-installed error handler for nontimeout for error %d." " Treating as INT_EXIT\n"; static const DBLIB_ERROR_MESSAGE default_message = { 0, EXCONSISTENCY, "unrecognized msgno" }; DBLIB_ERROR_MESSAGE constructed_message = { 0, EXCONSISTENCY, NULL }; const DBLIB_ERROR_MESSAGE *msg = &default_message; int i, rc = INT_CANCEL; const char *os_msgtext = strerror(errnum), *rc_name = "logic error"; char rc_buf[16]; tdsdump_log(TDS_DBG_FUNC, "dbperror(%p, %d, %ld)\n", dbproc, msgno, errnum); /* dbproc can be NULL */ #ifdef _WIN32 /* * Unfortunately MingW uses the "old" msvcrt.dll (Visual C++ 2005 uses * a newer version) which does not set errno when allocation functions * cannot allocate memory, so we do it for them. */ if (msgno == SYBEMEM) errnum = ENOMEM; #endif if (os_msgtext == NULL) os_msgtext = "no OS error"; assert(_dblib_err_handler != NULL); /* always installed by dbinit() or dberrhandle() */ /* look up the error message */ for (i=0; i < TDS_VECTOR_SIZE(dblib_error_messages); i++ ) { if (dblib_error_messages[i].msgno == msgno) { /* * See if the message has placeholders. If so, build a message string on the heap. * The presence of placeholders is indicated by the existence of a "string after the string", * i.e., a format string (for dbstrbuild) after a null "terminator" in the message. * On error -- can't allocate, can't build the string -- give up and call the client handler anyway. */ const char * ptext = dblib_error_messages[i].msgtext; const char * pformats = ptext + strlen(ptext) + 1; msg = &dblib_error_messages[i]; assert(*(pformats - 1) == '\0'); if(*pformats != '\0') { va_list ap; int result_len, len = 2 * (int)strlen(ptext); char * buffer = tds_new0(char, len); if (buffer == NULL) break; va_start(ap, errnum); rc = tds_vstrbuild(buffer, len, &result_len, ptext, TDS_NULLTERM, pformats, TDS_NULLTERM, ap); buffer[result_len] = '\0'; va_end(ap); if (TDS_FAILED(rc)) { free(buffer); break; } constructed_message.msgtext = buffer; constructed_message.severity = msg->severity; msg = &constructed_message; } break; } } if (dbproc && dbproc->tds_socket && dbproc->tds_socket->login) { DSTR server_name_dstr = dbproc->tds_socket->login->server_name; if (!tds_dstr_isempty(&server_name_dstr)) { char * buffer = NULL; if (asprintf(&buffer, "%s (%s)", msg->msgtext, tds_dstr_cstr(&server_name_dstr)) >= 0) { free((char*) constructed_message.msgtext); constructed_message.msgtext = buffer; constructed_message.severity = msg->severity; msg = &constructed_message; } } } tdsdump_log(TDS_DBG_FUNC, "dbperror: Calling dblib_err_handler with msgno = %d; msg->msgtext = \"%s\"\n", msgno, msg->msgtext); /* call the error handler */ rc = (*_dblib_err_handler)(dbproc, msg->severity, msgno, errnum, (char*) msg->msgtext, (char*) os_msgtext); switch (rc) { case INT_EXIT: rc_name = "INT_EXIT"; break; case INT_CONTINUE: rc_name = "INT_CONTINUE"; break; case INT_CANCEL: rc_name = "INT_CANCEL"; break; case INT_TIMEOUT: rc_name = "INT_TIMEOUT"; break; default: rc_name = "invalid"; break; } tdsdump_log(TDS_DBG_FUNC, "dbperror: dblib_err_handler for msgno = %d; msg->msgtext = \"%s\" -- returns %d (%s)\n", msgno, msg->msgtext, rc, rc_name); /* we're done with the dynamic string now. */ free((char*) constructed_message.msgtext); /* Timeout return codes are errors for non-timeout conditions. */ if (msgno != SYBETIME) { switch (rc) { case INT_CONTINUE: tdsdump_log(TDS_DBG_SEVERE, int_invalid_text, "INT_CONTINUE", rc, msgno); rc = INT_EXIT; break; case INT_TIMEOUT: tdsdump_log(TDS_DBG_SEVERE, int_invalid_text, "INT_TIMEOUT", rc, msgno); rc = INT_EXIT; break; default: break; } } /* * Sybase exits on INT_EXIT; Microsoft converts to INT_CANCEL. * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dblibc/dbc_pdc04c_6v39.asp */ switch (rc) { case INT_CONTINUE: /* Microsoft does not define INT_TIMEOUT. Instead, two consecutive INT_CONTINUEs yield INT_CANCEL. */ if (dbproc && dbproc->msdblib && ++dbproc->ntimeouts >=2) { dbproc->ntimeouts = 0; rc = INT_CANCEL; } /* fall through */ case INT_CANCEL: case INT_TIMEOUT: return rc; /* normal case */ break; default: sprintf(rc_buf, "%d", rc); rc_name = rc_buf; tdsdump_log(TDS_DBG_SEVERE, int_invalid_text, "Invalid return code", rc, msgno); /* fall through */ case INT_EXIT: if (dbproc && dbproc->msdblib) { /* Microsoft behavior */ return INT_CANCEL; } fprintf(stderr, int_exit_text, rc_name, msgno); tdsdump_log(TDS_DBG_SEVERE, int_exit_text, rc_name, msgno); break; } exit(EXIT_FAILURE); return rc; /* not reached */ } freetds-1.00.82/src/dblib/dbutil.c100644 025423 025423 00000017650 12717145107 0012336/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_ERRNO_H # include #endif /* HAVE_ERRNO_H */ #include #include #include #include #include /* * test include consistency * I don't think all compiler are able to compile this code... if not comment it */ #if ENABLE_EXTRA_CHECKS /* TODO test SYBxxx consistency */ #define TEST_ATTRIBUTE(t,sa,fa,sb,fb) \ TDS_COMPILE_CHECK(t,sizeof(((sa*)0)->fa) == sizeof(((sb*)0)->fb) && TDS_OFFSET(sa,fa) == TDS_OFFSET(sb,fb)) TEST_ATTRIBUTE(t21,TDS_MONEY4,mny4,DBMONEY4,mny4); TEST_ATTRIBUTE(t22,TDS_OLD_MONEY,mnyhigh,DBMONEY,mnyhigh); TEST_ATTRIBUTE(t23,TDS_OLD_MONEY,mnylow,DBMONEY,mnylow); TEST_ATTRIBUTE(t24,TDS_DATETIME,dtdays,DBDATETIME,dtdays); TEST_ATTRIBUTE(t25,TDS_DATETIME,dttime,DBDATETIME,dttime); TEST_ATTRIBUTE(t26,TDS_DATETIME4,days,DBDATETIME4,days); TEST_ATTRIBUTE(t27,TDS_DATETIME4,minutes,DBDATETIME4,minutes); TEST_ATTRIBUTE(t28,TDS_NUMERIC,precision,DBNUMERIC,precision); TEST_ATTRIBUTE(t29,TDS_NUMERIC,scale,DBNUMERIC,scale); TEST_ATTRIBUTE(t30,TDS_NUMERIC,array,DBNUMERIC,array); #endif /* * The next 2 functions receive the info and error messages that come from the TDS layer. * The address of this function is passed to the TDS layer in dbinit(). * It takes a pointer to a DBPROCESS, it's just that the TDS layer didn't * know what it really was. */ int _dblib_handle_info_message(const TDSCONTEXT * tds_ctx, TDSSOCKET * tds, TDSMESSAGE * msg) { DBPROCESS *dbproc = (tds && tds_get_parent(tds))? (DBPROCESS *) tds_get_parent(tds) : NULL; tdsdump_log(TDS_DBG_FUNC, "_dblib_handle_info_message(%p, %p, %p)\n", tds_ctx, tds, msg); tdsdump_log(TDS_DBG_FUNC, "msgno %d: \"%s\"\n", msg->msgno, msg->message); /* * Check to see if the user supplied a function, else ignore the message. */ if (_dblib_msg_handler) { _dblib_msg_handler(dbproc, msg->msgno, msg->state, msg->severity, msg->message, msg->server, msg->proc_name, msg->line_number); } if (msg->severity > 10 && _dblib_err_handler) { /* call the application's error handler, if installed. */ /* * Sybase docs say SYBESMSG is generated only in specific * cases (severity greater than 16, or deadlock occurred, or * a syntax error occurred.) However, actual observed * behavior is that SYBESMSG is always generated for * server messages with severity greater than 10. */ /* Cannot call dbperror() here because server messsage numbers (and text) are not in its lookup table. */ static const char message[] = "General SQL Server error: Check messages from the SQL Server"; (*_dblib_err_handler)(dbproc, msg->severity, SYBESMSG, DBNOERR, (char *) message, NULL); } return TDS_SUCCESS; } /** \internal * \dblib_internal * \brief handle errors generated by libtds * \param tds_ctx actually a dbproc: contains all information needed by db-lib to manage communications with the server. * \param tds contains all information needed by libtds to manage communications with the server. * \param msg the message to send * \returns * \remarks This function is called by libtds via tds_ctx->err_handler. It exists to convert the db-lib * error handler's return code into one that libtds will know how to handle. * libtds conveniently issues msgno's with the same values and meanings as db-lib and ODBC use. * (N.B. ODBC actually uses db-lib msgno numbers for its driver-specific "server errors". */ /* * Stack: * libtds * tds_ctx->err_handler (pointer to _dblib_handle_err_message) * _dblib_handle_err_message * dbperror * client (or default) error handler * returns db-lib defined return code INT_something. * returns db-lib return code with Sybase semantics (adjusting client's code if need be) * returns libtds return code * decides what to do based on the universal libtds return code, thank you. */ int _dblib_handle_err_message(const TDSCONTEXT * tds_ctx, TDSSOCKET * tds, TDSMESSAGE * msg) { DBPROCESS *dbproc = (tds && tds_get_parent(tds))? (DBPROCESS *) tds_get_parent(tds) : NULL; int rc = INT_CANCEL; assert(_dblib_err_handler); assert(msg); rc = dbperror(dbproc, msg->msgno, msg->oserr); /* * Preprocess the return code to handle INT_TIMEOUT/INT_CONTINUE * for non-SYBETIME errors in the strange and different ways as * specified by Sybase and Microsoft. */ if (msg->msgno != SYBETIME) { switch (rc) { case INT_TIMEOUT: rc = INT_EXIT; break; case INT_CONTINUE: if (!dbproc || !dbproc->msdblib) { /* Sybase behavior */ assert(0); /* dbperror() should prevent */ rc = INT_EXIT; } else { /* Microsoft behavior */ rc = INT_CANCEL; } break; default: break; } } /* * Convert db-lib return code to libtds return code, and return. */ switch (rc) { case INT_CANCEL: return TDS_INT_CANCEL; case INT_TIMEOUT: return TDS_INT_TIMEOUT; case INT_CONTINUE: return TDS_INT_CONTINUE; case INT_EXIT: assert(0); /* dbperror() should prevent */ default: /* unknown return code from error handler */ exit(EXIT_FAILURE); break; } /* not reached */ assert(0); return TDS_INT_CANCEL; } /** * \ingroup dblib_internal * \brief check interrupts for libtds. * * \param vdbproc a DBPROCESS pointer, contains all information needed by db-lib to manage communications with the server. * \sa DBDEAD(), dbsetinterrupt(). */ int _dblib_check_and_handle_interrupt(void * vdbproc) { DBPROCESS * dbproc = (DBPROCESS*) vdbproc; int ret = INT_CONTINUE; assert( dbproc != NULL ); if (dbproc->chkintr == NULL || dbproc->hndlintr == NULL) return INT_CONTINUE; tdsdump_log(TDS_DBG_FUNC, "_dblib_check_and_handle_interrupt %p [%p, %p]\n", dbproc, dbproc->chkintr, dbproc->hndlintr); if (dbproc->chkintr(dbproc)){ switch (ret = dbproc->hndlintr(dbproc)) { case INT_EXIT: tdsdump_log(TDS_DBG_FUNC, "dbproc->hndlintr returned INT_EXIT, goodbye!\n"); exit(1); case INT_CANCEL: tdsdump_log(TDS_DBG_FUNC, "dbproc->hndlintr returned INT_CANCEL\n"); break; case INT_CONTINUE: tdsdump_log(TDS_DBG_FUNC, "dbproc->hndlintr returned INT_CONTINUE\n"); break; default: tdsdump_log(TDS_DBG_FUNC, "dbproc->hndlintr returned an invalid value (%d), returning INT_CONTINUE\n", ret); ret = INT_CONTINUE; break; } } return ret; } void _dblib_setTDS_version(TDSLOGIN * tds_login, DBINT version) { switch (version) { case DBVERSION_42: tds_set_version(tds_login, 4, 2); break; case DBVERSION_46: tds_set_version(tds_login, 4, 6); break; case DBVERSION_100: tds_set_version(tds_login, 5, 0); break; } } void _dblib_convert_err(DBPROCESS * dbproc, TDS_INT len) { switch (len) { case TDS_CONVERT_NOAVAIL: dbperror(dbproc, SYBERDCN, 0); break; case TDS_CONVERT_SYNTAX: dbperror(dbproc, SYBECSYN, 0); break; case TDS_CONVERT_NOMEM: dbperror(dbproc, SYBEMEM, ENOMEM); break; case TDS_CONVERT_OVERFLOW: dbperror(dbproc, SYBECOFL, 0); break; default: case TDS_CONVERT_FAIL: dbperror(dbproc, SYBECINTERNAL, 0); break; } } freetds-1.00.82/src/dblib/rpc.c100644 025423 025423 00000034142 12717145107 0011632/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001 Brian Bruns * Copyright (C) 2002, 2003, 2004, 2005 James K. Lowden * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #ifdef HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #ifdef HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #ifdef HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_ERRNO_H # include #endif /* HAVE_ERRNO_H */ #include #include #include #include #include #include #include #include static void rpc_clear(DBREMOTE_PROC * rpc); static void param_clear(DBREMOTE_PROC_PARAM * pparam); static TDSPARAMINFO *param_info_alloc(TDSSOCKET * tds, DBREMOTE_PROC * rpc); /** * \ingroup dblib_rpc * \brief Initialize a remote procedure call. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param rpcname name of the stored procedure to be run. * \param options Only supported option would be DBRPCRECOMPILE, * which causes the stored procedure to be recompiled before executing. * \remark The RPC functions are the only way to get back OUTPUT parameter data with db-lib * from modern Microsoft servers. * \retval SUCCEED normal. * \retval FAIL on error * \sa dbrpcparam(), dbrpcsend() */ RETCODE dbrpcinit(DBPROCESS * dbproc, const char rpcname[], DBSMALLINT options) { DBREMOTE_PROC **rpc; tdsdump_log(TDS_DBG_FUNC, "dbrpcinit(%p, %s, %d)\n", dbproc, rpcname, options); CHECK_CONN(FAIL); CHECK_NULP(rpcname, "dbrpcinit", 2, FAIL); /* * TODO: adhere to docs. Only Microsoft supports DBRPCRESET. They say: * "Cancels a single stored procedure or a batch of stored procedures. * If rpcname is specified, that new stored procedure is initialized after the cancellation is complete." */ if (options & DBRPCRESET) { rpc_clear(dbproc->rpc); dbproc->rpc = NULL; return SUCCEED; } /* any bits we want from the options argument */ /* dbrpcrecompile = options & DBRPCRECOMPILE; */ options &= ~DBRPCRECOMPILE; /* turn that one off, now that we've extracted it */ /* all other options except DBRPCRECOMPILE are invalid */ DBPERROR_RETURN3(options, SYBEIPV, (int) options, "options", "dbrpcinit"); /* find a free node */ for (rpc = &dbproc->rpc; *rpc != NULL; rpc = &(*rpc)->next) { /* check existing nodes for name match (there shouldn't be one) */ if ((*rpc)->name == NULL || strcmp((*rpc)->name, rpcname) == 0) { tdsdump_log(TDS_DBG_INFO1, "error: dbrpcinit called twice for procedure \"%s\"\n", rpcname); return FAIL; } } /* rpc now contains the address of the dbproc's first empty (null) DBREMOTE_PROC* */ /* allocate */ if ((*rpc = tds_new0(DBREMOTE_PROC, 1)) == NULL) { dbperror(dbproc, SYBEMEM, errno); return FAIL; } if (((*rpc)->name = strdup(rpcname)) == NULL) { free(*rpc); *rpc = NULL; dbperror(dbproc, SYBEMEM, errno); return FAIL; } /* store */ (*rpc)->options = options & DBRPCRECOMPILE; (*rpc)->param_list = NULL; /* completed */ tdsdump_log(TDS_DBG_INFO1, "dbrpcinit() added rpcname \"%s\"\n", rpcname); return SUCCEED; } /** * \ingroup dblib_rpc * \brief Add a parameter to a remote procedure call. * * Call between dbrpcinit() and dbrpcsend() * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param paramname literal name of the parameter, according to the stored procedure (starts with '@'). Optional. * If not used, parameters will be passed in order instead of by name. * \param status must be DBRPCRETURN, if this parameter is a return parameter, else 0. * \param type datatype of the value parameter e.g., SYBINT4, SYBCHAR. * \param maxlen Maximum output size of the parameter's value to be returned by the stored procedure, * usually the size of your host variable. * Fixed-length datatypes take -1 (NULL or not). * Non-OUTPUT parameters also use -1. * Use 0 to send a NULL value for a variable length datatype. * \param datalen For variable-length datatypes, the byte size of the data to be sent, exclusive of any null terminator. * For fixed-length datatypes use -1. To send a NULL value, use 0. * \param value Address of your host variable. * \retval SUCCEED normal. * \retval FAIL on error * \sa dbrpcinit(), dbrpcsend() */ RETCODE dbrpcparam(DBPROCESS * dbproc, const char paramname[], BYTE status, int db_type, DBINT maxlen, DBINT datalen, BYTE * value) { char *name = NULL; DBREMOTE_PROC *rpc; DBREMOTE_PROC_PARAM **pparam; DBREMOTE_PROC_PARAM *param; TDS_SERVER_TYPE type; tdsdump_log(TDS_DBG_FUNC, "dbrpcparam(%p, %s, 0x%x, %d, %d, %d, %p)\n", dbproc, paramname, status, db_type, maxlen, datalen, value); CHECK_CONN(FAIL); CHECK_PARAMETER(dbproc->rpc, SYBERPCS, FAIL); DBPERROR_RETURN(!is_tds_type_valid(db_type), SYBEUDTY); type = (TDS_SERVER_TYPE) db_type; /* validate datalen parameter */ if (is_fixed_type(type)) { if (datalen != 0) datalen = -1; } else { /* Sybooks: "Passing datalen as -1 for any of these [non-fixed] datatypes results * in the DBPROCESS referenced by dbproc being marked as "dead," or unusable." */ DBPERROR_RETURN(datalen < 0, SYBERPIL); } /* "value parameter for dbprcparam() can be NULL, only if the datalen parameter is 0." */ DBPERROR_RETURN(value == NULL && datalen != 0, SYBERPNULL); /* nullable types must provide a data length */ DBPERROR_RETURN(is_nullable_type(type) && datalen < 0, SYBERPUL); /* validate maxlen parameter */ if (status & DBRPCRETURN) { if (is_fixed_type(type)) { maxlen = -1; } else { if (maxlen == -1) maxlen = 255; } } else { /* * Well, maxlen should be used only for output parameter however it seems * that ms implementation wrongly require this 0 for NULL variable * input parameters, so fix it */ DBPERROR_RETURN3(maxlen != -1 && maxlen != 0, SYBEIPV, (int) maxlen, "maxlen", "dbrpcparam"); maxlen = -1; } /* end validation */ /* This trick is to allow for client using utf8 to insert any character into a NVARCHAR parameter * The 4000 check is to allow varchar with more then 4000 characters (varchar is limited to 8000 * characters) which can't be converted to nvarchar (which is limited to 4000 character) */ if (type == SYBVARCHAR && IS_TDS7_PLUS(dbproc->tds_socket->conn) && maxlen <= 4000 && datalen <= 4000) type = XSYBNVARCHAR; /* allocate */ param = tds_new(DBREMOTE_PROC_PARAM, 1); if (param == NULL) { dbperror(dbproc, SYBEMEM, 0); return FAIL; } if (paramname) { name = strdup(paramname); if (name == NULL) { free(param); dbperror(dbproc, SYBEMEM, 0); return FAIL; } } /* initialize */ param->next = NULL; /* NULL signifies end of linked list */ param->name = name; param->status = status; param->type = type; param->maxlen = maxlen; param->datalen = datalen; /* * If datalen = 0, value parameter is ignored. * This is one way to specify a NULL input parameter. */ if (datalen == 0) param->value = NULL; else param->value = value; /* * Add a parameter to the current rpc. * * Traverse the dbproc's procedure list to find the current rpc, * then traverse the parameter linked list until its end, * then tack on our parameter's address. */ for (rpc = dbproc->rpc; rpc->next != NULL; rpc = rpc->next) /* find "current" procedure */ continue; for (pparam = &rpc->param_list; *pparam != NULL; pparam = &(*pparam)->next) continue; /* pparam now contains the address of the end of the rpc's parameter list */ *pparam = param; /* add to the end of the list */ tdsdump_log(TDS_DBG_INFO1, "dbrpcparam() added parameter \"%s\"\n", (paramname) ? paramname : ""); return SUCCEED; } /** * \ingroup dblib_rpc * \brief Execute the procedure and free associated memory * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \retval SUCCEED normal. * \retval FAIL on error * \sa dbrpcinit(), dbrpcparam() */ RETCODE dbrpcsend(DBPROCESS * dbproc) { DBREMOTE_PROC *rpc; tdsdump_log(TDS_DBG_FUNC, "dbrpcsend(%p)\n", dbproc); CHECK_CONN(FAIL); CHECK_PARAMETER(dbproc->rpc, SYBERPCS, FAIL); /* dbrpcinit should allocate pointer */ /* sanity */ if (dbproc->rpc->name == NULL) { /* can't be ready without a name */ tdsdump_log(TDS_DBG_INFO1, "returning FAIL: name is NULL\n"); return FAIL; } dbproc->dbresults_state = _DB_RES_INIT; for (rpc = dbproc->rpc; rpc != NULL; rpc = rpc->next) { TDSRET erc; TDSPARAMINFO *pparam_info = NULL; /* * liam@inodes.org: allow stored procedures to have no paramaters */ if (rpc->param_list != NULL) { pparam_info = param_info_alloc(dbproc->tds_socket, rpc); if (!pparam_info) return FAIL; } erc = tds_submit_rpc(dbproc->tds_socket, dbproc->rpc->name, pparam_info, NULL); tds_free_param_results(pparam_info); if (TDS_FAILED(erc)) { tdsdump_log(TDS_DBG_INFO1, "returning FAIL: tds_submit_rpc() failed\n"); return FAIL; } } /* free up the memory */ rpc_clear(dbproc->rpc); dbproc->rpc = NULL; tdsdump_log(TDS_DBG_FUNC, "dbrpcsend() returning SUCCEED\n"); return SUCCEED; } /** * Tell the TDSPARAMINFO structure where the data go. This is a kind of "bind" operation. */ static const unsigned char * param_row_alloc(TDSPARAMINFO * params, TDSCOLUMN * curcol, int param_num, void *value, int size) { const void *row = tds_alloc_param_data(curcol); tdsdump_log(TDS_DBG_INFO1, "parameter size = %d, data = %p, row_size = %d\n", size, curcol->column_data, params->row_size); if (!row) return NULL; if (size > 0 && value) { tdsdump_log(TDS_DBG_FUNC, "copying %d bytes of data to parameter #%d\n", size, param_num); if (!is_blob_col(curcol)) { if (is_numeric_type(curcol->column_type)) memset(curcol->column_data, 0, sizeof(TDS_NUMERIC)); memcpy(curcol->column_data, value, size); } else { TDSBLOB *blob = (TDSBLOB *) curcol->column_data; blob->textvalue = tds_new(TDS_CHAR, size); tdsdump_log(TDS_DBG_FUNC, "blob parameter supported, size %d textvalue pointer is %p\n", size, blob->textvalue); if (!blob->textvalue) return NULL; memcpy(blob->textvalue, value, size); } } else { tdsdump_log(TDS_DBG_FUNC, "setting parameter #%d to NULL\n", param_num); curcol->column_cur_size = -1; } return (const unsigned char*) row; } /** * Allocate memory and copy the rpc information into a TDSPARAMINFO structure. */ static TDSPARAMINFO * param_info_alloc(TDSSOCKET * tds, DBREMOTE_PROC * rpc) { int i; DBREMOTE_PROC_PARAM *p; TDSCOLUMN *pcol; TDSPARAMINFO *params = NULL, *new_params; BYTE *temp_value; int temp_datalen; TDS_SERVER_TYPE temp_type; int param_is_null; /* sanity */ if (rpc == NULL) return NULL; /* see v 1.10 2002/11/23 for first broken attempt */ for (i = 0, p = rpc->param_list; p != NULL; p = p->next, i++) { const unsigned char *prow; if (!(new_params = tds_alloc_param_result(params))) { tds_free_param_results(params); tdsdump_log(TDS_DBG_ERROR, "out of rpc memory!"); return NULL; } params = new_params; /* * Determine whether an input parameter is NULL or not. */ param_is_null = 0; temp_type = p->type; temp_value = p->value; temp_datalen = p->datalen; if (p->datalen == 0) param_is_null = 1; tdsdump_log(TDS_DBG_INFO1, "parm_info_alloc(): parameter null-ness = %d\n", param_is_null); pcol = params->columns[i]; if (temp_value && is_numeric_type(temp_type)) { DBDECIMAL *dec = (DBDECIMAL*) temp_value; pcol->column_prec = dec->precision; pcol->column_scale = dec->scale; if (dec->precision > 0 && dec->precision <= MAXPRECISION) temp_datalen = tds_numeric_bytes_per_prec[dec->precision] + 2; } if (param_is_null || (p->status & DBRPCRETURN)) { if (param_is_null) { temp_datalen = 0; temp_value = NULL; } else if (is_fixed_type(temp_type)) { temp_datalen = tds_get_size_by_type(temp_type); } temp_type = tds_get_null_type(temp_type); } else if (is_fixed_type(temp_type)) { temp_datalen = tds_get_size_by_type(temp_type); } /* meta data */ if (p->name) if (!tds_dstr_copy(&pcol->column_name, p->name)) { tds_free_param_results(params); tdsdump_log(TDS_DBG_ERROR, "out of rpc memory!"); return NULL; } tds_set_param_type(tds->conn, pcol, temp_type); if (p->maxlen > 0) pcol->column_size = p->maxlen; else { if (is_fixed_type(p->type)) { pcol->column_size = tds_get_size_by_type(p->type); } else { pcol->column_size = p->datalen; } } if (p->type == XSYBNVARCHAR) pcol->column_size *= 2; pcol->on_server.column_size = pcol->column_size; pcol->column_output = p->status; pcol->column_cur_size = temp_datalen; prow = param_row_alloc(params, pcol, i, temp_value, temp_datalen); if (!prow) { tds_free_param_results(params); tdsdump_log(TDS_DBG_ERROR, "out of memory for rpc row!"); return NULL; } } return params; } /** * erase the procedure list */ static void rpc_clear(DBREMOTE_PROC * rpc) { DBREMOTE_PROC * next; while (rpc) { next = rpc->next; param_clear(rpc->param_list); free(rpc->name); free(rpc); rpc = next; } } /** * erase the parameter list */ static void param_clear(DBREMOTE_PROC_PARAM * pparam) { DBREMOTE_PROC_PARAM * next; while (pparam) { next = pparam->next; free(pparam->name); /* free self */ free(pparam); pparam = next; } } freetds-1.00.82/src/dblib/bcp.c100644 025423 025423 00000206471 13007047022 0011606/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns * Copyright (C) 2010, 2011 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #ifdef _WIN32 #include #endif #include #include #include #include #include #include #include #include #include #include #define HOST_COL_CONV_ERROR 1 #define HOST_COL_NULL_ERROR 2 #ifndef MAX #define MAX(a,b) ( (a) > (b) ? (a) : (b) ) #endif #ifdef HAVE_FSEEKO typedef off_t offset_type; #elif defined(_WIN32) || defined(_WIN64) /* win32 version */ typedef __int64 offset_type; # if defined(HAVE__FSEEKI64) && defined(HAVE__FTELLI64) # define fseeko(f,o,w) _fseeki64((f),o,w) # define ftello(f) _ftelli64((f)) # else # define fseeko(f,o,w) (_lseeki64(fileno(f),o,w) == -1 ? -1 : 0) # define ftello(f) _telli64(fileno(f)) # endif #else /* use old version */ #define fseeko(f,o,w) fseek(f,o,w) #define ftello(f) ftell(f) typedef long offset_type; #endif static void _bcp_free_storage(DBPROCESS * dbproc); static void _bcp_free_columns(DBPROCESS * dbproc); static TDSRET _bcp_get_col_data(TDSBCPINFO *bcpinfo, TDSCOLUMN *bindcol, int offset); static TDSRET _bcp_no_get_col_data(TDSBCPINFO *bcpinfo, TDSCOLUMN *bindcol, int offset); static int rtrim(char *, int); static STATUS _bcp_read_hostfile(DBPROCESS * dbproc, FILE * hostfile, int *row_error); static int _bcp_readfmt_colinfo(DBPROCESS * dbproc, char *buf, BCP_HOSTCOLINFO * ci); static int _bcp_get_term_var(BYTE * pdata, BYTE * term, int term_len); /* * "If a host file is being used ... the default data formats are as follows: * * > The order, type, length and number of the columns in the host file are * assumed to be identical to the order, type and number of the columns in the database table. * > If a given database column's data is fixed-length, * then the host file's data column will also be fixed-length. * > If a given database column's data is variable-length or may contain null values, * the host file's data column will be prefixed by * a 4-byte length value for SYBTEXT and SYBIMAGE data types, and * a 1-byte length value for all other types. * > There are no terminators of any kind between host file columns." */ static void init_hostfile_columns(DBPROCESS *dbproc) { const int ncols = dbproc->bcpinfo->bindinfo->num_cols; RETCODE erc; int icol; if (ncols == 0) return; if ((erc = bcp_columns(dbproc, ncols)) != SUCCEED) { assert(erc == SUCCEED); return; } for (icol = 0; icol < ncols; icol++) { const TDSCOLUMN *pcol = dbproc->bcpinfo->bindinfo->columns[icol]; int prefixlen = 0, termlen = 0; switch (pcol->column_type) { case SYBTEXT: case SYBIMAGE: prefixlen = 4; break; default: prefixlen = dbvarylen(dbproc, icol+1)? 1 : 0; } erc = bcp_colfmt(dbproc, icol+1, pcol->column_type, prefixlen, pcol->column_size, NULL, termlen, icol+1); assert(erc == SUCCEED); if (erc != SUCCEED) return; } } /** * \ingroup dblib_bcp * \brief Prepare for bulk copy operation on a table * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param tblname the name of the table receiving or providing the data. * \param hfile the data file opposite the table, if any. * \param errfile the "error file" captures messages and, if errors are encountered, * copies of any rows that could not be written to the table. * \param direction one of * - \b DB_IN writing to the table * - \b DB_OUT writing to the host file * . * \remarks bcp_init() sets the host file data format and acquires the table metadata. * It is called before the other bulk copy functions. * * When writing to a table, bcp can use as its data source a data file (\a hfile), * or program data in an application's variables. In the latter case, call bcp_bind() * to associate your data with the appropriate table column. * \return SUCCEED or FAIL. * \sa BCP_SETL(), bcp_bind(), bcp_done(), bcp_exec() */ RETCODE bcp_init(DBPROCESS * dbproc, const char *tblname, const char *hfile, const char *errfile, int direction) { tdsdump_log(TDS_DBG_FUNC, "bcp_init(%p, %s, %s, %s, %d)\n", dbproc, tblname? tblname:"NULL", hfile? hfile:"NULL", errfile? errfile:"NULL", direction); CHECK_CONN(FAIL); /* * Validate other parameters */ if (dbproc->tds_socket->conn->tds_version < 0x500) { dbperror(dbproc, SYBETDSVER, 0); return FAIL; } if (tblname == NULL) { dbperror(dbproc, SYBEBCITBNM, 0); return FAIL; } if (strlen(tblname) > 92 && !IS_TDS7_PLUS(dbproc->tds_socket->conn)) { /* 30.30.30 */ dbperror(dbproc, SYBEBCITBLEN, 0); return FAIL; } if (direction != DB_IN && direction != DB_OUT && direction != DB_QUERYOUT) { dbperror(dbproc, SYBEBDIO, 0); return FAIL; } /* Free previously allocated storage in dbproc & initialise flags, etc. */ _bcp_free_storage(dbproc); /* Allocate storage */ dbproc->bcpinfo = tds_alloc_bcpinfo(); if (dbproc->bcpinfo == NULL) goto memory_error; if (!tds_dstr_copy(&dbproc->bcpinfo->tablename, tblname)) goto memory_error; dbproc->bcpinfo->direction = direction; dbproc->bcpinfo->xfer_init = 0; dbproc->bcpinfo->bind_count = 0; if (TDS_FAILED(tds_bcp_init(dbproc->tds_socket, dbproc->bcpinfo))) { /* TODO return proper error */ /* Attempt to use Bulk Copy with a non-existent Server table (might be why ...) */ dbperror(dbproc, SYBEBCNT, 0); return FAIL; } /* Prepare default hostfile columns */ if (hfile == NULL) { dbproc->hostfileinfo = NULL; return SUCCEED; } dbproc->hostfileinfo = tds_new0(BCP_HOSTFILEINFO, 1); if (dbproc->hostfileinfo == NULL) goto memory_error; if ((dbproc->hostfileinfo->hostfile = strdup(hfile)) == NULL) goto memory_error; if (errfile != NULL) if ((dbproc->hostfileinfo->errorfile = strdup(errfile)) == NULL) goto memory_error; init_hostfile_columns(dbproc); return SUCCEED; memory_error: _bcp_free_storage(dbproc); dbperror(dbproc, SYBEMEM, ENOMEM); return FAIL; } /** * \ingroup dblib_bcp * \brief Set the length of a host variable to be written to a table. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param varlen size of the variable, in bytes, or * - \b 0 indicating NULL * - \b -1 indicating size is determined by the prefix or terminator. * (If both a prefix and a terminator are present, bcp is supposed to use the smaller of the * two. This feature might or might not actually work.) * \param table_column the number of the column in the table (starting with 1, not zero). * * \return SUCCEED or FAIL. * \sa bcp_bind(), bcp_colptr(), bcp_sendrow() */ RETCODE bcp_collen(DBPROCESS * dbproc, DBINT varlen, int table_column) { TDSCOLUMN *bcpcol; tdsdump_log(TDS_DBG_FUNC, "bcp_collen(%p, %d, %d)\n", dbproc, varlen, table_column); CHECK_CONN(FAIL); CHECK_PARAMETER(dbproc->bcpinfo, SYBEBCPI, FAIL); /* not initialized */ DBPERROR_RETURN(dbproc->bcpinfo->direction != DB_IN, SYBEBCPN) /* not inbound */ DBPERROR_RETURN(dbproc->hostfileinfo != NULL, SYBEBCPI) /* cannot have data file */ CHECK_PARAMETER(0 < table_column && table_column <= dbproc->bcpinfo->bindinfo->num_cols, SYBECNOR, FAIL); bcpcol = dbproc->bcpinfo->bindinfo->columns[table_column - 1]; #if USING_SYBEBCNN DBPERROR_RETURN(varlen == 0 && !bcpcol->column_nullable, SYBEBCNN); /* non-nullable column cannot receive a NULL */ #endif bcpcol->column_bindlen = varlen; return SUCCEED; } /** * \ingroup dblib_bcp * \brief Indicate how many columns are to be found in the datafile. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param host_colcount count of columns in the datafile, irrespective of how many you intend to use. * \remarks This function describes the file as it is, not how it will be used. * * \return SUCCEED or FAIL. It's hard to see how it could fail. * \sa bcp_colfmt() */ RETCODE bcp_columns(DBPROCESS * dbproc, int host_colcount) { int i; tdsdump_log(TDS_DBG_FUNC, "bcp_columns(%p, %d)\n", dbproc, host_colcount); CHECK_CONN(FAIL); CHECK_PARAMETER(dbproc->bcpinfo, SYBEBCPI, FAIL); CHECK_PARAMETER(dbproc->hostfileinfo, SYBEBIVI, FAIL); if (host_colcount < 1) { dbperror(dbproc, SYBEBCFO, 0); return FAIL; } _bcp_free_columns(dbproc); dbproc->hostfileinfo->host_columns = tds_new0(BCP_HOSTCOLINFO *, host_colcount); if (dbproc->hostfileinfo->host_columns == NULL) { dbperror(dbproc, SYBEMEM, ENOMEM); return FAIL; } dbproc->hostfileinfo->host_colcount = host_colcount; for (i = 0; i < host_colcount; i++) { dbproc->hostfileinfo->host_columns[i] = tds_new0(BCP_HOSTCOLINFO, 1); if (dbproc->hostfileinfo->host_columns[i] == NULL) { dbproc->hostfileinfo->host_colcount = i; _bcp_free_columns(dbproc); dbperror(dbproc, SYBEMEM, ENOMEM); return FAIL; } } return SUCCEED; } /** * \ingroup dblib_bcp * \brief Specify the format of a datafile prior to writing to a table. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param host_colnum datafile column number (starting with 1, not zero). * \param host_type dataype token describing the data type in \a host_colnum. E.g. SYBCHAR for character data. * \param host_prefixlen size of the prefix in the datafile column, if any. For delimited files: zero. * May be 0, 1, 2, or 4 bytes. The prefix will be read as an integer (not a character string) from the * data file, and will be interpreted the data size of that column, in bytes. * \param host_collen maximum size of datafile column, exclusive of any prefix/terminator. Just the data, ma'am. * Special values: * - \b 0 indicates NULL. * - \b -1 for fixed-length non-null datatypes * - \b -1 for variable-length datatypes (e.g. SYBCHAR) where the length is established * by a prefix/terminator. * \param host_term the sequence of characters that will serve as a column terminator (delimiter) in the datafile. * Often a tab character, but can be any string of any length. Zero indicates no terminator. * Special characters: * - \b '\\0' terminator is an ASCII NUL. * - \b '\\t' terminator is an ASCII TAB. * - \b '\\n' terminator is an ASCII NL. * \param host_termlen the length of \a host_term, in bytes. * \param table_colnum Nth column, starting at 1, in the table that maps to \a host_colnum. * If there is a column in the datafile that does not map to a table column, set \a table_colnum to zero. * *\remarks bcp_colfmt() is called once for each column in the datafile, as specified with bcp_columns(). * In so doing, you describe to FreeTDS how to parse each line of your datafile, and where to send each field. * * When a prefix or terminator is used with variable-length data, \a host_collen may have one of three values: * - \b positive indicating the maximum number of bytes to be used * - \b 0 indicating NULL * - \b -1 indicating no maximum; all data, as described by the prefix/terminator will be used. * . * \return SUCCEED or FAIL. * \sa bcp_batch(), bcp_bind(), bcp_colfmt_ps(), bcp_collen(), bcp_colptr(), bcp_columns(), * bcp_control(), bcp_done(), bcp_exec(), bcp_init(), bcp_sendrow */ RETCODE bcp_colfmt(DBPROCESS * dbproc, int host_colnum, int host_type, int host_prefixlen, DBINT host_collen, const BYTE * host_term, int host_termlen, int table_colnum) { BCP_HOSTCOLINFO *hostcol; BYTE *terminator = NULL; tdsdump_log(TDS_DBG_FUNC, "bcp_colfmt(%p, %d, %d, %d, %d, %p, %d, %d)\n", dbproc, host_colnum, host_type, host_prefixlen, (int) host_collen, host_term, host_termlen, table_colnum); CHECK_CONN(FAIL); CHECK_PARAMETER(dbproc->bcpinfo, SYBEBCPI, FAIL); CHECK_PARAMETER(dbproc->hostfileinfo, SYBEBIVI, FAIL); /* Microsoft specifies a "file_termlen" of zero if there's no terminator */ if (dbproc->msdblib && host_termlen == 0) host_termlen = -1; if (host_termlen < 0) host_termlen = -1; if (dbproc->hostfileinfo->host_colcount == 0) { dbperror(dbproc, SYBEBCBC, 0); return FAIL; } if (host_colnum < 1) { dbperror(dbproc, SYBEBCFO, 0); return FAIL; } if (host_colnum > dbproc->hostfileinfo->host_colcount) { dbperror(dbproc, SYBECNOR, 0); return FAIL; } if (host_prefixlen != 0 && host_prefixlen != 1 && host_prefixlen != 2 && host_prefixlen != 4 && host_prefixlen != -1) { dbperror(dbproc, SYBEBCPREF, 0); return FAIL; } /* if column is not copied you cannot specify destination type */ if (table_colnum <= 0 && host_type == 0) { dbperror(dbproc, SYBEBCPCTYP, 0); return FAIL; } if (table_colnum > 0 && !is_tds_type_valid(host_type)) { dbperror(dbproc, SYBEUDTY, 0); return FAIL; } if (host_type && host_prefixlen == 0 && host_collen == -1 && host_termlen == -1 && !is_fixed_type(host_type)) { dbperror(dbproc, SYBEVDPT, 0); return FAIL; } if (host_collen < -1) { dbperror(dbproc, SYBEBCHLEN, 0); return FAIL; } /* No official error message. Fix and warn. */ if (is_fixed_type(host_type) && (host_collen != -1 && host_collen != 0)) { tdsdump_log(TDS_DBG_FUNC, "bcp_colfmt: changing host_collen to -1 from %d for fixed type %d.\n", host_collen, host_type); host_collen = -1; } /* * If there's a positive terminator length, we need a valid terminator pointer. * If the terminator length is 0 or -1, then there's no terminator. */ if (host_term == NULL && host_termlen > 0) { dbperror(dbproc, SYBEVDPT, 0); /* "all variable-length data must have either a length-prefix ..." */ return FAIL; } hostcol = dbproc->hostfileinfo->host_columns[host_colnum - 1]; /* TODO add precision scale and join with bcp_colfmt_ps */ if (host_term && host_termlen > 0) { if ((terminator = tds_new(BYTE, host_termlen)) == NULL) { dbperror(dbproc, SYBEMEM, errno); return FAIL; } memcpy(terminator, host_term, host_termlen); } hostcol->host_column = host_colnum; hostcol->datatype = host_type ? (TDS_SERVER_TYPE) host_type : TDS_INVALID_TYPE; hostcol->prefix_len = host_prefixlen; hostcol->column_len = host_collen; free(hostcol->terminator); hostcol->terminator = terminator; hostcol->term_len = host_termlen; hostcol->tab_colnum = table_colnum; return SUCCEED; } /** * \ingroup dblib_bcp * \brief Specify the format of a host file for bulk copy purposes, * with precision and scale support for numeric and decimal columns. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param host_colnum datafile column number (starting with 1, not zero). * \param host_type dataype token describing the data type in \a host_colnum. E.g. SYBCHAR for character data. * \param host_prefixlen size of the prefix in the datafile column, if any. For delimited files: zero. * May be 0, 1, 2, or 4 bytes. The prefix will be read as an integer (not a character string) from the * data file, and will be interpreted the data size of that column, in bytes. * \param host_collen maximum size of datafile column, exclusive of any prefix/terminator. Just the data, ma'am. * Special values: * - \b 0 indicates NULL. * - \b -1 for fixed-length non-null datatypes * - \b -1 for variable-length datatypes (e.g. SYBCHAR) where the length is established * by a prefix/terminator. * \param host_term the sequence of characters that will serve as a column terminator (delimiter) in the datafile. * Often a tab character, but can be any string of any length. Zero indicates no terminator. * Special characters: * - \b '\\0' terminator is an ASCII NUL. * - \b '\\t' terminator is an ASCII TAB. * - \b '\\n' terminator is an ASCII NL. * \param host_termlen the length of \a host_term, in bytes. * \param table_colnum Nth column, starting at 1, in the table that maps to \a host_colnum. * If there is a column in the datafile that does not map to a table column, set \a table_colnum to zero. * \param typeinfo something * \todo Not implemented. * \return SUCCEED or FAIL. * \sa bcp_batch(), bcp_bind(), bcp_colfmt(), bcp_collen(), bcp_colptr(), bcp_columns(), * bcp_control(), bcp_done(), bcp_exec(), bcp_init(), bcp_sendrow */ RETCODE bcp_colfmt_ps(DBPROCESS * dbproc, int host_colnum, int host_type, int host_prefixlen, DBINT host_collen, BYTE * host_term, int host_termlen, int table_colnum, DBTYPEINFO * typeinfo) { tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED: bcp_colfmt_ps(%p, %d, %d)\n", dbproc, host_colnum, host_type); CHECK_CONN(FAIL); CHECK_PARAMETER(dbproc->bcpinfo, SYBEBCPI, FAIL); /* dbperror(dbproc, , 0); Illegal precision specified */ /* TODO see bcp_colfmt */ return FAIL; } /** * \ingroup dblib_bcp * \brief Set BCP options for uploading a datafile * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param field symbolic constant indicating the option to be set, one of: * - \b BCPMAXERRS Maximum errors tolerated before quitting. The default is 10. * - \b BCPFIRST The first row to read in the datafile. The default is 1. * - \b BCPLAST The last row to read in the datafile. The default is to copy all rows. A value of * -1 resets this field to its default? * - \b BCPBATCH The number of rows per batch. Default is 0, meaning a single batch. * \param value The value for \a field. * * \remarks These options control the behavior of bcp_exec(). * When writing to a table from application host memory variables, * program logic controls error tolerance and batch size. * * \return SUCCEED or FAIL. * \sa bcp_batch(), bcp_bind(), bcp_colfmt(), bcp_collen(), bcp_colptr(), bcp_columns(), bcp_done(), bcp_exec(), bcp_options() */ RETCODE bcp_control(DBPROCESS * dbproc, int field, DBINT value) { tdsdump_log(TDS_DBG_FUNC, "bcp_control(%p, %d, %d)\n", dbproc, field, value); CHECK_CONN(FAIL); CHECK_PARAMETER(dbproc->bcpinfo, SYBEBCPI, FAIL); if (field == BCPKEEPIDENTITY) { dbproc->bcpinfo->identity_insert_on = (value != 0); return SUCCEED; } CHECK_PARAMETER(dbproc->hostfileinfo, SYBEBIVI, FAIL); switch (field) { case BCPMAXERRS: dbproc->hostfileinfo->maxerrs = value; break; case BCPFIRST: dbproc->hostfileinfo->firstrow = value; break; case BCPLAST: dbproc->hostfileinfo->lastrow = value; break; case BCPBATCH: dbproc->hostfileinfo->batch = value; break; default: dbperror(dbproc, SYBEIFNB, 0); return FAIL; } return SUCCEED; } /* * \ingroup dblib_bcp * \brief Get BCP batch option * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \remarks This function is specific to FreeTDS. * * \return the value that was set by bcp_control. * \sa bcp_batch(), bcp_control() */ int bcp_getbatchsize(DBPROCESS * dbproc) { return dbproc->hostfileinfo->batch; } /** * \ingroup dblib_bcp * \brief Set "hints" for uploading a file. A FreeTDS-only function. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param option symbolic constant indicating the option to be set, one of: * - \b BCPLABELED Not implemented. * - \b BCPHINTS The hint to be passed when the bulk-copy begins. * \param value The string constant for \a option a/k/a the hint. One of: * - \b ORDER The data are ordered in accordance with the table's clustered index. * - \b ROWS_PER_BATCH The batch size * - \b KILOBYTES_PER_BATCH The approximate number of kilobytes to use for a batch size * - \b TABLOCK Lock the table * - \b CHECK_CONSTRAINTS Apply constraints * - \b FIRE_TRIGGERS Fire any INSERT triggers on the target table * \param valuelen The strlen of \a value. * * \return SUCCEED or FAIL. * \sa bcp_control(), * bcp_exec(), * \todo Simplify. Remove \a valuelen, and dbproc->bcpinfo->hint = strdup(hints[i]) */ RETCODE bcp_options(DBPROCESS * dbproc, int option, BYTE * value, int valuelen) { int i; static const char *const hints[] = { "ORDER", "ROWS_PER_BATCH", "KILOBYTES_PER_BATCH", "TABLOCK", "CHECK_CONSTRAINTS", "FIRE_TRIGGERS", NULL }; tdsdump_log(TDS_DBG_FUNC, "bcp_options(%p, %d, %p, %d)\n", dbproc, option, value, valuelen); CHECK_CONN(FAIL); CHECK_PARAMETER(dbproc->bcpinfo, SYBEBCPI, FAIL); CHECK_NULP(value, "bcp_options", 3, FAIL); switch (option) { case BCPLABELED: tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED bcp option: BCPLABELED\n"); break; case BCPHINTS: if (!value || valuelen <= 0) break; for (i = 0; hints[i]; i++) { /* look up hint */ if (strncasecmp((char *) value, hints[i], strlen(hints[i])) == 0) { dbproc->bcpinfo->hint = hints[i]; /* safe: hints[i] is static constant, above */ return SUCCEED; } } tdsdump_log(TDS_DBG_FUNC, "failed, no such hint\n"); break; default: tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED bcp option: %u\n", option); break; } return FAIL; } /** * \ingroup dblib_bcp * \brief Override bcp_bind() by pointing to a different host variable. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param colptr The pointer, the address of your variable. * \param table_column The 1-based column ordinal in the table. * \remarks Use between calls to bcp_sendrow(). After calling bcp_colptr(), * subsequent calls to bcp_sendrow() will bind to the new address. * \return SUCCEED or FAIL. * \sa bcp_bind(), bcp_collen(), bcp_sendrow() */ RETCODE bcp_colptr(DBPROCESS * dbproc, BYTE * colptr, int table_column) { TDSCOLUMN *curcol; tdsdump_log(TDS_DBG_FUNC, "bcp_colptr(%p, %p, %d)\n", dbproc, colptr, table_column); CHECK_CONN(FAIL); CHECK_PARAMETER(dbproc->bcpinfo, SYBEBCPI, FAIL); CHECK_PARAMETER(dbproc->bcpinfo->bindinfo, SYBEBCPI, FAIL); /* colptr can be NULL */ if (dbproc->bcpinfo->direction != DB_IN) { dbperror(dbproc, SYBEBCPN, 0); return FAIL; } if (table_column <= 0 || table_column > dbproc->bcpinfo->bindinfo->num_cols) { dbperror(dbproc, SYBEBCPN, 0); return FAIL; } curcol = dbproc->bcpinfo->bindinfo->columns[table_column - 1]; curcol->column_varaddr = (TDS_CHAR *)colptr; return SUCCEED; } /** * \ingroup dblib_bcp * \brief See if BCP_SETL() was used to set the LOGINREC for BCP work. * * \param login Address of the LOGINREC variable to be passed to dbopen(). * * \return TRUE or FALSE. * \sa BCP_SETL(), bcp_init(), dblogin(), dbopen() */ DBBOOL bcp_getl(LOGINREC * login) { TDSLOGIN *tdsl = login->tds_login; tdsdump_log(TDS_DBG_FUNC, "bcp_getl(%p)\n", login); return (tdsl->bulk_copy); } /** * Convert column for output (usually to a file) * Conversion is slightly different from input as: * - date is formatted differently; * - you have to set properly numeric while on input the column metadata are * used; * - we need to make sure buffer is always at least a minimum bytes. */ static int _bcp_convert_out(DBPROCESS * dbproc, TDSCOLUMN *curcol, BCP_HOSTCOLINFO *hostcol, TDS_UCHAR **p_data, const char *bcpdatefmt) { BYTE *src; int srclen; int buflen; int srctype = tds_get_conversion_type(curcol->column_type, curcol->column_size); src = curcol->column_data; if (is_blob_col(curcol)) src = (BYTE *) ((TDSBLOB *) src)->textvalue; srclen = curcol->column_cur_size; /* * if we are converting datetime to string, need to override any * date time formats already established */ if (is_datetime_type(srctype) && is_ascii_type(hostcol->datatype)) { TDSDATEREC when; tds_datecrack(srctype, src, &when); buflen = (int)tds_strftime((TDS_CHAR *)(*p_data), 256, bcpdatefmt, &when, 3); } else if (srclen == 0 && is_variable_type(curcol->column_type) && is_ascii_type(hostcol->datatype)) { /* * An empty string is denoted in the output file by a single ASCII NUL * byte that we request by specifying a destination length of -1. (Not * to be confused with a database NULL, which is denoted in the output * file with an empty string!) */ (*p_data)[0] = 0; buflen = 1; } else if (is_numeric_type(hostcol->datatype)) { TDS_NUMERIC *num = (TDS_NUMERIC *) (*p_data); if (is_numeric_type(srctype)) { TDS_NUMERIC *nsrc = (TDS_NUMERIC *) src; num->precision = nsrc->precision; num->scale = nsrc->scale; } else { num->precision = 18; num->scale = 0; } buflen = tds_convert(dbproc->tds_socket->conn->tds_ctx, srctype, (const TDS_CHAR *) src, srclen, hostcol->datatype, (CONV_RESULT *) num); if (buflen > 0) buflen = tds_numeric_bytes_per_prec[num->precision] + 2; } else if (!is_variable_type(hostcol->datatype)) { buflen = tds_convert(dbproc->tds_socket->conn->tds_ctx, srctype, (const TDS_CHAR *) src, srclen, hostcol->datatype, (CONV_RESULT *) (*p_data)); } else { CONV_RESULT cr; /* * For null columns, the above work to determine the output buffer size is moot, * because bcpcol->data_size is zero, so dbconvert() won't write anything, * and returns zero. */ buflen = tds_convert(dbproc->tds_socket->conn->tds_ctx, srctype, (const TDS_CHAR *) src, srclen, hostcol->datatype, (CONV_RESULT *) &cr); if (buflen < 0) return buflen; if (buflen >= 256) { free(*p_data); *p_data = (TDS_UCHAR *) cr.c; } else { memcpy(*p_data, cr.c, buflen); free(cr.c); } /* * Special case: When outputting database varchar data * (either varchar or nullable char) conversion may have * trimmed trailing blanks such that nothing is left. * In this case we need to put a single blank to the output file. */ if (is_char_type(curcol->column_type) && srclen > 0 && buflen == 0) { strcpy ((char *) (*p_data), " "); buflen = 1; } } return buflen; } static int bcp_cache_prefix_len(BCP_HOSTCOLINFO *hostcol, const TDSCOLUMN *curcol) { int plen; if (is_blob_type(hostcol->datatype)) plen = 4; else if (is_numeric_type(hostcol->datatype)) plen = 1; else if (!is_fixed_type(hostcol->datatype)) plen = 2; else if (curcol->column_nullable) plen = 1; else plen = 0; /* cache */ return hostcol->prefix_len = plen; } static RETCODE bcp_write_prefix(FILE *hostfile, BCP_HOSTCOLINFO *hostcol, TDSCOLUMN *curcol, int buflen) { union { TDS_TINYINT ti; TDS_SMALLINT si; TDS_INT li; } u; int plen; /* compute prefix len if needed */ if ((plen = hostcol->prefix_len) == -1) plen = bcp_cache_prefix_len(hostcol, curcol); /* output prefix to file */ switch (plen) { default: return SUCCEED; case 1: u.ti = buflen; break; case 2: u.si = buflen; break; case 4: u.li = buflen; break; } if (fwrite(&u, plen, 1, hostfile) == 1) return SUCCEED; return FAIL; } /** * \ingroup dblib_bcp_internal * \brief * * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param rows_copied * * \return SUCCEED or FAIL. * \sa BCP_SETL(), bcp_batch(), bcp_bind(), bcp_colfmt(), bcp_colfmt_ps(), bcp_collen(), bcp_colptr(), bcp_columns(), bcp_control(), bcp_done(), bcp_exec(), bcp_getl(), bcp_init(), bcp_moretext(), bcp_options(), bcp_readfmt(), bcp_sendrow() */ static RETCODE _bcp_exec_out(DBPROCESS * dbproc, DBINT * rows_copied) { FILE *hostfile = NULL; TDS_UCHAR *data = NULL; int i; TDSSOCKET *tds; TDSRESULTINFO *resinfo; TDSCOLUMN *curcol = NULL; BCP_HOSTCOLINFO *hostcol; int buflen; TDS_INT result_type; int row_of_query; int rows_written; const char *bcpdatefmt; TDSRET tdsret; tdsdump_log(TDS_DBG_FUNC, "_bcp_exec_out(%p, %p)\n", dbproc, rows_copied); assert(dbproc); assert(rows_copied); tds = dbproc->tds_socket; assert(tds); bcpdatefmt = getenv("FREEBCP_DATEFMT"); if (!bcpdatefmt) bcpdatefmt = "%Y-%m-%d %H:%M:%S.%z"; if (dbproc->bcpinfo->direction == DB_QUERYOUT ) { if (TDS_FAILED(tds_submit_query(tds, tds_dstr_cstr(&dbproc->bcpinfo->tablename)))) return FAIL; } else { /* TODO quote if needed */ if (TDS_FAILED(tds_submit_queryf(tds, "select * from %s", tds_dstr_cstr(&dbproc->bcpinfo->tablename)))) return FAIL; } tdsret = tds_process_tokens(tds, &result_type, NULL, TDS_TOKEN_RESULTS); if (TDS_FAILED(tdsret)) return FAIL; if (!tds->res_info) { /* TODO flush/cancel to keep consistent state */ return FAIL; } resinfo = tds->res_info; row_of_query = 0; rows_written = 0; /* allocate at least 256 bytes */ /* allocate data for buffer conversion */ data = tds_new(TDS_UCHAR, 256); if (!data) { dbperror(dbproc, SYBEMEM, errno); goto Cleanup; } /* * TODO above we allocate many buffer just to convert and store * to file.. avoid all that passages... */ if (!(hostfile = fopen(dbproc->hostfileinfo->hostfile, "w"))) { dbperror(dbproc, SYBEBCUO, errno); goto Cleanup; } /* fetch a row of data from the server */ while (tds_process_tokens(tds, &result_type, NULL, TDS_STOPAT_ROWFMT|TDS_RETURN_DONE|TDS_RETURN_ROW|TDS_RETURN_COMPUTE) == TDS_SUCCESS) { if (result_type != TDS_ROW_RESULT && result_type != TDS_COMPUTE_RESULT) break; row_of_query++; /* skip rows outside of the firstrow/lastrow range, if specified */ if (dbproc->hostfileinfo->firstrow > row_of_query || row_of_query > MAX(dbproc->hostfileinfo->lastrow, 0x7FFFFFFF)) continue; /* Go through the hostfile columns, finding those that relate to database columns. */ for (i = 0; i < dbproc->hostfileinfo->host_colcount; i++) { hostcol = dbproc->hostfileinfo->host_columns[i]; if (hostcol->tab_colnum < 1 || hostcol->tab_colnum > resinfo->num_cols) continue; curcol = resinfo->columns[hostcol->tab_colnum - 1]; if (curcol->column_cur_size < 0) { buflen = 0; } else { buflen = _bcp_convert_out(dbproc, curcol, hostcol, &data, bcpdatefmt); } if (buflen < 0) { _dblib_convert_err(dbproc, buflen); goto Cleanup; } /* The prefix */ if (bcp_write_prefix(hostfile, hostcol, curcol, buflen) != SUCCEED) goto write_error; /* The data */ if (hostcol->column_len != -1) { buflen = buflen > hostcol->column_len ? hostcol->column_len : buflen; } if (buflen > 0) { if (fwrite(data, buflen, 1, hostfile) != 1) goto write_error; } /* The terminator */ if (hostcol->terminator && hostcol->term_len > 0) { if (fwrite(hostcol->terminator, hostcol->term_len, 1, hostfile) != 1) goto write_error; } } rows_written++; } if (fclose(hostfile) != 0) { dbperror(dbproc, SYBEBCUC, errno); goto Cleanup; } hostfile = NULL; if (dbproc->hostfileinfo->firstrow > 0 && row_of_query < dbproc->hostfileinfo->firstrow) { /* * The table which bulk-copy is attempting to * copy to a host-file is shorter than the * number of rows which bulk-copy was instructed to skip. */ /* TODO reset TDSSOCKET state */ dbperror(dbproc, SYBETTS, 0); goto Cleanup; } *rows_copied = rows_written; free(data); return SUCCEED; write_error: dbperror(dbproc, SYBEBCWE, errno); Cleanup: if (hostfile) fclose(hostfile); free(data); return FAIL; } static STATUS _bcp_check_eof(DBPROCESS * dbproc, FILE *file, int icol) { int errnum = errno; tdsdump_log(TDS_DBG_FUNC, "_bcp_check_eof(%p, %p, %d)\n", dbproc, file, icol); assert(dbproc); assert(file); if (feof(file)) { if (icol == 0) { tdsdump_log(TDS_DBG_FUNC, "Normal end-of-file reached while loading bcp data file.\n"); return NO_MORE_ROWS; } dbperror(dbproc, SYBEBEOF, errnum); return FAIL; } dbperror(dbproc, SYBEBCRE, errnum); return FAIL; } /** * Convert column for input to a table */ static TDSRET _bcp_convert_in(DBPROCESS *dbproc, TDS_SERVER_TYPE srctype, const TDS_CHAR *src, TDS_UINT srclen, TDS_SERVER_TYPE desttype, BCPCOLDATA *coldata) { int variable = 1; CONV_RESULT cr, *p_cr; TDS_INT len; coldata->is_null = 0; if (!is_variable_type(desttype)) { variable = 0; p_cr = (CONV_RESULT *) coldata->data; } else { p_cr = &cr; } len = tds_convert(dbproc->tds_socket->conn->tds_ctx, srctype, src, srclen, desttype, p_cr); if (len < 0) { _dblib_convert_err(dbproc, len); return TDS_FAIL; } coldata->datalen = len; if (variable) { free(coldata->data); coldata->data = (TDS_UCHAR *) cr.c; } return TDS_SUCCESS; } /** * \ingroup dblib_bcp_internal * \brief * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param hostfile * \param row_error * * \return MORE_ROWS, NO_MORE_ROWS, or FAIL. * \sa BCP_SETL(), bcp_batch(), bcp_bind(), bcp_colfmt(), bcp_colfmt_ps(), bcp_collen(), bcp_colptr(), bcp_columns(), bcp_control(), bcp_done(), bcp_exec(), bcp_getl(), bcp_init(), bcp_moretext(), bcp_options(), bcp_readfmt(), bcp_sendrow() */ static STATUS _bcp_read_hostfile(DBPROCESS * dbproc, FILE * hostfile, int *row_error) { TDSCOLUMN *bcpcol; BCP_HOSTCOLINFO *hostcol; TDS_TINYINT ti; TDS_SMALLINT si; TDS_INT li; TDS_SERVER_TYPE desttype; TDS_CHAR *coldata; int i, collen, data_is_null; tdsdump_log(TDS_DBG_FUNC, "_bcp_read_hostfile(%p, %p, %p)\n", dbproc, hostfile, row_error); assert(dbproc); assert(hostfile); assert(row_error); /* for each host file column defined by calls to bcp_colfmt */ for (i = 0; i < dbproc->hostfileinfo->host_colcount; i++) { offset_type col_start; tdsdump_log(TDS_DBG_FUNC, "parsing host column %d\n", i + 1); hostcol = dbproc->hostfileinfo->host_columns[i]; data_is_null = 0; collen = 0; hostcol->column_error = 0; /* * If this host file column contains table data, * find the right element in the table/column list. */ bcpcol = NULL; if (hostcol->tab_colnum > 0) { if (hostcol->tab_colnum > dbproc->bcpinfo->bindinfo->num_cols) { tdsdump_log(TDS_DBG_FUNC, "error: file wider than table: %d/%d\n", i+1, dbproc->bcpinfo->bindinfo->num_cols); dbperror(dbproc, SYBEBEOF, 0); return FAIL; } tdsdump_log(TDS_DBG_FUNC, "host column %d uses bcpcol %d (%p)\n", i+1, hostcol->tab_colnum, bcpcol); bcpcol = dbproc->bcpinfo->bindinfo->columns[hostcol->tab_colnum - 1]; assert(bcpcol != NULL); } /* detect prefix len */ if (bcpcol && hostcol->prefix_len == -1) bcp_cache_prefix_len(hostcol, bcpcol); /* a prefix length, if extant, specifies how many bytes to read */ if (hostcol->prefix_len > 0) { switch (hostcol->prefix_len) { case 1: if (fread(&ti, 1, 1, hostfile) != 1) return _bcp_check_eof(dbproc, hostfile, i); collen = ti ? ti : -1; break; case 2: if (fread(&si, 2, 1, hostfile) != 1) return _bcp_check_eof(dbproc, hostfile, i); collen = si; break; case 4: if (fread(&li, 4, 1, hostfile) != 1) return _bcp_check_eof(dbproc, hostfile, i); collen = li; break; default: /* FIXME return error, remember that prefix_len can be 3 */ assert(hostcol->prefix_len <= 4); break; } /* TODO test all NULL types */ /* TODO for < -1 error */ if (collen <= -1) { data_is_null = 1; collen = 0; } } /* if (Max) column length specified take that into consideration. (Meaning what, exactly?) */ if (!data_is_null && hostcol->column_len >= 0) { if (hostcol->column_len == 0) data_is_null = 1; else { if (collen) collen = (hostcol->column_len < collen) ? hostcol->column_len : collen; else collen = hostcol->column_len; } } tdsdump_log(TDS_DBG_FUNC, "prefix_len = %d collen = %d \n", hostcol->prefix_len, collen); /* Fixed Length data - this overrides anything else specified */ if (is_fixed_type(hostcol->datatype)) collen = tds_get_size_by_type(hostcol->datatype); col_start = ftello(hostfile); /* * The data file either contains prefixes stating the length, or is delimited. * If delimited, we "measure" the field by looking for the terminator, then read it, * and set collen to the field's post-iconv size. */ if (hostcol->term_len > 0) { /* delimited data file */ size_t col_bytes; TDSRET conv_res; /* * Read and convert the data */ coldata = NULL; conv_res = tds_bcp_fread(dbproc->tds_socket, bcpcol ? bcpcol->char_conv : NULL, hostfile, (const char *) hostcol->terminator, hostcol->term_len, &coldata, &col_bytes); if (TDS_FAILED(conv_res)) { tdsdump_log(TDS_DBG_FUNC, "col %d: error converting %ld bytes!\n", (i+1), (long) collen); *row_error = TRUE; free(coldata); dbperror(dbproc, SYBEBCOR, 0); return FAIL; } if (conv_res == TDS_NO_MORE_RESULTS) { free(coldata); return _bcp_check_eof(dbproc, hostfile, i); } if (col_bytes > 0x7fffffffl) { free(coldata); *row_error = TRUE; tdsdump_log(TDS_DBG_FUNC, "data from file is too large!\n"); dbperror(dbproc, SYBEBCOR, 0); return FAIL; } collen = (int)col_bytes; if (collen == 0) data_is_null = 1; /* * TODO: * Dates are a problem. In theory, we should be able to read non-English dates, which * would contain non-ASCII characters. One might suppose we should convert date * strings to ISO-8859-1 (or another canonical form) here, because tds_convert() can't be * expected to deal with encodings. But instead date strings are read verbatim and * passed to tds_convert() without even waving to iconv(). For English dates, this works, * because English dates expressed as UTF-8 strings are indistinguishable from the ASCII. */ } else { /* unterminated field */ coldata = tds_new(TDS_UCHAR, 1 + collen); if (coldata == NULL) { *row_error = TRUE; dbperror(dbproc, SYBEMEM, errno); return FAIL; } coldata[collen] = 0; if (collen) { /* * Read and convert the data * TODO: Call tds_iconv_fread() instead of fread(3). * The columns should each have their iconv cd set, and noncharacter data * should have -1 as the iconv cd, causing tds_iconv_fread() to not attempt * any conversion. We do not need a datatype switch here to decide what to do. * As of 0.62, this *should* actually work. All that remains is to change the * call and test it. */ tdsdump_log(TDS_DBG_FUNC, "Reading %d bytes from hostfile.\n", collen); if (fread(coldata, collen, 1, hostfile) != 1) { free(coldata); return _bcp_check_eof(dbproc, hostfile, i); } } } /* * At this point, however the field was read, however big it was, its address is coldata and its size is collen. */ tdsdump_log(TDS_DBG_FUNC, "Data read from hostfile: collen is now %d, data_is_null is %d\n", collen, data_is_null); if (bcpcol) { if (data_is_null) { bcpcol->bcp_column_data->is_null = 1; bcpcol->bcp_column_data->datalen = 0; } else { TDSRET rc; desttype = tds_get_conversion_type(bcpcol->column_type, bcpcol->column_size); rc = _bcp_convert_in(dbproc, hostcol->datatype, (const TDS_CHAR*) coldata, collen, desttype, bcpcol->bcp_column_data); if (TDS_FAILED(rc)) { hostcol->column_error = HOST_COL_CONV_ERROR; *row_error = 1; tdsdump_log(TDS_DBG_FUNC, "_bcp_read_hostfile failed to convert %d bytes at offset 0x%" PRIx64 " in the data file.\n", collen, (TDS_INT8) col_start); } /* trim trailing blanks from character data */ if (is_ascii_type(bcpcol->on_server.column_type)) { /* A single NUL byte indicates an empty string. */ if (bcpcol->bcp_column_data->datalen == 1 && bcpcol->bcp_column_data->data[0] == '\0') { bcpcol->bcp_column_data->datalen = 0; } else { bcpcol->bcp_column_data->datalen = rtrim((char *) bcpcol->bcp_column_data->data, bcpcol->bcp_column_data->datalen); } } } #if USING_SYBEBCNN if (!hostcol->column_error) { if (bcpcol->bcp_column_data->datalen <= 0) { /* Are we trying to insert a NULL ? */ if (!bcpcol->column_nullable) { /* too bad if the column is not nullable */ hostcol->column_error = HOST_COL_NULL_ERROR; *row_error = 1; dbperror(dbproc, SYBEBCNN, 0); } } } #endif } free(coldata); } return MORE_ROWS; } /** * \ingroup dblib_bcp * \brief Write data in host variables to the table. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * * \remarks Call bcp_bind() first to describe the variables to be used. * Use bcp_batch() to commit sets of rows. * After sending the last row call bcp_done(). * \return SUCCEED or FAIL. * \sa bcp_batch(), bcp_bind(), bcp_colfmt(), bcp_collen(), bcp_colptr(), bcp_columns(), * bcp_control(), bcp_done(), bcp_exec(), bcp_init(), bcp_moretext(), bcp_options() */ RETCODE bcp_sendrow(DBPROCESS * dbproc) { TDSSOCKET *tds; tdsdump_log(TDS_DBG_FUNC, "bcp_sendrow(%p)\n", dbproc); CHECK_CONN(FAIL); CHECK_PARAMETER(dbproc->bcpinfo, SYBEBCPI, FAIL); tds = dbproc->tds_socket; if (dbproc->bcpinfo->direction != DB_IN) { dbperror(dbproc, SYBEBCPN, 0); return FAIL; } if (dbproc->hostfileinfo != NULL) { dbperror(dbproc, SYBEBCPB, 0); return FAIL; } /* * The first time sendrow is called after bcp_init, * there is a certain amount of initialisation to be done. */ if (dbproc->bcpinfo->xfer_init == 0) { /* The start_copy function retrieves details of the table's columns */ if (TDS_FAILED(tds_bcp_start_copy_in(tds, dbproc->bcpinfo))) { dbperror(dbproc, SYBEBULKINSERT, 0); return FAIL; } dbproc->bcpinfo->xfer_init = 1; } dbproc->bcpinfo->parent = dbproc; return TDS_FAILED(tds_bcp_send_record(dbproc->tds_socket, dbproc->bcpinfo, _bcp_get_col_data, NULL, 0)) ? FAIL : SUCCEED; } /** * \ingroup dblib_bcp_internal * \brief * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param rows_copied * * \return SUCCEED or FAIL. * \sa BCP_SETL(), bcp_batch(), bcp_bind(), bcp_colfmt(), bcp_colfmt_ps(), bcp_collen(), bcp_colptr(), bcp_columns(), bcp_control(), bcp_done(), bcp_exec(), bcp_getl(), bcp_init(), bcp_moretext(), bcp_options(), bcp_readfmt(), bcp_sendrow() */ static RETCODE _bcp_exec_in(DBPROCESS * dbproc, DBINT * rows_copied) { FILE *hostfile, *errfile = NULL; TDSSOCKET *tds = dbproc->tds_socket; BCP_HOSTCOLINFO *hostcol; STATUS ret; int i, row_of_hostfile, rows_written_so_far; int row_error, row_error_count; offset_type row_start, row_end; offset_type error_row_size; const size_t chunk_size = 0x20000u; tdsdump_log(TDS_DBG_FUNC, "_bcp_exec_in(%p, %p)\n", dbproc, rows_copied); assert(dbproc); assert(rows_copied); *rows_copied = 0; if (!(hostfile = fopen(dbproc->hostfileinfo->hostfile, "r"))) { dbperror(dbproc, SYBEBCUO, 0); return FAIL; } if (TDS_FAILED(tds_bcp_start_copy_in(tds, dbproc->bcpinfo))) { fclose(hostfile); return FAIL; } row_of_hostfile = 0; rows_written_so_far = 0; row_start = ftello(hostfile); row_error_count = 0; row_error = 0; dbproc->bcpinfo->parent = dbproc; while ((ret=_bcp_read_hostfile(dbproc, hostfile, &row_error)) == MORE_ROWS) { row_of_hostfile++; if (row_error) { int count; if (errfile == NULL && dbproc->hostfileinfo->errorfile) { if (!(errfile = fopen(dbproc->hostfileinfo->errorfile, "w"))) { fclose(hostfile); dbperror(dbproc, SYBEBUOE, 0); return FAIL; } } if (errfile != NULL) { char *row_in_error = NULL; for (i = 0; i < dbproc->hostfileinfo->host_colcount; i++) { hostcol = dbproc->hostfileinfo->host_columns[i]; if (hostcol->column_error == HOST_COL_CONV_ERROR) { count = fprintf(errfile, "#@ data conversion error on host data file Row %d Column %d\n", row_of_hostfile, i + 1); if( count < 0 ) { dbperror(dbproc, SYBEBWEF, errno); } } else if (hostcol->column_error == HOST_COL_NULL_ERROR) { count = fprintf(errfile, "#@ Attempt to bulk-copy a NULL value into Server column" " which does not accept NULL values. Row %d, Column %d\n", row_of_hostfile, i + 1); if( count < 0 ) { dbperror(dbproc, SYBEBWEF, errno); } } } row_end = ftello(hostfile); /* error data can be very long so split in chunks */ error_row_size = row_end - row_start; fseeko(hostfile, row_start, SEEK_SET); while (error_row_size > 0) { size_t chunk = error_row_size > chunk_size ? chunk_size : (size_t) error_row_size; if (!row_in_error) { if ((row_in_error = tds_new(char, chunk)) == NULL) { dbperror(dbproc, SYBEMEM, errno); } } if (fread(row_in_error, chunk, 1, hostfile) != 1) { printf("BILL fread failed after fseek\n"); } count = (int)fwrite(row_in_error, chunk, 1, errfile); if( (size_t)count < chunk ) { dbperror(dbproc, SYBEBWEF, errno); } error_row_size -= chunk; } free(row_in_error); fseeko(hostfile, row_end, SEEK_SET); count = fprintf(errfile, "\n"); if( count < 0 ) { dbperror(dbproc, SYBEBWEF, errno); } } row_error_count++; if (row_error_count > dbproc->hostfileinfo->maxerrs) break; } else { if (dbproc->hostfileinfo->firstrow <= row_of_hostfile && row_of_hostfile <= MAX(dbproc->hostfileinfo->lastrow, 0x7FFFFFFF)) { if (TDS_SUCCEED(tds_bcp_send_record(dbproc->tds_socket, dbproc->bcpinfo, _bcp_no_get_col_data, NULL, 0))) { rows_written_so_far++; if (dbproc->hostfileinfo->batch > 0 && rows_written_so_far == dbproc->hostfileinfo->batch) { if (TDS_FAILED(tds_bcp_done(tds, &rows_written_so_far))) { if (errfile) fclose(errfile); fclose(hostfile); return FAIL; } *rows_copied += rows_written_so_far; rows_written_so_far = 0; dbperror(dbproc, SYBEBBCI, 0); /* batch copied to server */ tds_bcp_start(tds, dbproc->bcpinfo); } } } } row_start = ftello(hostfile); row_error = 0; } if( row_error_count == 0 && row_of_hostfile < dbproc->hostfileinfo->firstrow ) { /* "The BCP hostfile '%1!' contains only %2! rows. */ dbperror(dbproc, SYBEBCSA, 0, dbproc->hostfileinfo->hostfile, row_of_hostfile); } if (errfile && 0 != fclose(errfile) ) { dbperror(dbproc, SYBEBUCE, 0); } if (fclose(hostfile) != 0) { dbperror(dbproc, SYBEBCUC, 0); ret = FAIL; } tds_bcp_done(tds, &rows_written_so_far); *rows_copied += rows_written_so_far; return ret == NO_MORE_ROWS? SUCCEED : FAIL; /* (ret is returned from _bcp_read_hostfile) */ } /** * \ingroup dblib_bcp * \brief Write a datafile to a table. * * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param rows_copied bcp_exec will write the count of rows successfully written to this address. * If \a rows_copied is NULL, it will be ignored by db-lib. * * \return SUCCEED or FAIL. * \sa bcp_batch(), bcp_bind(), bcp_colfmt(), bcp_collen(), bcp_colptr(), bcp_columns(), * bcp_control(), bcp_done(), bcp_init(), bcp_sendrow() */ RETCODE bcp_exec(DBPROCESS * dbproc, DBINT *rows_copied) { DBINT dummy_copied; RETCODE ret = FAIL; tdsdump_log(TDS_DBG_FUNC, "bcp_exec(%p, %p)\n", dbproc, rows_copied); CHECK_CONN(FAIL); CHECK_PARAMETER(dbproc->bcpinfo, SYBEBCPI, FAIL); CHECK_PARAMETER(dbproc->hostfileinfo, SYBEBCVH, FAIL); if (rows_copied == NULL) /* NULL means we should ignore it */ rows_copied = &dummy_copied; if (dbproc->bcpinfo->direction == DB_OUT || dbproc->bcpinfo->direction == DB_QUERYOUT) { ret = _bcp_exec_out(dbproc, rows_copied); } else if (dbproc->bcpinfo->direction == DB_IN) { ret = _bcp_exec_in(dbproc, rows_copied); } _bcp_free_storage(dbproc); return ret; } /** * \ingroup dblib_bcp_internal * \brief * * \param buffer * \param size * \param f * * \return SUCCEED or FAIL. * \sa BCP_SETL(), bcp_batch(), bcp_bind(), bcp_colfmt(), bcp_colfmt_ps(), bcp_collen(), bcp_colptr(), bcp_columns(), bcp_control(), bcp_done(), bcp_exec(), bcp_getl(), bcp_init(), bcp_moretext(), bcp_options(), bcp_readfmt(), bcp_sendrow() */ static char * _bcp_fgets(char *buffer, int size, FILE *f) { char *p = fgets(buffer, size, f); if (p == NULL) return p; /* discard newline */ p = strchr(buffer, 0) - 1; if (p >= buffer && *p == '\n') *p = 0; return buffer; } /** * \ingroup dblib_bcp * \brief Read a format definition file. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param filename Name that will be passed to fopen(3). * * \remarks Reads a format file and calls bcp_columns() and bcp_colfmt() as needed. * * \return SUCCEED or FAIL. * \sa bcp_colfmt(), bcp_colfmt_ps(), bcp_columns(), bcp_writefmt() */ RETCODE bcp_readfmt(DBPROCESS * dbproc, const char filename[]) { BCP_HOSTCOLINFO hostcol[1]; FILE *ffile; char buffer[1024]; float lf_version = 0.0; int li_numcols = 0; int colinfo_count = 0; tdsdump_log(TDS_DBG_FUNC, "bcp_readfmt(%p, %s)\n", dbproc, filename? filename:"NULL"); CHECK_CONN(FAIL); CHECK_PARAMETER(dbproc->bcpinfo, SYBEBCPI, FAIL); CHECK_NULP(filename, "bcp_readfmt", 2, FAIL); memset(hostcol, 0, sizeof(hostcol)); if ((ffile = fopen(filename, "r")) == NULL) { dbperror(dbproc, SYBEBUOF, 0); goto Cleanup; } if ((_bcp_fgets(buffer, sizeof(buffer), ffile)) != NULL) { lf_version = (float)atof(buffer); } else if (ferror(ffile)) { dbperror(dbproc, SYBEBRFF, errno); goto Cleanup; } if ((_bcp_fgets(buffer, sizeof(buffer), ffile)) != NULL) { li_numcols = atoi(buffer); } else if (ferror(ffile)) { dbperror(dbproc, SYBEBRFF, errno); goto Cleanup; } if (li_numcols <= 0) goto Cleanup; if (bcp_columns(dbproc, li_numcols) == FAIL) goto Cleanup; do { memset(hostcol, 0, sizeof(hostcol)); if (_bcp_fgets(buffer, sizeof(buffer), ffile) == NULL) goto Cleanup; if (!_bcp_readfmt_colinfo(dbproc, buffer, hostcol)) goto Cleanup; if (bcp_colfmt(dbproc, hostcol->host_column, hostcol->datatype, hostcol->prefix_len, hostcol->column_len, hostcol->terminator, hostcol->term_len, hostcol->tab_colnum) == FAIL) { goto Cleanup; } TDS_ZERO_FREE(hostcol->terminator); } while (++colinfo_count < li_numcols); if (ferror(ffile)) { dbperror(dbproc, SYBEBRFF, errno); goto Cleanup; } if (fclose(ffile) != 0) { dbperror(dbproc, SYBEBUCF, 0); /* even if failure is returned ffile is no more valid */ ffile = NULL; goto Cleanup; } ffile = NULL; if (colinfo_count != li_numcols) goto Cleanup; return SUCCEED; Cleanup: TDS_ZERO_FREE(hostcol->terminator); _bcp_free_columns(dbproc); if (ffile) fclose(ffile); return FAIL; } /** * \ingroup dblib_bcp_internal * \brief * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param buf * \param ci * * \return SUCCEED or FAIL. * \sa BCP_SETL(), bcp_batch(), bcp_bind(), bcp_colfmt(), bcp_colfmt_ps(), bcp_collen(), bcp_colptr(), bcp_columns(), bcp_control(), bcp_done(), bcp_exec(), bcp_getl(), bcp_init(), bcp_moretext(), bcp_options(), bcp_readfmt(), bcp_sendrow() */ static int _bcp_readfmt_colinfo(DBPROCESS * dbproc, char *buf, BCP_HOSTCOLINFO * ci) { char *tok; int whichcol; char term[30]; int i; char *lasts; enum nextcol { HOST_COLUMN, DATATYPE, PREFIX_LEN, COLUMN_LEN, TERMINATOR, TAB_COLNUM, NO_MORE_COLS }; assert(dbproc); assert(buf); assert(ci); tdsdump_log(TDS_DBG_FUNC, "_bcp_readfmt_colinfo(%p, %s, %p)\n", dbproc, buf, ci); tok = strtok_r(buf, " \t", &lasts); whichcol = HOST_COLUMN; /* TODO use a better way to get an int atoi is very error prone */ while (tok != NULL && whichcol != NO_MORE_COLS) { switch (whichcol) { case HOST_COLUMN: ci->host_column = atoi(tok); if (ci->host_column < 1) { dbperror(dbproc, SYBEBIHC, 0); return (FALSE); } whichcol = DATATYPE; break; case DATATYPE: if (strcmp(tok, "SYBCHAR") == 0) ci->datatype = SYBCHAR; else if (strcmp(tok, "SYBTEXT") == 0) ci->datatype = SYBTEXT; else if (strcmp(tok, "SYBBINARY") == 0) ci->datatype = SYBBINARY; else if (strcmp(tok, "SYBIMAGE") == 0) ci->datatype = SYBIMAGE; else if (strcmp(tok, "SYBINT1") == 0) ci->datatype = SYBINT1; else if (strcmp(tok, "SYBINT2") == 0) ci->datatype = SYBINT2; else if (strcmp(tok, "SYBINT4") == 0) ci->datatype = SYBINT4; else if (strcmp(tok, "SYBINT8") == 0) ci->datatype = SYBINT8; else if (strcmp(tok, "SYBFLT8") == 0) ci->datatype = SYBFLT8; else if (strcmp(tok, "SYBREAL") == 0) ci->datatype = SYBREAL; else if (strcmp(tok, "SYBBIT") == 0) ci->datatype = SYBBIT; else if (strcmp(tok, "SYBNUMERIC") == 0) ci->datatype = SYBNUMERIC; else if (strcmp(tok, "SYBDECIMAL") == 0) ci->datatype = SYBDECIMAL; else if (strcmp(tok, "SYBMONEY") == 0) ci->datatype = SYBMONEY; else if (strcmp(tok, "SYBMONEY4") == 0) ci->datatype = SYBMONEY4; else if (strcmp(tok, "SYBDATETIME") == 0) ci->datatype = SYBDATETIME; else if (strcmp(tok, "SYBDATETIME4") == 0) ci->datatype = SYBDATETIME4; /* TODO SQL* for MS SQLNCHAR SQLBIGINT SQLTINYINT SQLSMALLINT SQLUNIQUEID SQLVARIANT SQLUDT */ else { dbperror(dbproc, SYBEBUDF, 0); return (FALSE); } whichcol = PREFIX_LEN; break; case PREFIX_LEN: ci->prefix_len = atoi(tok); whichcol = COLUMN_LEN; break; case COLUMN_LEN: ci->column_len = atoi(tok); whichcol = TERMINATOR; break; case TERMINATOR: if (*tok++ != '\"') return (FALSE); for (i = 0; *tok != '\"' && i < sizeof(term); i++) { if (*tok == '\\') { tok++; switch (*tok) { case 't': term[i] = '\t'; break; case 'n': term[i] = '\n'; break; case 'r': term[i] = '\r'; break; case '\\': term[i] = '\\'; break; case '0': term[i] = '\0'; break; default: return (FALSE); } tok++; } else term[i] = *tok++; } if (*tok != '\"') return (FALSE); ci->term_len = i; TDS_ZERO_FREE(ci->terminator); if (i > 0) { if ((ci->terminator = tds_new(BYTE, i)) == NULL) { dbperror(dbproc, SYBEMEM, errno); return FALSE; } memcpy(ci->terminator, term, i); } whichcol = TAB_COLNUM; break; case TAB_COLNUM: ci->tab_colnum = atoi(tok); whichcol = NO_MORE_COLS; break; } tok = strtok_r(NULL, " \t", &lasts); } if (whichcol == NO_MORE_COLS) return (TRUE); else return (FALSE); } #if defined(DBLIB_UNIMPLEMENTED) /** * \ingroup dblib_bcp * \brief Write a format definition file. Not Implemented. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param filename Name that would be passed to fopen(3). * * \remarks Reads a format file and calls bcp_columns() and bcp_colfmt() as needed. * \a FreeTDS includes freebcp, a utility to copy data to or from a host file. * * \todo For completeness, \a freebcp ought to be able to create format files, but that functionality * is currently lacking, as is bcp_writefmt(). * \todo See the vendors' documentation for the format of these files. * * \return SUCCEED or FAIL. * \sa bcp_colfmt(), bcp_colfmt_ps(), bcp_columns(), bcp_readfmt() */ RETCODE bcp_writefmt(DBPROCESS * dbproc, const char filename[]) { tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED: bcp_writefmt(%p, %s)\n", dbproc, filename? filename:"NULL"); CHECK_CONN(FAIL); CHECK_PARAMETER(dbproc->bcpinfo, SYBEBCPI, FAIL); CHECK_NULP(filename, "bcp_writefmt", 2, FAIL); #if 0 dbperror(dbproc, SYBEBUFF, errno); /* bcp: Unable to create format file */ dbperror(dbproc, SYBEBWFF, errno); /* I/O error while writing bcp format file */ #endif return FAIL; } /** * \ingroup dblib_bcp * \brief Write some text or image data to the server. Not implemented, sadly. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param size How much to write, in bytes. * \param text Address of the data to be written. * \remarks For a SYBTEXT or SYBIMAGE column, bcp_bind() can be called with * a NULL varaddr parameter. If it is, bcp_sendrow() will return control * to the application after the non-text data have been sent. The application then calls * bcp_moretext() -- usually in a loop -- to send the text data in manageable chunks. * \todo implement bcp_moretext(). * \return SUCCEED or FAIL. * \sa bcp_bind(), bcp_sendrow(), dbmoretext(), dbwritetext() */ RETCODE bcp_moretext(DBPROCESS * dbproc, DBINT size, BYTE * text) { tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED: bcp_moretext(%p, %d, %p)\n", dbproc, size, text); CHECK_CONN(FAIL); CHECK_PARAMETER(dbproc->bcpinfo, SYBEBCPI, FAIL); CHECK_NULP(text, "bcp_moretext", 3, FAIL); #if 0 dbperror(dbproc, SYBEBCMTXT, 0); /* bcp_moretext may be used only when there is at least one text or image column in the server table */ dbperror(dbproc, SYBEBTMT, 0); /* Attempt to send too much text data via the bcp_moretext call */ #endif return FAIL; } #endif /** * \ingroup dblib_bcp * \brief Commit a set of rows to the table. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \remarks If not called, bcp_done() will cause the rows to be saved. * \return Count of rows saved, or -1 on error. * \sa bcp_bind(), bcp_done(), bcp_sendrow() */ DBINT bcp_batch(DBPROCESS * dbproc) { int rows_copied = 0; tdsdump_log(TDS_DBG_FUNC, "bcp_batch(%p)\n", dbproc); CHECK_CONN(-1); CHECK_PARAMETER(dbproc->bcpinfo, SYBEBCPI, -1); if (TDS_FAILED(tds_bcp_done(dbproc->tds_socket, &rows_copied))) return -1; tds_bcp_start(dbproc->tds_socket, dbproc->bcpinfo); return rows_copied; } /** * \ingroup dblib_bcp * \brief Conclude the transfer of data from program variables. * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \remarks Do not overlook this function. According to Sybase, failure to call bcp_done() * "will result in unpredictable errors". * \return As with bcp_batch(), the count of rows saved, or -1 on error. * \sa bcp_batch(), bcp_bind(), bcp_moretext(), bcp_sendrow() */ DBINT bcp_done(DBPROCESS * dbproc) { int rows_copied; tdsdump_log(TDS_DBG_FUNC, "bcp_done(%p)\n", dbproc); CHECK_CONN(-1); if (!(dbproc->bcpinfo)) return -1; if (TDS_FAILED(tds_bcp_done(dbproc->tds_socket, &rows_copied))) return -1; _bcp_free_storage(dbproc); return rows_copied; } /** * \ingroup dblib_bcp * \brief Bind a program host variable to a database column * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param varaddr address of host variable * \param prefixlen length of any prefix found at the beginning of \a varaddr, in bytes. Use zero for fixed-length datatypes. * \param varlen bytes of data in \a varaddr. Zero for NULL, -1 for fixed-length datatypes. * \param terminator byte sequence that marks the end of the data in \a varaddr * \param termlen length of \a terminator * \param vartype datatype of the host variable * \param table_column Nth column, starting at 1, in the table. * * \remarks The order of operation is: * - bcp_init() with \a hfile == NULL and \a direction == DB_IN. * - bcp_bind(), once per column you want to write to * - bcp_batch(), optionally, to commit a set of rows * - bcp_done() * \return SUCCEED or FAIL. * \sa bcp_batch(), bcp_colfmt(), bcp_collen(), bcp_colptr(), bcp_columns(), bcp_control(), * bcp_done(), bcp_exec(), bcp_moretext(), bcp_sendrow() */ RETCODE bcp_bind(DBPROCESS * dbproc, BYTE * varaddr, int prefixlen, DBINT varlen, BYTE * terminator, int termlen, int db_vartype, int table_column) { TDS_SERVER_TYPE vartype; TDSCOLUMN *colinfo; tdsdump_log(TDS_DBG_FUNC, "bcp_bind(%p, %p, %d, %d -- %p, %d, %s, %d)\n", dbproc, varaddr, prefixlen, varlen, terminator, termlen, dbprtype(db_vartype), table_column); CHECK_CONN(FAIL); CHECK_PARAMETER(dbproc->bcpinfo, SYBEBCPI, FAIL); DBPERROR_RETURN(!is_tds_type_valid(db_vartype), SYBEUDTY); vartype = (TDS_SERVER_TYPE) db_vartype; if (dbproc->hostfileinfo != NULL) { dbperror(dbproc, SYBEBCPB, 0); return FAIL; } if (dbproc->bcpinfo->direction != DB_IN) { dbperror(dbproc, SYBEBCPN, 0); return FAIL; } if (varlen < -1) { dbperror(dbproc, SYBEBCVLEN, 0); return FAIL; } if (prefixlen != 0 && prefixlen != 1 && prefixlen != 2 && prefixlen != 4) { dbperror(dbproc, SYBEBCBPREF, 0); return FAIL; } if (prefixlen == 0 && varlen == -1 && termlen == -1 && !is_fixed_type(vartype)) { tdsdump_log(TDS_DBG_FUNC, "bcp_bind(): non-fixed type %d requires prefix or terminator\n", vartype); return FAIL; } if (is_fixed_type(vartype) && (varlen != -1 && varlen != 0)) { dbperror(dbproc, SYBEBCIT, 0); return FAIL; } if (table_column <= 0 || table_column > dbproc->bcpinfo->bindinfo->num_cols) { dbperror(dbproc, SYBECNOR, 0); return FAIL; } if (varaddr == NULL && (prefixlen != 0 || termlen != 0)) { dbperror(dbproc, SYBEBCBNPR, 0); return FAIL; } colinfo = dbproc->bcpinfo->bindinfo->columns[table_column - 1]; /* If varaddr is NULL and varlen greater than 0, the table column type must be SYBTEXT or SYBIMAGE and the program variable type must be SYBTEXT, SYBCHAR, SYBIMAGE or SYBBINARY */ if (varaddr == NULL && varlen > 0) { int fOK = (colinfo->column_type == SYBTEXT || colinfo->column_type == SYBIMAGE) && (vartype == SYBTEXT || vartype == SYBCHAR || vartype == SYBIMAGE || vartype == SYBBINARY ); if( !fOK ) { dbperror(dbproc, SYBEBCBNTYP, 0); tdsdump_log(TDS_DBG_FUNC, "bcp_bind: SYBEBCBNTYP: column=%d and vartype=%d (should fail?)\n", colinfo->column_type, vartype); /* return FAIL; */ } } colinfo->column_varaddr = (char *)varaddr; colinfo->column_bindtype = vartype; colinfo->column_bindlen = varlen; colinfo->bcp_prefix_len = prefixlen; TDS_ZERO_FREE(colinfo->bcp_terminator); colinfo->bcp_term_len = 0; if (termlen > 0) { if ((colinfo->bcp_terminator = tds_new(TDS_CHAR, termlen)) == NULL) { dbperror(dbproc, SYBEMEM, errno); return FAIL; } memcpy(colinfo->bcp_terminator, terminator, termlen); colinfo->bcp_term_len = termlen; } return SUCCEED; } /** * \ingroup dblib_bcp_internal * \brief For a bcp in from program variables, get the data from the host variable * * \param dbproc contains all information needed by db-lib to manage communications with the server. * \param bindcol * * \return TDS_SUCCESS or TDS_FAIL. * \sa _bcp_add_fixed_columns, _bcp_add_variable_columns, _bcp_send_bcp_record */ static TDSRET _bcp_get_col_data(TDSBCPINFO *bcpinfo, TDSCOLUMN *bindcol, int offset) { TDS_SERVER_TYPE coltype, desttype; int collen; int bytes_read; BYTE *dataptr; DBPROCESS *dbproc = (DBPROCESS *) bcpinfo->parent; TDSRET rc; tdsdump_log(TDS_DBG_FUNC, "_bcp_get_col_data(%p, %p)\n", bcpinfo, bindcol); CHECK_CONN(TDS_FAIL); CHECK_NULP(bindcol, "_bcp_get_col_data", 2, TDS_FAIL); dataptr = (BYTE *) bindcol->column_varaddr; collen = 0; /* If a prefix length specified, read the correct amount of data. */ if (bindcol->bcp_prefix_len > 0) { switch (bindcol->bcp_prefix_len) { case 1: collen = TDS_GET_UA1(dataptr); dataptr += 1; break; case 2: collen = (TDS_SMALLINT) TDS_GET_UA2(dataptr); dataptr += 2; break; case 4: collen = (TDS_INT) TDS_GET_UA4(dataptr); dataptr += 4; break; } if (collen <= 0) goto null_data; } /* if (Max) column length specified take that into consideration. */ if (bindcol->column_bindlen >= 0) { if (bindcol->column_bindlen == 0) goto null_data; if (collen) collen = (int) ((bindcol->column_bindlen < (TDS_UINT)collen) ? bindcol->column_bindlen : (TDS_UINT)collen); else collen = (int) bindcol->column_bindlen; } desttype = tds_get_conversion_type(bindcol->column_type, bindcol->column_size); /* Fixed Length data - this overrides anything else specified */ coltype = bindcol->column_bindtype == 0 ? desttype : (TDS_SERVER_TYPE) bindcol->column_bindtype; if (is_fixed_type(coltype)) { collen = tds_get_size_by_type(coltype); } /* read the data, finally */ if (bindcol->bcp_term_len > 0) { /* terminated field */ bytes_read = _bcp_get_term_var(dataptr, (BYTE *)bindcol->bcp_terminator, bindcol->bcp_term_len); if (collen) collen = (bytes_read < collen) ? bytes_read : collen; else collen = bytes_read; if (collen == 0) goto null_data; } if (collen < 0) collen = (int) strlen((char *) dataptr); rc = _bcp_convert_in(dbproc, coltype, (const TDS_CHAR*) dataptr, collen, desttype, bindcol->bcp_column_data); if (TDS_FAILED(rc)) return rc; return TDS_SUCCESS; null_data: bindcol->bcp_column_data->datalen = 0; bindcol->bcp_column_data->is_null = 1; return TDS_SUCCESS; } /** * Function to read data from file. I this case is empty as data * are already on bcp_column_data */ static TDSRET _bcp_no_get_col_data(TDSBCPINFO *bcpinfo, TDSCOLUMN *bindcol, int offset) { return TDS_SUCCESS; } /** * Get the data for bcp-in from program variables, where the program data * have been identified as character terminated, * This is a low-level, internal function. Call it correctly. */ /** * \ingroup dblib_bcp_internal * \brief * * \param pdata * \param term * \param term_len * * \return data length. */ static int _bcp_get_term_var(BYTE * pdata, BYTE * term, int term_len) { int bufpos; assert(term_len > 0); /* if bufpos becomes negative, we probably failed to find the terminator */ for (bufpos = 0; bufpos >= 0 && memcmp(pdata, term, term_len) != 0; pdata++) { bufpos++; } assert(bufpos >= 0); return bufpos; } /** * \ingroup dblib_bcp_internal * \brief trim a string of trailing blanks * * Replaces spaces at the end of a string with NULs * \param str pointer to a character buffer (not null-terminated) * \param len size of the \a str in bytes * * \return modified length */ static int rtrim(char *str, int len) { char *p = str + len - 1; while (p > str && *p == ' ') { *p-- = '\0'; } return (int)(1 + p - str); } /** * \ingroup dblib_bcp_internal * \brief * * \param dbproc contains all information needed by db-lib to manage communications with the server. */ static void _bcp_free_columns(DBPROCESS * dbproc) { int i; tdsdump_log(TDS_DBG_FUNC, "_bcp_free_columns(%p)\n", dbproc); assert(dbproc && dbproc->hostfileinfo); if (dbproc->hostfileinfo->host_columns) { for (i = 0; i < dbproc->hostfileinfo->host_colcount; i++) { TDS_ZERO_FREE(dbproc->hostfileinfo->host_columns[i]->terminator); TDS_ZERO_FREE(dbproc->hostfileinfo->host_columns[i]); } TDS_ZERO_FREE(dbproc->hostfileinfo->host_columns); dbproc->hostfileinfo->host_colcount = 0; } } /** * \ingroup dblib_bcp_internal * \brief * * \param dbproc contains all information needed by db-lib to manage communications with the server. * * \sa bcp_done(), bcp_exec(), bcp_init() */ static void _bcp_free_storage(DBPROCESS * dbproc) { tdsdump_log(TDS_DBG_FUNC, "_bcp_free_storage(%p)\n", dbproc); assert(dbproc); if (dbproc->hostfileinfo) { TDS_ZERO_FREE(dbproc->hostfileinfo->hostfile); TDS_ZERO_FREE(dbproc->hostfileinfo->errorfile); _bcp_free_columns(dbproc); TDS_ZERO_FREE(dbproc->hostfileinfo); } tds_free_bcpinfo(dbproc->bcpinfo); dbproc->bcpinfo = NULL; } freetds-1.00.82/src/dblib/xact.c100644 025423 025423 00000004503 12717145107 0012003/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-1999 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #include #include #include #include #if defined(DBLIB_UNIMPLEMENTED) void build_xact_string(char *xact_name, char *service_name, DBINT commid, char *result) { tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED build_xact_string()\n"); } RETCODE remove_xact(DBPROCESS * connect, DBINT commid, int n) { tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED remove_xact()\n"); return SUCCEED; } RETCODE abort_xact(DBPROCESS * connect, DBINT commid) { tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED abort_xact()\n"); return SUCCEED; } void close_commit(DBPROCESS * connect) { tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED close_commit()\n"); } RETCODE commit_xact(DBPROCESS * connect, DBINT commid) { tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED commit_xact()\n"); return SUCCEED; } DBPROCESS * open_commit(LOGINREC * login, char *servername) { tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED open_commit()\n"); return NULL; } RETCODE scan_xact(DBPROCESS * connect, DBINT commid) { tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED scan_xact()\n"); return SUCCEED; } DBINT start_xact(DBPROCESS * connect, char *application_name, char *xact_name, int site_count) { tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED start_xact()\n"); return 0; } DBINT stat_xact(DBPROCESS * connect, DBINT commid) { tdsdump_log(TDS_DBG_FUNC, "UNIMPLEMENTED stat_xact()\n"); return 0; } #endif freetds-1.00.82/src/dblib/dbpivot.c100644 025423 025423 00000070003 12717145107 0012511/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2011 James K. Lowden * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #if HAVE_ERRNO_H # include #endif /* HAVE_ERRNO_H */ #include #include #include #include #include #include #include #include #include #define TDS_FIND(k,b,c) tds_find(k, b, sizeof(b)/sizeof(b[0]), sizeof(b[0]), c) typedef bool (*compare_func)(const void *, const void *); static void * tds_find(const void *key, const void *base, size_t nelem, size_t width, compare_func compar) { size_t i; for (i=0; i < nelem; i++) { char *p = (char*)base + width * i; if (true == compar(key, p)) { return p; } } return NULL; } struct col_t { size_t len; TDS_SERVER_TYPE type; int null_indicator; char *s; union { DBTINYINT ti; DBSMALLINT si; DBINT i; DBREAL r; DBFLT8 f; } data; }; static TDS_SERVER_TYPE infer_col_type(int sybtype); static struct col_t * col_init(struct col_t *pcol, int sybtype, int collen) { assert(pcol); pcol->type = infer_col_type(sybtype); if (pcol->type == TDS_INVALID_TYPE) return NULL; pcol->len = collen; switch(sybtype) { case 0: pcol->len = 0; return NULL; case SYBDATETIME: case SYBDATETIME4: case SYBDATETIMN: collen = 30; case SYBCHAR: case SYBVARCHAR: case SYBTEXT: case SYBNTEXT: pcol->len = collen; if ((pcol->s = tds_new(char, 1+collen)) == NULL) { return NULL; } break; } return pcol; } static void col_free(struct col_t *p) { free(p->s); memset(p, 0, sizeof(*p)); } static bool col_equal(const struct col_t *pc1, const struct col_t *pc2) { assert( pc1 && pc2 ); assert( pc1->type == pc2->type ); switch(pc1->type) { case SYBCHAR: case SYBVARCHAR: if( pc1->len != pc2->len) return false; return strncmp(pc1->s, pc2->s, pc1->len) == 0? true : false; case SYBINT1: return pc1->data.ti == pc2->data.ti? true : false; case SYBINT2: return pc1->data.si == pc2->data.si? true : false; case SYBINT4: return pc1->data.i == pc2->data.i? true : false; case SYBFLT8: return pc1->data.f == pc2->data.f? true : false; case SYBREAL: return pc1->data.r == pc2->data.r? true : false; case SYBINTN: case SYBDATETIME: case SYBBIT: case SYBTEXT: case SYBNTEXT: case SYBIMAGE: case SYBMONEY4: case SYBMONEY: case SYBDATETIME4: case SYBBINARY: case SYBVOID: case SYBVARBINARY: case SYBBITN: case SYBNUMERIC: case SYBDECIMAL: case SYBFLTN: case SYBMONEYN: case SYBDATETIMN: assert( false && pc1->type ); break; } return false; } static void * col_buffer(struct col_t *pcol) { switch(pcol->type) { case SYBCHAR: case SYBVARCHAR: return pcol->s; case SYBINT1: return &pcol->data.ti; case SYBINT2: return &pcol->data.si; case SYBINT4: return &pcol->data.i; case SYBFLT8: return &pcol->data.f; case SYBREAL: return &pcol->data.r; case SYBINTN: case SYBDATETIME: case SYBBIT: case SYBTEXT: case SYBNTEXT: case SYBIMAGE: case SYBMONEY4: case SYBMONEY: case SYBDATETIME4: case SYBBINARY: case SYBVOID: case SYBVARBINARY: case SYBBITN: case SYBNUMERIC: case SYBDECIMAL: case SYBFLTN: case SYBMONEYN: case SYBDATETIMN: assert( false && pcol->type ); break; } return NULL; } #if 0 static int col_print(FILE* out, const struct col_t *pcol) { char *fmt; switch(pcol->type) { case SYBCHAR: case SYBVARCHAR: return (int) fwrite(pcol->s, pcol->len, 1, out); case SYBINT1: return fprintf(out, "%d", (int)pcol->ti); case SYBINT2: return fprintf(out, "%d", (int)pcol->si); case SYBINT4: return fprintf(out, "%d", (int)pcol->i); case SYBFLT8: return fprintf(out, "%f", pcol->f); case SYBREAL: return fprintf(out, "%f", (double)pcol->r); case SYBINTN: case SYBDATETIME: case SYBBIT: case SYBTEXT: case SYBNTEXT: case SYBIMAGE: case SYBMONEY4: case SYBMONEY: case SYBDATETIME4: case SYBBINARY: case SYBVOID: case SYBVARBINARY: case SYBBITN: case SYBNUMERIC: case SYBDECIMAL: case SYBFLTN: case SYBMONEYN: case SYBDATETIMN: assert( false && pcol->type ); break; } return false; } #endif static struct col_t * col_cpy(struct col_t *pdest, const struct col_t *psrc) { assert( pdest && psrc ); assert( psrc->len > 0 || psrc->null_indicator == -1); memcpy(pdest, psrc, sizeof(*pdest)); if (psrc->s) { assert(psrc->len >= 0); if ((pdest->s = tds_new(char, psrc->len)) == NULL) return NULL; memcpy(pdest->s, psrc->s, psrc->len); } assert( pdest->len > 0 || pdest->null_indicator == -1); return pdest; } static bool col_null( const struct col_t *pcol ) { assert(pcol); return pcol->null_indicator == -1? true : false; } static char * string_value(const struct col_t *pcol) { char *output = NULL; int len = -1; switch(pcol->type) { case SYBCHAR: case SYBVARCHAR: if ((output = tds_new0(char, 1 + pcol->len)) == NULL) return NULL; strncpy(output, pcol->s, pcol->len); return output; break; case SYBINT1: len = asprintf(&output, "%d", (int)pcol->data.ti); break; case SYBINT2: len = asprintf(&output, "%d", (int)pcol->data.si); break; case SYBINT4: len = asprintf(&output, "%d", (int)pcol->data.i); break; case SYBFLT8: len = asprintf(&output, "%f", pcol->data.f); break; case SYBREAL: len = asprintf(&output, "%f", (double)pcol->data.r); break; default: case SYBINTN: case SYBDATETIME: case SYBBIT: case SYBTEXT: case SYBNTEXT: case SYBIMAGE: case SYBMONEY4: case SYBMONEY: case SYBDATETIME4: case SYBBINARY: case SYBVOID: case SYBVARBINARY: case SYBBITN: case SYBNUMERIC: case SYBDECIMAL: case SYBFLTN: case SYBMONEYN: case SYBDATETIMN: assert( false && pcol->type ); return NULL; break; } return len >= 0? output : NULL; } static char * join(int argc, char *argv[], const char sep[]) { size_t len = 0; char **p, *output; for (p=argv; p < argv + argc; p++) { len += strlen(*p); } len += 1 + argc * strlen(sep); /* allows one too many */ output = tds_new0(char, len); for (p=argv; p < argv + argc; p++) { if (p != argv) strcat(output, sep); strcat(output, *p); } return output; } static TDS_SERVER_TYPE infer_col_type(int sybtype) { switch(sybtype) { case SYBCHAR: case SYBVARCHAR: case SYBTEXT: case SYBNTEXT: return SYBCHAR; case SYBDATETIME: case SYBDATETIME4: case SYBDATETIMN: return SYBCHAR; case SYBINT1: case SYBBIT: case SYBBITN: return SYBINT1; case SYBINT2: return SYBINT2; case SYBINT4: case SYBINTN: return SYBINT4; case SYBFLT8: case SYBMONEY4: case SYBMONEY: case SYBFLTN: case SYBMONEYN: case SYBNUMERIC: case SYBDECIMAL: return SYBFLT8; case SYBREAL: return SYBREAL; case SYBIMAGE: case SYBBINARY: case SYBVOID: case SYBVARBINARY: assert( false && sybtype ); break; } return TDS_INVALID_TYPE; } static int bind_type(int sybtype) { switch(sybtype) { case SYBCHAR: case SYBVARCHAR: case SYBTEXT: case SYBNTEXT: case SYBDATETIME: case SYBDATETIME4: case SYBDATETIMN: return NTBSTRINGBIND; case SYBINT1: case SYBBIT: case SYBBITN: return TINYBIND; case SYBINT2: return SMALLBIND; case SYBINT4: case SYBINTN: return INTBIND; case SYBFLT8: case SYBMONEY4: case SYBMONEY: case SYBFLTN: case SYBMONEYN: case SYBNUMERIC: case SYBDECIMAL: return FLT8BIND; case SYBREAL: return REALBIND; case SYBIMAGE: case SYBBINARY: case SYBVOID: case SYBVARBINARY: assert( false && sybtype ); break; } return 0; } typedef struct KEY_T { int nkeys; struct col_t *keys; } KEY_T; static bool key_equal(const KEY_T *a, const KEY_T *b) { int i; assert(a && b); assert(a->keys && b->keys); assert(a->nkeys == b->nkeys); for (i=0; i < a->nkeys; i++) { if (! col_equal(a->keys+i, b->keys+i)) return false; } return true; } static void key_free(KEY_T *p) { col_free(p->keys); free(p->keys); memset(p, 0, sizeof(*p)); } static KEY_T * key_cpy(KEY_T *pdest, const KEY_T *psrc) { int i; assert( pdest && psrc ); if ((pdest->keys = tds_new0(struct col_t, psrc->nkeys)) == NULL) return NULL; pdest->nkeys = psrc->nkeys; for( i=0; i < psrc->nkeys; i++) { if (NULL == col_cpy(pdest->keys+i, psrc->keys+i)) return NULL; } return pdest; } static char * make_col_name(const KEY_T *k) { const struct col_t *pc; char **names, **s, *output; assert(k); assert(k->nkeys); assert(k->keys); s = names = tds_new0(char *, k->nkeys); for(pc=k->keys; pc < k->keys + k->nkeys; pc++) { *s++ = strdup(string_value(pc)); } output = join(k->nkeys, names, "/"); for(s=names; s < names + k->nkeys; s++) { free(*s); } free(names); return output; } typedef struct agg_t { KEY_T row_key, col_key; struct col_t value; } AGG_T; #if 0 static bool agg_key_equal(const void *a, const void *b) { int i; const AGG_T *p1 = a, *p2 = b; assert(p1 && p2); assert(p1->row_key.keys && p2->row_key.keys); assert(p1->row_key.nkeys == p2->row_key.nkeys); for( i=0; i < p1->row_key.nkeys; i++ ) { if (! col_equal(p1->row_key.keys+i, p2->row_key.keys+i)) return false; } return true; } #endif static bool agg_next(const AGG_T *p1, const AGG_T *p2) { int i; assert(p1 && p2); if (p1->row_key.keys == NULL || p2->row_key.keys == NULL) return false; assert(p1->row_key.keys && p2->row_key.keys); assert(p1->row_key.nkeys == p2->row_key.nkeys); assert(p1->col_key.keys && p2->col_key.keys); assert(p1->col_key.nkeys == p2->col_key.nkeys); for( i=0; i < p1->row_key.nkeys; i++ ) { assert(p1->row_key.keys[i].type); assert(p2->row_key.keys[i].type); if (p1->row_key.keys[i].type != p2->row_key.keys[i].type) return false; } for( i=0; i < p1->row_key.nkeys; i++ ) { if (! col_equal(p1->row_key.keys+i, p2->row_key.keys+i)) return false; } for( i=0; i < p1->col_key.nkeys; i++ ) { if (p1->col_key.keys[i].type != p2->col_key.keys[i].type) return false; } for( i=0; i < p1->col_key.nkeys; i++ ) { if (! col_equal(p1->col_key.keys+i, p2->col_key.keys+i)) return false; } return true; } static void agg_free(AGG_T *p) { key_free(&p->row_key); key_free(&p->col_key); col_free(&p->value); } static bool agg_equal(const AGG_T *p1, const AGG_T *p2) { int i; assert(p1 && p2); assert(p1->row_key.keys && p1->col_key.keys); assert(p2->row_key.keys && p2->col_key.keys); assert(p1->row_key.nkeys == p2->row_key.nkeys); assert(p1->col_key.nkeys == p2->col_key.nkeys); /* todo: use key_equal */ for( i=0; i < p1->row_key.nkeys; i++ ) { if (! col_equal(p1->row_key.keys+i, p2->row_key.keys+i)) return false; } for( i=0; i < p1->col_key.nkeys; i++ ) { if (! col_equal(p1->col_key.keys+i, p2->col_key.keys+i)) return false; } return true; } #undef TEST_MALLOC #define TEST_MALLOC(dest,type) \ {if (!(dest = (type*)calloc(1, sizeof(type)))) goto Cleanup;} #undef TEST_CALLOC #define TEST_CALLOC(dest,type,n) \ {if (!(dest = (type*)calloc((n), sizeof(type)))) goto Cleanup;} #define tds_alloc_column() ((TDSCOLUMN*) calloc(1, sizeof(TDSCOLUMN))) static TDSRESULTINFO * alloc_results(size_t num_cols) { TDSRESULTINFO *res_info; TDSCOLUMN **ppcol; TEST_MALLOC(res_info, TDSRESULTINFO); res_info->ref_count = 1; TEST_CALLOC(res_info->columns, TDSCOLUMN *, num_cols); for (ppcol = res_info->columns; ppcol < res_info->columns + num_cols; ppcol++) if ((*ppcol = tds_alloc_column()) == NULL) goto Cleanup; res_info->num_cols = num_cols; res_info->row_size = 0; return res_info; Cleanup: tds_free_results(res_info); return NULL; } static TDSRET set_result_column(TDSSOCKET * tds, TDSCOLUMN * curcol, const char name[], const struct col_t *pvalue) { assert(curcol && pvalue); assert(name); curcol->column_usertype = pvalue->type; curcol->column_nullable = true; curcol->column_writeable = false; curcol->column_identity = false; tds_set_column_type(tds->conn, curcol, pvalue->type); /* sets "cardinal" type */ curcol->column_timestamp = (curcol->column_type == SYBBINARY && curcol->column_usertype == TDS_UT_TIMESTAMP); #if 0 curcol->funcs->get_info(tds, curcol); #endif curcol->on_server.column_size = curcol->column_size; if (!tds_dstr_copy(&curcol->column_name, name)) return TDS_FAIL; tdsdump_log(TDS_DBG_INFO1, "tds7_get_data_info: \n" "\tcolname = %s\n" "\ttype = %d (%s)\n" "\tserver's type = %d (%s)\n" "\tcolumn_varint_size = %d\n" "\tcolumn_size = %d (%d on server)\n", tds_dstr_cstr(&curcol->column_name), curcol->column_type, tds_prtype(curcol->column_type), curcol->on_server.column_type, tds_prtype(curcol->on_server.column_type), curcol->column_varint_size, curcol->column_size, curcol->on_server.column_size); return TDS_SUCCESS; } struct metadata_t { KEY_T *pacross; char *name; struct col_t col; }; static bool reinit_results(TDSSOCKET * tds, size_t num_cols, const struct metadata_t meta[]) { TDSRESULTINFO *info; int i; assert(tds); assert(num_cols); assert(meta); tds_free_all_results(tds); tds->rows_affected = TDS_NO_COUNT; if ((info = alloc_results(num_cols)) == NULL) return false; tds_set_current_results(tds, info); if (tds->cur_cursor) { tds_free_results(tds->cur_cursor->res_info); tds->cur_cursor->res_info = info; tdsdump_log(TDS_DBG_INFO1, "set current_results to cursor->res_info\n"); } else { tds->res_info = info; tdsdump_log(TDS_DBG_INFO1, "set current_results (%u column%s) to tds->res_info\n", (unsigned) num_cols, (num_cols==1? "":"s")); } tdsdump_log(TDS_DBG_INFO1, "setting up %u columns\n", (unsigned) num_cols); for (i = 0; i < num_cols; i++) { set_result_column(tds, info->columns[i], meta[i].name, &meta[i].col); info->columns[i]->bcp_terminator = (char*) meta[i].pacross; /* overload available pointer */ } if (num_cols > 0) { static const char dashes[31] = "------------------------------"; tdsdump_log(TDS_DBG_INFO1, " %-20s %-15s %-15s %-7s\n", "name", "size/wsize", "type/wtype", "utype"); tdsdump_log(TDS_DBG_INFO1, " %-20s %15s %15s %7s\n", dashes+10, dashes+30-15, dashes+30-15, dashes+30-7); } for (i = 0; i < num_cols; i++) { TDSCOLUMN *curcol = info->columns[i]; tdsdump_log(TDS_DBG_INFO1, " %-20s %7d/%-7d %7d/%-7d %7d\n", tds_dstr_cstr(&curcol->column_name), curcol->column_size, curcol->on_server.column_size, curcol->column_type, curcol->on_server.column_type, curcol->column_usertype); } #if 1 /* all done now allocate a row for tds_process_row to use */ if (TDS_FAILED(tds_alloc_row(info))) return false; #endif return true; } typedef struct pivot_t { DBPROCESS *dbproc; STATUS status; DB_RESULT_STATE dbresults_state; AGG_T *output; KEY_T *across; size_t nout, nacross; } PIVOT_T; static bool pivot_key_equal(const PIVOT_T *a, const PIVOT_T *b) { assert(a && b); return a->dbproc == b->dbproc? true : false; } static PIVOT_T *pivots = NULL; static size_t npivots = 0; PIVOT_T * dbrows_pivoted(DBPROCESS *dbproc) { PIVOT_T P; assert(dbproc); P.dbproc = dbproc; return (PIVOT_T *) tds_find(&P, pivots, npivots, sizeof(*pivots), (compare_func) pivot_key_equal); } STATUS dbnextrow_pivoted(DBPROCESS *dbproc, PIVOT_T *pp) { int i; AGG_T candidate, *pout; assert(pp); assert(dbproc && dbproc->tds_socket); assert(dbproc->tds_socket->res_info); assert(dbproc->tds_socket->res_info->columns || 0 == dbproc->tds_socket->res_info->num_cols); for (pout = pp->output; pout < pp->output + pp->nout; pout++) { if (pout->row_key.keys != NULL) break; } if (pout == pp->output + pp->nout) { dbproc->dbresults_state = _DB_RES_NEXT_RESULT; return NO_MORE_ROWS; } memset(&candidate, 0, sizeof(candidate)); key_cpy(&candidate.row_key, &pout->row_key); /* "buffer_transfer_bound_data" */ for (i = 0; i < dbproc->tds_socket->res_info->num_cols; i++) { struct col_t *pval = NULL; TDSCOLUMN *pcol = dbproc->tds_socket->res_info->columns[i]; assert(pcol); if (pcol->column_nullbind) { if (pcol->column_cur_size < 0) { *(DBINT *)(pcol->column_nullbind) = -1; } else { *(DBINT *)(pcol->column_nullbind) = 0; } } if (!pcol->column_varaddr) { fprintf(stderr, "no pcol->column_varaddr in col %d\n", i); continue; } /* find column in output */ if (pcol->bcp_terminator == NULL) { /* not a cross-tab column */ pval = &candidate.row_key.keys[i]; } else { AGG_T *pcan; key_cpy(&candidate.col_key, (KEY_T *) pcol->bcp_terminator); if ((pcan = tds_find(&candidate, pout, pp->output + pp->nout - pout, sizeof(*pp->output), (compare_func) agg_next)) != NULL) { /* flag this output as used */ pout->row_key.keys = NULL; pval = &pcan->value; } } if (!pval || col_null(pval)) { /* nothing in output for this x,y location */ dbgetnull(dbproc, pcol->column_bindtype, pcol->column_bindlen, (BYTE *) pcol->column_varaddr); continue; } assert(pval); #if 0 printf("\ncopying col %d, type %d/%d, len %d to %p ", i, pval->type, pcol->column_type, pval->len, pcol->column_varaddr); switch (pval->type) { case 48: printf("value %d", (int)pval->ti); break; case 56: printf("value %d", (int)pval->si); break; } printf("\n"); #endif pcol->column_size = pval->len; pcol->column_data = col_buffer(pval); copy_data_to_host_var( dbproc, pval->type, col_buffer(pval), pval->len, (BYTE *) pcol->column_varaddr, pcol->column_bindlen, pcol->column_bindtype, (DBINT*) pcol->column_nullbind ); } return REG_ROW; } /** * Pivot the rows, creating a new resultset * * Call dbpivot() immediately after dbresults(). It calls dbnextrow() as long as * it returns REG_ROW, transforming the results into a cross-tab report. * dbpivot() modifies the metadata such that DB-Library can be used tranparently: * retrieve the rows as usual with dbnumcols(), dbnextrow(), etc. * * @dbproc, our old friend * @nkeys the number of left-edge columns to group by * @keys an array of left-edge columns to group by * @ncols the number of top-edge columns to group by * @cols an array of top-edge columns to group by * @func the aggregation function to use * @val the number of the column to which @func is applied * * @returns the return code from the final call to dbnextrow(). * Success is normally indicated by NO_MORE_ROWS. */ RETCODE dbpivot(DBPROCESS *dbproc, int nkeys, int *keys, int ncols, int *cols, DBPIVOT_FUNC func, int val) { enum { logalot = 1 }; PIVOT_T P, *pp; AGG_T input, *pout = NULL; struct metadata_t *metadata, *pmeta; size_t i, nmeta = 0; tdsdump_log(TDS_DBG_FUNC, "dbpivot(%p, %d,%p, %d,%p, %p, %d)\n", dbproc, nkeys, keys, ncols, cols, func, val); if (logalot) { char buffer[1024] = {'\0'}, *s = buffer; const static char *const names[2] = { "\tkeys (down)", "\n\tcols (across)" }; int *p = keys, *pend = p + nkeys; for (i=0; i < 2; i++) { const char *sep = ""; s += sprintf(s, "%s: ", names[i]); for ( ; p < pend; p++) { s += sprintf(s, "%s%d", sep, *p); sep = ", "; } p = cols; pend = p + ncols; assert(s < buffer + sizeof(buffer)); } tdsdump_log(TDS_DBG_FUNC, "%s\n", buffer); } memset(&input, 0, sizeof(input)); P.dbproc = dbproc; if ((pp = tds_find(&P, pivots, npivots, sizeof(*pivots), (compare_func) pivot_key_equal)) == NULL ) { pp = TDS_RESIZE(pivots, 1 + npivots); if (!pp) return FAIL; pp += npivots++; } else { agg_free(pp->output); key_free(pp->across); } memset(pp, 0, sizeof(*pp)); if ((input.row_key.keys = tds_new0(struct col_t, nkeys)) == NULL) return FAIL; input.row_key.nkeys = nkeys; for (i=0; i < nkeys; i++) { int type = dbcoltype(dbproc, keys[i]); int len = dbcollen(dbproc, keys[i]); assert(type && len); if (!col_init(input.row_key.keys+i, type, len)) return FAIL; if (FAIL == dbbind(dbproc, keys[i], bind_type(type), input.row_key.keys[i].len, col_buffer(input.row_key.keys+i))) return FAIL; if (FAIL == dbnullbind(dbproc, keys[i], &input.row_key.keys[i].null_indicator)) return FAIL; } if ((input.col_key.keys = tds_new0(struct col_t, ncols)) == NULL) return FAIL; input.col_key.nkeys = ncols; for (i=0; i < ncols; i++) { int type = dbcoltype(dbproc, cols[i]); int len = dbcollen(dbproc, cols[i]); assert(type && len); if (!col_init(input.col_key.keys+i, type, len)) return FAIL; if (FAIL == dbbind(dbproc, cols[i], bind_type(type), input.col_key.keys[i].len, col_buffer(input.col_key.keys+i))) return FAIL; if (FAIL == dbnullbind(dbproc, cols[i], &input.col_key.keys[i].null_indicator)) return FAIL; } /* value */ { int type = dbcoltype(dbproc, val); int len = dbcollen(dbproc, val); assert(type && len); if (!col_init(&input.value, type, len)) return FAIL; if (FAIL == dbbind(dbproc, val, bind_type(type), input.value.len, col_buffer(&input.value))) return FAIL; if (FAIL == dbnullbind(dbproc, val, &input.value.null_indicator)) return FAIL; } while ((pp->status = dbnextrow(dbproc)) == REG_ROW) { /* add to unique list of crosstab columns */ if (tds_find(&input.col_key, pp->across, pp->nacross, sizeof(*pp->across), (compare_func) key_equal) == NULL) { if (!TDS_RESIZE(pp->across, 1 + pp->nacross)) return FAIL; key_cpy(pp->across + pp->nacross, &input.col_key); } assert(pp->across); if ((pout = tds_find(&input, pp->output, pp->nout, sizeof(*pp->output), (compare_func) agg_equal)) == NULL ) { if (!TDS_RESIZE(pp->output, 1 + pp->nout)) return FAIL; pout = pp->output + pp->nout++; if ((pout->row_key.keys = tds_new0(struct col_t, input.row_key.nkeys)) == NULL) return FAIL; key_cpy(&pout->row_key, &input.row_key); if ((pout->col_key.keys = tds_new0(struct col_t, input.col_key.nkeys)) == NULL) return FAIL; key_cpy(&pout->col_key, &input.col_key); if (!col_init(&pout->value, input.value.type, input.value.len)) return FAIL; } func(&pout->value, &input.value); } /* Mark this proc as pivoted, so that dbnextrow() sees it when the application calls it */ pp->dbproc = dbproc; pp->dbresults_state = dbproc->dbresults_state; dbproc->dbresults_state = pp->output < pout? _DB_RES_RESULTSET_ROWS : _DB_RES_RESULTSET_EMPTY; /* * Initialize new metadata */ nmeta = input.row_key.nkeys + pp->nacross; metadata = tds_new0(struct metadata_t, nmeta); assert(pp->across || pp->nacross == 0); /* key columns are passed through as-is, verbatim */ for (i=0; i < input.row_key.nkeys; i++) { assert(i < nkeys); metadata[i].name = strdup(dbcolname(dbproc, keys[i])); metadata[i].pacross = NULL; col_cpy(&metadata[i].col, input.row_key.keys+i); } /* pivoted columms are found in the "across" data */ for (i=0, pmeta = metadata + input.row_key.nkeys; i < pp->nacross; i++) { struct col_t col; if (!col_init(&col, SYBFLT8, sizeof(double))) return FAIL; assert(pmeta + i < metadata + nmeta); pmeta[i].name = make_col_name(pp->across+i); assert(pp->across); pmeta[i].pacross = pp->across + i; col_cpy(&pmeta[i].col, pp->nout? &pp->output[0].value : &col); } if (!reinit_results(dbproc->tds_socket, nmeta, metadata)) { return FAIL; } return SUCCEED; #if 0 for (pp->pout=pp->output; pp->pout < pp->output + pp->nout; pp->pout++) { char name[256] = {0}; assert(pp->pout->col_key.keys[0].len < sizeof(name)); memset(name, '\0', sizeof(name)); memcpy(name, pp->pout->col_key.keys[0].s, pp->pout->col_key.keys[0].len), printf("%5d %-30s %5d\n", pp->pout->row_key.keys[0].i, name, pp->pout->value.i ); } exit(1); #endif } /* * Aggregation functions */ void dbpivot_count (struct col_t *tgt, const struct col_t *src) { assert( tgt && src); assert (src->type); tgt->type = SYBINT4; if (! col_null(src)) tgt->data.i++; } void dbpivot_sum (struct col_t *tgt, const struct col_t *src) { assert( tgt && src); assert (src->type); tgt->type = src->type; if (col_null(src)) return; switch (src->type) { case SYBINT1: tgt->data.ti += src->data.ti; break; case SYBINT2: tgt->data.si += src->data.si; break; case SYBINT4: tgt->data.i += src->data.i; break; case SYBFLT8: tgt->data.f += src->data.f; break; case SYBREAL: tgt->data.r += src->data.r; break; case SYBCHAR: case SYBVARCHAR: case SYBINTN: case SYBDATETIME: case SYBBIT: case SYBTEXT: case SYBNTEXT: case SYBIMAGE: case SYBMONEY4: case SYBMONEY: case SYBDATETIME4: case SYBBINARY: case SYBVOID: case SYBVARBINARY: case SYBBITN: case SYBNUMERIC: case SYBDECIMAL: case SYBFLTN: case SYBMONEYN: case SYBDATETIMN: default: tdsdump_log(TDS_DBG_INFO1, "dbpivot_sum(): invalid operand %d\n", src->type); tgt->type = SYBINT4; tgt->data.i = 0; break; } } void dbpivot_min (struct col_t *tgt, const struct col_t *src) { assert( tgt && src); assert (src->type); tgt->type = src->type; if (col_null(src)) return; switch (src->type) { case SYBINT1: tgt->data.ti = tgt->data.ti < src->data.ti? tgt->data.ti : src->data.ti; break; case SYBINT2: tgt->data.si = tgt->data.si < src->data.si? tgt->data.si : src->data.si; break; case SYBINT4: tgt->data.i = tgt->data.i < src->data.i? tgt->data.i : src->data.i; break; case SYBFLT8: tgt->data.f = tgt->data.f < src->data.f? tgt->data.f : src->data.f; break; case SYBREAL: tgt->data.r = tgt->data.r < src->data.r? tgt->data.r : src->data.r; break; case SYBCHAR: case SYBVARCHAR: case SYBINTN: case SYBDATETIME: case SYBBIT: case SYBTEXT: case SYBNTEXT: case SYBIMAGE: case SYBMONEY4: case SYBMONEY: case SYBDATETIME4: case SYBBINARY: case SYBVOID: case SYBVARBINARY: case SYBBITN: case SYBNUMERIC: case SYBDECIMAL: case SYBFLTN: case SYBMONEYN: case SYBDATETIMN: default: tdsdump_log(TDS_DBG_INFO1, "dbpivot_sum(): invalid operand %d\n", src->type); tgt->type = SYBINT4; tgt->data.i = 0; break; } } void dbpivot_max (struct col_t *tgt, const struct col_t *src) { assert( tgt && src); assert (src->type); tgt->type = src->type; if (col_null(src)) return; switch (src->type) { case SYBINT1: tgt->data.ti = tgt->data.ti > src->data.ti? tgt->data.ti : src->data.ti; break; case SYBINT2: tgt->data.si = tgt->data.si > src->data.si? tgt->data.si : src->data.si; break; case SYBINT4: tgt->data.i = tgt->data.i > src->data.i? tgt->data.i : src->data.i; break; case SYBFLT8: tgt->data.f = tgt->data.f > src->data.f? tgt->data.f : src->data.f; break; case SYBREAL: tgt->data.r = tgt->data.r > src->data.r? tgt->data.r : src->data.r; break; case SYBCHAR: case SYBVARCHAR: case SYBINTN: case SYBDATETIME: case SYBBIT: case SYBTEXT: case SYBNTEXT: case SYBIMAGE: case SYBMONEY4: case SYBMONEY: case SYBDATETIME4: case SYBBINARY: case SYBVOID: case SYBVARBINARY: case SYBBITN: case SYBNUMERIC: case SYBDECIMAL: case SYBFLTN: case SYBMONEYN: case SYBDATETIMN: default: tdsdump_log(TDS_DBG_INFO1, "dbpivot_sum(): invalid operand %d\n", src->type); tgt->type = SYBINT4; tgt->data.i = 0; break; } } static const struct name_t { char name[14]; DBPIVOT_FUNC func; } names[] = { { "count", dbpivot_count } , { "sum", dbpivot_sum } , { "min", dbpivot_min } , { "max", dbpivot_max } }; static bool name_equal( const struct name_t *n1, const struct name_t *n2 ) { assert(n1 && n2); return strcmp(n1->name, n2->name) == 0; } DBPIVOT_FUNC dbpivot_lookup_name( const char name[] ) { struct name_t *n = TDS_FIND(name, names, (compare_func) name_equal); return n ? n->func : NULL; } freetds-1.00.82/src/dblib/dbopen.c100644 025423 025423 00000002365 12717145107 0012317/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-1999 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #include #ifdef dbopen #undef dbopen #endif /** * Normally not used. * The function is linked in only if the --enable-sybase-compat configure option is used. * Cf. sybdb.h dbopen() macros, and dbdatecrack(). */ DBPROCESS * dbopen(LOGINREC * login, const char *server) { return tdsdbopen(login, server, dblib_msdblib); } freetds-1.00.82/src/dblib/winmain.c100644 025423 025423 00000000041 12717145107 0012477#include "../../win32/initnet.c" freetds-1.00.82/src/dblib/buffering.h100644 025423 025423 00000031655 12717145107 0013030typedef struct dblib_buffer_row { /** pointer to result informations */ TDSRESULTINFO *resinfo; /** row data, NULL for resinfo->current_row */ unsigned char *row_data; /** row number */ DBINT row; /** save old sizes */ TDS_INT *sizes; } DBLIB_BUFFER_ROW; static void buffer_struct_print(const DBPROC_ROWBUF *buf); static RETCODE buffer_save_row(DBPROCESS *dbproc); static DBLIB_BUFFER_ROW* buffer_row_address(const DBPROC_ROWBUF * buf, int idx); #if ENABLE_EXTRA_CHECKS static void buffer_check(const DBPROC_ROWBUF *buf) { int i; /* no buffering */ if (buf->capacity == 0 || buf->capacity == 1) { assert(buf->head == 0); assert(buf->tail == 0 || buf->tail == 1); assert(buf->capacity == 1 || buf->rows == NULL); return; } assert(buf->capacity > 0); assert(buf->head >= 0); assert(buf->tail >= 0); assert(buf->head < buf->capacity); assert(buf->tail <= buf->capacity); /* check empty */ if (buf->tail == buf->capacity) { assert(buf->head == 0); for (i = 0; buf->rows && i < buf->capacity; ++i) { assert(buf->rows[i].resinfo == NULL); assert(buf->rows[i].row_data == NULL); assert(buf->rows[i].sizes == NULL); assert(buf->rows[i].row == 0); } return; } if (buf->rows == NULL) return; /* check filled part */ i = buf->tail; do { assert(i >= 0 && i < buf->capacity); assert(buf->rows[i].resinfo != NULL); assert(buf->rows[i].row > 0); assert(buf->rows[i].row <= buf->received); ++i; if (i == buf->capacity) i = 0; } while (i != buf->head); /* check empty part */ if (buf->head != buf->tail) { i = buf->head; do { assert(i >= 0 && i < buf->capacity); assert(buf->rows[i].resinfo == NULL); assert(buf->rows[i].row_data == NULL); assert(buf->rows[i].sizes == NULL); assert(buf->rows[i].row == 0); ++i; if (i == buf->capacity) i = 0; } while (i != buf->tail); } } #define BUFFER_CHECK(buf) buffer_check(buf) #else #define BUFFER_CHECK(buf) do {} while(0) #endif /** * A few words on the buffering design. * * DBPROC_ROWBUF::buf is a block of row buffers, * managed as a ring, indexed by head, tail, and current: * * head -- where new elements are inserted. * tail -- oldest element. * current -- active row (read by dbgetrow/dbnextrow) * * capacity is the number of rows that buf can hold. * * Each element in buf is preceded by its row_number: * the result_set row number, determined by counting the rows * as they're received from the server. Applications communicate * to db-lib in row numbers, not buffer indices. * * Semantics: * head == 0 && tail == capacity is the initial condition. * head == tail means the buffer is full, except when capacity is 1. * head < tail means the buffer has wrapped around. * * Whether or not buffering is active is governed by * dbproc->dbopts[DBBUFFER].optactive. */ /** * number of rows in the buffer */ static int buffer_count(const DBPROC_ROWBUF *buf) { BUFFER_CHECK(buf); return (buf->head > buf->tail) ? buf->head - buf->tail : /* |...TddddH....| */ buf->capacity - (buf->tail - buf->head); /* |ddddH....Tddd| */ } /** * Can the buffer be written to? */ static int buffer_is_full(const DBPROC_ROWBUF *buf) { BUFFER_CHECK(buf); return buf->capacity == buffer_count(buf) && buf->capacity > 1; } #ifndef NDEBUG static int buffer_index_valid(const DBPROC_ROWBUF *buf, int idx) { BUFFER_CHECK(buf); if (buf->tail <= buf->head) if (buf->head <= idx && idx <= buf->tail) return 1; if (0 <= idx && idx <= buf->head) return 1; if (buf->tail <= idx && idx < buf->capacity) return 1; #if 0 printf("buffer_index_valid: idx = %d\n", idx); buffer_struct_print(buf); #endif return 0; } #endif static void buffer_free_row(DBLIB_BUFFER_ROW *row) { if (row->sizes) TDS_ZERO_FREE(row->sizes); if (row->row_data) { tds_free_row(row->resinfo, row->row_data); row->row_data = NULL; } tds_free_results(row->resinfo); row->resinfo = NULL; row->row = 0; } /* * Buffer is freed at slightly odd points, whenever * capacity changes: * * 1. When setting capacity, to release prior buffer. * 2. By dbresults. When called the second time, it has to * release prior storage because the new resultset will have * a different width. * 3. By dbclose(), else open/close/open would leak. */ static void buffer_free(DBPROC_ROWBUF *buf) { BUFFER_CHECK(buf); if (buf->rows != NULL) { int i; for (i = 0; i < buf->capacity; ++i) buffer_free_row(&buf->rows[i]); TDS_ZERO_FREE(buf->rows); } BUFFER_CHECK(buf); } /* * When no rows are currently buffered (and the buffer is allocated) * set the indices to their initial positions. */ static void buffer_reset(DBPROC_ROWBUF *buf) { buf->head = 0; buf->current = buf->tail = buf->capacity; BUFFER_CHECK(buf); } static int buffer_idx_increment(const DBPROC_ROWBUF *buf, int idx) { if (++idx >= buf->capacity) { idx = 0; } return idx; } /** * Given an index, return the row storage, including * the DBINT row number prefix. */ static DBLIB_BUFFER_ROW* buffer_row_address(const DBPROC_ROWBUF * buf, int idx) { BUFFER_CHECK(buf); if (idx < 0 || idx >= buf->capacity) { printf("idx is %d:\n", idx); buffer_struct_print(buf); return NULL; } return &(buf->rows[idx]); } /** * Convert an index to a row number. */ static DBINT buffer_idx2row(const DBPROC_ROWBUF *buf, int idx) { BUFFER_CHECK(buf); return buffer_row_address(buf, idx)->row; } /** * Convert a row number to an index. */ static int buffer_row2idx(const DBPROC_ROWBUF *buf, int row_number) { int i = buf->tail; #ifndef NDEBUG int ii = 0; #endif BUFFER_CHECK(buf); if (i == buf->capacity) { assert (buf->head == 0); return -1; /* no rows buffered */ } /* * March through the buffers from tail to head, stop if we find our row. * A full queue is indicated by tail == head (which means we can't write). */ do { if (buffer_idx2row(buf, i) == row_number) return i; assert(ii++ < buf->capacity); /* prevent infinite loop */ i = buffer_idx_increment(buf, i); } while (i != buf->head); return -1; } /** * Deleting a row from the buffer doesn't affect memory allocation. * It just makes the space available for a different row. */ static void buffer_delete_rows(DBPROC_ROWBUF * buf, int count) { int i; BUFFER_CHECK(buf); if (count < 0 || count > buffer_count(buf)) { count = buffer_count(buf); } for (i=0; i < count; i++) { if (buf->tail < buf->capacity) buffer_free_row(&buf->rows[buf->tail]); buf->tail = buffer_idx_increment(buf, buf->tail); /* * If deleting rows from the buffer catches the tail to the head, * return to the initial position. Otherwise, it will look full. */ if (buf->tail == buf->head) { buffer_reset(buf); break; } } #if 0 buffer_struct_print(buf); #endif BUFFER_CHECK(buf); } static void buffer_transfer_bound_data(DBPROC_ROWBUF *buf, TDS_INT res_type, TDS_INT compute_id, DBPROCESS * dbproc, int idx) { int i; BYTE *src; const DBLIB_BUFFER_ROW *row; tdsdump_log(TDS_DBG_FUNC, "buffer_transfer_bound_data(%p %d %d %p %d)\n", buf, res_type, compute_id, dbproc, idx); BUFFER_CHECK(buf); assert(buffer_index_valid(buf, idx)); row = buffer_row_address(buf, idx); assert(row->resinfo); for (i = 0; i < row->resinfo->num_cols; i++) { TDS_SERVER_TYPE srctype; DBINT srclen; TDSCOLUMN *curcol = row->resinfo->columns[i]; if (row->sizes) curcol->column_cur_size = row->sizes[i]; srclen = curcol->column_cur_size; if (curcol->column_nullbind) { if (srclen < 0) { *(DBINT *)(curcol->column_nullbind) = -1; } else { *(DBINT *)(curcol->column_nullbind) = 0; } } if (!curcol->column_varaddr) continue; if (srclen <= 0) { if (srclen == 0 || !curcol->column_nullbind) dbgetnull(dbproc, curcol->column_bindtype, curcol->column_bindlen, (BYTE *) curcol->column_varaddr); continue; } srctype = tds_get_conversion_type(curcol->column_type, curcol->column_size); if (row->row_data) src = &row->row_data[curcol->column_data - row->resinfo->current_row]; else src = curcol->column_data; if (is_blob_col(curcol)) src = (BYTE *) ((TDSBLOB *) src)->textvalue; copy_data_to_host_var(dbproc, srctype, src, srclen, (BYTE *) curcol->column_varaddr, curcol->column_bindlen, curcol->column_bindtype, (DBINT*) curcol->column_nullbind); } /* * This function always bumps current. Usually, it's called * by dbnextrow(), so bumping current is a pretty obvious choice. * It can also be called by dbgetrow(), but that function also * causes the bump. If you call dbgetrow() for row N, a subsequent * call to dbnextrow() yields N+1. */ buf->current = buffer_idx_increment(buf, buf->current); } /* end buffer_transfer_bound_data() */ static void buffer_struct_print(const DBPROC_ROWBUF *buf) { assert(buf); printf("\t%d rows in buffer\n", buffer_count(buf)); printf("\thead = %d\t", buf->head); printf("\ttail = %d\t", buf->tail); printf("\tcurrent = %d\n", buf->current); printf("\tcapacity = %d\t", buf->capacity); printf("\thead row number = %d\n", buf->received); } /* * * Functions called only by public db-lib API take DBPROCESS* * */ /** * Return the current row buffer index. * We strive to validate it first. It must be: * between zero and capacity (obviously), and * between the head and the tail, logically. * * If the head has wrapped the tail, it shouldn't be in no man's land. * IOW, if capacity is 9, head is 3 and tail is 7, good rows are 7-8 and 0-2. * (Row 3 is about-to-be-inserted, and 4-6 are not in use.) Here's a diagram: * d d d ! ! ! ! d d * 0 1 2 3 4 5 6 7 8 * ^ ^ * Head Tail * * The special case is capacity == 1, meaning there's no buffering, and head == tail === 0. */ static int buffer_current_index(const DBPROCESS *dbproc) { const DBPROC_ROWBUF *buf = &dbproc->row_buf; #if 0 buffer_struct_print(buf); #endif if (buf->capacity <= 1) /* no buffering */ return -1; if (buf->current == buf->head || buf->current == buf->capacity) return -1; assert(buf->current >= 0); assert(buf->current < buf->capacity); if( buf->tail < buf->head) { assert(buf->tail < buf->current); assert(buf->current < buf->head); } else { if (buf->current > buf->head) assert(buf->current > buf->tail); } return buf->current; } /* * Normally called by dbsetopt() to prepare for buffering * Called with nrows == 0 by dbopen to safely set buf->rows to NULL. */ static void buffer_set_capacity(DBPROCESS *dbproc, int nrows) { DBPROC_ROWBUF *buf = &dbproc->row_buf; buffer_free(buf); memset(buf, 0, sizeof(DBPROC_ROWBUF)); if (0 == nrows) { buf->capacity = 1; BUFFER_CHECK(buf); return; } assert(0 < nrows); buf->capacity = nrows; BUFFER_CHECK(buf); } /* * Called only by dbresults(); capacity must be >= 1. * Sybase's documents say dbresults() cannot return FAIL if the prior calls worked, * which is a little strange, because (for FreeTDS, at least), dbresults * is when we learn about the result set's width. Without that information, we * can't allocate memory for the buffer. But if we *fail* to allocate memory, * we're not to communicate it back to the caller? */ static void buffer_alloc(DBPROCESS *dbproc) { DBPROC_ROWBUF *buf = &dbproc->row_buf; /* Call this function only after setting capacity. */ assert(buf); assert(buf->capacity > 0); assert(buf->rows == NULL); buf->rows = tds_new0(DBLIB_BUFFER_ROW, buf->capacity); assert(buf->rows); buffer_reset(buf); buf->received = 0; } /** * Called by dbnextrow * Returns a row buffer index, or -1 to indicate the buffer is full. */ static int buffer_add_row(DBPROCESS *dbproc, TDSRESULTINFO *resinfo) { DBPROC_ROWBUF *buf = &dbproc->row_buf; DBLIB_BUFFER_ROW *row; int i; assert(buf->capacity >= 0); if (buffer_is_full(buf)) return -1; row = buffer_row_address(buf, buf->head); /* bump the row number, write it, and move the data to head */ if (row->resinfo) { tds_free_row(row->resinfo, row->row_data); tds_free_results(row->resinfo); } row->row = ++buf->received; ++resinfo->ref_count; row->resinfo = resinfo; row->row_data = NULL; if (row->sizes) free(row->sizes); row->sizes = tds_new0(TDS_INT, resinfo->num_cols); for (i = 0; i < resinfo->num_cols; ++i) row->sizes[i] = resinfo->columns[i]->column_cur_size; /* initial condition is head == 0 and tail == capacity */ if (buf->tail == buf->capacity) { /* bumping this tail will set it to zero */ assert(buf->head == 0); buf->tail = 0; } /* update current, bump the head */ buf->current = buf->head; buf->head = buffer_idx_increment(buf, buf->head); return buf->current; } static RETCODE buffer_save_row(DBPROCESS *dbproc) { DBPROC_ROWBUF *buf = &dbproc->row_buf; DBLIB_BUFFER_ROW *row; int idx = buf->head - 1; if (buf->capacity <= 1) return SUCCEED; if (idx < 0) idx = buf->capacity - 1; if (idx >= 0 && idx < buf->capacity) { row = &buf->rows[idx]; if (row->resinfo && !row->row_data) { row->row_data = row->resinfo->current_row; tds_alloc_row(row->resinfo); } } return SUCCEED; } freetds-1.00.82/src/dblib/CMakeLists.txt100644 025423 025423 00000001247 13206501221 0013425add_subdirectory(unittests) if(WIN32) add_definitions(-DDLL_EXPORT) set(win_SRCS winmain.c dblib.def dbopen.c) endif() # TODO add dbopen.c if necessary add_library(sybdb SHARED dblib.c dbutil.c rpc.c bcp.c xact.c dbpivot.c buffering.h ${win_SRCS} ) target_link_libraries(sybdb tds replacements ${lib_NETWORK} ${lib_BASE}) add_library(db-lib STATIC dblib.c dbutil.c rpc.c bcp.c xact.c dbpivot.c buffering.h ) target_link_libraries(db-lib tds replacements ${lib_NETWORK} ${lib_BASE}) if(NOT WIN32) set_target_properties(sybdb PROPERTIES SOVERSION "5.1.0") endif() if(MINGW OR CYGWIN) set_target_properties(sybdb PROPERTIES LINK_FLAGS "--static") endif(MINGW OR CYGWIN) freetds-1.00.82/src/dblib/dblib.def100644 025423 025423 00000004017 12717145107 0012434EXPORTS bcp_batch bcp_bind bcp_colfmt bcp_colfmt_ps bcp_collen bcp_colptr bcp_columns bcp_control bcp_done bcp_exec bcp_getbatchsize bcp_getl bcp_init bcp_options bcp_readfmt bcp_sendrow dbadata dbadlen dbaltbind dbaltcolid dbaltlen dbaltop dbalttype dbaltutype dbanullbind dbbind dbbylist dbcancel dbcanquery dbchange dbclose dbclrbuf dbclropt dbcmd dbcmdrow dbcolinfo dbcollen dbcolname dbcolsource dbcoltype dbcoltypeinfo dbcolutype dbconvert dbconvert_ps dbcount dbcurcmd dbcurrow dbdata dbdatecmp dbdatecrack dbanydatecrack dbdatlen dbdead dberrhandle dbexit dbfcmd dbfirstrow dbfreebuf dbgetchar dbgetmaxprocs dbgetpacket dbgetrow dbgettime dbgetuserdata dbhasretstat dbinit dbiordesc dbiowdesc dbisavail dbiscount dbisopt dblastrow dblogin dbloginfree dbmny4add dbmny4cmp dbmny4copy dbmny4minus dbmny4sub dbmny4zero dbmnycmp dbmnycopy dbmnydec dbmnyinc dbmnymaxneg dbmnymaxpos dbmnyminus dbmnyzero dbmonthname dbmorecmds dbmoretext dbmsghandle dbname dbnextrow dbnextrow_pivoted dbnullbind dbnumalts dbnumcols dbnumcompute dbnumrets dbpivot_count dbpivot_max dbpivot_min dbpivot_sum dbprcollen dbprhead dbprrow dbopen dbpivot dbpivot_lookup_name dbprtype dbreadtext dbrecftos dbresults dbretdata dbretlen dbretname dbretstatus dbrettype dbrows dbrows_pivoted dbrowtype dbrpcinit dbrpcparam dbrpcsend dbsafestr dbservcharset dbsetavail dbsetifile dbsetinterrupt dbsetlbool dbsetllong dbsetlname dbsetlogintime dbsetlversion dbsetmaxprocs dbsetnull dbsetopt dbsetrow dbsettime dbsetuserdata dbsetversion dbspid dbspr1row dbspr1rowlen dbsprhead dbsprline dbsqlexec dbsqlok dbsqlsend dbstrbuild dbstrcpy dbstrlen dbtablecolinfo dbtds dbtxptr dbtxtimestamp dbuse dbvarylen dbversion dbwillconvert dbwritetext tdsdbopen tdsdump_open freetds-1.00.82/src/dblib/unittests/Makefile.am100644 025423 025423 00000006611 13111516422 0014767TESTS = t0001$(EXEEXT) t0002$(EXEEXT) t0003$(EXEEXT)\ t0004$(EXEEXT) t0005$(EXEEXT) t0006$(EXEEXT)\ t0007$(EXEEXT) t0008$(EXEEXT) t0009$(EXEEXT)\ t0011$(EXEEXT) t0012$(EXEEXT) t0013$(EXEEXT)\ t0014$(EXEEXT) t0015$(EXEEXT) t0016$(EXEEXT)\ t0017$(EXEEXT) t0018$(EXEEXT) t0019$(EXEEXT)\ t0020$(EXEEXT) t0021$(EXEEXT) t0022$(EXEEXT)\ t0023$(EXEEXT) rpc$(EXEEXT) dbmorecmds$(EXEEXT)\ bcp$(EXEEXT) thread$(EXEEXT) text_buffer$(EXEEXT)\ done_handling$(EXEEXT) timeout$(EXEEXT) \ hang$(EXEEXT) null$(EXEEXT) null2$(EXEEXT) \ setnull$(EXEEXT) numeric$(EXEEXT) pending$(EXEEXT) \ cancel$(EXEEXT) spid$(EXEEXT) bcp_getl$(EXEEXT) check_PROGRAMS = $(TESTS) SQL_DIST = bcp.sql dbmorecmds.sql done_handling.sql rpc.sql spid.sql \ t0001.sql t0002.sql t0003.sql t0004.sql t0005.sql t0006.sql t0007.sql t0009.sql \ t0011.sql t0012.sql t0013.sql t0014.sql t0015.sql t0016.sql t0017.sql t0018.sql \ t0020.sql t0022.sql t0023.sql text_buffer.sql timeout.sql numeric.sql numeric_2.sql \ pending.sql cancel.sql t0016_10.sql t0016_11.sql t0016_1.sql t0016_2.sql \ t0016_3.sql t0016_4.sql t0016_5.sql t0016_6.sql t0016_7.sql t0016_8.sql t0016_9.sql noinst_SCRIPTS = $(SQL_DIST) t0001_SOURCES = t0001.c common.c common.h t0001.sql t0002_SOURCES = t0002.c common.c common.h t0003_SOURCES = t0003.c common.c common.h t0004_SOURCES = t0004.c common.c common.h t0005_SOURCES = t0005.c common.c common.h t0006_SOURCES = t0006.c common.c common.h t0007_SOURCES = t0007.c common.c common.h t0008_SOURCES = t0008.c common.c common.h t0009_SOURCES = t0009.c common.c common.h t0011_SOURCES = t0011.c common.c common.h t0012_SOURCES = t0012.c common.c common.h t0013_SOURCES = t0013.c common.c common.h t0014_SOURCES = t0014.c common.c common.h t0015_SOURCES = t0015.c common.c common.h t0016_SOURCES = t0016.c common.c common.h t0017_SOURCES = t0017.c common.c common.h t0018_SOURCES = t0018.c common.c common.h t0019_SOURCES = t0019.c common.c common.h t0020_SOURCES = t0020.c common.c common.h t0021_SOURCES = t0021.c common.c common.h t0022_SOURCES = t0022.c common.c common.h t0023_SOURCES = t0023.c common.c common.h rpc_SOURCES = rpc.c common.c common.h dbmorecmds_SOURCES = dbmorecmds.c common.c common.h bcp_SOURCES = bcp.c bcp.h common.c common.h thread_SOURCES = thread.c bcp.h common.c common.h text_buffer_SOURCES = text_buffer.c common.c common.h done_handling_SOURCES = done_handling.c common.c common.h timeout_SOURCES = timeout.c common.c common.h hang_SOURCES = hang.c common.c common.h null_SOURCES = null.c common.c common.h null2_SOURCES = null2.c common.c common.h setnull_SOURCES = setnull.c common.c common.h numeric_SOURCES = numeric.c common.c common.h pending_SOURCES = pending.c common.c common.h cancel_SOURCES = cancel.c common.c common.h spid_SOURCES = spid.c common.c common.h bcp_getl_SOURCES= bcp_getl.c AM_CPPFLAGS = -DFREETDS_TOPDIR=\"$(top_srcdir)\" -I$(top_srcdir)/include if MINGW32 AM_LDFLAGS = -no-fast-install else AM_LDFLAGS = -no-install -L../.libs -R $(abs_builddir)/../.libs endif LIBS = ../libsybdb.la ../../replacements/libreplacements.la $(LTLIBICONV) EXTRA_DIST = t0016.in t0017.in t0017.in.be data.bin CMakeLists.txt $(SQL_DIST) \ t0016_1.in t0016_2.in t0016_3.in t0016_4.in t0016_5.in \ t0016_6.in t0016_7.in t0016_8.in t0016_9.in t0016_10.in \ t0016_11.in CLEANFILES = tdsdump.out t0013.out t0014.out t0016.out \ t0016.err t0017.err t0017.out $(SQL_DIST): ln -s $(srcdir)/$@ . freetds-1.00.82/src/dblib/unittests/Makefile.in100644 025423 025423 00000171543 13242511111 0015002# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/dblib/unittests ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = \ $(top_srcdir)/m4/ac_caolan_func_which_gethostbyname_r.m4 \ $(top_srcdir)/m4/ac_have_inaddr_none.m4 \ $(top_srcdir)/m4/ac_have_malloc_options.m4 \ $(top_srcdir)/m4/ac_nullzero.m4 \ $(top_srcdir)/m4/ac_raf_func_which_getservbyname_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_gethostbyaddr_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_getpwuid_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_localtime_r.m4 \ $(top_srcdir)/m4/acx_pthread.m4 \ $(top_srcdir)/m4/ax_cflags_gcc_option.m4 \ $(top_srcdir)/m4/check_openssl.m4 \ $(top_srcdir)/m4/gettimemilli.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/pushlibs.m4 \ $(top_srcdir)/m4/sprintf_i64_format.m4 \ $(top_srcdir)/m4/type_socklen_t.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am_bcp_OBJECTS = bcp.$(OBJEXT) common.$(OBJEXT) bcp_OBJECTS = $(am_bcp_OBJECTS) bcp_LDADD = $(LDADD) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = am_bcp_getl_OBJECTS = bcp_getl.$(OBJEXT) bcp_getl_OBJECTS = $(am_bcp_getl_OBJECTS) bcp_getl_LDADD = $(LDADD) am_cancel_OBJECTS = cancel.$(OBJEXT) common.$(OBJEXT) cancel_OBJECTS = $(am_cancel_OBJECTS) cancel_LDADD = $(LDADD) am_dbmorecmds_OBJECTS = dbmorecmds.$(OBJEXT) common.$(OBJEXT) dbmorecmds_OBJECTS = $(am_dbmorecmds_OBJECTS) dbmorecmds_LDADD = $(LDADD) am_done_handling_OBJECTS = done_handling.$(OBJEXT) common.$(OBJEXT) done_handling_OBJECTS = $(am_done_handling_OBJECTS) done_handling_LDADD = $(LDADD) am_hang_OBJECTS = hang.$(OBJEXT) common.$(OBJEXT) hang_OBJECTS = $(am_hang_OBJECTS) hang_LDADD = $(LDADD) am_null_OBJECTS = null.$(OBJEXT) common.$(OBJEXT) null_OBJECTS = $(am_null_OBJECTS) null_LDADD = $(LDADD) am_null2_OBJECTS = null2.$(OBJEXT) common.$(OBJEXT) null2_OBJECTS = $(am_null2_OBJECTS) null2_LDADD = $(LDADD) am_numeric_OBJECTS = numeric.$(OBJEXT) common.$(OBJEXT) numeric_OBJECTS = $(am_numeric_OBJECTS) numeric_LDADD = $(LDADD) am_pending_OBJECTS = pending.$(OBJEXT) common.$(OBJEXT) pending_OBJECTS = $(am_pending_OBJECTS) pending_LDADD = $(LDADD) am_rpc_OBJECTS = rpc.$(OBJEXT) common.$(OBJEXT) rpc_OBJECTS = $(am_rpc_OBJECTS) rpc_LDADD = $(LDADD) am_setnull_OBJECTS = setnull.$(OBJEXT) common.$(OBJEXT) setnull_OBJECTS = $(am_setnull_OBJECTS) setnull_LDADD = $(LDADD) am_spid_OBJECTS = spid.$(OBJEXT) common.$(OBJEXT) spid_OBJECTS = $(am_spid_OBJECTS) spid_LDADD = $(LDADD) am_t0001_OBJECTS = t0001.$(OBJEXT) common.$(OBJEXT) t0001_OBJECTS = $(am_t0001_OBJECTS) t0001_LDADD = $(LDADD) am_t0002_OBJECTS = t0002.$(OBJEXT) common.$(OBJEXT) t0002_OBJECTS = $(am_t0002_OBJECTS) t0002_LDADD = $(LDADD) am_t0003_OBJECTS = t0003.$(OBJEXT) common.$(OBJEXT) t0003_OBJECTS = $(am_t0003_OBJECTS) t0003_LDADD = $(LDADD) am_t0004_OBJECTS = t0004.$(OBJEXT) common.$(OBJEXT) t0004_OBJECTS = $(am_t0004_OBJECTS) t0004_LDADD = $(LDADD) am_t0005_OBJECTS = t0005.$(OBJEXT) common.$(OBJEXT) t0005_OBJECTS = $(am_t0005_OBJECTS) t0005_LDADD = $(LDADD) am_t0006_OBJECTS = t0006.$(OBJEXT) common.$(OBJEXT) t0006_OBJECTS = $(am_t0006_OBJECTS) t0006_LDADD = $(LDADD) am_t0007_OBJECTS = t0007.$(OBJEXT) common.$(OBJEXT) t0007_OBJECTS = $(am_t0007_OBJECTS) t0007_LDADD = $(LDADD) am_t0008_OBJECTS = t0008.$(OBJEXT) common.$(OBJEXT) t0008_OBJECTS = $(am_t0008_OBJECTS) t0008_LDADD = $(LDADD) am_t0009_OBJECTS = t0009.$(OBJEXT) common.$(OBJEXT) t0009_OBJECTS = $(am_t0009_OBJECTS) t0009_LDADD = $(LDADD) am_t0011_OBJECTS = t0011.$(OBJEXT) common.$(OBJEXT) t0011_OBJECTS = $(am_t0011_OBJECTS) t0011_LDADD = $(LDADD) am_t0012_OBJECTS = t0012.$(OBJEXT) common.$(OBJEXT) t0012_OBJECTS = $(am_t0012_OBJECTS) t0012_LDADD = $(LDADD) am_t0013_OBJECTS = t0013.$(OBJEXT) common.$(OBJEXT) t0013_OBJECTS = $(am_t0013_OBJECTS) t0013_LDADD = $(LDADD) am_t0014_OBJECTS = t0014.$(OBJEXT) common.$(OBJEXT) t0014_OBJECTS = $(am_t0014_OBJECTS) t0014_LDADD = $(LDADD) am_t0015_OBJECTS = t0015.$(OBJEXT) common.$(OBJEXT) t0015_OBJECTS = $(am_t0015_OBJECTS) t0015_LDADD = $(LDADD) am_t0016_OBJECTS = t0016.$(OBJEXT) common.$(OBJEXT) t0016_OBJECTS = $(am_t0016_OBJECTS) t0016_LDADD = $(LDADD) am_t0017_OBJECTS = t0017.$(OBJEXT) common.$(OBJEXT) t0017_OBJECTS = $(am_t0017_OBJECTS) t0017_LDADD = $(LDADD) am_t0018_OBJECTS = t0018.$(OBJEXT) common.$(OBJEXT) t0018_OBJECTS = $(am_t0018_OBJECTS) t0018_LDADD = $(LDADD) am_t0019_OBJECTS = t0019.$(OBJEXT) common.$(OBJEXT) t0019_OBJECTS = $(am_t0019_OBJECTS) t0019_LDADD = $(LDADD) am_t0020_OBJECTS = t0020.$(OBJEXT) common.$(OBJEXT) t0020_OBJECTS = $(am_t0020_OBJECTS) t0020_LDADD = $(LDADD) am_t0021_OBJECTS = t0021.$(OBJEXT) common.$(OBJEXT) t0021_OBJECTS = $(am_t0021_OBJECTS) t0021_LDADD = $(LDADD) am_t0022_OBJECTS = t0022.$(OBJEXT) common.$(OBJEXT) t0022_OBJECTS = $(am_t0022_OBJECTS) t0022_LDADD = $(LDADD) am_t0023_OBJECTS = t0023.$(OBJEXT) common.$(OBJEXT) t0023_OBJECTS = $(am_t0023_OBJECTS) t0023_LDADD = $(LDADD) am_text_buffer_OBJECTS = text_buffer.$(OBJEXT) common.$(OBJEXT) text_buffer_OBJECTS = $(am_text_buffer_OBJECTS) text_buffer_LDADD = $(LDADD) am_thread_OBJECTS = thread.$(OBJEXT) common.$(OBJEXT) thread_OBJECTS = $(am_thread_OBJECTS) thread_LDADD = $(LDADD) am_timeout_OBJECTS = timeout.$(OBJEXT) common.$(OBJEXT) timeout_OBJECTS = $(am_timeout_OBJECTS) timeout_LDADD = $(LDADD) SCRIPTS = $(noinst_SCRIPTS) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(bcp_SOURCES) $(bcp_getl_SOURCES) $(cancel_SOURCES) \ $(dbmorecmds_SOURCES) $(done_handling_SOURCES) $(hang_SOURCES) \ $(null_SOURCES) $(null2_SOURCES) $(numeric_SOURCES) \ $(pending_SOURCES) $(rpc_SOURCES) $(setnull_SOURCES) \ $(spid_SOURCES) $(t0001_SOURCES) $(t0002_SOURCES) \ $(t0003_SOURCES) $(t0004_SOURCES) $(t0005_SOURCES) \ $(t0006_SOURCES) $(t0007_SOURCES) $(t0008_SOURCES) \ $(t0009_SOURCES) $(t0011_SOURCES) $(t0012_SOURCES) \ $(t0013_SOURCES) $(t0014_SOURCES) $(t0015_SOURCES) \ $(t0016_SOURCES) $(t0017_SOURCES) $(t0018_SOURCES) \ $(t0019_SOURCES) $(t0020_SOURCES) $(t0021_SOURCES) \ $(t0022_SOURCES) $(t0023_SOURCES) $(text_buffer_SOURCES) \ $(thread_SOURCES) $(timeout_SOURCES) DIST_SOURCES = $(bcp_SOURCES) $(bcp_getl_SOURCES) $(cancel_SOURCES) \ $(dbmorecmds_SOURCES) $(done_handling_SOURCES) $(hang_SOURCES) \ $(null_SOURCES) $(null2_SOURCES) $(numeric_SOURCES) \ $(pending_SOURCES) $(rpc_SOURCES) $(setnull_SOURCES) \ $(spid_SOURCES) $(t0001_SOURCES) $(t0002_SOURCES) \ $(t0003_SOURCES) $(t0004_SOURCES) $(t0005_SOURCES) \ $(t0006_SOURCES) $(t0007_SOURCES) $(t0008_SOURCES) \ $(t0009_SOURCES) $(t0011_SOURCES) $(t0012_SOURCES) \ $(t0013_SOURCES) $(t0014_SOURCES) $(t0015_SOURCES) \ $(t0016_SOURCES) $(t0017_SOURCES) $(t0018_SOURCES) \ $(t0019_SOURCES) $(t0020_SOURCES) $(t0021_SOURCES) \ $(t0022_SOURCES) $(t0023_SOURCES) $(text_buffer_SOURCES) \ $(thread_SOURCES) $(timeout_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__tty_colors_dummy = \ mgn= red= grn= lgn= blu= brg= std=; \ am__color_tests=no am__tty_colors = { \ $(am__tty_colors_dummy); \ if test "X$(AM_COLOR_TESTS)" = Xno; then \ am__color_tests=no; \ elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ am__color_tests=yes; \ elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ am__color_tests=yes; \ fi; \ if test $$am__color_tests = yes; then \ red=''; \ grn=''; \ lgn=''; \ blu=''; \ mgn=''; \ brg=''; \ std=''; \ fi; \ } am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__recheck_rx = ^[ ]*:recheck:[ ]* am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* # A command that, given a newline-separated list of test names on the # standard input, print the name of the tests that are to be re-run # upon "make recheck". am__list_recheck_tests = $(AWK) '{ \ recheck = 1; \ while ((rc = (getline line < ($$0 ".trs"))) != 0) \ { \ if (rc < 0) \ { \ if ((getline line2 < ($$0 ".log")) < 0) \ recheck = 0; \ break; \ } \ else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ { \ recheck = 0; \ break; \ } \ else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ { \ break; \ } \ }; \ if (recheck) \ print $$0; \ close ($$0 ".trs"); \ close ($$0 ".log"); \ }' # A command that, given a newline-separated list of test names on the # standard input, create the global log from their .trs and .log files. am__create_global_log = $(AWK) ' \ function fatal(msg) \ { \ print "fatal: making $@: " msg | "cat >&2"; \ exit 1; \ } \ function rst_section(header) \ { \ print header; \ len = length(header); \ for (i = 1; i <= len; i = i + 1) \ printf "="; \ printf "\n\n"; \ } \ { \ copy_in_global_log = 1; \ global_test_result = "RUN"; \ while ((rc = (getline line < ($$0 ".trs"))) != 0) \ { \ if (rc < 0) \ fatal("failed to read from " $$0 ".trs"); \ if (line ~ /$(am__global_test_result_rx)/) \ { \ sub("$(am__global_test_result_rx)", "", line); \ sub("[ ]*$$", "", line); \ global_test_result = line; \ } \ else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ copy_in_global_log = 0; \ }; \ if (copy_in_global_log) \ { \ rst_section(global_test_result ": " $$0); \ while ((rc = (getline line < ($$0 ".log"))) != 0) \ { \ if (rc < 0) \ fatal("failed to read from " $$0 ".log"); \ print line; \ }; \ printf "\n"; \ }; \ close ($$0 ".trs"); \ close ($$0 ".log"); \ }' # Restructured Text title. am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } # Solaris 10 'make', and several other traditional 'make' implementations, # pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it # by disabling -e (using the XSI extension "set +e") if it's set. am__sh_e_setup = case $$- in *e*) set +e;; esac # Default flags passed to test drivers. am__common_driver_flags = \ --color-tests "$$am__color_tests" \ --enable-hard-errors "$$am__enable_hard_errors" \ --expect-failure "$$am__expect_failure" # To be inserted before the command running the test. Creates the # directory for the log if needed. Stores in $dir the directory # containing $f, in $tst the test, in $log the log. Executes the # developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and # passes TESTS_ENVIRONMENT. Set up options for the wrapper that # will run the test scripts (or their associated LOG_COMPILER, if # thy have one). am__check_pre = \ $(am__sh_e_setup); \ $(am__vpath_adj_setup) $(am__vpath_adj) \ $(am__tty_colors); \ srcdir=$(srcdir); export srcdir; \ case "$@" in \ */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ *) am__odir=.;; \ esac; \ test "x$$am__odir" = x"." || test -d "$$am__odir" \ || $(MKDIR_P) "$$am__odir" || exit $$?; \ if test -f "./$$f"; then dir=./; \ elif test -f "$$f"; then dir=; \ else dir="$(srcdir)/"; fi; \ tst=$$dir$$f; log='$@'; \ if test -n '$(DISABLE_HARD_ERRORS)'; then \ am__enable_hard_errors=no; \ else \ am__enable_hard_errors=yes; \ fi; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ am__expect_failure=yes;; \ *) \ am__expect_failure=no;; \ esac; \ $(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) # A shell command to get the names of the tests scripts with any registered # extension removed (i.e., equivalently, the names of the test logs, with # the '.log' extension removed). The result is saved in the shell variable # '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, # we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", # since that might cause problem with VPATH rewrites for suffix-less tests. # See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. am__set_TESTS_bases = \ bases='$(TEST_LOGS)'; \ bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ bases=`echo $$bases` RECHECK_LOGS = $(TEST_LOGS) AM_RECURSIVE_TARGETS = check recheck TEST_SUITE_LOG = test-suite.log TEST_EXTENSIONS = @EXEEXT@ .test LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) am__set_b = \ case '$@' in \ */*) \ case '$*' in \ */*) b='$*';; \ *) b=`echo '$@' | sed 's/\.log$$//'`; \ esac;; \ *) \ b='$*';; \ esac am__test_logs1 = $(TESTS:=.log) am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) TEST_LOGS = $(am__test_logs2:.test.log=.log) TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ $(TEST_LOG_FLAGS) am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp \ $(top_srcdir)/mkinstalldirs $(top_srcdir)/test-driver README DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BUILD_NUMBER = @BUILD_NUMBER@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOXYGEN = @DOXYGEN@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FREETDS_LIBGCC = @FREETDS_LIBGCC@ FREETDS_ODBC_MODULE = @FREETDS_ODBC_MODULE@ FREETDS_SYMBOLIC = @FREETDS_SYMBOLIC@ GCRYPT_CFLAGS = @GCRYPT_CFLAGS@ GCRYPT_LIBS = @GCRYPT_LIBS@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ HAVE_OPENSSL = @HAVE_OPENSSL@ HAVE_PERL_SOURCES = @HAVE_PERL_SOURCES@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBADD_DL = @LIBADD_DL@ LIBADD_DLD_LINK = @LIBADD_DLD_LINK@ LIBADD_DLOPEN = @LIBADD_DLOPEN@ LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@ LIBICONV = @LIBICONV@ LIBOBJS = @LIBOBJS@ LIBS = ../libsybdb.la ../../replacements/libreplacements.la $(LTLIBICONV) LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBOBJS = @LTLIBOBJS@ LT_DLLOADERS = @LT_DLLOADERS@ LT_DLPREOPEN = @LT_DLPREOPEN@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ NETTLE_CFLAGS = @NETTLE_CFLAGS@ NETTLE_LIBS = @NETTLE_LIBS@ NETWORK_LIBS = @NETWORK_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ODBC = @ODBC@ ODBCINSTLIB = @ODBCINSTLIB@ ODBCLIB = @ODBCLIB@ ODBCNODMLIB = @ODBCNODMLIB@ ODBCNODMLIBAPP = @ODBCNODMLIBAPP@ ODBC_CONFIG = @ODBC_CONFIG@ ODBC_INC = @ODBC_INC@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ RC = @RC@ READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SUBVERSION = @SUBVERSION@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ dblib_define = @dblib_define@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ tds_sysdep_int16_type = @tds_sysdep_int16_type@ tds_sysdep_int32_type = @tds_sysdep_int32_type@ tds_sysdep_int64_type = @tds_sysdep_int64_type@ tds_sysdep_intptr_type = @tds_sysdep_intptr_type@ tds_sysdep_real32_type = @tds_sysdep_real32_type@ tds_sysdep_real64_type = @tds_sysdep_real64_type@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ TESTS = t0001$(EXEEXT) t0002$(EXEEXT) t0003$(EXEEXT)\ t0004$(EXEEXT) t0005$(EXEEXT) t0006$(EXEEXT)\ t0007$(EXEEXT) t0008$(EXEEXT) t0009$(EXEEXT)\ t0011$(EXEEXT) t0012$(EXEEXT) t0013$(EXEEXT)\ t0014$(EXEEXT) t0015$(EXEEXT) t0016$(EXEEXT)\ t0017$(EXEEXT) t0018$(EXEEXT) t0019$(EXEEXT)\ t0020$(EXEEXT) t0021$(EXEEXT) t0022$(EXEEXT)\ t0023$(EXEEXT) rpc$(EXEEXT) dbmorecmds$(EXEEXT)\ bcp$(EXEEXT) thread$(EXEEXT) text_buffer$(EXEEXT)\ done_handling$(EXEEXT) timeout$(EXEEXT) \ hang$(EXEEXT) null$(EXEEXT) null2$(EXEEXT) \ setnull$(EXEEXT) numeric$(EXEEXT) pending$(EXEEXT) \ cancel$(EXEEXT) spid$(EXEEXT) bcp_getl$(EXEEXT) check_PROGRAMS = $(TESTS) SQL_DIST = bcp.sql dbmorecmds.sql done_handling.sql rpc.sql spid.sql \ t0001.sql t0002.sql t0003.sql t0004.sql t0005.sql t0006.sql t0007.sql t0009.sql \ t0011.sql t0012.sql t0013.sql t0014.sql t0015.sql t0016.sql t0017.sql t0018.sql \ t0020.sql t0022.sql t0023.sql text_buffer.sql timeout.sql numeric.sql numeric_2.sql \ pending.sql cancel.sql t0016_10.sql t0016_11.sql t0016_1.sql t0016_2.sql \ t0016_3.sql t0016_4.sql t0016_5.sql t0016_6.sql t0016_7.sql t0016_8.sql t0016_9.sql noinst_SCRIPTS = $(SQL_DIST) t0001_SOURCES = t0001.c common.c common.h t0001.sql t0002_SOURCES = t0002.c common.c common.h t0003_SOURCES = t0003.c common.c common.h t0004_SOURCES = t0004.c common.c common.h t0005_SOURCES = t0005.c common.c common.h t0006_SOURCES = t0006.c common.c common.h t0007_SOURCES = t0007.c common.c common.h t0008_SOURCES = t0008.c common.c common.h t0009_SOURCES = t0009.c common.c common.h t0011_SOURCES = t0011.c common.c common.h t0012_SOURCES = t0012.c common.c common.h t0013_SOURCES = t0013.c common.c common.h t0014_SOURCES = t0014.c common.c common.h t0015_SOURCES = t0015.c common.c common.h t0016_SOURCES = t0016.c common.c common.h t0017_SOURCES = t0017.c common.c common.h t0018_SOURCES = t0018.c common.c common.h t0019_SOURCES = t0019.c common.c common.h t0020_SOURCES = t0020.c common.c common.h t0021_SOURCES = t0021.c common.c common.h t0022_SOURCES = t0022.c common.c common.h t0023_SOURCES = t0023.c common.c common.h rpc_SOURCES = rpc.c common.c common.h dbmorecmds_SOURCES = dbmorecmds.c common.c common.h bcp_SOURCES = bcp.c bcp.h common.c common.h thread_SOURCES = thread.c bcp.h common.c common.h text_buffer_SOURCES = text_buffer.c common.c common.h done_handling_SOURCES = done_handling.c common.c common.h timeout_SOURCES = timeout.c common.c common.h hang_SOURCES = hang.c common.c common.h null_SOURCES = null.c common.c common.h null2_SOURCES = null2.c common.c common.h setnull_SOURCES = setnull.c common.c common.h numeric_SOURCES = numeric.c common.c common.h pending_SOURCES = pending.c common.c common.h cancel_SOURCES = cancel.c common.c common.h spid_SOURCES = spid.c common.c common.h bcp_getl_SOURCES = bcp_getl.c AM_CPPFLAGS = -DFREETDS_TOPDIR=\"$(top_srcdir)\" -I$(top_srcdir)/include @MINGW32_FALSE@AM_LDFLAGS = -no-install -L../.libs -R $(abs_builddir)/../.libs @MINGW32_TRUE@AM_LDFLAGS = -no-fast-install EXTRA_DIST = t0016.in t0017.in t0017.in.be data.bin CMakeLists.txt $(SQL_DIST) \ t0016_1.in t0016_2.in t0016_3.in t0016_4.in t0016_5.in \ t0016_6.in t0016_7.in t0016_8.in t0016_9.in t0016_10.in \ t0016_11.in CLEANFILES = tdsdump.out t0013.out t0014.out t0016.out \ t0016.err t0017.err t0017.out all: all-am .SUFFIXES: .SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/dblib/unittests/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/dblib/unittests/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-checkPROGRAMS: @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list bcp$(EXEEXT): $(bcp_OBJECTS) $(bcp_DEPENDENCIES) $(EXTRA_bcp_DEPENDENCIES) @rm -f bcp$(EXEEXT) $(AM_V_CCLD)$(LINK) $(bcp_OBJECTS) $(bcp_LDADD) $(LIBS) bcp_getl$(EXEEXT): $(bcp_getl_OBJECTS) $(bcp_getl_DEPENDENCIES) $(EXTRA_bcp_getl_DEPENDENCIES) @rm -f bcp_getl$(EXEEXT) $(AM_V_CCLD)$(LINK) $(bcp_getl_OBJECTS) $(bcp_getl_LDADD) $(LIBS) cancel$(EXEEXT): $(cancel_OBJECTS) $(cancel_DEPENDENCIES) $(EXTRA_cancel_DEPENDENCIES) @rm -f cancel$(EXEEXT) $(AM_V_CCLD)$(LINK) $(cancel_OBJECTS) $(cancel_LDADD) $(LIBS) dbmorecmds$(EXEEXT): $(dbmorecmds_OBJECTS) $(dbmorecmds_DEPENDENCIES) $(EXTRA_dbmorecmds_DEPENDENCIES) @rm -f dbmorecmds$(EXEEXT) $(AM_V_CCLD)$(LINK) $(dbmorecmds_OBJECTS) $(dbmorecmds_LDADD) $(LIBS) done_handling$(EXEEXT): $(done_handling_OBJECTS) $(done_handling_DEPENDENCIES) $(EXTRA_done_handling_DEPENDENCIES) @rm -f done_handling$(EXEEXT) $(AM_V_CCLD)$(LINK) $(done_handling_OBJECTS) $(done_handling_LDADD) $(LIBS) hang$(EXEEXT): $(hang_OBJECTS) $(hang_DEPENDENCIES) $(EXTRA_hang_DEPENDENCIES) @rm -f hang$(EXEEXT) $(AM_V_CCLD)$(LINK) $(hang_OBJECTS) $(hang_LDADD) $(LIBS) null$(EXEEXT): $(null_OBJECTS) $(null_DEPENDENCIES) $(EXTRA_null_DEPENDENCIES) @rm -f null$(EXEEXT) $(AM_V_CCLD)$(LINK) $(null_OBJECTS) $(null_LDADD) $(LIBS) null2$(EXEEXT): $(null2_OBJECTS) $(null2_DEPENDENCIES) $(EXTRA_null2_DEPENDENCIES) @rm -f null2$(EXEEXT) $(AM_V_CCLD)$(LINK) $(null2_OBJECTS) $(null2_LDADD) $(LIBS) numeric$(EXEEXT): $(numeric_OBJECTS) $(numeric_DEPENDENCIES) $(EXTRA_numeric_DEPENDENCIES) @rm -f numeric$(EXEEXT) $(AM_V_CCLD)$(LINK) $(numeric_OBJECTS) $(numeric_LDADD) $(LIBS) pending$(EXEEXT): $(pending_OBJECTS) $(pending_DEPENDENCIES) $(EXTRA_pending_DEPENDENCIES) @rm -f pending$(EXEEXT) $(AM_V_CCLD)$(LINK) $(pending_OBJECTS) $(pending_LDADD) $(LIBS) rpc$(EXEEXT): $(rpc_OBJECTS) $(rpc_DEPENDENCIES) $(EXTRA_rpc_DEPENDENCIES) @rm -f rpc$(EXEEXT) $(AM_V_CCLD)$(LINK) $(rpc_OBJECTS) $(rpc_LDADD) $(LIBS) setnull$(EXEEXT): $(setnull_OBJECTS) $(setnull_DEPENDENCIES) $(EXTRA_setnull_DEPENDENCIES) @rm -f setnull$(EXEEXT) $(AM_V_CCLD)$(LINK) $(setnull_OBJECTS) $(setnull_LDADD) $(LIBS) spid$(EXEEXT): $(spid_OBJECTS) $(spid_DEPENDENCIES) $(EXTRA_spid_DEPENDENCIES) @rm -f spid$(EXEEXT) $(AM_V_CCLD)$(LINK) $(spid_OBJECTS) $(spid_LDADD) $(LIBS) t0001$(EXEEXT): $(t0001_OBJECTS) $(t0001_DEPENDENCIES) $(EXTRA_t0001_DEPENDENCIES) @rm -f t0001$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0001_OBJECTS) $(t0001_LDADD) $(LIBS) t0002$(EXEEXT): $(t0002_OBJECTS) $(t0002_DEPENDENCIES) $(EXTRA_t0002_DEPENDENCIES) @rm -f t0002$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0002_OBJECTS) $(t0002_LDADD) $(LIBS) t0003$(EXEEXT): $(t0003_OBJECTS) $(t0003_DEPENDENCIES) $(EXTRA_t0003_DEPENDENCIES) @rm -f t0003$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0003_OBJECTS) $(t0003_LDADD) $(LIBS) t0004$(EXEEXT): $(t0004_OBJECTS) $(t0004_DEPENDENCIES) $(EXTRA_t0004_DEPENDENCIES) @rm -f t0004$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0004_OBJECTS) $(t0004_LDADD) $(LIBS) t0005$(EXEEXT): $(t0005_OBJECTS) $(t0005_DEPENDENCIES) $(EXTRA_t0005_DEPENDENCIES) @rm -f t0005$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0005_OBJECTS) $(t0005_LDADD) $(LIBS) t0006$(EXEEXT): $(t0006_OBJECTS) $(t0006_DEPENDENCIES) $(EXTRA_t0006_DEPENDENCIES) @rm -f t0006$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0006_OBJECTS) $(t0006_LDADD) $(LIBS) t0007$(EXEEXT): $(t0007_OBJECTS) $(t0007_DEPENDENCIES) $(EXTRA_t0007_DEPENDENCIES) @rm -f t0007$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0007_OBJECTS) $(t0007_LDADD) $(LIBS) t0008$(EXEEXT): $(t0008_OBJECTS) $(t0008_DEPENDENCIES) $(EXTRA_t0008_DEPENDENCIES) @rm -f t0008$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0008_OBJECTS) $(t0008_LDADD) $(LIBS) t0009$(EXEEXT): $(t0009_OBJECTS) $(t0009_DEPENDENCIES) $(EXTRA_t0009_DEPENDENCIES) @rm -f t0009$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0009_OBJECTS) $(t0009_LDADD) $(LIBS) t0011$(EXEEXT): $(t0011_OBJECTS) $(t0011_DEPENDENCIES) $(EXTRA_t0011_DEPENDENCIES) @rm -f t0011$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0011_OBJECTS) $(t0011_LDADD) $(LIBS) t0012$(EXEEXT): $(t0012_OBJECTS) $(t0012_DEPENDENCIES) $(EXTRA_t0012_DEPENDENCIES) @rm -f t0012$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0012_OBJECTS) $(t0012_LDADD) $(LIBS) t0013$(EXEEXT): $(t0013_OBJECTS) $(t0013_DEPENDENCIES) $(EXTRA_t0013_DEPENDENCIES) @rm -f t0013$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0013_OBJECTS) $(t0013_LDADD) $(LIBS) t0014$(EXEEXT): $(t0014_OBJECTS) $(t0014_DEPENDENCIES) $(EXTRA_t0014_DEPENDENCIES) @rm -f t0014$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0014_OBJECTS) $(t0014_LDADD) $(LIBS) t0015$(EXEEXT): $(t0015_OBJECTS) $(t0015_DEPENDENCIES) $(EXTRA_t0015_DEPENDENCIES) @rm -f t0015$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0015_OBJECTS) $(t0015_LDADD) $(LIBS) t0016$(EXEEXT): $(t0016_OBJECTS) $(t0016_DEPENDENCIES) $(EXTRA_t0016_DEPENDENCIES) @rm -f t0016$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0016_OBJECTS) $(t0016_LDADD) $(LIBS) t0017$(EXEEXT): $(t0017_OBJECTS) $(t0017_DEPENDENCIES) $(EXTRA_t0017_DEPENDENCIES) @rm -f t0017$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0017_OBJECTS) $(t0017_LDADD) $(LIBS) t0018$(EXEEXT): $(t0018_OBJECTS) $(t0018_DEPENDENCIES) $(EXTRA_t0018_DEPENDENCIES) @rm -f t0018$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0018_OBJECTS) $(t0018_LDADD) $(LIBS) t0019$(EXEEXT): $(t0019_OBJECTS) $(t0019_DEPENDENCIES) $(EXTRA_t0019_DEPENDENCIES) @rm -f t0019$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0019_OBJECTS) $(t0019_LDADD) $(LIBS) t0020$(EXEEXT): $(t0020_OBJECTS) $(t0020_DEPENDENCIES) $(EXTRA_t0020_DEPENDENCIES) @rm -f t0020$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0020_OBJECTS) $(t0020_LDADD) $(LIBS) t0021$(EXEEXT): $(t0021_OBJECTS) $(t0021_DEPENDENCIES) $(EXTRA_t0021_DEPENDENCIES) @rm -f t0021$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0021_OBJECTS) $(t0021_LDADD) $(LIBS) t0022$(EXEEXT): $(t0022_OBJECTS) $(t0022_DEPENDENCIES) $(EXTRA_t0022_DEPENDENCIES) @rm -f t0022$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0022_OBJECTS) $(t0022_LDADD) $(LIBS) t0023$(EXEEXT): $(t0023_OBJECTS) $(t0023_DEPENDENCIES) $(EXTRA_t0023_DEPENDENCIES) @rm -f t0023$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0023_OBJECTS) $(t0023_LDADD) $(LIBS) text_buffer$(EXEEXT): $(text_buffer_OBJECTS) $(text_buffer_DEPENDENCIES) $(EXTRA_text_buffer_DEPENDENCIES) @rm -f text_buffer$(EXEEXT) $(AM_V_CCLD)$(LINK) $(text_buffer_OBJECTS) $(text_buffer_LDADD) $(LIBS) thread$(EXEEXT): $(thread_OBJECTS) $(thread_DEPENDENCIES) $(EXTRA_thread_DEPENDENCIES) @rm -f thread$(EXEEXT) $(AM_V_CCLD)$(LINK) $(thread_OBJECTS) $(thread_LDADD) $(LIBS) timeout$(EXEEXT): $(timeout_OBJECTS) $(timeout_DEPENDENCIES) $(EXTRA_timeout_DEPENDENCIES) @rm -f timeout$(EXEEXT) $(AM_V_CCLD)$(LINK) $(timeout_OBJECTS) $(timeout_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bcp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bcp_getl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cancel.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/common.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbmorecmds.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/done_handling.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hang.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/null.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/null2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/numeric.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pending.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rpc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/setnull.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spid.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0001.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0002.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0003.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0004.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0005.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0006.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0007.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0008.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0009.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0011.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0012.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0013.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0014.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0015.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0016.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0017.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0018.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0019.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0020.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0021.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0022.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0023.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/text_buffer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/thread.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timeout.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags # Recover from deleted '.trs' file; this should ensure that # "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create # both 'foo.log' and 'foo.trs'. Break the recipe in two subshells # to avoid problems with "make -n". .log.trs: rm -f $< $@ $(MAKE) $(AM_MAKEFLAGS) $< # Leading 'am--fnord' is there to ensure the list of targets does not # expand to empty, as could happen e.g. with make check TESTS=''. am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) am--force-recheck: @: $(TEST_SUITE_LOG): $(TEST_LOGS) @$(am__set_TESTS_bases); \ am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ redo_bases=`for i in $$bases; do \ am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ done`; \ if test -n "$$redo_bases"; then \ redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ if $(am__make_dryrun); then :; else \ rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ fi; \ fi; \ if test -n "$$am__remaking_logs"; then \ echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ "recursion detected" >&2; \ elif test -n "$$redo_logs"; then \ am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ fi; \ if $(am__make_dryrun); then :; else \ st=0; \ errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ for i in $$redo_bases; do \ test -f $$i.trs && test -r $$i.trs \ || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ test -f $$i.log && test -r $$i.log \ || { echo "$$errmsg $$i.log" >&2; st=1; }; \ done; \ test $$st -eq 0 || exit 1; \ fi @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ ws='[ ]'; \ results=`for b in $$bases; do echo $$b.trs; done`; \ test -n "$$results" || results=/dev/null; \ all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ if test `expr $$fail + $$xpass + $$error` -eq 0; then \ success=true; \ else \ success=false; \ fi; \ br='==================='; br=$$br$$br$$br$$br; \ result_count () \ { \ if test x"$$1" = x"--maybe-color"; then \ maybe_colorize=yes; \ elif test x"$$1" = x"--no-color"; then \ maybe_colorize=no; \ else \ echo "$@: invalid 'result_count' usage" >&2; exit 4; \ fi; \ shift; \ desc=$$1 count=$$2; \ if test $$maybe_colorize = yes && test $$count -gt 0; then \ color_start=$$3 color_end=$$std; \ else \ color_start= color_end=; \ fi; \ echo "$${color_start}# $$desc $$count$${color_end}"; \ }; \ create_testsuite_report () \ { \ result_count $$1 "TOTAL:" $$all "$$brg"; \ result_count $$1 "PASS: " $$pass "$$grn"; \ result_count $$1 "SKIP: " $$skip "$$blu"; \ result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ result_count $$1 "FAIL: " $$fail "$$red"; \ result_count $$1 "XPASS:" $$xpass "$$red"; \ result_count $$1 "ERROR:" $$error "$$mgn"; \ }; \ { \ echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ $(am__rst_title); \ create_testsuite_report --no-color; \ echo; \ echo ".. contents:: :depth: 2"; \ echo; \ for b in $$bases; do echo $$b; done \ | $(am__create_global_log); \ } >$(TEST_SUITE_LOG).tmp || exit 1; \ mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ if $$success; then \ col="$$grn"; \ else \ col="$$red"; \ test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ fi; \ echo "$${col}$$br$${std}"; \ echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ echo "$${col}$$br$${std}"; \ create_testsuite_report --maybe-color; \ echo "$$col$$br$$std"; \ if $$success; then :; else \ echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ if test -n "$(PACKAGE_BUGREPORT)"; then \ echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ fi; \ echo "$$col$$br$$std"; \ fi; \ $$success || exit 1 check-TESTS: @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ log_list=`for i in $$bases; do echo $$i.log; done`; \ trs_list=`for i in $$bases; do echo $$i.trs; done`; \ log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ exit $$?; recheck: all $(check_PROGRAMS) @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ bases=`for i in $$bases; do echo $$i; done \ | $(am__list_recheck_tests)` || exit 1; \ log_list=`for i in $$bases; do echo $$i.log; done`; \ log_list=`echo $$log_list`; \ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ am__force_recheck=am--force-recheck \ TEST_LOGS="$$log_list"; \ exit $$? t0001.log: t0001$(EXEEXT) @p='t0001$(EXEEXT)'; \ b='t0001'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0002.log: t0002$(EXEEXT) @p='t0002$(EXEEXT)'; \ b='t0002'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0003.log: t0003$(EXEEXT) @p='t0003$(EXEEXT)'; \ b='t0003'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0004.log: t0004$(EXEEXT) @p='t0004$(EXEEXT)'; \ b='t0004'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0005.log: t0005$(EXEEXT) @p='t0005$(EXEEXT)'; \ b='t0005'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0006.log: t0006$(EXEEXT) @p='t0006$(EXEEXT)'; \ b='t0006'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0007.log: t0007$(EXEEXT) @p='t0007$(EXEEXT)'; \ b='t0007'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0008.log: t0008$(EXEEXT) @p='t0008$(EXEEXT)'; \ b='t0008'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0009.log: t0009$(EXEEXT) @p='t0009$(EXEEXT)'; \ b='t0009'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0011.log: t0011$(EXEEXT) @p='t0011$(EXEEXT)'; \ b='t0011'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0012.log: t0012$(EXEEXT) @p='t0012$(EXEEXT)'; \ b='t0012'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0013.log: t0013$(EXEEXT) @p='t0013$(EXEEXT)'; \ b='t0013'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0014.log: t0014$(EXEEXT) @p='t0014$(EXEEXT)'; \ b='t0014'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0015.log: t0015$(EXEEXT) @p='t0015$(EXEEXT)'; \ b='t0015'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0016.log: t0016$(EXEEXT) @p='t0016$(EXEEXT)'; \ b='t0016'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0017.log: t0017$(EXEEXT) @p='t0017$(EXEEXT)'; \ b='t0017'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0018.log: t0018$(EXEEXT) @p='t0018$(EXEEXT)'; \ b='t0018'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0019.log: t0019$(EXEEXT) @p='t0019$(EXEEXT)'; \ b='t0019'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0020.log: t0020$(EXEEXT) @p='t0020$(EXEEXT)'; \ b='t0020'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0021.log: t0021$(EXEEXT) @p='t0021$(EXEEXT)'; \ b='t0021'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0022.log: t0022$(EXEEXT) @p='t0022$(EXEEXT)'; \ b='t0022'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0023.log: t0023$(EXEEXT) @p='t0023$(EXEEXT)'; \ b='t0023'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) rpc.log: rpc$(EXEEXT) @p='rpc$(EXEEXT)'; \ b='rpc'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) dbmorecmds.log: dbmorecmds$(EXEEXT) @p='dbmorecmds$(EXEEXT)'; \ b='dbmorecmds'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) bcp.log: bcp$(EXEEXT) @p='bcp$(EXEEXT)'; \ b='bcp'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) thread.log: thread$(EXEEXT) @p='thread$(EXEEXT)'; \ b='thread'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) text_buffer.log: text_buffer$(EXEEXT) @p='text_buffer$(EXEEXT)'; \ b='text_buffer'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) done_handling.log: done_handling$(EXEEXT) @p='done_handling$(EXEEXT)'; \ b='done_handling'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) timeout.log: timeout$(EXEEXT) @p='timeout$(EXEEXT)'; \ b='timeout'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) hang.log: hang$(EXEEXT) @p='hang$(EXEEXT)'; \ b='hang'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) null.log: null$(EXEEXT) @p='null$(EXEEXT)'; \ b='null'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) null2.log: null2$(EXEEXT) @p='null2$(EXEEXT)'; \ b='null2'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) setnull.log: setnull$(EXEEXT) @p='setnull$(EXEEXT)'; \ b='setnull'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) numeric.log: numeric$(EXEEXT) @p='numeric$(EXEEXT)'; \ b='numeric'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) pending.log: pending$(EXEEXT) @p='pending$(EXEEXT)'; \ b='pending'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) cancel.log: cancel$(EXEEXT) @p='cancel$(EXEEXT)'; \ b='cancel'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) spid.log: spid$(EXEEXT) @p='spid$(EXEEXT)'; \ b='spid'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) bcp_getl.log: bcp_getl$(EXEEXT) @p='bcp_getl$(EXEEXT)'; \ b='bcp_getl'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) .test.log: @p='$<'; \ $(am__set_b); \ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) @am__EXEEXT_TRUE@.test$(EXEEXT).log: @am__EXEEXT_TRUE@ @p='$<'; \ @am__EXEEXT_TRUE@ $(am__set_b); \ @am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ @am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ @am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ @am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-am all-am: Makefile $(SCRIPTS) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: check-am install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am clean \ clean-checkPROGRAMS clean-generic clean-libtool cscopelist-am \ ctags ctags-am distclean distclean-compile distclean-generic \ 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-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 \ recheck tags tags-am uninstall uninstall-am .PRECIOUS: Makefile $(SQL_DIST): ln -s $(srcdir)/$@ . # 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: freetds-1.00.82/src/dblib/unittests/README100644 025423 025423 00000001327 12522201763 0013616The programs in this directory test the db-lib routines. Tests that db-lib passes print "dblib okay for t000X.c" as the last line of output and exit with a status of 0. If the test does not print that message for the last line of output it means that db-lib failed that test. Some of the tests are designed to dump core if an error is detected. This is to assist with post-mortem debugging of the dblib routines. Run all tests with 'make check'. The test programs read the 'PWD' file in the root of the source tree to determine which server to run the tests on and which account to login as. You will want to modify PWD accordingly. All unit tests are expected to pass on all servers and all operating systems. freetds-1.00.82/src/dblib/unittests/bcp.c100644 025423 025423 00000015071 12717145107 0013654/* * Purpose: Test bcp functions * Functions: bcp_batch bcp_bind bcp_done bcp_init bcp_sendrow */ #include "common.h" #include #if HAVE_SYS_STAT_H #include #endif /* HAVE_SYS_STAT_H */ #include "bcp.h" static char cmd[512]; static int init(DBPROCESS * dbproc, const char *name); static void test_bind(DBPROCESS * dbproc); /* * Static data for insertion */ static int not_null_bit = 1; static char not_null_char[] = "a char"; static char not_null_varchar[] = "a varchar"; static char not_null_datetime[] = "Dec 17 2003 3:44PM"; static char not_null_smalldatetime[] = "Dec 17 2003 3:44PM"; static char not_null_money[] = "12.34"; static char not_null_smallmoney[] = "12.34"; static char not_null_float[] = "12.34"; static char not_null_real[] = "12.34"; static char not_null_decimal[] = "12.34"; static char not_null_numeric[] = "12.34"; static int not_null_int = 1234; static int not_null_smallint = 1234; static int not_null_tinyint = 123; static int init(DBPROCESS * dbproc, const char *name) { int res = 0; RETCODE rc; fprintf(stdout, "Dropping %s.%s..%s\n", SERVER, DATABASE, name); sql_cmd(dbproc); dbsqlexec(dbproc); while ((rc=dbresults(dbproc)) == SUCCEED) { /* nop */ } if (rc != NO_MORE_RESULTS) return 1; fprintf(stdout, "Creating %s.%s..%s\n", SERVER, DATABASE, name); sql_cmd(dbproc); sql_cmd(dbproc); if (dbsqlexec(dbproc) == FAIL) { res = 1; } while ((rc=dbresults(dbproc)) == SUCCEED) { dbprhead(dbproc); dbprrow(dbproc); while ((rc=dbnextrow(dbproc)) == REG_ROW) { dbprrow(dbproc); } } if (rc != NO_MORE_RESULTS) return 1; fprintf(stdout, "%s\n", res? "error" : "ok"); return res; } #define VARCHAR_BIND(x) \ bcp_bind( dbproc, (unsigned char *) &x, prefixlen, strlen(x), NULL, termlen, SYBVARCHAR, col++ ) #define INT_BIND(x) \ bcp_bind( dbproc, (unsigned char *) &x, prefixlen, -1, NULL, termlen, SYBINT4, col++ ) #define NULL_BIND(x, type) \ bcp_bind( dbproc, (unsigned char *) &x, prefixlen, 0, NULL, termlen, type, col++ ) static void test_bind(DBPROCESS * dbproc) { enum { prefixlen = 0 }; enum { termlen = 0 }; enum NullValue { IsNull, IsNotNull }; RETCODE fOK; int col=1; /* non nulls */ fOK = INT_BIND(not_null_bit); assert(fOK == SUCCEED); fOK = VARCHAR_BIND(not_null_char); assert(fOK == SUCCEED); fOK = VARCHAR_BIND(not_null_varchar); assert(fOK == SUCCEED); fOK = VARCHAR_BIND(not_null_datetime); assert(fOK == SUCCEED); fOK = VARCHAR_BIND(not_null_smalldatetime); assert(fOK == SUCCEED); fOK = VARCHAR_BIND(not_null_money); assert(fOK == SUCCEED); fOK = VARCHAR_BIND(not_null_smallmoney); assert(fOK == SUCCEED); fOK = VARCHAR_BIND(not_null_float); assert(fOK == SUCCEED); fOK = VARCHAR_BIND(not_null_real); assert(fOK == SUCCEED); fOK = VARCHAR_BIND(not_null_decimal); assert(fOK == SUCCEED); fOK = VARCHAR_BIND(not_null_numeric); assert(fOK == SUCCEED); fOK = INT_BIND(not_null_int); assert(fOK == SUCCEED); fOK = INT_BIND(not_null_smallint); assert(fOK == SUCCEED); fOK = INT_BIND(not_null_tinyint); assert(fOK == SUCCEED); /* nulls */ fOK = NULL_BIND(not_null_char, SYBVARCHAR); assert(fOK == SUCCEED); fOK = NULL_BIND(not_null_varchar, SYBVARCHAR); assert(fOK == SUCCEED); fOK = NULL_BIND(not_null_datetime, SYBVARCHAR); assert(fOK == SUCCEED); fOK = NULL_BIND(not_null_smalldatetime, SYBVARCHAR); assert(fOK == SUCCEED); fOK = NULL_BIND(not_null_money, SYBVARCHAR); assert(fOK == SUCCEED); fOK = NULL_BIND(not_null_smallmoney, SYBVARCHAR); assert(fOK == SUCCEED); fOK = NULL_BIND(not_null_float, SYBVARCHAR); assert(fOK == SUCCEED); fOK = NULL_BIND(not_null_real, SYBVARCHAR); assert(fOK == SUCCEED); fOK = NULL_BIND(not_null_decimal, SYBVARCHAR); assert(fOK == SUCCEED); fOK = NULL_BIND(not_null_numeric, SYBVARCHAR); assert(fOK == SUCCEED); fOK = NULL_BIND(not_null_int, SYBINT4); assert(fOK == SUCCEED); fOK = NULL_BIND(not_null_smallint, SYBINT4); assert(fOK == SUCCEED); fOK = NULL_BIND(not_null_tinyint, SYBINT4); assert(fOK == SUCCEED); } int main(int argc, char **argv) { LOGINREC *login; DBPROCESS *dbproc; int i, rows_sent=0; int failed = 0; const char *s; const char *table_name = "all_types_bcp_unittest"; set_malloc_options(); read_login_info(argc, argv); fprintf(stdout, "Starting %s\n", argv[0]); dbinit(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "bcp.c unit test"); BCP_SETL(login, 1); fprintf(stdout, "About to open %s.%s\n", SERVER, DATABASE); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); dbloginfree(login); if (init(dbproc, table_name)) exit(1); /* set up and send the bcp */ sprintf(cmd, "%s..%s", DATABASE, table_name); fprintf(stdout, "preparing to insert into %s ... ", cmd); if (bcp_init(dbproc, cmd, NULL, NULL, DB_IN) == FAIL) { fprintf(stdout, "failed\n"); exit(1); } fprintf(stdout, "OK\n"); test_bind(dbproc); fprintf(stdout, "Sending same row 10 times... \n"); for (i=0; i<10; i++) { if (bcp_sendrow(dbproc) == FAIL) { fprintf(stdout, "send failed\n"); exit(1); } } fprintf(stdout, "Sending 5 more rows ... \n"); for (i=15; i <= 27; i++) { int type = dbcoltype(dbproc, i); int len = (type == SYBCHAR || type == SYBVARCHAR)? dbcollen(dbproc, i) : -1; if (bcp_collen(dbproc, len, i) == FAIL) { fprintf(stdout, "bcp_collen failed for column %d\n", i); exit(1); } } for (i=0; i<5; i++) { if (bcp_sendrow(dbproc) == FAIL) { fprintf(stdout, "send failed\n"); exit(1); } } #if 1 rows_sent = bcp_batch(dbproc); if (rows_sent == -1) { fprintf(stdout, "batch failed\n"); exit(1); } #endif fprintf(stdout, "OK\n"); /* end bcp. */ if ((rows_sent += bcp_done(dbproc)) == -1) printf("Bulk copy unsuccessful.\n"); else printf("%d rows copied.\n", rows_sent); printf("done\n"); #if 1 sql_cmd(dbproc); dbsqlexec(dbproc); while ((i=dbresults(dbproc)) == SUCCEED) { dbprhead(dbproc); dbprrow(dbproc); while ((i=dbnextrow(dbproc)) == REG_ROW) { dbprrow(dbproc); } } #endif if ((s = getenv("BCP")) != NULL && 0 == strcmp(s, "nodrop")) { fprintf(stdout, "BCP=nodrop: '%s..%s' kept\n", DATABASE, table_name); } else { fprintf(stdout, "Dropping table %s\n", table_name); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } } dbexit(); failed = 0; fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); return failed ? 1 : 0; } freetds-1.00.82/src/dblib/unittests/bcp.h100644 025423 025423 00000006711 12522201763 0013655static const char create_table_sql[] = "CREATE TABLE all_types_bcp_unittest (\n" " not_null_bit bit NOT NULL\n" "\n" " , not_null_char char(10) NOT NULL\n" " , not_null_varchar varchar(10) NOT NULL\n" "\n" " , not_null_datetime datetime NOT NULL\n" " , not_null_smalldatetime smalldatetime NOT NULL\n" "\n" " , not_null_money money NOT NULL\n" " , not_null_smallmoney smallmoney NOT NULL\n" "\n" " , not_null_float float NOT NULL\n" " , not_null_real real NOT NULL\n" "\n" " , not_null_decimal decimal(5,2) NOT NULL\n" " , not_null_numeric numeric(5,2) NOT NULL\n" "\n" " , not_null_int int NOT NULL\n" " , not_null_smallint smallint NOT NULL\n" " , not_null_tinyint tinyint NOT NULL\n" "\n" " , nullable_char char(10) NULL\n" " , nullable_varchar varchar(10) NULL\n" "\n" " , nullable_datetime datetime NULL\n" " , nullable_smalldatetime smalldatetime NULL\n" "\n" " , nullable_money money NULL\n" " , nullable_smallmoney smallmoney NULL\n" "\n" " , nullable_float float NULL\n" " , nullable_real real NULL\n" "\n" " , nullable_decimal decimal(5,2) NULL\n" " , nullable_numeric numeric(5,2) NULL\n" "\n" " , nullable_int int NULL\n" " , nullable_smallint smallint NULL\n" " , nullable_tinyint tinyint NULL\n" "\n" " /* Excludes: \n" " * binary\n" " * image\n" " * uniqueidentifier\n" " * varbinary\n" " * text\n" " * timestamp\n" " * nchar\n" " * ntext\n" " * nvarchar\n" " */\n" ")\n" "\n" "INSERT all_types_bcp_unittest \n" "VALUES ( 1 -- not_null_bit\n" "\n" " , 'a char' -- not_null_char\n" " , 'a varchar' -- not_null_varchar\n" "\n" " , 'Dec 17 2003 3:44PM' -- not_null_datetime\n" " , 'Dec 17 2003 3:44PM' -- not_null_smalldatetime\n" "\n" " , 12.34 -- not_null_money\n" " , 12.34 -- not_null_smallmoney\n" "\n" " , 12.34 -- not_null_float\n" " , 12.34 -- not_null_real\n" "\n" " , 12.34 -- not_null_decimal\n" " , 12.34 -- not_null_numeric\n" "\n" " , 1234 -- not_null_int\n" " , 1234 -- not_null_smallint\n" " , 123 -- not_null_tinyint\n" "\n" " , 'a char' -- nullable_char\n" " , 'a varchar' -- nullable_varchar\n" "\n" " , 'Dec 17 2003 3:44PM' -- nullable_datetime\n" " , 'Dec 17 2003 3:44PM' -- nullable_smalldatetime\n" "\n" " , 12.34 -- nullable_money\n" " , 12.34 -- nullable_smallmoney\n" "\n" " , 12.34 -- nullable_float\n" " , 12.34 -- nullable_real\n" "\n" " , 12.34 -- nullable_decimal\n" " , 12.34 -- nullable_numeric\n" "\n" " , 1234 -- nullable_int\n" " , 1234 -- nullable_smallint\n" " , 123 -- nullable_tinyint\n" ")\n" "INSERT all_types_bcp_unittest\n" " ( not_null_bit \n" "\n" " , not_null_char \n" " , not_null_varchar \n" "\n" " , not_null_datetime \n" " , not_null_smalldatetime \n" "\n" " , not_null_money \n" " , not_null_smallmoney \n" "\n" " , not_null_float \n" " , not_null_real \n" "\n" " , not_null_decimal \n" " , not_null_numeric \n" "\n" " , not_null_int \n" " , not_null_smallint \n" " , not_null_tinyint \n" " ) \n" "VALUES (\n" " 1 -- not_null_bit\n" "\n" " , 'a char' -- not_null_char\n" " , 'a varchar' -- not_null_varchar\n" "\n" " , 'Dec 17 2003 3:44PM' -- not_null_datetime\n" " , 'Dec 17 2003 3:44PM' -- not_null_smalldatetime\n" "\n" " , 12.34 -- not_null_money\n" " , 12.34 -- not_null_smallmoney\n" "\n" " , 12.34 -- not_null_float\n" " , 12.34 -- not_null_real\n" "\n" " , 12.34 -- not_null_decimal\n" " , 12.34 -- not_null_numeric\n" "\n" " , 1234 -- not_null_int\n" " , 1234 -- not_null_smallint\n" " , 123 -- not_null_tinyint\n" ")\n"; freetds-1.00.82/src/dblib/unittests/common.c100644 025423 025423 00000024162 12717145107 0014401#include "common.h" #if HAVE_UNISTD_H #include #endif #if HAVE_LIBGEN_H #include #endif /* HAVE_LIBGEN_H */ #if HAVE_SYS_PARAM_H #include #endif /* HAVE_SYS_PARAM_H */ #include #if HAVE_SYS_RESOURCE_H #include #endif /* HAVE_SYS_RESOURCE_H */ #include "replacements.h" #if !defined(PATH_MAX) #define PATH_MAX 256 #endif char USER[512]; char SERVER[512]; char PASSWORD[512]; char DATABASE[512]; static char sql_file[PATH_MAX]; static FILE* input_file = NULL; static char *ARGV0 = NULL; static char *DIRNAME = NULL; static const char *BASENAME = NULL; #if HAVE_MALLOC_OPTIONS extern const char *malloc_options; #endif /* HAVE_MALLOC_OPTIONS */ void set_malloc_options(void) { #if HAVE_MALLOC_OPTIONS /* * Options for malloc * A- all warnings are fatal * J- init memory to 0xD0 * R- always move memory block on a realloc */ malloc_options = "AJR"; #endif /* HAVE_MALLOC_OPTIONS */ } #if defined(__MINGW32__) || defined(_MSC_VER) static char * tds_dirname(char* path) { char *p, *p2; for (p = path + strlen(path); --p > path && (*p == '/' || *p == '\\');) *p = '\0'; p = strrchr(path, '/'); if (!p) p = path; p2 = strrchr(p, '\\'); if (p2) p = p2; if (p == path) { if (*p == '/' || *p == '\\') return "\\"; return "."; } *p = 0; return path; } #define dirname tds_dirname #endif char free_file_registered = 0; static void free_file(void) { if (input_file) { fclose(input_file); input_file = NULL; } if (ARGV0) { DIRNAME = NULL; BASENAME = NULL; free(ARGV0); ARGV0 = NULL; } } int read_login_info(int argc, char **argv) { int len; FILE *in = NULL; #if !defined(__MINGW32__) && !defined(_MSC_VER) int ch; #endif char line[512]; char *s1, *s2; char filename[PATH_MAX]; static const char *PWD = "../../../PWD"; struct { char *username, *password, *servername, *database; char fverbose; } options; #if defined(HAVE_SETRLIMIT) && defined(RLIMIT_STACK) #define MAX_STACK (8*1024*1024) struct rlimit rlim; if (!getrlimit(RLIMIT_STACK, &rlim) && (rlim.rlim_cur == RLIM_INFINITY || rlim.rlim_cur > MAX_STACK)) { rlim.rlim_cur = MAX_STACK; setrlimit(RLIMIT_STACK, &rlim); } #endif setbuf(stdout, NULL); setbuf(stderr, NULL); free(ARGV0); #ifdef __VMS { /* basename expects unix format */ s1 = strrchr(argv[0], ';'); /* trim version; extension trimmed later */ if (s1) *s1 = 0; const char *unixspec = decc$translate_vms(argv[0]); ARGV0 = strdup(unixspec); } #else ARGV0 = strdup(argv[0]); #endif BASENAME = basename(ARGV0); #if defined(_WIN32) || defined(__VMS) s1 = strrchr(BASENAME, '.'); if (s1) *s1 = 0; #endif DIRNAME = dirname(ARGV0); memset(&options, 0, sizeof(options)); #if !defined(__MINGW32__) && !defined(_MSC_VER) /* process command line options (handy for manual testing) */ while ((ch = getopt(argc, (char**)argv, "U:P:S:D:f:v")) != -1) { switch (ch) { case 'U': options.username = strdup(optarg); break; case 'P': options.password = strdup(optarg); break; case 'S': options.servername = strdup(optarg); break; case 'D': options.database = strdup(optarg); break; case 'f': /* override default PWD file */ PWD = strdup(optarg); break; case 'v': options.fverbose = 1; /* doesn't normally do anything */ break; case '?': default: fprintf(stderr, "usage: %s \n" " [-U username] [-P password]\n" " [-S servername] [-D database]\n" " [-i input filename] [-o output filename] " "[-e error filename]\n" , BASENAME); exit(1); } } #endif strcpy(filename, PWD); s1 = getenv("TDSPWDFILE"); if (s1 && s1[0]) in = fopen(s1, "r"); if (!in) in = fopen(filename, "r"); if (!in) in = fopen("PWD", "r"); if (!in) { sprintf(filename, "%s/%s", (DIRNAME) ? DIRNAME : ".", PWD); in = fopen(filename, "r"); if (!in) { fprintf(stderr, "Can not open %s file\n\n", filename); goto Override; } } while (fgets(line, 512, in)) { s1 = strtok(line, "="); s2 = strtok(NULL, "\n"); if (!s1 || !s2) continue; if (!strcmp(s1, "UID")) { strcpy(USER, s2); } else if (!strcmp(s1, "SRV")) { strcpy(SERVER, s2); } else if (!strcmp(s1, "PWD")) { strcpy(PASSWORD, s2); } else if (!strcmp(s1, "DB")) { strcpy(DATABASE, s2); } } fclose(in); Override: /* apply command-line overrides */ if (options.username) { strcpy(USER, options.username); free(options.username); } if (options.password) { strcpy(PASSWORD, options.password); free(options.password); } if (options.servername) { strcpy(SERVER, options.servername); free(options.servername); } if (options.database) { strcpy(DATABASE, options.database); free(options.database); } if (!*SERVER) { fprintf(stderr, "no servername provided, quitting.\n"); exit(1); } printf("found %s.%s for %s in \"%s\"\n", SERVER, DATABASE, USER, filename); #if 0 dbrecftos(BASENAME); #endif len = snprintf(sql_file, sizeof(sql_file), "%s/%s.sql", FREETDS_SRCDIR, BASENAME); assert(len >= 0 && len <= sizeof(sql_file)); if (input_file) fclose(input_file); if ((input_file = fopen(sql_file, "r")) == NULL) { fflush(stdout); fprintf(stderr, "could not open SQL input file \"%s\"\n", sql_file); } if (!free_file_registered) atexit(free_file); free_file_registered = 1; printf("SQL text will be read from %s\n", sql_file); return 0; } /* * Fill the command buffer from a file while echoing it to standard output. */ RETCODE sql_cmd(DBPROCESS *dbproc) { char line[2048], *p = line; int i = 0; RETCODE erc=SUCCEED; if (!input_file) { fprintf(stderr, "%s: error: SQL input file \"%s\" not opened\n", BASENAME, sql_file); exit(1); } while ((p = fgets(line, (int)sizeof(line), input_file)) != NULL && strcasecmp("go\n", p) != 0) { printf("\t%3d: %s", ++i, p); if ((erc = dbcmd(dbproc, p)) != SUCCEED) { fprintf(stderr, "%s: error: could write \"%s\" to dbcmd()\n", BASENAME, p); exit(1); } } if (ferror(input_file)) { fprintf(stderr, "%s: error: could not read SQL input file \"%s\"\n", BASENAME, sql_file); exit(1); } return erc; } RETCODE sql_rewind(void) { if (!input_file) return FAIL; rewind(input_file); return SUCCEED; } RETCODE sql_reopen(const char *fn) { int len = snprintf(sql_file, sizeof(sql_file), "%s/%s.sql", FREETDS_SRCDIR, fn); assert(len >= 0 && len <= sizeof(sql_file)); if (input_file) fclose(input_file); if ((input_file = fopen(sql_file, "r")) == NULL) { fflush(stdout); fprintf(stderr, "could not open SQL input file \"%s\"\n", sql_file); sql_file[0] = 0; return FAIL; } return SUCCEED; } int syb_msg_handler(DBPROCESS * dbproc, DBINT msgno, int msgstate, int severity, char *msgtext, char *srvname, char *procname, int line) { int *pexpected_msgno; /* * Check for "database changed", or "language changed" messages from * the client. If we get one of these, then we need to pull the * name of the database or charset from the message and set the * appropriate variable. */ if (msgno == 5701 || /* database context change */ msgno == 5703 || /* language changed */ msgno == 5704) { /* charset changed */ /* fprintf( stderr, "msgno = %d: %s\n", msgno, msgtext ) ; */ return 0; } /* * If the user data indicates this is an expected error message (because we're testing the * error propogation, say) then indicate this message was anticipated. */ if (dbproc != NULL) { pexpected_msgno = (int *) dbgetuserdata(dbproc); if (pexpected_msgno && *pexpected_msgno == msgno) { fprintf(stdout, "OK: anticipated message arrived: %d %s\n", (int) msgno, msgtext); *pexpected_msgno = 0; return 0; } } /* * If the severity is something other than 0 or the msg number is * 0 (user informational messages). */ fflush(stdout); if (severity >= 0 || msgno == 0) { /* * If the message was something other than informational, and * the severity was greater than 0, then print information to * stderr with a little pre-amble information. */ if (msgno > 0 && severity > 0) { fprintf(stderr, "Msg %d, Level %d, State %d\n", (int) msgno, (int) severity, (int) msgstate); fprintf(stderr, "Server '%s'", srvname); if (procname != NULL && *procname != '\0') fprintf(stderr, ", Procedure '%s'", procname); if (line > 0) fprintf(stderr, ", Line %d", line); fprintf(stderr, "\n"); fprintf(stderr, "%s\n", msgtext); fflush(stderr); } else { /* * Otherwise, it is just an informational (e.g. print) message * from the server, so send it to stdout. */ fprintf(stdout, "%s\n", msgtext); fflush(stdout); severity = 0; } } if (severity) { fprintf(stderr, "exit: no unanticipated messages allowed in unit tests\n"); exit(EXIT_FAILURE); } return 0; } int syb_err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr) { int *pexpected_dberr; /* * For server messages, cancel the query and rely on the * message handler to spew the appropriate error messages out. */ if (dberr == SYBESMSG) return INT_CANCEL; /* * If the user data indicates this is an expected error message (because we're testing the * error propogation, say) then indicate this message was anticipated. */ if (dbproc != NULL) { pexpected_dberr = (int *) dbgetuserdata(dbproc); if (pexpected_dberr && *pexpected_dberr == dberr) { fprintf(stdout, "OK: anticipated error %d (%s) arrived\n", dberr, dberrstr); *pexpected_dberr = 0; return INT_CANCEL; } } fflush(stdout); fprintf(stderr, "DB-LIBRARY error (dberr %d (severity %d): \"%s\"; oserr %d: \"%s\")\n", dberr, severity, dberrstr ? dberrstr : "(null)", oserr, oserrstr ? oserrstr : "(null)"); fflush(stderr); /* * If the dbprocess is dead or the dbproc is a NULL pointer and * we are not in the middle of logging in, then we need to exit. * We can't do anything from here on out anyway. * It's OK to end up here in response to a dbconvert() that * resulted in overflow, so don't exit in that case. */ if ((dbproc == NULL) || DBDEAD(dbproc)) { if (dberr != SYBECOFL) { exit(255); } } if (severity) { fprintf(stderr, "error: no unanticipated errors allowed in unit tests\n"); exit(EXIT_FAILURE); } return INT_CANCEL; } freetds-1.00.82/src/dblib/unittests/common.h100644 025423 025423 00000004324 12717145107 0014404 #ifndef COMMON_h #define COMMON_h #undef NDEBUG #include #include #include #include #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #ifdef DBNTWIN32 #include /* fix MingW missing declare */ #ifndef _WINDOWS_ #define _WINDOWS_ 1 #endif #endif #include #include #include #if !defined(EXIT_FAILURE) #define EXIT_FAILURE 1 #define EXIT_SUCCESS 0 #endif #define FREETDS_SRCDIR FREETDS_TOPDIR "/src/dblib/unittests" #if defined(HAVE__SNPRINTF) && !defined(HAVE_SNPRINTF) #define snprintf _snprintf #endif #ifdef DBNTWIN32 /* * Define Sybase's symbols in terms of Microsoft's. * This allows these tests to be run using Microsoft's include * files and library (libsybdb.lib). */ #define MSDBLIB 1 #define MICROSOFT_DBLIB 1 #define dbloginfree(l) dbfreelogin(l) #define SYBESMSG SQLESMSG #define SYBECOFL SQLECOFL #define SYBAOPSUM SQLAOPSUM #define SYBAOPMAX SQLAOPMAX #define SYBINT4 SQLINT4 #define SYBDATETIME SQLDATETIME #define SYBCHAR SQLCHAR #define SYBVARCHAR SQLVARCHAR #define SYBTEXT SQLTEXT #define SYBBINARY SQLBINARY #define SYBIMAGE SQLIMAGE #define SYBDECIMAL SQLDECIMAL #define dberrhandle(h) dberrhandle((DBERRHANDLE_PROC) h) #define dbmsghandle(h) dbmsghandle((DBMSGHANDLE_PROC) h) #endif /* cf getopt(3) */ extern char *optarg; extern int optind; extern int optopt; extern int opterr; extern int optreset; extern char PASSWORD[512]; extern char USER[512]; extern char SERVER[512]; extern char DATABASE[512]; void set_malloc_options(void); int read_login_info(int argc, char **argv); int syb_msg_handler(DBPROCESS * dbproc, DBINT msgno, int msgstate, int severity, char *msgtext, char *srvname, char *procname, int line); int syb_err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr); RETCODE sql_cmd(DBPROCESS *dbproc); RETCODE sql_rewind(void); RETCODE sql_reopen(const char *fn); #define int2ptr(i) ((void*)(((char*)0)+(i))) #define ptr2int(p) ((int)(((char*)(p))-((char*)0))) #endif freetds-1.00.82/src/dblib/unittests/bcp_getl.c100644 025423 025423 00000000170 13111516422 0014650 #include "common.h" int main(void) { LOGINREC *c = dblogin(); BCP_SETL(c, TRUE); assert(bcp_getl(c)); return 0; } freetds-1.00.82/src/dblib/unittests/cancel.c100644 025423 025423 00000003437 12620060220 0014321/* * Purpose: Test we can cancel a query inside message handler * Some server some additional tokens which can prevent second query to work * correctly. */ #include "common.h" static int cancel_msg_handler(DBPROCESS * dbproc, DBINT msgno, int msgstate, int severity, char *msgtext, char *srvname, char *procname, int line) { dbcancel(dbproc); return 0; } int main(int argc, char **argv) { LOGINREC *login; DBPROCESS *dbproc; int i; DBINT testint = -1; read_login_info(argc, argv); printf("Starting %s\n", argv[0]); dbinit(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); printf("About to logon\n"); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "cancel"); printf("About to open\n"); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); dbloginfree(login); /* first query, select with error */ dbmsghandle(cancel_msg_handler); sql_cmd(dbproc); dbsqlexec(dbproc); dbmsghandle(syb_msg_handler); /* second query, select */ printf("second select\n"); if (SUCCEED != sql_cmd(dbproc) || SUCCEED != dbsqlexec(dbproc)) { fprintf(stderr, "%s:%d: dbcmd failed\n", __FILE__, __LINE__); exit(1); } if (dbresults(dbproc) != SUCCEED) { fprintf(stderr, "Was expecting a result set."); exit(1); } for (i = 1; i <= dbnumcols(dbproc); i++) printf("col %d is %s\n", i, dbcolname(dbproc, i)); dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint); if (REG_ROW != dbnextrow(dbproc)) { fprintf(stderr, "Failed. Expected a row\n"); exit(1); } if (testint != 1) { fprintf(stderr, "Failed. Expected i to be %d, was %d\n", i, (int) testint); exit(1); } if (dbnextrow(dbproc) != NO_MORE_ROWS) { fprintf(stderr, "No other rows expected\n"); } dbexit(); printf("ok\n"); return 0; } freetds-1.00.82/src/dblib/unittests/dbmorecmds.c100644 025423 025423 00000004436 12717145107 0015232/* * Purpose: Test behaviour of dbmorecmds() * Functions: dbmorecmds */ #include "common.h" int failed = 0; int main(int argc, char **argv) { const int rows_to_add = 10; LOGINREC *login; DBPROCESS *dbproc; int i, nresults; set_malloc_options(); read_login_info(argc, argv); fprintf(stdout, "Starting %s\n", argv[0]); /* Fortify_EnterScope(); */ dbinit(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); login = dblogin(); fprintf(stdout, "after dblogin\n"); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "t0024"); fprintf(stdout, "About to open [%s]\n", USER); dbproc = dbopen(login, SERVER); fprintf(stdout, "After dbopen [%s]\n", SERVER); if (strlen(DATABASE)) { fprintf(stdout, "About to dbuse [%s]\n", DATABASE); dbuse(dbproc, DATABASE); } dbloginfree(login); fprintf(stdout, "After dbuse [%s]\n", DATABASE); fprintf(stdout, "creating table\n"); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } fprintf(stdout, "insert\n"); for (i = 0; i < rows_to_add; i++) { sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } } fprintf(stdout, "select one resultset\n"); sql_cmd(dbproc); dbsqlexec(dbproc); nresults = 0; if (dbresults(dbproc) == SUCCEED) { do { while (dbnextrow(dbproc) != NO_MORE_ROWS) continue; nresults++; } while (dbmorecmds(dbproc) == SUCCEED); } /* dbmorecmds should return success 0 times for select 1 */ if (nresults != 1) { failed = 1; fprintf(stdout, "Was expecting nresults == 1.\n"); exit(1); } dbcancel(dbproc); fprintf(stdout, "select two resultsets\n"); sql_cmd(dbproc); dbsqlexec(dbproc); nresults = 0; do { if (dbresults(dbproc) == SUCCEED) { while (dbnextrow(dbproc) != NO_MORE_ROWS) continue; nresults++; } } while (dbmorecmds(dbproc) == SUCCEED); /* dbmorecmds should return success 2 times for select 2 */ if (nresults != 2) { /* two results sets plus a return code */ failed = 1; fprintf(stdout, "nresults was %d; was expecting nresults = 2.\n", nresults); exit(1); } /* end of test processing */ dbexit(); fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); return failed ? 1 : 0; } freetds-1.00.82/src/dblib/unittests/done_handling.c100644 025423 025423 00000014021 12522201763 0015666#include "common.h" static char software_version[] = "$Id: done_handling.c,v 1.11 2010-09-22 07:03:59 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; /* * This test try do discovery how dblib process token looking for state * at every iteration. It issue a query to server and check * - row count (valid number means DONE processed) * - if possible to send another query (means state IDLE) * - if error readed (means ERROR token readed) * - if status present (PARAMRESULT token readed) * - if parameter present (PARAM token readed) * It try these query types: * - normal row * - normal row with no count * - normal row without rows * - error query * - store procedure call with output parameters */ /* Forward declarations of the error handler and message handler. */ static int err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr); static int msg_handler(DBPROCESS * dbproc, DBINT msgno, int msgstate, int severity, char *msgtext, char *srvname, char *procname, int line); static DBPROCESS *dbproc; static int silent = 0; static int check_idle = 0; /* print functions adapted from src/dblib/dblib.c */ static const char * prdbretcode(int retcode) { static char unknown[24]; switch(retcode) { case REG_ROW: return "REG_ROW/MORE_ROWS"; case NO_MORE_ROWS: return "NO_MORE_ROWS"; case BUF_FULL: return "BUF_FULL"; case NO_MORE_RESULTS: return "NO_MORE_RESULTS"; case SUCCEED: return "SUCCEED"; case FAIL: return "FAIL"; default: sprintf(unknown, "oops: %u ??", retcode); } return unknown; } static const char * prretcode(int retcode) { static char unknown[24]; switch(retcode) { case SUCCEED: return "SUCCEED"; case FAIL: return "FAIL"; case NO_MORE_RESULTS: return "NO_MORE_RESULTS"; default: sprintf(unknown, "oops: %u ??", retcode); } return unknown; } static void query(const char comment[]) { if (comment) printf("%s\n", comment); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) == SUCCEED) { /* nop */ } } typedef const char* (*prfunc)(int); static void check_state(const char name[], prfunc print, int erc) { printf("State %-15s %-20s ", name, print(erc)); if (dbnumcols(dbproc) > 0) printf("COLS(%d) ", dbnumcols(dbproc)); /* row count */ if (dbcount(dbproc) >= 0) printf("ROWS(%d) ", (int) dbcount(dbproc)); silent = 1; if (dbdata(dbproc, 1)) printf("DATA "); silent = 0; /* if status present */ if (dbretstatus(dbproc) == TRUE) printf("STATUS %d ", (int) dbretstatus(dbproc)); /* if parameter present */ if (dbnumrets(dbproc) > 0) printf("PARAMS "); /* * if possible to send another query * NOTE this must be the last */ if (check_idle) { silent = 1; dbcmd(dbproc, "declare @i int "); if (FAIL != dbsqlexec(dbproc)) printf("IDLE "); silent = 0; } printf("\n"); } static void do_test(const char comment[]) { int ret; prfunc print_with = NULL; if (comment) printf("%s\n", comment); sql_cmd(dbproc); check_state("sqlexec ", prretcode, dbsqlexec(dbproc)); check_state("nextrow ", prdbretcode, dbnextrow(dbproc)); check_state("nextrow ", prdbretcode, dbnextrow(dbproc)); check_state("results ", prretcode, dbresults(dbproc)); check_state("nextrow ", prdbretcode, dbnextrow(dbproc)); check_state("nextrow ", prdbretcode, dbnextrow(dbproc)); check_idle = 0; for (;;) { ret = dbresults(dbproc); check_state("results ", prretcode, ret); if (ret != SUCCEED) { print_with = prretcode; break; } do { ret = dbnextrow(dbproc); check_state("nextrow ", prdbretcode, ret); } while (ret == REG_ROW); print_with = prdbretcode; } check_state("more results?", print_with, ret); } int main(int argc, char *argv[]) { const static int invalid_column_name = 207; LOGINREC *login; /* Our login information. */ int i; setbuf(stdout, NULL); read_login_info(argc, argv); if (dbinit() == FAIL) exit(1); dberrhandle(err_handler); dbmsghandle(msg_handler); #if 0 /* * FIXME: Should be able to use the common err/msg handlers, but something about * the IDLE checking causes them to fail. Not sure about purpose of IDLE checking. * -- jkl January 2009 */ dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); #endif login = dblogin(); DBSETLUSER(login, USER); DBSETLPWD(login, PASSWORD); DBSETLAPP(login, __FILE__); dbproc = dbopen(login, SERVER); dbloginfree(login); if (!dbproc) exit(1); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); for (i=0; i < 6; i++) query(NULL); #if 0 check_state("setup done ", prretcode, erc); printf("wasting results\n"); while ((erc = dbresults(dbproc)) == SUCCEED) { while (dbnextrow(dbproc) == REG_ROW); /* no-op */ } #endif check_idle = 1; do_test("normal row with rowcount on"); query("turn rowcount off"); do_test("normal row with rowcount off"); query("turn rowcount back on"); do_test("normal row without rows"); dbsetuserdata(dbproc, (BYTE*) &invalid_column_name); do_test("error query"); do_test("stored procedure call with output parameters"); do_test("execute done2"); query("drop done_test"); query("drop done_test2"); dbexit(); return 0; } static int err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr) { if (silent) return INT_CANCEL; fflush(stdout); fprintf(stderr, "DB-Library error (severity %d):\n\t%s\n", severity, dberrstr); if (oserr != DBNOERR) fprintf(stderr, "Operating-system error:\n\t%s\n", oserrstr ? oserrstr : "(null)"); fflush(stderr); return INT_CANCEL; } static int msg_handler(DBPROCESS * dbproc, DBINT msgno, int msgstate, int severity, char *msgtext, char *srvname, char *procname, int line) { if (silent) return 0; fflush(stdout); fprintf(stderr, "Msg %d, Level %d, State %d\n", (int) msgno, severity, msgstate); if (strlen(srvname) > 0) fprintf(stderr, "Server '%s', ", srvname); if (procname && strlen(procname) > 0) { fprintf(stderr, "Procedure '%s', ", procname); if (line > 0) fprintf(stderr, "Line %d", line); } fprintf(stderr, "\n\t%s\n", msgtext); fflush(stderr); return 0; } freetds-1.00.82/src/dblib/unittests/hang.c100644 025423 025423 00000005457 12717145107 0014034/* * Purpose: Test for dbsqlexec on closed connection */ #include "common.h" #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #include #if HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #if HAVE_SYS_STAT_H #include #endif /* HAVE_SYS_STAT_H */ #if HAVE_SYS_IOCTL_H #include #endif /* HAVE_SYS_IOCTL_H */ #if HAVE_SYS_WAIT_H #include #endif /* HAVE_SYS_WAIT_H */ #if HAVE_NETINET_IN_H #include #endif /* HAVE_NET_INET_IN_H */ #include char *UNITTEST; #if HAVE_FSTAT && defined(S_IFSOCK) static int end_socket = -1; static int shutdown_socket(DBPROCESS *dbproc) { union { struct sockaddr sa; char data[256]; } u; SOCKLEN_T addrlen; struct stat file_stat; TDS_SYS_SOCKET sockets[2]; TDS_SYS_SOCKET socket = DBIOWDESC(dbproc); if (fstat(socket, &file_stat)) return 0; if ((file_stat.st_mode & S_IFSOCK) != S_IFSOCK) return 0; addrlen = sizeof(u); if (tds_getsockname(socket, &u.sa, &addrlen) < 0 || (u.sa.sa_family != AF_INET && u.sa.sa_family != AF_INET6)) return 0; /* replace socket with a new one */ if (socketpair(AF_UNIX, SOCK_STREAM, 0, sockets) < 0) return 0; /* substitute socket */ close(socket); dup2(sockets[0], socket); /* close connection */ close(sockets[0]); end_socket = sockets[1]; return 1; } static int test(int close_socket) { LOGINREC *login; DBPROCESS *dbproc; RETCODE ret; int expected_error = -1; printf("Starting %s\n", UNITTEST); dbinit(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); printf("About to logon\n"); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "t0020"); printf("About to open\n"); dbproc = dbopen(login, SERVER); dbsetuserdata(dbproc, (BYTE*) &expected_error); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); dbloginfree(login); dbcmd(dbproc, "select * from sysobjects"); printf("dbsqlexec should not hang.\n"); ret = dbsettime(15); if (ret != SUCCEED) { fprintf(stderr, "Failed. Error setting timeout.\n"); return 1; } if (!shutdown_socket(dbproc)) { fprintf(stderr, "Error shutting down connection\n"); return 1; } if (close_socket) close(end_socket); alarm(20); expected_error = close_socket ? 20006 : 20003; ret = dbsqlexec(dbproc); alarm(0); if (ret != FAIL) { fprintf(stderr, "Failed. Expected FAIL to be returned.\n"); return 1; } dbsetuserdata(dbproc, NULL); if (!close_socket) close(end_socket); dbexit(); printf("dblib okay on %s\n", __FILE__); return 0; } int main(int argc, char **argv) { UNITTEST = argv[0]; read_login_info(argc, argv); if (test(0) || test(1)) return 1; return 0; } #else int main(void) { fprintf(stderr, "Not possible for this platform.\n"); return 0; } #endif freetds-1.00.82/src/dblib/unittests/null.c100644 025423 025423 00000007745 12522201763 0014066/* * Purpose: Test NULL behavior in order to fix problems with PHP and NULLs * PHP use dbdata to get data */ #include "common.h" #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ static char software_version[] = "$Id: null.c,v 1.9 2010-10-26 08:12:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #ifndef DBNTWIN32 static DBPROCESS *dbproc = NULL; static int failed = 0; static int ignore_msg_handler(DBPROCESS * dbproc, DBINT msgno, int state, int severity, char *text, char *server, char *proc, int line) { return 0; } static int ignore_err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr) { return INT_CANCEL; } static void query(const char *query) { printf("query: %s\n", query); dbcmd(dbproc, (char *) query); dbsqlexec(dbproc); while (dbresults(dbproc) == SUCCEED) { /* nop */ } } static void test0(int n, int expected) { static const char sql[] = "select c from #null where n = %d"; fprintf(stdout, sql, n); fprintf(stdout, " ... "); dbfcmd(dbproc, sql, n); dbsqlexec(dbproc); if (dbresults(dbproc) != SUCCEED || dbnextrow(dbproc) != REG_ROW) { fprintf(stdout, "\nExpected a row.\n"); failed = 1; dbcancel(dbproc); return; } fprintf(stdout, "got %p and length %d\n", dbdata(dbproc, 1), dbdatlen(dbproc, 1)); if (dbdatlen(dbproc, 1) != (expected < 0? 0 : expected)) { fprintf(stderr, "Error: n=%d: dbdatlen returned %d, expected %d\n", n, dbdatlen(dbproc, 1), expected < 0? 0 : expected); dbcancel(dbproc); failed = 1; } if (dbdata(dbproc, 1) != NULL && expected < 0) { fprintf(stderr, "Error: n=%d: dbdata returned %p, expected NULL and length %d\n", n, dbdata(dbproc, 1), expected); dbcancel(dbproc); failed = 1; } if (dbdata(dbproc, 1) == NULL && expected > 0) { fprintf(stderr, "Error: n=%d: dbdata returned %p, expected non-NULL and length %d\n", n, dbdata(dbproc, 1), expected); dbcancel(dbproc); failed = 1; } if (dbnextrow(dbproc) != NO_MORE_ROWS) { fprintf(stderr, "Error: Only one row expected (cancelling remaining results)\n"); dbcancel(dbproc); failed = 1; } while (dbresults(dbproc) == SUCCEED) { /* nop */ } } static void test(const char *type, int give_err) { RETCODE ret; query("if object_id('#null') is not NULL drop table #null"); dberrhandle(ignore_err_handler); dbmsghandle(ignore_msg_handler); printf("create table #null (n int, c %s NULL)\n", type); dbfcmd(dbproc, "create table #null (n int, c %s NULL)", type); dbsqlexec(dbproc); ret = dbresults(dbproc); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); if (ret != SUCCEED) { dbcancel(dbproc); if (!give_err) return; fprintf(stdout, "Was expecting a result set.\n"); failed = 1; return; } query("insert into #null values(1, '')"); query("insert into #null values(2, NULL)"); query("insert into #null values(3, ' ')"); query("insert into #null values(4, 'a')"); test0(1, DBTDS_5_0 < DBTDS(dbproc)? 0 : 1); test0(2, DBTDS_5_0 < DBTDS(dbproc)? -1 : 0); test0(3, 1); test0(4, 1); query("drop table #null"); } int main(int argc, char **argv) { LOGINREC *login; read_login_info(argc, argv); fprintf(stdout, "Starting %s\n", argv[0]); dbinit(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "thread"); fprintf(stdout, "About to open \"%s\"\n", SERVER); dbproc = dbopen(login, SERVER); if (!dbproc) { fprintf(stderr, "Unable to connect to %s\n", SERVER); return 1; } dbloginfree(login); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); test("VARCHAR(10)", 1); test("TEXT", 1); test("NVARCHAR(10)", 0); if (DBTDS_5_0 < DBTDS(dbproc)) { test("NTEXT", 0); test("VARCHAR(MAX)", 0); test("NVARCHAR(MAX)", 0); } dbexit(); return failed ? 1 : 0; } #else int main(void) { fprintf(stderr, "Not supported by MS DBLib\n"); return 0; } #endif freetds-1.00.82/src/dblib/unittests/null2.c100644 025423 025423 00000007375 12717145107 0014154/* * Purpose: Test NULL behavior using dbbind */ #include "common.h" #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ static DBPROCESS *dbproc = NULL; static int failed = 0; static int ignore_msg_handler(DBPROCESS * dbproc, DBINT msgno, int state, int severity, char *text, char *server, char *proc, int line) { return 0; } static int ignore_err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr) { return INT_CANCEL; } static void query(const char *query) { printf("query: %s\n", query); dbcmd(dbproc, (char *) query); dbsqlexec(dbproc); while (dbresults(dbproc) == SUCCEED) { /* nop */ } } static int use_nullbind = 0; static void test0(int n, const char * expected) { DBINT ind, expected_ind; char text_buf[16]; dbfcmd(dbproc, "select c from #null where n = %d", n); dbsqlexec(dbproc); if (dbresults(dbproc) != SUCCEED) { fprintf(stderr, "Was expecting a row.\n"); failed = 1; dbcancel(dbproc); return; } dbbind(dbproc, 1, NTBSTRINGBIND, 0, (BYTE *)text_buf); if (use_nullbind) dbnullbind(dbproc, 1, &ind); memset(text_buf, 'a', sizeof(text_buf)); ind = -5; if (dbnextrow(dbproc) != REG_ROW) { fprintf(stderr, "Was expecting a row.\n"); failed = 1; dbcancel(dbproc); return; } text_buf[sizeof(text_buf) - 1] = 0; printf("ind %d text_buf -%s-\n", (int) ind, text_buf); expected_ind = 0; if (strcmp(expected, "aaaaaaaaaaaaaaa") == 0) expected_ind = -1; /* do not check indicator if not bound */ if (!use_nullbind) ind = expected_ind; if (ind != expected_ind || strcmp(expected, text_buf) != 0) { fprintf(stderr, "expected_ind %d expected -%s-\n", (int) expected_ind, expected); failed = 1; dbcancel(dbproc); return; } if (dbnextrow(dbproc) != NO_MORE_ROWS) { fprintf(stderr, "Only one row expected\n"); dbcancel(dbproc); failed = 1; } while (dbresults(dbproc) == SUCCEED) { /* nop */ } } static void test(const char *type, int give_err) { RETCODE ret; query("if object_id('#null') is not NULL drop table #null"); dberrhandle(ignore_err_handler); dbmsghandle(ignore_msg_handler); printf("create table #null (n int, c %s NULL)\n", type); dbfcmd(dbproc, "create table #null (n int, c %s NULL)", type); dbsqlexec(dbproc); ret = dbresults(dbproc); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); if (ret != SUCCEED) { dbcancel(dbproc); if (!give_err) return; fprintf(stdout, "Was expecting a result set.\n"); failed = 1; return; } query("insert into #null values(1, '')"); query("insert into #null values(2, NULL)"); query("insert into #null values(3, ' ')"); query("insert into #null values(4, 'foo')"); use_nullbind = 1; test0(1, ""); test0(2, "aaaaaaaaaaaaaaa"); test0(3, ""); test0(4, "foo"); use_nullbind = 0; test0(1, ""); test0(2, ""); test0(3, ""); test0(4, "foo"); query("drop table #null"); } int main(int argc, char **argv) { LOGINREC *login; read_login_info(argc, argv); fprintf(stdout, "Starting %s\n", argv[0]); dbinit(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "thread"); fprintf(stdout, "About to open \"%s\"\n", SERVER); dbproc = dbopen(login, SERVER); if (!dbproc) { fprintf(stderr, "Unable to connect to %s\n", SERVER); return 1; } dbloginfree(login); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); test("VARCHAR(10)", 1); test("CHAR(10)", 1); test("TEXT", 1); test("NVARCHAR(10)", 0); #ifndef DBNTWIN32 if (dbtds(dbproc) >= DBTDS_7_0) test("NTEXT", 0); #endif test("VARCHAR(MAX)", 0); #ifndef DBNTWIN32 if (dbtds(dbproc) >= DBTDS_7_0) test("NVARCHAR(MAX)", 0); #endif dbexit(); return failed ? 1 : 0; } freetds-1.00.82/src/dblib/unittests/numeric.c100644 025423 025423 00000013176 12717145107 0014556#define MSDBLIB 1 #include "common.h" static void dump_addr(FILE *out, const char *msg, const void *p, size_t len) { size_t n; if (msg) fprintf(out, "%s", msg); for (n = 0; n < len; ++n) fprintf(out, " %02X", ((unsigned char*) p)[n]); fprintf(out, "\n"); } static void chk(RETCODE ret, const char *msg) { printf("%s: res %d\n", msg, ret); if (ret == SUCCEED) return; fprintf(stderr, "error: %s\n", msg); exit(1); } static void zero_end(DBNUMERIC *num) { /* 27213 == math.floor(math.log(10,256)*65536) */ unsigned len = 4u+num->precision*27213u/65536u; if (num->precision < 1 || num->precision > 77) return; assert(len >= 4 && len <= sizeof(*num)); memset(((char*) num) + len, 0, sizeof(*num) - len); } static int msdblib; static void test(int bind_type, const char *bind_name, int override_prec, int override_scale, int out_prec, int out_scale, int line) { LOGINREC *login; DBPROCESS *dbproc; DBNUMERIC *num = NULL, *num2 = NULL; RETCODE ret; DBTYPEINFO ti; int i; printf("*** Starting test msdblib %d bind %s prec %d scale %d out prec %d out scale %d line %d\n", msdblib, bind_name, override_prec, override_scale, out_prec, out_scale, line); chk(sql_rewind(), "sql_rewind"); login = dblogin(); DBSETLUSER(login, USER); DBSETLPWD(login, PASSWORD); DBSETLAPP(login, "numeric"); dbsetmaxprocs(25); DBSETLHOST(login, SERVER); dbproc = tdsdbopen(login, SERVER, msdblib); dbloginfree(login); login = NULL; if (strlen(DATABASE)) dbuse(dbproc, DATABASE); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } if (DBTDS_5_0 < DBTDS(dbproc)) { ret = dbcmd(dbproc, "SET ARITHABORT ON;" "SET CONCAT_NULL_YIELDS_NULL ON;" "SET ANSI_NULLS ON;" "SET ANSI_NULL_DFLT_ON ON;" "SET ANSI_PADDING ON;" "SET ANSI_WARNINGS ON;" "SET ANSI_NULL_DFLT_ON ON;" "SET CURSOR_CLOSE_ON_COMMIT ON;" "SET QUOTED_IDENTIFIER ON"); chk(ret, "dbcmd"); ret = dbsqlexec(dbproc); chk(ret, "dbsqlexec"); ret = dbcancel(dbproc); chk(ret, "dbcancel"); } ret = dbrpcinit(dbproc, "testDecimal", 0); chk(ret, "dbrpcinit"); num = (DBDECIMAL *) calloc(1, sizeof(DBDECIMAL)); ti.scale = 5; ti.precision = 16; ret = dbconvert_ps(dbproc, SYBVARCHAR, (const BYTE *) "123.45", -1, SYBDECIMAL, (BYTE *) num, sizeof(*num), &ti); chk(ret > 0, "dbconvert_ps"); ret = dbrpcparam(dbproc, "@idecimal", 0, SYBDECIMAL, -1, sizeof(DBDECIMAL), (BYTE *) num); chk(ret, "dbrpcparam"); ret = dbrpcsend(dbproc); chk(ret, "dbrpcsend"); ret = dbsqlok(dbproc); chk(ret, "dbsqlok"); /* TODO check MS/Sybase format */ num2 = (DBDECIMAL *) calloc(1, sizeof(DBDECIMAL)); ti.precision = override_prec; ti.scale = override_scale; ret = dbconvert_ps(dbproc, SYBVARCHAR, (const BYTE *) "246.9", -1, SYBDECIMAL, (BYTE *) num2, sizeof(*num2), &ti); chk(ret > 0, "dbconvert_ps"); for (i=0; (ret = dbresults(dbproc)) != NO_MORE_RESULTS; ++i) { RETCODE row_code; switch (ret) { case SUCCEED: if (DBROWS(dbproc) == FAIL) continue; assert(DBROWS(dbproc) == SUCCEED); printf("dbrows() returned SUCCEED, processing rows\n"); memset(num, 0, sizeof(*num)); num->precision = out_prec ? out_prec : num2->precision; num->scale = out_scale ? out_scale : num2->scale; dbbind(dbproc, 1, bind_type, 0, (BYTE *) num); while ((row_code = dbnextrow(dbproc)) != NO_MORE_ROWS) { if (row_code == REG_ROW) { zero_end(num); zero_end(num2); if (memcmp(num, num2, sizeof(*num)) != 0) { fprintf(stderr, "Failed. Output results does not match\n"); dump_addr(stderr, "got: ", num, sizeof(*num)); dump_addr(stderr, "expected: ", num2, sizeof(*num2)); exit(1); } } else { /* not supporting computed rows in this unit test */ fprintf(stderr, "Failed. Expected a row\n"); exit(1); } } break; case FAIL: fprintf(stderr, "dbresults returned FAIL\n"); exit(1); default: fprintf(stderr, "unexpected return code %d from dbresults\n", ret); exit(1); } } /* while dbresults */ sql_cmd(dbproc); free(num2); free(num); dbclose(dbproc); } #define test(a,b,c,d,e) test(a, #a, b, c, d, e, __LINE__) int main(int argc, char **argv) { read_login_info(argc, argv); dbsetversion(DBVERSION_100); dbinit(); /* tests with MS behaviour */ msdblib = 1; test(DECIMALBIND, 20, 10, 0, 0); test(NUMERICBIND, 20, 10, 0, 0); test(SRCDECIMALBIND, 20, 10, 0, 0); test(SRCNUMERICBIND, 20, 10, 0, 0); /* in these 2 case MS override what server returns */ test(DECIMALBIND, 10, 4, 10, 4); test(NUMERICBIND, 10, 4, 10, 4); test(SRCDECIMALBIND, 20, 10, 10, 4); test(SRCNUMERICBIND, 20, 10, 10, 4); /* tests with Sybase behaviour */ msdblib = 0; test(DECIMALBIND, 20, 10, 0, 0); test(NUMERICBIND, 20, 10, 0, 0); test(SRCDECIMALBIND, 20, 10, 0, 0); test(SRCNUMERICBIND, 20, 10, 0, 0); /* no matter what Sybase return always according to source */ test(DECIMALBIND, 20, 10, 10, 4); test(NUMERICBIND, 20, 10, 10, 4); test(SRCDECIMALBIND, 20, 10, 10, 4); test(SRCNUMERICBIND, 20, 10, 10, 4); chk(sql_reopen("numeric_2"), "sql_reopen"); msdblib = 1; /* on MS use always output */ test(DECIMALBIND, 20, 0, 20, 0); test(NUMERICBIND, 19, 0, 19, 0); test(SRCDECIMALBIND, 18, 0, 18, 0); test(SRCNUMERICBIND, 17, 0, 17, 0); msdblib = 0; test(DECIMALBIND, 18, 0, 20, 0); test(NUMERICBIND, 18, 0, 19, 0); /* this is MS only and behave like MS */ test(SRCDECIMALBIND, 18, 0, 18, 0); test(SRCNUMERICBIND, 17, 0, 17, 0); dbexit(); printf("Succeed\n"); return 0; } freetds-1.00.82/src/dblib/unittests/pending.c100644 025423 025423 00000003374 12522201763 0014532/* * Purpose: Test we can send another query after beginning transaction * Some server some additional tokens which can prevent second query to work * correctly. */ #include "common.h" int main(int argc, char **argv) { LOGINREC *login; DBPROCESS *dbproc; int i; DBINT testint = -1; read_login_info(argc, argv); printf("Starting %s\n", argv[0]); dbinit(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); printf("About to logon\n"); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "pending"); printf("About to open\n"); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); dbloginfree(login); /* first query, start transactions */ sql_cmd(dbproc); dbsqlexec(dbproc); /* second query, select */ printf("second select\n"); if (SUCCEED != sql_cmd(dbproc) || SUCCEED != dbsqlexec(dbproc)) { fprintf(stderr, "%s:%d: dbcmd failed\n", __FILE__, __LINE__); exit(1); } if (dbresults(dbproc) != SUCCEED) { fprintf(stderr, "Was expecting a result set."); exit(1); } for (i = 1; i <= dbnumcols(dbproc); i++) printf("col %d is %s\n", i, dbcolname(dbproc, i)); dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint); if (REG_ROW != dbnextrow(dbproc)) { fprintf(stderr, "Failed. Expected a row\n"); exit(1); } if (testint != 634) { fprintf(stderr, "Failed. Expected i to be %d, was %d\n", i, (int) testint); exit(1); } if (dbnextrow(dbproc) != NO_MORE_ROWS) { fprintf(stderr, "No other rows expected\n"); } /* third query, commit */ if (SUCCEED != sql_cmd(dbproc)) { fprintf(stderr, "%s:%d: dbcmd failed\n", __FILE__, __LINE__); exit(1); } while (dbresults(dbproc) != NO_MORE_RESULTS) continue; dbexit(); printf("ok\n"); return 0; } freetds-1.00.82/src/dblib/unittests/rpc.c100644 025423 025423 00000031730 12522201763 0013667/* * Purpose: Test remote procedure calls * Functions: dbretdata dbretlen dbretname dbretstatus dbrettype dbrpcinit dbrpcparam dbrpcsend */ #include "common.h" static RETCODE init_proc(DBPROCESS * dbproc, const char *name); int ignore_err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr); int ignore_msg_handler(DBPROCESS * dbproc, DBINT msgno, int state, int severity, char *text, char *server, char *proc, int line); typedef struct { char *name, *value; int type, len; } RETPARAM; static RETPARAM* save_retparam(RETPARAM *param, char *name, char *value, int type, int len); static RETCODE init_proc(DBPROCESS * dbproc, const char *name) { RETCODE ret = FAIL; if (name[0] != '#') { fprintf(stdout, "Dropping procedure %s\n", name); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } } fprintf(stdout, "Creating procedure %s\n", name); sql_cmd(dbproc); if ((ret = dbsqlexec(dbproc)) == FAIL) { if (name[0] == '#') fprintf(stdout, "Failed to create procedure %s. Wrong permission or not MSSQL.\n", name); else fprintf(stdout, "Failed to create procedure %s. Wrong permission.\n", name); } while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } return ret; } static RETPARAM* save_retparam(RETPARAM *param, char *name, char *value, int type, int len) { free(param->name); free(param->value); param->name = strdup(name); param->value = strdup(value); param->type = type; param->len = len; return param; } static void free_retparam(RETPARAM *param) { free(param->name); free(param->value); param->name = param->value = NULL; } int ignore_msg_handler(DBPROCESS * dbproc, DBINT msgno, int state, int severity, char *text, char *server, char *proc, int line) { int ret; dbsetuserdata(dbproc, (BYTE*) &msgno); /* printf("(ignoring message %d)\n", msgno); */ ret = syb_msg_handler(dbproc, msgno, state, severity, text, server, proc, line); dbsetuserdata(dbproc, NULL); return ret; } /* * The bad procedure name message has severity 15, causing db-lib to call the error handler after calling the message handler. * This wrapper anticipates that behavior, and again sets the userdata, telling the handler this error is expected. */ int ignore_err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr) { int erc; static int recursion_depth = 0; if (dbproc == NULL) { printf("expected error %d: \"%s\"\n", dberr, dberrstr? dberrstr : ""); return INT_CANCEL; } if (recursion_depth++) { printf("error %d: \"%s\"\n", dberr, dberrstr? dberrstr : ""); printf("logic error: recursive call to ignore_err_handler\n"); exit(1); } dbsetuserdata(dbproc, (BYTE*) &dberr); /* printf("(ignoring error %d)\n", dberr); */ erc = syb_err_handler(dbproc, severity, dberr, oserr, dberrstr, oserrstr); dbsetuserdata(dbproc, NULL); recursion_depth--; return erc; } static int colwidth( DBPROCESS * dbproc, int icol ) { int width = dbwillconvert(dbcoltype(dbproc, icol), SYBCHAR); return 255 == width? dbcollen(dbproc, icol) : width; } char param_data1[64], param_data3[8000+1], param_data4[2 * 4000 + 1]; int param_data2, param_data5; struct parameters_t { char *name; BYTE status; int type; DBINT maxlen; DBINT datalen; BYTE *value; } bindings[] = { { "@null_input", DBRPCRETURN, SYBCHAR, -1, 0, NULL } , { "@first_type", DBRPCRETURN, SYBCHAR, sizeof(param_data1), 0, (BYTE *) ¶m_data1 } , { "@nullout", DBRPCRETURN, SYBINT4, -1, 0, (BYTE *) ¶m_data2 } , { "@varchar_tds7_out", DBRPCRETURN, SYBVARCHAR, sizeof(param_data3), 0, (BYTE *) ¶m_data3 } , { "@nvarchar_tds7_out", DBRPCRETURN, 231, sizeof(param_data4), 0, (BYTE *) ¶m_data4 } , { "@nrows", DBRPCRETURN, SYBINT4, -1, -1, (BYTE *) ¶m_data5 } , { "@c_this_name_is_way_more_than_thirty_characters_charlie", 0, SYBVARCHAR, 0, 0, NULL } , { "@nv", 0, SYBVARCHAR, -1, 2, (BYTE *) "OK:" } }, *pb = bindings; int main(int argc, char **argv) { LOGINREC *login; DBPROCESS *dbproc; RETPARAM save_param, save_varchar_tds7_param, save_nvarchar_tds7_param; char teststr[8000+1], abbrev_data[10+3+1], *output; char *retname = NULL; int i, failed = 0; int rettype = 0, retlen = 0, return_status = 0; char proc[] = "#t0022"; char *proc_name = proc; int num_resultset = 0, num_empty_resultset = 0; int num_params = 6; static const char dashes30[] = "------------------------------"; static const char *dashes5 = dashes30 + (sizeof(dashes30) - 5), *dashes20 = dashes30 + (sizeof(dashes30) - 20); RETCODE erc, row_code; set_malloc_options(); memset(&save_param, 0, sizeof(save_param)); memset(&save_varchar_tds7_param, 0, sizeof(save_varchar_tds7_param)); memset(&save_nvarchar_tds7_param, 0, sizeof(save_nvarchar_tds7_param)); read_login_info(argc, argv); fprintf(stdout, "Starting %s\n", argv[0]); dbinit(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "rpc"); dberrhandle(ignore_err_handler); DBSETLPACKET(login, -1); dberrhandle(syb_err_handler); fprintf(stdout, "About to open %s.%s\n", SERVER, DATABASE); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); dbloginfree(login); printf("Check if server support long identifiers\n"); sql_cmd(dbproc); i = 103; dbsetuserdata(dbproc, (BYTE*) &i); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) while (dbnextrow(dbproc) != NO_MORE_ROWS) continue; dbsetuserdata(dbproc, NULL); if (i == 0) { fprintf(stderr, "This server does not support long identifiers\n"); dbexit(); return 0; } dberrhandle(ignore_err_handler); dbmsghandle(ignore_msg_handler); printf("trying to create a temporary stored procedure\n"); if (FAIL == init_proc(dbproc, proc_name)) { num_params = 4; printf("trying to create a permanent stored procedure\n"); if (FAIL == init_proc(dbproc, ++proc_name)) exit(EXIT_FAILURE); } dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "Created procedure %s\n", proc_name); /* set up and send the rpc */ printf("executing dbrpcinit\n"); erc = dbrpcinit(dbproc, proc_name, 0); /* no options */ if (erc == FAIL) { fprintf(stderr, "Failed line %d: dbrpcinit\n", __LINE__); failed = 1; } for (pb = bindings, i = 0; pb < bindings + sizeof(bindings)/sizeof(bindings[0]); pb++, i++) { printf("executing dbrpcparam for %s\n", pb->name); if (num_params == 4 && (i == 3 || i == 4)) continue; if ((erc = dbrpcparam(dbproc, pb->name, pb->status, pb->type, pb->maxlen, pb->datalen, pb->value)) == FAIL) { fprintf(stderr, "Failed line %d: dbrpcparam\n", __LINE__); failed++; } } printf("executing dbrpcsend\n"); param_data5 = 0x11223344; erc = dbrpcsend(dbproc); if (erc == FAIL) { fprintf(stderr, "Failed line %d: dbrpcsend\n", __LINE__); exit(1); } /* wait for it to execute */ printf("executing dbsqlok\n"); erc = dbsqlok(dbproc); if (erc == FAIL) { fprintf(stderr, "Failed line %d: dbsqlok\n", __LINE__); exit(1); } /* retrieve outputs per usual */ printf("fetching results\n"); while ((erc = dbresults(dbproc)) != NO_MORE_RESULTS) { printf("fetched resultset %d %s:\n", 1+num_resultset, erc==SUCCEED? "successfully":"unsuccessfully"); if (erc == SUCCEED) { const int ncol = dbnumcols(dbproc); int empty_resultset = 1, c; enum {buflen=1024, nbuf=5}; char bound_buffers[nbuf][buflen] = { "one", "two", "three", "four", "five" }; ++num_resultset; for( c=0; c < ncol && c < nbuf; c++ ) { printf("column %d (%s) is %d wide, ", c+1, dbcolname(dbproc, c+1), colwidth(dbproc, c+1)); printf("buffer initialized to '%s'\n", bound_buffers[c]); } for( c=0; c < ncol && c < nbuf; c++ ) { erc = dbbind(dbproc, c+1, STRINGBIND, 0, (BYTE *) bound_buffers[c]); if (erc == FAIL) { fprintf(stderr, "Failed line %d: dbbind\n", __LINE__); exit(1); } printf("%-*s ", colwidth(dbproc, c+1), dbcolname(dbproc, c+1)); } printf("\n"); while ((row_code = dbnextrow(dbproc)) != NO_MORE_ROWS) { empty_resultset = 0; if (row_code == REG_ROW) { int c; for( c=0; c < ncol && c < nbuf; c++ ) { printf("%-*s ", colwidth(dbproc, c+1), bound_buffers[c]); } printf("\n"); } else { /* not supporting computed rows in this unit test */ failed = 1; fprintf(stderr, "Failed. Expected a row\n"); exit(1); } } printf("row count %d\n", (int) dbcount(dbproc)); if (empty_resultset) ++num_empty_resultset; } else { fprintf(stderr, "Expected a result set.\n"); exit(1); } } /* while dbresults */ /* check return status */ printf("retrieving return status...\n"); if (dbhasretstat(dbproc) == TRUE) { printf("%d\n", return_status = dbretstatus(dbproc)); } else { printf("none\n"); } /* * Check output parameter values */ if (dbnumrets(dbproc) != num_params) { /* dbnumrets missed something */ fprintf(stderr, "Expected %d output parameters.\n", num_params); exit(1); } printf("retrieving output parameters...\n"); printf("%-5s %-20s %5s %6s %-30s\n", "param", "name", "type", "length", "data"); printf("%-5s %-20s %5s %5s- %-30s\n", dashes5, dashes20, dashes5, dashes5, dashes30); for (i = 1; i <= dbnumrets(dbproc); i++) { retname = dbretname(dbproc, i); rettype = dbrettype(dbproc, i); retlen = dbretlen(dbproc, i); dbconvert(dbproc, rettype, dbretdata(dbproc, i), retlen, SYBVARCHAR, (BYTE*) teststr, -1); if(retlen <= 10) { output = teststr; } else { memcpy(abbrev_data, teststr, 10); sprintf(&abbrev_data[10], "..."); output = abbrev_data; } printf("%-5d %-20s %5d %6d %-30s\n", i, retname, rettype, retlen, output); save_retparam(&save_param, retname, teststr, rettype, retlen); if (i == 4) { save_retparam(&save_varchar_tds7_param, retname, teststr, rettype, retlen); } if (i == 5) { save_retparam(&save_nvarchar_tds7_param, retname, teststr, rettype, retlen); } } /* * Test the last parameter for expected outcome */ if ((save_param.name == NULL) || strcmp(save_param.name, bindings[5].name)) { fprintf(stderr, "Expected retname to be '%s', got ", bindings[5].name); if (save_param.name == NULL) fprintf(stderr, " instead.\n"); else fprintf(stderr, "'%s' instead.\n", save_param.name); exit(1); } if (strcmp(save_param.value, "3")) { fprintf(stderr, "Expected retdata to be 3.\n"); exit(1); } if (save_param.type != SYBINT4) { fprintf(stderr, "Expected rettype to be SYBINT4 was %d.\n", save_param.type); exit(1); } if (save_param.len != 4) { fprintf(stderr, "Expected retlen to be 4.\n"); exit(1); } if (num_params == 6) { /* * Test name, size, contents of the VARCHAR(8000) output parameter */ if ((save_varchar_tds7_param.name == NULL) || strcmp(save_varchar_tds7_param.name, bindings[3].name)) { fprintf(stderr, "Expected retname to be '%s', got ", bindings[3].name); if (save_varchar_tds7_param.name == NULL) fprintf(stderr, " instead.\n"); else fprintf(stderr, "'%s' instead.\n", save_varchar_tds7_param.name); exit(1); } if (save_varchar_tds7_param.type != SYBVARCHAR) { fprintf(stderr, "Expected rettype to be SYBVARCHAR was %d.\n", save_varchar_tds7_param.type); exit(1); } if (save_varchar_tds7_param.len != 8000) { fprintf(stderr, "Expected retlen to be 8000 was %d.\n", save_varchar_tds7_param.len); exit(1); } /* * Test name, size, contents of the NVARCHAR(4000) output parameter */ if ((save_nvarchar_tds7_param.name == NULL) || strcmp(save_nvarchar_tds7_param.name, bindings[4].name)) { fprintf(stderr, "Expected retname to be '%s', got ", bindings[4].name); if (save_varchar_tds7_param.name == NULL) fprintf(stderr, " instead.\n"); else fprintf(stderr, "'%s' instead.\n", save_nvarchar_tds7_param.name); exit(1); } if (save_nvarchar_tds7_param.len != 4000) { fprintf(stderr, "Expected retlen to be 4000 was %d.\n", save_nvarchar_tds7_param.len); exit(1); } } if(42 != return_status) { fprintf(stderr, "Expected status to be 42.\n"); exit(1); } printf("Good: Got 6 output parameters and 1 return status of %d.\n", return_status); /* Test number of result sets */ if (num_resultset != 4) { fprintf(stderr, "Expected 4 resultset got %d.\n", num_resultset); exit(1); } if (num_empty_resultset != 1) { fprintf(stderr, "Expected an empty resultset got %d.\n", num_empty_resultset); exit(1); } printf("Good: Got %d resultsets and %d empty resultset.\n", num_resultset, num_empty_resultset); fprintf(stdout, "Dropping procedure\n"); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } dbexit(); fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); free_retparam(&save_param); free_retparam(&save_varchar_tds7_param); free_retparam(&save_nvarchar_tds7_param); return failed ? 1 : 0; } freetds-1.00.82/src/dblib/unittests/setnull.c100644 025423 025423 00000007671 12717145107 0014605/* * Purpose: dbnull behavior */ #include "common.h" #include "replacements.h" static int failed = 0; static DBPROCESS *dbproc = NULL; static void char_test(const char *null, int bindlen, const char *expected) { char db_c[16]; RETCODE ret; if (null) { fprintf(stderr, "\tdbsetnull(CHARBIND, %u, '%s').\n", (unsigned int) strlen(null), null); ret = dbsetnull(dbproc, CHARBIND, strlen(null), (BYTE *) null); if (ret != SUCCEED) { fprintf(stderr, "dbsetnull returned error %d\n", (int) ret); failed = 1; } } memset(db_c, '_', sizeof(db_c)); strcpy(db_c, "123456"); dbcmd(dbproc, "select convert(char(20), null)"); dbsqlexec(dbproc); if (dbresults(dbproc) != SUCCEED) { fprintf(stderr, "Was expecting a row.\n"); failed = 1; dbcancel(dbproc); } fprintf(stderr, "dbbind(CHARBIND, bindlen= %d).\n", bindlen); dbbind(dbproc, 1, CHARBIND, bindlen, (BYTE *) &db_c); db_c[sizeof(db_c)-1] = 0; printf("buffer before/after dbnextrow: '%s'/", db_c); if (dbnextrow(dbproc) != REG_ROW) { fprintf(stderr, "Was expecting a row.\n"); failed = 1; dbcancel(dbproc); } db_c[sizeof(db_c)-1] = 0; printf("'%s'\n", db_c); if (dbnextrow(dbproc) != NO_MORE_ROWS) { fprintf(stderr, "Only one row expected\n"); dbcancel(dbproc); failed = 1; } while (dbresults(dbproc) == SUCCEED) { /* nop */ } if (strcmp(db_c, expected) != 0) { fprintf(stderr, "Invalid NULL '%s' returned expected '%s' (%s:%d)\n", db_c, expected, basename(__FILE__), __LINE__); failed = 1; } } int main(int argc, char **argv) { LOGINREC *login; DBINT db_i; RETCODE ret; read_login_info(argc, argv); printf("Starting %s\n", argv[0]); dbinit(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "setnull"); printf("About to open %s.%s\n", SERVER, DATABASE); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); dbloginfree(login); /* try to set an int */ db_i = 0xdeadbeef; ret = dbsetnull(dbproc, INTBIND, 0, (BYTE *) &db_i); if (ret != SUCCEED) { fprintf(stderr, "dbsetnull returned error %d\n", (int) ret); failed = 1; } ret = dbsetnull(dbproc, INTBIND, 1, (BYTE *) &db_i); if (ret != SUCCEED) { fprintf(stderr, "dbsetnull returned error %d\n", (int) ret); failed = 1; } /* check result */ db_i = 0; dbcmd(dbproc, "select convert(int, null)"); dbsqlexec(dbproc); if (dbresults(dbproc) != SUCCEED) { fprintf(stderr, "Was expecting a row.\n"); failed = 1; dbcancel(dbproc); } dbbind(dbproc, 1, INTBIND, 0, (BYTE *) &db_i); printf("db_i = %ld\n", (long int) db_i); if (dbnextrow(dbproc) != REG_ROW) { fprintf(stderr, "Was expecting a row.\n"); failed = 1; dbcancel(dbproc); } printf("db_i = %ld\n", (long int) db_i); if (dbnextrow(dbproc) != NO_MORE_ROWS) { fprintf(stderr, "Only one row expected\n"); dbcancel(dbproc); failed = 1; } while (dbresults(dbproc) == SUCCEED) { /* nop */ } if (db_i != 0xdeadbeef) { fprintf(stderr, "Invalid NULL %ld returned (%s:%d)\n", (long int) db_i, basename(__FILE__), __LINE__); failed = 1; } /* try if dbset null consider length */ for (db_i = 1; db_i > 0; db_i <<= 1) { printf("db_i = %ld\n", (long int) db_i); ret = dbsetnull(dbproc, INTBIND, db_i, (BYTE *) &db_i); if (ret != SUCCEED) { fprintf(stderr, "dbsetnull returned error %d for bindlen %ld\n", (int) ret, (long int) db_i); failed = 1; break; } } char_test(NULL, -1, "123456"); char_test(NULL, 0, "123456"); char_test(NULL, 2, " 3456"); char_test("foo", -1, "foo456"); char_test("foo", 0, "foo456"); /* char_test("foo", 2, ""); */ char_test("foo", 5, "foo 6"); char_test("foo ", -1, "foo 56"); char_test("foo ", 0, "foo 56"); /* char_test("foo ", 2, ""); */ char_test("foo ", 5, "foo 6"); char_test("foo ", 10, "foo _____"); printf("dblib %s on %s\n", (failed ? "failed!" : "okay"), __FILE__); dbexit(); return failed ? 1 : 0; } freetds-1.00.82/src/dblib/unittests/spid.c100644 025423 025423 00000003272 12717145107 0014047/* * Purpose: Retrieve the connection SPID. * Functions: dbspid */ #include "common.h" int main(int argc, char **argv) { LOGINREC *login; DBPROCESS *dbproc; DBINT expected_spid, actual_spid; RETCODE erc; set_malloc_options(); read_login_info(argc, argv); printf("Starting %s\n", argv[0]); dbinit(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); printf("About to logon as \"%s\"\n", USER); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "spid"); printf("About to open \"%s\"\n", SERVER); dbproc = dbopen(login, SERVER); if (!dbproc) { fprintf(stderr, "Unable to connect to %s\n", SERVER); return 1; } dbloginfree(login); printf("Using database \"%s\"\n", DATABASE); if (strlen(DATABASE)) { erc = dbuse(dbproc, DATABASE); assert(erc == SUCCEED); } #ifdef DBQUOTEDIDENT printf("QUOTED_IDENTIFIER is %s\n", (dbisopt(dbproc, DBQUOTEDIDENT, NULL))? "ON":"OFF"); #endif sql_cmd(dbproc); dbsqlexec(dbproc); if (dbresults(dbproc) != SUCCEED) { fprintf(stderr, "error: expected a result set, none returned.\n"); return 1; } if (SUCCEED != dbbind(dbproc, 1, INTBIND, -1, (BYTE *) & expected_spid)) { fprintf(stderr, "Had problem with bind\n"); return 1; } if (REG_ROW != dbnextrow(dbproc)) { fprintf(stderr, "Failed. Expected a row\n"); return 1; } assert(expected_spid > 0); actual_spid = dbspid(dbproc); if (expected_spid != actual_spid) { fprintf(stderr, "Failed. Expected spid to be %d, was %d\n", expected_spid, actual_spid); return 1; } if (dbnextrow(dbproc) != NO_MORE_ROWS) { fprintf(stderr, "Was expecting no more rows\n"); return 1; } dbclose(dbproc); dbexit(); return 0; } freetds-1.00.82/src/dblib/unittests/t0001.c100644 025423 025423 00000006355 12717145107 0013661/* * Purpose: Log in, create a table, insert a few rows, select them, and log out. * Functions: dbbind dbcmd dbcolname dberrhandle dbisopt dbmsghandle dbnextrow dbnumcols dbopen dbresults dbsetlogintime dbsqlexec dbuse */ #include "common.h" int failed = 0; int main(int argc, char **argv) { const int rows_to_add = 50; LOGINREC *login; DBPROCESS *dbproc; int i; char teststr[1024]; DBINT testint, erc; set_malloc_options(); read_login_info(argc, argv); if (argc > 1) { argc -= optind; argv += optind; } fprintf(stdout, "Starting %s\n", argv[0]); /* Fortify_EnterScope(); */ dbinit(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon as \"%s\"\n", USER); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "t0001"); if (argc > 1) { printf("server and login timeout overrides (%s and %s) detected\n", argv[0], argv[1]); strcpy(SERVER, argv[0]); i = atoi(argv[1]); if (i) { i = dbsetlogintime(i); printf("dbsetlogintime returned %s.\n", (i == SUCCEED)? "SUCCEED" : "FAIL"); } } fprintf(stdout, "About to open \"%s\"\n", SERVER); dbproc = dbopen(login, SERVER); if (!dbproc) { fprintf(stderr, "Unable to connect to %s\n", SERVER); return 1; } dbloginfree(login); fprintf(stdout, "Using database \"%s\"\n", DATABASE); if (strlen(DATABASE)) { erc = dbuse(dbproc, DATABASE); assert(erc == SUCCEED); } #ifdef DBQUOTEDIDENT fprintf(stdout, "QUOTED_IDENTIFIER is %s\n", (dbisopt(dbproc, DBQUOTEDIDENT, NULL))? "ON":"OFF"); #endif sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) == SUCCEED) { /* nop */ } for (i = 0; i < rows_to_add && sql_cmd(dbproc) == SUCCEED; i++) { dbsqlexec(dbproc); while (dbresults(dbproc) == SUCCEED) { /* nop */ } } sql_cmd(dbproc); dbsqlexec(dbproc); if (dbresults(dbproc) != SUCCEED) { failed = 1; fprintf(stderr, "error: expected a result set, none returned.\n"); exit(1); } for (i = 1; i <= dbnumcols(dbproc); i++) printf("col %d is %s\n", i, dbcolname(dbproc, i)); if (SUCCEED != dbbind(dbproc, 1, INTBIND, -1, (BYTE *) & testint)) { failed = 1; fprintf(stderr, "Had problem with bind\n"); abort(); } if (SUCCEED != dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) teststr)) { failed = 1; fprintf(stderr, "Had problem with bind\n"); abort(); } for (i = 0; i < rows_to_add; i++) { char expected[1024]; sprintf(expected, "row %03d", i); memset(teststr, 'x', sizeof(teststr)); teststr[0] = 0; teststr[sizeof(teststr) - 1] = 0; if (REG_ROW != dbnextrow(dbproc)) { failed = 1; fprintf(stderr, "Failed. Expected a row\n"); exit(1); } if (testint != i) { failed = 1; fprintf(stderr, "Failed. Expected i to be %d, was %d\n", i, (int) testint); abort(); } if (0 != strncmp(teststr, expected, strlen(expected))) { failed = 1; fprintf(stdout, "Failed. Expected s to be |%s|, was |%s|\n", expected, teststr); abort(); } printf("Read a row of data -> %d |%s|\n", (int) testint, teststr); } if (dbnextrow(dbproc) != NO_MORE_ROWS) { failed = 1; fprintf(stderr, "Was expecting no more rows\n"); exit(1); } dbexit(); fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); return failed ? 1 : 0; } freetds-1.00.82/src/dblib/unittests/t0001.sql100644 025423 025423 00000005034 12522201763 0014222create table #dblib0001 (i int not null, s char(10) not null) go insert into #dblib0001 values (0, "row 000") go insert into #dblib0001 values (1, "row 001") go insert into #dblib0001 values (2, "row 002") go insert into #dblib0001 values (3, "row 003") go insert into #dblib0001 values (4, "row 004") go insert into #dblib0001 values (5, "row 005") go insert into #dblib0001 values (6, "row 006") go insert into #dblib0001 values (7, "row 007") go insert into #dblib0001 values (8, "row 008") go insert into #dblib0001 values (9, "row 009") go insert into #dblib0001 values (10, "row 010") go insert into #dblib0001 values (11, "row 011") go insert into #dblib0001 values (12, "row 012") go insert into #dblib0001 values (13, "row 013") go insert into #dblib0001 values (14, "row 014") go insert into #dblib0001 values (15, "row 015") go insert into #dblib0001 values (16, "row 016") go insert into #dblib0001 values (17, "row 017") go insert into #dblib0001 values (18, "row 018") go insert into #dblib0001 values (19, "row 019") go insert into #dblib0001 values (20, "row 020") go insert into #dblib0001 values (21, "row 021") go insert into #dblib0001 values (22, "row 022") go insert into #dblib0001 values (23, "row 023") go insert into #dblib0001 values (24, "row 024") go insert into #dblib0001 values (25, "row 025") go insert into #dblib0001 values (26, "row 026") go insert into #dblib0001 values (27, "row 027") go insert into #dblib0001 values (28, "row 028") go insert into #dblib0001 values (29, "row 029") go insert into #dblib0001 values (30, "row 030") go insert into #dblib0001 values (31, "row 031") go insert into #dblib0001 values (32, "row 032") go insert into #dblib0001 values (33, "row 033") go insert into #dblib0001 values (34, "row 034") go insert into #dblib0001 values (35, "row 035") go insert into #dblib0001 values (36, "row 036") go insert into #dblib0001 values (37, "row 037") go insert into #dblib0001 values (38, "row 038") go insert into #dblib0001 values (39, "row 039") go insert into #dblib0001 values (40, "row 040") go insert into #dblib0001 values (41, "row 041") go insert into #dblib0001 values (42, "row 042") go insert into #dblib0001 values (43, "row 043") go insert into #dblib0001 values (44, "row 044") go insert into #dblib0001 values (45, "row 045") go insert into #dblib0001 values (46, "row 046") go insert into #dblib0001 values (47, "row 047") go insert into #dblib0001 values (48, "row 048") go insert into #dblib0001 values (49, "row 049") go select * from #dblib0001 order by i go /* dbclose() at Sat Jan 31 21:36:54 2009 */ freetds-1.00.82/src/dblib/unittests/t0002.c100644 025423 025423 00000013212 12717145107 0013650/* * Purpose: Test buffering * Functions: dbclrbuf dbgetrow dbsetopt */ #if 0 # Find functions with: sed -ne'/db/ s/.*\(db[[:alnum:]_]*\)(.*/\1/gp' src/dblib/unittests/t0002.c |sort -u |fmt #endif #include "common.h" #include int failed = 0; static void verify(int i, int testint, char *teststr) { char expected[1024]; sprintf(expected, "row %03d", i); if (testint != i) { failed = 1; fprintf(stderr, "Failed. Expected i to be %d, was %d\n", i, testint); abort(); } if (0 != strncmp(teststr, expected, strlen(expected))) { failed = 1; fprintf(stderr, "Failed. Expected s to be |%s|, was |%s|\n", expected, teststr); abort(); } printf("Read a row of data -> %d %s\n", testint, teststr); } int main(int argc, char **argv) { LOGINREC *login; DBPROCESS *dbproc; DBINT testint; STATUS rc; int i, iresults; char teststr[1024]; int rows_in_buffer, limit_rows; const int buffer_count = 10; const int rows_to_add = 50; set_malloc_options(); read_login_info(argc, argv); fprintf(stdout, "Starting %s\n", argv[0]); /* Fortify_EnterScope(); */ dbinit(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "t0002"); fprintf(stdout, "About to open %s..%s\n", SERVER, DATABASE); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); dbloginfree(login); fprintf(stdout, "Setting row buffer to 10 rows\n"); #ifdef MICROSOFT_DBLIB dbsetopt(dbproc, DBBUFFER, "10"); #else dbsetopt(dbproc, DBBUFFER, "10", 0); #endif sql_cmd(dbproc); /* drop table if exists */ dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } if (dbresults(dbproc) != NO_MORE_RESULTS) { fprintf(stdout, "Failed: dbresults call after NO_MORE_RESULTS should return NO_MORE_RESULTS.\n"); failed = 1; } sql_cmd(dbproc); /* create table */ dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } for (i = 1; i <= rows_to_add; i++) { sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } } sql_cmd(dbproc); /* two result sets */ dbsqlexec(dbproc); for (iresults=1; iresults <= 2; iresults++ ) { fprintf(stdout, "fetching resultset %i\n", iresults); if (dbresults(dbproc) != SUCCEED) { fprintf(stderr, "Was expecting a result set %d.\n", iresults); if( iresults == 2 ) fprintf(stderr, "Buffering with multiple resultsets is broken.\n"); exit(1); } rows_in_buffer = 0; for (i = 1; i <= dbnumcols(dbproc); i++) printf("col %d is [%s]\n", i, dbcolname(dbproc, i)); dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint); dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) teststr); /* Fetch a result set */ /* Second resultset stops at row 46 */ limit_rows = rows_to_add - (iresults == 2 ? 4 : 0); for (i=0; i < limit_rows;) { fprintf(stdout, "clearing %d rows from buffer\n", rows_in_buffer ? buffer_count - 1 : buffer_count); #ifdef MICROSOFT_DBLIB if (i == 0) { rc = dbnextrow(dbproc); assert(rc == REG_ROW); ++i; rows_in_buffer = 1; } #endif dbclrbuf(dbproc, buffer_count); rows_in_buffer = rows_in_buffer ? 1 : 0; do { int rc; i++; if (REG_ROW != (rc = dbnextrow(dbproc))) { failed = 1; fprintf(stderr, "Failed: Expected a row (%s:%d)\n", __FILE__, __LINE__); if (rc == BUF_FULL) fprintf(stderr, "Failed: dbnextrow returned BUF_FULL (%d). Fix dbclrbuf.\n", rc); exit(1); } ++rows_in_buffer; verify(i, testint, teststr); } while (rows_in_buffer < buffer_count && i < limit_rows); if (rows_in_buffer == buffer_count) { /* The buffer should be full */ assert(BUF_FULL == dbnextrow(dbproc)); } } if (iresults == 1) { fprintf(stdout, "clearing %d rows from buffer\n", buffer_count); dbclrbuf(dbproc, buffer_count); while (dbnextrow(dbproc) != NO_MORE_ROWS) { abort(); /* All rows were read: should not enter loop */ } } } printf("\n"); /* * Now test the buffered rows. * Should be operating on rows 37-46 of 2nd resultset */ rc = dbgetrow(dbproc, 1); if(rc != NO_MORE_ROWS) /* row 1 is not among the 31-40 in the buffer */ fprintf(stderr, "Failed: dbgetrow returned %d.\n", rc); assert(rc == NO_MORE_ROWS); rc = dbgetrow(dbproc, 37); if(rc != REG_ROW) fprintf(stderr, "Failed: dbgetrow returned %d.\n", rc); assert(rc == REG_ROW); verify(37, testint, teststr); /* first buffered row should be 37 */ rc = dbnextrow(dbproc); if(rc != REG_ROW) fprintf(stderr, "Failed: dbgetrow returned %d.\n", rc); assert(rc == REG_ROW); verify(38, testint, teststr); /* next buffered row should be 38 */ rc = dbgetrow(dbproc, 11); assert(rc == NO_MORE_ROWS); /* only 10 (not 11) rows buffered */ rc = dbgetrow(dbproc, 46); assert(rc == REG_ROW); verify(46, testint, teststr); /* last buffered row should be 46 */ /* Attempt dbnextrow when buffer has no space (10 out of 10 in use). */ rc = dbnextrow(dbproc); assert(rc == BUF_FULL); dbclrbuf(dbproc, 3); /* remove rows 37, 38, and 39 */ rc = dbnextrow(dbproc); assert(rc == REG_ROW); verify(47, testint, teststr); /* fetch row from database, should be 47 */ rc = dbnextrow(dbproc); assert(rc == REG_ROW); verify(48, testint, teststr); /* fetch row from database, should be 48 */ /* buffer contains 8 rows (40-47) try removing 10 rows */ dbclrbuf(dbproc, buffer_count); while (dbnextrow(dbproc) != NO_MORE_ROWS) { /* waste rows 49-50 */ } dbclose(dbproc); /* close while buffer not cleared: OK */ dbexit(); fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); return failed ? 1 : 0; } freetds-1.00.82/src/dblib/unittests/t0003.c100644 025423 025423 00000004756 12717145107 0013666/* * Purpose: Test buffering * Functions: dbclrbuf dbgetrow dbsetopt */ #include "common.h" int failed = 0; int main(int argc, char **argv) { RETCODE rc; const int rows_to_add = 50; LOGINREC *login; DBPROCESS *dbproc; int i; char teststr[1024]; DBINT testint; set_malloc_options(); read_login_info(argc, argv); fprintf(stdout, "Starting %s\n", argv[0]); /* Fortify_EnterScope(); */ dbinit(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "t0003"); DBSETLHOST(login, "ntbox.dntis.ro"); fprintf(stdout, "About to open\n"); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); dbloginfree(login); #ifdef MICROSOFT_DBLIB dbsetopt(dbproc, DBBUFFER, "100"); #else dbsetopt(dbproc, DBBUFFER, "100", 0); #endif fprintf(stdout, "creating table\n"); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } fprintf(stdout, "insert\n"); for (i = 1; i < rows_to_add; i++) { sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } } fprintf(stdout, "select\n"); sql_cmd(dbproc); dbsqlexec(dbproc); if (dbresults(dbproc) != SUCCEED) { failed = 1; fprintf(stdout, "Was expecting a result set."); exit(1); } for (i = 1; i <= dbnumcols(dbproc); i++) printf("col %d is %s\n", i, dbcolname(dbproc, i)); dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint); dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) teststr); for (i = 1; i < rows_to_add; i++) { char expected[1024]; sprintf(expected, "row %03d", i); if (i % 100 == 0) { dbclrbuf(dbproc, 100); } if (REG_ROW != dbnextrow(dbproc)) { failed = 1; fprintf(stderr, "Failed. Expected a row\n"); exit(1); } if (testint != i) { failed = 1; fprintf(stderr, "Failed. Expected i to be %d, was %d\n", i, (int) testint); abort(); } if (0 != strncmp(teststr, expected, strlen(expected))) { failed = 1; fprintf(stdout, "Failed. Expected s to be |%s|, was |%s|\n", expected, teststr); abort(); } printf("Read a row of data -> %d %s\n", (int) testint, teststr); } dbclrbuf(dbproc, 1); rc = dbnextrow(dbproc); if (rc != NO_MORE_ROWS) { failed = 1; fprintf(stderr, "Was expecting no more rows. (rc=%d)\n", rc); exit(1); } dbexit(); fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); return failed ? 1 : 0; } freetds-1.00.82/src/dblib/unittests/t0004.c100644 025423 025423 00000005766 12717145107 0013671/* * Purpose: Test retrieving data and attempting to initiate a new query with results pending * Functions: dbnextrow dbresults dbsqlexec dbgetchar */ #include "common.h" #include int main(int argc, char **argv) { const int rows_to_add = 50; LOGINREC *login; DBPROCESS *dbproc; int i, expected_error; char *s, teststr[1024]; DBINT testint; int failed = 0; set_malloc_options(); read_login_info(argc, argv); fprintf(stdout, "Starting %s\n", argv[0]); dbinit(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "t0004"); fprintf(stdout, "About to open\n"); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); dbloginfree(login); fprintf(stdout, "creating table\n"); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } fprintf(stdout, "insert\n"); for (i = 1; i < rows_to_add; i++) { sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } } sql_cmd(dbproc); /* select */ dbsqlexec(dbproc); if (dbresults(dbproc) != SUCCEED) { fprintf(stdout, "Was expecting a result set."); exit(1); } for (i = 1; i <= dbnumcols(dbproc); i++) printf("col %d is %s\n", i, dbcolname(dbproc, i)); dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint); dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) teststr); for (i = 1; i <= 24; i++) { char expected[1024]; sprintf(expected, "row %04d", i); if (i % 5 == 0) { dbclrbuf(dbproc, 5); } testint = -1; strcpy(teststr, "bogus"); if (REG_ROW != dbnextrow(dbproc)) { fprintf(stderr, "Failed. Expected a row\n"); exit(1); } if (testint != i) { fprintf(stderr, "Failed. Expected i to be %d, was %d\n", i, (int) testint); abort(); } if (0 != strncmp(teststr, expected, strlen(expected))) { fprintf(stdout, "Failed. Expected s to be |%s|, was |%s|\n", expected, teststr); abort(); } printf("Read a row of data -> %d %s\n", (int) testint, teststr); } fprintf(stdout, "second select\n"); fprintf(stdout, "testing dbgetchar...\n"); for (i=0; (s = dbgetchar(dbproc, i)) != NULL; i++) { putchar(*s); if (!(isprint((unsigned char)*s) || iscntrl((unsigned char)*s))) { fprintf(stderr, "%s:%d: dbgetchar failed with %x at position %d\n", __FILE__, __LINE__, *s, i); failed = 1; break; } } fprintf(stdout, "<== end of command buffer\n"); if (SUCCEED != sql_cmd(dbproc)) { fprintf(stderr, "%s:%d: dbcmd failed\n", __FILE__, __LINE__); failed = 1; } fprintf(stdout, "About to exec for the second time. Should fail\n"); expected_error = 20019; dbsetuserdata(dbproc, (BYTE*) &expected_error); if (FAIL != dbsqlexec(dbproc)) { fprintf(stderr, "%s:%d: dbsqlexec should have failed but didn't\n", __FILE__, __LINE__); failed = 1; } dbexit(); fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); return failed ? 1 : 0; } freetds-1.00.82/src/dblib/unittests/t0005.c100644 025423 025423 00000014103 12717145107 0013653/* * Purpose: Test data retrieval accuracy and cancelling results * Functions: dbbind dbcancel dbcmd dbcolname dbnextrow dbnumcols dbresults dbsqlexec */ #include "common.h" int main(int argc, char **argv) { const int rows_to_add = 50; LOGINREC *login; DBPROCESS *dbproc; int i; char teststr[1024]; DBINT testint; int failed = 0; int expected_error; set_malloc_options(); read_login_info(argc, argv); fprintf(stdout, "Starting %s\n", argv[0]); dbinit(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "t0005"); DBSETLHOST(login, "ntbox.dntis.ro"); fprintf(stdout, "About to open\n"); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); dbloginfree(login); fprintf(stdout, "creating table\n"); if (SUCCEED != sql_cmd(dbproc)) { fprintf(stderr, "%s:%d: dbcmd failed\n", __FILE__, __LINE__); failed = 1; } if (SUCCEED != dbsqlexec(dbproc)) { fprintf(stderr, "%s:%d: dbcmd failed\n", __FILE__, __LINE__); failed = 1; } while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } fprintf(stdout, "insert\n"); for (i = 1; i < rows_to_add; i++) { sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } } sql_cmd(dbproc); dbsqlexec(dbproc); if (dbresults(dbproc) != SUCCEED) { fprintf(stdout, "Was expecting a result set."); exit(1); } for (i = 1; i <= dbnumcols(dbproc); i++) printf("col %d is %s\n", i, dbcolname(dbproc, i)); dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint); dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) teststr); for (i = 1; i < 5; i++) { char expected[1024]; sprintf(expected, "row %04d", i); testint = -1; strcpy(teststr, "bogus"); if (REG_ROW != dbnextrow(dbproc)) { fprintf(stderr, "Failed. Expected a row\n"); exit(1); } if (testint != i) { fprintf(stderr, "Failed. Expected i to be %d, was %d\n", i, (int) testint); abort(); } if (0 != strncmp(teststr, expected, strlen(expected))) { fprintf(stdout, "Failed. Expected s to be |%s|, was |%s|\n", expected, teststr); abort(); } printf("Read a row of data -> %d %s\n", (int) testint, teststr); } fprintf(stdout, "This query should succeeded as we have fetched the exact\n" "number of rows in the result set\n"); expected_error = 20019; dbsetuserdata(dbproc, (BYTE*) &expected_error); if (SUCCEED != sql_cmd(dbproc)) { fprintf(stderr, "%s:%d: dbcmd failed\n", __FILE__, __LINE__); failed = 1; } if (SUCCEED != dbsqlexec(dbproc)) { fprintf(stderr, "%s:%d: dbsqlexec should have succeeded but didn't\n", __FILE__, __LINE__); failed = 1; } if (dbresults(dbproc) != SUCCEED) { fprintf(stdout, "Was expecting a result set."); exit(1); } for (i = 1; i <= dbnumcols(dbproc); i++) printf("col %d is %s\n", i, dbcolname(dbproc, i)); dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint); dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) teststr); for (i = 1; i < 5; i++) { char expected[1024]; sprintf(expected, "row %04d", i); testint = -1; strcpy(teststr, "bogus"); if (REG_ROW != dbnextrow(dbproc)) { fprintf(stderr, "Failed. Expected a row\n"); exit(1); } if (testint != i) { fprintf(stderr, "Failed. Expected i to be %d, was %d\n", i, (int) testint); abort(); } if (0 != strncmp(teststr, expected, strlen(expected))) { fprintf(stdout, "Failed. Expected s to be |%s|, was |%s|\n", expected, teststr); abort(); } printf("Read a row of data -> %d %s\n", (int) testint, teststr); } fprintf(stdout, "Testing anticipated failure\n"); if (SUCCEED != sql_cmd(dbproc)) { fprintf(stderr, "%s:%d: dbcmd failed\n", __FILE__, __LINE__); failed = 1; } if (SUCCEED == dbsqlexec(dbproc)) { fprintf(stderr, "%s:%d: dbsqlexec should have failed but didn't\n", __FILE__, __LINE__); failed = 1; } fprintf(stdout, "calling dbcancel to flush results\n"); dbcancel(dbproc); fprintf(stdout, "Dropping proc\n"); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } fprintf(stdout, "creating proc\n"); sql_cmd(dbproc); if (dbsqlexec(dbproc) == FAIL) { fprintf(stderr, "%s:%d: failed to create procedure\n", __FILE__, __LINE__); failed = 1; } while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } fprintf(stdout, "calling proc\n"); sql_cmd(dbproc); if (dbsqlexec(dbproc) == FAIL) { fprintf(stderr, "%s:%d: failed to call procedure\n", __FILE__, __LINE__); failed = 1; } if (dbresults(dbproc) != SUCCEED) { fprintf(stdout, "Was expecting a result set."); exit(1); } for (i = 1; i <= dbnumcols(dbproc); i++) printf("col %d is %s\n", i, dbcolname(dbproc, i)); dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint); dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) teststr); for (i = 1; i < 6; i++) { char expected[1024]; sprintf(expected, "row %04d", i); testint = -1; strcpy(teststr, "bogus"); if (REG_ROW != dbnextrow(dbproc)) { fprintf(stderr, "Failed. Expected a row\n"); exit(1); } if (testint != i) { fprintf(stderr, "Failed. Expected i to be %d, was %d\n", i, (int) testint); abort(); } if (0 != strncmp(teststr, expected, strlen(expected))) { fprintf(stdout, "Failed. Expected s to be |%s|, was |%s|\n", expected, teststr); abort(); } printf("Read a row of data -> %d %s\n", (int) testint, teststr); } fprintf(stdout, "Calling dbsqlexec before dbnextrow returns NO_MORE_ROWS\n"); fprintf(stdout, "The following command should succeed because\n" "we have fetched the exact number of rows in the result set\n"); if (SUCCEED != sql_cmd(dbproc)) { fprintf(stderr, "%s:%d: dbcmd failed\n", __FILE__, __LINE__); failed = 1; } if (SUCCEED != dbsqlexec(dbproc)) { fprintf(stderr, "%s:%d: dbsqlexec should have succeeded but didn't\n", __FILE__, __LINE__); failed = 1; } dbcancel(dbproc); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } dbexit(); fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); return failed ? 1 : 0; } freetds-1.00.82/src/dblib/unittests/t0006.c100644 025423 025423 00000006014 12717145107 0013656/* * Purpose: Test fetching 50 rows in two result sets with a 5000-row buffer. * Functions: dbbind dbcmd dbnextrow dbnumcols dbresults dbsetopt dbsqlexec */ #include "common.h" static char teststr[1024]; static DBINT testint; static int failed = 0; static void get_results(DBPROCESS * dbproc, int start) { int current = start - 1; while (REG_ROW == dbnextrow(dbproc)) { char expected[1024]; current++; sprintf(expected, "row %04d", current); if (testint != current) { fprintf(stderr, "Failed. Expected i to be %d, was %d\n", current, (int) testint); abort(); } if (0 != strncmp(teststr, expected, strlen(expected))) { fprintf(stdout, "Failed. Expected s to be |%s|, was |%s|\n", expected, teststr); abort(); } printf("Read a row of data -> %d %s\n", (int) testint, teststr); } } int main(int argc, char **argv) { RETCODE rc; const int rows_to_add = 50; LOGINREC *login; DBPROCESS *dbproc; int i; set_malloc_options(); read_login_info(argc, argv); fprintf(stdout, "Starting %s\n", argv[0]); /* Fortify_EnterScope(); */ dbinit(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "t0006"); DBSETLHOST(login, "ntbox.dntis.ro"); fprintf(stdout, "About to open\n"); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); dbloginfree(login); #ifdef MICROSOFT_DBLIB dbsetopt(dbproc, DBBUFFER, "5000"); #else dbsetopt(dbproc, DBBUFFER, "5000", 0); #endif fprintf(stdout, "creating table\n"); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } fprintf(stdout, "insert\n"); for (i = 1; i < rows_to_add; i++) { sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } } fprintf(stdout, "first select\n"); if (SUCCEED != sql_cmd(dbproc)) { fprintf(stderr, "%s:%d: dbcmd failed\n", __FILE__, __LINE__); failed = 1; } if (SUCCEED != dbsqlexec(dbproc)) { fprintf(stderr, "%s:%d: dbsqlexec failed\n", __FILE__, __LINE__); failed = 1; } if (dbresults(dbproc) != SUCCEED) { fprintf(stdout, "%s:%d: Was expecting a result set.", __FILE__, __LINE__); failed = 1; exit(1); } for (i = 1; i <= dbnumcols(dbproc); i++) printf("col %d is %s\n", i, dbcolname(dbproc, i)); dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint); dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) teststr); get_results(dbproc, 1); testint = -1; strcpy(teststr, "bogus"); fprintf(stdout, "second select\n"); sql_cmd(dbproc); dbsqlexec(dbproc); if ((rc = dbresults(dbproc)) != SUCCEED) { fprintf(stdout, "%s:%d: Was expecting a result set. (rc=%d)\n", __FILE__, __LINE__, rc); failed = 1; } if (!failed) { dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint); dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) teststr); get_results(dbproc, 25); } dbexit(); fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); return failed ? 1 : 0; } freetds-1.00.82/src/dblib/unittests/t0007.c100644 025423 025423 00000010457 12717145107 0013665/* * Purpose: Test binding strings and ints, attempt 2nd query with results pending. * Functions: dbbind dbcmd dbnextrow dbopen dbresults dbsqlexec */ #include "common.h" static void create_tables(DBPROCESS * dbproc, int rows_to_add) { int i; fprintf(stdout, "creating table\n"); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } fprintf(stdout, "insert\n"); for (i = 1; i < rows_to_add; i++) { sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } } } static int start_query(DBPROCESS * dbproc) { int i; if (SUCCEED != sql_cmd(dbproc)) { return 0; } if (SUCCEED != dbsqlexec(dbproc)) { return 0; } if (dbresults(dbproc) != SUCCEED) return 0; for (i = 1; i <= dbnumcols(dbproc); i++) printf("col %d is named \"%s\"\n", i, dbcolname(dbproc, i)); return 1; } int main(int argc, char **argv) { LOGINREC *login; DBPROCESS *dbproc; int i; char teststr[1024]; DBINT testint; DBVARYBIN testvbin; DBVARYCHAR testvstr; int failed = 0; int expected_error; set_malloc_options(); read_login_info(argc, argv); fprintf(stdout, "Starting %s\n", argv[0]); dbinit(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "t0007"); fprintf(stdout, "About to open\n"); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); dbloginfree(login); create_tables(dbproc, 10); if (!start_query(dbproc)) { fprintf(stderr, "%s:%d: start_query failed\n", __FILE__, __LINE__); failed = 1; } dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint); dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) teststr); for (i = 1; i <= 2; i++) { char expected[1024]; sprintf(expected, "row %07d", i); if (i % 5 == 0) { dbclrbuf(dbproc, 5); } testint = -1; strcpy(teststr, "bogus"); if (REG_ROW != dbnextrow(dbproc)) { fprintf(stderr, "Failed. Expected a row\n"); abort(); } if (testint != i) { fprintf(stderr, "Failed. Expected i to be %d, was %d\n", i, (int) testint); abort(); } if (0 != strncmp(teststr, expected, strlen(expected))) { fprintf(stdout, "Failed. Expected s to be |%s|, was |%s|\n", expected, teststr); abort(); } printf("Read a row of data -> %d %s\n", (int) testint, teststr); } fprintf(stdout, "second select. Should fail.\n"); expected_error = 20019; dbsetuserdata(dbproc, (BYTE*) &expected_error); if (start_query(dbproc)) { fprintf(stderr, "%s:%d: start_query should have failed but didn't\n", __FILE__, __LINE__); failed = 1; } dbcancel(dbproc); /* * Test Binary binding */ if (!start_query(dbproc)) { fprintf(stderr, "%s:%d: start_query failed\n", __FILE__, __LINE__); failed = 1; } dbbind(dbproc, 1, VARYBINBIND, sizeof(testvbin), (BYTE *) &testvbin); dbbind(dbproc, 2, VARYCHARBIND, sizeof(testvstr), (BYTE *) &testvstr); dbbind(dbproc, 3, BINARYBIND, sizeof(testint), (BYTE *) &testint); for (i = 1; i <= 2; i++) { char expected[1024]; sprintf(expected, "row %07d ", i); testint = -1; memset(&testvbin, '*', sizeof(testvbin)); memset(&testvstr, '*', sizeof(testvstr)); if (REG_ROW != dbnextrow(dbproc)) { fprintf(stderr, "Failed. Expected a row\n"); abort(); } if (testint != i) { fprintf(stderr, "Failed, line %d. Expected i to be %d, was %d (0x%x)\n", __LINE__, i, (int) testint, (int) testint); abort(); } if (testvbin.len != sizeof(testint)) { fprintf(stderr, "Failed, line %d. Expected bin lenght to be %d, was %d\n", __LINE__, (int) sizeof(testint), (int) testvbin.len); abort(); } memcpy(&testint, testvbin.array, sizeof(testint)); if (testint != i) { fprintf(stderr, "Failed, line %d. Expected i to be %d, was %d (0x%x)\n", __LINE__, i, (int) testint, (int) testint); abort(); } if (testvstr.len != strlen(expected) || 0 != strncmp(testvstr.str, expected, strlen(expected))) { fprintf(stdout, "Failed, line %d. Expected s to be |%s|, was |%s|\n", __LINE__, expected, testvstr.str); abort(); } testvstr.str[testvstr.len] = 0; printf("Read a row of data -> %d %s\n", (int) testint, testvstr.str); } dbexit(); fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); return failed ? 1 : 0; } freetds-1.00.82/src/dblib/unittests/t0008.c100644 025423 025423 00000005603 12717145107 0013663/* * Purpose: Test buffering. As of April 2005, jkl believes this test is broken. * Functions: dbclrbuf dbsetopt */ #include "common.h" int main(int argc, char **argv) { const int rows_to_add = 48; LOGINREC *login; DBPROCESS *dbproc; int i; char teststr[1024]; DBINT testint; DBINT last_read = -1; set_malloc_options(); read_login_info(argc, argv); fprintf(stdout, "Starting %s\n", argv[0]); /* Fortify_EnterScope(); */ dbinit(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "t0008"); DBSETLHOST(login, "ntbox.dntis.ro"); fprintf(stdout, "About to open\n"); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); dbloginfree(login); #ifdef MICROSOFT_DBLIB dbsetopt(dbproc, DBBUFFER, "25"); #else dbsetopt(dbproc, DBBUFFER, "25", 0); #endif fprintf(stdout, "creating table\n"); dbcmd(dbproc, "create table #dblib0008 (i int not null, s char(10) not null)"); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } fprintf(stdout, "insert\n"); for (i = 1; i <= rows_to_add; i++) { char cmd[1024]; sprintf(cmd, "insert into #dblib0008 values (%d, 'row %03d')", i, i); dbcmd(dbproc, cmd); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } } fprintf(stdout, "select\n"); dbcmd(dbproc, "select * from #dblib0008 order by i"); dbsqlexec(dbproc); if (dbresults(dbproc) != SUCCEED) { fprintf(stdout, "Was expecting a result set."); exit(1); } for (i = 1; i <= dbnumcols(dbproc); i++) printf("col %d is %s\n", i, dbcolname(dbproc, i)); dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint); dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) teststr); for (i = 1; i <= rows_to_add; i++) { char expected[1024]; sprintf(expected, "row %03d", i); if (i % 25 == 0) { dbclrbuf(dbproc, 25); } if (REG_ROW != dbnextrow(dbproc)) { fprintf(stderr, "dblib failed for %s, dbnextrow1\n", __FILE__); dbexit(); return 1; } last_read = testint; if (testint < 1 || testint > rows_to_add) { fprintf(stderr, "dblib failed for %s testint = %d\n", __FILE__, (int) testint); exit(1); } if (testint != i) { fprintf(stderr, "Failed. Expected i to be %d, was %d\n", i, (int) testint); abort(); } if (0 != strncmp(teststr, expected, strlen(expected))) { fprintf(stdout, "Failed. Expected s to be |%s|, was |%s|\n", expected, teststr); abort(); } printf("Read a row of data -> %d %s\n", (int) testint, teststr); } if (REG_ROW == dbnextrow(dbproc)) { fprintf(stderr, "dblib failed for %s, dbnextrow2\n", __FILE__); dbexit(); return 1; } dbexit(); fprintf(stdout, "%s %s (last_read: %d)\n", __FILE__, ((last_read != rows_to_add)? "failed!" : "OK"), (int) last_read); return (last_read == rows_to_add) ? 0 : 1; } freetds-1.00.82/src/dblib/unittests/t0009.c100644 025423 025423 00000004476 12717145107 0013673/* * Purpose: Test if dbbind can handle a varlen of 0 with a column bound as STRINGBIND and a database column of CHAR. * Functions: dbbind dbcmd dbnextrow dbnumcols dbopen dbresults dbsqlexec */ #include "common.h" int main(int argc, char **argv) { LOGINREC *login; DBPROCESS *dbproc; int i; char teststr[1024]; DBINT testint; set_malloc_options(); read_login_info(argc, argv); fprintf(stdout, "Starting %s\n", argv[0]); /* Fortify_EnterScope(); */ dbinit(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "t0009"); DBSETLHOST(login, "ntbox.dntis.ro"); fprintf(stdout, "About to open\n"); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); dbloginfree(login); #ifdef MICROSOFT_DBLIB dbsetopt(dbproc, DBBUFFER, "100"); #else dbsetopt(dbproc, DBBUFFER, "100", 0); #endif fprintf(stdout, "creating table\n"); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } fprintf(stdout, "insert\n"); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } fprintf(stdout, "select\n"); sql_cmd(dbproc); dbsqlexec(dbproc); if (dbresults(dbproc) != SUCCEED) { fprintf(stdout, "Was expecting a result set."); exit(1); } for (i = 1; i <= dbnumcols(dbproc); i++) printf("col %d is %s\n", i, dbcolname(dbproc, i)); dbbind(dbproc, 1, INTBIND, -1, (BYTE *) & testint); dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) teststr); if (REG_ROW != dbnextrow(dbproc)) { fprintf(stderr, "dblib failed for %s\n", __FILE__); exit(1); } if (0 != strcmp("abcdef ", teststr)) { fprintf(stderr, "Expected |%s|, found |%s|\n", "abcdef", teststr); fprintf(stderr, "dblib failed for %s\n", __FILE__); exit(1); } if (REG_ROW != dbnextrow(dbproc)) { fprintf(stderr, "dblib failed for %s\n", __FILE__); exit(1); } if (0 != strcmp("abc ", teststr)) { fprintf(stderr, "Expected |%s|, found |%s|\n", "abc", teststr); fprintf(stderr, "dblib failed for %s\n", __FILE__); exit(1); } dbexit(); printf("dblib passed for %s\n", __FILE__); return 0; } freetds-1.00.82/src/dblib/unittests/t0011.c100644 025423 025423 00000005650 12522201763 0013652/* * Purpose: Test binding of string types * Functions: dbbind dbcmd dbcolname dbnextrow dbnumcols dbopen dbresults dbsqlexec */ #include "common.h" static char software_version[] = "$Id: t0011.c,v 1.16 2009-02-27 15:52:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; int failed = 0; const char long_column[] = "This is a really long column to ensure that the next row ends properly."; const char short_column[] = "Short column"; void insert_row(DBPROCESS * dbproc); int select_rows(DBPROCESS * dbproc, int bind_type); int main(int argc, char **argv) { LOGINREC *login; DBPROCESS *dbproc; read_login_info(argc, argv); fprintf(stdout, "Starting %s\n", argv[0]); dbinit(); fprintf(stdout, "About to logon\n"); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "t0011"); fprintf(stdout, "About to open\n"); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); dbloginfree(login); fprintf(stdout, "Dropping table\n"); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } fprintf(stdout, "creating table\n"); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } fprintf(stdout, "insert\n"); insert_row(dbproc); insert_row(dbproc); insert_row(dbproc); failed = select_rows(dbproc, STRINGBIND); dbexit(); fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); return failed ? 1 : 0; } int select_rows(DBPROCESS * dbproc, int bind_type) { char teststr[1024]; char teststr2[1024]; char testvstr[1024]; DBINT testint; DBINT i; fprintf(stdout, "select\n"); sql_cmd(dbproc); dbsqlexec(dbproc); if (dbresults(dbproc) != SUCCEED) { failed = 1; fprintf(stdout, "Was expecting a result set."); exit(1); } for (i = 1; i <= dbnumcols(dbproc); i++) { printf("col %d is %s\n", i, dbcolname(dbproc, i)); } if (SUCCEED != dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint)) { fprintf(stderr, "Had problem with bind\n"); return 1; } if (SUCCEED != dbbind(dbproc, 2, bind_type, 0, (BYTE *) teststr)) { fprintf(stderr, "Had problem with bind\n"); return 1; } if (SUCCEED != dbbind(dbproc, 3, bind_type, 0, (BYTE *) teststr2)) { fprintf(stderr, "Had problem with bind\n"); return 1; } if (SUCCEED != dbbind(dbproc, 4, bind_type, 0, (BYTE *) testvstr)) { fprintf(stderr, "Had problem with bind\n"); return 1; } i = 0; while (dbnextrow(dbproc) == REG_ROW) { i++; if (testint != i) { fprintf(stdout, "Failed. Expected i to be |%d|, was |%d|\n", testint, i); return 1; } printf("c: %s$\n", teststr); printf("c2: %s$\n", teststr2); printf("vc: %s$\n", testvstr); if (bind_type == STRINGBIND) { } else { } } return 0; } void insert_row(DBPROCESS * dbproc) { sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } } freetds-1.00.82/src/dblib/unittests/t0012.c100644 025423 025423 00000010765 12627531420 0013660/* * Purpose: Test datetime conversion as well as dbdata() & dbdatlen() * Functions: dbcmd dbdata dbdatecrack dbdatlen dbnextrow dbresults dbsqlexec */ #include "common.h" static int failed = 0; static void set_failed(int line) { failed = 1; fprintf(stderr, "Failed check at line %d\n", line); } #define set_failed() set_failed(__LINE__) #ifdef MSDBLIB #define dateyear year #define datemonth month #define datedmonth day #define datedyear dayofyear #define datedweek weekday #define datehour hour #define dateminute minute #define datesecond second #define datemsecond millisecond #define datensecond nanosecond #endif static int ignore_msg_handler(DBPROCESS * dbproc, DBINT msgno, int state, int severity, char *text, char *server, char *proc, int line) { return 0; } int main(int argc, char *argv[]) { LOGINREC *login; DBPROCESS *dbproc; char datestring[256]; DBDATEREC dateinfo; #ifdef SYBMSDATETIME2 DBDATEREC2 dateinfo2; #endif DBDATETIME mydatetime; int output_count = 0; set_malloc_options(); read_login_info(argc, argv); fprintf(stdout, "Starting %s\n", argv[0]); dbinit(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "t0012"); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) { dbuse(dbproc, DATABASE); } dbloginfree(login); fprintf(stdout, "After logon\n"); fprintf(stdout, "creating table\n"); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) == SUCCEED) { /* nop */ } /* insert */ sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) == SUCCEED) { /* nop */ } /* insert */ sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) == SUCCEED) { /* nop */ } /* select */ sql_cmd(dbproc); dbsqlexec(dbproc); dbresults(dbproc); while (dbnextrow(dbproc) != NO_MORE_ROWS) { ++output_count; /* Print the date info */ dbconvert(dbproc, dbcoltype(dbproc, 1), dbdata(dbproc, 1), dbdatlen(dbproc, 1), SYBCHAR, (BYTE*) datestring, -1); printf("%s\n", datestring); /* Break up the creation date into its constituent parts */ memcpy(&mydatetime, (DBDATETIME *) (dbdata(dbproc, 1)), sizeof(DBDATETIME)); dbdatecrack(dbproc, &dateinfo, &mydatetime); /* Print the parts of the creation date */ printf("\tYear = %d.\n", dateinfo.dateyear); printf("\tMonth = %d.\n", dateinfo.datemonth); printf("\tDay of month = %d.\n", dateinfo.datedmonth); printf("\tDay of year = %d.\n", dateinfo.datedyear); printf("\tDay of week = %d.\n", dateinfo.datedweek); printf("\tHour = %d.\n", dateinfo.datehour); printf("\tMinute = %d.\n", dateinfo.dateminute); printf("\tSecond = %d.\n", dateinfo.datesecond); printf("\tMillisecond = %d.\n", dateinfo.datemsecond); if (dateinfo.dateyear != 1898 && dateinfo.dateyear != 2001) set_failed(); if (dateinfo.dateminute != 24 && dateinfo.dateminute != 30) set_failed(); if (dateinfo.datehour != 19 && dateinfo.datehour != 10) set_failed(); } dbresults(dbproc); if (output_count != 2) set_failed(); #ifdef SYBMSDATETIME2 dbmsghandle(ignore_msg_handler); /* select */ sql_cmd(dbproc); dbsqlexec(dbproc); dbresults(dbproc); while (dbnextrow(dbproc) != NO_MORE_ROWS) { int type = dbcoltype(dbproc, 1); ++output_count; /* Print the date info */ dbconvert(dbproc, type, dbdata(dbproc, 1), dbdatlen(dbproc, 1), SYBCHAR, (BYTE*) datestring, -1); printf("%s\n", datestring); /* network not high enough for this type ! */ if (type == SYBCHAR || type == SYBVARCHAR) break; /* Break up the creation date into its constituent parts */ if (dbanydatecrack(dbproc, &dateinfo2, dbcoltype(dbproc, 1), dbdata(dbproc, 1)) != SUCCEED) set_failed(); /* Print the parts of the creation date */ printf("\tYear = %d.\n", dateinfo2.dateyear); printf("\tMonth = %d.\n", dateinfo2.datemonth); printf("\tDay of month = %d.\n", dateinfo2.datedmonth); printf("\tDay of year = %d.\n", dateinfo2.datedyear); printf("\tDay of week = %d.\n", dateinfo2.datedweek); printf("\tHour = %d.\n", dateinfo2.datehour); printf("\tMinute = %d.\n", dateinfo2.dateminute); printf("\tSecond = %d.\n", dateinfo2.datesecond); printf("\tNanosecond = %d.\n", dateinfo2.datensecond); if (dateinfo2.dateyear != 1898 || dateinfo2.datensecond != 567000000) set_failed(); } #endif dbclose(dbproc); dbexit(); if (output_count < 2 || output_count > 3) set_failed(); fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); return failed ? 1 : 0; } freetds-1.00.82/src/dblib/unittests/t0013.c100644 025423 025423 00000014714 12717145107 0013662/* * Purpose: Test sending and receiving TEXT datatype * Functions: dbmoretext dbreadtext dbtxptr dbtxtimestamp dbwritetext */ #include "common.h" #define BLOB_BLOCK_SIZE 4096 int failed = 0; #define TABLE_NAME "freetds_dblib_t0013" char *testargs[] = { "", FREETDS_SRCDIR "/data.bin", "t0013.out" }; DBPROCESS *dbproc, *dbprocw; static void drop_table(void) { if (!dbproc) return; dbcancel(dbproc); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } } static int test(int argc, char **argv, int over4k) { LOGINREC *login; int i; DBINT testint; FILE *fp; long result, isiz; char *blob, *rblob; DBBINARY *textPtr = NULL, *timeStamp = NULL; char objname[256]; char rbuf[BLOB_BLOCK_SIZE]; long numread; int data_ok; int numtowrite, numwritten; set_malloc_options(); read_login_info(argc, argv); fprintf(stdout, "Starting %s\n", argv[0]); dbinit(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "t0013"); fprintf(stdout, "About to open, PASSWORD: %s, USER: %s, SERVER: %s\n", "", "", ""); /* PASSWORD, USER, SERVER); */ dbproc = dbopen(login, SERVER); dbprocw = dbopen(login, SERVER); if (strlen(DATABASE)) { dbuse(dbproc, DATABASE); dbuse(dbprocw, DATABASE); } dbloginfree(login); fprintf(stdout, "logged in\n"); if (argc == 1) { argv = testargs; argc = 3; } if (argc < 3) { fprintf(stderr, "Usage: %s infile outfile\n", argv[0]); return 1; } if ((fp = fopen(argv[1], "rb")) == NULL) { fprintf(stderr, "Cannot open input file: %s\n", argv[1]); return 2; } fprintf(stdout, "Reading binary input file\n"); fseek(fp, 0, SEEK_END); isiz = ftell(fp); fseek(fp, 0, SEEK_SET); blob = (char *) malloc(isiz); assert(blob); result = fread((void *) blob, isiz, 1, fp); assert(result == 1); fclose(fp); drop_table(); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } sql_cmd(dbproc); dbsqlexec(dbproc); if (dbresults(dbproc) != SUCCEED) { fprintf(stderr, "Error inserting blob\n"); return 4; } for (i=0; (result = dbnextrow(dbproc)) != NO_MORE_ROWS; i++) { assert(REG_ROW == result); printf("fetching row %d\n", i+1); strcpy(objname, TABLE_NAME ".PigTure"); textPtr = dbtxptr(dbproc, 1); timeStamp = dbtxtimestamp(dbproc, 1); break; /* can't proceed until no more rows */ } assert(REG_ROW == result || 0 < i); if (!textPtr && !timeStamp && dbtds(dbproc) >= DBTDS_7_2) { printf("Protocol 7.2+ detected, test not supported\n"); free(blob); dbclose(dbproc); dbproc = NULL; dbexit(); exit(0); } if (!textPtr) { fprintf(stderr, "Error getting textPtr\n"); exit(1); } /* * Use #ifdef if you want to test dbmoretext mode (needed for 16-bit apps) * Use #ifndef for big buffer version (32-bit) */ fprintf(stdout, "writing text ... "); if (over4k) { if (dbwritetext(dbprocw, objname, textPtr, DBTXPLEN, timeStamp, FALSE, isiz, (BYTE*) blob) != SUCCEED) return 5; fprintf(stdout, "done (in one shot)\n"); for (; (result = dbnextrow(dbproc)) != NO_MORE_ROWS; i++) { assert(REG_ROW == result); printf("fetching row %d?\n", i+1); } } else { if (dbwritetext(dbprocw, objname, textPtr, DBTXPLEN, timeStamp, FALSE, isiz, NULL) != SUCCEED) return 15; fprintf(stdout, "done\n"); fprintf(stdout, "dbsqlok\n"); dbsqlok(dbprocw); fprintf(stdout, "dbresults\n"); dbresults(dbprocw); numtowrite = 0; /* Send the update value in chunks. */ for (numwritten = 0; numwritten < isiz; numwritten += numtowrite) { fprintf(stdout, "dbmoretext %d\n", 1 + numwritten); numtowrite = (isiz - numwritten); if (numtowrite > BLOB_BLOCK_SIZE) numtowrite = BLOB_BLOCK_SIZE; dbmoretext(dbprocw, (DBINT) numtowrite, (BYTE *) (blob + numwritten)); } dbsqlok(dbprocw); while (dbresults(dbprocw) != NO_MORE_RESULTS){ printf("suprise!\n"); } } #if 0 if (SUCCEED != dbclose(dbproc)){ fprintf(stdout, "dbclose failed"); exit(1); } dbproc = dbopen(login, SERVER); assert(dbproc); if (strlen(DATABASE)) { dbuse(dbproc, DATABASE); } #endif sql_cmd(dbproc); dbsqlexec(dbproc); if (dbresults(dbproc) != SUCCEED) { failed = 1; fprintf(stdout, "Was expecting a result set."); exit(1); } for (i = 1; i <= dbnumcols(dbproc); i++) { printf("col %d, \"%s\", is type %s\n", i, dbcolname(dbproc, i), dbprtype(dbcoltype(dbproc, i))); } if (2 != dbnumcols(dbproc)) { fprintf(stderr, "Failed. Expected 2 columns\n"); exit(1); } if (SUCCEED != dbbind(dbproc, 1, INTBIND, -1, (BYTE *) & testint)) { fprintf(stderr, "Had problem with bind\n"); exit(1); } if (REG_ROW != dbnextrow(dbproc)) { fprintf(stderr, "Failed. Expected a row\n"); exit(1); } if (testint != 1) { failed = 1; fprintf(stderr, "Failed. Expected i to be %d, was %d\n", 1, (int) testint); exit(1); } dbnextrow(dbproc); /* get the image */ sql_cmd(dbproc); dbsqlexec(dbproc); dbresults(dbproc); fprintf(stdout, "select 2\n"); sql_cmd(dbproc); dbsqlexec(dbproc); if (dbresults(dbproc) != SUCCEED) { fprintf(stderr, "Error extracting blob\n"); return 6; } numread = 0; rblob = NULL; while ((result = dbreadtext(dbproc, rbuf, BLOB_BLOCK_SIZE)) != NO_MORE_ROWS) { if (result != 0) { /* this indicates not end of row */ rblob = (char*) realloc(rblob, result + numread); memcpy((void *) (rblob + numread), (void *) rbuf, result); numread += result; } } data_ok = 1; if (memcmp(blob, rblob, numread) != 0) { printf("Saving first blob data row to file: %s\n", argv[2]); if ((fp = fopen(argv[2], "wb")) == NULL) { fprintf(stderr, "Unable to open output file: %s\n", argv[2]); return 3; } fwrite((void *) rblob, numread, 1, fp); fclose(fp); failed = 1; data_ok = 0; } printf("Read blob data row %d --> %s %ld byte comparison\n", (int) testint, data_ok ? "PASSED" : "failed", numread); free(rblob); if (dbnextrow(dbproc) != NO_MORE_ROWS) { failed = 1; fprintf(stderr, "Was expecting no more rows\n"); exit(1); } free(blob); drop_table(); dbclose(dbproc); dbproc = NULL; dbexit(); return 0; } int main(int argc, char **argv) { int res = test(argc, argv, 0); if (!res) res = test(argc, argv, 1); if (res) return res; fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); return failed ? 1 : 0; } freetds-1.00.82/src/dblib/unittests/t0014.c100644 025423 025423 00000014014 12717145107 0013654/* * Purpose: Test sending and receiving TEXT datatype * Functions: dbbind dbmoretext dbreadtext dbtxptr dbtxtimestamp dbwritetext */ #include "common.h" #define BLOB_BLOCK_SIZE 4096 char *testargs[] = { "", FREETDS_SRCDIR "/data.bin", "t0014.out" }; static int test(int argc, char **argv, int over4k) { const int rows_to_add = 3; LOGINREC *login; DBPROCESS *dbproc; DBPROCESS *blobproc; int i; DBINT testint; FILE *fp; long result, isiz; char *blob, *rblob; unsigned char *textPtr, *timeStamp; char objname[256]; char sqlCmd[256]; char rbuf[BLOB_BLOCK_SIZE]; long numread; int numtowrite, numwritten; set_malloc_options(); read_login_info(argc, argv); fprintf(stdout, "Starting %s\n", argv[0]); dbinit(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "t0014"); fprintf(stdout, "About to open %s..%s for user '%s'\n", SERVER, DATABASE, USER); dbproc = dbopen(login, SERVER); blobproc = dbopen(login, SERVER); if (strlen(DATABASE)) { dbuse(dbproc, DATABASE); dbuse(blobproc, DATABASE); } dbloginfree(login); fprintf(stdout, "After logon\n"); fprintf(stdout, "About to read binary input file\n"); if (argc == 1) { argv = testargs; argc = 3; } if (argc < 3) { fprintf(stderr, "Usage: %s infile outfile\n", argv[0]); return 1; } if ((fp = fopen(argv[1], "rb")) == NULL) { fprintf(stderr, "Cannot open input file: %s\n", argv[1]); return 2; } result = fseek(fp, 0, SEEK_END); isiz = ftell(fp); result = fseek(fp, 0, SEEK_SET); blob = (char *) malloc(isiz); result = fread((void *) blob, isiz, 1, fp); assert(result == 1); fclose(fp); /* FIXME this test seem to not work using temporary tables (sybase?)... */ fprintf(stdout, "Dropping table\n"); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } fprintf(stdout, "creating table\n"); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } fprintf(stdout, "insert\n"); for (i = 0; i < rows_to_add; i++) { sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } } for (i = 0; i < rows_to_add; i++) { sql_cmd(dbproc); dbsqlexec(dbproc); if (dbresults(dbproc) != SUCCEED) { fprintf(stderr, "Error inserting blob\n"); return 4; } while ((result = dbnextrow(dbproc)) != NO_MORE_ROWS) { result = REG_ROW; result = DBTXPLEN; strcpy(objname, "dblib0014.PigTure"); textPtr = dbtxptr(dbproc, 1); timeStamp = dbtxtimestamp(dbproc, 1); if (!textPtr && !timeStamp && dbtds(dbproc) >= DBTDS_7_2) { printf("Protocol 7.2+ detected, test not supported\n"); free(blob); dbexit(); exit(0); } /* * Use #ifdef if you want to test dbmoretext mode (needed for 16-bit apps) * Use #ifndef for big buffer version (32-bit) */ if (over4k) { if (dbwritetext(blobproc, objname, textPtr, DBTXPLEN, timeStamp, TRUE, isiz, (BYTE*) blob) != SUCCEED) return 5; } else { if (dbwritetext(blobproc, objname, textPtr, DBTXPLEN, timeStamp, TRUE, isiz, NULL) != SUCCEED) return 15; dbsqlok(blobproc); dbresults(blobproc); numtowrite = 0; /* Send the update value in chunks. */ for (numwritten = 0; numwritten < isiz; numwritten += numtowrite) { numtowrite = (isiz - numwritten); if (numtowrite > BLOB_BLOCK_SIZE) numtowrite = BLOB_BLOCK_SIZE; dbmoretext(blobproc, (DBINT) numtowrite, (BYTE *) (blob + numwritten)); } dbsqlok(blobproc); while (dbresults(blobproc) != NO_MORE_RESULTS) continue; } } } fprintf(stdout, "select\n"); sql_cmd(dbproc); dbsqlexec(dbproc); if (dbresults(dbproc) != SUCCEED) { fprintf(stdout, "Was expecting a result set."); exit(1); } for (i = 1; i <= dbnumcols(dbproc); i++) { printf("col %d is %s\n", i, dbcolname(dbproc, i)); } if (SUCCEED != dbbind(dbproc, 1, INTBIND, -1, (BYTE *) & testint)) { fprintf(stderr, "Had problem with bind\n"); abort(); } for (i = 0; i < rows_to_add; i++) { char expected[1024]; sprintf(expected, "row %03d", i); if (REG_ROW != dbnextrow(dbproc)) { fprintf(stderr, "Failed. Expected a row\n"); exit(1); } if (testint != i) { fprintf(stderr, "Failed. Expected i to be %d, was %d\n", i, (int) testint); abort(); } /* get the image */ strcpy(sqlCmd, "SET TEXTSIZE 2147483647"); dbcmd(blobproc, sqlCmd); dbsqlexec(blobproc); if (dbresults(blobproc) != SUCCEED) { dbcancel(blobproc); return 16; } sprintf(sqlCmd, "SELECT PigTure FROM dblib0014 WHERE i = %d", i); dbcmd(blobproc, sqlCmd); dbsqlexec(blobproc); if (dbresults(blobproc) != SUCCEED) { fprintf(stderr, "Error extracting blob\n"); return 6; } numread = 0; rblob = NULL; while ((result = dbreadtext(blobproc, rbuf, BLOB_BLOCK_SIZE)) != NO_MORE_ROWS) { if (result != 0) { /* this indicates not end of row */ rblob = (char*) realloc(rblob, result + numread); memcpy((void *) (rblob + numread), (void *) rbuf, result); numread += result; } } if (i == 0) { printf("Saving first blob data row to file: %s\n", argv[2]); if ((fp = fopen(argv[2], "wb")) == NULL) { fprintf(stderr, "Unable to open output file: %s\n", argv[2]); return 3; } result = fwrite((void *) rblob, numread, 1, fp); fclose(fp); } printf("Read blob data row %d --> %s %ld byte comparison\n", (int) testint, (memcmp(blob, rblob, numread)) ? "failed" : "PASSED", numread); free(rblob); } if (dbnextrow(dbproc) != NO_MORE_ROWS) { fprintf(stderr, "Was expecting no more rows\n"); exit(1); } free(blob); fprintf(stdout, "Dropping table\n"); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } dbexit(); return 0; } int main(int argc, char **argv) { int res; res = test(argc, argv, 0); if (!res) res = test(argc, argv, 1); if (res) return res; fprintf(stdout, "dblib okay on %s\n", __FILE__); return 0; } freetds-1.00.82/src/dblib/unittests/t0015.c100644 025423 025423 00000006123 12717145107 0013657/* * Purpose: Test binding and retrieving strings and ints, and cancelling results * Functions: dbbind dbcancel dbnextrow dbnumcols dbresults dbsqlexec */ #include "common.h" int failed = 0; int main(int argc, char **argv) { const int rows_to_add = 50; LOGINREC *login; DBPROCESS *dbproc; int i; char teststr[1024]; DBINT testint; set_malloc_options(); read_login_info(argc, argv); fprintf(stdout, "Starting %s\n", argv[0]); /* Fortify_EnterScope(); */ dbinit(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "t0015"); fprintf(stdout, "About to open\n"); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); dbloginfree(login); fprintf(stdout, "creating table\n"); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } fprintf(stdout, "insert\n"); for (i = 0; i < rows_to_add; i++) { sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } } fprintf(stdout, "select\n"); sql_cmd(dbproc); dbsqlexec(dbproc); if (dbresults(dbproc) != SUCCEED) { failed = 1; fprintf(stdout, "Was expecting a result set."); exit(1); } for (i = 1; i <= dbnumcols(dbproc); i++) printf("col %d is %s\n", i, dbcolname(dbproc, i)); if (SUCCEED != dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint)) { failed = 1; fprintf(stderr, "Had problem with bind\n"); abort(); } if (SUCCEED != dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) teststr)) { failed = 1; fprintf(stderr, "Had problem with bind\n"); abort(); } if (REG_ROW != dbnextrow(dbproc)) { failed = 1; fprintf(stderr, "Failed. Expected a row\n"); exit(1); } dbcancel(dbproc); fprintf(stdout, "select 2\n"); sql_cmd(dbproc); dbsqlexec(dbproc); if (dbresults(dbproc) != SUCCEED) { failed = 1; fprintf(stdout, "Was expecting a result set."); exit(1); } if (SUCCEED != dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint)) { failed = 1; fprintf(stderr, "Had problem with bind\n"); abort(); } if (SUCCEED != dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) teststr)) { failed = 1; fprintf(stderr, "Had problem with bind\n"); abort(); } for (i = 26; i < rows_to_add; i++) { char expected[1024]; sprintf(expected, "row %03d", i); if (REG_ROW != dbnextrow(dbproc)) { failed = 1; fprintf(stderr, "Failed. Expected a row\n"); exit(1); } if (testint != i) { failed = 1; fprintf(stderr, "Failed. Expected i to be %d, was %d\n", i, (int) testint); abort(); } if (0 != strncmp(teststr, expected, strlen(expected))) { failed = 1; fprintf(stdout, "Failed. Expected s to be |%s|, was |%s|\n", expected, teststr); abort(); } printf("Read a row of data -> %d %s\n", (int) testint, teststr); } if (dbnextrow(dbproc) != NO_MORE_ROWS) { failed = 1; fprintf(stderr, "Was expecting no more rows\n"); exit(1); } dbexit(); fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); return failed ? 1 : 0; } freetds-1.00.82/src/dblib/unittests/t0016.c100644 025423 025423 00000015044 12522201763 0013655/* * Purpose: Test bcp in and out, and specifically bcp_colfmt() * Functions: bcp_colfmt bcp_columns bcp_exec bcp_init */ #include "common.h" static int failed = 0; static void failure(const char *fmt, ...) { va_list ap; failed = 1; va_start(ap, fmt); vfprintf(stderr, fmt, ap); va_end(ap); } #define INFILE_NAME "t0016" #define TABLE_NAME "#dblib0016" static void test_file(const char *fn); static int compare_files(const char *fn1, const char *fn2); static unsigned count_file_rows(FILE *f); static DBPROCESS *dbproc; int main(int argc, char *argv[]) { LOGINREC *login; char in_file[30]; unsigned int n; setbuf(stdout, NULL); setbuf(stderr, NULL); set_malloc_options(); read_login_info(argc, argv); printf("Starting %s\n", argv[0]); dbinit(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); printf("About to logon\n"); login = dblogin(); BCP_SETL(login, TRUE); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "t0016"); DBSETLCHARSET(login, "UTF-8"); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) { dbuse(dbproc, DATABASE); } dbloginfree(login); printf("After logon\n"); strcpy(in_file, INFILE_NAME); for (n = 1; n <= 100; ++n) { test_file(in_file); sprintf(in_file, "%s_%d", INFILE_NAME, n); if (sql_reopen(in_file) != SUCCEED) break; } dbclose(dbproc); dbexit(); printf("dblib %s on %s\n", (failed ? "failed!" : "okay"), __FILE__); return failed ? 1 : 0; } static int got_error = 0; static int ignore_msg_handler(DBPROCESS * dbproc, DBINT msgno, int state, int severity, char *text, char *server, char *proc, int line) { got_error = 1; return 0; } static int ignore_err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr) { got_error = 1; return INT_CANCEL; } static char line1[1024*16]; static char line2[1024*16]; static void test_file(const char *fn) { int i; RETCODE ret; int num_cols = 0; const char *out_file = "t0016.out"; const char *err_file = "t0016.err"; DBINT rows_copied; unsigned num_rows = 2; FILE *input_file; char in_file[256]; snprintf(in_file, sizeof(in_file), "%s/%s.in", FREETDS_SRCDIR, fn); input_file = fopen(in_file, "rb"); if (!input_file) { sprintf(in_file, "%s.in", fn); input_file = fopen(in_file, "rb"); } if (!input_file) { fprintf(stderr, "could not open %s\n", in_file); exit(1); } num_rows = count_file_rows(input_file); fclose(input_file); dberrhandle(ignore_err_handler); dbmsghandle(ignore_msg_handler); printf("Creating table '%s'\n", TABLE_NAME); got_error = 0; sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) continue; dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); if (got_error) return; /* BCP in */ printf("bcp_init with in_file as '%s'\n", in_file); ret = bcp_init(dbproc, TABLE_NAME, in_file, err_file, DB_IN); if (ret != SUCCEED) failure("bcp_init failed\n"); printf("return from bcp_init = %d\n", ret); ret = sql_cmd(dbproc); printf("return from dbcmd = %d\n", ret); ret = dbsqlexec(dbproc); printf("return from dbsqlexec = %d\n", ret); if (dbresults(dbproc) != FAIL) { num_cols = dbnumcols(dbproc); printf("Number of columns = %d\n", num_cols); while (dbnextrow(dbproc) != NO_MORE_ROWS) { } } ret = bcp_columns(dbproc, num_cols); if (ret != SUCCEED) failure("bcp_columns failed\n"); printf("return from bcp_columns = %d\n", ret); for (i = 1; i < num_cols; i++) { if ((ret = bcp_colfmt(dbproc, i, SYBCHAR, 0, -1, (const BYTE *) "\t", sizeof(char), i)) == FAIL) failure("return from bcp_colfmt = %d\n", ret); } if ((ret = bcp_colfmt(dbproc, num_cols, SYBCHAR, 0, -1, (const BYTE *) "\n", sizeof(char), num_cols)) == FAIL) failure("return from bcp_colfmt = %d\n", ret); ret = bcp_exec(dbproc, &rows_copied); if (ret != SUCCEED || rows_copied != num_rows) failure("bcp_exec failed\n"); printf("%d rows copied in\n", rows_copied); /* BCP out */ rows_copied = 0; ret = bcp_init(dbproc, TABLE_NAME, out_file, err_file, DB_OUT); if (ret != SUCCEED) failure("bcp_int failed\n"); printf("select\n"); sql_cmd(dbproc); dbsqlexec(dbproc); if (dbresults(dbproc) != FAIL) { num_cols = dbnumcols(dbproc); while (dbnextrow(dbproc) != NO_MORE_ROWS) { } } ret = bcp_columns(dbproc, num_cols); for (i = 1; i < num_cols; i++) { if ((ret = bcp_colfmt(dbproc, i, SYBCHAR, 0, -1, (const BYTE *) "\t", sizeof(char), i)) == FAIL) failure("return from bcp_colfmt = %d\n", ret); } if ((ret = bcp_colfmt(dbproc, num_cols, SYBCHAR, 0, -1, (const BYTE *) "\n", sizeof(char), num_cols)) == FAIL) failure("return from bcp_colfmt = %d\n", ret); ret = bcp_exec(dbproc, &rows_copied); if (ret != SUCCEED || rows_copied != num_rows) failure("bcp_exec failed\n"); printf("%d rows copied out\n", rows_copied); printf("Dropping table '%s'\n", TABLE_NAME); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) continue; if (failed) return; if (compare_files(in_file, out_file)) printf("Input and output files are equal\n"); else failed = 1; } static size_t fgets_raw(char *s, int len, FILE *f) { char *p = s; while (len > 1) { int c = getc(f); if (c == EOF) { if (ferror(f)) return 0; break; } *p++ = c; --len; if (c == '\n') break; } if (len > 0) *p = 0; return p - s; } static int compare_files(const char *fn1, const char *fn2) { int equal = 1; FILE *f1, *f2; size_t s1, s2; /* check input and output should be the same */ f1 = fopen(fn1, "r"); f2 = fopen(fn2, "r"); if (f1 != NULL && f2 != NULL) { int line = 1; for (;; ++line) { s1 = fgets_raw(line1, sizeof(line1), f1); s2 = fgets_raw(line2, sizeof(line2), f2); /* EOF or error of one */ if (!!s1 != !!s2) { equal = 0; failure("error reading a file or EOF of a file\n"); break; } /* EOF or error of both */ if (!s1) { if (feof(f1) && feof(f2)) break; equal = 0; failure("error reading a file\n"); break; } if (s1 != s2 || memcmp(line1, line2, s1) != 0) { equal = 0; failure("File different at line %d\n" " input: %s" " output: %s", line, line1, line2); } } } else { equal = 0; failure("error opening files\n"); } if (f1) fclose(f1); if (f2) fclose(f2); return equal; } static unsigned count_file_rows(FILE *f) { size_t s; unsigned rows = 1; char last = '\n'; assert(f); while ((s = fgets_raw(line1, sizeof(line1), f)) != 0) { last = line1[s-1]; if (last == '\n') ++rows; } if (last == '\n') --rows; assert(!ferror(f)); return rows; } freetds-1.00.82/src/dblib/unittests/t0017.c100644 025423 025423 00000011475 12522201763 0013662/* * Purpose: Test bcp in, with dbvarylen() * Functions: bcp_colfmt bcp_columns bcp_exec bcp_init dbvarylen */ #include "common.h" #include static char software_version[] = "$Id: t0017.c,v 1.29 2009-02-27 15:52:48 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; int failed = 0; int main(int argc, char *argv[]) { LOGINREC *login; DBPROCESS *dbproc; int i; RETCODE ret; int big_endian = 1; char *out_file = "t0017.out"; static const char in_file_le[] = FREETDS_SRCDIR "/t0017.in"; static const char in_file_be[] = FREETDS_SRCDIR "/t0017.in.be"; const char *in_file = in_file_le; const char *err_file = "t0017.err"; DBINT rows_copied; int num_cols = 0; int col_type[256]; DBBOOL col_varylen[256]; int prefix_len; if (((char *) &big_endian)[0] == 1) big_endian = 0; if (big_endian) in_file = in_file_be; setbuf(stdout, NULL); setbuf(stderr, NULL); set_malloc_options(); read_login_info(argc, argv); printf("Starting %s\n", software_version); dbinit(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); printf("About to logon ... "); login = dblogin(); assert(login); BCP_SETL(login, TRUE); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "t0017"); printf("done\n"); printf("Opening \"%s\" for \"%s\" ... ", SERVER, USER); dbproc = dbopen(login, SERVER); assert(dbproc); if (strlen(DATABASE)) { dbuse(dbproc, DATABASE); } dbloginfree(login); printf("done\n"); printf("Creating table ... "); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } printf("done\n"); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } /* BCP out */ printf("bcp_init... "); ret = bcp_init(dbproc, "#dblib0017", out_file, err_file, DB_OUT); if (ret != SUCCEED) failed = 1; printf("done\n"); printf("Issuing SELECT ... "); sql_cmd(dbproc); dbsqlexec(dbproc); printf("done\nFetching metadata ... "); if (dbresults(dbproc) != FAIL) { num_cols = dbnumcols(dbproc); for (i = 0; i < num_cols; ++i) { col_type[i] = dbcoltype(dbproc, i + 1); col_varylen[i] = dbvarylen(dbproc, i + 1); } while (dbnextrow(dbproc) != NO_MORE_ROWS) { } } printf("done\n"); printf("bcp_columns ... "); ret = bcp_columns(dbproc, num_cols); if (ret != SUCCEED) failed = 1; for (i = 0; i < num_cols; i++) { prefix_len = 0; if (col_type[i] == SYBIMAGE || col_type[i] == SYBTEXT) { prefix_len = 4; } else if (col_varylen[i]) { prefix_len = 1; } printf("bind %d prefix %d col_type %s\n", i, prefix_len, col_type[i] == SYBIMAGE ? "image" : "other"); ret = bcp_colfmt(dbproc, i + 1, col_type[i], prefix_len, -1, NULL, 0, i + 1); if (ret == FAIL) { fprintf(stderr, "return from bcp_colfmt = %d\n", ret); failed = 1; } } printf("done\n"); rows_copied = -1; printf("bcp_exec ... "); ret = bcp_exec(dbproc, &rows_copied); if (ret != SUCCEED || rows_copied != 1) failed = 1; printf("%d rows copied\n", rows_copied); /* delete rows */ sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } /* * BCP in */ printf("bcp_init... "); ret = bcp_init(dbproc, "#dblib0017", in_file, err_file, DB_IN); if (ret != SUCCEED) failed = 1; printf("done\n"); printf("Issuing SELECT ... "); sql_cmd(dbproc); dbsqlexec(dbproc); printf("done\nFetching metadata ... "); if (dbresults(dbproc) != FAIL) { num_cols = dbnumcols(dbproc); for (i = 0; i < num_cols; i++) { col_type[i] = dbcoltype(dbproc, i + 1); col_varylen[i] = dbvarylen(dbproc, i + 1); } while (dbnextrow(dbproc) != NO_MORE_ROWS) { } } while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } printf("done\n"); printf("bcp_columns ... "); ret = bcp_columns(dbproc, num_cols); if (ret != SUCCEED) failed = 1; for (i = 0; i < num_cols; i++) { prefix_len = 0; if (col_type[i] == SYBIMAGE || col_type[i] == SYBTEXT) { prefix_len = 4; } else if (col_varylen[i]) { prefix_len = 1; } ret = bcp_colfmt(dbproc, i + 1, col_type[i], prefix_len, -1, NULL, 0, i + 1); if (ret == FAIL) { fprintf(stderr, "return from bcp_colfmt = %d\n", ret); failed = 1; } } printf("done\n"); printf("bcp_exec ... "); rows_copied = -1; ret = bcp_exec(dbproc, &rows_copied); if (ret != SUCCEED || rows_copied != 1) failed = 1; printf("done\n"); /* test we inserted correctly row */ if (!failed) { sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { while ((ret=dbnextrow(dbproc)) != NO_MORE_ROWS) { fprintf(stderr, "Invalid dbnextrow result %d executing query\n", ret); failed = 1; } } } printf("%d rows copied\n", rows_copied); dbclose(dbproc); dbexit(); printf("dblib %s on %s\n", (failed ? "failed!" : "okay"), __FILE__); return failed ? 1 : 0; } freetds-1.00.82/src/dblib/unittests/t0018.c100644 025423 025423 00000006723 12717145107 0013670/* * Purpose: Test behaviour of DBCOUNT() for updates and inserts * Functions: DBCOUNT dbbind dbnextrow dbnumcols dbopen dbresults dbsqlexec */ #include "common.h" int failed = 0; int main(int argc, char **argv) { const int rows_to_add = 50; LOGINREC *login; DBPROCESS *dbproc; int i; char teststr[1024]; DBINT testint; set_malloc_options(); read_login_info(argc, argv); fprintf(stdout, "Starting %s\n", argv[0]); /* Fortify_EnterScope(); */ dbinit(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "t0018"); fprintf(stdout, "About to open\n"); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); dbloginfree(login); fprintf(stdout, "creating table\n"); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } fprintf(stdout, "insert\n"); for (i = 0; i < rows_to_add; i++) { sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } if (DBCOUNT(dbproc) != 1) { failed = 1; fprintf(stdout, "Was expecting a rows affect to be 1."); exit(1); } } fprintf(stdout, "select\n"); sql_cmd(dbproc); dbsqlexec(dbproc); fprintf(stdout, "Checking for an empty result set.\n"); if (dbresults(dbproc) != SUCCEED) { failed = 1; fprintf(stdout, "Was expecting a result set.\n"); exit(1); } if(DBROWS(dbproc) != FAIL) { failed = 1; fprintf(stdout, "Was expecting no rows to be available.\n"); exit(1); } fprintf(stdout, "Checking for a result set with content.\n"); if (dbresults(dbproc) != SUCCEED) { failed = 1; fprintf(stdout, "Was expecting a result set."); exit(1); } for (i = 1; i <= dbnumcols(dbproc); i++) printf("col %d is %s\n", i, dbcolname(dbproc, i)); if (SUCCEED != dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint)) { failed = 1; fprintf(stderr, "Had problem with bind\n"); abort(); } if (SUCCEED != dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) teststr)) { failed = 1; fprintf(stderr, "Had problem with bind\n"); abort(); } for (i = 0; i < rows_to_add; i++) { char expected[1024]; sprintf(expected, "row %03d", i); if (REG_ROW != dbnextrow(dbproc)) { failed = 1; fprintf(stderr, "Failed. Expected a row\n"); exit(1); } if (testint != i) { failed = 1; fprintf(stderr, "Failed. Expected i to be %d, was %d\n", i, (int) testint); abort(); } if (0 != strncmp(teststr, expected, strlen(expected))) { failed = 1; fprintf(stdout, "Failed. Expected s to be |%s|, was |%s|\n", expected, teststr); abort(); } printf("Read a row of data -> %d %s\n", (int) testint, teststr); } if (dbnextrow(dbproc) != NO_MORE_ROWS) { failed = 1; fprintf(stderr, "Was expecting no more rows\n"); exit(1); } if (DBCOUNT(dbproc) != rows_to_add) { failed = 1; fprintf(stdout, "Was expecting a rows affect to be %d was %d.\n", rows_to_add, DBCOUNT(dbproc)); exit(1); } sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } if (DBCOUNT(dbproc) != rows_to_add) { failed = 1; fprintf(stdout, "Was expecting a rows affect to be %d was %d.\n", rows_to_add, DBCOUNT(dbproc)); exit(1); } else { fprintf(stdout, "Number of rows affected by update = %d.\n", DBCOUNT(dbproc)); } dbexit(); fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); return failed ? 1 : 0; } freetds-1.00.82/src/dblib/unittests/t0019.c100644 025423 025423 00000007616 12717145107 0013673/* * Purpose: Test Some conversion, check trimming error and results * Functions: dbconvert dberrhandle dbmsghandle dbinit dbexit */ #include "common.h" #include static int failure = 0; static const char *cur_result = ""; static const char *cur_test = ""; static int cur_line = 0; int test(int srctype, const void *srcdata, int srclen, int dsttype, int dstlen); int err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr); int err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr) { /* * For server messages, cancel the query and rely on the * message handler to spew the appropriate error messages out. */ if (dberr == SYBESMSG) return INT_CANCEL; if (dberr == 20049) { fprintf(stderr, "OK: anticipated error %d (%s) arrived\n", dberr, dberrstr); } else { fprintf(stderr, "DB-LIBRARY error (severity %d, dberr %d, oserr %d, dberrstr %s, oserrstr %s):\n", severity, dberr, oserr, dberrstr ? dberrstr : "(null)", oserrstr ? oserrstr : "(null)"); } fflush(stderr); return INT_CANCEL; } int test(int srctype, const void *srcdata, int srclen, int dsttype, int dstlen) { DBCHAR buf[10]; char s[20], *p; int i, len, correct; char out[256]; memset(buf, '*', sizeof(buf)); len = dbconvert(NULL, srctype, (const BYTE*) srcdata, srclen, dsttype, (BYTE*) buf, dstlen); /* build result string */ sprintf(out, "len=%d", len); p = s; for (i = 0; i < sizeof(buf); ++i) { *p++ = isprint((unsigned char) buf[i]) ? buf[i] : '.'; sprintf(strchr(out, 0), " %02X", (unsigned char) buf[i]); } *p = 0; correct = 0; if (len == -1) { if (strcmp(cur_result, "error") == 0) correct = 1; } else { if (strcmp(cur_result, out) == 0) correct = 1; } if (!correct) { failure = 1; printf("\nline: %d test: %s\n" "%s\n%s\n" "failed :( should be '%s'\n", cur_line, cur_test, s, out, cur_result); } return 0; } #define TEST(s,out) \ { cur_result = out; cur_line = __LINE__; cur_test = #s; test s; } int main(int argc, char *argv[]) { if (dbinit() == FAIL) return 1; dberrhandle(err_handler); dbmsghandle(syb_msg_handler); TEST((SYBBINARY, "ciao\0\0", 6, SYBBINARY, -2), "len=6 63 69 61 6F 00 00 2A 2A 2A 2A"); TEST((SYBCHAR, "ciao ", 6, SYBCHAR, -2), "len=6 63 69 61 6F 20 20 00 2A 2A 2A"); TEST((SYBCHAR, "ciao\0\0", 6, SYBCHAR, -2), "len=6 63 69 61 6F 00 00 00 2A 2A 2A"); TEST((SYBCHAR, "ciao ", 6, SYBCHAR, -1), "len=4 63 69 61 6F 00 2A 2A 2A 2A 2A"); TEST((SYBCHAR, "ciao\0\0", 6, SYBCHAR, -1), "len=6 63 69 61 6F 00 00 00 2A 2A 2A"); TEST((SYBCHAR, "ciao ", 6, SYBCHAR, 8), "len=6 63 69 61 6F 20 20 20 20 2A 2A"); TEST((SYBCHAR, "ciao\0\0", 6, SYBCHAR, 8), "len=6 63 69 61 6F 00 00 20 20 2A 2A"); TEST((SYBCHAR, "ciao ", 6, SYBCHAR, 4), "error"); TEST((SYBCHAR, "ciao\0\0", 6, SYBCHAR, 4), "error"); TEST((SYBCHAR, "ciao ", 6, SYBCHAR, 6), "len=6 63 69 61 6F 20 20 2A 2A 2A 2A"); TEST((SYBCHAR, "ciao\0\0", 6, SYBCHAR, 6), "len=6 63 69 61 6F 00 00 2A 2A 2A 2A"); /* convert from NULL to BINARY */ TEST((SYBBINARY, "", 0, SYBBINARY, 6), "len=6 00 00 00 00 00 00 2A 2A 2A 2A"); TEST((SYBVARBINARY, "", 0, SYBBINARY, 6), "len=6 00 00 00 00 00 00 2A 2A 2A 2A"); TEST((SYBIMAGE, "", 0, SYBBINARY, 6), "len=6 00 00 00 00 00 00 2A 2A 2A 2A"); TEST((SYBBINARY, "", 0, SYBVARBINARY, 6), "len=6 00 00 00 00 00 00 2A 2A 2A 2A"); TEST((SYBVARBINARY, "", 0, SYBVARBINARY, 6), "len=6 00 00 00 00 00 00 2A 2A 2A 2A"); TEST((SYBIMAGE, "", 0, SYBVARBINARY, 6), "len=6 00 00 00 00 00 00 2A 2A 2A 2A"); TEST((SYBBINARY, "", 0, SYBIMAGE, 6), "len=6 00 00 00 00 00 00 2A 2A 2A 2A"); TEST((SYBVARBINARY, "", 0, SYBIMAGE, 6), "len=6 00 00 00 00 00 00 2A 2A 2A 2A"); TEST((SYBIMAGE, "", 0, SYBIMAGE, 6), "len=6 00 00 00 00 00 00 2A 2A 2A 2A"); TEST((SYBBINARY, "", 0, SYBBINARY, -1), "len=0 2A 2A 2A 2A 2A 2A 2A 2A 2A 2A"); dbexit(); if (!failure) printf("All tests passed!\n"); return failure; } freetds-1.00.82/src/dblib/unittests/t0020.c100644 025423 025423 00000004040 12717145107 0013647/* * Purpose: Test for proper return code from dbsqlexec() * Functions: db_name dbcmd dberrhandle dbmsghandle dbnextrow dbopen dbresults dbsqlexec */ #include "common.h" int failed = 0; int err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr); /* * The bad column name message has severity 16, causing db-lib to call the error handler after calling the message handler. * This wrapper anticipates that behavior, and again sets the userdata, telling the handler this error is expected. */ int err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr) { int expected_error = 207; dbsetuserdata(dbproc, (BYTE*) &expected_error); return syb_err_handler(dbproc, severity, dberr, oserr, dberrstr, oserrstr); } int main(int argc, char **argv) { LOGINREC *login; DBPROCESS *dbproc; RETCODE ret; int expected_error; set_malloc_options(); read_login_info(argc, argv); fprintf(stdout, "Starting %s\n", argv[0]); /* Fortify_EnterScope(); */ dbinit(); dberrhandle(err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "t0020"); fprintf(stdout, "About to open\n"); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); dbloginfree(login); sql_cmd(dbproc); fprintf(stderr, "The following invalid column error is normal.\n"); expected_error = 207; dbsetuserdata(dbproc, (BYTE*) &expected_error); ret = dbsqlexec(dbproc); if (ret != FAIL) { failed = 1; fprintf(stderr, "Failed. Expected FAIL to be returned.\n"); exit(1); } sql_cmd(dbproc); ret = dbsqlexec(dbproc); if (ret != SUCCEED) { failed = 1; fprintf(stderr, "Failed. Expected SUCCEED to be returned.\n"); exit(1); } while (dbresults(dbproc) != NO_MORE_RESULTS) { while (dbnextrow(dbproc) != NO_MORE_ROWS) continue; } dbexit(); fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); return failed ? 1 : 0; } freetds-1.00.82/src/dblib/unittests/t0021.c100644 025423 025423 00000003173 12522201763 0013651/* * Purpose: Test dbsafestr() * Functions: dbsafestr */ #include "common.h" static char software_version[] = "$Id: t0021.c,v 1.15 2009-03-19 13:11:41 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #ifndef DBNTWIN32 int failed = 0; /* unsafestr must contain one quote of each type */ const char *unsafestr = "This is a string with ' and \" in it."; /* safestr must be at least strlen(unsafestr) + 3 */ char safestr[100]; int main(int argc, char **argv) { int len; RETCODE ret; set_malloc_options(); fprintf(stdout, "Starting %s\n", argv[0]); /* Fortify_EnterScope(); */ dbinit(); len = strlen(unsafestr); ret = dbsafestr(NULL, unsafestr, -1, safestr, len, DBSINGLE); if (ret != FAIL) failed++; fprintf(stdout, "short buffer, single\n%s\n", safestr); /* plus one for termination and one for the quote */ ret = dbsafestr(NULL, unsafestr, -1, safestr, len + 2, DBSINGLE); if (ret != SUCCEED) failed++; if (strlen(safestr) != len + 1) failed++; fprintf(stdout, "single quote\n%s\n", safestr); ret = dbsafestr(NULL, unsafestr, -1, safestr, len + 2, DBDOUBLE); if (ret != SUCCEED) failed++; if (strlen(safestr) != len + 1) failed++; fprintf(stdout, "double quote\n%s\n", safestr); ret = dbsafestr(NULL, unsafestr, -1, safestr, len + 3, DBBOTH); if (ret != SUCCEED) failed++; if (strlen(safestr) != len + 2) failed++; fprintf(stdout, "both quotes\n%s\n", safestr); dbexit(); fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); return failed ? 1 : 0; } #else int main(void) { fprintf(stderr, "Not supported by MS DBLib\n"); return 0; } #endif freetds-1.00.82/src/dblib/unittests/t0022.c100644 025423 025423 00000013255 12717145107 0013661/* * Purpose: Test retrieving output parameters and return status * Functions: DBTDS dbnumrets dbresults dbretdata dbretlen dbretname dbrettype dbsqlexec */ #include "common.h" #include int main(int argc, char **argv) { LOGINREC *login; DBPROCESS *dbproc; int i; char teststr[1024]; int erc, failed = 0; char *retname = NULL; int rettype = 0, retlen = 0; set_malloc_options(); read_login_info(argc, argv); fprintf(stdout, "Starting %s\n", argv[0]); dbinit(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "t0022"); fprintf(stdout, "About to open\n"); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); dbloginfree(login); fprintf(stdout, "Dropping proc\n"); sql_cmd(dbproc); dbsqlexec(dbproc); while ((erc = dbresults(dbproc)) == SUCCEED) { fprintf(stdout, "dbresult succeeded dropping procedure\n"); while ((erc = dbnextrow(dbproc)) == SUCCEED) { fprintf(stdout, "dbnextrow returned spurious rows dropping procedure\n"); assert(0); /* dropping a procedure returns no rows */ } assert(erc == NO_MORE_ROWS); } assert(erc == NO_MORE_RESULTS); fprintf(stdout, "creating proc\n"); sql_cmd(dbproc); if (dbsqlexec(dbproc) == FAIL) { fprintf(stdout, "Failed to create proc t0022.\n"); exit(1); } while ((erc = dbresults(dbproc)) != NO_MORE_RESULTS) { assert(erc != FAIL); while ((erc = dbnextrow(dbproc)) == SUCCEED) { assert(0); /* creating a procedure returns no rows */ } assert(erc == NO_MORE_ROWS); } sql_cmd(dbproc); dbsqlexec(dbproc); while ((erc = dbresults(dbproc)) != NO_MORE_RESULTS) { if (erc == FAIL) { fprintf(stdout, "Was expecting a result set.\n"); exit(1); } while ((erc = dbnextrow(dbproc)) == SUCCEED) { assert(0); /* procedure returns no rows */ } assert(erc == NO_MORE_ROWS); } #if defined(DBTDS_7_0) && defined(DBTDS_7_1) && defined(DBTDS_7_2) && defined(DBTDS_7_3) && defined(DBTDS_7_4) if ((dbnumrets(dbproc) == 0) && ((DBTDS(dbproc) == DBTDS_7_0) || (DBTDS(dbproc) == DBTDS_7_1) || (DBTDS(dbproc) == DBTDS_7_2) || (DBTDS(dbproc) == DBTDS_7_3) || (DBTDS(dbproc) == DBTDS_7_4))) { fprintf(stdout, "WARNING: Received no return parameters from server!\n"); fprintf(stdout, "WARNING: This is likely due to a bug in Microsoft\n"); fprintf(stdout, "WARNING: SQL Server 7.0 SP3 and later.\n"); fprintf(stdout, "WARNING: Please try again using TDS protocol 4.2.\n"); dbcmd(dbproc, "drop proc t0022"); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } dbexit(); exit(0); } #endif for (i = 1; i <= dbnumrets(dbproc); i++) { retname = dbretname(dbproc, i); printf("ret name %d is %s\n", i, retname); rettype = dbrettype(dbproc, i); printf("ret type %d is %d\n", i, rettype); retlen = dbretlen(dbproc, i); printf("ret len %d is %d\n", i, retlen); dbconvert(dbproc, rettype, dbretdata(dbproc, i), retlen, SYBVARCHAR, (BYTE*) teststr, -1); printf("ret data %d is %s\n", i, teststr); } if ((retname == NULL) || strcmp(retname, "@b")) { fprintf(stdout, "Was expecting a retname to be @b.\n"); exit(1); } if (strcmp(teststr, "42")) { fprintf(stdout, "Was expecting a retdata to be 42.\n"); exit(1); } if (rettype != SYBINT4) { fprintf(stdout, "Was expecting a rettype to be SYBINT4 was %d.\n", rettype); exit(1); } if (retlen != 4) { fprintf(stdout, "Was expecting a retlen to be 4.\n"); exit(1); } fprintf(stdout, "Dropping proc\n"); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } /* * Chapter 2: test for resultsets containing only a return status */ fprintf(stdout, "Dropping proc t0022a\n"); sql_cmd(dbproc); dbsqlexec(dbproc); while ((erc = dbresults(dbproc)) == SUCCEED) { fprintf(stdout, "dbresult succeeded dropping procedure\n"); while ((erc = dbnextrow(dbproc)) == SUCCEED) { fprintf(stdout, "dbnextrow returned spurious rows dropping procedure\n"); assert(0); /* dropping a procedure returns no rows */ } assert(erc == NO_MORE_ROWS); } assert(erc == NO_MORE_RESULTS); fprintf(stdout, "creating proc t0022a\n"); sql_cmd(dbproc); if (dbsqlexec(dbproc) == FAIL) { fprintf(stdout, "Failed to create proc t0022a.\n"); exit(1); } while ((erc = dbresults(dbproc)) != NO_MORE_RESULTS) { assert(erc != FAIL); while ((erc = dbnextrow(dbproc)) == SUCCEED) { assert(0); /* creating a procedure returns no rows */ } assert(erc == NO_MORE_ROWS); } sql_cmd(dbproc); dbsqlexec(dbproc); for (i=1; (erc = dbresults(dbproc)) != NO_MORE_RESULTS; i++) { enum {expected_iterations = 2}; DBBOOL fret; DBINT status; if (erc == FAIL) { fprintf(stdout, "t0022a failed for some reason.\n"); exit(1); } printf("procedure returned %srows\n", DBROWS(dbproc)==SUCCEED? "" : "no "); while ((erc = dbnextrow(dbproc)) == SUCCEED) { assert(0); /* procedure returns no rows */ } assert(erc == NO_MORE_ROWS); fret = dbhasretstat(dbproc); printf("procedure has %sreturn status\n", fret==TRUE? "" : "no "); assert(fret == TRUE); status = dbretstatus(dbproc); printf("return status %d is %d\n", i, (int) status); switch (i) { case 1: assert(status == 17); break; case 2: assert(status == 1024); break; default: assert(i <= expected_iterations); } } assert(erc == NO_MORE_RESULTS); fprintf(stdout, "Dropping proc t0022a\n"); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } /* end chapter 2 */ dbexit(); fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); return failed ? 1 : 0; } freetds-1.00.82/src/dblib/unittests/t0023.c100644 025423 025423 00000011451 12717145107 0013656/* * Purpose: Test retrieving compute rows * Functions: dbaltbind dbaltcolid dbaltop dbalttype dbnumalts */ #include "common.h" #include static int failed = 0; static int got_error = 0; static int compute_supported = 1; static int compute_msg_handler(DBPROCESS * dbproc, DBINT msgno, int state, int severity, char *text, char *server, char *proc, int line) { if (strstr(text, "compute")) compute_supported = 0; else got_error = 1; return 0; } int main(int argc, char *argv[]) { LOGINREC *login; DBPROCESS *dbproc; int i; DBINT rowint; DBCHAR rowchar[2]; DBCHAR rowdate[32]; DBINT rowtype; DBINT computeint; DBCHAR computedate[32]; set_malloc_options(); read_login_info(argc, argv); fprintf(stdout, "Starting %s\n", argv[0]); /* Fortify_EnterScope(); */ dbinit(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "t0023"); fprintf(stdout, "About to open\n"); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); dbloginfree(login); sql_cmd(dbproc); dbmsghandle(compute_msg_handler); i = dbsqlexec(dbproc); dbmsghandle(syb_msg_handler); if (!compute_supported) { printf("compute clause not supported, skip test!\n"); dbexit(); return 0; } if (got_error) { failed = 1; fprintf(stderr, "Unexpected error from query.\n"); exit(1); } while ((i=dbresults(dbproc)) != NO_MORE_RESULTS) { while (dbnextrow(dbproc) != NO_MORE_ROWS) continue; } fprintf(stdout, "creating table\n"); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) == SUCCEED) { /* nop */ } fprintf(stdout, "insert\n"); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) == SUCCEED) { /* nop */ } sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) == SUCCEED) { /* nop */ } sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) == SUCCEED) { /* nop */ } sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) == SUCCEED) { /* nop */ } sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) == SUCCEED) { /* nop */ } fprintf(stdout, "select\n"); sql_cmd(dbproc); dbsqlexec(dbproc); if (dbresults(dbproc) != SUCCEED) { failed = 1; fprintf(stdout, "Was expecting a result set.\n"); exit(1); } for (i = 1; i <= dbnumcols(dbproc); i++) printf("col %d is %s\n", i, dbcolname(dbproc, i)); fprintf(stdout, "binding row columns\n"); if (SUCCEED != dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & rowint)) { failed = 1; fprintf(stderr, "Had problem with bind col1\n"); abort(); } if (SUCCEED != dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) rowchar)) { failed = 1; fprintf(stderr, "Had problem with bind col2\n"); abort(); } if (SUCCEED != dbbind(dbproc, 3, STRINGBIND, 0, (BYTE *) rowdate)) { failed = 1; fprintf(stderr, "Had problem with bind col3\n"); abort(); } fprintf(stdout, "testing compute clause 1\n"); if (dbnumalts(dbproc, 1) != 1) { failed = 1; fprintf(stderr, "Had problem with dbnumalts 1\n"); abort(); } if (dbalttype(dbproc, 1, 1) != SYBINT4) { failed = 1; fprintf(stderr, "Had problem with dbalttype 1, 1\n"); abort(); } if (dbaltcolid(dbproc, 1, 1) != 1) { failed = 1; fprintf(stderr, "Had problem with dbaltcolid 1, 1\n"); abort(); } if (dbaltop(dbproc, 1, 1) != SYBAOPSUM) { failed = 1; fprintf(stderr, "Had problem with dbaltop 1, 1\n"); abort(); } if (SUCCEED != dbaltbind(dbproc, 1, 1, INTBIND, 0, (BYTE *) & computeint)) { failed = 1; fprintf(stderr, "Had problem with dbaltbind 1, 1\n"); abort(); } fprintf(stdout, "testing compute clause 2\n"); if (dbnumalts(dbproc, 2) != 1) { failed = 1; fprintf(stderr, "Had problem with dbnumalts 2\n"); abort(); } if (dbalttype(dbproc, 2, 1) != SYBDATETIME) { failed = 1; fprintf(stderr, "Had problem with dbalttype 2, 1\n"); abort(); } if (dbaltcolid(dbproc, 2, 1) != 3) { failed = 1; fprintf(stderr, "Had problem with dbaltcolid 2, 1\n"); abort(); } if (dbaltop(dbproc, 2, 1) != SYBAOPMAX) { failed = 1; fprintf(stderr, "Had problem with dbaltop 2, 1\n"); abort(); } if (SUCCEED != dbaltbind(dbproc, 2, 1, STRINGBIND, -1, (BYTE *) computedate)) { failed = 1; fprintf(stderr, "Had problem with dbaltbind 2, 1\n"); abort(); } while ((rowtype = dbnextrow(dbproc)) != NO_MORE_ROWS) { if (rowtype == REG_ROW) { printf("gotten a regular row\n"); } if (rowtype == 1) { printf("gotten a compute row for clause 1\n"); printf("value of sum(col1) = %d\n", computeint); } if (rowtype == 2) { printf("gotten a compute row for clause 2\n"); printf("value of max(col3) = %s\n", computedate); } } dbexit(); fprintf(stdout, "%s %s\n", __FILE__, (failed ? "failed!" : "OK")); return failed ? 1 : 0; } freetds-1.00.82/src/dblib/unittests/text_buffer.c100644 025423 025423 00000005710 12717145107 0015424/* * Purpose: Test to see if row buffering and blobs works correctly. * Functions: dbbind dbnextrow dbopen dbresults dbsqlexec dbgetrow */ #include "common.h" int main(int argc, char **argv) { LOGINREC *login; DBPROCESS *dbproc; int i; char teststr[1024]; DBINT testint; set_malloc_options(); read_login_info(argc, argv); fprintf(stdout, "Starting %s\n", argv[0]); /* Fortify_EnterScope(); */ dbinit(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "text_buffer"); DBSETLHOST(login, "ntbox.dntis.ro"); fprintf(stdout, "About to open\n"); dbproc = dbopen(login, SERVER); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); dbloginfree(login); #ifdef MICROSOFT_DBLIB dbsetopt(dbproc, DBBUFFER, "100"); #else dbsetopt(dbproc, DBBUFFER, "100", 0); #endif fprintf(stdout, "creating table\n"); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } fprintf(stdout, "insert\n"); sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } sql_cmd(dbproc); dbsqlexec(dbproc); while (dbresults(dbproc) != NO_MORE_RESULTS) { /* nop */ } fprintf(stdout, "select\n"); dbcmd(dbproc, "select * from #dblib order by i"); dbsqlexec(dbproc); if (dbresults(dbproc) != SUCCEED) { fprintf(stdout, "Was expecting a result set."); return 1; } for (i = 1; i <= dbnumcols(dbproc); i++) { printf("col %d is %s\n", i, dbcolname(dbproc, i)); } dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint); dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) teststr); if (REG_ROW != dbnextrow(dbproc)) { fprintf(stderr, "dblib failed for %s:%d\n", __FILE__, __LINE__); return 1; } if (dbdatlen(dbproc, 2) != 6 || 0 != strcmp("ABCDEF", teststr)) { fprintf(stderr, "Expected |%s|, found |%s|\n", "ABCDEF", teststr); fprintf(stderr, "dblib failed for %s:%d\n", __FILE__, __LINE__); return 1; } if (REG_ROW != dbnextrow(dbproc)) { fprintf(stderr, "dblib failed for %s:%d\n", __FILE__, __LINE__); return 1; } if (dbdatlen(dbproc, 2) != 3 || 0 != strcmp("abc", teststr)) { fprintf(stderr, "Expected |%s|, found |%s|\n", "abc", teststr); fprintf(stderr, "dblib failed for %s:%d\n", __FILE__, __LINE__); return 1; } /* get again row 1 */ dbgetrow(dbproc, 1); /* here length and string should be ok */ if (dbdatlen(dbproc, 2) != 6 || 0 != strcmp("ABCDEF", teststr)) { fprintf(stderr, "Expected |%s|, found |%s|\n", "ABCDEF", teststr); fprintf(stderr, "dblib failed for %s:%d\n", __FILE__, __LINE__); return 1; } dbgetrow(dbproc, 2); if (dbdatlen(dbproc, 2) != 3 || 0 != strcmp("abc", teststr)) { fprintf(stderr, "Expected |%s|, found |%s|\n", "abc", teststr); fprintf(stderr, "dblib failed for %s:%d\n", __FILE__, __LINE__); return 1; } dbexit(); fprintf(stdout, "%s %s\n", __FILE__, (0 ? "failed!" : "OK")); return 0; } freetds-1.00.82/src/dblib/unittests/thread.c100644 025423 025423 00000011352 12522201763 0014350/* * Purpose: Test dblib thread safety */ #include "common.h" #include #ifdef HAVE_UNISTD_H #include #endif #include "replacements.h" #ifdef TDS_HAVE_MUTEX static tds_mutex mutex = TDS_MUTEX_INITIALIZER; static int result = 0; static int thread_count = 0; #define ROWS 20 #define NUM_THREAD 10 #define NUM_LOOP 100 static void set_failed(void) { tds_mutex_lock(&mutex); result = 1; tds_mutex_unlock(&mutex); } static int test(DBPROCESS *dbproc) { int i; char teststr[1024]; DBINT testint; /* fprintf(stdout, "select\n"); */ dbcmd(dbproc, "select * from dblib_thread order by i"); dbsqlexec(dbproc); if (dbresults(dbproc) != SUCCEED) { fprintf(stdout, "Was expecting a result set.\n"); set_failed(); return 1; } if (SUCCEED != dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint)) { fprintf(stderr, "Had problem with bind\n"); abort(); } if (SUCCEED != dbbind(dbproc, 2, STRINGBIND, 0, (BYTE *) teststr)) { fprintf(stderr, "Had problem with bind\n"); abort(); } for (i = 0; i < ROWS; i++) { char expected[64]; sprintf(expected, "row %d", i); memset(teststr, 'x', sizeof(teststr)); teststr[0] = 0; teststr[sizeof(teststr) - 1] = 0; if (REG_ROW != dbnextrow(dbproc)) { fprintf(stderr, "Failed. Expected a row\n"); set_failed(); return 1; } if (testint != i) { fprintf(stderr, "Failed. Expected i to be %d, was %d\n", i, (int) testint); abort(); } if (0 != strncmp(teststr, expected, strlen(expected))) { fprintf(stdout, "Failed. Expected s to be |%s|, was |%s|\n", expected, teststr); abort(); } /* printf("Read a row of data -> %d |%s|\n", (int) testint, teststr); */ } if (dbnextrow(dbproc) != NO_MORE_ROWS) { fprintf(stderr, "Was expecting no more rows\n"); set_failed(); return 1; } dbcancel(dbproc); return 0; } static TDS_THREAD_PROC_DECLARE(thread_test, arg) { int i; int num = ptr2int(arg); DBPROCESS *dbproc; LOGINREC *login; login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "thread"); dbproc = dbopen(login, SERVER); if (!dbproc) { dbloginfree(login); fprintf(stderr, "Unable to connect to %s\n", SERVER); set_failed(); return NULL; } dbloginfree(login); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); tds_mutex_lock(&mutex); ++thread_count; tds_mutex_unlock(&mutex); printf("thread %2d waiting for all threads to start\n", num+1); tds_mutex_lock(&mutex); while (thread_count < NUM_THREAD) { tds_mutex_unlock(&mutex); tds_sleep_s(1); tds_mutex_lock(&mutex); } tds_mutex_unlock(&mutex); for (i = 1; i <= NUM_LOOP; ++i) { printf("thread %2d of %2d loop %d\n", num+1, NUM_THREAD, i); if (test(dbproc) || result != 0) break; } dbclose(dbproc); return NULL; } int main(int argc, char **argv) { int i; tds_thread th[NUM_THREAD]; DBPROCESS *dbproc; LOGINREC *login; read_login_info(argc, argv); fprintf(stdout, "Starting %s\n", argv[0]); dbinit(); dberrhandle(syb_err_handler); dbmsghandle(syb_msg_handler); fprintf(stdout, "About to logon\n"); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "thread"); fprintf(stdout, "About to open \"%s\"\n", SERVER); dbproc = dbopen(login, SERVER); if (!dbproc) { fprintf(stderr, "Unable to connect to %s\n", SERVER); return 1; } dbloginfree(login); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); fprintf(stdout, "Dropping table\n"); dbcmd(dbproc, "if object_id('dblib_thread') is not null drop table dblib_thread"); dbsqlexec(dbproc); while (dbresults(dbproc) == SUCCEED) { /* nop */ } fprintf(stdout, "creating table\n"); dbcmd(dbproc, "create table dblib_thread (i int not null, s char(10) not null)"); dbsqlexec(dbproc); while (dbresults(dbproc) == SUCCEED) { /* nop */ } fprintf(stdout, "insert\n"); for (i = 0; i < ROWS; i++) { char cmd[128]; sprintf(cmd, "insert into dblib_thread values (%d, 'row %d')", i, i); dbcmd(dbproc, cmd); dbsqlexec(dbproc); while (dbresults(dbproc) == SUCCEED) { /* nop */ } } for (i = 0; i < NUM_THREAD; ++i) { int err = tds_thread_create(&th[i], thread_test, int2ptr(i)); if (err != 0) { fprintf(stderr, "Error %d (%s) creating thread\n", err, strerror(err)); return 1; } /* MSSQL rejects the connections if they come in too fast */ tds_sleep_s(1); } for (i = 0; i < NUM_THREAD; ++i) { tds_thread_join(th[i], NULL); fprintf(stdout, "thread: %d exited\n", i + 1); } fprintf(stdout, "Dropping table\n"); dbcmd(dbproc, "drop table dblib_thread"); dbsqlexec(dbproc); while (dbresults(dbproc) == SUCCEED) { /* nop */ } dbexit(); return result; } #else /* !TDS_HAVE_PTHREAD_MUTEX */ int main(int argc, char **argv) { printf("Not possible for this platform.\n"); return 0; } #endif freetds-1.00.82/src/dblib/unittests/timeout.c100644 025423 025423 00000016626 13100113554 0014571/* * Purpose: Test handling of timeouts with an error handler * Functions: dberrhandle, dbsetlogintime, dbsettime, dbsetopt, dbclropt, dbisopt * \todo We test returning INT_CANCEL for a login timeout. We don't test it for a query_timeout. */ #include "common.h" #include static int ntimeouts = 0, ncancels = 0; static const int max_timeouts = 2, timeout_seconds = 2; static time_t start_time; static int timeout_err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr); static int chkintr(DBPROCESS * dbproc); static int hndlintr(DBPROCESS * dbproc); #if !defined(SYBETIME) #define SYBETIME SQLETIME #define INT_TIMEOUT INT_CANCEL dbsetinterrupt(DBPROCESS *dbproc, void* hand, void* p) {} #endif static int timeout_err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr) { /* * For server messages, cancel the query and rely on the * message handler to spew the appropriate error messages out. */ if (dberr == SYBESMSG) return INT_CANCEL; if (dberr == SYBETIME) { fprintf(stderr, "%d timeouts received in %ld seconds, ", ++ntimeouts, (long int) (time(NULL) - start_time)); if (ntimeouts > max_timeouts) { if (++ncancels > 1) { fprintf(stderr, "could not timeout cleanly, breaking connection\n"); ncancels = 0; return INT_CANCEL; } fprintf(stderr, "lost patience, cancelling (allowing 10 seconds)\n"); if (dbsettime(10) == FAIL) fprintf(stderr, "... but dbsettime() failed in error handler\n"); return INT_TIMEOUT; } fprintf(stderr, "continuing to wait\n"); return INT_CONTINUE; } ntimeouts = 0; /* reset */ fprintf(stderr, "DB-LIBRARY error (severity %d, dberr %d, oserr %d, dberrstr %s, oserrstr %s):\n", severity, dberr, oserr, dberrstr ? dberrstr : "(null)", oserrstr ? oserrstr : "(null)"); fflush(stderr); /* * If the dbprocess is dead or the dbproc is a NULL pointer and * we are not in the middle of logging in, then we need to exit. * We can't do anything from here on out anyway. * It's OK to end up here in response to a dbconvert() that * resulted in overflow, so don't exit in that case. */ if ((dbproc == NULL) || DBDEAD(dbproc)) { if (dberr != SYBECOFL) { fprintf(stderr, "error: dbproc (%p) is %s, goodbye\n", dbproc, dbproc? (DBDEAD(dbproc)? "DEAD" : "OK") : "NULL"); exit(255); } } return INT_CANCEL; } static int chkintr(DBPROCESS * dbproc) { printf("in chkintr, %ld seconds elapsed\n", (long int) (time(NULL) - start_time)); return FALSE; } static int hndlintr(DBPROCESS * dbproc) { printf("in hndlintr, %ld seconds elapsed\n", (long int) (time(NULL) - start_time)); return INT_CONTINUE; } static int failed = 0; static void test(int per_process) { LOGINREC *login; DBPROCESS *dbproc; int i, r; RETCODE erc, row_code; int num_resultset = 0; char teststr[1024]; char timeout[32]; sprintf(timeout, "%d", timeout_seconds); ntimeouts = 0; ncancels = 0; /* * Connect to server */ dberrhandle(timeout_err_handler); dbmsghandle(syb_msg_handler); printf("About to logon\n"); login = dblogin(); DBSETLPWD(login, PASSWORD); DBSETLUSER(login, USER); DBSETLAPP(login, "#timeout"); printf("About to open %s.%s\n", SERVER, DATABASE); /* * One way to test the login timeout is to connect to a discard server (grep discard /etc/services). * It's normally supported by inetd. */ printf ("using %d 1-second login timeouts\n", max_timeouts); dbsetlogintime(1); start_time = time(NULL); /* keep track of when we started for reporting purposes */ if (NULL == (dbproc = dbopen(login, SERVER))){ fprintf(stderr, "Failed: dbopen\n"); exit(1); } printf ("connected.\n"); if (strlen(DATABASE)) dbuse(dbproc, DATABASE); dbloginfree(login); /* Set a very long global timeout. */ if (per_process) dbsettime(5 * 60); /* Verify no query timeout is set for this DBPROCESS */ if (dbisopt(dbproc, DBSETTIME, 0)) { printf("unexpected return code from dbisopt() before calling dbsetopt(..., DBSETTIME, ...)\n"); exit(1); } if (FAIL == dbsetopt(dbproc, DBSETTIME, timeout, 0)) { fprintf(stderr, "Failed: dbsetopt(..., DBSETTIME, \"%d\")\n", timeout_seconds); exit(1); } /* Verify a query timeout is actually set for this DBPROCESS now */ if (!dbisopt(dbproc, DBSETTIME, 0)) { printf("unexpected return code from dbisopt() after calling dbsetopt(..., DBSETTIME, ...)\n"); exit(1); } if (FAIL == dbclropt(dbproc, DBSETTIME, 0)) { fprintf(stderr, "Failed: dbclropt(..., DBSETTIME, ...)\n"); exit(1); } /* Verify no query timeout remains set for this DBPROCESS */ if (dbisopt(dbproc, DBSETTIME, 0)) { printf("unexpected return code from dbisopt() after calling dbclropt(..., DBSETTIME, ...)\n"); exit(1); } printf ("using %d %d-second query timeouts\n", max_timeouts, timeout_seconds); if (per_process) { if (FAIL == dbsetopt(dbproc, DBSETTIME, timeout, 0)) { fprintf(stderr, "Failed: dbsetopt(..., DBSETTIME, \"%d\")\n", timeout_seconds); exit(1); } /* Verify setting the global timeout won't override the per-process timeout value */ dbsettime(35); } else { if (FAIL == dbsettime(timeout_seconds)) { fprintf(stderr, "Failed: dbsettime\n"); exit(1); } } /* send something that will take awhile to execute */ printf ("issuing a query that will take 30 seconds\n"); if (FAIL == sql_cmd(dbproc)) { fprintf(stderr, "Failed: dbcmd\n"); exit(1); } start_time = time(NULL); /* keep track of when we started for reporting purposes */ ntimeouts = 0; dbsetinterrupt(dbproc, (void*)chkintr, (void*)hndlintr); if (FAIL == dbsqlsend(dbproc)) { fprintf(stderr, "Failed: dbsend\n"); exit(1); } /* wait for it to execute */ printf("executing dbsqlok\n"); erc = dbsqlok(dbproc); if (erc != FAIL) { fprintf(stderr, "dbsqlok should fail for timeout\n"); exit(1); } /* retrieve outputs per usual */ r = 0; for (i=0; (erc = dbresults(dbproc)) != NO_MORE_RESULTS; i++) { int nrows, ncols; switch (erc) { case SUCCEED: if (DBROWS(dbproc) == FAIL){ r++; continue; } assert(DBROWS(dbproc) == SUCCEED); printf("dbrows() returned SUCCEED, processing rows\n"); ncols = dbnumcols(dbproc); ++num_resultset; printf("bound 1 of %d columns ('%s') in result %d.\n", ncols, dbcolname(dbproc, 1), ++r); dbbind(dbproc, 1, STRINGBIND, 0, (BYTE *) teststr); printf("\t%s\n\t-----------\n", dbcolname(dbproc, 1)); while ((row_code = dbnextrow(dbproc)) != NO_MORE_ROWS) { if (row_code == REG_ROW) { printf("\t%s\n", teststr); } else { /* not supporting computed rows in this unit test */ failed = 1; fprintf(stderr, "Failed. Expected a row\n"); exit(1); } } nrows = (int) dbcount(dbproc); printf("row count %d\n", nrows); if (nrows < 0){ failed++; printf("error: dbrows() returned SUCCEED, but dbcount() returned -1\n"); } if (FAIL == dbclropt(dbproc, DBSETTIME, 0)) { failed++; printf("error: dbclropt(dbproc, DBSETTIME, ...) failed\n"); } break; case FAIL: printf("dbresults returned FAIL\n"); exit(1); default: printf("unexpected return code %d from dbresults\n", erc); exit(1); } if (i > 1) { failed++; break; } } /* while dbresults */ } int main(int argc, char **argv) { set_malloc_options(); read_login_info(argc, argv); fprintf(stdout, "Starting %s\n", argv[0]); dbinit(); test(0); test(1); dbexit(); printf("%s %s\n", __FILE__, (failed ? "failed!" : "OK")); return failed ? 1 : 0; } freetds-1.00.82/src/dblib/unittests/t0016.in100644 025423 025423 00000000224 12522201763 00140331 2 123.45 This is a varchar 255 field 2001-09-11 09:13:13.663 group1 4 5 56789.12 This is another varchar 255 field 2000-02-29 13:01:01.000 group2 freetds-1.00.82/src/dblib/unittests/t0017.in100644 025423 025423 00000000116 12522201763 0014034"3DEprova di testo questo testo dovrebbe andare a finire in un campo textfreetds-1.00.82/src/dblib/unittests/t0017.in.be100644 025423 025423 00000000116 12522201763 0014421D3"Eprova di testo questo testo dovrebbe andare a finire in un campo textfreetds-1.00.82/src/dblib/unittests/data.bin100644 025423 025423 00000164644 12522201763 0014355ELFdÕ4( U‰åWVSìHjèüÿÿÿèüÿÿÿ[^hÿ5èüÿÿÿèüÿÿÿÇ$èüÿÿÿÇ$èüÿÿÿZYhÿ5èüÿÿÿèüÿÿÿƒÄ j‰ÃhSèüÿÿÿƒÄ jhSèüÿÿÿƒÄ jhSèüÿÿÿÇ$hhhÿ5èüÿÿÿƒÄhSèüÿÿÿº‰Ó‰…Äåÿÿü1À¹ÿÿÿÿ‰ßò®ƒÄƒùþtƒìRÿµÄåÿÿèüÿÿÿƒÄƒìhÿ5èüÿÿÿ_Xhÿ5èüÿÿÿƒÄƒ} V‹E ÿ0hÿ5èüÿÿÿ¸éWƒìh‹} ÿwèüÿÿÿ‰ÃƒÄ…Ûu Sÿwhÿ5èüÿÿÿ¸é‰öQjjSèüÿÿÿ‰$èüÿÿÿƒÄ jjS‰…àåÿÿèüÿÿÿZÿµàåÿÿèüÿÿÿSjÿµàåÿÿP‰…ÜåÿÿèüÿÿÿƒÄSèüÿÿÿ_Xhÿ5èüÿÿÿ[^hÿµÄåÿÿèüÿÿÿYÿµÄåÿÿèüÿÿÿƒÄƒì ÿµÄåÿÿèüÿÿÿƒÄƒøuêƒìhÿ5èüÿÿÿXZhÿµÄåÿÿèüÿÿÿ_ÿµÄåÿÿèüÿÿÿƒÄ‰öƒì ÿµÄåÿÿèüÿÿÿƒÄƒøuêƒìhÿ5èüÿÿÿ[^hèåÿÿSèüÿÿÿƒÄ Shÿ5èüÿÿÿZYSÿµÄåÿÿèüÿÿÿXÿµÄåÿÿèüÿÿÿƒÄvƒì ÿµÄåÿÿèüÿÿÿƒÄƒøuêƒìhèùÿÿSèüÿÿÿ^_SÿµÄåÿÿèüÿÿÿYÿµÄåÿÿèüÿÿÿZÿµÄåÿÿèüÿÿÿƒÄHtƒìhÿ5èüÿÿÿ¸éhèúÿÿë;PjhSèüÿÿÿ^_jÿµÄåÿÿèüÿÿÿZYjÿµÄåÿÿ‰…Ôåÿÿèüÿÿÿ‰…ÐåÿÿƒÄƒì ÿµÄåÿÿèüÿÿÿ‰ÆƒÄƒþþu­ÿµÜåÿÿÿµàåÿÿjÿµÐåÿÿjÿµÔåÿÿ…èúÿÿPÿµÄåÿÿèüÿÿÿƒÄ Ht ¸éÎvƒìhÿ5èüÿÿÿ_XhÿµÄåÿÿèüÿÿÿ^ÿµÄåÿÿèüÿÿÿ[ÿµÄåÿÿèüÿÿÿƒÄHt)ƒìhÿ5ÇèüÿÿÿÇ$èüÿÿÿ»ë#ƒìSÿµÄåÿÿèüÿÿÿƒÄ PShèüÿÿÿƒÄCƒì ÿµÄåÿÿèüÿÿÿƒÄ9Ã~Éƒì …äåÿÿPjÿjjÿµÄåÿÿèüÿÿÿƒÄ Ht$ƒìhÿ5Çèüÿÿÿèüÿÿÿ‰öƒì ÿµÄåÿÿèüÿÿÿƒÄ@t,ƒìhÿ5ÇèüÿÿÿÇ$èüÿÿÿv‹…äåÿÿƒøt!PShÿ5Çèüÿÿÿèüÿÿÿƒì ÿµÄåÿÿèüÿÿÿƒÄ jèùÿÿhSèüÿÿÿZYSÿµÄåÿÿèüÿÿÿXÿµÄåÿÿèüÿÿÿ_ÿµÄåÿÿèüÿÿÿY^hÿ5èüÿÿÿXZhSèüÿÿÿ^_SÿµÄåÿÿèüÿÿÿ[ÿµÄåÿÿèüÿÿÿYÿµÄåÿÿèüÿÿÿƒÄHtƒìhÿ5èüÿÿÿ¸é½‰ö…èéÿÿÇ…ÌåÿÿÇ…Øåÿÿ‰…Èåÿÿë?‰ö…öt9‹½Ìåÿÿƒì7SÿµØåÿÿèüÿÿÿƒÄ VÿµÈåÿÿ‰…ØåÿÿøPèüÿÿÿƒÄ‰ÌåÿÿRhÿµÈåÿÿÿµÄåÿÿèüÿÿÿ‰ÆƒÄƒþþu¢ƒì‹E ÿphèüÿÿÿ_Xh‹} ÿwèüÿÿÿ‰ÃƒÄ…Ûu Vÿwhÿ5èüÿÿÿ¸éí‰öSjÿµÌåÿÿÿµØåÿÿèüÿÿÿ‰$èüÿÿÿ‹Ìåÿÿ‹…Øåÿÿ9ɉÇÿµÌåÿÿ‹µÜåÿÿüó¦—Â’À8¹u¹QÿµäåÿÿhèüÿÿÿƒÄÿµØåÿÿèüÿÿÿ[ÿµÄåÿÿèüÿÿÿƒÄƒøþt*ƒìhÿ5ÇèüÿÿÿÇ$èüÿÿÿèüÿÿÿ‹ …Éh¸u¸Phÿ5èüÿÿÿ‹1ÀƒÄ…Ò•Àeô[^_]Ã$Id: tds.h.in,v 1.39 2002/08/30 20:23:00 freddy77 Exp $8$Id: tds_configs.h.in,v 1.3 2002/02/17 20:23:37 brianb Exp $@€$Header: /cvsroot/freetds/freetds/include/tdsver.h.in,v 1.2 2002/05/25 00:33:49 brianb Exp $ $Id: sybdb.h,v 1.14 2002/08/30 21:09:22 castellano Exp $ \$Id: sybfront.h,v 1.1.1.1 2001/10/12 23:28:55 brianb Exp $€¼$Id: sqlfront.h,v 1.1.1.1 2001/10/12 23:28:56 brianb Exp $à$Id: sqldb.h,v 1.1.1.1 2001/10/12 23:28:56 brianb Exp $@x$Id: common.h,v 1.1.1.1 2001/10/12 23:29:13 brianb Exp $€¼$Id: t0013.c,v 1.3 2002/08/29 09:54:54 freddy77 Exp $à01.01—š d?dG<V€€€š€É€€>€€à€ €:€d€€§€Â€ã€€?€d€Ž€·‚̂䂢ý‚¢¢‚O€Ç¢c‚}‚¢•‚¢Î€ å€!ü€"€#'€%?€&U€1l€2„€3›€4´€5Ì€6å€8ý€9€;6€=L€>b€?x€@Ž€A¥€B½€CÓ€Dê€E€F€G/€HH€I]€NÀQÛ€Rû€S€T-€UI€Va€Xy€[“€^«€eÁ€hÛ€lõ€q €r) €uD €va €y| €z™ €}± €€Ê €ƒå €„ €‡ €Š4 ‚U ‚o €¢¥ €í €#) €, €4H €<• €CÍ €Fé €S| €Zº €^× €Œ¢¢ï €- €7!‚6‚O‚¢i‚¢€¸€8¢Í‚â‚¢‚¢5€K¢¸€ý€#D‚Y‚¢q‚†‚¢¿‚¢¢Ù‚¢€ñ€(€HR€K€L²€Uå€Z €^Y€a‘€bÉ€v€€€Œ€­¢°€5&€7?€8X€9s€:¢Ž‚Ç€+¢å€ªÿ€\€À€€A˜€X¾€aå€i €l¢0€PE‚¢c‚¢¢}‚“‚¢«‚¢ä€b€jW‚p‚¢ˆ‚¢¢€"·€#Í€$á€%ö€& €'"€(8€-N€1c€=y€B€G¦€L¾€QÔ€Wê€c €h €m- €sE €t] €zs ‚‡ ‚¢¡ €F· ‚¢Ñ €Rê ‚¢!€^¢!‚¢T!€–i!€—!€˜“!€¾ª!€¿Á!€ÀØ!€Áï!€Ä"€Å!"€Æ:"€ÇS"€Ém"‚ƒ"‚¢›"‚¢¢¶"‚Ð"‚¢è"‚¢#‚¢#‚8#€U#€¢#€&µ#‚É#€¢$‚$‚¢8$€¢t$€1$€7§$€Jñ$€Q¢%‚¢%%€æ>%€êY%€î¢t%€$&€«&‚Á&‚¢Ù&‚¢¢'€¨¢@'‚V'‚¢¢n'‚¢ƒ'‚Ÿ'‚»'‚Ô'‚ë'&(&8D(‚c(&@“(&€¢Ì(‚¢å(‚ÿ(‚¢)‚.)‚¢F)‚¢_)‚w)‚¢)€¢¢Ë)‚¢*‚*‚¢X*‚‘*‚Í*‚+‚+‚¢4+‚S+‚q+‚¢¢¢+‚¢¢¢¢¢¬+‚¢Å+€$Þ+€H,‚e,€¢,€Õ,€R-€B.€/€‹/€È/€0‚+0‚¢¢F0€¢‚0€Ù0€¢1‚ 1‚¢81‚N1‚¢f1‚¢€1‚¢1€1´1€2Ë1€4â1€;ù1€B2€C12€DM2€Ii2€M†2€N¤2€OÂ2€Tà2€[ü2€a3€b43€dP3€hm3€nŠ3€o§3€qÄ3€~Ü3€õ3€‹ 4€¢&4‚¢@4€ù5€Y6€þ7€…8€>8€î8‚¢ 9€‘9€*:€~:‚•:€ç:€0;€‘;€¢ð;‚¢<‚¢#<€¢n<‚‡<‚¢Ÿ<‚¢¢¹<‚Î<‚¢æ<‚¢=‚¢=‚/=‚¢G=‚¢€=€¢Ý=‚÷=€¢a>€è>€P?€¥?€¢…@‚Ÿ@‚µ@‚¢Í@‚¢è@€(A‚¢A‚¢:A€GkA€¼‚A‚¢–A‚²A‚¢ÏA€B€%(B€ŠD€k¦D€E€E€F€2F€hF€‘F€óF€CG€WH€!uH€¢¯H‚ÍH€¢©I€ÿI‚J‚Y\€¡\€ç\€x¢]‚]‚¢5]‚¢S]‚¢m]‚¢¦]‚Ã]€A_€ñm€¢)n‚¢¢?n‚Yn& …n&¢ºn€SÑn€Tên€Uo€V o€W;D@GDBYDC^DBcDCeDDpDE€DGDJ±DK¿DJÆDKÌDLàDMïDNòDPDRDS DT6DW@DX\DYpD[|D\‡D]D\—D]D_¢D`®D_¸D`¾DaÃDcÌDdÞDeðDfüDkDl)Dn;DoGDubDwuDxˆDyœDzªD{¶D€ÒDæD‚ôDƒD„D…%Dˆ0D‹8DŒHDUDŒ_DeDŽpD“‹D”¿D¨ÌDªßD«ñD­ýD°D¯D°'D±,D´8D¶@D´^D¹wD¼˜D»¦D¼°D½µDÀ¼DÃÐDÂÞDÃèDÄíDÆüDÉDÈDÉDË#DÍ(DÐ6DÑNDÒZDÓfDÕrDׄDØ‘DÙŸDÚ«DÛ½DÜÐDÝÚDâÜDßâDàìDâöDäDèDéDè&Dé,Dë4Dê7Dì=Dî^DïqDðŒDñ Dó¬DôÀDöÈDù DûDþ.Dý<DþFDÿKDXD]D‡D—Û˜@ò˜€Äåÿÿ ™@™€èûÿÿ7™€ äåÿÿG™@!Y™@"g™€"àåÿÿr™€#Üåÿÿ~™€#Øåÿÿ‹™€$Ôåÿÿ›™€$Ðåÿÿ­™€%èúÿÿ½™€&èùÿÿÌ™€'èéÿÿ(Ìåÿÿü™€*èåÿÿÀà—$ŸdŸt0013.c/home/freddy/cpp/freetds/freetds/src/dblib/unittests/t0013.cgcc2_compiled.int:t(0,1)=r(0,1);-2147483648;2147483647;char:t(0,2)=r(0,2);0;127;long int:t(0,3)=r(0,3);-2147483648;2147483647;unsigned int:t(0,4)=r(0,4);0000000000000;0037777777777;long unsigned int:t(0,5)=r(0,5);0000000000000;0037777777777;long long int:t(0,6)=@s64;r(0,6);01000000000000000000000;0777777777777777777777;long long unsigned int:t(0,7)=@s64;r(0,7);0000000000000;01777777777777777777777;short int:t(0,8)=@s16;r(0,8);-32768;32767;short unsigned int:t(0,9)=@s16;r(0,9);0;65535;signed char:t(0,10)=@s8;r(0,10);-128;127;unsigned char:t(0,11)=@s8;r(0,11);0;255;float:t(0,12)=r(0,1);4;0;double:t(0,13)=r(0,1);8;0;long double:t(0,14)=r(0,1);12;0;complex int:t(0,15)=s8real:(0,1),0,32;imag:(0,1),32,32;;complex float:t(0,16)=r(0,16);8;0;complex double:t(0,17)=r(0,17);16;0;complex long double:t(0,18)=r(0,18);24;0;__builtin_va_list:t(0,19)=*(0,20)=(0,20)/usr/include/stdio.h/usr/include/features.h/usr/include/sys/cdefs.h/usr/include/gnu/stubs.h/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stddef.hsize_t:t(5,1)=(0,4)/usr/include/bits/types.h/usr/include/features.h/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stddef.h__u_char:t(6,1)=(0,11)__u_short:t(6,2)=(0,9)__u_int:t(6,3)=(0,4)__u_long:t(6,4)=(0,5)__u_quad_t:t(6,5)=(0,7)__quad_t:t(6,6)=(0,6)__int8_t:t(6,7)=(0,10)__uint8_t:t(6,8)=(0,11)__int16_t:t(6,9)=(0,8)__uint16_t:t(6,10)=(0,9)__int32_t:t(6,11)=(0,1)__uint32_t:t(6,12)=(0,4)__int64_t:t(6,13)=(0,6)__uint64_t:t(6,14)=(0,7)__qaddr_t:t(6,15)=(6,16)=*(6,6)__dev_t:t(6,17)=(6,5)__uid_t:t(6,18)=(6,3)__gid_t:t(6,19)=(6,3)__ino_t:t(6,20)=(6,4)__mode_t:t(6,21)=(6,3)__nlink_t:t(6,22)=(6,3)__off_t:t(6,23)=(0,3)__loff_t:t(6,24)=(6,6)__pid_t:t(6,25)=(0,1)__ssize_t:t(6,26)=(0,1)__rlim_t:t(6,27)=(6,4)__rlim64_t:t(6,28)=(6,5)__id_t:t(6,29)=(6,3)__fsid_t:t(6,30)=(6,31)=s8__val:(6,32)=ar(6,33)=r(6,33);0000000000000;0037777777777;;0;1;(0,1),0,64;;__daddr_t:t(6,34)=(0,1)__caddr_t:t(6,35)=(6,36)=*(0,2)__time_t:t(6,37)=(0,3)__useconds_t:t(6,38)=(0,4)__suseconds_t:t(6,39)=(0,3)__swblk_t:t(6,40)=(0,3)__clock_t:t(6,41)=(0,3)__clockid_t:t(6,42)=(0,1)__timer_t:t(6,43)=(0,1)__key_t:t(6,44)=(0,1)__ipc_pid_t:t(6,45)=(0,9)__blksize_t:t(6,46)=(0,3)__blkcnt_t:t(6,47)=(0,3)__blkcnt64_t:t(6,48)=(6,6)__fsblkcnt_t:t(6,49)=(6,4)__fsblkcnt64_t:t(6,50)=(6,5)__fsfilcnt_t:t(6,51)=(6,4)__fsfilcnt64_t:t(6,52)=(6,5)__ino64_t:t(6,53)=(6,5)__off64_t:t(6,54)=(6,24)__t_scalar_t:t(6,55)=(0,3)__t_uscalar_t:t(6,56)=(0,5)__intptr_t:t(6,57)=(0,1)__socklen_t:t(6,58)=(0,4)/usr/include/bits/pthreadtypes.h/usr/include/bits/sched.h__sched_param:T(10,1)=s4__sched_priority:(0,1),0,32;;_pthread_fastlock:T(9,1)=s8__status:(0,3),0,32;__spinlock:(0,1),32,32;;_pthread_descr:t(9,2)=(9,3)=*(9,4)=xs_pthread_descr_struct:__pthread_attr_s:T(9,5)=s36__detachstate:(0,1),0,32;__schedpolicy:(0,1),32,32;__schedparam:(10,1),64,32;__inheritsched:(0,1),96,32;__scope:(0,1),128,32;__guardsize:(5,1),160,32;__stackaddr_set:(0,1),192,32;__stackaddr:(0,19),224,32;__stacksize:(5,1),256,32;;pthread_attr_t:t(9,6)=(9,5)pthread_cond_t:t(9,7)=(9,8)=s12__c_lock:(9,1),0,64;__c_waiting:(9,2),64,32;;pthread_condattr_t:t(9,9)=(9,10)=s4__dummy:(0,1),0,32;;pthread_key_t:t(9,11)=(0,4)pthread_mutex_t:t(9,12)=(9,13)=s24__m_reserved:(0,1),0,32;__m_count:(0,1),32,32;__m_owner:(9,2),64,32;__m_kind:(0,1),96,32;__m_lock:(9,1),128,64;;pthread_mutexattr_t:t(9,14)=(9,15)=s4__mutexkind:(0,1),0,32;;pthread_once_t:t(9,16)=(0,1)pthread_t:t(9,17)=(0,5)FILE:t(1,1)=(1,2)=xs_IO_FILE:__FILE:t(1,3)=(1,2)/usr/include/libio.h/usr/include/_G_config.h/usr/include/bits/types.h/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stddef.hwchar_t:t(14,1)=(0,3)wint_t:t(14,2)=(0,4)/usr/include/wchar.h/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stddef.h/usr/include/bits/wchar.h__mbstate_t:t(15,1)=(15,2)=s8__count:(0,1),0,32;__value:(15,3)=u4__wch:(14,2),0,32;__wchb:(15,4)=ar(6,33);0;3;(0,2),0,32;;,32,32;;_G_fpos_t:t(12,1)=(12,2)=s12__pos:(6,23),0,32;__state:(15,1),32,64;;_G_fpos64_t:t(12,3)=(12,4)=s16__pos:(6,54),0,64;__state:(15,1),64,64;;/usr/include/gconv.h/usr/include/features.h/usr/include/wchar.h/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stddef.h/usr/include/bits/wchar.h/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stddef.h :T(18,1)=e__GCONV_OK:0,__GCONV_NOCONV:1,__GCONV_NODB:2,__GCONV_NOMEM:3,__GCONV_EMPTY_INPUT:4,__GCONV_FULL_OUTPUT:5,__GCONV_ILLEGAL_INPUT:6,__GCONV_INCOMPLETE_INPUT:7,__GCONV_ILLEGAL_DESCRIPTOR:8,__GCONV_INTERNAL_ERROR:9,; :T(18,2)=e__GCONV_IS_LAST:1,__GCONV_IGNORE_ERRORS:2,;__gconv_fct:t(18,3)=(18,4)=*(18,5)=f(0,1)__gconv_init_fct:t(18,6)=(18,7)=*(18,8)=f(0,1)__gconv_end_fct:t(18,9)=(18,10)=*(18,11)=f(0,20)__gconv_trans_fct:t(18,12)=(18,13)=*(18,14)=f(0,1)__gconv_trans_context_fct:t(18,15)=(18,16)=*(18,17)=f(0,1)__gconv_trans_query_fct:t(18,18)=(18,19)=*(18,20)=f(0,1)__gconv_trans_init_fct:t(18,21)=(18,22)=*(18,23)=f(0,1)__gconv_trans_end_fct:t(18,24)=(18,25)=*(18,26)=f(0,20)__gconv_trans_data:T(18,27)=s20__trans_fct:(18,12),0,32;__trans_context_fct:(18,15),32,32;__trans_end_fct:(18,24),64,32;__data:(0,19),96,32;__next:(18,28)=*(18,27),128,32;;__gconv_step:T(18,29)=s56__shlib_handle:(18,30)=*(18,31)=xs__gconv_loaded_object:,0,32;__modname:(18,32)=*(0,2),32,32;__counter:(0,1),64,32;__from_name:(6,36),96,32;__to_name:(6,36),128,32;__fct:(18,3),160,32;__init_fct:(18,6),192,32;__end_fct:(18,9),224,32;__min_needed_from:(0,1),256,32;__max_needed_from:(0,1),288,32;__min_needed_to:(0,1),320,32;__max_needed_to:(0,1),352,32;__stateful:(0,1),384,32;__data:(0,19),416,32;;__gconv_step_data:T(18,33)=s36__outbuf:(18,34)=*(0,11),0,32;__outbufend:(18,34),32,32;__flags:(0,1),64,32;__invocation_counter:(0,1),96,32;__internal_use:(0,1),128,32;__statep:(18,35)=*(15,1),160,32;__state:(15,1),192,64;__trans:(18,28),256,32;;__gconv_info:T(18,36)=s8__nsteps:(5,1),0,32;__steps:(18,37)=*(18,29),32,32;__data:(18,38)=ar(6,33);0;-1;(18,33),64,0;;__gconv_t:t(18,39)=(18,40)=*(18,36)_G_iconv_t:t(12,5)=(12,6)=u44__cd:(18,36),0,64;__combined:(12,7)=s44__cd:(18,36),0,64;__data:(18,33),64,288;;,0,352;;_G_int16_t:t(12,8)=(0,8)_G_int32_t:t(12,9)=(0,1)_G_uint16_t:t(12,10)=(0,9)_G_uint32_t:t(12,11)=(0,4)/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stdarg.h__gnuc_va_list:t(24,1)=(0,19)_IO_lock_t:t(11,1)=(0,20)_IO_marker:T(11,2)=s12_next:(11,3)=*(11,2),0,32;_sbuf:(11,4)=*(1,2),32,32;_pos:(0,1),64,32;;__codecvt_result:T(11,5)=e__codecvt_ok:0,__codecvt_partial:1,__codecvt_error:2,__codecvt_noconv:3,;_IO_FILE:T(1,2)=s148_flags:(0,1),0,32;_IO_read_ptr:(6,36),32,32;_IO_read_end:(6,36),64,32;_IO_read_base:(6,36),96,32;_IO_write_base:(6,36),128,32;_IO_write_ptr:(6,36),160,32;_IO_write_end:(6,36),192,32;_IO_buf_base:(6,36),224,32;_IO_buf_end:(6,36),256,32;_IO_save_base:(6,36),288,32;_IO_backup_base:(6,36),320,32;_IO_save_end:(6,36),352,32;_markers:(11,3),384,32;_chain:(11,4),416,32;_fileno:(0,1),448,32;_blksize:(0,1),480,32;_old_offset:(6,23),512,32;_cur_column:(0,9),544,16;_vtable_offset:(0,10),560,8;_shortbuf:(11,6)=ar(6,33);0;0;(0,2),568,8;_lock:(11,7)=*(11,1),576,32;_offset:(6,54),608,64;__pad1:(0,19),672,32;__pad2:(0,19),704,32;_mode:(0,1),736,32;_unused2:(11,8)=ar(6,33);0;51;(0,2),768,416;;_IO_FILE:t(11,9)=(1,2)__io_read_fn:t(11,10)=(11,11)=f(6,26)__io_write_fn:t(11,12)=(11,13)=f(6,26)__io_seek_fn:t(11,14)=(11,15)=f(0,1)__io_close_fn:t(11,16)=(11,17)=f(0,1)fpos_t:t(1,4)=(12,1)/usr/include/bits/stdio_lim.h/usr/include/bits/stdio.h/usr/include/stdlib.h/usr/include/features.h/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stddef.hdiv_t:t(27,1)=(27,2)=s8quot:(0,1),0,32;rem:(0,1),32,32;;ldiv_t:t(27,3)=(27,4)=s8quot:(0,3),0,32;rem:(0,3),32,32;;/usr/include/sys/types.h/usr/include/features.h/usr/include/bits/types.hu_char:t(30,1)=(6,1)u_short:t(30,2)=(6,2)u_int:t(30,3)=(6,3)u_long:t(30,4)=(6,4)quad_t:t(30,5)=(6,6)u_quad_t:t(30,6)=(6,5)fsid_t:t(30,7)=(6,30)loff_t:t(30,8)=(6,24)ino_t:t(30,9)=(6,20)dev_t:t(30,10)=(6,17)gid_t:t(30,11)=(6,19)mode_t:t(30,12)=(6,21)nlink_t:t(30,13)=(6,22)uid_t:t(30,14)=(6,18)off_t:t(30,15)=(6,23)pid_t:t(30,16)=(6,25)id_t:t(30,17)=(6,29)ssize_t:t(30,18)=(6,26)daddr_t:t(30,19)=(6,34)caddr_t:t(30,20)=(6,35)key_t:t(30,21)=(6,44)/usr/include/time.h/usr/include/bits/types.htime_t:t(33,1)=(6,37)/usr/include/bits/types.hclockid_t:t(33,2)=(6,42)/usr/include/bits/types.htimer_t:t(33,3)=(6,43)/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stddef.hulong:t(30,22)=(0,5)ushort:t(30,23)=(0,9)uint:t(30,24)=(0,4)int8_t:t(30,25)=(0,10)int16_t:t(30,26)=(0,8)int32_t:t(30,27)=(0,1)int64_t:t(30,28)=(0,6)u_int8_t:t(30,29)=(0,11)u_int16_t:t(30,30)=(0,9)u_int32_t:t(30,31)=(0,4)u_int64_t:t(30,32)=(0,7)register_t:t(30,33)=(0,1)/usr/include/endian.h/usr/include/features.h/usr/include/bits/endian.h/usr/include/sys/select.h/usr/include/features.h/usr/include/bits/types.h/usr/include/bits/select.h/usr/include/bits/sigset.h__sig_atomic_t:t(45,1)=(0,1)__sigset_t:t(45,2)=(45,3)=s128__val:(45,4)=ar(6,33);0;31;(0,5),0,1024;;sigset_t:t(41,1)=(45,2)/usr/include/time.htimespec:T(46,1)=s8tv_sec:(6,37),0,32;tv_nsec:(0,3),32,32;;/usr/include/bits/time.h/usr/include/bits/types.htimeval:T(47,1)=s8tv_sec:(6,37),0,32;tv_usec:(6,39),32,32;;suseconds_t:t(41,2)=(6,39)__fd_mask:t(41,3)=(0,3)fd_set:t(41,4)=(41,5)=s128__fds_bits:(41,6)=ar(6,33);0;31;(41,3),0,1024;;fd_mask:t(41,7)=(41,3)/usr/include/sys/sysmacros.hblkcnt_t:t(30,34)=(6,47)fsblkcnt_t:t(30,35)=(6,49)fsfilcnt_t:t(30,36)=(6,51)random_data:T(27,5)=s28fptr:(27,6)=*(30,27),0,32;rptr:(27,6),32,32;state:(27,6),64,32;rand_type:(0,1),96,32;rand_deg:(0,1),128,32;rand_sep:(0,1),160,32;end_ptr:(27,6),192,32;;drand48_data:T(27,7)=s24__x:(27,8)=ar(6,33);0;2;(0,9),0,48;__old_x:(27,8),48,48;__c:(0,9),96,16;__init:(0,9),112,16;__a:(0,7),128,64;;/usr/include/alloca.h/usr/include/features.h/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stddef.h__compar_fn_t:t(27,9)=(27,10)=*(27,11)=f(0,1)/usr/include/assert.h/usr/include/features.h/usr/include/stdio.h../../../include/sqlfront.h../../../include/sybfront.h../../../include/sybdb.h../../../include/tds.hrcsid_tds_h:S(59,1)=ar(6,33);0;55;(0,2)no_unused_tds_h_warn:S(59,2)=ar(0,1);0;-1;(0,19)../../../include/tds_configs.hrcsid_tds_configs_h:S(60,1)=ar(6,33);0;60;(0,2)no_unused_tds_configs_h_warn:S(60,2)=ar(0,1);0;-1;(0,19)/usr/include/sys/types.h/usr/include/sys/socket.h/usr/include/features.h/usr/include/sys/uio.h/usr/include/features.h/usr/include/sys/types.h/usr/include/bits/uio.h/usr/include/sys/types.hiovec:T(67,1)=s8iov_base:(0,19),0,32;iov_len:(5,1),32,32;;/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stddef.h/usr/include/bits/socket.h/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stddef.h/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/limits.h/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/syslimits.h/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/limits.h/usr/include/limits.h/usr/include/features.h/usr/include/bits/posix1_lim.h/usr/include/bits/local_lim.h/usr/include/linux/limits.h/usr/include/bits/posix2_lim.h/usr/include/sys/types.hsocklen_t:t(70,1)=(6,58)__socket_type:T(70,2)=eSOCK_STREAM:1,SOCK_DGRAM:2,SOCK_RAW:3,SOCK_RDM:4,SOCK_SEQPACKET:5,SOCK_PACKET:10,;/usr/include/bits/sockaddr.hsa_family_t:t(82,1)=(0,9)sockaddr:T(70,3)=s16sa_family:(82,1),0,16;sa_data:(70,4)=ar(6,33);0;13;(0,2),16,112;;sockaddr_storage:T(70,5)=s128ss_family:(82,1),0,16;__ss_align:(6,12),32,32;__ss_padding:(70,6)=ar(6,33);0;119;(0,2),64,960;; :T(70,7)=eMSG_OOB:1,MSG_PEEK:2,MSG_DONTROUTE:4,MSG_CTRUNC:8,MSG_PROXY:16,MSG_TRUNC:32,MSG_DONTWAIT:64,MSG_EOR:128,MSG_WAITALL:256,MSG_FIN:512,MSG_SYN:1024,MSG_CONFIRM:2048,MSG_RST:4096,MSG_ERRQUEUE:8192,MSG_NOSIGNAL:16384,MSG_MORE:32768,;msghdr:T(70,8)=s28msg_name:(0,19),0,32;msg_namelen:(70,1),32,32;msg_iov:(70,9)=*(67,1),64,32;msg_iovlen:(0,1),96,32;msg_control:(0,19),128,32;msg_controllen:(70,1),160,32;msg_flags:(0,1),192,32;;cmsghdr:T(70,10)=s12cmsg_len:(5,1),0,32;cmsg_level:(0,1),32,32;cmsg_type:(0,1),64,32;__cmsg_data:(70,11)=ar(6,33);0;-1;(0,11),96,0;; :T(70,12)=eSCM_RIGHTS:1,SCM_CREDENTIALS:2,__SCM_CONNECT:3,;ucred:T(70,13)=s12pid:(30,16),0,32;uid:(30,14),32,32;gid:(30,11),64,32;;/usr/include/asm/socket.h/usr/include/asm/sockios.hlinger:T(70,14)=s8l_onoff:(0,1),0,32;l_linger:(0,1),32,32;;osockaddr:T(62,1)=s16sa_family:(0,9),0,16;sa_data:(62,2)=ar(6,33);0;13;(0,11),16,112;; :T(62,3)=eSHUT_RD:0,SHUT_WR:1,SHUT_RDWR:2,;/usr/include/netinet/in.h/usr/include/features.h/usr/include/stdint.h/usr/include/features.h/usr/include/bits/wchar.h/usr/include/bits/wordsize.huint8_t:t(87,1)=(0,11)uint16_t:t(87,2)=(0,9)uint32_t:t(87,3)=(0,4)uint64_t:t(87,4)=(0,7)int_least8_t:t(87,5)=(0,10)int_least16_t:t(87,6)=(0,8)int_least32_t:t(87,7)=(0,1)int_least64_t:t(87,8)=(0,6)uint_least8_t:t(87,9)=(0,11)uint_least16_t:t(87,10)=(0,9)uint_least32_t:t(87,11)=(0,4)uint_least64_t:t(87,12)=(0,7)int_fast8_t:t(87,13)=(0,10)int_fast16_t:t(87,14)=(0,1)int_fast32_t:t(87,15)=(0,1)int_fast64_t:t(87,16)=(0,6)uint_fast8_t:t(87,17)=(0,11)uint_fast16_t:t(87,18)=(0,4)uint_fast32_t:t(87,19)=(0,4)uint_fast64_t:t(87,20)=(0,7)intptr_t:t(87,21)=(0,1)uintptr_t:t(87,22)=(0,4)intmax_t:t(87,23)=(0,6)uintmax_t:t(87,24)=(0,7)/usr/include/bits/types.h :T(85,1)=eIPPROTO_IP:0,IPPROTO_HOPOPTS:0,IPPROTO_ICMP:1,IPPROTO_IGMP:2,IPPROTO_IPIP:4,IPPROTO_TCP:6,IPPROTO_EGP:8,IPPROTO_PUP:12,IPPROTO_UDP:17,IPPROTO_IDP:22,IPPROTO_TP:29,IPPROTO_IPV6:41,IPPROTO_ROUTING:43,IPPROTO_FRAGMENT:44,IPPROTO_RSVP:46,IPPROTO_GRE:47,IPPROTO_ESP:50,IPPROTO_AH:51,IPPROTO_ICMPV6:58,IPPROTO_NONE:59,IPPROTO_DSTOPTS:60,IPPROTO_MTP:92,IPPROTO_ENCAP:98,IPPROTO_PIM:103,IPPROTO_COMP:108,IPPROTO_RAW:255,IPPROTO_MAX:256,;in_port_t:t(85,2)=(87,2) :T(85,3)=eIPPORT_ECHO:7,IPPORT_DISCARD:9,IPPORT_SYSTAT:11,IPPORT_DAYTIME:13,IPPORT_NETSTAT:15,IPPORT_FTP:21,IPPORT_TELNET:23,IPPORT_SMTP:25,IPPORT_TIMESERVER:37,IPPORT_NAMESERVER:42,IPPORT_WHOIS:43,IPPORT_MTP:57,IPPORT_TFTP:69,IPPORT_RJE:77,IPPORT_FINGER:79,IPPORT_TTYLINK:87,IPPORT_SUPDUP:95,IPPORT_EXECSERVER:512,IPPORT_LOGINSERVER:513,IPPORT_CMDSERVER:514,IPPORT_EFSSERVER:520,IPPORT_BIFFUDP:512,IPPORT_WHOSERVER:513,IPPORT_ROUTESERVER:520,IPPORT_RESERVED:1024,IPPORT_USERRESERVED:5000,;in_addr_t:t(85,4)=(87,3)in_addr:T(85,5)=s4s_addr:(85,4),0,32;;in6_addr:T(85,6)=s16in6_u:(85,7)=u16u6_addr8:(85,8)=ar(6,33);0;15;(87,1),0,128;u6_addr16:(85,9)=ar(6,33);0;7;(87,2),0,128;u6_addr32:(85,10)=ar(6,33);0;3;(87,3),0,128;;,0,128;;/usr/include/bits/socket.hsockaddr_in:T(85,11)=s16sin_family:(82,1),0,16;sin_port:(85,2),16,16;sin_addr:(85,5),32,32;sin_zero:(85,12)=ar(6,33);0;7;(0,11),64,64;;sockaddr_in6:T(85,13)=s28sin6_family:(82,1),0,16;sin6_port:(85,2),16,16;sin6_flowinfo:(87,3),32,32;sin6_addr:(85,6),64,128;sin6_scope_id:(87,3),192,32;;ipv6_mreq:T(85,14)=s20ipv6mr_multiaddr:(85,6),0,128;ipv6mr_interface:(0,4),128,32;;/usr/include/bits/in.hip_opts:T(93,1)=s44ip_dst:(85,5),0,32;ip_opts:(93,2)=ar(6,33);0;39;(0,2),32,320;;ip_mreq:T(93,3)=s8imr_multiaddr:(85,5),0,32;imr_interface:(85,5),32,32;;ip_mreqn:T(93,4)=s12imr_multiaddr:(85,5),0,32;imr_address:(85,5),32,32;imr_ifindex:(0,1),64,32;;in_pktinfo:T(93,5)=s12ipi_ifindex:(0,1),0,32;ipi_spec_dst:(85,5),32,32;ipi_addr:(85,5),64,32;;/usr/include/endian.h/usr/include/bits/byteswap.hin6_pktinfo:T(85,15)=s20ipi6_addr:(85,6),0,128;ipi6_ifindex:(0,4),128,32;;/usr/include/arpa/inet.h/usr/include/features.h/usr/include/netinet/in.h/usr/include/netdb.h/usr/include/features.h/usr/include/netinet/in.h/usr/include/stdint.h/usr/include/rpc/netdb.h/usr/include/features.h/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stddef.hrpcent:T(103,1)=s12r_name:(6,36),0,32;r_aliases:(103,2)=*(6,36),32,32;r_number:(0,1),64,32;;/usr/include/bits/netdb.hnetent:T(106,1)=s16n_name:(6,36),0,32;n_aliases:(103,2),32,32;n_addrtype:(0,1),64,32;n_net:(87,3),96,32;;hostent:T(99,1)=s20h_name:(6,36),0,32;h_aliases:(103,2),32,32;h_addrtype:(0,1),64,32;h_length:(0,1),96,32;h_addr_list:(103,2),128,32;;servent:T(99,2)=s16s_name:(6,36),0,32;s_aliases:(103,2),32,32;s_port:(0,1),64,32;s_proto:(6,36),96,32;;protoent:T(99,3)=s12p_name:(6,36),0,32;p_aliases:(103,2),32,32;p_proto:(0,1),64,32;;addrinfo:T(99,4)=s32ai_flags:(0,1),0,32;ai_family:(0,1),32,32;ai_socktype:(0,1),64,32;ai_protocol:(0,1),96,32;ai_addrlen:(70,1),128,32;ai_addr:(99,5)=*(70,3),160,32;ai_canonname:(6,36),192,32;ai_next:(99,6)=*(99,4),224,32;;/usr/include/sys/signal.h/usr/include/signal.h/usr/include/features.h/usr/include/bits/sigset.hsig_atomic_t:t(108,1)=(45,1)/usr/include/bits/types.h/usr/include/bits/signum.h__sighandler_t:t(108,2)=(108,3)=*(108,4)=f(0,20)sig_t:t(108,5)=(108,2)/usr/include/time.h/usr/include/bits/siginfo.h/usr/include/bits/wordsize.hsigval:T(114,1)=u4sival_int:(0,1),0,32;sival_ptr:(0,19),0,32;;sigval_t:t(114,2)=(114,1)siginfo:T(114,3)=s128si_signo:(0,1),0,32;si_errno:(0,1),32,32;si_code:(0,1),64,32;_sifields:(114,4)=u116_pad:(114,5)=ar(6,33);0;28;(0,1),0,928;_kill:(114,6)=s8si_pid:(6,25),0,32;si_uid:(6,18),32,32;;,0,64;_timer:(114,7)=s8_timer1:(0,4),0,32;_timer2:(0,4),32,32;;,0,64;_rt:(114,8)=s12si_pid:(6,25),0,32;si_uid:(6,18),32,32;si_sigval:(114,2),64,32;;,0,96;_sigchld:(114,9)=s20si_pid:(6,25),0,32;si_uid:(6,18),32,32;si_status:(0,1),64,32;si_utime:(6,41),96,32;si_stime:(6,41),128,32;;,0,160;_sigfault:(114,10)=s4si_addr:(0,19),0,32;;,0,32;_sigpoll:(114,11)=s8si_band:(0,3),0,32;si_fd:(0,1),32,32;;,0,64;;,96,928;;siginfo_t:t(114,12)=(114,3) :T(114,13)=eSI_ASYNCNL:-6,SI_SIGIO:-5,SI_ASYNCIO:-4,SI_MESGQ:-3,SI_TIMER:-2,SI_QUEUE:-1,SI_USER:0,SI_KERNEL:128,; :T(114,14)=eILL_ILLOPC:1,ILL_ILLOPN:2,ILL_ILLADR:3,ILL_ILLTRP:4,ILL_PRVOPC:5,ILL_PRVREG:6,ILL_COPROC:7,ILL_BADSTK:8,; :T(114,15)=eFPE_INTDIV:1,FPE_INTOVF:2,FPE_FLTDIV:3,FPE_FLTOVF:4,FPE_FLTUND:5,FPE_FLTRES:6,FPE_FLTINV:7,FPE_FLTSUB:8,; :T(114,16)=eSEGV_MAPERR:1,SEGV_ACCERR:2,; :T(114,17)=eBUS_ADRALN:1,BUS_ADRERR:2,BUS_OBJERR:3,; :T(114,18)=eTRAP_BRKPT:1,TRAP_TRACE:2,; :T(114,19)=eCLD_EXITED:1,CLD_KILLED:2,CLD_DUMPED:3,CLD_TRAPPED:4,CLD_STOPPED:5,CLD_CONTINUED:6,; :T(114,20)=ePOLL_IN:1,POLL_OUT:2,POLL_MSG:3,POLL_ERR:4,POLL_PRI:5,POLL_HUP:6,;sigevent:T(114,21)=s64sigev_value:(114,2),0,32;sigev_signo:(0,1),32,32;sigev_notify:(0,1),64,32;_sigev_un:(114,22)=u52_pad:(114,23)=ar(6,33);0;12;(0,1),0,416;_sigev_thread:(114,24)=s8_function:(114,25)=*(114,26)=f(0,20),0,32;_attribute:(114,27)=*(9,5),32,32;;,0,64;;,96,416;;sigevent_t:t(114,28)=(114,21) :T(114,29)=eSIGEV_SIGNAL:0,SIGEV_NONE:1,SIGEV_THREAD:2,;/usr/include/bits/sigaction.hsigaction:T(116,1)=s140__sigaction_handler:(116,2)=u4sa_handler:(108,2),0,32;sa_sigaction:(116,3)=*(116,4)=f(0,20),0,32;;,0,32;sa_mask:(45,2),32,1024;sa_flags:(0,1),1056,32;sa_restorer:(116,5)=*(116,6)=f(0,20),1088,32;;sigvec:T(108,6)=s12sv_handler:(108,2),0,32;sv_mask:(0,1),32,32;sv_flags:(0,1),64,32;;/usr/include/bits/sigcontext.h/usr/include/asm/sigcontext.h_fpreg:T(118,1)=s10significand:(118,2)=ar(6,33);0;3;(0,9),0,64;exponent:(0,9),64,16;;_fpxreg:T(118,3)=s16significand:(118,2),0,64;exponent:(0,9),64,16;padding:(27,8),80,48;;_xmmreg:T(118,4)=s16element:(118,5)=ar(6,33);0;3;(0,5),0,128;;_fpstate:T(118,6)=s624cw:(0,5),0,32;sw:(0,5),32,32;tag:(0,5),64,32;ipoff:(0,5),96,32;cssel:(0,5),128,32;dataoff:(0,5),160,32;datasel:(0,5),192,32;_st:(118,7)=ar(6,33);0;7;(118,1),224,640;status:(0,9),864,16;magic:(0,9),880,16;_fxsr_env:(118,8)=ar(6,33);0;5;(0,5),896,192;mxcsr:(0,5),1088,32;reserved:(0,5),1120,32;_fxsr_st:(118,9)=ar(6,33);0;7;(118,3),1152,1024;_xmm:(118,10)=ar(6,33);0;7;(118,4),2176,1024;padding:(118,11)=ar(6,33);0;55;(0,5),3200,1792;;sigcontext:T(118,12)=s88gs:(0,9),0,16;__gsh:(0,9),16,16;fs:(0,9),32,16;__fsh:(0,9),48,16;es:(0,9),64,16;__esh:(0,9),80,16;ds:(0,9),96,16;__dsh:(0,9),112,16;edi:(0,5),128,32;esi:(0,5),160,32;ebp:(0,5),192,32;esp:(0,5),224,32;ebx:(0,5),256,32;edx:(0,5),288,32;ecx:(0,5),320,32;eax:(0,5),352,32;trapno:(0,5),384,32;err:(0,5),416,32;eip:(0,5),448,32;cs:(0,9),480,16;__csh:(0,9),496,16;eflags:(0,5),512,32;esp_at_signal:(0,5),544,32;ss:(0,9),576,16;__ssh:(0,9),592,16;fpstate:(118,13)=*(118,6),608,32;oldmask:(0,5),640,32;cr2:(0,5),672,32;;/usr/include/bits/sigstack.hsigstack:T(119,1)=s8ss_sp:(0,19),0,32;ss_onstack:(0,1),32,32;; :T(119,2)=eSS_ONSTACK:1,SS_DISABLE:2,;sigaltstack:T(119,3)=s12ss_sp:(0,19),0,32;ss_flags:(0,1),32,32;ss_size:(5,1),64,32;;stack_t:t(119,4)=(119,3)/usr/include/bits/sigthread.h/usr/include/sys/wait.h/usr/include/features.h/usr/include/signal.h/usr/include/sys/resource.h/usr/include/features.h/usr/include/bits/resource.h/usr/include/bits/types.h__rlimit_resource:T(126,1)=eRLIMIT_CPU:0,RLIMIT_FSIZE:1,RLIMIT_DATA:2,RLIMIT_STACK:3,RLIMIT_CORE:4,RLIMIT_RSS:5,RLIMIT_NOFILE:7,RLIMIT_OFILE:7,RLIMIT_AS:9,RLIMIT_NPROC:6,RLIMIT_MEMLOCK:8,RLIMIT_LOCKS:10,RLIMIT_NLIMITS:11,RLIM_NLIMITS:11,;rlim_t:t(126,2)=(6,27)rlimit:T(126,3)=s8rlim_cur:(126,2),0,32;rlim_max:(126,2),32,32;;__rusage_who:T(126,4)=eRUSAGE_SELF:0,RUSAGE_CHILDREN:-1,RUSAGE_BOTH:-2,;/usr/include/bits/time.hrusage:T(126,5)=s72ru_utime:(47,1),0,64;ru_stime:(47,1),64,64;ru_maxrss:(0,3),128,32;ru_ixrss:(0,3),160,32;ru_idrss:(0,3),192,32;ru_isrss:(0,3),224,32;ru_minflt:(0,3),256,32;ru_majflt:(0,3),288,32;ru_nswap:(0,3),320,32;ru_inblock:(0,3),352,32;ru_oublock:(0,3),384,32;ru_msgsnd:(0,3),416,32;ru_msgrcv:(0,3),448,32;ru_nsignals:(0,3),480,32;ru_nvcsw:(0,3),512,32;ru_nivcsw:(0,3),544,32;;__priority_which:T(126,6)=ePRIO_PROCESS:0,PRIO_PGRP:1,PRIO_USER:2,;__rlimit_resource_t:t(124,1)=(0,1)__rusage_who_t:t(124,2)=(0,1)__priority_which_t:t(124,3)=(0,1)/usr/include/bits/waitflags.h__WAIT_STATUS:t(121,1)=(121,2)=u4__uptr:(121,3)=*(121,4)=xuwait:,0,32;__iptr:(121,5)=*(0,1),0,32;;/usr/include/bits/waitstatus.h/usr/include/endian.hwait:T(121,4)=u4w_status:(0,1),0,32;__wait_terminated:(130,1)=s4__w_termsig:(0,4),0,7;__w_coredump:(0,4),7,1;__w_retcode:(0,4),8,8;:(0,4),16,16;;,0,32;__wait_stopped:(130,2)=s4__w_stopval:(0,4),0,8;__w_stopsig:(0,4),8,8;:(0,4),16,16;;,0,32;; :T(121,6)=eP_ALL:0,P_PID:1,P_PGID:2,;idtype_t:t(121,7)=(121,6)/usr/include/bits/siginfo.h/usr/include/bits/wordsize.h/usr/include/errno.h/usr/include/features.h/usr/include/bits/errno.h/usr/include/linux/errno.h/usr/include/asm/errno.h/usr/include/stdio.h/usr/include/ctype.h/usr/include/features.h/usr/include/bits/types.h/usr/include/endian.h :T(140,1)=e_ISupper:256,_ISlower:512,_ISalpha:1024,_ISdigit:2048,_ISxdigit:4096,_ISspace:8192,_ISprint:16384,_ISgraph:32768,_ISblank:1,_IScntrl:2,_ISpunct:4,_ISalnum:8,;/usr/include/string.h/usr/include/features.h/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stddef.h/usr/include/bits/string.h/usr/include/bits/string2.h/usr/include/endian.h/usr/include/bits/types.h/usr/include/stdlib.h/usr/include/stdlib.h/usr/include/time.h/usr/include/features.h/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stddef.h/usr/include/bits/time.h/usr/include/bits/types.h/usr/include/bits/types.hclock_t:t(153,1)=(6,41)tm:T(153,2)=s44tm_sec:(0,1),0,32;tm_min:(0,1),32,32;tm_hour:(0,1),64,32;tm_mday:(0,1),96,32;tm_mon:(0,1),128,32;tm_year:(0,1),160,32;tm_wday:(0,1),192,32;tm_yday:(0,1),224,32;tm_isdst:(0,1),256,32;tm_gmtoff:(0,3),288,32;tm_zone:(18,32),320,32;;itimerspec:T(153,3)=s16it_interval:(46,1),0,64;it_value:(46,1),64,64;;/usr/include/sys/time.h/usr/include/features.h/usr/include/bits/types.h/usr/include/time.h/usr/include/bits/time.h/usr/include/sys/select.htimezone:T(159,1)=s8tz_minuteswest:(0,1),0,32;tz_dsttime:(0,1),32,32;;__timezone_ptr_t:t(159,2)=(159,3)=*(159,1)__itimer_which:T(159,4)=eITIMER_REAL:0,ITIMER_VIRTUAL:1,ITIMER_PROF:2,;itimerval:T(159,5)=s16it_interval:(47,1),0,64;it_value:(47,1),64,64;;__itimer_which_t:t(159,6)=(0,1)/usr/include/unistd.h/usr/include/features.h/usr/include/bits/posix_opt.h/usr/include/bits/types.h/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stddef.h/usr/include/bits/confname.h :T(170,1)=e_PC_LINK_MAX:0,_PC_MAX_CANON:1,_PC_MAX_INPUT:2,_PC_NAME_MAX:3,_PC_PATH_MAX:4,_PC_PIPE_BUF:5,_PC_CHOWN_RESTRICTED:6,_PC_NO_TRUNC:7,_PC_VDISABLE:8,_PC_SYNC_IO:9,_PC_ASYNC_IO:10,_PC_PRIO_IO:11,_PC_SOCK_MAXBUF:12,_PC_FILESIZEBITS:13,_PC_REC_INCR_XFER_SIZE:14,_PC_REC_MAX_XFER_SIZE:15,_PC_REC_MIN_XFER_SIZE:16,_PC_REC_XFER_ALIGN:17,_PC_ALLOC_SIZE_MIN:18,_PC_SYMLINK_MAX:19,; :T(170,2)=e_SC_ARG_MAX:0,_SC_CHILD_MAX:1,_SC_CLK_TCK:2,_SC_NGROUPS_MAX:3,_SC_OPEN_MAX:4,_SC_STREAM_MAX:5,_SC_TZNAME_MAX:6,_SC_JOB_CONTROL:7,_SC_SAVED_IDS:8,_SC_REALTIME_SIGNALS:9,_SC_PRIORITY_SCHEDULING:10,_SC_TIMERS:11,_SC_ASYNCHRONOUS_IO:12,_SC_PRIORITIZED_IO:13,_SC_SYNCHRONIZED_IO:14,_SC_FSYNC:15,_SC_MAPPED_FILES:16,_SC_MEMLOCK:17,_SC_MEMLOCK_RANGE:18,_SC_MEMORY_PROTECTION:19,_SC_MESSAGE_PASSING:20,_SC_SEMAPHORES:21,_SC_SHARED_MEMORY_OBJECTS:22,_SC_AIO_LISTIO_MAX:23,_SC_AIO_MAX:24,_SC_AIO_PRIO_DELTA_MAX:25,_SC_DELAYTIMER_MAX:26,_SC_MQ_OPEN_MAX:27,_SC_MQ_PRIO_MAX:28,_SC_VERSION:29,_SC_PAGESIZE:30,_SC_RTSIG_MAX:31,_SC_SEM_NSEMS_MAX:32,_SC_SEM_VALUE_MAX:33,_SC_SIGQUEUE_MAX:34,_SC_TIMER_MAX:35,_SC_BC_BASE_MAX:36,_SC_BC_DIM_MAX:37,_SC_BC_SCALE_MAX:38,_SC_BC_STRING_MAX:39,_SC_COLL_WEIGHTS_MAX:40,_SC_EQUIV_CLASS_MAX:41,_SC_EXPR_NEST_MAX:42,_SC_LINE_MAX:43,_SC_RE_DUP_MAX:44,_SC_CHARCLASS_NAME_MAX:45,_SC_2_VERSION:46,_SC_2_C_BIND:47,_SC_2_C_DEV:48,_SC_2_FORT_DEV:49,_SC_2_FORT_RUN:50,_SC_2_SW_DEV:51,_SC_2_LOCALEDEF:52,_SC_PII:53,_SC_PII_XTI:54,_SC_PII_SOCKET:55,_SC_PII_INTERNET:56,_SC_PII_OSI:57,_SC_POLL:58,_SC_SELECT:59,_SC_UIO_MAXIOV:60,_SC_IOV_MAX:60,_SC_PII_INTERNET_STREAM:61,_SC_PII_INTERNET_DGRAM:62,_SC_PII_OSI_COTS:63,_SC_PII_OSI_CLTS:64,_SC_PII_OSI_M:65,_SC_T_IOV_MAX:66,_SC_THREADS:67,_SC_THREAD_SAFE_FUNCTIONS:68,_SC_GETGR_R_SIZE_MAX:69,_SC_GETPW_R_SIZE_MAX:70,_SC_LOGIN_NAME_MAX:71,_SC_TTY_NAME_MAX:72,_SC_THREAD_DESTRUCTOR_ITERATIONS:73,_SC_THREAD_KEYS_MAX:74,_SC_THREAD_STACK_MIN:75,_SC_THREAD_THREADS_MAX:76,_SC_THREAD_ATTR_STACKADDR:77,_SC_THREAD_ATTR_STACKSIZE:78,_SC_THREAD_PRIORITY_SCHEDULING:79,_SC_THREAD_PRIO_INHERIT:80,_SC_THREAD_PRIO_PROTECT:81,_SC_THREAD_PROCESS_SHARED:82,_SC_NPROCESSORS_CONF:83,_SC_NPROCESSORS_ONLN:84,_SC_PHYS_PAGES:85,_SC_AVPHYS_PAGES:86,_SC_ATEXIT_MAX:87,_SC_PASS_MAX:88,_SC_XOPEN_VERSION:89,_SC_XOPEN_XCU_VERSION:90,_SC_XOPEN_UNIX:91,_SC_XOPEN_CRYPT:92,_SC_XOPEN_ENH_I18N:93,_SC_XOPEN_SHM:94,_SC_2_CHAR_TERM:95,_SC_2_C_VERSION:96,_SC_2_UPE:97,_SC_XOPEN_XPG2:98,_SC_XOPEN_XPG3:99,_SC_XOPEN_XPG4:100,_SC_CHAR_BIT:101,_SC_CHAR_MAX:102,_SC_CHAR_MIN:103,_SC_INT_MAX:104,_SC_INT_MIN:105,_SC_LONG_BIT:106,_SC_WORD_BIT:107,_SC_MB_LEN_MAX:108,_SC_NZERO:109,_SC_SSIZE_MAX:110,_SC_SCHAR_MAX:111,_SC_SCHAR_MIN:112,_SC_SHRT_MAX:113,_SC_SHRT_MIN:114,_SC_UCHAR_MAX:115,_SC_UINT_MAX:116,_SC_ULONG_MAX:117,_SC_USHRT_MAX:118,_SC_NL_ARGMAX:119,_SC_NL_LANGMAX:120,_SC_NL_MSGMAX:121,_SC_NL_NMAX:122,_SC_NL_SETMAX:123,_SC_NL_TEXTMAX:124,_SC_XBS5_ILP32_OFF32:125,_SC_XBS5_ILP32_OFFBIG:126,_SC_XBS5_LP64_OFF64:127,_SC_XBS5_LPBIG_OFFBIG:128,_SC_XOPEN_LEGACY:129,_SC_XOPEN_REALTIME:130,_SC_XOPEN_REALTIME_THREADS:131,_SC_ADVISORY_INFO:132,_SC_BARRIERS:133,_SC_BASE:134,_SC_C_LANG_SUPPORT:135,_SC_C_LANG_SUPPORT_R:136,_SC_CLOCK_SELECTION:137,_SC_CPUTIME:138,_SC_THREAD_CPUTIME:139,_SC_DEVICE_IO:140,_SC_DEVICE_SPECIFIC:141,_SC_DEVICE_SPECIFIC_R:142,_SC_FD_MGMT:143,_SC_FIFO:144,_SC_PIPE:145,_SC_FILE_ATTRIBUTES:146,_SC_FILE_LOCKING:147,_SC_FILE_SYSTEM:148,_SC_MONOTONIC_CLOCK:149,_SC_MULTI_PROCESS:150,_SC_SINGLE_PROCESS:151,_SC_NETWORKING:152,_SC_READER_WRITER_LOCKS:153,_SC_SPIN_LOCKS:154,_SC_REGEXP:155,_SC_REGEX_VERSION:156,_SC_SHELL:157,_SC_SIGNALS:158,_SC_SPAWN:159,_SC_SPORADIC_SERVER:160,_SC_THREAD_SPORADIC_SERVER:161,_SC_SYSTEM_DATABASE:162,_SC_SYSTEM_DATABASE_R:163,_SC_TIMEOUTS:164,_SC_TYPED_MEMORY_OBJECTS:165,_SC_USER_GROUPS:166,_SC_USER_GROUPS_R:167,_SC_2_PBS:168,_SC_2_PBS_ACCOUNTING:169,_SC_2_PBS_LOCATE:170,_SC_2_PBS_MESSAGE:171,_SC_2_PBS_TRACK:172,_SC_SYMLOOP_MAX:173,_SC_STREAMS:174,_SC_2_PBS_CHECKPOINT:175,_SC_V6_ILP32_OFF32:176,_SC_V6_ILP32_OFFBIG:177,_SC_V6_LP64_OFF64:178,_SC_V6_LPBIG_OFFBIG:179,_SC_HOST_NAME_MAX:180,_SC_TRACE:181,_SC_TRACE_EVENT_FILTER:182,_SC_TRACE_INHERIT:183,_SC_TRACE_LOG:184,; :T(170,3)=e_CS_PATH:0,_CS_V6_WIDTH_RESTRICTED_ENVS:1,;/usr/include/getopt.h../../../include/tdsver.hrcsid_tdsver_h:S(172,1)=ar(6,33);0;92;(0,2)no_unused_tdsver_h_warn:S(172,2)=ar(0,1);0;-1;(0,19)TDS_CHAR:t(59,3)=(0,2)TDS_UCHAR:t(59,4)=(0,11)TDS_TINYINT:t(59,5)=(0,11)TDS_SMALLINT:t(59,6)=(0,8)TDS_USMALLINT:t(59,7)=(0,9)TDS_INT:t(59,8)=(0,1)TDS_UINT:t(59,9)=(0,4)TDS_REAL:t(59,10)=(0,12)TDS_FLOAT:t(59,11)=(0,13)TDS_INT8:t(59,12)=(0,6)TDS_UINT8:t(59,13)=(0,7)tdsnumeric:T(59,14)=s19precision:(0,11),0,8;scale:(0,11),8,8;array:(59,15)=ar(6,33);0;16;(0,11),16,136;;TDS_NUMERIC:t(59,16)=(59,14)tdsoldmoney:T(59,17)=s8mnyhigh:(59,8),0,32;mnylow:(59,8),32,32;;TDS_OLD_MONEY:t(59,18)=(59,17)tdsmoney:T(59,19)=u8tdsoldmoney:(59,18),0,64;mny:(59,12),0,64;;TDS_MONEY:t(59,20)=(59,19)tdsmoney4:T(59,21)=s4mny4:(59,8),0,32;;TDS_MONEY4:t(59,22)=(59,21)tdsdatetime:T(59,23)=s8dtdays:(59,8),0,32;dttime:(59,8),32,32;;TDS_DATETIME:t(59,24)=(59,23)tdsdatetime4:T(59,25)=s4days:(59,7),0,16;minutes:(59,7),16,16;;TDS_DATETIME4:t(59,26)=(59,25)tdsvarbinary:T(59,27)=s260len:(59,8),0,32;array:(59,28)=ar(6,33);0;255;(59,3),32,2048;;TDS_VARBINARY:t(59,29)=(59,27)tdsvarchar:T(59,30)=s260len:(59,8),0,32;array:(59,28),32,2048;;TDS_VARCHAR:t(59,31)=(59,30)tdsunique:T(59,32)=s16Data1:(59,9),0,32;Data2:(59,7),32,16;Data3:(59,7),48,16;Data4:(59,33)=ar(6,33);0;7;(59,4),64,64;;TDS_UNIQUE:t(59,34)=(59,32)tdsdaterec:T(59,35)=s40year:(59,8),0,32;month:(59,8),32,32;day:(59,8),64,32;dayofyear:(59,8),96,32;weekday:(59,8),128,32;hour:(59,8),160,32;minute:(59,8),192,32;second:(59,8),224,32;millisecond:(59,8),256,32;tzone:(59,8),288,32;;TDSDATEREC:t(59,36)=(59,35)tds_login:T(59,37)=s292host_name:(59,38)=ar(6,33);0;30;(59,3),0,248;user_name:(59,38),248,248;password:(59,39)=ar(6,33);0;40;(59,3),496,328;bulk_copy:(59,5),824,8;app_name:(59,38),832,248;server_name:(59,38),1080,248;major_version:(59,5),1328,8;minor_version:(59,5),1336,8;library:(59,40)=ar(6,33);0;11;(59,3),1344,96;language:(59,38),1440,248;encrypted:(59,5),1688,8;char_set:(59,38),1696,248;block_size:(59,6),1952,16;suppress_language:(59,5),1968,8;connect_timeout:(59,8),1984,32;query_timeout:(59,8),2016,32;longquery_timeout:(59,8),2048,32;longquery_func:(59,41)=*(59,42)=f(0,20),2080,32;longquery_param:(0,3),2112,32;capabilities:(59,43)=ar(6,33);0;17;(0,11),2144,144;port:(0,1),2304,32;;TDSLOGIN:t(59,44)=(59,37)tds_config_info:T(59,45)=s120server_name:(6,36),0,32;host:(6,36),32,32;ip_addr:(6,36),64,32;port:(0,1),96,32;minor_version:(59,6),128,16;major_version:(59,6),144,16;block_size:(0,1),160,32;language:(6,36),192,32;char_set:(6,36),224,32;database:(6,36),256,32;dump_file:(6,36),288,32;broken_dates:(0,1),320,32;broken_money:(0,1),352,32;timeout:(0,1),384,32;connect_timeout:(0,1),416,32;host_name:(6,36),448,32;default_domain:(6,36),480,32;try_server_login:(0,1),512,32;try_domain_login:(0,1),544,32;xdomain_auth:(0,1),576,32;debug_level:(0,1),608,32;emul_little_endian:(0,1),640,32;text_size:(0,1),672,32;app_name:(6,36),704,32;user_name:(6,36),736,32;password:(6,36),768,32;library:(6,36),800,32;bulk_copy:(0,1),832,32;suppress_language:(0,1),864,32;encrypted:(0,1),896,32;client_charset:(6,36),928,32;;TDSCONFIGINFO:t(59,46)=(59,45)tds_loc_info:T(59,47)=s12language:(6,36),0,32;char_set:(6,36),32,32;date_fmt:(6,36),64,32;;TDSLOCINFO:t(59,48)=(59,47)tds_column_info:T(59,49)=s356column_type:(59,6),0,16;column_type_save:(59,6),16,16;column_usertype:(59,6),32,16;column_flags:(59,6),48,16;column_size:(59,8),64,32;column_offset:(59,8),96,32;column_namelen:(59,5),128,8;column_varint_size:(59,5),136,8;column_name:(59,28),144,2048;column_bindtype:(59,6),2192,16;column_bindfmt:(59,6),2208,16;column_bindlen:(59,9),2240,32;column_nullbind:(59,50)=*(59,3),2272,32;varaddr:(59,50),2304,32;column_lenbind:(59,50),2336,32;column_prec:(59,6),2368,16;column_scale:(59,6),2384,16;column_textsize:(59,8),2400,32;column_textpos:(59,8),2432,32;column_text_sqlgetdatapos:(59,8),2464,32;column_textptr:(59,51)=ar(6,33);0;15;(59,3),2496,128;column_timestamp:(59,52)=ar(6,33);0;7;(59,3),2624,64;column_textvalue:(59,50),2688,32;column_nullable:(59,5),2720,8;column_writeable:(59,5),2728,8;column_identity:(59,5),2736,8;column_unicodedata:(59,5),2744,8;collation:(59,53)=ar(6,33);0;4;(59,3),2752,40;cur_row_size:(59,8),2816,32;;TDSCOLINFO:t(59,54)=(59,49)tds_result_info:T(59,55)=s28rows_exist:(59,6),0,16;row_count:(59,8),32,32;row_size:(59,8),64,32;num_cols:(59,6),96,16;more_results:(59,5),112,8;columns:(59,56)=*(59,57)=*(59,54),128,32;null_info_size:(0,1),160,32;current_row:(18,34),192,32;;TDSRESULTINFO:t(59,58)=(59,55) :T(59,59)=eTDS_QUERYING:0,TDS_PENDING:1,TDS_COMPLETED:2,TDS_CANCELED:3,TDS_DEAD:4,;tds_compute_info:T(59,60)=s20num_cols:(59,6),0,16;row_size:(59,8),32,32;columns:(59,56),64,32;null_info_size:(0,1),96,32;current_row:(18,34),128,32;;TDSCOMPUTEINFO:t(59,61)=(59,60)tds_param_info:T(59,62)=s20num_cols:(59,6),0,16;row_size:(59,8),32,32;columns:(59,56),64,32;null_info_size:(0,1),96,32;current_row:(18,34),128,32;;TDSPARAMINFO:t(59,63)=(59,62)tds_input_param:T(59,64)=s16column_type:(59,6),0,16;varaddr:(59,50),32,32;column_bindlen:(59,9),64,32;is_null:(59,3),96,8;;TDSINPUTPARAM:t(59,65)=(59,64)tds_msg_info:T(59,66)=s28priv_msg_type:(59,6),0,16;line_number:(59,6),16,16;msg_number:(59,9),32,32;msg_state:(59,6),64,16;msg_level:(59,6),80,16;server:(59,50),96,32;message:(59,50),128,32;proc_name:(59,50),160,32;sql_state:(59,50),192,32;;TDSMSGINFO:t(59,67)=(59,66)tds_env_info:T(59,68)=s16block_size:(0,1),0,32;language:(6,36),32,32;charset:(6,36),64,32;database:(6,36),96,32;;TDSENVINFO:t(59,69)=(59,68)tds_dynamic:T(59,70)=s48id:(59,71)=ar(6,33);0;29;(0,2),0,240;dyn_state:(0,1),256,32;res_info:(59,72)=*(59,58),288,32;num_params:(0,1),320,32;params:(59,73)=*(59,74)=*(59,65),352,32;;TDSDYNAMIC:t(59,75)=(59,70)TDSCONTEXT:t(59,76)=(59,77)=xstds_context:TDSSOCKET:t(59,78)=(59,79)=xstds_socket:tds_context:T(59,77)=s16locale:(59,80)=*(59,48),0,32;parent:(0,19),32,32;msg_handler:(59,81)=*(59,82)=f(0,1),64,32;err_handler:(59,81),96,32;;tds_socket:T(59,79)=s152s:(0,1),0,32;major_version:(59,6),32,16;minor_version:(59,6),48,16;capabilities:(59,43),64,144;broken_dates:(0,11),208,8;in_buf:(18,34),224,32;out_buf:(18,34),256,32;in_buf_max:(0,4),288,32;in_pos:(0,4),320,32;out_pos:(0,4),352,32;in_len:(0,4),384,32;out_len:(0,4),416,32;out_flag:(0,11),448,8;last_packet:(0,11),456,8;parent:(0,19),480,32;res_info:(59,72),512,32;comp_info:(59,83)=*(59,61),544,32;param_info:(59,84)=*(59,63),576,32;has_status:(59,5),608,8;ret_status:(59,8),640,32;msg_info:(59,85)=*(59,67),672,32;state:(59,5),704,8;rows_affected:(0,1),736,32;timeout:(59,8),768,32;longquery_timeout:(59,8),800,32;longquery_func:(59,41),832,32;longquery_param:(0,3),864,32;queryStarttime:(33,1),896,32;env:(59,86)=*(59,69),928,32;num_dyns:(0,1),960,32;cur_dyn_elem:(0,1),992,32;dyns:(59,87)=*(59,88)=*(59,75),1024,32;emul_little_endian:(0,1),1056,32;date_fmt:(6,36),1088,32;tds_ctx:(59,89)=*(59,76),1120,32;iconv_info:(0,19),1152,32;config:(59,90)=*(59,46),1184,32;;tds_answer:T(59,91)=s48lm_resp:(59,92)=ar(6,33);0;23;(0,11),0,192;nt_resp:(59,92),192,192;;TDSANSWER:t(59,93)=(59,91)rcsid_sybdb_h:S(58,1)=ar(6,33);0;56;(0,2)no_unused_sybdb_h_warn:S(58,2)=ar(0,1);0;-1;(0,19)RETCODE:t(58,3)=(0,1)DBCURSOR:t(58,4)=(0,20)DBXLATE:t(58,5)=(0,20)DBSORTORDER:t(58,6)=(0,20)DBLOGINFO:t(58,7)=(0,20)DBVOIDPTR:t(58,8)=(0,19)SHORT:t(58,9)=(0,8)USHORT:t(58,10)=(0,9)INTFUNCPTR:t(58,11)=(58,12)=*(58,13)=f(0,1)STATUS:t(58,14)=(0,1)BOOL:t(58,15)=(0,11)DBBOOL:t(58,16)=(0,11)DBCHAR:t(58,17)=(59,3)DBTINYINT:t(58,18)=(0,11)DBSMALLINT:t(58,19)=(59,6)DBINT:t(58,20)=(59,8)DBBINARY:t(58,21)=(0,11)DBREAL:t(58,22)=(59,10)DBFLT8:t(58,23)=(59,11)DBUSMALLINT:t(58,24)=(0,9)DBNUMERIC:t(58,25)=(59,16)DBMONEY:t(58,26)=(59,20)DBMONEY4:t(58,27)=(59,22)DBDATETIME:t(58,28)=(59,24)DBDATETIME4:t(58,29)=(59,26)LOGINREC:t(58,30)=(58,31)=s4tds_login:(0,19),0,32;;BYTE:t(58,32)=(0,11)dbtypeinfo:T(58,33)=s8precision:(58,20),0,32;scale:(58,20),32,32;;DBTYPEINFO:t(58,34)=(58,33)tag_DBPROC_ROWBUF:T(58,35)=s36buffering_on:(0,1),0,32;first_in_buf:(0,1),32,32;next_row:(0,1),64,32;newest:(0,1),96,32;oldest:(0,1),128,32;elcount:(0,1),160,32;element_size:(0,1),192,32;rows_in_buf:(0,1),224,32;rows:(0,19),256,32;;DBPROC_ROWBUF:t(58,36)=(58,35)BCP_HOSTCOLINFO:t(58,37)=(58,38)=s32host_column:(0,1),0,32;host_var:(0,19),32,32;datatype:(0,1),64,32;prefix_len:(0,1),96,32;column_len:(58,20),128,32;terminator:(58,39)=*(58,32),160,32;term_len:(0,1),192,32;tab_colnum:(0,1),224,32;;BCP_COLINFO:t(58,40)=(58,41)=s312tab_colnum:(0,1),0,32;db_name:(58,42)=ar(6,33);0;255;(0,2),32,2048;db_minlen:(59,6),2080,16;db_maxlen:(59,6),2096,16;db_colcnt:(59,6),2112,16;db_type:(59,5),2128,8;db_type_save:(59,5),2136,8;db_usertype:(59,6),2144,16;db_varint_size:(59,5),2160,8;db_length:(59,8),2176,32;db_nullable:(59,5),2208,8;db_status:(59,5),2216,8;db_offset:(59,6),2224,16;db_default:(59,5),2240,8;db_prec:(59,5),2248,8;db_scale:(59,5),2256,8;db_flags:(59,6),2272,16;db_size:(59,8),2304,32;db_unicodedata:(59,5),2336,8;db_collate:(58,43)=ar(6,33);0;4;(0,2),2344,40;data_size:(0,3),2400,32;data:(58,39),2432,32;txptr_offset:(0,1),2464,32;;DBPROCESS:t(58,44)=(58,45)=s144tds_socket:(58,46)=*(59,78),0,32;row_buf:(58,36),32,288;noautofree:(0,1),320,32;more_results:(0,1),352,32;user_data:(58,39),384,32;dbbuf:(18,34),416,32;dbbufsz:(0,1),448,32;empty_res_hack:(0,1),480,32;text_size:(59,8),512,32;text_sent:(59,8),544,32;bcp_hostfile:(59,50),576,32;bcp_errorfile:(59,50),608,32;bcp_tablename:(59,50),640,32;bcp_insert_stmt:(59,50),672,32;bcp_direction:(59,8),704,32;bcp_colcount:(59,8),736,32;host_colcount:(59,8),768,32;bcp_columns:(58,47)=*(58,48)=*(58,40),800,32;host_columns:(58,49)=*(58,50)=*(58,37),832,32;firstrow:(59,8),864,32;lastrow:(59,8),896,32;maxerrs:(59,8),928,32;bcpbatch:(59,8),960,32;sendrow_init:(59,8),992,32;var_cols:(59,8),1024,32;typeinfo:(58,34),1056,64;avail_flag:(0,11),1120,8;;dbdaterec:T(58,51)=s40dateyear:(58,20),0,32;datemonth:(58,20),32,32;datedmonth:(58,20),64,32;datedyear:(58,20),96,32;datedweek:(58,20),128,32;datehour:(58,20),160,32;dateminute:(58,20),192,32;datesecond:(58,20),224,32;datemsecond:(58,20),256,32;datetzone:(58,20),288,32;;DBDATEREC:t(58,52)=(58,51)EHANDLEFUNC:t(58,53)=(58,54)=*(58,55)=f(0,1)MHANDLEFUNC:t(58,56)=(58,57)=*(58,58)=f(0,1) :T(58,59)=eDBPADOFF:0,DBPADON:1,;rcsid_sybfront_h:S(57,1)=ar(6,33);0;58;(0,2)no_unused_sybfront_h_warn:S(57,2)=ar(0,1);0;-1;(0,19)rcsid_sqlfront_h:S(56,1)=ar(6,33);0;58;(0,2)no_unused_sqlfront_h_warn:S(56,2)=ar(0,1);0;-1;(0,19)../../../include/sqldb.h../../../include/sybdb.hrcsid_sqldb_h:S(173,1)=ar(6,33);0;55;(0,2)no_unused_sqldb_h_warn:S(173,2)=ar(0,1);0;-1;(0,19)common.hrcsid_common_h:S(175,1)=ar(6,33);0;56;(0,2)no_unused_common_h_warn:S(175,2)=ar(0,1);0;-1;(0,19)software_version:S(0,21)=ar(6,33);0;53;(0,2)no_unused_var_warn:S(0,22)=ar(0,1);0;-1;(0,19)failed:G(0,1)main:F(0,1)argc:p(0,1)argv:p(103,2)login:r(0,23)=*(58,30)dbproc:(0,24)=*(58,44)i:r(0,1)teststr:(0,25)=ar(6,33);0;1023;(0,2)testint:(58,20)fp:r(0,26)=*(1,1)result:r(0,3)isiz:(0,3)blob:(6,36)rblob:(6,36)textPtr:(18,34)timeStamp:(18,34)objname:(58,42)sqlCmd:(58,42)rbuf:(0,27)=ar(6,33);0;4095;(0,2)numread:(0,3)cmd:(0,25)Start About to logon t0013After logon Usage: %s infile outfile rbCannot open input file: %s Dropping table drop table #dblib0013creating table insert %s Error inserting blob #dblib0013.PigTureselect Was expecting a result set.col %d is %s Had problem with bind Failed. Expected a row SET TEXTSIZE 2147483647select 2 Error extracting blob wbfailedPASSEDWas expecting no more rows t0013.cfailed!okaydblib %s on %s About to open, PASSWORD: %s, USER: %s, SERVER: %s About to read binary input file create table #dblib0013 (i int not null, PigTure image not null)insert into #dblib0013 values (1, '')SELECT PigTure FROM #dblib0013 WHERE i = 1select * from #dblib0013 order by iFailed. Expected i to be %d, was %d Saving first blob data row to file: %s Unable to open output file: %s Read blob data row %d --> %s %d byte comparison GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.2 2.96-108.7.2).symtab.strtab.shstrtab.text.rel.text.data.rel.data.bss.note.stab.rel.stab.stabstr.rodata.str1.1.rodata.str1.32.comment4 ! ãX+à@ 1 dè; @ F4 +  L ôè°VT6š_2[мn2 Ò€ ~ Ô;ÛÔ‡ä×@F $ßæñÿ 88*@=>€[ ]j‚ 9\§€;¸¼Òà;ãý@8 x"€91¼Ià6Z  m r w |  † ‹@ + •E šH Ÿd ¥t «Š ±€ ·š ½à â É  Ϧ Õ¼ ÛÏ á` ç× íó ó ù ÿ  1 I S à j #  )m /t 5@ ;{ A— GŸ M§ S¬   Y `Ÿer‚‰‘˜¨´ÄÐØáìñø $*17>DNX`go}‡“˜¢©³ºÀÈÓÚßt0013.crcsid_tds_hno_unused_tds_h_warnrcsid_tds_configs_hno_unused_tds_configs_h_warnrcsid_tdsver_hno_unused_tdsver_h_warnrcsid_sybdb_hno_unused_sybdb_h_warnrcsid_sybfront_hno_unused_sybfront_h_warnrcsid_sqlfront_hno_unused_sqlfront_h_warnrcsid_sqldb_hno_unused_sqldb_h_warnrcsid_common_hno_unused_common_h_warnsoftware_versionno_unused_var_warn.LC0.LC1.LC2.LC3.LC4.LC5.LC6.LC7.LC8.LC9.LC10.LC11.LC12.LC13.LC14.LC15.LC16.LC17.LC18.LC19.LC20.LC21.LC22.LC23.LC24.LC25.LC26.LC27.LC28.LC29.LC30.LC31.LC32.LC33.LC34.LC35.LC36.LC37.LC38.LC39.LC40failedmaintdsdump_openread_login_infostdoutfprintfdbinitsyb_err_handlerdberrhandlesyb_msg_handlerdbmsghandledbloginPASSWORDdbsetlnameUSERSERVERtdsdbopenDATABASEdbusestderrfopenfseekftellmallocfreadfclosedbcmddbsqlexecdbresultssprintfmemcpydbtxptrdbtxtimestampdbnextrowdbwritetextexitdbcolnameprintfdbnumcolsdbbindabortreallocdbreadtextfwritefreedbexitHI!J&K+L2M7N>OCPJPJUKZQfRlSvT|S†ŒS“˜¢¨J­KµU»VÀWëXöüJKJK' -Y2KD!OZa"gYlKƒ[‹\ž[ª]¿^È_Ï#ÕJÚKá$ì`øa b% J%K,&7`CaVbf'lJqKx(„c)“J˜K¦`²aÆbÖ*âcð`üab+Y!K<,BdQeff}gµhÐ-ÖJÛKâ.í`ùab/JF(K4iKjU0ZkllŽmœ1¢Y¨F±K¶nÆgÔ2ÚYàFéKõi 3YFK$n2gB4HdV`banbu5{J€K‡*c›`§a³bÁ6ÇYÌKo0dPph7mkt8Z‘9—YœK¼qÄ_ð:÷;<kr"g2=8Y>FGKSiYs_Ff>k?r@xA~JƒK‰F8<€„\`¼À x|¼À Ð Ü ô ÌØÌ Ø Ä"Ð"è"ô"0#<#`#l#„##¨#G+freetds-1.00.82/src/dblib/unittests/CMakeLists.txt100644 025423 025423 00000001252 13111516422 0015467add_library(d_common STATIC common.c common.h) foreach(target t0001 t0002 t0003 t0004 t0005 t0006 t0007 t0008 t0009 t0011 t0012 t0013 t0014 t0015 t0016 t0017 t0018 t0019 t0020 t0021 t0022 t0023 rpc dbmorecmds bcp thread text_buffer done_handling timeout hang null null2 setnull numeric pending cancel bcp_getl) add_executable(d_${target} EXCLUDE_FROM_ALL ${target}.c) set_target_properties(d_${target} PROPERTIES OUTPUT_NAME ${target}) target_link_libraries(d_${target} d_common sybdb replacements ${lib_NETWORK} ${lib_BASE}) add_test(NAME d_${target} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${target}) add_dependencies(check d_${target}) endforeach(target) freetds-1.00.82/src/dblib/unittests/bcp.sql100644 025423 025423 00000011351 12522201763 0014221if exists (select 1 from sysobjects where type = 'U' and name = 'all_types_bcp_unittest') drop table all_types_bcp_unittest go CREATE TABLE all_types_bcp_unittest ( not_null_bit bit NOT NULL , not_null_char char(10) NOT NULL , not_null_varchar varchar(10) NOT NULL , not_null_datetime datetime NOT NULL , not_null_smalldatetime smalldatetime NOT NULL , not_null_money money NOT NULL , not_null_smallmoney smallmoney NOT NULL , not_null_float float NOT NULL , not_null_real real NOT NULL , not_null_decimal decimal(5,2) NOT NULL , not_null_numeric numeric(5,2) NOT NULL , not_null_int int NOT NULL , not_null_smallint smallint NOT NULL , not_null_tinyint tinyint NOT NULL , nullable_char char(10) NULL , nullable_varchar varchar(10) NULL , nullable_datetime datetime NULL , nullable_smalldatetime smalldatetime NULL , nullable_money money NULL , nullable_smallmoney smallmoney NULL , nullable_float float NULL , nullable_real real NULL , nullable_decimal decimal(5,2) NULL , nullable_numeric numeric(5,2) NULL , nullable_int int NULL , nullable_smallint smallint NULL , nullable_tinyint tinyint NULL /* Excludes: * binary * image * uniqueidentifier * varbinary * text * timestamp * nchar * ntext * nvarchar */ ) INSERT all_types_bcp_unittest VALUES ( 1 -- not_null_bit , 'a char' -- not_null_char , 'a varchar' -- not_null_varchar , 'Dec 17 2003 3:44PM' -- not_null_datetime , 'Dec 17 2003 3:44PM' -- not_null_smalldatetime , 12.34 -- not_null_money , 12.34 -- not_null_smallmoney , 12.34 -- not_null_float , 12.34 -- not_null_real , 12.34 -- not_null_decimal , 12.34 -- not_null_numeric , 1234 -- not_null_int , 1234 -- not_null_smallint , 123 -- not_null_tinyint , 'a char' -- nullable_char , 'a varchar' -- nullable_varchar , 'Dec 17 2003 3:44PM' -- nullable_datetime , 'Dec 17 2003 3:44PM' -- nullable_smalldatetime , 12.34 -- nullable_money , 12.34 -- nullable_smallmoney , 12.34 -- nullable_float , 12.34 -- nullable_real , 12.34 -- nullable_decimal , 12.34 -- nullable_numeric , 1234 -- nullable_int , 1234 -- nullable_smallint , 123 -- nullable_tinyint ) INSERT all_types_bcp_unittest ( not_null_bit , not_null_char , not_null_varchar , not_null_datetime , not_null_smalldatetime , not_null_money , not_null_smallmoney , not_null_float , not_null_real , not_null_decimal , not_null_numeric , not_null_int , not_null_smallint , not_null_tinyint ) VALUES ( 1 -- not_null_bit , 'a char' -- not_null_char , 'a varchar' -- not_null_varchar , 'Dec 17 2003 3:44PM' -- not_null_datetime , 'Dec 17 2003 3:44PM' -- not_null_smalldatetime , 12.34 -- not_null_money , 12.34 -- not_null_smallmoney , 12.34 -- not_null_float , 12.34 -- not_null_real , 12.34 -- not_null_decimal , 12.34 -- not_null_numeric , 1234 -- not_null_int , 1234 -- not_null_smallint , 123 -- not_null_tinyint ) INSERT all_types_bcp_unittest ( not_null_bit , not_null_char , not_null_varchar , not_null_datetime , not_null_smalldatetime , not_null_money , not_null_smallmoney , not_null_float , not_null_real , not_null_decimal , not_null_numeric , not_null_int , not_null_smallint , not_null_tinyint , nullable_char , nullable_varchar ) VALUES ( 1 -- not_null_bit , '' -- not_null_char empty string , '' -- not_null_varchar empty string , 'Dec 17 2003 3:44PM' -- not_null_datetime , 'Dec 17 2003 3:44PM' -- not_null_smalldatetime , 12.34 -- not_null_money , 12.34 -- not_null_smallmoney , 12.34 -- not_null_float , 12.34 -- not_null_real , 12.34 -- not_null_decimal , 12.34 -- not_null_numeric , 1234 -- not_null_int , 1234 -- not_null_smallint , 123 -- not_null_tinyint , '' -- nullable_char empty string , '' -- nullable_varchar empty string ) go select colid, cast(c.name as varchar(30)) as name, c.length , ' '+ substring('NY', convert(bit,(c.status & 8))+1,1) as Nulls from syscolumns as c left join systypes as t on c.usertype = t.usertype where c.id = object_id('all_types_bcp_unittest') order by colid go select 'nullable_char' as col, count(*) nrows, datalength(nullable_char) as len, nullable_char as value from all_types_bcp_unittest group by nullable_char UNION select 'nullable_varchar' as col, count(*) nrows, datalength(nullable_varchar) as len, nullable_varchar as value from all_types_bcp_unittest group by nullable_varchar UNION select 'nullable_int' as col, count(*) nrows, datalength(nullable_int) as len, cast(nullable_int as varchar(6))as value from all_types_bcp_unittest group by nullable_int order by col, len, nrows go drop table all_types_bcp_unittest go freetds-1.00.82/src/dblib/unittests/dbmorecmds.sql100644 025423 025423 00000001217 12717145107 0015601create table #dblib0024 (i int not null, s char(10) not null) go insert into #dblib0024 values (0, 'row 000') go insert into #dblib0024 values (1, 'row 001') go insert into #dblib0024 values (2, 'row 002') go insert into #dblib0024 values (3, 'row 003') go insert into #dblib0024 values (4, 'row 004') go insert into #dblib0024 values (5, 'row 005') go insert into #dblib0024 values (6, 'row 006') go insert into #dblib0024 values (7, 'row 007') go insert into #dblib0024 values (8, 'row 008') go insert into #dblib0024 values (9, 'row 009') go select count(*) from #dblib0024 -- order by i go select count(*) from sysusers select name from sysobjects go freetds-1.00.82/src/dblib/unittests/done_handling.sql100644 025423 025423 00000001413 12522201763 0016244create table #dummy (s char(10)) go insert into #dummy values('xxx') go if object_id('done_test') is not NULL drop proc done_test go create proc done_test @a varchar(10) output as select * from #dummy go if object_id('done_test2') is not NULL drop proc done_test2 go create proc done_test2 as select * from #dummy where s = 'aaa' select * from #dummy go select * from #dummy /* normal row */ go set nocount on go select * from #dummy /* normal row with no count */ go set nocount off go select * from #dummy where 0=1 /* normal row without rows */ go select dklghdlgkh from #dummy /* error query */ go /* stored procedure call with output parameters */ declare @s varchar(10) exec done_test @s output go exec done_test2 go drop proc done_test go drop proc done_test2 go freetds-1.00.82/src/dblib/unittests/rpc.sql100644 025423 025423 00000006201 12527260163 0014243SELECT 'x' AS this_is_a_really_really_long_identifier go CREATE PROCEDURE #t0022 @null_input varchar(30) OUTPUT , @first_type varchar(30) OUTPUT , @nullout int OUTPUT , @varchar_tds7_out varchar(8000) OUTPUT , @nvarchar_tds7_out nvarchar(4000) OUTPUT , @nrows int OUTPUT , @c_this_name_is_way_more_than_thirty_characters_charlie varchar(20) , @nv nvarchar(20) = N'hello' AS BEGIN if @null_input is not NULL begin select 'error: should be NULL' as status, @null_input as 'null_input' return -42 end else begin print 'Good: @null_input is NULL' end if @c_this_name_is_way_more_than_thirty_characters_charlie is not NULL begin select 'error: should be NULL' as status, @c_this_name_is_way_more_than_thirty_characters_charlie as '@c_this_name_is_way_more_than_thirty_characters_charlie' return -42 end else begin print 'Good: @c_this_name_is_way_more_than_thirty_characters_charlie is NULL' end select @null_input = max(convert(varchar(30), name)) from systypes select @first_type = min(convert(varchar(30), name)) from systypes select name from sysobjects where 0=1 select distinct convert(varchar(30), name) as 'type' from systypes where name in ('int', 'char', 'text') select @nrows = @@rowcount set @varchar_tds7_out = replicate(char(247), 8000) set @nvarchar_tds7_out = replicate(nchar(246), 4000) select distinct @nv as '@nv', convert(varchar(30), name) as name from systypes select @null_input as 'null_input' , @first_type as 'first_type' , @nullout as 'nullout' , @nrows as 'nrows' , @c_this_name_is_way_more_than_thirty_characters_charlie as 'c' , @nv as 'nv' into #parameters select * from #parameters return 42 END go IF OBJECT_ID('t0022') IS NOT NULL DROP PROC t0022 go CREATE PROCEDURE t0022 @null_input varchar(30) OUTPUT , @first_type varchar(30) OUTPUT , @nullout int OUTPUT , @nrows int OUTPUT , @c_this_name_is_way_more_than_thirty_characters_charlie varchar(20) , @nv nvarchar(20) = N'hello' AS BEGIN if @null_input is not NULL begin select 'error: should be NULL' as status, @null_input as 'null_input' return -42 end else begin print 'Good: @null_input is NULL' end if @c_this_name_is_way_more_than_thirty_characters_charlie is not NULL begin select 'error: should be NULL' as status, @c_this_name_is_way_more_than_thirty_characters_charlie as '@c_this_name_is_way_more_than_thirty_characters_charlie' return -42 end else begin print 'Good: @c_this_name_is_way_more_than_thirty_characters_charlie is NULL' end select @null_input = max(convert(varchar(30), name)) from systypes select @first_type = min(convert(varchar(30), name)) from systypes select name from sysobjects where 0=1 select distinct convert(varchar(30), name) as 'type' from systypes where name in ('int', 'char', 'text') select @nrows = @@rowcount select distinct @nv as '@nv', convert(varchar(30), name) as name from sysobjects where type = 'S' select @null_input as 'null_input' , @first_type as 'first_type' , @nullout as 'nullout' , @nrows as 'nrows' , @c_this_name_is_way_more_than_thirty_characters_charlie as 'c' , @nv as 'nv' into #parameters select * from #parameters return 42 END go IF OBJECT_ID('t0022') IS NOT NULL DROP PROC t0022 go freetds-1.00.82/src/dblib/unittests/spid.sql100644 025423 025423 00000000021 12717145107 0014411select @@SPID go freetds-1.00.82/src/dblib/unittests/t0002.sql100644 025423 025423 00000005212 12522201763 0014221if exists ( select 1 from tempdb..sysobjects where id = object_id('tempdb..#dblib0002') ) drop table #dblib0002 go create table #dblib0002 (i int not null, s char(10) not null) go insert into #dblib0002 values (1, 'row 001') go insert into #dblib0002 values (2, 'row 002') go insert into #dblib0002 values (3, 'row 003') go insert into #dblib0002 values (4, 'row 004') go insert into #dblib0002 values (5, 'row 005') go insert into #dblib0002 values (6, 'row 006') go insert into #dblib0002 values (7, 'row 007') go insert into #dblib0002 values (8, 'row 008') go insert into #dblib0002 values (9, 'row 009') go insert into #dblib0002 values (10, 'row 010') go insert into #dblib0002 values (11, 'row 011') go insert into #dblib0002 values (12, 'row 012') go insert into #dblib0002 values (13, 'row 013') go insert into #dblib0002 values (14, 'row 014') go insert into #dblib0002 values (15, 'row 015') go insert into #dblib0002 values (16, 'row 016') go insert into #dblib0002 values (17, 'row 017') go insert into #dblib0002 values (18, 'row 018') go insert into #dblib0002 values (19, 'row 019') go insert into #dblib0002 values (20, 'row 020') go insert into #dblib0002 values (21, 'row 021') go insert into #dblib0002 values (22, 'row 022') go insert into #dblib0002 values (23, 'row 023') go insert into #dblib0002 values (24, 'row 024') go insert into #dblib0002 values (25, 'row 025') go insert into #dblib0002 values (26, 'row 026') go insert into #dblib0002 values (27, 'row 027') go insert into #dblib0002 values (28, 'row 028') go insert into #dblib0002 values (29, 'row 029') go insert into #dblib0002 values (30, 'row 030') go insert into #dblib0002 values (31, 'row 031') go insert into #dblib0002 values (32, 'row 032') go insert into #dblib0002 values (33, 'row 033') go insert into #dblib0002 values (34, 'row 034') go insert into #dblib0002 values (35, 'row 035') go insert into #dblib0002 values (36, 'row 036') go insert into #dblib0002 values (37, 'row 037') go insert into #dblib0002 values (38, 'row 038') go insert into #dblib0002 values (39, 'row 039') go insert into #dblib0002 values (40, 'row 040') go insert into #dblib0002 values (41, 'row 041') go insert into #dblib0002 values (42, 'row 042') go insert into #dblib0002 values (43, 'row 043') go insert into #dblib0002 values (44, 'row 044') go insert into #dblib0002 values (45, 'row 045') go insert into #dblib0002 values (46, 'row 046') go insert into #dblib0002 values (47, 'row 047') go insert into #dblib0002 values (48, 'row 048') go insert into #dblib0002 values (49, 'row 049') go insert into #dblib0002 values (50, 'row 050') go select * from #dblib0002 order by i select * from #dblib0002 order by i go freetds-1.00.82/src/dblib/unittests/t0003.sql100644 025423 025423 00000004700 12522201763 0014223create table #dblib0003 (i int not null, s char(10) not null) go insert into #dblib0003 values (1, 'row 001') go insert into #dblib0003 values (2, 'row 002') go insert into #dblib0003 values (3, 'row 003') go insert into #dblib0003 values (4, 'row 004') go insert into #dblib0003 values (5, 'row 005') go insert into #dblib0003 values (6, 'row 006') go insert into #dblib0003 values (7, 'row 007') go insert into #dblib0003 values (8, 'row 008') go insert into #dblib0003 values (9, 'row 009') go insert into #dblib0003 values (10, 'row 010') go insert into #dblib0003 values (11, 'row 011') go insert into #dblib0003 values (12, 'row 012') go insert into #dblib0003 values (13, 'row 013') go insert into #dblib0003 values (14, 'row 014') go insert into #dblib0003 values (15, 'row 015') go insert into #dblib0003 values (16, 'row 016') go insert into #dblib0003 values (17, 'row 017') go insert into #dblib0003 values (18, 'row 018') go insert into #dblib0003 values (19, 'row 019') go insert into #dblib0003 values (20, 'row 020') go insert into #dblib0003 values (21, 'row 021') go insert into #dblib0003 values (22, 'row 022') go insert into #dblib0003 values (23, 'row 023') go insert into #dblib0003 values (24, 'row 024') go insert into #dblib0003 values (25, 'row 025') go insert into #dblib0003 values (26, 'row 026') go insert into #dblib0003 values (27, 'row 027') go insert into #dblib0003 values (28, 'row 028') go insert into #dblib0003 values (29, 'row 029') go insert into #dblib0003 values (30, 'row 030') go insert into #dblib0003 values (31, 'row 031') go insert into #dblib0003 values (32, 'row 032') go insert into #dblib0003 values (33, 'row 033') go insert into #dblib0003 values (34, 'row 034') go insert into #dblib0003 values (35, 'row 035') go insert into #dblib0003 values (36, 'row 036') go insert into #dblib0003 values (37, 'row 037') go insert into #dblib0003 values (38, 'row 038') go insert into #dblib0003 values (39, 'row 039') go insert into #dblib0003 values (40, 'row 040') go insert into #dblib0003 values (41, 'row 041') go insert into #dblib0003 values (42, 'row 042') go insert into #dblib0003 values (43, 'row 043') go insert into #dblib0003 values (44, 'row 044') go insert into #dblib0003 values (45, 'row 045') go insert into #dblib0003 values (46, 'row 046') go insert into #dblib0003 values (47, 'row 047') go insert into #dblib0003 values (48, 'row 048') go insert into #dblib0003 values (49, 'row 049') go select * from #dblib0003 order by i go freetds-1.00.82/src/dblib/unittests/t0004.sql100644 025423 025423 00000005313 12522201763 0014225create table #dblib0004 (i int not null, s char(10) not null) go insert into #dblib0004 values (1, 'row 0001') go insert into #dblib0004 values (2, 'row 0002') go insert into #dblib0004 values (3, 'row 0003') go insert into #dblib0004 values (4, 'row 0004') go insert into #dblib0004 values (5, 'row 0005') go insert into #dblib0004 values (6, 'row 0006') go insert into #dblib0004 values (7, 'row 0007') go insert into #dblib0004 values (8, 'row 0008') go insert into #dblib0004 values (9, 'row 0009') go insert into #dblib0004 values (10, 'row 0010') go insert into #dblib0004 values (11, 'row 0011') go insert into #dblib0004 values (12, 'row 0012') go insert into #dblib0004 values (13, 'row 0013') go insert into #dblib0004 values (14, 'row 0014') go insert into #dblib0004 values (15, 'row 0015') go insert into #dblib0004 values (16, 'row 0016') go insert into #dblib0004 values (17, 'row 0017') go insert into #dblib0004 values (18, 'row 0018') go insert into #dblib0004 values (19, 'row 0019') go insert into #dblib0004 values (20, 'row 0020') go insert into #dblib0004 values (21, 'row 0021') go insert into #dblib0004 values (22, 'row 0022') go insert into #dblib0004 values (23, 'row 0023') go insert into #dblib0004 values (24, 'row 0024') go insert into #dblib0004 values (25, 'row 0025') go insert into #dblib0004 values (26, 'row 0026') go insert into #dblib0004 values (27, 'row 0027') go insert into #dblib0004 values (28, 'row 0028') go insert into #dblib0004 values (29, 'row 0029') go insert into #dblib0004 values (30, 'row 0030') go insert into #dblib0004 values (31, 'row 0031') go insert into #dblib0004 values (32, 'row 0032') go insert into #dblib0004 values (33, 'row 0033') go insert into #dblib0004 values (34, 'row 0034') go insert into #dblib0004 values (35, 'row 0035') go insert into #dblib0004 values (36, 'row 0036') go insert into #dblib0004 values (37, 'row 0037') go insert into #dblib0004 values (38, 'row 0038') go insert into #dblib0004 values (39, 'row 0039') go insert into #dblib0004 values (40, 'row 0040') go insert into #dblib0004 values (41, 'row 0041') go insert into #dblib0004 values (42, 'row 0042') go insert into #dblib0004 values (43, 'row 0043') go insert into #dblib0004 values (44, 'row 0044') go insert into #dblib0004 values (45, 'row 0045') go insert into #dblib0004 values (46, 'row 0046') go insert into #dblib0004 values (47, 'row 0047') go insert into #dblib0004 values (48, 'row 0048') go insert into #dblib0004 values (49, 'row 0049') go select * from #dblib0004 where i<=25 order by i go /* The following statement fails intentionally: * the unit test is checking that db-lib returns FAIL * when results have not been fully processed. */ select * from #dblib0004 where i<=25 order by i go freetds-1.00.82/src/dblib/unittests/t0005.sql100644 025423 025423 00000005766 12522201763 0014242create table #dblib0005 (i int not null, s char(10) not null) go insert into #dblib0005 values (1, 'row 0001') go insert into #dblib0005 values (2, 'row 0002') go insert into #dblib0005 values (3, 'row 0003') go insert into #dblib0005 values (4, 'row 0004') go insert into #dblib0005 values (5, 'row 0005') go insert into #dblib0005 values (6, 'row 0006') go insert into #dblib0005 values (7, 'row 0007') go insert into #dblib0005 values (8, 'row 0008') go insert into #dblib0005 values (9, 'row 0009') go insert into #dblib0005 values (10, 'row 0010') go insert into #dblib0005 values (11, 'row 0011') go insert into #dblib0005 values (12, 'row 0012') go insert into #dblib0005 values (13, 'row 0013') go insert into #dblib0005 values (14, 'row 0014') go insert into #dblib0005 values (15, 'row 0015') go insert into #dblib0005 values (16, 'row 0016') go insert into #dblib0005 values (17, 'row 0017') go insert into #dblib0005 values (18, 'row 0018') go insert into #dblib0005 values (19, 'row 0019') go insert into #dblib0005 values (20, 'row 0020') go insert into #dblib0005 values (21, 'row 0021') go insert into #dblib0005 values (22, 'row 0022') go insert into #dblib0005 values (23, 'row 0023') go insert into #dblib0005 values (24, 'row 0024') go insert into #dblib0005 values (25, 'row 0025') go insert into #dblib0005 values (26, 'row 0026') go insert into #dblib0005 values (27, 'row 0027') go insert into #dblib0005 values (28, 'row 0028') go insert into #dblib0005 values (29, 'row 0029') go insert into #dblib0005 values (30, 'row 0030') go insert into #dblib0005 values (31, 'row 0031') go insert into #dblib0005 values (32, 'row 0032') go insert into #dblib0005 values (33, 'row 0033') go insert into #dblib0005 values (34, 'row 0034') go insert into #dblib0005 values (35, 'row 0035') go insert into #dblib0005 values (36, 'row 0036') go insert into #dblib0005 values (37, 'row 0037') go insert into #dblib0005 values (38, 'row 0038') go insert into #dblib0005 values (39, 'row 0039') go insert into #dblib0005 values (40, 'row 0040') go insert into #dblib0005 values (41, 'row 0041') go insert into #dblib0005 values (42, 'row 0042') go insert into #dblib0005 values (43, 'row 0043') go insert into #dblib0005 values (44, 'row 0044') go insert into #dblib0005 values (45, 'row 0045') go insert into #dblib0005 values (46, 'row 0046') go insert into #dblib0005 values (47, 'row 0047') go insert into #dblib0005 values (48, 'row 0048') go insert into #dblib0005 values (49, 'row 0049') go select * from #dblib0005 where i < 5 order by i go select * from #dblib0005 where i < 6 order by i go /* * The following query should fail because the test * has not fetched all the rows in the result set. */ select * from #dblib0005 where i > 950 order by i go if object_id('t0005_proc') is not null drop procedure t0005_proc go create proc t0005_proc (@b int out) as begin select * from #dblib0005 where i < 6 order by i select @b = 42 end go declare @myout int exec t0005_proc @b = @myout output go select getdate() go drop procedure t0005_proc go freetds-1.00.82/src/dblib/unittests/t0006.sql100644 025423 025423 00000005057 12522201763 0014234create table #dblib0006 (i int not null, s char(10) not null) go insert into #dblib0006 values (1, 'row 0001') go insert into #dblib0006 values (2, 'row 0002') go insert into #dblib0006 values (3, 'row 0003') go insert into #dblib0006 values (4, 'row 0004') go insert into #dblib0006 values (5, 'row 0005') go insert into #dblib0006 values (6, 'row 0006') go insert into #dblib0006 values (7, 'row 0007') go insert into #dblib0006 values (8, 'row 0008') go insert into #dblib0006 values (9, 'row 0009') go insert into #dblib0006 values (10, 'row 0010') go insert into #dblib0006 values (11, 'row 0011') go insert into #dblib0006 values (12, 'row 0012') go insert into #dblib0006 values (13, 'row 0013') go insert into #dblib0006 values (14, 'row 0014') go insert into #dblib0006 values (15, 'row 0015') go insert into #dblib0006 values (16, 'row 0016') go insert into #dblib0006 values (17, 'row 0017') go insert into #dblib0006 values (18, 'row 0018') go insert into #dblib0006 values (19, 'row 0019') go insert into #dblib0006 values (20, 'row 0020') go insert into #dblib0006 values (21, 'row 0021') go insert into #dblib0006 values (22, 'row 0022') go insert into #dblib0006 values (23, 'row 0023') go insert into #dblib0006 values (24, 'row 0024') go insert into #dblib0006 values (25, 'row 0025') go insert into #dblib0006 values (26, 'row 0026') go insert into #dblib0006 values (27, 'row 0027') go insert into #dblib0006 values (28, 'row 0028') go insert into #dblib0006 values (29, 'row 0029') go insert into #dblib0006 values (30, 'row 0030') go insert into #dblib0006 values (31, 'row 0031') go insert into #dblib0006 values (32, 'row 0032') go insert into #dblib0006 values (33, 'row 0033') go insert into #dblib0006 values (34, 'row 0034') go insert into #dblib0006 values (35, 'row 0035') go insert into #dblib0006 values (36, 'row 0036') go insert into #dblib0006 values (37, 'row 0037') go insert into #dblib0006 values (38, 'row 0038') go insert into #dblib0006 values (39, 'row 0039') go insert into #dblib0006 values (40, 'row 0040') go insert into #dblib0006 values (41, 'row 0041') go insert into #dblib0006 values (42, 'row 0042') go insert into #dblib0006 values (43, 'row 0043') go insert into #dblib0006 values (44, 'row 0044') go insert into #dblib0006 values (45, 'row 0045') go insert into #dblib0006 values (46, 'row 0046') go insert into #dblib0006 values (47, 'row 0047') go insert into #dblib0006 values (48, 'row 0048') go insert into #dblib0006 values (49, 'row 0049') go select * from #dblib0006 where i<50 order by i go select * from #dblib0006 where i>=25 order by i go freetds-1.00.82/src/dblib/unittests/t0007.sql100644 025423 025423 00000001437 12522201763 0014233create table #dblib0007 (i int not null, s char(12) not null) go insert into #dblib0007 values (1, 'row 0000001') go insert into #dblib0007 values (2, 'row 0000002') go insert into #dblib0007 values (3, 'row 0000003') go insert into #dblib0007 values (4, 'row 0000004') go insert into #dblib0007 values (5, 'row 0000005') go insert into #dblib0007 values (6, 'row 0000006') go insert into #dblib0007 values (7, 'row 0000007') go insert into #dblib0007 values (8, 'row 0000008') go insert into #dblib0007 values (9, 'row 0000009') go select * from #dblib0007 where i<=5 order by i go /* * Second select, should fail: expected_error = 20019 */ select * from #dblib0007 where i>=5 order by i go /* * Third select for binary bindings */ select i, s, i from #dblib0007 x where x.i<=5 order by x.i go freetds-1.00.82/src/dblib/unittests/t0009.sql100644 025423 025423 00000000303 12522201763 0014224create table #dblib0009 (i int not null, s char(10) not null) go insert into #dblib0009 values (1, 'abcdef') go insert into #dblib0009 values (2, 'abc') go select * from #dblib0009 order by i go freetds-1.00.82/src/dblib/unittests/t0011.sql100644 025423 025423 00000001102 12522201763 0014213drop table #dblib0011 go create table #dblib0011 (i int not null, c1 char(200) not null, c2 char(200) null, vc varchar(200) null) go insert into #dblib0011 values (1, 'This is a really long column to ensure that the next row ends properly.','This is a really long column to ensure that the next row ends properly.','This is a really long column to ensure that the next row ends properly.') go insert into #dblib0011 values (2, 'Short column','Short column','Short column') go insert into #dblib0011 values (3, 'Short column',NULL,NULL) go select * from #dblib0011 order by i go freetds-1.00.82/src/dblib/unittests/t0012.sql100644 025423 025423 00000000422 12642432220 0014215create table #dblib0012 (dt datetime not null) go insert into #dblib0012 values ('Feb 27 2001 10:24:35:056AM') go insert into #dblib0012 values ('Dec 25 1898 07:30:00:567PM') go SELECT dt FROM #dblib0012 go SELECT CAST('1898-12-25 16:00:00.567 -08:00' AS DATETIMEOFFSET) go freetds-1.00.82/src/dblib/unittests/t0013.sql100644 025423 025423 00000000665 12522201763 0014232if object_id('freetds_dblib_t0013') is not null drop table freetds_dblib_t0013 go create table freetds_dblib_t0013 (i int not null, PigTure image not null) go insert into freetds_dblib_t0013 values (1, '') go SELECT PigTure FROM freetds_dblib_t0013 WHERE i = 1 go select i, PigTure from freetds_dblib_t0013 order by i go SET TEXTSIZE 2147483647 go SELECT PigTure FROM freetds_dblib_t0013 WHERE i = 1 go drop table freetds_dblib_t0013 go freetds-1.00.82/src/dblib/unittests/t0014.sql100644 025423 025423 00000000676 12522201763 0014235if object_id('dblib0014') is not null drop table dblib0014 go create table dblib0014 (i int not null, PigTure image not null) go insert into dblib0014 values (0, '') go insert into dblib0014 values (1, '') go insert into dblib0014 values (2, '') go SELECT PigTure FROM dblib0014 WHERE i = 0 go SELECT PigTure FROM dblib0014 WHERE i = 1 go SELECT PigTure FROM dblib0014 WHERE i = 2 go select * from dblib0014 order by i go drop table dblib0014 go freetds-1.00.82/src/dblib/unittests/t0015.sql100644 025423 025423 00000005044 12522201763 0014230create table #dblib0015 (i int not null, s char(10) not null) go insert into #dblib0015 values (0, 'row 000') go insert into #dblib0015 values (1, 'row 001') go insert into #dblib0015 values (2, 'row 002') go insert into #dblib0015 values (3, 'row 003') go insert into #dblib0015 values (4, 'row 004') go insert into #dblib0015 values (5, 'row 005') go insert into #dblib0015 values (6, 'row 006') go insert into #dblib0015 values (7, 'row 007') go insert into #dblib0015 values (8, 'row 008') go insert into #dblib0015 values (9, 'row 009') go insert into #dblib0015 values (10, 'row 010') go insert into #dblib0015 values (11, 'row 011') go insert into #dblib0015 values (12, 'row 012') go insert into #dblib0015 values (13, 'row 013') go insert into #dblib0015 values (14, 'row 014') go insert into #dblib0015 values (15, 'row 015') go insert into #dblib0015 values (16, 'row 016') go insert into #dblib0015 values (17, 'row 017') go insert into #dblib0015 values (18, 'row 018') go insert into #dblib0015 values (19, 'row 019') go insert into #dblib0015 values (20, 'row 020') go insert into #dblib0015 values (21, 'row 021') go insert into #dblib0015 values (22, 'row 022') go insert into #dblib0015 values (23, 'row 023') go insert into #dblib0015 values (24, 'row 024') go insert into #dblib0015 values (25, 'row 025') go insert into #dblib0015 values (26, 'row 026') go insert into #dblib0015 values (27, 'row 027') go insert into #dblib0015 values (28, 'row 028') go insert into #dblib0015 values (29, 'row 029') go insert into #dblib0015 values (30, 'row 030') go insert into #dblib0015 values (31, 'row 031') go insert into #dblib0015 values (32, 'row 032') go insert into #dblib0015 values (33, 'row 033') go insert into #dblib0015 values (34, 'row 034') go insert into #dblib0015 values (35, 'row 035') go insert into #dblib0015 values (36, 'row 036') go insert into #dblib0015 values (37, 'row 037') go insert into #dblib0015 values (38, 'row 038') go insert into #dblib0015 values (39, 'row 039') go insert into #dblib0015 values (40, 'row 040') go insert into #dblib0015 values (41, 'row 041') go insert into #dblib0015 values (42, 'row 042') go insert into #dblib0015 values (43, 'row 043') go insert into #dblib0015 values (44, 'row 044') go insert into #dblib0015 values (45, 'row 045') go insert into #dblib0015 values (46, 'row 046') go insert into #dblib0015 values (47, 'row 047') go insert into #dblib0015 values (48, 'row 048') go insert into #dblib0015 values (49, 'row 049') go select * from #dblib0015 order by i go select * from #dblib0015 where i > 25 order by i go freetds-1.00.82/src/dblib/unittests/t0016.sql100644 025423 025423 00000000371 12522201763 0014227create table #dblib0016 (f1 int not null, s1 int null, f2 numeric(10,2) null, f3 varchar(255) not null, f4 datetime null, [group] varchar(20)) go select * from #dblib0016 where 0=1 go select * from #dblib0016 where 0=1 go drop table #dblib0016 go freetds-1.00.82/src/dblib/unittests/t0017.sql100644 025423 025423 00000000726 12522201763 0014234create table #dblib0017 (c1 int null, c2 text) go insert into #dblib0017(c1,c2) values(1144201745,'prova di testo questo testo dovrebbe andare a finire in un campo text') go select * from #dblib0017 where 0=1 go delete from #dblib0017 go select * from #dblib0017 where 0=1 go SET NOCOUNT ON DECLARE @n INT SELECT @n = COUNT(*) FROM #dblib0017 WHERE c1=1144201745 AND c2 LIKE 'prova di testo questo testo dovrebbe andare a finire in un campo text' IF @n <> 1 SELECT 0 go freetds-1.00.82/src/dblib/unittests/t0018.sql100644 025423 025423 00000005066 12522201763 0014237create table #dblib0018 (i int not null, s char(10) not null) go insert into #dblib0018 values (0, 'row 000') go insert into #dblib0018 values (1, 'row 001') go insert into #dblib0018 values (2, 'row 002') go insert into #dblib0018 values (3, 'row 003') go insert into #dblib0018 values (4, 'row 004') go insert into #dblib0018 values (5, 'row 005') go insert into #dblib0018 values (6, 'row 006') go insert into #dblib0018 values (7, 'row 007') go insert into #dblib0018 values (8, 'row 008') go insert into #dblib0018 values (9, 'row 009') go insert into #dblib0018 values (10, 'row 010') go insert into #dblib0018 values (11, 'row 011') go insert into #dblib0018 values (12, 'row 012') go insert into #dblib0018 values (13, 'row 013') go insert into #dblib0018 values (14, 'row 014') go insert into #dblib0018 values (15, 'row 015') go insert into #dblib0018 values (16, 'row 016') go insert into #dblib0018 values (17, 'row 017') go insert into #dblib0018 values (18, 'row 018') go insert into #dblib0018 values (19, 'row 019') go insert into #dblib0018 values (20, 'row 020') go insert into #dblib0018 values (21, 'row 021') go insert into #dblib0018 values (22, 'row 022') go insert into #dblib0018 values (23, 'row 023') go insert into #dblib0018 values (24, 'row 024') go insert into #dblib0018 values (25, 'row 025') go insert into #dblib0018 values (26, 'row 026') go insert into #dblib0018 values (27, 'row 027') go insert into #dblib0018 values (28, 'row 028') go insert into #dblib0018 values (29, 'row 029') go insert into #dblib0018 values (30, 'row 030') go insert into #dblib0018 values (31, 'row 031') go insert into #dblib0018 values (32, 'row 032') go insert into #dblib0018 values (33, 'row 033') go insert into #dblib0018 values (34, 'row 034') go insert into #dblib0018 values (35, 'row 035') go insert into #dblib0018 values (36, 'row 036') go insert into #dblib0018 values (37, 'row 037') go insert into #dblib0018 values (38, 'row 038') go insert into #dblib0018 values (39, 'row 039') go insert into #dblib0018 values (40, 'row 040') go insert into #dblib0018 values (41, 'row 041') go insert into #dblib0018 values (42, 'row 042') go insert into #dblib0018 values (43, 'row 043') go insert into #dblib0018 values (44, 'row 044') go insert into #dblib0018 values (45, 'row 045') go insert into #dblib0018 values (46, 'row 046') go insert into #dblib0018 values (47, 'row 047') go insert into #dblib0018 values (48, 'row 048') go insert into #dblib0018 values (49, 'row 049') go select * into #tmp0 from #dblib0018 select * from #tmp0 order by i go update #dblib0018 set s = 'row 000' go freetds-1.00.82/src/dblib/unittests/t0020.sql100644 025423 025423 00000000144 12522201763 0014220/* request an invalid column from a non-existent table */ select dsjfkl dsjf go select db_name() go freetds-1.00.82/src/dblib/unittests/t0022.sql100644 025423 025423 00000000531 12522201763 0014222if object_id('t0022') is not null drop proc t0022 go create proc t0022 (@b int out) as begin select @b = 42 return 66 end go declare @b int exec t0022 @b = @b output go drop proc t0022 go if object_id('t0022a') is not null drop proc t0022a go create proc t0022a (@b int) as return @b go exec t0022a 17 exec t0022a 1024 go drop proc t0022a go freetds-1.00.82/src/dblib/unittests/t0023.sql100644 025423 025423 00000001140 12717145107 0014225select name from sysobjects where name = 'missing' compute max(name) go create table #dblib0023 (col1 int not null, col2 char(1) not null, col3 datetime not null) go insert into #dblib0023 values (1, 'A', 'Jan 1 2002 10:00:00AM') go insert into #dblib0023 values (2, 'A', 'Jan 2 2002 10:00:00AM') go insert into #dblib0023 values (3, 'A', 'Jan 3 2002 10:00:00AM') go insert into #dblib0023 values (8, 'B', 'Jan 4 2002 10:00:00AM') go insert into #dblib0023 values (9, 'B', 'Jan 5 2002 10:00:00AM') go select col1, col2, col3 from #dblib0023 order by col2 compute sum(col1) by col2 compute max(col3) go freetds-1.00.82/src/dblib/unittests/text_buffer.sql100644 025423 025423 00000000246 12522201763 0015773create table #dblib (i int not null, s text) go insert into #dblib values (1, 'ABCDEF') go insert into #dblib values (2, 'abc') go select * from #dblib order by i go freetds-1.00.82/src/dblib/unittests/timeout.sql100644 025423 025423 00000000264 12717145107 0015151select getdate() as 'begintime' waitfor delay '00:00:30' select getdate() as 'endtime' go select getdate() as 'begintime' waitfor delay '00:00:30' select getdate() as 'endtime' go freetds-1.00.82/src/dblib/unittests/numeric.sql100644 025423 025423 00000000367 12522201763 0015124IF OBJECT_ID('testDecimal') IS NOT NULL DROP PROC testDecimal go CREATE PROCEDURE testDecimal @idecimal NUMERIC(20,10) AS BEGIN SELECT CAST(@idecimal*2 AS NUMERIC(20,10)) END go IF OBJECT_ID('testDecimal') IS NOT NULL DROP PROC testDecimal go freetds-1.00.82/src/dblib/unittests/numeric_2.sql100644 025423 025423 00000000350 12522201763 0015335IF OBJECT_ID('testDecimal') IS NOT NULL DROP PROC testDecimal go CREATE PROCEDURE testDecimal @idecimal NUMERIC(20,10) AS BEGIN SELECT CAST(246 AS INTEGER) END go IF OBJECT_ID('testDecimal') IS NOT NULL DROP PROC testDecimal go freetds-1.00.82/src/dblib/unittests/pending.sql100644 025423 025423 00000000204 12522201763 0015074declare @a int select @a = 123 begin transaction go /* The following statement should success */ select 634 as number go commit go freetds-1.00.82/src/dblib/unittests/cancel.sql100644 025423 025423 00000000070 12620060220 0014664select * from I_dont_exists_table go select 1 as one go freetds-1.00.82/src/dblib/unittests/t0016_10.sql100644 025423 025423 00000000261 12522201763 0014525set textsize 65536 create table #dblib0016 (id int not null, data image) go select * from #dblib0016 where 0=1 go select * from #dblib0016 where 0=1 go drop table #dblib0016 go freetds-1.00.82/src/dblib/unittests/t0016_11.sql100644 025423 025423 00000000516 12522201763 0014531create table #dblib0016 (id int not null, var uniqueidentifier null, c1 char(20) not null, v1 varchar(20) not null, c2 char(20) null, v2 varchar(20) null, b1 binary(20) null, vb1 varbinary(20) null, img image null, txt text null) go select * from #dblib0016 where 0=1 go select * from #dblib0016 where 0=1 go drop table #dblib0016 go freetds-1.00.82/src/dblib/unittests/t0016_1.sql100644 025423 025423 00000000273 12522201763 0014450create table #dblib0016 (f1 int not null, str nvarchar(5), uuid uniqueidentifier) go select * from #dblib0016 where 0=1 go select * from #dblib0016 where 0=1 go drop table #dblib0016 go freetds-1.00.82/src/dblib/unittests/t0016_2.sql100644 025423 025423 00000000255 12522201763 0014451create table #dblib0016 (f1 int not null, f2 text, f3 varchar(20) ) go select * from #dblib0016 where 0=1 go select * from #dblib0016 where 0=1 go drop table #dblib0016 go freetds-1.00.82/src/dblib/unittests/t0016_3.sql100644 025423 025423 00000000300 12522201763 0014441create table #dblib0016 (f1 int not null, f2 char(20) not null, f3 binary(4) not null) go select * from #dblib0016 where 0=1 go select * from #dblib0016 where 0=1 go drop table #dblib0016 go freetds-1.00.82/src/dblib/unittests/t0016_4.sql100644 025423 025423 00000000270 12522201763 0014450create table #dblib0016 (f1 int not null, f2 char(20) null, f3 binary(4) null) go select * from #dblib0016 where 0=1 go select * from #dblib0016 where 0=1 go drop table #dblib0016 go freetds-1.00.82/src/dblib/unittests/t0016_5.sql100644 025423 025423 00000001221 12522201763 0014446create table #dblib0016 (f0 int not null, f1 varchar(60) not null, f2 varchar(60) not null, f3 varchar(60) not null, f4 varchar(60) not null, f5 varchar(60) not null, f6 varchar(60) not null, f7 varchar(60) not null, f8 varchar(60) not null, f9 varchar(60) not null, f10 varchar(60) not null, f11 varchar(60) not null, f12 varchar(60) not null, f13 varchar(60) not null, f14 varchar(60) not null, f15 varchar(60) not null, f16 varchar(60) not null, f17 varchar(60) not null, f18 varchar(60) not null, f19 varchar(60) not null, f20 varchar(60) not null) go select * from #dblib0016 where 0=1 go select * from #dblib0016 where 0=1 go drop table #dblib0016 go freetds-1.00.82/src/dblib/unittests/t0016_6.sql100644 025423 025423 00000000233 12522201763 0014451create table #dblib0016 (f0 datetime2(3) not null) go select * from #dblib0016 where 0=1 go select * from #dblib0016 where 0=1 go drop table #dblib0016 go freetds-1.00.82/src/dblib/unittests/t0016_7.sql100644 025423 025423 00000000262 12522201763 0014454create table #dblib0016 (b1 bit, b2 bit, i1 int not null, b3 bit, b4 bit) go select * from #dblib0016 where 0=1 go select * from #dblib0016 where 0=1 go drop table #dblib0016 go freetds-1.00.82/src/dblib/unittests/t0016_8.sql100644 025423 025423 00000000241 12522201763 0014452create table #dblib0016 (b1 bit, b2 bit, b3 bit, b4 bit) go select * from #dblib0016 where 0=1 go select * from #dblib0016 where 0=1 go drop table #dblib0016 go freetds-1.00.82/src/dblib/unittests/t0016_9.sql100644 025423 025423 00000000505 12522201763 0014456-- check if bit are all collased together, the layout will be -- 8 bits (b1-b8), i1, 1 bit (b9) -> 6 bytes create table #dblib0016 (b1 bit, b2 bit, b3 bit, b4 bit, b5 bit, b6 bit, b7 bit, b8 bit, i1 int not null, b9 bit) go select * from #dblib0016 where 0=1 go select * from #dblib0016 where 0=1 go drop table #dblib0016 go freetds-1.00.82/src/dblib/unittests/t0016_1.in100644 025423 025423 00000000140 12522201763 00142501 æâ€Â¢Ã°Å‹ 47C9B7E7-7AD6-4EE5-B29B-D81569251E8B 4 ciao2 82E8E9A8-61D3-424E-9AB5-AFD38CC41E36 freetds-1.00.82/src/dblib/unittests/t0016_2.in100644 025423 025423 00000001413 12522201763 00142551 This is a text 255 field varchar 1 4 This is another text 255 field. I'm trying to get a quite long string. This is the first bcp text test! This is the first bcp text test! This is the first bcp text test! This is the first bcp text test! This is the first bcp text test! This is the first bcp text test! This is the first bcp text test! This is the first bcp text test! This is the first bcp text test! This is the first bcp text test! This is the first bcp text test! This is the first bcp text test! This is the first bcp text test! This is the first bcp text test! This is the first bcp text test! This is the first bcp text test! This is the first bcp text test! This is the first bcp text test! This is the first bcp text test! This is the first bcp text test! varcharX freetds-1.00.82/src/dblib/unittests/t0016_3.in100644 025423 025423 00000000100 12522201763 00142461 Just a char 01020304 2 Other test 89abcdef freetds-1.00.82/src/dblib/unittests/t0016_4.in100644 025423 025423 00000000055 12522201763 00142601 Just a char 01020304 2 Other test 89abcdef freetds-1.00.82/src/dblib/unittests/t0016_5.in100644 025423 025423 00000001732 12522201763 00142641 test very very very long varchar 1 test very very very long varchar 2 test very very very long varchar 3 test very very very long varchar 4 test very very very long varchar 5 test very very very long varchar 6 test very very very long varchar 7 test very very very long varchar 8 test very very very long varchar 9 test very very very long varchar 10 test very very very long varchar 11 test very very very long varchar 12 test very very very long varchar 13 test very very very long varchar 14 test very very very long varchar 15 test very very very long varchar 16 test very very very long varchar 17 test very very very long varchar 18 test very very very long varchar 19 test very very very long varchar 20 3 test very very very long varchar 1 test very very very long varchar 2 test very very very long varchar 3 test very very very long varchar 4 test very very very long varchar 5 test very very very long varchar 6 test very very very long varchar 7 x x x x x x x x x x x x x freetds-1.00.82/src/dblib/unittests/t0016_6.in100644 025423 025423 00000000060 12522201763 00142562014-04-15 20:23:45.123 2038-11-27 04:12:32.876 freetds-1.00.82/src/dblib/unittests/t0016_7.in100644 025423 025423 00000000032 12522201763 00142561 0 1234 1 0 0 1 7654 0 1 freetds-1.00.82/src/dblib/unittests/t0016_8.in100644 025423 025423 00000000020 12522201763 00142541 0 1 0 0 1 1 0 freetds-1.00.82/src/dblib/unittests/t0016_9.in100644 025423 025423 00000000063 12522201763 00142641 0 1 0 1 0 1 0 123456 1 0 1 1 0 0 1 1 0 8765432 1 freetds-1.00.82/src/dblib/unittests/t0016_10.in100644 025423 025423 00000052376 12522201763 00143521 012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 2 fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210 freetds-1.00.82/src/dblib/unittests/t0016_11.in100644 025423 025423 00000000107 12522201763 00143341 00 2 a b freetds-1.00.82/src/server/Makefile.am100644 025423 025423 00000000575 13203773221 0013166# $Id: Makefile.am,v 1.18 2011-06-08 09:25:53 freddy77 Exp $ AM_CPPFLAGS = -I$(top_srcdir)/include noinst_LTLIBRARIES = libtdssrv.la libtdssrv_la_SOURCES= query.c server.c login.c libtdssrv_la_LIBADD = ../tds/libtds.la ../replacements/libreplacements.la $(FREETDS_LIBGCC) $(LTLIBICONV) noinst_PROGRAMS = tdssrv tdssrv_LDADD = libtdssrv.la $(LTLIBICONV) tdssrv_SOURCES = unittest.c freetds-1.00.82/src/server/Makefile.in100644 025423 025423 00000051551 13242511111 0013166# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ noinst_PROGRAMS = tdssrv$(EXEEXT) subdir = src/server ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = \ $(top_srcdir)/m4/ac_caolan_func_which_gethostbyname_r.m4 \ $(top_srcdir)/m4/ac_have_inaddr_none.m4 \ $(top_srcdir)/m4/ac_have_malloc_options.m4 \ $(top_srcdir)/m4/ac_nullzero.m4 \ $(top_srcdir)/m4/ac_raf_func_which_getservbyname_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_gethostbyaddr_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_getpwuid_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_localtime_r.m4 \ $(top_srcdir)/m4/acx_pthread.m4 \ $(top_srcdir)/m4/ax_cflags_gcc_option.m4 \ $(top_srcdir)/m4/check_openssl.m4 \ $(top_srcdir)/m4/gettimemilli.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/pushlibs.m4 \ $(top_srcdir)/m4/sprintf_i64_format.m4 \ $(top_srcdir)/m4/type_socklen_t.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) am__DEPENDENCIES_1 = libtdssrv_la_DEPENDENCIES = ../tds/libtds.la \ ../replacements/libreplacements.la $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) am_libtdssrv_la_OBJECTS = query.lo server.lo login.lo libtdssrv_la_OBJECTS = $(am_libtdssrv_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = PROGRAMS = $(noinst_PROGRAMS) am_tdssrv_OBJECTS = unittest.$(OBJEXT) tdssrv_OBJECTS = $(am_tdssrv_OBJECTS) tdssrv_DEPENDENCIES = libtdssrv.la $(am__DEPENDENCIES_1) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libtdssrv_la_SOURCES) $(tdssrv_SOURCES) DIST_SOURCES = $(libtdssrv_la_SOURCES) $(tdssrv_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp \ $(top_srcdir)/mkinstalldirs DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BUILD_NUMBER = @BUILD_NUMBER@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOXYGEN = @DOXYGEN@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FREETDS_LIBGCC = @FREETDS_LIBGCC@ FREETDS_ODBC_MODULE = @FREETDS_ODBC_MODULE@ FREETDS_SYMBOLIC = @FREETDS_SYMBOLIC@ GCRYPT_CFLAGS = @GCRYPT_CFLAGS@ GCRYPT_LIBS = @GCRYPT_LIBS@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ HAVE_OPENSSL = @HAVE_OPENSSL@ HAVE_PERL_SOURCES = @HAVE_PERL_SOURCES@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBADD_DL = @LIBADD_DL@ LIBADD_DLD_LINK = @LIBADD_DLD_LINK@ LIBADD_DLOPEN = @LIBADD_DLOPEN@ LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@ LIBICONV = @LIBICONV@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBOBJS = @LTLIBOBJS@ LT_DLLOADERS = @LT_DLLOADERS@ LT_DLPREOPEN = @LT_DLPREOPEN@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ NETTLE_CFLAGS = @NETTLE_CFLAGS@ NETTLE_LIBS = @NETTLE_LIBS@ NETWORK_LIBS = @NETWORK_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ODBC = @ODBC@ ODBCINSTLIB = @ODBCINSTLIB@ ODBCLIB = @ODBCLIB@ ODBCNODMLIB = @ODBCNODMLIB@ ODBCNODMLIBAPP = @ODBCNODMLIBAPP@ ODBC_CONFIG = @ODBC_CONFIG@ ODBC_INC = @ODBC_INC@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ RC = @RC@ READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SUBVERSION = @SUBVERSION@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ dblib_define = @dblib_define@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ tds_sysdep_int16_type = @tds_sysdep_int16_type@ tds_sysdep_int32_type = @tds_sysdep_int32_type@ tds_sysdep_int64_type = @tds_sysdep_int64_type@ tds_sysdep_intptr_type = @tds_sysdep_intptr_type@ tds_sysdep_real32_type = @tds_sysdep_real32_type@ tds_sysdep_real64_type = @tds_sysdep_real64_type@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # $Id: Makefile.am,v 1.18 2011-06-08 09:25:53 freddy77 Exp $ AM_CPPFLAGS = -I$(top_srcdir)/include noinst_LTLIBRARIES = libtdssrv.la libtdssrv_la_SOURCES = query.c server.c login.c libtdssrv_la_LIBADD = ../tds/libtds.la ../replacements/libreplacements.la $(FREETDS_LIBGCC) $(LTLIBICONV) tdssrv_LDADD = libtdssrv.la $(LTLIBICONV) tdssrv_SOURCES = unittest.c all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/server/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/server/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libtdssrv.la: $(libtdssrv_la_OBJECTS) $(libtdssrv_la_DEPENDENCIES) $(EXTRA_libtdssrv_la_DEPENDENCIES) $(AM_V_CCLD)$(LINK) $(libtdssrv_la_OBJECTS) $(libtdssrv_la_LIBADD) $(LIBS) clean-noinstPROGRAMS: @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list tdssrv$(EXEEXT): $(tdssrv_OBJECTS) $(tdssrv_DEPENDENCIES) $(EXTRA_tdssrv_DEPENDENCIES) @rm -f tdssrv$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tdssrv_OBJECTS) $(tdssrv_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/login.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/query.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/server.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unittest.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ clean-noinstPROGRAMS mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-noinstLTLIBRARIES clean-noinstPROGRAMS \ cscopelist-am ctags ctags-am distclean distclean-compile \ distclean-generic 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-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 .PRECIOUS: Makefile # 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: freetds-1.00.82/src/server/query.c100644 025423 025423 00000012570 12717145107 0012446/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-2004 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #include #include static char *query; static size_t query_buflen = 0; /** * Read a TDS5 tokenized query. */ char * tds_get_query(TDSSOCKET * tds) { int len; if (query_buflen == 0) { query_buflen = 1024; query = tds_new(char, query_buflen); } tds_get_byte(tds); /* 33 */ len = tds_get_int(tds); /* query size +1 */ tds_get_byte(tds); /* has args, ignored TODO */ assert(len >= 1); /* TODO handle correctly */ if (len > query_buflen) { query_buflen = len; query = (char *) realloc(query, query_buflen); } --len; tds_get_n(tds, query, len); query[len] = 0; return query; } static int tds_lastpacket(TDSSOCKET * tds) { if (!tds || !tds->in_buf || tds->recv_packet->capacity < 2) return 1; return tds->in_buf[1] != 0; } /** * Read a query, and return it as an ASCII string with a \0 terminator. This * should work for TDS4, TDS5, and TDS7+ connections. Also, it converts RPC * calls into stored procedure queries, and it skips CANCEL packets. The query * string is returned in a static buffer which is overwritten each time this * function is called. * \param tds The socket to read from. * \return A query string if successful, or NULL if we either can't read from * the socket or we read something that we can't handle. */ char *tds_get_generic_query(TDSSOCKET * tds) { int token, byte; int len, more, i, j; for (;;) { /* * Read a new packet. We must explicitly read it, * instead of letting functions such as tds_get_byte() * to read it for us, so that we can examine the packet * type via tds->in_flag. */ if (tds_read_packet(tds) < 0) { return NULL; } /* Queries can arrive in a couple different formats. */ switch (tds->in_flag) { case TDS_RPC: /* TODO */ case TDS_NORMAL: /* TDS5 query packet */ /* get the token */ token = tds_get_byte(tds); switch (token) { case TDS_LANGUAGE_TOKEN: /* SQL query */ len = tds_get_int(tds); /* query size +1 */ assert(len >= 1); /* TODO handle */ tds_get_byte(tds); /* has args, ignored TODO */ if (len > query_buflen) { query_buflen = len; query = (char *) realloc(query, query_buflen); } --len; tds_get_n(tds, query, len); query[len] = 0; return query; case TDS_DBRPC_TOKEN: /* RPC call -- make it look like a query */ /* skip the overall length */ (void)tds_get_smallint(tds); /* get the length of the stored procedure's name */ len = tds_get_byte(tds) + 1;/* sproc name size +1 */ if (len > query_buflen) { query_buflen = len; query = (char *) realloc(query, query_buflen); } /* * Read the chars of the name. Skip NUL * bytes, as a cheap way to convert * Unicode to ASCII. (For TDS7+, the * name is sent in Unicode.) */ for (i = j = 0; i < len - 1; i++) { byte = tds_get_byte(tds); if (byte != '\0') query[j++] = byte; } query[j] = '\0'; /* TODO: WE DON'T HANDLE PARAMETERS YET! */ /* eat the rest of the packet */ while (!tds_lastpacket(tds) && tds_read_packet(tds) > 0) { } return query; default: /* unexpected token */ /* eat the rest of the packet */ while (!tds_lastpacket(tds) && tds_read_packet(tds) > 0) { } return NULL; } break; case TDS_QUERY: /* TDS4 and TDS7+ fill the whole packet with a query */ len = 0; for (;;) { const char *src; /* If buffer needs to grow, then grow */ more = tds->in_len - tds->in_pos; src = (char *) (tds->in_buf + tds->in_pos); if ((size_t)(len + more + 1) > query_buflen) { query_buflen = len + more + 1024u; query_buflen -= query_buflen % 1024u; query = (char *)realloc(query, query_buflen); } /* * Pull new data into the query buffer. * Ignore NUL bytes -- this is a cheap way * to convert Unicode to Latin-1/ASCII. */ while (--more >= 0) { query[len] = *src++; if (query[len] != '\0') len++; } /* if more then read it */ if (tds_lastpacket(tds)) break; if (tds_read_packet(tds) < 0) return NULL; } /* add a NUL to mark the end */ query[len] = '\0'; return query; case TDS_CANCEL: /* * ignore cancel requests -- if we're waiting * for the next query then it's obviously too * late to cancel the previous query. */ /* TODO it's not too late -- freddy77 */ break; default: /* not a query packet */ return NULL; } } } freetds-1.00.82/src/server/server.c100644 025423 025423 00000033353 12717145107 0012611/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Brian Bruns * Copyright (C) 2010 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include #include #include #include void tds_env_change(TDSSOCKET * tds, int type, const char *oldvalue, const char *newvalue) { TDS_SMALLINT totsize; /* If oldvalue is NULL, treat it like "" */ if (oldvalue == NULL) oldvalue = ""; /* * NOTE: I don't know why each type of environment value has a different * format. According to the TDS5 specifications, they should all use * the same format. The code for the TDS_ENV_CHARSET case *should* * work for all environment values. -- Steve Kirkendall */ switch (type) { case TDS_ENV_DATABASE: case TDS_ENV_LANG: case TDS_ENV_PACKSIZE: case TDS_ENV_CHARSET: tds_put_byte(tds, TDS_ENVCHANGE_TOKEN); /* totsize = type + newlen + newvalue + oldlen + oldvalue */ /* FIXME ucs2 */ totsize = (IS_TDS7_PLUS(tds->conn) ? 2 : 1) * (strlen(oldvalue) + strlen(newvalue)) + 3; tds_put_smallint(tds, totsize); tds_put_byte(tds, type); tds_put_byte(tds, strlen(newvalue)); /* FIXME this assume singlebyte -> ucs2 for mssql */ tds_put_string(tds, newvalue, strlen(newvalue)); tds_put_byte(tds, strlen(oldvalue)); /* FIXME this assume singlebyte -> ucs2 for mssql */ tds_put_string(tds, oldvalue, strlen(oldvalue)); break; case TDS_ENV_LCID: case TDS_ENV_SQLCOLLATION: #if 1 tds_put_byte(tds, TDS_ENVCHANGE_TOKEN); /* totsize = type + len + oldvalue + len + newvalue */ totsize = 3 + strlen(newvalue) + strlen(oldvalue); tds_put_smallint(tds, totsize); tds_put_byte(tds, type); tds_put_byte(tds, strlen(newvalue)); tds_put_n(tds, newvalue, strlen(newvalue)); tds_put_byte(tds, strlen(oldvalue)); tds_put_n(tds, oldvalue, strlen(oldvalue)); break; #endif default: tdsdump_log(TDS_DBG_WARN, "tds_env_change() ignoring unsupported environment code #%d", type); } } void tds_send_eed(TDSSOCKET * tds, int msgno, int msgstate, int severity, char *msgtext, char *srvname, char *procname, int line) { int totsize; tds_put_byte(tds, TDS_EED_TOKEN); totsize = 7 + strlen(procname) + 5 + strlen(msgtext) + 2 + strlen(srvname) + 3; tds_put_smallint(tds, totsize); tds_put_smallint(tds, msgno); tds_put_smallint(tds, 0); /* unknown */ tds_put_byte(tds, msgstate); tds_put_byte(tds, severity); tds_put_byte(tds, strlen(procname)); tds_put_n(tds, procname, strlen(procname)); tds_put_byte(tds, 0); /* unknown */ tds_put_byte(tds, 1); /* unknown */ tds_put_byte(tds, 0); /* unknown */ tds_put_smallint(tds, strlen(msgtext) + 1); tds_put_n(tds, msgtext, strlen(msgtext)); tds_put_byte(tds, severity); tds_put_byte(tds, strlen(srvname)); tds_put_n(tds, srvname, strlen(srvname)); tds_put_byte(tds, 0); /* unknown */ tds_put_byte(tds, 1); /* unknown */ tds_put_byte(tds, 0); /* unknown */ } void tds_send_msg(TDSSOCKET * tds, int msgno, int msgstate, int severity, const char *msgtext, const char *srvname, const char *procname, int line) { int msgsz; size_t len; tds_put_byte(tds, TDS_INFO_TOKEN); if (!procname) procname = ""; len = strlen(procname); msgsz = 4 /* msg no */ + 1 /* msg state */ + 1 /* severity */ /* FIXME ucs2 */ + 4 + (IS_TDS7_PLUS(tds->conn) ? 2 : 1) * (strlen(msgtext) + strlen(srvname) + len) + (IS_TDS72_PLUS(tds->conn) ? 4 : 2); /* line number */ tds_put_smallint(tds, msgsz); tds_put_int(tds, msgno); tds_put_byte(tds, msgstate); tds_put_byte(tds, severity); tds_put_smallint(tds, strlen(msgtext)); /* FIXME ucs2 */ tds_put_string(tds, msgtext, strlen(msgtext)); tds_put_byte(tds, strlen(srvname)); /* FIXME ucs2 */ tds_put_string(tds, srvname, strlen(srvname)); if (len) { tds_put_byte(tds, len); /* FIXME ucs2 */ tds_put_string(tds, procname, len); } else { tds_put_byte(tds, 0); } if (IS_TDS72_PLUS(tds->conn)) tds_put_int(tds, line); else tds_put_smallint(tds, line); } void tds_send_err(TDSSOCKET * tds, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr) { tds_put_byte(tds, TDS_ERROR_TOKEN); } void tds_send_login_ack(TDSSOCKET * tds, const char *progname) { TDS_UINT ui, version; tds_put_byte(tds, TDS_LOGINACK_TOKEN); tds_put_smallint(tds, 10 + (IS_TDS7_PLUS(tds->conn)? 2 : 1) * strlen(progname)); /* length of message */ if (IS_TDS50(tds->conn)) { tds_put_byte(tds, 5); version = 0x05000000u; } else { tds_put_byte(tds, 1); /* see src/tds/token.c */ if (IS_TDS73_PLUS(tds->conn)) { version = 0x730B0003u; } else if (IS_TDS72_PLUS(tds->conn)) { version = 0x72090002u; } else if (IS_TDS71_PLUS(tds->conn)) { version = tds->conn->tds71rev1 ? 0x07010000u : 0x71000001u; } else { version = (TDS_MAJOR(tds->conn) << 24) | (TDS_MINOR(tds->conn) << 16); } } TDS_PUT_A4BE(&ui, version); tds_put_n(tds, &ui, 4); tds_put_byte(tds, strlen(progname)); /* FIXME ucs2 */ tds_put_string(tds, progname, strlen(progname)); /* server version, always big endian */ TDS_PUT_A4BE(&ui, tds->conn->product_version & 0x7fffffffu); tds_put_n(tds, &ui, 4); } void tds_send_capabilities_token(TDSSOCKET * tds) { tds_put_byte(tds, TDS_CAPABILITY_TOKEN); tds_put_smallint(tds, 18); tds_put_byte(tds, 1); tds_put_byte(tds, 7); tds_put_byte(tds, 7); tds_put_byte(tds, 97); tds_put_byte(tds, 65); tds_put_byte(tds, 207); tds_put_byte(tds, 255); tds_put_byte(tds, 255); tds_put_byte(tds, 230); tds_put_byte(tds, 2); tds_put_byte(tds, 7); tds_put_byte(tds, 0); tds_put_byte(tds, 0); tds_put_byte(tds, 2); tds_put_byte(tds, 0); tds_put_byte(tds, 0); tds_put_byte(tds, 0); tds_put_byte(tds, 0); } /** * Send a "done" token, marking the end of a table, stored procedure, or query. * \param tds Where the token will be written to. * \param token The appropriate type of "done" token for this context: * TDS_DONE_TOKEN outside a stored procedure, * TDS_DONEINPROC_TOKEN inside a stored procedure, or * TDS_DONEPROC_TOKEN at the end of a stored procedure. * \param flags Bitwise-OR of flags in the "enum tds_end" data type. * TDS_DONE_FINAL for the last statement in a query, * TDS_DONE_MORE_RESULTS if not the last statement, * TDS_DONE_ERROR if the statement had an error, * TDS_DONE_INXACT if a transaction is pending, * TDS_DONE_PROC inside a stored procedure, * TDS_DONE_COUNT if a table was sent (and rows counted) * TDS_DONE_CANCELLED if the query was canceled, and * TDS_DONE_EVENT if the token marks an event. * \param numrows Number of rows, if flags has TDS_DONE_COUNT. */ void tds_send_done(TDSSOCKET * tds, int token, TDS_SMALLINT flags, TDS_INT numrows) { tds_put_byte(tds, token); tds_put_smallint(tds, flags); tds_put_smallint(tds, 2); /* are these two bytes the transaction status? */ if (IS_TDS72_PLUS(tds->conn)) tds_put_int8(tds, numrows); else tds_put_int(tds, numrows); } void tds_send_done_token(TDSSOCKET * tds, TDS_SMALLINT flags, TDS_INT numrows) { tds_send_done(tds, TDS_DONE_TOKEN, flags, numrows); } void tds_send_control_token(TDSSOCKET * tds, TDS_SMALLINT numcols) { int i; tds_put_byte(tds, TDS_CONTROL_FEATUREEXTACK_TOKEN); tds_put_smallint(tds, numcols); for (i = 0; i < numcols; i++) { tds_put_byte(tds, 0); } } void tds_send_col_name(TDSSOCKET * tds, TDSRESULTINFO * resinfo) { int col, hdrsize = 0; TDSCOLUMN *curcol; tds_put_byte(tds, TDS_COLNAME_TOKEN); for (col = 0; col < resinfo->num_cols; col++) { curcol = resinfo->columns[col]; hdrsize += tds_dstr_len(&curcol->column_name) + 1; } tds_put_smallint(tds, hdrsize); for (col = 0; col < resinfo->num_cols; col++) { curcol = resinfo->columns[col]; tds_put_byte(tds, tds_dstr_len(&curcol->column_name)); /* exclude the null */ tds_put_n(tds, tds_dstr_cstr(&curcol->column_name), tds_dstr_len(&curcol->column_name)); } } void tds_send_col_info(TDSSOCKET * tds, TDSRESULTINFO * resinfo) { int col, hdrsize = 0; TDSCOLUMN *curcol; tds_put_byte(tds, TDS_COLFMT_TOKEN); for (col = 0; col < resinfo->num_cols; col++) { curcol = resinfo->columns[col]; hdrsize += 5; if (!is_fixed_type(curcol->column_type)) { hdrsize++; } } tds_put_smallint(tds, hdrsize); for (col = 0; col < resinfo->num_cols; col++) { curcol = resinfo->columns[col]; tds_put_n(tds, "\0\0\0\0", 4); tds_put_byte(tds, curcol->column_type); if (!is_fixed_type(curcol->column_type)) { tds_put_byte(tds, curcol->column_size); } } } void tds_send_result(TDSSOCKET * tds, TDSRESULTINFO * resinfo) { TDSCOLUMN *curcol; int i, totlen; size_t len; tds_put_byte(tds, TDS_RESULT_TOKEN); totlen = 2; for (i = 0; i < resinfo->num_cols; i++) { curcol = resinfo->columns[i]; len = tds_dstr_len(&curcol->column_name); totlen += 8; totlen += len; curcol = resinfo->columns[i]; if (!is_fixed_type(curcol->column_type)) { totlen++; } } tds_put_smallint(tds, totlen); tds_put_smallint(tds, resinfo->num_cols); for (i = 0; i < resinfo->num_cols; i++) { curcol = resinfo->columns[i]; len = tds_dstr_len(&curcol->column_name); tds_put_byte(tds, tds_dstr_len(&curcol->column_name)); tds_put_n(tds, tds_dstr_cstr(&curcol->column_name), len); tds_put_byte(tds, '0'); tds_put_int(tds, curcol->column_usertype); tds_put_byte(tds, curcol->column_type); if (!is_fixed_type(curcol->column_type)) { tds_put_byte(tds, curcol->column_size); } tds_put_byte(tds, 0); } } void tds7_send_result(TDSSOCKET * tds, TDSRESULTINFO * resinfo) { int i, j; TDSCOLUMN *curcol; /* TDS7+ uses TDS7_RESULT_TOKEN to send column names and info */ tds_put_byte(tds, TDS7_RESULT_TOKEN); /* send the number of columns */ tds_put_smallint(tds, resinfo->num_cols); /* send info about each column */ for (i = 0; i < resinfo->num_cols; i++) { /* usertype, flags, and type */ curcol = resinfo->columns[i]; tds_put_smallint(tds, curcol->column_usertype); tds_put_smallint(tds, curcol->column_flags); tds_put_byte(tds, curcol->column_type); /* smallint? */ /* bytes in "size" field varies */ if (is_blob_type(curcol->column_type)) { tds_put_int(tds, curcol->column_size); } else if (curcol->column_type>=128) { /*is_large_type*/ tds_put_smallint(tds, curcol->column_size); } else { tds_put_tinyint(tds, curcol->column_size); } /* some types have extra info */ if (is_numeric_type(curcol->column_type)) { tds_put_tinyint(tds, curcol->column_prec); tds_put_tinyint(tds, curcol->column_scale); } else if (is_blob_type(curcol->column_type)) { size_t len = tds_dstr_len(&curcol->table_name); const char *name = tds_dstr_cstr(&curcol->table_name); tds_put_smallint(tds, 2 * len); for (j = 0; name[j] != '\0'; j++){ tds_put_byte(tds, name[j]); tds_put_byte(tds, 0); } } /* finally the name, in UCS16 format */ tds_put_byte(tds, tds_dstr_len(&curcol->column_name)); for (j = 0; j < tds_dstr_len(&curcol->column_name); j++) { tds_put_byte(tds, tds_dstr_cstr(&curcol->column_name)[j]); tds_put_byte(tds, 0); } } } /** * Send any tokens that mark the start of a table. This automatically chooses * the right tokens for this client's version of the TDS protocol. In other * words, it is a wrapper around tds_send_col_name(), tds_send_col_info(), * tds_send_result(), and tds7_send_result(). * \param tds The socket to which the tokens will be written. Also, * it contains the TDS protocol version number. * \param resinfo Describes the table to be send, especially the number * of columns and the names & data types of each column. */ void tds_send_table_header(TDSSOCKET * tds, TDSRESULTINFO * resinfo) { switch (TDS_MAJOR(tds->conn)) { case 4: /* * TDS4 uses TDS_COLNAME_TOKEN to send column names, and * TDS_COLFMT_TOKEN to send column info. The number of columns * is implied by the number of column names. */ tds_send_col_name(tds, resinfo); tds_send_col_info(tds, resinfo); break; case 5: /* TDS5 uses a TDS_RESULT_TOKEN to send all column information */ tds_send_result(tds, resinfo); break; case 7: /* * TDS7+ uses a TDS7_RESULT_TOKEN to send all column * information. */ tds7_send_result(tds, resinfo); break; } } void tds_send_row(TDSSOCKET * tds, TDSRESULTINFO * resinfo) { TDSCOLUMN *curcol; int colsize, i; tds_put_byte(tds, TDS_ROW_TOKEN); for (i = 0; i < resinfo->num_cols; i++) { curcol = resinfo->columns[i]; if (!is_fixed_type(curcol->column_type)) { /* FIX ME -- I have no way of knowing the actual length of non character variable data (eg nullable int) */ colsize = strlen((char *) curcol->column_data); tds_put_byte(tds, colsize); tds_put_n(tds, curcol->column_data, colsize); } else { tds_put_n(tds, curcol->column_data, tds_get_size_by_type(curcol->column_type)); } } } void tds71_send_prelogin(TDSSOCKET * tds) { static const unsigned char prelogin[] = { 0x00, 0x00, 0x15, 0x00, 0x06, 0x01, 0x00, 0x1b, 0x00, 0x01, 0x02, 0x00, 0x1c, 0x00, 0x01, 0x03, 0x00, 0x1d, 0x00, 0x00, 0xff, 0x08, 0x00, 0x01, 0x55, 0x00, 0x00, 0x02, 0x00 }; tds_put_n(tds, prelogin, sizeof(prelogin)); } freetds-1.00.82/src/server/login.c100644 025423 025423 00000024144 12717145107 0012411/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #if HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #if HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #if HAVE_NETINET_IN_H #include #endif /* HAVE_NETINET_IN_H */ #if HAVE_ARPA_INET_H #include #endif /* HAVE_ARPA_INET_H */ #include #include #include #include unsigned char * tds7_decrypt_pass(const unsigned char *crypt_pass, int len, unsigned char *clear_pass) { int i; const unsigned char xormask = 0x5A; unsigned char hi_nibble, lo_nibble; for (i = 0; i < len; i++) { lo_nibble = (crypt_pass[i] << 4) ^ (xormask & 0xF0); hi_nibble = (crypt_pass[i] >> 4) ^ (xormask & 0x0F); clear_pass[i] = hi_nibble | lo_nibble; } return clear_pass; } TDSSOCKET * tds_listen(TDSCONTEXT * ctx, int ip_port) { TDSSOCKET *tds; struct sockaddr_in sin; TDS_SYS_SOCKET fd, s; socklen_t len; sin.sin_addr.s_addr = INADDR_ANY; sin.sin_port = htons((short) ip_port); sin.sin_family = AF_INET; s = socket(AF_INET, SOCK_STREAM, 0); if (TDS_IS_SOCKET_INVALID(s)) { perror("socket"); return NULL; } if (bind(s, (struct sockaddr *) &sin, sizeof(sin)) < 0) { CLOSESOCKET(s); perror("bind"); return NULL; } listen(s, 5); len = sizeof(sin); fd = tds_accept(s, (struct sockaddr *) &sin, &len); if (TDS_IS_SOCKET_INVALID(fd)) { CLOSESOCKET(s); perror("accept"); return NULL; } CLOSESOCKET(s); tds = tds_alloc_socket(ctx, 4096); tds_set_s(tds, fd); tds->out_flag = TDS_LOGIN; /* TODO proper charset */ tds_iconv_open(tds->conn, "ISO8859-1", 0); /* get_incoming(tds->s); */ return tds; } static int tds_read_string(TDSSOCKET * tds, DSTR * s, int size); int tds_read_login(TDSSOCKET * tds, TDSLOGIN * login) { DSTR blockstr = DSTR_INITIALIZER; TDS_USMALLINT major; int res = 1; /* while (len = tds_read_packet(tds)) { for (i=0;iin_buf[i], (tds->in_buf[i]>=' ' && tds->in_buf[i]<='z') ? tds->in_buf[i] : ' '); } */ res = res && tds_read_string(tds, &login->client_host_name, 30); res = res && tds_read_string(tds, &login->user_name, 30); res = res && tds_read_string(tds, &login->password, 30); tds_get_n(tds, NULL, 31); /* host process, junk for now */ tds_get_n(tds, NULL, 16); /* magic */ res = res && tds_read_string(tds, &login->app_name, 30); res = res && tds_read_string(tds, &login->server_name, 30); tds_get_n(tds, NULL, 256); /* secondary passwd...encryption? */ major = tds_get_byte(tds); login->tds_version = (major << 8) | tds_get_byte(tds); tds_get_smallint(tds); /* unused part of protocol field */ res = res && tds_read_string(tds, &login->library, 10); tds_get_byte(tds); /* program version, junk it */ tds_get_byte(tds); tds_get_smallint(tds); tds_get_n(tds, NULL, 3); /* magic */ res = res && tds_read_string(tds, &login->language, 30); tds_get_n(tds, NULL, 14); /* magic */ res = res && tds_read_string(tds, &login->server_charset, 30); tds_get_n(tds, NULL, 1); /* magic */ res = res && tds_read_string(tds, &blockstr, 6); printf("block size %s\n", tds_dstr_cstr(&blockstr)); login->block_size = atoi(tds_dstr_cstr(&blockstr)); tds_dstr_free(&blockstr); tds_get_n(tds, NULL, tds->in_len - tds->in_pos); /* read junk at end */ return res; } int tds7_read_login(TDSSOCKET * tds, TDSLOGIN * login) { int a; unsigned host_name_len, user_name_len, app_name_len, server_name_len; unsigned library_name_len, language_name_len; unsigned auth_len, database_name_len; size_t unicode_len, password_len; char *unicode_string, *psrc; char *pbuf; int res = 1; unsigned packet_start, len, start; TDS_UINT packet_len; packet_len = tds_get_uint(tds); /*total packet size */ a = tds_get_int(tds); /*TDS version */ if ((a & 0xff) == 7) tds_set_version(login, a & 0xff, (a >> 8) & 0xff); else tds_set_version(login, (a >> 28) & 0xf, (a >> 24) & 0xf); tds_get_int(tds); /*desired packet size being requested by client */ /* client prog ver (4 byte) + pid (int) + connection id (4 byte) + flag1 (byte) */ tds_get_n(tds, NULL, 13); login->option_flag2 = tds_get_byte(tds); /* sql type (byte) + flag3 (byte) + timezone (int) + collation (4 byte) */ tds_get_n(tds, NULL, 10); packet_start = IS_TDS72_PLUS(tds->conn) ? 86 + 8 : 86; /* ? */ if (packet_len < packet_start) return 0; #define READ_BUF(len, base_len) do { \ start = tds_get_usmallint(tds); \ len = tds_get_usmallint(tds); \ if (len != 0 && (start < packet_start || start + base_len * len > packet_len)) \ return 0; \ } while(0) /* hostname */ READ_BUF(host_name_len, 2); /* username */ READ_BUF(user_name_len, 2); /* password */ READ_BUF(password_len, 2); /* app name */ READ_BUF(app_name_len, 2); /* server */ READ_BUF(server_name_len, 2); /* unknown */ tds_get_smallint(tds); tds_get_smallint(tds); /* library */ READ_BUF(library_name_len, 2); /* language */ READ_BUF(language_name_len, 2); /* database */ READ_BUF(database_name_len, 2); /* client mac address */ tds_get_n(tds, NULL, 6); /* authentication */ READ_BUF(auth_len, 1); /* db file */ READ_BUF(len, 2); if (IS_TDS72_PLUS(login)) { /* new password */ READ_BUF(len, 2); /* SSPI */ tds_get_int(tds); } res = res && tds_dstr_get(tds, &login->client_host_name, host_name_len); res = res && tds_dstr_get(tds, &login->user_name, user_name_len); unicode_len = password_len * 2; unicode_string = tds_new(char, unicode_len); if (!unicode_string || !tds_dstr_alloc(&login->password, password_len)) { free(unicode_string); return 0; } tds_get_n(tds, unicode_string, unicode_len); tds7_decrypt_pass((unsigned char *) unicode_string, unicode_len, (unsigned char *) unicode_string); pbuf = tds_dstr_buf(&login->password); memset(&tds->conn->char_convs[client2ucs2]->suppress, 0, sizeof(tds->conn->char_convs[client2ucs2]->suppress)); psrc = unicode_string; a = tds_iconv(tds, tds->conn->char_convs[client2ucs2], to_client, (const char **) &psrc, &unicode_len, &pbuf, &password_len); if (a < 0 ) { fprintf(stderr, "error: %s:%d: tds7_read_login: tds_iconv() failed\n", __FILE__, __LINE__); free(unicode_string); return 0; } tds_dstr_setlen(&login->password, pbuf - tds_dstr_buf(&login->password)); free(unicode_string); res = res && tds_dstr_get(tds, &login->app_name, app_name_len); res = res && tds_dstr_get(tds, &login->server_name, server_name_len); res = res && tds_dstr_get(tds, &login->library, library_name_len); res = res && tds_dstr_get(tds, &login->language, language_name_len); res = res && tds_dstr_get(tds, &login->database, database_name_len); tds_get_n(tds, NULL, auth_len); tds_dstr_empty(&login->server_charset); /*empty char_set for TDS 7.0 */ login->block_size = 0; /*0 block size for TDS 7.0 */ login->encryption_level = TDS_ENCRYPTION_OFF; return res; } static int tds_read_string(TDSSOCKET * tds, DSTR * s, int size) { int len; /* FIXME this can fails... */ if (!tds_dstr_alloc(s, size)) return 0; tds_get_n(tds, tds_dstr_buf(s), size); len = tds_get_byte(tds); if (len <= size) tds_dstr_setlen(s, len); return 1; } /** * Allocate a TDSLOGIN structure, read a login packet into it, and return it. * This is smart enough to distinguish between TDS4/5 or TDS7. The calling * function should call tds_free_login() on the returned structure when it is * no longer needed. * \param tds The socket to read from * \return Returns NULL if no login was received. The calling function can * use IS_TDSDEAD(tds) to distinguish between an error/shutdown on the socket, * or the receipt of an unexpected packet type. In the latter case, * tds->in_flag will indicate the return type. */ TDSLOGIN * tds_alloc_read_login(TDSSOCKET * tds) { TDSLOGIN * login; /* * This should only be done on a server connection, and the server * always sends 0x04 packets. */ tds->out_flag = TDS_REPLY; /* Pre-read the next packet so we know what kind of packet it is */ if (tds_read_packet(tds) < 1) { return NULL; } /* Allocate the login packet */ login = tds_alloc_login(1); if (!login) return NULL; /* Use the packet type to determine which login format to expect */ switch (tds->in_flag) { case TDS_LOGIN: /* TDS4/5 login */ tds->conn->tds_version = 0x402; if (!tds_read_login(tds, login)) { tds_free_login(login); return NULL; } if (login->block_size == 0) { login->block_size = 512; } break; case TDS7_LOGIN: /* TDS7+ login */ tds->conn->tds_version = 0x700; if (!tds7_read_login(tds, login)) { tds_free_login(login); return NULL; } break; case TDS71_PRELOGIN: /* TDS7.1+ prelogin, hopefully followed by a login */ tds->conn->tds_version = 0x701; /* ignore client and just send our reply TODO... finish */ tds71_send_prelogin(tds); tds_flush_packet(tds); if (tds_read_packet(tds) < 0 || tds->in_flag != TDS7_LOGIN) { tds_free_login(login); return NULL; } if (!tds7_read_login(tds, login)) { tds_free_login(login); return NULL; } break; default: /* unexpected packet */ tds_free_login(login); return NULL; } /* Return it */ return login; } freetds-1.00.82/src/server/unittest.c100644 025423 025423 00000007430 12522201763 0013152/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-1999 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #include #include #include static void dump_login(TDSLOGIN * login); int main(int argc, char **argv) { TDSCONTEXT *ctx; TDSSOCKET *tds; TDSLOGIN *login; TDSRESULTINFO *resinfo; if (argc < 2 || atoi(argv[1]) <= 0) { fprintf(stderr, "syntax: %s \n", argv[0]); return 1; } ctx = tds_alloc_context(NULL); tds = tds_listen(ctx, atoi(argv[1])); if (!tds) return 1; /* get_incoming(tds->s); */ login = tds_alloc_read_login(tds); if (!login) { fprintf(stderr, "Error reading login\n"); exit(1); } dump_login(login); if (!strcmp(tds_dstr_cstr(&login->user_name), "guest") && !strcmp(tds_dstr_cstr(&login->password), "sybase")) { tds->out_flag = TDS_REPLY; tds_env_change(tds, TDS_ENV_DATABASE, "master", "pubs2"); tds_send_msg(tds, 5701, 2, 10, "Changed database context to 'pubs2'.", "JDBC", "ZZZZZ", 1); if (!login->suppress_language) { tds_env_change(tds, TDS_ENV_LANG, NULL, "us_english"); tds_send_msg(tds, 5703, 1, 10, "Changed language setting to 'us_english'.", "JDBC", "ZZZZZ", 1); } tds_env_change(tds, TDS_ENV_PACKSIZE, NULL, "512"); /* TODO set mssql if tds7+ */ tds_send_login_ack(tds, "sql server"); if (IS_TDS50(tds->conn)) tds_send_capabilities_token(tds); tds_send_done_token(tds, 0, 1); } else { /* send nack before exiting */ exit(1); } tds_flush_packet(tds); tds_free_login(login); login = NULL; /* printf("incoming packet %d\n", tds_read_packet(tds)); */ printf("query : %s\n", tds_get_generic_query(tds)); tds->out_flag = TDS_REPLY; resinfo = tds_alloc_results(1); resinfo->columns[0]->column_type = SYBVARCHAR; resinfo->columns[0]->column_size = 30; if (!tds_dstr_copy(&resinfo->columns[0]->column_name, "name")) exit(1); resinfo->current_row = (TDS_UCHAR*) "pubs2"; resinfo->columns[0]->column_data = resinfo->current_row; tds_send_result(tds, resinfo); tds_send_control_token(tds, 1); tds_send_row(tds, resinfo); tds_send_done_token(tds, 16, 1); tds_flush_packet(tds); tds_sleep_s(30); tds_free_results(resinfo); tds_free_socket(tds); tds_free_context(ctx); return 0; } static void dump_login(TDSLOGIN * login) { printf("host %s\n", tds_dstr_cstr(&login->client_host_name)); printf("user %s\n", tds_dstr_cstr(&login->user_name)); printf("pass %s\n", tds_dstr_cstr(&login->password)); printf("app %s\n", tds_dstr_cstr(&login->app_name)); printf("srvr %s\n", tds_dstr_cstr(&login->server_name)); printf("vers %d.%d\n", TDS_MAJOR(login), TDS_MINOR(login)); printf("lib %s\n", tds_dstr_cstr(&login->library)); printf("lang %s\n", tds_dstr_cstr(&login->language)); printf("char %s\n", tds_dstr_cstr(&login->server_charset)); printf("bsiz %d\n", login->block_size); } freetds-1.00.82/src/pool/Makefile.am100644 025423 025423 00000000733 12717145107 0012632# $Id: Makefile.am,v 1.17 2012-01-16 00:27:04 jklowden Exp $ AM_CPPFLAGS = -I$(top_srcdir)/include -I. -I$(SERVERDIR) bin_PROGRAMS = tdspool tdspool_SOURCES = config.c main.c member.c user.c util.c pool.h SERVERDIR = ../server LDADD = ../server/libtdssrv.la $(LTLIBICONV) EXTRA_DIST = BUGS pool.conf ETC = $(DESTDIR)$(sysconfdir) install-data-local: $(mkinstalldirs) $(ETC) if test ! -f $(ETC)/pool.conf; then \ $(INSTALL) $(srcdir)/pool.conf $(ETC)/pool.conf; \ fi freetds-1.00.82/src/pool/Makefile.in100644 025423 025423 00000054161 13242511111 0012631# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ bin_PROGRAMS = tdspool$(EXEEXT) subdir = src/pool ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = \ $(top_srcdir)/m4/ac_caolan_func_which_gethostbyname_r.m4 \ $(top_srcdir)/m4/ac_have_inaddr_none.m4 \ $(top_srcdir)/m4/ac_have_malloc_options.m4 \ $(top_srcdir)/m4/ac_nullzero.m4 \ $(top_srcdir)/m4/ac_raf_func_which_getservbyname_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_gethostbyaddr_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_getpwuid_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_localtime_r.m4 \ $(top_srcdir)/m4/acx_pthread.m4 \ $(top_srcdir)/m4/ax_cflags_gcc_option.m4 \ $(top_srcdir)/m4/check_openssl.m4 \ $(top_srcdir)/m4/gettimemilli.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/pushlibs.m4 \ $(top_srcdir)/m4/sprintf_i64_format.m4 \ $(top_srcdir)/m4/type_socklen_t.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" PROGRAMS = $(bin_PROGRAMS) am_tdspool_OBJECTS = config.$(OBJEXT) main.$(OBJEXT) member.$(OBJEXT) \ user.$(OBJEXT) util.$(OBJEXT) tdspool_OBJECTS = $(am_tdspool_OBJECTS) tdspool_LDADD = $(LDADD) am__DEPENDENCIES_1 = tdspool_DEPENDENCIES = ../server/libtdssrv.la $(am__DEPENDENCIES_1) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(tdspool_SOURCES) DIST_SOURCES = $(tdspool_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp \ $(top_srcdir)/mkinstalldirs README TODO DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BUILD_NUMBER = @BUILD_NUMBER@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOXYGEN = @DOXYGEN@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FREETDS_LIBGCC = @FREETDS_LIBGCC@ FREETDS_ODBC_MODULE = @FREETDS_ODBC_MODULE@ FREETDS_SYMBOLIC = @FREETDS_SYMBOLIC@ GCRYPT_CFLAGS = @GCRYPT_CFLAGS@ GCRYPT_LIBS = @GCRYPT_LIBS@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ HAVE_OPENSSL = @HAVE_OPENSSL@ HAVE_PERL_SOURCES = @HAVE_PERL_SOURCES@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBADD_DL = @LIBADD_DL@ LIBADD_DLD_LINK = @LIBADD_DLD_LINK@ LIBADD_DLOPEN = @LIBADD_DLOPEN@ LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@ LIBICONV = @LIBICONV@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBOBJS = @LTLIBOBJS@ LT_DLLOADERS = @LT_DLLOADERS@ LT_DLPREOPEN = @LT_DLPREOPEN@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ NETTLE_CFLAGS = @NETTLE_CFLAGS@ NETTLE_LIBS = @NETTLE_LIBS@ NETWORK_LIBS = @NETWORK_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ODBC = @ODBC@ ODBCINSTLIB = @ODBCINSTLIB@ ODBCLIB = @ODBCLIB@ ODBCNODMLIB = @ODBCNODMLIB@ ODBCNODMLIBAPP = @ODBCNODMLIBAPP@ ODBC_CONFIG = @ODBC_CONFIG@ ODBC_INC = @ODBC_INC@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ RC = @RC@ READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SUBVERSION = @SUBVERSION@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ dblib_define = @dblib_define@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ tds_sysdep_int16_type = @tds_sysdep_int16_type@ tds_sysdep_int32_type = @tds_sysdep_int32_type@ tds_sysdep_int64_type = @tds_sysdep_int64_type@ tds_sysdep_intptr_type = @tds_sysdep_intptr_type@ tds_sysdep_real32_type = @tds_sysdep_real32_type@ tds_sysdep_real64_type = @tds_sysdep_real64_type@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # $Id: Makefile.am,v 1.17 2012-01-16 00:27:04 jklowden Exp $ AM_CPPFLAGS = -I$(top_srcdir)/include -I. -I$(SERVERDIR) tdspool_SOURCES = config.c main.c member.c user.c util.c pool.h SERVERDIR = ../server LDADD = ../server/libtdssrv.la $(LTLIBICONV) EXTRA_DIST = BUGS pool.conf ETC = $(DESTDIR)$(sysconfdir) all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/pool/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/pool/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ fi; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p \ || test -f $$p1 \ ; then echo "$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n;h' \ -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) files[d] = files[d] " " $$1; \ else { print "f", $$3 "/" $$4, $$1; } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ } \ ; done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ -e 's/$$/$(EXEEXT)/' \ `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(bindir)" && rm -f $$files clean-binPROGRAMS: @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list tdspool$(EXEEXT): $(tdspool_OBJECTS) $(tdspool_DEPENDENCIES) $(EXTRA_tdspool_DEPENDENCIES) @rm -f tdspool$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tdspool_OBJECTS) $(tdspool_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/config.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/member.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/user.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/util.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(PROGRAMS) installdirs: for dir in "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-data-local install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-binPROGRAMS install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \ clean-binPROGRAMS clean-generic clean-libtool cscopelist-am \ ctags ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-binPROGRAMS \ install-data install-data-am install-data-local 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-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-binPROGRAMS .PRECIOUS: Makefile install-data-local: $(mkinstalldirs) $(ETC) if test ! -f $(ETC)/pool.conf; then \ $(INSTALL) $(srcdir)/pool.conf $(ETC)/pool.conf; \ fi # 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: freetds-1.00.82/src/pool/README100644 025423 025423 00000006236 12522201763 0011455TDS Connection Pooling v0.01 Introduction ------------ The purpose of the TDS Connection Pool is to share a limited number of actual database connections among a larger group of virtual database clients. The advantages are twofold. First, a dataserver with a limited number of licenses can be used with the tdspool program to support a large number of client connections. For instance if you have a database with a 10 concurrent license limit and 35 Apache/PHP children, which access the database infrequently, you could share those 10 real connections among all the apache children. Secondly, TDS Connection Pool acts as a sort of persistant connect for it's clients. This works because logins to the connection pool are very quick in comparision to logins into the dataserver. Connections to the dataserver are maintained for the life of the tdspool program. Terminology ----------- Pool Server, the tdspool program. Client, the application using TDS (generally through freetds dblib or ctlib) to connect to the Connection Pooling Server. DataServer, the Sybase or MS SQL Server database. Pool User, the connection from the client to the Pool Server. Pool Member, a connection to the dataserver maintained by the tdspool program. How It Works ------------ On start up the Pool Server opens a predefined number of connections (Members) to the DataServer. It then opens a listening socket on the configured port and goes into its main loop. When a Client connects, the Pool Server accepts the connection, creates a User and sets its state to TDS_SRV_LOGIN, and returns to the main loop. When a Client in the TDS_SRV_LOGIN state sends a login packet, the packet is parsed and if the login information matches, a TDS login acknowledgement stream is forged by the Pool Server and sent to the Client. The User structure then goes to the TDS_SRV_IDLE state. The Pool Server then returns to the main loop. When the Client in the TDS_SRV_IDLE state sends a query, the member list is searched for a Member with its TDS socket in the TDS_COMPLETED state. This Member is then allocated to the User. The User is then switched to the TDS_SRV_QUERY state. If no free Member is found, the User is placed in the TDS_SRV_WAIT state and the search will be reattempted the next time the server is woken up by activity (such as a Member completing). When a User is placed in a wait, a message is logged to let the administrator know that the number of Members may need to be adjusted upwards. When results are recieved from the DataServer, they are forwarded to the User that currently has that Member allocated. The Pool Server processes through the results prior to forwarding, looking for the end token. When it is found the Member is deallocated from the User. The Member returns to the idle list and the User is returned to the TDS_SRV_IDLE state. One caveat to this is that querys that contain stateful information, such as the need to query @@identity after inserting, will not work. I am currently, thinking of adding a "lock connection" command that will be intercepted by the Pool Server and will cause it to allocate a Member to that User until an "unlock connection" command is received. freetds-1.00.82/src/pool/TODO100644 025423 025423 00000000553 12522201763 0011261Handle closed connections by the dataserver (done) Timeout open member connections. (done) Open member connections on the fly. (done) Add TDS_SRV_WAIT state when all members are in use. (done) Handle SIGTERM (partial...add timeout to select() call) Error checking is weak in several places. Need to handle larger packet sizes Add blob support Add TDS 5/7 support freetds-1.00.82/src/pool/config.c100644 025423 025423 00000007247 12717145107 0012216/* TDSPool - Connection pooling for TDS based databases * Copyright (C) 2001 Brian Bruns * Copyright (C) 2005 Frediano Ziglio * * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include #include #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif #ifdef HAVE_LIMITS_H #include #endif #include "pool.h" #include #define POOL_STR_SERVER "server" #define POOL_STR_PORT "port" #define POOL_STR_USER "user" #define POOL_STR_PASSWORD "password" #define POOL_STR_DATABASE "database" #define POOL_STR_MAX_MBR_AGE "max member age" #define POOL_STR_MAX_POOL_CONN "max pool conn" #define POOL_STR_MIN_POOL_CONN "min pool conn" #define POOL_STR_MAX_POOL_USERS "max pool users" static void pool_parse(const char *option, const char *value, void *param); typedef struct { TDS_POOL *pool; char **err; } conf_params; int pool_read_conf_file(const char *poolname, TDS_POOL * pool, char **err) { FILE *in; int found = 0; conf_params params = { pool, err }; in = fopen(FREETDS_POOLCONFFILE, "r"); if (in) { tdsdump_log(TDS_DBG_INFO1, "Found conf file in %s reading sections\n", FREETDS_POOLCONFFILE); tds_read_conf_section(in, "global", pool_parse, ¶ms); rewind(in); found = tds_read_conf_section(in, poolname, pool_parse, ¶ms); fclose(in); } return found; } /** * Parse an unsigned number, returns -1 on error. * Returns a signed int to make possible to return negative * values for include numbers (we don't need big numbers) */ static int pool_get_uint(const char *value) { char *end; unsigned long int val; errno = 0; val = strtoul(value, &end, 0); if (errno != 0 || end == value || val > INT_MAX) return -1; return (int) val; } static void pool_parse(const char *option, const char *value, void *param) { conf_params *params = (conf_params *) param; TDS_POOL *pool = params->pool; int val = 0; if (!strcmp(option, POOL_STR_PORT)) { val = pool_get_uint(value); if (val < 1 || val >= 65536) val = -1; pool->port = val; } else if (!strcmp(option, POOL_STR_SERVER)) { free(pool->server); pool->server = strdup(value); } else if (!strcmp(option, POOL_STR_USER)) { free(pool->user); pool->user = strdup(value); } else if (!strcmp(option, POOL_STR_DATABASE)) { free(pool->database); pool->database = strdup(value); } else if (!strcmp(option, POOL_STR_PASSWORD)) { free(pool->password); pool->password = strdup(value); } else if (!strcmp(option, POOL_STR_MAX_MBR_AGE)) { val = pool_get_uint(value); pool->max_member_age = val; } else if (!strcmp(option, POOL_STR_MAX_POOL_CONN)) { val = pool_get_uint(value); pool->max_open_conn = val; } else if (!strcmp(option, POOL_STR_MIN_POOL_CONN)) { val = pool_get_uint(value); pool->min_open_conn = val; } if (val < 0) { free(*params->err); if (asprintf(params->err, "Invalid value '%s' specified for %s", value, option) < 0) *params->err = "Memory error parsing options"; } } freetds-1.00.82/src/pool/main.c100644 025423 025423 00000022312 13115740221 0011652/* TDSPool - Connection pooling for TDS based databases * Copyright (C) 2001 Brian Bruns * * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ /* * Note on terminology: a pool member is a connection to the database, * a pool user is a client connection that is temporarily assigned to a * pool member. */ #include #include #include #include #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #if HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #if HAVE_NETINET_IN_H #include #endif /* HAVE_NETINET_IN_H */ #if HAVE_ARPA_INET_H #include #endif /* HAVE_ARPA_INET_H */ #include "pool.h" /* to be set by sig term */ static int got_sigterm = 0; static int got_sighup = 0; static const char *logfile_name = NULL; static void sigterm_handler(int sig); static void pool_schedule_waiters(TDS_POOL * pool); static TDS_POOL *pool_init(const char *name); static void pool_socket_init(TDS_POOL * pool); static void pool_main_loop(TDS_POOL * pool); static bool pool_open_logfile(TDS_POOL * pool); static void sigterm_handler(int sig) { got_sigterm = 1; } static void sighup_handler(int sig) { got_sighup = 1; } static void check_field(const char *pool_name, bool cond, const char *field_name) { if (!cond) { fprintf(stderr, "No %s specified for pool ``%s''.\n", field_name, pool_name); exit(EXIT_FAILURE); } } /* * pool_init creates a named pool and opens connections to the database */ static TDS_POOL * pool_init(const char *name) { TDS_POOL *pool; char *err = NULL; /* initialize the pool */ pool = tds_new0(TDS_POOL, 1); pool->password = strdup(""); pool->event_fd = INVALID_SOCKET; if (tds_mutex_init(&pool->events_mtx)) { fprintf(stderr, "Error initializing pool mutex\n"); exit(EXIT_FAILURE); } /* FIXME -- read this from the conf file */ if (!pool_read_conf_file(name, pool, &err)) { fprintf(stderr, "Configuration for pool ``%s'' not found.\n", name); exit(EXIT_FAILURE); } if (err) { fprintf(stderr, "%s\n", err); exit(EXIT_FAILURE); } check_field(name, pool->user != NULL, "user"); check_field(name, pool->server != NULL, "server"); check_field(name, pool->port != 0, "port"); if (pool->max_open_conn < pool->min_open_conn) { fprintf(stderr, "Max connections less than minimum\n"); exit(EXIT_FAILURE); } pool->name = strdup(name); pool_open_logfile(pool); pool_mbr_init(pool); pool_user_init(pool); pool_socket_init(pool); return pool; } static void pool_destroy(TDS_POOL *pool) { pool_mbr_destroy(pool); pool_user_destroy(pool); CLOSESOCKET(pool->wakeup_fd); CLOSESOCKET(pool->listen_fd); CLOSESOCKET(pool->event_fd); tds_mutex_free(&pool->events_mtx); free(pool->user); free(pool->password); free(pool->server); free(pool->database); free(pool->name); free(pool); } static void pool_schedule_waiters(TDS_POOL * pool) { TDS_POOL_USER *puser; /* first see if there are free members to do the request */ if (!dlist_member_first(&pool->idle_members)) return; while ((puser = dlist_user_first(&pool->waiters)) != NULL) { if (puser->user_state == TDS_SRV_WAIT) { /* place back in query state */ puser->user_state = TDS_SRV_QUERY; dlist_user_remove(&pool->waiters, puser); dlist_user_append(&pool->users, puser); /* now try again */ pool_user_query(pool, puser); return; } } } typedef struct select_info { fd_set rfds, wfds; TDS_SYS_SOCKET maxfd; } SELECT_INFO; static void pool_select_add_socket(SELECT_INFO *sel, TDS_POOL_SOCKET *sock) { /* skip dead connections */ if (IS_TDSDEAD(sock->tds)) return; if (!sock->poll_recv && !sock->poll_send) return; if (tds_get_s(sock->tds) > sel->maxfd) sel->maxfd = tds_get_s(sock->tds); if (sock->poll_recv) FD_SET(tds_get_s(sock->tds), &sel->rfds); if (sock->poll_send) FD_SET(tds_get_s(sock->tds), &sel->wfds); } static void pool_process_events(TDS_POOL *pool) { TDS_POOL_EVENT *events, *next; /* detach events from pool */ tds_mutex_lock(&pool->events_mtx); events = pool->events; pool->events = NULL; tds_mutex_unlock(&pool->events_mtx); /* process them */ while (events) { next = events->next; events->next = NULL; events->execute(events); free(events); events = next; } } static bool pool_open_logfile(TDS_POOL *pool) { int fd; tds_g_append_mode = 0; tdsdump_open(getenv("TDSDUMP")); if (!logfile_name) return true; fd = open(logfile_name, O_WRONLY|O_CREAT|O_APPEND, 0644); if (fd < 0) return false; fflush(stdout); fflush(stderr); while (dup2(fd, fileno(stdout)) < 0 && errno == EINTR) continue; while (dup2(fd, fileno(stderr)) < 0 && errno == EINTR) continue; close(fd); fflush(stdout); fflush(stderr); return true; } static void pool_socket_init(TDS_POOL * pool) { struct sockaddr_in sin; TDS_SYS_SOCKET s, event_pair[2]; int socktrue = 1; /* FIXME -- read the interfaces file and bind accordingly */ sin.sin_addr.s_addr = INADDR_ANY; sin.sin_port = htons(pool->port); sin.sin_family = AF_INET; if (TDS_IS_SOCKET_INVALID(s = socket(AF_INET, SOCK_STREAM, 0))) { perror("socket"); exit(1); } tds_socket_set_nonblocking(s); /* don't keep addr in use from s.craig@andronics.com */ setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (const void *) &socktrue, sizeof(socktrue)); fprintf(stderr, "Listening on port %d\n", pool->port); if (bind(s, (struct sockaddr *) &sin, sizeof(sin)) < 0) { perror("bind"); exit(1); } listen(s, 5); pool->listen_fd = s; if (socketpair(AF_UNIX, SOCK_STREAM, 0, event_pair) < 0) { perror("socketpair"); exit(1); } tds_socket_set_nonblocking(event_pair[0]); tds_socket_set_nonblocking(event_pair[1]); pool->event_fd = event_pair[1]; pool->wakeup_fd = event_pair[0]; } /* * pool_main_loop * Accept new connections from clients, and handle all input from clients and * pool members. */ static void pool_main_loop(TDS_POOL * pool) { TDS_POOL_MEMBER *pmbr; TDS_POOL_USER *puser; TDS_SYS_SOCKET s, wakeup; SELECT_INFO sel; s = pool->listen_fd; wakeup = pool->wakeup_fd; while (!got_sigterm) { FD_ZERO(&sel.rfds); FD_ZERO(&sel.wfds); /* add the listening socket to the read list */ FD_SET(s, &sel.rfds); FD_SET(wakeup, &sel.rfds); sel.maxfd = s > wakeup ? s : wakeup; /* add the user sockets to the read list */ DLIST_FOREACH(dlist_user, &pool->users, puser) pool_select_add_socket(&sel, &puser->sock); /* add the pool member sockets to the read list */ DLIST_FOREACH(dlist_member, &pool->active_members, pmbr) pool_select_add_socket(&sel, &pmbr->sock); /* FIXME check return value */ select(sel.maxfd + 1, &sel.rfds, &sel.wfds, NULL, NULL); if (TDS_UNLIKELY(got_sigterm)) break; if (TDS_UNLIKELY(got_sighup)) { got_sighup = 0; pool_open_logfile(pool); } /* process events */ if (FD_ISSET(wakeup, &sel.rfds)) { char buf[32]; READSOCKET(wakeup, buf, sizeof(buf)); pool_process_events(pool); } /* process the sockets */ if (FD_ISSET(s, &sel.rfds)) { pool_user_create(pool, s); } pool_process_users(pool, &sel.rfds, &sel.wfds); pool_process_members(pool, &sel.rfds, &sel.wfds); /* back from members */ if (dlist_user_first(&pool->waiters)) pool_schedule_waiters(pool); } /* while !got_sigterm */ tdsdump_log(TDS_DBG_INFO2, "Shutdown Requested\n"); } static void print_usage(const char *progname) { fprintf(stderr, "Usage:\t%s [-l ] [-d] \n", progname); } int main(int argc, char **argv) { int opt; #ifdef HAVE_FORK bool daemonize = false; # define DAEMON_OPT "d" #else # define DAEMON_OPT "" #endif TDS_POOL *pool; signal(SIGTERM, sigterm_handler); signal(SIGINT, sigterm_handler); #ifndef _WIN32 signal(SIGHUP, sighup_handler); signal(SIGPIPE, SIG_IGN); #endif while ((opt = getopt(argc, argv, "l:" DAEMON_OPT)) != -1) { switch (opt) { case 'l': logfile_name = optarg; break; #ifdef HAVE_FORK case 'd': daemonize = true; break; #endif default: print_usage(argv[0]); return EXIT_FAILURE; } } if (optind >= argc) { print_usage(argv[0]); return EXIT_FAILURE; } pool = pool_init(argv[optind]); #ifdef HAVE_FORK if (daemonize) { if (daemon(0, 0) < 0) { fprintf(stderr, "Failed to daemonize %s\n", argv[0]); return EXIT_FAILURE; } } #endif pool_main_loop(pool); printf("User logins %lu members logins %lu members at end %d\n", pool->user_logins, pool->member_logins, pool->num_active_members); pool_destroy(pool); printf("tdspool Shutdown\n"); return EXIT_SUCCESS; } freetds-1.00.82/src/pool/member.c100644 025423 025423 00000032113 12717145107 0012206/* TDSPool - Connection pooling for TDS based databases * Copyright (C) 2001, 2002, 2003, 2004, 2005 Brian Bruns * * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #if HAVE_SYS_PARAM_H #include #endif /* HAVE_SYS_PARAM_H */ #if HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #if HAVE_NETINET_IN_H #include #endif /* HAVE_NETINET_IN_H */ #if HAVE_ARPA_INET_H #include #endif /* HAVE_ARPA_INET_H */ #include "pool.h" #include "replacements.h" #include #ifndef MAXHOSTNAMELEN #define MAXHOSTNAMELEN 256 #endif /* MAXHOSTNAMELEN */ static void pool_mbr_free_socket(TDSSOCKET *tds) { if (tds) { TDSCONTEXT *ctx = (TDSCONTEXT *) tds->conn->tds_ctx; tds_free_socket(tds); tds_free_context(ctx); } } /* * pool_mbr_login open a single pool login, to be call at init time or * to reconnect. */ static TDSSOCKET * pool_mbr_login(const TDS_POOL * pool, int tds_version) { TDSCONTEXT *context; TDSLOGIN *login; TDSSOCKET *tds; TDSLOGIN *connection; char hostname[MAXHOSTNAMELEN]; login = tds_alloc_login(1); if (gethostname(hostname, MAXHOSTNAMELEN) < 0) strlcpy(hostname, "tdspool", MAXHOSTNAMELEN); if (!tds_set_passwd(login, pool->password) || !tds_set_user(login, pool->user) || !tds_set_app(login, "tdspool") || !tds_set_host(login, hostname) || !tds_set_library(login, "TDS-Library") || !tds_set_server(login, pool->server) || !tds_set_client_charset(login, "iso_1") || !tds_set_language(login, "us_english")) { tds_free_login(login); return NULL; } if (tds_version > 0) login->tds_version = tds_version; if (pool->database && strlen(pool->database)) { if (!tds_dstr_copy(&login->database, pool->database)) { tds_free_login(login); return NULL; } } context = tds_alloc_context(NULL); tds = tds_alloc_socket(context, 512); connection = tds_read_config_info(tds, login, context->locale); tds_free_login(login); if (!connection || TDS_FAILED(tds_connect_and_login(tds, connection))) { pool_mbr_free_socket(tds); tds_free_login(connection); /* what to do? */ fprintf(stderr, "Could not open connection to server %s\n", pool->server); return NULL; } tds_free_login(connection); if (pool->database && strlen(pool->database)) { if (strcasecmp(tds->conn->env.database, pool->database) != 0) { fprintf(stderr, "changing database failed\n"); return NULL; } } return tds; } void pool_assign_member(TDS_POOL *pool, TDS_POOL_MEMBER * pmbr, TDS_POOL_USER *puser) { assert(pmbr->current_user == NULL); if (pmbr->current_user) { pmbr->current_user->assigned_member = NULL; } else { dlist_member_remove(&pool->idle_members, pmbr); dlist_member_append(&pool->active_members, pmbr); } pmbr->current_user = puser; puser->assigned_member = pmbr; } void pool_deassign_member(TDS_POOL *pool, TDS_POOL_MEMBER * pmbr) { if (pmbr->current_user) { pmbr->current_user->assigned_member = NULL; pmbr->current_user = NULL; dlist_member_remove(&pool->active_members, pmbr); dlist_member_append(&pool->idle_members, pmbr); } pmbr->sock.poll_send = false; } /* * if a dead connection on the client side left this member in a questionable * state, let's bring in a correct one * We are not sure what the client did so we must try to clean as much as * possible. * Use pool_free_member if the state is really broken. */ void pool_reset_member(TDS_POOL * pool, TDS_POOL_MEMBER * pmbr) { // FIXME not wait for server !!! asyncronous TDSSOCKET *tds = pmbr->sock.tds; TDS_POOL_USER *puser; puser = pmbr->current_user; if (puser) { pool_deassign_member(pool, pmbr); pool_free_user(pool, puser); } /* cancel whatever pending */ tds_init_write_buf(tds); if (tds_set_state(tds, TDS_WRITING) != TDS_WRITING) goto failure; tds->out_flag = TDS_CANCEL; if (TDS_FAILED(tds_flush_packet(tds))) goto failure; tds_set_state(tds, TDS_PENDING); tds->in_cancel = 2; if (TDS_FAILED(tds_process_cancel(tds))) goto failure; if (IS_TDS71_PLUS(tds->conn)) { /* this 0x9 final reset the state from mssql 2000 */ if (tds_set_state(tds, TDS_WRITING) != TDS_WRITING) goto failure; tds_start_query(tds, TDS_QUERY); tds_put_string(tds, "WHILE @@TRANCOUNT > 0 ROLLBACK SET TRANSACTION ISOLATION LEVEL READ COMMITTED", -1); tds_write_packet(tds, 0x9); tds_set_state(tds, TDS_PENDING); if (TDS_FAILED(tds_process_simple_query(tds))) goto failure; } return; failure: pool_free_member(pool, pmbr); } void pool_free_member(TDS_POOL * pool, TDS_POOL_MEMBER * pmbr) { TDSSOCKET *tds; TDS_POOL_USER *puser; tds = pmbr->sock.tds; if (tds) { if (!IS_TDSDEAD(tds)) tds_close_socket(tds); pool_mbr_free_socket(tds); pmbr->sock.tds = NULL; } /* * if he is allocated disconnect the client * otherwise we end up with broken client. */ puser = pmbr->current_user; if (puser) { pool_deassign_member(pool, pmbr); pool_free_user(pool, puser); } if (dlist_member_in_list(&pool->active_members, pmbr)) { pool->num_active_members--; dlist_member_remove(&pool->active_members, pmbr); } free(pmbr); } void pool_mbr_init(TDS_POOL * pool) { TDS_POOL_MEMBER *pmbr; /* allocate room for pool members */ pool->num_active_members = 0; dlist_member_init(&pool->active_members); dlist_member_init(&pool->idle_members); /* open connections for each member */ while (pool->num_active_members < pool->min_open_conn) { pmbr = tds_new0(TDS_POOL_MEMBER, 1); if (!pmbr) { fprintf(stderr, "Out of memory\n"); exit(1); } pmbr->sock.poll_recv = true; pmbr->sock.tds = pool_mbr_login(pool, 0); if (!pmbr->sock.tds) { fprintf(stderr, "Could not open initial connection\n"); exit(1); } pmbr->last_used_tm = time(NULL); pool->num_active_members++; dlist_member_append(&pool->idle_members, pmbr); if (!IS_TDS71_PLUS(pmbr->sock.tds->conn)) { fprintf(stderr, "Current pool implementation does not support protocol versions former than 7.1\n"); exit(1); } pool->member_logins++; } } void pool_mbr_destroy(TDS_POOL * pool) { while (dlist_member_first(&pool->active_members)) pool_free_member(pool, dlist_member_first(&pool->active_members)); while (dlist_member_first(&pool->idle_members)) pool_free_member(pool, dlist_member_first(&pool->idle_members)); assert(pool->num_active_members == 0); pool->num_active_members = 0; } static bool pool_process_data(TDS_POOL *pool, TDS_POOL_MEMBER *pmbr) { TDSSOCKET *tds = pmbr->sock.tds; TDS_POOL_USER *puser = NULL; for (;;) { if (pool_packet_read(tds)) break; /* disconnected */ if (tds->in_len == 0) { tdsdump_log(TDS_DBG_INFO1, "Uh oh! member disconnected\n"); /* mark as dead */ pool_free_member(pool, pmbr); return false; } tdsdump_dump_buf(TDS_DBG_NETWORK, "Got packet from server:", tds->in_buf, tds->in_len); puser = pmbr->current_user; if (!puser) break; tdsdump_log(TDS_DBG_INFO1, "writing it sock %d\n", tds_get_s(puser->sock.tds)); if (!pool_write_data(&pmbr->sock, &puser->sock)) { tdsdump_log(TDS_DBG_ERROR, "member received error while writing\n"); pool_free_user(pool, puser); return false; } if (tds->in_pos < tds->in_len) /* partial write, schedule a future write */ break; } if (puser && !puser->sock.poll_send) tds_socket_flush(tds_get_s(puser->sock.tds)); return true; } /* * pool_process_members * check the fd_set for members returning data to the client, lookup the * client holding this member and forward the results. */ void pool_process_members(TDS_POOL * pool, fd_set * rfds, fd_set * wfds) { TDS_POOL_MEMBER *pmbr, *next; TDSSOCKET *tds; int age; time_t time_now; for (next = dlist_member_first(&pool->active_members); (pmbr = next) != NULL; ) { bool processed = false; next = dlist_member_next(&pool->active_members, pmbr); if (pmbr->doing_async) continue; tds = pmbr->sock.tds; assert(tds); time_now = time(NULL); if (pmbr->sock.poll_recv && FD_ISSET(tds_get_s(tds), rfds)) { if (!pool_process_data(pool, pmbr)) continue; processed = true; } if (pmbr->sock.poll_send && FD_ISSET(tds_get_s(tds), wfds)) { if (!pool_write_data(&pmbr->current_user->sock, &pmbr->sock)) { pool_free_member(pool, pmbr); continue; } processed = true; } if (processed) pmbr->last_used_tm = time_now; } /* close old connections */ time_now = time(NULL); for (next = dlist_member_first(&pool->idle_members); (pmbr = next) != NULL; ) { next = dlist_member_next(&pool->idle_members, pmbr); assert(pmbr->sock.tds); assert(!pmbr->current_user); age = time_now - pmbr->last_used_tm; if (age > pool->max_member_age && pool->num_active_members > pool->min_open_conn) { tdsdump_log(TDS_DBG_INFO1, "member is %d seconds old...closing\n", age); pool_free_member(pool, pmbr); } } } static bool compatible_versions(const TDSSOCKET *tds, const TDS_POOL_USER *user) { if (tds->conn->tds_version != user->login->tds_version) return false; return true; } typedef struct { TDS_POOL_EVENT common; TDS_POOL *pool; TDS_POOL_MEMBER *pmbr; int tds_version; } CONNECT_EVENT; static void connect_execute_ok(TDS_POOL_EVENT *base_event); static void connect_execute_ko(TDS_POOL_EVENT *base_event); static TDS_THREAD_PROC_DECLARE(connect_proc, arg) { CONNECT_EVENT *ev = (CONNECT_EVENT *) arg; TDS_POOL_MEMBER *pmbr = ev->pmbr; TDS_POOL *pool = ev->pool; for (;;) { pmbr->sock.tds = pool_mbr_login(pool, ev->tds_version); if (!pmbr->sock.tds) { tdsdump_log(TDS_DBG_ERROR, "Error opening a new connection to server\n"); break; } if (!IS_TDS71_PLUS(pmbr->sock.tds->conn)) { tdsdump_log(TDS_DBG_ERROR, "Protocol server version not supported\n"); break; } /* if already attached to a user we can send login directly */ if (pmbr->current_user) if (!pool_user_send_login_ack(pool, pmbr->current_user)) break; pool_event_add(pool, &ev->common, connect_execute_ok); return NULL; } /* failure */ pool_event_add(pool, &ev->common, connect_execute_ko); return NULL; } static void connect_execute_ko(TDS_POOL_EVENT *base_event) { CONNECT_EVENT *ev = (CONNECT_EVENT *) base_event; pool_free_member(ev->pool, ev->pmbr); } static void connect_execute_ok(TDS_POOL_EVENT *base_event) { CONNECT_EVENT *ev = (CONNECT_EVENT *) base_event; TDS_POOL_MEMBER *pmbr = ev->pmbr; TDS_POOL_USER *puser = pmbr->current_user; ev->pool->member_logins++; pmbr->doing_async = false; pmbr->last_used_tm = time(NULL); if (puser) { pmbr->sock.poll_recv = true; puser->sock.poll_recv = true; puser->user_state = TDS_SRV_QUERY; } } /* * pool_assign_idle_member * assign a member to the user specified */ TDS_POOL_MEMBER * pool_assign_idle_member(TDS_POOL * pool, TDS_POOL_USER *puser) { TDS_POOL_MEMBER *pmbr; CONNECT_EVENT *ev; puser->sock.poll_recv = false; puser->sock.poll_send = false; DLIST_FOREACH(dlist_member, &pool->idle_members, pmbr) { assert(pmbr->current_user == NULL); assert(!pmbr->doing_async); assert(pmbr->sock.tds); if (!compatible_versions(pmbr->sock.tds, puser)) continue; pool_assign_member(pool, pmbr, puser); /* * make sure member wasn't idle more that the timeout * otherwise it'll send the query and close leaving a * hung client */ pmbr->last_used_tm = time(NULL); pmbr->sock.poll_recv = false; pmbr->sock.poll_send = false; pool_user_finish_login(pool, puser); return pmbr; } /* if we can open a new connection open it */ if (pool->num_active_members >= pool->max_open_conn) { fprintf(stderr, "No idle members left, increase \"max pool conn\"\n"); return NULL; } pmbr = tds_new0(TDS_POOL_MEMBER, 1); if (!pmbr) { fprintf(stderr, "Out of memory\n"); return NULL; } tdsdump_log(TDS_DBG_INFO1, "No open connections left, opening new member\n"); ev = tds_new0(CONNECT_EVENT, 1); if (!ev) { free(pmbr); fprintf(stderr, "Out of memory\n"); return NULL; } ev->pmbr = pmbr; ev->pool = pool; ev->tds_version = puser->login->tds_version; if (tds_thread_create_detached(connect_proc, ev) != 0) { free(pmbr); free(ev); fprintf(stderr, "error creating thread\n"); return NULL; } pmbr->doing_async = true; pool->num_active_members++; dlist_member_append(&pool->idle_members, pmbr); pool_assign_member(pool, pmbr, puser); puser->sock.poll_send = false; puser->sock.poll_recv = false; return pmbr; } freetds-1.00.82/src/pool/user.c100644 025423 025423 00000034617 12744631022 0011724/* TDSPool - Connection pooling for TDS based databases * Copyright (C) 2001, 2002, 2003, 2004, 2005 Brian Bruns * * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include #include #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #if HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #if HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #include "pool.h" #include #include static TDS_POOL_USER *pool_user_find_new(TDS_POOL * pool); static bool pool_user_login(TDS_POOL * pool, TDS_POOL_USER * puser); static bool pool_user_read(TDS_POOL * pool, TDS_POOL_USER * puser); static void login_execute(TDS_POOL_EVENT *base_event); static void end_login_execute(TDS_POOL_EVENT *base_event); void pool_user_init(TDS_POOL * pool) { dlist_user_init(&pool->users); dlist_user_init(&pool->waiters); pool->ctx = tds_alloc_context(NULL); } void pool_user_destroy(TDS_POOL * pool) { while (dlist_user_first(&pool->users)) pool_free_user(pool, dlist_user_first(&pool->users)); while (dlist_user_first(&pool->waiters)) pool_free_user(pool, dlist_user_first(&pool->waiters)); tds_free_context(pool->ctx); pool->ctx = NULL; } static TDS_POOL_USER * pool_user_find_new(TDS_POOL * pool) { TDS_POOL_USER *puser; /* did we exhaust the number of concurrent users? */ if (pool->num_users >= MAX_POOL_USERS) { fprintf(stderr, "Max concurrent users exceeded, increase in pool.h\n"); return NULL; } puser = tds_new0(TDS_POOL_USER, 1); if (!puser) { fprintf(stderr, "Out of memory\n"); return NULL; } dlist_user_append(&pool->users, puser); pool->num_users++; return puser; } typedef struct { TDS_POOL_EVENT common; TDS_POOL *pool; TDS_POOL_USER *puser; bool success; } LOGIN_EVENT; static TDS_THREAD_PROC_DECLARE(login_proc, arg) { LOGIN_EVENT *ev = (LOGIN_EVENT *) arg; ev->success = pool_user_login(ev->pool, ev->puser); pool_event_add(ev->pool, &ev->common, login_execute); return NULL; } static void login_execute(TDS_POOL_EVENT *base_event) { LOGIN_EVENT *ev = (LOGIN_EVENT *) base_event; TDS_POOL_USER *puser = ev->puser; TDS_POOL *pool = ev->pool; if (!ev->success) { /* login failed...free socket */ pool_free_user(pool, puser); return; } puser->sock.poll_recv = true; /* try to assign a member, connection can have transactions * and so on so deassign only when disconnected */ pool_user_query(pool, puser); tdsdump_log(TDS_DBG_INFO1, "user state %d\n", puser->user_state); assert(puser->login || puser->user_state == TDS_SRV_QUERY); } /* * pool_user_create * accepts a client connection and adds it to the users list and returns it */ TDS_POOL_USER * pool_user_create(TDS_POOL * pool, TDS_SYS_SOCKET s) { TDS_POOL_USER *puser; TDS_SYS_SOCKET fd; TDSSOCKET *tds; LOGIN_EVENT *ev; tdsdump_log(TDS_DBG_NETWORK, "accepting connection\n"); if (TDS_IS_SOCKET_INVALID(fd = tds_accept(s, NULL, NULL))) { char *errstr = sock_strerror(errno); tdsdump_log(TDS_DBG_ERROR, "error calling assert :%s\n", errstr); sock_strerror_free(errstr); return NULL; } if (tds_socket_set_nonblocking(fd) != 0) { CLOSESOCKET(fd); return NULL; } puser = pool_user_find_new(pool); if (!puser) { CLOSESOCKET(fd); return NULL; } tds = tds_alloc_socket(pool->ctx, BLOCKSIZ); if (!tds) { CLOSESOCKET(fd); return NULL; } ev = tds_new0(LOGIN_EVENT, 1); if (!ev || TDS_FAILED(tds_iconv_open(tds->conn, "UTF-8", 0))) { free(ev); tds_free_socket(tds); CLOSESOCKET(fd); return NULL; } /* FIX ME - little endian emulation should be config file driven */ tds->conn->emul_little_endian = 1; tds_set_s(tds, fd); tds->state = TDS_IDLE; tds->out_flag = TDS_LOGIN; puser->sock.tds = tds; puser->user_state = TDS_SRV_QUERY; puser->sock.poll_recv = false; puser->sock.poll_send = false; /* launch login asyncronously */ ev->puser = puser; ev->pool = pool; if (tds_thread_create_detached(login_proc, ev) != 0) { pool_free_user(pool, puser); fprintf(stderr, "error creating thread\n"); return NULL; } return puser; } /* * pool_free_user * close out a disconnected user. */ void pool_free_user(TDS_POOL *pool, TDS_POOL_USER * puser) { TDS_POOL_MEMBER *pmbr = puser->assigned_member; if (pmbr) { assert(pmbr->current_user == puser); pool_deassign_member(pool, pmbr); pool_reset_member(pool, pmbr); } tds_free_socket(puser->sock.tds); tds_free_login(puser->login); /* make sure to decrement the waiters list if he is waiting */ if (puser->user_state == TDS_SRV_WAIT) dlist_user_remove(&pool->waiters, puser); else dlist_user_remove(&pool->users, puser); pool->num_users--; free(puser); } /* * pool_process_users * check the fd_set for user input, allocate a pool member to it, and forward * the query to that member. */ void pool_process_users(TDS_POOL * pool, fd_set * rfds, fd_set * wfds) { TDS_POOL_USER *puser, *next; for (next = dlist_user_first(&pool->users); (puser = next) != NULL; ) { next = dlist_user_next(&pool->users, puser); if (!puser->sock.tds) continue; /* dead connection */ if (puser->sock.poll_recv && FD_ISSET(tds_get_s(puser->sock.tds), rfds)) { assert(puser->user_state == TDS_SRV_QUERY); if (!pool_user_read(pool, puser)) continue; } if (puser->sock.poll_send && FD_ISSET(tds_get_s(puser->sock.tds), wfds)) { if (!pool_write_data(&puser->assigned_member->sock, &puser->sock)) pool_free_member(pool, puser->assigned_member); } } /* for */ } /* * pool_user_login * Reads clients login packet and forges a login acknowledgement sequence */ static bool pool_user_login(TDS_POOL * pool, TDS_POOL_USER * puser) { TDSSOCKET *tds; TDSLOGIN *login; tds = puser->sock.tds; while (tds->in_len <= tds->in_pos) if (tds_read_packet(tds) < 0) return false; tdsdump_log(TDS_DBG_NETWORK, "got packet type %d\n", tds->in_flag); if (tds->in_flag == TDS71_PRELOGIN) { if (!tds->conn->tds_version) tds->conn->tds_version = 0x701; tds->out_flag = TDS_REPLY; // TODO proper one !! // TODO detect TDS version here ?? tds_put_n(tds, "\x00\x00\x1a\x00\x06" /* version */ "\x01\x00\x20\x00\x01" /* encryption */ "\x02\x00\x21\x00\x01" /* instance ?? */ "\x03\x00\x22\x00\x00" /* process id ?? */ "\x04\x00\x22\x00\x01" /* MARS */ "\xff" "\x0a\x00\x06\x40\x00\x00" "\x02" "\x01" "" "\x00", 0x23); tds_flush_packet(tds); /* read another packet */ tds->in_pos = tds->in_len; while (tds->in_len <= tds->in_pos) if (tds_read_packet(tds) < 0) return false; } puser->login = login = tds_alloc_login(1); if (tds->in_flag == TDS_LOGIN) { if (!tds->conn->tds_version) tds->conn->tds_version = 0x500; tds_read_login(tds, login); } else if (tds->in_flag == TDS7_LOGIN) { if (!tds->conn->tds_version) tds->conn->tds_version = 0x700; if (!tds7_read_login(tds, login)) return false; } else { return false; } /* check we support version required */ // TODO function to check it if (!IS_TDS71_PLUS(login)) return false; tds->in_len = tds->in_pos = 0; dump_login(login); if (strcmp(tds_dstr_cstr(&login->user_name), pool->user) != 0 || strcmp(tds_dstr_cstr(&login->password), pool->password) != 0) /* TODO send nack before exiting */ return false; return true; } bool pool_user_send_login_ack(TDS_POOL * pool, TDS_POOL_USER * puser) { char msg[256]; char block[32]; TDSSOCKET *tds = puser->sock.tds, *mtds = puser->assigned_member->sock.tds; TDSLOGIN *login = puser->login; const char *database; const char *server = mtds->conn->server ? mtds->conn->server : "JDBC"; bool dbname_mismatch, odbc_mismatch; pool->user_logins++; /* copy a bit of information, resize socket with block */ tds->conn->tds_version = mtds->conn->tds_version; tds->conn->product_version = mtds->conn->product_version; memcpy(tds->conn->collation, mtds->conn->collation, sizeof(tds->conn->collation)); tds->conn->tds71rev1 = mtds->conn->tds71rev1; free(tds->conn->product_name); tds->conn->product_name = strdup(mtds->conn->product_name); tds_realloc_socket(tds, mtds->conn->env.block_size); tds->conn->env.block_size = mtds->conn->env.block_size; tds->conn->client_spid = mtds->conn->spid; /* if database is different use USE statement */ database = pool->database; dbname_mismatch = !tds_dstr_isempty(&login->database) && strcasecmp(tds_dstr_cstr(&login->database), database) != 0; odbc_mismatch = (login->option_flag2 & TDS_ODBC_ON) == 0; if (dbname_mismatch || odbc_mismatch) { char *str; int len = 128 + tds_quote_id(mtds, NULL, tds_dstr_cstr(&login->database),-1); TDSRET ret; if ((str = tds_new(char, len)) == NULL) return false; str[0] = 0; /* swicth to dblib options */ if (odbc_mismatch) strcat(str, "SET ANSI_DEFAULTS OFF\nSET CONCAT_NULL_YIELDS_NULL OFF\n"); if (dbname_mismatch) { strcat(str, "USE "); tds_quote_id(mtds, strchr(str, 0), tds_dstr_cstr(&login->database), -1); } ret = tds_submit_query(mtds, str); free(str); if (TDS_FAILED(ret) || TDS_FAILED(tds_process_simple_query(mtds))) return false; if (dbname_mismatch) database = tds_dstr_cstr(&login->database); else database = mtds->conn->env.database; } // 7.0 // env database // database change message (with server name correct) // env language // language change message // env 0x3 charset ("iso_1") // env 0x5 lcid ("1033") // env 0x6 ("196609" ?? 0x30001) // loginack // env 0x4 packet size // done // // 7.1/7.2/7.3 // env database // database change message (with server name correct) // env 0x7 collation // env language // language change message // loginack // env 0x4 packet size // done tds->out_flag = TDS_REPLY; tds_env_change(tds, TDS_ENV_DATABASE, "master", database); sprintf(msg, "Changed database context to '%s'.", database); tds_send_msg(tds, 5701, 2, 0, msg, server, NULL, 1); if (!login->suppress_language) { tds_env_change(tds, TDS_ENV_LANG, NULL, "us_english"); tds_send_msg(tds, 5703, 1, 0, "Changed language setting to 'us_english'.", server, NULL, 1); } if (IS_TDS71_PLUS(tds->conn)) { tds_put_byte(tds, TDS_ENVCHANGE_TOKEN); tds_put_smallint(tds, 8); tds_put_byte(tds, TDS_ENV_SQLCOLLATION); tds_put_byte(tds, 5); tds_put_n(tds, tds->conn->collation, 5); tds_put_byte(tds, 0); } tds_send_login_ack(tds, mtds->conn->product_name); sprintf(block, "%d", tds->conn->env.block_size); tds_env_change(tds, TDS_ENV_PACKSIZE, block, block); /* tds_send_capabilities_token(tds); */ tds_send_done_token(tds, 0, 0); /* send it! */ tds_flush_packet(tds); tds_free_login(login); puser->login = NULL; return true; } /* * pool_user_read * checks the packet type of data coming from the client and allocates a * pool member if necessary. */ static bool pool_user_read(TDS_POOL * pool, TDS_POOL_USER * puser) { TDSSOCKET *tds = puser->sock.tds; TDS_POOL_MEMBER *pmbr = NULL; for (;;) { if (pool_packet_read(tds)) break; if (tds->in_len == 0) { tdsdump_log(TDS_DBG_INFO1, "user disconnected\n"); pool_free_user(pool, puser); return false; } else { TDS_UCHAR in_flag = tds->in_buf[0]; tdsdump_dump_buf(TDS_DBG_NETWORK, "Got packet from client:", tds->in_buf, tds->in_len); switch (in_flag) { case TDS_QUERY: case TDS_NORMAL: case TDS_RPC: case TDS_BULK: case TDS_CANCEL: case TDS7_TRANS: if (!pool_write_data(&puser->sock, &puser->assigned_member->sock)) { pool_reset_member(pool, puser->assigned_member); return false; } pmbr = puser->assigned_member; break; default: tdsdump_log(TDS_DBG_ERROR, "Unrecognized packet type, closing user\n"); pool_free_user(pool, puser); return false; } } if (tds->in_pos < tds->in_len) /* partial write, schedule a future write */ break; } if (pmbr && !pmbr->sock.poll_send) tds_socket_flush(tds_get_s(pmbr->sock.tds)); return true; } void pool_user_query(TDS_POOL * pool, TDS_POOL_USER * puser) { TDS_POOL_MEMBER *pmbr; tdsdump_log(TDS_DBG_FUNC, "pool_user_query\n"); assert(puser->assigned_member == NULL); assert(puser->login); puser->user_state = TDS_SRV_QUERY; pmbr = pool_assign_idle_member(pool, puser); if (!pmbr) { /* * put into wait state * check when member is deallocated */ tdsdump_log(TDS_DBG_INFO1, "Not enough free members...placing user in WAIT\n"); puser->user_state = TDS_SRV_WAIT; puser->sock.poll_recv = false; puser->sock.poll_send = false; dlist_user_remove(&pool->users, puser); dlist_user_append(&pool->waiters, puser); } } typedef struct { TDS_POOL_EVENT common; TDS_POOL *pool; TDS_POOL_USER *puser; bool success; } END_LOGIN_EVENT; static TDS_THREAD_PROC_DECLARE(end_login_proc, arg) { END_LOGIN_EVENT *ev = (END_LOGIN_EVENT *) arg; TDS_POOL *pool = ev->pool; ev->success = pool_user_send_login_ack(pool, ev->puser); pool_event_add(pool, &ev->common, end_login_execute); return NULL; } static void end_login_execute(TDS_POOL_EVENT *base_event) { END_LOGIN_EVENT *ev = (END_LOGIN_EVENT *) base_event; TDS_POOL *pool = ev->pool; TDS_POOL_USER *puser = ev->puser; TDS_POOL_MEMBER *pmbr = puser->assigned_member; if (!ev->success) { pool_free_member(pool, pmbr); return; } puser->sock.poll_recv = true; puser->sock.poll_send = false; pmbr->sock.poll_recv = true; pmbr->sock.poll_send = false; } /** * Handle async login */ void pool_user_finish_login(TDS_POOL * pool, TDS_POOL_USER * puser) { END_LOGIN_EVENT *ev = tds_new0(END_LOGIN_EVENT, 1); if (!ev) { pool_free_member(pool, puser->assigned_member); return; } ev->pool = pool; ev->puser = puser; if (tds_thread_create_detached(end_login_proc, ev) != 0) { pool_free_member(pool, puser->assigned_member); free(ev); fprintf(stderr, "error creating thread\n"); } } freetds-1.00.82/src/pool/util.c100644 025423 025423 00000011754 12744631022 0011720/* TDSPool - Connection pooling for TDS based databases * Copyright (C) 2001 Brian Bruns * * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #if HAVE_ERRNO_H #include #endif /* HAVE_ERRNO_H */ #include #include "pool.h" #include #include #include void dump_login(TDSLOGIN * login) { fprintf(stderr, "host %s\n", tds_dstr_cstr(&login->client_host_name)); fprintf(stderr, "user %s\n", tds_dstr_cstr(&login->user_name)); fprintf(stderr, "pass %s\n", tds_dstr_cstr(&login->password)); fprintf(stderr, "app %s\n", tds_dstr_cstr(&login->app_name)); fprintf(stderr, "srvr %s\n", tds_dstr_cstr(&login->server_name)); fprintf(stderr, "vers %d.%d\n", TDS_MAJOR(login), TDS_MINOR(login)); fprintf(stderr, "lib %s\n", tds_dstr_cstr(&login->library)); fprintf(stderr, "lang %s\n", tds_dstr_cstr(&login->language)); fprintf(stderr, "char %s\n", tds_dstr_cstr(&login->server_charset)); fprintf(stderr, "bsiz %d\n", login->block_size); } /** * Read part of packet. Function does not block. * @return true if packet is not complete and we must call again, * false on full packet or error. */ bool pool_packet_read(TDSSOCKET *tds) { int packet_len; int readed, err; tdsdump_log(TDS_DBG_INFO1, "tds in_len %d in_pos %d\n", tds->in_len, tds->in_pos); // TODO MARS /* determine packet size */ packet_len = tds->in_len >= 4 ? TDS_GET_A2BE(&tds->in_buf[2]) : 8; if (TDS_UNLIKELY(packet_len < 8)) { tds->in_len = 0; return false; } /* get another packet */ if (tds->in_len >= packet_len) { /* packet was not fully forwarded */ if (tds->in_pos < tds->in_len) return false; tds->in_pos = 0; tds->in_len = 0; } for (;;) { /* determine packet size */ packet_len = 8; if (tds->in_len >= 4) { packet_len = TDS_GET_A2BE(&tds->in_buf[2]); if (packet_len < 8) break; tdsdump_log(TDS_DBG_INFO1, "packet_len %d in_len %d\n", packet_len, tds->in_len); /* resize packet if not enough */ if (packet_len > tds->recv_packet->capacity) { TDSPACKET *packet; packet = tds_realloc_packet(tds->recv_packet, packet_len); if (!packet) break; tds->in_buf = packet->buf; tds->recv_packet = packet; } CHECK_TDS_EXTRA(tds); if (tds->in_len >= packet_len) return false; } assert(packet_len > tds->in_len); assert(packet_len <= tds->recv_packet->capacity); assert(tds->in_len < tds->recv_packet->capacity); readed = read(tds_get_s(tds), &tds->in_buf[tds->in_len], packet_len - tds->in_len); tdsdump_log(TDS_DBG_INFO1, "readed %d\n", readed); /* socket closed */ if (readed == 0) break; /* error */ if (readed < 0) { err = sock_errno; if (err == EINTR) continue; if (TDSSOCK_WOULDBLOCK(err)) return true; break; } /* got some data */ tds->in_len += readed; } /* failure */ tds->in_len = 0; return false; } int pool_write(TDS_SYS_SOCKET sock, const void *buf, size_t len) { int ret; const unsigned char *p = (const unsigned char *) buf; while (len) { ret = WRITESOCKET(sock, p, len); if (ret <= 0) { int err = errno; if (TDSSOCK_WOULDBLOCK(err) || err == EINTR) break; return -1; } p += ret; len -= ret; } return p - (const unsigned char *) buf; } void pool_event_add(TDS_POOL *pool, TDS_POOL_EVENT *ev, TDS_POOL_EXECUTE execute) { tds_mutex_lock(&pool->events_mtx); ev->execute = execute; ev->next = pool->events; pool->events = ev; tds_mutex_unlock(&pool->events_mtx); WRITESOCKET(pool->event_fd, "x", 1); } bool pool_write_data(TDS_POOL_SOCKET *from, TDS_POOL_SOCKET *to) { int ret; TDSSOCKET *tds; tdsdump_log(TDS_DBG_INFO1, "trying to send\n"); tds = from->tds; tdsdump_log(TDS_DBG_INFO1, "sending %d bytes\n", tds->in_len); /* cf. net.c for better technique. */ ret = pool_write(tds_get_s(to->tds), tds->in_buf + tds->in_pos, tds->in_len - tds->in_pos); /* write failed, cleanup member */ if (ret < 0) return false; tds->in_pos += ret; if (tds->in_pos < tds->in_len) { /* partial write, schedule a future write */ to->poll_send = true; from->poll_recv = false; } else { to->poll_send = false; from->poll_recv = true; } return true; } freetds-1.00.82/src/pool/pool.h100644 025423 025423 00000010573 12717145107 0011723/* TDSPool - Connection pooling for TDS based databases * Copyright (C) 2001 Brian Bruns * * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ifndef _pool_h_ #define _pool_h_ #include #if HAVE_SYS_TYPES_H #include #endif #if HAVE_NETINET_IN_H #include #endif /* * POSIX says fd_set type may be defined in either sys/select.h or sys/time.h. */ #if HAVE_SYS_TIME_H #include #endif #include #include /* defines */ #define PGSIZ 2048 #define BLOCKSIZ 512 #define MAX_POOL_USERS 1024 /* enums and typedefs */ typedef enum { TDS_SRV_WAIT, /* if no members are free wait */ TDS_SRV_QUERY, } TDS_USER_STATE; /* forward declaration */ typedef struct tds_pool_event TDS_POOL_EVENT; typedef struct tds_pool_socket TDS_POOL_SOCKET; typedef struct tds_pool_member TDS_POOL_MEMBER; typedef struct tds_pool_user TDS_POOL_USER; typedef struct tds_pool TDS_POOL; typedef void (*TDS_POOL_EXECUTE)(TDS_POOL_EVENT *event); struct tds_pool_event { TDS_POOL_EVENT *next; TDS_POOL_EXECUTE execute; }; struct tds_pool_socket { TDSSOCKET *tds; bool poll_recv; bool poll_send; }; struct tds_pool_user { TDS_POOL_SOCKET sock; DLIST_FIELDS(dlist_user_item); TDSLOGIN *login; TDS_USER_STATE user_state; TDS_POOL_MEMBER *assigned_member; }; struct tds_pool_member { TDS_POOL_SOCKET sock; DLIST_FIELDS(dlist_member_item); bool doing_async; time_t last_used_tm; TDS_POOL_USER *current_user; }; #define DLIST_NAME(suffix) dlist_member_ ## suffix #define DLIST_LIST_TYPE dlist_members #define DLIST_TYPE TDS_POOL_MEMBER #include #define DLIST_NAME(suffix) dlist_user_ ## suffix #define DLIST_LIST_TYPE dlist_users #define DLIST_TYPE TDS_POOL_USER #include struct tds_pool { char *name; char *user; char *password; char *server; char *database; int port; int max_member_age; /* in seconds */ int min_open_conn; int max_open_conn; tds_mutex events_mtx; TDS_SYS_SOCKET listen_fd; TDS_SYS_SOCKET wakeup_fd; TDS_SYS_SOCKET event_fd; TDS_POOL_EVENT *events; int num_active_members; dlist_members active_members; dlist_members idle_members; /** users in wait state */ dlist_users waiters; int num_users; dlist_users users; TDSCONTEXT *ctx; unsigned long user_logins; unsigned long member_logins; }; /* prototypes */ /* member.c */ void pool_process_members(TDS_POOL * pool, fd_set * rfds, fd_set * wfds); TDS_POOL_MEMBER *pool_assign_idle_member(TDS_POOL * pool, TDS_POOL_USER *user); void pool_mbr_init(TDS_POOL * pool); void pool_mbr_destroy(TDS_POOL * pool); void pool_free_member(TDS_POOL *pool, TDS_POOL_MEMBER * pmbr); void pool_assign_member(TDS_POOL *pool, TDS_POOL_MEMBER * pmbr, TDS_POOL_USER *puser); void pool_deassign_member(TDS_POOL *pool, TDS_POOL_MEMBER * pmbr); void pool_reset_member(TDS_POOL *pool, TDS_POOL_MEMBER * pmbr); bool pool_packet_read(TDSSOCKET * tds); /* user.c */ void pool_process_users(TDS_POOL * pool, fd_set * rfds, fd_set * wfds); void pool_user_init(TDS_POOL * pool); void pool_user_destroy(TDS_POOL * pool); TDS_POOL_USER *pool_user_create(TDS_POOL * pool, TDS_SYS_SOCKET s); void pool_free_user(TDS_POOL * pool, TDS_POOL_USER * puser); void pool_user_query(TDS_POOL * pool, TDS_POOL_USER * puser); bool pool_user_send_login_ack(TDS_POOL * pool, TDS_POOL_USER * puser); void pool_user_finish_login(TDS_POOL * pool, TDS_POOL_USER * puser); /* util.c */ void dump_login(TDSLOGIN * login); void pool_event_add(TDS_POOL *pool, TDS_POOL_EVENT *ev, TDS_POOL_EXECUTE execute); int pool_write(TDS_SYS_SOCKET sock, const void *buf, size_t len); bool pool_write_data(TDS_POOL_SOCKET *from, TDS_POOL_SOCKET *to); /* config.c */ int pool_read_conf_file(const char *poolname, TDS_POOL * pool, char **err); #endif freetds-1.00.82/src/pool/BUGS100644 025423 025423 00000000157 12522201763 0011254Need to handle results larger than 1 packet. fixed 11/18/00 Disconnect doesn't leave the FDSET. fixed 11/18/00 freetds-1.00.82/src/pool/pool.conf100644 025423 025423 00000000333 12522201763 0012405[global] min pool conn = 5 max pool conn = 10 max member age = 120 [mypool] user = guest password = sybase database = tempdb server = JDBC_42 port = 5000 freetds-1.00.82/src/apps/Makefile.am100644 025423 025423 00000002144 13203773221 0012615# $Id: Makefile.am,v 1.31 2011-06-08 09:25:51 freddy77 Exp $ AM_CPPFLAGS = -I$(top_srcdir)/include SUBDIRS = fisql DIST_SUBDIRS = $(SUBDIRS) bin_PROGRAMS = tsql freebcp bsqldb defncopy datacopy # build bsqlodbc only if the ODBC library was to be built if ODBC bin_PROGRAMS += bsqlodbc endif dist_bin_SCRIPTS = osql freebcp_LDADD = ../dblib/libsybdb.la ../replacements/libreplacements.la $(LTLIBICONV) freebcp_SOURCES = freebcp.c freebcp.h tsql_LDADD = ../tds/libtds.la \ ../replacements/libreplacements.la \ $(FREETDS_LIBGCC) $(LTLIBICONV) $(READLINE_LIBS) $(NETWORK_LIBS) bsqldb_LDADD = ../dblib/libsybdb.la \ ../replacements/libreplacements.la \ $(LTLIBICONV) if ODBC bsqlodbc_CPPFLAGS = $(ODBC_INC) $(AM_CPPFLAGS) bsqlodbc_LDADD = $(ODBCLIB) $(ODBCNODMLIBAPP) \ ../replacements/libreplacements.la $(LTLIBICONV) $(NETWORK_LIBS) endif defncopy_LDADD = ../dblib/libsybdb.la \ ../replacements/libreplacements.la \ $(LTLIBICONV) datacopy_SOURCES= datacopy.c datacopy_LDADD = ../dblib/libsybdb.la \ ../replacements/libreplacements.la \ $(LTLIBICONV) EXTRA_DIST = CMakeLists.txt freetds-1.00.82/src/apps/osql100755 025423 025423 00000022230 12717145107 0011470#! /bin/sh # $Id: osql,v 1.12 2011-05-11 03:08:13 jklowden Exp $ # # Check odbc.ini, odbcinst, and, optionally, freetds.conf, # then execute isql (assume it's unixODBC's isql). # USAGE="Syntax: $(basename $0) -S server -U user -P password" while getopts I:S:U:P: OPTION do case ${OPTION} in I) OVER_DIR=${OPTARG} # override ;; S) DSN=${OPTARG} ;; U) USERNAME=${OPTARG} ;; P) PASSWORD=${OPTARG} ;; \?) echo $USAGE exit 1 ;; esac done #cho ${DSN} ${USERNAME} ${PASSWORD} if [ -z "${DSN}" -o -z "${USERNAME}" -o -z "${PASSWORD}" ] then echo $USAGE exit 1 fi ISQL=$(command -v isql) if [ -z "${ISQL}" ] then echo "$(basename $0): error: no \"isql\" command found. Is unixODBC installed?" exit 1 fi # Establish ODBC prefix directory ISQL_DIR=$(strings ${ISQL} | grep ^/ | grep -v elf | grep -v '\.so\.' | head -1 | sed 's/lib$/etc/' ) INI_DIRNAME="/tmp/$(basename $0).$$" exec 3> ${INI_DIRNAME} # Check the libraries, too. if [ -z "${OVER_DIR}" ] then echo "checking shared odbc libraries linked to isql for default directories..." (echo ${ISQL_DIR}; ldd "${ISQL}" | awk '/libodbc\./ {print $3}') \ | while read L do strings "$L" | grep '^/' | grep -v '/lib' \ | while read D do if [ ! -s "${INI_DIRNAME}" ] then printf " trying $D ... " if [ -d "$D" -a -r "${D}/odbc.ini" ] then printf $D >&3 printf "OK" else printf "no" fi printf "\n" fi done done fi ODBC_DIR=$(cat ${INI_DIRNAME}) && rm ${INI_DIRNAME} if [ -z "${ODBC_DIR}" -a -z "${OVER_DIR}" ] then echo "$(basename $0): problem: no potential directory strings in \"$(command -v isql)\"" echo "$(basename $0): advice: use \"osql -I DIR\" where DIR unixODBC\'s install prefix e.g. /usr/local" echo "isql strings are:" strings ${ISQL} | grep ^/ | sed 's/^/+ /' #xit 1 fi if [ "${OVER_DIR}" ] then if [ -d "${ODBC_DIR}" ] then echo "\"${ODBC_DIR}\" is a directory, overridden by" else echo "\"${ODBC_DIR}\" is NOT a directory, overridden by" fi echo "\"${OVER_DIR}\"." if [ -d "${OVER_DIR}" ] then ODBC_DIR=${OVER_DIR} else echo "$(basename $0): error: \"${OVER_DIR}\" is not a directory" exit 1 fi fi # Look for server entry in odbc.ini echo 'checking odbc.ini files' for F in "${HOME}/.odbc.ini" "${ODBC_DIR}/odbc.ini" do if [ ! -d "$(dirname $F)" ] then echo "warning: $(dirname $F) is not a directory" continue fi if [ -r "$F" ] then echo " reading $F" else echo " cannot read \"$F\"" continue fi grep -F "[${DSN}]" $F > /dev/null if [ $? -eq 0 ] then echo "[${DSN}] found in $F" ODBC_INI=$F break else echo "[${DSN}] not found in $F" fi done if [ -z "${ODBC_INI}" ] then echo "$(basename $0): error: unable to locate ${DSN} in any odbc.ini" exit 1 fi # Report finding of server entry echo found this section: SED_CMD="/^\[${DSN}\]/,/^[[:space:]]*$/ { s/^/ /; p; }" sed -ne "${SED_CMD}" ${ODBC_INI} # # Examine server entry in odbc.ini # # Find the driver in the servername or default section for D in "${DSN}" 'default' do echo "looking for driver for DSN [$D] in ${ODBC_INI}" grep "$D" ${ODBC_INI} > /dev/null if [ $? -eq 0 ] then CMD="/^\[$D\]/,/^[[:space:]]*$/ { s/^/ /; p; }" DRIVER_LINE=$(sed -ne "${CMD}" ${ODBC_INI} \ | grep -Ei '^[[:space:]]*driver[[:space:]]*=') if [ -z "${DRIVER_LINE}" ] then echo " no driver mentioned for [$D] in $(basename ${ODBC_INI})" continue fi echo " found driver line: \"${DRIVER_LINE}\"" DRIVER=$(echo ${DRIVER_LINE} \ | awk -F ' *= *' '{print $2}' \ | sed 's/[[:space:]][[:space:]]*//g') if [ "${DRIVER}" ] then echo " driver \"${DRIVER}\" found for [$D] in $(basename ${ODBC_INI})" break else echo " driver line for [$D] incomplete in $(basename ${ODBC_INI})" continue fi fi done if [ -z "${DRIVER}" ] then echo "$(basename $0): error: no driver found for [${DSN}] in $(basename ${ODBC_INI})" exit 1 fi # get filename of driver echo found driver named \"${DRIVER}\" if [ -d "${DRIVER}" -o ! -x "${DRIVER}" ] then # not a filename, look it up DRIVERNAME=${DRIVER} ODBC_INST="${ODBC_DIR}/odbcinst.ini" echo "\"${DRIVERNAME}\" is not an executable file" echo "looking for entry named [${DRIVERNAME}] in ${ODBC_INST}" grep "${DRIVERNAME}" ${ODBC_INST} > /dev/null if [ $? -ne 0 ] then if [ $? -eq 1 ] then echo "$(basename $0): error: no driver entry [${DRIVERNAME}] in ${ODBC_INST}" fi exit 1; fi CMD="/^\[${DRIVERNAME}\]/,/^[[:space:]]*$/ { s/^/ /; p; }" DRIVER_LINE=$(sed -ne "${CMD}" ${ODBC_INST} \ | grep -Ei '^[[:space:]]*driver[[:space:]]*=') if [ -z "${DRIVER_LINE}" ] then echo "$(basename $0): no driver mentioned for [${DRIVERNAME}] in $(basename ${ODBC_INST})" exit 1 fi echo " found driver line: \"${DRIVER_LINE}\"" DRIVER=$(echo ${DRIVER_LINE} | awk -F ' *= *' '{print $2}') if [ -z "${DRIVER}" ] then echo "$(basename $0): driver line incomplete for [${DRIVERNAME}] in $(basename ${ODBC_INST})" exit 1 fi echo " found driver ${DRIVER} for [${DRIVERNAME}] in $(basename ${ODBC_INST})" fi if [ -z "${DRIVER}" ] then echo $(basename $0): 'error: sorry, failed sanity check: ${DRIVER} is null' exit 1 fi if [ -x "${DRIVER}" ] then echo "${DRIVER} is an executable file" else echo "${DRIVER} is not an executable file" echo "$(basename $0): error: no driver found for ${DSN}" exit 1 fi # find the server/servername SERVER_LINE=$(sed -ne "${SED_CMD}" ${ODBC_INI} \ | grep -Ei '^[[:space:]]*server(name)*[[:space:]]*=') ATTRIBUTE=$(echo ${SERVER_LINE} | awk -F' *= *' '{print $1}') if [ -z "${ATTRIBUTE}" ] then echo "$(basename $0): neither \"Server\" nor \"Servername\" found for [${DSN}] in $(basename ${ODBC_INI})" exit 1 fi echo ${SERVER_LINE} | grep -i servername >/dev/null # # Find the server's hostname # if [ $? -eq 0 ] # ODBC-Combined then TDS_SERVER=$(echo ${SERVER_LINE} | awk -F ' *= *' '{print $2}') echo 'Using ODBC-Combined strategy' echo "DSN [${DSN}] has servername \"${TDS_SERVER}\" (from ${ODBC_INI})" if [ -z "${TDS_SERVER}" ] then exit 1 fi # Look for $TDS_SERVER in freetds.conf FREETDS_DIR=$(tsql -C | grep 'freetds.conf directory' | awk -F: '{print $2}' | sed 's/^ *//') if [ -z "${FREETDS_DIR}" ] then echo "$(basename $0): error: unable to locate directory for freetds.conf using \"$(command -v tsql)\"" exit 1 fi for F in "${HOME}/.freetds.conf" "${FREETDS_DIR}/freetds.conf" do if [ -r "$F" ] then echo $F is a readable file else echo cannot read \"$F\" continue fi echo "looking for [${TDS_SERVER}] in $F" grep -F "[${TDS_SERVER}]" $F > /dev/null if [ $? -eq 0 ] then FREETDS_CONF=$F break else echo "[${TDS_SERVER}]" not found in $F fi done if [ -z "${FREETDS_CONF}" ] then echo "$(basename $0): error: unable to locate ${TDS_SERVER} in any freetds.conf" exit 1 fi # Examine server entry in freetds.conf echo found this section: SED_CMD="/^\[${TDS_SERVER}\]/,/^[[:space:]]*$/ { s/^/ /; p; }" sed -ne "${SED_CMD}" ${FREETDS_CONF} SERVER_LINE=$(sed -ne "${SED_CMD}" ${FREETDS_CONF} \ | grep -Ei '^[[:space:]]*host[[:space:]]*=') # No character class support in mawk, # cf. "Mawk does not support Posix character classes in expressions" # https://bugs.launchpad.net/ubuntu/+source/mawk/+bug/69724 HOST=$(echo ${SERVER_LINE} | awk -F' *= *' '{print $2}') if [ -z "${HOST}" ] then echo "$(basename $0): no \"host\" entry found for [${TDS_SERVER}] in $(basename ${FREETDS_CONF})" exit 1 fi else # odbc.ini contains a "server", a DNS host HOST=$(echo ${SERVER_LINE} | awk -F ' *= *' '{print $2}') echo "\"${ATTRIBUTE}\" found, not using freetds.conf" echo "${ATTRIBUTE} is \"${HOST}\"" if [ -z "${HOST}" ] then echo "$(basename $0): no value found for \"${ATTRIBUTE}\" entry in $(basename ${ODBC_INI})" exit 1 fi fi # If the "host" is an ip address, look up the name, for neatness, e.g. ## $ host 10.81.36.39 ## 39.36.81.10.IN-ADDR.ARPA domain name pointer ntc5003.eg.com if [ "${HOST}" = "$(echo ${HOST} | sed 's/[^.0-9]*//')" ] then ADDRESS=${HOST} echo 'looking up hostname for ip address' ${ADDRESS} HOST=$(host ${HOST} | awk '/domain/ {print $5}' | sed 's/\.$//') if [ -z "${HOST}" ] then echo "$(basename $0): warning: no DNS hostname found for \"${ADDRESS}\"" HOST=${ADDRESS} # restore host address string fi fi # Now we have a DNS hostname for the server in HOST if [ "${HOST}" != "${ADDRESS}" ] then ADDRESS=$(host ${HOST} | awk '/has address/ {print $4}' | head -1) fi if [ -z "${ADDRESS}" ] then echo "$(basename $0): no IP address found for \"${HOST}\"" exit 1 fi #cho ${HOST} has address ${ADDRESS} # Report what we know and exec isql printf "\n" printf "Configuration looks OK. Connection details:\n\n" printf "%22s:\t%-30s\n" DSN ${DSN} printf "%22s:\t%-30s\n" odbc.ini "${ODBC_INI}" printf "%22s:\t%-30s\n" Driver ${DRIVER} printf "%22s:\t%-30s\n" "Server hostname" ${HOST} printf "%22s:\t%-30s\n" Address ${ADDRESS} printf "\n" echo Attempting connection as ${USERNAME} ... if [ -z "${TDSDUMP}" ] then TDSDUMP_AUTO="/tmp/$(basename $0).dump.$$" export TDSDUMP=${TDSDUMP_AUTO} fi ( set -x; isql ${DSN} ${USERNAME} ${PASSWORD} -v ) \ || sed -ne 's/Connecting/FAILED &/p' ${TDSDUMP} test "${TDSDUMP_AUTO}" && rm -f ${TDSDUMP_AUTO} freetds-1.00.82/src/apps/Makefile.in100644 025423 025423 00000103166 13242511110 0012622# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # $Id: Makefile.am,v 1.31 2011-06-08 09:25:51 freddy77 Exp $ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ bin_PROGRAMS = tsql$(EXEEXT) freebcp$(EXEEXT) bsqldb$(EXEEXT) \ defncopy$(EXEEXT) datacopy$(EXEEXT) $(am__EXEEXT_1) # build bsqlodbc only if the ODBC library was to be built @ODBC_TRUE@am__append_1 = bsqlodbc subdir = src/apps ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = \ $(top_srcdir)/m4/ac_caolan_func_which_gethostbyname_r.m4 \ $(top_srcdir)/m4/ac_have_inaddr_none.m4 \ $(top_srcdir)/m4/ac_have_malloc_options.m4 \ $(top_srcdir)/m4/ac_nullzero.m4 \ $(top_srcdir)/m4/ac_raf_func_which_getservbyname_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_gethostbyaddr_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_getpwuid_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_localtime_r.m4 \ $(top_srcdir)/m4/acx_pthread.m4 \ $(top_srcdir)/m4/ax_cflags_gcc_option.m4 \ $(top_srcdir)/m4/check_openssl.m4 \ $(top_srcdir)/m4/gettimemilli.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/pushlibs.m4 \ $(top_srcdir)/m4/sprintf_i64_format.m4 \ $(top_srcdir)/m4/type_socklen_t.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(dist_bin_SCRIPTS) \ $(am__DIST_COMMON) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = @ODBC_TRUE@am__EXEEXT_1 = bsqlodbc$(EXEEXT) am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)" PROGRAMS = $(bin_PROGRAMS) bsqldb_SOURCES = bsqldb.c bsqldb_OBJECTS = bsqldb.$(OBJEXT) am__DEPENDENCIES_1 = bsqldb_DEPENDENCIES = ../dblib/libsybdb.la \ ../replacements/libreplacements.la $(am__DEPENDENCIES_1) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = bsqlodbc_SOURCES = bsqlodbc.c bsqlodbc_OBJECTS = bsqlodbc-bsqlodbc.$(OBJEXT) @ODBC_TRUE@bsqlodbc_DEPENDENCIES = $(am__DEPENDENCIES_1) \ @ODBC_TRUE@ $(am__DEPENDENCIES_1) \ @ODBC_TRUE@ ../replacements/libreplacements.la \ @ODBC_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am_datacopy_OBJECTS = datacopy.$(OBJEXT) datacopy_OBJECTS = $(am_datacopy_OBJECTS) datacopy_DEPENDENCIES = ../dblib/libsybdb.la \ ../replacements/libreplacements.la $(am__DEPENDENCIES_1) defncopy_SOURCES = defncopy.c defncopy_OBJECTS = defncopy.$(OBJEXT) defncopy_DEPENDENCIES = ../dblib/libsybdb.la \ ../replacements/libreplacements.la $(am__DEPENDENCIES_1) am_freebcp_OBJECTS = freebcp.$(OBJEXT) freebcp_OBJECTS = $(am_freebcp_OBJECTS) freebcp_DEPENDENCIES = ../dblib/libsybdb.la \ ../replacements/libreplacements.la $(am__DEPENDENCIES_1) tsql_SOURCES = tsql.c tsql_OBJECTS = tsql.$(OBJEXT) tsql_DEPENDENCIES = ../tds/libtds.la \ ../replacements/libreplacements.la $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } SCRIPTS = $(dist_bin_SCRIPTS) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = bsqldb.c bsqlodbc.c $(datacopy_SOURCES) defncopy.c \ $(freebcp_SOURCES) tsql.c DIST_SOURCES = bsqldb.c bsqlodbc.c $(datacopy_SOURCES) defncopy.c \ $(freebcp_SOURCES) tsql.c RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp \ $(top_srcdir)/mkinstalldirs DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BUILD_NUMBER = @BUILD_NUMBER@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOXYGEN = @DOXYGEN@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FREETDS_LIBGCC = @FREETDS_LIBGCC@ FREETDS_ODBC_MODULE = @FREETDS_ODBC_MODULE@ FREETDS_SYMBOLIC = @FREETDS_SYMBOLIC@ GCRYPT_CFLAGS = @GCRYPT_CFLAGS@ GCRYPT_LIBS = @GCRYPT_LIBS@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ HAVE_OPENSSL = @HAVE_OPENSSL@ HAVE_PERL_SOURCES = @HAVE_PERL_SOURCES@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBADD_DL = @LIBADD_DL@ LIBADD_DLD_LINK = @LIBADD_DLD_LINK@ LIBADD_DLOPEN = @LIBADD_DLOPEN@ LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@ LIBICONV = @LIBICONV@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBOBJS = @LTLIBOBJS@ LT_DLLOADERS = @LT_DLLOADERS@ LT_DLPREOPEN = @LT_DLPREOPEN@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ NETTLE_CFLAGS = @NETTLE_CFLAGS@ NETTLE_LIBS = @NETTLE_LIBS@ NETWORK_LIBS = @NETWORK_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ODBC = @ODBC@ ODBCINSTLIB = @ODBCINSTLIB@ ODBCLIB = @ODBCLIB@ ODBCNODMLIB = @ODBCNODMLIB@ ODBCNODMLIBAPP = @ODBCNODMLIBAPP@ ODBC_CONFIG = @ODBC_CONFIG@ ODBC_INC = @ODBC_INC@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ RC = @RC@ READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SUBVERSION = @SUBVERSION@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ dblib_define = @dblib_define@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ tds_sysdep_int16_type = @tds_sysdep_int16_type@ tds_sysdep_int32_type = @tds_sysdep_int32_type@ tds_sysdep_int64_type = @tds_sysdep_int64_type@ tds_sysdep_intptr_type = @tds_sysdep_intptr_type@ tds_sysdep_real32_type = @tds_sysdep_real32_type@ tds_sysdep_real64_type = @tds_sysdep_real64_type@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = -I$(top_srcdir)/include SUBDIRS = fisql DIST_SUBDIRS = $(SUBDIRS) dist_bin_SCRIPTS = osql freebcp_LDADD = ../dblib/libsybdb.la ../replacements/libreplacements.la $(LTLIBICONV) freebcp_SOURCES = freebcp.c freebcp.h tsql_LDADD = ../tds/libtds.la \ ../replacements/libreplacements.la \ $(FREETDS_LIBGCC) $(LTLIBICONV) $(READLINE_LIBS) $(NETWORK_LIBS) bsqldb_LDADD = ../dblib/libsybdb.la \ ../replacements/libreplacements.la \ $(LTLIBICONV) @ODBC_TRUE@bsqlodbc_CPPFLAGS = $(ODBC_INC) $(AM_CPPFLAGS) @ODBC_TRUE@bsqlodbc_LDADD = $(ODBCLIB) $(ODBCNODMLIBAPP) \ @ODBC_TRUE@ ../replacements/libreplacements.la $(LTLIBICONV) $(NETWORK_LIBS) defncopy_LDADD = ../dblib/libsybdb.la \ ../replacements/libreplacements.la \ $(LTLIBICONV) datacopy_SOURCES = datacopy.c datacopy_LDADD = ../dblib/libsybdb.la \ ../replacements/libreplacements.la \ $(LTLIBICONV) EXTRA_DIST = CMakeLists.txt all: all-recursive .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/apps/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/apps/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ fi; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p \ || test -f $$p1 \ ; then echo "$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n;h' \ -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) files[d] = files[d] " " $$1; \ else { print "f", $$3 "/" $$4, $$1; } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ } \ ; done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ -e 's/$$/$(EXEEXT)/' \ `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(bindir)" && rm -f $$files clean-binPROGRAMS: @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list bsqldb$(EXEEXT): $(bsqldb_OBJECTS) $(bsqldb_DEPENDENCIES) $(EXTRA_bsqldb_DEPENDENCIES) @rm -f bsqldb$(EXEEXT) $(AM_V_CCLD)$(LINK) $(bsqldb_OBJECTS) $(bsqldb_LDADD) $(LIBS) bsqlodbc$(EXEEXT): $(bsqlodbc_OBJECTS) $(bsqlodbc_DEPENDENCIES) $(EXTRA_bsqlodbc_DEPENDENCIES) @rm -f bsqlodbc$(EXEEXT) $(AM_V_CCLD)$(LINK) $(bsqlodbc_OBJECTS) $(bsqlodbc_LDADD) $(LIBS) datacopy$(EXEEXT): $(datacopy_OBJECTS) $(datacopy_DEPENDENCIES) $(EXTRA_datacopy_DEPENDENCIES) @rm -f datacopy$(EXEEXT) $(AM_V_CCLD)$(LINK) $(datacopy_OBJECTS) $(datacopy_LDADD) $(LIBS) defncopy$(EXEEXT): $(defncopy_OBJECTS) $(defncopy_DEPENDENCIES) $(EXTRA_defncopy_DEPENDENCIES) @rm -f defncopy$(EXEEXT) $(AM_V_CCLD)$(LINK) $(defncopy_OBJECTS) $(defncopy_LDADD) $(LIBS) freebcp$(EXEEXT): $(freebcp_OBJECTS) $(freebcp_DEPENDENCIES) $(EXTRA_freebcp_DEPENDENCIES) @rm -f freebcp$(EXEEXT) $(AM_V_CCLD)$(LINK) $(freebcp_OBJECTS) $(freebcp_LDADD) $(LIBS) tsql$(EXEEXT): $(tsql_OBJECTS) $(tsql_DEPENDENCIES) $(EXTRA_tsql_DEPENDENCIES) @rm -f tsql$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tsql_OBJECTS) $(tsql_LDADD) $(LIBS) install-dist_binSCRIPTS: $(dist_bin_SCRIPTS) @$(NORMAL_INSTALL) @list='$(dist_bin_SCRIPTS)'; test -n "$(bindir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n' \ -e 'h;s|.*|.|' \ -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) { files[d] = files[d] " " $$1; \ if (++n[d] == $(am__install_max)) { \ print "f", d, files[d]; n[d] = 0; files[d] = "" } } \ else { print "f", d "/" $$4, $$1 } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(bindir)$$dir'"; \ $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ } \ ; done uninstall-dist_binSCRIPTS: @$(NORMAL_UNINSTALL) @list='$(dist_bin_SCRIPTS)'; test -n "$(bindir)" || exit 0; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 's,.*/,,;$(transform)'`; \ dir='$(DESTDIR)$(bindir)'; $(am__uninstall_files_from_dir) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bsqldb.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bsqlodbc-bsqlodbc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/datacopy.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/defncopy.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/freebcp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tsql.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< bsqlodbc-bsqlodbc.o: bsqlodbc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bsqlodbc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT bsqlodbc-bsqlodbc.o -MD -MP -MF $(DEPDIR)/bsqlodbc-bsqlodbc.Tpo -c -o bsqlodbc-bsqlodbc.o `test -f 'bsqlodbc.c' || echo '$(srcdir)/'`bsqlodbc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/bsqlodbc-bsqlodbc.Tpo $(DEPDIR)/bsqlodbc-bsqlodbc.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bsqlodbc.c' object='bsqlodbc-bsqlodbc.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bsqlodbc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o bsqlodbc-bsqlodbc.o `test -f 'bsqlodbc.c' || echo '$(srcdir)/'`bsqlodbc.c bsqlodbc-bsqlodbc.obj: bsqlodbc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bsqlodbc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT bsqlodbc-bsqlodbc.obj -MD -MP -MF $(DEPDIR)/bsqlodbc-bsqlodbc.Tpo -c -o bsqlodbc-bsqlodbc.obj `if test -f 'bsqlodbc.c'; then $(CYGPATH_W) 'bsqlodbc.c'; else $(CYGPATH_W) '$(srcdir)/bsqlodbc.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/bsqlodbc-bsqlodbc.Tpo $(DEPDIR)/bsqlodbc-bsqlodbc.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='bsqlodbc.c' object='bsqlodbc-bsqlodbc.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(bsqlodbc_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o bsqlodbc-bsqlodbc.obj `if test -f 'bsqlodbc.c'; then $(CYGPATH_W) 'bsqlodbc.c'; else $(CYGPATH_W) '$(srcdir)/bsqlodbc.c'; fi` mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile $(PROGRAMS) $(SCRIPTS) installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am distclean: distclean-recursive -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-binPROGRAMS install-dist_binSCRIPTS install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-binPROGRAMS uninstall-dist_binSCRIPTS .MAKE: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-binPROGRAMS clean-generic clean-libtool \ cscopelist-am ctags ctags-am distclean distclean-compile \ distclean-generic distclean-libtool distclean-tags distdir dvi \ dvi-am html html-am info info-am install install-am \ install-binPROGRAMS install-data install-data-am \ install-dist_binSCRIPTS 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-ps install-ps-am install-strip \ installcheck installcheck-am installdirs installdirs-am \ 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-binPROGRAMS uninstall-dist_binSCRIPTS .PRECIOUS: Makefile # 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: freetds-1.00.82/src/apps/bsqldb.c100644 025423 025423 00000074726 13167106021 0012210/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2004-2009 James K. Lowden * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #undef NDEBUG #include #include #include #include #if HAVE_ERRNO_H #include #endif #if HAVE_UNISTD_H #include #endif #if HAVE_STDLIB_H #include #endif #if HAVE_STRING_H #include #endif #if HAVE_LIMITS_H #include #endif #if HAVE_LOCALE_H #include #endif #include #include #include "replacements.h" #include #ifdef _WIN32 #define NULL_DEVICE "NUL:" #else #define NULL_DEVICE "/dev/null" #endif int err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr); int msg_handler(DBPROCESS * dbproc, DBINT msgno, int msgstate, int severity, char *msgtext, char *srvname, char *procname, int line); static int next_query(DBPROCESS *dbproc); static void print_results(DBPROCESS *dbproc); static int get_printable_size(int type, int size); static void usage(const char invoked_as[]); struct METADATA { char *name, *format_string; const char *source; int type, size, width; }; struct DATA { char *buffer; int status; }; struct METACOMP { int numalts; struct METADATA *meta; struct DATA *data; }; static int set_format_string(struct METADATA * meta, const char separator[]); typedef struct KEY_T { size_t nkeys; int *keys; } KEY_T; typedef struct _options { int fverbose, fquiet; FILE *headers, *verbose; char *servername, *database, *appname, hostname[128]; const char *colsep; char *input_filename, *output_filename, *error_filename; struct pivot_t { KEY_T row_key, col_key; int val_col; DBPIVOT_FUNC func; } pivot; } OPTIONS; static void parse_pivot_description(OPTIONS *options, const char *optarg); LOGINREC* get_login(int argc, char *argv[], OPTIONS *poptions); /* global variables */ OPTIONS options; static const char default_colsep[] = " "; /* end global variables */ /** * The purpose of this program is threefold: * * 1. To provide a generalized SQL processor suitable for testing db-lib. * 2. To offer a robust batch-oriented SQL processor suitable for use in a production environment. * 3. To serve as a model example of how to use db-lib functions. * * These purposes may be somewhat at odds with one another. For instance, the tutorial aspect calls for * explanatory comments that wouldn't appear in production code. Nevertheless, I hope the experienced * reader will forgive the verbosity and still find the program useful. * * \todo The error/message handlers are not robust enough. They should anticipate certain conditions * and cause the application to retry the operation. */ int main(int argc, char *argv[]) { LOGINREC *login; DBPROCESS *dbproc; RETCODE erc; setlocale(LC_ALL, ""); /* Initialize db-lib */ erc = dbinit(); if (erc == FAIL) { fprintf(stderr, "%s:%d: dbinit() failed\n", options.appname, __LINE__); exit(1); } /* Install our error and message handlers */ dberrhandle(err_handler); dbmsghandle(msg_handler); memset(&options, 0, sizeof(options)); options.headers = stderr; login = get_login(argc, argv, &options); /* get command-line parameters and call dblogin() */ assert(login != NULL); /* * Override stdin, stdout, and stderr, as required */ if (options.input_filename) { if (freopen(options.input_filename, "r", stdin) == NULL) { fprintf(stderr, "%s: unable to open %s: %s\n", options.appname, options.input_filename, strerror(errno)); exit(1); } } if (options.output_filename) { if (freopen(options.output_filename, "w", stdout) == NULL) { fprintf(stderr, "%s: unable to open %s: %s\n", options.appname, options.output_filename, strerror(errno)); exit(1); } } if (options.error_filename) { if (freopen(options.error_filename, "w", stderr) == NULL) { fprintf(stderr, "%s: unable to open %s: %s\n", options.appname, options.error_filename, strerror(errno)); exit(1); } } if (options.fverbose) { options.verbose = stderr; } else { static const char null_device[] = NULL_DEVICE; options.verbose = fopen(null_device, "w"); if (options.verbose == NULL) { fprintf(stderr, "%s:%d unable to open %s for verbose operation: %s\n", options.appname, __LINE__, null_device, strerror(errno)); exit(1); } } fprintf(options.verbose, "%s:%d: Verbose operation enabled\n", options.appname, __LINE__); /* Select the specified database, if any */ if (options.database) DBSETLDBNAME(login, options.database); /* * Connect to the server */ if ((dbproc = dbopen(login, options.servername)) == NULL) return 1; /* * Read the queries and write the results */ while (next_query(dbproc) != -1 ) { /* Send the query to the server (we could use dbsqlexec(), instead) */ erc = dbsqlsend(dbproc); if (erc == FAIL) { fprintf(stderr, "%s:%d: dbsqlsend() failed\n", options.appname, __LINE__); exit(1); } fprintf(options.verbose, "%s:%d: dbsqlsend(): OK\n", options.appname, __LINE__); /* Wait for it to execute */ erc = dbsqlok(dbproc); if (erc == FAIL) { fprintf(stderr, "%s:%d: dbsqlok() failed\n", options.appname, __LINE__); exit(1); } fprintf(options.verbose, "%s:%d: dbsqlok(): OK\n", options.appname, __LINE__); /* Write the output */ print_results(dbproc); } return 0; } static int next_query(DBPROCESS *dbproc) { char query_line[4096]; RETCODE erc; if (feof(stdin)) return -1; fprintf(options.verbose, "%s:%d: Query:\n", options.appname, __LINE__); /* * Normally, a call to dbcmd() clears the buffer the first time it's * invoked after a call to dbsqlexec() or dbsqlsend(). If fgets(3) * returns 0 below, however, we'd indicate "success" without calling * dbcmd(). This would leave the prior query in the buffer, which * our caller would re-send. To avoid such nonsense, we invoke * dbfreebuf() as a precaution. */ dbfreebuf(dbproc); while (fgets(query_line, sizeof(query_line), stdin)) { /* 'go' or 'GO' separates command batches */ const char *p = query_line; /* Skip past leading white spaces */ while (isspace((unsigned char) *p)) p++; if (strncasecmp(p, "go", 2) == 0) { for (p+=2; isspace((unsigned char) *p); p++) { if (*p == '\n') return 1; } } fprintf(options.verbose, "\t%s", query_line); /* Add the query line to the command to be sent to the server */ erc = dbcmd(dbproc, query_line); if (erc == FAIL) { fprintf(stderr, "%s:%d: dbcmd() failed\n", options.appname, __LINE__); return -1; } } if (feof(stdin)) return dbstrlen(dbproc) > 0? 0 : -1; if (ferror(stdin)) { fprintf(stderr, "%s:%d: next_query() failed\n", options.appname, __LINE__); perror(NULL); return -1; } return 1; } static void free_metadata(struct METADATA **pmetadata, int ncols) { int c; struct METADATA *metadata = *pmetadata; if (!metadata) return; for (c=0; c < ncols; c++) { free(metadata[c].format_string); } free(metadata); *pmetadata = NULL; } static void free_data(struct DATA **pdata, int ncols) { int c; struct DATA *data = *pdata; if (!data) return; for (c=0; c < ncols; c++) { free(data[c].buffer); } free(data); *pdata = NULL; } static void free_metacomp(struct METACOMP ***pmetacompute, int ncomputeids) { int i, c; struct METACOMP **metacompute = *pmetacompute; if (!metacompute) return; for (i=0; i < ncomputeids; i++) { for (c=0; c < metacompute[i]->numalts; c++) { free(metacompute[i]->meta[c].name); free(metacompute[i]->meta[c].format_string); } free(metacompute[i]->meta); free(metacompute[i]->data); free(metacompute[i]); } free(metacompute); *pmetacompute = NULL; } static void print_results(DBPROCESS *dbproc) { static const char empty_string[] = ""; static const char dashes[] = "----------------------------------------------------------------" /* each line is 64 */ "----------------------------------------------------------------" "----------------------------------------------------------------" "----------------------------------------------------------------"; struct METADATA *metadata = NULL, return_status; struct DATA *data = NULL; struct METACOMP **metacompute = NULL; RETCODE erc; int row_code; int i, c, ret; int iresultset; int ncomputeids = 0, ncols = 0; /* * If using default column separator, we want columns to line up vertically, * so we use blank padding (STRINGBIND). * For any other separator, we use no padding. */ const int bindtype = (0 == strcmp(options.colsep, default_colsep))? STRINGBIND : NTBSTRINGBIND; /* * Set up each result set with dbresults() * This is more commonly implemented as a while() loop, but we're counting the result sets. */ fprintf(options.verbose, "%s:%d: calling dbresults: OK\n", options.appname, __LINE__); for (iresultset=1; (erc = dbresults(dbproc)) != NO_MORE_RESULTS; iresultset++) { if (erc == FAIL) { fprintf(stderr, "%s:%d: dbresults(), result set %d failed\n", options.appname, __LINE__, iresultset); free_metadata(&metadata, ncols); free_data(&data, ncols); free_metacomp(&metacompute, ncomputeids); return; } if (options.pivot.func) { const KEY_T *rk = &options.pivot.row_key, *ck = &options.pivot.col_key; erc = dbpivot(dbproc, rk->nkeys, rk->keys, ck->nkeys, ck->keys, options.pivot.func, options.pivot.val_col); } fprintf(options.verbose, "Result set %d\n", iresultset); /* Free prior allocations, if any. */ free_metadata(&metadata, ncols); free_data(&data, ncols); ncols = 0; free_metacomp(&metacompute, ncomputeids); ncomputeids = 0; /* * Allocate memory for metadata and bound columns */ fprintf(options.verbose, "Allocating buffers\n"); ncols = dbnumcols(dbproc); metadata = (struct METADATA*) calloc(ncols, sizeof(struct METADATA)); assert(metadata); data = (struct DATA*) calloc(ncols, sizeof(struct DATA)); assert(data); /* metadata is more complicated only because there may be several compute ids for each result set */ fprintf(options.verbose, "Allocating compute buffers\n"); ncomputeids = dbnumcompute(dbproc); if (ncomputeids > 0) { metacompute = (struct METACOMP**) calloc(ncomputeids, sizeof(struct METACOMP*)); assert(metacompute); } for (i=0; i < ncomputeids; i++) { metacompute[i] = (struct METACOMP*) calloc(ncomputeids, sizeof(struct METACOMP)); assert(metacompute[i]); metacompute[i]->numalts = dbnumalts(dbproc, 1+i); fprintf(options.verbose, "%d columns found in computeid %d\n", metacompute[i]->numalts, 1+i); if (metacompute[i]->numalts > 0) { fprintf(options.verbose, "allocating column %d\n", 1+i); metacompute[i]->meta = (struct METADATA*) calloc(metacompute[i]->numalts, sizeof(struct METADATA)); assert(metacompute[i]->meta); metacompute[i]->data = (struct DATA*) calloc(metacompute[i]->numalts, sizeof(struct DATA)); assert(metacompute[i]->data); } } /* * For each column, get its name, type, and size. * Allocate a buffer to hold the data, and bind the buffer to the column. * "bind" here means to give db-lib the address of the buffer we want filled as each row is fetched. * TODO: Implement dbcoltypeinfo() for numeric/decimal datatypes. */ fprintf(options.verbose, "Metadata\n"); fprintf(options.verbose, "%-6s %-30s %-30s %-15s %-6s %-6s \n", "col", "name", "source", "type", "size", "varies"); fprintf(options.verbose, "%.6s %.30s %.30s %.15s %.6s %.6s \n", dashes, dashes, dashes, dashes, dashes, dashes); for (c=0; c < ncols; c++) { /* Get and print the metadata. Optional: get only what you need. */ char *name = dbcolname(dbproc, c+1); metadata[c].name = strdup(name ? (const char *) name : empty_string); name = dbcolsource(dbproc, c+1); metadata[c].source = (name)? name : empty_string; metadata[c].type = dbcoltype(dbproc, c+1); metadata[c].size = dbcollen(dbproc, c+1); assert(metadata[c].size != -1); /* -1 means indicates an out-of-range request*/ fprintf(options.verbose, "%6d %30s %30s %15s %6d %6d \n", c+1, metadata[c].name, metadata[c].source, dbprtype(metadata[c].type), metadata[c].size, dbvarylen(dbproc, c+1)); /* * Build the column header format string, based on the column width. * This is just one solution to the question, "How wide should my columns be when I print them out?" */ metadata[c].width = get_printable_size(metadata[c].type, metadata[c].size); if (metadata[c].width < strlen(metadata[c].name)) metadata[c].width = strlen(metadata[c].name); ret = set_format_string(&metadata[c], (c+1 < ncols)? options.colsep : "\n"); if (ret <= 0) { fprintf(stderr, "%s:%d: asprintf(), column %d failed\n", options.appname, __LINE__, c+1); exit(1); } /* * Bind the column to our variable. * We bind everything to strings, because we want db-lib to convert everything to strings for us. * If you're performing calculations on the data in your application, you'd bind the numeric data * to C integers and floats, etc. instead. * * It is not necessary to bind to every column returned by the query. * Data in unbound columns are simply never copied to the user's buffers and are thus * inaccesible to the application. */ if (metadata[c].width < INT_MAX) { data[c].buffer = (char *) calloc(1, 1 + metadata[c].width); /* allow for null terminator */ assert(data[c].buffer); erc = dbbind(dbproc, c+1, bindtype, 0, (BYTE *) data[c].buffer); if (erc == FAIL) { fprintf(stderr, "%s:%d: dbbind(), column %d failed\n", options.appname, __LINE__, c+1); exit(1); } erc = dbnullbind(dbproc, c+1, &data[c].status); if (erc == FAIL) { fprintf(stderr, "%s:%d: dbnullbind(), column %d failed\n", options.appname, __LINE__, c+1); exit(1); } } else { /* We don't bind text buffers, but use dbreadtext instead. */ data[c].buffer = NULL; } } /* * Get metadata and bind the columns for any compute rows. */ for (i=0; i < ncomputeids; i++) { fprintf(options.verbose, "For computeid %d:\n", 1+i); for (c=0; c < metacompute[i]->numalts; c++) { /* read metadata */ struct METADATA *meta = &metacompute[i]->meta[c]; int nby, iby; BYTE *bylist; char *colname, *bynames; int altcolid = dbaltcolid(dbproc, i+1, c+1); metacompute[i]->meta[c].type = dbalttype(dbproc, i+1, c+1); metacompute[i]->meta[c].size = dbaltlen(dbproc, i+1, c+1); /* * Jump through hoops to determine a useful name for the computed column * If the query says "compute count(c) by a,b", we get a "by list" indicating a & b. */ bylist = dbbylist(dbproc, c+1, &nby); bynames = strdup("by ("); for (iby=0; iby < nby; iby++) { char *s = NULL; int ret = asprintf(&s, "%s%s%s", bynames, dbcolname(dbproc, bylist[iby]), (iby+1 < nby)? ", " : ")"); if (ret < 0) { fprintf(options.verbose, "Insufficient room to create name for column %d:\n", 1+c); exit(1); } free(bynames); bynames = s; } if( altcolid == -1 ) { colname = "*"; } else { assert(0 < altcolid && altcolid <= dbnumcols(dbproc)); colname = metadata[--altcolid].name; } ret = asprintf(&metacompute[i]->meta[c].name, "%s(%s)", dbprtype(dbaltop(dbproc, i+1, c+1)), colname); if (ret < 0) { fprintf(stderr, "%s:%d: asprintf(), column %d failed\n", options.appname, __LINE__, c+1); exit(1); } metacompute[i]->meta[c].width = get_printable_size(metacompute[i]->meta[c].type, metacompute[i]->meta[c].size); if (metacompute[i]->meta[c].width < strlen(metacompute[i]->meta[c].name)) metacompute[i]->meta[c].width = strlen(metacompute[i]->meta[c].name); ret = set_format_string(meta, (c+1 < metacompute[i]->numalts)? options.colsep : "\n"); if (ret <= 0) { free(bynames); fprintf(stderr, "%s:%d: asprintf(), column %d failed\n", options.appname, __LINE__, c+1); exit(1); } fprintf(options.verbose, "\tcolumn %d is %s, type %s, size %d %s\n", c+1, metacompute[i]->meta[c].name, dbprtype(metacompute[i]->meta[c].type), metacompute[i]->meta[c].size, (nby > 0)? bynames : ""); free(bynames); /* allocate buffer */ assert(metacompute[i]->data); metacompute[i]->data[c].buffer = (char *) calloc(1, metacompute[i]->meta[c].width); assert(metacompute[i]->data[c].buffer); /* bind */ erc = dbaltbind(dbproc, i+1, c+1, bindtype, -1, (BYTE*) metacompute[i]->data[c].buffer); if (erc == FAIL) { fprintf(stderr, "%s:%d: dbaltbind(), column %d failed\n", options.appname, __LINE__, c+1); exit(1); } } } fprintf(options.verbose, "\n"); fprintf(options.verbose, "Data\n"); if (!options.fquiet) { /* Print the column headers to stderr to keep them separate from the data. */ for (c=0; c < ncols; c++) { fprintf(options.headers, metadata[c].format_string, metadata[c].name); } /* Underline the column headers. */ for (c=0; c < ncols; c++) { fprintf(options.headers, metadata[c].format_string, dashes); } } /* * Print the data to stdout. */ while ((row_code = dbnextrow(dbproc)) != NO_MORE_ROWS) { switch (row_code) { case REG_ROW: for (c=0; c < ncols; c++) { if (metadata[c].width == INT_MAX) { /* TEXT/IMAGE */ BYTE *p = dbdata(dbproc, c+1); size_t len = dbdatlen(dbproc, c+1); if (len == 0) { fputs("NULL", stdout); } else { BYTE *pend = p + len; switch(dbcoltype(dbproc, c+1)) { case SYBTEXT: if (fwrite(p, len, 1, stdout) != 1) { perror("could not write to output file"); exit(EXIT_FAILURE); } break; default: /* image, binary */ fprintf(stdout, "0x"); for (; p < pend; p++) { printf("%02hx", (unsigned short int)*p); } break; } } fprintf(stdout, metadata[c].format_string, ""); /* col/row separator */ continue; } switch (data[c].status) { /* handle nulls */ case -1: /* is null */ /* TODO: FreeTDS 0.62 does not support dbsetnull() */ fprintf(stdout, metadata[c].format_string, "NULL"); break; case 0: /* case >1 is datlen when buffer is too small */ default: fprintf(stdout, metadata[c].format_string, data[c].buffer); break; } } break; case BUF_FULL: assert(row_code != BUF_FULL); break; case FAIL: fprintf(stderr, "bsqldb: fatal error: dbnextrow returned FAIL\n"); assert(row_code != FAIL); exit(EXIT_FAILURE); break; default: /* computeid */ fprintf(options.verbose, "Data for computeid %d\n", row_code); for (c=0; c < metacompute[row_code-1]->numalts; c++) { char fmt[256] = "%-"; struct METADATA *meta = &metacompute[row_code-1]->meta[c]; /* left justify the names */ strlcat(fmt, &meta->format_string[1], sizeof(fmt)); fprintf(options.headers, fmt, meta->name); } /* Underline the column headers. */ for (c=0; c < metacompute[row_code-1]->numalts; c++) { fprintf(options.headers, metacompute[row_code-1]->meta[c].format_string, dashes); } for (c=0; c < metacompute[row_code-1]->numalts; c++) { struct METADATA *meta = &metacompute[row_code-1]->meta[c]; struct DATA *data = &metacompute[row_code-1]->data[c]; switch (data->status) { /* handle nulls */ case -1: /* is null */ /* TODO: FreeTDS 0.62 does not support dbsetnull() */ fprintf(stdout, meta->format_string, "NULL"); break; case 0: /* case >1 is datlen when buffer is too small */ default: fprintf(stdout, meta->format_string, data->buffer); break; } } } } /* Check return status */ if (!options.fquiet) { fprintf(options.verbose, "Retrieving return status... "); if (dbhasretstat(dbproc) == TRUE) { fprintf(stderr, "Procedure returned %d\n", dbretstatus(dbproc)); } else { fprintf(options.verbose, "none\n"); } } /* * Get row count, if available. */ if (!options.fquiet) { if (DBCOUNT(dbproc) > -1) fprintf(stderr, "%d rows affected\n", DBCOUNT(dbproc)); else fprintf(stderr, "@@rowcount not available\n"); } /* * Check return parameter values */ fprintf(options.verbose, "Retrieving output parameters... "); if (dbnumrets(dbproc) > 0) { for (i = 1; i <= dbnumrets(dbproc); i++) { char parameter_string[1024]; return_status.name = dbretname(dbproc, i); fprintf(stderr, "ret name %d is %s\n", i, return_status.name); return_status.type = dbrettype(dbproc, i); fprintf(options.verbose, "\n\tret type %d is %d", i, return_status.type); return_status.size = dbretlen(dbproc, i); fprintf(options.verbose, "\n\tret len %d is %d\n", i, return_status.size); dbconvert(dbproc, return_status.type, dbretdata(dbproc, i), return_status.size, SYBVARCHAR, (BYTE *) parameter_string, -1); fprintf(stderr, "ret data %d is %s\n", i, parameter_string); } } else { fprintf(options.verbose, "none\n"); } } /* wend dbresults */ fprintf(options.verbose, "%s:%d: dbresults() returned NO_MORE_RESULTS (%d):\n", options.appname, __LINE__, erc); free_metadata(&metadata, ncols); free_data(&data, ncols); free_metacomp(&metacompute, ncomputeids); } static int get_printable_size(int type, int size) /* adapted from src/dblib/dblib.c */ { switch (type) { case SYBBITN: case SYBBIT: return 1; case SYBINTN: switch (size) { case 1: return 3; case 2: return 6; case 4: return 11; case 8: return 21; } case SYBINT1: return 3; case SYBINT2: return 6; case SYBINT4: return 11; case SYBDECIMAL: case SYBNUMERIC: case SYBINT8: return 21; case SYBVARCHAR: case SYBCHAR: return size; case SYBNVARCHAR: return size/2; case SYBFLT8: return 11; /* FIX ME -- we do not track precision */ case SYBREAL: return 11; /* FIX ME -- we do not track precision */ case SYBMONEY: return 12; /* FIX ME */ case SYBMONEY4: return 12; /* FIX ME */ case SYBDATETIME: case SYBDATETIME4: case SYBDATETIMN: return 26; /* FIX ME */ #if 0 /* not exported by sybdb.h */ case SYBLONGBINARY: case SYBLONGCHAR: #endif case SYBBINARY: case SYBIMAGE: case SYBTEXT: case SYBNTEXT: case SYBVARBINARY: return INT_MAX; } /* FIX ME -- not all types present */ fprintf(stderr, "type %d not supported, sorry\n", type); exit(EXIT_FAILURE); } /** * Build the column header format string, based on the column width. * This is just one solution to the question, "How wide should my columns be when I print them out?" */ #define is_character_data(x) (x==SYBTEXT || x==SYBCHAR || x==SYBVARCHAR) static int set_format_string(struct METADATA * meta, const char separator[]) { int width; const char *size_and_width; assert(meta); if ((width = get_printable_size(meta->type, meta->size)) == INT_MAX) { /* TEXT/IMAGE: no attempt to format the column; just splat the data */ meta->format_string = strdup(separator); return strlen(meta->format_string); } /* For anything except the default two-space separator, don't justify the strings. */ if(0 != strcmp(options.colsep, default_colsep)) { return asprintf(&meta->format_string, "%%s%s", separator); } /* Set the printing width large enough for the data or its title, whichever is greater. */ if (width < strlen(meta->name)) width = strlen(meta->name); /* right justify numbers, left justify strings */ size_and_width = is_character_data(meta->type)? "%%-%d.%ds%s" : "%%%d.%ds%s"; return asprintf(&meta->format_string, size_and_width, width, width, separator); } static void usage(const char invoked_as[]) { fprintf(stderr, "usage: %s \n" " [-U username] [-P password]\n" " [-S servername] [-D database]\n" " [-i input filename] [-o output filename] [-e error filename]\n" , invoked_as); } static void unescape(char arg[]) { char *p = arg; char escaped = '1'; /* any digit will do for an initial value */ while ((p = strchr(p, '\\')) != NULL) { switch (p[1]) { case '0': /* FIXME we use strlen() of field/row terminators, which obviously won't work here */ fprintf(stderr, "bsqldb, line %d: NULL terminators ('\\0') not yet supported.\n", __LINE__); escaped = '\0'; break; case 't': escaped = '\t'; break; case 'r': escaped = '\r'; break; case 'n': escaped = '\n'; break; case '\\': escaped = '\\'; break; default: break; } /* Overwrite the backslash with the intended character, and shift everything down one */ if (!isdigit((unsigned char) escaped)) { *p++ = escaped; memmove(p, p+1, 1 + strlen(p+1)); escaped = '1'; } } } /* pivot syntax: down cols, across cols, function, value */ static void parse_pivot_description(OPTIONS *options, const char *optarg) { /** KEY_T { size_t nkeys; int *keys; }; struct pivot_t { KEY_T row_key, col_key; int val_col; DBPIVOT_FUNC func; **/ char *p, *pend; KEY_T *keys[2] = { &options->pivot.row_key, &options->pivot.col_key},**pk; int nchars; char ch, *input = strdup(optarg); assert(input); keys[0]->keys = NULL; keys[1]->keys = NULL; keys[0]->nkeys = 0; keys[1]->nkeys = 0; for (p=input, pk=keys; pk < keys + 2; p++, pk++) { if ((pend = strchr(p, ' ')) != NULL) { unsigned col; int ncols; *pend = '\0'; while((ncols = sscanf(p, "%u%c%n", &col, &ch, &nchars)) > 0) { int *pi; assert(ncols <= 2); if ((pi = (int *) realloc((*pk)->keys, sizeof((*pk)->keys[0]) * ++((*pk)->nkeys))) == NULL) { assert(pi); return; } (*pk)->keys = pi; (*pk)->keys[(*pk)->nkeys - 1] = col; if (ncols == 2) { assert(nchars <= pend - p); if (ch != ',') fprintf(stderr, "surprised by %c\n", ch); p += nchars; } else { p = pend; break; } } } } if (options->fverbose) printf("found %lu row and %lu col keys\n", (unsigned long) options->pivot.row_key.nkeys, (unsigned long) options->pivot.col_key.nkeys); if ((pend = strchr(p, ' ')) == NULL) { fprintf(stderr, "bsqldb(): no name in %s\n", p); free(input); return; } *pend = '\0'; if ((options->pivot.func = dbpivot_lookup_name(p)) == NULL) { fprintf(stderr, "bsqldb(): invalid name in %s\n", p); free(input); return; } p = ++pend; if( sscanf(p, "%d%c%n", &options->pivot.val_col, &ch, &nchars) != 1) { fprintf(stderr, "bsqldb(): could not parse value column %s\n", p); free(input); return; } free(input); } LOGINREC * get_login(int argc, char *argv[], OPTIONS *options) { LOGINREC *login; int ch; char *username = NULL, *password = NULL; extern char *optarg; assert(options && argv); options->appname = basename(argv[0]); options->colsep = default_colsep; /* may be overridden by -t */ login = dblogin(); if (!login) { fprintf(stderr, "%s: unable to allocate login structure\n", options->appname); exit(1); } DBSETLAPP(login, options->appname); options->servername = getenv("DSQUERY"); while ((ch = getopt(argc, argv, "U:P:R:S:d:D:i:o:e:t:H:hqv")) != -1) { switch (ch) { case 'U': free(username); username = strdup(optarg); break; case 'R': parse_pivot_description(options, optarg); break; case 'P': free(password); password = tds_getpassarg(optarg); break; case 'S': options->servername = strdup(optarg); break; case 'd': case 'D': options->database = strdup(optarg); break; case 'i': options->input_filename = strdup(optarg); break; case 'o': options->output_filename = strdup(optarg); break; case 'e': options->error_filename = strdup(optarg); break; case 't': unescape(optarg); options->colsep = strdup(optarg); break; case 'h': options->headers = stdout; break; case 'H': strlcpy(options->hostname, optarg, sizeof(options->hostname)); break; case 'q': options->fquiet = 1; break; case 'v': options->fverbose = 1; break; case '?': default: usage(options->appname); exit(1); } } if (username) DBSETLUSER(login, username); if( !options->hostname[0] ) { if (-1 == gethostname(options->hostname, sizeof(options->hostname))) { perror("unable to get hostname"); } } if( options->hostname[0] ) { DBSETLHOST(login, options->hostname); } /* Look for a password if a username was provided, else assume domain login */ if (password) { DBSETLPWD(login, password); memset(password, 0, strlen(password)); } else if (username) { char password[128]; readpassphrase("Password: ", password, sizeof(password), RPP_ECHO_OFF); DBSETLPWD(login, password); } if (!options->servername) { usage(options->appname); exit(1); } return login; } int err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr) { if (dberr) { fprintf(stderr, "%s: Msg %d, Level %d", options.appname, dberr, severity); } else { fprintf(stderr, "%s: DB-LIBRARY error", options.appname); } if (oserr && oserrstr) fprintf(stderr, " (OS error %d: %s)", oserr, oserrstr); printf("\n"); fprintf(stderr, "%s\n\n", dberrstr); return INT_CANCEL; } int msg_handler(DBPROCESS * dbproc, DBINT msgno, int msgstate, int severity, char *msgtext, char *srvname, char *procname, int line) { enum {changed_database = 5701, changed_language = 5703 }; if (msgno == changed_database || msgno == changed_language) return 0; if (msgno > 0) { fprintf(stderr, "Msg %ld, Level %d, State %d\n", (long) msgno, severity, msgstate); if (strlen(srvname) > 0) fprintf(stderr, "Server '%s', ", srvname); if (strlen(procname) > 0) fprintf(stderr, "Procedure '%s', ", procname); if (line > 0) fprintf(stderr, "Line %d", line); fprintf(stderr, "\n\t"); } fprintf(stderr, "%s\n", msgtext); if (severity > 10) { fprintf(stderr, "%s: error: severity %d > 10, exiting\n", options.appname, severity); exit(severity); } return 0; } freetds-1.00.82/src/apps/bsqlodbc.c100644 025423 025423 00000055141 12717145107 0012530/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2004, 2005 James K. Lowden * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #include #if HAVE_ERRNO_H #include #endif #if HAVE_UNISTD_H #include #endif #if HAVE_STDLIB_H #include #endif #if HAVE_STRING_H #include #endif #if HAVE_LIBGEN_H #include #endif #if HAVE_LOCALE_H #include #endif #include "tds_sysdep_public.h" #include #include #include "replacements.h" #include static char * next_query(void); static void print_results(SQLHSTMT hStmt); /* static int get_printable_size(int type, int size); */ static void usage(const char invoked_as[]); static SQLINTEGER print_error_message(SQLSMALLINT hType, SQLHANDLE handle); static SQLRETURN odbc_herror(SQLSMALLINT hType, SQLHANDLE handle, SQLRETURN erc, const char func[], const char msg[]); static SQLRETURN odbc_perror(SQLHSTMT hStmt, SQLRETURN erc, const char func[], const char msg[]); static const char * prret(SQLRETURN erc); struct METADATA { char *name, *format_string; const char *source; SQLSMALLINT type; SQLINTEGER nchars; SQLULEN size, width; }; struct DATA { char *buffer; SQLLEN len; int status; }; static int set_format_string(struct METADATA * meta, const char separator[]); typedef struct _options { int fverbose, fquiet; size_t odbc_version; FILE *headers, *verbose; char *servername, *database, *appname, hostname[128]; const char *colsep; char *input_filename, *output_filename, *error_filename; } OPTIONS; typedef struct { int connect_timeout, query_timeout; char *client_hostname, *username, *password, *client_charset; } LOGINREC; static LOGINREC* get_login(int argc, char *argv[], OPTIONS *poptions); /* global variables */ OPTIONS options; static const char default_colsep[] = " "; /* end global variables */ /** * The purpose of this program is threefold: * * 1. To provide a generalized SQL processor suitable for testing the FreeTDS ODBC driver. * 2. To offer a robust batch-oriented SQL processor suitable for use in a production environment. * 3. To serve as a model example of how to use ODBC functions. * * These purposes may be somewhat impossible. The original author is not an experienced ODBC programmer. * Nevertheless the first objective can be met and is useful by itself. * If others join in, perhaps the others can be met, too. */ /** * When SQLExecute returns either SQL_ERROR or SQL_SUCCESS_WITH_INFO, * an associated SQLSTATE value can be obtained by calling SQLGetDiagRec * with a HandleType of SQL_HANDLE_STMT and a Handle of StatementHandle. */ static SQLINTEGER print_error_message(SQLSMALLINT hType, SQLHANDLE handle) { int i; SQLINTEGER ndiag=0; SQLRETURN ret; SQLCHAR state[6]; SQLINTEGER error, maxerror=0; SQLCHAR text[1024]; SQLSMALLINT len; ret = SQLGetDiagField(hType, handle, 0, SQL_DIAG_NUMBER, &ndiag, sizeof(ndiag), NULL); assert(ret == SQL_SUCCESS); for(i=1; i <= ndiag; i++) { memset(text, '\0', sizeof(text)); ret = SQLGetDiagRec(hType, handle, i, state, &error, text, sizeof(text), &len); if (ret == SQL_SUCCESS && error == 0) { fprintf(stdout, "\"%s\"\n", text); continue; } fprintf(stderr, "%s: error %d: %s: %s\n", options.appname, (int)error, state, text); assert(ret == SQL_SUCCESS); if (error > maxerror) maxerror = error; } return maxerror; } static const char * prret(SQLRETURN erc) { switch(erc) { case SQL_SUCCESS: return "SQL_SUCCESS"; case SQL_SUCCESS_WITH_INFO: return "SQL_SUCCESS_WITH_INFO"; case SQL_ERROR: return "SQL_ERROR"; case SQL_STILL_EXECUTING: return "SQL_STILL_EXECUTING"; case SQL_INVALID_HANDLE: return "SQL_INVALID_HANDLE"; case SQL_NO_DATA: return "SQL_NO_DATA"; } fprintf(stderr, "error:%d: prret cannot interpret SQLRETURN code %d\n", __LINE__, erc); return "unknown"; } static SQLRETURN odbc_herror(SQLSMALLINT hType, SQLHANDLE handle, SQLRETURN erc, const char func[], const char msg[]) { char * ercstr; assert(func && msg); switch(erc) { case SQL_SUCCESS: return erc; case SQL_SUCCESS_WITH_INFO: ercstr = "SQL_SUCCESS_WITH_INFO"; break; case SQL_ERROR: ercstr = "SQL_ERROR"; break; case SQL_STILL_EXECUTING: ercstr = "SQL_STILL_EXECUTING"; break; case SQL_INVALID_HANDLE: fprintf(stderr, "%s: error %d: %s: invalid handle: %s\n", options.appname, (int)erc, func, msg); exit(EXIT_FAILURE); default: fprintf(stderr, "%s: error: %d is an unknown return code for %s\n", options.appname, (int)erc, func); exit(EXIT_FAILURE); } fprintf(stderr, "%s: error %d: %s: %s: %s\n", options.appname, (int)erc, func, ercstr, msg); print_error_message(hType, handle); return erc; } static SQLRETURN odbc_perror(SQLHSTMT hStmt, SQLRETURN erc, const char func[], const char msg[]) { return odbc_herror(SQL_HANDLE_STMT, hStmt, erc, func, msg); } int main(int argc, char *argv[]) { LOGINREC *login; SQLHENV hEnv = 0; SQLHDBC hDbc = 0; SQLRETURN erc; const char *sql; setlocale(LC_ALL, ""); memset(&options, 0, sizeof(options)); options.headers = stderr; login = get_login(argc, argv, &options); /* get command-line parameters and call dblogin() */ assert(login != NULL); /* * Override stdin, stdout, and stderr, as required */ if (options.input_filename) { if (freopen(options.input_filename, "r", stdin) == NULL) { fprintf(stderr, "%s: unable to open %s: %s\n", options.appname, options.input_filename, strerror(errno)); exit(1); } } if (options.output_filename) { if (freopen(options.output_filename, "w", stdout) == NULL) { fprintf(stderr, "%s: unable to open %s: %s\n", options.appname, options.output_filename, strerror(errno)); exit(1); } } if (options.error_filename) { if (freopen(options.error_filename, "w", stderr) == NULL) { fprintf(stderr, "%s: unable to open %s: %s\n", options.appname, options.error_filename, strerror(errno)); exit(1); } } if (options.fverbose) { options.verbose = stderr; } else { static const char null_device[] = "/dev/null"; options.verbose = fopen(null_device, "w"); if (options.verbose == NULL) { fprintf(stderr, "%s:%d unable to open %s for verbose operation: %s\n", options.appname, __LINE__, null_device, strerror(errno)); exit(1); } } fprintf(options.verbose, "%s:%d: Verbose operation enabled\n", options.appname, __LINE__); /* * Connect to the server */ if ((erc = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &hEnv)) != SQL_SUCCESS) { odbc_herror(SQL_HANDLE_ENV, hEnv, erc, "SQLAllocHandle", "failed to allocate an environment"); exit(EXIT_FAILURE); } assert(hEnv); if ((erc = SQLSetEnvAttr(hEnv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER)options.odbc_version, SQL_IS_UINTEGER)) != SQL_SUCCESS){ odbc_herror(SQL_HANDLE_DBC, hDbc, erc, "SQLSetEnvAttr", "failed to set SQL_OV_ODBC3"); exit(EXIT_FAILURE); } if ((erc = SQLAllocHandle(SQL_HANDLE_DBC, hEnv, &hDbc)) != SQL_SUCCESS) { odbc_herror(SQL_HANDLE_DBC, hDbc, erc, "SQLAllocHandle", "failed to allocate a connection"); exit(EXIT_FAILURE); } assert(hDbc); if ((erc = SQLConnect(hDbc, (SQLCHAR *) options.servername, SQL_NTS, (SQLCHAR *) login->username, SQL_NTS, (SQLCHAR *) login->password, SQL_NTS)) != SQL_SUCCESS) { odbc_herror(SQL_HANDLE_DBC, hDbc, erc, "SQLConnect", "failed"); exit(EXIT_FAILURE); } #if 0 /* Switch to the specified database, if any */ if (options.database) dbuse(dbproc, options.database); #endif /* * Read the queries and write the results */ while ((sql = next_query()) != NULL ) { SQLHSTMT hStmt; if ((erc = SQLAllocHandle(SQL_HANDLE_STMT, hDbc, &hStmt)) != SQL_SUCCESS) { odbc_perror(hStmt, erc, "SQLAllocHandle", "failed to allocate a statement handle"); exit(EXIT_FAILURE); } /* "Prepare" the query and send it to the server */ if ((erc = SQLPrepare(hStmt, (SQLCHAR *) sql, SQL_NTS)) != SQL_SUCCESS) { odbc_perror(hStmt, erc, "SQLPrepare", "failed"); exit(EXIT_FAILURE); } if((erc = SQLExecute(hStmt)) != SQL_SUCCESS) { switch(erc) { case SQL_NEED_DATA: goto FreeStatement; case SQL_SUCCESS_WITH_INFO: if (0 != print_error_message(SQL_HANDLE_STMT, hStmt)) { fprintf(stderr, "SQLExecute: continuing...\n"); } break; default: odbc_perror(hStmt, erc, "SQLExecute", "failed"); exit(EXIT_FAILURE); } } /* Write the output */ print_results(hStmt); FreeStatement: if ((erc = SQLFreeHandle(SQL_HANDLE_STMT, hStmt)) != SQL_SUCCESS){ odbc_perror(hStmt, erc, "SQLFreeHandle", "failed"); exit(EXIT_FAILURE); } } SQLDisconnect(hDbc); SQLFreeHandle(SQL_HANDLE_DBC, hDbc); SQLFreeHandle(SQL_HANDLE_ENV, hEnv); return 0; } static char * next_query() { char query_line[4096]; static char *sql = NULL; if (feof(stdin)) return NULL; fprintf(options.verbose, "%s:%d: Query:\n", options.appname, __LINE__); free(sql); sql = NULL; while (fgets(query_line, sizeof(query_line), stdin)) { /* 'go' or 'GO' separates command batches */ char *p = query_line; if (strncasecmp(p, "go", 2) == 0) { for (p+=2; isspace((unsigned char) *p); p++) { if (*p == '\n') return sql; } } fprintf(options.verbose, "\t%s", query_line); /* Add the query line to the command to be sent to the server */ if (!strlen(query_line)) continue; p = (char *) realloc(sql, 1 + (sql? strlen(sql) : 0) + strlen(query_line)); if (!p) { fprintf(stderr, "%s:%d: could not allocate memory\n", options.appname, __LINE__); return NULL; } if (!sql) { strcpy(p, query_line); } else { strcat(p, query_line); } sql = p; } if (feof(stdin)) return sql; if (ferror(stdin)) { fprintf(stderr, "%s:%d: next_query() failed\n", options.appname, __LINE__); perror(NULL); return NULL; } return sql; } static void free_metadata(struct METADATA *metadata, struct DATA *data, int ncols) { int c; for (c=0; c < ncols; c++) { free(metadata[c].format_string); free(data[c].buffer); } free(metadata); free(data); } static const char * prtype(SQLSMALLINT type) { static char buffer[64]; switch(type) { case SQL_UNKNOWN_TYPE: return "SQL_UNKNOWN_TYPE"; case SQL_CHAR: return "SQL_CHAR"; case SQL_NUMERIC: return "SQL_NUMERIC"; case SQL_DECIMAL: return "SQL_DECIMAL"; case SQL_INTEGER: return "SQL_INTEGER"; case SQL_SMALLINT: return "SQL_SMALLINT"; case SQL_FLOAT: return "SQL_FLOAT"; case SQL_REAL: return "SQL_REAL"; case SQL_DOUBLE: return "SQL_DOUBLE"; #if (ODBCVER >= 0x0300) case SQL_DATETIME: return "SQL_DATETIME"; #else case SQL_DATE: return "SQL_DATE"; #endif case SQL_VARCHAR: return "SQL_VARCHAR"; #if (ODBCVER >= 0x0300) case SQL_TYPE_DATE: return "SQL_TYPE_DATE"; case SQL_TYPE_TIME: return "SQL_TYPE_TIME"; case SQL_TYPE_TIMESTAMP: return "SQL_TYPE_TIMESTAMP"; #endif #if (ODBCVER >= 0x0300) case SQL_INTERVAL: return "SQL_INTERVAL"; #else case SQL_TIME: return "SQL_TIME"; #endif /* ODBCVER >= 0x0300 */ case SQL_TIMESTAMP: return "SQL_TIMESTAMP"; case SQL_LONGVARCHAR: return "SQL_LONGVARCHAR"; case SQL_BINARY: return "SQL_BINARY"; case SQL_VARBINARY: return "SQL_VARBINARY"; case SQL_LONGVARBINARY: return "SQL_LONGVARBINARY"; case SQL_BIGINT: return "SQL_BIGINT"; case SQL_TINYINT: return "SQL_TINYINT"; case SQL_BIT: return "SQL_BIT"; #if (ODBCVER >= 0x0350) case SQL_GUID: return "SQL_GUID"; #endif /* ODBCVER >= 0x0350 */ } sprintf(buffer, "unknown: %d", (int)type); return buffer; } #define is_character_data(x) (x==SQL_CHAR || \ x==SQL_VARCHAR || \ x==SQL_LONGVARCHAR || \ x==SQL_WCHAR || \ x==SQL_WVARCHAR || \ x==SQL_WLONGVARCHAR) static SQLLEN bufsize(const struct METADATA *meta) { assert(meta); return meta->size > meta->width? meta->size : meta->width; } static void print_results(SQLHSTMT hStmt) { static const char dashes[] = "----------------------------------------------------------------" /* each line is 64 */ "----------------------------------------------------------------" "----------------------------------------------------------------" "----------------------------------------------------------------"; struct METADATA *metadata = NULL; struct DATA *data = NULL; SQLSMALLINT ncols = 0; RETCODE erc; int c, ret; /* * Process each resultset */ do { /* free metadata, in case it was previously allocated */ free_metadata(metadata, data, ncols); metadata = NULL; data = NULL; ncols = 0; /* * Allocate memory for metadata and bound columns */ if ((erc = SQLNumResultCols(hStmt, &ncols)) != SQL_SUCCESS){ odbc_perror(hStmt, erc, "SQLNumResultCols", "failed"); exit(EXIT_FAILURE); } metadata = (struct METADATA*) calloc(ncols, sizeof(struct METADATA)); assert(metadata); data = (struct DATA*) calloc(ncols, sizeof(struct DATA)); assert(data); /* * For each column, get its name, type, and size. * Allocate a buffer to hold the data, and bind the buffer to the column. * "bind" here means to give the address of the buffer we want filled as each row is fetched. */ fprintf(options.verbose, "Metadata\n"); fprintf(options.verbose, "%-6s %-30s %-10s %-18s %-6s %-6s \n", "col", "name", "type value", "type name", "size", "varies"); fprintf(options.verbose, "%.6s %.30s %.10s %.18s %.6s %.6s \n", dashes, dashes, dashes, dashes, dashes, dashes); for (c=0; c < ncols; c++) { /* Get and print the metadata. Optional: get only what you need. */ SQLCHAR name[512]; SQLSMALLINT namelen, ndigits, fnullable; if ((erc = SQLDescribeCol(hStmt, c+1, name, sizeof(name), &namelen, &metadata[c].type, &metadata[c].size, &ndigits, &fnullable)) != SQL_SUCCESS) { odbc_perror(hStmt, erc, "SQLDescribeCol", "failed"); exit(EXIT_FAILURE); } assert(namelen < sizeof(name)); name[namelen] = '\0'; metadata[c].name = strdup((char *) name); metadata[c].width = (ndigits >= 0 && (unsigned) ndigits > metadata[c].size)? ndigits : metadata[c].size; if (is_character_data(metadata[c].type)) { SQLHDESC hDesc; SQLINTEGER buflen; metadata[c].nchars = metadata[c].size; if ((erc = SQLGetStmtAttr(hStmt, SQL_ATTR_IMP_ROW_DESC, &hDesc, sizeof(hDesc), NULL)) != SQL_SUCCESS) { odbc_perror(hStmt, erc, "SQLGetStmtAttr", "failed"); exit(EXIT_FAILURE); } if ((erc = SQLGetDescField(hDesc, c+1, SQL_DESC_OCTET_LENGTH, &metadata[c].size, sizeof(metadata[c].size), &buflen)) != SQL_SUCCESS) { odbc_perror(hStmt, erc, "SQLGetDescField", "failed"); exit(EXIT_FAILURE); } metadata[c].size = metadata[c].size * 2 + 1; } fprintf(options.verbose, "%6d %30s %10d %18s %6lu %6d \n", c+1, metadata[c].name, (int)metadata[c].type, prtype(metadata[c].type), (long unsigned int) metadata[c].size, -1); #if 0 fprintf(options.verbose, "%6d %30s %30s %15s %6d %6d \n", c+1, metadata[c].name, metadata[c].source, dbprtype(metadata[c].type), metadata[c].size, dbvarylen(dbproc, c+1)); metadata[c].width = get_printable_size(metadata[c].type, metadata[c].size); if (metadata[c].width < strlen(metadata[c].name)) metadata[c].width = strlen(metadata[c].name); #endif /* * Build the column header format string, based on the column width. * This is just one solution to the question, "How wide should my columns be when I print them out?" */ ret = set_format_string(&metadata[c], (c+1 < ncols)? options.colsep : "\n"); if (ret <= 0) { fprintf(stderr, "%s:%d: asprintf(), column %d failed\n", options.appname, __LINE__, c+1); free_metadata(metadata, data, ncols); return; } /* * Bind the column to our variable. * We bind everything to strings, because we want to convert everything to strings for us. * If you're performing calculations on the data in your application, you'd bind the numeric data * to C integers and floats, etc. instead. * * It is not necessary to bind to every column returned by the query. * Data in unbound columns are simply never copied to the user's buffers and are thus * inaccesible to the application. */ data[c].buffer = (char *) calloc(1, bufsize(&metadata[c])); assert(data[c].buffer); if ((erc = SQLBindCol(hStmt, c+1, SQL_C_CHAR, (SQLPOINTER)data[c].buffer, bufsize(&metadata[c]), &data[c].len)) != SQL_SUCCESS){ odbc_perror(hStmt, erc, "SQLBindCol", "failed"); exit(EXIT_FAILURE); } } if (!options.fquiet) { /* Print the column headers to stderr to keep them separate from the data. */ for (c=0; c < ncols; c++) { fprintf(options.headers, metadata[c].format_string, metadata[c].name); } /* Underline the column headers. */ for (c=0; c < ncols; c++) { fprintf(options.headers, metadata[c].format_string, dashes); } } /* * Print the data to stdout. */ while (ncols > 0 && (erc = SQLFetch(hStmt)) != SQL_NO_DATA) { switch(erc) { case SQL_SUCCESS_WITH_INFO: print_error_message(SQL_HANDLE_STMT, hStmt); case SQL_SUCCESS: break; default: odbc_perror(hStmt, erc, "SQLFetch", "failed"); exit(EXIT_FAILURE); } for (c=0; c < ncols; c++) { switch (data[c].len) { /* handle nulls */ case SQL_NULL_DATA: /* is null */ fprintf(stdout, metadata[c].format_string, "NULL"); break; default: assert(data[c].len >= 0); case SQL_NO_TOTAL: fprintf(stdout, metadata[c].format_string, data[c].buffer); break; } } } if (ncols > 0 && erc == SQL_NO_DATA) print_error_message(SQL_HANDLE_STMT, hStmt); erc = SQLMoreResults(hStmt); fprintf(options.verbose, "SQLMoreResults returned %s\n", prret(erc)); switch (erc) { case SQL_NO_DATA: print_error_message(SQL_HANDLE_STMT, hStmt); break; case SQL_SUCCESS_WITH_INFO: print_error_message(SQL_HANDLE_STMT, hStmt); case SQL_SUCCESS: continue; default: odbc_perror(hStmt, erc, "SQLMoreResults", "failed"); exit(EXIT_FAILURE); } } while (erc != SQL_NO_DATA); if (erc != SQL_NO_DATA) { assert(erc != SQL_STILL_EXECUTING); odbc_perror(hStmt, erc, "SQLMoreResults", "failed"); exit(EXIT_FAILURE); } free_metadata(metadata, data, ncols); } /** * Build the column header format string, based on the column width. * This is just one solution to the question, "How wide should my columns be when I print them out?" */ static int set_format_string(struct METADATA * meta, const char separator[]) { int ret; unsigned width; const char *size_and_width; assert(meta); if(0 == strcmp(options.colsep, default_colsep)) { /* right justify numbers, left justify strings */ size_and_width = is_character_data(meta->type)? "%%-%u.%us%s" : "%%%u.%us%s"; width = meta->width; /* get_printable_size(meta->type, meta->size); */ if (width < strlen(meta->name)) width = strlen(meta->name); ret = asprintf(&meta->format_string, size_and_width, width, width, separator); } else { /* For anything except the default two-space separator, don't justify the strings. */ ret = asprintf(&meta->format_string, "%%s%s", separator); } return ret; } static void usage(const char invoked_as[]) { fprintf(stderr, "usage: %s \n" " [-U username] [-P password]\n" " [-S servername] [-D database]\n" " [-i input filename] [-o output filename] [-e error filename]\n" , invoked_as); } static void unescape(char arg[]) { char *p = arg; char escaped = '1'; /* any digit will do for an initial value */ while ((p = strchr(p, '\\')) != NULL) { switch (p[1]) { case '0': /* FIXME we use strlen() of field/row terminators, which obviously won't work here */ fprintf(stderr, "bsqlodbc, line %d: NULL terminators ('\\0') not yet supported.\n", __LINE__); escaped = '\0'; break; case 't': escaped = '\t'; break; case 'r': escaped = '\r'; break; case 'n': escaped = '\n'; break; case '\\': escaped = '\\'; break; default: break; } /* Overwrite the backslash with the intended character, and shift everything down one */ if (!isdigit((unsigned char) escaped)) { *p++ = escaped; memmove(p, p+1, 1 + strlen(p+1)); escaped = '1'; } } } static LOGINREC * get_login(int argc, char *argv[], OPTIONS *options) { LOGINREC *login; int ch; extern char *optarg; assert(options && argv); options->appname = basename(argv[0]); options->colsep = default_colsep; /* may be overridden by -t */ options->odbc_version = SQL_OV_ODBC3; /* may be overridden by -V */ login = (LOGINREC *) calloc(1, sizeof(LOGINREC)); if (!login) { fprintf(stderr, "%s: unable to allocate login structure\n", options->appname); exit(1); } if (-1 == gethostname(options->hostname, sizeof(options->hostname))) { perror("unable to get hostname"); } while ((ch = getopt(argc, argv, "U:P:S:d:D:i:o:e:t:V:hqv")) != -1) { char *p; switch (ch) { case 'U': login->username = strdup(optarg); break; case 'P': login->password = strdup(optarg); memset(optarg, 0, strlen(optarg)); break; case 'S': options->servername = strdup(optarg); break; case 'd': case 'D': options->database = strdup(optarg); break; case 'i': options->input_filename = strdup(optarg); break; case 'o': options->output_filename = strdup(optarg); break; case 'e': options->error_filename = strdup(optarg); break; case 't': unescape(optarg); options->colsep = strdup(optarg); break; case 'h': options->headers = stdout; break; case 'q': options->fquiet = 1; break; case 'V': switch(strtol(optarg, &p, 10)) { case 3: options->odbc_version = SQL_OV_ODBC3 ; break; case 2: options->odbc_version = SQL_OV_ODBC2; break; default: fprintf(stderr, "warning: -V must be 2 or 3, not %s. Using default of 3\n", optarg); break; } case 'v': options->fverbose = 1; break; case '?': default: usage(options->appname); exit(1); } } if (!options->servername) { usage(options->appname); exit(1); } return login; } freetds-1.00.82/src/apps/datacopy.c100644 025423 025423 00000045727 13167106021 0012544/* datacopy - Program to move database table between servers * Copyright (C) 2004-2005 Bill Thompson * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_STRINGS_H #include #endif /* HAVE_STRINGS_H */ #if HAVE_UNISTD_H #include #endif #include #include #if HAVE_LOCALE_H #include #endif #include #include #include "replacements.h" typedef struct { char *user; char *pass; char *server; char *db; char *dbobject; } OBJECTINFO; typedef struct pd { int batchsize; int packetsize; OBJECTINFO src, dest; char *owner; int textsize; int tflag; int aflag; int cflag; int Sflag; int Dflag; int bflag; int pflag; int Eflag; int vflag; } BCPPARAMDATA; static void pusage(void); static int process_parameters(int, char **, struct pd *); static int login_to_databases(const BCPPARAMDATA * pdata, DBPROCESS ** dbsrc, DBPROCESS ** dbdest); static int create_target_table(char *sobjname, char *owner, char *dobjname, DBPROCESS * dbsrc, DBPROCESS * dbdest); static int check_table_structures(char *sobjname, char *dobjname, DBPROCESS * dbsrc, DBPROCESS * dbdest); static int transfer_data(const BCPPARAMDATA * params, DBPROCESS * dbsrc, DBPROCESS * dbdest); static RETCODE set_textsize(DBPROCESS *dbproc, int textsize); static int err_handler(DBPROCESS *, int, int, int, char *, char *); static int msg_handler(DBPROCESS *, DBINT, int, int, char *, char *, char *, int); int tdsdump_open(const char *filename); int main(int argc, char **argv) { BCPPARAMDATA params; DBPROCESS *dbsrc; DBPROCESS *dbtarget; setlocale(LC_ALL, ""); memset(¶ms, '\0', sizeof(params)); if (process_parameters(argc, argv, ¶ms) == FALSE) { pusage(); return 1; } if (login_to_databases(¶ms, &dbsrc, &dbtarget) == FALSE) return 1; if (set_textsize(dbtarget, params.textsize) != SUCCEED || set_textsize(dbsrc, params.textsize) != SUCCEED) return 1; if (params.cflag) { if (create_target_table(params.src.dbobject, params.owner, params.dest.dbobject, dbsrc, dbtarget) == FALSE) { printf("datacopy: could not create target table %s.%s . terminating\n", params.owner, params.dest.dbobject); dbclose(dbsrc); dbclose(dbtarget); return 1; } } if (check_table_structures(params.src.dbobject, params.dest.dbobject, dbsrc, dbtarget) == FALSE) { printf("datacopy: table structures do not match. terminating\n"); dbclose(dbsrc); dbclose(dbtarget); return 1; } if (transfer_data(¶ms, dbsrc, dbtarget) == FALSE) { printf("datacopy: table copy failed.\n"); printf(" the data may have been partially copied into the target database \n"); dbclose(dbsrc); dbclose(dbtarget); return 1; } dbclose(dbsrc); dbclose(dbtarget); return 0; } static char * gets_alloc(void) { char reply[256]; char *p = NULL; if (fgets(reply, sizeof(reply), stdin) != NULL) { p = strchr(reply, '\n'); if (p) *p = 0; p = strdup(reply); } memset(reply, 0, sizeof(reply)); return p; } static int process_objectinfo(OBJECTINFO *oi, char *arg, const char *prompt) { char *tok; tok = strsep(&arg, "/"); if (!tok) return FALSE; oi->server = strdup(tok); tok = strsep(&arg, "/"); if (!tok) return FALSE; oi->user = strdup(tok); tok = strsep(&arg, "/"); if (!tok) return FALSE; if (strcmp(tok,"-") == 0) { printf("%s", prompt); oi->pass = gets_alloc(); } else { oi->pass = strdup(tok); memset(tok, '*', strlen(tok)); } tok = strsep(&arg, "/"); if (!tok) return FALSE; oi->db = strdup(tok); tok = strsep(&arg, "/"); if (!tok) return FALSE; oi->dbobject = strdup(tok); return TRUE; } static int process_parameters(int argc, char **argv, BCPPARAMDATA * pdata) { int opt; /* set some defaults */ pdata->textsize = -1; pdata->batchsize = 1000; /* get the rest of the arguments */ while ((opt = getopt(argc, argv, "b:p:tac:dS:D:T:Ev")) != -1) { switch (opt) { case 'b': pdata->bflag++; pdata->batchsize = atoi(optarg); break; case 'p': pdata->pflag++; pdata->packetsize = atoi(optarg); break; case 't': pdata->tflag++; break; case 'a': pdata->aflag++; break; case 'c': pdata->cflag++; if (optarg[0] == '-') { fprintf(stderr, "Invalid owner specified.\n"); return FALSE; } pdata->owner = strdup(optarg); break; case 'd': tdsdump_open(NULL); break; case 'S': pdata->Sflag++; if (process_objectinfo(&pdata->src, optarg, "Enter Source Password: ") == FALSE) return FALSE; break; case 'D': pdata->Dflag++; if (process_objectinfo(&pdata->dest, optarg, "Enter Destination Password: ") == FALSE) return FALSE; break; case 'T': pdata->textsize = opt = atoi(optarg); if (opt < 0 || opt > 0x7fffffff) { fprintf(stderr, "Invalid textsize specified.\n"); return FALSE; } break; case 'E': pdata->Eflag++; break; case 'v': pdata->vflag++; break; default: return FALSE; } } /* one of these must be specified */ if ((pdata->tflag + pdata->aflag + pdata->cflag) != 1) { fprintf(stderr, "one (and only one) of -t, -a or -c must be specified\n"); return FALSE; } if (!pdata->Sflag) { printf("\nNo [-S]ource information supplied.\n\n"); printf("Enter Server : "); pdata->src.server = gets_alloc(); printf("Enter Login : "); pdata->src.user = gets_alloc(); printf("Enter Password : "); pdata->src.pass = gets_alloc(); printf("Enter Database : "); pdata->src.db = gets_alloc(); printf("Enter Table : "); pdata->src.dbobject = gets_alloc(); } if (!pdata->Dflag) { printf("\nNo [-D]estination information supplied.\n\n"); printf("Enter Server : "); pdata->dest.server = gets_alloc(); printf("Enter Login : "); pdata->dest.user = gets_alloc(); printf("Enter Password : "); pdata->dest.pass = gets_alloc(); printf("Enter Database : "); pdata->dest.db = gets_alloc(); printf("Enter Table : "); pdata->dest.dbobject = gets_alloc(); } return TRUE; } static int login_to_databases(const BCPPARAMDATA * pdata, DBPROCESS ** dbsrc, DBPROCESS ** dbdest) { int result = FALSE; LOGINREC *slogin = NULL; LOGINREC *dlogin = NULL; /* Initialize DB-Library. */ if (dbinit() == FAIL) return FALSE; /* * Install the user-supplied error-handling and message-handling * routines. They are defined at the bottom of this source file. */ dberrhandle(err_handler); dbmsghandle(msg_handler); /* * Allocate and initialize the LOGINREC structure to be used * to open a connection to SQL Server. */ slogin = dblogin(); if (pdata->src.user) DBSETLUSER(slogin, pdata->src.user); if (pdata->src.pass) DBSETLPWD(slogin, pdata->src.pass); if (pdata->src.db) DBSETLDBNAME(slogin, pdata->src.db); DBSETLAPP(slogin, "Migrate Data"); /* if packet size specified, set in login record */ if (pdata->pflag && pdata->packetsize > 0) { DBSETLPACKET(slogin, pdata->packetsize); } /* * Get a connection to the database. */ if ((*dbsrc = dbopen(slogin, pdata->src.server)) == (DBPROCESS *) NULL) { fprintf(stderr, "Can't connect to source server.\n"); goto cleanup; } dlogin = dblogin(); if (pdata->dest.user) DBSETLUSER(dlogin, pdata->dest.user); if (pdata->dest.pass) DBSETLPWD(dlogin, pdata->dest.pass); if (pdata->dest.db) DBSETLDBNAME(dlogin, pdata->dest.db); DBSETLAPP(dlogin, "Migrate Data"); /* Enable bulk copy for this connection. */ BCP_SETL(dlogin, TRUE); /* if packet size specified, set in login record */ if (pdata->pflag && pdata->packetsize > 0) { DBSETLPACKET(dlogin, pdata->packetsize); } /* * Get a connection to the database. */ if ((*dbdest = dbopen(dlogin, pdata->dest.server)) == (DBPROCESS *) NULL) { fprintf(stderr, "Can't connect to destination server.\n"); goto cleanup; } result = TRUE; cleanup: dbloginfree(slogin); dbloginfree(dlogin); return result; } static int create_target_table(char *sobjname, char *owner, char *dobjname, DBPROCESS * dbsrc, DBPROCESS * dbdest) { char ls_command[2048]; int i; const char *sep; DBINT num_cols; DBCOL2 colinfo; sprintf(ls_command, "SET FMTONLY ON select * from %s SET FMTONLY OFF", sobjname); if (dbcmd(dbsrc, ls_command) == FAIL) { printf("dbcmd failed\n"); return FALSE; } if (dbsqlexec(dbsrc) == FAIL) { printf("table %s not found on SOURCE\n", sobjname); return FALSE; } while (dbresults(dbsrc) != NO_MORE_RESULTS) continue; sprintf(ls_command, "CREATE TABLE %s%s%s ", owner, owner[0] ? "." : "", dobjname); num_cols = dbnumcols(dbsrc); sep = "( "; for (i = 1; i <= num_cols; i++) { colinfo.SizeOfStruct = sizeof(colinfo); if (dbtablecolinfo(dbsrc, i, (DBCOL *) &colinfo) != SUCCEED) return FALSE; strlcat(ls_command, sep, sizeof(ls_command)); sep = ", "; strlcat(ls_command, colinfo.Name, sizeof(ls_command)); strlcat(ls_command, " ", sizeof(ls_command)); strlcat(ls_command, colinfo.ServerTypeDeclaration, sizeof(ls_command)); if (colinfo.Null == TRUE) { strlcat(ls_command, " NULL", sizeof(ls_command)); } else { strlcat(ls_command, " NOT NULL", sizeof(ls_command)); } } if (strlcat(ls_command, " )", sizeof(ls_command)) >= sizeof(ls_command)) { fprintf(stderr, "Buffer overflow building command to create table\n"); return FALSE; } if (dbcmd(dbdest, ls_command) == FAIL) { printf("dbcmd failed\n"); return FALSE; } if (dbsqlexec(dbdest) == FAIL) { printf("create table on DESTINATION failed\n"); return FALSE; } while (NO_MORE_RESULTS != dbresults(dbdest)) continue; return TRUE; } static RETCODE set_textsize(DBPROCESS *dbproc, int textsize) { char buf[32]; if (textsize < 0) return SUCCEED; sprintf(buf, "%d", textsize); if (dbsetopt(dbproc, DBTEXTSIZE, buf, -1) == FAIL) { fprintf(stderr, "dbsetopt failed\n"); return FAIL; } return SUCCEED; } static int check_table_structures(char *sobjname, char *dobjname, DBPROCESS * dbsrc, DBPROCESS * dbdest) { char ls_command[256]; int i, ret; DBINT src_numcols = 0; DBINT dest_numcols = 0; DBINT src_coltype, dest_coltype; DBINT src_collen, dest_collen; sprintf(ls_command, "SET FMTONLY ON select * from %s SET FMTONLY OFF", sobjname); if (dbcmd(dbsrc, ls_command) == FAIL) { printf("dbcmd failed\n"); return FALSE; } if (dbsqlexec(dbsrc) == FAIL) { printf("table %s not found on SOURCE\n", sobjname); return FALSE; } while ((ret=dbresults(dbsrc)) == SUCCEED) src_numcols = dbnumcols(dbsrc); if (ret != NO_MORE_RESULTS) { printf("Error in dbresults\n"); return FALSE; } if (0 == src_numcols) { printf("Error in dbnumcols 1\n"); return FALSE; } sprintf(ls_command, "SET FMTONLY ON select * from %s SET FMTONLY OFF", dobjname); if (dbcmd(dbdest, ls_command) == FAIL) { printf("dbcmd failed\n"); return FALSE; } if (dbsqlexec(dbdest) == FAIL) { printf("table %s not found on DEST\n", sobjname); return FALSE; } while ((ret=dbresults(dbdest)) == SUCCEED) dest_numcols = dbnumcols(dbdest); if (ret != NO_MORE_RESULTS) { printf("Error in dbresults\n"); return FALSE; } if (0 == dest_numcols) { printf("Error in dbnumcols 2\n"); return FALSE; } if (src_numcols != dest_numcols) { printf("number of columns do not match. source : %d , dest: %d\n", src_numcols, dest_numcols); return FALSE; } for (i = 1; i <= src_numcols; i++) { src_coltype = dbcoltype(dbsrc, i); src_collen = dbcollen(dbsrc, i); dest_coltype = dbcoltype(dbdest, i); dest_collen = dbcollen(dbdest, i); if ((src_coltype == SYBNUMERIC && dest_coltype == SYBNUMERIC) || (src_coltype == SYBDECIMAL && dest_coltype == SYBDECIMAL) ) { continue; } if (src_coltype != dest_coltype || src_collen != dest_collen) { printf("COLUMN TYPE MISMATCH: column %d\n", i); printf("source: type %d, length %d\n", src_coltype, src_collen); printf("dest : type %d, length %d\n", dest_coltype, dest_collen); return FALSE; } } return TRUE; } static int transfer_data(const BCPPARAMDATA * params, DBPROCESS * dbsrc, DBPROCESS * dbdest) { char ls_command[256]; int col; DBINT src_numcols = 0; typedef struct migcoldata { DBINT coltype; } MIGCOLDATA; MIGCOLDATA *srcdata; DBINT rows_read = 0; DBINT rows_sent = 0; DBINT rows_done = 0; DBINT ret; struct timeval start_time; struct timeval end_time; double elapsed_time; DBCOL2 colinfo; BOOL identity_column_exists = FALSE; if (params->vflag) { printf("\nStarting copy...\n"); } if (params->tflag) { sprintf(ls_command, "truncate table %s", params->dest.dbobject); if (dbcmd(dbdest, ls_command) == FAIL) { printf("dbcmd failed\n"); return FALSE; } if (dbsqlexec(dbdest) == FAIL) { printf("dbsqlexec failed\n"); return FALSE; } if (dbresults(dbdest) == FAIL) { printf("Error in dbresults\n"); return FALSE; } } sprintf(ls_command, "select * from %s", params->src.dbobject); if (dbcmd(dbsrc, ls_command) == FAIL) { printf("dbcmd failed\n"); return FALSE; } if (dbsqlexec(dbsrc) == FAIL) { printf("dbsqlexec failed\n"); return FALSE; } if (NO_MORE_RESULTS != dbresults(dbsrc)) { if (0 == (src_numcols = dbnumcols(dbsrc))) { printf("Error in dbnumcols\n"); return FALSE; } } if (bcp_init(dbdest, params->dest.dbobject, (char *) NULL, (char *) NULL, DB_IN) == FAIL) { printf("Error in bcp_init\n"); return FALSE; } srcdata = (MIGCOLDATA *) calloc(sizeof(MIGCOLDATA), src_numcols); for (col = 0; col < src_numcols; col++) { /* Find out if there is an identity column. */ colinfo.SizeOfStruct = sizeof(colinfo); if (dbtablecolinfo(dbsrc, col+1, (DBCOL *) &colinfo) != SUCCEED) return FALSE; if (colinfo.Identity) identity_column_exists = TRUE; srcdata[col].coltype = dbcoltype(dbsrc, col + 1); switch (srcdata[col].coltype) { case SYBBIT: case SYBINT1: case SYBINT2: case SYBINT4: case SYBINT8: case SYBFLT8: case SYBREAL: case SYBMONEY: case SYBMONEY4: case SYBDATETIME: case SYBDATETIME4: case SYBTIME: case SYBDATE: case SYBBIGTIME: case SYBBIGDATETIME: case SYBCHAR: case SYBTEXT: case SYBBINARY: case SYBIMAGE: case SYBNUMERIC: case SYBDECIMAL: break; default: fprintf(stderr, "Type %d not handled by datacopy\n", srcdata[col].coltype); exit(1); } } /* Take appropriate action if there's an identity column and we've been asked to preserve identity values. */ if (params->Eflag && identity_column_exists) bcp_control(dbdest, BCPKEEPIDENTITY, 1); gettimeofday(&start_time, 0); while (dbnextrow(dbsrc) != NO_MORE_ROWS) { rows_read++; for (col = 0; col < src_numcols; col++) { BYTE *data = dbdata(dbsrc, col + 1); switch (srcdata[col].coltype) { case SYBBIT: case SYBINT1: case SYBINT2: case SYBINT4: case SYBINT8: case SYBFLT8: case SYBREAL: case SYBDATETIME: case SYBDATETIME4: case SYBTIME: case SYBDATE: case SYBBIGTIME: case SYBBIGDATETIME: case SYBMONEY: case SYBMONEY4: case SYBCHAR: case SYBTEXT: case SYBBINARY: case SYBIMAGE: case SYBNUMERIC: case SYBDECIMAL: bcp_colptr(dbdest, data, col + 1); if (data == NULL) { /* NULL data retrieved from source */ bcp_collen(dbdest, 0, col + 1); } else { bcp_collen(dbdest, dbdatlen(dbsrc, col + 1), col + 1); } break; default: fprintf(stderr, "Type %d not handled by datacopy\n", srcdata[col].coltype); exit(1); } } if (bcp_sendrow(dbdest) == FAIL) { fprintf(stderr, "bcp_sendrow failed. \n"); return FALSE; } else { rows_sent++; if (rows_sent == params->batchsize) { ret = bcp_batch(dbdest); if (ret == -1) { printf("bcp_batch error\n"); return FALSE; } else { rows_done += ret; printf("%d rows successfully copied (total %d)\n", ret, rows_done); rows_sent = 0; } } } } if (rows_read) { ret = bcp_done(dbdest); if (ret == -1) { fprintf(stderr, "bcp_done failed. \n"); return FALSE; } else { rows_done += ret; } } gettimeofday(&end_time, 0); elapsed_time = (double) (end_time.tv_sec - start_time.tv_sec) + ((double) (end_time.tv_usec - start_time.tv_usec) / 1000000.00); if (params->vflag) { printf("\n"); printf("rows read : %d\n", rows_read); printf("rows written : %d\n", rows_done); printf("elapsed time (secs) : %f\n", elapsed_time); printf("rows per second : %f\n", rows_done / elapsed_time); } return TRUE; } static void pusage(void) { fprintf(stderr, "usage: datacopy [-t | -a | -c owner] [-b batchsize] [-p packetsize] [-T textsize] [-v] [-d] [-E]\n"); fprintf(stderr, " [-S server/username/password/database/table]\n"); fprintf(stderr, " [-D server/username/password/database/table]\n"); fprintf(stderr, " -t : truncate target table before loading data\n"); fprintf(stderr, " -a : append data to target table\n"); fprintf(stderr, " -c : create table owner.table before loading data\n"); fprintf(stderr, " -b : alter the number of records in each bcp batch\n"); fprintf(stderr, " (larger batch size = faster)\n"); fprintf(stderr, " -p : alter the default TDS packet size from the default\n"); fprintf(stderr, " (larger packet size = faster)\n"); fprintf(stderr, " -T : Text and image size\n"); fprintf(stderr, " -E : keep identity values\n"); fprintf(stderr, " -v : produce verbose output (timings etc.)\n"); fprintf(stderr, " -d : produce TDS DUMP log (serious debug only!)\n"); } static int err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr) { if (dberr) { fprintf(stderr, "Msg %d, Level %d\n", dberr, severity); fprintf(stderr, "%s\n\n", dberrstr); } else { fprintf(stderr, "DB-LIBRARY error:\n\t"); fprintf(stderr, "%s\n", dberrstr); } return INT_CANCEL; } static int msg_handler(DBPROCESS * dbproc, DBINT msgno, int msgstate, int severity, char *msgtext, char *srvname, char *procname, int line) { /* * If it's a database change message, we'll ignore it. * Also ignore language change message. */ if (msgno == 5701 || msgno == 5703) return 0; printf("Msg %ld, Level %d, State %d\n", (long int) msgno, severity, msgstate); if (strlen(srvname) > 0) printf("Server '%s', ", srvname); if (strlen(procname) > 0) printf("Procedure '%s', ", procname); if (line > 0) printf("Line %d", line); printf("\n\t%s\n", msgtext); return 0; } freetds-1.00.82/src/apps/defncopy.c100644 025423 025423 00000053426 13241246021 0012540/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2004-2011 James K. Lowden * * 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 library 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 * Library General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifdef MicrosoftsDbLib #ifdef _WIN32 # pragma warning( disable : 4142 ) # include "win32.microsoft/have.h" # include "../../include/replacements.win32.hacked.h" int getopt(int argc, const char *argv[], char *optstring); # ifndef DBNTWIN32 # define DBNTWIN32 /* * As of Visual Studio .NET 2003, define WIN32_LEAN_AND_MEAN to avoid redefining LPCBYTE in sqlfront.h * Unless it was already defined, undefine it after windows.h has been included. * (windows.h includes a bunch of stuff needed by sqlfront.h. Bleh.) */ # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN_DEFINED_HERE # endif # include # include # ifdef WIN32_LEAN_AND_MEAN_DEFINED_HERE # undef WIN32_LEAN_AND_MEAN_DEFINED_HERE # undef WIN32_LEAN_AND_MEAN # endif # include # include # include #endif /* DBNTWIN32 */ # include "win32.microsoft/syb2ms.h" #endif #endif /* MicrosoftsDbLib */ #include #include #include #if HAVE_ERRNO_H #include #endif #if HAVE_UNISTD_H #include #endif #if HAVE_STDLIB_H #include #endif #if HAVE_STRING_H #include #endif #if HAVE_LIBGEN_H #include #endif #if HAVE_LOCALE_H #include #endif #include #include #ifndef MicrosoftsDbLib #include "replacements.h" #else #ifndef _WIN32 # include "replacements.h" #endif #endif /* MicrosoftsDbLib */ #include #ifndef MicrosoftsDbLib static int err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr); static int msg_handler(DBPROCESS * dbproc, DBINT msgno, int msgstate, int severity, char *msgtext, char *srvname, char *procname, int line); #else static int err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, const char dberrstr[], const char oserrstr[]); static int msg_handler(DBPROCESS * dbproc, DBINT msgno, int msgstate, int severity, const char msgtext[], const char srvname[], const char procname[], unsigned short int line); #endif /* MicrosoftsDbLib */ typedef struct _options { int optind; char *servername, *database, *appname, hostname[128], *input_filename, *output_filename; } OPTIONS; typedef struct _procedure { char name[512], owner[512]; } PROCEDURE; static int print_ddl(DBPROCESS *dbproc, PROCEDURE *procedure); static int print_results(DBPROCESS *dbproc); static LOGINREC* get_login(int argc, char *argv[], OPTIONS *poptions); static void parse_argument(const char argument[], PROCEDURE* procedure); static void usage(const char invoked_as[]); static char * rtrim(char * s); /* global variables */ static OPTIONS options; static char use_statement[512]; /* end global variables */ /** * The purpose of this program is to load or extract the text of a stored procedure. * This first cut does extract only. * TODO: support loading procedures onto the server. */ int main(int argc, char *argv[]) { LOGINREC *login; DBPROCESS *dbproc; PROCEDURE procedure; RETCODE erc; int i, nrows; setlocale(LC_ALL, ""); #ifdef __VMS /* Convert VMS-style arguments to Unix-style */ parse_vms_args(&argc, &argv); #endif /* Initialize db-lib */ #if _WIN32 && defined(MicrosoftsDbLib) LPCSTR msg = dbinit(); if (msg == NULL) { #else erc = dbinit(); if (erc == FAIL) { #endif /* MicrosoftsDbLib */ fprintf(stderr, "%s:%d: dbinit() failed\n", options.appname, __LINE__); exit(1); } memset(&options, 0, sizeof(options)); login = get_login(argc, argv, &options); /* get command-line parameters and call dblogin() */ assert(login != NULL); /* Install our error and message handlers */ dberrhandle(err_handler); dbmsghandle(msg_handler); /* * Override stdin, stdout, and stderr, as required */ if (options.input_filename) { if (freopen(options.input_filename, "rb", stdin) == NULL) { fprintf(stderr, "%s: unable to open %s: %s\n", options.appname, options.input_filename, strerror(errno)); exit(1); } } if (options.output_filename) { if (freopen(options.output_filename, "wb", stdout) == NULL) { fprintf(stderr, "%s: unable to open %s: %s\n", options.appname, options.output_filename, strerror(errno)); exit(1); } } /* Select the specified database, if any */ if (options.database) DBSETLDBNAME(login, options.database); /* * Connect to the server */ dbproc = dbopen(login, options.servername); if (!dbproc) { fprintf(stderr, "There was a problem connecting to the server.\n"); exit(1); } /* * Read the procedure names and move their texts. */ for (i=options.optind; i < argc; i++) { #ifndef MicrosoftsDbLib static const char query[] = " select c.text" #else static const char query[] = " select cast(c.text as text)" #endif /* MicrosoftsDbLib */ ", number " " from syscomments c," " sysobjects o" " where o.id = c.id" " and o.name = '%s'" " and o.uid = user_id('%s')" " and o.type not in ('U', 'S')" /* no user or system tables */ " order by c.number, %sc.colid" ; static const char query_table[] = " execute sp_help '%s.%s' "; parse_argument(argv[i], &procedure); erc = dbfcmd(dbproc, query, procedure.name, procedure.owner, (DBTDS(dbproc) == DBTDS_5_0) ? "c.colid2, ":""); /* Send the query to the server (we could use dbsqlexec(), instead) */ erc = dbsqlsend(dbproc); if (erc == FAIL) { fprintf(stderr, "%s:%d: dbsqlsend() failed\n", options.appname, __LINE__); exit(1); } /* Wait for it to execute */ erc = dbsqlok(dbproc); if (erc == FAIL) { fprintf(stderr, "%s:%d: dbsqlok() failed\n", options.appname, __LINE__); exit(1); } /* Write the output */ nrows = print_results(dbproc); if (0 == nrows) { erc = dbfcmd(dbproc, query_table, procedure.owner, procedure.name); assert(SUCCEED == erc); erc = dbsqlexec(dbproc); if (erc == FAIL) { fprintf(stderr, "%s:%d: dbsqlexec() failed\n", options.appname, __LINE__); exit(1); } nrows = print_ddl(dbproc, &procedure); } switch (nrows) { case -1: return 1; case 0: fprintf(stderr, "%s: error: %s.%s.%s.%s not found\n", options.appname, options.servername, options.database, procedure.owner, procedure.name); return 2; default: break; } } return 0; } static void parse_argument(const char argument[], PROCEDURE* procedure) { const char *s = strchr(argument, '.'); if (s) { size_t len = s - argument; if (len > sizeof(procedure->owner) - 1) len = sizeof(procedure->owner) - 1; memcpy(procedure->owner, argument, len); procedure->owner[len] = '\0'; strlcpy(procedure->name, s+1, sizeof(procedure->name)); } else { strcpy(procedure->owner, "dbo"); strlcpy(procedure->name, argument, sizeof(procedure->name)); } } static char * rtrim(char * s) { char *p = strchr(s, ' '); if (p) *p = '\0'; return s; } /* * Get the table information from sp_help, because it's easier to get the index information (eventually). * The column descriptions are in resultset #2, which is where we start. * As shown below, sp_help returns different columns for resultset #2, so we build a map. * Sybase Microsoft * ----------------- ---------------- * 1. Column_name Column_name * 2. Type Type * 3. Computed * 4. Length Length * 5. Prec Prec * 6. Scale Scale * 7. Nulls Nullable * 8. Default_name TrimTrail * 9. Rule_name FixedLenNullIn * 10. Access_Rule_name Collation * 11. Identity */ static int print_ddl(DBPROCESS *dbproc, PROCEDURE *procedure) { struct DDL { char *name, *type, *length, *precision, *scale, *nullable; } *ddl = NULL; static int microsoft_colmap[6] = {1,2, 4,5,6,7}, sybase_colmap[6] = {1,2,3,4,5,6 }; int *colmap = NULL; FILE *create_index; RETCODE erc; int row_code, iresultset, i, ret; int maxnamelen = 0, nrows = 0; char **p_str; create_index = tmpfile(); assert(dbproc); assert(procedure); assert(create_index); /* sp_help returns several result sets. We want just the second one, for now */ for (iresultset=1; (erc = dbresults(dbproc)) != NO_MORE_RESULTS; iresultset++) { if (erc == FAIL) { fprintf(stderr, "%s:%d: dbresults(), result set %d failed\n", options.appname, __LINE__, iresultset); goto cleanup; } /* Get the data */ while ((row_code = dbnextrow(dbproc)) != NO_MORE_ROWS) { struct DDL *p; char **coldesc[sizeof(struct DDL)/sizeof(char*)]; /* an array of pointers to the DDL elements */ assert(row_code == REG_ROW); /* Look for index data */ if (0 == strcmp("index_name", dbcolname(dbproc, 1))) { char *index_name, *index_description, *index_keys, *p, fprimary=0; DBINT datlen; assert(dbnumcols(dbproc) >=3 ); /* column had better be in range */ /* name */ datlen = dbdatlen(dbproc, 1); index_name = (char *) calloc(1, 1 + datlen); assert(index_name); memcpy(index_name, dbdata(dbproc, 1), datlen); /* kind */ datlen = dbdatlen(dbproc, 2); index_description = (char *) calloc(1, 1 + datlen); assert(index_description); memcpy(index_description, dbdata(dbproc, 2), datlen); /* columns */ datlen = dbdatlen(dbproc, 3); index_keys = (char *) calloc(1, 1 + datlen); assert(index_keys); memcpy(index_keys, dbdata(dbproc, 3), datlen); /* fix up the index attributes; we're going to use the string verbatim (almost). */ p = strstr(index_description, "located"); if (p) { *p = '\0'; /* we don't care where it's located */ } /* Microsoft version: [non]clustered[, unique][, primary key] located on PRIMARY */ p = strstr(index_description, "primary key"); if (p) { fprimary = 1; *p = '\0'; /* we don't care where it's located */ if ((p = strchr(index_description, ',')) != NULL) *p = '\0'; /* we use only the first term (clustered/nonclustered) */ } else { /* reorder "unique" and "clustered" */ char nonclustered[] = "nonclustered", unique[] = "unique"; char *pclustering = nonclustered; if (NULL == strstr(index_description, pclustering)) { pclustering += 3; if (NULL == strstr(index_description, pclustering)) *pclustering = '\0'; } if (NULL == strstr(index_description, unique)) unique[0] = '\0'; sprintf(index_description, "%s %s", unique, pclustering); } /* Put it to a temporary file; we'll print it after the CREATE TABLE statement. */ if (fprimary) { fprintf(create_index, "ALTER TABLE %s.%s ADD CONSTRAINT %s PRIMARY KEY %s (%s)\nGO\n\n", procedure->owner, procedure->name, index_name, index_description, index_keys); } else { fprintf(create_index, "CREATE %s INDEX %s on %s.%s(%s)\nGO\n\n", index_description, index_name, procedure->owner, procedure->name, index_keys); } free(index_name); free(index_description); free(index_keys); continue; } /* skip other resultsets that don't describe the table's columns */ if (0 != strcmp("Column_name", dbcolname(dbproc, 1))) continue; /* Infer which columns we need from their names */ colmap = (0 == strcmp("Computed", dbcolname(dbproc, 3)))? microsoft_colmap : sybase_colmap; /* Make room for the next row */ p = (struct DDL *) realloc(ddl, ++nrows * sizeof(struct DDL)); if (p == NULL) { perror("error: insufficient memory for row DDL"); assert(p != NULL); exit(1); } ddl = p; /* take the address of each member, so we can loop through them */ coldesc[0] = &ddl[nrows-1].name; coldesc[1] = &ddl[nrows-1].type; coldesc[2] = &ddl[nrows-1].length; coldesc[3] = &ddl[nrows-1].precision; coldesc[4] = &ddl[nrows-1].scale; coldesc[5] = &ddl[nrows-1].nullable; for( i=0; i < sizeof(struct DDL)/sizeof(char*); i++) { DBINT datlen = dbdatlen(dbproc, colmap[i]); assert(datlen >= 0); /* column had better be in range */ if (datlen == 0) { *coldesc[i] = NULL; continue; } *coldesc[i] = (char *) calloc(1, 1 + datlen); /* calloc will null terminate */ if( *coldesc[i] == NULL ) { perror("error: insufficient memory for row detail"); assert(*coldesc[i] != NULL); exit(1); } memcpy(*coldesc[i], dbdata(dbproc, colmap[i]), datlen); /* * maxnamelen will determine how much room we allow for column names * in the CREATE TABLE statement */ if (i == 0) maxnamelen = (maxnamelen > datlen)? maxnamelen : datlen; } } /* wend */ } /* * We've collected the description for the columns in the 'ddl' array. * Now we'll print the CREATE TABLE statement in jkl's preferred format. */ if (nrows == 0) goto cleanup; printf("%sCREATE TABLE %s.%s\n", use_statement, procedure->owner, procedure->name); for (i=0; i < nrows; i++) { static const char *varytypenames[] = { "char" , "nchar" , "varchar" , "nvarchar" , "text" , "ntext" , "unichar" , "univarchar" , "binary" , "varbinary" , "image" , NULL }; const char **t; char *type = NULL; int is_null; /* get size of decimal, numeric, char, and image types */ ret = 0; if (0 == strcasecmp("decimal", ddl[i].type) || 0 == strcasecmp("numeric", ddl[i].type)) { if (ddl[i].precision && 0 != strcasecmp("NULL", ddl[i].precision)) { rtrim(ddl[i].precision); rtrim(ddl[i].scale); ret = asprintf(&type, "%s(%s,%s)", ddl[i].type, ddl[i].precision, ddl[i].scale); } } else { for (t = varytypenames; *t; t++) { if (0 == strcasecmp(*t, ddl[i].type)) { ret = asprintf(&type, "%s(%d)", ddl[i].type, *(int*)ddl[i].length); break; } } } assert(ret >= 0); if (colmap == sybase_colmap) is_null = *(int*)ddl[i].nullable == 1; else is_null = (0 == strcasecmp("1", ddl[i].nullable) || 0 == strcasecmp("yes", ddl[i].nullable)); /* {(|,} name type [NOT] NULL */ printf("\t%c %-*s %-15s %3s NULL\n", (i==0? '(' : ','), maxnamelen, ddl[i].name, (type? type : ddl[i].type), (is_null? "" : "NOT")); free(type); } printf("\t)\nGO\n\n"); /* print the CREATE INDEX statements */ rewind(create_index); while ((i = fgetc(create_index)) != EOF) { fputc(i, stdout); } cleanup: p_str = (char **) ddl; for (i=0; i < nrows * (sizeof(struct DDL)/sizeof(char*)); ++i) free(p_str[i]); free(ddl); fclose(create_index); return nrows; } static int /* return count of SQL text rows */ print_results(DBPROCESS *dbproc) { RETCODE erc; int row_code; int iresultset; int nrows=0; int prior_procedure_number=1; /* bound variables */ enum column_id { ctext=1, number=2 }; char sql_text[16002]; int sql_text_status; int procedure_number; /* for create proc abc;2 */ int procedure_number_status; /* * Set up each result set with dbresults() */ for (iresultset=1; (erc = dbresults(dbproc)) != NO_MORE_RESULTS; iresultset++) { if (erc == FAIL) { fprintf(stderr, "%s:%d: dbresults(), result set %d failed\n", options.appname, __LINE__, iresultset); return -1; } if (SUCCEED != DBROWS(dbproc)) { return 0; } /* * Bind the columns to our variables. */ if (sizeof(sql_text) <= dbcollen(dbproc, ctext) ) { assert(sizeof(sql_text) > dbcollen(dbproc, ctext)); return 0; } erc = dbbind(dbproc, ctext, STRINGBIND, 0, (BYTE *) sql_text); if (erc == FAIL) { fprintf(stderr, "%s:%d: dbbind(), column %d failed\n", options.appname, __LINE__, ctext); return -1; } erc = dbnullbind(dbproc, ctext, &sql_text_status); if (erc == FAIL) { fprintf(stderr, "%s:%d: dbnullbind(), column %d failed\n", options.appname, __LINE__, ctext); return -1; } erc = dbbind(dbproc, number, INTBIND, -1, (BYTE *) &procedure_number); if (erc == FAIL) { fprintf(stderr, "%s:%d: dbbind(), column %d failed\n", options.appname, __LINE__, number); return -1; } erc = dbnullbind(dbproc, number, &procedure_number_status); if (erc == FAIL) { fprintf(stderr, "%s:%d: dbnullbind(), column %d failed\n", options.appname, __LINE__, number); return -1; } /* * Print the data to stdout. */ fprintf(stdout, "%s", use_statement); for (;(row_code = dbnextrow(dbproc)) != NO_MORE_ROWS; nrows++, prior_procedure_number = procedure_number) { switch (row_code) { case REG_ROW: if ( -1 == sql_text_status) { fprintf(stderr, "defncopy: error: unexpected NULL row in SQL text\n"); } else { if (prior_procedure_number != procedure_number) fprintf(stdout, "\nGO\n"); fprintf(stdout, "%s", sql_text); } break; case BUF_FULL: default: fprintf(stderr, "defncopy: error: expected REG_ROW (%d), got %d instead\n", REG_ROW, row_code); assert(row_code == REG_ROW); break; } /* row_code */ } /* wend dbnextrow */ fprintf(stdout, "\nGO\n"); } /* wend dbresults */ return nrows; } static void usage(const char invoked_as[]) { fprintf(stderr, "usage: %s \n" " [-U username] [-P password]\n" " [-S servername] [-D database]\n" " [-i input filename] [-o output filename]\n" " [owner.]object_name [[owner.]object_name...]\n" , invoked_as); /** defncopy Syntax Error Usage: defncopy [-v] [-X] -- [-a ] -- [-I ] -- [-J []] -- [-K ] [-P ] -- [-R ] [-S []] [-U ] -- [-V ] -- [-Z ] -- [-z ] { in | out [.] [[.]...] } **/ } static LOGINREC * get_login(int argc, char *argv[], OPTIONS *options) { LOGINREC *login; char *password; int ch; int fdomain = TRUE; extern char *optarg; extern int optind; assert(options && argv); options->appname = basename(argv[0]); login = dblogin(); if (!login) { fprintf(stderr, "%s: unable to allocate login structure\n", options->appname); exit(1); } DBSETLAPP(login, options->appname); if (-1 != gethostname(options->hostname, sizeof(options->hostname))) { DBSETLHOST(login, options->hostname); } while ((ch = getopt(argc, argv, "U:P:S:d:D:i:o:v")) != -1) { switch (ch) { case 'U': DBSETLUSER(login, optarg); fdomain = FALSE; break; case 'P': password = tds_getpassarg(optarg); DBSETLPWD(login, password); memset(password, 0, strlen(password)); free(password); password = NULL; fdomain = FALSE; break; case 'S': options->servername = strdup(optarg); break; case 'd': case 'D': options->database = strdup(optarg); break; case 'i': options->input_filename = strdup(optarg); break; case 'o': options->output_filename = strdup(optarg); break; case 'v': printf("%s\n\n%s", argv[0], "Copyright (C) 2004 James K. Lowden\n" "This program is free software; you can redistribute it and/or\n" "modify it under the terms of the GNU General Public\n" "License as published by the Free Software Foundation\n"); exit(1); break; case '?': default: usage(options->appname); exit(1); } } #ifdef MicrosoftsDbLib #if _WIN32 if (fdomain) DBSETLSECURE(login); #endif #endif /* MicrosoftsDbLib */ if (!options->servername) { usage(options->appname); exit(1); } options->optind = optind; return login; } static int #ifndef MicrosoftsDbLib err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr) #else err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, const char dberrstr[], const char oserrstr[]) #endif /* MicrosoftsDbLib */ { if (dberr) { fprintf(stderr, "%s: Msg %d, Level %d\n", options.appname, dberr, severity); fprintf(stderr, "%s\n\n", dberrstr); } else { fprintf(stderr, "%s: DB-LIBRARY error:\n\t", options.appname); fprintf(stderr, "%s\n", dberrstr); } return INT_CANCEL; } static int #ifndef MicrosoftsDbLib msg_handler(DBPROCESS * dbproc, DBINT msgno, int msgstate, int severity, char *msgtext, char *srvname, char *procname, int line) #else msg_handler(DBPROCESS * dbproc, DBINT msgno, int msgstate, int severity, const char msgtext[], const char srvname[], const char procname[], unsigned short int line) #endif /* MicrosoftsDbLib */ { char *dbname, *endquote; switch (msgno) { case 5701: /* Print "USE dbname" for "Changed database context to 'dbname'" */ dbname = strchr(msgtext, '\''); if (!dbname) break; endquote = strchr(++dbname, '\''); if (!endquote) break; *endquote = '\0'; sprintf(use_statement, "USE %s\nGO\n\n", dbname); return 0; case 0: /* Ignore print messages */ case 5703: /* Ignore "Changed language setting to ". */ return 0; default: break; } #if 0 printf("Msg %ld, Severity %d, State %d\n", (long) msgno, severity, msgstate); if (strlen(srvname) > 0) printf("Server '%s', ", srvname); if (strlen(procname) > 0) printf("Procedure '%s', ", procname); if (line > 0) printf("Line %d", line); #endif printf("\t/* %s */\n", msgtext); return 0; } freetds-1.00.82/src/apps/freebcp.c100644 025423 025423 00000046423 12734165421 0012350/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns * Copyright (C) 2011 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #if HAVE_ERRNO_H #include #endif /* HAVE_ERRNO_H */ #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ /* These should be in stdlib */ #ifndef EXIT_SUCCESS #define EXIT_SUCCESS 0 #endif #ifndef EXIT_FAILURE #define EXIT_FAILURE 1 #endif #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_STRINGS_H #include #endif /* HAVE_STRINGS_H */ #if HAVE_UNISTD_H #include #endif #if HAVE_LOCALE_H #include #endif #include #include "replacements.h" #include #include #include "freebcp.h" void pusage(void); int process_parameters(int, char **, struct pd *); static int unescape(char arg[]); int login_to_database(struct pd *, DBPROCESS **); int file_character(BCPPARAMDATA * pdata, DBPROCESS * dbproc, DBINT dir); int file_native(BCPPARAMDATA * pdata, DBPROCESS * dbproc, DBINT dir); int file_formatted(BCPPARAMDATA * pdata, DBPROCESS * dbproc, DBINT dir); int setoptions (DBPROCESS * dbproc, BCPPARAMDATA * params); int err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr); int msg_handler(DBPROCESS * dbproc, DBINT msgno, int msgstate, int severity, char *msgtext, char *srvname, char *procname, int line); static int set_bcp_hints(BCPPARAMDATA *pdata, DBPROCESS *pdbproc); int main(int argc, char **argv) { BCPPARAMDATA params; DBPROCESS *dbproc; int ok = FALSE; setlocale(LC_ALL, ""); #ifdef __VMS /* Convert VMS-style arguments to Unix-style */ parse_vms_args(&argc, &argv); #endif memset(¶ms, '\0', sizeof(params)); params.textsize = 4096; /* our default text size is 4K */ if (process_parameters(argc, argv, ¶ms) == FALSE) { exit(EXIT_FAILURE); } if (getenv("FREEBCP")) { fprintf(stderr, "User name: \"%s\"\n", params.user); } if (login_to_database(¶ms, &dbproc) == FALSE) { exit(EXIT_FAILURE); } if (!setoptions(dbproc, ¶ms)) return FALSE; if (params.cflag) { /* character format file */ ok = file_character(¶ms, dbproc, params.direction); } else if (params.nflag) { /* native format file */ ok = file_native(¶ms, dbproc, params.direction); } else if (params.fflag) { /* formatted file */ ok = file_formatted(¶ms, dbproc, params.direction); } else { ok = FALSE; } exit((ok == TRUE) ? EXIT_SUCCESS : EXIT_FAILURE); return 0; } static int unescape(char arg[]) { char *p = arg, *next; char escaped; while ((next = strchr(p, '\\')) != NULL) { p = next; switch (p[1]) { case '0': escaped = '\0'; break; case 't': escaped = '\t'; break; case 'r': escaped = '\r'; break; case 'n': escaped = '\n'; break; case '\\': escaped = '\\'; break; default: ++p; continue; } /* Overwrite the backslash with the intended character, and shift everything down one */ *p++ = escaped; memmove(p, p+1, 1 + strlen(p+1)); } return strchr(p, 0) - arg; } int process_parameters(int argc, char **argv, BCPPARAMDATA *pdata) { extern char *optarg; extern int optind; extern int optopt; int ch; if (argc < 6) { pusage(); return (FALSE); } /* * Set some defaults and read the table, file, and direction arguments. */ pdata->firstrow = 0; pdata->lastrow = 0; pdata->batchsize = 1000; pdata->maxerrors = 10; /* argument 1 - the database object */ pdata->dbobject = strdup(argv[1]); if (pdata->dbobject == NULL) { fprintf(stderr, "Out of memory!\n"); return FALSE; } /* argument 2 - the direction */ strlcpy(pdata->dbdirection, argv[2], sizeof(pdata->dbdirection)); if (strcasecmp(pdata->dbdirection, "in") == 0) { pdata->direction = DB_IN; } else if (strcasecmp(pdata->dbdirection, "out") == 0) { pdata->direction = DB_OUT; } else if (strcasecmp(pdata->dbdirection, "queryout") == 0) { pdata->direction = DB_QUERYOUT; } else { fprintf(stderr, "Copy direction must be either 'in', 'out' or 'queryout'.\n"); return (FALSE); } /* argument 3 - the datafile name */ free(pdata->hostfilename); pdata->hostfilename = strdup(argv[3]); /* * Get the rest of the arguments */ optind = 4; /* start processing options after table, direction, & filename */ while ((ch = getopt(argc, argv, "m:f:e:F:L:b:t:r:U:P:i:I:S:h:T:A:o:O:0:C:ncEdvVD:")) != -1) { switch (ch) { case 'v': case 'V': printf("freebcp version %s\n", TDS_VERSION_NO); return FALSE; break; case 'm': pdata->mflag++; pdata->maxerrors = atoi(optarg); break; case 'f': pdata->fflag++; free(pdata->formatfile); pdata->formatfile = strdup(optarg); break; case 'e': pdata->eflag++; pdata->errorfile = strdup(optarg); break; case 'F': pdata->Fflag++; pdata->firstrow = atoi(optarg); break; case 'L': pdata->Lflag++; pdata->lastrow = atoi(optarg); break; case 'b': pdata->bflag++; pdata->batchsize = atoi(optarg); break; case 'n': pdata->nflag++; break; case 'c': pdata->cflag++; break; case 'E': pdata->Eflag++; break; case 'd': tdsdump_open(NULL); break; case 't': pdata->tflag++; pdata->fieldterm = strdup(optarg); pdata->fieldtermlen = unescape(pdata->fieldterm); break; case 'r': pdata->rflag++; pdata->rowterm = strdup(optarg); pdata->rowtermlen = unescape(pdata->rowterm); break; case 'U': pdata->Uflag++; pdata->user = strdup(optarg); break; case 'P': pdata->Pflag++; pdata->pass = tds_getpassarg(optarg); break; case 'i': free(pdata->inputfile); pdata->inputfile = strdup(optarg); break; case 'I': pdata->Iflag++; free(pdata->interfacesfile); pdata->interfacesfile = strdup(optarg); break; case 'S': pdata->Sflag++; pdata->server = strdup(optarg); break; case 'D': pdata->dbname = strdup(optarg); break; case 'h': pdata->hint = strdup(optarg); break; case 'o': free(pdata->outputfile); pdata->outputfile = strdup(optarg); break; case 'O': case '0': pdata->options = strdup(optarg); break; case 'T': pdata->Tflag++; pdata->textsize = atoi(optarg); break; case 'A': pdata->Aflag++; pdata->packetsize = atoi(optarg); break; case 'C': pdata->charset = strdup(optarg); break; case '?': default: pusage(); return (FALSE); } } /* * Check for required/disallowed option combinations * If no username is provided, rely on domain login. */ /* Server */ if (!pdata->Sflag) { if ((pdata->server = getenv("DSQUERY")) != NULL) { pdata->server = strdup(pdata->server); /* can be freed */ pdata->Sflag++; } else { fprintf(stderr, "-S must be supplied.\n"); return (FALSE); } } /* Only one of these can be specified */ if (pdata->cflag + pdata->nflag + pdata->fflag != 1) { fprintf(stderr, "Exactly one of options -c, -n, -f must be supplied.\n"); return (FALSE); } /* Character mode file: fill in default values */ if (pdata->cflag) { if (!pdata->tflag || !pdata->fieldterm) { /* field terminator not specified */ pdata->fieldterm = "\t"; pdata->fieldtermlen = 1; } if (!pdata->rflag || !pdata->rowterm) { /* row terminator not specified */ pdata->rowterm = "\n"; pdata->rowtermlen = 1; } } /* * Override stdin and/or stdout if requested. */ /* FIXME -- Since we don't implement prompting for field data types when neither -c nor -n * is specified, redirecting stdin doesn't do much yet. */ if (pdata->inputfile) { if (freopen(pdata->inputfile, "rb", stdin) == NULL) { fprintf(stderr, "%s: unable to open %s: %s\n", "freebcp", pdata->inputfile, strerror(errno)); exit(EXIT_FAILURE); } } if (pdata->outputfile) { if (freopen(pdata->outputfile, "wb", stdout) == NULL) { fprintf(stderr, "%s: unable to open %s: %s\n", "freebcp", pdata->outputfile, strerror(errno)); exit(EXIT_FAILURE); } } return (TRUE); } int login_to_database(BCPPARAMDATA * pdata, DBPROCESS ** pdbproc) { LOGINREC *login; /* Initialize DB-Library. */ if (dbinit() == FAIL) return (FALSE); /* * Install the user-supplied error-handling and message-handling * routines. They are defined at the bottom of this source file. */ dberrhandle(err_handler); dbmsghandle(msg_handler); /* If the interfaces file was specified explicitly, set it. */ if (pdata->interfacesfile != NULL) dbsetifile(pdata->interfacesfile); /* * Allocate and initialize the LOGINREC structure to be used * to open a connection to SQL Server. */ login = dblogin(); if (!login) return FALSE; if (pdata->user) DBSETLUSER(login, pdata->user); if (pdata->pass) { DBSETLPWD(login, pdata->pass); memset(pdata->pass, 0, strlen(pdata->pass)); } DBSETLAPP(login, "FreeBCP"); if (pdata->charset) DBSETLCHARSET(login, pdata->charset); if (pdata->Aflag && pdata->packetsize > 0) { DBSETLPACKET(login, pdata->packetsize); } if (pdata->dbname) DBSETLDBNAME(login, pdata->dbname); /* Enable bulk copy for this connection. */ BCP_SETL(login, TRUE); /* * Get a connection to the database. */ if ((*pdbproc = dbopen(login, pdata->server)) == NULL) { fprintf(stderr, "Can't connect to server \"%s\".\n", pdata->server); dbloginfree(login); return (FALSE); } dbloginfree(login); login = NULL; return (TRUE); } int file_character(BCPPARAMDATA * pdata, DBPROCESS * dbproc, DBINT dir) { DBINT li_rowsread = 0; int i; int li_numcols = 0; RETCODE ret_code = 0; if (FAIL == bcp_init(dbproc, pdata->dbobject, pdata->hostfilename, pdata->errorfile, dir)) return FALSE; if (!set_bcp_hints(pdata, dbproc)) return FALSE; if (pdata->Eflag) { bcp_control(dbproc, BCPKEEPIDENTITY, 1); if (dbfcmd(dbproc, "set identity_insert %s on", pdata->dbobject) == FAIL) { printf("dbfcmd failed\n"); return FALSE; } if (dbsqlexec(dbproc) == FAIL) { printf("dbsqlexec failed\n"); return FALSE; } while (NO_MORE_RESULTS != dbresults(dbproc)) continue; } bcp_control(dbproc, BCPFIRST, pdata->firstrow); bcp_control(dbproc, BCPLAST, pdata->lastrow); bcp_control(dbproc, BCPMAXERRS, pdata->maxerrors); if (dir == DB_QUERYOUT) { if (dbfcmd(dbproc, "SET FMTONLY ON %s SET FMTONLY OFF", pdata->dbobject) == FAIL) { printf("dbfcmd failed\n"); return FALSE; } } else { if (dbfcmd(dbproc, "SET FMTONLY ON select * from %s SET FMTONLY OFF", pdata->dbobject) == FAIL) { printf("dbfcmd failed\n"); return FALSE; } } if (dbsqlexec(dbproc) == FAIL) { printf("dbsqlexec failed\n"); return FALSE; } while (NO_MORE_RESULTS != (ret_code = dbresults(dbproc))) { if (ret_code == SUCCEED && li_numcols == 0) { li_numcols = dbnumcols(dbproc); } } if (0 == li_numcols) { printf("Error in dbnumcols\n"); return FALSE; } if (bcp_columns(dbproc, li_numcols) == FAIL) { printf("Error in bcp_columns.\n"); return FALSE; } for (i = 1; i < li_numcols; ++i) { if (bcp_colfmt(dbproc, i, SYBCHAR, 0, -1, (const BYTE *) pdata->fieldterm, pdata->fieldtermlen, i) == FAIL) { printf("Error in bcp_colfmt col %d\n", i); return FALSE; } } if (bcp_colfmt(dbproc, li_numcols, SYBCHAR, 0, -1, (const BYTE *) pdata->rowterm, pdata->rowtermlen, li_numcols) == FAIL) { printf("Error in bcp_colfmt col %d\n", li_numcols); return FALSE; } bcp_control(dbproc, BCPBATCH, pdata->batchsize); printf("\nStarting copy...\n"); if (FAIL == bcp_exec(dbproc, &li_rowsread)) { fprintf(stderr, "bcp copy %s failed\n", (dir == DB_IN) ? "in" : "out"); return FALSE; } printf("%d rows copied.\n", li_rowsread); return TRUE; } int file_native(BCPPARAMDATA * pdata, DBPROCESS * dbproc, DBINT dir) { DBINT li_rowsread = 0; int i; int li_numcols = 0; int li_coltype; RETCODE ret_code = 0; if (FAIL == bcp_init(dbproc, pdata->dbobject, pdata->hostfilename, pdata->errorfile, dir)) return FALSE; if (!set_bcp_hints(pdata, dbproc)) return FALSE; if (pdata->Eflag) { bcp_control(dbproc, BCPKEEPIDENTITY, 1); if (dbfcmd(dbproc, "set identity_insert %s on", pdata->dbobject) == FAIL) { printf("dbfcmd failed\n"); return FALSE; } if (dbsqlexec(dbproc) == FAIL) { printf("dbsqlexec failed\n"); return FALSE; } while (NO_MORE_RESULTS != dbresults(dbproc)) continue; } bcp_control(dbproc, BCPFIRST, pdata->firstrow); bcp_control(dbproc, BCPLAST, pdata->lastrow); bcp_control(dbproc, BCPMAXERRS, pdata->maxerrors); if (dir == DB_QUERYOUT) { if (dbfcmd(dbproc, "SET FMTONLY ON %s SET FMTONLY OFF", pdata->dbobject) == FAIL) { printf("dbfcmd failed\n"); return FALSE; } } else { if (dbfcmd(dbproc, "SET FMTONLY ON select * from %s SET FMTONLY OFF", pdata->dbobject) == FAIL) { printf("dbfcmd failed\n"); return FALSE; } } if (dbsqlexec(dbproc) == FAIL) { printf("dbsqlexec failed\n"); return FALSE; } while (NO_MORE_RESULTS != (ret_code = dbresults(dbproc))) { if (ret_code == SUCCEED && li_numcols == 0) { li_numcols = dbnumcols(dbproc); } } if (0 == li_numcols) { printf("Error in dbnumcols\n"); return FALSE; } if (bcp_columns(dbproc, li_numcols) == FAIL) { printf("Error in bcp_columns.\n"); return FALSE; } for (i = 1; i <= li_numcols; i++) { li_coltype = dbcoltype(dbproc, i); if (bcp_colfmt(dbproc, i, li_coltype, -1, -1, NULL, -1, i) == FAIL) { printf("Error in bcp_colfmt col %d\n", i); return FALSE; } } printf("\nStarting copy...\n\n"); if (FAIL == bcp_exec(dbproc, &li_rowsread)) { fprintf(stderr, "bcp copy %s failed\n", (dir == DB_IN) ? "in" : "out"); return FALSE; } printf("%d rows copied.\n", li_rowsread); return TRUE; } int file_formatted(BCPPARAMDATA * pdata, DBPROCESS * dbproc, DBINT dir) { int li_rowsread; if (FAIL == bcp_init(dbproc, pdata->dbobject, pdata->hostfilename, pdata->errorfile, dir)) return FALSE; if (!set_bcp_hints(pdata, dbproc)) return FALSE; if (pdata->Eflag) { bcp_control(dbproc, BCPKEEPIDENTITY, 1); if (dbfcmd(dbproc, "set identity_insert %s on", pdata->dbobject) == FAIL) { printf("dbfcmd failed\n"); return FALSE; } if (dbsqlexec(dbproc) == FAIL) { printf("dbsqlexec failed\n"); return FALSE; } while (NO_MORE_RESULTS != dbresults(dbproc)) continue; } bcp_control(dbproc, BCPFIRST, pdata->firstrow); bcp_control(dbproc, BCPLAST, pdata->lastrow); bcp_control(dbproc, BCPMAXERRS, pdata->maxerrors); if (FAIL == bcp_readfmt(dbproc, pdata->formatfile)) return FALSE; printf("\nStarting copy...\n\n"); if (FAIL == bcp_exec(dbproc, &li_rowsread)) { fprintf(stderr, "bcp copy %s failed\n", (dir == DB_IN) ? "in" : "out"); return FALSE; } printf("%d rows copied.\n", li_rowsread); return TRUE; } int setoptions(DBPROCESS * dbproc, BCPPARAMDATA * params) { RETCODE fOK; if (dbfcmd(dbproc, "set textsize %d ", params->textsize) == FAIL) { fprintf(stderr, "setoptions() could not set textsize at %s:%d\n", __FILE__, __LINE__); return FALSE; } /* * If the option is a filename, read the SQL text from the file. * Else pass the option verbatim to the server. */ if (params->options) { FILE *optFile; char optBuf[256]; if ((optFile = fopen(params->options, "r")) == NULL) { if (dbcmd(dbproc, params->options) == FAIL) { fprintf(stderr, "setoptions() failed preparing options at %s:%d\n", __FILE__, __LINE__); return FALSE; } } else { while (fgets (optBuf, sizeof(optBuf), optFile) != NULL) { if (dbcmd(dbproc, optBuf) == FAIL) { fprintf(stderr, "setoptions() failed preparing options at %s:%d\n", __FILE__, __LINE__); fclose(optFile); return FALSE; } } if (!feof (optFile)) { perror("freebcp"); fprintf(stderr, "error reading options file \"%s\" at %s:%d\n", params->options, __FILE__, __LINE__); fclose(optFile); return FALSE; } fclose(optFile); } } if (dbsqlexec(dbproc) == FAIL) { fprintf(stderr, "setoptions() failed sending options at %s:%d\n", __FILE__, __LINE__); return FALSE; } while ((fOK = dbresults(dbproc)) == SUCCEED) { while ((fOK = dbnextrow(dbproc)) == REG_ROW) continue; if (fOK == FAIL) { fprintf(stderr, "setoptions() failed sending options at %s:%d\n", __FILE__, __LINE__); return FALSE; } } if (fOK == FAIL) { fprintf(stderr, "setoptions() failed sending options at %s:%d\n", __FILE__, __LINE__); return FALSE; } return TRUE; } static int set_bcp_hints(BCPPARAMDATA *pdata, DBPROCESS *pdbproc) { /* set hint if any */ if (pdata->hint) { if (bcp_options(pdbproc, BCPHINTS, (BYTE *) pdata->hint, strlen(pdata->hint)) != SUCCEED) { fprintf(stderr, "db-lib: Unable to set hint \"%s\"\n", pdata->hint); return FALSE; } } return TRUE; } void pusage(void) { fprintf(stderr, "usage: freebcp [[database_name.]owner.]table_name|query {in | out | queryout } datafile\n"); fprintf(stderr, " [-m maxerrors] [-f formatfile] [-e errfile]\n"); fprintf(stderr, " [-F firstrow] [-L lastrow] [-b batchsize]\n"); fprintf(stderr, " [-n] [-c] [-t field_terminator] [-r row_terminator]\n"); fprintf(stderr, " [-U username] [-P password] [-I interfaces_file] [-S server] [-D database]\n"); fprintf(stderr, " [-v] [-d] [-h \"hint [,...]\" [-O \"set connection_option on|off, ...]\"\n"); fprintf(stderr, " [-A packet size] [-T text or image size] [-E]\n"); fprintf(stderr, " [-i input_file] [-o output_file]\n"); fprintf(stderr, " \n"); fprintf(stderr, "example: freebcp testdb.dbo.inserttest in inserttest.txt -S mssql -U guest -P password -c\n"); } int err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr) { static int sent = 0; if (dberr == SYBEBBCI) { /* Batch successfully bulk copied to the server */ int batch = bcp_getbatchsize(dbproc); printf("%d rows sent to SQL Server.\n", sent += batch); return INT_CANCEL; } if (dberr) { fprintf(stderr, "Msg %d, Level %d\n", dberr, severity); fprintf(stderr, "%s\n\n", dberrstr); } else { fprintf(stderr, "DB-LIBRARY error:\n\t"); fprintf(stderr, "%s\n", dberrstr); } return INT_CANCEL; } int msg_handler(DBPROCESS * dbproc, DBINT msgno, int msgstate, int severity, char *msgtext, char *srvname, char *procname, int line) { /* * If it's a database change message, we'll ignore it. * Also ignore language change message. */ if (msgno == 5701 || msgno == 5703) return (0); printf("Msg %ld, Level %d, State %d\n", (long) msgno, severity, msgstate); if (strlen(srvname) > 0) printf("Server '%s', ", srvname); if (strlen(procname) > 0) printf("Procedure '%s', ", procname); if (line > 0) printf("Line %d", line); printf("\n\t%s\n", msgtext); return (0); } freetds-1.00.82/src/apps/freebcp.h100644 025423 025423 00000002042 12717145107 0012342enum states { GET_NEXTARG, GET_MAXERRORS, GET_FORMATFILE, GET_ERRORFILE, GET_FIRSTROW, GET_LASTROW, GET_BATCHSIZE, GET_FIELDTERM, GET_ROWTERM, GET_USER, GET_PASS, GET_INTERFACESFILE, GET_SERVER, GET_DISPLAYCHARSET, GET_DATAFILECHARSET, GET_LANGUAGE, GET_PACKETSIZE, GET_CLIENTCHARSET, GET_TEXTSIZE, GET_SYBASEDIR, GET_FROMLABEL, GET_TOLABEL, GET_HINT }; typedef struct pd { char *dbobject; char dbdirection[10]; DBINT direction; char *hostfilename; char *formatfile; char *errorfile; char *interfacesfile; int firstrow; int lastrow; int batchsize; int maxerrors; int textsize; char *fieldterm; int fieldtermlen; char *rowterm; int rowtermlen; char *user; char *pass; char *server; char *dbname; char *hint; char *options; char *charset; int packetsize; int mflag; int fflag; int eflag; int Fflag; int Lflag; int bflag; int nflag; int cflag; int tflag; int rflag; int Uflag; int Iflag; int Sflag; int Pflag; int Tflag; int Aflag; int Eflag; char *inputfile; char *outputfile; } BCPPARAMDATA; freetds-1.00.82/src/apps/tsql.c100644 025423 025423 00000054722 12717145107 0011726/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns * Copyright (C) 2006-2015 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #include #include #if HAVE_FORK #include #endif #include #ifdef HAVE_READLINE #include #include #endif /* HAVE_READLINE */ #if HAVE_ERRNO_H #include #endif /* HAVE_ERRNO_H */ #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_UNISTD_H # include #elif defined(_WIN32) # include # undef isatty # define isatty(fd) _isatty(fd) #endif /* HAVE_UNISTD_H */ /* HP-UX require some constants defined by limits.h */ #ifdef HAVE_LIMITS_H #include #endif /* HAVE_LIMITS_H */ #if defined(__hpux__) && !defined(_POSIX_PATH_MAX) #define _POSIX_PATH_MAX 255 #endif #ifdef HAVE_LOCALE_H #include #endif /* HAVE_LOCALE_H */ #ifdef HAVE_LANGINFO_H #include #endif /* HAVE_LANGINFO_H */ #ifdef HAVE_LOCALCHARSET_H #include #endif /* HAVE_LOCALCHARSET_H */ #include #include #include #include #include #include "replacements.h" #define TDS_ISSPACE(c) isspace((unsigned char) (c)) enum { OPT_VERSION = 0x01, OPT_TIMER = 0x02, OPT_NOFOOTER = 0x04, OPT_NOHEADER = 0x08, OPT_QUIET = 0x10, OPT_VERBOSE = 0x20, OPT_INSTANCES= 0x40 }; static int istty = 0; static int global_opt_flags = 0; #define QUIET (global_opt_flags & OPT_QUIET) #define VERBOSE (global_opt_flags & OPT_VERBOSE) static const char *opt_col_term = "\t"; static const char *opt_row_term = "\n"; static const char *opt_default_db = NULL; static int do_query(TDSSOCKET * tds, char *buf, int opt_flags); static int get_opt_flags(char *s, int *opt_flags); static void populate_login(TDSLOGIN * login, int argc, char **argv); static int tsql_handle_message(const TDSCONTEXT * context, TDSSOCKET * tds, TDSMESSAGE * msg); static int tsql_handle_error (const TDSCONTEXT * context, TDSSOCKET * tds, TDSMESSAGE * msg); static void slurp_input_file(char *fname, char **mybuf, size_t *bufsz, size_t *buflen, int *line); static char * tsql_readline(char *prompt) { size_t sz, pos; char *line, *p; #ifdef HAVE_READLINE if (istty) return readline(prompt); #endif sz = 1024; pos = 0; line = tds_new(char, sz); if (!line) return NULL; if (prompt && prompt[0]) printf("%s", prompt); for (;;) { /* read a piece */ if (fgets(line + pos, (int)(sz - pos), stdin) == NULL) { if (pos) return line; break; } /* got end-of-line ? */ p = strchr(line + pos, '\n'); if (p) { *p = 0; return line; } /* allocate space if needed */ pos += strlen(line + pos); if (pos + 1024 >= sz) { sz += 1024; p = (char*) realloc(line, sz); if (!p) break; line = p; } } free(line); return NULL; } static void tsql_add_history(const char *s) { #ifdef HAVE_READLINE if (istty) add_history(s); #endif } /** * Returns the version of the TDS protocol in effect for the link * as a decimal integer. * Typical returned values are 42, 50, 70, 80. * Also fills pversion_string unless it is null. * Typical pversion_string values are "4.2" and "7.0". */ static int tds_version(TDSCONNECTION * conn, char *pversion_string) { int iversion = 0; iversion = 10 * TDS_MAJOR(conn) + TDS_MINOR(conn); sprintf(pversion_string, "%d.%d", TDS_MAJOR(conn), TDS_MINOR(conn)); return iversion; } static int do_query(TDSSOCKET * tds, char *buf, int opt_flags) { int rows = 0; TDSRET rc; int i; TDSCOLUMN *col; int ctype; CONV_RESULT dres; unsigned char *src; TDS_INT srclen; TDS_INT resulttype; struct timeval start, stop; int print_rows = 1; char message[128]; rc = tds_submit_query(tds, buf); if (TDS_FAILED(rc)) { fprintf(stderr, "tds_submit_query() failed\n"); return 1; } while ((rc = tds_process_tokens(tds, &resulttype, NULL, TDS_TOKEN_RESULTS)) == TDS_SUCCESS) { const int stop_mask = TDS_STOPAT_ROWFMT|TDS_RETURN_DONE|TDS_RETURN_ROW|TDS_RETURN_COMPUTE; if (opt_flags & OPT_TIMER) { gettimeofday(&start, NULL); print_rows = 0; } switch (resulttype) { case TDS_ROWFMT_RESULT: if ((!(opt_flags & OPT_NOHEADER)) && tds->current_results) { for (i = 0; i < tds->current_results->num_cols; i++) { if (i) fputs(opt_col_term, stdout); fputs(tds_dstr_cstr(&tds->current_results->columns[i]->column_name), stdout); } fputs(opt_row_term, stdout); } break; case TDS_COMPUTE_RESULT: case TDS_ROW_RESULT: rows = 0; while ((rc = tds_process_tokens(tds, &resulttype, NULL, stop_mask)) == TDS_SUCCESS) { if (resulttype != TDS_ROW_RESULT && resulttype != TDS_COMPUTE_RESULT) break; rows++; if (!tds->current_results) continue; for (i = 0; i < tds->current_results->num_cols; i++) { col = tds->current_results->columns[i]; if (col->column_cur_size < 0) { if (print_rows) { if (i) fputs(opt_col_term, stdout); fputs("NULL", stdout); } continue; } ctype = tds_get_conversion_type(col->column_type, col->column_size); src = col->column_data; if (is_blob_col(col) && col->column_type != SYBVARIANT) src = (unsigned char *) ((TDSBLOB *) src)->textvalue; srclen = col->column_cur_size; if (tds_convert(tds_get_ctx(tds), ctype, (TDS_CHAR *) src, srclen, SYBVARCHAR, &dres) < 0) continue; if (print_rows) { if (i) fputs(opt_col_term, stdout); fputs(dres.c, stdout); } free(dres.c); } if (print_rows) fputs(opt_row_term, stdout); } if (!QUIET) fprintf(stdout, "(%d row%s affected)\n", rows, rows == 1 ? "" : "s"); break; case TDS_STATUS_RESULT: if (!QUIET) printf("(return status = %d)\n", tds->ret_status); break; default: break; } if (opt_flags & OPT_VERSION) { char version[64]; int line = 0; line = tds_version(tds->conn, version); if (line) { TDSMESSAGE msg; memset(&msg, 0, sizeof(TDSMESSAGE)); msg.server = "tsql"; sprintf(message, "using TDS version %s", version); msg.message = message; tsql_handle_message(tds_get_ctx(tds), tds, &msg); } } if (opt_flags & OPT_TIMER) { TDSMESSAGE msg; gettimeofday(&stop, NULL); sprintf(message, "Total time for processing %d rows: %ld msecs\n", rows, (long) ((stop.tv_sec - start.tv_sec) * 1000) + ((stop.tv_usec - start.tv_usec) / 1000)); memset(&msg, 0, sizeof(TDSMESSAGE)); msg.server = "tsql"; msg.message = message; tsql_handle_message(tds_get_ctx(tds), tds, &msg); } } return 0; } static void tsql_print_usage(const char *progname) { fprintf(stderr, "Usage:\t%s [-a ] [-S | -H -p ] -U [-P ] [-I ] [-o ] [-t delim] [-r delim] [-D database]\n" "\t%s -C\n" "Options:\n" "\tf\tDo not print footer\n" "\th\tDo not print header\n" "\tt\tPrint time informations\n" "\tv\tPrint TDS version\n" "\tq\tQuiet\n\n" "\tDelimiters can be multi-char strings appropriately escaped for your shell.\n" "\tDefault column delimitor is ; default row delimiter is \n", progname, progname); } static void reset_getopt(void) { #ifdef HAVE_GETOPT_OPTRESET optreset = 1; optind = 1; #else optind = 0; #endif } /* * The 'GO' command may be followed by options that apply to the batch. * If they don't appear to be right, assume the letters "go" are part of the * SQL, not a batch separator. */ static int get_opt_flags(char *s, int *opt_flags) { char **argv; int argc; int opt; /* make sure we have enough elements */ assert(s && opt_flags); argv = tds_new0(char*, strlen(s) + 2); if (!argv) return 0; /* parse the command line and assign to argv */ for (argc=0; (argv[argc] = strtok(s, " ")) != NULL; argc++) s = NULL; *opt_flags = 0; reset_getopt(); opterr = 0; /* suppress error messages */ while ((opt = getopt(argc, argv, "fhLqtv")) != -1) { switch (opt) { case 'f': *opt_flags |= OPT_NOFOOTER; break; case 'h': *opt_flags |= OPT_NOHEADER; break; case 't': *opt_flags |= OPT_TIMER; break; case 'v': *opt_flags |= OPT_VERSION; break; case 'q': *opt_flags |= OPT_QUIET; break; default: fprintf(stderr, "Warning: invalid option '%s' found: \"go\" treated as simple SQL\n", argv[optind-1]); free(argv); return 0; } } free(argv); return 1; } static int get_default_instance_port(const char hostname[]) { int port; struct addrinfo *addr; if ((addr = tds_lookup_host(hostname)) == NULL) return 0; port = tds7_get_instance_port(addr, "MSSQLSERVER"); freeaddrinfo(addr); return port; } #if !defined(LC_ALL) # define LC_ALL 0 #endif #ifdef HAVE_SSPI const char have_sspi[] = "yes"; #else const char have_sspi[] = "no"; #endif #ifdef ENABLE_KRB5 const char enable_krb5[] = "yes"; #else const char enable_krb5[] = "no"; #endif static void populate_login(TDSLOGIN * login, int argc, char **argv) { const TDS_COMPILETIME_SETTINGS *settings; char *hostname = NULL, *servername = NULL; char *username = NULL, *password = NULL; char *confile = NULL; const char *appname = "TSQL"; int opt, port=0, use_domain_login=0; char *charset = NULL; char *opt_flags_str = NULL; while ((opt = getopt(argc, argv, "a:H:S:I:J:P:U:p:Co:t:r:D:Lv")) != -1) { switch (opt) { case 'a': appname = optarg; break; case 't': opt_col_term = optarg; break; case 'r': opt_row_term = optarg; break; case 'D': opt_default_db = optarg; break; case 'o': opt_flags_str = optarg; break; case 'H': free(hostname); hostname = strdup(optarg); break; case 'S': free(servername); servername = strdup(optarg); break; case 'U': free(username); username = strdup(optarg); break; case 'P': free(password); password = tds_getpassarg(optarg); break; case 'I': free(confile); confile = strdup(optarg); break; case 'J': free(charset); charset = strdup(optarg); break; case 'p': port = atoi(optarg); break; case 'L': global_opt_flags |= OPT_INSTANCES; break; case 'v': global_opt_flags |= OPT_VERBOSE; break; case 'C': settings = tds_get_compiletime_settings(); printf("%s\n%35s: %s\n%35s: %s\n%35s: %s\n%35s: %s\n%35s: %s\n%35s: %s\n%35s: %s\n%35s: %s\n%35s: %s\n%35s: %s\n%35s: %s\n%35s: %s\n%35s: %s\n%35s: %s\n", "Compile-time settings (established with the \"configure\" script)", "Version", settings->freetds_version, "freetds.conf directory", settings->sysconfdir, /* settings->last_update */ "MS db-lib source compatibility", settings->msdblib ? "yes" : "no", "Sybase binary compatibility", (settings->sybase_compat == -1 ? "unknown" : (settings->sybase_compat ? "yes" : "no")), "Thread safety", settings->threadsafe ? "yes" : "no", "iconv library", settings->libiconv ? "yes" : "no", "TDS version", settings->tdsver, "iODBC", settings->iodbc ? "yes" : "no", "unixodbc", settings->unixodbc ? "yes" : "no", "SSPI \"trusted\" logins", have_sspi, "Kerberos", enable_krb5, "OpenSSL", settings->openssl ? "yes" : "no", "GnuTLS", settings->gnutls ? "yes" : "no", "MARS", settings->mars ? "yes" : "no"); exit(0); break; default: tsql_print_usage(argv[0]); exit(1); break; } } if (opt_flags_str != NULL) { char *minus_flags = tds_new(char, strlen(opt_flags_str) + 5); if (minus_flags != NULL) { strcpy(minus_flags, "go -"); strcat(minus_flags, opt_flags_str); get_opt_flags(minus_flags, &global_opt_flags); free(minus_flags); } } if ((global_opt_flags & OPT_INSTANCES) && hostname) { struct addrinfo *addr; char *filename = getenv("TDSDUMP"); if (filename) { if (asprintf(&filename, "%s.instances", filename) < 0) exit(1); tdsdump_open(filename); free(filename); } if ((addr = tds_lookup_host(hostname)) != NULL) { tds7_get_instance_ports(stderr, addr); freeaddrinfo(addr); } tdsdump_close(); exit(0); } /* validate parameters */ if (!servername && !hostname) { fprintf(stderr, "%s: error: Missing argument -S or -H\n", argv[0]); exit(1); } if (hostname && !port) { /* * TODO: It would be convenient to have a function that looks up a reasonable port based on: * - TDSPORT environment variable * - config files * - get_default_instance_port * - TDS version * in that order. */ if (!QUIET) { printf("Missing argument -p, looking for default instance ... "); } if (0 == (port = get_default_instance_port(hostname))) { fprintf(stderr, "%s: no default port provided by host %s\n", argv[0], hostname); exit(1); } if (!QUIET) printf("found default instance, port %d\n", port); } /* A NULL username indicates a domain (trusted) login */ if (!username) { username = tds_new0(char, 1); use_domain_login = 1; } if (!password) { password = tds_new0(char, 128); if (!use_domain_login) readpassphrase("Password: ", password, 128, RPP_ECHO_OFF); } if (!opt_col_term) { fprintf(stderr, "%s: missing delimiter for -t (check escaping)\n", argv[0]); exit(1); } if (!opt_row_term) { fprintf(stderr, "%s: missing delimiter for -r (check escaping)\n", argv[0]); exit(1); } /* all validated, let's do it */ if (!tds_set_user(login, username) || !tds_set_app(login, appname) || !tds_set_library(login, "TDS-Library") || !tds_set_language(login, "us_english") || !tds_set_passwd(login, password)) goto out_of_memory; if (charset && !tds_set_client_charset(login, charset)) goto out_of_memory; /* if it's a servername */ if (servername) { if (!tds_set_server(login, servername)) goto out_of_memory; if (confile) { tds_set_interfaces_file_loc(confile); } /* else we specified hostname/port */ } else { if (!tds_set_server(login, hostname)) goto out_of_memory; tds_set_port(login, port); } memset(password, 0, strlen(password)); /* free up all the memory */ free(confile); free(hostname); free(username); free(password); free(servername); free(charset); return; out_of_memory: fprintf(stderr, "%s: out of memory\n", argv[0]); exit(1); } static int tsql_handle_message(const TDSCONTEXT * context, TDSSOCKET * tds, TDSMESSAGE * msg) { if (msg->msgno == 0) { fprintf(stderr, "%s\n", msg->message); return 0; } switch (msg->msgno) { case 5701: /* changed_database */ case 5703: /* changed_language */ case 20018: /* The @optional_command_line is too long */ if (VERBOSE) fprintf(stderr, "%s\n", msg->message); break; default: fprintf(stderr, "Msg %d (severity %d, state %d) from %s", msg->msgno, msg->severity, msg->state, msg->server); if (msg->proc_name && strlen(msg->proc_name)) fprintf(stderr, ", Procedure %s", msg->proc_name); if (msg->line_number > 0) fprintf(stderr, " Line %d", msg->line_number); fprintf(stderr, ":\n\t\"%s\"\n", msg->message); break; } return 0; } static int /* error from library, not message from server */ tsql_handle_error(const TDSCONTEXT * context, TDSSOCKET * tds, TDSMESSAGE * msg) { fprintf(stderr, "Error %d (severity %d):\n\t%s\n", msg->msgno, msg->severity, msg->message); if (0 != msg->oserr) { fprintf(stderr, "\tOS error %d, \"%s\"\n", msg->oserr, strerror(msg->oserr)); } return TDS_INT_CANCEL; } static void slurp_input_file(char *fname, char **mybuf, size_t *bufsz, size_t *buflen, int *line) { FILE *fp = NULL; register char *n; char linebuf[1024]; char *s = NULL; if ((fp = fopen(fname, "r")) == NULL) { fprintf(stderr, "Unable to open input file '%s': %s\n", fname, strerror(errno)); return; } while ((s = fgets(linebuf, sizeof(linebuf), fp)) != NULL) { while (*buflen + strlen(s) + 2 > *bufsz) { *bufsz *= 2; *mybuf = (char *) realloc(*mybuf, *bufsz); } strcpy(*mybuf + *buflen, s); *buflen += strlen(*mybuf + *buflen); n = strrchr(s, '\n'); if (n != NULL) *n = '\0'; tsql_add_history(s); (*line)++; } fclose(fp); } static void print_instance_data(TDSLOGIN *login) { if (!login) return; if (!tds_dstr_isempty(&login->instance_name)) printf("connecting to instance %s on port %d\n", tds_dstr_cstr(&login->instance_name), login->port); } int main(int argc, char **argv) { char *s = NULL, *s2 = NULL, *cmd = NULL; char prompt[20]; int line = 0; char *mybuf; size_t bufsz = 4096; size_t buflen = 0; TDSSOCKET *tds; TDSLOGIN *login; TDSCONTEXT *context; TDSLOGIN *connection; int opt_flags = 0; #if HAVE_FORK pid_t timer_pid = 0; int pipes[2]; #endif const char *locale = NULL; const char *charset = NULL; istty = isatty(0); if (INITSOCKET()) { fprintf(stderr, "Unable to initialize sockets\n"); return 1; } setlocale(LC_ALL, ""); /* grab a login structure */ login = tds_alloc_login(1); context = tds_alloc_context(NULL); if (context->locale && !context->locale->date_fmt) { /* set default in case there's no locale file */ context->locale->date_fmt = strdup(STD_DATETIME_FMT); } context->msg_handler = tsql_handle_message; context->err_handler = tsql_handle_error; /* process all the command line args into the login structure */ populate_login(login, argc, argv); /* Try to open a connection */ tds = tds_alloc_socket(context, 512); assert(tds); tds_set_parent(tds, NULL); connection = tds_read_config_info(tds, login, context->locale); if (!connection) return 1; locale = setlocale(LC_ALL, NULL); #if HAVE_LOCALE_CHARSET charset = locale_charset(); #endif #if HAVE_NL_LANGINFO && defined(CODESET) if (!charset) charset = nl_langinfo(CODESET); #endif if (locale) if (!QUIET) printf("locale is \"%s\"\n", locale); if (charset) { if (!QUIET) printf("locale charset is \"%s\"\n", charset); } if (tds_dstr_isempty(&connection->client_charset)) { if (!charset) charset = "ISO-8859-1"; if (!tds_set_client_charset(login, charset)) return 1; if (!tds_dstr_dup(&connection->client_charset, &login->client_charset)) return 1; } if (!QUIET) printf("using default charset \"%s\"\n", tds_dstr_cstr(&connection->client_charset)); if (opt_default_db) { if (!tds_dstr_copy(&connection->database, opt_default_db)) return 1; if (!QUIET) fprintf(stderr, "Setting %s as default database in login packet\n", opt_default_db); } /* * If we're able to establish an ip address for the server, we'll try to connect to it. * If that machine is currently unreachable, show a timer connecting to the server. */ #if HAVE_FORK if (connection && !QUIET) { /* * We use a pipe so that the child is killed even main program aborts. * Note that we do not read or write from this pipe. */ if (pipe(pipes) < 0) { perror("tsql: pipe"); return 1; } timer_pid = fork(); if (-1 == timer_pid) { perror("tsql: warning"); /* make a note */ } if (0 == timer_pid) { int i=0; close(pipes[1]); while(1) { fd_set set; struct timeval tv; FD_ZERO(&set); FD_SET(pipes[0], &set); tv.tv_sec = 1; tv.tv_usec = 0; if (select(pipes[0] + 1, &set, NULL, &set, &tv) != 0) return 0; fprintf(stderr, "\r%2d", ++i); } } close(pipes[0]); } #endif if (!connection || TDS_FAILED(tds_connect_and_login(tds, connection))) { if (VERBOSE) print_instance_data(connection); tds_free_socket(tds); tds_free_login(login); tds_free_context(context); fprintf(stderr, "There was a problem connecting to the server\n"); exit(1); } if (VERBOSE) print_instance_data(connection); tds_free_login(connection); /* give the buffer an initial size */ bufsz = 4096; mybuf = tds_new(char, bufsz); mybuf[0] = '\0'; buflen = 0; #if defined(HAVE_READLINE) && HAVE_RL_INHIBIT_COMPLETION rl_inhibit_completion = 1; #endif #if HAVE_FORK if (timer_pid > 0 ) { close(pipes[1]); if (wait(0) == -1 ) { perror("tsql: warning"); } else { fprintf(stderr, "\r"); } } #endif for (s=NULL, s2=NULL; ; free(s), free(s2), s2=NULL) { sprintf(prompt, "%d> ", ++line); s = tsql_readline(QUIET ? NULL : prompt); if (s == NULL) break; /* * 'GO' is special only at the start of a line * The rest of the line may include options that apply to the batch, * and perhaps whitespace. */ if (0 == strncasecmp(s, "go", 2) && (strlen(s) == 2 || TDS_ISSPACE(s[2]))) { char *go_line = strdup(s); assert(go_line); line = 0; if (get_opt_flags(go_line, &opt_flags)) { free(go_line); opt_flags ^= global_opt_flags; do_query(tds, mybuf, opt_flags); mybuf[0] = '\0'; buflen = 0; continue; } free(go_line); } /* skip leading whitespace */ if ((s2 = strdup(s)) == NULL) { /* copy to mangle with strtok() */ perror("tsql: "); exit(1); } if ((cmd = strtok(s2, " \t")) == NULL) cmd = ""; if (!strcasecmp(cmd, "exit") || !strcasecmp(cmd, "quit") || !strcasecmp(cmd, "bye")) break; if (!strcasecmp(cmd, "version")) { tds_version(tds->conn, mybuf); printf("using TDS version %s\n", mybuf); line = 0; mybuf[0] = '\0'; buflen = 0; continue; } if (!strcasecmp(cmd, "reset")) { line = 0; mybuf[0] = '\0'; buflen = 0; } else if (!strcasecmp(cmd, ":r")) { slurp_input_file(strtok(NULL, " \t"), &mybuf, &bufsz, &buflen, &line); } else { while (buflen + strlen(s) + 2 > bufsz) { char *newbuf; bufsz *= 2; if ((newbuf = (char *) realloc(mybuf, bufsz)) == NULL) { perror("tsql: "); exit(1); } mybuf = newbuf; } tsql_add_history(s); strcpy(mybuf + buflen, s); /* preserve line numbering for the parser */ strcat(mybuf + buflen, "\n"); buflen += strlen(mybuf + buflen); } } /* close up shop */ free(mybuf); tds_close_socket(tds); tds_free_socket(tds); tds_free_login(login); tds_free_context(context); DONESOCKET(); return 0; } freetds-1.00.82/src/apps/CMakeLists.txt100644 025423 025423 00000000730 12522201763 0013320set(libs ${lib_NETWORK} ${lib_BASE}) foreach(target freebcp bsqldb defncopy datacopy) add_executable(${target} ${target}.c) target_link_libraries(${target} sybdb replacements ${libs}) endforeach(target) add_executable(tsql tsql.c) target_link_libraries(tsql tds replacements ${lib_READLINE} ${libs}) if(WIN32) set(libs odbc32 ${lib_NETWORK} ${lib_BASE}) endif(WIN32) add_executable(bsqlodbc bsqlodbc.c) target_link_libraries(bsqlodbc tdsodbc replacements ${libs}) freetds-1.00.82/src/apps/fisql/Makefile.am100644 025423 025423 00000000606 12717145107 0013741# $Id: Makefile.am,v 1.5 2011-06-08 09:25:52 freddy77 Exp $ AM_CPPFLAGS = -I$(top_srcdir)/include if !MINGW32 bin_PROGRAMS = fisql fisql_SOURCES = fisql.c \ terminal.h terminal.c \ edit.h edit.c \ handlers.h handlers.c \ interrupt.h interrupt.c fisql_LDADD = ../../dblib/libsybdb.la \ ../../replacements/libreplacements.la \ $(LTLIBICONV) $(READLINE_LIBS) endif freetds-1.00.82/src/apps/fisql/Makefile.in100644 025423 025423 00000054554 13242511111 0013747# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # $Id: Makefile.am,v 1.5 2011-06-08 09:25:52 freddy77 Exp $ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @MINGW32_FALSE@bin_PROGRAMS = fisql$(EXEEXT) subdir = src/apps/fisql ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = \ $(top_srcdir)/m4/ac_caolan_func_which_gethostbyname_r.m4 \ $(top_srcdir)/m4/ac_have_inaddr_none.m4 \ $(top_srcdir)/m4/ac_have_malloc_options.m4 \ $(top_srcdir)/m4/ac_nullzero.m4 \ $(top_srcdir)/m4/ac_raf_func_which_getservbyname_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_gethostbyaddr_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_getpwuid_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_localtime_r.m4 \ $(top_srcdir)/m4/acx_pthread.m4 \ $(top_srcdir)/m4/ax_cflags_gcc_option.m4 \ $(top_srcdir)/m4/check_openssl.m4 \ $(top_srcdir)/m4/gettimemilli.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/pushlibs.m4 \ $(top_srcdir)/m4/sprintf_i64_format.m4 \ $(top_srcdir)/m4/type_socklen_t.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" PROGRAMS = $(bin_PROGRAMS) am__fisql_SOURCES_DIST = fisql.c terminal.h terminal.c edit.h edit.c \ handlers.h handlers.c interrupt.h interrupt.c @MINGW32_FALSE@am_fisql_OBJECTS = fisql.$(OBJEXT) terminal.$(OBJEXT) \ @MINGW32_FALSE@ edit.$(OBJEXT) handlers.$(OBJEXT) \ @MINGW32_FALSE@ interrupt.$(OBJEXT) fisql_OBJECTS = $(am_fisql_OBJECTS) am__DEPENDENCIES_1 = @MINGW32_FALSE@fisql_DEPENDENCIES = ../../dblib/libsybdb.la \ @MINGW32_FALSE@ ../../replacements/libreplacements.la \ @MINGW32_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(fisql_SOURCES) DIST_SOURCES = $(am__fisql_SOURCES_DIST) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp \ $(top_srcdir)/mkinstalldirs DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BUILD_NUMBER = @BUILD_NUMBER@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOXYGEN = @DOXYGEN@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FREETDS_LIBGCC = @FREETDS_LIBGCC@ FREETDS_ODBC_MODULE = @FREETDS_ODBC_MODULE@ FREETDS_SYMBOLIC = @FREETDS_SYMBOLIC@ GCRYPT_CFLAGS = @GCRYPT_CFLAGS@ GCRYPT_LIBS = @GCRYPT_LIBS@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ HAVE_OPENSSL = @HAVE_OPENSSL@ HAVE_PERL_SOURCES = @HAVE_PERL_SOURCES@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBADD_DL = @LIBADD_DL@ LIBADD_DLD_LINK = @LIBADD_DLD_LINK@ LIBADD_DLOPEN = @LIBADD_DLOPEN@ LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@ LIBICONV = @LIBICONV@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBOBJS = @LTLIBOBJS@ LT_DLLOADERS = @LT_DLLOADERS@ LT_DLPREOPEN = @LT_DLPREOPEN@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ NETTLE_CFLAGS = @NETTLE_CFLAGS@ NETTLE_LIBS = @NETTLE_LIBS@ NETWORK_LIBS = @NETWORK_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ODBC = @ODBC@ ODBCINSTLIB = @ODBCINSTLIB@ ODBCLIB = @ODBCLIB@ ODBCNODMLIB = @ODBCNODMLIB@ ODBCNODMLIBAPP = @ODBCNODMLIBAPP@ ODBC_CONFIG = @ODBC_CONFIG@ ODBC_INC = @ODBC_INC@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ RC = @RC@ READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SUBVERSION = @SUBVERSION@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ dblib_define = @dblib_define@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ tds_sysdep_int16_type = @tds_sysdep_int16_type@ tds_sysdep_int32_type = @tds_sysdep_int32_type@ tds_sysdep_int64_type = @tds_sysdep_int64_type@ tds_sysdep_intptr_type = @tds_sysdep_intptr_type@ tds_sysdep_real32_type = @tds_sysdep_real32_type@ tds_sysdep_real64_type = @tds_sysdep_real64_type@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = -I$(top_srcdir)/include @MINGW32_FALSE@fisql_SOURCES = fisql.c \ @MINGW32_FALSE@ terminal.h terminal.c \ @MINGW32_FALSE@ edit.h edit.c \ @MINGW32_FALSE@ handlers.h handlers.c \ @MINGW32_FALSE@ interrupt.h interrupt.c @MINGW32_FALSE@fisql_LDADD = ../../dblib/libsybdb.la \ @MINGW32_FALSE@ ../../replacements/libreplacements.la \ @MINGW32_FALSE@ $(LTLIBICONV) $(READLINE_LIBS) all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/apps/fisql/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/apps/fisql/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ fi; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p \ || test -f $$p1 \ ; then echo "$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n;h' \ -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) files[d] = files[d] " " $$1; \ else { print "f", $$3 "/" $$4, $$1; } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ } \ ; done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ -e 's/$$/$(EXEEXT)/' \ `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(bindir)" && rm -f $$files clean-binPROGRAMS: @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list fisql$(EXEEXT): $(fisql_OBJECTS) $(fisql_DEPENDENCIES) $(EXTRA_fisql_DEPENDENCIES) @rm -f fisql$(EXEEXT) $(AM_V_CCLD)$(LINK) $(fisql_OBJECTS) $(fisql_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/edit.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fisql.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/handlers.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/interrupt.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/terminal.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(PROGRAMS) installdirs: for dir in "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-binPROGRAMS install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \ clean-binPROGRAMS clean-generic clean-libtool cscopelist-am \ ctags ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-binPROGRAMS \ 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-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-binPROGRAMS .PRECIOUS: Makefile # 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: freetds-1.00.82/src/apps/fisql/fisql.c100644 025423 025423 00000046044 13167106021 0013165/* Free ISQL - An isql for DB-Library (C) 2007 Nicholas S. Castellano * * 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 library 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 * Library General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #include #include #include #include #include #ifdef HAVE_READLINE #include #include #endif #if HAVE_LOCALE_H #include #endif #if HAVE_SYS_TYPES_H #include #endif /* HAVE_SYS_TYPES_H */ #if HAVE_SYS_STAT_H #include #endif /* HAVE_SYS_STAT_H */ #include #include #include "terminal.h" #include "edit.h" #include "handlers.h" #include "interrupt.h" #include "replacements.h" #define READPASSPHRASE_MAXLEN 128 #ifndef HAVE_READLINE static FILE *rl_outstream = NULL; static FILE *rl_instream = NULL; static const char *rl_readline_name = NULL; static char * fisql_readline(char *prompt) { size_t sz, pos; char *line, *p; sz = 1024; pos = 0; line = (char*) malloc(sz); if (!line) return NULL; if (prompt && prompt[0]) fprintf(rl_outstream ? rl_outstream : stdout, "%s", prompt); for (;;) { /* read a piece */ if (fgets(line + pos, sz - pos, rl_instream ? rl_instream : stdin) == NULL) { if (pos) return line; break; } /* got end-of-line ? */ p = strchr(line + pos, '\n'); if (p) { *p = 0; return line; } /* allocate space if needed */ pos += strlen(line + pos); if (pos + 1024 >= sz) { sz += 1024; p = (char*) realloc(line, sz); if (!p) break; line = p; } } free(line); return NULL; } static void fisql_add_history(const char *s) { } #define readline fisql_readline #define add_history fisql_add_history #define rl_bind_key(c,f) do {} while(0) #define rl_reset_line_state() do {} while(0) #define rl_on_new_line() do {} while(0) #endif #if !HAVE_RL_ON_NEW_LINE && !defined(rl_on_new_line) #define rl_on_new_line() do {} while(0) #endif #if !HAVE_RL_RESET_LINE_STATE && !defined(rl_reset_line_state) #define rl_reset_line_state() do {} while(0) #endif static void *xmalloc(size_t s); static void *xrealloc(void *p, size_t s); static int get_printable_size(int type, int size); static int get_printable_column_size(DBPROCESS * dbproc, int col); static void * xmalloc(size_t s) { void *p = malloc(s); if (!p) { fprintf(stderr, "Out of memory\n"); exit(EXIT_FAILURE); } return p; } static void * xrealloc(void *p, size_t s) { p = realloc(p, s); if (!p) { fprintf(stderr, "Out of memory\n"); exit(EXIT_FAILURE); } return p; } /* adapted from src/dblib/dblib.c (via src/apps/bsqldb.c) */ static int get_printable_size(int type, int size) { switch (type) { case SYBINTN: switch (size) { case 1: return 3; case 2: return 6; case 4: return 11; case 8: return 21; } case SYBINT1: return 3; case SYBINT2: return 6; case SYBINT4: return 11; case SYBINT8: return 21; case SYBVARCHAR: case SYBCHAR: return size; case SYBFLT8: return 11; /* FIX ME -- we do not track precision */ case SYBREAL: return 11; /* FIX ME -- we do not track precision */ case SYBMONEY: return 12; /* FIX ME */ case SYBMONEY4: return 12; /* FIX ME */ case SYBDATETIME: case SYBDATETIME4: case SYBDATETIMN: return 26; /* FIX ME */ #if 0 /* seems not to be exported to sybdb.h */ case SYBBITN: #endif case SYBBIT: return 1; /* FIX ME -- not all types present */ default: return 0; } } static int get_printable_column_size(DBPROCESS * dbproc, int col) { int collen; collen = get_printable_size(dbcoltype(dbproc, col), dbcollen(dbproc, col)); if (strlen(dbcolname(dbproc, col)) > collen) { collen = strlen(dbcolname(dbproc, col)); } return collen; } int main(int argc, char *argv[]) { int echo = 0; #ifdef notyet int print_statistics = 0; #endif int fipsflagger = 0; int perfstats = 0; int no_prompt = 0; int use_encryption = 0; int chained_transactions = 0; const char *cmdend = "go"; int headers = 0; char *columnwidth = NULL; const char *colseparator = " "; const char *lineseparator = "\n"; int timeout = 0; char *username = NULL; char *password = NULL; char *server = NULL; DBCHAR *char_set = NULL; const char *editor; char *hostname = NULL; char *sqlch; char *interfaces_filename = NULL; char *input_filename = NULL; char *output_filename = NULL; int logintime = -1; char *language = NULL; int size = 0; char *sybenv; DBPROCESS *dbproc; LOGINREC *login; char **ibuf = NULL; int ibuflines = 0; int printedlines; int i; char *line; int dbrc; char foobuf[512]; char *firstword; char *cp; int c; int errflg = 0; char *prbuf; int prbuflen; FILE *fp; FILE *tmpfp; FILE *tmpfp2; char *tfn; char tmpfn[256]; int num_cols; int selcol; int col; int collen; DBINT colid; const char *opname; char adbuf[512]; DBINT convlen; int printedcompute = 0; char adash; const char *database_name = NULL; int default_exit = EXIT_SUCCESS; setlocale(LC_ALL, ""); #ifdef __VMS /* Convert VMS-style arguments to Unix-style */ parse_vms_args(&argc, &argv); #endif editor = getenv("EDITOR"); if (!editor) { editor = getenv("VISUAL"); } if (!editor) { editor = "vi"; } opterr = 0; optarg = NULL; while (!errflg && (c = getopt(argc, argv, "eFgpnvXYa:c:D:E:h:H:i:I:J:l:m:o:P:s:S:t:U:w:y:z:A:")) != -1) { switch (c) { case 'e': echo = 1; break; case 'F': fipsflagger = 1; break; case 'g': errflg++; break; case 'p': errflg++; perfstats = 1; break; case 'n': no_prompt = 1; break; case 'v': puts("fisql, a free isql replacement by Nicholas S. Castellano"); exit(EXIT_SUCCESS); break; case 'X': /* XXX: We get a different error message than isql gives; neither seems * to work */ use_encryption = 1; break; case 'Y': chained_transactions = 1; break; case 'c': cmdend = optarg; break; case 'E': editor = optarg; break; case 'h': headers = atoi(optarg); break; case 'H': hostname = optarg; break; case 'i': input_filename = optarg; break; case 'I': interfaces_filename = optarg; break; case 'J': errflg++; break; case 'l': logintime = atoi(optarg); break; case 'm': global_errorlevel = atoi(optarg); break; case 'o': output_filename = optarg; break; case 'P': password = optarg; break; case 's': colseparator = optarg; break; case 'S': server = optarg; break; case 't': timeout = atoi(optarg); break; case 'U': username = optarg; break; case 'w': columnwidth = optarg; break; case 'y': /* XXX: this doesn't seem to be what isql does with -y...it doesn't * seem to do anything actually */ sybenv = (char *) xmalloc((strlen(optarg) + 8) * sizeof(char)); strcpy(sybenv, "SYBASE="); strcat(sybenv, optarg); putenv(sybenv); break; case 'z': language = optarg; break; case 'A': size = atoi(optarg); break; case 'D': database_name = optarg; break; default: errflg++; break; } } if (errflg) { fprintf(stderr, "usage: fisql [-e] [-F] [-g] [-p] [-n] [-v] [-X] [-Y]\n"); fprintf(stderr, "\t[-c cmdend] [-D database_name] [-E editor]\n"); fprintf(stderr, "\t[-h headers] [-H hostname] [-i inputfile]\n"); fprintf(stderr, "\t[-I interfaces_file] [-J client character set]\n"); fprintf(stderr, "\t[-l login_timeout] [-m errorlevel]\n"); fprintf(stderr, "\t[-o outputfile]\n"); fprintf(stderr, "\t[-P password] [-s colseparator] [-S server]\n"); fprintf(stderr, "\t[-t timeout] [-U username] [-w columnwidth]\n"); fprintf(stderr, "\t[-y sybase_dir] [-z language]\n"); exit(EXIT_FAILURE); } if (!(isatty(fileno(stdin)))) { no_prompt = 1; rl_outstream = fopen("/dev/null", "rw"); } rl_readline_name = "fisql"; rl_bind_key('\t', rl_insert); if (password == NULL) { password = (char *) xmalloc(READPASSPHRASE_MAXLEN); readpassphrase("Password: ", password, READPASSPHRASE_MAXLEN, RPP_ECHO_OFF); } if (input_filename) { if (freopen(input_filename, "r", stdin) == NULL) { /* XXX: sybase isql generates this error while parsing the options, * but doesn't redirect the input until after the Password: prompt */ /* lack of newline for bug-compatibility with isql */ fprintf(stderr, "Unable to open input file '%s'.", optarg); exit(EXIT_FAILURE); } } if (output_filename) { if (freopen(output_filename, "w", stdout) == NULL) { /* XXX: sybase isql generates this error while parsing the options, * but doesn't redirect the output until after the Password: prompt */ /* lack of newline for bug-compatibility with isql */ fprintf(stderr, "Unable to open output file '%s'.", output_filename); exit(EXIT_FAILURE); } } if (isatty(fileno(stdin))) { rl_outstream = stdout; } dbinit(); #if 0 #ifdef DBVERSION_100 dbsetversion(DBVERSION_100); #endif #endif if ((login = dblogin()) == NULL) { reset_term(); exit(EXIT_FAILURE); } dbmsghandle(msg_handler); dberrhandle(err_handler); DBSETLAPP(login, "fisql"); if (username) { DBSETLUSER(login, username); } DBSETLPWD(login, password); memset(password, 0, strlen(password)); if (char_set) { DBSETLCHARSET(login, char_set); } if (use_encryption) { DBSETLENCRYPT(login, TRUE); } if (hostname) { DBSETLHOST(login, hostname); } if (language) { DBSETLNATLANG(login, language); } if (size) { DBSETLPACKET(login, (short) size); } if (interfaces_filename) { dbsetifile(interfaces_filename); } dbsettime(timeout); if (logintime >= 0) { dbsetlogintime(logintime); } if (database_name) { DBSETLDBNAME(login, database_name); } if ((dbproc = dbopen(login, server)) == NULL) { fprintf(stderr, "fisql: dbopen() failed.\n"); reset_term(); exit(EXIT_FAILURE); } dbsetopt(dbproc, DBPRLINESEP, lineseparator, strlen(lineseparator)); if (colseparator) { dbsetopt(dbproc, DBPRCOLSEP, colseparator, strlen(colseparator)); } if (columnwidth) { dbsetopt(dbproc, DBPRLINELEN, columnwidth, 0); } if (chained_transactions) { dbsetopt(dbproc, DBCHAINXACTS, NULL, 0); } if (fipsflagger) { dbsetopt(dbproc, DBFIPSFLAG, NULL, 0); } if (perfstats) { dbsetopt(dbproc, DBSTAT, "time", 0); } while (1) { if (sigsetjmp(restart, 1)) { if (ibuf) { for (i = 0; i < ibuflines; i++) { free(ibuf[i]); } ibuflines = 0; free(ibuf); ibuf = NULL; } fputc('\n', stdout); rl_on_new_line(); rl_reset_line_state(); } dbcancel(dbproc); signal(SIGINT, inactive_interrupt_handler); ibuf = (char **) xmalloc(sizeof(char *)); ibuflines = 0; while (1) { if (no_prompt) { foobuf[0] = '\0'; } else { sprintf(foobuf, "%d>> ", ibuflines + 1); } line = readline(foobuf); if (line == NULL) { line = "exit"; } for (cp = line; *cp && isspace((unsigned char) *cp); cp++) continue; if (*cp) { add_history(line); } if (!(strncasecmp(line, "!!", 2))) { int rv; cp = line + 2; switch (rv = system(cp)) { case 0: continue; case -1: fprintf(stderr, "Failed to execute `%s'\n", cp); continue; default: fprintf(stderr, "Command `%s' exited " "with code %d\n", cp, rv); continue; } } /* XXX: isql off-by-one line count error for :r not duplicated */ if (!(strncasecmp(line, ":r", 2))) { for (cp = line + 2; *cp && (isspace((unsigned char) *cp)); cp++) continue; tfn = cp; for (; *cp && !(isspace((unsigned char) *cp)); cp++) continue; *cp = '\0'; if ((fp = fopen(tfn, "r")) == NULL) { fprintf(stderr, "Operating system error: Failed to open %s.\n", tfn); continue; } tmpfp = rl_instream; tmpfp2 = rl_outstream; rl_instream = fp; rl_outstream = fopen("/dev/null", "w"); while ((line = readline("")) != NULL) { ibuf[ibuflines++] = line; ibuf = (char **) xrealloc(ibuf, (ibuflines + 1) * sizeof(char *)); } rl_instream = tmpfp; fclose(rl_outstream); rl_outstream = tmpfp2; fclose(fp); fputc('\r', stdout); fflush(stdout); continue; } firstword = (char *) xmalloc((strlen(line) + 1) * sizeof(char)); strcpy(firstword, line); for (cp = firstword; *cp; cp++) { if (isspace((unsigned char) *cp)) { *cp = '\0'; break; } } if ((!(strcasecmp(firstword, "exit"))) || (!(strcasecmp(firstword, "quit")))) { reset_term(); dbexit(); exit(default_exit); } if (!(strcasecmp(firstword, "reset"))) { for (i = 0; i < ibuflines; i++) { free(ibuf[i]); } ibuflines = 0; continue; } if (!(strcasecmp(firstword, cmdend))) { if (ibuflines == 0) { continue; } free(firstword); break; } if ((!(strcasecmp(firstword, "vi"))) || (!(strcasecmp(firstword, editor)))) { int tmpfd; mode_t old_mask; strcpy(tmpfn, "/tmp/fisqlXXXXXX"); old_mask = umask(0600); tmpfd = mkstemp(tmpfn); umask(old_mask); if ((fp = fdopen(tmpfd, "w")) == NULL) { perror("fisql"); reset_term(); dbexit(); exit(2); } if (ibuflines) { for (i = 0; i < ibuflines; i++) { fputs(ibuf[i], fp); fputc('\n', fp); free(ibuf[i]); } } else { for (i = 0; ((sqlch = dbgetchar(dbproc, i)) != NULL); i++) { fputc(*sqlch, fp); } } fclose(fp); if (!(strcmp(firstword, "vi"))) { edit("vi", tmpfn); } else { edit(editor, tmpfn); } ibuflines = 0; fp = fopen(tmpfn, "r"); tmpfp = rl_instream; rl_instream = fp; strcpy(foobuf, "1>> "); while ((line = readline(foobuf)) != NULL) { ibuf[ibuflines++] = line; sprintf(foobuf, "%d>> ", ibuflines + 1); ibuf = (char **) xrealloc(ibuf, (ibuflines + 1) * sizeof(char *)); } rl_instream = tmpfp; fclose(fp); fputc('\r', stdout); fflush(stdout); unlink(tmpfn); continue; } free(firstword); ibuf[ibuflines++] = line; ibuf = (char **) xrealloc(ibuf, (ibuflines + 1) * sizeof(char *)); } dbfreebuf(dbproc); for (i = 0; i < ibuflines; i++) { if (echo) { puts(ibuf[i]); } dbcmd(dbproc, ibuf[i]); dbcmd(dbproc, "\n"); free(ibuf[i]); } free(ibuf); ibuf = NULL; signal(SIGINT, active_interrupt_handler); dbsetinterrupt(dbproc, (void *) active_interrupt_pending, (void *) active_interrupt_servhandler); if (dbsqlexec(dbproc) == SUCCEED) { maybe_handle_active_interrupt(); while ((dbrc = dbresults(dbproc)) != NO_MORE_RESULTS) { printedlines = 0; #define USE_DBPRROW 0 #if USE_DBPRROW dbprhead(dbproc); dbprrow(dbproc); #else if ((dbrc == SUCCEED) && (DBROWS(dbproc) == SUCCEED)) { prbuflen = dbspr1rowlen(dbproc); prbuf = (char *) xmalloc(prbuflen * sizeof(char)); dbsprhead(dbproc, prbuf, prbuflen); fputs(prbuf, stdout); fputc('\n', stdout); dbsprline(dbproc, prbuf, prbuflen, '-'); fputs(prbuf, stdout); fputc('\n', stdout); maybe_handle_active_interrupt(); while ((dbrc = dbnextrow(dbproc)) != NO_MORE_ROWS) { if (dbrc == FAIL) { break; } if (dbrc != REG_ROW) { num_cols = dbnumalts(dbproc, dbrc); for (selcol = col = 1; col <= num_cols; col++) { colid = dbaltcolid(dbproc, dbrc, col); while (selcol < colid) { collen = get_printable_column_size(dbproc, selcol); for (i = 0; i < collen; i++) { putchar(' '); } selcol++; printf("%s", colseparator); } opname = dbprtype(dbaltop(dbproc, dbrc, col)); printf("%s", opname); collen = get_printable_column_size(dbproc, colid); collen -= strlen(opname); while (collen-- > 0) { putchar(' '); } selcol++; printf("%s", colseparator); } printf("%s", lineseparator); for (selcol = col = 1; col <= num_cols; col++) { colid = dbaltcolid(dbproc, dbrc, col); while (selcol < colid) { collen = get_printable_column_size(dbproc, selcol); for (i = 0; i < collen; i++) { putchar(' '); } selcol++; printf("%s", colseparator); } collen = get_printable_column_size(dbproc, colid); adash = '-'; for (i = 0; i < collen; i++) { putchar(adash); } selcol++; printf("%s", colseparator); } printf("%s", lineseparator); for (selcol = col = 1; col <= num_cols; col++) { colid = dbaltcolid(dbproc, dbrc, col); while (selcol < colid) { collen = get_printable_column_size(dbproc, selcol); for (i = 0; i < collen; i++) { putchar(' '); } selcol++; printf("%s", colseparator); } convlen = dbconvert(dbproc, dbalttype(dbproc, dbrc, col), dbadata(dbproc, dbrc, col), dbadlen(dbproc, dbrc, col), SYBCHAR, (BYTE *) adbuf, sizeof(adbuf)); printf("%.*s", (int) convlen, adbuf); collen = get_printable_column_size(dbproc, colid); collen -= convlen; while (collen-- > 0) { putchar(' '); } selcol++; printf("%s", colseparator); } printf("%s", lineseparator); printedcompute = 1; continue; } if (printedcompute || (headers && (printedlines >= headers) && ((printedlines % headers) == 0))) { fputc('\n', stdout); dbsprhead(dbproc, prbuf, prbuflen); fputs(prbuf, stdout); fputc('\n', stdout); dbsprline(dbproc, prbuf, prbuflen, '-'); fputs(prbuf, stdout); fputc('\n', stdout); printedcompute = 0; } printedlines++; dbspr1row(dbproc, prbuf, prbuflen); fputs(prbuf, stdout); fputc('\n', stdout); maybe_handle_active_interrupt(); } fputc('\n', stdout); free(prbuf); maybe_handle_active_interrupt(); } #endif if (dbrc != FAIL) { if ((DBCOUNT(dbproc) >= 0) || dbhasretstat(dbproc)) { if (DBCOUNT(dbproc) >= 0) { fprintf(stdout, "(%d rows affected", (int) DBCOUNT(dbproc)); if (dbhasretstat(dbproc)) { dbrc = dbretstatus(dbproc); fprintf(stdout, ", return status = %d", dbrc); } fprintf(stdout, ")\n"); } else { if (dbhasretstat(dbproc)) { dbrc = dbretstatus(dbproc); fprintf(stdout, "(return status = %d)\n", dbrc); } } } } } } else { /* Something failed, so change the default * exit status to reflect that. */ default_exit = EXIT_FAILURE; } } reset_term(); dbexit(); exit(EXIT_FAILURE); return (0); } freetds-1.00.82/src/apps/fisql/terminal.h100644 025423 025423 00000001653 12522201763 0013667/* Free ISQL - An isql for DB-Library (C) 2007 Nicholas S. Castellano * * 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 library 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 * Library General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /* $Id: terminal.h,v 1.4 2007-01-20 06:32:27 castellano Exp $ */ int save_term(void); int set_term_noecho(void); int reset_term(void); freetds-1.00.82/src/apps/fisql/terminal.c100644 025423 025423 00000003242 12522201763 0013656/* Free ISQL - An isql for DB-Library (C) 2007 Nicholas S. Castellano * * 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 library 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 * Library General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #include "terminal.h" static struct termios term; static struct termios oterm; static int term_init = 0; int save_term() { int r; if (!isatty(fileno(stdin))) { return 1; } if (term_init) { return 0; } if ((r = tcgetattr(fileno(stdin), &oterm)) != 0) { return r; } term_init = 1; return 0; } int set_term_noecho() { int r; if (!isatty(fileno(stdin))) { return 1; } if ((r = save_term()) != 0) { return r; } if ((r = tcgetattr(fileno(stdin), &term)) != 0) { return r; } term.c_lflag &= ~(ICANON | ECHO); if ((r = tcsetattr(fileno(stdin), TCSANOW, &term)) != 0) { return r; } return 0; } int reset_term() { int r; if (!isatty(fileno(stdin))) { return 1; } if ((r = save_term()) != 0) { return r; } if ((r = tcsetattr(fileno(stdin), TCSANOW, &oterm)) != 0) { return r; } return 0; } freetds-1.00.82/src/apps/fisql/edit.h100644 025423 025423 00000001620 12522201763 0012773/* Free ISQL - An isql for DB-Library (C) 2007 Nicholas S. Castellano * * 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 library 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 * Library General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /* $Id: edit.h,v 1.3 2007-01-20 06:32:27 castellano Exp $ */ int edit(const char *editor, const char *arg); freetds-1.00.82/src/apps/fisql/edit.c100644 025423 025423 00000002711 12522201763 0012770/* Free ISQL - An isql for DB-Library (C) 2007 Nicholas S. Castellano * * 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 library 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 * Library General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #include #include #include #include #include #include "edit.h" #include "terminal.h" int edit(const char *editor, const char *arg) { int pid; retry_fork: pid = fork(); switch (pid) { case -1: if (errno == EAGAIN) { sleep(5); goto retry_fork; } perror("fisql"); reset_term(); dbexit(); exit(EXIT_FAILURE); break; case 0: execlp(editor, editor, arg, (char *) 0); fprintf(stderr, "Unable to invoke the '%s' editor.\n", editor); exit(EXIT_FAILURE); break; default: waitpid(pid, (int *) 0, 0); break; } return 0; } freetds-1.00.82/src/apps/fisql/handlers.h100644 025423 025423 00000002166 12522201763 0013654/* Free ISQL - An isql for DB-Library (C) 2007 Nicholas S. Castellano * * 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 library 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 * Library General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /* $Id: handlers.h,v 1.4 2007-01-20 06:32:27 castellano Exp $ */ extern int global_errorlevel; int err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr); int msg_handler(DBPROCESS * dbproc, DBINT msgno, int msgstate, int severity, char *msgtext, char *srvname, char *procname, int line); freetds-1.00.82/src/apps/fisql/handlers.c100644 025423 025423 00000003712 12522201763 0013645/* Free ISQL - An isql for DB-Library (C) 2007 Nicholas S. Castellano * * 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 library 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 * Library General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #include #include "handlers.h" int global_errorlevel = -1; int err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr) { if ((dbproc == NULL) || (DBDEAD(dbproc))) { return (INT_EXIT); } if (dberr != SYBESMSG) { fprintf(stdout, "DB-LIBRARY error:\n\t%s\n", dberrstr); } if (oserr != DBNOERR) { fprintf(stdout, "Operating-system error:\n\t%s\n", oserrstr); } return (INT_CANCEL); } int msg_handler(DBPROCESS * dbproc, DBINT msgno, int msgstate, int severity, char *msgtext, char *srvname, char *procname, int line) { if (severity > 10) { if ((global_errorlevel == -1) || (severity >= global_errorlevel)) { fprintf(stdout, "Msg %ld, Level %d, State %d:\n", (long) msgno, severity, msgstate); } if (global_errorlevel == -1) { if (strlen(srvname) > 0) { fprintf(stdout, "Server '%s', ", srvname); } if (strlen(procname) > 0) { fprintf(stdout, "Procedure '%s', ", procname); } if (line > 0) { fprintf(stdout, "Line %d:\n", line); } } } if (global_errorlevel == -1) { fprintf(stdout, "%s\n", msgtext); } return (0); } freetds-1.00.82/src/apps/fisql/interrupt.h100644 025423 025423 00000002146 12522201763 0014106/* Free ISQL - An isql for DB-Library (C) 2007 Nicholas S. Castellano * * 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 library 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 * Library General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /* $Id: interrupt.h,v 1.4 2007-01-20 06:32:27 castellano Exp $ */ extern sigjmp_buf restart; void inactive_interrupt_handler(int sig); void active_interrupt_handler(int sig); void maybe_handle_active_interrupt(void); int active_interrupt_pending(DBPROCESS * dbproc); int active_interrupt_servhandler(DBPROCESS * dbproc); freetds-1.00.82/src/apps/fisql/interrupt.c100644 025423 025423 00000002640 12522201763 0014100/* Free ISQL - An isql for DB-Library (C) 2007 Nicholas S. Castellano * * 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 library 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 * Library General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #include #include "interrupt.h" sigjmp_buf restart; volatile int os_interrupt = 0; void inactive_interrupt_handler(int sig) { siglongjmp(restart, 1); } void active_interrupt_handler(int sig) { os_interrupt = sig; } void maybe_handle_active_interrupt(void) { int sig; if (os_interrupt) { sig = os_interrupt; os_interrupt = 0; inactive_interrupt_handler(sig); } } int active_interrupt_pending(DBPROCESS * dbproc) { if (os_interrupt) { return TRUE; } return FALSE; } int active_interrupt_servhandler(DBPROCESS * dbproc) { return INT_CANCEL; } freetds-1.00.82/src/odbc/Makefile.am100644 025423 025423 00000003177 13203773221 0012570# $Id: Makefile.am,v 1.52 2012-02-26 22:09:20 freddy77 Exp $ SUBDIRS = . unittests AM_CPPFLAGS = -I$(top_srcdir)/include $(ODBC_INC) lib_LTLIBRARIES = libtdsodbc.la ##EXTRA_LTLIBRARIES = libtdsodbc.la libtdsodbc_la_SOURCES = odbc.c connectparams.c convert_tds2sql.c \ descriptor.c prepare_query.c odbc_util.c bcp.c \ native.c sql2tds.c error.c odbc_checks.c sqlwchar.c sqlwparams.h \ odbc_export.h error_export.h odbc_data.c libtdsodbc_la_LIBADD = ../tds/libtds.la ../replacements/libreplacements.la $(ODBCINSTLIB) $(FREETDS_LIBGCC) $(LTLIBICONV) # -module is needed by Darwin (Mac OS X) libtdsodbc_la_LDFLAGS = $(FREETDS_SYMBOLIC) $(FREETDS_ODBC_MODULE) if MINGW32 libtdsodbc_la_SOURCES += winlogin.c winsetup.c winmain.c endif if MINGW32 libtdsodbc_la_LIBADD += setup.res libtdsodbc_la_LDFLAGS += -Wl,--kill-at -Wl,--enable-stdcall-fixup -Wl,-s -Wl,@srcdir@/odbc_w.def -Wl,setup.res .rc.res: $(RC) -i $< --input-format=rc -o $@ -O coff else if !MACOSX libtdsodbc_la_LDFLAGS += -export-symbols-regex '^(SQL|ODBCINST).*' endif endif EXTRA_DIST = CMakeLists.txt winmain.c winlogin.c winsetup.c \ version.rc version.rc.in setup.rc resource.h \ odbc.def odbc_w.def CLEANFILES = setup.res ## Need blank statement to avoid compiling odbc.c odbc: $(EXTRA_LTLIBRARIES) @echo '' if HAVE_PERL_SOURCES BUILT_SOURCES = odbc_export.h error_export.h clean-local: cd $(srcdir) && rm -f $(BUILT_SOURCES) odbc_export.h: odbc_export.pl Makefile odbc.c perl $(srcdir)/odbc_export.pl $(srcdir)/odbc.c > $@.tmp mv $@.tmp $@ error_export.h: odbc_export.pl Makefile error.c perl $(srcdir)/odbc_export.pl $(srcdir)/error.c > $@.tmp mv $@.tmp $@ endif freetds-1.00.82/src/odbc/Makefile.in100644 025423 025423 00000074356 13242511111 0012577# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @MINGW32_TRUE@am__append_1 = winlogin.c winsetup.c winmain.c @MINGW32_TRUE@am__append_2 = setup.res @MINGW32_TRUE@am__append_3 = -Wl,--kill-at -Wl,--enable-stdcall-fixup -Wl,-s -Wl,@srcdir@/odbc_w.def -Wl,setup.res @MACOSX_FALSE@@MINGW32_FALSE@am__append_4 = -export-symbols-regex '^(SQL|ODBCINST).*' subdir = src/odbc ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = \ $(top_srcdir)/m4/ac_caolan_func_which_gethostbyname_r.m4 \ $(top_srcdir)/m4/ac_have_inaddr_none.m4 \ $(top_srcdir)/m4/ac_have_malloc_options.m4 \ $(top_srcdir)/m4/ac_nullzero.m4 \ $(top_srcdir)/m4/ac_raf_func_which_getservbyname_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_gethostbyaddr_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_getpwuid_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_localtime_r.m4 \ $(top_srcdir)/m4/acx_pthread.m4 \ $(top_srcdir)/m4/ax_cflags_gcc_option.m4 \ $(top_srcdir)/m4/check_openssl.m4 \ $(top_srcdir)/m4/gettimemilli.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/pushlibs.m4 \ $(top_srcdir)/m4/sprintf_i64_format.m4 \ $(top_srcdir)/m4/type_socklen_t.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = version.rc CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(libdir)" LTLIBRARIES = $(lib_LTLIBRARIES) am__DEPENDENCIES_1 = libtdsodbc_la_DEPENDENCIES = ../tds/libtds.la \ ../replacements/libreplacements.la $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_2) am__libtdsodbc_la_SOURCES_DIST = odbc.c connectparams.c \ convert_tds2sql.c descriptor.c prepare_query.c odbc_util.c \ bcp.c native.c sql2tds.c error.c odbc_checks.c sqlwchar.c \ sqlwparams.h odbc_export.h error_export.h odbc_data.c \ winlogin.c winsetup.c winmain.c @MINGW32_TRUE@am__objects_1 = winlogin.lo winsetup.lo winmain.lo am_libtdsodbc_la_OBJECTS = odbc.lo connectparams.lo convert_tds2sql.lo \ descriptor.lo prepare_query.lo odbc_util.lo bcp.lo native.lo \ sql2tds.lo error.lo odbc_checks.lo sqlwchar.lo odbc_data.lo \ $(am__objects_1) libtdsodbc_la_OBJECTS = $(am_libtdsodbc_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = libtdsodbc_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(libtdsodbc_la_LDFLAGS) $(LDFLAGS) -o $@ AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libtdsodbc_la_SOURCES) DIST_SOURCES = $(am__libtdsodbc_la_SOURCES_DIST) RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/version.rc.in \ $(top_srcdir)/depcomp $(top_srcdir)/mkinstalldirs DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BUILD_NUMBER = @BUILD_NUMBER@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOXYGEN = @DOXYGEN@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FREETDS_LIBGCC = @FREETDS_LIBGCC@ FREETDS_ODBC_MODULE = @FREETDS_ODBC_MODULE@ FREETDS_SYMBOLIC = @FREETDS_SYMBOLIC@ GCRYPT_CFLAGS = @GCRYPT_CFLAGS@ GCRYPT_LIBS = @GCRYPT_LIBS@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ HAVE_OPENSSL = @HAVE_OPENSSL@ HAVE_PERL_SOURCES = @HAVE_PERL_SOURCES@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBADD_DL = @LIBADD_DL@ LIBADD_DLD_LINK = @LIBADD_DLD_LINK@ LIBADD_DLOPEN = @LIBADD_DLOPEN@ LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@ LIBICONV = @LIBICONV@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBOBJS = @LTLIBOBJS@ LT_DLLOADERS = @LT_DLLOADERS@ LT_DLPREOPEN = @LT_DLPREOPEN@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ NETTLE_CFLAGS = @NETTLE_CFLAGS@ NETTLE_LIBS = @NETTLE_LIBS@ NETWORK_LIBS = @NETWORK_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ODBC = @ODBC@ ODBCINSTLIB = @ODBCINSTLIB@ ODBCLIB = @ODBCLIB@ ODBCNODMLIB = @ODBCNODMLIB@ ODBCNODMLIBAPP = @ODBCNODMLIBAPP@ ODBC_CONFIG = @ODBC_CONFIG@ ODBC_INC = @ODBC_INC@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ RC = @RC@ READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SUBVERSION = @SUBVERSION@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ dblib_define = @dblib_define@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ tds_sysdep_int16_type = @tds_sysdep_int16_type@ tds_sysdep_int32_type = @tds_sysdep_int32_type@ tds_sysdep_int64_type = @tds_sysdep_int64_type@ tds_sysdep_intptr_type = @tds_sysdep_intptr_type@ tds_sysdep_real32_type = @tds_sysdep_real32_type@ tds_sysdep_real64_type = @tds_sysdep_real64_type@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # $Id: Makefile.am,v 1.52 2012-02-26 22:09:20 freddy77 Exp $ SUBDIRS = . unittests AM_CPPFLAGS = -I$(top_srcdir)/include $(ODBC_INC) lib_LTLIBRARIES = libtdsodbc.la libtdsodbc_la_SOURCES = odbc.c connectparams.c convert_tds2sql.c \ descriptor.c prepare_query.c odbc_util.c bcp.c native.c \ sql2tds.c error.c odbc_checks.c sqlwchar.c sqlwparams.h \ odbc_export.h error_export.h odbc_data.c $(am__append_1) libtdsodbc_la_LIBADD = ../tds/libtds.la \ ../replacements/libreplacements.la $(ODBCINSTLIB) \ $(FREETDS_LIBGCC) $(LTLIBICONV) $(am__append_2) # -module is needed by Darwin (Mac OS X) libtdsodbc_la_LDFLAGS = $(FREETDS_SYMBOLIC) $(FREETDS_ODBC_MODULE) \ $(am__append_3) $(am__append_4) EXTRA_DIST = CMakeLists.txt winmain.c winlogin.c winsetup.c \ version.rc version.rc.in setup.rc resource.h \ odbc.def odbc_w.def CLEANFILES = setup.res @HAVE_PERL_SOURCES_TRUE@BUILT_SOURCES = odbc_export.h error_export.h all: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: .SUFFIXES: .c .lo .o .obj .rc .res $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/odbc/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/odbc/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): version.rc: $(top_builddir)/config.status $(srcdir)/version.rc.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libtdsodbc.la: $(libtdsodbc_la_OBJECTS) $(libtdsodbc_la_DEPENDENCIES) $(EXTRA_libtdsodbc_la_DEPENDENCIES) $(AM_V_CCLD)$(libtdsodbc_la_LINK) -rpath $(libdir) $(libtdsodbc_la_OBJECTS) $(libtdsodbc_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bcp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/connectparams.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/convert_tds2sql.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/descriptor.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/error.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/native.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/odbc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/odbc_checks.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/odbc_data.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/odbc_util.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/prepare_query.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sql2tds.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sqlwchar.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/winlogin.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/winmain.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/winsetup.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) check-recursive all-am: Makefile $(LTLIBRARIES) installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(libdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) @HAVE_PERL_SOURCES_FALSE@clean-local: clean: clean-recursive clean-am: clean-generic clean-libLTLIBRARIES clean-libtool clean-local \ mostlyclean-am distclean: distclean-recursive -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-libLTLIBRARIES install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-libLTLIBRARIES .MAKE: $(am__recursive_targets) all check install install-am \ install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-generic clean-libLTLIBRARIES \ clean-libtool clean-local cscopelist-am ctags ctags-am \ distclean distclean-compile distclean-generic \ 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-libLTLIBRARIES install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs installdirs-am \ 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-libLTLIBRARIES .PRECIOUS: Makefile @MINGW32_TRUE@.rc.res: @MINGW32_TRUE@ $(RC) -i $< --input-format=rc -o $@ -O coff odbc: $(EXTRA_LTLIBRARIES) @echo '' @HAVE_PERL_SOURCES_TRUE@clean-local: @HAVE_PERL_SOURCES_TRUE@ cd $(srcdir) && rm -f $(BUILT_SOURCES) @HAVE_PERL_SOURCES_TRUE@odbc_export.h: odbc_export.pl Makefile odbc.c @HAVE_PERL_SOURCES_TRUE@ perl $(srcdir)/odbc_export.pl $(srcdir)/odbc.c > $@.tmp @HAVE_PERL_SOURCES_TRUE@ mv $@.tmp $@ @HAVE_PERL_SOURCES_TRUE@error_export.h: odbc_export.pl Makefile error.c @HAVE_PERL_SOURCES_TRUE@ perl $(srcdir)/odbc_export.pl $(srcdir)/error.c > $@.tmp @HAVE_PERL_SOURCES_TRUE@ mv $@.tmp $@ # 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: freetds-1.00.82/src/odbc/version.rc.in100644 025423 025423 00000002356 12717145107 0013157 #ifndef _MAC ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO FILEVERSION @MAJOR@,@MINOR@,@SUBVERSION@,@BUILD_NUMBER@ PRODUCTVERSION @MAJOR@,@MINOR@,@SUBVERSION@,@BUILD_NUMBER@ FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L #else FILEFLAGS 0x0L #endif FILEOS 0x40004L FILETYPE 0x2L FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904b0" BEGIN VALUE "Comments", "\0" VALUE "CompanyName", "FreeTDS.org\0" VALUE "FileDescription", "FreeTDS\0" VALUE "FileVersion", "@MAJOR@, @MINOR@, @SUBVERSION@, @BUILD_NUMBER@\0" VALUE "InternalName", "FreeTDS\0" VALUE "LegalCopyright", "Copyright © 2004-2015 under terms of GNU LGPL\0" VALUE "LegalTrademarks", "\0" VALUE "OriginalFilename", "FreeTDS.dll\0" VALUE "PrivateBuild", "\0" VALUE "ProductName", "FreeTDS ODBC Driver\0" VALUE "ProductVersion", "@MAJOR@, @MINOR@, @SUBVERSION@, @BUILD_NUMBER@\0" VALUE "SpecialBuild", "\0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1200 END END #endif // !_MAC freetds-1.00.82/src/odbc/odbc.c100644 025423 025423 00000653773 13142276621 0011630/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001 Brian Bruns * Copyright (C) 2002-2012 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include #include #include #include #include "replacements.h" #include "sqlwparams.h" /* Include odbcss.h with all bcp functions */ /* The define trick is to make inline functions calls internal * _SQLSetConnectAttr instead of SQLSetConnectAttr */ ODBC_FUNC(SQLSetConnectAttr, (P(SQLHDBC,hdbc), P(SQLINTEGER,Attribute), P(SQLPOINTER,ValuePtr), P(SQLINTEGER,StringLength) WIDE)); #define TDSODBC_BCP #undef SQLSetConnectAttr #define SQLSetConnectAttr(h, n, p, t) _SQLSetConnectAttr(h, n, p, t _wide0) #include #undef SQLSetConnectAttr static SQLRETURN _SQLAllocConnect(SQLHENV henv, SQLHDBC FAR * phdbc); static SQLRETURN _SQLAllocEnv(SQLHENV FAR * phenv, SQLINTEGER odbc_version); static SQLRETURN _SQLAllocStmt(SQLHDBC hdbc, SQLHSTMT FAR * phstmt); static SQLRETURN _SQLAllocDesc(SQLHDBC hdbc, SQLHDESC FAR * phdesc); static SQLRETURN _SQLFreeConnect(SQLHDBC hdbc); static SQLRETURN _SQLFreeEnv(SQLHENV henv); static SQLRETURN _SQLFreeStmt(SQLHSTMT hstmt, SQLUSMALLINT fOption, int force); static SQLRETURN _SQLFreeDesc(SQLHDESC hdesc); static SQLRETURN _SQLExecute(TDS_STMT * stmt); static SQLRETURN _SQLSetStmtAttr(SQLHSTMT hstmt, SQLINTEGER Attribute, SQLPOINTER ValuePtr, SQLINTEGER StringLength WIDE); static SQLRETURN _SQLGetStmtAttr(SQLHSTMT hstmt, SQLINTEGER Attribute, SQLPOINTER Value, SQLINTEGER BufferLength, SQLINTEGER * StringLength WIDE); static SQLRETURN _SQLColAttribute(SQLHSTMT hstmt, SQLUSMALLINT icol, SQLUSMALLINT fDescType, SQLPOINTER rgbDesc, SQLSMALLINT cbDescMax, SQLSMALLINT FAR * pcbDesc, SQLLEN FAR * pfDesc _WIDE); static SQLRETURN _SQLFetch(TDS_STMT * stmt, SQLSMALLINT FetchOrientation, SQLLEN FetchOffset); static SQLRETURN odbc_populate_ird(TDS_STMT * stmt); static int odbc_errmsg_handler(const TDSCONTEXT * ctx, TDSSOCKET * tds, TDSMESSAGE * msg); static void odbc_log_unimplemented_type(const char function_name[], int fType); static void odbc_upper_column_names(TDS_STMT * stmt); static void odbc_col_setname(TDS_STMT * stmt, int colpos, const char *name); static SQLRETURN odbc_stat_execute(TDS_STMT * stmt _WIDE, const char *begin, int nparams, ...); static SQLRETURN odbc_free_dynamic(TDS_STMT * stmt); static SQLRETURN odbc_free_cursor(TDS_STMT * stmt); static SQLRETURN odbc_update_ird(TDS_STMT *stmt, TDS_ERRS *errs); static SQLRETURN odbc_prepare(TDS_STMT *stmt); static SQLSMALLINT odbc_swap_datetime_sql_type(SQLSMALLINT sql_type, int version); static int odbc_process_tokens(TDS_STMT * stmt, unsigned flag); static int odbc_lock_statement(TDS_STMT* stmt); static void odbc_unlock_statement(TDS_STMT* stmt); #if ENABLE_EXTRA_CHECKS static void odbc_ird_check(TDS_STMT * stmt); #define IRD_CHECK odbc_ird_check(stmt) #else #define IRD_CHECK #endif /** * \defgroup odbc_api ODBC API * Functions callable by \c ODBC client programs */ /* utils to check handles */ #define INIT_HANDLE(t, n) \ TDS_##t *n = (TDS_##t*)h##n; \ if (SQL_NULL_H##t == h##n || !IS_H##t(h##n)) return SQL_INVALID_HANDLE; \ tds_mutex_lock(&n->mtx); \ CHECK_##t##_EXTRA(n); \ odbc_errs_reset(&n->errs); #define ODBC_ENTER_HSTMT INIT_HANDLE(STMT, stmt) #define ODBC_ENTER_HDBC INIT_HANDLE(DBC, dbc) #define ODBC_ENTER_HENV INIT_HANDLE(ENV, env) #define ODBC_ENTER_HDESC INIT_HANDLE(DESC, desc) #define IS_VALID_LEN(len) ((len) >= 0 || (len) == SQL_NTS || (len) == SQL_NULL_DATA) #define ODBC_SAFE_ERROR(stmt) \ do { \ if (!stmt->errs.num_errors) \ odbc_errs_add(&stmt->errs, "HY000", "Unknown error"); \ } while(0) #define DEFAULT_QUERY_TIMEOUT (~((SQLUINTEGER) 0)) /* * Note: I *HATE* hungarian notation, it has to be the most idiotic thing * I've ever seen. So, you will note it is avoided other than in the function * declarations. "Gee, let's make our code totally hard to read and they'll * beg for GUI tools" * Bah! */ static const char * odbc_prret(SQLRETURN ret, char *unknown, size_t unknown_size) { switch (ret) { case SQL_ERROR: return "SQL_ERROR"; case SQL_INVALID_HANDLE: return "SQL_INVALID_HANDLE"; case SQL_SUCCESS: return "SQL_SUCCESS"; case SQL_SUCCESS_WITH_INFO: return "SQL_SUCCESS_WITH_INFO"; #if ODBCVER >= 0x0300 case SQL_NO_DATA: return "SQL_NO_DATA"; #endif case SQL_STILL_EXECUTING: return "SQL_STILL_EXECUTING"; case SQL_NEED_DATA: return "SQL_NEED_DATA"; } snprintf(unknown, unknown_size, "unknown: %d", (int)ret); return unknown; } #define ODBC_PRRET_BUF char unknown_prret_buf[24] #define odbc_prret(ret) odbc_prret(ret, unknown_prret_buf, sizeof(unknown_prret_buf)) static void odbc_col_setname(TDS_STMT * stmt, int colpos, const char *name) { #if ENABLE_EXTRA_CHECKS TDSRESULTINFO *resinfo; #endif IRD_CHECK; #if ENABLE_EXTRA_CHECKS if (colpos > 0 && stmt->tds != NULL && (resinfo = stmt->tds->current_results) != NULL) { if (colpos <= resinfo->num_cols) { /* no overflow possible, name is always shorter */ if (!tds_dstr_copy(&resinfo->columns[colpos - 1]->column_name, name)) odbc_errs_add(&stmt->errs, "HY001", NULL); tds_dstr_empty(&resinfo->columns[colpos - 1]->table_column_name); } } #endif if (colpos > 0 && colpos <= stmt->ird->header.sql_desc_count) { --colpos; if (!tds_dstr_copy(&stmt->ird->records[colpos].sql_desc_label, name) || !tds_dstr_copy(&stmt->ird->records[colpos].sql_desc_name, name)) odbc_errs_add(&stmt->errs, "HY001", NULL); } } /* spinellia@acm.org : copied shamelessly from change_database */ static SQLRETURN change_autocommit(TDS_DBC * dbc, int state) { TDSSOCKET *tds = dbc->tds_socket; TDSRET ret; if (dbc->attr.autocommit == state) return SQL_SUCCESS; /* * We may not be connected yet and dbc->tds_socket * may not initialized. */ if (tds) { /* TODO better idle check, not thread safe */ if (tds->state == TDS_IDLE) tds->query_timeout = dbc->default_query_timeout; if (state == SQL_AUTOCOMMIT_ON) ret = tds_submit_rollback(tds, 0); else ret = tds_submit_begin_tran(tds); if (TDS_FAILED(ret)) { odbc_errs_add(&dbc->errs, "HY000", "Could not change transaction status"); return SQL_ERROR; } if (TDS_FAILED(tds_process_simple_query(tds))) { odbc_errs_add(&dbc->errs, "HY000", "Could not change transaction status"); return SQL_ERROR; } dbc->attr.autocommit = state; } else { /* if not connected we will change auto-commit after login */ dbc->attr.autocommit = state; } ODBC_RETURN_(dbc); } static SQLRETURN change_database(TDS_DBC * dbc, const char *database, int database_len) { TDSSOCKET *tds = dbc->tds_socket; /* * We may not be connected yet and dbc->tds_socket * may not initialized. */ if (tds) { /* build query */ char *query = tds_new(char, 6 + tds_quote_id(tds, NULL, database, database_len)); if (!query) { odbc_errs_add(&dbc->errs, "HY001", NULL); return SQL_ERROR; } strcpy(query, "USE "); tds_quote_id(tds, query + 4, database, database_len); tdsdump_log(TDS_DBG_INFO1, "change_database: executing %s\n", query); /* TODO better idle check, not thread safe */ if (tds->state == TDS_IDLE) tds->query_timeout = dbc->default_query_timeout; if (TDS_FAILED(tds_submit_query(tds, query))) { free(query); odbc_errs_add(&dbc->errs, "HY000", "Could not change database"); return SQL_ERROR; } free(query); if (TDS_FAILED(tds_process_simple_query(tds))) { odbc_errs_add(&dbc->errs, "HY000", "Could not change database"); return SQL_ERROR; } } else { if (!tds_dstr_copyn(&dbc->attr.current_catalog, database, database_len)) { odbc_errs_add(&dbc->errs, "HY001", NULL); return SQL_ERROR; } } ODBC_RETURN_(dbc); } static SQLRETURN change_txn(TDS_DBC * dbc, SQLUINTEGER txn_isolation) { char query[64]; const char *level; TDSSOCKET *tds = dbc->tds_socket; switch (txn_isolation) { case SQL_TXN_READ_COMMITTED: level = "READ COMMITTED"; break; case SQL_TXN_READ_UNCOMMITTED: level = "READ UNCOMMITTED"; break; case SQL_TXN_REPEATABLE_READ: level = "REPEATABLE READ"; break; case SQL_TXN_SERIALIZABLE: level = "SERIALIZABLE"; break; default: odbc_errs_add(&dbc->errs, "HY024", NULL); return SQL_ERROR; } /* if not connected return success, will be set after connection */ if (!tds) return SQL_SUCCESS; if (tds->state != TDS_IDLE) { odbc_errs_add(&dbc->errs, "HY011", NULL); return SQL_ERROR; } tds->query_timeout = dbc->default_query_timeout; sprintf(query, "SET TRANSACTION ISOLATION LEVEL %s", level); if (TDS_FAILED(tds_submit_query(tds, query))) { ODBC_SAFE_ERROR(dbc); return SQL_ERROR; } if (TDS_FAILED(tds_process_simple_query(tds))) { ODBC_SAFE_ERROR(dbc); return SQL_ERROR; } return SQL_SUCCESS; } static TDS_DBC* odbc_get_dbc(TDSSOCKET *tds) { TDS_CHK *chk = (TDS_CHK *) tds_get_parent(tds); if (!chk) return NULL; if (chk->htype == SQL_HANDLE_DBC) return (TDS_DBC *) chk; assert(chk->htype == SQL_HANDLE_STMT); return ((TDS_STMT *) chk)->dbc; } static TDS_STMT* odbc_get_stmt(TDSSOCKET *tds) { TDS_CHK *chk = (TDS_CHK *) tds_get_parent(tds); if (!chk || chk->htype != SQL_HANDLE_STMT) return NULL; return (TDS_STMT *) chk; } static void odbc_env_change(TDSSOCKET * tds, int type, char *oldval, char *newval) { TDS_DBC *dbc; assert(tds); dbc = odbc_get_dbc(tds); if (!dbc) return; switch (type) { case TDS_ENV_DATABASE: tds_dstr_copy(&dbc->attr.current_catalog, newval); break; case TDS_ENV_PACKSIZE: dbc->attr.packet_size = atoi(newval); break; } } static SQLRETURN odbc_connect(TDS_DBC * dbc, TDSLOGIN * login) { TDS_ENV *env = dbc->env; #ifdef ENABLE_ODBC_WIDE dbc->mb_conv = NULL; #endif dbc->tds_socket = tds_alloc_socket(env->tds_ctx, 512); if (!dbc->tds_socket) goto memory_error; dbc->tds_socket->conn->use_iconv = 0; tds_set_parent(dbc->tds_socket, (void *) dbc); /* Set up our environment change hook */ dbc->tds_socket->env_chg_func = odbc_env_change; tds_fix_login(login); /* use connection timeout if set */ if (dbc->attr.connection_timeout) login->connect_timeout = dbc->attr.connection_timeout; if (dbc->attr.mars_enabled != SQL_MARS_ENABLED_NO) login->mars = 1; if (dbc->attr.bulk_enabled != SQL_BCP_OFF) tds_set_bulk(login, 1); #ifdef ENABLE_ODBC_WIDE /* force utf-8 in order to support wide characters */ if (!tds_dstr_dup(&dbc->original_charset, &login->client_charset) || !tds_dstr_copy(&login->client_charset, "UTF-8")) goto memory_error; #endif /* replace password with old one */ if (dbc->use_oldpwd) { if (!tds_dstr_dup(&login->new_password, &login->password) || !tds_dstr_dup(&login->password, &dbc->oldpwd)) goto memory_error; login->use_new_password = 1; } if (TDS_FAILED(tds_connect_and_login(dbc->tds_socket, login))) { tds_free_socket(dbc->tds_socket); dbc->tds_socket = NULL; odbc_errs_add(&dbc->errs, "08001", NULL); return SQL_ERROR; } #ifdef ENABLE_ODBC_WIDE dbc->mb_conv = tds_iconv_get(dbc->tds_socket->conn, tds_dstr_cstr(&dbc->original_charset), "UTF-8"); #endif dbc->default_query_timeout = dbc->tds_socket->query_timeout; if (IS_TDS7_PLUS(dbc->tds_socket->conn)) dbc->cursor_support = 1; #if ENABLE_ODBC_MARS /* check if mars is enabled */ if (!IS_TDS72_PLUS(dbc->tds_socket->conn) || !dbc->tds_socket->conn->mars) dbc->attr.mars_enabled = SQL_MARS_ENABLED_NO; #else dbc->attr.mars_enabled = SQL_MARS_ENABLED_NO; #endif if (dbc->attr.txn_isolation != SQL_TXN_READ_COMMITTED) { if (!SQL_SUCCEEDED(change_txn(dbc, dbc->attr.txn_isolation))) ODBC_RETURN_(dbc); } if (dbc->attr.autocommit != SQL_AUTOCOMMIT_ON) { dbc->attr.autocommit = SQL_AUTOCOMMIT_ON; if (!SQL_SUCCEEDED(change_autocommit(dbc, SQL_AUTOCOMMIT_OFF))) ODBC_RETURN_(dbc); } /* this overwrite any error arrived (wanted behavior, Sybase return error for conversion errors) */ ODBC_RETURN(dbc, SQL_SUCCESS); memory_error: tds_free_socket(dbc->tds_socket); dbc->tds_socket = NULL; odbc_errs_add(&dbc->errs, "HY001", NULL); ODBC_RETURN_(dbc); } static SQLRETURN odbc_update_ird(TDS_STMT *stmt, TDS_ERRS *errs) { SQLRETURN res; if (!stmt->need_reprepare || stmt->prepared_query_is_rpc || !stmt->dbc || !IS_TDS7_PLUS(stmt->dbc->tds_socket->conn)) { stmt->need_reprepare = 0; return SQL_SUCCESS; } /* FIXME where error are put ?? on stmt... */ if (!odbc_lock_statement(stmt)) ODBC_RETURN_(stmt); /* FIXME error */ res = start_parse_prepared_query(stmt, 0); if (res != SQL_SUCCESS) { /* prepare with dummy parameters just to fill IRD */ tds_free_param_results(stmt->params); stmt->params = NULL; stmt->param_num = 0; /* * TODO * we need to prepare again with parameters but need_reprepare * flag is reset by odbc_prepare... perhaps should be checked * later, not calling describeCol or similar * we need prepare to get dynamic and cause we change parameters */ } return odbc_prepare(stmt); } static SQLRETURN odbc_prepare(TDS_STMT *stmt) { TDSSOCKET *tds = stmt->tds; int in_row = 0; if (TDS_FAILED(tds_submit_prepare(tds, tds_dstr_cstr(&stmt->query), NULL, &stmt->dyn, stmt->params))) { ODBC_SAFE_ERROR(stmt); return SQL_ERROR; } /* try to go to the next recordset */ /* TODO merge with similar code */ desc_free_records(stmt->ird); stmt->row_status = PRE_NORMAL_ROW; for (;;) { TDS_INT result_type; int done_flags; switch (tds_process_tokens(tds, &result_type, &done_flags, TDS_RETURN_ROWFMT|TDS_RETURN_DONE)) { case TDS_SUCCESS: switch (result_type) { case TDS_DONE_RESULT: case TDS_DONEPROC_RESULT: case TDS_DONEINPROC_RESULT: stmt->row_count = tds->rows_affected; if (done_flags & TDS_DONE_ERROR && !stmt->dyn->emulated) stmt->errs.lastrc = SQL_ERROR; /* FIXME this row is used only as a flag for update binding, should be cleared if binding/result changed */ stmt->row = 0; break; case TDS_ROWFMT_RESULT: /* store first row informations */ if (!in_row) odbc_populate_ird(stmt); stmt->row = 0; stmt->row_count = TDS_NO_COUNT; stmt->row_status = PRE_NORMAL_ROW; in_row = 1; break; } continue; case TDS_NO_MORE_RESULTS: break; case TDS_CANCELLED: odbc_errs_add(&stmt->errs, "HY008", NULL); default: stmt->errs.lastrc = SQL_ERROR; break; } break; } if (stmt->errs.lastrc == SQL_ERROR && !stmt->dyn->emulated) { tds_release_dynamic(&stmt->dyn); } odbc_unlock_statement(stmt); stmt->need_reprepare = 0; ODBC_RETURN_(stmt); } ODBC_FUNC(SQLDriverConnect, (P(SQLHDBC,hdbc), P(SQLHWND,hwnd), PCHARIN(ConnStrIn,SQLSMALLINT), PCHAROUT(ConnStrOut,SQLSMALLINT), P(SQLUSMALLINT,fDriverCompletion) WIDE)) { TDSLOGIN *login; TDS_PARSED_PARAM params[ODBC_PARAM_SIZE]; DSTR conn_str = DSTR_INITIALIZER; ODBC_ENTER_HDBC; #ifdef TDS_NO_DM /* Check string length */ if (!IS_VALID_LEN(cbConnStrIn) || cbConnStrIn == 0) { odbc_errs_add(&dbc->errs, "HY090", NULL); ODBC_EXIT_(dbc); } /* Check completion param */ switch (fDriverCompletion) { case SQL_DRIVER_NOPROMPT: case SQL_DRIVER_COMPLETE: case SQL_DRIVER_PROMPT: case SQL_DRIVER_COMPLETE_REQUIRED: break; default: odbc_errs_add(&dbc->errs, "HY110", NULL); ODBC_EXIT_(dbc); } #endif if (!odbc_dstr_copy(dbc, &conn_str, cbConnStrIn, szConnStrIn)) { odbc_errs_add(&dbc->errs, "HY001", NULL); ODBC_EXIT_(dbc); } login = tds_alloc_login(0); if (!login || !tds_init_login(login, dbc->env->tds_ctx->locale)) { tds_free_login(login); tds_dstr_free(&conn_str); odbc_errs_add(&dbc->errs, "HY001", NULL); ODBC_EXIT_(dbc); } if (!tds_dstr_isempty(&dbc->attr.current_catalog)) if (!tds_dstr_dup(&login->database, &dbc->attr.current_catalog)) { tds_free_login(login); tds_dstr_free(&conn_str); odbc_errs_add(&dbc->errs, "HY001", NULL); ODBC_EXIT_(dbc); } /* parse the DSN string */ if (!odbc_parse_connect_string(&dbc->errs, tds_dstr_buf(&conn_str), tds_dstr_buf(&conn_str) + tds_dstr_len(&conn_str), login, params)) { tds_dstr_free(&conn_str); ODBC_EXIT_(dbc); } odbc_set_string(dbc, szConnStrOut, cbConnStrOutMax, pcbConnStrOut, tds_dstr_buf(&conn_str), tds_dstr_len(&conn_str)); tds_dstr_free(&conn_str); /* add login info */ if (hwnd && fDriverCompletion != SQL_DRIVER_NOPROMPT && (fDriverCompletion == SQL_DRIVER_PROMPT || (!params[ODBC_PARAM_UID].p && !params[ODBC_PARAM_Trusted_Connection].p) || tds_dstr_isempty(&login->server_name))) { #ifdef _WIN32 char *out = NULL; /* prompt for login information */ if (!get_login_info(hwnd, login)) { tds_free_login(login); odbc_errs_add(&dbc->errs, "08001", "User canceled login"); ODBC_EXIT_(dbc); } if (tds_dstr_isempty(&login->user_name)) { params[ODBC_PARAM_UID].p = NULL; params[ODBC_PARAM_PWD].p = NULL; params[ODBC_PARAM_Trusted_Connection].p = "Yes"; params[ODBC_PARAM_Trusted_Connection].len = 3; } else { params[ODBC_PARAM_UID].p = tds_dstr_cstr(&login->user_name); params[ODBC_PARAM_UID].len = tds_dstr_len(&login->user_name); params[ODBC_PARAM_PWD].p = tds_dstr_cstr(&login->password); params[ODBC_PARAM_PWD].len = tds_dstr_len(&login->password); params[ODBC_PARAM_Trusted_Connection].p = NULL; } if (!odbc_build_connect_string(&dbc->errs, params, &out)) ODBC_EXIT_(dbc); odbc_set_string(dbc, szConnStrOut, cbConnStrOutMax, pcbConnStrOut, out, -1); tdsdump_log(TDS_DBG_INFO1, "connection string is now: %s\n", out); free(out); #else /* we dont support a dialog box */ odbc_errs_add(&dbc->errs, "HYC00", NULL); #endif } if (tds_dstr_isempty(&login->server_name)) { tds_free_login(login); odbc_errs_add(&dbc->errs, "IM007", "Could not find Servername or server parameter"); ODBC_EXIT_(dbc); } odbc_connect(dbc, login); tds_free_login(login); ODBC_EXIT_(dbc); } #if 0 SQLRETURN ODBC_API SQLBrowseConnect(SQLHDBC hdbc, SQLCHAR FAR * szConnStrIn, SQLSMALLINT cbConnStrIn, SQLCHAR FAR * szConnStrOut, SQLSMALLINT cbConnStrOutMax, SQLSMALLINT FAR * pcbConnStrOut) { tdsdump_log(TDS_DBG_FUNC, "SQLBrowseConnect(%p, %s, %d, %p, %d, %p)\n", hdbc, szConnStrIn, cbConnStrIn, szConnStrOut, cbConnStrOutMax, pcbConnStrOut); ODBC_ENTER_HDBC; odbc_errs_add(&dbc->errs, "HYC00", "SQLBrowseConnect: function not implemented"); ODBC_EXIT_(dbc); } #endif ODBC_FUNC(SQLColumnPrivileges, (P(SQLHSTMT,hstmt), PCHARIN(CatalogName,SQLSMALLINT), PCHARIN(SchemaName,SQLSMALLINT), PCHARIN(TableName,SQLSMALLINT), PCHARIN(ColumnName,SQLSMALLINT) WIDE)) { int retcode; ODBC_ENTER_HSTMT; retcode = odbc_stat_execute(stmt _wide, "sp_column_privileges", 4, "O@table_qualifier", szCatalogName, cbCatalogName, "O@table_owner", szSchemaName, cbSchemaName, "O@table_name", szTableName, cbTableName, "P@column_name", szColumnName, cbColumnName); if (SQL_SUCCEEDED(retcode) && stmt->dbc->env->attr.odbc_version == SQL_OV_ODBC3) { odbc_col_setname(stmt, 1, "TABLE_CAT"); odbc_col_setname(stmt, 2, "TABLE_SCHEM"); } ODBC_EXIT_(stmt); } #if 0 SQLRETURN ODBC_API SQLDescribeParam(SQLHSTMT hstmt, SQLUSMALLINT ipar, SQLSMALLINT FAR * pfSqlType, SQLUINTEGER FAR * pcbParamDef, SQLSMALLINT FAR * pibScale, SQLSMALLINT FAR * pfNullable) { tdsdump_log(TDS_DBG_FUNC, "SQLDescribeParam(%p, %d, %p, %p, %p, %p)\n", hstmt, ipar, pfSqlType, pcbParamDef, pibScale, pfNullable); ODBC_ENTER_HSTMT; odbc_errs_add(&stmt->errs, "HYC00", "SQLDescribeParam: function not implemented"); ODBC_EXIT_(stmt); } #endif SQLRETURN ODBC_PUBLIC ODBC_API SQLExtendedFetch(SQLHSTMT hstmt, SQLUSMALLINT fFetchType, SQLROWOFFSET irow, SQLROWSETSIZE FAR * pcrow, SQLUSMALLINT FAR * rgfRowStatus) { SQLRETURN ret; SQLULEN * tmp_rows; SQLUSMALLINT * tmp_status; SQLULEN tmp_size; SQLLEN * tmp_offset; SQLPOINTER tmp_bookmark; SQLULEN bookmark; SQLULEN out_len = 0; ODBC_ENTER_HSTMT; tdsdump_log(TDS_DBG_FUNC, "SQLExtendedFetch(%p, %d, %d, %p, %p)\n", hstmt, fFetchType, (int)irow, pcrow, rgfRowStatus); if (fFetchType != SQL_FETCH_NEXT && !stmt->dbc->cursor_support) { odbc_errs_add(&stmt->errs, "HY106", NULL); ODBC_EXIT_(stmt); } /* save and change IRD/ARD state */ tmp_rows = stmt->ird->header.sql_desc_rows_processed_ptr; stmt->ird->header.sql_desc_rows_processed_ptr = &out_len; tmp_status = stmt->ird->header.sql_desc_array_status_ptr; stmt->ird->header.sql_desc_array_status_ptr = rgfRowStatus; tmp_size = stmt->ard->header.sql_desc_array_size; stmt->ard->header.sql_desc_array_size = stmt->sql_rowset_size; tmp_offset = stmt->ard->header.sql_desc_bind_offset_ptr; stmt->ard->header.sql_desc_bind_offset_ptr = NULL; tmp_bookmark = stmt->attr.fetch_bookmark_ptr; /* SQL_FETCH_BOOKMARK different */ if (fFetchType == SQL_FETCH_BOOKMARK) { bookmark = irow; irow = 0; stmt->attr.fetch_bookmark_ptr = &bookmark; } /* TODO errors are sligthly different ... perhaps it's better to leave DM do this job ?? */ /* TODO check fFetchType can be converted to USMALLINT */ ret = _SQLFetch(stmt, fFetchType, irow); /* restore IRD/ARD */ stmt->ird->header.sql_desc_rows_processed_ptr = tmp_rows; if (pcrow) *pcrow = out_len; stmt->ird->header.sql_desc_array_status_ptr = tmp_status; stmt->ard->header.sql_desc_array_size = tmp_size; stmt->ard->header.sql_desc_bind_offset_ptr = tmp_offset; stmt->attr.fetch_bookmark_ptr = tmp_bookmark; ODBC_EXIT(stmt, ret); } ODBC_FUNC(SQLForeignKeys, (P(SQLHSTMT,hstmt), PCHARIN(PkCatalogName,SQLSMALLINT), PCHARIN(PkSchemaName,SQLSMALLINT), PCHARIN(PkTableName,SQLSMALLINT), PCHARIN(FkCatalogName,SQLSMALLINT), PCHARIN(FkSchemaName,SQLSMALLINT), PCHARIN(FkTableName,SQLSMALLINT) WIDE)) { int retcode; ODBC_ENTER_HSTMT; retcode = odbc_stat_execute(stmt _wide, "sp_fkeys", 6, "O@pktable_qualifier", szPkCatalogName, cbPkCatalogName, "O@pktable_owner", szPkSchemaName, cbPkSchemaName, "O@pktable_name", szPkTableName, cbPkTableName, "O@fktable_qualifier", szFkCatalogName, cbFkCatalogName, "O@fktable_owner", szFkSchemaName, cbFkSchemaName, "O@fktable_name", szFkTableName, cbFkTableName); if (SQL_SUCCEEDED(retcode) && stmt->dbc->env->attr.odbc_version == SQL_OV_ODBC3) { odbc_col_setname(stmt, 1, "PKTABLE_CAT"); odbc_col_setname(stmt, 2, "PKTABLE_SCHEM"); odbc_col_setname(stmt, 5, "FKTABLE_CAT"); odbc_col_setname(stmt, 6, "FKTABLE_SCHEM"); } ODBC_EXIT_(stmt); } static int odbc_lock_statement(TDS_STMT* stmt) { #if ENABLE_ODBC_MARS TDSSOCKET *tds = stmt->tds; /* we already own a socket, just use it */ if (!tds) { /* try with one saved into DBC */ TDSSOCKET *dbc_tds = stmt->dbc->tds_socket; tds_mutex_lock(&stmt->dbc->mtx); if (stmt->dbc->current_statement == NULL || stmt->dbc->current_statement == stmt) { tds = dbc_tds; stmt->dbc->current_statement = stmt; } /* try to grab current locked one */ if (!tds && dbc_tds->state == TDS_IDLE) { stmt->dbc->current_statement->tds = NULL; tds = dbc_tds; stmt->dbc->current_statement = stmt; } tds_mutex_unlock(&stmt->dbc->mtx); /* try with MARS */ if (!tds) tds = tds_alloc_additional_socket(dbc_tds->conn); } if (tds) { tds->query_timeout = (stmt->attr.query_timeout != DEFAULT_QUERY_TIMEOUT) ? stmt->attr.query_timeout : stmt->dbc->default_query_timeout; tds_set_parent(tds, stmt); stmt->tds = tds; return 1; } odbc_errs_add(&stmt->errs, "24000", NULL); return 0; #else TDSSOCKET *tds = stmt->dbc->tds_socket; tds_mutex_lock(&stmt->dbc->mtx); if (stmt->dbc->current_statement != NULL && stmt->dbc->current_statement != stmt) { if (!tds || tds->state != TDS_IDLE) { tds_mutex_unlock(&stmt->dbc->mtx); odbc_errs_add(&stmt->errs, "24000", NULL); return 0; } stmt->dbc->current_statement->tds = NULL; } stmt->dbc->current_statement = stmt; if (tds) { tds->query_timeout = (stmt->attr.query_timeout != DEFAULT_QUERY_TIMEOUT) ? stmt->attr.query_timeout : stmt->dbc->default_query_timeout; tds_set_parent(tds, stmt); stmt->tds = tds; } tds_mutex_unlock(&stmt->dbc->mtx); return 1; #endif } static void odbc_unlock_statement(TDS_STMT* stmt) { TDSSOCKET * tds; tds_mutex_lock(&stmt->dbc->mtx); tds = stmt->tds; if (stmt->dbc->current_statement == stmt) { assert(tds == stmt->dbc->tds_socket); if (tds->state == TDS_IDLE) { stmt->dbc->current_statement = NULL; tds_set_parent(tds, stmt->dbc); stmt->tds = NULL; } #if ENABLE_ODBC_MARS } else if (tds) { if (tds->state == TDS_IDLE || tds->state == TDS_DEAD) { assert(tds != stmt->dbc->tds_socket); tds_free_socket(tds); stmt->tds = NULL; } #endif } tds_mutex_unlock(&stmt->dbc->mtx); } SQLRETURN ODBC_PUBLIC ODBC_API SQLMoreResults(SQLHSTMT hstmt) { TDSSOCKET *tds; TDS_INT result_type; TDSRET tdsret; int in_row = 0; SQLUSMALLINT param_status; int token_flags; ODBC_ENTER_HSTMT; tdsdump_log(TDS_DBG_FUNC, "SQLMoreResults(%p)\n", hstmt); tds = stmt->tds; /* We already read all results... */ if (!tds) ODBC_EXIT(stmt, SQL_NO_DATA); stmt->row_count = TDS_NO_COUNT; stmt->special_row = ODBC_SPECIAL_NONE; /* TODO this code is TOO similar to _SQLExecute, merge it - freddy77 */ /* try to go to the next recordset */ if (stmt->row_status == IN_COMPUTE_ROW) { /* FIXME doesn't seem so fine ... - freddy77 */ tds_process_tokens(tds, &result_type, NULL, TDS_TOKEN_TRAILING); stmt->row_status = IN_COMPUTE_ROW; in_row = 1; } param_status = SQL_PARAM_SUCCESS; token_flags = (TDS_TOKEN_RESULTS & (~TDS_STOPAT_COMPUTE)) | TDS_RETURN_COMPUTE; if (stmt->dbc->env->attr.odbc_version == SQL_OV_ODBC3) token_flags |= TDS_RETURN_MSG; for (;;) { result_type = odbc_process_tokens(stmt, token_flags); tdsdump_log(TDS_DBG_INFO1, "SQLMoreResults: result_type=%d, row_count=%" PRId64 ", lastrc=%d\n", result_type, stmt->row_count, stmt->errs.lastrc); switch (result_type) { case TDS_CMD_DONE: #if 1 /* !UNIXODBC */ tds_free_all_results(tds); #endif odbc_populate_ird(stmt); odbc_unlock_statement(stmt); if (stmt->row_count == TDS_NO_COUNT && !in_row) { stmt->row_status = NOT_IN_ROW; tdsdump_log(TDS_DBG_INFO1, "SQLMoreResults: row_status=%d\n", stmt->row_status); } tdsdump_log(TDS_DBG_INFO1, "SQLMoreResults: row_count=%" PRId64 ", lastrc=%d\n", stmt->row_count, stmt->errs.lastrc); if (stmt->row_count == TDS_NO_COUNT) { if (stmt->errs.lastrc == SQL_SUCCESS || stmt->errs.lastrc == SQL_SUCCESS_WITH_INFO) ODBC_EXIT(stmt, SQL_NO_DATA); } ODBC_EXIT_(stmt); case TDS_CMD_FAIL: ODBC_SAFE_ERROR(stmt); ODBC_EXIT_(stmt); case TDS_COMPUTE_RESULT: switch (stmt->row_status) { /* skip this recordset */ case IN_COMPUTE_ROW: /* TODO here we should set current_results to normal results */ in_row = 1; /* fall through */ /* in normal row, put in compute status */ case AFTER_COMPUTE_ROW: case IN_NORMAL_ROW: case PRE_NORMAL_ROW: stmt->row_status = IN_COMPUTE_ROW; odbc_populate_ird(stmt); ODBC_EXIT_(stmt); case NOT_IN_ROW: /* this should never happen, protocol error */ ODBC_SAFE_ERROR(stmt); ODBC_EXIT_(stmt); break; } break; case TDS_ROW_RESULT: if (in_row || (stmt->row_status != IN_NORMAL_ROW && stmt->row_status != PRE_NORMAL_ROW)) { stmt->row_status = PRE_NORMAL_ROW; odbc_populate_ird(stmt); ODBC_EXIT_(stmt); } /* Skipping current result set's rows to access next resultset or proc's retval */ tdsret = tds_process_tokens(tds, &result_type, NULL, TDS_STOPAT_ROWFMT|TDS_RETURN_DONE|TDS_STOPAT_COMPUTE); /* TODO should we set in_row ?? */ switch (tdsret) { case TDS_CANCELLED: odbc_errs_add(&stmt->errs, "HY008", NULL); default: if (TDS_FAILED(tdsret)) { ODBC_SAFE_ERROR(stmt); ODBC_EXIT_(stmt); } } break; case TDS_DONE_RESULT: case TDS_DONEPROC_RESULT: /* FIXME here ??? */ if (!in_row) tds_free_all_results(tds); switch (stmt->errs.lastrc) { case SQL_ERROR: param_status = SQL_PARAM_ERROR; break; case SQL_SUCCESS_WITH_INFO: param_status = SQL_PARAM_SUCCESS_WITH_INFO; break; } if (stmt->curr_param_row < stmt->num_param_rows) { if (stmt->ipd->header.sql_desc_array_status_ptr) stmt->ipd->header.sql_desc_array_status_ptr[stmt->curr_param_row] = param_status; ++stmt->curr_param_row; if (stmt->ipd->header.sql_desc_rows_processed_ptr) *stmt->ipd->header.sql_desc_rows_processed_ptr = stmt->curr_param_row; } if (stmt->curr_param_row < stmt->num_param_rows) { #if 0 if (stmt->errs.lastrc == SQL_SUCCESS_WITH_INFO) found_info = 1; if (stmt->errs.lastrc == SQL_ERROR) found_error = 1; #endif stmt->errs.lastrc = SQL_SUCCESS; param_status = SQL_PARAM_SUCCESS; break; } odbc_populate_ird(stmt); ODBC_EXIT_(stmt); break; /* * TODO test flags ? check error and change result ? * see also other DONEINPROC handle (below) */ case TDS_DONEINPROC_RESULT: if (in_row) { odbc_populate_ird(stmt); ODBC_EXIT_(stmt); } /* TODO perhaps it can be a problem if SET NOCOUNT ON, test it */ tds_free_all_results(tds); odbc_populate_ird(stmt); break; /* do not stop at metadata, an error can follow... */ case TDS_ROWFMT_RESULT: if (in_row) { odbc_populate_ird(stmt); ODBC_EXIT_(stmt); } stmt->row = 0; stmt->row_count = TDS_NO_COUNT; /* we expect a row */ stmt->row_status = PRE_NORMAL_ROW; in_row = 1; break; case TDS_MSG_RESULT: if (!in_row) { tds_free_all_results(tds); odbc_populate_ird(stmt); } in_row = 1; break; } } ODBC_EXIT(stmt, SQL_ERROR); } ODBC_FUNC(SQLNativeSql, (P(SQLHDBC,hdbc), PCHARIN(SqlStrIn,SQLINTEGER), PCHAROUT(SqlStr,SQLINTEGER) WIDE)) { SQLRETURN ret = SQL_SUCCESS; DSTR query = DSTR_INITIALIZER; ODBC_ENTER_HDBC; #ifdef TDS_NO_DM if (!szSqlStrIn || !IS_VALID_LEN(cbSqlStrIn)) { odbc_errs_add(&dbc->errs, "HY009", NULL); ODBC_EXIT_(dbc); } #endif if (!odbc_dstr_copy(dbc, &query, cbSqlStrIn, szSqlStrIn)) { odbc_errs_add(&dbc->errs, "HY001", NULL); ODBC_EXIT_(dbc); } native_sql(dbc, &query); /* FIXME if error set some kind of error */ ret = odbc_set_string(dbc, szSqlStr, cbSqlStrMax, pcbSqlStr, tds_dstr_cstr(&query), -1); tds_dstr_free(&query); ODBC_EXIT(dbc, ret); } SQLRETURN ODBC_PUBLIC ODBC_API SQLNumParams(SQLHSTMT hstmt, SQLSMALLINT FAR * pcpar) { ODBC_ENTER_HSTMT; tdsdump_log(TDS_DBG_FUNC, "SQLNumParams(%p, %p)\n", hstmt, pcpar); *pcpar = stmt->param_count; ODBC_EXIT_(stmt); } SQLRETURN ODBC_PUBLIC ODBC_API SQLParamOptions(SQLHSTMT hstmt, SQLULEN crow, SQLULEN FAR * pirow) { SQLRETURN res; tdsdump_log(TDS_DBG_FUNC, "SQLParamOptions(%p, %lu, %p)\n", hstmt, (unsigned long int)crow, pirow); /* emulate for ODBC 2 DM */ res = _SQLSetStmtAttr(hstmt, SQL_ATTR_PARAMS_PROCESSED_PTR, pirow, 0 _wide0); if (res != SQL_SUCCESS) return res; return _SQLSetStmtAttr(hstmt, SQL_ATTR_PARAMSET_SIZE, (SQLPOINTER) (TDS_INTPTR) crow, 0 _wide0); } ODBC_FUNC(SQLPrimaryKeys, (P(SQLHSTMT,hstmt), PCHARIN(CatalogName,SQLSMALLINT), PCHARIN(SchemaName,SQLSMALLINT), PCHARIN(TableName,SQLSMALLINT) WIDE)) { int retcode; ODBC_ENTER_HSTMT; retcode = odbc_stat_execute(stmt _wide, "sp_pkeys", 3, "O@table_qualifier", szCatalogName, cbCatalogName, "O@table_owner", szSchemaName, cbSchemaName, "O@table_name", szTableName, cbTableName); if (SQL_SUCCEEDED(retcode) && stmt->dbc->env->attr.odbc_version == SQL_OV_ODBC3) { odbc_col_setname(stmt, 1, "TABLE_CAT"); odbc_col_setname(stmt, 2, "TABLE_SCHEM"); } ODBC_EXIT_(stmt); } ODBC_FUNC(SQLProcedureColumns, (P(SQLHSTMT,hstmt), PCHARIN(CatalogName,SQLSMALLINT), PCHARIN(SchemaName,SQLSMALLINT), PCHARIN(ProcName,SQLSMALLINT), PCHARIN(ColumnName,SQLSMALLINT) WIDE)) { int retcode; ODBC_ENTER_HSTMT; retcode = odbc_stat_execute(stmt _wide, "sp_sproc_columns", TDS_IS_MSSQL(stmt->dbc->tds_socket) ? 5 : 4, "O@procedure_qualifier", szCatalogName, cbCatalogName, "P@procedure_owner", szSchemaName, cbSchemaName, "P@procedure_name", szProcName, cbProcName, "P@column_name", szColumnName, cbColumnName, "V@ODBCVer", (char*) NULL, 0); if (SQL_SUCCEEDED(retcode) && stmt->dbc->env->attr.odbc_version == SQL_OV_ODBC3) { odbc_col_setname(stmt, 1, "PROCEDURE_CAT"); odbc_col_setname(stmt, 2, "PROCEDURE_SCHEM"); odbc_col_setname(stmt, 8, "COLUMN_SIZE"); odbc_col_setname(stmt, 9, "BUFFER_LENGTH"); odbc_col_setname(stmt, 10, "DECIMAL_DIGITS"); odbc_col_setname(stmt, 11, "NUM_PREC_RADIX"); if (TDS_IS_SYBASE(stmt->dbc->tds_socket)) stmt->special_row = ODBC_SPECIAL_PROCEDURECOLUMNS; } ODBC_EXIT_(stmt); } ODBC_FUNC(SQLProcedures, (P(SQLHSTMT,hstmt), PCHARIN(CatalogName,SQLSMALLINT), PCHARIN(SchemaName,SQLSMALLINT), PCHARIN(ProcName,SQLSMALLINT) WIDE)) { int retcode; ODBC_ENTER_HSTMT; retcode = odbc_stat_execute(stmt _wide, "..sp_stored_procedures", 3, "P@sp_name", szProcName, cbProcName, "P@sp_owner", szSchemaName, cbSchemaName, "O@sp_qualifier", szCatalogName, cbCatalogName); if (SQL_SUCCEEDED(retcode) && stmt->dbc->env->attr.odbc_version == SQL_OV_ODBC3) { odbc_col_setname(stmt, 1, "PROCEDURE_CAT"); odbc_col_setname(stmt, 2, "PROCEDURE_SCHEM"); } ODBC_EXIT_(stmt); } static TDSPARAMINFO* odbc_build_update_params(TDS_STMT * stmt, unsigned int n_row) { unsigned int n; TDSPARAMINFO * params = NULL; struct _drecord *drec_ird; for (n = 0; n < stmt->ird->header.sql_desc_count && n < stmt->ard->header.sql_desc_count; ++n) { TDSPARAMINFO *temp_params; TDSCOLUMN *curcol; drec_ird = &stmt->ird->records[n]; if (drec_ird->sql_desc_updatable == SQL_FALSE) continue; /* we have certainly a parameter */ if (!(temp_params = tds_alloc_param_result(params))) goto memory_error; params = temp_params; curcol = params->columns[params->num_cols - 1]; if (!tds_dstr_dup(&curcol->column_name, &drec_ird->sql_desc_name)) goto memory_error; /* TODO use all infos... */ if (!tds_dstr_dup(&curcol->table_name, &drec_ird->sql_desc_base_table_name)) goto memory_error; switch (odbc_sql2tds(stmt, drec_ird, &stmt->ard->records[n], curcol, 1, stmt->ard, n_row)) { case SQL_NEED_DATA: goto memory_error; case SQL_ERROR: tds_free_param_results(params); return NULL; } } return params; memory_error: tds_free_param_results(params); odbc_errs_add(&stmt->errs, "HY001", NULL); return NULL; } SQLRETURN ODBC_PUBLIC ODBC_API SQLSetPos(SQLHSTMT hstmt, SQLSETPOSIROW irow, SQLUSMALLINT fOption, SQLUSMALLINT fLock) { TDSRET ret; TDSSOCKET *tds; TDS_CURSOR_OPERATION op; TDSPARAMINFO *params = NULL; ODBC_ENTER_HSTMT; tdsdump_log(TDS_DBG_FUNC, "SQLSetPos(%p, %ld, %d, %d)\n", hstmt, (long) irow, fOption, fLock); if (!stmt->dbc->cursor_support) { odbc_errs_add(&stmt->errs, "HYC00", "SQLSetPos: function not implemented"); ODBC_EXIT_(stmt); } /* TODO handle irow == 0 (all rows) */ if (!stmt->cursor) { odbc_errs_add(&stmt->errs, "HY109", NULL); ODBC_EXIT_(stmt); } switch (fOption) { case SQL_POSITION: op = TDS_CURSOR_POSITION; break; /* TODO cursor support */ case SQL_REFRESH: default: odbc_errs_add(&stmt->errs, "HY092", NULL); ODBC_EXIT_(stmt); break; case SQL_UPDATE: op = TDS_CURSOR_UPDATE; /* prepare paremeters for update */ /* scan all columns and build parameter list */ params = odbc_build_update_params(stmt, irow >= 1 ? irow - 1 : 0); if (!params) { ODBC_SAFE_ERROR(stmt); ODBC_EXIT_(stmt); } break; case SQL_DELETE: op = TDS_CURSOR_DELETE; break; case SQL_ADD: op = TDS_CURSOR_INSERT; break; } if (!odbc_lock_statement(stmt)) { tds_free_param_results(params); ODBC_EXIT_(stmt); } tds = stmt->tds; if (TDS_FAILED(tds_cursor_update(tds, stmt->cursor, op, irow, params))) { tds_free_param_results(params); ODBC_SAFE_ERROR(stmt); ODBC_EXIT_(stmt); } tds_free_param_results(params); params = NULL; ret = tds_process_simple_query(tds); odbc_unlock_statement(stmt); if (TDS_FAILED(ret)) { ODBC_SAFE_ERROR(stmt); ODBC_EXIT_(stmt); } ODBC_EXIT_(stmt); } ODBC_FUNC(SQLTablePrivileges, (P(SQLHSTMT,hstmt), PCHARIN(CatalogName,SQLSMALLINT), PCHARIN(SchemaName,SQLSMALLINT), PCHARIN(TableName,SQLSMALLINT) WIDE)) { int retcode; ODBC_ENTER_HSTMT; retcode = odbc_stat_execute(stmt _wide, "sp_table_privileges", 3, "O@table_qualifier", szCatalogName, cbCatalogName, "P@table_owner", szSchemaName, cbSchemaName, "P@table_name", szTableName, cbTableName); if (SQL_SUCCEEDED(retcode) && stmt->dbc->env->attr.odbc_version == SQL_OV_ODBC3) { odbc_col_setname(stmt, 1, "TABLE_CAT"); odbc_col_setname(stmt, 2, "TABLE_SCHEM"); } ODBC_EXIT_(stmt); } #if (ODBCVER >= 0x0300) SQLRETURN ODBC_PUBLIC ODBC_API SQLSetEnvAttr(SQLHENV henv, SQLINTEGER Attribute, SQLPOINTER Value, SQLINTEGER StringLength) { SQLINTEGER i_val = (SQLINTEGER) (TDS_INTPTR) Value; ODBC_ENTER_HENV; tdsdump_log(TDS_DBG_FUNC, "SQLSetEnvAttr(%p, %d, %p, %d)\n", henv, (int)Attribute, Value, (int)StringLength); switch (Attribute) { case SQL_ATTR_CONNECTION_POOLING: case SQL_ATTR_CP_MATCH: odbc_errs_add(&env->errs, "HYC00", NULL); break; case SQL_ATTR_ODBC_VERSION: switch (i_val) { case SQL_OV_ODBC3: case SQL_OV_ODBC2: env->attr.odbc_version = i_val; break; default: odbc_errs_add(&env->errs, "HY024", NULL); break; } break; case SQL_ATTR_OUTPUT_NTS: /* TODO - Make this really work */ /* env->attr.output_nts = i_val; */ env->attr.output_nts = SQL_TRUE; break; default: odbc_errs_add(&env->errs, "HY092", NULL); break; } ODBC_EXIT_(env); } SQLRETURN ODBC_PUBLIC ODBC_API SQLGetEnvAttr(SQLHENV henv, SQLINTEGER Attribute, SQLPOINTER Value, SQLINTEGER BufferLength, SQLINTEGER * StringLength) { size_t size; void *src; ODBC_ENTER_HENV; tdsdump_log(TDS_DBG_FUNC, "SQLGetEnvAttr(%p, %d, %p, %d, %p)\n", henv, (int)Attribute, Value, (int)BufferLength, StringLength); switch (Attribute) { case SQL_ATTR_CONNECTION_POOLING: src = &env->attr.connection_pooling; size = sizeof(env->attr.connection_pooling); break; case SQL_ATTR_CP_MATCH: src = &env->attr.cp_match; size = sizeof(env->attr.cp_match); break; case SQL_ATTR_ODBC_VERSION: src = &env->attr.odbc_version; size = sizeof(env->attr.odbc_version); break; case SQL_ATTR_OUTPUT_NTS: /* TODO handle output_nts flags */ env->attr.output_nts = SQL_TRUE; src = &env->attr.output_nts; size = sizeof(env->attr.output_nts); break; default: odbc_errs_add(&env->errs, "HY092", NULL); ODBC_EXIT_(env); break; } if (StringLength) { *StringLength = size; } memcpy(Value, src, size); ODBC_EXIT_(env); } #endif #define IRD_UPDATE(desc, errs, exit) \ do { \ if (desc->type == DESC_IRD && ((TDS_STMT*)desc->parent)->need_reprepare && \ odbc_update_ird((TDS_STMT*)desc->parent, errs) != SQL_SUCCESS) \ exit; \ } while(0) static SQLRETURN _SQLBindParameter(SQLHSTMT hstmt, SQLUSMALLINT ipar, SQLSMALLINT fParamType, SQLSMALLINT fCType, SQLSMALLINT fSqlType, SQLULEN cbColDef, SQLSMALLINT ibScale, SQLPOINTER rgbValue, SQLLEN cbValueMax, SQLLEN FAR * pcbValue) { TDS_DESC *apd, *ipd; struct _drecord *drec; SQLSMALLINT orig_apd_size, orig_ipd_size; int is_numeric = 0; ODBC_ENTER_HSTMT; tdsdump_log(TDS_DBG_FUNC, "_SQLBindParameter(%p, %u, %d, %d, %d, %u, %d, %p, %d, %p)\n", hstmt, (unsigned short)ipar, (int)fParamType, (int)fCType, (int)fSqlType, (unsigned int)cbColDef, (int)ibScale, rgbValue, (int)cbValueMax, pcbValue); #ifdef TDS_NO_DM /* TODO - more error checking ... XXX smurph */ /* Check param type */ switch (fParamType) { case SQL_PARAM_INPUT: case SQL_PARAM_INPUT_OUTPUT: case SQL_PARAM_OUTPUT: break; default: odbc_errs_add(&stmt->errs, "HY105", NULL); ODBC_EXIT_(stmt); } /* Check max buffer length */ if (cbValueMax < 0) { odbc_errs_add(&stmt->errs, "HY090", NULL); ODBC_EXIT_(stmt); } #endif /* check cbColDef and ibScale */ if (fSqlType == SQL_DECIMAL || fSqlType == SQL_NUMERIC) { is_numeric = 1; if (cbColDef < 1 || cbColDef > 38) { odbc_errs_add(&stmt->errs, "HY104", "Invalid precision value"); ODBC_EXIT_(stmt); } if (ibScale < 0 || ibScale > cbColDef) { odbc_errs_add(&stmt->errs, "HY104", "Invalid scale value"); ODBC_EXIT_(stmt); } } /* Check parameter number */ if (ipar <= 0 || ipar > 4000) { odbc_errs_add(&stmt->errs, "07009", NULL); ODBC_EXIT_(stmt); } /* fill APD related fields */ apd = stmt->apd; orig_apd_size = apd->header.sql_desc_count; if (ipar > apd->header.sql_desc_count && desc_alloc_records(apd, ipar) != SQL_SUCCESS) { odbc_errs_add(&stmt->errs, "HY001", NULL); ODBC_EXIT_(stmt); } drec = &apd->records[ipar - 1]; if (odbc_set_concise_c_type(fCType, drec, 0) != SQL_SUCCESS) { desc_alloc_records(apd, orig_apd_size); odbc_errs_add(&stmt->errs, "HY004", NULL); ODBC_EXIT_(stmt); } stmt->need_reprepare = 1; /* TODO other types ?? handle SQL_C_DEFAULT */ if (drec->sql_desc_type == SQL_C_CHAR || drec->sql_desc_type == SQL_C_WCHAR || drec->sql_desc_type == SQL_C_BINARY) drec->sql_desc_octet_length = cbValueMax; drec->sql_desc_indicator_ptr = pcbValue; drec->sql_desc_octet_length_ptr = pcbValue; drec->sql_desc_data_ptr = (char *) rgbValue; /* field IPD related fields */ ipd = stmt->ipd; orig_ipd_size = ipd->header.sql_desc_count; if (ipar > ipd->header.sql_desc_count && desc_alloc_records(ipd, ipar) != SQL_SUCCESS) { desc_alloc_records(apd, orig_apd_size); odbc_errs_add(&stmt->errs, "HY001", NULL); ODBC_EXIT_(stmt); } drec = &ipd->records[ipar - 1]; drec->sql_desc_parameter_type = fParamType; if (odbc_set_concise_sql_type(fSqlType, drec, 0) != SQL_SUCCESS) { desc_alloc_records(ipd, orig_ipd_size); desc_alloc_records(apd, orig_apd_size); odbc_errs_add(&stmt->errs, "HY004", NULL); ODBC_EXIT_(stmt); } if (is_numeric) { drec->sql_desc_precision = cbColDef; drec->sql_desc_scale = ibScale; } else { drec->sql_desc_length = cbColDef; } ODBC_EXIT_(stmt); } SQLRETURN ODBC_PUBLIC ODBC_API SQLBindParameter(SQLHSTMT hstmt, SQLUSMALLINT ipar, SQLSMALLINT fParamType, SQLSMALLINT fCType, SQLSMALLINT fSqlType, SQLULEN cbColDef, SQLSMALLINT ibScale, SQLPOINTER rgbValue, SQLLEN cbValueMax, SQLLEN FAR * pcbValue) { tdsdump_log(TDS_DBG_FUNC, "SQLBindParameter(%p, %u, %d, %d, %d, %u, %d, %p, %d, %p)\n", hstmt, (unsigned)ipar, fParamType, fCType, (int)fSqlType, (unsigned)cbColDef, ibScale, rgbValue, (int)cbValueMax, pcbValue); return _SQLBindParameter(hstmt, ipar, fParamType, fCType, fSqlType, cbColDef, ibScale, rgbValue, cbValueMax, pcbValue); } /* compatibility with X/Open */ SQLRETURN ODBC_PUBLIC ODBC_API SQLBindParam(SQLHSTMT hstmt, SQLUSMALLINT ipar, SQLSMALLINT fCType, SQLSMALLINT fSqlType, SQLULEN cbColDef, SQLSMALLINT ibScale, SQLPOINTER rgbValue, SQLLEN FAR * pcbValue) { tdsdump_log(TDS_DBG_FUNC, "SQLBindParam(%p, %d, %d, %d, %u, %d, %p, %p)\n", hstmt, ipar, fCType, fSqlType, (unsigned)cbColDef, ibScale, rgbValue, pcbValue); return _SQLBindParameter(hstmt, ipar, SQL_PARAM_INPUT, fCType, fSqlType, cbColDef, ibScale, rgbValue, 0, pcbValue); } #if (ODBCVER >= 0x0300) SQLRETURN ODBC_PUBLIC ODBC_API SQLAllocHandle(SQLSMALLINT HandleType, SQLHANDLE InputHandle, SQLHANDLE * OutputHandle) { tdsdump_log(TDS_DBG_FUNC, "SQLAllocHandle(%d, %p, %p)\n", HandleType, InputHandle, OutputHandle); switch (HandleType) { case SQL_HANDLE_STMT: return _SQLAllocStmt(InputHandle, OutputHandle); break; case SQL_HANDLE_DBC: return _SQLAllocConnect(InputHandle, OutputHandle); break; case SQL_HANDLE_ENV: return _SQLAllocEnv(OutputHandle, SQL_OV_ODBC3); break; case SQL_HANDLE_DESC: return _SQLAllocDesc(InputHandle, OutputHandle); break; } /* * As the documentation puts it, * "There is no handle with which to associate additional diagnostic information." * * The DM must catch HY092 because the driver has no valid handle at this early stage in which * to store the error for later retrieval by the application. */ tdsdump_log(TDS_DBG_FUNC, "SQLAllocHandle(): invalid HandleType, error HY092: should be caught by DM\n"); return SQL_ERROR; } #endif static SQLRETURN _SQLAllocConnect(SQLHENV henv, SQLHDBC FAR * phdbc) { TDS_DBC *dbc; ODBC_ENTER_HENV; tdsdump_log(TDS_DBG_FUNC, "_SQLAllocConnect(%p, %p)\n", henv, phdbc); dbc = tds_new0(TDS_DBC, 1); if (!dbc) { odbc_errs_add(&env->errs, "HY001", NULL); ODBC_EXIT_(env); } dbc->htype = SQL_HANDLE_DBC; dbc->env = env; tds_dstr_init(&dbc->dsn); dbc->attr.cursor_type = SQL_CURSOR_FORWARD_ONLY; dbc->attr.access_mode = SQL_MODE_READ_WRITE; dbc->attr.async_enable = SQL_ASYNC_ENABLE_OFF; dbc->attr.auto_ipd = SQL_FALSE; /* * spinellia@acm.org * after login is enabled autocommit */ dbc->attr.autocommit = SQL_AUTOCOMMIT_ON; dbc->attr.connection_dead = SQL_CD_TRUE; /* No connection yet */ dbc->attr.connection_timeout = 0; /* This is set in the environment change function */ tds_dstr_init(&dbc->attr.current_catalog); dbc->attr.login_timeout = 0; /* TODO */ dbc->attr.metadata_id = SQL_FALSE; dbc->attr.odbc_cursors = SQL_CUR_USE_IF_NEEDED; dbc->attr.packet_size = 0; dbc->attr.quite_mode = NULL; /* We don't support GUI dialogs yet */ #ifdef TDS_NO_DM dbc->attr.trace = SQL_OPT_TRACE_OFF; tds_dstr_init(&dbc->attr.tracefile); #endif tds_dstr_init(&dbc->attr.translate_lib); #ifdef ENABLE_ODBC_WIDE tds_dstr_init(&dbc->original_charset); #endif tds_dstr_init(&dbc->oldpwd); dbc->attr.translate_option = 0; dbc->attr.txn_isolation = SQL_TXN_READ_COMMITTED; dbc->attr.mars_enabled = SQL_MARS_ENABLED_NO; dbc->attr.bulk_enabled = SQL_BCP_OFF; tds_mutex_init(&dbc->mtx); *phdbc = (SQLHDBC) dbc; ODBC_EXIT_(env); } SQLRETURN ODBC_PUBLIC ODBC_API SQLAllocConnect(SQLHENV henv, SQLHDBC FAR * phdbc) { tdsdump_log(TDS_DBG_FUNC, "SQLAllocConnect(%p, %p)\n", henv, phdbc); return _SQLAllocConnect(henv, phdbc); } static SQLRETURN _SQLAllocEnv(SQLHENV FAR * phenv, SQLINTEGER odbc_version) { TDS_ENV *env; TDSCONTEXT *ctx; tdsdump_log(TDS_DBG_FUNC, "_SQLAllocEnv(%p, %d)\n", phenv, (int) odbc_version); env = tds_new0(TDS_ENV, 1); if (!env) return SQL_ERROR; env->htype = SQL_HANDLE_ENV; env->attr.odbc_version = odbc_version; /* TODO use it */ env->attr.output_nts = SQL_TRUE; ctx = tds_alloc_context(env); if (!ctx) { free(env); return SQL_ERROR; } env->tds_ctx = ctx; ctx->msg_handler = odbc_errmsg_handler; ctx->err_handler = odbc_errmsg_handler; /* ODBC has its own format */ free(ctx->locale->date_fmt); ctx->locale->date_fmt = strdup("%Y-%m-%d %H:%M:%S.%z"); tds_mutex_init(&env->mtx); *phenv = (SQLHENV) env; return SQL_SUCCESS; } SQLRETURN ODBC_PUBLIC ODBC_API SQLAllocEnv(SQLHENV FAR * phenv) { tdsdump_log(TDS_DBG_FUNC, "SQLAllocEnv(%p)\n", phenv); return _SQLAllocEnv(phenv, SQL_OV_ODBC2); } static SQLRETURN _SQLAllocDesc(SQLHDBC hdbc, SQLHDESC FAR * phdesc) { int i; ODBC_ENTER_HDBC; tdsdump_log(TDS_DBG_FUNC, "_SQLAllocDesc(%p, %p)\n", hdbc, phdesc); for (i = 0; ; ++i) { if (i >= TDS_MAX_APP_DESC) { odbc_errs_add(&dbc->errs, "HY014", NULL); break; } if (dbc->uad[i] == NULL) { TDS_DESC *desc = desc_alloc(dbc, DESC_ARD, SQL_DESC_ALLOC_USER); if (desc == NULL) { odbc_errs_add(&dbc->errs, "HY001", NULL); break; } dbc->uad[i] = desc; *phdesc = (SQLHDESC) desc; break; } } ODBC_EXIT_(dbc); } static SQLRETURN _SQLAllocStmt(SQLHDBC hdbc, SQLHSTMT FAR * phstmt) { TDS_STMT *stmt; char *pstr; ODBC_ENTER_HDBC; tdsdump_log(TDS_DBG_FUNC, "_SQLAllocStmt(%p, %p)\n", hdbc, phstmt); stmt = tds_new0(TDS_STMT, 1); if (!stmt) { odbc_errs_add(&dbc->errs, "HY001", NULL); ODBC_EXIT_(dbc); } tds_dstr_init(&stmt->cursor_name); tds_dstr_init(&stmt->query); stmt->htype = SQL_HANDLE_STMT; stmt->dbc = dbc; stmt->num_param_rows = 1; pstr = NULL; /* TODO test initial cursor ... */ if (asprintf(&pstr, "SQL_CUR%lx", (unsigned long) stmt) < 0 || !tds_dstr_set(&stmt->cursor_name, pstr)) { free(stmt); free(pstr); odbc_errs_add(&dbc->errs, "HY001", NULL); ODBC_EXIT_(dbc); } /* do not free pstr tds_dstr_set do it if necessary */ /* allocate descriptors */ stmt->ird = desc_alloc(stmt, DESC_IRD, SQL_DESC_ALLOC_AUTO); stmt->ard = desc_alloc(stmt, DESC_ARD, SQL_DESC_ALLOC_AUTO); stmt->ipd = desc_alloc(stmt, DESC_IPD, SQL_DESC_ALLOC_AUTO); stmt->apd = desc_alloc(stmt, DESC_APD, SQL_DESC_ALLOC_AUTO); if (!stmt->ird || !stmt->ard || !stmt->ipd || !stmt->apd) { tds_dstr_free(&stmt->cursor_name); desc_free(stmt->ird); desc_free(stmt->ard); desc_free(stmt->ipd); desc_free(stmt->apd); free(stmt); odbc_errs_add(&dbc->errs, "HY001", NULL); ODBC_EXIT_(dbc); } /* save original ARD and APD */ stmt->orig_apd = stmt->apd; stmt->orig_ard = stmt->ard; /* set the default statement attributes */ /* stmt->attr.app_param_desc = stmt->apd; */ /* stmt->attr.app_row_desc = stmt->ard; */ stmt->attr.async_enable = SQL_ASYNC_ENABLE_OFF; stmt->attr.concurrency = SQL_CONCUR_READ_ONLY; stmt->attr.cursor_scrollable = SQL_NONSCROLLABLE; stmt->attr.cursor_sensitivity = SQL_INSENSITIVE; stmt->attr.cursor_type = SQL_CURSOR_FORWARD_ONLY; /* TODO ?? why two attributes */ stmt->attr.enable_auto_ipd = dbc->attr.auto_ipd = SQL_FALSE; stmt->attr.fetch_bookmark_ptr = NULL; /* stmt->attr.imp_param_desc = stmt->ipd; */ /* stmt->attr.imp_row_desc = stmt->ird; */ stmt->attr.keyset_size = 0; stmt->attr.max_length = 0; stmt->attr.max_rows = 0; stmt->attr.metadata_id = dbc->attr.metadata_id; /* TODO check this flag in prepare_call */ stmt->attr.noscan = SQL_NOSCAN_OFF; assert(stmt->apd->header.sql_desc_bind_offset_ptr == NULL); assert(stmt->apd->header.sql_desc_bind_type == SQL_PARAM_BIND_BY_COLUMN); assert(stmt->apd->header.sql_desc_array_status_ptr == NULL); assert(stmt->ipd->header.sql_desc_array_status_ptr == NULL); assert(stmt->ipd->header.sql_desc_rows_processed_ptr == NULL); assert(stmt->apd->header.sql_desc_array_size == 1); stmt->attr.query_timeout = DEFAULT_QUERY_TIMEOUT; stmt->attr.retrieve_data = SQL_RD_ON; assert(stmt->ard->header.sql_desc_array_size == 1); assert(stmt->ard->header.sql_desc_bind_offset_ptr == NULL); assert(stmt->ard->header.sql_desc_bind_type == SQL_BIND_BY_COLUMN); stmt->attr.row_number = 0; assert(stmt->ard->header.sql_desc_array_status_ptr == NULL); assert(stmt->ird->header.sql_desc_array_status_ptr == NULL); assert(stmt->ird->header.sql_desc_rows_processed_ptr == NULL); stmt->attr.simulate_cursor = SQL_SC_NON_UNIQUE; stmt->attr.use_bookmarks = SQL_UB_OFF; tds_dstr_init(&stmt->attr.qn_msgtext); tds_dstr_init(&stmt->attr.qn_options); stmt->attr.qn_timeout = 432000; stmt->sql_rowset_size = 1; stmt->row_count = TDS_NO_COUNT; stmt->row_status = NOT_IN_ROW; /* insert into list */ stmt->next = dbc->stmt_list; if (dbc->stmt_list) dbc->stmt_list->prev = stmt; dbc->stmt_list = stmt; tds_mutex_init(&stmt->mtx); *phstmt = (SQLHSTMT) stmt; if (dbc->attr.cursor_type != SQL_CURSOR_FORWARD_ONLY) _SQLSetStmtAttr(stmt, SQL_CURSOR_TYPE, (SQLPOINTER) (TDS_INTPTR) dbc->attr.cursor_type, SQL_IS_INTEGER _wide0); ODBC_EXIT_(dbc); } SQLRETURN ODBC_PUBLIC ODBC_API SQLAllocStmt(SQLHDBC hdbc, SQLHSTMT FAR * phstmt) { tdsdump_log(TDS_DBG_FUNC, "SQLAllocStmt(%p, %p)\n", hdbc, phstmt); return _SQLAllocStmt(hdbc, phstmt); } SQLRETURN ODBC_PUBLIC ODBC_API SQLBindCol(SQLHSTMT hstmt, SQLUSMALLINT icol, SQLSMALLINT fCType, SQLPOINTER rgbValue, SQLLEN cbValueMax, SQLLEN FAR * pcbValue) { TDS_DESC *ard; struct _drecord *drec; SQLSMALLINT orig_ard_size; ODBC_ENTER_HSTMT; tdsdump_log(TDS_DBG_FUNC, "SQLBindCol(%p, %d, %d, %p, %d, %p)\n", hstmt, icol, fCType, rgbValue, (int)cbValueMax, pcbValue); /* TODO - More error checking XXX smurph */ #ifdef TDS_NO_DM /* check conversion type */ switch (fCType) { case SQL_C_CHAR: case SQL_C_WCHAR: case SQL_C_BINARY: case SQL_C_DEFAULT: /* check max buffer length */ if (!IS_VALID_LEN(cbValueMax)) { odbc_errs_add(&stmt->errs, "HY090", NULL); ODBC_EXIT_(stmt); } break; } #endif if (icol <= 0 || icol > 4000) { odbc_errs_add(&stmt->errs, "07009", NULL); ODBC_EXIT_(stmt); } ard = stmt->ard; orig_ard_size = ard->header.sql_desc_count; if (icol > ard->header.sql_desc_count && desc_alloc_records(ard, icol) != SQL_SUCCESS) { odbc_errs_add(&stmt->errs, "HY001", NULL); ODBC_EXIT_(stmt); } drec = &ard->records[icol - 1]; if (odbc_set_concise_c_type(fCType, drec, 0) != SQL_SUCCESS) { desc_alloc_records(ard, orig_ard_size); odbc_errs_add(&stmt->errs, "HY003", NULL); ODBC_EXIT_(stmt); } drec->sql_desc_octet_length = cbValueMax; drec->sql_desc_octet_length_ptr = pcbValue; drec->sql_desc_indicator_ptr = pcbValue; drec->sql_desc_data_ptr = rgbValue; /* force rebind */ stmt->row = 0; ODBC_EXIT_(stmt); } SQLRETURN ODBC_PUBLIC ODBC_API SQLCancel(SQLHSTMT hstmt) { TDSSOCKET *tds; /* * FIXME this function can be called from other thread, do not free * errors for this function * If function is called from another thread errors are not touched */ /* TODO some tests required */ TDS_STMT *stmt = (TDS_STMT*)hstmt; if (SQL_NULL_HSTMT == hstmt || !IS_HSTMT(hstmt)) return SQL_INVALID_HANDLE; tdsdump_log(TDS_DBG_FUNC, "SQLCancel(%p)\n", hstmt); tds = stmt->tds; /* cancelling an inactive statement ?? */ if (!tds) { ODBC_SAFE_ERROR(stmt); ODBC_EXIT_(stmt); } if (tds_mutex_trylock(&stmt->mtx) == 0) { CHECK_STMT_EXTRA(stmt); odbc_errs_reset(&stmt->errs); /* FIXME test current statement */ /* FIXME here we are unlocked */ if (TDS_FAILED(tds_send_cancel(tds))) { ODBC_SAFE_ERROR(stmt); ODBC_EXIT_(stmt); } if (TDS_FAILED(tds_process_cancel(tds))) { ODBC_SAFE_ERROR(stmt); ODBC_EXIT_(stmt); } /* only if we processed cancel reset statement */ if (tds->state == TDS_IDLE) odbc_unlock_statement(stmt); ODBC_EXIT_(stmt); } /* don't access error here, just return error */ if (TDS_FAILED(tds_send_cancel(tds))) return SQL_ERROR; return SQL_SUCCESS; } ODBC_FUNC(SQLConnect, (P(SQLHDBC,hdbc), PCHARIN(DSN,SQLSMALLINT), PCHARIN(UID,SQLSMALLINT), PCHARIN(AuthStr,SQLSMALLINT) WIDE)) { TDSLOGIN *login; DSTR *s; ODBC_ENTER_HDBC; #ifdef TDS_NO_DM if (szDSN && !IS_VALID_LEN(cbDSN)) { odbc_errs_add(&dbc->errs, "HY090", "Invalid DSN buffer length"); ODBC_EXIT_(dbc); } if (szUID && !IS_VALID_LEN(cbUID)) { odbc_errs_add(&dbc->errs, "HY090", "Invalid UID buffer length"); ODBC_EXIT_(dbc); } if (szAuthStr && !IS_VALID_LEN(cbAuthStr)) { odbc_errs_add(&dbc->errs, "HY090", "Invalid PWD buffer length"); ODBC_EXIT_(dbc); } #endif login = tds_alloc_login(0); if (!login || !tds_init_login(login, dbc->env->tds_ctx->locale)) goto memory_error; /* data source name */ if (odbc_get_string_size(cbDSN, szDSN _wide)) s = odbc_dstr_copy(dbc, &dbc->dsn, cbDSN, szDSN); else s = tds_dstr_copy(&dbc->dsn, "DEFAULT"); if (!s) goto memory_error; if (!odbc_get_dsn_info(&dbc->errs, tds_dstr_cstr(&dbc->dsn), login)) { tds_free_login(login); ODBC_EXIT_(dbc); } if (!tds_dstr_isempty(&dbc->attr.current_catalog)) if (!tds_dstr_dup(&login->database, &dbc->attr.current_catalog)) goto memory_error; /* * username/password are never saved to ini file, * so you do not check in ini file */ /* user id */ if (odbc_get_string_size(cbUID, szUID _wide)) { if (!odbc_dstr_copy(dbc, &login->user_name, cbUID, szUID)) goto memory_error; } /* password */ if (szAuthStr && !tds_dstr_isempty(&login->user_name)) { if (!odbc_dstr_copy(dbc, &login->password, cbAuthStr, szAuthStr)) goto memory_error; } /* DO IT */ odbc_connect(dbc, login); tds_free_login(login); ODBC_EXIT_(dbc); memory_error: tds_free_login(login); odbc_errs_add(&dbc->errs, "HY001", NULL); ODBC_EXIT_(dbc); } ODBC_FUNC(SQLDescribeCol, (P(SQLHSTMT,hstmt), P(SQLUSMALLINT,icol), PCHAROUT(ColName,SQLSMALLINT), P(SQLSMALLINT FAR *,pfSqlType), P(SQLULEN FAR *,pcbColDef), P(SQLSMALLINT FAR *,pibScale), P(SQLSMALLINT FAR *,pfNullable) WIDE)) { TDS_DESC *ird; struct _drecord *drec; SQLRETURN result; ODBC_ENTER_HSTMT; ird = stmt->ird; IRD_UPDATE(ird, &stmt->errs, ODBC_EXIT(stmt, SQL_ERROR)); if (icol <= 0 || icol > ird->header.sql_desc_count) { odbc_errs_add(&stmt->errs, "07009", "Column out of range"); ODBC_EXIT_(stmt); } /* check name length */ if (cbColNameMax < 0) { odbc_errs_add(&stmt->errs, "HY090", NULL); ODBC_EXIT_(stmt); } drec = &ird->records[icol - 1]; /* cbColNameMax can be 0 (to retrieve name length) */ if (szColName == NULL) cbColNameMax = 0; /* straight copy column name up to cbColNameMax */ result = odbc_set_string(stmt->dbc, szColName, cbColNameMax, pcbColName, tds_dstr_cstr(&drec->sql_desc_label), -1); if (szColName && result == SQL_SUCCESS_WITH_INFO) odbc_errs_add(&stmt->errs, "01004", NULL); if (pfSqlType) { /* TODO sure ? check documentation for date and intervals */ *pfSqlType = drec->sql_desc_concise_type; } if (pcbColDef) { if (drec->sql_desc_type == SQL_NUMERIC || drec->sql_desc_type == SQL_DECIMAL) { *pcbColDef = drec->sql_desc_precision; } else { *pcbColDef = drec->sql_desc_length; } } if (pibScale) { *pibScale = drec->sql_desc_scale; } if (pfNullable) { *pfNullable = drec->sql_desc_nullable; } ODBC_EXIT_(stmt); } static SQLRETURN _SQLColAttribute(SQLHSTMT hstmt, SQLUSMALLINT icol, SQLUSMALLINT fDescType, SQLPOINTER rgbDesc, SQLSMALLINT cbDescMax, SQLSMALLINT FAR * pcbDesc, SQLLEN FAR * pfDesc _WIDE) { TDS_DESC *ird; struct _drecord *drec; SQLRETURN result = SQL_SUCCESS; ODBC_ENTER_HSTMT; tdsdump_log(TDS_DBG_FUNC, "_SQLColAttribute(%p, %u, %u, %p, %d, %p, %p)\n", hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc); ird = stmt->ird; #define COUT(src) result = odbc_set_string_oct(stmt->dbc, rgbDesc, cbDescMax, pcbDesc, src ? src : "", -1); #define SOUT(src) result = odbc_set_string_oct(stmt->dbc, rgbDesc, cbDescMax, pcbDesc, tds_dstr_cstr(&src), -1); /* SQLColAttribute returns always attributes using SQLINTEGER */ #if ENABLE_EXTRA_CHECKS #define IOUT(type, src) do { \ /* trick warning if type wrong */ \ type *p_test = &src; p_test = p_test; \ *pfDesc = src; } while(0) #else #define IOUT(type, src) *pfDesc = src #endif IRD_UPDATE(ird, &stmt->errs, ODBC_EXIT(stmt, SQL_ERROR)); /* dont check column index for these */ switch (fDescType) { #if SQL_COLUMN_COUNT != SQL_DESC_COUNT case SQL_COLUMN_COUNT: #endif case SQL_DESC_COUNT: IOUT(SQLSMALLINT, ird->header.sql_desc_count); ODBC_EXIT(stmt, SQL_SUCCESS); break; } if (!ird->header.sql_desc_count) { odbc_errs_add(&stmt->errs, "07005", NULL); ODBC_EXIT_(stmt); } if (icol <= 0 || icol > ird->header.sql_desc_count) { odbc_errs_add(&stmt->errs, "07009", "Column out of range"); ODBC_EXIT_(stmt); } drec = &ird->records[icol - 1]; tdsdump_log(TDS_DBG_INFO1, "SQLColAttribute: fDescType is %d\n", fDescType); switch (fDescType) { case SQL_DESC_AUTO_UNIQUE_VALUE: IOUT(SQLUINTEGER, drec->sql_desc_auto_unique_value); break; case SQL_DESC_BASE_COLUMN_NAME: SOUT(drec->sql_desc_base_column_name); break; case SQL_DESC_BASE_TABLE_NAME: SOUT(drec->sql_desc_base_table_name); break; case SQL_DESC_CASE_SENSITIVE: IOUT(SQLINTEGER, drec->sql_desc_case_sensitive); break; case SQL_DESC_CATALOG_NAME: SOUT(drec->sql_desc_catalog_name); break; #if SQL_COLUMN_TYPE != SQL_DESC_CONCISE_TYPE case SQL_COLUMN_TYPE: #endif case SQL_DESC_CONCISE_TYPE: /* special case, get ODBC 2 type, not ODBC 3 SQL_DESC_CONCISE_TYPE (different for datetime) */ if (stmt->dbc->env->attr.odbc_version == SQL_OV_ODBC3) { IOUT(SQLSMALLINT, drec->sql_desc_concise_type); break; } /* get type and convert it to ODBC 2 type */ { SQLSMALLINT type = drec->sql_desc_concise_type; switch (type) { case SQL_TYPE_DATE: type = SQL_DATE; break; case SQL_TYPE_TIME: type = SQL_TIME; break; case SQL_TYPE_TIMESTAMP: type = SQL_TIMESTAMP; break; } IOUT(SQLSMALLINT, type); } break; case SQL_DESC_DISPLAY_SIZE: IOUT(SQLLEN, drec->sql_desc_display_size); break; case SQL_DESC_FIXED_PREC_SCALE: IOUT(SQLSMALLINT, drec->sql_desc_fixed_prec_scale); break; case SQL_DESC_LABEL: SOUT(drec->sql_desc_label); break; /* FIXME special cases for SQL_COLUMN_LENGTH */ case SQL_COLUMN_LENGTH: IOUT(SQLLEN, drec->sql_desc_octet_length); break; case SQL_DESC_LENGTH: IOUT(SQLULEN, drec->sql_desc_length); break; case SQL_DESC_LITERAL_PREFIX: COUT(drec->sql_desc_literal_prefix); break; case SQL_DESC_LITERAL_SUFFIX: COUT(drec->sql_desc_literal_suffix); break; case SQL_DESC_LOCAL_TYPE_NAME: SOUT(drec->sql_desc_local_type_name); break; #if SQL_COLUMN_NAME != SQL_DESC_NAME case SQL_COLUMN_NAME: #endif case SQL_DESC_NAME: SOUT(drec->sql_desc_name); break; #if SQL_COLUMN_NULLABLE != SQL_DESC_NULLABLE case SQL_COLUMN_NULLABLE: #endif case SQL_DESC_NULLABLE: IOUT(SQLSMALLINT, drec->sql_desc_nullable); break; case SQL_DESC_NUM_PREC_RADIX: IOUT(SQLINTEGER, drec->sql_desc_num_prec_radix); break; case SQL_DESC_OCTET_LENGTH: IOUT(SQLLEN, drec->sql_desc_octet_length); break; /* FIXME special cases for SQL_COLUMN_PRECISION */ case SQL_COLUMN_PRECISION: if (drec->sql_desc_concise_type == SQL_REAL) { *pfDesc = 7; break; } if (drec->sql_desc_concise_type == SQL_DOUBLE) { *pfDesc = 15; break; } if (drec->sql_desc_concise_type == SQL_TYPE_TIMESTAMP || drec->sql_desc_concise_type == SQL_TIMESTAMP) { *pfDesc = drec->sql_desc_precision ? 23 : 16; break; } case SQL_DESC_PRECISION: /* this section may be wrong */ if (drec->sql_desc_concise_type == SQL_NUMERIC || drec->sql_desc_concise_type == SQL_DECIMAL || drec->sql_desc_concise_type == SQL_TYPE_TIMESTAMP || drec->sql_desc_concise_type == SQL_TYPE_DATE || drec->sql_desc_concise_type == SQL_TIMESTAMP || drec->sql_desc_concise_type == SQL_SS_TIME2 || drec->sql_desc_concise_type == SQL_SS_TIMESTAMPOFFSET) IOUT(SQLSMALLINT, drec->sql_desc_precision); else *pfDesc = drec->sql_desc_length; break; /* FIXME special cases for SQL_COLUMN_SCALE */ case SQL_COLUMN_SCALE: case SQL_DESC_SCALE: /* this section may be wrong */ if (drec->sql_desc_concise_type == SQL_NUMERIC || drec->sql_desc_concise_type == SQL_DECIMAL || drec->sql_desc_concise_type == SQL_TYPE_TIMESTAMP || drec->sql_desc_concise_type == SQL_TYPE_DATE || drec->sql_desc_concise_type == SQL_TIMESTAMP || drec->sql_desc_concise_type == SQL_FLOAT || drec->sql_desc_concise_type == SQL_SS_TIME2 || drec->sql_desc_concise_type == SQL_SS_TIMESTAMPOFFSET) IOUT(SQLSMALLINT, drec->sql_desc_scale); else *pfDesc = 0; break; case SQL_DESC_SCHEMA_NAME: SOUT(drec->sql_desc_schema_name); break; case SQL_DESC_SEARCHABLE: IOUT(SQLSMALLINT, drec->sql_desc_searchable); break; case SQL_DESC_TABLE_NAME: SOUT(drec->sql_desc_table_name); break; case SQL_DESC_TYPE: IOUT(SQLSMALLINT, drec->sql_desc_type); break; case SQL_DESC_TYPE_NAME: COUT(drec->sql_desc_type_name); break; case SQL_DESC_UNNAMED: IOUT(SQLSMALLINT, drec->sql_desc_unnamed); break; case SQL_DESC_UNSIGNED: IOUT(SQLSMALLINT, drec->sql_desc_unsigned); break; case SQL_DESC_UPDATABLE: IOUT(SQLSMALLINT, drec->sql_desc_updatable); break; default: tdsdump_log(TDS_DBG_INFO2, "SQLColAttribute: fDescType %d not catered for...\n", fDescType); odbc_errs_add(&stmt->errs, "HY091", NULL); ODBC_EXIT_(stmt); break; } if (result == SQL_SUCCESS_WITH_INFO) odbc_errs_add(&stmt->errs, "01004", NULL); ODBC_EXIT(stmt, result); #undef COUT #undef SOUT #undef IOUT } SQLRETURN ODBC_PUBLIC ODBC_API SQLColAttributes(SQLHSTMT hstmt, SQLUSMALLINT icol, SQLUSMALLINT fDescType, SQLPOINTER rgbDesc, SQLSMALLINT cbDescMax, SQLSMALLINT FAR * pcbDesc, SQLLEN FAR * pfDesc) { tdsdump_log(TDS_DBG_FUNC, "SQLColAttributes(%p, %d, %d, %p, %d, %p, %p)\n", hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc); return _SQLColAttribute(hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc _wide0); } #if (ODBCVER >= 0x0300) SQLRETURN ODBC_PUBLIC ODBC_API SQLColAttribute(SQLHSTMT hstmt, SQLUSMALLINT icol, SQLUSMALLINT fDescType, SQLPOINTER rgbDesc, SQLSMALLINT cbDescMax, SQLSMALLINT FAR * pcbDesc, #ifdef TDS_SQLCOLATTRIBUTE_SQLLEN SQLLEN FAR * pfDesc #else SQLPOINTER pfDesc #endif ) { return _SQLColAttribute(hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc _wide0); } #ifdef ENABLE_ODBC_WIDE SQLRETURN ODBC_PUBLIC ODBC_API SQLColAttributeW(SQLHSTMT hstmt, SQLUSMALLINT icol, SQLUSMALLINT fDescType, SQLPOINTER rgbDesc, SQLSMALLINT cbDescMax, SQLSMALLINT FAR * pcbDesc, #ifdef TDS_SQLCOLATTRIBUTE_SQLLEN SQLLEN FAR * pfDesc #else SQLPOINTER pfDesc #endif ) { tdsdump_log(TDS_DBG_FUNC, "SQLColAttributeW(%p, %u, %u, %p, %d, %p, %p)\n", hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc); return _SQLColAttribute(hstmt, icol, fDescType, rgbDesc, cbDescMax, pcbDesc, pfDesc, 1); } #endif #endif SQLRETURN ODBC_PUBLIC ODBC_API SQLDisconnect(SQLHDBC hdbc) { int i; ODBC_ENTER_HDBC; tdsdump_log(TDS_DBG_FUNC, "SQLDisconnect(%p)\n", hdbc); /* free all associated statements */ while (dbc->stmt_list) { tds_mutex_unlock(&dbc->mtx); _SQLFreeStmt(dbc->stmt_list, SQL_DROP, 1); tds_mutex_lock(&dbc->mtx); } /* free all associated descriptors */ for (i = 0; i < TDS_MAX_APP_DESC; ++i) { if (dbc->uad[i]) { desc_free(dbc->uad[i]); dbc->uad[i] = NULL; } } #ifdef ENABLE_ODBC_WIDE dbc->mb_conv = NULL; #endif tds_close_socket(dbc->tds_socket); tds_free_socket(dbc->tds_socket); dbc->tds_socket = NULL; dbc->cursor_support = 0; ODBC_EXIT_(dbc); } static int odbc_errmsg_handler(const TDSCONTEXT * ctx, TDSSOCKET * tds, TDSMESSAGE * msg) { struct _sql_errors *errs = NULL; TDS_DBC *dbc = NULL; TDS_STMT *stmt = NULL; tdsdump_log(TDS_DBG_INFO1, "msgno %d %d\n", (int) msg->msgno, TDSETIME); if (msg->msgno == TDSETIME) { tdsdump_log(TDS_DBG_INFO1, "in timeout\n"); if (!tds) return TDS_INT_CANCEL; if ((stmt = odbc_get_stmt(tds)) != NULL) { /* first time, try to send a cancel */ if (!tds->in_cancel) { odbc_errs_add(&stmt->errs, "HYT00", "Timeout expired"); tdsdump_log(TDS_DBG_INFO1, "returning from timeout\n"); return TDS_INT_TIMEOUT; } } else if ((dbc = odbc_get_dbc(tds)) != NULL) { odbc_errs_add(&dbc->errs, "HYT00", "Timeout expired"); } tds_close_socket(tds); tdsdump_log(TDS_DBG_INFO1, "returning cancel from timeout\n"); return TDS_INT_CANCEL; } if (tds && (dbc = odbc_get_dbc(tds)) != NULL) { errs = &dbc->errs; stmt = odbc_get_stmt(tds); if (stmt) errs = &stmt->errs; } else if (ctx->parent) { errs = &((TDS_ENV *) ctx->parent)->errs; } if (errs) { int severity = msg->severity; const char * state = msg->sql_state; /* fix severity for Sybase */ if (severity <= 10 && dbc && !TDS_IS_MSSQL(dbc->tds_socket) && msg->sql_state && msg->sql_state[0] && strncmp(msg->sql_state, "00", 2) != 0) { if (strncmp(msg->sql_state, "01", 2) != 0 && strncmp(msg->sql_state, "IM", 2) != 0) severity = 11; } /* compute state if not available */ if (!state) state = severity <= 10 ? "01000" : "42000"; /* add error, do not overwrite connection timeout error */ if (msg->msgno != TDSEFCON || errs->lastrc != SQL_ERROR || errs->num_errors < 1) odbc_errs_add_rdbms(errs, msg->msgno, state, msg->message, msg->line_number, msg->severity, msg->server, stmt ? stmt->curr_param_row + 1 : 0); /* set lastc according */ if (severity <= 10) { if (errs->lastrc == SQL_SUCCESS) errs->lastrc = SQL_SUCCESS_WITH_INFO; } else { errs->lastrc = SQL_ERROR; } } return TDS_INT_CANCEL; } /* TODO optimize, change only if some data change (set same value should not set this flag) */ #define DESC_SET_NEED_REPREPARE \ do {\ if (desc->type == DESC_IPD) {\ assert(IS_HSTMT(desc->parent));\ ((TDS_STMT *) desc->parent)->need_reprepare = 1;\ }\ } while(0) SQLRETURN ODBC_PUBLIC ODBC_API SQLSetDescRec(SQLHDESC hdesc, SQLSMALLINT nRecordNumber, SQLSMALLINT nType, SQLSMALLINT nSubType, SQLLEN nLength, SQLSMALLINT nPrecision, SQLSMALLINT nScale, SQLPOINTER pData, SQLLEN FAR * pnStringLength, SQLLEN FAR * pnIndicator) { struct _drecord *drec; SQLSMALLINT concise_type; ODBC_ENTER_HDESC; tdsdump_log(TDS_DBG_FUNC, "SQLSetDescRec(%p, %d, %d, %d, %d, %d, %d, %p, %p, %p)\n", hdesc, nRecordNumber, nType, nSubType, (int)nLength, nPrecision, nScale, pData, pnStringLength, pnIndicator); if (desc->type == DESC_IRD) { odbc_errs_add(&desc->errs, "HY016", NULL); ODBC_EXIT_(desc); } if (nRecordNumber > desc->header.sql_desc_count || nRecordNumber <= 0) { odbc_errs_add(&desc->errs, "07009", NULL); ODBC_EXIT_(desc); } drec = &desc->records[nRecordNumber - 1]; /* check for valid types and return "HY021" if not */ if (desc->type == DESC_IPD) { DESC_SET_NEED_REPREPARE; concise_type = odbc_get_concise_sql_type(nType, nSubType); } else { concise_type = odbc_get_concise_c_type(nType, nSubType); } if (nType == SQL_INTERVAL || nType == SQL_DATETIME) { if (!concise_type) { odbc_errs_add(&desc->errs, "HY021", NULL); ODBC_EXIT_(desc); } } else { if (concise_type != nType) { odbc_errs_add(&desc->errs, "HY021", NULL); ODBC_EXIT_(desc); } nSubType = 0; } drec->sql_desc_concise_type = concise_type; drec->sql_desc_type = nType; drec->sql_desc_datetime_interval_code = nSubType; drec->sql_desc_octet_length = nLength; drec->sql_desc_precision = nPrecision; drec->sql_desc_scale = nScale; drec->sql_desc_data_ptr = pData; drec->sql_desc_octet_length_ptr = pnStringLength; drec->sql_desc_indicator_ptr = pnIndicator; ODBC_EXIT_(desc); } ODBC_FUNC(SQLGetDescRec, (P(SQLHDESC,hdesc), P(SQLSMALLINT,RecordNumber), PCHAROUT(Name,SQLSMALLINT), P(SQLSMALLINT *,Type), P(SQLSMALLINT *,SubType), P(SQLLEN FAR *,Length), P(SQLSMALLINT *,Precision), P(SQLSMALLINT *,Scale), P(SQLSMALLINT *,Nullable) WIDE)) { struct _drecord *drec = NULL; SQLRETURN rc = SQL_SUCCESS; ODBC_ENTER_HDESC; if (RecordNumber <= 0) { odbc_errs_add(&desc->errs, "07009", NULL); ODBC_EXIT_(desc); } IRD_UPDATE(desc, &desc->errs, ODBC_EXIT(desc, SQL_ERROR)); if (RecordNumber > desc->header.sql_desc_count) ODBC_EXIT(desc, SQL_NO_DATA); if (desc->type == DESC_IRD && !desc->header.sql_desc_count) { odbc_errs_add(&desc->errs, "HY007", NULL); ODBC_EXIT_(desc); } drec = &desc->records[RecordNumber - 1]; if ((rc = odbc_set_string(desc_get_dbc(desc), szName, cbNameMax, pcbName, tds_dstr_cstr(&drec->sql_desc_name), -1)) != SQL_SUCCESS) odbc_errs_add(&desc->errs, "01004", NULL); if (Type) *Type = drec->sql_desc_type; if (Length) *Length = drec->sql_desc_octet_length; if (Precision) *Precision = drec->sql_desc_precision; if (Scale) *Scale = drec->sql_desc_scale; if (SubType) *SubType = drec->sql_desc_datetime_interval_code; if (Nullable) *Nullable = drec->sql_desc_nullable; ODBC_EXIT(desc, rc); } ODBC_FUNC(SQLGetDescField, (P(SQLHDESC,hdesc), P(SQLSMALLINT,icol), P(SQLSMALLINT,fDescType), P(SQLPOINTER,Value), P(SQLINTEGER,BufferLength), P(SQLINTEGER *,StringLength) WIDE)) { struct _drecord *drec; SQLRETURN result = SQL_SUCCESS; ODBC_ENTER_HDESC; #define COUT(src) result = odbc_set_string_oct(desc_get_dbc(desc), Value, BufferLength, StringLength, src, -1); #define SOUT(src) result = odbc_set_string_oct(desc_get_dbc(desc), Value, BufferLength, StringLength, tds_dstr_cstr(&src), -1); #if ENABLE_EXTRA_CHECKS #define IOUT(type, src) do { \ /* trick warning if type wrong */ \ type *p_test = &src; p_test = p_test; \ *((type *)Value) = src; } while(0) #else #define IOUT(type, src) *((type *)Value) = src #endif /* dont check column index for these */ switch (fDescType) { case SQL_DESC_ALLOC_TYPE: IOUT(SQLSMALLINT, desc->header.sql_desc_alloc_type); ODBC_EXIT_(desc); break; case SQL_DESC_ARRAY_SIZE: IOUT(SQLULEN, desc->header.sql_desc_array_size); ODBC_EXIT_(desc); break; case SQL_DESC_ARRAY_STATUS_PTR: IOUT(SQLUSMALLINT *, desc->header.sql_desc_array_status_ptr); ODBC_EXIT_(desc); break; case SQL_DESC_BIND_OFFSET_PTR: IOUT(SQLLEN *, desc->header.sql_desc_bind_offset_ptr); ODBC_EXIT_(desc); break; case SQL_DESC_BIND_TYPE: IOUT(SQLINTEGER, desc->header.sql_desc_bind_type); ODBC_EXIT_(desc); break; case SQL_DESC_COUNT: IRD_UPDATE(desc, &desc->errs, ODBC_EXIT(desc, SQL_ERROR)); IOUT(SQLSMALLINT, desc->header.sql_desc_count); ODBC_EXIT_(desc); break; case SQL_DESC_ROWS_PROCESSED_PTR: IOUT(SQLULEN *, desc->header.sql_desc_rows_processed_ptr); ODBC_EXIT_(desc); break; } IRD_UPDATE(desc, &desc->errs, ODBC_EXIT(desc, SQL_ERROR)); if (!desc->header.sql_desc_count) { odbc_errs_add(&desc->errs, "07005", NULL); ODBC_EXIT_(desc); } if (icol < 1) { odbc_errs_add(&desc->errs, "07009", "Column out of range"); ODBC_EXIT_(desc); } if (icol > desc->header.sql_desc_count) ODBC_EXIT(desc, SQL_NO_DATA); drec = &desc->records[icol - 1]; tdsdump_log(TDS_DBG_INFO1, "SQLGetDescField: fDescType is %d\n", fDescType); switch (fDescType) { case SQL_DESC_AUTO_UNIQUE_VALUE: IOUT(SQLUINTEGER, drec->sql_desc_auto_unique_value); break; case SQL_DESC_BASE_COLUMN_NAME: SOUT(drec->sql_desc_base_column_name); break; case SQL_DESC_BASE_TABLE_NAME: SOUT(drec->sql_desc_base_table_name); break; case SQL_DESC_CASE_SENSITIVE: IOUT(SQLINTEGER, drec->sql_desc_case_sensitive); break; case SQL_DESC_CATALOG_NAME: SOUT(drec->sql_desc_catalog_name); break; case SQL_DESC_CONCISE_TYPE: IOUT(SQLSMALLINT, drec->sql_desc_concise_type); break; case SQL_DESC_DATA_PTR: IOUT(SQLPOINTER, drec->sql_desc_data_ptr); break; case SQL_DESC_DATETIME_INTERVAL_CODE: IOUT(SQLSMALLINT, drec->sql_desc_datetime_interval_code); break; case SQL_DESC_DATETIME_INTERVAL_PRECISION: IOUT(SQLINTEGER, drec->sql_desc_datetime_interval_precision); break; case SQL_DESC_DISPLAY_SIZE: IOUT(SQLLEN, drec->sql_desc_display_size); break; case SQL_DESC_FIXED_PREC_SCALE: IOUT(SQLSMALLINT, drec->sql_desc_fixed_prec_scale); break; case SQL_DESC_INDICATOR_PTR: IOUT(SQLLEN *, drec->sql_desc_indicator_ptr); break; case SQL_DESC_LABEL: SOUT(drec->sql_desc_label); break; case SQL_DESC_LENGTH: IOUT(SQLULEN, drec->sql_desc_length); break; case SQL_DESC_LITERAL_PREFIX: COUT(drec->sql_desc_literal_prefix); break; case SQL_DESC_LITERAL_SUFFIX: COUT(drec->sql_desc_literal_suffix); break; case SQL_DESC_LOCAL_TYPE_NAME: SOUT(drec->sql_desc_local_type_name); break; case SQL_DESC_NAME: SOUT(drec->sql_desc_name); break; case SQL_DESC_NULLABLE: IOUT(SQLSMALLINT, drec->sql_desc_nullable); break; case SQL_DESC_NUM_PREC_RADIX: IOUT(SQLINTEGER, drec->sql_desc_num_prec_radix); break; case SQL_DESC_OCTET_LENGTH: IOUT(SQLLEN, drec->sql_desc_octet_length); break; case SQL_DESC_OCTET_LENGTH_PTR: IOUT(SQLLEN *, drec->sql_desc_octet_length_ptr); break; case SQL_DESC_PARAMETER_TYPE: IOUT(SQLSMALLINT, drec->sql_desc_parameter_type); break; case SQL_DESC_PRECISION: if (drec->sql_desc_concise_type == SQL_NUMERIC || drec->sql_desc_concise_type == SQL_DECIMAL || drec->sql_desc_concise_type == SQL_TIMESTAMP || drec->sql_desc_concise_type == SQL_TYPE_TIMESTAMP) IOUT(SQLSMALLINT, drec->sql_desc_precision); else /* TODO support date/time */ *((SQLSMALLINT *) Value) = 0; break; #ifdef SQL_DESC_ROWVER case SQL_DESC_ROWVER: IOUT(SQLSMALLINT, drec->sql_desc_rowver); break; #endif case SQL_DESC_SCALE: if (drec->sql_desc_concise_type == SQL_NUMERIC || drec->sql_desc_concise_type == SQL_DECIMAL || drec->sql_desc_concise_type == SQL_TYPE_TIMESTAMP || drec->sql_desc_concise_type == SQL_TIMESTAMP || drec->sql_desc_concise_type == SQL_FLOAT) IOUT(SQLSMALLINT, drec->sql_desc_scale); else *((SQLSMALLINT *) Value) = 0; break; case SQL_DESC_SCHEMA_NAME: SOUT(drec->sql_desc_schema_name); break; case SQL_DESC_SEARCHABLE: IOUT(SQLSMALLINT, drec->sql_desc_searchable); break; case SQL_DESC_TABLE_NAME: SOUT(drec->sql_desc_table_name); break; case SQL_DESC_TYPE: IOUT(SQLSMALLINT, drec->sql_desc_type); break; case SQL_DESC_TYPE_NAME: COUT(drec->sql_desc_type_name); break; case SQL_DESC_UNNAMED: IOUT(SQLSMALLINT, drec->sql_desc_unnamed); break; case SQL_DESC_UNSIGNED: IOUT(SQLSMALLINT, drec->sql_desc_unsigned); break; case SQL_DESC_UPDATABLE: IOUT(SQLSMALLINT, drec->sql_desc_updatable); break; default: odbc_errs_add(&desc->errs, "HY091", NULL); ODBC_EXIT_(desc); break; } if (result == SQL_SUCCESS_WITH_INFO) odbc_errs_add(&desc->errs, "01004", NULL); ODBC_EXIT(desc, result); #undef COUT #undef SOUT #undef IOUT } ODBC_FUNC(SQLSetDescField, (P(SQLHDESC,hdesc), P(SQLSMALLINT,icol), P(SQLSMALLINT,fDescType), P(SQLPOINTER,Value), P(SQLINTEGER,BufferLength) WIDE)) { struct _drecord *drec; SQLRETURN result = SQL_SUCCESS; ODBC_ENTER_HDESC; #if ENABLE_EXTRA_CHECKS #define IIN(type, dest) do { \ /* trick warning if type wrong */ \ type *p_test = &dest; p_test = p_test; \ dest = (type)(TDS_INTPTR)Value; } while(0) #define PIN(type, dest) do { \ /* trick warning if type wrong */ \ type *p_test = &dest; p_test = p_test; \ dest = (type)Value; } while(0) #else #define IIN(type, dest) dest = (type)(TDS_INTPTR)Value #define PIN(type, dest) dest = (type)Value #endif /* special case for IRD */ if (desc->type == DESC_IRD && fDescType != SQL_DESC_ARRAY_STATUS_PTR && fDescType != SQL_DESC_ROWS_PROCESSED_PTR) { odbc_errs_add(&desc->errs, "HY016", NULL); ODBC_EXIT_(desc); } /* dont check column index for these */ switch (fDescType) { case SQL_DESC_ALLOC_TYPE: odbc_errs_add(&desc->errs, "HY091", "Descriptor type read only"); ODBC_EXIT_(desc); break; case SQL_DESC_ARRAY_SIZE: IIN(SQLULEN, desc->header.sql_desc_array_size); ODBC_EXIT_(desc); break; case SQL_DESC_ARRAY_STATUS_PTR: PIN(SQLUSMALLINT *, desc->header.sql_desc_array_status_ptr); ODBC_EXIT_(desc); break; case SQL_DESC_ROWS_PROCESSED_PTR: PIN(SQLULEN *, desc->header.sql_desc_rows_processed_ptr); ODBC_EXIT_(desc); break; case SQL_DESC_BIND_TYPE: IIN(SQLINTEGER, desc->header.sql_desc_bind_type); ODBC_EXIT_(desc); break; case SQL_DESC_COUNT: { int n = (int) (TDS_INTPTR) Value; if (n <= 0 || n > 4000) { odbc_errs_add(&desc->errs, "07009", NULL); ODBC_EXIT_(desc); } result = desc_alloc_records(desc, n); if (result == SQL_ERROR) odbc_errs_add(&desc->errs, "HY001", NULL); ODBC_EXIT(desc, result); } break; } if (!desc->header.sql_desc_count) { odbc_errs_add(&desc->errs, "07005", NULL); ODBC_EXIT_(desc); } if (icol <= 0 || icol > desc->header.sql_desc_count) { odbc_errs_add(&desc->errs, "07009", "Column out of range"); ODBC_EXIT_(desc); } drec = &desc->records[icol - 1]; tdsdump_log(TDS_DBG_INFO1, "SQLColAttributes: fDescType is %d\n", fDescType); switch (fDescType) { case SQL_DESC_AUTO_UNIQUE_VALUE: case SQL_DESC_BASE_COLUMN_NAME: case SQL_DESC_BASE_TABLE_NAME: case SQL_DESC_CASE_SENSITIVE: case SQL_DESC_CATALOG_NAME: odbc_errs_add(&desc->errs, "HY091", "Descriptor type read only"); result = SQL_ERROR; break; case SQL_DESC_CONCISE_TYPE: DESC_SET_NEED_REPREPARE; if (desc->type == DESC_IPD) result = odbc_set_concise_sql_type((SQLSMALLINT) (TDS_INTPTR) Value, drec, 0); else result = odbc_set_concise_c_type((SQLSMALLINT) (TDS_INTPTR) Value, drec, 0); if (result != SQL_SUCCESS) odbc_errs_add(&desc->errs, "HY021", NULL); break; case SQL_DESC_DATA_PTR: PIN(SQLPOINTER, drec->sql_desc_data_ptr); break; /* TODO SQL_DESC_DATETIME_INTERVAL_CODE remember to check sql_desc_type */ /* TODO SQL_DESC_DATETIME_INTERVAL_PRECISION */ case SQL_DESC_DISPLAY_SIZE: case SQL_DESC_FIXED_PREC_SCALE: odbc_errs_add(&desc->errs, "HY091", "Descriptor type read only"); result = SQL_ERROR; break; case SQL_DESC_INDICATOR_PTR: PIN(SQLLEN *, drec->sql_desc_indicator_ptr); break; case SQL_DESC_LABEL: odbc_errs_add(&desc->errs, "HY091", "Descriptor type read only"); result = SQL_ERROR; break; case SQL_DESC_LENGTH: DESC_SET_NEED_REPREPARE; IIN(SQLULEN, drec->sql_desc_length); break; case SQL_DESC_LITERAL_PREFIX: case SQL_DESC_LITERAL_SUFFIX: case SQL_DESC_LOCAL_TYPE_NAME: odbc_errs_add(&desc->errs, "HY091", "Descriptor type read only"); result = SQL_ERROR; break; case SQL_DESC_NAME: if (!odbc_dstr_copy_oct(desc_get_dbc(desc), &drec->sql_desc_name, BufferLength, (ODBC_CHAR*) Value)) { odbc_errs_add(&desc->errs, "HY001", NULL); result = SQL_ERROR; } break; case SQL_DESC_NULLABLE: odbc_errs_add(&desc->errs, "HY091", "Descriptor type read only"); result = SQL_ERROR; break; case SQL_DESC_NUM_PREC_RADIX: IIN(SQLINTEGER, drec->sql_desc_num_prec_radix); break; case SQL_DESC_OCTET_LENGTH: DESC_SET_NEED_REPREPARE; IIN(SQLLEN, drec->sql_desc_octet_length); break; case SQL_DESC_OCTET_LENGTH_PTR: PIN(SQLLEN *, drec->sql_desc_octet_length_ptr); break; case SQL_DESC_PARAMETER_TYPE: DESC_SET_NEED_REPREPARE; IIN(SQLSMALLINT, drec->sql_desc_parameter_type); break; case SQL_DESC_PRECISION: DESC_SET_NEED_REPREPARE; /* TODO correct ?? */ if (drec->sql_desc_concise_type == SQL_NUMERIC || drec->sql_desc_concise_type == SQL_DECIMAL) IIN(SQLSMALLINT, drec->sql_desc_precision); else IIN(SQLULEN, drec->sql_desc_length); break; #ifdef SQL_DESC_ROWVER case SQL_DESC_ROWVER: odbc_errs_add(&desc->errs, "HY091", "Descriptor type read only"); result = SQL_ERROR; break; #endif case SQL_DESC_SCALE: DESC_SET_NEED_REPREPARE; if (drec->sql_desc_concise_type == SQL_NUMERIC || drec->sql_desc_concise_type == SQL_DECIMAL) IIN(SQLSMALLINT, drec->sql_desc_scale); else /* TODO even for datetime/money ?? */ drec->sql_desc_scale = 0; break; case SQL_DESC_SCHEMA_NAME: case SQL_DESC_SEARCHABLE: case SQL_DESC_TABLE_NAME: odbc_errs_add(&desc->errs, "HY091", "Descriptor type read only"); result = SQL_ERROR; break; case SQL_DESC_TYPE: DESC_SET_NEED_REPREPARE; IIN(SQLSMALLINT, drec->sql_desc_type); /* FIXME what happen for interval/datetime ?? */ drec->sql_desc_concise_type = drec->sql_desc_type; break; case SQL_DESC_TYPE_NAME: odbc_errs_add(&desc->errs, "HY091", "Descriptor type read only"); result = SQL_ERROR; break; case SQL_DESC_UNNAMED: IIN(SQLSMALLINT, drec->sql_desc_unnamed); break; case SQL_DESC_UNSIGNED: case SQL_DESC_UPDATABLE: odbc_errs_add(&desc->errs, "HY091", "Descriptor type read only"); result = SQL_ERROR; break; default: odbc_errs_add(&desc->errs, "HY091", NULL); ODBC_EXIT_(desc); break; } #undef IIN ODBC_EXIT(desc, result); } SQLRETURN ODBC_PUBLIC ODBC_API SQLCopyDesc(SQLHDESC hsrc, SQLHDESC hdesc) { TDS_DESC *src; ODBC_ENTER_HDESC; tdsdump_log(TDS_DBG_FUNC, "SQLCopyDesc(%p, %p)\n", hsrc, hdesc); if (SQL_NULL_HDESC == hsrc || !IS_HDESC(hsrc)) return SQL_INVALID_HANDLE; src = (TDS_DESC *) hsrc; CHECK_DESC_EXTRA(src); /* do not write on IRD */ if (desc->type == DESC_IRD) { odbc_errs_add(&desc->errs, "HY016", NULL); ODBC_EXIT_(desc); } IRD_UPDATE(src, &src->errs, ODBC_EXIT(desc, SQL_ERROR)); ODBC_EXIT(desc, desc_copy(desc, src)); } #if ENABLE_EXTRA_CHECKS static void odbc_ird_check(TDS_STMT * stmt) { #if !ENABLE_ODBC_MARS TDS_DESC *ird = stmt->ird; TDSRESULTINFO *res_info = NULL; int cols = 0, i; if (!stmt->tds) return; if (stmt->tds->current_results) { res_info = stmt->tds->current_results; cols = res_info->num_cols; } if (stmt->cursor != NULL) return; /* check columns number */ assert(ird->header.sql_desc_count <= cols || ird->header.sql_desc_count == 0); /* check all columns */ for (i = 0; i < ird->header.sql_desc_count; ++i) { struct _drecord *drec = &ird->records[i]; TDSCOLUMN *col = res_info->columns[i]; assert(strcmp(tds_dstr_cstr(&drec->sql_desc_label), tds_dstr_cstr(&col->column_name)) == 0); } #endif } #endif static void odbc_unquote(char *buf, size_t buf_len, const char *start, const char *end) { char quote; assert(buf_len > 0); /* empty string */ if (start >= end) { buf[0] = 0; return; } /* not quoted */ if (*start != '[' && *start != '\"') { --buf_len; if (end - start < buf_len) buf_len = end - start; memcpy(buf, start, buf_len); buf[buf_len] = 0; return; } /* quoted... unquote */ quote = (*start == '[') ? ']' : *start; ++start; while (buf_len > 0 && start < end) { if (*start == quote) if (++start >= end) break; *buf++ = *start++; --buf_len; } *buf = 0; } /* FIXME check result !!! */ static SQLRETURN odbc_populate_ird(TDS_STMT * stmt) { TDS_DESC *ird = stmt->ird; struct _drecord *drec; TDSCOLUMN *col; TDSRESULTINFO *res_info; int num_cols; int i; desc_free_records(ird); if (!stmt->tds || !(res_info = stmt->tds->current_results)) return SQL_SUCCESS; if (res_info == stmt->tds->param_info) return SQL_SUCCESS; num_cols = res_info->num_cols; /* ignore hidden columns... TODO correct? */ while (num_cols > 0 && res_info->columns[num_cols - 1]->column_hidden == 1) --num_cols; if (desc_alloc_records(ird, num_cols) != SQL_SUCCESS) goto memory_error; for (i = 0; i < num_cols; i++) { drec = &ird->records[i]; col = res_info->columns[i]; drec->sql_desc_auto_unique_value = col->column_identity ? SQL_TRUE : SQL_FALSE; /* TODO SQL_FALSE ?? */ drec->sql_desc_case_sensitive = SQL_TRUE; /* * TODO how to handle when in datetime we change precision ?? * should we change display size too ?? * is formatting function correct ?? * we should not convert to string with invalid precision! */ odbc_set_sql_type_info(col, drec, stmt->dbc->env->attr.odbc_version); drec->sql_desc_fixed_prec_scale = (col->column_prec && col->column_scale) ? SQL_TRUE : SQL_FALSE; if (!tds_dstr_dup(&drec->sql_desc_label, &col->column_name)) goto memory_error; if (tds_dstr_isempty(&col->table_column_name)) { if (!tds_dstr_dup(&drec->sql_desc_name, &col->column_name)) goto memory_error; } else { if (!tds_dstr_dup(&drec->sql_desc_name, &col->table_column_name)) goto memory_error; if (!tds_dstr_dup(&drec->sql_desc_base_column_name, &col->table_column_name)) goto memory_error; } /* extract sql_desc_(catalog/schema/base_table)_name */ /* TODO extract them dinamically (when needed) ? */ /* TODO store in libTDS in different way (separately) ? */ if (!tds_dstr_isempty(&col->table_name)) { struct { const char *start; const char *end; } partials[4]; const char *p; char buf[256]; int i; p = tds_dstr_cstr(&col->table_name); for (i = 0; ; ++i) { const char *pend; if (*p == '[' || *p == '\"') { pend = tds_skip_quoted(p); } else { pend = strchr(p, '.'); if (!pend) pend = strchr(p, 0); } partials[i].start = p; partials[i].end = pend; p = pend; if (i == 3 || *p != '.') break; ++p; } /* here i points to last element */ odbc_unquote(buf, sizeof(buf), partials[i].start, partials[i].end); if (!tds_dstr_copy(&drec->sql_desc_base_table_name, buf)) goto memory_error; --i; if (i >= 0) { odbc_unquote(buf, sizeof(buf), partials[i].start, partials[i].end); if (!tds_dstr_copy(&drec->sql_desc_schema_name, buf)) goto memory_error; } --i; if (i >= 0) { odbc_unquote(buf, sizeof(buf), partials[i].start, partials[i].end); if (!tds_dstr_copy(&drec->sql_desc_catalog_name, buf)) goto memory_error; } } drec->sql_desc_unnamed = tds_dstr_isempty(&drec->sql_desc_name) ? SQL_UNNAMED : SQL_NAMED; /* TODO use is_nullable_type ?? */ drec->sql_desc_nullable = col->column_nullable ? SQL_TRUE : SQL_FALSE; drec->sql_desc_octet_length_ptr = NULL; /* TODO test timestamp from db, FOR BROWSE query */ drec->sql_desc_rowver = SQL_FALSE; /* TODO seem not correct */ drec->sql_desc_searchable = (drec->sql_desc_unnamed == SQL_NAMED) ? SQL_PRED_SEARCHABLE : SQL_UNSEARCHABLE; drec->sql_desc_updatable = col->column_writeable && !col->column_identity ? SQL_TRUE : SQL_FALSE; } return SQL_SUCCESS; memory_error: odbc_errs_add(&stmt->errs, "HY001", NULL); return SQL_ERROR; } static TDSRET odbc_cursor_execute(TDS_STMT * stmt) { TDSSOCKET *tds = stmt->tds; int send = 0, i; TDSRET ret; TDSCURSOR *cursor; TDSPARAMINFO *params = stmt->params; assert(tds); assert(stmt->attr.cursor_type != SQL_CURSOR_FORWARD_ONLY || stmt->attr.concurrency != SQL_CONCUR_READ_ONLY); tds_release_cursor(&stmt->cursor); cursor = tds_alloc_cursor(tds, tds_dstr_cstr(&stmt->cursor_name), tds_dstr_len(&stmt->cursor_name), tds_dstr_cstr(&stmt->query), tds_dstr_len(&stmt->query)); if (!cursor) { odbc_unlock_statement(stmt); odbc_errs_add(&stmt->errs, "HY001", NULL); return TDS_FAIL; } stmt->cursor = cursor; /* TODO cursor add enums for tds7 */ switch (stmt->attr.cursor_type) { default: case SQL_CURSOR_FORWARD_ONLY: i = TDS_CUR_TYPE_FORWARD; break; case SQL_CURSOR_STATIC: i = TDS_CUR_TYPE_STATIC; break; case SQL_CURSOR_KEYSET_DRIVEN: i = TDS_CUR_TYPE_KEYSET; break; case SQL_CURSOR_DYNAMIC: i = TDS_CUR_TYPE_DYNAMIC; break; } cursor->type = i; switch (stmt->attr.concurrency) { default: case SQL_CONCUR_READ_ONLY: i = TDS_CUR_CONCUR_READ_ONLY; break; case SQL_CONCUR_LOCK: i = TDS_CUR_CONCUR_SCROLL_LOCKS; break; case SQL_CONCUR_ROWVER: i = TDS_CUR_CONCUR_OPTIMISTIC; break; case SQL_CONCUR_VALUES: i = TDS_CUR_CONCUR_OPTIMISTIC_VALUES; break; } cursor->concurrency = 0x2000 | i; ret = tds_cursor_declare(tds, cursor, params, &send); if (TDS_FAILED(ret)) return ret; ret = tds_cursor_open(tds, cursor, params, &send); if (TDS_FAILED(ret)) return ret; /* TODO read results, set row count, check type and scroll returned */ ret = tds_flush_packet(tds); tds_set_state(tds, TDS_PENDING); /* set cursor name for TDS7+ */ if (TDS_SUCCEED(ret) && IS_TDS7_PLUS(tds->conn) && !tds_dstr_isempty(&stmt->cursor_name)) { ret = odbc_process_tokens(stmt, TDS_RETURN_DONE|TDS_STOPAT_ROW|TDS_STOPAT_COMPUTE); stmt->row_count = tds->rows_affected; if (ret == TDS_CMD_DONE && cursor->cursor_id != 0) { ret = tds_cursor_setname(tds, cursor); tds_set_state(tds, TDS_PENDING); } else { ret = (ret == TDS_CMD_FAIL) ? TDS_FAIL : TDS_SUCCESS; } if (!cursor->cursor_id) { tds_cursor_dealloc(tds, cursor); tds_release_cursor(&stmt->cursor); } } return ret; } static TDSHEADERS * odbc_init_headers(TDS_STMT * stmt, TDSHEADERS * head) { if (tds_dstr_isempty(&stmt->attr.qn_msgtext) || tds_dstr_isempty(&stmt->attr.qn_options)) return NULL; memset(head, 0, sizeof(*head)); head->qn_timeout = stmt->attr.qn_timeout; head->qn_msgtext = tds_dstr_cstr(&stmt->attr.qn_msgtext); head->qn_options = tds_dstr_cstr(&stmt->attr.qn_options); return head; } static SQLRETURN _SQLExecute(TDS_STMT * stmt) { TDSRET ret; TDSSOCKET *tds; TDS_INT result_type; TDS_INT done = 0; int in_row = 0; SQLUSMALLINT param_status; int found_info = 0, found_error = 0; TDS_INT8 total_rows = TDS_NO_COUNT; TDSHEADERS head; tdsdump_log(TDS_DBG_FUNC, "_SQLExecute(%p)\n", stmt); stmt->row = 0; /* check parameters are all OK */ if (stmt->params && stmt->param_num <= stmt->param_count) { /* TODO what error ?? */ ODBC_SAFE_ERROR(stmt); return SQL_ERROR; } if (!odbc_lock_statement(stmt)) return SQL_ERROR; tds = stmt->tds; tdsdump_log(TDS_DBG_FUNC, "_SQLExecute() starting with state %d\n", tds->state); if (tds->state != TDS_IDLE) { if (tds->state == TDS_DEAD) { odbc_errs_add(&stmt->errs, "08S01", NULL); } else { odbc_errs_add(&stmt->errs, "24000", NULL); } return SQL_ERROR; } stmt->curr_param_row = 0; stmt->num_param_rows = ODBC_MAX(1, stmt->apd->header.sql_desc_array_size); stmt->row_count = TDS_NO_COUNT; if (stmt->prepared_query_is_rpc) { /* TODO support stmt->apd->header.sql_desc_array_size for RPC */ /* get rpc name */ /* TODO change method */ /* TODO cursor change way of calling */ char *name = tds_dstr_buf(&stmt->query); char *end, tmp; end = name; end = (char *) odbc_skip_rpc_name(end); stmt->prepared_pos = end; tmp = *end; *end = 0; ret = tds_submit_rpc(tds, name, stmt->params, odbc_init_headers(stmt, &head)); *end = tmp; } else if (stmt->attr.cursor_type != SQL_CURSOR_FORWARD_ONLY || stmt->attr.concurrency != SQL_CONCUR_READ_ONLY) { ret = odbc_cursor_execute(stmt); } else if (!stmt->is_prepared_query) { /* not prepared query */ /* TODO cursor change way of calling */ /* SQLExecDirect */ if (stmt->num_param_rows <= 1) { if (!stmt->params) { ret = tds_submit_query_params(tds, tds_dstr_cstr(&stmt->query), NULL, odbc_init_headers(stmt, &head)); } else { ret = tds_submit_execdirect(tds, tds_dstr_cstr(&stmt->query), stmt->params, odbc_init_headers(stmt, &head)); } } else { /* pack multiple submit using language */ TDSMULTIPLE multiple; ret = tds_multiple_init(tds, &multiple, TDS_MULTIPLE_QUERY, odbc_init_headers(stmt, &head)); for (stmt->curr_param_row = 0; TDS_SUCCEED(ret); ) { /* submit a query */ ret = tds_multiple_query(tds, &multiple, tds_dstr_cstr(&stmt->query), stmt->params); if (++stmt->curr_param_row >= stmt->num_param_rows) break; /* than process others parameters */ /* TODO handle all results*/ if (start_parse_prepared_query(stmt, 1) != SQL_SUCCESS) break; } if (TDS_SUCCEED(ret)) ret = tds_multiple_done(tds, &multiple); } } else if (stmt->num_param_rows <= 1 && IS_TDS71_PLUS(tds->conn) && (!stmt->dyn || stmt->need_reprepare)) { if (stmt->dyn) { if (odbc_free_dynamic(stmt) != SQL_SUCCESS) ODBC_RETURN(stmt, SQL_ERROR); } stmt->need_reprepare = 0; ret = tds71_submit_prepexec(tds, tds_dstr_cstr(&stmt->query), NULL, &stmt->dyn, stmt->params); } else { /* TODO cursor change way of calling */ /* SQLPrepare */ TDSDYNAMIC *dyn; /* prepare dynamic query (only for first SQLExecute call) */ if (!stmt->dyn || (stmt->need_reprepare && !stmt->dyn->emulated && IS_TDS7_PLUS(tds->conn))) { /* free previous prepared statement */ if (stmt->dyn) { if (odbc_free_dynamic(stmt) != SQL_SUCCESS) ODBC_RETURN(stmt, SQL_ERROR); } stmt->need_reprepare = 0; tdsdump_log(TDS_DBG_INFO1, "Creating prepared statement\n"); /* TODO use tds_submit_prepexec (mssql2k, tds71) */ if (TDS_FAILED(tds_submit_prepare(tds, tds_dstr_cstr(&stmt->query), NULL, &stmt->dyn, stmt->params))) { /* TODO ?? tds_free_param_results(params); */ ODBC_SAFE_ERROR(stmt); return SQL_ERROR; } if (TDS_FAILED(tds_process_simple_query(tds))) { tds_release_dynamic(&stmt->dyn); /* TODO ?? tds_free_param_results(params); */ ODBC_SAFE_ERROR(stmt); return SQL_ERROR; } } stmt->row_count = TDS_NO_COUNT; if (stmt->num_param_rows <= 1) { dyn = stmt->dyn; tds_free_input_params(dyn); dyn->params = stmt->params; /* prevent double free */ stmt->params = NULL; tdsdump_log(TDS_DBG_INFO1, "End prepare, execute\n"); /* TODO return error to client */ ret = tds_submit_execute(tds, dyn); } else { TDSMULTIPLE multiple; ret = tds_multiple_init(tds, &multiple, TDS_MULTIPLE_EXECUTE, NULL); for (stmt->curr_param_row = 0; TDS_SUCCEED(ret); ) { dyn = stmt->dyn; tds_free_input_params(dyn); dyn->params = stmt->params; /* prevent double free */ stmt->params = NULL; ret = tds_multiple_execute(tds, &multiple, dyn); if (++stmt->curr_param_row >= stmt->num_param_rows) break; /* than process others parameters */ /* TODO handle all results*/ if (start_parse_prepared_query(stmt, 1) != SQL_SUCCESS) break; } if (TDS_SUCCEED(ret)) ret = tds_multiple_done(tds, &multiple); } } if (TDS_FAILED(ret)) { ODBC_SAFE_ERROR(stmt); return SQL_ERROR; } /* catch all errors */ if (!odbc_lock_statement(stmt)) ODBC_RETURN_(stmt); stmt->row_status = PRE_NORMAL_ROW; stmt->curr_param_row = 0; param_status = SQL_PARAM_SUCCESS; /* TODO review this, ODBC return parameter in other way, for compute I don't know */ /* TODO perhaps we should return SQL_NO_DATA if no data available... see old SQLExecute code */ for (;;) { result_type = odbc_process_tokens(stmt, TDS_TOKEN_RESULTS); tdsdump_log(TDS_DBG_FUNC, "_SQLExecute: odbc_process_tokens returned result_type %d\n", result_type); switch (result_type) { case TDS_CMD_FAIL: case TDS_CMD_DONE: case TDS_COMPUTE_RESULT: case TDS_ROW_RESULT: done = 1; break; case TDS_DONE_RESULT: case TDS_DONEPROC_RESULT: switch (stmt->errs.lastrc) { case SQL_ERROR: found_error = 1; param_status = SQL_PARAM_ERROR; break; case SQL_SUCCESS_WITH_INFO: found_info = 1; param_status = SQL_PARAM_SUCCESS_WITH_INFO; break; } if (stmt->curr_param_row < stmt->num_param_rows && stmt->ipd->header.sql_desc_array_status_ptr) stmt->ipd->header.sql_desc_array_status_ptr[stmt->curr_param_row] = param_status; param_status = SQL_PARAM_SUCCESS; ++stmt->curr_param_row; /* actually is quite strange, if prepared always success with info or success * if not prepared return last one */ if (stmt->curr_param_row < stmt->num_param_rows || result_type == TDS_DONEPROC_RESULT) stmt->errs.lastrc = SQL_SUCCESS; if (total_rows == TDS_NO_COUNT) total_rows = stmt->row_count; else if (stmt->row_count != TDS_NO_COUNT) total_rows += stmt->row_count; stmt->row_count = TDS_NO_COUNT; if (stmt->curr_param_row >= stmt->num_param_rows) { done = 1; break; } break; case TDS_DONEINPROC_RESULT: if (in_row) done = 1; break; /* ignore metadata, stop at done or row */ case TDS_ROWFMT_RESULT: if (in_row) { done = 1; break; } stmt->row = 0; stmt->row_count = TDS_NO_COUNT; stmt->row_status = PRE_NORMAL_ROW; in_row = 1; break; } if (done) break; } if ((found_info || found_error) && stmt->errs.lastrc != SQL_ERROR) stmt->errs.lastrc = SQL_SUCCESS_WITH_INFO; if (tds_dstr_isempty(&stmt->attr.qn_msgtext) != tds_dstr_isempty(&stmt->attr.qn_options)) { odbc_errs_add(&stmt->errs, "HY000", "Attribute ignored"); stmt->errs.lastrc = SQL_SUCCESS_WITH_INFO; } if (found_error && stmt->num_param_rows <= 1) stmt->errs.lastrc = SQL_ERROR; if (stmt->curr_param_row < stmt->num_param_rows) { if (stmt->ipd->header.sql_desc_array_status_ptr) stmt->ipd->header.sql_desc_array_status_ptr[stmt->curr_param_row] = param_status; ++stmt->curr_param_row; if (total_rows == TDS_NO_COUNT) total_rows = stmt->row_count; else if (stmt->row_count != TDS_NO_COUNT) total_rows += stmt->row_count; stmt->row_count = TDS_NO_COUNT; } if (stmt->ipd->header.sql_desc_rows_processed_ptr) *stmt->ipd->header.sql_desc_rows_processed_ptr = ODBC_MIN(stmt->curr_param_row, stmt->num_param_rows); if (total_rows != TDS_NO_COUNT) stmt->row_count = total_rows; odbc_populate_ird(stmt); switch (result_type) { case TDS_CMD_DONE: odbc_unlock_statement(stmt); if (stmt->errs.lastrc == SQL_SUCCESS && stmt->dbc->env->attr.odbc_version == SQL_OV_ODBC3 && stmt->row_count == TDS_NO_COUNT && !stmt->cursor) ODBC_RETURN(stmt, SQL_NO_DATA); break; case TDS_CMD_FAIL: /* TODO test what happened, report correct error to client */ tdsdump_log(TDS_DBG_INFO1, "SQLExecute: bad results\n"); ODBC_SAFE_ERROR(stmt); return SQL_ERROR; } ODBC_RETURN_(stmt); } ODBC_FUNC(SQLExecDirect, (P(SQLHSTMT,hstmt), PCHARIN(SqlStr,SQLINTEGER) WIDE)) { SQLRETURN res; ODBC_ENTER_HSTMT; if (SQL_SUCCESS != odbc_set_stmt_query(stmt, szSqlStr, cbSqlStr _wide)) { odbc_errs_add(&stmt->errs, "HY001", NULL); ODBC_EXIT_(stmt); } /* count placeholders */ /* note: szSqlStr can be no-null terminated, so first we set query and then count placeholders */ stmt->param_count = tds_count_placeholders(tds_dstr_cstr(&stmt->query)); stmt->param_data_called = 0; if (SQL_SUCCESS != prepare_call(stmt)) { /* TODO return another better error, prepare_call should set error ?? */ odbc_errs_add(&stmt->errs, "HY000", "Could not prepare call"); ODBC_EXIT_(stmt); } res = start_parse_prepared_query(stmt, 1); if (SQL_SUCCESS != res) ODBC_EXIT(stmt, res); ODBC_EXIT(stmt, _SQLExecute(stmt)); } SQLRETURN ODBC_PUBLIC ODBC_API SQLExecute(SQLHSTMT hstmt) { ODBC_PRRET_BUF; SQLRETURN res; ODBC_ENTER_HSTMT; tdsdump_log(TDS_DBG_FUNC, "SQLExecute(%p)\n", hstmt); if (!stmt->is_prepared_query) { /* TODO error report, only without DM ?? */ tdsdump_log(TDS_DBG_FUNC, "SQLExecute returns SQL_ERROR (not prepared)\n"); ODBC_EXIT(stmt, SQL_ERROR); } /* TODO rebuild should be done for every bindings change, not every time */ /* TODO free previous parameters */ /* build parameters list */ stmt->param_data_called = 0; stmt->curr_param_row = 0; if ((res = start_parse_prepared_query(stmt, 1)) != SQL_SUCCESS) { tdsdump_log(TDS_DBG_FUNC, "SQLExecute returns %s (start_parse_prepared_query failed)\n", odbc_prret(res)); ODBC_EXIT(stmt, res); } /* TODO test if two SQLPrepare on a statement */ /* TODO test unprepare on statement free or connection close */ res = _SQLExecute(stmt); tdsdump_log(TDS_DBG_FUNC, "SQLExecute returns %s\n", odbc_prret(res)); ODBC_EXIT(stmt, res); } static int odbc_process_tokens(TDS_STMT * stmt, unsigned flag) { TDS_INT result_type; int done_flags; TDSSOCKET * tds = stmt->tds; flag |= TDS_RETURN_DONE | TDS_RETURN_PROC; for (;;) { TDSRET retcode = tds_process_tokens(tds, &result_type, &done_flags, flag); tdsdump_log(TDS_DBG_FUNC, "odbc_process_tokens: tds_process_tokens returned %d\n", retcode); tdsdump_log(TDS_DBG_FUNC, " result_type=%d, TDS_DONE_COUNT=%x, TDS_DONE_ERROR=%x\n", result_type, (done_flags & TDS_DONE_COUNT), (done_flags & TDS_DONE_ERROR)); switch (retcode) { case TDS_SUCCESS: break; case TDS_NO_MORE_RESULTS: return TDS_CMD_DONE; case TDS_CANCELLED: odbc_errs_add(&stmt->errs, "HY008", NULL); default: return TDS_CMD_FAIL; } switch (result_type) { case TDS_STATUS_RESULT: odbc_set_return_status(stmt, ODBC_MIN(stmt->curr_param_row, stmt->num_param_rows - 1)); break; case TDS_PARAM_RESULT: odbc_set_return_params(stmt, ODBC_MIN(stmt->curr_param_row, stmt->num_param_rows - 1)); break; case TDS_DONE_RESULT: case TDS_DONEPROC_RESULT: if (stmt->dbc->env->attr.odbc_version == SQL_OV_ODBC3) flag |= TDS_STOPAT_MSG; if (done_flags & TDS_DONE_COUNT) { /* correct ?? overwrite ?? */ if (stmt->row_count == TDS_NO_COUNT) stmt->row_count = tds->rows_affected; } if (done_flags & TDS_DONE_ERROR) stmt->errs.lastrc = SQL_ERROR; /* test for internal_sp not very fine, used for param set -- freddy77 */ if ((done_flags & (TDS_DONE_COUNT|TDS_DONE_ERROR)) != 0 || (stmt->errs.lastrc == SQL_SUCCESS_WITH_INFO && stmt->dbc->env->attr.odbc_version == SQL_OV_ODBC3) || (result_type == TDS_DONEPROC_RESULT && tds->current_op == TDS_OP_EXECUTE)) { /* FIXME this row is used only as a flag for update binding, should be cleared if binding/result changed */ stmt->row = 0; #if 0 tds_free_all_results(tds); odbc_populate_ird(stmt); #endif tdsdump_log(TDS_DBG_FUNC, "odbc_process_tokens: row_count=%" PRId64 "\n", stmt->row_count); return result_type; } tdsdump_log(TDS_DBG_FUNC, "odbc_process_tokens: processed %s\n", result_type==TDS_DONE_RESULT? "TDS_DONE_RESULT" : "TDS_DONEPROC_RESULT"); break; /* * TODO test flags ? check error and change result ? * see also other DONEINPROC handle (below) */ case TDS_DONEINPROC_RESULT: if (stmt->dbc->env->attr.odbc_version == SQL_OV_ODBC3) flag |= TDS_STOPAT_MSG; if (done_flags & TDS_DONE_COUNT) { stmt->row_count = tds->rows_affected; } if (done_flags & TDS_DONE_ERROR) stmt->errs.lastrc = SQL_ERROR; /* TODO perhaps it can be a problem if SET NOCOUNT ON, test it */ #if 0 tds_free_all_results(tds); odbc_populate_ird(stmt); #endif tdsdump_log(TDS_DBG_FUNC, "odbc_process_tokens: processed TDS_DONEINPROC_RESULT\n"); if (stmt->row_status == PRE_NORMAL_ROW) return result_type; break; default: tdsdump_log(TDS_DBG_FUNC, "odbc_process_tokens: returning result_type %d\n", result_type); return result_type; } } } static void odbc_fix_data_type_col(TDS_STMT *stmt, int idx) { TDSSOCKET *tds = stmt->tds; TDSRESULTINFO *resinfo; TDSCOLUMN *colinfo; if (!tds) return; resinfo = tds->current_results; if (!resinfo || resinfo->num_cols <= idx) return; colinfo = resinfo->columns[idx]; if (colinfo->column_cur_size < 0) return; switch (tds_get_conversion_type(colinfo->column_type, colinfo->column_size)) { case SYBINT2: { TDS_SMALLINT *data = (TDS_SMALLINT *) colinfo->column_data; *data = odbc_swap_datetime_sql_type(*data, 0); } break; case SYBINT4: { TDS_INT *data = (TDS_INT *) colinfo->column_data; *data = odbc_swap_datetime_sql_type(*data, 0); } break; } } /* * - handle correctly SQLGetData (for forward cursors accept only row_size == 1 * for other types application must use SQLSetPos) * - handle correctly results (SQL_SUCCESS_WITH_INFO if error on some rows, * SQL_ERROR for all rows, see doc) */ static SQLRETURN _SQLFetch(TDS_STMT * stmt, SQLSMALLINT FetchOrientation, SQLLEN FetchOffset) { TDSSOCKET *tds; TDSRESULTINFO *resinfo; TDSCOLUMN *colinfo; int i; SQLULEN curr_row, num_rows; SQLINTEGER len = 0; TDS_CHAR *src; int srclen; struct _drecord *drec_ard; TDS_DESC *ard; SQLULEN dummy, *fetched_ptr; SQLUSMALLINT *status_ptr, row_status; TDS_INT result_type; int truncated = 0; #define AT_ROW(ptr, type) (row_offset ? (type*)(((char*)(ptr)) + row_offset) : &ptr[curr_row]) SQLLEN row_offset = 0; tdsdump_log(TDS_DBG_FUNC, "_SQLFetch(%p, %d, %d)\n", stmt, (int)FetchOrientation, (int)FetchOffset); if (stmt->ard->header.sql_desc_bind_type != SQL_BIND_BY_COLUMN && stmt->ard->header.sql_desc_bind_offset_ptr) row_offset = *stmt->ard->header.sql_desc_bind_offset_ptr; ard = stmt->ard; tds = stmt->tds; num_rows = ard->header.sql_desc_array_size; /* TODO cursor check also type of cursor (scrollable, not forward) */ if (FetchOrientation != SQL_FETCH_NEXT && (!stmt->cursor || !stmt->dbc->cursor_support)) { odbc_errs_add(&stmt->errs, "HY106", NULL); return SQL_ERROR; } /* handle cursors, fetch wanted rows */ if (stmt->cursor && odbc_lock_statement(stmt)) { TDSCURSOR *cursor = stmt->cursor; TDS_CURSOR_FETCH fetch_type = TDS_CURSOR_FETCH_NEXT; tds = stmt->tds; switch (FetchOrientation) { case SQL_FETCH_NEXT: break; case SQL_FETCH_FIRST: fetch_type = TDS_CURSOR_FETCH_FIRST; break; case SQL_FETCH_LAST: fetch_type = TDS_CURSOR_FETCH_LAST; break; case SQL_FETCH_PRIOR: fetch_type = TDS_CURSOR_FETCH_PREV; break; case SQL_FETCH_ABSOLUTE: fetch_type = TDS_CURSOR_FETCH_ABSOLUTE; break; case SQL_FETCH_RELATIVE: fetch_type = TDS_CURSOR_FETCH_RELATIVE; break; /* TODO cursor bookmark */ default: odbc_errs_add(&stmt->errs, "HYC00", NULL); return SQL_ERROR; } if (cursor->cursor_rows != num_rows) { int send = 0; cursor->cursor_rows = num_rows; /* TODO handle change rows (tds5) */ /* * TODO curerntly we support cursors only using tds7+ * so this function can't fail but remember to add error * check when tds5 will be supported */ tds_cursor_setrows(tds, cursor, &send); } if (TDS_FAILED(tds_cursor_fetch(tds, cursor, fetch_type, FetchOffset))) { /* TODO what kind of error ?? */ ODBC_SAFE_ERROR(stmt); return SQL_ERROR; } /* TODO handle errors in a better way */ odbc_process_tokens(stmt, TDS_RETURN_ROW|TDS_STOPAT_COMPUTE|TDS_STOPAT_ROW); stmt->row_status = PRE_NORMAL_ROW; } if (!tds || stmt->row_status == NOT_IN_ROW) { odbc_errs_add(&stmt->errs, "24000", NULL); return SQL_ERROR; } IRD_CHECK; if (stmt->ird->header.sql_desc_count <= 0) { odbc_errs_add(&stmt->errs, "24000", NULL); return SQL_ERROR; } stmt->row++; fetched_ptr = &dummy; if (stmt->ird->header.sql_desc_rows_processed_ptr) fetched_ptr = stmt->ird->header.sql_desc_rows_processed_ptr; *fetched_ptr = 0; status_ptr = stmt->ird->header.sql_desc_array_status_ptr; if (status_ptr) { for (i = 0; i < num_rows; ++i) *status_ptr++ = SQL_ROW_NOROW; status_ptr = stmt->ird->header.sql_desc_array_status_ptr; } curr_row = 0; do { row_status = SQL_ROW_SUCCESS; /* do not get compute row if we are not expecting a compute row */ switch (stmt->row_status) { case AFTER_COMPUTE_ROW: /* handle done if needed */ /* FIXME doesn't seem so fine ... - freddy77 */ tds_process_tokens(tds, &result_type, NULL, TDS_TOKEN_TRAILING); goto all_done; case IN_COMPUTE_ROW: /* compute recorset contains only a row */ /* we already fetched compute row in SQLMoreResults so do not fetch another one */ num_rows = 1; stmt->row_status = AFTER_COMPUTE_ROW; break; default: /* FIXME stmt->row_count set correctly ?? TDS_DONE_COUNT not checked */ switch (odbc_process_tokens(stmt, TDS_STOPAT_ROWFMT|TDS_RETURN_ROW|TDS_STOPAT_COMPUTE)) { case TDS_ROW_RESULT: break; default: #if 0 stmt->row_count = tds->rows_affected; #endif /* * NOTE do not set row_status to NOT_IN_ROW, * if compute tds_process_tokens above returns TDS_NO_MORE_RESULTS */ stmt->row_status = PRE_NORMAL_ROW; stmt->special_row = ODBC_SPECIAL_NONE; #if 0 odbc_populate_ird(stmt); #endif tdsdump_log(TDS_DBG_INFO1, "SQLFetch: NO_DATA_FOUND\n"); goto all_done; break; case TDS_CMD_FAIL: ODBC_SAFE_ERROR(stmt); return SQL_ERROR; break; } stmt->row_status = IN_NORMAL_ROW; /* handle special row */ switch (stmt->special_row) { case ODBC_SPECIAL_GETTYPEINFO: odbc_fix_data_type_col(stmt, 1); break; case ODBC_SPECIAL_COLUMNS: odbc_fix_data_type_col(stmt, 4); odbc_fix_data_type_col(stmt, 13); /* TODO sure ?? */ break; case ODBC_SPECIAL_PROCEDURECOLUMNS: odbc_fix_data_type_col(stmt, 5); odbc_fix_data_type_col(stmt, 14); /* TODO sure ?? */ break; case ODBC_SPECIAL_SPECIALCOLUMNS: odbc_fix_data_type_col(stmt, 2); break; case ODBC_SPECIAL_NONE: break; } } resinfo = tds->current_results; if (!resinfo) { tdsdump_log(TDS_DBG_INFO1, "SQLFetch: !resinfo\n"); break; } /* we got a row, return a row readed even if error (for ODBC specifications) */ ++(*fetched_ptr); for (i = 0; i < resinfo->num_cols; i++) { colinfo = resinfo->columns[i]; colinfo->column_text_sqlgetdatapos = 0; drec_ard = (i < ard->header.sql_desc_count) ? &ard->records[i] : NULL; if (!drec_ard) continue; if (colinfo->column_cur_size < 0) { if (drec_ard->sql_desc_indicator_ptr) { *AT_ROW(drec_ard->sql_desc_indicator_ptr, SQLLEN) = SQL_NULL_DATA; } else if (drec_ard->sql_desc_data_ptr) { odbc_errs_add(&stmt->errs, "22002", NULL); row_status = SQL_ROW_ERROR; break; } continue; } /* set indicator to 0 if data is not null */ if (drec_ard->sql_desc_indicator_ptr) *AT_ROW(drec_ard->sql_desc_indicator_ptr, SQLLEN) = 0; /* TODO what happen to length if no data is returned (drec->sql_desc_data_ptr == NULL) ?? */ len = 0; if (drec_ard->sql_desc_data_ptr) { int c_type; TDS_CHAR *data_ptr = (TDS_CHAR *) drec_ard->sql_desc_data_ptr; src = (TDS_CHAR *) colinfo->column_data; srclen = colinfo->column_cur_size; colinfo->column_text_sqlgetdatapos = 0; c_type = drec_ard->sql_desc_concise_type; if (c_type == SQL_C_DEFAULT) c_type = odbc_sql_to_c_type_default(stmt->ird->records[i].sql_desc_concise_type); if (row_offset || curr_row == 0) { data_ptr += row_offset; } else { data_ptr += odbc_get_octet_len(c_type, drec_ard) * curr_row; } len = odbc_tds2sql(stmt, colinfo, tds_get_conversion_type(colinfo->on_server.column_type, colinfo->on_server.column_size), src, srclen, c_type, data_ptr, drec_ard->sql_desc_octet_length, drec_ard); if (len == SQL_NULL_DATA) { row_status = SQL_ROW_ERROR; break; } if ((c_type == SQL_C_CHAR && len >= drec_ard->sql_desc_octet_length) || (c_type == SQL_C_BINARY && len > drec_ard->sql_desc_octet_length)) { truncated = 1; stmt->errs.lastrc = SQL_SUCCESS_WITH_INFO; } } if (drec_ard->sql_desc_octet_length_ptr) *AT_ROW(drec_ard->sql_desc_octet_length_ptr, SQLLEN) = len; } if (status_ptr) *status_ptr++ = truncated ? SQL_ROW_ERROR : row_status; if (row_status == SQL_ROW_ERROR) { stmt->errs.lastrc = SQL_ERROR; break; } #if SQL_BIND_BY_COLUMN != 0 if (stmt->ard->header.sql_desc_bind_type != SQL_BIND_BY_COLUMN) #endif row_offset += stmt->ard->header.sql_desc_bind_type; } while (++curr_row < num_rows); if (truncated) odbc_errs_add(&stmt->errs, "01004", NULL); all_done: /* TODO cursor correct ?? */ if (stmt->cursor) { tds_process_tokens(tds, &result_type, NULL, TDS_TOKEN_TRAILING); odbc_unlock_statement(stmt); } if (*fetched_ptr == 0 && (stmt->errs.lastrc == SQL_SUCCESS || stmt->errs.lastrc == SQL_SUCCESS_WITH_INFO)) ODBC_RETURN(stmt, SQL_NO_DATA); if (stmt->errs.lastrc == SQL_ERROR && (*fetched_ptr > 1 || (*fetched_ptr == 1 && row_status != SQL_ROW_ERROR))) ODBC_RETURN(stmt, SQL_SUCCESS_WITH_INFO); ODBC_RETURN_(stmt); } SQLRETURN ODBC_PUBLIC ODBC_API SQLFetch(SQLHSTMT hstmt) { SQLRETURN ret; struct { SQLULEN array_size; SQLULEN *rows_processed_ptr; SQLUSMALLINT *array_status_ptr; } keep; ODBC_ENTER_HSTMT; tdsdump_log(TDS_DBG_FUNC, "SQLFetch(%p)\n", hstmt); keep.array_size = stmt->ard->header.sql_desc_array_size; keep.rows_processed_ptr = stmt->ird->header.sql_desc_rows_processed_ptr; keep.array_status_ptr = stmt->ird->header.sql_desc_array_status_ptr; if (stmt->dbc->env->attr.odbc_version != SQL_OV_ODBC3) { stmt->ard->header.sql_desc_array_size = 1; stmt->ird->header.sql_desc_rows_processed_ptr = NULL; stmt->ird->header.sql_desc_array_status_ptr = NULL; } ret = _SQLFetch(stmt, SQL_FETCH_NEXT, 0); if (stmt->dbc->env->attr.odbc_version != SQL_OV_ODBC3) { stmt->ard->header.sql_desc_array_size = keep.array_size; stmt->ird->header.sql_desc_rows_processed_ptr = keep.rows_processed_ptr; stmt->ird->header.sql_desc_array_status_ptr = keep.array_status_ptr; } ODBC_EXIT(stmt, ret); } #if (ODBCVER >= 0x0300) SQLRETURN ODBC_PUBLIC ODBC_API SQLFetchScroll(SQLHSTMT hstmt, SQLSMALLINT FetchOrientation, SQLLEN FetchOffset) { ODBC_ENTER_HSTMT; tdsdump_log(TDS_DBG_FUNC, "SQLFetchScroll(%p, %d, %d)\n", hstmt, FetchOrientation, (int)FetchOffset); if (FetchOrientation != SQL_FETCH_NEXT && !stmt->dbc->cursor_support) { odbc_errs_add(&stmt->errs, "HY106", NULL); ODBC_EXIT_(stmt); } ODBC_EXIT(stmt, _SQLFetch(stmt, FetchOrientation, FetchOffset)); } #endif #if (ODBCVER >= 0x0300) SQLRETURN ODBC_PUBLIC ODBC_API SQLFreeHandle(SQLSMALLINT HandleType, SQLHANDLE Handle) { tdsdump_log(TDS_DBG_INFO1, "SQLFreeHandle(%d, %p)\n", HandleType, (void *) Handle); switch (HandleType) { case SQL_HANDLE_STMT: return _SQLFreeStmt(Handle, SQL_DROP, 0); break; case SQL_HANDLE_DBC: return _SQLFreeConnect(Handle); break; case SQL_HANDLE_ENV: return _SQLFreeEnv(Handle); break; case SQL_HANDLE_DESC: return _SQLFreeDesc(Handle); break; } return SQL_ERROR; } static SQLRETURN _SQLFreeConnect(SQLHDBC hdbc) { int i; ODBC_ENTER_HDBC; tdsdump_log(TDS_DBG_FUNC, "_SQLFreeConnect(%p)\n", hdbc); tds_close_socket(dbc->tds_socket); /* TODO if connected return error */ tds_free_socket(dbc->tds_socket); odbc_bcp_free_storage(dbc); /* free attributes */ #ifdef TDS_NO_DM tds_dstr_free(&dbc->attr.tracefile); #endif tds_dstr_free(&dbc->attr.current_catalog); tds_dstr_free(&dbc->attr.translate_lib); tds_dstr_zero(&dbc->oldpwd); tds_dstr_free(&dbc->oldpwd); #ifdef ENABLE_ODBC_WIDE tds_dstr_free(&dbc->original_charset); #endif tds_dstr_free(&dbc->dsn); for (i = 0; i < TDS_MAX_APP_DESC; i++) { if (dbc->uad[i]) { desc_free(dbc->uad[i]); } } odbc_errs_reset(&dbc->errs); tds_mutex_unlock(&dbc->mtx); tds_mutex_free(&dbc->mtx); free(dbc); return SQL_SUCCESS; } SQLRETURN ODBC_PUBLIC ODBC_API SQLFreeConnect(SQLHDBC hdbc) { tdsdump_log(TDS_DBG_INFO2, "SQLFreeConnect(%p)\n", hdbc); return _SQLFreeConnect(hdbc); } #endif static SQLRETURN _SQLFreeEnv(SQLHENV henv) { ODBC_ENTER_HENV; tdsdump_log(TDS_DBG_FUNC, "_SQLFreeEnv(%p)\n", henv); odbc_errs_reset(&env->errs); tds_free_context(env->tds_ctx); tds_mutex_unlock(&env->mtx); tds_mutex_free(&env->mtx); free(env); return SQL_SUCCESS; } SQLRETURN ODBC_PUBLIC ODBC_API SQLFreeEnv(SQLHENV henv) { tdsdump_log(TDS_DBG_FUNC, "SQLFreeEnv(%p)\n", henv); return _SQLFreeEnv(henv); } static SQLRETURN _SQLFreeStmt(SQLHSTMT hstmt, SQLUSMALLINT fOption, int force) { TDSSOCKET *tds; ODBC_ENTER_HSTMT; tdsdump_log(TDS_DBG_FUNC, "_SQLFreeStmt(%p, %d, %d)\n", hstmt, fOption, force); /* check if option correct */ if (fOption != SQL_DROP && fOption != SQL_CLOSE && fOption != SQL_UNBIND && fOption != SQL_RESET_PARAMS) { tdsdump_log(TDS_DBG_ERROR, "SQLFreeStmt: Unknown option %d\n", fOption); odbc_errs_add(&stmt->errs, "HY092", NULL); ODBC_EXIT_(stmt); } /* if we have bound columns, free the temporary list */ if (fOption == SQL_DROP || fOption == SQL_UNBIND) { desc_free_records(stmt->ard); } /* do the same for bound parameters */ if (fOption == SQL_DROP || fOption == SQL_RESET_PARAMS) { desc_free_records(stmt->apd); desc_free_records(stmt->ipd); } /* close statement */ if (fOption == SQL_DROP || fOption == SQL_CLOSE) { SQLRETURN retcode; tds = stmt->tds; /* * FIXME -- otherwise make sure the current statement is complete */ /* do not close other running query ! */ if (tds && tds->state != TDS_IDLE && tds->state != TDS_DEAD) { if (TDS_SUCCEED(tds_send_cancel(tds))) tds_process_cancel(tds); } /* free cursor */ retcode = odbc_free_cursor(stmt); if (!force && retcode != SQL_SUCCESS) ODBC_EXIT(stmt, retcode); } /* free it */ if (fOption == SQL_DROP) { SQLRETURN retcode; /* close prepared statement or add to connection */ retcode = odbc_free_dynamic(stmt); if (!force && retcode != SQL_SUCCESS) ODBC_EXIT(stmt, retcode); /* detatch from list */ tds_mutex_lock(&stmt->dbc->mtx); if (stmt->next) stmt->next->prev = stmt->prev; if (stmt->prev) stmt->prev->next = stmt->next; if (stmt->dbc->stmt_list == stmt) stmt->dbc->stmt_list = stmt->next; tds_mutex_unlock(&stmt->dbc->mtx); tds_dstr_free(&stmt->query); tds_free_param_results(stmt->params); odbc_errs_reset(&stmt->errs); odbc_unlock_statement(stmt); tds_dstr_free(&stmt->cursor_name); tds_dstr_free(&stmt->attr.qn_msgtext); tds_dstr_free(&stmt->attr.qn_options); desc_free(stmt->ird); desc_free(stmt->ipd); desc_free(stmt->orig_ard); desc_free(stmt->orig_apd); tds_mutex_unlock(&stmt->mtx); tds_mutex_free(&stmt->mtx); free(stmt); /* NOTE we freed stmt, do not use ODBC_EXIT */ return SQL_SUCCESS; } ODBC_EXIT_(stmt); } SQLRETURN ODBC_PUBLIC ODBC_API SQLFreeStmt(SQLHSTMT hstmt, SQLUSMALLINT fOption) { tdsdump_log(TDS_DBG_FUNC, "SQLFreeStmt(%p, %d)\n", hstmt, fOption); return _SQLFreeStmt(hstmt, fOption, 0); } SQLRETURN ODBC_PUBLIC ODBC_API SQLCloseCursor(SQLHSTMT hstmt) { /* TODO cursors */ /* * Basic implementation for when no driver manager is present. * - according to ODBC documentation SQLCloseCursor is more or less * equivalent to SQLFreeStmt(..., SQL_CLOSE). * - indeed that is what the DM does if it can't find the function * in the driver, so this is pretty close. */ /* TODO remember to close cursors really when get implemented */ /* TODO read all results and discard them or use cancellation ?? test behaviour */ tdsdump_log(TDS_DBG_FUNC, "SQLCloseCursor(%p)\n", hstmt); return _SQLFreeStmt(hstmt, SQL_CLOSE, 0); } static SQLRETURN _SQLFreeDesc(SQLHDESC hdesc) { ODBC_ENTER_HDESC; tdsdump_log(TDS_DBG_FUNC, "_SQLFreeDesc(%p)\n", hdesc); if (desc->header.sql_desc_alloc_type != SQL_DESC_ALLOC_USER) { odbc_errs_add(&desc->errs, "HY017", NULL); ODBC_EXIT_(desc); } if (IS_HDBC(desc->parent)) { TDS_DBC *dbc = (TDS_DBC *) desc->parent; TDS_STMT *stmt; int i; /* freeing descriptors associated to statements revert state of statements */ tds_mutex_lock(&dbc->mtx); for (stmt = dbc->stmt_list; stmt != NULL; stmt = stmt->next) { if (stmt->ard == desc) stmt->ard = stmt->orig_ard; if (stmt->apd == desc) stmt->apd = stmt->orig_apd; } tds_mutex_unlock(&dbc->mtx); for (i = 0; i < TDS_MAX_APP_DESC; ++i) { if (dbc->uad[i] == desc) { dbc->uad[i] = NULL; tds_mutex_unlock(&desc->mtx); desc_free(desc); break; } } } return SQL_SUCCESS; } static SQLRETURN _SQLGetStmtAttr(SQLHSTMT hstmt, SQLINTEGER Attribute, SQLPOINTER Value, SQLINTEGER BufferLength, SQLINTEGER * StringLength WIDE) { void *src; size_t size; ODBC_ENTER_HSTMT; /* TODO assign directly, use macro for size */ switch (Attribute) { case SQL_ATTR_APP_PARAM_DESC: size = sizeof(stmt->apd); src = &stmt->apd; break; case SQL_ATTR_APP_ROW_DESC: size = sizeof(stmt->ard); src = &stmt->ard; break; case SQL_ATTR_ASYNC_ENABLE: size = sizeof(stmt->attr.async_enable); src = &stmt->attr.async_enable; break; case SQL_ATTR_CONCURRENCY: size = sizeof(stmt->attr.concurrency); src = &stmt->attr.concurrency; break; case SQL_ATTR_CURSOR_TYPE: size = sizeof(stmt->attr.cursor_type); src = &stmt->attr.cursor_type; break; case SQL_ATTR_ENABLE_AUTO_IPD: size = sizeof(stmt->attr.enable_auto_ipd); src = &stmt->attr.enable_auto_ipd; break; case SQL_ATTR_FETCH_BOOKMARK_PTR: size = sizeof(stmt->attr.fetch_bookmark_ptr); src = &stmt->attr.fetch_bookmark_ptr; break; case SQL_ATTR_KEYSET_SIZE: size = sizeof(stmt->attr.keyset_size); src = &stmt->attr.keyset_size; break; case SQL_ATTR_MAX_LENGTH: size = sizeof(stmt->attr.max_length); src = &stmt->attr.max_length; break; case SQL_ATTR_MAX_ROWS: size = sizeof(stmt->attr.max_rows); src = &stmt->attr.max_rows; break; case SQL_ATTR_METADATA_ID: size = sizeof(stmt->attr.metadata_id); src = &stmt->attr.noscan; break; case SQL_ATTR_NOSCAN: size = sizeof(stmt->attr.noscan); src = &stmt->attr.noscan; break; case SQL_ATTR_PARAM_BIND_OFFSET_PTR: size = sizeof(stmt->apd->header.sql_desc_bind_offset_ptr); src = &stmt->apd->header.sql_desc_bind_offset_ptr; break; case SQL_ATTR_PARAM_BIND_TYPE: size = sizeof(stmt->apd->header.sql_desc_bind_type); src = &stmt->apd->header.sql_desc_bind_type; break; case SQL_ATTR_PARAM_OPERATION_PTR: size = sizeof(stmt->apd->header.sql_desc_array_status_ptr); src = &stmt->apd->header.sql_desc_array_status_ptr; break; case SQL_ATTR_PARAM_STATUS_PTR: size = sizeof(stmt->ipd->header.sql_desc_array_status_ptr); src = &stmt->ipd->header.sql_desc_array_status_ptr; break; case SQL_ATTR_PARAMS_PROCESSED_PTR: size = sizeof(stmt->ipd->header.sql_desc_rows_processed_ptr); src = &stmt->ipd->header.sql_desc_rows_processed_ptr; break; case SQL_ATTR_PARAMSET_SIZE: size = sizeof(stmt->apd->header.sql_desc_array_size); src = &stmt->apd->header.sql_desc_array_size; break; case SQL_ATTR_QUERY_TIMEOUT: size = sizeof(stmt->attr.query_timeout); src = &stmt->attr.query_timeout; break; case SQL_ATTR_RETRIEVE_DATA: size = sizeof(stmt->attr.retrieve_data); src = &stmt->attr.retrieve_data; break; case SQL_ATTR_ROW_BIND_OFFSET_PTR: size = sizeof(stmt->ard->header.sql_desc_bind_offset_ptr); src = &stmt->ard->header.sql_desc_bind_offset_ptr; break; #if SQL_BIND_TYPE != SQL_ATTR_ROW_BIND_TYPE case SQL_BIND_TYPE: /* although this is ODBC2 we must support this attribute */ #endif case SQL_ATTR_ROW_BIND_TYPE: size = sizeof(stmt->ard->header.sql_desc_bind_type); src = &stmt->ard->header.sql_desc_bind_type; break; case SQL_ATTR_ROW_NUMBER: /* TODO do not get info every time, cache somewhere */ if (stmt->cursor && odbc_lock_statement(stmt)) { TDS_UINT row_number, row_count; tds_cursor_get_cursor_info(stmt->tds, stmt->cursor, &row_number, &row_count); stmt->attr.row_number = row_number; } size = sizeof(stmt->attr.row_number); src = &stmt->attr.row_number; break; case SQL_ATTR_ROW_OPERATION_PTR: size = sizeof(stmt->ard->header.sql_desc_array_status_ptr); src = &stmt->ard->header.sql_desc_array_status_ptr; break; case SQL_ATTR_ROW_STATUS_PTR: size = sizeof(stmt->ird->header.sql_desc_array_status_ptr); src = &stmt->ird->header.sql_desc_array_status_ptr; break; case SQL_ATTR_ROWS_FETCHED_PTR: size = sizeof(stmt->ird->header.sql_desc_rows_processed_ptr); src = &stmt->ird->header.sql_desc_rows_processed_ptr; break; case SQL_ATTR_ROW_ARRAY_SIZE: size = sizeof(stmt->ard->header.sql_desc_array_size); src = &stmt->ard->header.sql_desc_array_size; break; case SQL_ATTR_SIMULATE_CURSOR: size = sizeof(stmt->attr.simulate_cursor); src = &stmt->attr.simulate_cursor; break; case SQL_ATTR_USE_BOOKMARKS: size = sizeof(stmt->attr.use_bookmarks); src = &stmt->attr.use_bookmarks; break; case SQL_ATTR_CURSOR_SCROLLABLE: size = sizeof(stmt->attr.cursor_scrollable); src = &stmt->attr.cursor_scrollable; break; case SQL_ATTR_CURSOR_SENSITIVITY: size = sizeof(stmt->attr.cursor_sensitivity); src = &stmt->attr.cursor_sensitivity; break; case SQL_ATTR_IMP_ROW_DESC: size = sizeof(stmt->ird); src = &stmt->ird; break; case SQL_ATTR_IMP_PARAM_DESC: size = sizeof(stmt->ipd); src = &stmt->ipd; break; case SQL_ROWSET_SIZE: /* although this is ODBC2 we must support this attribute */ size = sizeof(stmt->sql_rowset_size); src = &stmt->sql_rowset_size; break; case SQL_SOPT_SS_QUERYNOTIFICATION_TIMEOUT: size = sizeof(stmt->attr.qn_timeout); src = &stmt->attr.qn_timeout; break; case SQL_SOPT_SS_QUERYNOTIFICATION_MSGTEXT: { SQLRETURN rc = odbc_set_string_oct(stmt->dbc, Value, BufferLength, StringLength, tds_dstr_cstr(&stmt->attr.qn_msgtext), tds_dstr_len(&stmt->attr.qn_msgtext)); ODBC_EXIT(stmt, rc); } case SQL_SOPT_SS_QUERYNOTIFICATION_OPTIONS: { SQLRETURN rc = odbc_set_string_oct(stmt->dbc, Value, BufferLength, StringLength, tds_dstr_cstr(&stmt->attr.qn_options), tds_dstr_len(&stmt->attr.qn_options)); ODBC_EXIT(stmt, rc); } /* TODO SQL_COLUMN_SEARCHABLE, although ODBC2 */ default: odbc_errs_add(&stmt->errs, "HY092", NULL); ODBC_EXIT_(stmt); } memcpy(Value, src, size); if (StringLength) *StringLength = size; ODBC_EXIT_(stmt); } #if (ODBCVER >= 0x0300) SQLRETURN ODBC_PUBLIC ODBC_API SQLGetStmtAttr(SQLHSTMT hstmt, SQLINTEGER Attribute, SQLPOINTER Value, SQLINTEGER BufferLength, SQLINTEGER * StringLength) { tdsdump_log(TDS_DBG_FUNC, "SQLGetStmtAttr(%p, %d, %p, %d, %p)\n", hstmt, (int)Attribute, Value, (int)BufferLength, StringLength); return _SQLGetStmtAttr(hstmt, Attribute, Value, BufferLength, StringLength _wide0); } #ifdef ENABLE_ODBC_WIDE SQLRETURN ODBC_PUBLIC ODBC_API SQLGetStmtAttrW(SQLHSTMT hstmt, SQLINTEGER Attribute, SQLPOINTER Value, SQLINTEGER BufferLength, SQLINTEGER * StringLength) { tdsdump_log(TDS_DBG_FUNC, "SQLGetStmtAttr(%p, %d, %p, %d, %p)\n", hstmt, (int)Attribute, Value, (int)BufferLength, StringLength); return _SQLGetStmtAttr(hstmt, Attribute, Value, BufferLength, StringLength, 1); } #endif #endif SQLRETURN ODBC_PUBLIC ODBC_API SQLGetStmtOption(SQLHSTMT hstmt, SQLUSMALLINT fOption, SQLPOINTER pvParam) { tdsdump_log(TDS_DBG_FUNC, "SQLGetStmtOption(%p, %d, %p)\n", hstmt, fOption, pvParam); return _SQLGetStmtAttr(hstmt, (SQLINTEGER) fOption, pvParam, SQL_MAX_OPTION_STRING_LENGTH, NULL _wide0); } SQLRETURN ODBC_PUBLIC ODBC_API SQLNumResultCols(SQLHSTMT hstmt, SQLSMALLINT FAR * pccol) { ODBC_ENTER_HSTMT; tdsdump_log(TDS_DBG_FUNC, "SQLNumResultCols(%p, %p)\n", hstmt, pccol); /* * 3/15/2001 bsb - DBD::ODBC calls SQLNumResultCols on non-result * generating queries such as 'drop table' */ #if 0 if (stmt->row_status == NOT_IN_ROW) { odbc_errs_add(&stmt->errs, "24000", NULL); ODBC_EXIT_(stmt); } #endif IRD_UPDATE(stmt->ird, &stmt->errs, ODBC_EXIT(stmt, SQL_ERROR)); *pccol = stmt->ird->header.sql_desc_count; ODBC_EXIT_(stmt); } ODBC_FUNC(SQLPrepare, (P(SQLHSTMT,hstmt), PCHARIN(SqlStr,SQLINTEGER) WIDE)) { SQLRETURN retcode; ODBC_ENTER_HSTMT; /* try to free dynamic associated */ retcode = odbc_free_dynamic(stmt); if (retcode != SQL_SUCCESS) ODBC_EXIT(stmt, retcode); if (SQL_SUCCESS != odbc_set_stmt_query(stmt, szSqlStr, cbSqlStr _wide)) ODBC_EXIT(stmt, SQL_ERROR); stmt->is_prepared_query = 1; /* count parameters */ stmt->param_count = tds_count_placeholders(tds_dstr_cstr(&stmt->query)); /* trasform to native (one time, not for every SQLExecute) */ if (SQL_SUCCESS != prepare_call(stmt)) ODBC_EXIT(stmt, SQL_ERROR); /* TODO needed ?? */ tds_release_dynamic(&stmt->dyn); /* try to prepare query */ /* TODO support getting info for RPC */ if (!stmt->prepared_query_is_rpc && (stmt->attr.cursor_type == SQL_CURSOR_FORWARD_ONLY && stmt->attr.concurrency == SQL_CONCUR_READ_ONLY)) { tds_free_param_results(stmt->params); stmt->params = NULL; stmt->param_num = 0; stmt->need_reprepare = 0; /* * using TDS7+ we need parameters to prepare a query so try * to get them * TDS5 do not need parameters type and we have always to * prepare sepatarely so this is not an issue */ if (IS_TDS7_PLUS(stmt->dbc->tds_socket->conn)) { stmt->need_reprepare = 1; ODBC_EXIT_(stmt); } tdsdump_log(TDS_DBG_INFO1, "Creating prepared statement\n"); if (odbc_lock_statement(stmt)) odbc_prepare(stmt); } ODBC_EXIT_(stmt); } /* TDS_NO_COUNT must be -1 for SQLRowCount to return -1 when there is no rowcount */ #if TDS_NO_COUNT != -1 # error TDS_NO_COUNT != -1 #endif SQLRETURN _SQLRowCount(SQLHSTMT hstmt, SQLLEN FAR * pcrow) { ODBC_ENTER_HSTMT; tdsdump_log(TDS_DBG_FUNC, "_SQLRowCount(%p, %p), %ld rows \n", hstmt, pcrow, (long)stmt->row_count); *pcrow = stmt->row_count; ODBC_EXIT_(stmt); } SQLRETURN ODBC_PUBLIC ODBC_API SQLRowCount(SQLHSTMT hstmt, SQLLEN FAR * pcrow) { SQLRETURN rc = _SQLRowCount(hstmt, pcrow); tdsdump_log(TDS_DBG_INFO1, "SQLRowCount returns %d, row count %ld\n", rc, (long int) *pcrow); return rc; } ODBC_FUNC(SQLSetCursorName, (P(SQLHSTMT,hstmt), PCHARIN(Cursor,SQLSMALLINT) WIDE)) { ODBC_ENTER_HSTMT; /* cursor already present, we cannot set name */ if (stmt->cursor) { odbc_errs_add(&stmt->errs, "24000", NULL); ODBC_EXIT_(stmt); } if (!odbc_dstr_copy(stmt->dbc, &stmt->cursor_name, cbCursor, szCursor)) { odbc_errs_add(&stmt->errs, "HY001", NULL); ODBC_EXIT_(stmt); } ODBC_EXIT_(stmt); } ODBC_FUNC(SQLGetCursorName, (P(SQLHSTMT,hstmt), PCHAROUT(Cursor,SQLSMALLINT) WIDE)) { SQLRETURN rc; ODBC_ENTER_HSTMT; if ((rc = odbc_set_string(stmt->dbc, szCursor, cbCursorMax, pcbCursor, tds_dstr_cstr(&stmt->cursor_name), -1))) odbc_errs_add(&stmt->errs, "01004", NULL); ODBC_EXIT(stmt, rc); } /* * spinellia@acm.org : copied shamelessly from change_database * transaction support * 1 = commit, 0 = rollback */ static SQLRETURN change_transaction(TDS_DBC * dbc, int state) { TDSSOCKET *tds = dbc->tds_socket; int cont; TDSRET ret; tdsdump_log(TDS_DBG_INFO1, "change_transaction(0x%p,%d)\n", dbc, state); if (dbc->attr.autocommit == SQL_AUTOCOMMIT_ON) cont = 0; else cont = 1; /* if pending drop all recordset, don't issue cancel */ if (tds->state == TDS_PENDING && dbc->current_statement != NULL) { /* TODO what happen on multiple errors ?? discard all ?? */ if (TDS_FAILED(tds_process_simple_query(tds))) return SQL_ERROR; } /* TODO better idle check, not thread safe */ if (tds->state == TDS_IDLE) tds->query_timeout = dbc->default_query_timeout; if (state) ret = tds_submit_commit(tds, cont); else ret = tds_submit_rollback(tds, cont); if (TDS_FAILED(ret)) { odbc_errs_add(&dbc->errs, "HY000", "Could not perform COMMIT or ROLLBACK"); return SQL_ERROR; } if (TDS_FAILED(tds_process_simple_query(tds))) return SQL_ERROR; /* TODO some query can collect errors so perhaps it's better to return SUCCES_WITH_INFO in such case... */ return SQL_SUCCESS; } static SQLRETURN _SQLTransact(SQLHENV henv, SQLHDBC hdbc, SQLUSMALLINT fType) { int op = (fType == SQL_COMMIT ? 1 : 0); /* I may live without a HENV */ /* CHECK_HENV; */ /* ..but not without a HDBC! */ ODBC_ENTER_HDBC; tdsdump_log(TDS_DBG_FUNC, "_SQLTransact(%p, %p, %d)\n", henv, hdbc, fType); ODBC_EXIT(dbc, change_transaction(dbc, op)); } SQLRETURN ODBC_PUBLIC ODBC_API SQLTransact(SQLHENV henv, SQLHDBC hdbc, SQLUSMALLINT fType) { tdsdump_log(TDS_DBG_FUNC, "SQLTransact(%p, %p, %d)\n", henv, hdbc, fType); return _SQLTransact(henv, hdbc, fType); } #if ODBCVER >= 0x300 SQLRETURN ODBC_PUBLIC ODBC_API SQLEndTran(SQLSMALLINT handleType, SQLHANDLE handle, SQLSMALLINT completionType) { /* * Do not call the exported SQLTransact(), * because we may wind up calling a function with the same name implemented by the DM. */ tdsdump_log(TDS_DBG_FUNC, "SQLEndTran(%d, %p, %d)\n", handleType, handle, completionType); switch (handleType) { case SQL_HANDLE_ENV: return _SQLTransact(handle, NULL, completionType); case SQL_HANDLE_DBC: return _SQLTransact(NULL, handle, completionType); } return SQL_ERROR; } #endif /* end of transaction support */ SQLRETURN ODBC_PUBLIC ODBC_API SQLSetParam(SQLHSTMT hstmt, SQLUSMALLINT ipar, SQLSMALLINT fCType, SQLSMALLINT fSqlType, SQLULEN cbParamDef, SQLSMALLINT ibScale, SQLPOINTER rgbValue, SQLLEN FAR * pcbValue) { tdsdump_log(TDS_DBG_FUNC, "SQLSetParam(%p, %d, %d, %d, %u, %d, %p, %p)\n", hstmt, ipar, fCType, fSqlType, (unsigned)cbParamDef, ibScale, rgbValue, pcbValue); return _SQLBindParameter(hstmt, ipar, SQL_PARAM_INPUT_OUTPUT, fCType, fSqlType, cbParamDef, ibScale, rgbValue, SQL_SETPARAM_VALUE_MAX, pcbValue); } /** * SQLColumns * * Return column information for a table or view. This is * mapped to a call to sp_columns which - lucky for us - returns * the exact result set we need. * * exec sp_columns [ @table_name = ] object * [ , [ @table_owner = ] owner ] * [ , [ @table_qualifier = ] qualifier ] * [ , [ @column_name = ] column ] * [ , [ @ODBCVer = ] ODBCVer ] * */ ODBC_FUNC(SQLColumns, (P(SQLHSTMT,hstmt), PCHARIN(CatalogName,SQLSMALLINT), /* object_qualifier */ PCHARIN(SchemaName,SQLSMALLINT), /* object_owner */ PCHARIN(TableName,SQLSMALLINT), /* object_name */ PCHARIN(ColumnName,SQLSMALLINT) /* column_name */ WIDE)) { int retcode; ODBC_ENTER_HSTMT; retcode = odbc_stat_execute(stmt _wide, "sp_columns", TDS_IS_MSSQL(stmt->dbc->tds_socket) ? 5 : 4, "P@table_name", szTableName, cbTableName, "P@table_owner", szSchemaName, cbSchemaName, "O@table_qualifier", szCatalogName, cbCatalogName, "P@column_name", szColumnName, cbColumnName, "V@ODBCVer", (char*) NULL, 0); if (SQL_SUCCEEDED(retcode) && stmt->dbc->env->attr.odbc_version == SQL_OV_ODBC3) { odbc_col_setname(stmt, 1, "TABLE_CAT"); odbc_col_setname(stmt, 2, "TABLE_SCHEM"); odbc_col_setname(stmt, 7, "COLUMN_SIZE"); odbc_col_setname(stmt, 8, "BUFFER_LENGTH"); odbc_col_setname(stmt, 9, "DECIMAL_DIGITS"); odbc_col_setname(stmt, 10, "NUM_PREC_RADIX"); if (TDS_IS_SYBASE(stmt->dbc->tds_socket)) stmt->special_row = ODBC_SPECIAL_COLUMNS; } ODBC_EXIT_(stmt); } ODBC_FUNC(SQLGetConnectAttr, (P(SQLHDBC,hdbc), P(SQLINTEGER,Attribute), P(SQLPOINTER,Value), P(SQLINTEGER,BufferLength), P(SQLINTEGER *,StringLength) WIDE)) { const char *p = NULL; ODBC_ENTER_HDBC; tdsdump_log(TDS_DBG_FUNC, "_SQLGetConnectAttr(%p, %d, %p, %d, %p)\n", hdbc, (int)Attribute, Value, (int)BufferLength, StringLength); switch (Attribute) { case SQL_ATTR_AUTOCOMMIT: *((SQLUINTEGER *) Value) = dbc->attr.autocommit; break; #if defined(SQL_ATTR_CONNECTION_DEAD) && defined(SQL_CD_TRUE) case SQL_ATTR_CONNECTION_DEAD: *((SQLUINTEGER *) Value) = IS_TDSDEAD(dbc->tds_socket) ? SQL_CD_TRUE : SQL_CD_FALSE; break; #endif case SQL_ATTR_CONNECTION_TIMEOUT: *((SQLUINTEGER *) Value) = dbc->attr.connection_timeout; break; case SQL_ATTR_ACCESS_MODE: *((SQLUINTEGER *) Value) = dbc->attr.access_mode; break; case SQL_ATTR_CURRENT_CATALOG: p = tds_dstr_cstr(&dbc->attr.current_catalog); break; case SQL_ATTR_LOGIN_TIMEOUT: *((SQLUINTEGER *) Value) = dbc->attr.login_timeout; break; case SQL_ATTR_ODBC_CURSORS: *((SQLUINTEGER *) Value) = dbc->attr.odbc_cursors; break; case SQL_ATTR_PACKET_SIZE: *((SQLUINTEGER *) Value) = dbc->attr.packet_size; break; case SQL_ATTR_QUIET_MODE: *((SQLHWND *) Value) = dbc->attr.quite_mode; break; #ifdef TDS_NO_DM case SQL_ATTR_TRACE: *((SQLUINTEGER *) Value) = dbc->attr.trace; break; case SQL_ATTR_TRACEFILE: p = tds_dstr_cstr(&dbc->attr.tracefile); break; #endif case SQL_ATTR_TXN_ISOLATION: *((SQLUINTEGER *) Value) = dbc->attr.txn_isolation; break; case SQL_COPT_SS_MARS_ENABLED: *((SQLUINTEGER *) Value) = dbc->attr.mars_enabled; break; case SQL_ATTR_TRANSLATE_LIB: case SQL_ATTR_TRANSLATE_OPTION: odbc_errs_add(&dbc->errs, "HYC00", NULL); break; case SQL_COPT_SS_BCP: *((SQLUINTEGER *) Value) = dbc->attr.bulk_enabled; break; default: odbc_errs_add(&dbc->errs, "HY092", NULL); break; } if (p) { SQLRETURN rc = odbc_set_string_oct(dbc, Value, BufferLength, StringLength, p, -1); ODBC_EXIT(dbc, rc); } ODBC_EXIT_(dbc); } SQLRETURN ODBC_PUBLIC ODBC_API SQLGetConnectOption(SQLHDBC hdbc, SQLUSMALLINT fOption, SQLPOINTER pvParam) { tdsdump_log(TDS_DBG_FUNC, "SQLGetConnectOption(%p, %u, %p)\n", hdbc, fOption, pvParam); return _SQLGetConnectAttr(hdbc, (SQLINTEGER) fOption, pvParam, SQL_MAX_OPTION_STRING_LENGTH, NULL _wide0); } #ifdef ENABLE_ODBC_WIDE SQLRETURN ODBC_PUBLIC ODBC_API SQLGetConnectOptionW(SQLHDBC hdbc, SQLUSMALLINT fOption, SQLPOINTER pvParam) { tdsdump_log(TDS_DBG_FUNC, "SQLGetConnectOptionW(%p, %u, %p)\n", hdbc, fOption, pvParam); return _SQLGetConnectAttr(hdbc, (SQLINTEGER) fOption, pvParam, SQL_MAX_OPTION_STRING_LENGTH, NULL, 1); } #endif SQLRETURN ODBC_PUBLIC ODBC_API SQLGetData(SQLHSTMT hstmt, SQLUSMALLINT icol, SQLSMALLINT fCType, SQLPOINTER rgbValue, SQLLEN cbValueMax, SQLLEN FAR * pcbValue) { /* TODO cursors fetch row if needed ?? */ TDSCOLUMN *colinfo; TDSRESULTINFO *resinfo; SQLLEN dummy_cb; ODBC_ENTER_HSTMT; tdsdump_log(TDS_DBG_FUNC, "SQLGetData(%p, %u, %d, %p, %d, %p)\n", hstmt, icol, fCType, rgbValue, (int)cbValueMax, pcbValue); if (cbValueMax < 0) { odbc_errs_add(&stmt->errs, "HY090", NULL); ODBC_EXIT_(stmt); } /* read data from TDS only if current statement */ if ((stmt->cursor == NULL && !stmt->tds) || stmt->row_status == PRE_NORMAL_ROW || stmt->row_status == NOT_IN_ROW) { odbc_errs_add(&stmt->errs, "24000", NULL); ODBC_EXIT_(stmt); } IRD_CHECK; if (!pcbValue) pcbValue = &dummy_cb; resinfo = stmt->cursor ? stmt->cursor->res_info : stmt->tds->current_results; if (!resinfo) { odbc_errs_add(&stmt->errs, "HY010", NULL); ODBC_EXIT_(stmt); } if (icol <= 0 || icol > resinfo->num_cols) { odbc_errs_add(&stmt->errs, "07009", "Column out of range"); ODBC_EXIT_(stmt); } colinfo = resinfo->columns[icol - 1]; if (colinfo->column_cur_size < 0) { /* TODO check what should happen if pcbValue was NULL */ *pcbValue = SQL_NULL_DATA; } else { TDS_CHAR *src; int srclen; int nSybType; if (colinfo->column_text_sqlgetdatapos > 0 && colinfo->column_text_sqlgetdatapos >= colinfo->column_cur_size) ODBC_EXIT(stmt, SQL_NO_DATA); src = (TDS_CHAR *) colinfo->column_data; srclen = colinfo->column_cur_size; if (!is_variable_type(colinfo->column_type)) colinfo->column_text_sqlgetdatapos = 0; nSybType = tds_get_conversion_type(colinfo->on_server.column_type, colinfo->on_server.column_size); if (fCType == SQL_C_DEFAULT) fCType = odbc_sql_to_c_type_default(stmt->ird->records[icol - 1].sql_desc_concise_type); if (fCType == SQL_ARD_TYPE) { if (icol > stmt->ard->header.sql_desc_count) { odbc_errs_add(&stmt->errs, "07009", NULL); ODBC_EXIT_(stmt); } fCType = stmt->ard->records[icol - 1].sql_desc_concise_type; } assert(fCType); *pcbValue = odbc_tds2sql(stmt, colinfo, nSybType, src, srclen, fCType, (TDS_CHAR *) rgbValue, cbValueMax, NULL); if (*pcbValue == SQL_NULL_DATA) ODBC_EXIT(stmt, SQL_ERROR); if (is_variable_type(colinfo->column_type) && (fCType == SQL_C_CHAR || fCType == SQL_C_WCHAR || fCType == SQL_C_BINARY)) { /* avoid infinite SQL_SUCCESS on empty strings */ if (colinfo->column_text_sqlgetdatapos == 0 && cbValueMax > 0) ++colinfo->column_text_sqlgetdatapos; if (colinfo->column_text_sqlgetdatapos < colinfo->column_cur_size) { /* not all read ?? */ odbc_errs_add(&stmt->errs, "01004", "String data, right truncated"); ODBC_EXIT_(stmt); } } else { colinfo->column_text_sqlgetdatapos = colinfo->column_cur_size; if (is_fixed_type(nSybType) && (fCType == SQL_C_CHAR || fCType == SQL_C_WCHAR || fCType == SQL_C_BINARY) && cbValueMax < *pcbValue) { odbc_errs_add(&stmt->errs, "22003", NULL); ODBC_EXIT_(stmt); } } } ODBC_EXIT_(stmt); } SQLRETURN ODBC_PUBLIC ODBC_API SQLGetFunctions(SQLHDBC hdbc, SQLUSMALLINT fFunction, SQLUSMALLINT FAR * pfExists) { int i; ODBC_ENTER_HDBC; tdsdump_log(TDS_DBG_FUNC, "SQLGetFunctions: fFunction is %d\n", fFunction); switch (fFunction) { #if (ODBCVER >= 0x0300) case SQL_API_ODBC3_ALL_FUNCTIONS: for (i = 0; i < SQL_API_ODBC3_ALL_FUNCTIONS_SIZE; ++i) { pfExists[i] = 0; } /* * every api available are contained in a macro * all these macro begin with API followed by 2 letter * first letter mean pre ODBC 3 (_) or ODBC 3 (3) * second letter mean implemented (X) or unimplemented (_) * You should copy these macro 3 times... not very good * but works. Perhaps best method is build the bit array statically * and then use it but I don't know how to build it... */ #undef ODBC_ALL_API #undef ODBC_COLATTRIBUTE #if SQL_API_SQLCOLATTRIBUTE != SQL_API_SQLCOLATTRIBUTES #define ODBC_COLATTRIBUTE(s) s #else #define ODBC_COLATTRIBUTE(s) #endif #define ODBC_ALL_API \ API_X(SQL_API_SQLALLOCCONNECT);\ API_X(SQL_API_SQLALLOCENV);\ API3X(SQL_API_SQLALLOCHANDLE);\ API_X(SQL_API_SQLALLOCSTMT);\ API_X(SQL_API_SQLBINDCOL);\ API_X(SQL_API_SQLBINDPARAM);\ API_X(SQL_API_SQLBINDPARAMETER);\ API__(SQL_API_SQLBROWSECONNECT);\ API3_(SQL_API_SQLBULKOPERATIONS);\ API_X(SQL_API_SQLCANCEL);\ API3X(SQL_API_SQLCLOSECURSOR);\ ODBC_COLATTRIBUTE(API3X(SQL_API_SQLCOLATTRIBUTE);)\ API_X(SQL_API_SQLCOLATTRIBUTES);\ API_X(SQL_API_SQLCOLUMNPRIVILEGES);\ API_X(SQL_API_SQLCOLUMNS);\ API_X(SQL_API_SQLCONNECT);\ API3X(SQL_API_SQLCOPYDESC);\ API_X(SQL_API_SQLDESCRIBECOL);\ API__(SQL_API_SQLDESCRIBEPARAM);\ API_X(SQL_API_SQLDISCONNECT);\ API_X(SQL_API_SQLDRIVERCONNECT);\ API3X(SQL_API_SQLENDTRAN);\ API_X(SQL_API_SQLERROR);\ API_X(SQL_API_SQLEXECDIRECT);\ API_X(SQL_API_SQLEXECUTE);\ API_X(SQL_API_SQLEXTENDEDFETCH);\ API_X(SQL_API_SQLFETCH);\ API3X(SQL_API_SQLFETCHSCROLL);\ API_X(SQL_API_SQLFOREIGNKEYS);\ API_X(SQL_API_SQLFREECONNECT);\ API_X(SQL_API_SQLFREEENV);\ API3X(SQL_API_SQLFREEHANDLE);\ API_X(SQL_API_SQLFREESTMT);\ API3X(SQL_API_SQLGETCONNECTATTR);\ API_X(SQL_API_SQLGETCONNECTOPTION);\ API_X(SQL_API_SQLGETCURSORNAME);\ API_X(SQL_API_SQLGETDATA);\ API3X(SQL_API_SQLGETDESCFIELD);\ API3X(SQL_API_SQLGETDESCREC);\ API3X(SQL_API_SQLGETDIAGFIELD);\ API3X(SQL_API_SQLGETDIAGREC);\ API3X(SQL_API_SQLGETENVATTR);\ API_X(SQL_API_SQLGETFUNCTIONS);\ API_X(SQL_API_SQLGETINFO);\ API3X(SQL_API_SQLGETSTMTATTR);\ API_X(SQL_API_SQLGETSTMTOPTION);\ API_X(SQL_API_SQLGETTYPEINFO);\ API_X(SQL_API_SQLMORERESULTS);\ API_X(SQL_API_SQLNATIVESQL);\ API_X(SQL_API_SQLNUMPARAMS);\ API_X(SQL_API_SQLNUMRESULTCOLS);\ API_X(SQL_API_SQLPARAMDATA);\ API_X(SQL_API_SQLPARAMOPTIONS);\ API_X(SQL_API_SQLPREPARE);\ API_X(SQL_API_SQLPRIMARYKEYS);\ API_X(SQL_API_SQLPROCEDURECOLUMNS);\ API_X(SQL_API_SQLPROCEDURES);\ API_X(SQL_API_SQLPUTDATA);\ API_X(SQL_API_SQLROWCOUNT);\ API3X(SQL_API_SQLSETCONNECTATTR);\ API_X(SQL_API_SQLSETCONNECTOPTION);\ API_X(SQL_API_SQLSETCURSORNAME);\ API3X(SQL_API_SQLSETDESCFIELD);\ API3X(SQL_API_SQLSETDESCREC);\ API3X(SQL_API_SQLSETENVATTR);\ API_X(SQL_API_SQLSETPARAM);\ API_X(SQL_API_SQLSETPOS);\ API_X(SQL_API_SQLSETSCROLLOPTIONS);\ API3X(SQL_API_SQLSETSTMTATTR);\ API_X(SQL_API_SQLSETSTMTOPTION);\ API_X(SQL_API_SQLSPECIALCOLUMNS);\ API_X(SQL_API_SQLSTATISTICS);\ API_X(SQL_API_SQLTABLEPRIVILEGES);\ API_X(SQL_API_SQLTABLES);\ API_X(SQL_API_SQLTRANSACT); #define API_X(n) if (n >= 0 && n < (16*SQL_API_ODBC3_ALL_FUNCTIONS_SIZE)) pfExists[n/16] |= (1 << n%16); #define API__(n) #define API3X(n) if (n >= 0 && n < (16*SQL_API_ODBC3_ALL_FUNCTIONS_SIZE)) pfExists[n/16] |= (1 << n%16); #define API3_(n) ODBC_ALL_API #undef API_X #undef API__ #undef API3X #undef API3_ break; #endif case SQL_API_ALL_FUNCTIONS: tdsdump_log(TDS_DBG_FUNC, "SQLGetFunctions: " "fFunction is SQL_API_ALL_FUNCTIONS\n"); for (i = 0; i < 100; ++i) { pfExists[i] = SQL_FALSE; } #define API_X(n) if (n >= 0 && n < 100) pfExists[n] = SQL_TRUE; #define API__(n) #define API3X(n) #define API3_(n) ODBC_ALL_API #undef API_X #undef API__ #undef API3X #undef API3_ break; #define API_X(n) case n: #define API__(n) #if (ODBCVER >= 0x300) #define API3X(n) case n: #else #define API3X(n) #endif #define API3_(n) ODBC_ALL_API #undef API_X #undef API__ #undef API3X #undef API3_ *pfExists = SQL_TRUE; break; default: *pfExists = SQL_FALSE; break; } ODBC_EXIT(dbc, SQL_SUCCESS); #undef ODBC_ALL_API } static SQLRETURN _SQLGetInfo(TDS_DBC * dbc, SQLUSMALLINT fInfoType, SQLPOINTER rgbInfoValue, SQLSMALLINT cbInfoValueMax, SQLSMALLINT FAR * pcbInfoValue _WIDE) { const char *p = NULL; char buf[32]; TDSSOCKET *tds; int is_ms = -1; unsigned int smajor = 6; SQLUINTEGER mssql7plus_mask = 0; int out_len = -1; tdsdump_log(TDS_DBG_FUNC, "_SQLGetInfo(%p, %u, %p, %d, %p)\n", dbc, fInfoType, rgbInfoValue, cbInfoValueMax, pcbInfoValue); #define SIVAL out_len = sizeof(SQLSMALLINT), *((SQLSMALLINT *) rgbInfoValue) #define USIVAL out_len = sizeof(SQLUSMALLINT), *((SQLUSMALLINT *) rgbInfoValue) #define IVAL out_len = sizeof(SQLINTEGER), *((SQLINTEGER *) rgbInfoValue) #define UIVAL out_len = sizeof(SQLUINTEGER), *((SQLUINTEGER *) rgbInfoValue) #define ULVAL out_len = sizeof(SQLULEN), *((SQLULEN *) rgbInfoValue) if ((tds = dbc->tds_socket) != NULL) { is_ms = TDS_IS_MSSQL(tds); smajor = (tds->conn->product_version >> 24) & 0x7F; if (is_ms && smajor >= 7) mssql7plus_mask = ~((SQLUINTEGER) 0); } switch (fInfoType) { case SQL_ACCESSIBLE_PROCEDURES: case SQL_ACCESSIBLE_TABLES: p = "Y"; break; /* SQL_ACTIVE_CONNECTIONS renamed to SQL_MAX_DRIVER_CONNECTIONS */ #if (ODBCVER >= 0x0300) case SQL_ACTIVE_ENVIRONMENTS: UIVAL = 0; break; #endif /* ODBCVER >= 0x0300 */ #if (ODBCVER >= 0x0300) case SQL_AGGREGATE_FUNCTIONS: UIVAL = SQL_AF_ALL; break; case SQL_ALTER_DOMAIN: UIVAL = 0; break; #endif /* ODBCVER >= 0x0300 */ case SQL_ALTER_TABLE: UIVAL = SQL_AT_ADD_COLUMN | SQL_AT_ADD_COLUMN_DEFAULT | SQL_AT_ADD_COLUMN_SINGLE | SQL_AT_ADD_CONSTRAINT | SQL_AT_ADD_TABLE_CONSTRAINT | SQL_AT_CONSTRAINT_NAME_DEFINITION | SQL_AT_DROP_COLUMN_RESTRICT; break; #if (ODBCVER >= 0x0300) case SQL_ASYNC_MODE: /* TODO we hope so in a not-too-far future */ /* UIVAL = SQL_AM_STATEMENT; */ UIVAL = SQL_AM_NONE; break; case SQL_BATCH_ROW_COUNT: UIVAL = SQL_BRC_EXPLICIT; break; case SQL_BATCH_SUPPORT: UIVAL = SQL_BS_ROW_COUNT_EXPLICIT | SQL_BS_ROW_COUNT_PROC | SQL_BS_SELECT_EXPLICIT | SQL_BS_SELECT_PROC; break; #endif /* ODBCVER >= 0x0300 */ case SQL_BOOKMARK_PERSISTENCE: /* TODO ??? */ UIVAL = SQL_BP_DELETE | SQL_BP_SCROLL | SQL_BP_UPDATE; break; case SQL_CATALOG_LOCATION: SIVAL = SQL_CL_START; break; #if (ODBCVER >= 0x0300) case SQL_CATALOG_NAME: p = "Y"; break; #endif /* ODBCVER >= 0x0300 */ case SQL_CATALOG_NAME_SEPARATOR: p = "."; break; case SQL_CATALOG_TERM: p = "database"; break; case SQL_CATALOG_USAGE: UIVAL = SQL_CU_DML_STATEMENTS | SQL_CU_PROCEDURE_INVOCATION | SQL_CU_TABLE_DEFINITION; break; /* TODO */ #if 0 case SQL_COLLATION_SEQ: break; #endif case SQL_COLUMN_ALIAS: p = "Y"; break; case SQL_CONCAT_NULL_BEHAVIOR: if (is_ms == -1) return SQL_ERROR; /* TODO a bit more complicate for mssql2k.. */ SIVAL = (!is_ms || smajor < 7) ? SQL_CB_NON_NULL : SQL_CB_NULL; break; /* TODO SQL_CONVERT_BIGINT SQL_CONVERT_GUID SQL_CONVERT_DATE SQL_CONVERT_TIME */ /* For Sybase/MSSql6.x we return 0 cause NativeSql is not so implemented */ case SQL_CONVERT_BINARY: UIVAL = (SQL_CVT_CHAR | SQL_CVT_NUMERIC | SQL_CVT_DECIMAL | SQL_CVT_INTEGER | SQL_CVT_SMALLINT | SQL_CVT_VARCHAR | SQL_CVT_BINARY | SQL_CVT_VARBINARY | SQL_CVT_TINYINT | SQL_CVT_LONGVARBINARY | SQL_CVT_WCHAR | SQL_CVT_WVARCHAR) & mssql7plus_mask; break; case SQL_CONVERT_BIT: UIVAL = (SQL_CVT_CHAR | SQL_CVT_NUMERIC | SQL_CVT_DECIMAL | SQL_CVT_INTEGER | SQL_CVT_SMALLINT | SQL_CVT_FLOAT | SQL_CVT_REAL | SQL_CVT_VARCHAR | SQL_CVT_BINARY | SQL_CVT_VARBINARY | SQL_CVT_BIT | SQL_CVT_TINYINT | SQL_CVT_WCHAR | SQL_CVT_WVARCHAR) & mssql7plus_mask; break; case SQL_CONVERT_CHAR: UIVAL = (SQL_CVT_CHAR | SQL_CVT_NUMERIC | SQL_CVT_DECIMAL | SQL_CVT_INTEGER | SQL_CVT_SMALLINT | SQL_CVT_FLOAT | SQL_CVT_REAL | SQL_CVT_VARCHAR | SQL_CVT_LONGVARCHAR | SQL_CVT_BINARY | SQL_CVT_VARBINARY | SQL_CVT_BIT | SQL_CVT_TINYINT | SQL_CVT_TIMESTAMP | SQL_CVT_LONGVARBINARY | SQL_CVT_WCHAR | SQL_CVT_WLONGVARCHAR | SQL_CVT_WVARCHAR) & mssql7plus_mask; break; case SQL_CONVERT_DECIMAL: UIVAL = (SQL_CVT_CHAR | SQL_CVT_NUMERIC | SQL_CVT_DECIMAL | SQL_CVT_INTEGER | SQL_CVT_SMALLINT | SQL_CVT_FLOAT | SQL_CVT_REAL | SQL_CVT_VARCHAR | SQL_CVT_BINARY | SQL_CVT_VARBINARY | SQL_CVT_BIT | SQL_CVT_TINYINT | SQL_CVT_WCHAR | SQL_CVT_WVARCHAR) & mssql7plus_mask; break; case SQL_CONVERT_FLOAT: UIVAL = (SQL_CVT_CHAR | SQL_CVT_NUMERIC | SQL_CVT_DECIMAL | SQL_CVT_INTEGER | SQL_CVT_SMALLINT | SQL_CVT_FLOAT | SQL_CVT_REAL | SQL_CVT_VARCHAR | SQL_CVT_BIT | SQL_CVT_TINYINT | SQL_CVT_WCHAR | SQL_CVT_WVARCHAR) & mssql7plus_mask; break; case SQL_CONVERT_INTEGER: UIVAL = (SQL_CVT_CHAR | SQL_CVT_NUMERIC | SQL_CVT_DECIMAL | SQL_CVT_INTEGER | SQL_CVT_SMALLINT | SQL_CVT_FLOAT | SQL_CVT_REAL | SQL_CVT_VARCHAR | SQL_CVT_BINARY | SQL_CVT_VARBINARY | SQL_CVT_BIT | SQL_CVT_TINYINT | SQL_CVT_WCHAR | SQL_CVT_WVARCHAR) & mssql7plus_mask; break; case SQL_CONVERT_LONGVARCHAR: UIVAL = (SQL_CVT_CHAR | SQL_CVT_VARCHAR | SQL_CVT_LONGVARCHAR | SQL_CVT_WCHAR | SQL_CVT_WLONGVARCHAR | SQL_CVT_WVARCHAR) & mssql7plus_mask; break; case SQL_CONVERT_NUMERIC: UIVAL = (SQL_CVT_CHAR | SQL_CVT_NUMERIC | SQL_CVT_DECIMAL | SQL_CVT_INTEGER | SQL_CVT_SMALLINT | SQL_CVT_FLOAT | SQL_CVT_REAL | SQL_CVT_VARCHAR | SQL_CVT_BINARY | SQL_CVT_VARBINARY | SQL_CVT_BIT | SQL_CVT_TINYINT | SQL_CVT_WCHAR | SQL_CVT_WVARCHAR) & mssql7plus_mask; break; case SQL_CONVERT_REAL: UIVAL = (SQL_CVT_CHAR | SQL_CVT_NUMERIC | SQL_CVT_DECIMAL | SQL_CVT_INTEGER | SQL_CVT_SMALLINT | SQL_CVT_FLOAT | SQL_CVT_REAL | SQL_CVT_VARCHAR | SQL_CVT_BIT | SQL_CVT_TINYINT | SQL_CVT_WCHAR | SQL_CVT_WVARCHAR) & mssql7plus_mask; break; case SQL_CONVERT_SMALLINT: UIVAL = (SQL_CVT_CHAR | SQL_CVT_NUMERIC | SQL_CVT_DECIMAL | SQL_CVT_INTEGER | SQL_CVT_SMALLINT | SQL_CVT_FLOAT | SQL_CVT_REAL | SQL_CVT_VARCHAR | SQL_CVT_BINARY | SQL_CVT_VARBINARY | SQL_CVT_BIT | SQL_CVT_TINYINT | SQL_CVT_WCHAR | SQL_CVT_WVARCHAR) & mssql7plus_mask; break; case SQL_CONVERT_TIMESTAMP: UIVAL = (SQL_CVT_CHAR | SQL_CVT_VARCHAR | SQL_CVT_BINARY | SQL_CVT_VARBINARY | SQL_CVT_TIMESTAMP | SQL_CVT_WCHAR | SQL_CVT_WVARCHAR) & mssql7plus_mask; break; case SQL_CONVERT_TINYINT: UIVAL = (SQL_CVT_CHAR | SQL_CVT_NUMERIC | SQL_CVT_DECIMAL | SQL_CVT_INTEGER | SQL_CVT_SMALLINT | SQL_CVT_FLOAT | SQL_CVT_REAL | SQL_CVT_VARCHAR | SQL_CVT_BINARY | SQL_CVT_VARBINARY | SQL_CVT_BIT | SQL_CVT_TINYINT | SQL_CVT_WCHAR | SQL_CVT_WVARCHAR) & mssql7plus_mask; break; case SQL_CONVERT_VARBINARY: UIVAL = (SQL_CVT_CHAR | SQL_CVT_NUMERIC | SQL_CVT_DECIMAL | SQL_CVT_INTEGER | SQL_CVT_SMALLINT | SQL_CVT_VARCHAR | SQL_CVT_BINARY | SQL_CVT_VARBINARY | SQL_CVT_TINYINT | SQL_CVT_LONGVARBINARY | SQL_CVT_WCHAR | SQL_CVT_WVARCHAR) & mssql7plus_mask; break; case SQL_CONVERT_VARCHAR: UIVAL = (SQL_CVT_CHAR | SQL_CVT_NUMERIC | SQL_CVT_DECIMAL | SQL_CVT_INTEGER | SQL_CVT_SMALLINT | SQL_CVT_FLOAT | SQL_CVT_REAL | SQL_CVT_VARCHAR | SQL_CVT_LONGVARCHAR | SQL_CVT_BINARY | SQL_CVT_VARBINARY | SQL_CVT_BIT | SQL_CVT_TINYINT | SQL_CVT_TIMESTAMP | SQL_CVT_LONGVARBINARY | SQL_CVT_WCHAR | SQL_CVT_WLONGVARCHAR | SQL_CVT_WVARCHAR) & mssql7plus_mask; break; case SQL_CONVERT_LONGVARBINARY: UIVAL = (SQL_CVT_BINARY | SQL_CVT_LONGVARBINARY | SQL_CVT_VARBINARY) & mssql7plus_mask; break; case SQL_CONVERT_WLONGVARCHAR: UIVAL = (SQL_CVT_CHAR | SQL_CVT_VARCHAR | SQL_CVT_LONGVARCHAR | SQL_CVT_WCHAR | SQL_CVT_WLONGVARCHAR | SQL_CVT_WVARCHAR) & mssql7plus_mask; break; #if (ODBCVER >= 0x0300) case SQL_CONVERT_WCHAR: UIVAL = (SQL_CVT_CHAR | SQL_CVT_NUMERIC | SQL_CVT_DECIMAL | SQL_CVT_INTEGER | SQL_CVT_SMALLINT | SQL_CVT_FLOAT | SQL_CVT_REAL | SQL_CVT_VARCHAR | SQL_CVT_LONGVARCHAR | SQL_CVT_BINARY | SQL_CVT_VARBINARY | SQL_CVT_BIT | SQL_CVT_TINYINT | SQL_CVT_TIMESTAMP | SQL_CVT_LONGVARBINARY | SQL_CVT_WCHAR | SQL_CVT_WLONGVARCHAR | SQL_CVT_WVARCHAR) & mssql7plus_mask; break; case SQL_CONVERT_WVARCHAR: UIVAL = (SQL_CVT_CHAR | SQL_CVT_NUMERIC | SQL_CVT_DECIMAL | SQL_CVT_INTEGER | SQL_CVT_SMALLINT | SQL_CVT_FLOAT | SQL_CVT_REAL | SQL_CVT_VARCHAR | SQL_CVT_LONGVARCHAR | SQL_CVT_BINARY | SQL_CVT_VARBINARY | SQL_CVT_BIT | SQL_CVT_TINYINT | SQL_CVT_TIMESTAMP | SQL_CVT_LONGVARBINARY | SQL_CVT_WCHAR | SQL_CVT_WLONGVARCHAR | SQL_CVT_WVARCHAR) & mssql7plus_mask; break; #endif /* ODBCVER >= 0x0300 */ case SQL_CONVERT_FUNCTIONS: /* TODO no CAST for Sybase ?? */ UIVAL = SQL_FN_CVT_CONVERT | SQL_FN_CVT_CAST; break; #if (ODBCVER >= 0x0300) case SQL_CREATE_ASSERTION: case SQL_CREATE_CHARACTER_SET: case SQL_CREATE_COLLATION: case SQL_CREATE_DOMAIN: UIVAL = 0; break; case SQL_CREATE_SCHEMA: UIVAL = SQL_CS_AUTHORIZATION | SQL_CS_CREATE_SCHEMA; break; case SQL_CREATE_TABLE: UIVAL = SQL_CT_CREATE_TABLE; break; case SQL_CREATE_TRANSLATION: UIVAL = 0; break; case SQL_CREATE_VIEW: UIVAL = SQL_CV_CHECK_OPTION | SQL_CV_CREATE_VIEW; break; #endif /* ODBCVER >= 0x0300 */ case SQL_CORRELATION_NAME: USIVAL = SQL_CN_ANY; break; case SQL_CURSOR_COMMIT_BEHAVIOR: /* currently cursors are not supported however sql server close automaticly cursors on commit */ /* TODO cursors test what happen if rollback, cursors get properly deleted ?? */ USIVAL = SQL_CB_CLOSE; break; case SQL_CURSOR_ROLLBACK_BEHAVIOR: USIVAL = SQL_CB_CLOSE; break; case SQL_CURSOR_SENSITIVITY: UIVAL = SQL_SENSITIVE; break; case SQL_DATABASE_NAME: p = tds_dstr_cstr(&dbc->attr.current_catalog); break; case SQL_DATA_SOURCE_NAME: p = tds_dstr_cstr(&dbc->dsn); break; case SQL_DATA_SOURCE_READ_ONLY: /* * TODO: determine the right answer from connection * attribute SQL_ATTR_ACCESS_MODE */ p = "N"; /* false, writable */ break; #if (ODBCVER >= 0x0300) case SQL_DATETIME_LITERALS: /* TODO ok ?? */ UIVAL = 0; break; #endif /* ODBCVER >= 0x0300 */ case SQL_DBMS_NAME: p = tds ? tds->conn->product_name : NULL; break; case SQL_DBMS_VER: if (!dbc->tds_socket) return SQL_ERROR; odbc_rdbms_version(dbc->tds_socket, buf); p = buf; break; #if (ODBCVER >= 0x0300) case SQL_DDL_INDEX: UIVAL = 0; break; #endif /* ODBCVER >= 0x0300 */ case SQL_DEFAULT_TXN_ISOLATION: UIVAL = SQL_TXN_READ_COMMITTED; break; #if (ODBCVER >= 0x0300) case SQL_DESCRIBE_PARAMETER: /* TODO */ p = "N"; break; #endif /* ODBCVER >= 0x0300 */ #ifdef TDS_NO_DM case SQL_DRIVER_HDBC: ULVAL = (SQLULEN) dbc; break; case SQL_DRIVER_HENV: ULVAL = (SQLULEN) dbc->env; break; case SQL_DRIVER_HSTMT: ULVAL = (SQLULEN) dbc->current_statement; break; #endif case SQL_DRIVER_NAME: /* ODBC 2.0 */ p = "libtdsodbc.so"; break; case SQL_DRIVER_ODBC_VER: p = "03.50"; break; case SQL_DRIVER_VER: sprintf(buf, "%02d.%02d.%04d", TDS_VERSION_MAJOR, TDS_VERSION_MINOR, TDS_VERSION_SUBVERSION); p = buf; break; #if (ODBCVER >= 0x0300) case SQL_DROP_ASSERTION: case SQL_DROP_CHARACTER_SET: case SQL_DROP_COLLATION: case SQL_DROP_DOMAIN: case SQL_DROP_SCHEMA: UIVAL = 0; break; case SQL_DROP_TABLE: UIVAL = SQL_DT_DROP_TABLE; break; case SQL_DROP_TRANSLATION: UIVAL = 0; break; case SQL_DROP_VIEW: UIVAL = SQL_DV_DROP_VIEW; break; case SQL_DYNAMIC_CURSOR_ATTRIBUTES1: if (dbc->cursor_support) /* TODO cursor SQL_CA1_BULK_ADD SQL_CA1_POS_REFRESH SQL_CA1_SELECT_FOR_UPDATE */ UIVAL = SQL_CA1_ABSOLUTE | SQL_CA1_NEXT | SQL_CA1_RELATIVE | SQL_CA1_LOCK_NO_CHANGE | SQL_CA1_POS_DELETE | SQL_CA1_POS_POSITION | SQL_CA1_POS_UPDATE | SQL_CA1_POSITIONED_UPDATE | SQL_CA1_POSITIONED_DELETE; else UIVAL = 0; break; case SQL_DYNAMIC_CURSOR_ATTRIBUTES2: /* TODO cursors */ /* Cursors not supported yet */ /* * Should be SQL_CA2_LOCK_CONCURRENCY SQL_CA2_MAX_ROWS_CATALOG SQL_CA2_MAX_ROWS_DELETE * SQL_CA2_MAX_ROWS_INSERT SQL_CA2_MAX_ROWS_SELECT SQL_CA2_MAX_ROWS_UPDATE SQL_CA2_OPT_ROWVER_CONCURRENCY * SQL_CA2_OPT_VALUES_CONCURRENCY SQL_CA2_READ_ONLY_CONCURRENCY SQL_CA2_SENSITIVITY_ADDITIONS * SQL_CA2_SENSITIVITY_UPDATES SQL_CA2_SIMULATE_UNIQUE */ UIVAL = 0; break; #endif /* ODBCVER >= 0x0300 */ case SQL_EXPRESSIONS_IN_ORDERBY: p = "Y"; break; case SQL_FILE_USAGE: USIVAL = SQL_FILE_NOT_SUPPORTED; break; case SQL_FETCH_DIRECTION: if (dbc->cursor_support) /* TODO cursors SQL_FD_FETCH_BOOKMARK */ UIVAL = SQL_FD_FETCH_ABSOLUTE|SQL_FD_FETCH_FIRST|SQL_FD_FETCH_LAST|SQL_FD_FETCH_NEXT|SQL_FD_FETCH_PRIOR|SQL_FD_FETCH_RELATIVE; else UIVAL = 0; break; #if (ODBCVER >= 0x0300) case SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1: if (dbc->cursor_support) /* TODO cursors SQL_CA1_SELECT_FOR_UPDATE */ UIVAL = SQL_CA1_NEXT|SQL_CA1_POSITIONED_DELETE|SQL_CA1_POSITIONED_UPDATE; else UIVAL = 0; break; case SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2: /* TODO cursors */ /* Cursors not supported yet */ /* * Should be SQL_CA2_LOCK_CONCURRENCY SQL_CA2_MAX_ROWS_CATALOG SQL_CA2_MAX_ROWS_DELETE * SQL_CA2_MAX_ROWS_INSERT SQL_CA2_MAX_ROWS_SELECT SQL_CA2_MAX_ROWS_UPDATE SQL_CA2_OPT_ROWVER_CONCURRENCY * SQL_CA2_OPT_VALUES_CONCURRENCY SQL_CA2_READ_ONLY_CONCURRENCY */ UIVAL = 0; break; #endif /* ODBCVER >= 0x0300 */ case SQL_GETDATA_EXTENSIONS: /* TODO FreeTDS support more ?? */ UIVAL = SQL_GD_BLOCK; break; case SQL_GROUP_BY: USIVAL = SQL_GB_GROUP_BY_CONTAINS_SELECT; break; case SQL_IDENTIFIER_CASE: /* TODO configuration dependend */ USIVAL = SQL_IC_MIXED; break; case SQL_IDENTIFIER_QUOTE_CHAR: p = "\""; /* TODO workaround for Sybase, use SET QUOTED_IDENTIFIER ON and fix unwanted quote */ if (!is_ms) p = ""; break; #if (ODBCVER >= 0x0300) case SQL_INDEX_KEYWORDS: UIVAL = SQL_IK_ASC | SQL_IK_DESC; break; #endif /* ODBCVER >= 0x0300 */ case SQL_INFO_SCHEMA_VIEWS: /* TODO finish */ UIVAL = 0; break; case SQL_INSERT_STATEMENT: UIVAL = 0; break; /* renamed from SQL_ODBC_SQL_OPT_IEF */ case SQL_INTEGRITY: p = "Y"; break; case SQL_KEYSET_CURSOR_ATTRIBUTES1: case SQL_KEYSET_CURSOR_ATTRIBUTES2: /* TODO cursors */ UIVAL = 0; break; case SQL_KEYWORDS: /* TODO ok for Sybase ? */ p = "BREAK,BROWSE,BULK,CHECKPOINT,CLUSTERED," "COMMITTED,COMPUTE,CONFIRM,CONTROLROW,DATABASE," "DBCC,DISK,DISTRIBUTED,DUMMY,DUMP,ERRLVL," "ERROREXIT,EXIT,FILE,FILLFACTOR,FLOPPY,HOLDLOCK," "IDENTITY_INSERT,IDENTITYCOL,IF,KILL,LINENO," "LOAD,MIRROREXIT,NONCLUSTERED,OFF,OFFSETS,ONCE," "OVER,PERCENT,PERM,PERMANENT,PLAN,PRINT,PROC," "PROCESSEXIT,RAISERROR,READ,READTEXT,RECONFIGURE," "REPEATABLE,RETURN,ROWCOUNT,RULE,SAVE,SERIALIZABLE," "SETUSER,SHUTDOWN,STATISTICS,TAPE,TEMP,TEXTSIZE," "TRAN,TRIGGER,TRUNCATE,TSEQUEL,UNCOMMITTED," "UPDATETEXT,USE,WAITFOR,WHILE,WRITETEXT"; break; case SQL_LIKE_ESCAPE_CLAUSE: p = "Y"; break; case SQL_LOCK_TYPES: if (dbc->cursor_support) IVAL = SQL_LCK_NO_CHANGE; else IVAL = 0; break; #if (ODBCVER >= 0x0300) case SQL_MAX_ASYNC_CONCURRENT_STATEMENTS: UIVAL = 1; break; #endif /* ODBCVER >= 0x0300 */ /* TODO same limits for Sybase ? */ case SQL_MAX_BINARY_LITERAL_LEN: UIVAL = 131072; break; case SQL_MAX_CHAR_LITERAL_LEN: UIVAL = 131072; break; case SQL_MAX_CONCURRENT_ACTIVITIES: USIVAL = 1; break; case SQL_MAX_COLUMNS_IN_GROUP_BY: case SQL_MAX_COLUMNS_IN_INDEX: case SQL_MAX_COLUMNS_IN_ORDER_BY: /* TODO Sybase ? */ USIVAL = 16; break; case SQL_MAX_COLUMNS_IN_SELECT: /* TODO Sybase ? */ USIVAL = 4000; break; case SQL_MAX_COLUMNS_IN_TABLE: /* TODO Sybase ? */ USIVAL = 250; break; case SQL_MAX_DRIVER_CONNECTIONS: USIVAL = 0; break; case SQL_MAX_IDENTIFIER_LEN: if (is_ms == -1) return SQL_ERROR; USIVAL = (!is_ms || smajor < 7) ? 30 : 128; break; case SQL_MAX_INDEX_SIZE: UIVAL = 127; break; case SQL_MAX_PROCEDURE_NAME_LEN: if (is_ms == -1) return SQL_ERROR; /* TODO Sybase ? */ USIVAL = (is_ms && smajor >= 7) ? 134 : 36; break; case SQL_MAX_ROW_SIZE: if (is_ms == -1) return SQL_ERROR; /* TODO Sybase ? */ UIVAL = (is_ms && smajor >= 7) ? 8062 : 1962; break; case SQL_MAX_ROW_SIZE_INCLUDES_LONG: p = "N"; break; case SQL_MAX_STATEMENT_LEN: /* TODO Sybase ? */ UIVAL = 131072; break; case SQL_MAX_TABLES_IN_SELECT: /* TODO Sybase ? */ USIVAL = 16; break; case SQL_MAX_USER_NAME_LEN: /* TODO Sybase ? */ if (is_ms == -1) return SQL_ERROR; USIVAL = (is_ms && smajor >= 7) ? 128 : 30; break; case SQL_MAX_COLUMN_NAME_LEN: case SQL_MAX_CURSOR_NAME_LEN: case SQL_MAX_SCHEMA_NAME_LEN: case SQL_MAX_CATALOG_NAME_LEN: case SQL_MAX_TABLE_NAME_LEN: /* TODO Sybase ? */ if (is_ms == -1) return SQL_ERROR; USIVAL = (is_ms && smajor >= 7) ? 128 : 30; break; case SQL_MULT_RESULT_SETS: p = "Y"; break; case SQL_MULTIPLE_ACTIVE_TXN: p = "Y"; break; case SQL_NEED_LONG_DATA_LEN: /* current implementation do not require length, however future will, so is correct to return yes */ p = "Y"; break; case SQL_NON_NULLABLE_COLUMNS: USIVAL = SQL_NNC_NON_NULL; break; case SQL_NULL_COLLATION: USIVAL = SQL_NC_LOW; break; case SQL_NUMERIC_FUNCTIONS: UIVAL = (SQL_FN_NUM_ABS | SQL_FN_NUM_ACOS | SQL_FN_NUM_ASIN | SQL_FN_NUM_ATAN | SQL_FN_NUM_ATAN2 | SQL_FN_NUM_CEILING | SQL_FN_NUM_COS | SQL_FN_NUM_COT | SQL_FN_NUM_DEGREES | SQL_FN_NUM_EXP | SQL_FN_NUM_FLOOR | SQL_FN_NUM_LOG | SQL_FN_NUM_LOG10 | SQL_FN_NUM_MOD | SQL_FN_NUM_PI | SQL_FN_NUM_POWER | SQL_FN_NUM_RADIANS | SQL_FN_NUM_RAND | SQL_FN_NUM_ROUND | SQL_FN_NUM_SIGN | SQL_FN_NUM_SIN | SQL_FN_NUM_SQRT | SQL_FN_NUM_TAN) & mssql7plus_mask; break; case SQL_ODBC_API_CONFORMANCE: SIVAL = SQL_OAC_LEVEL2; break; #if (ODBCVER >= 0x0300) case SQL_ODBC_INTERFACE_CONFORMANCE: UIVAL = SQL_OAC_LEVEL2; break; #endif /* ODBCVER >= 0x0300 */ case SQL_ODBC_SAG_CLI_CONFORMANCE: SIVAL = SQL_OSCC_NOT_COMPLIANT; break; case SQL_ODBC_SQL_CONFORMANCE: SIVAL = SQL_OSC_CORE; break; #ifdef TDS_NO_DM case SQL_ODBC_VER: /* TODO check format ##.##.0000 */ p = VERSION; break; #endif #if (ODBCVER >= 0x0300) case SQL_OJ_CAPABILITIES: UIVAL = SQL_OJ_ALL_COMPARISON_OPS | SQL_OJ_FULL | SQL_OJ_INNER | SQL_OJ_LEFT | SQL_OJ_NESTED | SQL_OJ_NOT_ORDERED | SQL_OJ_RIGHT; break; #endif /* ODBCVER >= 0x0300 */ case SQL_ORDER_BY_COLUMNS_IN_SELECT: p = "N"; break; case SQL_OUTER_JOINS: p = "Y"; break; #if (ODBCVER >= 0x0300) case SQL_PARAM_ARRAY_ROW_COUNTS: UIVAL = SQL_PARC_BATCH; break; case SQL_PARAM_ARRAY_SELECTS: UIVAL = SQL_PAS_BATCH; break; #endif /* ODBCVER >= 0x0300 */ case SQL_POS_OPERATIONS: if (dbc->cursor_support) /* TODO cursors SQL_POS_ADD SQL_POS_REFRESH */ /* test REFRESH, ADD under mssql, under Sybase I don't know how to do it but dblib do */ IVAL = SQL_POS_DELETE | SQL_POS_POSITION | SQL_POS_UPDATE; else IVAL = 0; break; case SQL_POSITIONED_STATEMENTS: /* TODO cursors SQL_PS_SELECT_FOR_UPDATE */ IVAL = SQL_PS_POSITIONED_DELETE | SQL_PS_POSITIONED_UPDATE; break; case SQL_PROCEDURE_TERM: p = "stored procedure"; break; case SQL_PROCEDURES: p = "Y"; break; case SQL_QUOTED_IDENTIFIER_CASE: /* TODO usually insensitive */ USIVAL = SQL_IC_MIXED; break; case SQL_ROW_UPDATES: p = "N"; break; #if (ODBCVER >= 0x0300) case SQL_SCHEMA_TERM: p = "owner"; break; case SQL_SCHEMA_USAGE: UIVAL = SQL_OU_DML_STATEMENTS | SQL_OU_INDEX_DEFINITION | SQL_OU_PRIVILEGE_DEFINITION | SQL_OU_PROCEDURE_INVOCATION | SQL_OU_TABLE_DEFINITION; break; #endif /* ODBCVER >= 0x0300 */ case SQL_SCROLL_CONCURRENCY: if (dbc->cursor_support) /* TODO cursors test them, Sybase support all ? */ IVAL = SQL_SCCO_LOCK | SQL_SCCO_OPT_ROWVER | SQL_SCCO_OPT_VALUES | SQL_SCCO_READ_ONLY; else IVAL = SQL_SCCO_READ_ONLY; break; case SQL_SCROLL_OPTIONS: if (dbc->cursor_support) /* TODO cursors test them, Sybase support all ?? */ UIVAL = SQL_SO_DYNAMIC | SQL_SO_FORWARD_ONLY | SQL_SO_KEYSET_DRIVEN | SQL_SO_STATIC; else UIVAL = SQL_SO_FORWARD_ONLY | SQL_SO_STATIC; break; case SQL_SEARCH_PATTERN_ESCAPE: p = "\\"; break; case SQL_SERVER_NAME: p = dbc->tds_socket->conn->server; break; case SQL_SPECIAL_CHARACTERS: /* TODO others ?? */ p = "\'\"[]{}"; break; #if (ODBCVER >= 0x0300) case SQL_SQL_CONFORMANCE: UIVAL = SQL_SC_SQL92_ENTRY; break; case SQL_SQL92_DATETIME_FUNCTIONS: case SQL_SQL92_FOREIGN_KEY_DELETE_RULE: case SQL_SQL92_FOREIGN_KEY_UPDATE_RULE: UIVAL = 0; break; case SQL_SQL92_GRANT: UIVAL = SQL_SG_WITH_GRANT_OPTION; break; case SQL_SQL92_NUMERIC_VALUE_FUNCTIONS: UIVAL = 0; break; case SQL_SQL92_PREDICATES: /* TODO Sybase ?? */ UIVAL = SQL_SP_EXISTS | SQL_SP_ISNOTNULL | SQL_SP_ISNULL; break; case SQL_SQL92_RELATIONAL_JOIN_OPERATORS: /* TODO Sybase ?? */ UIVAL = SQL_SRJO_CROSS_JOIN | SQL_SRJO_FULL_OUTER_JOIN | SQL_SRJO_INNER_JOIN | SQL_SRJO_LEFT_OUTER_JOIN | SQL_SRJO_RIGHT_OUTER_JOIN | SQL_SRJO_UNION_JOIN; break; case SQL_SQL92_REVOKE: UIVAL = SQL_SR_GRANT_OPTION_FOR; break; case SQL_SQL92_ROW_VALUE_CONSTRUCTOR: UIVAL = SQL_SRVC_DEFAULT | SQL_SRVC_NULL | SQL_SRVC_ROW_SUBQUERY | SQL_SRVC_VALUE_EXPRESSION; break; case SQL_SQL92_STRING_FUNCTIONS: UIVAL = SQL_SSF_LOWER | SQL_SSF_UPPER; break; case SQL_SQL92_VALUE_EXPRESSIONS: /* TODO Sybase ? CAST supported ? */ UIVAL = SQL_SVE_CASE | SQL_SVE_CAST | SQL_SVE_COALESCE | SQL_SVE_NULLIF; break; case SQL_STANDARD_CLI_CONFORMANCE: UIVAL = SQL_SCC_ISO92_CLI; break; case SQL_STATIC_SENSITIVITY: IVAL = 0; break; case SQL_STATIC_CURSOR_ATTRIBUTES1: if (dbc->cursor_support) /* TODO cursors SQL_CA1_BOOKMARK SQL_CA1_BULK_FETCH_BY_BOOKMARK SQL_CA1_POS_REFRESH */ UIVAL = SQL_CA1_ABSOLUTE | SQL_CA1_LOCK_NO_CHANGE | SQL_CA1_NEXT | SQL_CA1_POS_POSITION | SQL_CA1_RELATIVE; else UIVAL = 0; break; case SQL_STATIC_CURSOR_ATTRIBUTES2: /* TODO cursors */ UIVAL = 0; break; #endif /* ODBCVER >= 0x0300 */ case SQL_STRING_FUNCTIONS: UIVAL = (SQL_FN_STR_ASCII | SQL_FN_STR_BIT_LENGTH | SQL_FN_STR_CHAR | SQL_FN_STR_CONCAT | SQL_FN_STR_DIFFERENCE | SQL_FN_STR_INSERT | SQL_FN_STR_LCASE | SQL_FN_STR_LEFT | SQL_FN_STR_LENGTH | SQL_FN_STR_LOCATE_2 | SQL_FN_STR_LTRIM | SQL_FN_STR_OCTET_LENGTH | SQL_FN_STR_REPEAT | SQL_FN_STR_RIGHT | SQL_FN_STR_RTRIM | SQL_FN_STR_SOUNDEX | SQL_FN_STR_SPACE | SQL_FN_STR_SUBSTRING | SQL_FN_STR_UCASE) & mssql7plus_mask; break; case SQL_SUBQUERIES: UIVAL = SQL_SQ_COMPARISON | SQL_SQ_CORRELATED_SUBQUERIES | SQL_SQ_EXISTS | SQL_SQ_IN | SQL_SQ_QUANTIFIED; break; case SQL_SYSTEM_FUNCTIONS: UIVAL = SQL_FN_SYS_DBNAME | SQL_FN_SYS_IFNULL | SQL_FN_SYS_USERNAME; break; case SQL_TABLE_TERM: p = "table"; break; case SQL_TIMEDATE_ADD_INTERVALS: UIVAL = (SQL_FN_TSI_DAY | SQL_FN_TSI_FRAC_SECOND | SQL_FN_TSI_HOUR | SQL_FN_TSI_MINUTE | SQL_FN_TSI_MONTH | SQL_FN_TSI_QUARTER | SQL_FN_TSI_SECOND | SQL_FN_TSI_WEEK | SQL_FN_TSI_YEAR) & mssql7plus_mask; break; case SQL_TIMEDATE_DIFF_INTERVALS: UIVAL = (SQL_FN_TSI_DAY | SQL_FN_TSI_FRAC_SECOND | SQL_FN_TSI_HOUR | SQL_FN_TSI_MINUTE | SQL_FN_TSI_MONTH | SQL_FN_TSI_QUARTER | SQL_FN_TSI_SECOND | SQL_FN_TSI_WEEK | SQL_FN_TSI_YEAR) & mssql7plus_mask; break; case SQL_TIMEDATE_FUNCTIONS: UIVAL = (SQL_FN_TD_CURDATE | SQL_FN_TD_CURRENT_DATE | SQL_FN_TD_CURRENT_TIME | SQL_FN_TD_CURRENT_TIMESTAMP | SQL_FN_TD_CURTIME | SQL_FN_TD_DAYNAME | SQL_FN_TD_DAYOFMONTH | SQL_FN_TD_DAYOFWEEK | SQL_FN_TD_DAYOFYEAR | SQL_FN_TD_EXTRACT | SQL_FN_TD_HOUR | SQL_FN_TD_MINUTE | SQL_FN_TD_MONTH | SQL_FN_TD_MONTHNAME | SQL_FN_TD_NOW | SQL_FN_TD_QUARTER | SQL_FN_TD_SECOND | SQL_FN_TD_TIMESTAMPADD | SQL_FN_TD_TIMESTAMPDIFF | SQL_FN_TD_WEEK | SQL_FN_TD_YEAR) & mssql7plus_mask; break; case SQL_TXN_CAPABLE: /* transaction for DML and DDL */ SIVAL = SQL_TC_ALL; break; case SQL_TXN_ISOLATION_OPTION: UIVAL = SQL_TXN_READ_COMMITTED | SQL_TXN_READ_UNCOMMITTED | SQL_TXN_REPEATABLE_READ | SQL_TXN_SERIALIZABLE; break; case SQL_UNION: UIVAL = SQL_U_UNION | SQL_U_UNION_ALL; break; /* TODO finish */ case SQL_USER_NAME: /* TODO this is not correct username */ /* p = tds_dstr_cstr(&dbc->tds_login->user_name); */ /* make OpenOffice happy :) */ p = ""; break; case SQL_XOPEN_CLI_YEAR: /* TODO check specifications */ p = "1995"; break; case SQL_INFO_FREETDS_TDS_VERSION: if (!dbc->tds_socket) return SQL_ERROR; UIVAL = TDS_MAJOR(dbc->tds_socket->conn) << 16 | TDS_MINOR(dbc->tds_socket->conn); break; default: odbc_log_unimplemented_type("SQLGetInfo", fInfoType); odbc_errs_add(&dbc->errs, "HY092", "Option not supported"); return SQL_ERROR; } /* char data */ if (p) { return odbc_set_string_oct(dbc, rgbInfoValue, cbInfoValueMax, pcbInfoValue, p, -1); } else { if (out_len > 0 && pcbInfoValue) *pcbInfoValue = out_len; } return SQL_SUCCESS; #undef SIVAL #undef USIVAL #undef IVAL #undef UIVAL } SQLRETURN ODBC_PUBLIC ODBC_API SQLGetInfo(SQLHDBC hdbc, SQLUSMALLINT fInfoType, SQLPOINTER rgbInfoValue, SQLSMALLINT cbInfoValueMax, SQLSMALLINT FAR * pcbInfoValue) { ODBC_ENTER_HDBC; tdsdump_log(TDS_DBG_FUNC, "SQLGetInfo(%p, %d, %p, %d, %p)\n", hdbc, fInfoType, rgbInfoValue, cbInfoValueMax, pcbInfoValue); ODBC_EXIT(dbc, _SQLGetInfo(dbc, fInfoType, rgbInfoValue, cbInfoValueMax, pcbInfoValue _wide0)); } #ifdef ENABLE_ODBC_WIDE SQLRETURN ODBC_PUBLIC ODBC_API SQLGetInfoW(SQLHDBC hdbc, SQLUSMALLINT fInfoType, SQLPOINTER rgbInfoValue, SQLSMALLINT cbInfoValueMax, SQLSMALLINT FAR * pcbInfoValue) { ODBC_ENTER_HDBC; tdsdump_log(TDS_DBG_FUNC, "SQLGetInfoW(%p, %d, %p, %d, %p)\n", hdbc, fInfoType, rgbInfoValue, cbInfoValueMax, pcbInfoValue); ODBC_EXIT(dbc, _SQLGetInfo(dbc, fInfoType, rgbInfoValue, cbInfoValueMax, pcbInfoValue, 1)); } #endif static void tds_ascii_strupr(char *s) { for (; *s; ++s) if ('a' <= *s && *s <= 'z') *s = *s & (~0x20); } static void odbc_upper_column_names(TDS_STMT * stmt) { #if ENABLE_EXTRA_CHECKS TDSRESULTINFO *resinfo; TDSSOCKET *tds; #endif int icol; TDS_DESC *ird; IRD_CHECK; #if ENABLE_EXTRA_CHECKS tds = stmt->dbc->tds_socket; if (!tds || !tds->current_results) return; resinfo = tds->current_results; for (icol = 0; icol < resinfo->num_cols; ++icol) { TDSCOLUMN *colinfo = resinfo->columns[icol]; char *p = tds_dstr_buf(&colinfo->column_name); unsigned n, len = tds_dstr_len(&colinfo->column_name); /* upper case */ /* TODO procedure */ for (n = 0; n < len; ++n, ++p) if ('a' <= *p && *p <= 'z') *p = *p & (~0x20); } #endif ird = stmt->ird; for (icol = ird->header.sql_desc_count; --icol >= 0;) { struct _drecord *drec = &ird->records[icol]; /* upper case */ tds_ascii_strupr(tds_dstr_buf(&drec->sql_desc_label)); tds_ascii_strupr(tds_dstr_buf(&drec->sql_desc_name)); } } /** * Change sql datatype to a specific version * \param sql_type sql data type to change (any type) * \param version ODBC version to change to, 2 for ODBC 2, 3 for ODBC 3, 0 swap */ static SQLSMALLINT odbc_swap_datetime_sql_type(SQLSMALLINT sql_type, int version) { switch (sql_type) { case SQL_TYPE_TIMESTAMP: if (version != 3) sql_type = SQL_TIMESTAMP; break; case SQL_TIMESTAMP: if (version != 2) sql_type = SQL_TYPE_TIMESTAMP; break; case SQL_TYPE_DATE: if (version != 3) sql_type = SQL_DATE; break; case SQL_DATE: if (version != 2) sql_type = SQL_TYPE_DATE; break; case SQL_TYPE_TIME: if (version != 3) sql_type = SQL_TIME; break; case SQL_TIME: if (version != 2) sql_type = SQL_TYPE_TIME; break; } return sql_type; } SQLRETURN ODBC_PUBLIC ODBC_API SQLGetTypeInfo(SQLHSTMT hstmt, SQLSMALLINT fSqlType) { SQLRETURN res; TDSSOCKET *tds; TDS_INT result_type; TDS_INT compute_id; int varchar_pos = -1, n; static const char sql_templ_default[] = "sp_datatype_info %d"; const char *sql_templ = sql_templ_default; char sql[sizeof(sql_templ_default) + 36]; int odbc3; ODBC_ENTER_HSTMT; tdsdump_log(TDS_DBG_FUNC, "SQLGetTypeInfo(%p, %d)\n", hstmt, fSqlType); tds = stmt->dbc->tds_socket; odbc3 = (stmt->dbc->env->attr.odbc_version == SQL_OV_ODBC3); if (IS_TDS73_PLUS(tds->conn)) sql_templ = "sp_datatype_info_100 %d"; else if (IS_TDS72_PLUS(tds->conn)) sql_templ = "sp_datatype_info_90 %d"; /* For MSSQL6.5 and Sybase 11.9 sp_datatype_info work */ /* TODO what about early Sybase products ? */ /* TODO Does Sybase return all ODBC3 columns? Add them if not */ /* TODO ODBC3 convert type to ODBC version 2 (date) */ if (odbc3) { if (TDS_IS_SYBASE(tds)) { sprintf(sql, sql_templ, odbc_swap_datetime_sql_type(fSqlType, 0)); stmt->special_row = ODBC_SPECIAL_GETTYPEINFO; } else { sprintf(sql, sql_templ, fSqlType); strcat(sql, ",3"); } } else { /* MS ODBC translate SQL_TIMESTAMP to SQL_TYPE_TIMESTAMP even for ODBC 2 apps * other DM just pass value straight. * Convert always to version 2 to make version 2 datatype works with all DMs */ sprintf(sql, sql_templ, odbc_swap_datetime_sql_type(fSqlType, 2)); } if (SQL_SUCCESS != odbc_set_stmt_query(stmt, (ODBC_CHAR*) sql, strlen(sql) _wide0)) ODBC_EXIT(stmt, SQL_ERROR); redo: res = _SQLExecute(stmt); odbc_upper_column_names(stmt); if (odbc3) { odbc_col_setname(stmt, 3, "COLUMN_SIZE"); odbc_col_setname(stmt, 11, "FIXED_PREC_SCALE"); odbc_col_setname(stmt, 12, "AUTO_UNIQUE_VALUE"); } /* workaround for a mispelled column name in Sybase */ if (TDS_IS_SYBASE(stmt->dbc->tds_socket) && !odbc3) odbc_col_setname(stmt, 3, "PRECISION"); if (TDS_IS_MSSQL(stmt->dbc->tds_socket) || fSqlType != SQL_VARCHAR || res != SQL_SUCCESS) ODBC_EXIT(stmt, res); /* * Sybase return first nvarchar for char... and without length !!! * Some program use first entry so we discard all entry before varchar */ n = 0; while (tds->current_results) { TDSRESULTINFO *resinfo; TDSCOLUMN *colinfo; char *name; /* if next is varchar leave next for SQLFetch */ if (n == (varchar_pos - 1)) break; switch (tds_process_tokens(stmt->dbc->tds_socket, &result_type, &compute_id, TDS_STOPAT_ROWFMT|TDS_RETURN_ROW)) { case TDS_SUCCESS: if (result_type == TDS_ROW_RESULT) break; case TDS_NO_MORE_RESULTS: /* discard other tokens */ tds_process_simple_query(tds); if (n >= varchar_pos && varchar_pos > 0) goto redo; break; case TDS_CANCELLED: odbc_errs_add(&stmt->errs, "HY008", NULL); res = SQL_ERROR; break; } if (!tds->current_results) break; ++n; resinfo = tds->current_results; colinfo = resinfo->columns[0]; name = (char *) colinfo->column_data; if (is_blob_col(colinfo)) name = (char*) ((TDSBLOB *) name)->textvalue; /* skip nvarchar and sysname */ if (colinfo->column_cur_size == 7 && memcmp("varchar", name, 7) == 0) { varchar_pos = n; } } ODBC_EXIT(stmt, res); } #ifdef ENABLE_ODBC_WIDE SQLRETURN ODBC_PUBLIC ODBC_API SQLGetTypeInfoW(SQLHSTMT hstmt, SQLSMALLINT fSqlType) { return SQLGetTypeInfo(hstmt, fSqlType); } #endif static SQLRETURN _SQLParamData(SQLHSTMT hstmt, SQLPOINTER FAR * prgbValue) { ODBC_ENTER_HSTMT; tdsdump_log(TDS_DBG_FUNC, "SQLParamData(%p, %p) [param_num %d, param_data_called = %d]\n", hstmt, prgbValue, stmt->param_num, stmt->param_data_called); if (stmt->params && stmt->param_num <= stmt->param_count) { SQLRETURN res; if (stmt->param_num <= 0 || stmt->param_num > stmt->apd->header.sql_desc_count) { tdsdump_log(TDS_DBG_FUNC, "SQLParamData: logic_error: parameter out of bounds: 0 <= %d < %d\n", stmt->param_num, stmt->apd->header.sql_desc_count); ODBC_EXIT(stmt, SQL_ERROR); } /* * TODO compute output value with this formula: * Bound Address + Binding Offset + ((Row Number - 1) x Element Size) * (see SQLParamData documentation) * This is needed for updates using SQLBulkOperation (not currently supported) */ if (!stmt->param_data_called) { stmt->param_data_called = 1; *prgbValue = stmt->apd->records[stmt->param_num - 1].sql_desc_data_ptr; ODBC_EXIT(stmt, SQL_NEED_DATA); } ++stmt->param_num; switch (res = parse_prepared_query(stmt, 1)) { case SQL_NEED_DATA: *prgbValue = stmt->apd->records[stmt->param_num - 1].sql_desc_data_ptr; ODBC_EXIT(stmt, SQL_NEED_DATA); case SQL_SUCCESS: ODBC_EXIT(stmt, _SQLExecute(stmt)); } ODBC_EXIT(stmt, res); } odbc_errs_add(&stmt->errs, "HY010", NULL); ODBC_EXIT_(stmt); } SQLRETURN ODBC_PUBLIC ODBC_API SQLParamData(SQLHSTMT hstmt, SQLPOINTER FAR * prgbValue) { ODBC_PRRET_BUF; SQLRETURN ret = _SQLParamData(hstmt, prgbValue); tdsdump_log(TDS_DBG_FUNC, "SQLParamData returns %s\n", odbc_prret(ret)); return ret; } SQLRETURN ODBC_PUBLIC ODBC_API SQLPutData(SQLHSTMT hstmt, SQLPOINTER rgbValue, SQLLEN cbValue) { ODBC_PRRET_BUF; ODBC_ENTER_HSTMT; tdsdump_log(TDS_DBG_FUNC, "SQLPutData(%p, %p, %i)\n", hstmt, rgbValue, (int)cbValue); if (stmt->is_prepared_query || stmt->prepared_query_is_rpc) { SQLRETURN ret; const TDSCOLUMN *curcol = stmt->params->columns[stmt->param_num - (stmt->prepared_query_is_func ? 2 : 1)]; /* TODO do some more tests before setting this flag */ stmt->param_data_called = 1; ret = continue_parse_prepared_query(stmt, rgbValue, cbValue); tdsdump_log(TDS_DBG_FUNC, "SQLPutData returns %s, %d bytes left\n", odbc_prret(ret), curcol->column_size - curcol->column_cur_size); ODBC_EXIT(stmt, ret); } odbc_errs_add(&stmt->errs, "HY010", NULL); ODBC_EXIT_(stmt); } ODBC_FUNC(SQLSetConnectAttr, (P(SQLHDBC,hdbc), P(SQLINTEGER,Attribute), P(SQLPOINTER,ValuePtr), P(SQLINTEGER,StringLength) WIDE)) { SQLULEN u_value = (SQLULEN) (TDS_INTPTR) ValuePtr; ODBC_ENTER_HDBC; tdsdump_log(TDS_DBG_FUNC, "_SQLSetConnectAttr(%p, %d, %p, %d)\n", hdbc, (int)Attribute, ValuePtr, (int)StringLength); switch (Attribute) { case SQL_ATTR_AUTOCOMMIT: /* spinellia@acm.org */ change_autocommit(dbc, u_value); break; case SQL_ATTR_CONNECTION_TIMEOUT: dbc->attr.connection_timeout = u_value; break; case SQL_ATTR_ACCESS_MODE: dbc->attr.access_mode = u_value; break; case SQL_ATTR_CURRENT_CATALOG: if (!IS_VALID_LEN(StringLength)) { odbc_errs_add(&dbc->errs, "HY090", NULL); break; } { DSTR s = DSTR_INITIALIZER; if (!odbc_dstr_copy_oct(dbc, &s, StringLength, (ODBC_CHAR*) ValuePtr)) { odbc_errs_add(&dbc->errs, "HY001", NULL); break; } change_database(dbc, tds_dstr_cstr(&s), tds_dstr_len(&s)); tds_dstr_free(&s); } break; case SQL_ATTR_CURSOR_TYPE: if (dbc->cursor_support) dbc->attr.cursor_type = u_value; break; case SQL_ATTR_LOGIN_TIMEOUT: dbc->attr.login_timeout = u_value; break; case SQL_ATTR_ODBC_CURSORS: /* TODO cursors */ dbc->attr.odbc_cursors = u_value; break; case SQL_ATTR_PACKET_SIZE: dbc->attr.packet_size = u_value; break; case SQL_ATTR_QUIET_MODE: dbc->attr.quite_mode = (SQLHWND) (TDS_INTPTR) ValuePtr; break; #ifdef TDS_NO_DM case SQL_ATTR_TRACE: dbc->attr.trace = u_value; break; case SQL_ATTR_TRACEFILE: if (!IS_VALID_LEN(StringLength)) { odbc_errs_add(&dbc->errs, "HY090", NULL); break; } if (!odbc_dstr_copy(dbc, &dbc->attr.tracefile, StringLength, (ODBC_CHAR *) ValuePtr)) odbc_errs_add(&dbc->errs, "HY001", NULL); break; #endif case SQL_ATTR_TXN_ISOLATION: if (u_value != dbc->attr.txn_isolation) { if (change_txn(dbc, u_value) == SQL_SUCCESS) dbc->attr.txn_isolation = u_value; } break; case SQL_COPT_SS_MARS_ENABLED: dbc->attr.mars_enabled = u_value; break; case SQL_ATTR_TRANSLATE_LIB: case SQL_ATTR_TRANSLATE_OPTION: odbc_errs_add(&dbc->errs, "HYC00", NULL); break; case SQL_COPT_SS_OLDPWD: if (!IS_VALID_LEN(StringLength)) { odbc_errs_add(&dbc->errs, "HY090", NULL); break; } if (!odbc_dstr_copy(dbc, &dbc->oldpwd, StringLength, (ODBC_CHAR *) ValuePtr)) odbc_errs_add(&dbc->errs, "HY001", NULL); else dbc->use_oldpwd = 1; break; case SQL_COPT_SS_BCP: dbc->attr.bulk_enabled = u_value; break; case SQL_COPT_TDSODBC_IMPL_BCP_INITA: if (!ValuePtr) odbc_errs_add(&dbc->errs, "HY009", NULL); else { const struct tdsodbc_impl_bcp_init_params *params = (const struct tdsodbc_impl_bcp_init_params*)ValuePtr; odbc_bcp_init(dbc, (const ODBC_CHAR *) params->tblname, (const ODBC_CHAR *) params->hfile, (const ODBC_CHAR *) params->errfile, params->direction _wide0); } break; #ifdef ENABLE_ODBC_WIDE case SQL_COPT_TDSODBC_IMPL_BCP_INITW: if (!ValuePtr) odbc_errs_add(&dbc->errs, "HY009", NULL); else { const struct tdsodbc_impl_bcp_init_params *params = (const struct tdsodbc_impl_bcp_init_params*)ValuePtr; odbc_bcp_init(dbc, (const ODBC_CHAR *) params->tblname, (const ODBC_CHAR *) params->hfile, (const ODBC_CHAR *) params->errfile, params->direction, 1); } break; #endif case SQL_COPT_TDSODBC_IMPL_BCP_CONTROL: if (!ValuePtr) odbc_errs_add(&dbc->errs, "HY009", NULL); else { const struct tdsodbc_impl_bcp_control_params *params = (const struct tdsodbc_impl_bcp_control_params*)ValuePtr; odbc_bcp_control(dbc, params->field, params->value); } break; case SQL_COPT_TDSODBC_IMPL_BCP_COLPTR: if (!ValuePtr) odbc_errs_add(&dbc->errs, "HY009", NULL); else { const struct tdsodbc_impl_bcp_colptr_params *params = (const struct tdsodbc_impl_bcp_colptr_params*)ValuePtr; odbc_bcp_colptr(dbc, params->colptr, params->table_column); } break; case SQL_COPT_TDSODBC_IMPL_BCP_SENDROW: if (ValuePtr) odbc_errs_add(&dbc->errs, "HY000", NULL); else odbc_bcp_sendrow(dbc); break; case SQL_COPT_TDSODBC_IMPL_BCP_BATCH: if (!ValuePtr) odbc_errs_add(&dbc->errs, "HY009", NULL); else { struct tdsodbc_impl_bcp_batch_params *params = (struct tdsodbc_impl_bcp_batch_params*)ValuePtr; params->rows = odbc_bcp_batch(dbc); } break; case SQL_COPT_TDSODBC_IMPL_BCP_DONE: if (!ValuePtr) odbc_errs_add(&dbc->errs, "HY009", NULL); else { struct tdsodbc_impl_bcp_done_params *params = (struct tdsodbc_impl_bcp_done_params*)ValuePtr; params->rows = odbc_bcp_done(dbc); } break; case SQL_COPT_TDSODBC_IMPL_BCP_BIND: if (!ValuePtr) odbc_errs_add(&dbc->errs, "HY009", NULL); else { const struct tdsodbc_impl_bcp_bind_params *params = (const struct tdsodbc_impl_bcp_bind_params*)ValuePtr; odbc_bcp_bind(dbc, params->varaddr, params->prefixlen, params->varlen, params->terminator, params->termlen, params->vartype, params->table_column); } break; default: odbc_errs_add(&dbc->errs, "HY092", NULL); break; } ODBC_EXIT_(dbc); } SQLRETURN ODBC_PUBLIC ODBC_API SQLSetConnectOption(SQLHDBC hdbc, SQLUSMALLINT fOption, SQLULEN vParam) { tdsdump_log(TDS_DBG_FUNC, "SQLSetConnectOption(%p, %d, %u)\n", hdbc, fOption, (unsigned)vParam); /* XXX: Lost precision */ return _SQLSetConnectAttr(hdbc, (SQLINTEGER) fOption, (SQLPOINTER) (TDS_INTPTR) vParam, SQL_NTS _wide0); } #ifdef ENABLE_ODBC_WIDE SQLRETURN ODBC_PUBLIC ODBC_API SQLSetConnectOptionW(SQLHDBC hdbc, SQLUSMALLINT fOption, SQLULEN vParam) { tdsdump_log(TDS_DBG_FUNC, "SQLSetConnectOptionW(%p, %d, %u)\n", hdbc, fOption, (unsigned)vParam); /* XXX: Lost precision */ return _SQLSetConnectAttr(hdbc, (SQLINTEGER) fOption, (SQLPOINTER) (TDS_INTPTR) vParam, SQL_NTS, 1); } #endif static SQLRETURN _SQLSetStmtAttr(SQLHSTMT hstmt, SQLINTEGER Attribute, SQLPOINTER ValuePtr, SQLINTEGER StringLength WIDE) { SQLULEN ui = (SQLULEN) (TDS_INTPTR) ValuePtr; SQLUSMALLINT *usip = (SQLUSMALLINT *) ValuePtr; SQLLEN *lp = (SQLLEN *) ValuePtr; SQLULEN *ulp = (SQLULEN *) ValuePtr; ODBC_ENTER_HSTMT; tdsdump_log(TDS_DBG_FUNC, "_SQLSetStmtAttr(%p, %d, %p, %d)\n", hstmt, (int)Attribute, ValuePtr, (int)StringLength); /* TODO - error checking and real functionality :-) */ /* TODO some setting set also other attribute, see documentation */ switch (Attribute) { /* TODO check SQLFreeHandle on descriptor. Is possible to free an associated descriptor ? */ case SQL_ATTR_APP_PARAM_DESC: case SQL_ATTR_APP_ROW_DESC: { TDS_DESC *orig; TDS_DESC **curr; TDS_DESC *val = (TDS_DESC *) ValuePtr; if (Attribute == SQL_ATTR_APP_PARAM_DESC) { orig = stmt->orig_apd; curr = &stmt->apd; } else { orig = stmt->orig_ard; curr = &stmt->ard; } /* if ValuePtr is NULL or original descriptor set original */ if (!val || val == orig) { *curr = orig; break; } /* must be allocated by user, not implicit ones */ if (val->header.sql_desc_alloc_type != SQL_DESC_ALLOC_USER) { odbc_errs_add(&stmt->errs, "HY017", NULL); break; } /* TODO check HDESC (not associated, from DBC HY024) */ *curr = val; } break; case SQL_ATTR_ASYNC_ENABLE: if (stmt->attr.async_enable != ui) { odbc_errs_add(&stmt->errs, "HYC00", NULL); break; } stmt->attr.async_enable = ui; break; case SQL_ATTR_CONCURRENCY: if (stmt->attr.concurrency != ui && !stmt->dbc->cursor_support) { odbc_errs_add(&stmt->errs, "01S02", NULL); break; } if (stmt->cursor) { odbc_errs_add(&stmt->errs, "24000", NULL); break; } switch (ui) { case SQL_CONCUR_READ_ONLY: stmt->attr.cursor_sensitivity = SQL_INSENSITIVE; break; case SQL_CONCUR_LOCK: case SQL_CONCUR_ROWVER: case SQL_CONCUR_VALUES: stmt->attr.cursor_sensitivity = SQL_SENSITIVE; break; default: odbc_errs_add(&stmt->errs, "HY092", NULL); ODBC_EXIT_(stmt); } stmt->attr.concurrency = ui; break; case SQL_ATTR_CURSOR_SCROLLABLE: if (stmt->attr.cursor_scrollable != ui && !stmt->dbc->cursor_support) { odbc_errs_add(&stmt->errs, "HYC00", NULL); break; } switch (ui) { case SQL_SCROLLABLE: stmt->attr.cursor_type = SQL_CURSOR_KEYSET_DRIVEN; break; case SQL_NONSCROLLABLE: stmt->attr.cursor_type = SQL_CURSOR_FORWARD_ONLY; break; default: odbc_errs_add(&stmt->errs, "HY092", NULL); ODBC_EXIT_(stmt); } stmt->attr.cursor_scrollable = ui; break; case SQL_ATTR_CURSOR_SENSITIVITY: /* don't change anything */ if (ui == SQL_UNSPECIFIED) break; if (stmt->attr.cursor_sensitivity != ui && !stmt->dbc->cursor_support) { odbc_errs_add(&stmt->errs, "HYC00", NULL); break; } switch (ui) { case SQL_INSENSITIVE: stmt->attr.concurrency = SQL_CONCUR_READ_ONLY; stmt->attr.cursor_type = SQL_CURSOR_STATIC; break; case SQL_SENSITIVE: stmt->attr.concurrency = SQL_CONCUR_ROWVER; break; } stmt->attr.cursor_sensitivity = ui; break; case SQL_ATTR_CURSOR_TYPE: if (stmt->attr.cursor_type != ui && !stmt->dbc->cursor_support) { odbc_errs_add(&stmt->errs, "01S02", NULL); break; } if (stmt->cursor) { odbc_errs_add(&stmt->errs, "24000", NULL); break; } switch (ui) { case SQL_CURSOR_DYNAMIC: case SQL_CURSOR_KEYSET_DRIVEN: if (stmt->attr.concurrency != SQL_CONCUR_READ_ONLY) stmt->attr.cursor_sensitivity = SQL_SENSITIVE; stmt->attr.cursor_scrollable = SQL_SCROLLABLE; break; case SQL_CURSOR_STATIC: if (stmt->attr.concurrency != SQL_CONCUR_READ_ONLY) stmt->attr.cursor_sensitivity = SQL_SENSITIVE; else stmt->attr.cursor_sensitivity = SQL_INSENSITIVE; stmt->attr.cursor_scrollable = SQL_SCROLLABLE; break; case SQL_CURSOR_FORWARD_ONLY: stmt->attr.cursor_scrollable = SQL_NONSCROLLABLE; break; default: odbc_errs_add(&stmt->errs, "HY092", NULL); ODBC_EXIT_(stmt); } stmt->attr.cursor_type = ui; break; case SQL_ATTR_ENABLE_AUTO_IPD: if (stmt->attr.enable_auto_ipd != ui) { odbc_errs_add(&stmt->errs, "HYC00", NULL); break; } stmt->attr.enable_auto_ipd = ui; break; case SQL_ATTR_FETCH_BOOKMARK_PTR: stmt->attr.fetch_bookmark_ptr = ValuePtr; break; case SQL_ATTR_IMP_ROW_DESC: case SQL_ATTR_IMP_PARAM_DESC: odbc_errs_add(&stmt->errs, "HY017", NULL); break; /* TODO what's is this ??? */ case SQL_ATTR_KEYSET_SIZE: stmt->attr.keyset_size = ui; break; /* TODO max length of data returned. Use SQL TEXTSIZE or just truncate ?? */ case SQL_ATTR_MAX_LENGTH: if (stmt->attr.max_length != ui) { odbc_errs_add(&stmt->errs, "01S02", NULL); break; } stmt->attr.max_length = ui; break; /* TODO max row returned. Use SET ROWCOUNT */ case SQL_ATTR_MAX_ROWS: if (stmt->attr.max_rows != ui) { odbc_errs_add(&stmt->errs, "01S02", NULL); break; } stmt->attr.max_rows = ui; break; case SQL_ATTR_METADATA_ID: stmt->attr.metadata_id = ui; break; /* TODO use it !!! */ case SQL_ATTR_NOSCAN: stmt->attr.noscan = ui; break; case SQL_ATTR_PARAM_BIND_OFFSET_PTR: stmt->apd->header.sql_desc_bind_offset_ptr = lp; break; case SQL_ATTR_PARAM_BIND_TYPE: stmt->apd->header.sql_desc_bind_type = ui; break; case SQL_ATTR_PARAM_OPERATION_PTR: stmt->apd->header.sql_desc_array_status_ptr = usip; break; case SQL_ATTR_PARAM_STATUS_PTR: stmt->ipd->header.sql_desc_array_status_ptr = usip; break; case SQL_ATTR_PARAMS_PROCESSED_PTR: stmt->ipd->header.sql_desc_rows_processed_ptr = ulp; break; /* allow to exec procedure multiple time */ case SQL_ATTR_PARAMSET_SIZE: stmt->apd->header.sql_desc_array_size = ui; break; case SQL_ATTR_QUERY_TIMEOUT: stmt->attr.query_timeout = ui; break; /* retrieve data after positioning the cursor */ case SQL_ATTR_RETRIEVE_DATA: /* TODO cursors */ if (stmt->attr.retrieve_data != ui) { odbc_errs_add(&stmt->errs, "01S02", NULL); break; } stmt->attr.retrieve_data = ui; break; case SQL_ATTR_ROW_ARRAY_SIZE: stmt->ard->header.sql_desc_array_size = ui; break; case SQL_ATTR_ROW_BIND_OFFSET_PTR: /* TODO test what happen with column-wise and row-wise bindings and SQLGetData */ stmt->ard->header.sql_desc_bind_offset_ptr = lp; break; #if SQL_BIND_TYPE != SQL_ATTR_ROW_BIND_TYPE case SQL_BIND_TYPE: /* although this is ODBC2 we must support this attribute */ #endif case SQL_ATTR_ROW_BIND_TYPE: stmt->ard->header.sql_desc_bind_type = ui; break; case SQL_ATTR_ROW_NUMBER: odbc_errs_add(&stmt->errs, "HY092", NULL); break; case SQL_ATTR_ROW_OPERATION_PTR: stmt->ard->header.sql_desc_array_status_ptr = usip; break; case SQL_ATTR_ROW_STATUS_PTR: stmt->ird->header.sql_desc_array_status_ptr = usip; break; case SQL_ATTR_ROWS_FETCHED_PTR: stmt->ird->header.sql_desc_rows_processed_ptr = ulp; break; case SQL_ATTR_SIMULATE_CURSOR: /* TODO cursors */ if (stmt->cursor) { odbc_errs_add(&stmt->errs, "24000", NULL); break; } if (stmt->attr.simulate_cursor != ui) { odbc_errs_add(&stmt->errs, "01S02", NULL); break; } stmt->attr.simulate_cursor = ui; break; case SQL_ATTR_USE_BOOKMARKS: if (stmt->cursor) { odbc_errs_add(&stmt->errs, "24000", NULL); break; } stmt->attr.use_bookmarks = ui; break; case SQL_ROWSET_SIZE: /* although this is ODBC2 we must support this attribute */ if (((TDS_INTPTR) ValuePtr) < 1) { odbc_errs_add(&stmt->errs, "HY024", NULL); break; } stmt->sql_rowset_size = ui; break; case SQL_SOPT_SS_QUERYNOTIFICATION_TIMEOUT: if (ui < 1) { odbc_errs_add(&stmt->errs, "HY024", NULL); break; } stmt->attr.qn_timeout = ui; break; case SQL_SOPT_SS_QUERYNOTIFICATION_MSGTEXT: if (!IS_VALID_LEN(StringLength)) { odbc_errs_add(&stmt->errs, "HY090", NULL); break; } if (!odbc_dstr_copy_oct(stmt->dbc, &stmt->attr.qn_msgtext, StringLength, (ODBC_CHAR*) ValuePtr)) { odbc_errs_add(&stmt->errs, "HY001", NULL); break; } break; case SQL_SOPT_SS_QUERYNOTIFICATION_OPTIONS: if (!IS_VALID_LEN(StringLength)) { odbc_errs_add(&stmt->errs, "HY090", NULL); break; } if (!odbc_dstr_copy_oct(stmt->dbc, &stmt->attr.qn_options, StringLength, (ODBC_CHAR*) ValuePtr)) { odbc_errs_add(&stmt->errs, "HY001", NULL); break; } break; default: odbc_errs_add(&stmt->errs, "HY092", NULL); break; } ODBC_EXIT_(stmt); } #if (ODBCVER >= 0x0300) SQLRETURN ODBC_PUBLIC ODBC_API SQLSetStmtAttr(SQLHSTMT hstmt, SQLINTEGER Attribute, SQLPOINTER ValuePtr, SQLINTEGER StringLength) { tdsdump_log(TDS_DBG_FUNC, "SQLSetStmtAttr(%p, %d, %p, %d)\n", hstmt, (int)Attribute, ValuePtr, (int)StringLength); return _SQLSetStmtAttr(hstmt, Attribute, ValuePtr, StringLength _wide0); } #ifdef ENABLE_ODBC_WIDE SQLRETURN ODBC_PUBLIC ODBC_API SQLSetStmtAttrW(SQLHSTMT hstmt, SQLINTEGER Attribute, SQLPOINTER ValuePtr, SQLINTEGER StringLength) { tdsdump_log(TDS_DBG_FUNC, "SQLSetStmtAttr(%p, %d, %p, %d)\n", hstmt, (int)Attribute, ValuePtr, (int)StringLength); return _SQLSetStmtAttr(hstmt, Attribute, ValuePtr, StringLength, 1); } #endif #endif SQLRETURN ODBC_PUBLIC ODBC_API SQLSetStmtOption(SQLHSTMT hstmt, SQLUSMALLINT fOption, SQLULEN vParam) { tdsdump_log(TDS_DBG_FUNC, "SQLSetStmtOption(%p, %u, %u)\n", hstmt, fOption, (unsigned)vParam); /* XXX: Lost precision */ return _SQLSetStmtAttr(hstmt, (SQLINTEGER) fOption, (SQLPOINTER) (TDS_INTPTR) vParam, SQL_NTS _wide0); } ODBC_FUNC(SQLSpecialColumns, (P(SQLHSTMT,hstmt), P(SQLUSMALLINT,fColType), PCHARIN(CatalogName,SQLSMALLINT), PCHARIN(SchemaName,SQLSMALLINT), PCHARIN(TableName,SQLSMALLINT), P(SQLUSMALLINT,fScope), P(SQLUSMALLINT,fNullable) WIDE)) { int retcode; char nullable, scope, col_type; ODBC_ENTER_HSTMT; tdsdump_log(TDS_DBG_FUNC, "SQLSpecialColumns(%p, %d, %p, %d, %p, %d, %p, %d, %d, %d)\n", hstmt, fColType, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName, fScope, fNullable); #ifdef TDS_NO_DM /* Check column type */ if (fColType != SQL_BEST_ROWID && fColType != SQL_ROWVER) { odbc_errs_add(&stmt->errs, "HY097", NULL); ODBC_EXIT_(stmt); } /* check our buffer lengths */ if (!IS_VALID_LEN(cbCatalogName) || !IS_VALID_LEN(cbSchemaName) || !IS_VALID_LEN(cbTableName)) { odbc_errs_add(&stmt->errs, "HY090", NULL); ODBC_EXIT_(stmt); } /* Check nullable */ if (fNullable != SQL_NO_NULLS && fNullable != SQL_NULLABLE) { odbc_errs_add(&stmt->errs, "HY099", NULL); ODBC_EXIT_(stmt); } if (!odbc_get_string_size(cbTableName, szTableName _wide)) { odbc_errs_add(&stmt->errs, "HY009", "SQLSpecialColumns: The table name parameter is required"); ODBC_EXIT_(stmt); } switch (fScope) { case SQL_SCOPE_CURROW: case SQL_SCOPE_TRANSACTION: case SQL_SCOPE_SESSION: break; default: odbc_errs_add(&stmt->errs, "HY098", NULL); ODBC_EXIT_(stmt); } #endif if (fNullable == SQL_NO_NULLS) nullable = 'O'; else nullable = 'U'; if (fScope == SQL_SCOPE_CURROW) scope = 'C'; else scope = 'T'; if (fColType == SQL_BEST_ROWID) col_type = 'R'; else col_type = 'V'; retcode = odbc_stat_execute(stmt _wide, "sp_special_columns", TDS_IS_MSSQL(stmt->dbc->tds_socket) ? 7 : 4, "O", szTableName, cbTableName, "O", szSchemaName, cbSchemaName, "O@qualifier", szCatalogName, cbCatalogName, "!@col_type", &col_type, 1, "!@scope", &scope, 1, "!@nullable", &nullable, 1, "V@ODBCVer", (char*) NULL, 0); if (SQL_SUCCEEDED(retcode) && stmt->dbc->env->attr.odbc_version == SQL_OV_ODBC3) { odbc_col_setname(stmt, 5, "COLUMN_SIZE"); odbc_col_setname(stmt, 6, "BUFFER_LENGTH"); odbc_col_setname(stmt, 7, "DECIMAL_DIGITS"); if (TDS_IS_SYBASE(stmt->dbc->tds_socket)) stmt->special_row = ODBC_SPECIAL_SPECIALCOLUMNS; } ODBC_EXIT_(stmt); } ODBC_FUNC(SQLStatistics, (P(SQLHSTMT,hstmt), PCHARIN(CatalogName,SQLSMALLINT), PCHARIN(SchemaName,SQLSMALLINT), PCHARIN(TableName,SQLSMALLINT), P(SQLUSMALLINT,fUnique), P(SQLUSMALLINT,fAccuracy) WIDE)) { int retcode; char unique, accuracy; ODBC_ENTER_HSTMT; tdsdump_log(TDS_DBG_FUNC, "SQLStatistics(%p, %p, %d, %p, %d, %p, %d, %d, %d)\n", hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName, fUnique, fAccuracy); #ifdef TDS_NO_DM /* check our buffer lengths */ if (!IS_VALID_LEN(cbCatalogName) || !IS_VALID_LEN(cbSchemaName) || !IS_VALID_LEN(cbTableName)) { odbc_errs_add(&stmt->errs, "HY090", NULL); ODBC_EXIT_(stmt); } /* check our uniqueness value */ if (fUnique != SQL_INDEX_UNIQUE && fUnique != SQL_INDEX_ALL) { odbc_errs_add(&stmt->errs, "HY100", NULL); ODBC_EXIT_(stmt); } /* check our accuracy value */ if (fAccuracy != SQL_QUICK && fAccuracy != SQL_ENSURE) { odbc_errs_add(&stmt->errs, "HY101", NULL); ODBC_EXIT_(stmt); } if (!odbc_get_string_size(cbTableName, szTableName _wide)) { odbc_errs_add(&stmt->errs, "HY009", NULL); ODBC_EXIT_(stmt); } #endif if (fAccuracy == SQL_ENSURE) accuracy = 'E'; else accuracy = 'Q'; if (fUnique == SQL_INDEX_UNIQUE) unique = 'Y'; else unique = 'N'; retcode = odbc_stat_execute(stmt _wide, "sp_statistics", TDS_IS_MSSQL(stmt->dbc->tds_socket) ? 5 : 4, "O@table_qualifier", szCatalogName, cbCatalogName, "O@table_owner", szSchemaName, cbSchemaName, "O@table_name", szTableName, cbTableName, "!@is_unique", &unique, 1, "!@accuracy", &accuracy, 1); if (SQL_SUCCEEDED(retcode) && stmt->dbc->env->attr.odbc_version == SQL_OV_ODBC3) { odbc_col_setname(stmt, 1, "TABLE_CAT"); odbc_col_setname(stmt, 2, "TABLE_SCHEM"); odbc_col_setname(stmt, 8, "ORDINAL_POSITION"); odbc_col_setname(stmt, 10, "ASC_OR_DESC"); } ODBC_EXIT_(stmt); } ODBC_FUNC(SQLTables, (P(SQLHSTMT,hstmt), PCHARIN(CatalogName,SQLSMALLINT), PCHARIN(SchemaName,SQLSMALLINT), PCHARIN(TableName,SQLSMALLINT), PCHARIN(TableType,SQLSMALLINT) WIDE)) { int retcode; const char *proc = NULL; int wildcards; TDSSOCKET *tds; DSTR schema_name = DSTR_INITIALIZER; DSTR catalog_name = DSTR_INITIALIZER; DSTR table_name = DSTR_INITIALIZER; DSTR table_type = DSTR_INITIALIZER; ODBC_ENTER_HSTMT; tdsdump_log(TDS_DBG_FUNC, "SQLTables(%p, %p, %d, %p, %d, %p, %d, %p, %d)\n", hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName, szTableType, cbTableType); tds = stmt->dbc->tds_socket; if (!odbc_dstr_copy(stmt->dbc, &catalog_name, cbCatalogName, szCatalogName) || !odbc_dstr_copy(stmt->dbc, &schema_name, cbSchemaName, szSchemaName) || !odbc_dstr_copy(stmt->dbc, &table_name, cbTableName, szTableName) || !odbc_dstr_copy(stmt->dbc, &table_type, cbTableType, szTableType)) goto memory_error; if (cbTableName == SQL_NTS) cbTableName = tds_dstr_len(&table_name); if (cbSchemaName == SQL_NTS) cbSchemaName = tds_dstr_len(&schema_name); /* support wildcards on catalog (only odbc 3) */ wildcards = 0; if (stmt->dbc->env->attr.odbc_version == SQL_OV_ODBC3 && stmt->dbc->attr.metadata_id == SQL_FALSE && (strchr(tds_dstr_cstr(&catalog_name), '%') || strchr(tds_dstr_cstr(&catalog_name), '_'))) wildcards = 1; proc = "sp_tables"; if (!tds_dstr_isempty(&catalog_name)) { if (wildcards) { /* if catalog specified and wildcards use sp_tableswc under mssql2k */ if (TDS_IS_MSSQL(tds) && tds->conn->product_version >= TDS_MS_VER(8,0,0)) { proc = "sp_tableswc"; if (tds_dstr_isempty(&schema_name)) if (!tds_dstr_copy(&schema_name, "%")) goto memory_error; } /* * TODO support wildcards on catalog even for Sybase * first execute a select name from master..sysdatabases where name like catalog quoted * build a db1..sp_tables args db2..sp_tables args ... query * collapse results in a single recordset (how??) */ } else { /* if catalog specified and not wildcards use catatog on name (catalog..sp_tables) */ proc = "..sp_tables"; } } /* fix type if needed quoting it */ if (!tds_dstr_isempty(&table_type)) { int to_fix = 0; int elements = 0; const char *p = tds_dstr_cstr(&table_type); const char *const end = p + tds_dstr_len(&table_type); for (;;) { const char *begin = p; p = (const char*) memchr(p, ',', end - p); if (!p) p = end; ++elements; if ((p - begin) < 2 || begin[0] != '\'' || p[-1] != '\'') to_fix = 1; if (p >= end) break; ++p; } /* fix it */ tdsdump_log(TDS_DBG_INFO1, "to_fix %d elements %d\n", to_fix, elements); if (to_fix) { char *dst, *type; tdsdump_log(TDS_DBG_INFO1, "fixing type elements\n"); type = tds_new(char, tds_dstr_len(&table_type) + elements * 2 + 3); if (!type) goto memory_error; p = tds_dstr_cstr(&table_type); dst = type; for (;;) { const char *begin = p; p = (const char*) memchr(p, ',', end - p); if (!p) p = end; if ((p - begin) < 2 || begin[0] != '\'' || p[-1] != '\'') { *dst++ = '\''; memcpy(dst, begin, p - begin); dst += p - begin; *dst++ = '\''; } else { memcpy(dst, begin, p - begin); dst += p - begin; } if (p >= end) break; *dst++ = *p++; } *dst = 0; if (!tds_dstr_set(&table_type, type)) { free(type); goto memory_error; } } } /* special case for catalog list */ if (strcmp(tds_dstr_cstr(&catalog_name), "%") == 0 && cbTableName <= 0 && cbSchemaName <= 0) { retcode = odbc_stat_execute(stmt _wide, "sp_tables", 3, "$!P@table_name", "", 0, "$!P@table_owner", "", 0, "!P@table_qualifier", "%", 1); } else { retcode = odbc_stat_execute(stmt _wide, proc, 4, "!P@table_name", tds_dstr_cstr(&table_name), tds_dstr_len(&table_name), "!P@table_owner", tds_dstr_cstr(&schema_name), tds_dstr_len(&schema_name), "!P@table_qualifier", tds_dstr_cstr(&catalog_name), tds_dstr_len(&catalog_name), "!@table_type", tds_dstr_cstr(&table_type), tds_dstr_len(&table_type)); } tds_dstr_free(&schema_name); tds_dstr_free(&catalog_name); tds_dstr_free(&table_name); tds_dstr_free(&table_type); if (SQL_SUCCEEDED(retcode) && stmt->dbc->env->attr.odbc_version == SQL_OV_ODBC3) { odbc_col_setname(stmt, 1, "TABLE_CAT"); odbc_col_setname(stmt, 2, "TABLE_SCHEM"); } ODBC_EXIT_(stmt); memory_error: tds_dstr_free(&schema_name); tds_dstr_free(&catalog_name); tds_dstr_free(&table_name); tds_dstr_free(&table_type); odbc_errs_add(&stmt->errs, "HY001", NULL); ODBC_EXIT_(stmt); } /** * Log a useful message about unimplemented options * Defying belief, Microsoft defines mutually exclusive options that * some ODBC implementations #define as duplicate values (meaning, of course, * that they couldn't be implemented in the same function because they're * indistinguishable. * * Those duplicates are commented out below. */ static void odbc_log_unimplemented_type(const char function_name[], int fType) { const char *name, *category; switch (fType) { #ifdef SQL_ALTER_SCHEMA case SQL_ALTER_SCHEMA: name = "SQL_ALTER_SCHEMA"; category = "Supported SQL"; break; #endif #ifdef SQL_ANSI_SQL_DATETIME_LITERALS case SQL_ANSI_SQL_DATETIME_LITERALS: name = "SQL_ANSI_SQL_DATETIME_LITERALS"; category = "Supported SQL"; break; #endif case SQL_COLLATION_SEQ: name = "SQL_COLLATION_SEQ"; category = "Data Source Information"; break; case SQL_CONVERT_BIGINT: name = "SQL_CONVERT_BIGINT"; category = "Conversion Information"; break; case SQL_CONVERT_DATE: name = "SQL_CONVERT_DATE"; category = "Conversion Information"; break; case SQL_CONVERT_DOUBLE: name = "SQL_CONVERT_DOUBLE"; category = "Conversion Information"; break; case SQL_CONVERT_INTERVAL_DAY_TIME: name = "SQL_CONVERT_INTERVAL_DAY_TIME"; category = "Conversion Information"; break; case SQL_CONVERT_INTERVAL_YEAR_MONTH: name = "SQL_CONVERT_INTERVAL_YEAR_MONTH"; category = "Conversion Information"; break; case SQL_DM_VER: name = "SQL_DM_VER"; category = "Added for ODBC 3.x"; break; case SQL_DRIVER_HDESC: name = "SQL_DRIVER_HDESC"; category = "Driver Information"; break; case SQL_DRIVER_HLIB: name = "SQL_DRIVER_HLIB"; category = "Driver Information"; break; #ifdef SQL_ODBC_STANDARD_CLI_CONFORMANCE case SQL_ODBC_STANDARD_CLI_CONFORMANCE: name = "SQL_ODBC_STANDARD_CLI_CONFORMANCE"; category = "Driver Information"; break; #endif case SQL_USER_NAME: name = "SQL_USER_NAME"; category = "Data Source Information"; break; /* TODO extension SQL_INFO_SS_NETLIB_NAME ?? */ default: name = "unknown"; category = "unknown"; break; } tdsdump_log(TDS_DBG_INFO1, "not implemented: %s: option/type %d(%s) [category %s]\n", function_name, fType, name, category); return; } static int odbc_quote_metadata(TDS_DBC * dbc, char type, char *dest, DSTR * dstr) { int unquote = 0; char prev, buf[1200], *dst; const char *s = tds_dstr_cstr(dstr); int len = tds_dstr_len(dstr); /* limit string/id lengths */ if (len > 384) len = 384; if (!type || (type == 'O' && dbc->attr.metadata_id == SQL_FALSE)) { if (dest) memcpy(dest, s, len); return len; } /* where we can have ID or PV */ assert(type == 'P' || (type == 'O' && dbc->attr.metadata_id != SQL_FALSE)); /* ID ? */ if (dbc->attr.metadata_id != SQL_FALSE) { /* strip leading and trailing spaces */ while (len > 0 && *s == ' ') ++s, --len; while (len > 0 && s[len - 1] == ' ') --len; /* unquote if necessary */ if (len > 2 && *s == '\"' && s[len - 1] == '\"') { ++s, len -= 2; unquote = 1; } } if (!dest) dest = buf; dst = dest; /* * handle patterns * "'" -> "''" (normal string quoting) * * if metadata_id is FALSE * "\_" -> "[_]" * "\%" -> "[%]" * "[" -> "[[]" * * if metadata_id is TRUE * "\"\"" -> "\"" (if unquote id) * "_" -> "[_]" * "%" -> "[%]" * "[" -> "[[]" */ prev = 0; for (; --len >= 0; ++s) { switch (*s) { case '\"': if (unquote && prev == '\"') { prev = 0; /* avoid "\"\"\"" -> "\"" */ --dst; continue; } break; case '_': case '%': if (dbc->attr.metadata_id == SQL_FALSE) { if (prev != '\\') break; --dst; } case '[': if (type != 'P') break; /* quote search string */ *dst++ = '['; *dst++ = *s; *dst++ = ']'; prev = 0; continue; } *dst++ = prev = *s; } return dst - dest; } static TDSPARAMINFO* odbc_add_char_param(TDSSOCKET *tds, TDSPARAMINFO *params, const char *name, const char *value, size_t len) { TDSCOLUMN *col; params = tds_alloc_param_result(params); if (!params) return NULL; col = params->columns[params->num_cols-1]; if (!tds_dstr_copy(&col->column_name, name)) return NULL; tds_set_param_type(tds->conn, col, IS_TDS7_PLUS(tds->conn) ? XSYBNVARCHAR : SYBVARCHAR); col->column_size = len; if (!tds_alloc_param_data(col)) return NULL; memcpy(col->column_data, value, len); col->column_cur_size = len; return params; } static TDSPARAMINFO* odbc_add_int_param(TDSSOCKET *tds, TDSPARAMINFO *params, const char *name, int value) { TDSCOLUMN *col; params = tds_alloc_param_result(params); if (!params) return NULL; col = params->columns[params->num_cols-1]; if (!tds_dstr_copy(&col->column_name, name)) return NULL; tds_set_param_type(tds->conn, col, SYBINT4); if (!tds_alloc_param_data(col)) return NULL; *((TDS_INT*) col->column_data) = value; col->column_cur_size = sizeof(TDS_INT); return params; } static SQLRETURN odbc_stat_execute(TDS_STMT * stmt _WIDE, const char *begin, int nparams, ...) { int i, len, param_qualifier = -1; char *proc = NULL, *p; SQLRETURN retcode; va_list marker; DSTR qualifier = DSTR_INITIALIZER, value = DSTR_INITIALIZER; TDSPARAMINFO *params; /* read all params and calc len required */ va_start(marker, nparams); len = strlen(begin) + 3; params = tds_alloc_results(0); if (!params) goto mem_error; for (i = 0; i < nparams; ++i) { int param_len; bool convert = true; bool add_always = false; DSTR *out; const char *name; char type; p = va_arg(marker, char *); for (; ; ++p) { switch (*p) { case '$': add_always = true; continue; case '!': convert = 0; continue; case 'V': /* ODBC version */ case 'O': /* ordinary arguments */ case 'P': /* pattern value arguments */ type = *p++; break; default: type = 0; /* ordinary type */ break; } break; } name = p; p = va_arg(marker, char *); param_len = va_arg(marker, int); if (type == 'V') { int ver = (stmt->dbc->env->attr.odbc_version == SQL_OV_ODBC3) ? 3: 2; if (!odbc_add_int_param(stmt->dbc->tds_socket, params, name, ver)) goto mem_error; continue; } #ifdef ENABLE_ODBC_WIDE if (!convert) out = tds_dstr_copyn(&value, p, param_len); else out = odbc_dstr_copy(stmt->dbc, &value, param_len, (ODBC_CHAR *) p); #else out = odbc_dstr_copy(stmt->dbc, &value, param_len, (ODBC_CHAR *) p); #endif if (!out) goto mem_error; if (add_always || !tds_dstr_isempty(&value)) { char buf[1200]; int l; l = odbc_quote_metadata(stmt->dbc, type, buf, &value); if (!odbc_add_char_param(stmt->dbc->tds_socket, params, name, buf, l)) goto mem_error; if (begin[0] == '.' && strstr(name, "qualifier")) { if (!tds_dstr_dup(&qualifier, &value)) goto mem_error; len += tds_quote_id(stmt->dbc->tds_socket, NULL, tds_dstr_cstr(&qualifier), tds_dstr_len(&qualifier)); param_qualifier = i; } } } tds_dstr_free(&value); /* proc is neither mb or wide, is always utf encoded */ retcode = odbc_set_stmt_query(stmt, (ODBC_CHAR *) "-", 1 _wide0); if (retcode != SQL_SUCCESS) goto error; stmt->prepared_query_is_rpc = 1; /* set params */ tds_free_param_results(stmt->params); stmt->param_count = params->num_cols; stmt->param_num = 1 + stmt->param_count; stmt->params = params; params = NULL; /* allocate space for string */ if (!tds_dstr_alloc(&stmt->query, len)) goto mem_error; proc = tds_dstr_buf(&stmt->query); /* build query string */ p = proc; if (param_qualifier >= 0) p += tds_quote_id(stmt->dbc->tds_socket, p, tds_dstr_cstr(&qualifier), tds_dstr_len(&qualifier)); tds_dstr_free(&qualifier); strcpy(p, begin); p += strlen(begin); tds_dstr_setlen(&stmt->query, p - proc); assert(p - proc + 1 <= len); /* execute it */ retcode = _SQLExecute(stmt); if (SQL_SUCCEEDED(retcode)) odbc_upper_column_names(stmt); va_end(marker); ODBC_RETURN(stmt, retcode); mem_error: odbc_errs_add(&stmt->errs, "HY001", NULL); error: tds_dstr_free(&value); tds_dstr_free(&qualifier); tds_free_results(params); va_end(marker); return SQL_ERROR; } static SQLRETURN odbc_free_dynamic(TDS_STMT * stmt) { TDSSOCKET *tds; if (!stmt->dyn) return TDS_SUCCESS; tds = stmt->dbc->tds_socket; if (!tds_needs_unprepare(tds->conn, stmt->dyn)) { tds_release_dynamic(&stmt->dyn); return SQL_SUCCESS; } if (odbc_lock_statement(stmt)) { if (TDS_SUCCEED(tds_submit_unprepare(stmt->tds, stmt->dyn)) && TDS_SUCCEED(tds_process_simple_query(stmt->tds))) { odbc_unlock_statement(stmt); tds_release_dynamic(&stmt->dyn); return SQL_SUCCESS; } } if (TDS_SUCCEED(tds_deferred_unprepare(tds->conn, stmt->dyn))) { tds_release_dynamic(&stmt->dyn); return SQL_SUCCESS; } ODBC_SAFE_ERROR(stmt); return SQL_ERROR; } /** * Close server cursors */ static SQLRETURN odbc_free_cursor(TDS_STMT * stmt) { TDSCURSOR *cursor = stmt->cursor; TDSSOCKET *tds; if (!cursor) return SQL_SUCCESS; /* if possible deallocate now */ if (odbc_lock_statement(stmt)) { tds = stmt->tds; cursor->status.dealloc = TDS_CURSOR_STATE_REQUESTED; if (TDS_SUCCEED(tds_cursor_close(tds, cursor))) { if (TDS_SUCCEED(tds_process_simple_query(tds))) { /* TODO check error */ tds_cursor_dealloc(tds, cursor); tds_release_cursor(&stmt->cursor); return SQL_SUCCESS; } } } tds = stmt->dbc->tds_socket; if (TDS_SUCCEED(tds_deferred_cursor_dealloc(tds->conn, cursor))) { tds_release_cursor(&stmt->cursor); return SQL_SUCCESS; } ODBC_SAFE_ERROR(stmt); return SQL_ERROR; } SQLRETURN ODBC_PUBLIC ODBC_API SQLSetScrollOptions(SQLHSTMT hstmt, SQLUSMALLINT fConcurrency, SQLLEN crowKeyset, SQLUSMALLINT crowRowset) { SQLUSMALLINT info; SQLUINTEGER value, check; SQLUINTEGER cursor_type; ODBC_ENTER_HSTMT; tdsdump_log(TDS_DBG_FUNC, "SQLSetScrollOptions(%p, %u, %ld, %u)\n", hstmt, fConcurrency, (long int) crowKeyset, crowRowset); if (!stmt->dbc->cursor_support) { odbc_errs_add(&stmt->errs, "HYC00", NULL); ODBC_EXIT_(stmt); } if (stmt->cursor) { odbc_errs_add(&stmt->errs, "24000", NULL); ODBC_EXIT_(stmt); } switch (crowKeyset) { case SQL_SCROLL_FORWARD_ONLY: info = SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2; cursor_type = SQL_CURSOR_FORWARD_ONLY; break; case SQL_SCROLL_STATIC: info = SQL_STATIC_CURSOR_ATTRIBUTES2; cursor_type = SQL_CURSOR_STATIC; break; case SQL_SCROLL_KEYSET_DRIVEN: info = SQL_KEYSET_CURSOR_ATTRIBUTES2; cursor_type = SQL_CURSOR_KEYSET_DRIVEN; break; case SQL_SCROLL_DYNAMIC: info = SQL_DYNAMIC_CURSOR_ATTRIBUTES2; cursor_type = SQL_CURSOR_DYNAMIC; break; default: if (crowKeyset > crowRowset) { info = SQL_KEYSET_CURSOR_ATTRIBUTES2; cursor_type = SQL_CURSOR_KEYSET_DRIVEN; break; } odbc_errs_add(&stmt->errs, "HY107", NULL); ODBC_EXIT_(stmt); } switch (fConcurrency) { case SQL_CONCUR_READ_ONLY: check = SQL_CA2_READ_ONLY_CONCURRENCY; break; case SQL_CONCUR_LOCK: check = SQL_CA2_LOCK_CONCURRENCY; break; case SQL_CONCUR_ROWVER: check = SQL_CA2_OPT_ROWVER_CONCURRENCY; break; case SQL_CONCUR_VALUES: check = SQL_CA2_OPT_VALUES_CONCURRENCY; break; default: odbc_errs_add(&stmt->errs, "HY108", NULL); ODBC_EXIT_(stmt); } value = 0; _SQLGetInfo(stmt->dbc, info, &value, sizeof(value), NULL _wide0); if ((value & check) == 0) { odbc_errs_add(&stmt->errs, "HYC00", NULL); ODBC_EXIT_(stmt); } _SQLSetStmtAttr(hstmt, SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) (TDS_INTPTR) cursor_type, 0 _wide0); _SQLSetStmtAttr(hstmt, SQL_ATTR_CONCURRENCY, (SQLPOINTER) (TDS_INTPTR) fConcurrency, 0 _wide0); _SQLSetStmtAttr(hstmt, SQL_ATTR_KEYSET_SIZE, (SQLPOINTER) (TDS_INTPTR) crowKeyset, 0 _wide0); _SQLSetStmtAttr(hstmt, SQL_ROWSET_SIZE, (SQLPOINTER) (TDS_INTPTR) crowRowset, 0 _wide0); ODBC_EXIT_(stmt); } #include "odbc_export.h" /* Under Windows driver exports functions */ /* The win_ prefix is to avoid clash with inline function. * The prefix is removed from exported functions using definition file. */ #ifdef _WIN32 RETCODE SQL_API win_bcp_initA(HDBC hdbc, const char *tblname, const char *hfile, const char *errfile, int direction); RETCODE SQL_API win_bcp_initW(HDBC hdbc, const SQLWCHAR *tblname, const SQLWCHAR *hfile, const SQLWCHAR *errfile, int direction); RETCODE SQL_API win_bcp_control(HDBC hdbc, int field, void *value); RETCODE SQL_API win_bcp_colptr(HDBC hdbc, const unsigned char * colptr, int table_column); RETCODE SQL_API win_bcp_sendrow(HDBC hdbc); int SQL_API win_bcp_batch(HDBC hdbc); int SQL_API win_bcp_done(HDBC hdbc); RETCODE SQL_API win_bcp_bind(HDBC hdbc, const unsigned char * varaddr, int prefixlen, int varlen, const unsigned char * terminator, int termlen, int vartype, int table_column); RETCODE SQL_API win_bcp_initA(HDBC hdbc, const char *tblname, const char *hfile, const char *errfile, int direction) { return bcp_initA(hdbc, tblname, hfile, errfile, direction); } #ifdef ENABLE_ODBC_WIDE RETCODE SQL_API win_bcp_initW(HDBC hdbc, const SQLWCHAR *tblname, const SQLWCHAR *hfile, const SQLWCHAR *errfile, int direction) { return bcp_initW(hdbc, tblname, hfile, errfile, direction); } #endif RETCODE SQL_API win_bcp_control(HDBC hdbc, int field, void *value) { return bcp_control(hdbc, field, value); } RETCODE SQL_API win_bcp_colptr(HDBC hdbc, const unsigned char * colptr, int table_column) { return bcp_colptr(hdbc, colptr, table_column); } RETCODE SQL_API win_bcp_sendrow(HDBC hdbc) { return bcp_sendrow(hdbc); } int SQL_API win_bcp_batch(HDBC hdbc) { return bcp_batch(hdbc); } int SQL_API win_bcp_done(HDBC hdbc) { return bcp_done(hdbc); } RETCODE SQL_API win_bcp_bind(HDBC hdbc, const unsigned char * varaddr, int prefixlen, int varlen, const unsigned char * terminator, int termlen, int vartype, int table_column) { return bcp_bind(hdbc, varaddr, prefixlen, varlen, terminator, termlen, vartype, table_column); } #endif freetds-1.00.82/src/odbc/connectparams.c100644 025423 025423 00000062043 12717145107 0013537/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns * Copyright (C) 2005-2011 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #include #include #include #include #include #include #include "replacements.h" #define ODBC_PARAM(p) static const char odbc_param_##p[] = #p; ODBC_PARAM_LIST #undef ODBC_PARAM #ifdef _WIN32 #define ODBC_PARAM(p) odbc_param_##p, static const char *odbc_param_names[] = { ODBC_PARAM_LIST }; #undef ODBC_PARAM #endif #if !HAVE_SQLGETPRIVATEPROFILESTRING /* * Last resort place to check for INI file. This is usually set at compile time * by build scripts. */ #ifndef SYS_ODBC_INI #define SYS_ODBC_INI "/etc/odbc.ini" #endif /** * Call this to get the INI file containing Data Source Names. * @note rules for determining the location of ODBC config may be different * then what you expect - at this time they differ from unixODBC * * @return file opened or NULL if error * @retval 1 worked */ static FILE *tdoGetIniFileName(void); /** * SQLGetPrivateProfileString * * PURPOSE * * This is an implementation of a common MS API call. This implementation * should only be used if the ODBC sub-system/SDK does not have it. * For example; unixODBC has its own so those using unixODBC should NOT be * using this implementation because unixODBC; * - provides caching of ODBC config data * - provides consistent interpretation of ODBC config data (i.e, location) * * ARGS * * see ODBC documentation * * RETURNS * * see ODBC documentation * * NOTES: * * - the spec is not entirely implemented... consider this a lite version * - rules for determining the location of ODBC config may be different then what you * expect see tdoGetIniFileName(). * */ static int SQLGetPrivateProfileString(LPCSTR pszSection, LPCSTR pszEntry, LPCSTR pszDefault, LPSTR pRetBuffer, int nRetBuffer, LPCSTR pszFileName); #endif #if defined(FILENAME_MAX) && FILENAME_MAX < 512 #undef FILENAME_MAX #define FILENAME_MAX 512 #endif static int parse_server(TDS_ERRS *errs, char *server, TDSLOGIN * login) { char *p = (char *) strchr(server, '\\'); if (p) { if (!tds_dstr_copy(&login->instance_name, p+1)) { odbc_errs_add(errs, "HY001", NULL); return 0; } *p = 0; } else { p = (char *) strchr(server, ','); if (p && atoi(p+1) > 0) { login->port = atoi(p+1); *p = 0; } } if (TDS_SUCCEED(tds_lookup_host_set(server, &login->ip_addrs))) if (!tds_dstr_copy(&login->server_host_name, server)) { odbc_errs_add(errs, "HY001", NULL); return 0; } return 1; } static int myGetPrivateProfileString(const char *DSN, const char *key, char *buf) { buf[0] = '\0'; return SQLGetPrivateProfileString(DSN, key, "", buf, FILENAME_MAX, "odbc.ini"); } /** * Read connection information from given DSN * @param DSN DSN name * @param login where to store connection info * @return 1 if success 0 otherwhise */ int odbc_get_dsn_info(TDS_ERRS *errs, const char *DSN, TDSLOGIN * login) { char tmp[FILENAME_MAX]; int freetds_conf_less = 1; /* use old servername */ if (myGetPrivateProfileString(DSN, odbc_param_Servername, tmp) > 0) { freetds_conf_less = 0; if (!tds_dstr_copy(&login->server_name, tmp)) { odbc_errs_add(errs, "HY001", NULL); return 0; } tds_read_conf_file(login, tmp); if (myGetPrivateProfileString(DSN, odbc_param_Server, tmp) > 0) { odbc_errs_add(errs, "HY000", "You cannot specify both SERVERNAME and SERVER"); return 0; } if (myGetPrivateProfileString(DSN, odbc_param_Address, tmp) > 0) { odbc_errs_add(errs, "HY000", "You cannot specify both SERVERNAME and ADDRESS"); return 0; } } /* search for server (compatible with ms one) */ if (freetds_conf_less) { int address_specified = 0; if (myGetPrivateProfileString(DSN, odbc_param_Address, tmp) > 0) { address_specified = 1; /* TODO parse like MS */ if (TDS_FAILED(tds_lookup_host_set(tmp, &login->ip_addrs))) { odbc_errs_add(errs, "HY000", "Error parsing ADDRESS attribute"); return 0; } } if (myGetPrivateProfileString(DSN, odbc_param_Server, tmp) > 0) { if (!tds_dstr_copy(&login->server_name, tmp)) { odbc_errs_add(errs, "HY001", NULL); return 0; } if (!address_specified) { if (!parse_server(errs, tmp, login)) return 0; } } } if (myGetPrivateProfileString(DSN, odbc_param_Port, tmp) > 0) tds_parse_conf_section(TDS_STR_PORT, tmp, login); if (myGetPrivateProfileString(DSN, odbc_param_TDS_Version, tmp) > 0) tds_parse_conf_section(TDS_STR_VERSION, tmp, login); if (myGetPrivateProfileString(DSN, odbc_param_Language, tmp) > 0) tds_parse_conf_section(TDS_STR_LANGUAGE, tmp, login); if (tds_dstr_isempty(&login->database) && myGetPrivateProfileString(DSN, odbc_param_Database, tmp) > 0) if (!tds_dstr_copy(&login->database, tmp)) { odbc_errs_add(errs, "HY001", NULL); return 0; } if (myGetPrivateProfileString(DSN, odbc_param_TextSize, tmp) > 0) tds_parse_conf_section(TDS_STR_TEXTSZ, tmp, login); if (myGetPrivateProfileString(DSN, odbc_param_PacketSize, tmp) > 0) tds_parse_conf_section(TDS_STR_BLKSZ, tmp, login); if (myGetPrivateProfileString(DSN, odbc_param_ClientCharset, tmp) > 0) tds_parse_conf_section(TDS_STR_CLCHARSET, tmp, login); if (myGetPrivateProfileString(DSN, odbc_param_DumpFile, tmp) > 0) tds_parse_conf_section(TDS_STR_DUMPFILE, tmp, login); if (myGetPrivateProfileString(DSN, odbc_param_DumpFileAppend, tmp) > 0) tds_parse_conf_section(TDS_STR_APPENDMODE, tmp, login); if (myGetPrivateProfileString(DSN, odbc_param_DebugFlags, tmp) > 0) tds_parse_conf_section(TDS_STR_DEBUGFLAGS, tmp, login); if (myGetPrivateProfileString(DSN, odbc_param_Encryption, tmp) > 0) tds_parse_conf_section(TDS_STR_ENCRYPTION, tmp, login); if (myGetPrivateProfileString(DSN, odbc_param_UseNTLMv2, tmp) > 0) tds_parse_conf_section(TDS_STR_USENTLMV2, tmp, login); if (myGetPrivateProfileString(DSN, odbc_param_REALM, tmp) > 0) tds_parse_conf_section(TDS_STR_REALM, tmp, login); if (myGetPrivateProfileString(DSN, odbc_param_ServerSPN, tmp) > 0) tds_parse_conf_section(TDS_STR_SPN, tmp, login); if (myGetPrivateProfileString(DSN, odbc_param_Trusted_Connection, tmp) > 0 && tds_config_boolean(odbc_param_Trusted_Connection, tmp, login)) { tds_dstr_empty(&login->user_name); tds_dstr_empty(&login->password); } if (myGetPrivateProfileString(DSN, odbc_param_MARS_Connection, tmp) > 0 && tds_config_boolean(odbc_param_MARS_Connection, tmp, login)) { login->mars = 1; } if (myGetPrivateProfileString(DSN, odbc_param_AttachDbFilename, tmp) > 0) tds_parse_conf_section(TDS_STR_DBFILENAME, tmp, login); return 1; } /** * Swap two DSTR */ static void odbc_dstr_swap(DSTR *a, DSTR *b) { DSTR tmp = *a; *a = *b; *b = tmp; } /** * Parse connection string and fill login according * @param connect_string connect string * @param connect_string_end connect string end (pointer to char past last) * @param login where to store connection info * @return 1 if success 0 otherwhise */ int odbc_parse_connect_string(TDS_ERRS *errs, const char *connect_string, const char *connect_string_end, TDSLOGIN * login, TDS_PARSED_PARAM *parsed_params) { const char *p, *end; DSTR *dest_s, value = DSTR_INITIALIZER; enum { CFG_DSN = 1, CFG_SERVER = 2, CFG_SERVERNAME = 4 }; unsigned int cfgs = 0; /* flags for indicate second parse of string */ char option[24]; int trusted = 0; if (parsed_params) memset(parsed_params, 0, sizeof(*parsed_params)*ODBC_PARAM_SIZE); for (p = connect_string; p < connect_string_end && *p;) { int num_param = -1; dest_s = NULL; /* handle empty options */ while (p < connect_string_end && *p == ';') ++p; /* parse option */ end = (const char *) memchr(p, '=', connect_string_end - p); if (!end) break; /* account for spaces between ;'s. */ while (p < end && *p == ' ') ++p; if ((end - p) >= (int) sizeof(option)) option[0] = 0; else { memcpy(option, p, end - p); option[end - p] = 0; } /* parse value */ p = end + 1; if (*p == '{') { ++p; /* search "};" */ end = p; while ((end = (const char *) memchr(end, '}', connect_string_end - end)) != NULL) { if ((end + 1) != connect_string_end && end[1] == ';') break; ++end; } } else { end = (const char *) memchr(p, ';', connect_string_end - p); } if (!end) end = connect_string_end; if (!tds_dstr_copyn(&value, p, end - p)) { odbc_errs_add(errs, "HY001", NULL); return 0; } #define CHK_PARAM(p) (strcasecmp(option, odbc_param_##p) == 0 && (num_param=ODBC_PARAM_##p) >= 0) if (CHK_PARAM(Server)) { /* error if servername or DSN specified */ if ((cfgs & (CFG_DSN|CFG_SERVERNAME)) != 0) { tds_dstr_free(&value); odbc_errs_add(errs, "HY000", "Only one between SERVER, SERVERNAME and DSN can be specified"); return 0; } if (!cfgs) { dest_s = &login->server_name; /* not that safe cast but works -- freddy77 */ if (!parse_server(errs, (char *) tds_dstr_cstr(&value), login)) { tds_dstr_free(&value); return 0; } cfgs = CFG_SERVER; } } else if (CHK_PARAM(Servername)) { if ((cfgs & (CFG_DSN|CFG_SERVER)) != 0) { tds_dstr_free(&value); odbc_errs_add(errs, "HY000", "Only one between SERVER, SERVERNAME and DSN can be specified"); return 0; } if (!cfgs) { odbc_dstr_swap(&login->server_name, &value); tds_read_conf_file(login, tds_dstr_cstr(&login->server_name)); cfgs = CFG_SERVERNAME; p = connect_string; continue; } } else if (CHK_PARAM(DSN)) { if ((cfgs & (CFG_SERVER|CFG_SERVERNAME)) != 0) { tds_dstr_free(&value); odbc_errs_add(errs, "HY000", "Only one between SERVER, SERVERNAME and DSN can be specified"); return 0; } if (!cfgs) { if (!odbc_get_dsn_info(errs, tds_dstr_cstr(&value), login)) { tds_dstr_free(&value); return 0; } cfgs = CFG_DSN; p = connect_string; continue; } } else if (CHK_PARAM(Database)) { dest_s = &login->database; } else if (CHK_PARAM(UID)) { dest_s = &login->user_name; } else if (CHK_PARAM(PWD)) { dest_s = &login->password; } else if (CHK_PARAM(APP)) { dest_s = &login->app_name; } else if (CHK_PARAM(WSID)) { dest_s = &login->client_host_name; } else if (CHK_PARAM(Language)) { tds_parse_conf_section(TDS_STR_LANGUAGE, tds_dstr_cstr(&value), login); } else if (CHK_PARAM(Port)) { tds_parse_conf_section(TDS_STR_PORT, tds_dstr_cstr(&value), login); } else if (CHK_PARAM(TDS_Version)) { tds_parse_conf_section(TDS_STR_VERSION, tds_dstr_cstr(&value), login); } else if (CHK_PARAM(TextSize)) { tds_parse_conf_section(TDS_STR_TEXTSZ, tds_dstr_cstr(&value), login); } else if (CHK_PARAM(PacketSize)) { tds_parse_conf_section(TDS_STR_BLKSZ, tds_dstr_cstr(&value), login); } else if (CHK_PARAM(ClientCharset)) { tds_parse_conf_section(TDS_STR_CLCHARSET, tds_dstr_cstr(&value), login); } else if (CHK_PARAM(DumpFile)) { tds_parse_conf_section(TDS_STR_DUMPFILE, tds_dstr_cstr(&value), login); } else if (CHK_PARAM(DumpFileAppend)) { tds_parse_conf_section(TDS_STR_APPENDMODE, tds_dstr_cstr(&value), login); } else if (CHK_PARAM(DebugFlags)) { tds_parse_conf_section(TDS_STR_DEBUGFLAGS, tds_dstr_cstr(&value), login); } else if (CHK_PARAM(Encryption)) { tds_parse_conf_section(TDS_STR_ENCRYPTION, tds_dstr_cstr(&value), login); } else if (CHK_PARAM(UseNTLMv2)) { tds_parse_conf_section(TDS_STR_USENTLMV2, tds_dstr_cstr(&value), login); } else if (CHK_PARAM(REALM)) { tds_parse_conf_section(TDS_STR_REALM, tds_dstr_cstr(&value), login); } else if (CHK_PARAM(ServerSPN)) { tds_parse_conf_section(TDS_STR_SPN, tds_dstr_cstr(&value), login); } else if (CHK_PARAM(Trusted_Connection)) { trusted = tds_config_boolean(option, tds_dstr_cstr(&value), login); tdsdump_log(TDS_DBG_INFO1, "trusted %s -> %d\n", tds_dstr_cstr(&value), trusted); num_param = -1; /* TODO odbc_param_Address field */ } else if (CHK_PARAM(MARS_Connection)) { if (tds_config_boolean(option, tds_dstr_cstr(&value), login)) login->mars = 1; } else if (CHK_PARAM(AttachDbFilename)) { dest_s = &login->db_filename; } else if (CHK_PARAM(ApplicationIntent)) { const char *readonly_intent; if (strcasecmp(tds_dstr_cstr(&value), "ReadOnly") == 0) { readonly_intent = "yes"; } else if (strcasecmp(tds_dstr_cstr(&value), "ReadWrite") == 0) { readonly_intent = "no"; } else { tdsdump_log(TDS_DBG_ERROR, "Invalid ApplicationIntent %s\n", tds_dstr_cstr(&value)); return 0; } tds_parse_conf_section(TDS_STR_READONLY_INTENT, readonly_intent, login); tdsdump_log(TDS_DBG_INFO1, "Application Intent %s\n", readonly_intent); } if (num_param >= 0 && parsed_params) { parsed_params[num_param].p = p; parsed_params[num_param].len = end - p; } /* copy to destination */ if (dest_s) odbc_dstr_swap(dest_s, &value); p = end; /* handle "" ";.." "};.." cases */ if (p >= connect_string_end) break; if (*p == '}') ++p; ++p; } if (trusted) { if (parsed_params) { parsed_params[ODBC_PARAM_Trusted_Connection].p = "Yes"; parsed_params[ODBC_PARAM_Trusted_Connection].len = 3; parsed_params[ODBC_PARAM_UID].p = NULL; parsed_params[ODBC_PARAM_PWD].p = NULL; } tds_dstr_empty(&login->user_name); tds_dstr_empty(&login->password); } tds_dstr_free(&value); return 1; } #ifdef _WIN32 int odbc_build_connect_string(TDS_ERRS *errs, TDS_PARSED_PARAM *params, char **out) { unsigned n; size_t len = 1; char *p; /* compute string size */ for (n = 0; n < ODBC_PARAM_SIZE; ++n) { if (params[n].p) len += strlen(odbc_param_names[n]) + params[n].len + 2; } /* allocate */ p = tds_new(char, len); if (!p) { odbc_errs_add(errs, "HY001", NULL); return 0; } *out = p; /* build it */ for (n = 0; n < ODBC_PARAM_SIZE; ++n) { if (params[n].p) p += sprintf(p, "%s=%.*s;", odbc_param_names[n], (int) params[n].len, params[n].p); } *p = 0; return 1; } #endif #if !HAVE_SQLGETPRIVATEPROFILESTRING #ifdef _WIN32 # error There is something wrong in configuration... #endif typedef struct { LPCSTR entry; LPSTR buffer; int buffer_len; int ret_val; int found; } ProfileParam; static void tdoParseProfile(const char *option, const char *value, void *param) { ProfileParam *p = (ProfileParam *) param; if (strcasecmp(p->entry, option) == 0) { strlcpy(p->buffer, value, p->buffer_len); p->ret_val = strlen(p->buffer); p->found = 1; } } static int SQLGetPrivateProfileString(LPCSTR pszSection, LPCSTR pszEntry, LPCSTR pszDefault, LPSTR pRetBuffer, int nRetBuffer, LPCSTR pszFileName) { FILE *hFile; ProfileParam param; tdsdump_log(TDS_DBG_FUNC, "SQLGetPrivateProfileString(%p, %p, %p, %p, %d, %p)\n", pszSection, pszEntry, pszDefault, pRetBuffer, nRetBuffer, pszFileName); if (!pszSection) { /* spec says return list of all section names - but we will just return nothing */ tdsdump_log(TDS_DBG_WARN, "WARNING: Functionality for NULL pszSection not implemented.\n"); return 0; } if (!pszEntry) { /* spec says return list of all key names in section - but we will just return nothing */ tdsdump_log(TDS_DBG_WARN, "WARNING: Functionality for NULL pszEntry not implemented.\n"); return 0; } if (nRetBuffer < 1) tdsdump_log(TDS_DBG_WARN, "WARNING: No space to return a value because nRetBuffer < 1.\n"); if (pszFileName && *pszFileName == '/') hFile = fopen(pszFileName, "r"); else hFile = tdoGetIniFileName(); if (hFile == NULL) { tdsdump_log(TDS_DBG_ERROR, "ERROR: Could not open configuration file\n"); return 0; } param.entry = pszEntry; param.buffer = pRetBuffer; param.buffer_len = nRetBuffer; param.ret_val = 0; param.found = 0; pRetBuffer[0] = 0; tds_read_conf_section(hFile, pszSection, tdoParseProfile, ¶m); if (pszDefault && !param.found) { strlcpy(pRetBuffer, pszDefault, nRetBuffer); param.ret_val = strlen(pRetBuffer); } fclose(hFile); return param.ret_val; } static FILE * tdoGetIniFileName() { FILE *ret = NULL; char *p; char *fn; /* * First, try the ODBCINI environment variable */ if ((p = getenv("ODBCINI")) != NULL) ret = fopen(p, "r"); /* * Second, try the HOME environment variable */ if (!ret && (p = tds_get_homedir()) != NULL) { fn = NULL; if (asprintf(&fn, "%s/.odbc.ini", p) > 0) { ret = fopen(fn, "r"); free(fn); } free(p); } /* * As a last resort, try SYS_ODBC_INI */ if (!ret) ret = fopen(SYS_ODBC_INI, "r"); return ret; } #endif /* !HAVE_SQLGETPRIVATEPROFILESTRING */ #ifdef UNIXODBC /* * Begin BIG Hack. * * We need these from odbcinstext.h but it wants to * include and , which are not in the * standard include path. XXX smurph * confirmed by unixODBC stuff, odbcinstext.h shouldn't be installed. freddy77 */ #define INI_MAX_LINE 1000 #define INI_MAX_OBJECT_NAME INI_MAX_LINE #define INI_MAX_PROPERTY_NAME INI_MAX_LINE #define INI_MAX_PROPERTY_VALUE INI_MAX_LINE #define ODBCINST_PROMPTTYPE_LABEL 0 /* readonly */ #define ODBCINST_PROMPTTYPE_TEXTEDIT 1 #define ODBCINST_PROMPTTYPE_LISTBOX 2 #define ODBCINST_PROMPTTYPE_COMBOBOX 3 #define ODBCINST_PROMPTTYPE_FILENAME 4 #define ODBCINST_PROMPTTYPE_HIDDEN 5 typedef struct tODBCINSTPROPERTY { struct tODBCINSTPROPERTY *pNext; /* pointer to next property, NULL if last property */ char szName[INI_MAX_PROPERTY_NAME + 1]; /* property name */ char szValue[INI_MAX_PROPERTY_VALUE + 1]; /* property value */ int nPromptType; /* PROMPTTYPE_TEXTEDIT, PROMPTTYPE_LISTBOX, PROMPTTYPE_COMBOBOX, PROMPTTYPE_FILENAME */ char **aPromptData; /* array of pointers terminated with a NULL value in array. */ char *pszHelp; /* help on this property (driver setups should keep it short) */ void *pWidget; /* CALLER CAN STORE A POINTER TO ? HERE */ int bRefresh; /* app should refresh widget ie Driver Setup has changed aPromptData or szValue */ void *hDLL; /* for odbcinst internal use... only first property has valid one */ } ODBCINSTPROPERTY, *HODBCINSTPROPERTY; /* * End BIG Hack. */ int ODBCINSTGetProperties(HODBCINSTPROPERTY hLastProperty); static const char *const aTDSver[] = { "", "4.2", "5.0", "7.0", "7.1", "7.2", "7.3", "7.4", NULL }; static const char *const aLanguage[] = { "us_english", NULL }; static const char *const aEncryption[] = { TDS_STR_ENCRYPTION_OFF, TDS_STR_ENCRYPTION_REQUEST, TDS_STR_ENCRYPTION_REQUIRE, NULL }; static const char *const aBoolean[] = { "Yes", "No", NULL }; /* static const char *aAuth[] = { "Server", "Domain", "Both", NULL }; */ static HODBCINSTPROPERTY addProperty(HODBCINSTPROPERTY hLastProperty) { hLastProperty->pNext = (HODBCINSTPROPERTY) calloc(1, sizeof(ODBCINSTPROPERTY)); hLastProperty = hLastProperty->pNext; return hLastProperty; } static HODBCINSTPROPERTY definePropertyString(HODBCINSTPROPERTY hLastProperty, const char *name, const char *value, const char *comment) { hLastProperty = addProperty(hLastProperty); hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_TEXTEDIT; strlcpy(hLastProperty->szName, name, INI_MAX_PROPERTY_NAME); strlcpy(hLastProperty->szValue, value, INI_MAX_PROPERTY_VALUE); hLastProperty->pszHelp = (char *) strdup(comment); return hLastProperty; } static HODBCINSTPROPERTY definePropertyBoolean(HODBCINSTPROPERTY hLastProperty, const char *name, const char *value, const char *comment) { hLastProperty = addProperty(hLastProperty); hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_LISTBOX; hLastProperty->aPromptData = malloc(sizeof(aBoolean)); memcpy(hLastProperty->aPromptData, aBoolean, sizeof(aBoolean)); strlcpy(hLastProperty->szName, name, INI_MAX_PROPERTY_NAME); strlcpy(hLastProperty->szValue, value, INI_MAX_PROPERTY_VALUE); hLastProperty->pszHelp = (char *) strdup(comment); return hLastProperty; } static HODBCINSTPROPERTY definePropertyHidden(HODBCINSTPROPERTY hLastProperty, const char *name, const char *value, const char *comment) { hLastProperty = addProperty(hLastProperty); hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_HIDDEN; strlcpy(hLastProperty->szName, name, INI_MAX_PROPERTY_NAME); strlcpy(hLastProperty->szValue, value, INI_MAX_PROPERTY_VALUE); hLastProperty->pszHelp = (char *) strdup(comment); return hLastProperty; } static HODBCINSTPROPERTY definePropertyList(HODBCINSTPROPERTY hLastProperty, const char *name, const char *value, const void *list, int size, const char *comment) { hLastProperty = addProperty(hLastProperty); hLastProperty->nPromptType = ODBCINST_PROMPTTYPE_LISTBOX; hLastProperty->aPromptData = malloc(size); memcpy(hLastProperty->aPromptData, list, size); strlcpy(hLastProperty->szName, name, INI_MAX_PROPERTY_NAME); strlcpy(hLastProperty->szValue, value, INI_MAX_PROPERTY_VALUE); hLastProperty->pszHelp = (char *) strdup(comment); return hLastProperty; } int ODBCINSTGetProperties(HODBCINSTPROPERTY hLastProperty) { hLastProperty = definePropertyString(hLastProperty, odbc_param_Servername, "", "Name of FreeTDS connection to connect to.\n" "This server name refer to entry in freetds.conf file, not real server name.\n" "This property cannot be used with Server property."); hLastProperty = definePropertyString(hLastProperty, odbc_param_Server, "", "Name of server to connect to.\n" "This should be the name of real server.\n" "This property cannot be used with Servername property."); hLastProperty = definePropertyString(hLastProperty, odbc_param_Address, "", "The hostname or ip address of the server."); hLastProperty = definePropertyString(hLastProperty, odbc_param_Port, "1433", "TCP/IP Port to connect to."); hLastProperty = definePropertyString(hLastProperty, odbc_param_Database, "", "Default database."); hLastProperty = definePropertyList(hLastProperty, odbc_param_TDS_Version, "4.2", (void*) aTDSver, sizeof(aTDSver), "The TDS protocol version.\n" " 4.2 MSSQL 6.5 or Sybase < 10.x\n" " 5.0 Sybase >= 10.x\n" " 7.0 MSSQL 7\n" " 7.1 MSSQL 2000\n" " 7.2 MSSQL 2005\n" " 7.3 MSSQL 2008\n" " 7.4 MSSQL 2012 or 2014" ); hLastProperty = definePropertyList(hLastProperty, odbc_param_Language, "us_english", (void*) aLanguage, sizeof(aLanguage), "The default language setting."); hLastProperty = definePropertyHidden(hLastProperty, odbc_param_TextSize, "", "Text datatype limit."); /* ??? in odbc.ini ??? */ /* hLastProperty = definePropertyString(hLastProperty, odbc_param_UID, "", "User ID (Beware of security issues)."); hLastProperty = definePropertyString(hLastProperty, odbc_param_PWD, "", "Password (Beware of security issues)."); */ /* hLastProperty = definePropertyList(hLastProperty, odbc_param_Authentication, "Server", aAuth, sizeof(aAuth), "The server authentication mechanism."); hLastProperty = definePropertyString(hLastProperty, odbc_param_Domain, "", "The default domain to use when using Domain Authentication."); */ hLastProperty = definePropertyString(hLastProperty, odbc_param_PacketSize, "", "Size of network packets."); hLastProperty = definePropertyString(hLastProperty, odbc_param_ClientCharset, "", "The client character set name to convert application characters to UCS-2 in TDS 7.0 and higher."); hLastProperty = definePropertyString(hLastProperty, odbc_param_DumpFile, "", "Specifies the location of a tds dump file and turns on logging."); hLastProperty = definePropertyBoolean(hLastProperty, odbc_param_DumpFileAppend, "", "Appends dump file instead of overwriting it. Useful for debugging when many processes are active."); hLastProperty = definePropertyString(hLastProperty, odbc_param_DebugFlags, "", "Sets granularity of logging. A set of bit that specify levels and informations. See table below for bit specification."); hLastProperty = definePropertyList(hLastProperty, odbc_param_Encryption, TDS_STR_ENCRYPTION_OFF, aEncryption, sizeof(aEncryption), "The encryption method."); return 1; } #endif freetds-1.00.82/src/odbc/convert_tds2sql.c100644 025423 025423 00000037450 12717145107 0014042/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-1999 Brian Bruns * Copyright (C) 2003-2010 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include #include #include #include #define TDS_ISSPACE(c) isspace((unsigned char) (c)) /** * Handle conversions from TDS (N)CHAR to ODBC (W)CHAR */ static SQLLEN odbc_convert_char(TDS_STMT * stmt, TDSCOLUMN * curcol, TDS_CHAR * src, TDS_UINT srclen, int desttype, TDS_CHAR * dest, SQLULEN destlen) { const char *ib; char *ob; size_t il, ol, char_size; /* FIXME MARS not correct cause is the global tds but stmt->tds can be NULL on SQLGetData */ TDSSOCKET *tds = stmt->dbc->tds_socket; TDSICONV *conv = curcol->char_conv; if (!conv) conv = tds->conn->char_convs[client2server_chardata]; if (desttype == SQL_C_WCHAR) { const char *charset = odbc_get_wide_name(tds->conn); /* SQL_C_WCHAR, convert to wide encode */ conv = tds_iconv_get(tds->conn, charset, conv->to.charset.name); if (!conv) conv = tds_iconv_get(tds->conn, charset, "ISO-8859-1"); #ifdef ENABLE_ODBC_WIDE } else { conv = tds_iconv_get(tds->conn, tds_dstr_cstr(&stmt->dbc->original_charset), conv->to.charset.name); if (!conv) conv = tds_iconv_get(tds->conn, tds_dstr_cstr(&stmt->dbc->original_charset), "ISO-8859-1"); if (!conv) conv = tds_iconv_get(tds->conn, "ISO-8859-1", "ISO-8859-1"); #endif } ib = src; il = srclen; ob = dest; ol = 0; char_size = desttype == SQL_C_CHAR ? 1 : SIZEOF_SQLWCHAR; if (destlen >= char_size) { ol = destlen - char_size; memset(&conv->suppress, 0, sizeof(conv->suppress)); conv->suppress.e2big = 1; /* TODO check return value */ tds_iconv(tds, conv, to_client, &ib, &il, &ob, &ol); ol = ob - dest; /* bytes written */ curcol->column_text_sqlgetdatapos += ib - src; /* terminate string */ memset(ob, 0, char_size); } /* returned size have to take into account buffer left unconverted */ if (il == 0 || (conv->from.charset.min_bytes_per_char == conv->from.charset.max_bytes_per_char && conv->to.charset.min_bytes_per_char == conv->to.charset.max_bytes_per_char)) { ol += il * conv->from.charset.min_bytes_per_char / conv->to.charset.min_bytes_per_char; } else if ((conv->flags & TDS_ENCODING_MEMCPY) != 0) { ol += il; } else { /* TODO convert and discard ?? or return proper SQL_NO_TOTAL values ?? */ return SQL_NO_TOTAL; } return ol; } /** * Handle conversions from TDS NCHAR to ISO8859-1 striping spaces (for fixed types) */ static int odbc_tds_convert_wide_iso(TDSCOLUMN *curcol, TDS_CHAR *src, TDS_UINT srclen, TDS_CHAR *buf, TDS_UINT buf_len) { TDS_CHAR *p; /* * TODO check for endian * This affect for instance Sybase under little endian system */ /* skip white spaces */ while (srclen > 1 && src[1] == 0 && TDS_ISSPACE(src[0])) { srclen -= 2; src += 2; } /* convert */ p = buf; while (buf_len > 1 && srclen > 1 && src[1] == 0) { *p++ = src[0]; --buf_len; srclen -= 2; src += 2; } /* skip white spaces */ while (srclen > 1 && src[1] == 0 && TDS_ISSPACE(src[0])) { srclen -= 2; src += 2; } /* still characters, wrong format */ if (srclen) return -1; *p = 0; return p - buf; } /* The following structure is going to write in these structure not using them * but just knowing the ABI. Check these ABI. Mainly make sure the alignment * is still correct. */ TDS_COMPILE_CHECK(ss_time2, sizeof(SQL_SS_TIME2_STRUCT) == 12 && TDS_OFFSET(SQL_SS_TIME2_STRUCT, fraction) == 8); TDS_COMPILE_CHECK(ss_timestampoffset, sizeof(SQL_SS_TIMESTAMPOFFSET_STRUCT) == 20 && TDS_OFFSET(SQL_SS_TIMESTAMPOFFSET_STRUCT, fraction) == 12); TDS_COMPILE_CHECK(date_struct, sizeof(DATE_STRUCT) == 6 && TDS_OFFSET(DATE_STRUCT, year) == 0 && TDS_OFFSET(DATE_STRUCT, month) == 2 && TDS_OFFSET(DATE_STRUCT, day) == 4); TDS_COMPILE_CHECK(timestamp_struct, sizeof(TIMESTAMP_STRUCT) == 16 && TDS_OFFSET(TIMESTAMP_STRUCT, year) == 0 && TDS_OFFSET(TIMESTAMP_STRUCT, month) == 2 && TDS_OFFSET(TIMESTAMP_STRUCT, day) == 4 && TDS_OFFSET(TIMESTAMP_STRUCT, hour) == 6 && TDS_OFFSET(TIMESTAMP_STRUCT, minute) == 8 && TDS_OFFSET(TIMESTAMP_STRUCT, second) == 10 && TDS_OFFSET(TIMESTAMP_STRUCT, fraction) == 12); /** * Handle conversions from MSSQL 2008 DATE/TIME types to binary. * These types have a different binary representation in libTDS. */ static SQLLEN odbc_convert_datetime_to_binary(TDS_STMT * stmt, TDSCOLUMN *curcol, int srctype, TDS_DATETIMEALL * dta, TDS_CHAR * dest, SQLULEN destlen) { size_t len, cplen; TDS_USMALLINT buf[10]; TDSDATEREC when; tds_datecrack(srctype, dta, &when); len = 0; if (srctype != SYBMSTIME && srctype != SYBTIME && srctype != SYB5BIGTIME) { buf[0] = when.year; buf[1] = when.month + 1; buf[2] = when.day; len = 3; } if (srctype != SYBMSDATE && srctype != SYBDATE) { buf[len++] = when.hour; buf[len++] = when.minute; buf[len++] = when.second; if ((len % 2) != 0) buf[len++] = 0; *((TDS_UINT*) (buf+len)) = when.decimicrosecond * 100u; len += 2; } if (srctype == SYBMSDATETIMEOFFSET) { /* TODO check for negative hour/minutes */ buf[8] = dta->offset / 60; buf[9] = dta->offset % 60; len = 10; } len *= 2; /* just return length */ if (destlen == 0) return len; cplen = (destlen > len) ? len : destlen; memcpy(dest, buf, cplen); if (curcol) curcol->column_text_sqlgetdatapos += cplen; return len; } static SQLLEN odbc_convert_to_binary(TDS_STMT * stmt, TDSCOLUMN *curcol, int srctype, TDS_CHAR * src, TDS_UINT srclen, TDS_CHAR * dest, SQLULEN destlen) { SQLLEN ret = srclen; /* special case for date/time */ switch (srctype) { case SYBMSTIME: case SYBMSDATE: case SYBMSDATETIME2: case SYBMSDATETIMEOFFSET: case SYBDATE: case SYBTIME: case SYB5BIGTIME: case SYB5BIGDATETIME: return odbc_convert_datetime_to_binary(stmt, curcol, srctype, (TDS_DATETIMEALL *) src, dest, destlen); } /* if destlen == 0 we return only length */ if (destlen > 0) { size_t cplen = (destlen > srclen) ? srclen : destlen; /* do not NUL terminate binary buffer */ memcpy(dest, src, cplen); if (curcol) curcol->column_text_sqlgetdatapos += cplen; } return ret; } SQLLEN odbc_tds2sql(TDS_STMT * stmt, TDSCOLUMN *curcol, int srctype, TDS_CHAR * src, TDS_UINT srclen, int desttype, TDS_CHAR * dest, SQLULEN destlen, const struct _drecord *drec_ixd) { TDS_INT nDestSybType; TDS_INT nRetVal = TDS_CONVERT_FAIL; TDSCONTEXT *context = stmt->dbc->env->tds_ctx; CONV_RESULT ores; SQLLEN ret = SQL_NULL_DATA; int i, cplen; int binary_conversion = 0; TDS_CHAR conv_buf[256]; tdsdump_log(TDS_DBG_FUNC, "odbc_tds2sql: src is %d dest = %d\n", srctype, desttype); assert(desttype != SQL_C_DEFAULT); if (curcol) { if (is_blob_col(curcol)) { if (srctype == SYBLONGBINARY && ( curcol->column_usertype == USER_UNICHAR_TYPE || curcol->column_usertype == USER_UNIVARCHAR_TYPE)) srctype = SYBTEXT; if (curcol->column_type == SYBVARIANT) srctype = ((TDSVARIANT *) src)->type; src = ((TDSBLOB *) src)->textvalue; } if (is_variable_type(curcol->column_type)) { src += curcol->column_text_sqlgetdatapos; srclen -= curcol->column_text_sqlgetdatapos; } } nDestSybType = odbc_c_to_server_type(desttype); if (!nDestSybType) { odbc_errs_add(&stmt->errs, "HY003", NULL); return SQL_NULL_DATA; } /* special case for binary type */ if (desttype == SQL_C_BINARY) { tdsdump_log(TDS_DBG_FUNC, "odbc_tds2sql: outputting binary data destlen = %lu \n", (unsigned long) destlen); if (is_numeric_type(srctype)) { desttype = SQL_C_NUMERIC; nDestSybType = SYBNUMERIC; /* prevent buffer overflow */ if (destlen < sizeof(SQL_NUMERIC_STRUCT)) { odbc_errs_add(&stmt->errs, "07006", NULL); return SQL_NULL_DATA; } ores.n.precision = ((TDS_NUMERIC *) src)->precision; ores.n.scale = ((TDS_NUMERIC *) src)->scale; } else { return odbc_convert_to_binary(stmt, curcol, srctype, src, srclen, dest, destlen); } } else if (is_numeric_type(nDestSybType)) { /* TODO use descriptor information (APD) ?? However APD can contain SQL_C_DEFAULT... */ if (drec_ixd) ores.n.precision = drec_ixd->sql_desc_precision; else ores.n.precision = 38; ores.n.scale = 0; } if (is_char_type(srctype)) { if (desttype == SQL_C_CHAR || desttype == SQL_C_WCHAR) return odbc_convert_char(stmt, curcol, src, srclen, desttype, dest, destlen); if (is_unicode_type(srctype)) { /* * convert to single and then process normally. * Here we processed SQL_C_BINARY and SQL_C_*CHAR so only fixed types are left */ i = odbc_tds_convert_wide_iso(curcol, src, srclen, conv_buf, sizeof(conv_buf)); if (i < 0) return SQL_NULL_DATA; src = conv_buf; srclen = i; srctype = SYBVARCHAR; } } if (desttype == SQL_C_WCHAR) destlen /= sizeof(SQLWCHAR); if (desttype == SQL_C_CHAR || desttype == SQL_C_WCHAR) { switch (srctype) { case SYBLONGBINARY: case SYBBINARY: case SYBVARBINARY: case SYBIMAGE: case XSYBBINARY: case XSYBVARBINARY: binary_conversion = 1; if (destlen && !(destlen % 2)) --destlen; } nDestSybType = TDS_CONVERT_CHAR; ores.cc.len = destlen; ores.cc.c = dest; } if (desttype == SQL_C_CHAR || desttype == SQL_C_WCHAR) { char buf[48]; TDSDATEREC when; int prec; const char *fmt = NULL; const TDS_DATETIMEALL *dta = (const TDS_DATETIMEALL *) src; switch (srctype) { case SYBMSDATETIMEOFFSET: case SYBMSDATETIME2: prec = dta->time_prec; goto datetime; case SYB5BIGDATETIME: prec = 6; goto datetime; case SYBDATETIME: prec = 3; goto datetime; case SYBDATETIME4: prec = 0; datetime: fmt = "%Y-%m-%d %H:%M:%S.%z"; break; case SYBMSTIME: prec = dta->time_prec; goto time; case SYB5BIGTIME: prec = 6; goto time; case SYBTIME: prec = 3; time: fmt = "%H:%M:%S.%z"; break; case SYBMSDATE: case SYBDATE: prec = 0; fmt = "%Y-%m-%d"; break; } if (!fmt) goto normal_conversion; tds_datecrack(srctype, src, &when); tds_strftime(buf, sizeof(buf), fmt, &when, prec); if (srctype == SYBMSDATETIMEOFFSET) { char sign = '+'; int off = dta->offset; if (off < 0) { sign = '-'; off = -off; } sprintf(buf + strlen(buf), " %c%02d:%02d", sign, off / 60, off % 60); } nRetVal = strlen(buf); memcpy(dest, buf, destlen < nRetVal ? destlen : nRetVal); } else { normal_conversion: nRetVal = tds_convert(context, srctype, src, srclen, nDestSybType, &ores); } if (nRetVal < 0) { odbc_convert_err_set(&stmt->errs, nRetVal); return SQL_NULL_DATA; } switch (desttype) { case SQL_C_CHAR: tdsdump_log(TDS_DBG_FUNC, "odbc_tds2sql: outputting character data destlen = %lu \n", (unsigned long) destlen); ret = nRetVal; /* TODO handle not terminated configuration */ if (destlen > 0) { cplen = (destlen - 1) > nRetVal ? nRetVal : (destlen - 1); assert(cplen >= 0); /* * odbc always terminate but do not overwrite * destination buffer more than needed */ /* update datapos only for binary source (char already handled) */ if (curcol && binary_conversion) curcol->column_text_sqlgetdatapos += cplen / 2; dest[cplen] = 0; } else { /* if destlen == 0 we return only length */ } break; case SQL_C_WCHAR: tdsdump_log(TDS_DBG_FUNC, "odbc_tds2sql: outputting character data destlen = %lu \n", (unsigned long) destlen); ret = nRetVal * sizeof(SQLWCHAR); /* TODO handle not terminated configuration */ if (destlen > 0) { SQLWCHAR *wp = (SQLWCHAR *) dest; SQLCHAR *p = (SQLCHAR *) dest; cplen = (destlen - 1) > nRetVal ? nRetVal : (destlen - 1); assert(cplen >= 0); /* * odbc always terminate but do not overwrite * destination buffer more than needed */ /* update datapos only for binary source (char already handled) */ if (curcol && binary_conversion) curcol->column_text_sqlgetdatapos += cplen / 2; /* convert in place and terminate */ wp[cplen] = 0; while (cplen > 0) { --cplen; wp[cplen] = p[cplen]; } } else { /* if destlen == 0 we return only length */ } break; case SQL_C_TYPE_DATE: case SQL_C_DATE: { TDSDATEREC dr; DATE_STRUCT *dsp = (DATE_STRUCT *) dest; /* * we've already converted the returned value to a SYBMSDATETIME2 * now decompose date into constituent parts... */ tds_datecrack(SYBMSDATETIME2, &(ores.dt), &dr); dsp->year = dr.year; dsp->month = dr.month + 1; dsp->day = dr.day; ret = sizeof(DATE_STRUCT); } break; case SQL_C_TYPE_TIME: case SQL_C_TIME: { TDSDATEREC dr; TIME_STRUCT *tsp = (TIME_STRUCT *) dest; /* * we've already converted the returned value to a SYBMSDATETIME2 * now decompose date into constituent parts... */ tds_datecrack(SYBMSDATETIME2, &(ores.dt), &dr); tsp->hour = dr.hour; tsp->minute = dr.minute; tsp->second = dr.second; ret = sizeof(TIME_STRUCT); } break; case SQL_C_TYPE_TIMESTAMP: case SQL_C_TIMESTAMP: { TDSDATEREC dr; TIMESTAMP_STRUCT *tssp = (TIMESTAMP_STRUCT *) dest; /* * we've already converted the returned value to a SYBMSDATETIME2 * now decompose date into constituent parts... */ tds_datecrack(SYBMSDATETIME2, &(ores.dt), &dr); tssp->year = dr.year; tssp->month = dr.month + 1; tssp->day = dr.day; tssp->hour = dr.hour; tssp->minute = dr.minute; tssp->second = dr.second; tssp->fraction = dr.decimicrosecond * 100u; ret = sizeof(TIMESTAMP_STRUCT); } break; #ifdef SQL_C_SBIGINT case SQL_C_SBIGINT: case SQL_C_UBIGINT: *((TDS_INT8 *) dest) = ores.bi; ret = sizeof(TDS_INT8); break; #endif case SQL_C_LONG: case SQL_C_SLONG: case SQL_C_ULONG: *((TDS_INT *) dest) = ores.i; ret = sizeof(TDS_INT); break; case SQL_C_SHORT: case SQL_C_SSHORT: case SQL_C_USHORT: *((TDS_SMALLINT *) dest) = ores.si; ret = sizeof(TDS_SMALLINT); break; case SQL_C_TINYINT: case SQL_C_STINYINT: case SQL_C_UTINYINT: case SQL_C_BIT: *((TDS_TINYINT *) dest) = ores.ti; ret = sizeof(TDS_TINYINT); break; case SQL_C_DOUBLE: *((TDS_FLOAT *) dest) = ores.f; ret = sizeof(TDS_FLOAT); break; case SQL_C_FLOAT: *((TDS_REAL *) dest) = ores.r; ret = sizeof(TDS_REAL); break; case SQL_C_NUMERIC: { /* ODBC numeric is quite different from TDS one ... */ SQL_NUMERIC_STRUCT *num = (SQL_NUMERIC_STRUCT *) dest; num->precision = ores.n.precision; num->scale = ores.n.scale; num->sign = ores.n.array[0] ^ 1; /* * TODO can be greater than SQL_MAX_NUMERIC_LEN ?? * seeing Sybase manual wire support bigger numeric but currently * DBs so not support such precision */ i = ODBC_MIN(tds_numeric_bytes_per_prec[ores.n.precision] - 1, SQL_MAX_NUMERIC_LEN); memcpy(num->val, ores.n.array + 1, i); tds_swap_bytes(num->val, i); if (i < SQL_MAX_NUMERIC_LEN) memset(num->val + i, 0, SQL_MAX_NUMERIC_LEN - i); ret = sizeof(SQL_NUMERIC_STRUCT); } break; #ifdef SQL_C_GUID case SQL_C_GUID: memcpy(dest, &(ores.u), sizeof(TDS_UNIQUE)); ret = sizeof(TDS_UNIQUE); break; #endif default: break; } return ret; } freetds-1.00.82/src/odbc/descriptor.c100644 025423 025423 00000011624 12717145107 0013057/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2003 Steve Murphree * Copyright (C) 2004, 2005 Ziglio Frediano * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include static void desc_free_record(struct _drecord *drec); TDS_DESC * desc_alloc(SQLHANDLE parent, int desc_type, int alloc_type) { TDS_DESC *desc; desc = tds_new0(TDS_DESC, 1); if (!desc || tds_mutex_init(&desc->mtx)) { free(desc); return NULL; } /* set default header values */ desc->htype = SQL_HANDLE_DESC; desc->type = desc_type; desc->parent = parent; desc->header.sql_desc_alloc_type = alloc_type; desc->header.sql_desc_count = 0; desc->records = NULL; switch (desc_type) { case DESC_IRD: case DESC_IPD: break; case DESC_ARD: case DESC_APD: desc->header.sql_desc_bind_type = SQL_BIND_BY_COLUMN; desc->header.sql_desc_array_size = 1; break; default: free(desc); return NULL; } return desc; } #define SQL_DESC_STRINGS \ STR_OP(sql_desc_base_column_name); \ STR_OP(sql_desc_base_table_name); \ STR_OP(sql_desc_catalog_name); \ STR_OP(sql_desc_label); \ STR_OP(sql_desc_local_type_name); \ STR_OP(sql_desc_name); \ STR_OP(sql_desc_schema_name); \ STR_OP(sql_desc_table_name) SQLRETURN desc_alloc_records(TDS_DESC * desc, unsigned count) { struct _drecord *drec; int i; /* shrink records */ if (desc->header.sql_desc_count >= count) { for (i = count; i < desc->header.sql_desc_count; ++i) desc_free_record(&desc->records[i]); desc->header.sql_desc_count = count; return SQL_SUCCESS; } if (!TDS_RESIZE(desc->records, count)) return SQL_ERROR; memset(desc->records + desc->header.sql_desc_count, 0, sizeof(struct _drecord) * (count - desc->header.sql_desc_count)); for (i = desc->header.sql_desc_count; i < count; ++i) { drec = &desc->records[i]; #define STR_OP(name) tds_dstr_init(&drec->name) SQL_DESC_STRINGS; #undef STR_OP switch (desc->type) { case DESC_IRD: case DESC_IPD: drec->sql_desc_parameter_type = SQL_PARAM_INPUT; break; case DESC_ARD: case DESC_APD: drec->sql_desc_concise_type = SQL_C_DEFAULT; drec->sql_desc_type = SQL_C_DEFAULT; break; } } desc->header.sql_desc_count = count; return SQL_SUCCESS; } static void desc_free_record(struct _drecord *drec) { #define STR_OP(name) tds_dstr_free(&drec->name) SQL_DESC_STRINGS; #undef STR_OP } SQLRETURN desc_free_records(TDS_DESC * desc) { int i; if (desc->records) { for (i = 0; i < desc->header.sql_desc_count; i++) desc_free_record(&desc->records[i]); TDS_ZERO_FREE(desc->records); } desc->header.sql_desc_count = 0; return SQL_SUCCESS; } SQLRETURN desc_copy(TDS_DESC * dest, TDS_DESC * src) { int i; TDS_DESC tmp = *dest; /* copy header */ tmp.header = src->header; /* set no records */ tmp.header.sql_desc_count = 0; tmp.records = NULL; tmp.errs.num_errors = 0; tmp.errs.errs = NULL; if (desc_alloc_records(&tmp, src->header.sql_desc_count) != SQL_SUCCESS) return SQL_ERROR; for (i = 0; i < src->header.sql_desc_count; ++i) { struct _drecord *src_rec = &src->records[i]; struct _drecord *dest_rec = &tmp.records[i]; /* copy all integer in one time ! */ memcpy(dest_rec, src_rec, sizeof(struct _drecord)); /* reinitialize string, avoid doubling pointers */ #define STR_OP(name) tds_dstr_init(&dest_rec->name) SQL_DESC_STRINGS; #undef STR_OP /* copy strings */ #define STR_OP(name) if (!tds_dstr_dup(&dest_rec->name, &src_rec->name)) goto Cleanup SQL_DESC_STRINGS; #undef STR_OP } /* success, copy back to our descriptor */ desc_free_records(dest); odbc_errs_reset(&dest->errs); *dest = tmp; return SQL_SUCCESS; Cleanup: desc_free_records(&tmp); odbc_errs_reset(&tmp.errs); return SQL_ERROR; } SQLRETURN desc_free(TDS_DESC * desc) { if (desc) { desc_free_records(desc); odbc_errs_reset(&desc->errs); tds_mutex_free(&desc->mtx); free(desc); } return SQL_SUCCESS; } TDS_DBC * desc_get_dbc(TDS_DESC *desc) { if (IS_HSTMT(desc->parent)) return ((TDS_STMT *) desc->parent)->dbc; return (TDS_DBC *) desc->parent; } freetds-1.00.82/src/odbc/prepare_query.c100644 025423 025423 00000027326 12717145107 0013572/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Brian Bruns * Copyright (C) 2005-2008 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include #define TDS_ISSPACE(c) isspace((unsigned char) (c)) static int prepared_rpc(struct _hstmt *stmt, int compute_row) { int nparam = stmt->params ? stmt->params->num_cols : 0; const char *p = stmt->prepared_pos - 1; TDSCONNECTION *conn = stmt->dbc->tds_socket->conn; for (;;) { TDSPARAMINFO *temp_params; TDSCOLUMN *curcol; TDS_SERVER_TYPE type; const char *start; while (TDS_ISSPACE(*++p)) continue; if (!*p) return SQL_SUCCESS; /* we have certainly a parameter */ if (!(temp_params = tds_alloc_param_result(stmt->params))) { odbc_errs_add(&stmt->errs, "HY001", NULL); return SQL_ERROR; } stmt->params = temp_params; curcol = temp_params->columns[nparam]; switch (*p) { case ',': if (IS_TDS7_PLUS(conn)) { tds_set_param_type(conn, curcol, SYBVOID); curcol->column_size = curcol->column_cur_size = 0; } else { /* TODO is there a better type ? */ tds_set_param_type(conn, curcol, SYBINTN); curcol->column_size = curcol->on_server.column_size = 4; curcol->column_cur_size = -1; } if (compute_row) if (!tds_alloc_param_data(curcol)) { tds_free_param_result(temp_params); return SQL_ERROR; } --p; break; default: /* add next parameter to list */ start = p; if (!(p = parse_const_param(p, &type))) { tds_free_param_result(temp_params); return SQL_ERROR; } tds_set_param_type(conn, curcol, type); switch (type) { case SYBVARCHAR: curcol->column_size = p - start; break; case SYBVARBINARY: curcol->column_size = (p - start) / 2 -1; break; default: assert(0); case SYBINT4: case SYBFLT8: curcol->column_cur_size = curcol->column_size; break; } curcol->on_server.column_size = curcol->column_size; /* TODO support other type other than VARCHAR, do not strip escape in prepare_call */ if (compute_row) { char *dest; int len; CONV_RESULT cr; if (!tds_alloc_param_data(curcol)) { tds_free_param_result(temp_params); return SQL_ERROR; } dest = (char *) curcol->column_data; switch (type) { case SYBVARCHAR: if (*start != '\'') { memcpy(dest, start, p - start); curcol->column_cur_size = p - start; } else { ++start; for (;;) { if (*start == '\'') ++start; if (start >= p) break; *dest++ = *start++; } curcol->column_cur_size = dest - (char *) curcol->column_data; } break; case SYBVARBINARY: cr.cb.len = curcol->column_size; cr.cb.ib = dest; len = tds_convert(NULL, SYBVARCHAR, start, p - start, TDS_CONVERT_BINARY, &cr); if (len >= 0 && len <= curcol->column_size) curcol->column_cur_size = len; break; case SYBINT4: *((TDS_INT *) dest) = strtol(start, NULL, 10); break; case SYBFLT8: *((TDS_FLOAT *) dest) = strtod(start, NULL); break; default: break; } } --p; break; case '?': /* find bound parameter */ if (stmt->param_num > stmt->apd->header.sql_desc_count || stmt->param_num > stmt->ipd->header.sql_desc_count) { tds_free_param_result(temp_params); /* TODO set error */ return SQL_ERROR; } switch (odbc_sql2tds (stmt, &stmt->ipd->records[stmt->param_num - 1], &stmt->apd->records[stmt->param_num - 1], curcol, compute_row, stmt->apd, stmt->curr_param_row)) { case SQL_ERROR: return SQL_ERROR; case SQL_NEED_DATA: return SQL_NEED_DATA; } ++stmt->param_num; break; } ++nparam; while (TDS_ISSPACE(*++p)) continue; if (!*p || *p != ',') return SQL_SUCCESS; stmt->prepared_pos = (char *) p + 1; } } int parse_prepared_query(struct _hstmt *stmt, int compute_row) { /* try setting this parameter */ TDSPARAMINFO *temp_params; int nparam = stmt->params ? stmt->params->num_cols : 0; if (stmt->prepared_pos) return prepared_rpc(stmt, compute_row); tdsdump_log(TDS_DBG_FUNC, "parsing %d parameters\n", nparam); for (; stmt->param_num <= stmt->param_count; ++nparam, ++stmt->param_num) { /* find bound parameter */ if (stmt->param_num > stmt->apd->header.sql_desc_count || stmt->param_num > stmt->ipd->header.sql_desc_count) { tdsdump_log(TDS_DBG_FUNC, "parse_prepared_query: logic_error: parameter out of bounds: " "%d > %d || %d > %d\n", stmt->param_num, stmt->apd->header.sql_desc_count, stmt->param_num, stmt->ipd->header.sql_desc_count); return SQL_ERROR; } /* add a column to parameters */ if (!(temp_params = tds_alloc_param_result(stmt->params))) { odbc_errs_add(&stmt->errs, "HY001", NULL); return SQL_ERROR; } stmt->params = temp_params; switch (odbc_sql2tds (stmt, &stmt->ipd->records[stmt->param_num - 1], &stmt->apd->records[stmt->param_num - 1], stmt->params->columns[nparam], compute_row, stmt->apd, stmt->curr_param_row)) { case SQL_ERROR: return SQL_ERROR; case SQL_NEED_DATA: return SQL_NEED_DATA; } } return SQL_SUCCESS; } int start_parse_prepared_query(struct _hstmt *stmt, int compute_row) { /* TODO should be NULL already ?? */ tds_free_param_results(stmt->params); stmt->params = NULL; stmt->param_num = 0; stmt->param_num = stmt->prepared_query_is_func ? 2 : 1; return parse_prepared_query(stmt, compute_row); } static TDS_INT odbc_wchar2hex(TDS_CHAR *dest, TDS_UINT destlen, const SQLWCHAR * src, TDS_UINT srclen) { unsigned int i; SQLWCHAR hex1, c = 0; /* if srclen if odd we must add a "0" before ... */ i = 0; /* number where to start converting */ if (srclen & 1) { ++srclen; i = 1; --src; } for (; i < srclen; ++i) { hex1 = src[i]; if ('0' <= hex1 && hex1 <= '9') hex1 &= 0x0f; else { hex1 &= (SQLWCHAR) ~0x20u; /* mask off 0x20 to ensure upper case */ if ('A' <= hex1 && hex1 <= 'F') { hex1 -= ('A' - 10); } else { tdsdump_log(TDS_DBG_INFO1, "error_handler: attempt to convert data stopped by syntax error in source field \n"); return TDS_CONVERT_SYNTAX; } } assert(hex1 < 0x10); if ((i/2u) >= destlen) continue; if (i & 1) dest[i / 2u] = c | hex1; else c = hex1 << 4; } return srclen / 2u; } int continue_parse_prepared_query(struct _hstmt *stmt, SQLPOINTER DataPtr, SQLLEN StrLen_or_Ind) { struct _drecord *drec_apd, *drec_ipd; SQLLEN len; int need_bytes; TDSCOLUMN *curcol; TDSBLOB *blob; int sql_src_type; assert(stmt); tdsdump_log(TDS_DBG_FUNC, "continue_parse_prepared_query with parameter %d\n", stmt->param_num); if (!stmt->params) { tdsdump_log(TDS_DBG_FUNC, "error? continue_parse_prepared_query: no parameters provided"); return SQL_ERROR; } if (stmt->param_num > stmt->apd->header.sql_desc_count || stmt->param_num > stmt->ipd->header.sql_desc_count) return SQL_ERROR; drec_apd = &stmt->apd->records[stmt->param_num - 1]; drec_ipd = &stmt->ipd->records[stmt->param_num - 1]; curcol = stmt->params->columns[stmt->param_num - (stmt->prepared_query_is_func ? 2 : 1)]; blob = NULL; if (is_blob_col(curcol)) blob = (TDSBLOB *) curcol->column_data; assert(curcol->column_cur_size <= curcol->column_size); need_bytes = curcol->column_size - curcol->column_cur_size; if (DataPtr == NULL) { switch(StrLen_or_Ind) { case SQL_NULL_DATA: case SQL_DEFAULT_PARAM: break; /* OK */ default: odbc_errs_add(&stmt->errs, "HY009", NULL); /* Invalid use of null pointer */ return SQL_ERROR; } } /* get C type */ sql_src_type = drec_apd->sql_desc_concise_type; if (sql_src_type == SQL_C_DEFAULT) sql_src_type = odbc_sql_to_c_type_default(drec_ipd->sql_desc_concise_type); switch(StrLen_or_Ind) { case SQL_NTS: if (sql_src_type == SQL_C_WCHAR) len = sqlwcslen((SQLWCHAR *) DataPtr); else len = strlen((char *) DataPtr); break; case SQL_NULL_DATA: len = 0; break; case SQL_DEFAULT_PARAM: /* FIXME: use the default if the parameter has one. */ odbc_errs_add(&stmt->errs, "07S01", NULL); /* Invalid use of default parameter */ return SQL_ERROR; default: if (DataPtr && StrLen_or_Ind < 0) { /* * "The argument DataPtr was not a null pointer, and * the argument StrLen_or_Ind was less than 0 * but not equal to SQL_NTS or SQL_NULL_DATA." */ odbc_errs_add(&stmt->errs, "HY090", NULL); return SQL_ERROR; } len = StrLen_or_Ind; break; } if (!blob && len > need_bytes) len = need_bytes; /* copy to destination */ if (blob) { TDS_CHAR *p; int binary_convert = 0; SQLLEN orig_len = len; if (sql_src_type == SQL_C_CHAR || sql_src_type == SQL_C_WCHAR) { switch (tds_get_conversion_type(curcol->column_type, curcol->column_size)) { case SYBBINARY: case SYBVARBINARY: case XSYBBINARY: case XSYBVARBINARY: case SYBLONGBINARY: case SYBIMAGE: if (len && sql_src_type == SQL_C_CHAR && !*((char*)DataPtr+len-1)) --len; if (sql_src_type == SQL_C_WCHAR) len /= sizeof(SQLWCHAR); if (!len) return SQL_SUCCESS; binary_convert = 1; orig_len = len; len = len / 2u + 1u; break; } } if (!len) return SQL_SUCCESS; assert(blob->textvalue || curcol->column_cur_size == 0); p = (TDS_CHAR *) TDS_RESIZE(blob->textvalue, len + curcol->column_cur_size); if (!p) { odbc_errs_add(&stmt->errs, "HY001", NULL); /* Memory allocation error */ return SQL_ERROR; } p += curcol->column_cur_size; if (binary_convert) { int res; len = orig_len; if (curcol->column_cur_size > 0 && curcol->column_text_sqlputdatainfo) { SQLWCHAR data[2]; data[0] = curcol->column_text_sqlputdatainfo; data[1] = (sql_src_type == SQL_C_CHAR) ? *(unsigned char*)DataPtr : *(SQLWCHAR*)DataPtr; res = odbc_wchar2hex(p, 1, data, 2); if (res < 0) { odbc_convert_err_set(&stmt->errs, res); return SQL_ERROR; } p += res; DataPtr = (SQLPOINTER) (((char*)DataPtr) + (sql_src_type == SQL_C_CHAR ? 1 : sizeof(SQLWCHAR))); --len; } if (len&1) { --len; curcol->column_text_sqlputdatainfo = (sql_src_type == SQL_C_CHAR) ? ((char*)DataPtr)[len] : ((SQLWCHAR*)DataPtr)[len]; } res = (sql_src_type == SQL_C_CHAR) ? tds_char2hex(p, len / 2u, (const TDS_CHAR*) DataPtr, len): odbc_wchar2hex(p, len / 2u, (const SQLWCHAR*) DataPtr, len); if (res < 0) { odbc_convert_err_set(&stmt->errs, res); return SQL_ERROR; } p += res; len = p - (blob->textvalue + curcol->column_cur_size); } else { memcpy(blob->textvalue + curcol->column_cur_size, DataPtr, len); } } else { memcpy(curcol->column_data + curcol->column_cur_size, DataPtr, len); } curcol->column_cur_size += len; if (blob && curcol->column_cur_size > curcol->column_size) curcol->column_size = curcol->column_cur_size; return SQL_SUCCESS; } freetds-1.00.82/src/odbc/odbc_util.c100644 025423 025423 00000075071 13013270622 0012642/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns * Copyright (C) 2005-2010 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include #include #include #include #include /** * \ingroup odbc_api * \defgroup odbc_util ODBC utility * Functions called within \c ODBC driver. */ /** * \addtogroup odbc_util * @{ */ #ifdef ENABLE_ODBC_WIDE static DSTR *odbc_iso2utf(DSTR *res, const char *s, unsigned int len); static DSTR *odbc_mb2utf(TDS_DBC *dbc, DSTR *res, const char *s, unsigned int len); static DSTR *odbc_wide2utf(DSTR *res, const SQLWCHAR *s, unsigned int len); #endif int odbc_set_stmt_query(TDS_STMT * stmt, const ODBC_CHAR *sql, int sql_len _WIDE) { if (sql_len == SQL_NTS) #ifdef ENABLE_ODBC_WIDE sql_len = wide ? sqlwcslen(sql->wide) : strlen(sql->mb); #else sql_len = strlen((const char*) sql); #endif else if (sql_len <= 0) return SQL_ERROR; /* TODO already NULL ?? */ tds_free_param_results(stmt->params); stmt->params = NULL; stmt->param_num = 0; stmt->param_count = 0; stmt->is_prepared_query = 0; stmt->prepared_query_is_func = 0; stmt->prepared_query_is_rpc = 0; stmt->prepared_pos = NULL; stmt->curr_param_row = 0; stmt->num_param_rows = 1; stmt->need_reprepare = 0; if (!odbc_dstr_copy(stmt->dbc, &stmt->query, sql_len, sql)) return SQL_ERROR; return SQL_SUCCESS; } unsigned int odbc_get_string_size(int size, const ODBC_CHAR * str _WIDE) { if (str) { if (size == SQL_NTS) #ifdef ENABLE_ODBC_WIDE return wide ? sqlwcslen(str->wide) : strlen(str->mb); #else return strlen((const char*) str); #endif if (size >= 0) return (unsigned int) size; } /* SQL_NULL_DATA or any other strange value */ return 0; } #ifdef ENABLE_ODBC_WIDE static DSTR* odbc_iso2utf(DSTR *res, const char *s, unsigned int len) { unsigned int i, o_len = len + 1; char *out, *p; assert(s); for (i = 0; i < len; ++i) if ((s[i] & 0x80) != 0) ++o_len; if (!tds_dstr_alloc(res, o_len)) return NULL; out = tds_dstr_buf(res); for (p = out; len > 0; --len) { unsigned char u = (unsigned char) *s++; if ((u & 0x80) != 0) { *p++ = 0xc0 | (0x1f & (u >> 6)); *p++ = 0x80 | (0x3f & u); } else { *p++ = u; } } assert(p+1-out <= o_len); return tds_dstr_setlen(res, p - out); } static DSTR* odbc_wide2utf(DSTR *res, const SQLWCHAR *s, unsigned int len) { unsigned int i, o_len = len + 1; char *out, *p; #if SIZEOF_SQLWCHAR > 2 # define MASK(n) ((0xffffffffu << (n)) & 0xffffffffu) #else # define MASK(n) ((0xffffu << (n)) & 0xffffu) #endif assert(s || len == 0); for (i = 0; i < len; ++i) { if ((s[i] & MASK(7)) == 0) continue; ++o_len; if ((s[i] & MASK(11)) == 0) continue; ++o_len; #if SIZEOF_SQLWCHAR > 2 if ((s[i] & MASK(16)) == 0) continue; ++o_len; if ((s[i] & MASK(21)) == 0) continue; ++o_len; if ((s[i] & MASK(26)) == 0) continue; ++o_len; #endif } if (!tds_dstr_alloc(res, o_len)) return NULL; out = tds_dstr_buf(res); for (p = out; len > 0; --len) { SQLWCHAR u = *s++; if ((u & MASK(7)) == 0) { *p++ = (char) u; continue; } if ((u & MASK(11)) == 0) { *p++ = 0xc0 | (0x1f & (u >> 6)); } else { #if SIZEOF_SQLWCHAR > 2 if ((u & MASK(16)) == 0) { *p++ = 0xe0 | (0x0f & (u >> 12)); } else { if ((u & MASK(21)) == 0) { if ((u & MASK(26)) == 0) { *p++ = 0xfc | (0x01 & (u >> 30)); *p++ = 0x80 | (0x3f & (u >> 24)); } else { *p++ = 0xf8 | (0x03 & (u >> 24)); } *p++ = 0x80 | (0x3f & (u >> 18)); } else { *p++ = 0xf0 | (0x07 & (u >> 18)); } *p++ = 0x80 | (0x3f & (u >> 12)); } *p++ = 0x80 | (0x3f & (u >> 6)); #else *p++ = 0xe0 | (0x0f & (u >> 12)); *p++ = 0x80 | (0x3f & (u >> 6)); #endif } *p++ = 0x80 | (0x3f & u); } assert(p+1-out <= o_len); return tds_dstr_setlen(res, p - out); } static DSTR* odbc_mb2utf(TDS_DBC *dbc, DSTR *res, const char *s, unsigned int len) { char *buf; const char *ib; char *ob; size_t il, ol; TDSICONV *char_conv = dbc->mb_conv; if (!char_conv) return odbc_iso2utf(res, s, len); if (char_conv->flags == TDS_ENCODING_MEMCPY) return tds_dstr_copyn(res, s, len); il = len; /* allocate needed buffer (+1 is to exclude 0 case) */ ol = il * char_conv->to.charset.max_bytes_per_char / char_conv->from.charset.min_bytes_per_char + 1; assert(ol > 0); if (!tds_dstr_alloc(res, ol)) return NULL; buf = tds_dstr_buf(res); ib = s; ob = buf; --ol; /* leave space for terminator */ /* char_conv is only mostly const */ memset((TDS_ERRNO_MESSAGE_FLAGS*) &char_conv->suppress, 0, sizeof(char_conv->suppress)); if (tds_iconv(dbc->tds_socket, char_conv, to_server, &ib, &il, &ob, &ol) == (size_t)-1) return NULL; return tds_dstr_setlen(res, ob - buf); } #endif #ifdef ENABLE_ODBC_WIDE DSTR* odbc_dstr_copy_flag(TDS_DBC *dbc, DSTR *s, int size, const ODBC_CHAR * str, int flag) { int wide = flag&1; unsigned int len; len = odbc_get_string_size((flag&0x21) == 0x21 && size >= 0 ? size/SIZEOF_SQLWCHAR : size, str, wide); if (wide) return odbc_wide2utf(s, str->wide, len); return odbc_mb2utf(dbc, s, str->mb, len); } #else DSTR* odbc_dstr_copy(TDS_DBC *dbc, DSTR *s, int size, const ODBC_CHAR * str) { return tds_dstr_copyn(s, (const char *) str, odbc_get_string_size(size, str)); } #endif /** * Copy a string to client setting size according to ODBC convenction * @param dbc database connection. Can be NULL * @param buffer client buffer * @param cbBuffer client buffer size (in bytes) * @param pcbBuffer pointer to SQLSMALLINT to hold string size * @param s string to copy * @param len len of string to copy. <0 null terminated * @param flag set of flag 0x10 SQLINTEGER */ SQLRETURN odbc_set_string_flag(TDS_DBC *dbc, SQLPOINTER buffer, SQLINTEGER cbBuffer, void FAR * pcbBuffer, const char *s, int len, int flag) { SQLRETURN result = SQL_SUCCESS; int out_len = 0; #if !defined(NDEBUG) && defined(ENABLE_ODBC_WIDE) size_t initial_size; #endif if (len < 0) len = strlen(s); if (cbBuffer < 0) cbBuffer = 0; #ifdef ENABLE_ODBC_WIDE if ((flag & 1) != 0) { /* wide characters */ const unsigned char *p = (const unsigned char*) s; SQLWCHAR *dest = (SQLWCHAR*) buffer; if (flag&0x20) cbBuffer /= SIZEOF_SQLWCHAR; #ifndef NDEBUG initial_size = cbBuffer; #endif while (len) { unsigned char mask; unsigned u; int l; if (!(p[0] & 0x80)) { mask = 0x7f; l = 1; } else if ((p[0] & 0xe0) == 0xc0) { mask = 0x1f; l = 2; } else if ((p[0] & 0xf0) == 0xe0) { mask = 0x0f; l = 3; } else if ((p[0] & 0xf8) == 0xf0) { mask = 0x07; l = 4; } else if ((p[0] & 0xfc) == 0xf8) { mask = 0x03; l = 5; } else { mask = 0x7f; l = 1; } if (len < l) break; len -= l; u = *p++ & mask; while(--l) u = (u << 6) | (*p++ & 0x3f); ++out_len; if (!dest) continue; if (cbBuffer > 1) { *dest++ = (SQLWCHAR) u; --cbBuffer; continue; } result = SQL_SUCCESS_WITH_INFO; } /* terminate buffer */ assert(dest == NULL || dest-(SQLWCHAR*) buffer == out_len || (dest-(SQLWCHAR*) buffer <= out_len && cbBuffer <= 1)); if (dest && cbBuffer) { *dest++ = 0; assert(dest-(SQLWCHAR*) buffer <= initial_size); } assert(dest == NULL || dest-(SQLWCHAR*) buffer <= initial_size); if (flag&0x20) out_len *= SIZEOF_SQLWCHAR; } else if (!dbc || !dbc->mb_conv) { /* to ISO-8859-1 */ const unsigned char *p = (const unsigned char*) s; unsigned char *dest = (unsigned char*) buffer; #ifndef NDEBUG initial_size = cbBuffer; #endif while (len) { unsigned char mask; unsigned u; int l; if (!(p[0] & 0x80)) { mask = 0x7f; l = 1; } else if ((p[0] & 0xe0) == 0xc0) { mask = 0x1f; l = 2; } else if ((p[0] & 0xf0) == 0xe0) { mask = 0x0f; l = 3; } else if ((p[0] & 0xf8) == 0xf0) { mask = 0x07; l = 4; } else if ((p[0] & 0xfc) == 0xf8) { mask = 0x03; l = 5; } else { mask = 0x7f; l = 1; } if (len < l) break; len -= l; u = *p++ & mask; while(--l) u = (u << 6) | (*p++ & 0x3f); ++out_len; if (!dest) continue; if (cbBuffer > 1) { *dest++ = u > 0x100 ? '?' : u; --cbBuffer; continue; } result = SQL_SUCCESS_WITH_INFO; } assert(dest == NULL || dest-(unsigned char*) buffer == out_len || (dest-(unsigned char*) buffer <= out_len && cbBuffer <= 1)); /* terminate buffer */ if (dest && cbBuffer) { *dest++ = 0; assert(dest-(unsigned char*) buffer <= initial_size); } assert(dest == NULL || dest-(unsigned char*) buffer <= initial_size); } else if (dbc->mb_conv->flags == TDS_ENCODING_MEMCPY) { /* to UTF-8 */ out_len = len; if (len >= cbBuffer) { len = cbBuffer - 1; result = SQL_SUCCESS_WITH_INFO; } if (buffer && len >= 0) { /* buffer can overlap, use memmove, thanks to Valgrind */ memmove((char *) buffer, s, len); ((char *) buffer)[len] = 0; } } else { const char *ib; char *ob; size_t il, ol; TDSICONV *char_conv = dbc->mb_conv; il = len; ib = s; ol = cbBuffer; ob = (char *) buffer; /* char_conv is only mostly const */ memset((TDS_ERRNO_MESSAGE_FLAGS*) &char_conv->suppress, 0, sizeof(char_conv->suppress)); char_conv->suppress.e2big = 1; if (cbBuffer && tds_iconv(dbc->tds_socket, char_conv, to_client, &ib, &il, &ob, &ol) == (size_t)-1 && errno != E2BIG) result = SQL_ERROR; out_len = cbBuffer - ol; while (result != SQL_ERROR && il) { char discard[128]; ol = sizeof(discard); ob = discard; char_conv->suppress.e2big = 1; if (tds_iconv(dbc->tds_socket, char_conv, to_client, &ib, &il, &ob, &ol) == (size_t)-1 && errno != E2BIG) result = SQL_ERROR; ol = sizeof(discard) - ol; /* if there are still left space copy the partial conversion */ if (out_len < cbBuffer) { size_t max_copy = cbBuffer - out_len; if (max_copy > ol) max_copy = ol; memcpy(((char *) buffer) + out_len, discard, max_copy); } out_len += ol; } if (out_len >= cbBuffer && result != SQL_ERROR) result = SQL_SUCCESS_WITH_INFO; if (buffer && cbBuffer > 0) ((char *) buffer)[cbBuffer-1 < out_len ? cbBuffer-1:out_len] = 0; } #else out_len = len; if (len >= cbBuffer) { len = cbBuffer - 1; result = SQL_SUCCESS_WITH_INFO; } if (buffer && len >= 0) { /* buffer can overlap, use memmove, thanks to Valgrind */ memmove((char *) buffer, s, len); ((char *) buffer)[len] = 0; } #endif /* set output length */ if (pcbBuffer) { if (flag & 0x10) *((SQLINTEGER *) pcbBuffer) = out_len; else *((SQLSMALLINT *) pcbBuffer) = out_len; } return result; } void odbc_set_return_status(struct _hstmt *stmt, unsigned int n_row) { TDSSOCKET *tds = stmt->tds; /* TODO handle different type results (functions) on mssql2k */ if (stmt->prepared_query_is_func && tds->has_status) { struct _drecord *drec; int len; const TDS_DESC* axd = stmt->apd; TDS_INTPTR len_offset; char *data_ptr; if (axd->header.sql_desc_count < 1) return; drec = &axd->records[0]; data_ptr = (char*) drec->sql_desc_data_ptr; if (axd->header.sql_desc_bind_type != SQL_BIND_BY_COLUMN) { len_offset = axd->header.sql_desc_bind_type * n_row; if (axd->header.sql_desc_bind_offset_ptr) len_offset += *axd->header.sql_desc_bind_offset_ptr; data_ptr += len_offset; } else { len_offset = sizeof(SQLLEN) * n_row; data_ptr += sizeof(SQLINTEGER) * n_row; } #define LEN(ptr) *((SQLLEN*)(((char*)(ptr)) + len_offset)) len = odbc_tds2sql(stmt, NULL, SYBINT4, (TDS_CHAR *) & tds->ret_status, sizeof(TDS_INT), drec->sql_desc_concise_type, (TDS_CHAR *) data_ptr, drec->sql_desc_octet_length, NULL); if (len == SQL_NULL_DATA) return /* SQL_ERROR */ ; if (drec->sql_desc_indicator_ptr) LEN(drec->sql_desc_indicator_ptr) = 0; if (drec->sql_desc_octet_length_ptr) LEN(drec->sql_desc_octet_length_ptr) = len; } #undef LEN } void odbc_set_return_params(struct _hstmt *stmt, unsigned int n_row) { TDSSOCKET *tds = stmt->tds; TDSPARAMINFO *info = tds->current_results; int i_begin = stmt->prepared_query_is_func ? 1 : 0; int i; int nparam = i_begin; /* I don't understand why but this happen -- freddy77 */ /* TODO check why, put an assert ? */ if (!info) return; for (i = 0; i < info->num_cols; ++i) { const TDS_DESC* axd = stmt->apd; const struct _drecord *drec_apd, *drec_ipd; TDSCOLUMN *colinfo = info->columns[i]; TDS_CHAR *src; int srclen; SQLINTEGER len; int c_type; char *data_ptr; TDS_INTPTR len_offset; /* find next output parameter */ for (;;) { drec_apd = NULL; /* TODO best way to stop */ if (nparam >= axd->header.sql_desc_count || nparam >= stmt->ipd->header.sql_desc_count) return; drec_apd = &axd->records[nparam]; drec_ipd = &stmt->ipd->records[nparam]; if (stmt->ipd->records[nparam++].sql_desc_parameter_type != SQL_PARAM_INPUT) break; } data_ptr = (char*) drec_apd->sql_desc_data_ptr; if (axd->header.sql_desc_bind_type != SQL_BIND_BY_COLUMN) { len_offset = axd->header.sql_desc_bind_type * n_row; if (axd->header.sql_desc_bind_offset_ptr) len_offset += *axd->header.sql_desc_bind_offset_ptr; data_ptr += len_offset; } else { len_offset = sizeof(SQLLEN) * n_row; data_ptr += odbc_get_octet_len(drec_apd->sql_desc_concise_type, drec_apd) * n_row; } #define LEN(ptr) *((SQLLEN*)(((char*)(ptr)) + len_offset)) /* null parameter ? */ if (colinfo->column_cur_size < 0) { /* FIXME error if NULL */ if (drec_apd->sql_desc_indicator_ptr) LEN(drec_apd->sql_desc_indicator_ptr) = SQL_NULL_DATA; continue; } src = (TDS_CHAR *) colinfo->column_data; colinfo->column_text_sqlgetdatapos = 0; srclen = colinfo->column_cur_size; c_type = drec_apd->sql_desc_concise_type; if (c_type == SQL_C_DEFAULT) c_type = odbc_sql_to_c_type_default(drec_ipd->sql_desc_concise_type); /* * TODO why IPD ?? perhaps SQLBindParameter it's not correct ?? * Or tests are wrong ?? */ len = odbc_tds2sql(stmt, colinfo, tds_get_conversion_type(colinfo->on_server.column_type, colinfo->on_server.column_size), src, srclen, c_type, (TDS_CHAR*) data_ptr, drec_apd->sql_desc_octet_length, drec_ipd); if (len == SQL_NULL_DATA) return /* SQL_ERROR */ ; if (drec_apd->sql_desc_indicator_ptr) LEN(drec_apd->sql_desc_indicator_ptr) = 0; if (drec_apd->sql_desc_octet_length_ptr) LEN(drec_apd->sql_desc_octet_length_ptr) = len; #undef LEN } } /** * Pass this an SQL_C_* type and get a SYB* type which most closely corresponds * to the SQL_C_* type. * This function can return XSYBNVARCHAR or SYBUINTx even if server do not support it */ TDS_SERVER_TYPE odbc_c_to_server_type(int c_type) { switch (c_type) { /* FIXME this should be dependent on size of data !!! */ case SQL_C_BINARY: return SYBBINARY; #ifdef SQL_C_WCHAR case SQL_C_WCHAR: return XSYBNVARCHAR; #endif /* TODO what happen if varchar is more than 255 characters long */ case SQL_C_CHAR: return SYBVARCHAR; case SQL_C_FLOAT: return SYBREAL; case SQL_C_DOUBLE: return SYBFLT8; case SQL_C_BIT: return SYBBIT; #if (ODBCVER >= 0x0300) case SQL_C_UBIGINT: return SYBUINT8; case SQL_C_SBIGINT: return SYBINT8; #ifdef SQL_C_GUID case SQL_C_GUID: return SYBUNIQUE; #endif #endif case SQL_C_ULONG: return SYBUINT4; case SQL_C_LONG: case SQL_C_SLONG: return SYBINT4; case SQL_C_USHORT: return SYBUINT2; case SQL_C_SHORT: case SQL_C_SSHORT: return SYBINT2; case SQL_C_STINYINT: case SQL_C_TINYINT: case SQL_C_UTINYINT: return SYBINT1; /* ODBC date formats are completely differect from SQL one */ case SQL_C_DATE: case SQL_C_TIME: case SQL_C_TIMESTAMP: case SQL_C_TYPE_DATE: case SQL_C_TYPE_TIME: case SQL_C_TYPE_TIMESTAMP: return SYBMSDATETIME2; /* ODBC numeric/decimal formats are completely differect from tds one */ case SQL_C_NUMERIC: return SYBNUMERIC; /* not supported */ case SQL_C_INTERVAL_YEAR: case SQL_C_INTERVAL_MONTH: case SQL_C_INTERVAL_DAY: case SQL_C_INTERVAL_HOUR: case SQL_C_INTERVAL_MINUTE: case SQL_C_INTERVAL_SECOND: case SQL_C_INTERVAL_YEAR_TO_MONTH: case SQL_C_INTERVAL_DAY_TO_HOUR: case SQL_C_INTERVAL_DAY_TO_MINUTE: case SQL_C_INTERVAL_DAY_TO_SECOND: case SQL_C_INTERVAL_HOUR_TO_MINUTE: case SQL_C_INTERVAL_HOUR_TO_SECOND: case SQL_C_INTERVAL_MINUTE_TO_SECOND: break; } return TDS_INVALID_TYPE; } int odbc_sql_to_c_type_default(int sql_type) { switch (sql_type) { case SQL_CHAR: case SQL_VARCHAR: case SQL_LONGVARCHAR: /* these types map to SQL_C_CHAR for compatibility with old applications */ #ifdef SQL_C_WCHAR case SQL_WCHAR: case SQL_WVARCHAR: case SQL_WLONGVARCHAR: #endif return SQL_C_CHAR; /* for compatibility numeric are converted to CHAR, not to structure */ case SQL_DECIMAL: case SQL_NUMERIC: return SQL_C_CHAR; #ifdef SQL_GUID case SQL_GUID: /* TODO return SQL_C_CHAR for Sybase ?? */ return SQL_C_GUID; #endif case SQL_BIT: return SQL_C_BIT; case SQL_TINYINT: return SQL_C_UTINYINT; case SQL_SMALLINT: return SQL_C_SSHORT; case SQL_INTEGER: return SQL_C_SLONG; case SQL_BIGINT: return SQL_C_SBIGINT; case SQL_REAL: return SQL_C_FLOAT; case SQL_FLOAT: case SQL_DOUBLE: return SQL_C_DOUBLE; case SQL_DATE: case SQL_TYPE_DATE: return SQL_C_TYPE_DATE; case SQL_TIME: case SQL_TYPE_TIME: return SQL_C_TYPE_TIME; case SQL_TIMESTAMP: case SQL_TYPE_TIMESTAMP: return SQL_C_TYPE_TIMESTAMP; case SQL_BINARY: case SQL_VARBINARY: case SQL_LONGVARBINARY: return SQL_C_BINARY; /* TODO interval types */ default: return 0; } } TDS_SERVER_TYPE odbc_sql_to_server_type(TDSCONNECTION * conn, int sql_type, int sql_unsigned) { switch (sql_type) { case SQL_WCHAR: if (IS_TDS7_PLUS(conn)) return XSYBNCHAR; case SQL_CHAR: return SYBCHAR; case SQL_WVARCHAR: if (IS_TDS7_PLUS(conn)) return XSYBNVARCHAR; case SQL_VARCHAR: return SYBVARCHAR; case SQL_SS_VARIANT: if (IS_TDS71_PLUS(conn)) return SYBVARIANT; if (IS_TDS7_PLUS(conn)) return XSYBNVARCHAR; return SYBVARCHAR; case SQL_SS_XML: if (IS_TDS72_PLUS(conn)) return SYBMSXML; case SQL_WLONGVARCHAR: if (IS_TDS7_PLUS(conn)) return SYBNTEXT; /* fall thought */ case SQL_LONGVARCHAR: return SYBTEXT; case SQL_DECIMAL: return SYBDECIMAL; case SQL_NUMERIC: return SYBNUMERIC; #ifdef SQL_GUID case SQL_GUID: if (IS_TDS7_PLUS(conn)) return SYBUNIQUE; return TDS_INVALID_TYPE; #endif case SQL_BIT: if (IS_TDS7_PLUS(conn)) return SYBBITN; return SYBBIT; case SQL_TINYINT: return SYBINT1; case SQL_SMALLINT: if (sql_unsigned && tds_capability_has_req(conn, TDS_REQ_DATA_UINT2)) return SYBUINT2; return SYBINT2; case SQL_INTEGER: if (sql_unsigned && tds_capability_has_req(conn, TDS_REQ_DATA_UINT4)) return SYBUINT4; return SYBINT4; case SQL_BIGINT: if (sql_unsigned && tds_capability_has_req(conn, TDS_REQ_DATA_UINT8)) return SYBUINT8; return SYBINT8; case SQL_REAL: return SYBREAL; case SQL_FLOAT: case SQL_DOUBLE: return SYBFLT8; /* ODBC version 2 */ case SQL_DATE: case SQL_TIME: case SQL_TIMESTAMP: /* ODBC version 3 */ case SQL_TYPE_DATE: if (IS_TDS50(conn) && tds_capability_has_req(conn, TDS_REQ_DATA_BIGDATETIME)) return SYB5BIGDATETIME; if (IS_TDS50(conn) && tds_capability_has_req(conn, TDS_REQ_DATA_DATE)) return SYBDATE; if (IS_TDS73_PLUS(conn)) return SYBMSDATE; goto type_timestamp; case SQL_TYPE_TIME: if (IS_TDS50(conn) && tds_capability_has_req(conn, TDS_REQ_DATA_BIGTIME)) return SYB5BIGTIME; if (IS_TDS50(conn) && tds_capability_has_req(conn, TDS_REQ_DATA_TIME)) return SYBTIME; if (IS_TDS73_PLUS(conn)) return SYBMSTIME; type_timestamp: case SQL_TYPE_TIMESTAMP: if (IS_TDS73_PLUS(conn)) return SYBMSDATETIME2; if (IS_TDS50(conn) && tds_capability_has_req(conn, TDS_REQ_DATA_BIGDATETIME)) return SYB5BIGDATETIME; return SYBDATETIME; case SQL_SS_TIME2: if (IS_TDS73_PLUS(conn)) return SYBMSTIME; if (IS_TDS50(conn) && tds_capability_has_req(conn, TDS_REQ_DATA_BIGDATETIME)) return SYB5BIGDATETIME; return SYBDATETIME; case SQL_SS_TIMESTAMPOFFSET: if (IS_TDS73_PLUS(conn)) return SYBMSDATETIMEOFFSET; if (IS_TDS50(conn) && tds_capability_has_req(conn, TDS_REQ_DATA_BIGDATETIME)) return SYB5BIGDATETIME; return SYBDATETIME; case SQL_BINARY: return SYBBINARY; case SQL_VARBINARY: return SYBVARBINARY; case SQL_LONGVARBINARY: return SYBIMAGE; /* TODO interval types */ default: return TDS_INVALID_TYPE; } } /** Returns the version of the RDBMS in the ODBC format */ void odbc_rdbms_version(TDSSOCKET * tds, char *pversion_string) { TDS_UINT version = tds->conn->product_version; sprintf(pversion_string, "%.02d.%.02d.%.04d", (int) ((version & 0x7F000000) >> 24), (int) ((version & 0x00FF0000) >> 16), (int) (version & 0x0000FFFF)); } /** Return length of parameter from parameter information */ SQLINTEGER odbc_get_param_len(const struct _drecord *drec_axd, const struct _drecord *drec_ixd, const TDS_DESC* axd, unsigned int n_row) { SQLINTEGER len; int size; TDS_INTPTR len_offset; if (axd->header.sql_desc_bind_type != SQL_BIND_BY_COLUMN) { len_offset = axd->header.sql_desc_bind_type * n_row; if (axd->header.sql_desc_bind_offset_ptr) len_offset += *axd->header.sql_desc_bind_offset_ptr; } else { len_offset = sizeof(SQLLEN) * n_row; } #define LEN(ptr) *((SQLLEN*)(((char*)(ptr)) + len_offset)) if (drec_axd->sql_desc_indicator_ptr && LEN(drec_axd->sql_desc_indicator_ptr) == SQL_NULL_DATA) len = SQL_NULL_DATA; else if (drec_axd->sql_desc_octet_length_ptr) len = LEN(drec_axd->sql_desc_octet_length_ptr); else { len = 0; /* TODO add XML if defined */ /* FIXME, other types available */ if (drec_axd->sql_desc_concise_type == SQL_C_CHAR || drec_axd->sql_desc_concise_type == SQL_C_WCHAR || drec_axd->sql_desc_concise_type == SQL_C_BINARY) { len = SQL_NTS; } else { int type = drec_axd->sql_desc_concise_type; TDS_SERVER_TYPE server_type; if (type == SQL_C_DEFAULT) type = odbc_sql_to_c_type_default(drec_ixd->sql_desc_concise_type); server_type = odbc_c_to_server_type(type); /* FIXME check what happen to DATE/TIME types */ size = tds_get_size_by_type(server_type); if (size > 0) len = size; } } return len; #undef LEN } #ifdef SQL_GUID # define TYPE_NORMAL_SQL_GUID TYPE_NORMAL(SQL_GUID) #else # define TYPE_NORMAL_SQL_GUID #endif #define SQL_TYPES \ TYPE_NORMAL(SQL_BIT) \ TYPE_NORMAL(SQL_SMALLINT) \ TYPE_NORMAL(SQL_TINYINT) \ TYPE_NORMAL(SQL_INTEGER) \ TYPE_NORMAL(SQL_BIGINT) \ \ TYPE_NORMAL_SQL_GUID \ \ TYPE_NORMAL(SQL_BINARY) \ TYPE_NORMAL(SQL_VARBINARY) \ TYPE_NORMAL(SQL_LONGVARBINARY) \ \ TYPE_NORMAL(SQL_CHAR) \ TYPE_NORMAL(SQL_VARCHAR) \ TYPE_NORMAL(SQL_LONGVARCHAR) \ TYPE_NORMAL(SQL_WCHAR) \ TYPE_NORMAL(SQL_WVARCHAR) \ TYPE_NORMAL(SQL_WLONGVARCHAR) \ \ TYPE_NORMAL(SQL_DECIMAL) \ TYPE_NORMAL(SQL_NUMERIC) \ \ TYPE_NORMAL(SQL_FLOAT) \ TYPE_NORMAL(SQL_REAL) \ TYPE_NORMAL(SQL_DOUBLE)\ \ TYPE_NORMAL(SQL_SS_TIMESTAMPOFFSET) \ TYPE_NORMAL(SQL_SS_TIME2) \ TYPE_NORMAL(SQL_SS_XML) \ TYPE_NORMAL(SQL_SS_VARIANT) \ TYPE_NORMAL(SQL_TYPE_DATE) \ \ TYPE_VERBOSE_START(SQL_DATETIME) \ TYPE_VERBOSE_DATE(SQL_DATETIME, SQL_CODE_TIMESTAMP, SQL_TYPE_TIMESTAMP, SQL_TIMESTAMP) \ TYPE_VERBOSE_END(SQL_DATETIME) SQLSMALLINT odbc_get_concise_sql_type(SQLSMALLINT type, SQLSMALLINT interval) { #define TYPE_NORMAL(t) case t: return type; #define TYPE_VERBOSE_START(t) \ case t: switch (interval) { #define TYPE_VERBOSE_DATE(t, interval, concise, old) \ case interval: return concise; #define TYPE_VERBOSE_END(t) \ } switch (type) { SQL_TYPES; } return 0; #undef TYPE_NORMAL #undef TYPE_VERBOSE_START #undef TYPE_VERBOSE_DATE #undef TYPE_VERBOSE_END } /** * Set concise type and all cascading field. * @param concise_type concise type to set * @param drec record to set. NULL to test error without setting * @param check_only it <>0 (true) check only, do not set type */ SQLRETURN odbc_set_concise_sql_type(SQLSMALLINT concise_type, struct _drecord * drec, int check_only) { SQLSMALLINT type = concise_type, interval_code = 0; #define TYPE_NORMAL(t) case t: break; #define TYPE_VERBOSE_START(t) #define TYPE_VERBOSE_DATE(t, interval, concise, old) \ case old: concise_type = concise; \ case concise: type = t; interval_code = interval; break; #define TYPE_VERBOSE_END(t) switch (type) { SQL_TYPES; default: return SQL_ERROR; } if (!check_only) { drec->sql_desc_concise_type = concise_type; drec->sql_desc_type = type; drec->sql_desc_datetime_interval_code = interval_code; switch (drec->sql_desc_type) { case SQL_NUMERIC: case SQL_DECIMAL: drec->sql_desc_precision = 38; drec->sql_desc_scale = 0; break; /* TODO finish */ } } return SQL_SUCCESS; #undef TYPE_NORMAL #undef TYPE_VERBOSE_START #undef TYPE_VERBOSE_DATE #undef TYPE_VERBOSE_END } #ifdef SQL_C_GUID # define TYPE_NORMAL_SQL_C_GUID TYPE_NORMAL(SQL_C_GUID) #else # define TYPE_NORMAL_SQL_C_GUID #endif #define C_TYPES \ TYPE_NORMAL(SQL_C_BIT) \ TYPE_NORMAL(SQL_C_SHORT) \ TYPE_NORMAL(SQL_C_TINYINT) \ TYPE_NORMAL(SQL_C_UTINYINT) \ TYPE_NORMAL(SQL_C_STINYINT) \ TYPE_NORMAL(SQL_C_LONG) \ TYPE_NORMAL(SQL_C_SBIGINT) \ TYPE_NORMAL(SQL_C_UBIGINT) \ TYPE_NORMAL(SQL_C_SSHORT) \ TYPE_NORMAL(SQL_C_SLONG) \ TYPE_NORMAL(SQL_C_USHORT) \ TYPE_NORMAL(SQL_C_ULONG) \ \ TYPE_NORMAL_SQL_C_GUID \ TYPE_NORMAL(SQL_C_DEFAULT) \ \ TYPE_NORMAL(SQL_C_BINARY) \ \ TYPE_NORMAL(SQL_C_CHAR) \ TYPE_NORMAL(SQL_C_WCHAR) \ \ TYPE_NORMAL(SQL_C_NUMERIC) \ \ TYPE_NORMAL(SQL_C_FLOAT) \ TYPE_NORMAL(SQL_C_DOUBLE)\ \ TYPE_VERBOSE_START(SQL_DATETIME) \ TYPE_VERBOSE_DATE(SQL_DATETIME, SQL_CODE_DATE, SQL_C_TYPE_DATE, SQL_C_DATE) \ TYPE_VERBOSE_DATE(SQL_DATETIME, SQL_CODE_TIME, SQL_C_TYPE_TIME, SQL_C_TIME) \ TYPE_VERBOSE_DATE(SQL_DATETIME, SQL_CODE_TIMESTAMP, SQL_C_TYPE_TIMESTAMP, SQL_C_TIMESTAMP) \ TYPE_VERBOSE_END(SQL_DATETIME) \ \ TYPE_VERBOSE_START(SQL_INTERVAL) \ TYPE_VERBOSE(SQL_INTERVAL, SQL_CODE_DAY, SQL_C_INTERVAL_DAY) \ TYPE_VERBOSE(SQL_INTERVAL, SQL_CODE_DAY_TO_HOUR, SQL_C_INTERVAL_DAY_TO_HOUR) \ TYPE_VERBOSE(SQL_INTERVAL, SQL_CODE_DAY_TO_MINUTE, SQL_C_INTERVAL_DAY_TO_MINUTE) \ TYPE_VERBOSE(SQL_INTERVAL, SQL_CODE_DAY_TO_SECOND, SQL_C_INTERVAL_DAY_TO_SECOND) \ TYPE_VERBOSE(SQL_INTERVAL, SQL_CODE_HOUR, SQL_C_INTERVAL_HOUR) \ TYPE_VERBOSE(SQL_INTERVAL, SQL_CODE_HOUR_TO_MINUTE, SQL_C_INTERVAL_HOUR_TO_MINUTE) \ TYPE_VERBOSE(SQL_INTERVAL, SQL_CODE_HOUR_TO_SECOND, SQL_C_INTERVAL_HOUR_TO_SECOND) \ TYPE_VERBOSE(SQL_INTERVAL, SQL_CODE_MINUTE, SQL_C_INTERVAL_MINUTE) \ TYPE_VERBOSE(SQL_INTERVAL, SQL_CODE_MINUTE_TO_SECOND, SQL_C_INTERVAL_MINUTE_TO_SECOND) \ TYPE_VERBOSE(SQL_INTERVAL, SQL_CODE_MONTH, SQL_C_INTERVAL_MONTH) \ TYPE_VERBOSE(SQL_INTERVAL, SQL_CODE_SECOND, SQL_C_INTERVAL_SECOND) \ TYPE_VERBOSE(SQL_INTERVAL, SQL_CODE_YEAR, SQL_C_INTERVAL_YEAR) \ TYPE_VERBOSE(SQL_INTERVAL, SQL_CODE_YEAR_TO_MONTH, SQL_C_INTERVAL_YEAR_TO_MONTH) \ TYPE_VERBOSE_END(SQL_INTERVAL) SQLSMALLINT odbc_get_concise_c_type(SQLSMALLINT type, SQLSMALLINT interval) { #define TYPE_NORMAL(t) case t: return type; #define TYPE_VERBOSE_START(t) \ case t: switch (interval) { #define TYPE_VERBOSE(t, interval, concise) \ case interval: return concise; #define TYPE_VERBOSE_DATE(t, interval, concise, old) \ case interval: return concise; #define TYPE_VERBOSE_END(t) \ } switch (type) { C_TYPES; } return 0; #undef TYPE_NORMAL #undef TYPE_VERBOSE_START #undef TYPE_VERBOSE #undef TYPE_VERBOSE_DATE #undef TYPE_VERBOSE_END } /** * Set concise type and all cascading field. * @param concise_type concise type to set * @param drec record to set. NULL to test error without setting * @param check_only it <>0 (true) check only, do not set type */ SQLRETURN odbc_set_concise_c_type(SQLSMALLINT concise_type, struct _drecord * drec, int check_only) { SQLSMALLINT type = concise_type, interval_code = 0; #define TYPE_NORMAL(t) case t: break; #define TYPE_VERBOSE_START(t) #define TYPE_VERBOSE(t, interval, concise) \ case concise: type = t; interval_code = interval; break; #define TYPE_VERBOSE_DATE(t, interval, concise, old) \ case concise: type = t; interval_code = interval; break; \ case old: concise_type = concise; type = t; interval_code = interval; break; #define TYPE_VERBOSE_END(t) switch (type) { C_TYPES; default: return SQL_ERROR; } if (!check_only) { drec->sql_desc_concise_type = concise_type; drec->sql_desc_type = type; drec->sql_desc_datetime_interval_code = interval_code; switch (drec->sql_desc_type) { case SQL_C_NUMERIC: drec->sql_desc_length = 38; drec->sql_desc_precision = 38; drec->sql_desc_scale = 0; break; /* TODO finish */ } } return SQL_SUCCESS; #undef TYPE_NORMAL #undef TYPE_VERBOSE_START #undef TYPE_VERBOSE #undef TYPE_VERBOSE_DATE #undef TYPE_VERBOSE_END } SQLLEN odbc_get_octet_len(int c_type, const struct _drecord *drec) { SQLLEN len; /* this shit is mine -- freddy77 */ switch (c_type) { case SQL_C_CHAR: case SQL_C_WCHAR: case SQL_C_BINARY: len = drec->sql_desc_octet_length; break; case SQL_C_DATE: case SQL_C_TYPE_DATE: len = sizeof(DATE_STRUCT); break; case SQL_C_TIME: case SQL_C_TYPE_TIME: len = sizeof(TIME_STRUCT); break; case SQL_C_TIMESTAMP: case SQL_C_TYPE_TIMESTAMP: len = sizeof(TIMESTAMP_STRUCT); break; case SQL_C_NUMERIC: len = sizeof(SQL_NUMERIC_STRUCT); break; default: len = tds_get_size_by_type(odbc_c_to_server_type(c_type)); break; } return len; } void odbc_convert_err_set(struct _sql_errors *errs, TDS_INT err) { /* * TODO we really need a column offset in the _sql_error structure so that caller can * invoke SQLGetDiagField to learn which column is failing */ switch (err) { case TDS_CONVERT_NOAVAIL: odbc_errs_add(errs, "HY003", NULL); break; case TDS_CONVERT_SYNTAX: odbc_errs_add(errs, "22018", NULL); break; case TDS_CONVERT_OVERFLOW: odbc_errs_add(errs, "22003", NULL); break; case TDS_CONVERT_FAIL: odbc_errs_add(errs, "07006", NULL); break; case TDS_CONVERT_NOMEM: odbc_errs_add(errs, "HY001", NULL); break; } } /** @} */ freetds-1.00.82/src/odbc/bcp.c100644 025423 025423 00000046411 12726516341 0011451/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns * Copyright (C) 2010, 2011 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #include #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #ifdef _WIN32 #include #endif #include #include #include #include #include #define TDSODBC_BCP #include static TDSRET _bcp_get_col_data(TDSBCPINFO *bcpinfo, TDSCOLUMN *bindcol, int offset); static SQLLEN _bcp_get_term_var(const TDS_CHAR * pdata, const TDS_CHAR * term, int term_len); #define ODBCBCP_ERROR_RETURN(code) \ do {odbc_errs_add(&dbc->errs, code, NULL); return;} while(0) #define ODBCBCP_ERROR_DBINT(code) \ do {odbc_errs_add(&dbc->errs, code, NULL); return -1;} while(0) /** * \ingroup odbc_bcp * \brief Prepare for bulk copy operation on a table * * \param dbc ODBC database connection object * \param tblname the name of the table receiving or providing the data. * \param hfile the data file opposite the table, if any. NB: The current * implementation does not support file I/O so this must be NULL * \param errfile the "error file" captures messages and, if errors are * encountered. NB: The current implementation does not support * file I/O so this must be NULL * \param direction one of * - \b DB_IN writing to the table * - \b DB_OUT writing to the host file (Not currently supported) * . * \remarks bcp_init() sets the host file data format and acquires the table metadata. * It is called before the other bulk copy functions. * * The ODBC BCP functionality should be accessed via the inline functions in * odbcss.h. * * After calling this function, call bcp_bind() to associate your data with * the appropriate table column. * * \sa SQL_COPT_SS_BCP, odbc_bcp_bind(), odbc_bcp_done(), odbc_bcp_exec() */ void odbc_bcp_init(TDS_DBC *dbc, const ODBC_CHAR *tblname, const ODBC_CHAR *hfile, const ODBC_CHAR *errfile, int direction _WIDE) { if (TDS_UNLIKELY(tds_write_dump)) { #ifdef ENABLE_ODBC_WIDE if (wide) { SQLWSTR_BUFS(3); tdsdump_log(TDS_DBG_FUNC, "bcp_initW(%p, %ls, %ls, %ls, %d)\n", dbc, SQLWSTR(tblname->wide), SQLWSTR(hfile->wide), SQLWSTR(errfile->wide), direction); SQLWSTR_FREE(); } else { #endif tdsdump_log(TDS_DBG_FUNC, "bcp_init(%p, %s, %s, %s, %d)\n", dbc, tblname->mb, hfile->mb, errfile->mb, direction); #ifdef ENABLE_ODBC_WIDE } #endif } if (!tblname) ODBCBCP_ERROR_RETURN("HY009"); /* Free previously allocated storage in dbproc & initialise flags, etc. */ odbc_bcp_free_storage(dbc); /* * Validate other parameters */ if (dbc->tds_socket->conn->tds_version < 0x500) ODBCBCP_ERROR_RETURN("HYC00"); if (direction != BCP_DIRECTION_IN || hfile || errfile) ODBCBCP_ERROR_RETURN("HYC00"); /* Allocate storage */ dbc->bcpinfo = tds_alloc_bcpinfo(); if (dbc->bcpinfo == NULL) ODBCBCP_ERROR_RETURN("HY001"); if (!odbc_dstr_copy(dbc, &dbc->bcpinfo->tablename, SQL_NTS, tblname)) { odbc_bcp_free_storage(dbc); ODBCBCP_ERROR_RETURN("HY001"); } if (tds_dstr_len(&dbc->bcpinfo->tablename) > 92 && !IS_TDS7_PLUS(dbc->tds_socket->conn)) { /* 30.30.30 */ odbc_bcp_free_storage(dbc); ODBCBCP_ERROR_RETURN("HYC00"); } dbc->bcpinfo->direction = direction; dbc->bcpinfo->xfer_init = 0; dbc->bcpinfo->bind_count = 0; if (TDS_FAILED(tds_bcp_init(dbc->tds_socket, dbc->bcpinfo))) { /* TODO return proper error */ /* Attempt to use Bulk Copy with a non-existent Server table (might be why ...) */ ODBCBCP_ERROR_RETURN("HY000"); } } /** * \ingroup odbc_bcp * \brief Set BCP options for data transfer * * \param dbc ODBC database connection object * \param field symbolic constant indicating the option to be set, one of: * - \b BCPKEEPIDENTITY Enable identity insert, as if by executing * 'SET IDENTITY_INSERT \a table ON'. The default is off * - \b BCPHINTS Arbitrary extra text to pass to the server. See the * documentation for the bcp command-line tool which came with your * database server for the correct syntax. * \param value The value for \a field. * * \remarks These options control the behavior of bcp_sendrow(). * * \sa odbc_bcp_batch(), odbc_bcp_init(), odbc_bcp_done() */ void odbc_bcp_control(TDS_DBC *dbc, int field, void *value) { tdsdump_log(TDS_DBG_FUNC, "bcp_control(%p, %d, %p)\n", dbc, field, value); if (dbc->bcpinfo == NULL) ODBCBCP_ERROR_RETURN("HY010"); switch (field) { case BCPKEEPIDENTITY: dbc->bcpinfo->identity_insert_on = (value != NULL); break; case BCPHINTS: if (!value) ODBCBCP_ERROR_RETURN("HY009"); dbc->bcphint = strdup((char*)value); dbc->bcpinfo->hint = dbc->bcphint; break; default: ODBCBCP_ERROR_RETURN("HY009"); } } /** * \ingroup odbc_bcp * \brief Override bcp_bind() by pointing to a different host variable. * * \param dbc ODBC database connection object * \param colptr The pointer, the address of your variable. * \param table_column The 1-based column ordinal in the table. * \remarks Use between calls to bcp_sendrow(). After calling bcp_colptr(), * subsequent calls to bcp_sendrow() will bind to the new address. * \sa odbc_bcp_bind(), odbc_bcp_sendrow() */ void odbc_bcp_colptr(TDS_DBC *dbc, const void * colptr, int table_column) { TDSCOLUMN *curcol; tdsdump_log(TDS_DBG_FUNC, "bcp_colptr(%p, %p, %d)\n", dbc, colptr, table_column); if (dbc->bcpinfo == NULL || dbc->bcpinfo->bindinfo == NULL) ODBCBCP_ERROR_RETURN("HY010"); /* colptr can be NULL */ if (dbc->bcpinfo->direction != BCP_DIRECTION_IN) ODBCBCP_ERROR_RETURN("HY010"); if (table_column <= 0 || table_column > dbc->bcpinfo->bindinfo->num_cols) ODBCBCP_ERROR_RETURN("HY009"); curcol = dbc->bcpinfo->bindinfo->columns[table_column - 1]; curcol->column_varaddr = (TDS_CHAR *)colptr; } /** * \ingroup odbc_bcp * \brief Write data in host variables to the table. * * \param dbc ODBC database connection object * * \remarks Call bcp_bind() first to describe the variables to be used. * Use bcp_batch() to commit sets of rows. * After sending the last row call bcp_done(). * \sa odbc_bcp_batch(), odbc_bcp_bind(), odbc_bcp_colptr(), odbc_bcp_done(), * odbc_bcp_init() */ void odbc_bcp_sendrow(TDS_DBC *dbc) { TDSSOCKET *tds; tdsdump_log(TDS_DBG_FUNC, "bcp_sendrow(%p)\n", dbc); if (dbc->bcpinfo == NULL) ODBCBCP_ERROR_RETURN("HY010"); tds = dbc->tds_socket; if (dbc->bcpinfo->direction != BCP_DIRECTION_IN) ODBCBCP_ERROR_RETURN("HY010"); /* * The first time sendrow is called after bcp_init, * there is a certain amount of initialisation to be done. */ if (dbc->bcpinfo->xfer_init == 0) { /* The start_copy function retrieves details of the table's columns */ if (TDS_FAILED(tds_bcp_start_copy_in(tds, dbc->bcpinfo))) ODBCBCP_ERROR_RETURN("HY000"); dbc->bcpinfo->xfer_init = 1; } dbc->bcpinfo->parent = dbc; if (TDS_FAILED(tds_bcp_send_record(dbc->tds_socket, dbc->bcpinfo, _bcp_get_col_data, NULL, 0))) ODBCBCP_ERROR_RETURN("HY000"); } /** * \ingroup odbc_bcp * \brief Commit a set of rows to the table. * * \param dbc ODBC database connection object * \remarks If not called, bcp_done() will cause the rows to be saved. * \return Count of rows saved, or -1 on error. * \sa odbc_bcp_bind(), odbc_bcp_done(), odbc_bcp_sendrow() */ int odbc_bcp_batch(TDS_DBC *dbc) { int rows_copied = 0; tdsdump_log(TDS_DBG_FUNC, "bcp_batch(%p)\n", dbc); if (dbc->bcpinfo == NULL) ODBCBCP_ERROR_DBINT("HY010"); if (TDS_FAILED(tds_bcp_done(dbc->tds_socket, &rows_copied))) ODBCBCP_ERROR_DBINT("HY000"); tds_bcp_start(dbc->tds_socket, dbc->bcpinfo); return rows_copied; } /** * \ingroup odbc_bcp * \brief Conclude the transfer of data from program variables. * * \param dbc ODBC database connection object * \remarks Do not overlook this function. According to Sybase, failure to call bcp_done() * "will result in unpredictable errors". * \return As with bcp_batch(), the count of rows saved, or -1 on error. * \sa bcp_batch(), bcp_bind(), bcp_moretext(), bcp_sendrow() */ int odbc_bcp_done(TDS_DBC *dbc) { int rows_copied; tdsdump_log(TDS_DBG_FUNC, "bcp_done(%p)\n", dbc); if (!(dbc->bcpinfo)) ODBCBCP_ERROR_DBINT("HY010"); if (TDS_FAILED(tds_bcp_done(dbc->tds_socket, &rows_copied))) ODBCBCP_ERROR_DBINT("HY000"); odbc_bcp_free_storage(dbc); return rows_copied; } /** * \ingroup odbc_bcp * \brief Bind a program host variable to a database column * * \param dbc ODBC database connection object * \param varaddr address of host variable * \param prefixlen length of any prefix found at the beginning of \a varaddr, in bytes. * Use zero for fixed-length datatypes. * \param varlen bytes of data in \a varaddr. Zero for NULL, -1 for fixed-length datatypes. * \param terminator byte sequence that marks the end of the data in \a varaddr * \param termlen length of \a terminator * \param vartype datatype of the host variable * \param table_column Nth column, starting at 1, in the table. * * \remarks The order of operation is: * - bcp_init() with \a hfile == NULL and \a direction == DB_IN. * - bcp_bind(), once per column you want to write to * - bcp_batch(), optionally, to commit a set of rows * - bcp_done() * * \sa odbc_bcp_batch(), odbc_bcp_done(), odbc_bcp_sendrow() */ void odbc_bcp_bind(TDS_DBC *dbc, const void * varaddr, int prefixlen, int varlen, const void * terminator, int termlen, int vartype, int table_column) { TDSCOLUMN *colinfo; tdsdump_log(TDS_DBG_FUNC, "bcp_bind(%p, %p, %d, %d -- %p, %d, %d, %d)\n", dbc, varaddr, prefixlen, varlen, terminator, termlen, vartype, table_column); if (!dbc->bcpinfo) ODBCBCP_ERROR_RETURN("HY010"); if (dbc->bcpinfo->direction != BCP_DIRECTION_IN) ODBCBCP_ERROR_RETURN("HY010"); if (varlen < -1 && varlen != SQL_VARLEN_DATA) ODBCBCP_ERROR_RETURN("HY009"); if (prefixlen != 0 && prefixlen != 1 && prefixlen != 2 && prefixlen != 4 && prefixlen != 8) ODBCBCP_ERROR_RETURN("HY009"); if (vartype != 0 && !is_tds_type_valid(vartype)) ODBCBCP_ERROR_RETURN("HY004"); if (prefixlen == 0 && varlen == SQL_VARLEN_DATA && termlen == -1 && !is_fixed_type(vartype)) { tdsdump_log(TDS_DBG_FUNC, "bcp_bind(): non-fixed type %d requires prefix or terminator\n", vartype); ODBCBCP_ERROR_RETURN("HY009"); } if (table_column <= 0 || table_column > dbc->bcpinfo->bindinfo->num_cols) ODBCBCP_ERROR_RETURN("HY009"); if (varaddr == NULL && (prefixlen != 0 || termlen != 0)) ODBCBCP_ERROR_RETURN("HY009"); colinfo = dbc->bcpinfo->bindinfo->columns[table_column - 1]; /* If varaddr is NULL and varlen greater than 0, the table column type must be SYBTEXT or SYBIMAGE and the program variable type must be SYBTEXT, SYBCHAR, SYBIMAGE or SYBBINARY */ if (varaddr == NULL && varlen >= 0) { int fOK = (colinfo->column_type == SYBTEXT || colinfo->column_type == SYBIMAGE) && (vartype == SYBTEXT || vartype == SYBCHAR || vartype == SYBIMAGE || vartype == SYBBINARY ); if( !fOK ) { tdsdump_log(TDS_DBG_FUNC, "bcp_bind: SYBEBCBNTYP: column=%d and vartype=%d (should fail?)\n", colinfo->column_type, vartype); ODBCBCP_ERROR_RETURN("HY009"); } } colinfo->column_varaddr = (char *)varaddr; colinfo->column_bindtype = vartype; colinfo->column_bindlen = varlen; colinfo->bcp_prefix_len = prefixlen; TDS_ZERO_FREE(colinfo->bcp_terminator); colinfo->bcp_term_len = 0; if (termlen > 0) { if ((colinfo->bcp_terminator = tds_new(TDS_CHAR, termlen)) == NULL) ODBCBCP_ERROR_RETURN("HY001"); memcpy(colinfo->bcp_terminator, terminator, termlen); colinfo->bcp_term_len = termlen; } } static SQLLEN _bcp_iconv_helper(const TDS_DBC *dbc, const TDSCOLUMN *bindcol, const TDS_CHAR * src, size_t srclen, char * dest, size_t destlen) { if (bindcol->char_conv) { char *orig_dest = dest; if (tds_iconv(dbc->tds_socket, bindcol->char_conv, to_server, &src, &srclen, &dest, &destlen) == (size_t)-1) return -1; return dest - orig_dest; } if (destlen > srclen) destlen = srclen; memcpy(dest, src, destlen); return destlen; } static SQLLEN _tdsodbc_dbconvert(TDS_DBC *dbc, int srctype, const TDS_CHAR * src, SQLLEN src_len, int desttype, unsigned char * dest, TDSCOLUMN *bindcol) { CONV_RESULT dres; SQLLEN ret; SQLLEN len; SQLLEN destlen = bindcol->column_size; TDS_DATETIMEALL dta; TDS_NUMERIC num; SQL_NUMERIC_STRUCT * sql_num; int always_convert = 0; assert(src_len >= 0); assert(src != NULL); assert(dest != NULL); assert(destlen > 0); tdsdump_log(TDS_DBG_FUNC, "tdsodbc_dbconvert(%p, %d, %p, %d, %d, %p, %d)\n", dbc, srctype, src, (int)src_len, desttype, dest, (int)destlen); switch (srctype) { case SYBMSDATETIME2: convert_datetime2server(SQL_C_TYPE_TIMESTAMP, src, &dta); dta.time_prec = (destlen - 40) / 2; src = (char *) &dta; break; case SYBDECIMAL: case SYBNUMERIC: sql_num = (SQL_NUMERIC_STRUCT *) src; num.precision = sql_num->precision; num.scale = sql_num->scale; num.array[0] = sql_num->sign ^ 1; /* test precision so client do not crash our library */ if (num.precision <= 0 || num.precision > 38 || num.scale > num.precision) /* TODO add proper error */ return -1; len = tds_numeric_bytes_per_prec[num.precision]; memcpy(num.array + 1, sql_num->val, len - 1); tds_swap_bytes(num.array + 1, len - 1); if (len < sizeof(num.array)) memset(num.array + len, 0, sizeof(num.array) - len); src = (char *) # always_convert = num.scale != bindcol->column_scale; break; /* TODO intervals */ } /* oft times we are asked to convert a data type to itself */ if ((srctype == desttype || is_similar_type(srctype, desttype)) && !always_convert) { if (is_char_type(desttype)) { ret = _bcp_iconv_helper(dbc, bindcol, src, src_len, (char *)dest, destlen); } else { ret = destlen < src_len ? destlen : src_len; memcpy(dest, src, ret); } return ret; } tdsdump_log(TDS_DBG_INFO1, "dbconvert() calling tds_convert\n"); if (is_numeric_type(desttype)) { dres.n.precision = bindcol->column_prec; dres.n.scale = bindcol->column_scale; } len = tds_convert(dbc->env->tds_ctx, srctype, src, src_len, desttype, &dres); tdsdump_log(TDS_DBG_INFO1, "dbconvert() called tds_convert returned %d\n", (int)len); if (len < 0) { odbc_convert_err_set(&dbc->errs, len); return -1; } switch (desttype) { case SYBBINARY: case SYBVARBINARY: case SYBIMAGE: ret = destlen < len ? destlen : len; memcpy(dest, dres.ib, ret); free(dres.ib); break; case SYBINT1: case SYBINT2: case SYBINT4: case SYBINT8: case SYBFLT8: case SYBREAL: case SYBBIT: case SYBBITN: case SYBMONEY: case SYBMONEY4: case SYBDATETIME: case SYBDATETIME4: case SYBNUMERIC: case SYBDECIMAL: case SYBUNIQUE: case SYBMSDATE: case SYBMSTIME: case SYBMSDATETIME2: case SYBMSDATETIMEOFFSET: memcpy(dest, &dres, len); ret = len; break; case SYBCHAR: case SYBVARCHAR: case SYBTEXT: ret = _bcp_iconv_helper(dbc, bindcol, dres.c, len, (char *)dest, destlen); free(dres.c); break; default: tdsdump_log(TDS_DBG_INFO1, "error: dbconvert(): unrecognized desttype %d \n", desttype); ret = -1; break; } return (ret); } static TDSRET _bcp_get_col_data(TDSBCPINFO *bcpinfo, TDSCOLUMN *bindcol, int offset) { TDS_TINYINT ti; TDS_SMALLINT si; TDS_INT li; tds_sysdep_int64_type lli; TDS_SERVER_TYPE desttype, coltype; SQLLEN col_len; int data_is_null; SQLLEN bytes_read; int converted_data_size; TDS_CHAR *dataptr; TDS_DBC *dbc = (TDS_DBC *) bcpinfo->parent; tdsdump_log(TDS_DBG_FUNC, "_bcp_get_col_data(%p, %p)\n", bcpinfo, bindcol); dataptr = bindcol->column_varaddr; data_is_null = 0; col_len = SQL_NULL_DATA; /* If a prefix length specified, read the correct amount of data. */ if (bindcol->bcp_prefix_len > 0) { switch (bindcol->bcp_prefix_len) { case 1: memcpy(&ti, dataptr, 1); dataptr += 1; col_len = ti; break; case 2: memcpy(&si, dataptr, 2); dataptr += 2; col_len = si; break; case 4: memcpy(&li, dataptr, 4); dataptr += 4; col_len = li; break; case 8: memcpy(&lli, dataptr, 8); dataptr += 8; col_len = lli; if (lli != col_len) return TDS_FAIL; break; } if (col_len == SQL_NULL_DATA) data_is_null = 1; } /* if (Max) column length specified take that into consideration. */ if (bindcol->column_bindlen == SQL_NULL_DATA) data_is_null = 1; else if (!data_is_null && bindcol->column_bindlen != SQL_VARLEN_DATA) { if (col_len != SQL_NULL_DATA) col_len = ((tds_sysdep_int64_type)bindcol->column_bindlen < col_len) ? bindcol->column_bindlen : col_len; else col_len = bindcol->column_bindlen; } desttype = tds_get_conversion_type(bindcol->column_type, bindcol->column_size); /* Fixed Length data - this overrides anything else specified */ coltype = bindcol->column_bindtype == 0 ? desttype : (TDS_SERVER_TYPE) bindcol->column_bindtype; if (is_fixed_type(coltype)) { col_len = tds_get_size_by_type(coltype); } /* read the data, finally */ if (!data_is_null && bindcol->bcp_term_len > 0) { /* terminated field */ bytes_read = _bcp_get_term_var(dataptr, bindcol->bcp_terminator, bindcol->bcp_term_len); if (col_len != SQL_NULL_DATA) col_len = (bytes_read < col_len) ? bytes_read : col_len; else col_len = bytes_read; } if (data_is_null) { bindcol->bcp_column_data->datalen = 0; bindcol->bcp_column_data->is_null = 1; } else { if ((converted_data_size = _tdsodbc_dbconvert(dbc, coltype, dataptr, col_len, desttype, bindcol->bcp_column_data->data, bindcol)) == -1) { return TDS_FAIL; } bindcol->bcp_column_data->datalen = converted_data_size; bindcol->bcp_column_data->is_null = 0; } return TDS_SUCCESS; } /** * Get the data for bcp-in from program variables, where the program data * have been identified as character terminated, * This is a low-level, internal function. Call it correctly. */ static SQLLEN _bcp_get_term_var(const TDS_CHAR * pdata, const TDS_CHAR * term, int term_len) { SQLLEN bufpos; assert(term_len > 0); if (term_len == 1 && *term == '\0') /* significant optimization for very common case */ return strlen(pdata); /* if bufpos becomes negative, we probably failed to find the terminator */ for (bufpos = 0; bufpos >= 0 && memcmp(pdata, term, term_len) != 0; pdata++) { bufpos++; } assert(bufpos >= 0); return bufpos; } void odbc_bcp_free_storage(TDS_DBC *dbc) { tdsdump_log(TDS_DBG_FUNC, "_bcp_free_storage(%p)\n", dbc); assert(dbc); tds_free_bcpinfo(dbc->bcpinfo); dbc->bcpinfo = NULL; TDS_ZERO_FREE(dbc->bcphint); } freetds-1.00.82/src/odbc/native.c100644 025423 025423 00000023114 13142276621 0012163/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-2002 Brian Bruns * Copyright (C) 2004, 2005 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #if HAVE_ERRNO_H #include #endif /* HAVE_ERRNO_H */ #include #include #include #include #define TDS_ISSPACE(c) isspace((unsigned char) (c)) #define TDS_ISALPHA(c) isalpha((unsigned char) (c)) /* * Function transformation (from ODBC to Sybase) * String functions * ASCII(string) -> ASCII(string) * BIT_LENGTH(string) -> 8*OCTET_LENGTH(string) * CHAR_LENGTH(string_exp) -> CHAR_LENGTH(string_exp) * CHARACTER_LENGTH(string_exp) -> CHAR_LENGTH(string_exp) * CONCAT(string_exp1, string_exp2) -> string_exp1 + string_exp2 * DIFFERENCE(string_exp1, string_exp2) -> DIFFERENCE(string_exp1, string_exp2) * INSERT(string_exp1, start, length, string_exp2) -> STUFF(sameparams) * LCASE(string_exp) -> LOWER(string) * LEFT(string_exp, count) -> SUBSTRING(string, 1, count) * LENGTH(string_exp) -> CHAR_LENGTH(RTRIM(string_exp)) * LOCATE(string, string [,start]) -> CHARINDEX(string, string) * (SQLGetInfo should return third parameter not possible) * LTRIM(String) -> LTRIM(String) * OCTET_LENGTH(string_exp) -> OCTET_LENGTH(string_exp) * POSITION(character_exp IN character_exp) ??? * REPEAT(string_exp, count) -> REPLICATE(same) * REPLACE(string_exp1, string_exp2, string_exp3) -> ?? * RIGHT(string_exp, count) -> RIGHT(string_exp, count) * RTRIM(string_exp) -> RTRIM(string_exp) * SOUNDEX(string_exp) -> SOUNDEX(string_exp) * SPACE(count) (ODBC 2.0) -> SPACE(count) (ODBC 2.0) * SUBSTRING(string_exp, start, length) -> SUBSTRING(string_exp, start, length) * UCASE(string_exp) -> UPPER(string) * * Numeric * Nearly all function use same parameters, except: * ATAN2 -> ATN2 * TRUNCATE -> ?? */ static SQLRETURN to_native(struct _hdbc *dbc, struct _hstmt *stmt, DSTR *str) { char *d, *s; int nest_syntax = 0; char *buf = tds_dstr_buf(str); /* list of bit, used as stack, is call ? FIXME limites size... */ unsigned long is_calls = 0; int server_scalar; assert(dbc); server_scalar = TDS_IS_MSSQL(dbc->tds_socket) && dbc->tds_socket->conn->product_version >= TDS_MS_VER(7, 0, 0); /* * we can do it because result string will be * not bigger than source string */ d = s = buf; while (*s) { if (*s == '-' || *s == '/') { size_t len_comment = tds_skip_comment(s) - s; memmove(d, s, len_comment); s += len_comment; d += len_comment; continue; } /* TODO: test syntax like "select 1 as [pi]]p)p{?=call]]]]o], 2" on mssql7+ */ if (*s == '"' || *s == '\'' || *s == '[') { size_t len_quote = tds_skip_quoted(s) - s; memmove(d, s, len_quote); s += len_quote; d += len_quote; continue; } if (*s == '{') { char *pcall; while (TDS_ISSPACE(*++s)) continue; pcall = s; /* FIXME if nest_syntax > 0 problems */ if (server_scalar && strncasecmp(pcall, "fn ", 3) == 0) { *d++ = '{'; continue; } if (*pcall == '?') { /* skip spaces after ? */ while (TDS_ISSPACE(*++pcall)) continue; if (*pcall == '=') { while (TDS_ISSPACE(*++pcall)) continue; } else { /* avoid {?call ... syntax */ pcall = s; } } if (strncasecmp(pcall, "call ", 5) != 0) pcall = NULL; if (stmt) stmt->prepared_query_is_rpc = 1; ++nest_syntax; is_calls <<= 1; if (!pcall) { /* assume syntax in the form {type ...} */ while (TDS_ISALPHA(*s)) ++s; while (TDS_ISSPACE(*s)) ++s; } else { if (*s == '?' && stmt) stmt->prepared_query_is_func = 1; memcpy(d, "exec ", 5); d += 5; s = pcall + 5; is_calls |= 1; } } else if (nest_syntax > 0) { /* do not copy close syntax */ if (*s == '}') { --nest_syntax; is_calls >>= 1; ++s; continue; /* convert parenthesis in call to spaces */ } else if ((is_calls & 1) && (*s == '(' || *s == ')')) { *d++ = ' '; s++; } else { *d++ = *s++; } } else { *d++ = *s++; } } tds_dstr_setlen(str, d - buf); return SQL_SUCCESS; } const char * parse_const_param(const char *s, TDS_SERVER_TYPE *type) { char *end; /* binary */ if (strncasecmp(s, "0x", 2) == 0) { s += 2; while (isxdigit(*s)) ++s; *type = SYBVARBINARY; return s; } /* string */ if (*s == '\'') { *type = SYBVARCHAR; return tds_skip_quoted(s); } /* integer/float */ if (isdigit(*s) || *s == '+' || *s == '-') { errno = 0; strtod(s, &end); if (end != s && strcspn(s, ".eE") < (size_t) (end-s) && errno == 0) { *type = SYBFLT8; return end; } errno = 0; /* FIXME success if long is 64bit */ strtol(s, &end, 10); if (end != s && errno == 0) { *type = SYBINT4; return end; } } /* TODO date, time */ return NULL; } const char * odbc_skip_rpc_name(const char *s) { for (;*s; ++s) { if (*s == '[') { /* handle [dbo].[name] and [master]..[name] syntax */ s = tds_skip_quoted(s); if (*s != '.') break; } else if (TDS_ISSPACE(*s)) { /* FIXME: stop at other characters ??? */ break; } } return s; } SQLRETURN prepare_call(struct _hstmt * stmt) { const char *s, *p, *param_start; char *buf; SQLRETURN rc; TDS_SERVER_TYPE type; if (tds_dstr_isempty(&stmt->query)) return SQL_ERROR; if ((!tds_dstr_isempty(&stmt->attr.qn_msgtext) || !tds_dstr_isempty(&stmt->attr.qn_options)) && !IS_TDS72_PLUS(stmt->dbc->tds_socket->conn)) { odbc_errs_add(&stmt->errs, "HY000", "Feature is not supported by this server"); return SQL_SUCCESS_WITH_INFO; } if ((rc = to_native(stmt->dbc, stmt, &stmt->query)) != SQL_SUCCESS) return rc; /* now detect RPC */ if (stmt->prepared_query_is_rpc == 0) return SQL_SUCCESS; stmt->prepared_query_is_rpc = 0; s = buf = tds_dstr_buf(&stmt->query); while (TDS_ISSPACE(*s)) ++s; if (strncasecmp(s, "exec", 4) == 0) { if (TDS_ISSPACE(s[4])) s += 5; else if (strncasecmp(s, "execute", 7) == 0 && TDS_ISSPACE(s[7])) s += 8; else { stmt->prepared_query_is_func = 0; return SQL_SUCCESS; } } while (TDS_ISSPACE(*s)) ++s; p = s; s = (char *) odbc_skip_rpc_name(s); param_start = s; --s; /* trick, now s point to no blank */ for (;;) { while (TDS_ISSPACE(*++s)) continue; if (!*s) break; switch (*s) { case '?': break; case ',': --s; break; default: if (!(s = parse_const_param(s, &type))) { stmt->prepared_query_is_func = 0; return SQL_SUCCESS; } --s; break; } while (TDS_ISSPACE(*++s)) continue; if (!*s) break; if (*s != ',') { stmt->prepared_query_is_func = 0; return SQL_SUCCESS; } } stmt->prepared_query_is_rpc = 1; /* remove unneeded exec */ s += strlen(s); memmove(buf, p, s - p); tds_dstr_setlen(&stmt->query, s - p); stmt->prepared_pos = buf + (param_start - p); return SQL_SUCCESS; } /* TODO handle output parameter and not terminated string */ SQLRETURN native_sql(struct _hdbc * dbc, DSTR *s) { return to_native(dbc, NULL, s); } /* function info */ struct func_info; struct native_info; typedef void (*special_fn) (struct native_info * ni, struct func_info * fi, char **params); struct func_info { const char *name; int num_param; const char *sql_name; special_fn special; }; struct native_info { char *d; int length; }; #if 0 /* developing ... */ #define MAX_PARAMS 4 static const struct func_info funcs[] = { /* string functions */ {"ASCII", 1}, {"BIT_LENGTH", 1, "(8*OCTET_LENGTH", fn_parentheses}, {"CHAR", 1}, {"CHAR_LENGTH", 1}, {"CHARACTER_LENGTH", 1, "CHAR_LENGTH"}, {"CONCAT", 2, NULL, fn_concat}, /* a,b -> a+b */ {"DIFFERENCE", 2}, {"INSERT", 4, "STUFF"}, {"LCASE", 1, "LOWER"}, {"LEFT", 2, "SUBSTRING", fn_left}, {"LENGTH", 1, "CHAR_LENGTH(RTRIM", fn_parentheses}, {"LOCATE", 2, "CHARINDEX"}, /* (SQLGetInfo should return third parameter not possible) */ {"LTRIM", 1}, {"OCTET_LENGTH", 1}, /* POSITION(character_exp IN character_exp) */ {"REPEAT", 2, "REPLICATE"}, /* REPLACE(string_exp1, string_exp2, string_exp3) */ {"RIGHT", 2}, {"RTRIM", 1}, {"SOUNDEX", 1}, {"SPACE", 1}, {"SUBSTRING", 3}, {"UCASE", 1, "UPPER"}, /* numeric functions */ {"ABS", 1}, {"ACOS", 1}, {"ASIN", 1}, {"ATAN", 1}, {"ATAN2", 2, "ATN2"}, {"CEILING", 1}, {"COS", 1}, {"COT", 1}, {"DEGREES", 1}, {"EXP", 1}, {"FLOOR", 1}, {"LOG", 1}, {"LOG10", 1}, {"MOD", 2, NULL, fn_mod}, /* mod(a,b) -> ((a)%(b)) */ {"PI", 0}, {"POWER", 2}, {"RADIANS", 1}, {"RAND", -1, NULL, fn_rand}, /* accept 0 or 1 parameters */ {"ROUND", 2}, {"SIGN", 1}, {"SIN", 1}, {"SQRT", 1}, {"TAN", 1}, /* TRUNCATE(numeric_exp, integer_exp) */ /* system functions */ {"DATABASE", 0, "DB_NAME"}, {"IFNULL", 2, "ISNULL"}, {"USER", 0, "USER_NAME"} }; /** * Parse given sql and return converted sql */ int odbc_native_sql(const char *odbc_sql, char **out) { char *d; } #endif freetds-1.00.82/src/odbc/sql2tds.c100644 025423 025423 00000033535 12717145107 0012302/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns * Copyright (C) 2005-2015 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include #include #include TDS_INT convert_datetime2server(int bindtype, const void *src, TDS_DATETIMEALL * dta) { struct tm src_tm; int tm_dms; unsigned int dt_time; int i; time_t curr_time; const DATE_STRUCT *src_date = (const DATE_STRUCT *) src; const TIME_STRUCT *src_time = (const TIME_STRUCT *) src; const TIMESTAMP_STRUCT *src_timestamp = (const TIMESTAMP_STRUCT *) src; memset(dta, 0, sizeof(*dta)); switch (bindtype) { case SQL_C_DATE: case SQL_C_TYPE_DATE: src_tm.tm_year = src_date->year - 1900; src_tm.tm_mon = src_date->month - 1; src_tm.tm_mday = src_date->day; src_tm.tm_hour = 0; src_tm.tm_min = 0; src_tm.tm_sec = 0; tm_dms = 0; dta->has_date = 1; break; case SQL_C_TIME: case SQL_C_TYPE_TIME: #if HAVE_GETTIMEOFDAY { struct timeval tv; gettimeofday(&tv, NULL); curr_time = tv.tv_sec; } #else curr_time = time(NULL); #endif tds_localtime_r(&curr_time, &src_tm); src_tm.tm_hour = src_time->hour; src_tm.tm_min = src_time->minute; src_tm.tm_sec = src_time->second; tm_dms = 0; dta->has_time = 1; break; case SQL_C_TIMESTAMP: case SQL_C_TYPE_TIMESTAMP: src_tm.tm_year = src_timestamp->year - 1900; src_tm.tm_mon = src_timestamp->month - 1; src_tm.tm_mday = src_timestamp->day; src_tm.tm_hour = src_timestamp->hour; src_tm.tm_min = src_timestamp->minute; src_tm.tm_sec = src_timestamp->second; tm_dms = src_timestamp->fraction / 100lu; dta->has_date = 1; dta->has_time = 1; break; default: return TDS_CONVERT_FAIL; } /* TODO code copied from convert.c, function */ i = (src_tm.tm_mon - 13) / 12; dta->has_date = 1; dta->date = 1461 * (src_tm.tm_year + 300 + i) / 4 + (367 * (src_tm.tm_mon - 1 - 12 * i)) / 12 - (3 * ((src_tm.tm_year + 400 + i) / 100)) / 4 + src_tm.tm_mday - 109544; dta->has_time = 1; dt_time = (src_tm.tm_hour * 60 + src_tm.tm_min) * 60 + src_tm.tm_sec; dta->time = dt_time * ((TDS_UINT8) 10000000u) + tm_dms; return sizeof(TDS_DATETIMEALL); } static char* odbc_wstr2str(TDS_STMT * stmt, const char *src, int* len) { int srclen = (*len) / sizeof(SQLWCHAR); char *out = tds_new(char, srclen + 1), *p; const SQLWCHAR *wp = (const SQLWCHAR *) src; if (!out) { odbc_errs_add(&stmt->errs, "HY001", NULL); return NULL; } /* convert */ p = out; for (; srclen && *wp < 256; --srclen) *p++ = (char) *wp++; /* still characters, wrong format */ if (srclen) { free(out); /* TODO correct error ?? */ odbc_errs_add(&stmt->errs, "07006", NULL); return NULL; } *len = p - out; return out; } static void _odbc_blob_free(TDSCOLUMN *col) { if (!col->column_data) return; TDS_ZERO_FREE(col->column_data); } /** * Convert parameters to libtds format * @return SQL_SUCCESS, SQL_ERROR or SQL_NEED_DATA */ SQLRETURN odbc_sql2tds(TDS_STMT * stmt, const struct _drecord *drec_ipd, const struct _drecord *drec_apd, TDSCOLUMN *curcol, int compute_row, const TDS_DESC* axd, unsigned int n_row) { TDS_DBC * dbc = stmt->dbc; TDSCONNECTION * conn = dbc->tds_socket->conn; TDS_SERVER_TYPE dest_type; int src_type, sql_src_type, res; CONV_RESULT ores; TDSBLOB *blob; char *src, *converted_src; unsigned char *dest; int len; TDS_DATETIMEALL dta; TDS_NUMERIC num; SQL_NUMERIC_STRUCT *sql_num; SQLINTEGER sql_len; int need_data = 0, i; /* TODO handle bindings of char like "{d '2002-11-12'}" */ tdsdump_log(TDS_DBG_INFO2, "type=%d\n", drec_ipd->sql_desc_concise_type); /* what type to convert ? */ dest_type = odbc_sql_to_server_type(conn, drec_ipd->sql_desc_concise_type, drec_ipd->sql_desc_unsigned); if (dest_type == TDS_INVALID_TYPE) { odbc_errs_add(&stmt->errs, "07006", NULL); /* Restricted data type attribute violation */ return SQL_ERROR; } tdsdump_log(TDS_DBG_INFO2, "trace\n"); /* get C type */ sql_src_type = drec_apd->sql_desc_concise_type; if (sql_src_type == SQL_C_DEFAULT) sql_src_type = odbc_sql_to_c_type_default(drec_ipd->sql_desc_concise_type); tds_set_param_type(conn, curcol, dest_type); /* TODO what happen for unicode types ?? */ if (is_char_type(dest_type)) { TDSICONV *conv = conn->char_convs[is_unicode_type(dest_type) ? client2ucs2 : client2server_chardata]; /* use binary format for binary to char */ if (sql_src_type == SQL_C_BINARY) { curcol->char_conv = NULL; } else if (sql_src_type == SQL_C_WCHAR) { curcol->char_conv = tds_iconv_get(conn, odbc_get_wide_name(conn), conv->to.charset.name); memcpy(curcol->column_collation, conn->collation, sizeof(conn->collation)); } else { #ifdef ENABLE_ODBC_WIDE curcol->char_conv = tds_iconv_get(conn, tds_dstr_cstr(&dbc->original_charset), conv->to.charset.name); #else curcol->char_conv = NULL; #endif } } if (is_numeric_type(curcol->column_type)) { curcol->column_prec = drec_ipd->sql_desc_precision; curcol->column_scale = drec_ipd->sql_desc_scale; } if (drec_ipd->sql_desc_parameter_type != SQL_PARAM_INPUT) curcol->column_output = 1; /* compute destination length */ if (curcol->column_varint_size != 0) { /* curcol->column_size = drec_apd->sql_desc_octet_length; */ /* * TODO destination length should come from sql_desc_length, * however there is the encoding problem to take into account * we should fill destination length after conversion keeping * attention to fill correctly blob/fixed type/variable type */ /* TODO location of this test is correct here ?? */ if (dest_type != SYBUNIQUE && dest_type != SYBBITN && !is_fixed_type(dest_type)) { curcol->column_cur_size = 0; curcol->column_size = drec_ipd->sql_desc_length; if (curcol->column_size < 0) { curcol->on_server.column_size = curcol->column_size = 0x7FFFFFFFl; } else { if (is_unicode_type(dest_type)) curcol->on_server.column_size = curcol->column_size * 2; else curcol->on_server.column_size = curcol->column_size; } } } else if (dest_type != SYBBIT) { /* TODO only a trick... */ tds_set_param_type(conn, curcol, tds_get_null_type(dest_type)); } /* test source type */ /* TODO test intervals */ src_type = odbc_c_to_server_type(sql_src_type); if (!src_type) { odbc_errs_add(&stmt->errs, "07006", NULL); /* Restricted data type attribute violation */ return SQL_ERROR; } /* we have no data to convert, just return */ if (!compute_row) return SQL_SUCCESS; src = (char *) drec_apd->sql_desc_data_ptr; if (src && n_row) { SQLLEN len; if (axd->header.sql_desc_bind_type != SQL_BIND_BY_COLUMN) { len = axd->header.sql_desc_bind_type; if (axd->header.sql_desc_bind_offset_ptr) src += *axd->header.sql_desc_bind_offset_ptr; } else { len = odbc_get_octet_len(sql_src_type, drec_apd); if (len < 0) /* TODO sure ? what happen to upper layer ?? */ /* TODO fill error */ return SQL_ERROR; } src += len * n_row; } /* if only output assume input is NULL */ if (drec_ipd->sql_desc_parameter_type == SQL_PARAM_OUTPUT) { sql_len = SQL_NULL_DATA; } else { sql_len = odbc_get_param_len(drec_apd, drec_ipd, axd, n_row); /* special case, MS ODBC handle conversion from "\0" to any to NULL, DBD::ODBC require it */ if (src_type == SYBVARCHAR && sql_len == 1 && drec_ipd->sql_desc_parameter_type == SQL_PARAM_INPUT_OUTPUT && src && *src == 0) { sql_len = SQL_NULL_DATA; } } /* compute source length */ switch (sql_len) { case SQL_NULL_DATA: len = 0; break; case SQL_NTS: /* check that SQLBindParameter::ParameterValuePtr is not zero for input parameters */ if (!src) { odbc_errs_add(&stmt->errs, "HY090", NULL); return SQL_ERROR; } if (sql_src_type == SQL_C_WCHAR) len = sqlwcslen((const SQLWCHAR *) src) * sizeof(SQLWCHAR); else len = strlen(src); break; case SQL_DEFAULT_PARAM: odbc_errs_add(&stmt->errs, "07S01", NULL); /* Invalid use of default parameter */ return SQL_ERROR; break; case SQL_DATA_AT_EXEC: default: len = sql_len; if (sql_len < 0) { /* test for SQL_C_CHAR/SQL_C_BINARY */ switch (sql_src_type) { case SQL_C_CHAR: case SQL_C_WCHAR: case SQL_C_BINARY: break; default: odbc_errs_add(&stmt->errs, "HY090", NULL); return SQL_ERROR; } len = SQL_LEN_DATA_AT_EXEC(sql_len); need_data = 1; /* dynamic length allowed only for BLOB fields */ switch (drec_ipd->sql_desc_concise_type) { case SQL_LONGVARCHAR: case SQL_WLONGVARCHAR: case SQL_LONGVARBINARY: break; default: odbc_errs_add(&stmt->errs, "HY090", NULL); return SQL_ERROR; } } } /* set NULL. For NULLs we don't need to allocate row buffer so avoid it */ if (!need_data) { assert(drec_ipd->sql_desc_parameter_type != SQL_PARAM_OUTPUT || sql_len == SQL_NULL_DATA); if (sql_len == SQL_NULL_DATA) { curcol->column_cur_size = -1; return SQL_SUCCESS; } } if (is_char_type(dest_type) && !need_data && (sql_src_type == SQL_C_CHAR || sql_src_type == SQL_C_WCHAR || sql_src_type == SQL_C_BINARY)) { if (curcol->column_data && curcol->column_data_free) curcol->column_data_free(curcol); curcol->column_data_free = NULL; if (is_blob_col(curcol)) { /* trick to set blob without freeing it, _odbc_blob_free does not free TDSBLOB->textvalue */ TDSBLOB *blob = tds_new0(TDSBLOB, 1); if (!blob) { odbc_errs_add(&stmt->errs, "HY001", NULL); return SQL_ERROR; } blob->textvalue = src; curcol->column_data = (TDS_UCHAR*) blob; curcol->column_data_free = _odbc_blob_free; } else { curcol->column_data = (TDS_UCHAR*) src; } curcol->column_size = len; curcol->column_cur_size = len; return SQL_SUCCESS; } /* allocate given space */ if (!tds_alloc_param_data(curcol)) { odbc_errs_add(&stmt->errs, "HY001", NULL); return SQL_ERROR; } /* fill data with SQLPutData */ if (need_data) { curcol->column_cur_size = 0; return SQL_NEED_DATA; } if (!src) { odbc_errs_add(&stmt->errs, "HY090", NULL); return SQL_ERROR; } /* convert special parameters (not libTDS compatible) */ switch (src_type) { case SYBMSDATETIME2: convert_datetime2server(drec_apd->sql_desc_concise_type, src, &dta); src = (char *) &dta; break; case SYBDECIMAL: case SYBNUMERIC: sql_num = (SQL_NUMERIC_STRUCT *) src; num.precision = sql_num->precision; num.scale = sql_num->scale; num.array[0] = sql_num->sign ^ 1; /* test precision so client do not crash our library */ if (num.precision <= 0 || num.precision > 38 || num.scale > num.precision) /* TODO add proper error */ return SQL_ERROR; i = tds_numeric_bytes_per_prec[num.precision]; memcpy(num.array + 1, sql_num->val, i - 1); tds_swap_bytes(num.array + 1, i - 1); if (i < sizeof(num.array)) memset(num.array + i, 0, sizeof(num.array) - i); src = (char *) # break; /* TODO intervals */ } converted_src = NULL; if (sql_src_type == SQL_C_WCHAR) { converted_src = src = odbc_wstr2str(stmt, src, &len); if (!src) return SQL_ERROR; src_type = SYBVARCHAR; } dest = curcol->column_data; switch ((TDS_SERVER_TYPE) dest_type) { case SYBCHAR: case SYBVARCHAR: case XSYBCHAR: case XSYBVARCHAR: case XSYBNVARCHAR: case XSYBNCHAR: case SYBNVARCHAR: ores.cc.c = (TDS_CHAR*) dest; ores.cc.len = curcol->column_size; res = tds_convert(dbc->env->tds_ctx, src_type, src, len, TDS_CONVERT_CHAR, &ores); if (res > curcol->column_size) res = curcol->column_size; break; case SYBBINARY: case SYBVARBINARY: case XSYBBINARY: case XSYBVARBINARY: ores.cb.ib = (TDS_CHAR*) dest; ores.cb.len = curcol->column_size; res = tds_convert(dbc->env->tds_ctx, src_type, src, len, TDS_CONVERT_BINARY, &ores); if (res > curcol->column_size) res = curcol->column_size; break; case SYBNTEXT: dest_type = SYBTEXT; case SYBTEXT: case SYBLONGBINARY: case SYBIMAGE: res = tds_convert(dbc->env->tds_ctx, src_type, src, len, dest_type, &ores); if (res >= 0) { blob = (TDSBLOB *) dest; free(blob->textvalue); blob->textvalue = ores.ib; } break; case SYBNUMERIC: case SYBDECIMAL: ((TDS_NUMERIC *) dest)->precision = drec_ipd->sql_desc_precision; ((TDS_NUMERIC *) dest)->scale = drec_ipd->sql_desc_scale; case SYBINTN: case SYBINT1: case SYBINT2: case SYBINT4: case SYBINT8: case SYBFLT8: case SYBDATETIME: case SYBBIT: case SYBMONEY4: case SYBMONEY: case SYBDATETIME4: case SYBREAL: case SYBBITN: case SYBFLTN: case SYBMONEYN: case SYBDATETIMN: case SYBSINT1: case SYBUINT2: case SYBUINT4: case SYBUINT8: case SYBUNIQUE: case SYBMSTIME: case SYBMSDATE: case SYBMSDATETIME2: case SYBMSDATETIMEOFFSET: case SYB5BIGTIME: case SYB5BIGDATETIME: res = tds_convert(dbc->env->tds_ctx, src_type, src, len, dest_type, (CONV_RESULT*) dest); break; default: case SYBVOID: case SYBVARIANT: /* TODO ODBC 3.5 */ assert(0); res = -1; break; } free(converted_src); if (res < 0) { odbc_convert_err_set(&stmt->errs, res); return SQL_ERROR; } curcol->column_cur_size = res; return SQL_SUCCESS; } freetds-1.00.82/src/odbc/error.c100644 025423 025423 00000052165 12717145107 0012037/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-1999 Brian Bruns * Copyright (C) 2003-2012 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include "odbcss.h" #include #include "replacements.h" #include "sqlwparams.h" static void odbc_errs_pop(struct _sql_errors *errs); static const char *odbc_get_msg(const char *sqlstate); static void odbc_get_v2state(const char *sqlstate, char *dest_state); static void sqlstate2to3(char *state); struct s_SqlMsgMap { const char *msg; char sqlstate[6]; }; /* This list contains both v2 and v3 messages */ #define ODBCERR(s3,msg) { msg, s3 } static const struct s_SqlMsgMap SqlMsgMap[] = { ODBCERR("IM007", "No data source or driver specified"), ODBCERR("01000", "Warning"), ODBCERR("01002", "Disconnect error"), ODBCERR("01004", "Data truncated"), ODBCERR("01504", "The UPDATE or DELETE statement does not include a WHERE clause"), ODBCERR("01508", "Statement disqualified for blocking"), ODBCERR("01S00", "Invalid connection string attribute"), ODBCERR("01S01", "Error in row"), ODBCERR("01S02", "Option value changed"), ODBCERR("01S06", "Attempt to fetch before the result set returned the first rowset"), ODBCERR("01S07", "Fractional truncation"), ODBCERR("07001", "Wrong number of parameters"), ODBCERR("07002", "Too many columns"), ODBCERR("07005", "The statement did not return a result set"), ODBCERR("07006", "Invalid conversion"), ODBCERR("07009", "Invalid descriptor index"), ODBCERR("08001", "Unable to connect to data source"), ODBCERR("08002", "Connection in use"), ODBCERR("08003", "Connection is closed"), ODBCERR("08004", "The application server rejected establishment of the connection"), ODBCERR("08007", "Connection failure during transaction"), ODBCERR("08S01", "Communication link failure"), ODBCERR("0F001", "The LOB token variable does not currently represent any value"), ODBCERR("21S01", "Insert value list does not match column list"), ODBCERR("22001", "String data right truncation"), ODBCERR("22002", "Invalid output or indicator buffer specified"), ODBCERR("22003", "Numeric value out of range"), ODBCERR("22005", "Error in assignment"), ODBCERR("22007", "Invalid datetime format"), ODBCERR("22008", "Datetime field overflow"), ODBCERR("22011", "A substring error occurred"), ODBCERR("22012", "Division by zero is invalid"), ODBCERR("22015", "Interval field overflow"), ODBCERR("22018", "Invalid character value for cast specification"), ODBCERR("22019", "Invalid escape character"), ODBCERR("22025", "Invalid escape sequence"), ODBCERR("22026", "String data, length mismatch"), ODBCERR("23000", "Integrity constraint violation"), ODBCERR("24000", "Invalid cursor state"), ODBCERR("24504", "The cursor identified in the UPDATE, DELETE, SET, or GET statement is not positioned on a row"), ODBCERR("25501", "Invalid transaction state"), ODBCERR("28000", "Invalid authorization specification"), ODBCERR("34000", "Invalid cursor name"), ODBCERR("37000", "Invalid SQL syntax"), ODBCERR("40001", "Serialization failure"), ODBCERR("40003", "Statement completion unknown"), ODBCERR("42000", "Syntax error or access violation"), ODBCERR("42601", "PARMLIST syntax error"), ODBCERR("42818", "The operands of an operator or function are not compatible"), ODBCERR("42895", "The value of a host variable in the EXECUTE or OPEN statement cannot be used because of its data type"), ODBCERR("428A1", "Unable to access a file referenced by a host file variable"), ODBCERR("44000", "Integrity constraint violation"), ODBCERR("54028", "The maximum number of concurrent LOB handles has been reached"), ODBCERR("56084", "LOB data is not supported in DRDA"), ODBCERR("58004", "Unexpected system failure"), ODBCERR("HY000", "General driver error"), ODBCERR("HY001", "Memory allocation failure"), ODBCERR("HY002", "Invalid column number"), ODBCERR("HY003", "Program type out of range"), ODBCERR("HY004", "Invalid data type"), ODBCERR("HY007", "Associated statement is not prepared"), ODBCERR("HY008", "Operation was cancelled"), ODBCERR("HY009", "Invalid argument value"), ODBCERR("HY010", "Function sequence error"), ODBCERR("HY011", "Operation invalid at this time"), ODBCERR("HY012", "Invalid transaction code"), ODBCERR("HY013", "Unexpected memory handling error"), ODBCERR("HY014", "No more handles"), ODBCERR("HY016", "Cannot modify an implementation row descriptor"), ODBCERR("HY017", "Invalid use of an automatically allocated descriptor handle"), ODBCERR("HY018", "Server declined cancel request"), ODBCERR("HY021", "Inconsistent descriptor information"), ODBCERR("HY024", "Invalid attribute value"), ODBCERR("HY090", "Invalid string or buffer length"), ODBCERR("HY091", "Descriptor type out of range"), ODBCERR("HY092", "Invalid option"), ODBCERR("HY093", "Invalid parameter number"), ODBCERR("HY094", "Invalid scale value"), ODBCERR("HY096", "Information type out of range"), ODBCERR("HY097", "Column type out of range"), ODBCERR("HY098", "Scope type out of range"), ODBCERR("HY099", "Nullable type out of range"), ODBCERR("HY100", "Uniqueness option type out of range"), ODBCERR("HY101", "Accuracy option type out of range"), ODBCERR("HY103", "Direction option out of range"), ODBCERR("HY104", "Invalid precision value"), ODBCERR("HY105", "Invalid parameter type"), ODBCERR("HY106", "Fetch type out of range"), ODBCERR("HY107", "Row value out of range"), ODBCERR("HY108", "Concurrency option out of range"), ODBCERR("HY109", "Invalid cursor position"), ODBCERR("HY110", "Invalid driver completion"), ODBCERR("HY111", "Invalid bookmark value"), ODBCERR("HY501", "Invalid data source name"), ODBCERR("HY503", "Invalid file name length"), ODBCERR("HY506", "Error closing a file"), ODBCERR("HY509", "Error deleting a file"), ODBCERR("HYC00", "Driver not capable"), ODBCERR("HYT00", "Timeout expired"), ODBCERR("HYT01", "Connection timeout expired"), ODBCERR("S0001", "Database object already exists"), ODBCERR("S0002", "Database object does not exist"), ODBCERR("S0011", "Index already exists"), ODBCERR("S0012", "Index not found"), ODBCERR("S0021", "Column already exists"), ODBCERR("S0022", "Column not found"), ODBCERR("", NULL) }; #undef ODBCERR struct s_v3to2map { char v3[6]; char v2[6]; }; /* Map a v3 SQLSTATE to a v2 */ static const struct s_v3to2map v3to2map[] = { {"01001", "01S03"}, {"01001", "01S04"}, {"HY019", "22003"}, {"22007", "22008"}, {"22018", "22005"}, {"07005", "24000"}, {"42000", "37000"}, {"HY018", "70100"}, {"42S01", "S0001"}, {"42S02", "S0002"}, {"42S11", "S0011"}, {"42S12", "S0012"}, {"42S21", "S0021"}, {"42S22", "S0022"}, {"42S23", "S0023"}, {"HY000", "S1000"}, {"HY001", "S1001"}, {"07009", "S1002"}, {"HY003", "S1003"}, {"HY004", "S1004"}, {"HY008", "S1008"}, {"HY009", "S1009"}, {"HY024", "S1009"}, {"HY007", "S1010"}, {"HY010", "S1010"}, {"HY011", "S1011"}, {"HY012", "S1012"}, {"HY090", "S1090"}, {"HY091", "S1091"}, {"HY092", "S1092"}, /* {"07009", "S1093"}, */ {"HY096", "S1096"}, {"HY097", "S1097"}, {"HY098", "S1098"}, {"HY099", "S1099"}, {"HY100", "S1100"}, {"HY101", "S1101"}, {"HY103", "S1103"}, {"HY104", "S1104"}, {"HY105", "S1105"}, {"HY106", "S1106"}, {"HY107", "S1107"}, {"HY108", "S1108"}, {"HY109", "S1109"}, {"HY110", "S1110"}, {"HY111", "S1111"}, {"HYC00", "S1C00"}, {"HYT00", "S1T00"}, {"08001", "S1000"}, {"IM007", "S1000"}, {"", ""} }; /* * ODBC messages must be sorted by importance * 1. Errors regarding the status of a transaction * 2. Other errors (level ordered) * 3. No-Data messages with a state class of 02 ?? * 4. Warning * 5. Informational */ static void rank_errors(struct _sql_errors *errs) { int settled, current, best; struct _sql_error swapbuf; char istrans; /* already ranked or nothing to rank */ if (errs->ranked != 0 || errs->num_errors <= 1) { errs->ranked = 1; return; } /* Find the highest of all unranked errors until there are none left */ for (settled = 0; settled < errs->num_errors; settled++) { best = settled; for (current = settled; current < errs->num_errors; current++) { /* always sort by rows */ if (errs->errs[best].row < errs->errs[current].row) continue; if (errs->errs[best].row > errs->errs[current].row) { best = current; continue; } istrans = 0; switch (errs->errs[current].native) { case 1205: case 1211: case 2625: case 3309: case 7112: case 266: case 277: case 611: case 628: case 3902: case 3903: case 3906: case 3908: case 6401: istrans = 1; break; } if (istrans == 0) { if (strcmp(errs->errs[current].state3,"25000") == 0) istrans = 1; else if (strcmp(errs->errs[current].state3,"S1012") == 0) istrans = 1; else if (strcmp(errs->errs[current].state3,"08007") == 0) istrans = 1; } /* Transaction errors are always best */ if (istrans == 1 && errs->errs[current].msgstate >= 10) { best = current; break; } /* Non-terminating comparisons only below this point */ if (errs->errs[current].msgstate > errs->errs[best].msgstate) best = current; } /* swap settled position with best */ if (best != settled) { swapbuf = errs->errs[settled]; errs->errs[settled] = errs->errs[best]; errs->errs[best] = swapbuf; } } errs->ranked = 1; } static const char * odbc_get_msg(const char *sqlstate) { const struct s_SqlMsgMap *pmap = SqlMsgMap; /* TODO set flag and use pointers (no strdup) ?? */ while (pmap->msg) { if (!strcasecmp(sqlstate, pmap->sqlstate)) { return strdup(pmap->msg); } ++pmap; } return strdup(""); } static void odbc_get_v2state(const char *sqlstate, char *dest_state) { const struct s_v3to2map *pmap = v3to2map; while (pmap->v3[0]) { if (!strcasecmp(pmap->v3, sqlstate)) { strlcpy(dest_state, pmap->v2, 6); return; } ++pmap; } /* return the original if a v2 state is not found */ strlcpy(dest_state, sqlstate, 6); } void odbc_errs_reset(struct _sql_errors *errs) { int i; if (errs->errs) { for (i = 0; i < errs->num_errors; ++i) { /* TODO see flags */ free((char *) errs->errs[i].msg); free(errs->errs[i].server); } TDS_ZERO_FREE(errs->errs); errs->num_errors = 0; } errs->lastrc = SQL_SUCCESS; errs->ranked = 0; assert(errs->num_errors == 0); } /** Remove first element */ static void odbc_errs_pop(struct _sql_errors *errs) { if (!errs || !errs->errs || errs->num_errors <= 0) return; if (errs->num_errors == 1) { odbc_errs_reset(errs); return; } /* TODO see flags */ free((char *) errs->errs[0].msg); free(errs->errs[0].server); --errs->num_errors; memmove(&(errs->errs[0]), &(errs->errs[1]), errs->num_errors * sizeof(errs->errs[0])); } void odbc_errs_add(struct _sql_errors *errs, const char *sqlstate, const char *msg) { int n; assert(sqlstate); if (!errs) return; n = errs->num_errors; if (!TDS_RESIZE(errs->errs, n + 1)) { errs->lastrc = SQL_ERROR; return; } memset(&errs->errs[n], 0, sizeof(struct _sql_error)); errs->errs[n].native = 0; strlcpy(errs->errs[n].state3, sqlstate, 6); odbc_get_v2state(errs->errs[n].state3, errs->errs[n].state2); /* TODO why driver ?? -- freddy77 */ errs->errs[n].server = strdup("DRIVER"); errs->errs[n].msg = msg ? strdup(msg) : odbc_get_msg(errs->errs[n].state3); ++errs->num_errors; /* updated last error */ if (!strcmp(sqlstate, "01004") || !strcmp(sqlstate, "01S02")) { if (errs->lastrc != SQL_ERROR) errs->lastrc = SQL_SUCCESS_WITH_INFO; } else { errs->lastrc = SQL_ERROR; } tdsdump_log(TDS_DBG_FUNC, "odbc_errs_add: \"%s\"\n", errs->errs[n].msg); } /* TODO check if TDS_UINT is correct for native error */ void odbc_errs_add_rdbms(struct _sql_errors *errs, TDS_UINT native, const char *sqlstate, const char *msg, int linenum, int msgstate, const char *server, int row) { int n = errs->num_errors; if (!TDS_RESIZE(errs->errs, n + 1)) return; memset(&errs->errs[n], 0, sizeof(struct _sql_error)); errs->errs[n].row = row; errs->errs[n].native = native; if (sqlstate) strlcpy(errs->errs[n].state2, sqlstate, 6); else errs->errs[n].state2[0] = '\0'; strcpy(errs->errs[n].state3, errs->errs[n].state2); sqlstate2to3(errs->errs[n].state3); /* TODO why driver ?? -- freddy77 */ errs->errs[n].server = (server) ? strdup(server) : strdup("DRIVER"); errs->errs[n].msg = msg ? strdup(msg) : odbc_get_msg(errs->errs[n].state3); errs->errs[n].linenum = linenum; errs->errs[n].msgstate = msgstate; ++errs->num_errors; } #define SQLS_MAP(v2,v3) if (strcmp(p,v2) == 0) {strcpy(p,v3); return;} static void sqlstate2to3(char *state) { char *p = state; if (p[0] == 'S' && p[1] == '0' && p[2] == '0') { p[0] = '4'; p[1] = '2'; p[2] = 'S'; return; } /* TODO optimize with a switch */ SQLS_MAP("01S03", "01001"); SQLS_MAP("01S04", "01001"); SQLS_MAP("22003", "HY019"); SQLS_MAP("22008", "22007"); SQLS_MAP("22005", "22018"); SQLS_MAP("24000", "07005"); SQLS_MAP("37000", "42000"); SQLS_MAP("70100", "HY018"); SQLS_MAP("S1000", "HY000"); SQLS_MAP("S1001", "HY001"); SQLS_MAP("S1002", "07009"); SQLS_MAP("S1003", "HY003"); SQLS_MAP("S1004", "HY004"); SQLS_MAP("S1008", "HY008"); SQLS_MAP("S1009", "HY009"); SQLS_MAP("S1010", "HY007"); SQLS_MAP("S1011", "HY011"); SQLS_MAP("S1012", "HY012"); SQLS_MAP("S1090", "HY090"); SQLS_MAP("S1091", "HY091"); SQLS_MAP("S1092", "HY092"); SQLS_MAP("S1093", "07009"); SQLS_MAP("S1096", "HY096"); SQLS_MAP("S1097", "HY097"); SQLS_MAP("S1098", "HY098"); SQLS_MAP("S1099", "HY099"); SQLS_MAP("S1100", "HY100"); SQLS_MAP("S1101", "HY101"); SQLS_MAP("S1103", "HY103"); SQLS_MAP("S1104", "HY104"); SQLS_MAP("S1105", "HY105"); SQLS_MAP("S1106", "HY106"); SQLS_MAP("S1107", "HY107"); SQLS_MAP("S1108", "HY108"); SQLS_MAP("S1109", "HY109"); SQLS_MAP("S1110", "HY110"); SQLS_MAP("S1111", "HY111"); SQLS_MAP("S1C00", "HYC00"); SQLS_MAP("S1T00", "HYT00"); } ODBC_FUNC(SQLGetDiagRec, (P(SQLSMALLINT,handleType), P(SQLHANDLE,handle), P(SQLSMALLINT,numRecord), PCHAR(szSqlState), P(SQLINTEGER FAR *,pfNativeError), PCHAROUT(ErrorMsg,SQLSMALLINT) WIDE)) { SQLRETURN result; struct _sql_errors *errs; const char *msg; char *p; TDS_DBC *dbc = NULL; static const char msgprefix[] = "[FreeTDS][SQL Server]"; SQLINTEGER odbc_ver = SQL_OV_ODBC2; if (numRecord <= 0 || cbErrorMsgMax < 0) return SQL_ERROR; if (!handle || ((TDS_CHK *) handle)->htype != handleType) return SQL_INVALID_HANDLE; errs = &((TDS_CHK *) handle)->errs; switch (handleType) { case SQL_HANDLE_STMT: dbc = ((TDS_STMT *) handle)->dbc; odbc_ver = dbc->env->attr.odbc_version; break; case SQL_HANDLE_DBC: dbc = (TDS_DBC *) handle; odbc_ver = dbc->env->attr.odbc_version; break; case SQL_HANDLE_ENV: odbc_ver = ((TDS_ENV *) handle)->attr.odbc_version; break; case SQL_HANDLE_DESC: dbc = desc_get_dbc((TDS_DESC *) handle); odbc_ver = dbc->env->attr.odbc_version; break; default: return SQL_INVALID_HANDLE; } if (numRecord > errs->num_errors) return SQL_NO_DATA_FOUND; --numRecord; rank_errors(errs); if (szSqlState) { const char *state = (odbc_ver == SQL_OV_ODBC3) ? errs->errs[numRecord].state3 : errs->errs[numRecord].state2; odbc_set_string(dbc, szSqlState, 24, (SQLSMALLINT *) NULL, state, -1); } msg = errs->errs[numRecord].msg; if (asprintf(&p, "%s%s", msgprefix, msg) < 0) return SQL_ERROR; tdsdump_log(TDS_DBG_FUNC, "SQLGetDiagRec: \"%s\"\n", p); result = odbc_set_string(dbc, szErrorMsg, cbErrorMsgMax, pcbErrorMsg, p, -1); free(p); if (pfNativeError) *pfNativeError = errs->errs[numRecord].native; return result; } ODBC_FUNC(SQLError, (P(SQLHENV,henv), P(SQLHDBC,hdbc), P(SQLHSTMT,hstmt), PCHAR(szSqlState), P(SQLINTEGER FAR *,pfNativeError), PCHAROUT(ErrorMsg,SQLSMALLINT) WIDE)) { SQLRETURN result; SQLSMALLINT type; SQLHANDLE handle; if (hstmt) { handle = hstmt; type = SQL_HANDLE_STMT; } else if (hdbc) { handle = hdbc; type = SQL_HANDLE_DBC; } else if (henv) { handle = henv; type = SQL_HANDLE_ENV; } else return SQL_INVALID_HANDLE; result = _SQLGetDiagRec(type, handle, 1, szSqlState, pfNativeError, szErrorMsg, cbErrorMsgMax, pcbErrorMsg _wide); if (result == SQL_SUCCESS) { /* remove first error */ odbc_errs_pop(&((TDS_CHK *) handle)->errs); } return result; } ODBC_FUNC(SQLGetDiagField, (P(SQLSMALLINT,handleType), P(SQLHANDLE,handle), P(SQLSMALLINT,numRecord), P(SQLSMALLINT,diagIdentifier), P(SQLPOINTER,buffer), P(SQLSMALLINT,cbBuffer), P(SQLSMALLINT FAR *,pcbBuffer) WIDE)) { SQLRETURN result = SQL_SUCCESS; struct _sql_errors *errs; const char *msg; SQLINTEGER odbc_ver = SQL_OV_ODBC2; int cplen; TDS_STMT *stmt = NULL; TDS_DBC *dbc = NULL; TDS_ENV *env = NULL; char tmp[16]; if (cbBuffer < 0) return SQL_ERROR; if (!handle || ((TDS_CHK *) handle)->htype != handleType) return SQL_INVALID_HANDLE; switch (handleType) { case SQL_HANDLE_STMT: stmt = ((TDS_STMT *) handle); dbc = stmt->dbc; env = dbc->env; break; case SQL_HANDLE_DBC: dbc = ((TDS_DBC *) handle); env = dbc->env; break; case SQL_HANDLE_ENV: env = ((TDS_ENV *) handle); break; case SQL_HANDLE_DESC: dbc = desc_get_dbc((TDS_DESC *) handle); env = dbc->env; break; default: return SQL_INVALID_HANDLE; } errs = &((TDS_CHK *) handle)->errs; odbc_ver = env->attr.odbc_version; /* header (numRecord ignored) */ switch (diagIdentifier) { case SQL_DIAG_DYNAMIC_FUNCTION: if (handleType != SQL_HANDLE_STMT) return SQL_ERROR; /* TODO */ return odbc_set_string_oct(dbc, buffer, cbBuffer, pcbBuffer, "", 0); case SQL_DIAG_DYNAMIC_FUNCTION_CODE: *(SQLINTEGER *) buffer = 0; return SQL_SUCCESS; case SQL_DIAG_NUMBER: *(SQLINTEGER *) buffer = errs->num_errors; return SQL_SUCCESS; case SQL_DIAG_RETURNCODE: *(SQLRETURN *) buffer = errs->lastrc; return SQL_SUCCESS; case SQL_DIAG_CURSOR_ROW_COUNT: if (handleType != SQL_HANDLE_STMT) return SQL_ERROR; /* TODO */ *(SQLINTEGER *) buffer = 0; return SQL_SUCCESS; case SQL_DIAG_ROW_COUNT: if (handleType != SQL_HANDLE_STMT) return SQL_ERROR; return _SQLRowCount((SQLHSTMT) handle, (SQLLEN FAR *) buffer); } if (numRecord > errs->num_errors) return SQL_NO_DATA_FOUND; if (numRecord <= 0) return SQL_ERROR; --numRecord; switch (diagIdentifier) { case SQL_DIAG_ROW_NUMBER: *(SQLINTEGER *) buffer = errs->errs[numRecord].row > 0 ? errs->errs[numRecord].row : SQL_ROW_NUMBER_UNKNOWN; break; case SQL_DIAG_CLASS_ORIGIN: case SQL_DIAG_SUBCLASS_ORIGIN: if (odbc_ver == SQL_OV_ODBC2) result = odbc_set_string_oct(dbc, buffer, cbBuffer, pcbBuffer, "ISO 9075", -1); else result = odbc_set_string_oct(dbc, buffer, cbBuffer, pcbBuffer, "ODBC 3.0", -1); break; case SQL_DIAG_COLUMN_NUMBER: *(SQLINTEGER *) buffer = SQL_COLUMN_NUMBER_UNKNOWN; break; case SQL_DIAG_SS_MSGSTATE: if (errs->errs[numRecord].msgstate == 0) return SQL_ERROR; else *(SQLINTEGER *) buffer = errs->errs[numRecord].msgstate; break; case SQL_DIAG_SS_LINE: if (errs->errs[numRecord].linenum == 0) return SQL_ERROR; else *(SQLUSMALLINT *) buffer = errs->errs[numRecord].linenum; break; case SQL_DIAG_CONNECTION_NAME: if (dbc && dbc->tds_socket && dbc->tds_socket->conn->spid > 0) cplen = sprintf(tmp, "%d", dbc->tds_socket->conn->spid); else cplen = 0; result = odbc_set_string_oct(dbc, buffer, cbBuffer, pcbBuffer, tmp, cplen); break; case SQL_DIAG_MESSAGE_TEXT: msg = errs->errs[numRecord].msg; result = odbc_set_string_oct(dbc, buffer, cbBuffer, pcbBuffer, msg, -1); break; case SQL_DIAG_NATIVE: *(SQLINTEGER *) buffer = errs->errs[numRecord].native; break; case SQL_DIAG_SERVER_NAME: msg = NULL; switch (handleType) { case SQL_HANDLE_ENV: break; case SQL_HANDLE_DBC: if (dbc->tds_socket) msg = dbc->tds_socket->conn->server; break; case SQL_HANDLE_STMT: if (stmt->dbc->tds_socket) msg = stmt->dbc->tds_socket->conn->server; /* * if dbc->server is not initialized, init it * from the errs structure */ if (!msg && errs->errs[numRecord].server) { msg = errs->errs[numRecord].server; } break; } result = odbc_set_string_oct(dbc, buffer, cbBuffer, pcbBuffer, msg ? msg : "", -1); break; case SQL_DIAG_SQLSTATE: if (odbc_ver == SQL_OV_ODBC3) msg = errs->errs[numRecord].state3; else msg = errs->errs[numRecord].state2; result = odbc_set_string_oct(dbc, buffer, cbBuffer, pcbBuffer, msg, 5); break; default: return SQL_ERROR; } return result; } #include "error_export.h" freetds-1.00.82/src/odbc/odbc_checks.c100644 025423 025423 00000007536 12717145107 0013137/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2003-2008 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include #if ENABLE_EXTRA_CHECKS void odbc_check_env_extra(TDS_ENV * env) { assert(env && env->htype == SQL_HANDLE_ENV); assert(env->attr.odbc_version == SQL_OV_ODBC3 || env->attr.odbc_version == SQL_OV_ODBC2); } void odbc_check_dbc_extra(TDS_DBC * dbc) { assert(dbc && dbc->htype == SQL_HANDLE_DBC); } void odbc_check_stmt_extra(TDS_STMT * stmt) { assert(stmt && stmt->htype == SQL_HANDLE_STMT); /* TODO deep check on connection */ assert(stmt->dbc); odbc_check_desc_extra(stmt->ard); odbc_check_desc_extra(stmt->ird); odbc_check_desc_extra(stmt->apd); odbc_check_desc_extra(stmt->ipd); assert(!stmt->prepared_query_is_func || stmt->prepared_query_is_rpc); assert(stmt->param_num <= stmt->param_count + 1); assert(stmt->num_param_rows >= 1); assert(stmt->curr_param_row >= 0); assert(stmt->curr_param_row <= stmt->num_param_rows); if (stmt->prepared_query_is_rpc) { const char *query = tds_dstr_cstr(&stmt->query); assert(query); assert(stmt->prepared_pos == NULL || (stmt->prepared_pos >= query && stmt->prepared_pos <= strchr(query,0))); } else { assert(stmt->prepared_pos == NULL); } /* TODO assert dbc has this statement in list */ } static void odbc_check_drecord(TDS_DESC * desc, struct _drecord *drec) { assert(drec->sql_desc_concise_type != SQL_INTERVAL && drec->sql_desc_concise_type != SQL_DATETIME); /* unbound columns have type == 0 */ /* TODO test errors on code if type == 0 */ if (desc->type == DESC_IPD || desc->type == DESC_IRD) { assert((drec->sql_desc_type == 0 && drec->sql_desc_concise_type == 0) || odbc_get_concise_sql_type(drec->sql_desc_type, drec->sql_desc_datetime_interval_code) == drec->sql_desc_concise_type); } else { assert((drec->sql_desc_type == 0 && drec->sql_desc_concise_type == 0) || odbc_get_concise_c_type(drec->sql_desc_type, drec->sql_desc_datetime_interval_code) == drec->sql_desc_concise_type); } } void odbc_check_desc_extra(TDS_DESC * desc) { int i; assert(desc && desc->htype == SQL_HANDLE_DESC); assert(desc->header.sql_desc_alloc_type == SQL_DESC_ALLOC_AUTO || desc->header.sql_desc_alloc_type == SQL_DESC_ALLOC_USER); assert((desc->type != DESC_IPD && desc->type != DESC_IRD) || desc->header.sql_desc_alloc_type == SQL_DESC_ALLOC_AUTO); for (i = 0; i < desc->header.sql_desc_count; ++i) { odbc_check_drecord(desc, &desc->records[i]); } } void odbc_check_struct_extra(void *p) { const int invalid_htype = 0; switch (((TDS_CHK *) p)->htype) { case SQL_HANDLE_ENV: odbc_check_env_extra((TDS_ENV *) p); break; case SQL_HANDLE_DBC: odbc_check_dbc_extra((TDS_DBC *) p); break; case SQL_HANDLE_STMT: odbc_check_stmt_extra((TDS_STMT *) p); break; case SQL_HANDLE_DESC: odbc_check_desc_extra((TDS_DESC *) p); break; default: assert(invalid_htype); } } #endif /* ENABLE_EXTRA_CHECKS */ freetds-1.00.82/src/odbc/sqlwchar.c100644 025423 025423 00000004332 12717145107 0012523/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2008 Ziglio Frediano * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #include #include #include "../tds/encodings.h" #if SIZEOF_SQLWCHAR != SIZEOF_WCHAR_T size_t sqlwcslen(const SQLWCHAR * s) { const SQLWCHAR *p = s; while (*p) ++p; return p - s; } #ifdef ENABLE_ODBC_WIDE /** * Convert a SQLWCHAR string into a wchar_t * Used only for debugging purpose * \param str string to convert * \param bufs linked list of buffer * \return string converted */ const wchar_t *sqlwstr(const SQLWCHAR *str, SQLWSTRBUF **bufs) { wchar_t *dst, *dst_end; const SQLWCHAR *src = str; SQLWSTRBUF *buf; if (!str) return NULL; /* allocate buffer for string, we do not care for memory errors */ buf = tds_new0(SQLWSTRBUF, 1); if (!buf) return NULL; buf->next = *bufs; *bufs = buf; dst = buf->buf; dst_end = dst + (TDS_VECTOR_SIZE(buf->buf) - 1); for (; *src && dst < dst_end; *dst++ = *src++) continue; *dst = L'\0'; return buf->buf; } void sqlwstr_free(SQLWSTRBUF *bufs) { while (bufs) { SQLWSTRBUF *buf = bufs; bufs = buf->next; free(buf); } } #endif #endif #if SIZEOF_SQLWCHAR == 2 const char *odbc_get_wide_name(TDSCONNECTION *conn) { if (conn->char_convs[client2ucs2]->to.charset.canonic == TDS_CHARSET_UTF_16LE) return ODBC_WIDE_NAME_UTF; return ODBC_WIDE_NAME; } #endif freetds-1.00.82/src/odbc/sqlwparams.h100644 025423 025423 00000000763 12522201763 0013075#if 0 # ODBC_FUNC(SQLTest, (P(SQLSMALLINT, x), PCHAR(y) WIDE)) #endif #undef WIDE #undef P #undef PCHAR #undef PCHARIN #undef PCHAROUT #ifdef ENABLE_ODBC_WIDE # define WIDE , int wide # define PCHAR(a) ODBC_CHAR* a #else # define WIDE # define PCHAR(a) SQLCHAR* a #endif #define P(a,b) a b #define PCHARIN(n,t) PCHAR(sz ## n), P(t, cb ## n) #define PCHAROUT(n,t) PCHAR(sz ## n), P(t, cb ## n ## Max), P(t FAR*, pcb ## n) #define ODBC_FUNC(name, params) \ static SQLRETURN _ ## name params freetds-1.00.82/src/odbc/odbc_export.h100644 025423 025423 00000113075 13242511130 0013204#undef tdsdump_log #ifdef ENABLE_ODBC_WIDE static SQLRETURN _SQLDriverConnect(SQLHDBC hdbc, SQLHWND hwnd, ODBC_CHAR * szConnStrIn, SQLSMALLINT cbConnStrIn, ODBC_CHAR * szConnStrOut, SQLSMALLINT cbConnStrOutMax, SQLSMALLINT FAR* pcbConnStrOut, SQLUSMALLINT fDriverCompletion, int wide); SQLRETURN ODBC_PUBLIC ODBC_API SQLDriverConnectW( SQLHDBC hdbc, SQLHWND hwnd, SQLWCHAR * szConnStrIn, SQLSMALLINT cbConnStrIn, SQLWCHAR * szConnStrOut, SQLSMALLINT cbConnStrOutMax, SQLSMALLINT FAR* pcbConnStrOut, SQLUSMALLINT fDriverCompletion) { if (TDS_UNLIKELY(tds_write_dump)) { SQLWSTR_BUFS(1); tdsdump_log(TDS_DBG_FUNC, "SQLDriverConnectW(%p, %p, %ls, %d, %p, %d, %p, %u)\n", hdbc, hwnd, SQLWSTR(szConnStrIn), (int) cbConnStrIn, szConnStrOut, (int) cbConnStrOutMax, pcbConnStrOut, (unsigned int) fDriverCompletion); SQLWSTR_FREE(); } return _SQLDriverConnect(hdbc, hwnd, (ODBC_CHAR*) szConnStrIn, cbConnStrIn, (ODBC_CHAR*) szConnStrOut, cbConnStrOutMax, pcbConnStrOut, fDriverCompletion, 1); } #endif SQLRETURN ODBC_PUBLIC ODBC_API SQLDriverConnect( SQLHDBC hdbc, SQLHWND hwnd, SQLCHAR * szConnStrIn, SQLSMALLINT cbConnStrIn, SQLCHAR * szConnStrOut, SQLSMALLINT cbConnStrOutMax, SQLSMALLINT FAR* pcbConnStrOut, SQLUSMALLINT fDriverCompletion) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLDriverConnect(%p, %p, %s, %d, %p, %d, %p, %u)\n", hdbc, hwnd, (const char*) szConnStrIn, (int) cbConnStrIn, szConnStrOut, (int) cbConnStrOutMax, pcbConnStrOut, (unsigned int) fDriverCompletion); #ifdef ENABLE_ODBC_WIDE return _SQLDriverConnect(hdbc, hwnd, (ODBC_CHAR*) szConnStrIn, cbConnStrIn, (ODBC_CHAR*) szConnStrOut, cbConnStrOutMax, pcbConnStrOut, fDriverCompletion, 0); #else return _SQLDriverConnect(hdbc, hwnd, szConnStrIn, cbConnStrIn, szConnStrOut, cbConnStrOutMax, pcbConnStrOut, fDriverCompletion); #endif } #ifdef ENABLE_ODBC_WIDE static SQLRETURN _SQLColumnPrivileges(SQLHSTMT hstmt, ODBC_CHAR * szCatalogName, SQLSMALLINT cbCatalogName, ODBC_CHAR * szSchemaName, SQLSMALLINT cbSchemaName, ODBC_CHAR * szTableName, SQLSMALLINT cbTableName, ODBC_CHAR * szColumnName, SQLSMALLINT cbColumnName, int wide); SQLRETURN ODBC_PUBLIC ODBC_API SQLColumnPrivilegesW( SQLHSTMT hstmt, SQLWCHAR * szCatalogName, SQLSMALLINT cbCatalogName, SQLWCHAR * szSchemaName, SQLSMALLINT cbSchemaName, SQLWCHAR * szTableName, SQLSMALLINT cbTableName, SQLWCHAR * szColumnName, SQLSMALLINT cbColumnName) { if (TDS_UNLIKELY(tds_write_dump)) { SQLWSTR_BUFS(4); tdsdump_log(TDS_DBG_FUNC, "SQLColumnPrivilegesW(%p, %ls, %d, %ls, %d, %ls, %d, %ls, %d)\n", hstmt, SQLWSTR(szCatalogName), (int) cbCatalogName, SQLWSTR(szSchemaName), (int) cbSchemaName, SQLWSTR(szTableName), (int) cbTableName, SQLWSTR(szColumnName), (int) cbColumnName); SQLWSTR_FREE(); } return _SQLColumnPrivileges(hstmt, (ODBC_CHAR*) szCatalogName, cbCatalogName, (ODBC_CHAR*) szSchemaName, cbSchemaName, (ODBC_CHAR*) szTableName, cbTableName, (ODBC_CHAR*) szColumnName, cbColumnName, 1); } #endif SQLRETURN ODBC_PUBLIC ODBC_API SQLColumnPrivileges( SQLHSTMT hstmt, SQLCHAR * szCatalogName, SQLSMALLINT cbCatalogName, SQLCHAR * szSchemaName, SQLSMALLINT cbSchemaName, SQLCHAR * szTableName, SQLSMALLINT cbTableName, SQLCHAR * szColumnName, SQLSMALLINT cbColumnName) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLColumnPrivileges(%p, %s, %d, %s, %d, %s, %d, %s, %d)\n", hstmt, (const char*) szCatalogName, (int) cbCatalogName, (const char*) szSchemaName, (int) cbSchemaName, (const char*) szTableName, (int) cbTableName, (const char*) szColumnName, (int) cbColumnName); #ifdef ENABLE_ODBC_WIDE return _SQLColumnPrivileges(hstmt, (ODBC_CHAR*) szCatalogName, cbCatalogName, (ODBC_CHAR*) szSchemaName, cbSchemaName, (ODBC_CHAR*) szTableName, cbTableName, (ODBC_CHAR*) szColumnName, cbColumnName, 0); #else return _SQLColumnPrivileges(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName, szColumnName, cbColumnName); #endif } #ifdef ENABLE_ODBC_WIDE static SQLRETURN _SQLForeignKeys(SQLHSTMT hstmt, ODBC_CHAR * szPkCatalogName, SQLSMALLINT cbPkCatalogName, ODBC_CHAR * szPkSchemaName, SQLSMALLINT cbPkSchemaName, ODBC_CHAR * szPkTableName, SQLSMALLINT cbPkTableName, ODBC_CHAR * szFkCatalogName, SQLSMALLINT cbFkCatalogName, ODBC_CHAR * szFkSchemaName, SQLSMALLINT cbFkSchemaName, ODBC_CHAR * szFkTableName, SQLSMALLINT cbFkTableName, int wide); SQLRETURN ODBC_PUBLIC ODBC_API SQLForeignKeysW( SQLHSTMT hstmt, SQLWCHAR * szPkCatalogName, SQLSMALLINT cbPkCatalogName, SQLWCHAR * szPkSchemaName, SQLSMALLINT cbPkSchemaName, SQLWCHAR * szPkTableName, SQLSMALLINT cbPkTableName, SQLWCHAR * szFkCatalogName, SQLSMALLINT cbFkCatalogName, SQLWCHAR * szFkSchemaName, SQLSMALLINT cbFkSchemaName, SQLWCHAR * szFkTableName, SQLSMALLINT cbFkTableName) { if (TDS_UNLIKELY(tds_write_dump)) { SQLWSTR_BUFS(6); tdsdump_log(TDS_DBG_FUNC, "SQLForeignKeysW(%p, %ls, %d, %ls, %d, %ls, %d, %ls, %d, %ls, %d, %ls, %d)\n", hstmt, SQLWSTR(szPkCatalogName), (int) cbPkCatalogName, SQLWSTR(szPkSchemaName), (int) cbPkSchemaName, SQLWSTR(szPkTableName), (int) cbPkTableName, SQLWSTR(szFkCatalogName), (int) cbFkCatalogName, SQLWSTR(szFkSchemaName), (int) cbFkSchemaName, SQLWSTR(szFkTableName), (int) cbFkTableName); SQLWSTR_FREE(); } return _SQLForeignKeys(hstmt, (ODBC_CHAR*) szPkCatalogName, cbPkCatalogName, (ODBC_CHAR*) szPkSchemaName, cbPkSchemaName, (ODBC_CHAR*) szPkTableName, cbPkTableName, (ODBC_CHAR*) szFkCatalogName, cbFkCatalogName, (ODBC_CHAR*) szFkSchemaName, cbFkSchemaName, (ODBC_CHAR*) szFkTableName, cbFkTableName, 1); } #endif SQLRETURN ODBC_PUBLIC ODBC_API SQLForeignKeys( SQLHSTMT hstmt, SQLCHAR * szPkCatalogName, SQLSMALLINT cbPkCatalogName, SQLCHAR * szPkSchemaName, SQLSMALLINT cbPkSchemaName, SQLCHAR * szPkTableName, SQLSMALLINT cbPkTableName, SQLCHAR * szFkCatalogName, SQLSMALLINT cbFkCatalogName, SQLCHAR * szFkSchemaName, SQLSMALLINT cbFkSchemaName, SQLCHAR * szFkTableName, SQLSMALLINT cbFkTableName) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLForeignKeys(%p, %s, %d, %s, %d, %s, %d, %s, %d, %s, %d, %s, %d)\n", hstmt, (const char*) szPkCatalogName, (int) cbPkCatalogName, (const char*) szPkSchemaName, (int) cbPkSchemaName, (const char*) szPkTableName, (int) cbPkTableName, (const char*) szFkCatalogName, (int) cbFkCatalogName, (const char*) szFkSchemaName, (int) cbFkSchemaName, (const char*) szFkTableName, (int) cbFkTableName); #ifdef ENABLE_ODBC_WIDE return _SQLForeignKeys(hstmt, (ODBC_CHAR*) szPkCatalogName, cbPkCatalogName, (ODBC_CHAR*) szPkSchemaName, cbPkSchemaName, (ODBC_CHAR*) szPkTableName, cbPkTableName, (ODBC_CHAR*) szFkCatalogName, cbFkCatalogName, (ODBC_CHAR*) szFkSchemaName, cbFkSchemaName, (ODBC_CHAR*) szFkTableName, cbFkTableName, 0); #else return _SQLForeignKeys(hstmt, szPkCatalogName, cbPkCatalogName, szPkSchemaName, cbPkSchemaName, szPkTableName, cbPkTableName, szFkCatalogName, cbFkCatalogName, szFkSchemaName, cbFkSchemaName, szFkTableName, cbFkTableName); #endif } #ifdef ENABLE_ODBC_WIDE static SQLRETURN _SQLNativeSql(SQLHDBC hdbc, ODBC_CHAR * szSqlStrIn, SQLINTEGER cbSqlStrIn, ODBC_CHAR * szSqlStr, SQLINTEGER cbSqlStrMax, SQLINTEGER FAR* pcbSqlStr, int wide); SQLRETURN ODBC_PUBLIC ODBC_API SQLNativeSqlW( SQLHDBC hdbc, SQLWCHAR * szSqlStrIn, SQLINTEGER cbSqlStrIn, SQLWCHAR * szSqlStr, SQLINTEGER cbSqlStrMax, SQLINTEGER FAR* pcbSqlStr) { if (TDS_UNLIKELY(tds_write_dump)) { SQLWSTR_BUFS(1); tdsdump_log(TDS_DBG_FUNC, "SQLNativeSqlW(%p, %ls, %d, %p, %d, %p)\n", hdbc, SQLWSTR(szSqlStrIn), (int) cbSqlStrIn, szSqlStr, (int) cbSqlStrMax, pcbSqlStr); SQLWSTR_FREE(); } return _SQLNativeSql(hdbc, (ODBC_CHAR*) szSqlStrIn, cbSqlStrIn, (ODBC_CHAR*) szSqlStr, cbSqlStrMax, pcbSqlStr, 1); } #endif SQLRETURN ODBC_PUBLIC ODBC_API SQLNativeSql( SQLHDBC hdbc, SQLCHAR * szSqlStrIn, SQLINTEGER cbSqlStrIn, SQLCHAR * szSqlStr, SQLINTEGER cbSqlStrMax, SQLINTEGER FAR* pcbSqlStr) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLNativeSql(%p, %s, %d, %p, %d, %p)\n", hdbc, (const char*) szSqlStrIn, (int) cbSqlStrIn, szSqlStr, (int) cbSqlStrMax, pcbSqlStr); #ifdef ENABLE_ODBC_WIDE return _SQLNativeSql(hdbc, (ODBC_CHAR*) szSqlStrIn, cbSqlStrIn, (ODBC_CHAR*) szSqlStr, cbSqlStrMax, pcbSqlStr, 0); #else return _SQLNativeSql(hdbc, szSqlStrIn, cbSqlStrIn, szSqlStr, cbSqlStrMax, pcbSqlStr); #endif } #ifdef ENABLE_ODBC_WIDE static SQLRETURN _SQLPrimaryKeys(SQLHSTMT hstmt, ODBC_CHAR * szCatalogName, SQLSMALLINT cbCatalogName, ODBC_CHAR * szSchemaName, SQLSMALLINT cbSchemaName, ODBC_CHAR * szTableName, SQLSMALLINT cbTableName, int wide); SQLRETURN ODBC_PUBLIC ODBC_API SQLPrimaryKeysW( SQLHSTMT hstmt, SQLWCHAR * szCatalogName, SQLSMALLINT cbCatalogName, SQLWCHAR * szSchemaName, SQLSMALLINT cbSchemaName, SQLWCHAR * szTableName, SQLSMALLINT cbTableName) { if (TDS_UNLIKELY(tds_write_dump)) { SQLWSTR_BUFS(3); tdsdump_log(TDS_DBG_FUNC, "SQLPrimaryKeysW(%p, %ls, %d, %ls, %d, %ls, %d)\n", hstmt, SQLWSTR(szCatalogName), (int) cbCatalogName, SQLWSTR(szSchemaName), (int) cbSchemaName, SQLWSTR(szTableName), (int) cbTableName); SQLWSTR_FREE(); } return _SQLPrimaryKeys(hstmt, (ODBC_CHAR*) szCatalogName, cbCatalogName, (ODBC_CHAR*) szSchemaName, cbSchemaName, (ODBC_CHAR*) szTableName, cbTableName, 1); } #endif SQLRETURN ODBC_PUBLIC ODBC_API SQLPrimaryKeys( SQLHSTMT hstmt, SQLCHAR * szCatalogName, SQLSMALLINT cbCatalogName, SQLCHAR * szSchemaName, SQLSMALLINT cbSchemaName, SQLCHAR * szTableName, SQLSMALLINT cbTableName) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLPrimaryKeys(%p, %s, %d, %s, %d, %s, %d)\n", hstmt, (const char*) szCatalogName, (int) cbCatalogName, (const char*) szSchemaName, (int) cbSchemaName, (const char*) szTableName, (int) cbTableName); #ifdef ENABLE_ODBC_WIDE return _SQLPrimaryKeys(hstmt, (ODBC_CHAR*) szCatalogName, cbCatalogName, (ODBC_CHAR*) szSchemaName, cbSchemaName, (ODBC_CHAR*) szTableName, cbTableName, 0); #else return _SQLPrimaryKeys(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName); #endif } #ifdef ENABLE_ODBC_WIDE static SQLRETURN _SQLProcedureColumns(SQLHSTMT hstmt, ODBC_CHAR * szCatalogName, SQLSMALLINT cbCatalogName, ODBC_CHAR * szSchemaName, SQLSMALLINT cbSchemaName, ODBC_CHAR * szProcName, SQLSMALLINT cbProcName, ODBC_CHAR * szColumnName, SQLSMALLINT cbColumnName, int wide); SQLRETURN ODBC_PUBLIC ODBC_API SQLProcedureColumnsW( SQLHSTMT hstmt, SQLWCHAR * szCatalogName, SQLSMALLINT cbCatalogName, SQLWCHAR * szSchemaName, SQLSMALLINT cbSchemaName, SQLWCHAR * szProcName, SQLSMALLINT cbProcName, SQLWCHAR * szColumnName, SQLSMALLINT cbColumnName) { if (TDS_UNLIKELY(tds_write_dump)) { SQLWSTR_BUFS(4); tdsdump_log(TDS_DBG_FUNC, "SQLProcedureColumnsW(%p, %ls, %d, %ls, %d, %ls, %d, %ls, %d)\n", hstmt, SQLWSTR(szCatalogName), (int) cbCatalogName, SQLWSTR(szSchemaName), (int) cbSchemaName, SQLWSTR(szProcName), (int) cbProcName, SQLWSTR(szColumnName), (int) cbColumnName); SQLWSTR_FREE(); } return _SQLProcedureColumns(hstmt, (ODBC_CHAR*) szCatalogName, cbCatalogName, (ODBC_CHAR*) szSchemaName, cbSchemaName, (ODBC_CHAR*) szProcName, cbProcName, (ODBC_CHAR*) szColumnName, cbColumnName, 1); } #endif SQLRETURN ODBC_PUBLIC ODBC_API SQLProcedureColumns( SQLHSTMT hstmt, SQLCHAR * szCatalogName, SQLSMALLINT cbCatalogName, SQLCHAR * szSchemaName, SQLSMALLINT cbSchemaName, SQLCHAR * szProcName, SQLSMALLINT cbProcName, SQLCHAR * szColumnName, SQLSMALLINT cbColumnName) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLProcedureColumns(%p, %s, %d, %s, %d, %s, %d, %s, %d)\n", hstmt, (const char*) szCatalogName, (int) cbCatalogName, (const char*) szSchemaName, (int) cbSchemaName, (const char*) szProcName, (int) cbProcName, (const char*) szColumnName, (int) cbColumnName); #ifdef ENABLE_ODBC_WIDE return _SQLProcedureColumns(hstmt, (ODBC_CHAR*) szCatalogName, cbCatalogName, (ODBC_CHAR*) szSchemaName, cbSchemaName, (ODBC_CHAR*) szProcName, cbProcName, (ODBC_CHAR*) szColumnName, cbColumnName, 0); #else return _SQLProcedureColumns(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szProcName, cbProcName, szColumnName, cbColumnName); #endif } #ifdef ENABLE_ODBC_WIDE static SQLRETURN _SQLProcedures(SQLHSTMT hstmt, ODBC_CHAR * szCatalogName, SQLSMALLINT cbCatalogName, ODBC_CHAR * szSchemaName, SQLSMALLINT cbSchemaName, ODBC_CHAR * szProcName, SQLSMALLINT cbProcName, int wide); SQLRETURN ODBC_PUBLIC ODBC_API SQLProceduresW( SQLHSTMT hstmt, SQLWCHAR * szCatalogName, SQLSMALLINT cbCatalogName, SQLWCHAR * szSchemaName, SQLSMALLINT cbSchemaName, SQLWCHAR * szProcName, SQLSMALLINT cbProcName) { if (TDS_UNLIKELY(tds_write_dump)) { SQLWSTR_BUFS(3); tdsdump_log(TDS_DBG_FUNC, "SQLProceduresW(%p, %ls, %d, %ls, %d, %ls, %d)\n", hstmt, SQLWSTR(szCatalogName), (int) cbCatalogName, SQLWSTR(szSchemaName), (int) cbSchemaName, SQLWSTR(szProcName), (int) cbProcName); SQLWSTR_FREE(); } return _SQLProcedures(hstmt, (ODBC_CHAR*) szCatalogName, cbCatalogName, (ODBC_CHAR*) szSchemaName, cbSchemaName, (ODBC_CHAR*) szProcName, cbProcName, 1); } #endif SQLRETURN ODBC_PUBLIC ODBC_API SQLProcedures( SQLHSTMT hstmt, SQLCHAR * szCatalogName, SQLSMALLINT cbCatalogName, SQLCHAR * szSchemaName, SQLSMALLINT cbSchemaName, SQLCHAR * szProcName, SQLSMALLINT cbProcName) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLProcedures(%p, %s, %d, %s, %d, %s, %d)\n", hstmt, (const char*) szCatalogName, (int) cbCatalogName, (const char*) szSchemaName, (int) cbSchemaName, (const char*) szProcName, (int) cbProcName); #ifdef ENABLE_ODBC_WIDE return _SQLProcedures(hstmt, (ODBC_CHAR*) szCatalogName, cbCatalogName, (ODBC_CHAR*) szSchemaName, cbSchemaName, (ODBC_CHAR*) szProcName, cbProcName, 0); #else return _SQLProcedures(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szProcName, cbProcName); #endif } #ifdef ENABLE_ODBC_WIDE static SQLRETURN _SQLTablePrivileges(SQLHSTMT hstmt, ODBC_CHAR * szCatalogName, SQLSMALLINT cbCatalogName, ODBC_CHAR * szSchemaName, SQLSMALLINT cbSchemaName, ODBC_CHAR * szTableName, SQLSMALLINT cbTableName, int wide); SQLRETURN ODBC_PUBLIC ODBC_API SQLTablePrivilegesW( SQLHSTMT hstmt, SQLWCHAR * szCatalogName, SQLSMALLINT cbCatalogName, SQLWCHAR * szSchemaName, SQLSMALLINT cbSchemaName, SQLWCHAR * szTableName, SQLSMALLINT cbTableName) { if (TDS_UNLIKELY(tds_write_dump)) { SQLWSTR_BUFS(3); tdsdump_log(TDS_DBG_FUNC, "SQLTablePrivilegesW(%p, %ls, %d, %ls, %d, %ls, %d)\n", hstmt, SQLWSTR(szCatalogName), (int) cbCatalogName, SQLWSTR(szSchemaName), (int) cbSchemaName, SQLWSTR(szTableName), (int) cbTableName); SQLWSTR_FREE(); } return _SQLTablePrivileges(hstmt, (ODBC_CHAR*) szCatalogName, cbCatalogName, (ODBC_CHAR*) szSchemaName, cbSchemaName, (ODBC_CHAR*) szTableName, cbTableName, 1); } #endif SQLRETURN ODBC_PUBLIC ODBC_API SQLTablePrivileges( SQLHSTMT hstmt, SQLCHAR * szCatalogName, SQLSMALLINT cbCatalogName, SQLCHAR * szSchemaName, SQLSMALLINT cbSchemaName, SQLCHAR * szTableName, SQLSMALLINT cbTableName) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLTablePrivileges(%p, %s, %d, %s, %d, %s, %d)\n", hstmt, (const char*) szCatalogName, (int) cbCatalogName, (const char*) szSchemaName, (int) cbSchemaName, (const char*) szTableName, (int) cbTableName); #ifdef ENABLE_ODBC_WIDE return _SQLTablePrivileges(hstmt, (ODBC_CHAR*) szCatalogName, cbCatalogName, (ODBC_CHAR*) szSchemaName, cbSchemaName, (ODBC_CHAR*) szTableName, cbTableName, 0); #else return _SQLTablePrivileges(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName); #endif } #ifdef ENABLE_ODBC_WIDE static SQLRETURN _SQLConnect(SQLHDBC hdbc, ODBC_CHAR * szDSN, SQLSMALLINT cbDSN, ODBC_CHAR * szUID, SQLSMALLINT cbUID, ODBC_CHAR * szAuthStr, SQLSMALLINT cbAuthStr, int wide); SQLRETURN ODBC_PUBLIC ODBC_API SQLConnectW( SQLHDBC hdbc, SQLWCHAR * szDSN, SQLSMALLINT cbDSN, SQLWCHAR * szUID, SQLSMALLINT cbUID, SQLWCHAR * szAuthStr, SQLSMALLINT cbAuthStr) { if (TDS_UNLIKELY(tds_write_dump)) { SQLWSTR_BUFS(3); tdsdump_log(TDS_DBG_FUNC, "SQLConnectW(%p, %ls, %d, %ls, %d, %ls, %d)\n", hdbc, SQLWSTR(szDSN), (int) cbDSN, SQLWSTR(szUID), (int) cbUID, SQLWSTR(szAuthStr), (int) cbAuthStr); SQLWSTR_FREE(); } return _SQLConnect(hdbc, (ODBC_CHAR*) szDSN, cbDSN, (ODBC_CHAR*) szUID, cbUID, (ODBC_CHAR*) szAuthStr, cbAuthStr, 1); } #endif SQLRETURN ODBC_PUBLIC ODBC_API SQLConnect( SQLHDBC hdbc, SQLCHAR * szDSN, SQLSMALLINT cbDSN, SQLCHAR * szUID, SQLSMALLINT cbUID, SQLCHAR * szAuthStr, SQLSMALLINT cbAuthStr) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLConnect(%p, %s, %d, %s, %d, %s, %d)\n", hdbc, (const char*) szDSN, (int) cbDSN, (const char*) szUID, (int) cbUID, (const char*) szAuthStr, (int) cbAuthStr); #ifdef ENABLE_ODBC_WIDE return _SQLConnect(hdbc, (ODBC_CHAR*) szDSN, cbDSN, (ODBC_CHAR*) szUID, cbUID, (ODBC_CHAR*) szAuthStr, cbAuthStr, 0); #else return _SQLConnect(hdbc, szDSN, cbDSN, szUID, cbUID, szAuthStr, cbAuthStr); #endif } #ifdef ENABLE_ODBC_WIDE static SQLRETURN _SQLDescribeCol(SQLHSTMT hstmt, SQLUSMALLINT icol, ODBC_CHAR * szColName, SQLSMALLINT cbColNameMax, SQLSMALLINT FAR* pcbColName, SQLSMALLINT * pfSqlType, SQLULEN * pcbColDef, SQLSMALLINT * pibScale, SQLSMALLINT * pfNullable, int wide); SQLRETURN ODBC_PUBLIC ODBC_API SQLDescribeColW( SQLHSTMT hstmt, SQLUSMALLINT icol, SQLWCHAR * szColName, SQLSMALLINT cbColNameMax, SQLSMALLINT FAR* pcbColName, SQLSMALLINT * pfSqlType, SQLULEN * pcbColDef, SQLSMALLINT * pibScale, SQLSMALLINT * pfNullable) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLDescribeColW(%p, %u, %p, %d, %p, %p, %p, %p, %p)\n", hstmt, (unsigned int) icol, szColName, (int) cbColNameMax, pcbColName, pfSqlType, pcbColDef, pibScale, pfNullable); return _SQLDescribeCol(hstmt, icol, (ODBC_CHAR*) szColName, cbColNameMax, pcbColName, pfSqlType, pcbColDef, pibScale, pfNullable, 1); } #endif SQLRETURN ODBC_PUBLIC ODBC_API SQLDescribeCol( SQLHSTMT hstmt, SQLUSMALLINT icol, SQLCHAR * szColName, SQLSMALLINT cbColNameMax, SQLSMALLINT FAR* pcbColName, SQLSMALLINT * pfSqlType, SQLULEN * pcbColDef, SQLSMALLINT * pibScale, SQLSMALLINT * pfNullable) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLDescribeCol(%p, %u, %p, %d, %p, %p, %p, %p, %p)\n", hstmt, (unsigned int) icol, szColName, (int) cbColNameMax, pcbColName, pfSqlType, pcbColDef, pibScale, pfNullable); #ifdef ENABLE_ODBC_WIDE return _SQLDescribeCol(hstmt, icol, (ODBC_CHAR*) szColName, cbColNameMax, pcbColName, pfSqlType, pcbColDef, pibScale, pfNullable, 0); #else return _SQLDescribeCol(hstmt, icol, szColName, cbColNameMax, pcbColName, pfSqlType, pcbColDef, pibScale, pfNullable); #endif } #ifdef ENABLE_ODBC_WIDE static SQLRETURN _SQLGetDescRec(SQLHDESC hdesc, SQLSMALLINT RecordNumber, ODBC_CHAR * szName, SQLSMALLINT cbNameMax, SQLSMALLINT FAR* pcbName, SQLSMALLINT * Type, SQLSMALLINT * SubType, SQLLEN * Length, SQLSMALLINT * Precision, SQLSMALLINT * Scale, SQLSMALLINT * Nullable, int wide); SQLRETURN ODBC_PUBLIC ODBC_API SQLGetDescRecW( SQLHDESC hdesc, SQLSMALLINT RecordNumber, SQLWCHAR * szName, SQLSMALLINT cbNameMax, SQLSMALLINT FAR* pcbName, SQLSMALLINT * Type, SQLSMALLINT * SubType, SQLLEN * Length, SQLSMALLINT * Precision, SQLSMALLINT * Scale, SQLSMALLINT * Nullable) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLGetDescRecW(%p, %d, %p, %d, %p, %p, %p, %p, %p, %p, %p)\n", hdesc, (int) RecordNumber, szName, (int) cbNameMax, pcbName, Type, SubType, Length, Precision, Scale, Nullable); return _SQLGetDescRec(hdesc, RecordNumber, (ODBC_CHAR*) szName, cbNameMax, pcbName, Type, SubType, Length, Precision, Scale, Nullable, 1); } #endif SQLRETURN ODBC_PUBLIC ODBC_API SQLGetDescRec( SQLHDESC hdesc, SQLSMALLINT RecordNumber, SQLCHAR * szName, SQLSMALLINT cbNameMax, SQLSMALLINT FAR* pcbName, SQLSMALLINT * Type, SQLSMALLINT * SubType, SQLLEN * Length, SQLSMALLINT * Precision, SQLSMALLINT * Scale, SQLSMALLINT * Nullable) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLGetDescRec(%p, %d, %p, %d, %p, %p, %p, %p, %p, %p, %p)\n", hdesc, (int) RecordNumber, szName, (int) cbNameMax, pcbName, Type, SubType, Length, Precision, Scale, Nullable); #ifdef ENABLE_ODBC_WIDE return _SQLGetDescRec(hdesc, RecordNumber, (ODBC_CHAR*) szName, cbNameMax, pcbName, Type, SubType, Length, Precision, Scale, Nullable, 0); #else return _SQLGetDescRec(hdesc, RecordNumber, szName, cbNameMax, pcbName, Type, SubType, Length, Precision, Scale, Nullable); #endif } #ifdef ENABLE_ODBC_WIDE static SQLRETURN _SQLGetDescField(SQLHDESC hdesc, SQLSMALLINT icol, SQLSMALLINT fDescType, SQLPOINTER Value, SQLINTEGER BufferLength, SQLINTEGER * StringLength, int wide); SQLRETURN ODBC_PUBLIC ODBC_API SQLGetDescFieldW( SQLHDESC hdesc, SQLSMALLINT icol, SQLSMALLINT fDescType, SQLPOINTER Value, SQLINTEGER BufferLength, SQLINTEGER * StringLength) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLGetDescFieldW(%p, %d, %d, %p, %d, %p)\n", hdesc, (int) icol, (int) fDescType, Value, (int) BufferLength, StringLength); return _SQLGetDescField(hdesc, icol, fDescType, Value, BufferLength, StringLength, 1); } #endif SQLRETURN ODBC_PUBLIC ODBC_API SQLGetDescField( SQLHDESC hdesc, SQLSMALLINT icol, SQLSMALLINT fDescType, SQLPOINTER Value, SQLINTEGER BufferLength, SQLINTEGER * StringLength) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLGetDescField(%p, %d, %d, %p, %d, %p)\n", hdesc, (int) icol, (int) fDescType, Value, (int) BufferLength, StringLength); #ifdef ENABLE_ODBC_WIDE return _SQLGetDescField(hdesc, icol, fDescType, Value, BufferLength, StringLength, 0); #else return _SQLGetDescField(hdesc, icol, fDescType, Value, BufferLength, StringLength); #endif } #ifdef ENABLE_ODBC_WIDE static SQLRETURN _SQLSetDescField(SQLHDESC hdesc, SQLSMALLINT icol, SQLSMALLINT fDescType, SQLPOINTER Value, SQLINTEGER BufferLength, int wide); SQLRETURN ODBC_PUBLIC ODBC_API SQLSetDescFieldW( SQLHDESC hdesc, SQLSMALLINT icol, SQLSMALLINT fDescType, SQLPOINTER Value, SQLINTEGER BufferLength) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLSetDescFieldW(%p, %d, %d, %p, %d)\n", hdesc, (int) icol, (int) fDescType, Value, (int) BufferLength); return _SQLSetDescField(hdesc, icol, fDescType, Value, BufferLength, 1); } #endif SQLRETURN ODBC_PUBLIC ODBC_API SQLSetDescField( SQLHDESC hdesc, SQLSMALLINT icol, SQLSMALLINT fDescType, SQLPOINTER Value, SQLINTEGER BufferLength) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLSetDescField(%p, %d, %d, %p, %d)\n", hdesc, (int) icol, (int) fDescType, Value, (int) BufferLength); #ifdef ENABLE_ODBC_WIDE return _SQLSetDescField(hdesc, icol, fDescType, Value, BufferLength, 0); #else return _SQLSetDescField(hdesc, icol, fDescType, Value, BufferLength); #endif } #ifdef ENABLE_ODBC_WIDE static SQLRETURN _SQLExecDirect(SQLHSTMT hstmt, ODBC_CHAR * szSqlStr, SQLINTEGER cbSqlStr, int wide); SQLRETURN ODBC_PUBLIC ODBC_API SQLExecDirectW( SQLHSTMT hstmt, SQLWCHAR * szSqlStr, SQLINTEGER cbSqlStr) { if (TDS_UNLIKELY(tds_write_dump)) { SQLWSTR_BUFS(1); tdsdump_log(TDS_DBG_FUNC, "SQLExecDirectW(%p, %ls, %d)\n", hstmt, SQLWSTR(szSqlStr), (int) cbSqlStr); SQLWSTR_FREE(); } return _SQLExecDirect(hstmt, (ODBC_CHAR*) szSqlStr, cbSqlStr, 1); } #endif SQLRETURN ODBC_PUBLIC ODBC_API SQLExecDirect( SQLHSTMT hstmt, SQLCHAR * szSqlStr, SQLINTEGER cbSqlStr) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLExecDirect(%p, %s, %d)\n", hstmt, (const char*) szSqlStr, (int) cbSqlStr); #ifdef ENABLE_ODBC_WIDE return _SQLExecDirect(hstmt, (ODBC_CHAR*) szSqlStr, cbSqlStr, 0); #else return _SQLExecDirect(hstmt, szSqlStr, cbSqlStr); #endif } #ifdef ENABLE_ODBC_WIDE static SQLRETURN _SQLPrepare(SQLHSTMT hstmt, ODBC_CHAR * szSqlStr, SQLINTEGER cbSqlStr, int wide); SQLRETURN ODBC_PUBLIC ODBC_API SQLPrepareW( SQLHSTMT hstmt, SQLWCHAR * szSqlStr, SQLINTEGER cbSqlStr) { if (TDS_UNLIKELY(tds_write_dump)) { SQLWSTR_BUFS(1); tdsdump_log(TDS_DBG_FUNC, "SQLPrepareW(%p, %ls, %d)\n", hstmt, SQLWSTR(szSqlStr), (int) cbSqlStr); SQLWSTR_FREE(); } return _SQLPrepare(hstmt, (ODBC_CHAR*) szSqlStr, cbSqlStr, 1); } #endif SQLRETURN ODBC_PUBLIC ODBC_API SQLPrepare( SQLHSTMT hstmt, SQLCHAR * szSqlStr, SQLINTEGER cbSqlStr) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLPrepare(%p, %s, %d)\n", hstmt, (const char*) szSqlStr, (int) cbSqlStr); #ifdef ENABLE_ODBC_WIDE return _SQLPrepare(hstmt, (ODBC_CHAR*) szSqlStr, cbSqlStr, 0); #else return _SQLPrepare(hstmt, szSqlStr, cbSqlStr); #endif } #ifdef ENABLE_ODBC_WIDE static SQLRETURN _SQLSetCursorName(SQLHSTMT hstmt, ODBC_CHAR * szCursor, SQLSMALLINT cbCursor, int wide); SQLRETURN ODBC_PUBLIC ODBC_API SQLSetCursorNameW( SQLHSTMT hstmt, SQLWCHAR * szCursor, SQLSMALLINT cbCursor) { if (TDS_UNLIKELY(tds_write_dump)) { SQLWSTR_BUFS(1); tdsdump_log(TDS_DBG_FUNC, "SQLSetCursorNameW(%p, %ls, %d)\n", hstmt, SQLWSTR(szCursor), (int) cbCursor); SQLWSTR_FREE(); } return _SQLSetCursorName(hstmt, (ODBC_CHAR*) szCursor, cbCursor, 1); } #endif SQLRETURN ODBC_PUBLIC ODBC_API SQLSetCursorName( SQLHSTMT hstmt, SQLCHAR * szCursor, SQLSMALLINT cbCursor) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLSetCursorName(%p, %s, %d)\n", hstmt, (const char*) szCursor, (int) cbCursor); #ifdef ENABLE_ODBC_WIDE return _SQLSetCursorName(hstmt, (ODBC_CHAR*) szCursor, cbCursor, 0); #else return _SQLSetCursorName(hstmt, szCursor, cbCursor); #endif } #ifdef ENABLE_ODBC_WIDE static SQLRETURN _SQLGetCursorName(SQLHSTMT hstmt, ODBC_CHAR * szCursor, SQLSMALLINT cbCursorMax, SQLSMALLINT FAR* pcbCursor, int wide); SQLRETURN ODBC_PUBLIC ODBC_API SQLGetCursorNameW( SQLHSTMT hstmt, SQLWCHAR * szCursor, SQLSMALLINT cbCursorMax, SQLSMALLINT FAR* pcbCursor) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLGetCursorNameW(%p, %p, %d, %p)\n", hstmt, szCursor, (int) cbCursorMax, pcbCursor); return _SQLGetCursorName(hstmt, (ODBC_CHAR*) szCursor, cbCursorMax, pcbCursor, 1); } #endif SQLRETURN ODBC_PUBLIC ODBC_API SQLGetCursorName( SQLHSTMT hstmt, SQLCHAR * szCursor, SQLSMALLINT cbCursorMax, SQLSMALLINT FAR* pcbCursor) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLGetCursorName(%p, %p, %d, %p)\n", hstmt, szCursor, (int) cbCursorMax, pcbCursor); #ifdef ENABLE_ODBC_WIDE return _SQLGetCursorName(hstmt, (ODBC_CHAR*) szCursor, cbCursorMax, pcbCursor, 0); #else return _SQLGetCursorName(hstmt, szCursor, cbCursorMax, pcbCursor); #endif } #ifdef ENABLE_ODBC_WIDE static SQLRETURN _SQLColumns(SQLHSTMT hstmt, ODBC_CHAR * szCatalogName, SQLSMALLINT cbCatalogName, ODBC_CHAR * szSchemaName, SQLSMALLINT cbSchemaName, ODBC_CHAR * szTableName, SQLSMALLINT cbTableName, ODBC_CHAR * szColumnName, SQLSMALLINT cbColumnName, int wide); SQLRETURN ODBC_PUBLIC ODBC_API SQLColumnsW( SQLHSTMT hstmt, SQLWCHAR * szCatalogName, SQLSMALLINT cbCatalogName, SQLWCHAR * szSchemaName, SQLSMALLINT cbSchemaName, SQLWCHAR * szTableName, SQLSMALLINT cbTableName, SQLWCHAR * szColumnName, SQLSMALLINT cbColumnName) { if (TDS_UNLIKELY(tds_write_dump)) { SQLWSTR_BUFS(4); tdsdump_log(TDS_DBG_FUNC, "SQLColumnsW(%p, %ls, %d, %ls, %d, %ls, %d, %ls, %d)\n", hstmt, SQLWSTR(szCatalogName), (int) cbCatalogName, SQLWSTR(szSchemaName), (int) cbSchemaName, SQLWSTR(szTableName), (int) cbTableName, SQLWSTR(szColumnName), (int) cbColumnName); SQLWSTR_FREE(); } return _SQLColumns(hstmt, (ODBC_CHAR*) szCatalogName, cbCatalogName, (ODBC_CHAR*) szSchemaName, cbSchemaName, (ODBC_CHAR*) szTableName, cbTableName, (ODBC_CHAR*) szColumnName, cbColumnName, 1); } #endif SQLRETURN ODBC_PUBLIC ODBC_API SQLColumns( SQLHSTMT hstmt, SQLCHAR * szCatalogName, SQLSMALLINT cbCatalogName, SQLCHAR * szSchemaName, SQLSMALLINT cbSchemaName, SQLCHAR * szTableName, SQLSMALLINT cbTableName, SQLCHAR * szColumnName, SQLSMALLINT cbColumnName) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLColumns(%p, %s, %d, %s, %d, %s, %d, %s, %d)\n", hstmt, (const char*) szCatalogName, (int) cbCatalogName, (const char*) szSchemaName, (int) cbSchemaName, (const char*) szTableName, (int) cbTableName, (const char*) szColumnName, (int) cbColumnName); #ifdef ENABLE_ODBC_WIDE return _SQLColumns(hstmt, (ODBC_CHAR*) szCatalogName, cbCatalogName, (ODBC_CHAR*) szSchemaName, cbSchemaName, (ODBC_CHAR*) szTableName, cbTableName, (ODBC_CHAR*) szColumnName, cbColumnName, 0); #else return _SQLColumns(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName, szColumnName, cbColumnName); #endif } #ifdef ENABLE_ODBC_WIDE static SQLRETURN _SQLGetConnectAttr(SQLHDBC hdbc, SQLINTEGER Attribute, SQLPOINTER Value, SQLINTEGER BufferLength, SQLINTEGER * StringLength, int wide); SQLRETURN ODBC_PUBLIC ODBC_API SQLGetConnectAttrW( SQLHDBC hdbc, SQLINTEGER Attribute, SQLPOINTER Value, SQLINTEGER BufferLength, SQLINTEGER * StringLength) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLGetConnectAttrW(%p, %d, %p, %d, %p)\n", hdbc, (int) Attribute, Value, (int) BufferLength, StringLength); return _SQLGetConnectAttr(hdbc, Attribute, Value, BufferLength, StringLength, 1); } #endif SQLRETURN ODBC_PUBLIC ODBC_API SQLGetConnectAttr( SQLHDBC hdbc, SQLINTEGER Attribute, SQLPOINTER Value, SQLINTEGER BufferLength, SQLINTEGER * StringLength) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLGetConnectAttr(%p, %d, %p, %d, %p)\n", hdbc, (int) Attribute, Value, (int) BufferLength, StringLength); #ifdef ENABLE_ODBC_WIDE return _SQLGetConnectAttr(hdbc, Attribute, Value, BufferLength, StringLength, 0); #else return _SQLGetConnectAttr(hdbc, Attribute, Value, BufferLength, StringLength); #endif } #ifdef ENABLE_ODBC_WIDE static SQLRETURN _SQLSetConnectAttr(SQLHDBC hdbc, SQLINTEGER Attribute, SQLPOINTER ValuePtr, SQLINTEGER StringLength, int wide); SQLRETURN ODBC_PUBLIC ODBC_API SQLSetConnectAttrW( SQLHDBC hdbc, SQLINTEGER Attribute, SQLPOINTER ValuePtr, SQLINTEGER StringLength) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLSetConnectAttrW(%p, %d, %p, %d)\n", hdbc, (int) Attribute, ValuePtr, (int) StringLength); return _SQLSetConnectAttr(hdbc, Attribute, ValuePtr, StringLength, 1); } #endif SQLRETURN ODBC_PUBLIC ODBC_API SQLSetConnectAttr( SQLHDBC hdbc, SQLINTEGER Attribute, SQLPOINTER ValuePtr, SQLINTEGER StringLength) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLSetConnectAttr(%p, %d, %p, %d)\n", hdbc, (int) Attribute, ValuePtr, (int) StringLength); #ifdef ENABLE_ODBC_WIDE return _SQLSetConnectAttr(hdbc, Attribute, ValuePtr, StringLength, 0); #else return _SQLSetConnectAttr(hdbc, Attribute, ValuePtr, StringLength); #endif } #ifdef ENABLE_ODBC_WIDE static SQLRETURN _SQLSpecialColumns(SQLHSTMT hstmt, SQLUSMALLINT fColType, ODBC_CHAR * szCatalogName, SQLSMALLINT cbCatalogName, ODBC_CHAR * szSchemaName, SQLSMALLINT cbSchemaName, ODBC_CHAR * szTableName, SQLSMALLINT cbTableName, SQLUSMALLINT fScope, SQLUSMALLINT fNullable, int wide); SQLRETURN ODBC_PUBLIC ODBC_API SQLSpecialColumnsW( SQLHSTMT hstmt, SQLUSMALLINT fColType, SQLWCHAR * szCatalogName, SQLSMALLINT cbCatalogName, SQLWCHAR * szSchemaName, SQLSMALLINT cbSchemaName, SQLWCHAR * szTableName, SQLSMALLINT cbTableName, SQLUSMALLINT fScope, SQLUSMALLINT fNullable) { if (TDS_UNLIKELY(tds_write_dump)) { SQLWSTR_BUFS(3); tdsdump_log(TDS_DBG_FUNC, "SQLSpecialColumnsW(%p, %u, %ls, %d, %ls, %d, %ls, %d, %u, %u)\n", hstmt, (unsigned int) fColType, SQLWSTR(szCatalogName), (int) cbCatalogName, SQLWSTR(szSchemaName), (int) cbSchemaName, SQLWSTR(szTableName), (int) cbTableName, (unsigned int) fScope, (unsigned int) fNullable); SQLWSTR_FREE(); } return _SQLSpecialColumns(hstmt, fColType, (ODBC_CHAR*) szCatalogName, cbCatalogName, (ODBC_CHAR*) szSchemaName, cbSchemaName, (ODBC_CHAR*) szTableName, cbTableName, fScope, fNullable, 1); } #endif SQLRETURN ODBC_PUBLIC ODBC_API SQLSpecialColumns( SQLHSTMT hstmt, SQLUSMALLINT fColType, SQLCHAR * szCatalogName, SQLSMALLINT cbCatalogName, SQLCHAR * szSchemaName, SQLSMALLINT cbSchemaName, SQLCHAR * szTableName, SQLSMALLINT cbTableName, SQLUSMALLINT fScope, SQLUSMALLINT fNullable) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLSpecialColumns(%p, %u, %s, %d, %s, %d, %s, %d, %u, %u)\n", hstmt, (unsigned int) fColType, (const char*) szCatalogName, (int) cbCatalogName, (const char*) szSchemaName, (int) cbSchemaName, (const char*) szTableName, (int) cbTableName, (unsigned int) fScope, (unsigned int) fNullable); #ifdef ENABLE_ODBC_WIDE return _SQLSpecialColumns(hstmt, fColType, (ODBC_CHAR*) szCatalogName, cbCatalogName, (ODBC_CHAR*) szSchemaName, cbSchemaName, (ODBC_CHAR*) szTableName, cbTableName, fScope, fNullable, 0); #else return _SQLSpecialColumns(hstmt, fColType, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName, fScope, fNullable); #endif } #ifdef ENABLE_ODBC_WIDE static SQLRETURN _SQLStatistics(SQLHSTMT hstmt, ODBC_CHAR * szCatalogName, SQLSMALLINT cbCatalogName, ODBC_CHAR * szSchemaName, SQLSMALLINT cbSchemaName, ODBC_CHAR * szTableName, SQLSMALLINT cbTableName, SQLUSMALLINT fUnique, SQLUSMALLINT fAccuracy, int wide); SQLRETURN ODBC_PUBLIC ODBC_API SQLStatisticsW( SQLHSTMT hstmt, SQLWCHAR * szCatalogName, SQLSMALLINT cbCatalogName, SQLWCHAR * szSchemaName, SQLSMALLINT cbSchemaName, SQLWCHAR * szTableName, SQLSMALLINT cbTableName, SQLUSMALLINT fUnique, SQLUSMALLINT fAccuracy) { if (TDS_UNLIKELY(tds_write_dump)) { SQLWSTR_BUFS(3); tdsdump_log(TDS_DBG_FUNC, "SQLStatisticsW(%p, %ls, %d, %ls, %d, %ls, %d, %u, %u)\n", hstmt, SQLWSTR(szCatalogName), (int) cbCatalogName, SQLWSTR(szSchemaName), (int) cbSchemaName, SQLWSTR(szTableName), (int) cbTableName, (unsigned int) fUnique, (unsigned int) fAccuracy); SQLWSTR_FREE(); } return _SQLStatistics(hstmt, (ODBC_CHAR*) szCatalogName, cbCatalogName, (ODBC_CHAR*) szSchemaName, cbSchemaName, (ODBC_CHAR*) szTableName, cbTableName, fUnique, fAccuracy, 1); } #endif SQLRETURN ODBC_PUBLIC ODBC_API SQLStatistics( SQLHSTMT hstmt, SQLCHAR * szCatalogName, SQLSMALLINT cbCatalogName, SQLCHAR * szSchemaName, SQLSMALLINT cbSchemaName, SQLCHAR * szTableName, SQLSMALLINT cbTableName, SQLUSMALLINT fUnique, SQLUSMALLINT fAccuracy) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLStatistics(%p, %s, %d, %s, %d, %s, %d, %u, %u)\n", hstmt, (const char*) szCatalogName, (int) cbCatalogName, (const char*) szSchemaName, (int) cbSchemaName, (const char*) szTableName, (int) cbTableName, (unsigned int) fUnique, (unsigned int) fAccuracy); #ifdef ENABLE_ODBC_WIDE return _SQLStatistics(hstmt, (ODBC_CHAR*) szCatalogName, cbCatalogName, (ODBC_CHAR*) szSchemaName, cbSchemaName, (ODBC_CHAR*) szTableName, cbTableName, fUnique, fAccuracy, 0); #else return _SQLStatistics(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName, fUnique, fAccuracy); #endif } #ifdef ENABLE_ODBC_WIDE static SQLRETURN _SQLTables(SQLHSTMT hstmt, ODBC_CHAR * szCatalogName, SQLSMALLINT cbCatalogName, ODBC_CHAR * szSchemaName, SQLSMALLINT cbSchemaName, ODBC_CHAR * szTableName, SQLSMALLINT cbTableName, ODBC_CHAR * szTableType, SQLSMALLINT cbTableType, int wide); SQLRETURN ODBC_PUBLIC ODBC_API SQLTablesW( SQLHSTMT hstmt, SQLWCHAR * szCatalogName, SQLSMALLINT cbCatalogName, SQLWCHAR * szSchemaName, SQLSMALLINT cbSchemaName, SQLWCHAR * szTableName, SQLSMALLINT cbTableName, SQLWCHAR * szTableType, SQLSMALLINT cbTableType) { if (TDS_UNLIKELY(tds_write_dump)) { SQLWSTR_BUFS(4); tdsdump_log(TDS_DBG_FUNC, "SQLTablesW(%p, %ls, %d, %ls, %d, %ls, %d, %ls, %d)\n", hstmt, SQLWSTR(szCatalogName), (int) cbCatalogName, SQLWSTR(szSchemaName), (int) cbSchemaName, SQLWSTR(szTableName), (int) cbTableName, SQLWSTR(szTableType), (int) cbTableType); SQLWSTR_FREE(); } return _SQLTables(hstmt, (ODBC_CHAR*) szCatalogName, cbCatalogName, (ODBC_CHAR*) szSchemaName, cbSchemaName, (ODBC_CHAR*) szTableName, cbTableName, (ODBC_CHAR*) szTableType, cbTableType, 1); } #endif SQLRETURN ODBC_PUBLIC ODBC_API SQLTables( SQLHSTMT hstmt, SQLCHAR * szCatalogName, SQLSMALLINT cbCatalogName, SQLCHAR * szSchemaName, SQLSMALLINT cbSchemaName, SQLCHAR * szTableName, SQLSMALLINT cbTableName, SQLCHAR * szTableType, SQLSMALLINT cbTableType) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLTables(%p, %s, %d, %s, %d, %s, %d, %s, %d)\n", hstmt, (const char*) szCatalogName, (int) cbCatalogName, (const char*) szSchemaName, (int) cbSchemaName, (const char*) szTableName, (int) cbTableName, (const char*) szTableType, (int) cbTableType); #ifdef ENABLE_ODBC_WIDE return _SQLTables(hstmt, (ODBC_CHAR*) szCatalogName, cbCatalogName, (ODBC_CHAR*) szSchemaName, cbSchemaName, (ODBC_CHAR*) szTableName, cbTableName, (ODBC_CHAR*) szTableType, cbTableType, 0); #else return _SQLTables(hstmt, szCatalogName, cbCatalogName, szSchemaName, cbSchemaName, szTableName, cbTableName, szTableType, cbTableType); #endif } #define tdsdump_log TDSDUMP_LOG_FAST freetds-1.00.82/src/odbc/error_export.h100644 025423 025423 00000011457 13242511130 0013427#undef tdsdump_log #ifdef ENABLE_ODBC_WIDE static SQLRETURN _SQLGetDiagRec(SQLSMALLINT handleType, SQLHANDLE handle, SQLSMALLINT numRecord, ODBC_CHAR * szSqlStat, SQLINTEGER * pfNativeError, ODBC_CHAR * szErrorMsg, SQLSMALLINT cbErrorMsgMax, SQLSMALLINT FAR* pcbErrorMsg, int wide); SQLRETURN ODBC_PUBLIC ODBC_API SQLGetDiagRecW( SQLSMALLINT handleType, SQLHANDLE handle, SQLSMALLINT numRecord, SQLWCHAR * szSqlStat, SQLINTEGER * pfNativeError, SQLWCHAR * szErrorMsg, SQLSMALLINT cbErrorMsgMax, SQLSMALLINT FAR* pcbErrorMsg) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLGetDiagRecW(%d, %p, %d, %p, %p, %p, %d, %p)\n", (int) handleType, handle, (int) numRecord, szSqlStat, pfNativeError, szErrorMsg, (int) cbErrorMsgMax, pcbErrorMsg); return _SQLGetDiagRec(handleType, handle, numRecord, (ODBC_CHAR*) szSqlStat, pfNativeError, (ODBC_CHAR*) szErrorMsg, cbErrorMsgMax, pcbErrorMsg, 1); } #endif SQLRETURN ODBC_PUBLIC ODBC_API SQLGetDiagRec( SQLSMALLINT handleType, SQLHANDLE handle, SQLSMALLINT numRecord, SQLCHAR * szSqlStat, SQLINTEGER * pfNativeError, SQLCHAR * szErrorMsg, SQLSMALLINT cbErrorMsgMax, SQLSMALLINT FAR* pcbErrorMsg) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLGetDiagRec(%d, %p, %d, %p, %p, %p, %d, %p)\n", (int) handleType, handle, (int) numRecord, szSqlStat, pfNativeError, szErrorMsg, (int) cbErrorMsgMax, pcbErrorMsg); #ifdef ENABLE_ODBC_WIDE return _SQLGetDiagRec(handleType, handle, numRecord, (ODBC_CHAR*) szSqlStat, pfNativeError, (ODBC_CHAR*) szErrorMsg, cbErrorMsgMax, pcbErrorMsg, 0); #else return _SQLGetDiagRec(handleType, handle, numRecord, szSqlStat, pfNativeError, szErrorMsg, cbErrorMsgMax, pcbErrorMsg); #endif } #ifdef ENABLE_ODBC_WIDE static SQLRETURN _SQLError(SQLHENV henv, SQLHDBC hdbc, SQLHSTMT hstmt, ODBC_CHAR * szSqlStat, SQLINTEGER * pfNativeError, ODBC_CHAR * szErrorMsg, SQLSMALLINT cbErrorMsgMax, SQLSMALLINT FAR* pcbErrorMsg, int wide); SQLRETURN ODBC_PUBLIC ODBC_API SQLErrorW( SQLHENV henv, SQLHDBC hdbc, SQLHSTMT hstmt, SQLWCHAR * szSqlStat, SQLINTEGER * pfNativeError, SQLWCHAR * szErrorMsg, SQLSMALLINT cbErrorMsgMax, SQLSMALLINT FAR* pcbErrorMsg) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLErrorW(%p, %p, %p, %p, %p, %p, %d, %p)\n", henv, hdbc, hstmt, szSqlStat, pfNativeError, szErrorMsg, (int) cbErrorMsgMax, pcbErrorMsg); return _SQLError(henv, hdbc, hstmt, (ODBC_CHAR*) szSqlStat, pfNativeError, (ODBC_CHAR*) szErrorMsg, cbErrorMsgMax, pcbErrorMsg, 1); } #endif SQLRETURN ODBC_PUBLIC ODBC_API SQLError( SQLHENV henv, SQLHDBC hdbc, SQLHSTMT hstmt, SQLCHAR * szSqlStat, SQLINTEGER * pfNativeError, SQLCHAR * szErrorMsg, SQLSMALLINT cbErrorMsgMax, SQLSMALLINT FAR* pcbErrorMsg) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLError(%p, %p, %p, %p, %p, %p, %d, %p)\n", henv, hdbc, hstmt, szSqlStat, pfNativeError, szErrorMsg, (int) cbErrorMsgMax, pcbErrorMsg); #ifdef ENABLE_ODBC_WIDE return _SQLError(henv, hdbc, hstmt, (ODBC_CHAR*) szSqlStat, pfNativeError, (ODBC_CHAR*) szErrorMsg, cbErrorMsgMax, pcbErrorMsg, 0); #else return _SQLError(henv, hdbc, hstmt, szSqlStat, pfNativeError, szErrorMsg, cbErrorMsgMax, pcbErrorMsg); #endif } #ifdef ENABLE_ODBC_WIDE static SQLRETURN _SQLGetDiagField(SQLSMALLINT handleType, SQLHANDLE handle, SQLSMALLINT numRecord, SQLSMALLINT diagIdentifier, SQLPOINTER buffer, SQLSMALLINT cbBuffer, SQLSMALLINT * pcbBuffer, int wide); SQLRETURN ODBC_PUBLIC ODBC_API SQLGetDiagFieldW( SQLSMALLINT handleType, SQLHANDLE handle, SQLSMALLINT numRecord, SQLSMALLINT diagIdentifier, SQLPOINTER buffer, SQLSMALLINT cbBuffer, SQLSMALLINT * pcbBuffer) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLGetDiagFieldW(%d, %p, %d, %d, %p, %d, %p)\n", (int) handleType, handle, (int) numRecord, (int) diagIdentifier, buffer, (int) cbBuffer, pcbBuffer); return _SQLGetDiagField(handleType, handle, numRecord, diagIdentifier, buffer, cbBuffer, pcbBuffer, 1); } #endif SQLRETURN ODBC_PUBLIC ODBC_API SQLGetDiagField( SQLSMALLINT handleType, SQLHANDLE handle, SQLSMALLINT numRecord, SQLSMALLINT diagIdentifier, SQLPOINTER buffer, SQLSMALLINT cbBuffer, SQLSMALLINT * pcbBuffer) { TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLGetDiagField(%d, %p, %d, %d, %p, %d, %p)\n", (int) handleType, handle, (int) numRecord, (int) diagIdentifier, buffer, (int) cbBuffer, pcbBuffer); #ifdef ENABLE_ODBC_WIDE return _SQLGetDiagField(handleType, handle, numRecord, diagIdentifier, buffer, cbBuffer, pcbBuffer, 0); #else return _SQLGetDiagField(handleType, handle, numRecord, diagIdentifier, buffer, cbBuffer, pcbBuffer); #endif } #define tdsdump_log TDSDUMP_LOG_FAST freetds-1.00.82/src/odbc/odbc_data.c100644 025423 025423 00000032157 13101323621 0012570/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2014 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include #include #define SET_INFO(type, prefix, suffix) do { \ drec->sql_desc_literal_prefix = prefix; \ drec->sql_desc_literal_suffix = suffix; \ drec->sql_desc_type_name = type; \ return; \ } while(0) #define SET_INFO2(type, prefix, suffix, len) do { \ drec->sql_desc_length = (len); \ SET_INFO(type, prefix, suffix); \ } while(0) static void data_msdatetime_set_type_info(TDSCOLUMN * col, struct _drecord *drec, SQLINTEGER odbc_ver) { int decimals = col->column_prec ? col->column_prec + 1: 0; switch (col->on_server.column_type) { case SYBMSTIME: drec->sql_desc_octet_length = sizeof(SQL_SS_TIME2_STRUCT); drec->sql_desc_concise_type = SQL_SS_TIME2; /* always hh:mm:ss[.fff] */ drec->sql_desc_display_size = 8 + decimals; SET_INFO2("time", "'", "'", 8 + decimals); case SYBMSDATE: drec->sql_desc_octet_length = sizeof(DATE_STRUCT); drec->sql_desc_concise_type = SQL_TYPE_DATE; /* always yyyy-mm-dd ?? */ drec->sql_desc_display_size = 10; SET_INFO2("date", "'", "'", 10); case SYBMSDATETIMEOFFSET: drec->sql_desc_octet_length = sizeof(SQL_SS_TIMESTAMPOFFSET_STRUCT); drec->sql_desc_concise_type = SQL_SS_TIMESTAMPOFFSET; /* we always format using yyyy-mm-dd hh:mm:ss[.fff] +HH:MM, see convert_tds2sql.c */ drec->sql_desc_display_size = 26 + decimals; SET_INFO2("datetimeoffset", "'", "'", 26 + decimals); case SYBMSDATETIME2: drec->sql_desc_octet_length = sizeof(TIMESTAMP_STRUCT); drec->sql_desc_concise_type = SQL_TYPE_TIMESTAMP; drec->sql_desc_datetime_interval_code = SQL_CODE_TIMESTAMP; /* we always format using yyyy-mm-dd hh:mm:ss[.fff], see convert_tds2sql.c */ drec->sql_desc_display_size = 19 + decimals; SET_INFO2("datetime2", "'", "'", 19 + decimals); default: break; } } static void data_variant_set_type_info(TDSCOLUMN * col, struct _drecord *drec, SQLINTEGER odbc_ver) { drec->sql_desc_concise_type = SQL_SS_VARIANT; drec->sql_desc_display_size = 8000; drec->sql_desc_octet_length = 0; SET_INFO2("sql_variant", "", "", 8000); } static void data_numeric_set_type_info(TDSCOLUMN * col, struct _drecord *drec, SQLINTEGER odbc_ver) { const char *type_name = col->on_server.column_type == SYBNUMERIC ? "numeric" : "decimal"; drec->sql_desc_concise_type = SQL_NUMERIC; drec->sql_desc_octet_length = col->column_prec + 2; drec->sql_desc_display_size = col->column_prec + 2; drec->sql_desc_num_prec_radix = 10; SET_INFO2(type_name, "", "", col->column_prec); } static void data_clrudt_set_type_info(TDSCOLUMN * col, struct _drecord *drec, SQLINTEGER odbc_ver) { drec->sql_desc_concise_type = SQL_LONGVARBINARY; /* TODO ??? */ drec->sql_desc_display_size = col->column_size * 2; } static void data_sybbigtime_set_type_info(TDSCOLUMN * col, struct _drecord *drec, SQLINTEGER odbc_ver) { if (col->on_server.column_type == SYB5BIGTIME) { drec->sql_desc_concise_type = SQL_SS_TIME2; /* we always format using hh:mm:ss[.ffffff], see convert_tds2sql.c */ drec->sql_desc_display_size = 15; drec->sql_desc_octet_length = sizeof(SQL_SS_TIME2_STRUCT); drec->sql_desc_precision = 6; drec->sql_desc_scale = 6; drec->sql_desc_datetime_interval_code = SQL_CODE_TIMESTAMP; SET_INFO2("bigtime", "'", "'", 15); } assert(col->on_server.column_type == SYB5BIGDATETIME); drec->sql_desc_concise_type = SQL_TYPE_TIMESTAMP; drec->sql_desc_display_size = 26; drec->sql_desc_octet_length = sizeof(TIMESTAMP_STRUCT); drec->sql_desc_precision = 6; drec->sql_desc_scale = 6; drec->sql_desc_datetime_interval_code = SQL_CODE_TIMESTAMP; SET_INFO2("bigdatetime", "'", "'", 26); } static void data_generic_set_type_info(TDSCOLUMN * col, struct _drecord *drec, SQLINTEGER odbc_ver) { TDS_SERVER_TYPE col_type = col->on_server.column_type; int col_size = col->on_server.column_size; switch (tds_get_conversion_type(col_type, col_size)) { case XSYBNCHAR: drec->sql_desc_concise_type = SQL_WCHAR; drec->sql_desc_display_size = col->on_server.column_size / 2; SET_INFO2("nchar", "'", "'", col->on_server.column_size / 2); case XSYBCHAR: case SYBCHAR: drec->sql_desc_concise_type = SQL_CHAR; drec->sql_desc_display_size = col->on_server.column_size; SET_INFO("char", "'", "'"); /* TODO really sure ?? SYBNVARCHAR sybase only ?? */ case SYBNVARCHAR: case XSYBNVARCHAR: drec->sql_desc_concise_type = SQL_WVARCHAR; drec->sql_desc_display_size = col->on_server.column_size / 2; drec->sql_desc_length = col->on_server.column_size / 2u; if (is_blob_col(col)) { drec->sql_desc_display_size = SQL_SS_LENGTH_UNLIMITED; drec->sql_desc_octet_length = drec->sql_desc_length = SQL_SS_LENGTH_UNLIMITED; } SET_INFO("nvarchar", "'", "'"); case XSYBVARCHAR: case SYBVARCHAR: drec->sql_desc_concise_type = SQL_VARCHAR; drec->sql_desc_display_size = col->on_server.column_size; if (is_blob_col(col)) { drec->sql_desc_display_size = SQL_SS_LENGTH_UNLIMITED; drec->sql_desc_octet_length = drec->sql_desc_length = SQL_SS_LENGTH_UNLIMITED; } SET_INFO("varchar", "'", "'"); case SYBNTEXT: drec->sql_desc_concise_type = SQL_WLONGVARCHAR; drec->sql_desc_display_size = col->on_server.column_size / 2; SET_INFO2("ntext", "'", "'", col->on_server.column_size / 2); case SYBTEXT: drec->sql_desc_concise_type = SQL_LONGVARCHAR; drec->sql_desc_display_size = col->on_server.column_size; SET_INFO("text", "'", "'"); case SYBBIT: case SYBBITN: drec->sql_desc_concise_type = SQL_BIT; drec->sql_desc_display_size = 1; drec->sql_desc_unsigned = SQL_TRUE; SET_INFO2("bit", "", "", 1); #if (ODBCVER >= 0x0300) case SYB5INT8: case SYBINT8: /* TODO return numeric for odbc2 and convert bigint to numeric */ drec->sql_desc_concise_type = SQL_BIGINT; drec->sql_desc_display_size = 20; SET_INFO2("bigint", "", "", 19); #endif case SYBINT4: drec->sql_desc_concise_type = SQL_INTEGER; drec->sql_desc_display_size = 11; /* -1000000000 */ SET_INFO2("int", "", "", 10); case SYBINT2: drec->sql_desc_concise_type = SQL_SMALLINT; drec->sql_desc_display_size = 6; /* -10000 */ SET_INFO2("smallint", "", "", 5); case SYBUINT1: case SYBINT1: drec->sql_desc_unsigned = SQL_TRUE; case SYBSINT1: /* TODO not another type_name ?? */ drec->sql_desc_concise_type = SQL_TINYINT; drec->sql_desc_display_size = 3; /* 255 */ SET_INFO2("tinyint", "", "", 3); #if (ODBCVER >= 0x0300) case SYBUINT8: drec->sql_desc_unsigned = SQL_TRUE; drec->sql_desc_concise_type = SQL_BIGINT; drec->sql_desc_display_size = 20; /* TODO return numeric for odbc2 and convert bigint to numeric */ SET_INFO2("unsigned bigint", "", "", 20); #endif case SYBUINT4: drec->sql_desc_unsigned = SQL_TRUE; drec->sql_desc_concise_type = SQL_INTEGER; drec->sql_desc_display_size = 10; SET_INFO2("unsigned int", "", "", 10); case SYBUINT2: drec->sql_desc_unsigned = SQL_TRUE; drec->sql_desc_concise_type = SQL_SMALLINT; drec->sql_desc_display_size = 5; /* 65535 */ SET_INFO2("unsigned smallint", "", "", 5); case SYBREAL: drec->sql_desc_concise_type = SQL_REAL; drec->sql_desc_display_size = 14; SET_INFO2("real", "", "", odbc_ver == SQL_OV_ODBC3 ? 24 : 7); case SYBFLT8: drec->sql_desc_concise_type = SQL_DOUBLE; drec->sql_desc_display_size = 24; /* FIXME -- what should the correct size be? */ SET_INFO2("float", "", "", odbc_ver == SQL_OV_ODBC3 ? 53 : 15); case SYBMONEY: /* TODO check money format returned by propretary ODBC, scale == 4 but we use 2 digits */ drec->sql_desc_concise_type = SQL_DECIMAL; drec->sql_desc_octet_length = 21; drec->sql_desc_display_size = 21; drec->sql_desc_precision = 19; drec->sql_desc_scale = 4; SET_INFO2("money", "$", "", 19); case SYBMONEY4: drec->sql_desc_concise_type = SQL_DECIMAL; drec->sql_desc_octet_length = 12; drec->sql_desc_display_size = 12; drec->sql_desc_precision = 10; drec->sql_desc_scale = 4; SET_INFO2("money", "$", "", 10); case SYBDATETIME: drec->sql_desc_concise_type = SQL_TYPE_TIMESTAMP; drec->sql_desc_display_size = 23; drec->sql_desc_octet_length = sizeof(TIMESTAMP_STRUCT); drec->sql_desc_precision = 3; drec->sql_desc_scale = 3; drec->sql_desc_datetime_interval_code = SQL_CODE_TIMESTAMP; SET_INFO2("datetime", "'", "'", 23); case SYBDATETIME4: drec->sql_desc_concise_type = SQL_TYPE_TIMESTAMP; /* TODO dependent on precision (decimal second digits) */ /* we always format using yyyy-mm-dd hh:mm:ss[.fff], see convert_tds2sql.c */ drec->sql_desc_display_size = 19; drec->sql_desc_octet_length = sizeof(TIMESTAMP_STRUCT); drec->sql_desc_datetime_interval_code = SQL_CODE_TIMESTAMP; SET_INFO2("datetime", "'", "'", 16); /* The following two types are just Sybase types but as mainly our ODBC * driver is much more compatible with Windows use attributes similar * to MS one. For instance Sybase ODBC returns TIME into a TIME_STRUCT * however this truncate the precision to 0 as TIME does not have * fraction of seconds. Also Sybase ODBC have different concepts for * PRECISION for many types and making these 2 types compatibles with * Sybase would break this driver compatibility. */ case SYBTIME: drec->sql_desc_concise_type = SQL_SS_TIME2; drec->sql_desc_octet_length = sizeof(SQL_SS_TIME2_STRUCT); /* we always format using hh:mm:ss[.fff], see convert_tds2sql.c */ drec->sql_desc_display_size = 12; drec->sql_desc_precision = 3; drec->sql_desc_scale = 3; SET_INFO2("time", "'", "'", 12); case SYBDATE: drec->sql_desc_octet_length = sizeof(DATE_STRUCT); drec->sql_desc_concise_type = SQL_TYPE_DATE; /* we always format using yyyy-mm-dd, see convert_tds2sql.c */ drec->sql_desc_display_size = 10; SET_INFO2("date", "'", "'", 10); case XSYBBINARY: case SYBBINARY: drec->sql_desc_concise_type = SQL_BINARY; drec->sql_desc_display_size = col->column_size * 2; /* handle TIMESTAMP using usertype */ if (col->column_usertype == 80) SET_INFO("timestamp", "0x", ""); SET_INFO("binary", "0x", ""); case SYBLONGBINARY: case SYBIMAGE: drec->sql_desc_concise_type = SQL_LONGVARBINARY; drec->sql_desc_display_size = col->column_size * 2; SET_INFO("image", "0x", ""); case XSYBVARBINARY: case SYBVARBINARY: drec->sql_desc_concise_type = SQL_VARBINARY; drec->sql_desc_display_size = col->column_size * 2; if (is_blob_col(col)) { drec->sql_desc_display_size = SQL_SS_LENGTH_UNLIMITED; drec->sql_desc_octet_length = drec->sql_desc_length = SQL_SS_LENGTH_UNLIMITED; } SET_INFO("varbinary", "0x", ""); case SYBINTN: case SYBDATETIMN: case SYBFLTN: case SYBMONEYN: case SYBUINTN: case SYBTIMEN: case SYBDATEN: assert(0); case SYBVOID: case SYBINTERVAL: case SYBUNITEXT: case SYBXML: case SYBMSUDT: break; #if (ODBCVER >= 0x0300) case SYBUNIQUE: #ifdef SQL_GUID drec->sql_desc_concise_type = SQL_GUID; #else drec->sql_desc_concise_type = SQL_CHAR; #endif drec->sql_desc_display_size = 36; /* FIXME for Sybase ?? */ SET_INFO2("uniqueidentifier", "'", "'", 36); #endif case SYBMSXML: drec->sql_desc_concise_type = SQL_SS_XML; drec->sql_desc_display_size = SQL_SS_LENGTH_UNLIMITED; drec->sql_desc_octet_length = drec->sql_desc_length = SQL_SS_LENGTH_UNLIMITED; SET_INFO("xml", "'", "'"); } SET_INFO("", "", ""); } static void data_invalid_set_type_info(TDSCOLUMN * col, struct _drecord *drec, SQLINTEGER odbc_ver) { } void odbc_set_sql_type_info(TDSCOLUMN * col, struct _drecord *drec, SQLINTEGER odbc_ver) { drec->sql_desc_precision = col->column_prec; drec->sql_desc_scale = col->column_scale; drec->sql_desc_unsigned = SQL_FALSE; drec->sql_desc_octet_length = drec->sql_desc_length = col->on_server.column_size; drec->sql_desc_num_prec_radix = 0; drec->sql_desc_datetime_interval_code = 0; ((TDS_FUNCS *) col->funcs)->set_type_info(col, drec, odbc_ver); drec->sql_desc_type = drec->sql_desc_concise_type; if (drec->sql_desc_concise_type == SQL_TYPE_TIMESTAMP) drec->sql_desc_type = SQL_DATETIME; } # define TDS_DEFINE_FUNCS(name) \ const TDS_FUNCS tds_ ## name ## _funcs = { \ TDS_COMMON_FUNCS(name), \ data_ ## name ## _set_type_info, \ } TDS_DEFINE_FUNCS(invalid); TDS_DEFINE_FUNCS(generic); TDS_DEFINE_FUNCS(numeric); TDS_DEFINE_FUNCS(variant); TDS_DEFINE_FUNCS(msdatetime); TDS_DEFINE_FUNCS(clrudt); TDS_DEFINE_FUNCS(sybbigtime); freetds-1.00.82/src/odbc/winlogin.c100644 025423 025423 00000012255 12717145107 0012530/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2004 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /* * PROGRAMMER NAME CONTACT *============================================================== * SJK Steve Kirkendall kirkenda@cs.pdx.edu * *************************************************************** * DATE PROGRAMMER CHANGE *============================================================== * 29.FEB.04 SJK Original. */ /* This file implements the a login dialog for the FreeTDS ODBC driver. */ #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include #include "resource.h" #include #include #include #include #include "replacements.h" #include /* This is defined in ... */ extern HINSTANCE hinstFreeTDS; static char * get_desktop_file(const char *file) { LPITEMIDLIST pidl; char path[MAX_PATH]; HRESULT hr; LPMALLOC pMalloc = NULL; char * res = NULL; hr = SHGetMalloc(&pMalloc); if (SUCCEEDED(hr)) { hr = SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOPDIRECTORY, &pidl); if (SUCCEEDED(hr)) { if (SHGetPathFromIDList(pidl, path)) asprintf(&res, "%s\\%s", path, file); (*pMalloc->lpVtbl->Free)(pMalloc, pidl); } (*pMalloc->lpVtbl->Release)(pMalloc); } return res; } #ifndef _WIN64 #define GetWindowUserData(wnd) GetWindowLong((wnd), GWL_USERDATA) #define SetWindowUserData(wnd, data) SetWindowLong((wnd), GWL_USERDATA, (data)) #else #define GetWindowUserData(wnd) GetWindowLongPtr((wnd), GWLP_USERDATA) #define SetWindowUserData(wnd, data) SetWindowLongPtr((wnd), GWLP_USERDATA, (data)) #endif /** * Callback function for the DSN Configuration dialog * \param hDlg identifies the dialog * \param message what happened to the dialog * \param wParam varies with message * \param lParam pointer to TDSLOGIN struct */ static BOOL CALLBACK LoginDlgProc(HWND hDlg, UINT message, WPARAM wParam, /* */ LPARAM lParam) { TDSLOGIN *login; char tmp[100]; switch (message) { case WM_INITDIALOG: /* lParam points to the TDSLOGIN */ login = (TDSLOGIN *) lParam; SetWindowUserData(hDlg, lParam); /* copy info from TDSLOGIN to the dialog */ SendDlgItemMessage(hDlg, IDC_LOGINSERVER, WM_SETTEXT, 0, (LPARAM) tds_dstr_cstr(&login->server_name)); SendDlgItemMessage(hDlg, IDC_LOGINUID, WM_SETTEXT, 0, (LPARAM) tds_dstr_cstr(&login->user_name)); SendDlgItemMessage(hDlg, IDC_LOGINPWD, WM_SETTEXT, 0, (LPARAM) tds_dstr_cstr(&login->password)); SendDlgItemMessage(hDlg, IDC_LOGINDUMP, BM_SETCHECK, !tds_dstr_isempty(&login->dump_file), 0L); /* adjust label of logging checkbox */ SendDlgItemMessage(hDlg, IDC_LOGINDUMP, WM_SETTEXT, 0, (LPARAM) "\"FreeTDS.log\" on desktop"); return TRUE; case WM_COMMAND: /* Dialog's user data points to TDSLOGIN */ login = (TDSLOGIN *) GetWindowUserData(hDlg); /* The wParam indicates which button was pressed */ if (LOWORD(wParam) == IDCANCEL) { EndDialog(hDlg, FALSE); return TRUE; } else if (LOWORD(wParam) != IDOK) { /* Anything but IDCANCEL or IDOK is handled elsewhere */ break; } /* If we get here, then the user hit the [OK] button */ /* get values from dialog */ SendDlgItemMessage(hDlg, IDC_LOGINUID, WM_GETTEXT, sizeof tmp, (LPARAM) tmp); tds_dstr_copy(&login->user_name, tmp); SendDlgItemMessage(hDlg, IDC_LOGINPWD, WM_GETTEXT, sizeof tmp, (LPARAM) tmp); tds_dstr_copy(&login->password, tmp); if (SendDlgItemMessage(hDlg, IDC_LOGINDUMP, BM_GETCHECK, 0, 0)) { char * filename = get_desktop_file("FreeTDS.log"); if (filename) { tds_dstr_copy(&login->dump_file, filename); free(filename); } } else { tds_dstr_copy(&login->dump_file, ""); } /* And we're done */ EndDialog(hDlg, TRUE); return TRUE; } return FALSE; } /** * Use a dialog window to prompt for user_name and password. If the user hits * the [OK] button then store the entered values into the given TDSLOGIN * structure and return TRUE. If the user hits [CANCEL] then return FALSE. * \param hwndParent parent for dialog * \param login where to store login info */ BOOL get_login_info(HWND hwndParent, TDSLOGIN * login) { return DialogBoxParam(hinstFreeTDS, MAKEINTRESOURCE(IDD_LOGIN), hwndParent, (DLGPROC) LoginDlgProc, (LPARAM) login); } freetds-1.00.82/src/odbc/winsetup.c100644 025423 025423 00000030375 12717145107 0012563/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2004 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /* * PROGRAMMER NAME CONTACT *============================================================== * SJK Steve Kirkendall kirkenda@cs.pdx.edu * *************************************************************** * DATE PROGRAMMER CHANGE *============================================================== * 25.FEB.04 SJK Original. */ /* This file implements the setup API for FreeTDS. Specifically, * this includes the ConfigDSN() and ConfigDriver() functions. */ #include #include #include #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include #include "resource.h" #include #include #include #include #include "replacements.h" #include typedef struct { DSTR origdsn; /**< original name of the data source */ DSTR dsn; /**< edited name of the data source */ TDSLOGIN *login; /**< everything else */ } DSNINFO; /* This is defined in ... */ extern HINSTANCE hinstFreeTDS; /** Create an empty DSNINFO struct */ static DSNINFO * alloc_dsninfo(void) { DSNINFO *di; /* allocate & initialize it */ di = (DSNINFO *) malloc(sizeof(DSNINFO)); tds_dstr_init(&di->origdsn); tds_dstr_init(&di->dsn); di->login = tds_alloc_login(0); tds_init_login(di->login, NULL); return di; } /** Destroy a DSNINFO struct, freeing all memory associated with it */ static void free_dsninfo(DSNINFO * di) { /* the DSNINFO struct to be freed */ tds_free_login(di->login); tds_dstr_free(&di->origdsn); tds_dstr_free(&di->dsn); free(di); } /** * Parse a DSN string which is delimited with NULs instead of semicolons. * This uses odbc_parse_connect_string() internally, and also adds support * for parsing the DSN and driver * \param attribs 0-delimited string, with \0\0 terminator * \param di where to store the results */ static void parse_wacky_dsn_string(LPCSTR attribs, DSNINFO * di) { LPCSTR str; char *build; /* for each field... */ for (str = attribs; *str; str += strlen(str) + 1) { if (!strncasecmp(str, "DSN=", 4)) { tds_dstr_copy(&di->origdsn, str + 4); tds_dstr_copy(&di->dsn, str + 4); } } /* allocate space for a ;-delimited version */ build = (char *) malloc(str - attribs); /* copy the fields into the new buffer with ;'s */ *build = '\0'; for (str = attribs; *str; str += strlen(str) + 1) { if (*build) strcat(build, ";"); strcat(build, str); } /* let odbc_parse_connect_string() parse the ;-delimited version */ odbc_parse_connect_string(NULL, build, build + strlen(build), di->login, NULL); } /** * Update the attributes. Return TRUE if successful, else FALSE. The names * written here correspond to the names read by odbc_get_dsn_info(). */ #define WRITESTR(n,s) if (!SQLWritePrivateProfileString(section, (n), (s), odbcini)) return FALSE #define FIELD_STRING(f) tds_dstr_cstr(&di->login->f) static BOOL write_all_strings(DSNINFO * di) { char odbcini[FILENAME_MAX]; char tmp[100]; const char *section = tds_dstr_cstr(&di->dsn); strcpy(odbcini, "odbc.ini"); WRITESTR("Server", FIELD_STRING(server_name)); WRITESTR("Language", FIELD_STRING(language)); WRITESTR("Database", FIELD_STRING(database)); sprintf(tmp, "%u", di->login->port); WRITESTR("Port", tmp); sprintf(tmp, "%d.%d", TDS_MAJOR(di->login), TDS_MINOR(di->login)); WRITESTR("TDS_Version", tmp); sprintf(tmp, "%u", di->login->text_size); WRITESTR("TextSize", tmp); sprintf(tmp, "%u", di->login->block_size); WRITESTR("PacketSize", tmp); return TRUE; } /** * Go looking for trouble. Return NULL if the info is okay, or an error message * if something needs to change. */ static const char * validate(DSNINFO * di) { if (!SQLValidDSN(tds_dstr_cstr(&di->dsn))) return "Invalid DSN"; if (!IS_TDS42(di->login) && !IS_TDS46(di->login) && !IS_TDS50(di->login) && !IS_TDS7_PLUS(di->login)) return "Bad Protocol version"; if (tds_dstr_isempty(&di->login->server_name)) return "Address is required"; if (di->login->port < 1 || di->login->port > 65535) return "Bad port - Try 1433 or 4000"; return NULL; } #ifndef _WIN64 #define GetWindowUserData(wnd) GetWindowLong((wnd), GWL_USERDATA) #define SetWindowUserData(wnd, data) SetWindowLong((wnd), GWL_USERDATA, (data)) #else #define GetWindowUserData(wnd) GetWindowLongPtr((wnd), GWLP_USERDATA) #define SetWindowUserData(wnd, data) SetWindowLongPtr((wnd), GWLP_USERDATA, (data)) #endif /** * Callback function for the DSN Configuration dialog * \param hDlg identifies the dialog * \param message what happened to the dialog * \param wParam varies with message * \param lParam pointer to DSNINFO struct */ static BOOL CALLBACK DSNDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { DSNINFO *di; char tmp[100]; const char *pstr; int major, minor, i; static const char *protocols[] = { "TDS 4.2", "TDS 4.6", "TDS 5.0", "TDS 7.0", "TDS 7.1", "TDS 7.2", "TDS 7.3", "TDS 7.4", NULL }; switch (message) { case WM_INITDIALOG: /* lParam points to the DSNINFO */ di = (DSNINFO *) lParam; SetWindowUserData(hDlg, lParam); /* Stuff legal protocol names into IDC_PROTOCOL */ for (i = 0; protocols[i]; i++) { SendDlgItemMessage(hDlg, IDC_PROTOCOL, CB_ADDSTRING, 0, (LPARAM) protocols[i]); } /* copy info from DSNINFO to the dialog */ SendDlgItemMessage(hDlg, IDC_DSNNAME, WM_SETTEXT, 0, (LPARAM) tds_dstr_cstr(&di->dsn)); sprintf(tmp, "TDS %d.%d", TDS_MAJOR(di->login), TDS_MINOR(di->login)); SendDlgItemMessage(hDlg, IDC_PROTOCOL, CB_SELECTSTRING, -1, (LPARAM) tmp); SendDlgItemMessage(hDlg, IDC_ADDRESS, WM_SETTEXT, 0, (LPARAM) tds_dstr_cstr(&di->login->server_name)); sprintf(tmp, "%u", di->login->port); SendDlgItemMessage(hDlg, IDC_PORT, WM_SETTEXT, 0, (LPARAM) tmp); SendDlgItemMessage(hDlg, IDC_DATABASE, WM_SETTEXT, 0, (LPARAM) tds_dstr_cstr(&di->login->database)); return TRUE; case WM_COMMAND: /* Dialog's user data points to DSNINFO */ di = (DSNINFO *) GetWindowUserData(hDlg); /* The wParam indicates which button was pressed */ if (LOWORD(wParam) == IDCANCEL) { EndDialog(hDlg, FALSE); return TRUE; } else if (LOWORD(wParam) != IDOK) { /* Anything but IDCANCEL or IDOK is handled elsewhere */ break; } /* If we get here, then the user hit the [OK] button */ /* get values from dialog */ SendDlgItemMessage(hDlg, IDC_DSNNAME, WM_GETTEXT, sizeof tmp, (LPARAM) tmp); tds_dstr_copy(&di->dsn, tmp); SendDlgItemMessage(hDlg, IDC_PROTOCOL, WM_GETTEXT, sizeof tmp, (LPARAM) tmp); minor = 0; if (sscanf(tmp, "%*[^0-9]%d.%d", &major, &minor) > 1) { if (major == 8 && minor == 0) { major = 7; minor = 1; } di->login->tds_version = (major << 8) | minor; } SendDlgItemMessage(hDlg, IDC_ADDRESS, WM_GETTEXT, sizeof tmp, (LPARAM) tmp); tds_dstr_copy(&di->login->server_name, tmp); SendDlgItemMessage(hDlg, IDC_PORT, WM_GETTEXT, sizeof tmp, (LPARAM) tmp); di->login->port = atoi(tmp); SendDlgItemMessage(hDlg, IDC_DATABASE, WM_GETTEXT, sizeof tmp, (LPARAM) tmp); tds_dstr_copy(&di->login->database, tmp); /* validate */ SendDlgItemMessage(hDlg, IDC_HINT, WM_SETTEXT, 0, (LPARAM) "VALIDATING... please be patient"); pstr = validate(di); if (pstr != NULL) { SendDlgItemMessage(hDlg, IDC_HINT, WM_SETTEXT, 0, (LPARAM) pstr); return TRUE; } SendDlgItemMessage(hDlg, IDC_HINT, WM_SETTEXT, 0, (LPARAM) ""); /* No problems -- we're done */ EndDialog(hDlg, TRUE); return TRUE; } return FALSE; } /** * Add, remove, or modify a data source * \param hwndParent parent for dialog, NULL for batch ops * \param fRequest request type * \param lpszDriver driver name (for humans, not DLL name) * \param lpszAttributes attribute list */ BOOL INSTAPI ConfigDSN(HWND hwndParent, WORD fRequest, LPCSTR lpszDriver, LPCSTR lpszAttributes) { int result; DSNINFO *di; const char *errmsg; /* * Initialize Windows sockets. This is necessary even though * ConfigDSN() only looks up addresses and names, and never actually * uses any sockets. */ INITSOCKET(); /* Create a blank login struct */ di = alloc_dsninfo(); /* * Parse the attribute string. If this contains a DSN name, then it * also reads the current parameters of that DSN. */ parse_wacky_dsn_string(lpszAttributes, di); /* Maybe allow the user to edit it */ if (hwndParent && fRequest != ODBC_REMOVE_DSN) { result = DialogBoxParam(hinstFreeTDS, MAKEINTRESOURCE(IDD_DSN), hwndParent, (DLGPROC) DSNDlgProc, (LPARAM) di); if (result < 0) { DWORD errorcode = GetLastError(); char buf[1000]; FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, errorcode, 0, buf, 1000, NULL); } /* if user hit [Cancel] then clean up and return FALSE */ if (result == 0) { goto Fail; } } switch (fRequest) { case ODBC_ADD_DSN: errmsg = validate(di); if (errmsg != NULL) { SQLPostInstallerError(ODBC_ERROR_REQUEST_FAILED, errmsg); goto Fail; } if (!SQLWriteDSNToIni(tds_dstr_cstr(&di->dsn), lpszDriver)) { goto Fail; } if (!write_all_strings(di)) { goto Fail; } break; case ODBC_CONFIG_DSN: errmsg = validate(di); if (errmsg != NULL) { SQLPostInstallerError(ODBC_ERROR_REQUEST_FAILED, errmsg); goto Fail; } /* * if the DSN name has changed, then delete the old entry and * add the new one. */ if (strcasecmp(tds_dstr_cstr(&di->origdsn), tds_dstr_cstr(&di->dsn))) { if (!SQLRemoveDSNFromIni(tds_dstr_cstr(&di->origdsn)) || !SQLWriteDSNToIni(tds_dstr_cstr(&di->dsn), lpszDriver)) { goto Fail; } } if (!write_all_strings(di)) { goto Fail; } break; case ODBC_REMOVE_DSN: if (!SQLRemoveDSNFromIni(tds_dstr_cstr(&di->dsn))) { goto Fail; } break; } /* Clean up and return TRUE, indicating that the change took place */ free_dsninfo(di); DONESOCKET(); return TRUE; Fail: free_dsninfo(di); DONESOCKET(); return FALSE; } /** Add or remove an ODBC driver */ BOOL INSTAPI ConfigDriver(HWND hwndParent, WORD fRequest, LPCSTR lpszDriver, LPCSTR lpszArgs, LPSTR lpszMsg, WORD cbMsgMax, WORD * pcbMsgOut) { const char *msg = NULL; /* TODO finish ?? */ switch (fRequest) { case ODBC_INSTALL_DRIVER: msg = "Hello"; break; case ODBC_REMOVE_DRIVER: msg = "Goodbye"; break; } if (msg && lpszMsg && cbMsgMax > strlen(msg)) { strcpy(lpszMsg, msg); *pcbMsgOut = strlen(msg); } return TRUE; } BOOL INSTAPI ConfigTranslator(HWND hwndParent, DWORD * pvOption) { return TRUE; } /** * Allow install using regsvr32 */ HRESULT WINAPI DllRegisterServer(void) { TCHAR fn[MAX_PATH], full_fn[MAX_PATH]; LPTSTR name; WORD len_out; DWORD cnt; char *desc = NULL; BOOL b_res; if (!GetModuleFileName(hinstFreeTDS, fn, TDS_VECTOR_SIZE(fn))) return SELFREG_E_CLASS; if (!GetFullPathName(fn, TDS_VECTOR_SIZE(full_fn), full_fn, &name) || !name || full_fn == name) return SELFREG_E_CLASS; if (asprintf(&desc, "FreeTDS%c" "APILevel=2%c" "ConnectFunctions=YYN%c" "DriverODBCVer=03.00%c" "FileUsage=0%c" "SQLLevel=2%c" "Setup=%s%c" "Driver=%s%c", 0, 0, 0, 0, 0, 0, name, 0, name, 0 ) < 0) return SELFREG_E_CLASS; name[-1] = 0; b_res = SQLInstallDriverEx(desc, full_fn, fn, TDS_VECTOR_SIZE(fn), &len_out, ODBC_INSTALL_COMPLETE, &cnt); free(desc); if (!b_res) return SELFREG_E_CLASS; return S_OK; } /** * Allow uninstall using regsvr32 command */ HRESULT WINAPI DllUnregisterServer(void) { DWORD cnt; if (!SQLRemoveDriver("FreeTDS", FALSE, &cnt)) return SELFREG_E_CLASS; return S_OK; } freetds-1.00.82/src/odbc/winmain.c100644 025423 025423 00000000041 12717145107 0012332#include "../../win32/initnet.c" freetds-1.00.82/src/odbc/version.rc100644 025423 025423 00000002162 13242511125 0012534 #ifndef _MAC ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO FILEVERSION 1,00,82,6638 PRODUCTVERSION 1,00,82,6638 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L #else FILEFLAGS 0x0L #endif FILEOS 0x40004L FILETYPE 0x2L FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904b0" BEGIN VALUE "Comments", "\0" VALUE "CompanyName", "FreeTDS.org\0" VALUE "FileDescription", "FreeTDS\0" VALUE "FileVersion", "1, 00, 82, 6638\0" VALUE "InternalName", "FreeTDS\0" VALUE "LegalCopyright", "Copyright © 2004-2015 under terms of GNU LGPL\0" VALUE "LegalTrademarks", "\0" VALUE "OriginalFilename", "FreeTDS.dll\0" VALUE "PrivateBuild", "\0" VALUE "ProductName", "FreeTDS ODBC Driver\0" VALUE "ProductVersion", "1, 00, 82, 6638\0" VALUE "SpecialBuild", "\0" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1200 END END #endif // !_MAC freetds-1.00.82/src/odbc/CMakeLists.txt100644 025423 025423 00000002415 12717145107 0013273add_subdirectory(unittests) # TODO checks add_definitions(-DUNIXODBC -DHAVE_SQLGETPRIVATEPROFILESTRING -DDLL_EXPORT) if(PERL_FOUND AND NOT EXISTS "${CMAKE_SOURCE_DIR}/configure") add_custom_command(OUTPUT odbc_export.h COMMAND ${PERL_EXECUTABLE} odbc_export.pl odbc.c > odbc_export.h MAIN_DEPENDENCY odbc_export.pl DEPENDS odbc.c WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) add_custom_command(OUTPUT error_export.h COMMAND ${PERL_EXECUTABLE} odbc_export.pl error.c > error_export.h MAIN_DEPENDENCY odbc_export.pl DEPENDS error.c WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) endif(PERL_FOUND AND NOT EXISTS "${CMAKE_SOURCE_DIR}/configure") if(WIN32) set(win_SRCS winlogin.c winsetup.c winmain.c odbc_w.def setup.rc) endif() set(libs ${lib_ODBCINST}) add_library(tdsodbc SHARED odbc.c connectparams.c convert_tds2sql.c descriptor.c prepare_query.c odbc_util.c bcp.c native.c sql2tds.c error.c odbc_checks.c sqlwchar.c sqlwparams.h odbc_export.h error_export.h odbc_data.c ${win_SRCS} ) # TODO libiconv, odbcinstlib and other dynamics target_link_libraries(tdsodbc tds replacements ${libs} ${lib_NETWORK} ${lib_BASE}) if(MINGW OR CYGWIN) set_target_properties(tdsodbc PROPERTIES LINK_FLAGS "--static -Wl,--kill-at -Wl,--enable-stdcall-fixup") endif(MINGW OR CYGWIN) freetds-1.00.82/src/odbc/setup.rc100644 025423 025423 00000010123 12717145107 0012214//Microsoft Developer Studio generated resource script. // #include "resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. // #ifdef _MSC_VER # include "winres.h" #else # include "windows.h" # ifndef IDC_STATIC # define IDC_STATIC -1 # endif #endif #include "version.rc" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // English (U.S.) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) #ifdef _WIN32 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #pragma code_page(1252) #endif //_WIN32 ///////////////////////////////////////////////////////////////////////////// // // Dialog // IDD_DSN DIALOG DISCARDABLE 0, 0, 202, 140 STYLE DS_SYSMODAL | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION CAPTION "FreeTDS DSN Configuration" FONT 8, "MS Sans Serif" BEGIN LTEXT "DSN Name",IDC_STATIC,23,16,37,8 EDITTEXT IDC_DSNNAME,74,13,60,14,ES_AUTOHSCROLL LTEXT "Protocol Version",IDC_STATIC,8,34,52,8 COMBOBOX IDC_PROTOCOL,74,32,73,61,CBS_DROPDOWNLIST | CBS_SORT | WS_TABSTOP LTEXT "Server Address",IDC_STATIC,11,52,49,8 EDITTEXT IDC_ADDRESS,74,49,121,14,ES_AUTOHSCROLL LTEXT "Server Port",IDC_STATIC,24,71,36,8 EDITTEXT IDC_PORT,74,68,60,14,ES_AUTOHSCROLL | ES_NUMBER LTEXT "Database",IDC_STATIC,28,90,32,8 EDITTEXT IDC_DATABASE,74,87,121,14,ES_AUTOHSCROLL LTEXT "www.freetds.org",IDC_STATIC,7,123,52,8 CTEXT "",IDC_HINT,7,105,188,8 PUSHBUTTON "OK",IDOK,92,117,50,14 PUSHBUTTON "Cancel",IDCANCEL,144,117,50,14 END IDD_LOGIN DIALOG DISCARDABLE 0, 0, 164, 117 STYLE DS_MODALFRAME | DS_3DLOOK | WS_CAPTION | WS_VISIBLE CAPTION "FreeTDS Login" FONT 8, "MS Sans Serif" BEGIN LTEXT "Server",IDC_STATIC,23,17,22,8 LTEXT "Server Name",IDC_LOGINSERVER,51,13,106,16, SS_CENTERIMAGE | SS_SUNKEN LTEXT "User Name",IDC_STATIC,9,38,36,8 EDITTEXT IDC_LOGINUID,51,36,106,14,ES_AUTOHSCROLL LTEXT "Password",IDC_STATIC,13,60,32,8 EDITTEXT IDC_LOGINPWD,51,57,106,14,ES_PASSWORD | ES_AUTOHSCROLL DEFPUSHBUTTON "OK",IDOK,52,96,50,14 PUSHBUTTON "Cancel",IDCANCEL,107,96,50,14 LTEXT "Log File",IDC_STATIC,19,79,26,8 CONTROL """FreeTDS.log"" on desktop",IDC_LOGINDUMP,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,51,78,106,10 END #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // TEXTINCLUDE // 1 TEXTINCLUDE DISCARDABLE BEGIN "resource.h\0" END 2 TEXTINCLUDE DISCARDABLE BEGIN "#ifdef _MSC_VER\r\n" "# include ""winres.h""\r\n" "#else\r\n" "# include ""windows.h""\r\n" "# ifndef IDC_STATIC\r\n" "# define IDC_STATIC -1\r\n" "# endif\r\n" "#endif\r\n" "\r\n" "#include ""version.rc""\0" END 3 TEXTINCLUDE DISCARDABLE BEGIN "\r\n" "\0" END #endif // APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // DESIGNINFO // #ifdef APSTUDIO_INVOKED GUIDELINES DESIGNINFO DISCARDABLE BEGIN IDD_DSN, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 195 TOPMARGIN, 7 BOTTOMMARGIN, 131 END IDD_LOGIN, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 157 TOPMARGIN, 7 BOTTOMMARGIN, 110 END END #endif // APSTUDIO_INVOKED #endif // English (U.S.) resources ///////////////////////////////////////////////////////////////////////////// #ifndef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 3 resource. // ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED freetds-1.00.82/src/odbc/resource.h100644 025423 025423 00000001644 12717145107 0012536//{{NO_DEPENDENCIES}} // Microsoft Developer Studio generated include file. // Used by setup.rc // #define IDD_LOGIN 102 #define IDD_DSN 106 #define IDC_PROTOCOL 1003 #define IDC_ADDRESS 1004 #define IDC_PORT 1005 #define IDC_DATABASE 1011 #define IDC_DSNNAME 1015 #define IDC_HINT 1017 #define IDC_LOGINSERVER 1020 #define IDC_LOGINUID 1021 #define IDC_LOGINPWD 1022 #define IDC_LOGINDUMP 1023 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 103 #define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_CONTROL_VALUE 1024 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif freetds-1.00.82/src/odbc/odbc.def100644 025423 025423 00000003046 12717145107 0012123EXPORTS SQLAllocConnect SQLAllocEnv SQLAllocHandle SQLAllocStmt SQLBindCol SQLBindParam SQLBindParameter ; SQLBrowseConnect SQLCancel SQLCloseCursor SQLColAttribute SQLColAttributes SQLColumnPrivileges SQLColumns SQLConnect SQLCopyDesc SQLDescribeCol ; SQLDescribeParam SQLDisconnect SQLDriverConnect SQLEndTran SQLError SQLExecDirect SQLExecute SQLExtendedFetch SQLFetch SQLFetchScroll SQLForeignKeys SQLFreeConnect SQLFreeEnv SQLFreeHandle SQLFreeStmt SQLGetConnectAttr SQLGetConnectOption SQLGetCursorName SQLGetData SQLGetDescField SQLGetDescRec SQLGetDiagField SQLGetDiagRec SQLGetEnvAttr SQLGetFunctions SQLGetInfo SQLGetStmtAttr SQLGetStmtOption SQLGetTypeInfo SQLMoreResults SQLNativeSql SQLNumParams SQLNumResultCols SQLParamData SQLParamOptions SQLPrepare SQLPrimaryKeys SQLProcedureColumns SQLProcedures SQLPutData SQLRowCount SQLSetConnectAttr SQLSetConnectOption SQLSetCursorName SQLSetDescField SQLSetDescRec SQLSetEnvAttr SQLSetParam SQLSetPos SQLSetScrollOptions SQLSetStmtAttr SQLSetStmtOption SQLSpecialColumns SQLStatistics SQLTablePrivileges SQLTables SQLTransact ConfigDSN ConfigDriver ConfigTranslator bcp_initA = win_bcp_initA bcp_control = win_bcp_control bcp_colptr = win_bcp_colptr bcp_sendrow = win_bcp_sendrow bcp_batch = win_bcp_batch bcp_done = win_bcp_done bcp_bind = win_bcp_bind DllRegisterServer PRIVATE DllUnregisterServer PRIVATE SQLGetTypeInfoW = SQLGetTypeInfo freetds-1.00.82/src/odbc/odbc_w.def100644 025423 025423 00000004021 12717145107 0012443EXPORTS SQLAllocConnect SQLAllocEnv SQLAllocHandle SQLAllocStmt SQLBindCol SQLBindParam SQLBindParameter ; SQLBrowseConnect SQLCancel SQLCloseCursor SQLColAttribute SQLColAttributes SQLColumnPrivileges SQLColumns SQLConnect SQLCopyDesc SQLDescribeCol ; SQLDescribeParam SQLDisconnect SQLDriverConnect SQLEndTran SQLError SQLExecDirect SQLExecute SQLExtendedFetch SQLFetch SQLFetchScroll SQLForeignKeys SQLFreeConnect SQLFreeEnv SQLFreeHandle SQLFreeStmt SQLGetConnectAttr SQLGetConnectOption SQLGetCursorName SQLGetData SQLGetDescField SQLGetDescRec SQLGetDiagField SQLGetDiagRec SQLGetEnvAttr SQLGetFunctions SQLGetInfo SQLGetStmtAttr SQLGetStmtOption SQLGetTypeInfo SQLMoreResults SQLNativeSql SQLNumParams SQLNumResultCols SQLParamData SQLParamOptions SQLPrepare SQLPrimaryKeys SQLProcedureColumns SQLProcedures SQLPutData SQLRowCount SQLSetConnectAttr SQLSetConnectOption SQLSetCursorName SQLSetDescField SQLSetDescRec SQLSetEnvAttr SQLSetParam SQLSetPos SQLSetScrollOptions SQLSetStmtAttr SQLSetStmtOption SQLSpecialColumns SQLStatistics SQLTablePrivileges SQLTables SQLTransact ConfigDSN ConfigDriver ConfigTranslator bcp_initA = win_bcp_initA bcp_control = win_bcp_control bcp_colptr = win_bcp_colptr bcp_sendrow = win_bcp_sendrow bcp_batch = win_bcp_batch bcp_done = win_bcp_done bcp_bind = win_bcp_bind DllRegisterServer PRIVATE DllUnregisterServer PRIVATE SQLGetTypeInfoW = SQLGetTypeInfo SQLColAttributeW SQLColumnPrivilegesW SQLColumnsW SQLConnectW SQLDescribeColW SQLDriverConnectW SQLErrorW SQLExecDirectW SQLForeignKeysW SQLGetConnectAttrW SQLGetConnectOptionW SQLGetCursorNameW SQLGetDescFieldW SQLGetDescRecW SQLGetDiagFieldW SQLGetDiagRecW SQLGetInfoW SQLGetStmtAttrW SQLNativeSqlW SQLPrepareW SQLPrimaryKeysW SQLProcedureColumnsW SQLProceduresW SQLSetConnectAttrW SQLSetConnectOptionW SQLSetCursorNameW SQLSetDescFieldW SQLSetStmtAttrW SQLSpecialColumnsW SQLStatisticsW SQLTablePrivilegesW SQLTablesW bcp_initW = win_bcp_initW freetds-1.00.82/src/odbc/unittests/Makefile.am100644 025423 025423 00000013365 12717145107 0014637# $Id: Makefile.am,v 1.87 2012-03-06 20:40:12 freddy77 Exp $ TESTS = \ t0001$(EXEEXT) t0002$(EXEEXT) t0003$(EXEEXT)\ t0004$(EXEEXT) connect$(EXEEXT) print$(EXEEXT)\ date$(EXEEXT) norowset$(EXEEXT) funccall$(EXEEXT)\ lang_error$(EXEEXT) tables$(EXEEXT)\ binary_test$(EXEEXT) moreandcount$(EXEEXT)\ earlybind$(EXEEXT) putdata$(EXEEXT) params$(EXEEXT)\ raiserror$(EXEEXT) getdata$(EXEEXT)\ transaction$(EXEEXT) type$(EXEEXT) genparams$(EXEEXT)\ preperror$(EXEEXT) prepare_results$(EXEEXT)\ testodbc$(EXEEXT) data$(EXEEXT) error$(EXEEXT)\ rebindpar$(EXEEXT) rpc$(EXEEXT) convert_error$(EXEEXT)\ typeinfo$(EXEEXT) const_params$(EXEEXT)\ insert_speed$(EXEEXT) compute$(EXEEXT)\ timeout$(EXEEXT) array$(EXEEXT) array_out$(EXEEXT)\ cursor1$(EXEEXT) scroll$(EXEEXT) cursor2$(EXEEXT)\ describecol$(EXEEXT) copydesc$(EXEEXT)\ prepclose$(EXEEXT) warning$(EXEEXT) \ paramcore$(EXEEXT) timeout2$(EXEEXT) timeout3$(EXEEXT) \ connect2$(EXEEXT) timeout4$(EXEEXT) freeclose$(EXEEXT) \ cursor3$(EXEEXT) cursor4$(EXEEXT) cursor5$(EXEEXT) \ attributes$(EXEEXT) hidden$(EXEEXT) blob1$(EXEEXT) \ cancel$(EXEEXT) wchar$(EXEEXT) rowset$(EXEEXT) transaction2$(EXEEXT) \ cursor6$(EXEEXT) cursor7$(EXEEXT) utf8$(EXEEXT) utf8_2$(EXEEXT) \ stats$(EXEEXT) descrec$(EXEEXT) peter$(EXEEXT) test64$(EXEEXT) \ prepare_warn$(EXEEXT) long_error$(EXEEXT) mars1$(EXEEXT) \ array_error$(EXEEXT) describecol2$(EXEEXT) closestmt$(EXEEXT) bcp$(EXEEXT) check_PROGRAMS = $(TESTS) oldpwd$(EXEEXT) t0001_SOURCES = t0001.c common.c common.h t0002_SOURCES = t0002.c common.c common.h t0003_SOURCES = t0003.c common.c common.h t0004_SOURCES = t0004.c common.c common.h connect_SOURCES = connect.c common.c common.h connect_LDFLAGS = $(ODBCINSTLIB) -no-install print_SOURCES = print.c common.c common.h date_SOURCES = date.c common.c common.h norowset_SOURCES = norowset.c common.c common.h funccall_SOURCES = funccall.c common.c common.h lang_error_SOURCES = lang_error.c common.c common.h tables_SOURCES = tables.c common.c common.h binary_test_SOURCES = binary_test.c common.c common.h moreandcount_SOURCES = moreandcount.c common.c common.h earlybind_SOURCES = earlybind.c common.c common.h putdata_SOURCES = putdata.c common.c common.h params_SOURCES = params.c common.c common.h raiserror_SOURCES = raiserror.c common.c common.h getdata_SOURCES = getdata.c common.c common.h type_SOURCES = type.c common.c common.h transaction_SOURCES = transaction.c common.c common.h genparams_SOURCES = genparams.c common.c common.h c2string.c preperror_SOURCES = preperror.c common.c common.h prepare_results_SOURCES = prepare_results.c common.c common.h testodbc_SOURCES = testodbc.c common.c common.h data_SOURCES = data.c common.c common.h c2string.c parser.c parser.h error_SOURCES = error.c common.c common.h rebindpar_SOURCES = rebindpar.c common.c common.h rpc_SOURCES = rpc.c common.c common.h convert_error_SOURCES = convert_error.c common.c common.h typeinfo_SOURCES = typeinfo.c common.c common.h const_params_SOURCES = const_params.c common.c common.h insert_speed_SOURCES = insert_speed.c common.c common.h compute_SOURCES = compute.c common.c common.h timeout_SOURCES = timeout.c common.c common.h array_SOURCES = array.c common.c common.h array_out_SOURCES = array_out.c common.c common.h cursor1_SOURCES = cursor1.c common.c common.h scroll_SOURCES = scroll.c common.c common.h cursor2_SOURCES = cursor2.c common.c common.h describecol_SOURCES = describecol.c common.c common.h parser.c parser.h describecol2_SOURCES = describecol2.c common.c common.h copydesc_SOURCES = copydesc.c common.c common.h prepclose_SOURCES = prepclose.c common.c common.h warning_SOURCES = warning.c common.c common.h paramcore_SOURCES = paramcore.c common.c common.h timeout2_SOURCES = timeout2.c common.c common.h timeout3_SOURCES = timeout3.c common.c common.h connect2_SOURCES = connect2.c common.c common.h timeout4_SOURCES = timeout4.c common.c common.h freeclose_SOURCES = freeclose.c common.c common.h cursor3_SOURCES = cursor3.c common.c common.h cursor4_SOURCES = cursor4.c common.c common.h cursor5_SOURCES = cursor5.c common.c common.h attributes_SOURCES = attributes.c common.c common.h hidden_SOURCES = hidden.c common.c common.h blob1_SOURCES = blob1.c common.c common.h rowset_SOURCES = rowset.c common.c common.h cancel_SOURCES = cancel.c common.c common.h wchar_SOURCES = wchar.c common.c common.h transaction2_SOURCES = transaction2.c common.c common.h cursor6_SOURCES = cursor6.c common.c common.h cursor7_SOURCES = cursor7.c common.c common.h utf8_SOURCES = utf8.c common.c common.h utf8_2_SOURCES = utf8_2.c common.c common.h stats_SOURCES = stats.c common.c common.h descrec_SOURCES = descrec.c common.c common.h peter_SOURCES = peter.c common.c common.h test64_SOURCES = test64.c common.c common.h prepare_warn_SOURCES = prepare_warn.c common.c common.h long_error_SOURCES = long_error.c common.c common.h mars1_SOURCES = mars1.c common.c common.h array_error_SOURCES = array_error.c common.c common.h closestmt_SOURCES = closestmt.c common.c common.h oldpwd_SOURCES = oldpwd.c common.c common.h bcp_SOURCES = bcp.c common.c common.h GLOBAL_CPPFLAGS = -I$(top_srcdir)/include $(ODBC_INC) -DFREETDS_TOPDIR=\"$(top_srcdir)\" if ODBC_WIDE_TESTS AM_CPPFLAGS = $(GLOBAL_CPPFLAGS) -DUNICODE -D_UNICODE else AM_CPPFLAGS = $(GLOBAL_CPPFLAGS) endif # this test cannot work using wide characters as use UTF-8 and single byte encoding utf8_CPPFLAGS = $(GLOBAL_CPPFLAGS) oldpwd_CPPFLAGS = $(GLOBAL_CPPFLAGS) LIBS = $(ODBCLIB) $(ODBCNODMLIB) ../../replacements/libreplacements.la $(NETWORK_LIBS) if MINGW32 AM_LDFLAGS = -no-fast-install LIBS += $(ODBCINSTLIB) else AM_LDFLAGS = -no-install -L../.libs -R $(abs_builddir)/../.libs endif DISTCLEANFILES = odbc.ini odbcinst.ini EXTRA_DIST = data.in describecol.in attributes.in CMakeLists.txt freetds-1.00.82/src/odbc/unittests/Makefile.in100644 025423 025423 00000302527 13242511111 0014633# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @MINGW32_TRUE@am__append_1 = $(ODBCINSTLIB) subdir = src/odbc/unittests ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = \ $(top_srcdir)/m4/ac_caolan_func_which_gethostbyname_r.m4 \ $(top_srcdir)/m4/ac_have_inaddr_none.m4 \ $(top_srcdir)/m4/ac_have_malloc_options.m4 \ $(top_srcdir)/m4/ac_nullzero.m4 \ $(top_srcdir)/m4/ac_raf_func_which_getservbyname_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_gethostbyaddr_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_getpwuid_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_localtime_r.m4 \ $(top_srcdir)/m4/acx_pthread.m4 \ $(top_srcdir)/m4/ax_cflags_gcc_option.m4 \ $(top_srcdir)/m4/check_openssl.m4 \ $(top_srcdir)/m4/gettimemilli.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/pushlibs.m4 \ $(top_srcdir)/m4/sprintf_i64_format.m4 \ $(top_srcdir)/m4/type_socklen_t.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am_array_OBJECTS = array.$(OBJEXT) common.$(OBJEXT) array_OBJECTS = $(am_array_OBJECTS) array_LDADD = $(LDADD) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = am_array_error_OBJECTS = array_error.$(OBJEXT) common.$(OBJEXT) array_error_OBJECTS = $(am_array_error_OBJECTS) array_error_LDADD = $(LDADD) am_array_out_OBJECTS = array_out.$(OBJEXT) common.$(OBJEXT) array_out_OBJECTS = $(am_array_out_OBJECTS) array_out_LDADD = $(LDADD) am_attributes_OBJECTS = attributes.$(OBJEXT) common.$(OBJEXT) attributes_OBJECTS = $(am_attributes_OBJECTS) attributes_LDADD = $(LDADD) am_bcp_OBJECTS = bcp.$(OBJEXT) common.$(OBJEXT) bcp_OBJECTS = $(am_bcp_OBJECTS) bcp_LDADD = $(LDADD) am_binary_test_OBJECTS = binary_test.$(OBJEXT) common.$(OBJEXT) binary_test_OBJECTS = $(am_binary_test_OBJECTS) binary_test_LDADD = $(LDADD) am_blob1_OBJECTS = blob1.$(OBJEXT) common.$(OBJEXT) blob1_OBJECTS = $(am_blob1_OBJECTS) blob1_LDADD = $(LDADD) am_cancel_OBJECTS = cancel.$(OBJEXT) common.$(OBJEXT) cancel_OBJECTS = $(am_cancel_OBJECTS) cancel_LDADD = $(LDADD) am_closestmt_OBJECTS = closestmt.$(OBJEXT) common.$(OBJEXT) closestmt_OBJECTS = $(am_closestmt_OBJECTS) closestmt_LDADD = $(LDADD) am_compute_OBJECTS = compute.$(OBJEXT) common.$(OBJEXT) compute_OBJECTS = $(am_compute_OBJECTS) compute_LDADD = $(LDADD) am_connect_OBJECTS = connect.$(OBJEXT) common.$(OBJEXT) connect_OBJECTS = $(am_connect_OBJECTS) connect_LDADD = $(LDADD) connect_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(connect_LDFLAGS) $(LDFLAGS) -o $@ am_connect2_OBJECTS = connect2.$(OBJEXT) common.$(OBJEXT) connect2_OBJECTS = $(am_connect2_OBJECTS) connect2_LDADD = $(LDADD) am_const_params_OBJECTS = const_params.$(OBJEXT) common.$(OBJEXT) const_params_OBJECTS = $(am_const_params_OBJECTS) const_params_LDADD = $(LDADD) am_convert_error_OBJECTS = convert_error.$(OBJEXT) common.$(OBJEXT) convert_error_OBJECTS = $(am_convert_error_OBJECTS) convert_error_LDADD = $(LDADD) am_copydesc_OBJECTS = copydesc.$(OBJEXT) common.$(OBJEXT) copydesc_OBJECTS = $(am_copydesc_OBJECTS) copydesc_LDADD = $(LDADD) am_cursor1_OBJECTS = cursor1.$(OBJEXT) common.$(OBJEXT) cursor1_OBJECTS = $(am_cursor1_OBJECTS) cursor1_LDADD = $(LDADD) am_cursor2_OBJECTS = cursor2.$(OBJEXT) common.$(OBJEXT) cursor2_OBJECTS = $(am_cursor2_OBJECTS) cursor2_LDADD = $(LDADD) am_cursor3_OBJECTS = cursor3.$(OBJEXT) common.$(OBJEXT) cursor3_OBJECTS = $(am_cursor3_OBJECTS) cursor3_LDADD = $(LDADD) am_cursor4_OBJECTS = cursor4.$(OBJEXT) common.$(OBJEXT) cursor4_OBJECTS = $(am_cursor4_OBJECTS) cursor4_LDADD = $(LDADD) am_cursor5_OBJECTS = cursor5.$(OBJEXT) common.$(OBJEXT) cursor5_OBJECTS = $(am_cursor5_OBJECTS) cursor5_LDADD = $(LDADD) am_cursor6_OBJECTS = cursor6.$(OBJEXT) common.$(OBJEXT) cursor6_OBJECTS = $(am_cursor6_OBJECTS) cursor6_LDADD = $(LDADD) am_cursor7_OBJECTS = cursor7.$(OBJEXT) common.$(OBJEXT) cursor7_OBJECTS = $(am_cursor7_OBJECTS) cursor7_LDADD = $(LDADD) am_data_OBJECTS = data.$(OBJEXT) common.$(OBJEXT) c2string.$(OBJEXT) \ parser.$(OBJEXT) data_OBJECTS = $(am_data_OBJECTS) data_LDADD = $(LDADD) am_date_OBJECTS = date.$(OBJEXT) common.$(OBJEXT) date_OBJECTS = $(am_date_OBJECTS) date_LDADD = $(LDADD) am_descrec_OBJECTS = descrec.$(OBJEXT) common.$(OBJEXT) descrec_OBJECTS = $(am_descrec_OBJECTS) descrec_LDADD = $(LDADD) am_describecol_OBJECTS = describecol.$(OBJEXT) common.$(OBJEXT) \ parser.$(OBJEXT) describecol_OBJECTS = $(am_describecol_OBJECTS) describecol_LDADD = $(LDADD) am_describecol2_OBJECTS = describecol2.$(OBJEXT) common.$(OBJEXT) describecol2_OBJECTS = $(am_describecol2_OBJECTS) describecol2_LDADD = $(LDADD) am_earlybind_OBJECTS = earlybind.$(OBJEXT) common.$(OBJEXT) earlybind_OBJECTS = $(am_earlybind_OBJECTS) earlybind_LDADD = $(LDADD) am_error_OBJECTS = error.$(OBJEXT) common.$(OBJEXT) error_OBJECTS = $(am_error_OBJECTS) error_LDADD = $(LDADD) am_freeclose_OBJECTS = freeclose.$(OBJEXT) common.$(OBJEXT) freeclose_OBJECTS = $(am_freeclose_OBJECTS) freeclose_LDADD = $(LDADD) am_funccall_OBJECTS = funccall.$(OBJEXT) common.$(OBJEXT) funccall_OBJECTS = $(am_funccall_OBJECTS) funccall_LDADD = $(LDADD) am_genparams_OBJECTS = genparams.$(OBJEXT) common.$(OBJEXT) \ c2string.$(OBJEXT) genparams_OBJECTS = $(am_genparams_OBJECTS) genparams_LDADD = $(LDADD) am_getdata_OBJECTS = getdata.$(OBJEXT) common.$(OBJEXT) getdata_OBJECTS = $(am_getdata_OBJECTS) getdata_LDADD = $(LDADD) am_hidden_OBJECTS = hidden.$(OBJEXT) common.$(OBJEXT) hidden_OBJECTS = $(am_hidden_OBJECTS) hidden_LDADD = $(LDADD) am_insert_speed_OBJECTS = insert_speed.$(OBJEXT) common.$(OBJEXT) insert_speed_OBJECTS = $(am_insert_speed_OBJECTS) insert_speed_LDADD = $(LDADD) am_lang_error_OBJECTS = lang_error.$(OBJEXT) common.$(OBJEXT) lang_error_OBJECTS = $(am_lang_error_OBJECTS) lang_error_LDADD = $(LDADD) am_long_error_OBJECTS = long_error.$(OBJEXT) common.$(OBJEXT) long_error_OBJECTS = $(am_long_error_OBJECTS) long_error_LDADD = $(LDADD) am_mars1_OBJECTS = mars1.$(OBJEXT) common.$(OBJEXT) mars1_OBJECTS = $(am_mars1_OBJECTS) mars1_LDADD = $(LDADD) am_moreandcount_OBJECTS = moreandcount.$(OBJEXT) common.$(OBJEXT) moreandcount_OBJECTS = $(am_moreandcount_OBJECTS) moreandcount_LDADD = $(LDADD) am_norowset_OBJECTS = norowset.$(OBJEXT) common.$(OBJEXT) norowset_OBJECTS = $(am_norowset_OBJECTS) norowset_LDADD = $(LDADD) am_oldpwd_OBJECTS = oldpwd-oldpwd.$(OBJEXT) oldpwd-common.$(OBJEXT) oldpwd_OBJECTS = $(am_oldpwd_OBJECTS) oldpwd_LDADD = $(LDADD) am_paramcore_OBJECTS = paramcore.$(OBJEXT) common.$(OBJEXT) paramcore_OBJECTS = $(am_paramcore_OBJECTS) paramcore_LDADD = $(LDADD) am_params_OBJECTS = params.$(OBJEXT) common.$(OBJEXT) params_OBJECTS = $(am_params_OBJECTS) params_LDADD = $(LDADD) am_peter_OBJECTS = peter.$(OBJEXT) common.$(OBJEXT) peter_OBJECTS = $(am_peter_OBJECTS) peter_LDADD = $(LDADD) am_prepare_results_OBJECTS = prepare_results.$(OBJEXT) \ common.$(OBJEXT) prepare_results_OBJECTS = $(am_prepare_results_OBJECTS) prepare_results_LDADD = $(LDADD) am_prepare_warn_OBJECTS = prepare_warn.$(OBJEXT) common.$(OBJEXT) prepare_warn_OBJECTS = $(am_prepare_warn_OBJECTS) prepare_warn_LDADD = $(LDADD) am_prepclose_OBJECTS = prepclose.$(OBJEXT) common.$(OBJEXT) prepclose_OBJECTS = $(am_prepclose_OBJECTS) prepclose_LDADD = $(LDADD) am_preperror_OBJECTS = preperror.$(OBJEXT) common.$(OBJEXT) preperror_OBJECTS = $(am_preperror_OBJECTS) preperror_LDADD = $(LDADD) am_print_OBJECTS = print.$(OBJEXT) common.$(OBJEXT) print_OBJECTS = $(am_print_OBJECTS) print_LDADD = $(LDADD) am_putdata_OBJECTS = putdata.$(OBJEXT) common.$(OBJEXT) putdata_OBJECTS = $(am_putdata_OBJECTS) putdata_LDADD = $(LDADD) am_raiserror_OBJECTS = raiserror.$(OBJEXT) common.$(OBJEXT) raiserror_OBJECTS = $(am_raiserror_OBJECTS) raiserror_LDADD = $(LDADD) am_rebindpar_OBJECTS = rebindpar.$(OBJEXT) common.$(OBJEXT) rebindpar_OBJECTS = $(am_rebindpar_OBJECTS) rebindpar_LDADD = $(LDADD) am_rowset_OBJECTS = rowset.$(OBJEXT) common.$(OBJEXT) rowset_OBJECTS = $(am_rowset_OBJECTS) rowset_LDADD = $(LDADD) am_rpc_OBJECTS = rpc.$(OBJEXT) common.$(OBJEXT) rpc_OBJECTS = $(am_rpc_OBJECTS) rpc_LDADD = $(LDADD) am_scroll_OBJECTS = scroll.$(OBJEXT) common.$(OBJEXT) scroll_OBJECTS = $(am_scroll_OBJECTS) scroll_LDADD = $(LDADD) am_stats_OBJECTS = stats.$(OBJEXT) common.$(OBJEXT) stats_OBJECTS = $(am_stats_OBJECTS) stats_LDADD = $(LDADD) am_t0001_OBJECTS = t0001.$(OBJEXT) common.$(OBJEXT) t0001_OBJECTS = $(am_t0001_OBJECTS) t0001_LDADD = $(LDADD) am_t0002_OBJECTS = t0002.$(OBJEXT) common.$(OBJEXT) t0002_OBJECTS = $(am_t0002_OBJECTS) t0002_LDADD = $(LDADD) am_t0003_OBJECTS = t0003.$(OBJEXT) common.$(OBJEXT) t0003_OBJECTS = $(am_t0003_OBJECTS) t0003_LDADD = $(LDADD) am_t0004_OBJECTS = t0004.$(OBJEXT) common.$(OBJEXT) t0004_OBJECTS = $(am_t0004_OBJECTS) t0004_LDADD = $(LDADD) am_tables_OBJECTS = tables.$(OBJEXT) common.$(OBJEXT) tables_OBJECTS = $(am_tables_OBJECTS) tables_LDADD = $(LDADD) am_test64_OBJECTS = test64.$(OBJEXT) common.$(OBJEXT) test64_OBJECTS = $(am_test64_OBJECTS) test64_LDADD = $(LDADD) am_testodbc_OBJECTS = testodbc.$(OBJEXT) common.$(OBJEXT) testodbc_OBJECTS = $(am_testodbc_OBJECTS) testodbc_LDADD = $(LDADD) am_timeout_OBJECTS = timeout.$(OBJEXT) common.$(OBJEXT) timeout_OBJECTS = $(am_timeout_OBJECTS) timeout_LDADD = $(LDADD) am_timeout2_OBJECTS = timeout2.$(OBJEXT) common.$(OBJEXT) timeout2_OBJECTS = $(am_timeout2_OBJECTS) timeout2_LDADD = $(LDADD) am_timeout3_OBJECTS = timeout3.$(OBJEXT) common.$(OBJEXT) timeout3_OBJECTS = $(am_timeout3_OBJECTS) timeout3_LDADD = $(LDADD) am_timeout4_OBJECTS = timeout4.$(OBJEXT) common.$(OBJEXT) timeout4_OBJECTS = $(am_timeout4_OBJECTS) timeout4_LDADD = $(LDADD) am_transaction_OBJECTS = transaction.$(OBJEXT) common.$(OBJEXT) transaction_OBJECTS = $(am_transaction_OBJECTS) transaction_LDADD = $(LDADD) am_transaction2_OBJECTS = transaction2.$(OBJEXT) common.$(OBJEXT) transaction2_OBJECTS = $(am_transaction2_OBJECTS) transaction2_LDADD = $(LDADD) am_type_OBJECTS = type.$(OBJEXT) common.$(OBJEXT) type_OBJECTS = $(am_type_OBJECTS) type_LDADD = $(LDADD) am_typeinfo_OBJECTS = typeinfo.$(OBJEXT) common.$(OBJEXT) typeinfo_OBJECTS = $(am_typeinfo_OBJECTS) typeinfo_LDADD = $(LDADD) am_utf8_OBJECTS = utf8-utf8.$(OBJEXT) utf8-common.$(OBJEXT) utf8_OBJECTS = $(am_utf8_OBJECTS) utf8_LDADD = $(LDADD) am_utf8_2_OBJECTS = utf8_2.$(OBJEXT) common.$(OBJEXT) utf8_2_OBJECTS = $(am_utf8_2_OBJECTS) utf8_2_LDADD = $(LDADD) am_warning_OBJECTS = warning.$(OBJEXT) common.$(OBJEXT) warning_OBJECTS = $(am_warning_OBJECTS) warning_LDADD = $(LDADD) am_wchar_OBJECTS = wchar.$(OBJEXT) common.$(OBJEXT) wchar_OBJECTS = $(am_wchar_OBJECTS) wchar_LDADD = $(LDADD) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(array_SOURCES) $(array_error_SOURCES) $(array_out_SOURCES) \ $(attributes_SOURCES) $(bcp_SOURCES) $(binary_test_SOURCES) \ $(blob1_SOURCES) $(cancel_SOURCES) $(closestmt_SOURCES) \ $(compute_SOURCES) $(connect_SOURCES) $(connect2_SOURCES) \ $(const_params_SOURCES) $(convert_error_SOURCES) \ $(copydesc_SOURCES) $(cursor1_SOURCES) $(cursor2_SOURCES) \ $(cursor3_SOURCES) $(cursor4_SOURCES) $(cursor5_SOURCES) \ $(cursor6_SOURCES) $(cursor7_SOURCES) $(data_SOURCES) \ $(date_SOURCES) $(descrec_SOURCES) $(describecol_SOURCES) \ $(describecol2_SOURCES) $(earlybind_SOURCES) $(error_SOURCES) \ $(freeclose_SOURCES) $(funccall_SOURCES) $(genparams_SOURCES) \ $(getdata_SOURCES) $(hidden_SOURCES) $(insert_speed_SOURCES) \ $(lang_error_SOURCES) $(long_error_SOURCES) $(mars1_SOURCES) \ $(moreandcount_SOURCES) $(norowset_SOURCES) $(oldpwd_SOURCES) \ $(paramcore_SOURCES) $(params_SOURCES) $(peter_SOURCES) \ $(prepare_results_SOURCES) $(prepare_warn_SOURCES) \ $(prepclose_SOURCES) $(preperror_SOURCES) $(print_SOURCES) \ $(putdata_SOURCES) $(raiserror_SOURCES) $(rebindpar_SOURCES) \ $(rowset_SOURCES) $(rpc_SOURCES) $(scroll_SOURCES) \ $(stats_SOURCES) $(t0001_SOURCES) $(t0002_SOURCES) \ $(t0003_SOURCES) $(t0004_SOURCES) $(tables_SOURCES) \ $(test64_SOURCES) $(testodbc_SOURCES) $(timeout_SOURCES) \ $(timeout2_SOURCES) $(timeout3_SOURCES) $(timeout4_SOURCES) \ $(transaction_SOURCES) $(transaction2_SOURCES) $(type_SOURCES) \ $(typeinfo_SOURCES) $(utf8_SOURCES) $(utf8_2_SOURCES) \ $(warning_SOURCES) $(wchar_SOURCES) DIST_SOURCES = $(array_SOURCES) $(array_error_SOURCES) \ $(array_out_SOURCES) $(attributes_SOURCES) $(bcp_SOURCES) \ $(binary_test_SOURCES) $(blob1_SOURCES) $(cancel_SOURCES) \ $(closestmt_SOURCES) $(compute_SOURCES) $(connect_SOURCES) \ $(connect2_SOURCES) $(const_params_SOURCES) \ $(convert_error_SOURCES) $(copydesc_SOURCES) \ $(cursor1_SOURCES) $(cursor2_SOURCES) $(cursor3_SOURCES) \ $(cursor4_SOURCES) $(cursor5_SOURCES) $(cursor6_SOURCES) \ $(cursor7_SOURCES) $(data_SOURCES) $(date_SOURCES) \ $(descrec_SOURCES) $(describecol_SOURCES) \ $(describecol2_SOURCES) $(earlybind_SOURCES) $(error_SOURCES) \ $(freeclose_SOURCES) $(funccall_SOURCES) $(genparams_SOURCES) \ $(getdata_SOURCES) $(hidden_SOURCES) $(insert_speed_SOURCES) \ $(lang_error_SOURCES) $(long_error_SOURCES) $(mars1_SOURCES) \ $(moreandcount_SOURCES) $(norowset_SOURCES) $(oldpwd_SOURCES) \ $(paramcore_SOURCES) $(params_SOURCES) $(peter_SOURCES) \ $(prepare_results_SOURCES) $(prepare_warn_SOURCES) \ $(prepclose_SOURCES) $(preperror_SOURCES) $(print_SOURCES) \ $(putdata_SOURCES) $(raiserror_SOURCES) $(rebindpar_SOURCES) \ $(rowset_SOURCES) $(rpc_SOURCES) $(scroll_SOURCES) \ $(stats_SOURCES) $(t0001_SOURCES) $(t0002_SOURCES) \ $(t0003_SOURCES) $(t0004_SOURCES) $(tables_SOURCES) \ $(test64_SOURCES) $(testodbc_SOURCES) $(timeout_SOURCES) \ $(timeout2_SOURCES) $(timeout3_SOURCES) $(timeout4_SOURCES) \ $(transaction_SOURCES) $(transaction2_SOURCES) $(type_SOURCES) \ $(typeinfo_SOURCES) $(utf8_SOURCES) $(utf8_2_SOURCES) \ $(warning_SOURCES) $(wchar_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__tty_colors_dummy = \ mgn= red= grn= lgn= blu= brg= std=; \ am__color_tests=no am__tty_colors = { \ $(am__tty_colors_dummy); \ if test "X$(AM_COLOR_TESTS)" = Xno; then \ am__color_tests=no; \ elif test "X$(AM_COLOR_TESTS)" = Xalways; then \ am__color_tests=yes; \ elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \ am__color_tests=yes; \ fi; \ if test $$am__color_tests = yes; then \ red=''; \ grn=''; \ lgn=''; \ blu=''; \ mgn=''; \ brg=''; \ std=''; \ fi; \ } am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__recheck_rx = ^[ ]*:recheck:[ ]* am__global_test_result_rx = ^[ ]*:global-test-result:[ ]* am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]* # A command that, given a newline-separated list of test names on the # standard input, print the name of the tests that are to be re-run # upon "make recheck". am__list_recheck_tests = $(AWK) '{ \ recheck = 1; \ while ((rc = (getline line < ($$0 ".trs"))) != 0) \ { \ if (rc < 0) \ { \ if ((getline line2 < ($$0 ".log")) < 0) \ recheck = 0; \ break; \ } \ else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \ { \ recheck = 0; \ break; \ } \ else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \ { \ break; \ } \ }; \ if (recheck) \ print $$0; \ close ($$0 ".trs"); \ close ($$0 ".log"); \ }' # A command that, given a newline-separated list of test names on the # standard input, create the global log from their .trs and .log files. am__create_global_log = $(AWK) ' \ function fatal(msg) \ { \ print "fatal: making $@: " msg | "cat >&2"; \ exit 1; \ } \ function rst_section(header) \ { \ print header; \ len = length(header); \ for (i = 1; i <= len; i = i + 1) \ printf "="; \ printf "\n\n"; \ } \ { \ copy_in_global_log = 1; \ global_test_result = "RUN"; \ while ((rc = (getline line < ($$0 ".trs"))) != 0) \ { \ if (rc < 0) \ fatal("failed to read from " $$0 ".trs"); \ if (line ~ /$(am__global_test_result_rx)/) \ { \ sub("$(am__global_test_result_rx)", "", line); \ sub("[ ]*$$", "", line); \ global_test_result = line; \ } \ else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \ copy_in_global_log = 0; \ }; \ if (copy_in_global_log) \ { \ rst_section(global_test_result ": " $$0); \ while ((rc = (getline line < ($$0 ".log"))) != 0) \ { \ if (rc < 0) \ fatal("failed to read from " $$0 ".log"); \ print line; \ }; \ printf "\n"; \ }; \ close ($$0 ".trs"); \ close ($$0 ".log"); \ }' # Restructured Text title. am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; } # Solaris 10 'make', and several other traditional 'make' implementations, # pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it # by disabling -e (using the XSI extension "set +e") if it's set. am__sh_e_setup = case $$- in *e*) set +e;; esac # Default flags passed to test drivers. am__common_driver_flags = \ --color-tests "$$am__color_tests" \ --enable-hard-errors "$$am__enable_hard_errors" \ --expect-failure "$$am__expect_failure" # To be inserted before the command running the test. Creates the # directory for the log if needed. Stores in $dir the directory # containing $f, in $tst the test, in $log the log. Executes the # developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and # passes TESTS_ENVIRONMENT. Set up options for the wrapper that # will run the test scripts (or their associated LOG_COMPILER, if # thy have one). am__check_pre = \ $(am__sh_e_setup); \ $(am__vpath_adj_setup) $(am__vpath_adj) \ $(am__tty_colors); \ srcdir=$(srcdir); export srcdir; \ case "$@" in \ */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \ *) am__odir=.;; \ esac; \ test "x$$am__odir" = x"." || test -d "$$am__odir" \ || $(MKDIR_P) "$$am__odir" || exit $$?; \ if test -f "./$$f"; then dir=./; \ elif test -f "$$f"; then dir=; \ else dir="$(srcdir)/"; fi; \ tst=$$dir$$f; log='$@'; \ if test -n '$(DISABLE_HARD_ERRORS)'; then \ am__enable_hard_errors=no; \ else \ am__enable_hard_errors=yes; \ fi; \ case " $(XFAIL_TESTS) " in \ *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \ am__expect_failure=yes;; \ *) \ am__expect_failure=no;; \ esac; \ $(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT) # A shell command to get the names of the tests scripts with any registered # extension removed (i.e., equivalently, the names of the test logs, with # the '.log' extension removed). The result is saved in the shell variable # '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly, # we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)", # since that might cause problem with VPATH rewrites for suffix-less tests. # See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'. am__set_TESTS_bases = \ bases='$(TEST_LOGS)'; \ bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ bases=`echo $$bases` RECHECK_LOGS = $(TEST_LOGS) AM_RECURSIVE_TARGETS = check recheck TEST_SUITE_LOG = test-suite.log TEST_EXTENSIONS = @EXEEXT@ .test LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS) am__set_b = \ case '$@' in \ */*) \ case '$*' in \ */*) b='$*';; \ *) b=`echo '$@' | sed 's/\.log$$//'`; \ esac;; \ *) \ b='$*';; \ esac am__test_logs1 = $(TESTS:=.log) am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log) TEST_LOGS = $(am__test_logs2:.test.log=.log) TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \ $(TEST_LOG_FLAGS) am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp \ $(top_srcdir)/mkinstalldirs $(top_srcdir)/test-driver DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BUILD_NUMBER = @BUILD_NUMBER@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOXYGEN = @DOXYGEN@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FREETDS_LIBGCC = @FREETDS_LIBGCC@ FREETDS_ODBC_MODULE = @FREETDS_ODBC_MODULE@ FREETDS_SYMBOLIC = @FREETDS_SYMBOLIC@ GCRYPT_CFLAGS = @GCRYPT_CFLAGS@ GCRYPT_LIBS = @GCRYPT_LIBS@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ HAVE_OPENSSL = @HAVE_OPENSSL@ HAVE_PERL_SOURCES = @HAVE_PERL_SOURCES@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBADD_DL = @LIBADD_DL@ LIBADD_DLD_LINK = @LIBADD_DLD_LINK@ LIBADD_DLOPEN = @LIBADD_DLOPEN@ LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@ LIBICONV = @LIBICONV@ LIBOBJS = @LIBOBJS@ LIBS = $(ODBCLIB) $(ODBCNODMLIB) ../../replacements/libreplacements.la \ $(NETWORK_LIBS) $(am__append_1) LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBOBJS = @LTLIBOBJS@ LT_DLLOADERS = @LT_DLLOADERS@ LT_DLPREOPEN = @LT_DLPREOPEN@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ NETTLE_CFLAGS = @NETTLE_CFLAGS@ NETTLE_LIBS = @NETTLE_LIBS@ NETWORK_LIBS = @NETWORK_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ODBC = @ODBC@ ODBCINSTLIB = @ODBCINSTLIB@ ODBCLIB = @ODBCLIB@ ODBCNODMLIB = @ODBCNODMLIB@ ODBCNODMLIBAPP = @ODBCNODMLIBAPP@ ODBC_CONFIG = @ODBC_CONFIG@ ODBC_INC = @ODBC_INC@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ RC = @RC@ READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SUBVERSION = @SUBVERSION@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ dblib_define = @dblib_define@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ tds_sysdep_int16_type = @tds_sysdep_int16_type@ tds_sysdep_int32_type = @tds_sysdep_int32_type@ tds_sysdep_int64_type = @tds_sysdep_int64_type@ tds_sysdep_intptr_type = @tds_sysdep_intptr_type@ tds_sysdep_real32_type = @tds_sysdep_real32_type@ tds_sysdep_real64_type = @tds_sysdep_real64_type@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # $Id: Makefile.am,v 1.87 2012-03-06 20:40:12 freddy77 Exp $ TESTS = \ t0001$(EXEEXT) t0002$(EXEEXT) t0003$(EXEEXT)\ t0004$(EXEEXT) connect$(EXEEXT) print$(EXEEXT)\ date$(EXEEXT) norowset$(EXEEXT) funccall$(EXEEXT)\ lang_error$(EXEEXT) tables$(EXEEXT)\ binary_test$(EXEEXT) moreandcount$(EXEEXT)\ earlybind$(EXEEXT) putdata$(EXEEXT) params$(EXEEXT)\ raiserror$(EXEEXT) getdata$(EXEEXT)\ transaction$(EXEEXT) type$(EXEEXT) genparams$(EXEEXT)\ preperror$(EXEEXT) prepare_results$(EXEEXT)\ testodbc$(EXEEXT) data$(EXEEXT) error$(EXEEXT)\ rebindpar$(EXEEXT) rpc$(EXEEXT) convert_error$(EXEEXT)\ typeinfo$(EXEEXT) const_params$(EXEEXT)\ insert_speed$(EXEEXT) compute$(EXEEXT)\ timeout$(EXEEXT) array$(EXEEXT) array_out$(EXEEXT)\ cursor1$(EXEEXT) scroll$(EXEEXT) cursor2$(EXEEXT)\ describecol$(EXEEXT) copydesc$(EXEEXT)\ prepclose$(EXEEXT) warning$(EXEEXT) \ paramcore$(EXEEXT) timeout2$(EXEEXT) timeout3$(EXEEXT) \ connect2$(EXEEXT) timeout4$(EXEEXT) freeclose$(EXEEXT) \ cursor3$(EXEEXT) cursor4$(EXEEXT) cursor5$(EXEEXT) \ attributes$(EXEEXT) hidden$(EXEEXT) blob1$(EXEEXT) \ cancel$(EXEEXT) wchar$(EXEEXT) rowset$(EXEEXT) transaction2$(EXEEXT) \ cursor6$(EXEEXT) cursor7$(EXEEXT) utf8$(EXEEXT) utf8_2$(EXEEXT) \ stats$(EXEEXT) descrec$(EXEEXT) peter$(EXEEXT) test64$(EXEEXT) \ prepare_warn$(EXEEXT) long_error$(EXEEXT) mars1$(EXEEXT) \ array_error$(EXEEXT) describecol2$(EXEEXT) closestmt$(EXEEXT) bcp$(EXEEXT) check_PROGRAMS = $(TESTS) oldpwd$(EXEEXT) t0001_SOURCES = t0001.c common.c common.h t0002_SOURCES = t0002.c common.c common.h t0003_SOURCES = t0003.c common.c common.h t0004_SOURCES = t0004.c common.c common.h connect_SOURCES = connect.c common.c common.h connect_LDFLAGS = $(ODBCINSTLIB) -no-install print_SOURCES = print.c common.c common.h date_SOURCES = date.c common.c common.h norowset_SOURCES = norowset.c common.c common.h funccall_SOURCES = funccall.c common.c common.h lang_error_SOURCES = lang_error.c common.c common.h tables_SOURCES = tables.c common.c common.h binary_test_SOURCES = binary_test.c common.c common.h moreandcount_SOURCES = moreandcount.c common.c common.h earlybind_SOURCES = earlybind.c common.c common.h putdata_SOURCES = putdata.c common.c common.h params_SOURCES = params.c common.c common.h raiserror_SOURCES = raiserror.c common.c common.h getdata_SOURCES = getdata.c common.c common.h type_SOURCES = type.c common.c common.h transaction_SOURCES = transaction.c common.c common.h genparams_SOURCES = genparams.c common.c common.h c2string.c preperror_SOURCES = preperror.c common.c common.h prepare_results_SOURCES = prepare_results.c common.c common.h testodbc_SOURCES = testodbc.c common.c common.h data_SOURCES = data.c common.c common.h c2string.c parser.c parser.h error_SOURCES = error.c common.c common.h rebindpar_SOURCES = rebindpar.c common.c common.h rpc_SOURCES = rpc.c common.c common.h convert_error_SOURCES = convert_error.c common.c common.h typeinfo_SOURCES = typeinfo.c common.c common.h const_params_SOURCES = const_params.c common.c common.h insert_speed_SOURCES = insert_speed.c common.c common.h compute_SOURCES = compute.c common.c common.h timeout_SOURCES = timeout.c common.c common.h array_SOURCES = array.c common.c common.h array_out_SOURCES = array_out.c common.c common.h cursor1_SOURCES = cursor1.c common.c common.h scroll_SOURCES = scroll.c common.c common.h cursor2_SOURCES = cursor2.c common.c common.h describecol_SOURCES = describecol.c common.c common.h parser.c parser.h describecol2_SOURCES = describecol2.c common.c common.h copydesc_SOURCES = copydesc.c common.c common.h prepclose_SOURCES = prepclose.c common.c common.h warning_SOURCES = warning.c common.c common.h paramcore_SOURCES = paramcore.c common.c common.h timeout2_SOURCES = timeout2.c common.c common.h timeout3_SOURCES = timeout3.c common.c common.h connect2_SOURCES = connect2.c common.c common.h timeout4_SOURCES = timeout4.c common.c common.h freeclose_SOURCES = freeclose.c common.c common.h cursor3_SOURCES = cursor3.c common.c common.h cursor4_SOURCES = cursor4.c common.c common.h cursor5_SOURCES = cursor5.c common.c common.h attributes_SOURCES = attributes.c common.c common.h hidden_SOURCES = hidden.c common.c common.h blob1_SOURCES = blob1.c common.c common.h rowset_SOURCES = rowset.c common.c common.h cancel_SOURCES = cancel.c common.c common.h wchar_SOURCES = wchar.c common.c common.h transaction2_SOURCES = transaction2.c common.c common.h cursor6_SOURCES = cursor6.c common.c common.h cursor7_SOURCES = cursor7.c common.c common.h utf8_SOURCES = utf8.c common.c common.h utf8_2_SOURCES = utf8_2.c common.c common.h stats_SOURCES = stats.c common.c common.h descrec_SOURCES = descrec.c common.c common.h peter_SOURCES = peter.c common.c common.h test64_SOURCES = test64.c common.c common.h prepare_warn_SOURCES = prepare_warn.c common.c common.h long_error_SOURCES = long_error.c common.c common.h mars1_SOURCES = mars1.c common.c common.h array_error_SOURCES = array_error.c common.c common.h closestmt_SOURCES = closestmt.c common.c common.h oldpwd_SOURCES = oldpwd.c common.c common.h bcp_SOURCES = bcp.c common.c common.h GLOBAL_CPPFLAGS = -I$(top_srcdir)/include $(ODBC_INC) -DFREETDS_TOPDIR=\"$(top_srcdir)\" @ODBC_WIDE_TESTS_FALSE@AM_CPPFLAGS = $(GLOBAL_CPPFLAGS) @ODBC_WIDE_TESTS_TRUE@AM_CPPFLAGS = $(GLOBAL_CPPFLAGS) -DUNICODE -D_UNICODE # this test cannot work using wide characters as use UTF-8 and single byte encoding utf8_CPPFLAGS = $(GLOBAL_CPPFLAGS) oldpwd_CPPFLAGS = $(GLOBAL_CPPFLAGS) @MINGW32_FALSE@AM_LDFLAGS = -no-install -L../.libs -R $(abs_builddir)/../.libs @MINGW32_TRUE@AM_LDFLAGS = -no-fast-install DISTCLEANFILES = odbc.ini odbcinst.ini EXTRA_DIST = data.in describecol.in attributes.in CMakeLists.txt all: all-am .SUFFIXES: .SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/odbc/unittests/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/odbc/unittests/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-checkPROGRAMS: @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list array$(EXEEXT): $(array_OBJECTS) $(array_DEPENDENCIES) $(EXTRA_array_DEPENDENCIES) @rm -f array$(EXEEXT) $(AM_V_CCLD)$(LINK) $(array_OBJECTS) $(array_LDADD) $(LIBS) array_error$(EXEEXT): $(array_error_OBJECTS) $(array_error_DEPENDENCIES) $(EXTRA_array_error_DEPENDENCIES) @rm -f array_error$(EXEEXT) $(AM_V_CCLD)$(LINK) $(array_error_OBJECTS) $(array_error_LDADD) $(LIBS) array_out$(EXEEXT): $(array_out_OBJECTS) $(array_out_DEPENDENCIES) $(EXTRA_array_out_DEPENDENCIES) @rm -f array_out$(EXEEXT) $(AM_V_CCLD)$(LINK) $(array_out_OBJECTS) $(array_out_LDADD) $(LIBS) attributes$(EXEEXT): $(attributes_OBJECTS) $(attributes_DEPENDENCIES) $(EXTRA_attributes_DEPENDENCIES) @rm -f attributes$(EXEEXT) $(AM_V_CCLD)$(LINK) $(attributes_OBJECTS) $(attributes_LDADD) $(LIBS) bcp$(EXEEXT): $(bcp_OBJECTS) $(bcp_DEPENDENCIES) $(EXTRA_bcp_DEPENDENCIES) @rm -f bcp$(EXEEXT) $(AM_V_CCLD)$(LINK) $(bcp_OBJECTS) $(bcp_LDADD) $(LIBS) binary_test$(EXEEXT): $(binary_test_OBJECTS) $(binary_test_DEPENDENCIES) $(EXTRA_binary_test_DEPENDENCIES) @rm -f binary_test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(binary_test_OBJECTS) $(binary_test_LDADD) $(LIBS) blob1$(EXEEXT): $(blob1_OBJECTS) $(blob1_DEPENDENCIES) $(EXTRA_blob1_DEPENDENCIES) @rm -f blob1$(EXEEXT) $(AM_V_CCLD)$(LINK) $(blob1_OBJECTS) $(blob1_LDADD) $(LIBS) cancel$(EXEEXT): $(cancel_OBJECTS) $(cancel_DEPENDENCIES) $(EXTRA_cancel_DEPENDENCIES) @rm -f cancel$(EXEEXT) $(AM_V_CCLD)$(LINK) $(cancel_OBJECTS) $(cancel_LDADD) $(LIBS) closestmt$(EXEEXT): $(closestmt_OBJECTS) $(closestmt_DEPENDENCIES) $(EXTRA_closestmt_DEPENDENCIES) @rm -f closestmt$(EXEEXT) $(AM_V_CCLD)$(LINK) $(closestmt_OBJECTS) $(closestmt_LDADD) $(LIBS) compute$(EXEEXT): $(compute_OBJECTS) $(compute_DEPENDENCIES) $(EXTRA_compute_DEPENDENCIES) @rm -f compute$(EXEEXT) $(AM_V_CCLD)$(LINK) $(compute_OBJECTS) $(compute_LDADD) $(LIBS) connect$(EXEEXT): $(connect_OBJECTS) $(connect_DEPENDENCIES) $(EXTRA_connect_DEPENDENCIES) @rm -f connect$(EXEEXT) $(AM_V_CCLD)$(connect_LINK) $(connect_OBJECTS) $(connect_LDADD) $(LIBS) connect2$(EXEEXT): $(connect2_OBJECTS) $(connect2_DEPENDENCIES) $(EXTRA_connect2_DEPENDENCIES) @rm -f connect2$(EXEEXT) $(AM_V_CCLD)$(LINK) $(connect2_OBJECTS) $(connect2_LDADD) $(LIBS) const_params$(EXEEXT): $(const_params_OBJECTS) $(const_params_DEPENDENCIES) $(EXTRA_const_params_DEPENDENCIES) @rm -f const_params$(EXEEXT) $(AM_V_CCLD)$(LINK) $(const_params_OBJECTS) $(const_params_LDADD) $(LIBS) convert_error$(EXEEXT): $(convert_error_OBJECTS) $(convert_error_DEPENDENCIES) $(EXTRA_convert_error_DEPENDENCIES) @rm -f convert_error$(EXEEXT) $(AM_V_CCLD)$(LINK) $(convert_error_OBJECTS) $(convert_error_LDADD) $(LIBS) copydesc$(EXEEXT): $(copydesc_OBJECTS) $(copydesc_DEPENDENCIES) $(EXTRA_copydesc_DEPENDENCIES) @rm -f copydesc$(EXEEXT) $(AM_V_CCLD)$(LINK) $(copydesc_OBJECTS) $(copydesc_LDADD) $(LIBS) cursor1$(EXEEXT): $(cursor1_OBJECTS) $(cursor1_DEPENDENCIES) $(EXTRA_cursor1_DEPENDENCIES) @rm -f cursor1$(EXEEXT) $(AM_V_CCLD)$(LINK) $(cursor1_OBJECTS) $(cursor1_LDADD) $(LIBS) cursor2$(EXEEXT): $(cursor2_OBJECTS) $(cursor2_DEPENDENCIES) $(EXTRA_cursor2_DEPENDENCIES) @rm -f cursor2$(EXEEXT) $(AM_V_CCLD)$(LINK) $(cursor2_OBJECTS) $(cursor2_LDADD) $(LIBS) cursor3$(EXEEXT): $(cursor3_OBJECTS) $(cursor3_DEPENDENCIES) $(EXTRA_cursor3_DEPENDENCIES) @rm -f cursor3$(EXEEXT) $(AM_V_CCLD)$(LINK) $(cursor3_OBJECTS) $(cursor3_LDADD) $(LIBS) cursor4$(EXEEXT): $(cursor4_OBJECTS) $(cursor4_DEPENDENCIES) $(EXTRA_cursor4_DEPENDENCIES) @rm -f cursor4$(EXEEXT) $(AM_V_CCLD)$(LINK) $(cursor4_OBJECTS) $(cursor4_LDADD) $(LIBS) cursor5$(EXEEXT): $(cursor5_OBJECTS) $(cursor5_DEPENDENCIES) $(EXTRA_cursor5_DEPENDENCIES) @rm -f cursor5$(EXEEXT) $(AM_V_CCLD)$(LINK) $(cursor5_OBJECTS) $(cursor5_LDADD) $(LIBS) cursor6$(EXEEXT): $(cursor6_OBJECTS) $(cursor6_DEPENDENCIES) $(EXTRA_cursor6_DEPENDENCIES) @rm -f cursor6$(EXEEXT) $(AM_V_CCLD)$(LINK) $(cursor6_OBJECTS) $(cursor6_LDADD) $(LIBS) cursor7$(EXEEXT): $(cursor7_OBJECTS) $(cursor7_DEPENDENCIES) $(EXTRA_cursor7_DEPENDENCIES) @rm -f cursor7$(EXEEXT) $(AM_V_CCLD)$(LINK) $(cursor7_OBJECTS) $(cursor7_LDADD) $(LIBS) data$(EXEEXT): $(data_OBJECTS) $(data_DEPENDENCIES) $(EXTRA_data_DEPENDENCIES) @rm -f data$(EXEEXT) $(AM_V_CCLD)$(LINK) $(data_OBJECTS) $(data_LDADD) $(LIBS) date$(EXEEXT): $(date_OBJECTS) $(date_DEPENDENCIES) $(EXTRA_date_DEPENDENCIES) @rm -f date$(EXEEXT) $(AM_V_CCLD)$(LINK) $(date_OBJECTS) $(date_LDADD) $(LIBS) descrec$(EXEEXT): $(descrec_OBJECTS) $(descrec_DEPENDENCIES) $(EXTRA_descrec_DEPENDENCIES) @rm -f descrec$(EXEEXT) $(AM_V_CCLD)$(LINK) $(descrec_OBJECTS) $(descrec_LDADD) $(LIBS) describecol$(EXEEXT): $(describecol_OBJECTS) $(describecol_DEPENDENCIES) $(EXTRA_describecol_DEPENDENCIES) @rm -f describecol$(EXEEXT) $(AM_V_CCLD)$(LINK) $(describecol_OBJECTS) $(describecol_LDADD) $(LIBS) describecol2$(EXEEXT): $(describecol2_OBJECTS) $(describecol2_DEPENDENCIES) $(EXTRA_describecol2_DEPENDENCIES) @rm -f describecol2$(EXEEXT) $(AM_V_CCLD)$(LINK) $(describecol2_OBJECTS) $(describecol2_LDADD) $(LIBS) earlybind$(EXEEXT): $(earlybind_OBJECTS) $(earlybind_DEPENDENCIES) $(EXTRA_earlybind_DEPENDENCIES) @rm -f earlybind$(EXEEXT) $(AM_V_CCLD)$(LINK) $(earlybind_OBJECTS) $(earlybind_LDADD) $(LIBS) error$(EXEEXT): $(error_OBJECTS) $(error_DEPENDENCIES) $(EXTRA_error_DEPENDENCIES) @rm -f error$(EXEEXT) $(AM_V_CCLD)$(LINK) $(error_OBJECTS) $(error_LDADD) $(LIBS) freeclose$(EXEEXT): $(freeclose_OBJECTS) $(freeclose_DEPENDENCIES) $(EXTRA_freeclose_DEPENDENCIES) @rm -f freeclose$(EXEEXT) $(AM_V_CCLD)$(LINK) $(freeclose_OBJECTS) $(freeclose_LDADD) $(LIBS) funccall$(EXEEXT): $(funccall_OBJECTS) $(funccall_DEPENDENCIES) $(EXTRA_funccall_DEPENDENCIES) @rm -f funccall$(EXEEXT) $(AM_V_CCLD)$(LINK) $(funccall_OBJECTS) $(funccall_LDADD) $(LIBS) genparams$(EXEEXT): $(genparams_OBJECTS) $(genparams_DEPENDENCIES) $(EXTRA_genparams_DEPENDENCIES) @rm -f genparams$(EXEEXT) $(AM_V_CCLD)$(LINK) $(genparams_OBJECTS) $(genparams_LDADD) $(LIBS) getdata$(EXEEXT): $(getdata_OBJECTS) $(getdata_DEPENDENCIES) $(EXTRA_getdata_DEPENDENCIES) @rm -f getdata$(EXEEXT) $(AM_V_CCLD)$(LINK) $(getdata_OBJECTS) $(getdata_LDADD) $(LIBS) hidden$(EXEEXT): $(hidden_OBJECTS) $(hidden_DEPENDENCIES) $(EXTRA_hidden_DEPENDENCIES) @rm -f hidden$(EXEEXT) $(AM_V_CCLD)$(LINK) $(hidden_OBJECTS) $(hidden_LDADD) $(LIBS) insert_speed$(EXEEXT): $(insert_speed_OBJECTS) $(insert_speed_DEPENDENCIES) $(EXTRA_insert_speed_DEPENDENCIES) @rm -f insert_speed$(EXEEXT) $(AM_V_CCLD)$(LINK) $(insert_speed_OBJECTS) $(insert_speed_LDADD) $(LIBS) lang_error$(EXEEXT): $(lang_error_OBJECTS) $(lang_error_DEPENDENCIES) $(EXTRA_lang_error_DEPENDENCIES) @rm -f lang_error$(EXEEXT) $(AM_V_CCLD)$(LINK) $(lang_error_OBJECTS) $(lang_error_LDADD) $(LIBS) long_error$(EXEEXT): $(long_error_OBJECTS) $(long_error_DEPENDENCIES) $(EXTRA_long_error_DEPENDENCIES) @rm -f long_error$(EXEEXT) $(AM_V_CCLD)$(LINK) $(long_error_OBJECTS) $(long_error_LDADD) $(LIBS) mars1$(EXEEXT): $(mars1_OBJECTS) $(mars1_DEPENDENCIES) $(EXTRA_mars1_DEPENDENCIES) @rm -f mars1$(EXEEXT) $(AM_V_CCLD)$(LINK) $(mars1_OBJECTS) $(mars1_LDADD) $(LIBS) moreandcount$(EXEEXT): $(moreandcount_OBJECTS) $(moreandcount_DEPENDENCIES) $(EXTRA_moreandcount_DEPENDENCIES) @rm -f moreandcount$(EXEEXT) $(AM_V_CCLD)$(LINK) $(moreandcount_OBJECTS) $(moreandcount_LDADD) $(LIBS) norowset$(EXEEXT): $(norowset_OBJECTS) $(norowset_DEPENDENCIES) $(EXTRA_norowset_DEPENDENCIES) @rm -f norowset$(EXEEXT) $(AM_V_CCLD)$(LINK) $(norowset_OBJECTS) $(norowset_LDADD) $(LIBS) oldpwd$(EXEEXT): $(oldpwd_OBJECTS) $(oldpwd_DEPENDENCIES) $(EXTRA_oldpwd_DEPENDENCIES) @rm -f oldpwd$(EXEEXT) $(AM_V_CCLD)$(LINK) $(oldpwd_OBJECTS) $(oldpwd_LDADD) $(LIBS) paramcore$(EXEEXT): $(paramcore_OBJECTS) $(paramcore_DEPENDENCIES) $(EXTRA_paramcore_DEPENDENCIES) @rm -f paramcore$(EXEEXT) $(AM_V_CCLD)$(LINK) $(paramcore_OBJECTS) $(paramcore_LDADD) $(LIBS) params$(EXEEXT): $(params_OBJECTS) $(params_DEPENDENCIES) $(EXTRA_params_DEPENDENCIES) @rm -f params$(EXEEXT) $(AM_V_CCLD)$(LINK) $(params_OBJECTS) $(params_LDADD) $(LIBS) peter$(EXEEXT): $(peter_OBJECTS) $(peter_DEPENDENCIES) $(EXTRA_peter_DEPENDENCIES) @rm -f peter$(EXEEXT) $(AM_V_CCLD)$(LINK) $(peter_OBJECTS) $(peter_LDADD) $(LIBS) prepare_results$(EXEEXT): $(prepare_results_OBJECTS) $(prepare_results_DEPENDENCIES) $(EXTRA_prepare_results_DEPENDENCIES) @rm -f prepare_results$(EXEEXT) $(AM_V_CCLD)$(LINK) $(prepare_results_OBJECTS) $(prepare_results_LDADD) $(LIBS) prepare_warn$(EXEEXT): $(prepare_warn_OBJECTS) $(prepare_warn_DEPENDENCIES) $(EXTRA_prepare_warn_DEPENDENCIES) @rm -f prepare_warn$(EXEEXT) $(AM_V_CCLD)$(LINK) $(prepare_warn_OBJECTS) $(prepare_warn_LDADD) $(LIBS) prepclose$(EXEEXT): $(prepclose_OBJECTS) $(prepclose_DEPENDENCIES) $(EXTRA_prepclose_DEPENDENCIES) @rm -f prepclose$(EXEEXT) $(AM_V_CCLD)$(LINK) $(prepclose_OBJECTS) $(prepclose_LDADD) $(LIBS) preperror$(EXEEXT): $(preperror_OBJECTS) $(preperror_DEPENDENCIES) $(EXTRA_preperror_DEPENDENCIES) @rm -f preperror$(EXEEXT) $(AM_V_CCLD)$(LINK) $(preperror_OBJECTS) $(preperror_LDADD) $(LIBS) print$(EXEEXT): $(print_OBJECTS) $(print_DEPENDENCIES) $(EXTRA_print_DEPENDENCIES) @rm -f print$(EXEEXT) $(AM_V_CCLD)$(LINK) $(print_OBJECTS) $(print_LDADD) $(LIBS) putdata$(EXEEXT): $(putdata_OBJECTS) $(putdata_DEPENDENCIES) $(EXTRA_putdata_DEPENDENCIES) @rm -f putdata$(EXEEXT) $(AM_V_CCLD)$(LINK) $(putdata_OBJECTS) $(putdata_LDADD) $(LIBS) raiserror$(EXEEXT): $(raiserror_OBJECTS) $(raiserror_DEPENDENCIES) $(EXTRA_raiserror_DEPENDENCIES) @rm -f raiserror$(EXEEXT) $(AM_V_CCLD)$(LINK) $(raiserror_OBJECTS) $(raiserror_LDADD) $(LIBS) rebindpar$(EXEEXT): $(rebindpar_OBJECTS) $(rebindpar_DEPENDENCIES) $(EXTRA_rebindpar_DEPENDENCIES) @rm -f rebindpar$(EXEEXT) $(AM_V_CCLD)$(LINK) $(rebindpar_OBJECTS) $(rebindpar_LDADD) $(LIBS) rowset$(EXEEXT): $(rowset_OBJECTS) $(rowset_DEPENDENCIES) $(EXTRA_rowset_DEPENDENCIES) @rm -f rowset$(EXEEXT) $(AM_V_CCLD)$(LINK) $(rowset_OBJECTS) $(rowset_LDADD) $(LIBS) rpc$(EXEEXT): $(rpc_OBJECTS) $(rpc_DEPENDENCIES) $(EXTRA_rpc_DEPENDENCIES) @rm -f rpc$(EXEEXT) $(AM_V_CCLD)$(LINK) $(rpc_OBJECTS) $(rpc_LDADD) $(LIBS) scroll$(EXEEXT): $(scroll_OBJECTS) $(scroll_DEPENDENCIES) $(EXTRA_scroll_DEPENDENCIES) @rm -f scroll$(EXEEXT) $(AM_V_CCLD)$(LINK) $(scroll_OBJECTS) $(scroll_LDADD) $(LIBS) stats$(EXEEXT): $(stats_OBJECTS) $(stats_DEPENDENCIES) $(EXTRA_stats_DEPENDENCIES) @rm -f stats$(EXEEXT) $(AM_V_CCLD)$(LINK) $(stats_OBJECTS) $(stats_LDADD) $(LIBS) t0001$(EXEEXT): $(t0001_OBJECTS) $(t0001_DEPENDENCIES) $(EXTRA_t0001_DEPENDENCIES) @rm -f t0001$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0001_OBJECTS) $(t0001_LDADD) $(LIBS) t0002$(EXEEXT): $(t0002_OBJECTS) $(t0002_DEPENDENCIES) $(EXTRA_t0002_DEPENDENCIES) @rm -f t0002$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0002_OBJECTS) $(t0002_LDADD) $(LIBS) t0003$(EXEEXT): $(t0003_OBJECTS) $(t0003_DEPENDENCIES) $(EXTRA_t0003_DEPENDENCIES) @rm -f t0003$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0003_OBJECTS) $(t0003_LDADD) $(LIBS) t0004$(EXEEXT): $(t0004_OBJECTS) $(t0004_DEPENDENCIES) $(EXTRA_t0004_DEPENDENCIES) @rm -f t0004$(EXEEXT) $(AM_V_CCLD)$(LINK) $(t0004_OBJECTS) $(t0004_LDADD) $(LIBS) tables$(EXEEXT): $(tables_OBJECTS) $(tables_DEPENDENCIES) $(EXTRA_tables_DEPENDENCIES) @rm -f tables$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tables_OBJECTS) $(tables_LDADD) $(LIBS) test64$(EXEEXT): $(test64_OBJECTS) $(test64_DEPENDENCIES) $(EXTRA_test64_DEPENDENCIES) @rm -f test64$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test64_OBJECTS) $(test64_LDADD) $(LIBS) testodbc$(EXEEXT): $(testodbc_OBJECTS) $(testodbc_DEPENDENCIES) $(EXTRA_testodbc_DEPENDENCIES) @rm -f testodbc$(EXEEXT) $(AM_V_CCLD)$(LINK) $(testodbc_OBJECTS) $(testodbc_LDADD) $(LIBS) timeout$(EXEEXT): $(timeout_OBJECTS) $(timeout_DEPENDENCIES) $(EXTRA_timeout_DEPENDENCIES) @rm -f timeout$(EXEEXT) $(AM_V_CCLD)$(LINK) $(timeout_OBJECTS) $(timeout_LDADD) $(LIBS) timeout2$(EXEEXT): $(timeout2_OBJECTS) $(timeout2_DEPENDENCIES) $(EXTRA_timeout2_DEPENDENCIES) @rm -f timeout2$(EXEEXT) $(AM_V_CCLD)$(LINK) $(timeout2_OBJECTS) $(timeout2_LDADD) $(LIBS) timeout3$(EXEEXT): $(timeout3_OBJECTS) $(timeout3_DEPENDENCIES) $(EXTRA_timeout3_DEPENDENCIES) @rm -f timeout3$(EXEEXT) $(AM_V_CCLD)$(LINK) $(timeout3_OBJECTS) $(timeout3_LDADD) $(LIBS) timeout4$(EXEEXT): $(timeout4_OBJECTS) $(timeout4_DEPENDENCIES) $(EXTRA_timeout4_DEPENDENCIES) @rm -f timeout4$(EXEEXT) $(AM_V_CCLD)$(LINK) $(timeout4_OBJECTS) $(timeout4_LDADD) $(LIBS) transaction$(EXEEXT): $(transaction_OBJECTS) $(transaction_DEPENDENCIES) $(EXTRA_transaction_DEPENDENCIES) @rm -f transaction$(EXEEXT) $(AM_V_CCLD)$(LINK) $(transaction_OBJECTS) $(transaction_LDADD) $(LIBS) transaction2$(EXEEXT): $(transaction2_OBJECTS) $(transaction2_DEPENDENCIES) $(EXTRA_transaction2_DEPENDENCIES) @rm -f transaction2$(EXEEXT) $(AM_V_CCLD)$(LINK) $(transaction2_OBJECTS) $(transaction2_LDADD) $(LIBS) type$(EXEEXT): $(type_OBJECTS) $(type_DEPENDENCIES) $(EXTRA_type_DEPENDENCIES) @rm -f type$(EXEEXT) $(AM_V_CCLD)$(LINK) $(type_OBJECTS) $(type_LDADD) $(LIBS) typeinfo$(EXEEXT): $(typeinfo_OBJECTS) $(typeinfo_DEPENDENCIES) $(EXTRA_typeinfo_DEPENDENCIES) @rm -f typeinfo$(EXEEXT) $(AM_V_CCLD)$(LINK) $(typeinfo_OBJECTS) $(typeinfo_LDADD) $(LIBS) utf8$(EXEEXT): $(utf8_OBJECTS) $(utf8_DEPENDENCIES) $(EXTRA_utf8_DEPENDENCIES) @rm -f utf8$(EXEEXT) $(AM_V_CCLD)$(LINK) $(utf8_OBJECTS) $(utf8_LDADD) $(LIBS) utf8_2$(EXEEXT): $(utf8_2_OBJECTS) $(utf8_2_DEPENDENCIES) $(EXTRA_utf8_2_DEPENDENCIES) @rm -f utf8_2$(EXEEXT) $(AM_V_CCLD)$(LINK) $(utf8_2_OBJECTS) $(utf8_2_LDADD) $(LIBS) warning$(EXEEXT): $(warning_OBJECTS) $(warning_DEPENDENCIES) $(EXTRA_warning_DEPENDENCIES) @rm -f warning$(EXEEXT) $(AM_V_CCLD)$(LINK) $(warning_OBJECTS) $(warning_LDADD) $(LIBS) wchar$(EXEEXT): $(wchar_OBJECTS) $(wchar_DEPENDENCIES) $(EXTRA_wchar_DEPENDENCIES) @rm -f wchar$(EXEEXT) $(AM_V_CCLD)$(LINK) $(wchar_OBJECTS) $(wchar_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/array.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/array_error.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/array_out.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/attributes.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bcp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/binary_test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/blob1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/c2string.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cancel.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/closestmt.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/common.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/compute.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/connect.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/connect2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/const_params.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/convert_error.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/copydesc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cursor1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cursor2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cursor3.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cursor4.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cursor5.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cursor6.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cursor7.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/data.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/date.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/descrec.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/describecol.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/describecol2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earlybind.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/error.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/freeclose.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/funccall.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/genparams.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getdata.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hidden.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/insert_speed.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lang_error.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/long_error.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mars1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/moreandcount.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/norowset.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/oldpwd-common.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/oldpwd-oldpwd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/paramcore.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/params.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parser.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/peter.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/prepare_results.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/prepare_warn.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/prepclose.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/preperror.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/print.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/putdata.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/raiserror.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rebindpar.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rowset.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rpc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scroll.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stats.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0001.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0002.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0003.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t0004.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tables.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test64.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testodbc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timeout.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timeout2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timeout3.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timeout4.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/transaction.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/transaction2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/type.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/typeinfo.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utf8-common.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utf8-utf8.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utf8_2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/warning.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wchar.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< oldpwd-oldpwd.o: oldpwd.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(oldpwd_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT oldpwd-oldpwd.o -MD -MP -MF $(DEPDIR)/oldpwd-oldpwd.Tpo -c -o oldpwd-oldpwd.o `test -f 'oldpwd.c' || echo '$(srcdir)/'`oldpwd.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/oldpwd-oldpwd.Tpo $(DEPDIR)/oldpwd-oldpwd.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='oldpwd.c' object='oldpwd-oldpwd.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(oldpwd_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o oldpwd-oldpwd.o `test -f 'oldpwd.c' || echo '$(srcdir)/'`oldpwd.c oldpwd-oldpwd.obj: oldpwd.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(oldpwd_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT oldpwd-oldpwd.obj -MD -MP -MF $(DEPDIR)/oldpwd-oldpwd.Tpo -c -o oldpwd-oldpwd.obj `if test -f 'oldpwd.c'; then $(CYGPATH_W) 'oldpwd.c'; else $(CYGPATH_W) '$(srcdir)/oldpwd.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/oldpwd-oldpwd.Tpo $(DEPDIR)/oldpwd-oldpwd.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='oldpwd.c' object='oldpwd-oldpwd.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(oldpwd_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o oldpwd-oldpwd.obj `if test -f 'oldpwd.c'; then $(CYGPATH_W) 'oldpwd.c'; else $(CYGPATH_W) '$(srcdir)/oldpwd.c'; fi` oldpwd-common.o: common.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(oldpwd_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT oldpwd-common.o -MD -MP -MF $(DEPDIR)/oldpwd-common.Tpo -c -o oldpwd-common.o `test -f 'common.c' || echo '$(srcdir)/'`common.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/oldpwd-common.Tpo $(DEPDIR)/oldpwd-common.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='common.c' object='oldpwd-common.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(oldpwd_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o oldpwd-common.o `test -f 'common.c' || echo '$(srcdir)/'`common.c oldpwd-common.obj: common.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(oldpwd_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT oldpwd-common.obj -MD -MP -MF $(DEPDIR)/oldpwd-common.Tpo -c -o oldpwd-common.obj `if test -f 'common.c'; then $(CYGPATH_W) 'common.c'; else $(CYGPATH_W) '$(srcdir)/common.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/oldpwd-common.Tpo $(DEPDIR)/oldpwd-common.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='common.c' object='oldpwd-common.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(oldpwd_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o oldpwd-common.obj `if test -f 'common.c'; then $(CYGPATH_W) 'common.c'; else $(CYGPATH_W) '$(srcdir)/common.c'; fi` utf8-utf8.o: utf8.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(utf8_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT utf8-utf8.o -MD -MP -MF $(DEPDIR)/utf8-utf8.Tpo -c -o utf8-utf8.o `test -f 'utf8.c' || echo '$(srcdir)/'`utf8.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/utf8-utf8.Tpo $(DEPDIR)/utf8-utf8.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='utf8.c' object='utf8-utf8.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(utf8_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o utf8-utf8.o `test -f 'utf8.c' || echo '$(srcdir)/'`utf8.c utf8-utf8.obj: utf8.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(utf8_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT utf8-utf8.obj -MD -MP -MF $(DEPDIR)/utf8-utf8.Tpo -c -o utf8-utf8.obj `if test -f 'utf8.c'; then $(CYGPATH_W) 'utf8.c'; else $(CYGPATH_W) '$(srcdir)/utf8.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/utf8-utf8.Tpo $(DEPDIR)/utf8-utf8.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='utf8.c' object='utf8-utf8.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(utf8_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o utf8-utf8.obj `if test -f 'utf8.c'; then $(CYGPATH_W) 'utf8.c'; else $(CYGPATH_W) '$(srcdir)/utf8.c'; fi` utf8-common.o: common.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(utf8_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT utf8-common.o -MD -MP -MF $(DEPDIR)/utf8-common.Tpo -c -o utf8-common.o `test -f 'common.c' || echo '$(srcdir)/'`common.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/utf8-common.Tpo $(DEPDIR)/utf8-common.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='common.c' object='utf8-common.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(utf8_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o utf8-common.o `test -f 'common.c' || echo '$(srcdir)/'`common.c utf8-common.obj: common.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(utf8_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT utf8-common.obj -MD -MP -MF $(DEPDIR)/utf8-common.Tpo -c -o utf8-common.obj `if test -f 'common.c'; then $(CYGPATH_W) 'common.c'; else $(CYGPATH_W) '$(srcdir)/common.c'; fi` @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/utf8-common.Tpo $(DEPDIR)/utf8-common.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='common.c' object='utf8-common.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(utf8_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o utf8-common.obj `if test -f 'common.c'; then $(CYGPATH_W) 'common.c'; else $(CYGPATH_W) '$(srcdir)/common.c'; fi` mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags # Recover from deleted '.trs' file; this should ensure that # "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create # both 'foo.log' and 'foo.trs'. Break the recipe in two subshells # to avoid problems with "make -n". .log.trs: rm -f $< $@ $(MAKE) $(AM_MAKEFLAGS) $< # Leading 'am--fnord' is there to ensure the list of targets does not # expand to empty, as could happen e.g. with make check TESTS=''. am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck) am--force-recheck: @: $(TEST_SUITE_LOG): $(TEST_LOGS) @$(am__set_TESTS_bases); \ am__f_ok () { test -f "$$1" && test -r "$$1"; }; \ redo_bases=`for i in $$bases; do \ am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \ done`; \ if test -n "$$redo_bases"; then \ redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \ redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \ if $(am__make_dryrun); then :; else \ rm -f $$redo_logs && rm -f $$redo_results || exit 1; \ fi; \ fi; \ if test -n "$$am__remaking_logs"; then \ echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \ "recursion detected" >&2; \ elif test -n "$$redo_logs"; then \ am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \ fi; \ if $(am__make_dryrun); then :; else \ st=0; \ errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \ for i in $$redo_bases; do \ test -f $$i.trs && test -r $$i.trs \ || { echo "$$errmsg $$i.trs" >&2; st=1; }; \ test -f $$i.log && test -r $$i.log \ || { echo "$$errmsg $$i.log" >&2; st=1; }; \ done; \ test $$st -eq 0 || exit 1; \ fi @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \ ws='[ ]'; \ results=`for b in $$bases; do echo $$b.trs; done`; \ test -n "$$results" || results=/dev/null; \ all=` grep "^$$ws*:test-result:" $$results | wc -l`; \ pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \ fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \ skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \ xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \ xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \ error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \ if test `expr $$fail + $$xpass + $$error` -eq 0; then \ success=true; \ else \ success=false; \ fi; \ br='==================='; br=$$br$$br$$br$$br; \ result_count () \ { \ if test x"$$1" = x"--maybe-color"; then \ maybe_colorize=yes; \ elif test x"$$1" = x"--no-color"; then \ maybe_colorize=no; \ else \ echo "$@: invalid 'result_count' usage" >&2; exit 4; \ fi; \ shift; \ desc=$$1 count=$$2; \ if test $$maybe_colorize = yes && test $$count -gt 0; then \ color_start=$$3 color_end=$$std; \ else \ color_start= color_end=; \ fi; \ echo "$${color_start}# $$desc $$count$${color_end}"; \ }; \ create_testsuite_report () \ { \ result_count $$1 "TOTAL:" $$all "$$brg"; \ result_count $$1 "PASS: " $$pass "$$grn"; \ result_count $$1 "SKIP: " $$skip "$$blu"; \ result_count $$1 "XFAIL:" $$xfail "$$lgn"; \ result_count $$1 "FAIL: " $$fail "$$red"; \ result_count $$1 "XPASS:" $$xpass "$$red"; \ result_count $$1 "ERROR:" $$error "$$mgn"; \ }; \ { \ echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \ $(am__rst_title); \ create_testsuite_report --no-color; \ echo; \ echo ".. contents:: :depth: 2"; \ echo; \ for b in $$bases; do echo $$b; done \ | $(am__create_global_log); \ } >$(TEST_SUITE_LOG).tmp || exit 1; \ mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \ if $$success; then \ col="$$grn"; \ else \ col="$$red"; \ test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \ fi; \ echo "$${col}$$br$${std}"; \ echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \ echo "$${col}$$br$${std}"; \ create_testsuite_report --maybe-color; \ echo "$$col$$br$$std"; \ if $$success; then :; else \ echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \ if test -n "$(PACKAGE_BUGREPORT)"; then \ echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \ fi; \ echo "$$col$$br$$std"; \ fi; \ $$success || exit 1 check-TESTS: @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ log_list=`for i in $$bases; do echo $$i.log; done`; \ trs_list=`for i in $$bases; do echo $$i.trs; done`; \ log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \ exit $$?; recheck: all $(check_PROGRAMS) @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) @set +e; $(am__set_TESTS_bases); \ bases=`for i in $$bases; do echo $$i; done \ | $(am__list_recheck_tests)` || exit 1; \ log_list=`for i in $$bases; do echo $$i.log; done`; \ log_list=`echo $$log_list`; \ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \ am__force_recheck=am--force-recheck \ TEST_LOGS="$$log_list"; \ exit $$? t0001.log: t0001$(EXEEXT) @p='t0001$(EXEEXT)'; \ b='t0001'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0002.log: t0002$(EXEEXT) @p='t0002$(EXEEXT)'; \ b='t0002'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0003.log: t0003$(EXEEXT) @p='t0003$(EXEEXT)'; \ b='t0003'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) t0004.log: t0004$(EXEEXT) @p='t0004$(EXEEXT)'; \ b='t0004'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) connect.log: connect$(EXEEXT) @p='connect$(EXEEXT)'; \ b='connect'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) print.log: print$(EXEEXT) @p='print$(EXEEXT)'; \ b='print'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) date.log: date$(EXEEXT) @p='date$(EXEEXT)'; \ b='date'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) norowset.log: norowset$(EXEEXT) @p='norowset$(EXEEXT)'; \ b='norowset'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) funccall.log: funccall$(EXEEXT) @p='funccall$(EXEEXT)'; \ b='funccall'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) lang_error.log: lang_error$(EXEEXT) @p='lang_error$(EXEEXT)'; \ b='lang_error'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) tables.log: tables$(EXEEXT) @p='tables$(EXEEXT)'; \ b='tables'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) binary_test.log: binary_test$(EXEEXT) @p='binary_test$(EXEEXT)'; \ b='binary_test'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) moreandcount.log: moreandcount$(EXEEXT) @p='moreandcount$(EXEEXT)'; \ b='moreandcount'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) earlybind.log: earlybind$(EXEEXT) @p='earlybind$(EXEEXT)'; \ b='earlybind'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) putdata.log: putdata$(EXEEXT) @p='putdata$(EXEEXT)'; \ b='putdata'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) params.log: params$(EXEEXT) @p='params$(EXEEXT)'; \ b='params'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) raiserror.log: raiserror$(EXEEXT) @p='raiserror$(EXEEXT)'; \ b='raiserror'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) getdata.log: getdata$(EXEEXT) @p='getdata$(EXEEXT)'; \ b='getdata'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) transaction.log: transaction$(EXEEXT) @p='transaction$(EXEEXT)'; \ b='transaction'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) type.log: type$(EXEEXT) @p='type$(EXEEXT)'; \ b='type'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) genparams.log: genparams$(EXEEXT) @p='genparams$(EXEEXT)'; \ b='genparams'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) preperror.log: preperror$(EXEEXT) @p='preperror$(EXEEXT)'; \ b='preperror'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) prepare_results.log: prepare_results$(EXEEXT) @p='prepare_results$(EXEEXT)'; \ b='prepare_results'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) testodbc.log: testodbc$(EXEEXT) @p='testodbc$(EXEEXT)'; \ b='testodbc'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) data.log: data$(EXEEXT) @p='data$(EXEEXT)'; \ b='data'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) error.log: error$(EXEEXT) @p='error$(EXEEXT)'; \ b='error'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) rebindpar.log: rebindpar$(EXEEXT) @p='rebindpar$(EXEEXT)'; \ b='rebindpar'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) rpc.log: rpc$(EXEEXT) @p='rpc$(EXEEXT)'; \ b='rpc'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) convert_error.log: convert_error$(EXEEXT) @p='convert_error$(EXEEXT)'; \ b='convert_error'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) typeinfo.log: typeinfo$(EXEEXT) @p='typeinfo$(EXEEXT)'; \ b='typeinfo'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) const_params.log: const_params$(EXEEXT) @p='const_params$(EXEEXT)'; \ b='const_params'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) insert_speed.log: insert_speed$(EXEEXT) @p='insert_speed$(EXEEXT)'; \ b='insert_speed'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) compute.log: compute$(EXEEXT) @p='compute$(EXEEXT)'; \ b='compute'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) timeout.log: timeout$(EXEEXT) @p='timeout$(EXEEXT)'; \ b='timeout'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) array.log: array$(EXEEXT) @p='array$(EXEEXT)'; \ b='array'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) array_out.log: array_out$(EXEEXT) @p='array_out$(EXEEXT)'; \ b='array_out'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) cursor1.log: cursor1$(EXEEXT) @p='cursor1$(EXEEXT)'; \ b='cursor1'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) scroll.log: scroll$(EXEEXT) @p='scroll$(EXEEXT)'; \ b='scroll'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) cursor2.log: cursor2$(EXEEXT) @p='cursor2$(EXEEXT)'; \ b='cursor2'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) describecol.log: describecol$(EXEEXT) @p='describecol$(EXEEXT)'; \ b='describecol'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) copydesc.log: copydesc$(EXEEXT) @p='copydesc$(EXEEXT)'; \ b='copydesc'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) prepclose.log: prepclose$(EXEEXT) @p='prepclose$(EXEEXT)'; \ b='prepclose'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) warning.log: warning$(EXEEXT) @p='warning$(EXEEXT)'; \ b='warning'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) paramcore.log: paramcore$(EXEEXT) @p='paramcore$(EXEEXT)'; \ b='paramcore'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) timeout2.log: timeout2$(EXEEXT) @p='timeout2$(EXEEXT)'; \ b='timeout2'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) timeout3.log: timeout3$(EXEEXT) @p='timeout3$(EXEEXT)'; \ b='timeout3'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) connect2.log: connect2$(EXEEXT) @p='connect2$(EXEEXT)'; \ b='connect2'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) timeout4.log: timeout4$(EXEEXT) @p='timeout4$(EXEEXT)'; \ b='timeout4'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) freeclose.log: freeclose$(EXEEXT) @p='freeclose$(EXEEXT)'; \ b='freeclose'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) cursor3.log: cursor3$(EXEEXT) @p='cursor3$(EXEEXT)'; \ b='cursor3'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) cursor4.log: cursor4$(EXEEXT) @p='cursor4$(EXEEXT)'; \ b='cursor4'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) cursor5.log: cursor5$(EXEEXT) @p='cursor5$(EXEEXT)'; \ b='cursor5'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) attributes.log: attributes$(EXEEXT) @p='attributes$(EXEEXT)'; \ b='attributes'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) hidden.log: hidden$(EXEEXT) @p='hidden$(EXEEXT)'; \ b='hidden'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) blob1.log: blob1$(EXEEXT) @p='blob1$(EXEEXT)'; \ b='blob1'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) cancel.log: cancel$(EXEEXT) @p='cancel$(EXEEXT)'; \ b='cancel'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) wchar.log: wchar$(EXEEXT) @p='wchar$(EXEEXT)'; \ b='wchar'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) rowset.log: rowset$(EXEEXT) @p='rowset$(EXEEXT)'; \ b='rowset'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) transaction2.log: transaction2$(EXEEXT) @p='transaction2$(EXEEXT)'; \ b='transaction2'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) cursor6.log: cursor6$(EXEEXT) @p='cursor6$(EXEEXT)'; \ b='cursor6'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) cursor7.log: cursor7$(EXEEXT) @p='cursor7$(EXEEXT)'; \ b='cursor7'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) utf8.log: utf8$(EXEEXT) @p='utf8$(EXEEXT)'; \ b='utf8'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) utf8_2.log: utf8_2$(EXEEXT) @p='utf8_2$(EXEEXT)'; \ b='utf8_2'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) stats.log: stats$(EXEEXT) @p='stats$(EXEEXT)'; \ b='stats'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) descrec.log: descrec$(EXEEXT) @p='descrec$(EXEEXT)'; \ b='descrec'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) peter.log: peter$(EXEEXT) @p='peter$(EXEEXT)'; \ b='peter'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) test64.log: test64$(EXEEXT) @p='test64$(EXEEXT)'; \ b='test64'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) prepare_warn.log: prepare_warn$(EXEEXT) @p='prepare_warn$(EXEEXT)'; \ b='prepare_warn'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) long_error.log: long_error$(EXEEXT) @p='long_error$(EXEEXT)'; \ b='long_error'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) mars1.log: mars1$(EXEEXT) @p='mars1$(EXEEXT)'; \ b='mars1'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) array_error.log: array_error$(EXEEXT) @p='array_error$(EXEEXT)'; \ b='array_error'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) describecol2.log: describecol2$(EXEEXT) @p='describecol2$(EXEEXT)'; \ b='describecol2'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) closestmt.log: closestmt$(EXEEXT) @p='closestmt$(EXEEXT)'; \ b='closestmt'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) bcp.log: bcp$(EXEEXT) @p='bcp$(EXEEXT)'; \ b='bcp'; \ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) .test.log: @p='$<'; \ $(am__set_b); \ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) @am__EXEEXT_TRUE@.test$(EXEEXT).log: @am__EXEEXT_TRUE@ @p='$<'; \ @am__EXEEXT_TRUE@ $(am__set_b); \ @am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \ @am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \ @am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \ @am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT) distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-am all-am: Makefile installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS) -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs) -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG) clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: check-am install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-TESTS check-am clean \ clean-checkPROGRAMS clean-generic clean-libtool cscopelist-am \ ctags ctags-am distclean distclean-compile distclean-generic \ 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-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 \ recheck tags tags-am uninstall uninstall-am .PRECIOUS: Makefile # 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: freetds-1.00.82/src/odbc/unittests/array.c100644 025423 025423 00000013017 12717145107 0014057#include "common.h" #include /* Test using array binding */ static SQLTCHAR *test_query = NULL; static int multiply = 90; static int failure = 0; #define XMALLOC_N(t, n) (t*) ODBC_GET(n*sizeof(t)) static void query_test(int prepare, SQLRETURN expected, const char *expected_status) { #define DESC_LEN 51 #define ARRAY_SIZE 10 SQLUINTEGER *ids = XMALLOC_N(SQLUINTEGER,ARRAY_SIZE); typedef SQLCHAR desc_t[DESC_LEN]; desc_t *descs = XMALLOC_N(desc_t, ARRAY_SIZE); SQLLEN *id_lens = XMALLOC_N(SQLLEN,ARRAY_SIZE), *desc_lens = XMALLOC_N(SQLLEN,ARRAY_SIZE); SQLUSMALLINT i, *statuses = XMALLOC_N(SQLUSMALLINT,ARRAY_SIZE); unsigned *num_errors = XMALLOC_N(unsigned, ARRAY_SIZE); SQLULEN processed; RETCODE ret; char status[20]; SQLTCHAR *err = (SQLTCHAR *) ODBC_GET(sizeof(odbc_err)*sizeof(SQLTCHAR)); SQLTCHAR *state = (SQLTCHAR *) ODBC_GET(sizeof(odbc_sqlstate)*sizeof(SQLTCHAR)); assert(odbc_stmt != SQL_NULL_HSTMT); odbc_reset_statement(); odbc_command_with_result(odbc_stmt, "drop table #tmp1"); odbc_command("create table #tmp1 (id tinyint, value char(20))"); SQLSetStmtAttr(odbc_stmt, SQL_ATTR_PARAM_BIND_TYPE, SQL_PARAM_BIND_BY_COLUMN, 0); SQLSetStmtAttr(odbc_stmt, SQL_ATTR_PARAMSET_SIZE, (void *) ARRAY_SIZE, 0); SQLSetStmtAttr(odbc_stmt, SQL_ATTR_PARAM_STATUS_PTR, statuses, 0); SQLSetStmtAttr(odbc_stmt, SQL_ATTR_PARAMS_PROCESSED_PTR, &processed, 0); SQLBindParameter(odbc_stmt, 1, SQL_PARAM_INPUT, SQL_C_ULONG, SQL_INTEGER, 5, 0, ids, 0, id_lens); SQLBindParameter(odbc_stmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, DESC_LEN - 1, 0, descs, DESC_LEN, desc_lens); processed = ARRAY_SIZE + 1; for (i = 0; i < ARRAY_SIZE; i++) { statuses[i] = SQL_PARAM_DIAG_UNAVAILABLE; ids[i] = (i + 1) * multiply; sprintf((char *) descs[i], "data %d", i * 7); id_lens[i] = 0; desc_lens[i] = SQL_NTS; num_errors[i] = 0; } multiply = 90; if (!prepare) { ret = SQLExecDirect(odbc_stmt, test_query, SQL_NTS); } else { SQLPrepare(odbc_stmt, test_query, SQL_NTS); ret = SQLExecute(odbc_stmt); } if (processed > ARRAY_SIZE) { char buf[256]; sprintf(buf, "Invalid processed number: %d", (int) processed); ODBC_REPORT_ERROR(buf); } for (i = 1; CHKGetDiagRec(SQL_HANDLE_STMT, odbc_stmt, i, state, NULL, err, sizeof(odbc_err), NULL, "SINo") != SQL_NO_DATA; ++i) { SQLINTEGER row; strcpy(odbc_err, C(err)); strcpy(odbc_sqlstate, C(state)); CHKGetDiagField(SQL_HANDLE_STMT, odbc_stmt, i, SQL_DIAG_ROW_NUMBER, &row, sizeof(row), NULL, "S"); if (row == SQL_ROW_NUMBER_UNKNOWN) continue; if (row < 1 || row > ARRAY_SIZE) { fprintf(stderr, "invalid row %d returned reading error number %d\n", (int) row, i); exit(1); } ++num_errors[row-1]; printf("for row %2d returned '%s' %s\n", (int) row, odbc_sqlstate, odbc_err); } for (i = 0; i < processed; ++i) { int has_diag = 0; switch (statuses[i]) { case SQL_PARAM_SUCCESS_WITH_INFO: has_diag = 1; case SQL_PARAM_SUCCESS: status[i] = 'V'; break; case SQL_PARAM_ERROR: has_diag = 1; status[i] = '!'; break; case SQL_PARAM_UNUSED: status[i] = ' '; break; case SQL_PARAM_DIAG_UNAVAILABLE: status[i] = '?'; break; default: fprintf(stderr, "Invalid status returned %d\n", statuses[i]); exit(1); } if (has_diag) { if (!num_errors[i]) { fprintf(stderr, "Diagnostics not returned for status %d\n", i); failure = 1; } } else { if (num_errors[i]) { fprintf(stderr, "Diagnostics returned for status %d\n", i); failure = 1; } } } status[i] = 0; if (ret != expected || strcmp(expected_status, status) != 0) { fprintf(stderr, "Invalid result: got %d \"%s\" expected %d \"%s\" processed %d\n", ret, status, expected, expected_status, (int) processed); if (ret != SQL_SUCCESS) odbc_read_error(); failure = 1; odbc_reset_statement(); return; } odbc_reset_statement(); } int main(int argc, char *argv[]) { odbc_use_version3 = 1; odbc_connect(); if (odbc_db_is_microsoft()) { /* all successes */ test_query = T("INSERT INTO #tmp1 (id, value) VALUES (?, ?)"); multiply = 1; query_test(0, SQL_SUCCESS, "VVVVVVVVVV"); multiply = 1; query_test(1, SQL_SUCCESS, "VVVVVVVVVV"); /* all errors */ test_query = T("INSERT INTO #tmp1 (id, value) VALUES (?, ?)"); multiply = 257; query_test(0, SQL_ERROR, "!!!!!!!!!!"); multiply = 257; query_test(1, SQL_SUCCESS_WITH_INFO, "!!!!!!!!!!"); test_query = T("INSERT INTO #tmp1 (id, value) VALUES (?, ?)"); query_test(0, SQL_ERROR, "VV!!!!!!!!"); query_test(1, SQL_SUCCESS_WITH_INFO, "VV!!!!!!!!"); test_query = T("INSERT INTO #tmp1 (id, value) VALUES (900-?, ?)"); query_test(0, SQL_SUCCESS_WITH_INFO, "!!!!!!!VVV"); query_test(1, SQL_SUCCESS_WITH_INFO, "!!!!!!!VVV"); test_query = T("INSERT INTO #tmp1 (id) VALUES (?) UPDATE #tmp1 SET value = ?"); query_test(0, SQL_SUCCESS_WITH_INFO, "VVVV!V!V!V"); query_test(1, SQL_SUCCESS_WITH_INFO, "VV!!!!!!!!"); #ifdef ENABLE_DEVELOPING /* with result, see how SQLMoreResult work */ test_query = T("INSERT INTO #tmp1 (id) VALUES (?) SELECT * FROM #tmp1 UPDATE #tmp1 SET value = ?"); /* IMHO our driver is better here -- freddy77 */ query_test(0, SQL_SUCCESS, odbc_driver_is_freetds() ? "VVVVV!V!V!" : "VVVVVV!VVV"); query_test(1, SQL_SUCCESS, "VVVVVVVVVV"); #endif } else { /* Sybase test for conversions before executing */ test_query = T("INSERT INTO #tmp1 (id, value) VALUES (?/8, ?)"); query_test(0, SQL_SUCCESS, "VVVVVVVVVV"); } /* TODO record binding, array fetch, sqlputdata */ odbc_disconnect(); printf(failure ? "Failed :(\n" : "Success!\n"); return failure; } freetds-1.00.82/src/odbc/unittests/common.c100644 025423 025423 00000046220 12717145107 0014233#include "common.h" #include #include #if HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #if HAVE_SYS_STAT_H #include #endif /* HAVE_SYS_STAT_H */ #if HAVE_NETINET_IN_H #include #endif /* HAVE_NETINET_IN_H */ #if defined(UNIXODBC) || defined(_WIN32) #include #endif #ifndef _WIN32 #include #else #define TDS_SDIR_SEPARATOR "\\" #endif HENV odbc_env; HDBC odbc_conn; HSTMT odbc_stmt; int odbc_use_version3 = 0; void (*odbc_set_conn_attr)(void) = NULL; char odbc_user[512]; char odbc_server[512]; char odbc_password[512]; char odbc_database[512]; char odbc_driver[1024]; static int check_lib(char *path, const char *file) { int len = strlen(path); FILE *f; strcat(path, file); f = fopen(path, "rb"); if (f) { fclose(f); return 1; } path[len] = 0; return 0; } /* some platforms do not have setenv, define a replacement */ #if !HAVE_SETENV void odbc_setenv(const char *name, const char *value, int overwrite) { #if HAVE_PUTENV char buf[1024]; sprintf(buf, "%s=%s", name, value); putenv(buf); #endif } #endif /* this should be extended with all possible systems... */ static const char *const search_driver[] = { ".libs/libtdsodbc.so", ".libs/libtdsodbc.sl", ".libs/libtdsodbc.dylib", ".libs/libtdsodbc.dll", "_libs/libtdsodbc.dll", "debug/tdsodbc.dll", "release/tdsodbc.dll", "libtdsodbc.so", "tdsodbc.dll", NULL }; int odbc_read_login_info(void) { static const char *PWD = "../../../PWD"; FILE *in = NULL; char line[512]; char *s1, *s2; const char *const *search_p; char path[1024]; int len; #ifdef _WIN32 UWORD old_config_mode; #endif setbuf(stdout, NULL); setbuf(stderr, NULL); s1 = getenv("TDSPWDFILE"); if (s1 && s1[0]) in = fopen(s1, "r"); if (!in) in = fopen(PWD, "r"); if (!in) in = fopen("PWD", "r"); if (!in) { fprintf(stderr, "Can not open PWD file\n\n"); return 1; } while (fgets(line, 512, in)) { s1 = strtok(line, "="); s2 = strtok(NULL, "\n"); if (!s1 || !s2) continue; if (!strcmp(s1, "UID")) { strcpy(odbc_user, s2); } else if (!strcmp(s1, "SRV")) { strcpy(odbc_server, s2); } else if (!strcmp(s1, "PWD")) { strcpy(odbc_password, s2); } else if (!strcmp(s1, "DB")) { strcpy(odbc_database, s2); } } fclose(in); /* find our driver */ #ifndef _WIN32 if (!getcwd(path, sizeof(path))) #else if (!_getcwd(path, sizeof(path))) #endif return 0; #ifdef __VMS { /* A hard-coded driver path has to be in unix syntax to be recognized as such. */ const char *unixspec = decc$translate_vms(path); if ( (int)unixspec != 0 && (int)unixspec != -1 ) strcpy(path, unixspec); } #endif len = strlen(path); if (len < 10 || (strcasecmp(path + len - 10, "/unittests") != 0 #ifdef _WIN32 && strcasecmp(path + len - 10, "\\unittests") != 0 #endif )) return 0; path[len - 9] = 0; for (search_p = search_driver; *search_p; ++search_p) { if (check_lib(path, *search_p)) break; } if (!*search_p) return 0; strcpy(odbc_driver, path); #ifndef _WIN32 /* craft out odbc.ini, avoid to read wrong one */ sprintf(path, "odbc.ini.%d", (int) getpid()); in = fopen(path, "w"); if (in) { fprintf(in, "[%s]\nDriver = %s\nDatabase = %s\nServername = %s\n", odbc_server, odbc_driver, odbc_database, odbc_server); fclose(in); setenv("ODBCINI", "./odbc.ini", 1); setenv("SYSODBCINI", "./odbc.ini", 1); rename(path, "odbc.ini"); unlink(path); } #else if (SQLGetConfigMode(&old_config_mode)) { SQLSetConfigMode(ODBC_USER_DSN); SQLWritePrivateProfileString(odbc_server, "Driver", odbc_driver, "odbc.ini"); SQLWritePrivateProfileString(odbc_server, "Database", odbc_database, "odbc.ini"); SQLWritePrivateProfileString(odbc_server, "Servername", odbc_server, "odbc.ini"); SQLSetConfigMode(old_config_mode); } #endif return 0; } void odbc_report_error(const char *errmsg, int line, const char *file) { SQLSMALLINT handletype; SQLHANDLE handle; SQLRETURN ret; SQLTCHAR sqlstate[6]; SQLTCHAR msg[256]; ODBC_BUF *odbc_buf = NULL; if (odbc_stmt) { handletype = SQL_HANDLE_STMT; handle = odbc_stmt; } else if (odbc_conn) { handletype = SQL_HANDLE_DBC; handle = odbc_conn; } else { handletype = SQL_HANDLE_ENV; handle = odbc_env; } if (errmsg[0]) { if (line) fprintf(stderr, "%s:%d %s\n", file, line, errmsg); else fprintf(stderr, "%s\n", errmsg); } ret = SQLGetDiagRec(handletype, handle, 1, sqlstate, NULL, msg, ODBC_VECTOR_SIZE(msg), NULL); if (ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO) fprintf(stderr, "SQL error %s -- %s\n", C(sqlstate), C(msg)); odbc_disconnect(); ODBC_FREE(); exit(1); } static void ReportODBCError(const char *errmsg, SQLSMALLINT handletype, SQLHANDLE handle, SQLRETURN rc, int line, const char *file) { SQLRETURN ret; SQLTCHAR sqlstate[6]; SQLTCHAR msg[256]; ODBC_BUF *odbc_buf = NULL; if (errmsg[0]) { if (line) fprintf(stderr, "%s:%d rc=%d %s\n", file, line, (int) rc, errmsg); else fprintf(stderr, "rc=%d %s\n", (int) rc, errmsg); } ret = SQLGetDiagRec(handletype, handle, 1, sqlstate, NULL, msg, ODBC_VECTOR_SIZE(msg), NULL); if (ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO) fprintf(stderr, "SQL error %s -- %s\n", C(sqlstate), C(msg)); odbc_disconnect(); ODBC_FREE(); exit(1); } int odbc_connect(void) { ODBC_BUF *odbc_buf = NULL; char command[512]; const char *p; if (odbc_read_login_info()) exit(1); if (odbc_use_version3) { CHKAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &odbc_env, "S"); SQLSetEnvAttr(odbc_env, SQL_ATTR_ODBC_VERSION, (SQLPOINTER) (SQL_OV_ODBC3), SQL_IS_UINTEGER); CHKAllocHandle(SQL_HANDLE_DBC, odbc_env, &odbc_conn, "S"); } else { CHKAllocEnv(&odbc_env, "S"); CHKAllocConnect(&odbc_conn, "S"); } printf("odbctest\n--------\n\n"); printf("connection parameters:\nserver: '%s'\nuser: '%s'\npassword: '%s'\ndatabase: '%s'\n", odbc_server, odbc_user, "????" /* odbc_password */ , odbc_database); p = getenv("ODBC_MARS"); if (p && atoi(p) != 0) SQLSetConnectAttr(odbc_conn, 1224 /*SQL_COPT_SS_MARS_ENABLED*/, (SQLPOINTER) 1 /*SQL_MARS_ENABLED_YES*/, SQL_IS_UINTEGER); if (odbc_set_conn_attr) (*odbc_set_conn_attr)(); CHKConnect(T(odbc_server), SQL_NTS, T(odbc_user), SQL_NTS, T(odbc_password), SQL_NTS, "SI"); CHKAllocStmt(&odbc_stmt, "S"); sprintf(command, "use %s", odbc_database); printf("%s\n", command); CHKExecDirect(T(command), SQL_NTS, "SI"); #ifndef TDS_NO_DM /* unixODBC seems to require it */ SQLMoreResults(odbc_stmt); #endif ODBC_FREE(); return 0; } int odbc_disconnect(void) { if (odbc_stmt) { SQLFreeStmt(odbc_stmt, SQL_DROP); odbc_stmt = SQL_NULL_HSTMT; } if (odbc_conn) { SQLDisconnect(odbc_conn); SQLFreeConnect(odbc_conn); odbc_conn = SQL_NULL_HDBC; } if (odbc_env) { SQLFreeEnv(odbc_env); odbc_env = SQL_NULL_HENV; } ODBC_FREE(); return 0; } SQLRETURN odbc_command_with_result(HSTMT stmt, const char *command) { SQLRETURN ret; ODBC_BUF *odbc_buf = NULL; printf("%s\n", command); ret = SQLExecDirect(stmt, T(command), SQL_NTS); ODBC_FREE(); return ret; } static int ms_db = -1; int odbc_db_is_microsoft(void) { ODBC_BUF *odbc_buf = NULL; SQLTCHAR buf[64]; SQLSMALLINT len; int i; if (ms_db < 0) { buf[0] = 0; SQLGetInfo(odbc_conn, SQL_DBMS_NAME, buf, sizeof(buf), &len); for (i = 0; buf[i]; ++i) buf[i] = tolower(buf[i]); ms_db = (strstr(C(buf), "microsoft") != NULL); } ODBC_FREE(); return ms_db; } static int freetds_driver = -1; int odbc_driver_is_freetds(void) { ODBC_BUF *odbc_buf = NULL; SQLTCHAR buf[64]; SQLSMALLINT len; int i; if (freetds_driver < 0) { buf[0] = 0; SQLGetInfo(odbc_conn, SQL_DRIVER_NAME, buf, sizeof(buf), &len); for (i = 0; buf[i]; ++i) buf[i] = tolower(buf[i]); freetds_driver = (strstr(C(buf), "tds") != NULL); } ODBC_FREE(); return freetds_driver; } /* Detect protocol version using queries * This to make possible protocol discovery on drivers like MS */ static int odbc_tds_version_long(void) { SQLRETURN ret; SQLSMALLINT scale, nullable, type; SQLULEN prec; ODBC_BUF *odbc_buf = NULL; /* statement must be in a consistent state to do the check */ CHKExecDirect(T("select 1"), SQL_NTS, "S"); odbc_reset_statement(); /* select cast(123 as sql_variant) -> nvarchar('123') is 7.0 failure query is 5.0 ?? */ ret = CHKExecDirect(T("select cast('123' as sql_variant)"), SQL_NTS, "SNoE"); odbc_reset_statement(); if (ret == SQL_ERROR) { ODBC_FREE(); return 0x500; } /* see how bigint is returned, numeric means 7.0 */ CHKExecDirect(T("select cast('123' as bigint)"), SQL_NTS, "S"); CHKDescribeCol(1, NULL, 0, NULL, &type, &prec, &scale, &nullable, "S"); odbc_reset_statement(); if (type == SQL_NUMERIC || type == SQL_DECIMAL) { ODBC_FREE(); return 0x700; } if (type != SQL_BIGINT) { fprintf(stderr, "Strange type returned trying to detect protocol version\n"); odbc_disconnect(); ODBC_FREE(); exit(1); } /* select cast('123' as varchar(max)) -> ??? SQL_VARCHAR is 7.2 ?? */ ret = CHKExecDirect(T("select cast('123' as varchar(max))"), SQL_NTS, "SE"); if (ret == SQL_ERROR) { odbc_reset_statement(); ODBC_FREE(); return 0x701; } CHKDescribeCol(1, NULL, 0, NULL, &type, &prec, &scale, &nullable, "S"); odbc_reset_statement(); if (type == SQL_LONGVARCHAR) { ODBC_FREE(); return 0x701; } if (type != SQL_VARCHAR) { fprintf(stderr, "Strange type returned trying to detect protocol version\n"); odbc_disconnect(); ODBC_FREE(); exit(1); } /* select cast('12:13:14.1234' as time(4)) -> NVARCHAR('12:13:14.1234') is 7.2 else 7.3 */ ret = CHKExecDirect(T("select cast('12:13:14.1234' as time(4))"), SQL_NTS, "SE"); if (ret == SQL_ERROR) { odbc_reset_statement(); ODBC_FREE(); return 0x702; } CHKDescribeCol(1, NULL, 0, NULL, &type, &prec, &scale, &nullable, "S"); odbc_reset_statement(); if (scale == 4) return 0x703; if (scale != 0 || type != SQL_WVARCHAR) { fprintf(stderr, "Strange type or scale returned trying to detect protocol version\n"); odbc_disconnect(); ODBC_FREE(); exit(1); } ODBC_FREE(); return 0x702; } int odbc_tds_version(void) { static int tds_version = -1; ODBC_BUF *odbc_buf = NULL; SQLUINTEGER version; SQLSMALLINT len; if (odbc_driver_is_freetds() && tds_version < 0) { version = 0; len = 0; SQLGetInfo(odbc_conn, 1300 /* SQL_INFO_FREETDS_TDS_VERSION */, &version, sizeof(version), &len); if (len == sizeof(version)) tds_version = (version >> 16) << 8 | (version & 0xff); } if (tds_version < 0) { tds_version = odbc_tds_version_long(); } ODBC_FREE(); return tds_version; } static char db_str_version[32]; const char *odbc_db_version(void) { if (!db_str_version[0]) { ODBC_BUF *odbc_buf = NULL; SQLTCHAR buf[32]; SQLSMALLINT version_len; CHKR(SQLGetInfo, (odbc_conn, SQL_DBMS_VER, buf, sizeof(buf), &version_len), "S"); strcpy(db_str_version, C(buf)); ODBC_FREE(); } return db_str_version; } unsigned int odbc_db_version_int(void) { unsigned int h, l; if (sscanf(odbc_db_version(), "%u.%u.", &h, &l) != 2) { fprintf(stderr, "Wrong db version: %s\n", odbc_db_version()); odbc_disconnect(); exit(1); } return (h << 24) | ((l & 0xFFu) << 16); } void odbc_check_cols(int n, int line, const char * file) { SQLSMALLINT cols; if (n < 0) { CHKNumResultCols(&cols, "E"); return; } CHKNumResultCols(&cols, "S"); if (cols != n) { fprintf(stderr, "%s:%d: Expected %d columns returned %d\n", file, line, n, (int) cols); odbc_disconnect(); exit(1); } } void odbc_check_rows(int n, int line, const char * file) { SQLLEN rows; if (n < -1) { CHKRowCount(&rows, "E"); return; } CHKRowCount(&rows, "S"); if (rows != n) { fprintf(stderr, "%s:%d: Expected %d rows returned %d\n", file, line, n, (int) rows); odbc_disconnect(); exit(1); } } void odbc_reset_statement_proc(SQLHSTMT *stmt, const char *file, int line) { SQLFreeStmt(*stmt, SQL_DROP); *stmt = SQL_NULL_HSTMT; odbc_check_res(file, line, SQLAllocStmt(odbc_conn, stmt), SQL_HANDLE_DBC, odbc_conn, "SQLAllocStmt", "S"); } void odbc_test_skipped(void) { const char *p = getenv("TDS_SKIP_SUCCESS"); if (p && atoi(p) != 0) exit(0); exit(77); } void odbc_check_cursor(void) { SQLRETURN retcode; ODBC_BUF *odbc_buf = NULL; retcode = SQLSetStmtAttr(odbc_stmt, SQL_ATTR_CONCURRENCY, (SQLPOINTER) SQL_CONCUR_ROWVER, 0); if (retcode != SQL_SUCCESS) { SQLTCHAR output[256]; SQLTCHAR sqlstate[6]; CHKGetDiagRec(SQL_HANDLE_STMT, odbc_stmt, 1, sqlstate, NULL, output, ODBC_VECTOR_SIZE(output), NULL, "S"); sqlstate[5] = 0; if (strcmp(C(sqlstate), "01S02") == 0) { printf("Your connection seems to not support cursors, probably you are using wrong protocol version or Sybase\n"); odbc_disconnect(); ODBC_FREE(); odbc_test_skipped(); } ReportODBCError("SQLSetStmtAttr", SQL_HANDLE_STMT, odbc_stmt, retcode, __LINE__, __FILE__); } odbc_reset_statement(); ODBC_FREE(); } SQLRETURN odbc_check_res(const char *file, int line, SQLRETURN rc, SQLSMALLINT handle_type, SQLHANDLE handle, const char *func, const char *res) { const char *p = res; for (;;) { if (*p == 'S') { if (rc == SQL_SUCCESS) return rc; ++p; } else if (*p == 'I') { if (rc == SQL_SUCCESS_WITH_INFO) return rc; ++p; } else if (*p == 'E') { if (rc == SQL_ERROR) return rc; ++p; } else if (strncmp(p, "No", 2) == 0) { if (rc == SQL_NO_DATA) return rc; p += 2; } else if (strncmp(p, "Ne", 2) == 0) { if (rc == SQL_NEED_DATA) return rc; p += 2; } else if (!*p) { break; } else { odbc_report_error("Wrong results specified", line, file); return rc; } } ReportODBCError(func, handle_type, handle, rc, line, file); return rc; } SQLSMALLINT odbc_alloc_handle_err_type(SQLSMALLINT type) { switch (type) { case SQL_HANDLE_DESC: return SQL_HANDLE_STMT; case SQL_HANDLE_STMT: return SQL_HANDLE_DBC; case SQL_HANDLE_DBC: return SQL_HANDLE_ENV; } return 0; } SQLRETURN odbc_command_proc(HSTMT stmt, const char *command, const char *file, int line, const char *res) { SQLRETURN ret; ODBC_BUF *odbc_buf = NULL; printf("%s\n", command); ret = odbc_check_res(file, line, SQLExecDirect(stmt, T(command), SQL_NTS), SQL_HANDLE_STMT, stmt, "odbc_command", res); ODBC_FREE(); return ret; } char odbc_err[512]; char odbc_sqlstate[6]; void odbc_read_error(void) { ODBC_BUF *odbc_buf = NULL; SQLTCHAR *err = (SQLTCHAR *) ODBC_GET(sizeof(odbc_err)*sizeof(SQLTCHAR)); SQLTCHAR *state = (SQLTCHAR *) ODBC_GET(sizeof(odbc_sqlstate)*sizeof(SQLTCHAR)); memset(odbc_err, 0, sizeof(odbc_err)); memset(odbc_sqlstate, 0, sizeof(odbc_sqlstate)); CHKGetDiagRec(SQL_HANDLE_STMT, odbc_stmt, 1, state, NULL, err, sizeof(odbc_err), NULL, "SI"); strcpy(odbc_err, C(err)); strcpy(odbc_sqlstate, C(state)); ODBC_FREE(); printf("Message: '%s' %s\n", odbc_sqlstate, odbc_err); } int odbc_to_sqlwchar(SQLWCHAR *dst, const char *src, int n) { int i = n; while (--i >= 0) dst[i] = (unsigned char) src[i]; return n * sizeof(SQLWCHAR); } int odbc_from_sqlwchar(char *dst, const SQLWCHAR *src, int n) { int i; if (n < 0) { const SQLWCHAR *p = src; for (n=1; *p++ != 0; ++n) continue; } for (i = 0; i < n; ++i) { assert(src[i] < 256); dst[i] = (char) src[i]; } return n; } ODBC_BUF *odbc_buf = NULL; void * odbc_buf_get(ODBC_BUF** buf, size_t s) { ODBC_BUF *p = (ODBC_BUF*) calloc(1, sizeof(ODBC_BUF)); assert(p); p->buf = malloc(s); assert(p->buf); p->next = *buf; *buf = p; return p->buf; } void odbc_buf_free(ODBC_BUF** buf) { ODBC_BUF *cur = *buf; *buf = NULL; while (cur) { ODBC_BUF *next = cur->next; free(cur->buf); free(cur); cur = next; } } SQLWCHAR * odbc_get_sqlwchar(ODBC_BUF** buf, const char *s) { size_t l; SQLWCHAR *buffer; if (!s) return NULL; l = strlen(s) + 1; buffer = (SQLWCHAR*) odbc_buf_get(buf, l * sizeof(SQLWCHAR)); odbc_to_sqlwchar(buffer, s, l); return buffer; } char* odbc_get_sqlchar(ODBC_BUF** buf, SQLWCHAR *s) { int n; const SQLWCHAR *p = s; char *out; for (n=1; *p++ != 0; ++n) continue; out = (char *) odbc_buf_get(buf, n); odbc_from_sqlwchar(out, s, n); return out; } typedef union { struct sockaddr sa; struct sockaddr_in sin; char dummy[256]; } long_sockaddr; static int fd_is_socket(int fd) { long_sockaddr addr; socklen_t addr_len; #ifndef _WIN32 struct stat file_stat; if (fstat(fd, &file_stat)) return 0; if ((file_stat.st_mode & S_IFSOCK) != S_IFSOCK) return 0; #endif addr_len = sizeof(addr); if (tds_getpeername((TDS_SYS_SOCKET) fd, &addr.sa, &addr_len)) return 0; addr_len = sizeof(addr); if (tds_getsockname((TDS_SYS_SOCKET) fd, &addr.sa, &addr_len)) return 0; return 1; } enum {NUM_FDS = 4096*4}; static unsigned char fd_bitmask[NUM_FDS / 8]; static int mark_fd(int fd) { unsigned shift; unsigned char mask; if (fd < 0 || fd >= NUM_FDS) return 0; shift = fd & 7; mask = fd_bitmask[fd >> 3]; fd_bitmask[fd >> 3] = mask | (1 << shift); return (mask >> shift) & 1; } #ifdef _WIN32 #define FOR_ALL_SOCKETS(i) for (i = 4; i <= (4096*4); i += 4) #else #define FOR_ALL_SOCKETS(i) for (i = 3; i < 1024; ++i) #endif void odbc_mark_sockets_opened(void) { int i; memset(fd_bitmask, 0, sizeof(fd_bitmask)); FOR_ALL_SOCKETS(i) { if (fd_is_socket(i)) mark_fd(i); } } TDS_SYS_SOCKET odbc_find_last_socket(void) { typedef struct { TDS_SYS_SOCKET sock; int local_port; int remote_port; } sock_info; sock_info found[8]; unsigned num_found = 0, n; int i; FOR_ALL_SOCKETS(i) { long_sockaddr remote_addr, local_addr; struct sockaddr_in *in; socklen_t remote_addr_len, local_addr_len; sock_info *info; /* check if is a socket */ if (!fd_is_socket(i)) continue; if (mark_fd(i)) continue; remote_addr_len = sizeof(remote_addr); if (tds_getpeername((TDS_SYS_SOCKET) i, &remote_addr.sa, &remote_addr_len)) continue; if (remote_addr.sa.sa_family != AF_INET #ifdef AF_INET6 && remote_addr.sa.sa_family != AF_INET6 #endif ) continue; local_addr_len = sizeof(local_addr); if (tds_getsockname((TDS_SYS_SOCKET) i, &local_addr.sa, &local_addr_len)) continue; /* save in the array */ if (num_found >= 8) { memmove(found, found+1, sizeof(found) - sizeof(found[0])); num_found = 7; } info = &found[num_found++]; info->sock = (TDS_SYS_SOCKET) i; info->local_port = -1; info->remote_port = -1; /* now check if is a socketpair */ in = &remote_addr.sin; if (in->sin_family != AF_INET) continue; if (in->sin_addr.s_addr != htonl(INADDR_LOOPBACK)) continue; info->remote_port = ntohs(in->sin_port); in = &local_addr.sin; if (in->sin_family != AF_INET) continue; if (in->sin_addr.s_addr != htonl(INADDR_LOOPBACK)) continue; info->local_port = ntohs(in->sin_port); for (n = 0; n < num_found - 1; ++n) { if (found[n].remote_port != info->local_port || found[n].local_port != info->remote_port) continue; --num_found; memmove(found+n, found+n+1, num_found-n-1); --num_found; break; } } /* return last */ if (num_found == 0) return INVALID_SOCKET; return found[num_found-1].sock; } void odbc_check_no_row(const char *query) { SQLRETURN rc; rc = CHKExecDirect(T(query), SQL_NTS, "SINo"); if (rc == SQL_NO_DATA) return; do { SQLSMALLINT cols; CHKNumResultCols(&cols, "S"); if (cols != 0) { fprintf(stderr, "Data not expected here, query:\n\t%s\n", query); odbc_disconnect(); exit(1); } } while (CHKMoreResults("SNo") == SQL_SUCCESS); } freetds-1.00.82/src/odbc/unittests/common.h100644 025423 025423 00000020533 12717145107 0014237#ifdef _WIN32 #define _CRT_SECURE_NO_WARNINGS 1 #include #include #include #endif #include #include #include #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #if HAVE_STRING_H #include #endif /* HAVE_STRING_H */ #include #include #include #include #ifndef HAVE_SQLLEN #ifndef SQLULEN #define SQLULEN SQLUINTEGER #endif #ifndef SQLLEN #define SQLLEN SQLINTEGER #endif #endif #define FREETDS_SRCDIR FREETDS_TOPDIR "/src/odbc/unittests" extern HENV odbc_env; extern HDBC odbc_conn; extern HSTMT odbc_stmt; extern int odbc_use_version3; extern void (*odbc_set_conn_attr)(void); extern char odbc_err[512]; extern char odbc_sqlstate[6]; extern char odbc_user[512]; extern char odbc_server[512]; extern char odbc_password[512]; extern char odbc_database[512]; extern char odbc_driver[1024]; int odbc_read_login_info(void); void odbc_report_error(const char *msg, int line, const char *file); void odbc_read_error(void); void odbc_check_cols(int n, int line, const char * file); void odbc_check_rows(int n, int line, const char * file); #define ODBC_CHECK_ROWS(n) odbc_check_rows(n, __LINE__, __FILE__) #define ODBC_CHECK_COLS(n) odbc_check_cols(n, __LINE__, __FILE__) void odbc_reset_statement_proc(SQLHSTMT *stmt, const char *file, int line); #define odbc_reset_statement() odbc_reset_statement_proc(&odbc_stmt, __FILE__, __LINE__) void odbc_check_cursor(void); void odbc_check_no_row(const char *query); void odbc_test_skipped(void); #define ODBC_REPORT_ERROR(msg) odbc_report_error(msg, __LINE__, __FILE__) SQLRETURN odbc_check_res(const char *file, int line, SQLRETURN rc, SQLSMALLINT handle_type, SQLHANDLE handle, const char *func, const char *res); #define CHKR(func, params, res) \ odbc_check_res(__FILE__, __LINE__, (func params), 0, 0, #func, res) #define CHKR2(func, params, type, handle, res) \ odbc_check_res(__FILE__, __LINE__, (func params), type, handle, #func, res) SQLSMALLINT odbc_alloc_handle_err_type(SQLSMALLINT type); #define CHKAllocConnect(a,res) \ CHKR2(SQLAllocConnect, (odbc_env,a), SQL_HANDLE_ENV, odbc_env, res) #define CHKAllocEnv(a,res) \ CHKR2(SQLAllocEnv, (a), 0, 0, res) #define CHKAllocStmt(a,res) \ CHKR2(SQLAllocStmt, (odbc_conn,a), SQL_HANDLE_DBC, odbc_conn, res) #define CHKAllocHandle(a,b,c,res) \ CHKR2(SQLAllocHandle, (a,b,c), odbc_alloc_handle_err_type(a), b, res) #define CHKBindCol(a,b,c,d,e,res) \ CHKR2(SQLBindCol, (odbc_stmt,a,b,c,d,e), SQL_HANDLE_STMT, odbc_stmt, res) #define CHKBindParameter(a,b,c,d,e,f,g,h,i,res) \ CHKR2(SQLBindParameter, (odbc_stmt,a,b,c,d,e,f,g,h,i), SQL_HANDLE_STMT, odbc_stmt, res) #define CHKCancel(res) \ CHKR2(SQLCancel, (odbc_stmt), SQL_HANDLE_STMT, odbc_stmt, res) #define CHKCloseCursor(res) \ CHKR2(SQLCloseCursor, (odbc_stmt), SQL_HANDLE_STMT, odbc_stmt, res) #define CHKColAttribute(a,b,c,d,e,f,res) \ CHKR2(SQLColAttribute, (odbc_stmt,a,b,c,d,e,f), SQL_HANDLE_STMT, odbc_stmt, res) #define CHKDescribeCol(a,b,c,d,e,f,g,h,res) \ CHKR2(SQLDescribeCol, (odbc_stmt,a,b,c,d,e,f,g,h), SQL_HANDLE_STMT, odbc_stmt, res) #define CHKConnect(a,b,c,d,e,f,res) \ CHKR2(SQLConnect, (odbc_conn,a,b,c,d,e,f), SQL_HANDLE_DBC, odbc_conn, res) #define CHKDriverConnect(a,b,c,d,e,f,g,res) \ CHKR2(SQLDriverConnect, (odbc_conn,a,b,c,d,e,f,g), SQL_HANDLE_DBC, odbc_conn, res) #define CHKEndTran(a,b,c,res) \ CHKR2(SQLEndTran, (a,b,c), a, b, res) #define CHKExecDirect(a,b,res) \ CHKR2(SQLExecDirect, (odbc_stmt,a,b), SQL_HANDLE_STMT, odbc_stmt, res) #define CHKExecute(res) \ CHKR2(SQLExecute, (odbc_stmt), SQL_HANDLE_STMT, odbc_stmt, res) #define CHKExtendedFetch(a,b,c,d,res) \ CHKR2(SQLExtendedFetch, (odbc_stmt,a,b,c,d), SQL_HANDLE_STMT, odbc_stmt, res) #define CHKFetch(res) \ CHKR2(SQLFetch, (odbc_stmt), SQL_HANDLE_STMT, odbc_stmt, res) #define CHKFetchScroll(a,b,res) \ CHKR2(SQLFetchScroll, (odbc_stmt,a,b), SQL_HANDLE_STMT, odbc_stmt, res) #define CHKFreeHandle(a,b,res) \ CHKR2(SQLFreeHandle, (a,b), a, b, res) #define CHKFreeStmt(a,res) \ CHKR2(SQLFreeStmt, (odbc_stmt,a), SQL_HANDLE_STMT, odbc_stmt, res) #define CHKGetConnectAttr(a,b,c,d,res) \ CHKR2(SQLGetConnectAttr, (odbc_conn,a,b,c,d), SQL_HANDLE_DBC, odbc_conn, res) #define CHKGetDiagRec(a,b,c,d,e,f,g,h,res) \ CHKR2(SQLGetDiagRec, (a,b,c,d,e,f,g,h), a, b, res) #define CHKGetDiagField(a,b,c,d,e,f,g,res) \ CHKR2(SQLGetDiagField, (a,b,c,d,e,f,g), a, b, res) #define CHKGetStmtAttr(a,b,c,d,res) \ CHKR2(SQLGetStmtAttr, (odbc_stmt,a,b,c,d), SQL_HANDLE_STMT, odbc_stmt, res) #define CHKGetTypeInfo(a,res) \ CHKR2(SQLGetTypeInfo, (odbc_stmt,a), SQL_HANDLE_STMT, odbc_stmt, res) #define CHKGetData(a,b,c,d,e,res) \ CHKR2(SQLGetData, (odbc_stmt,a,b,c,d,e), SQL_HANDLE_STMT, odbc_stmt, res) #define CHKMoreResults(res) \ CHKR2(SQLMoreResults, (odbc_stmt), SQL_HANDLE_STMT, odbc_stmt, res) #define CHKNumResultCols(a,res) \ CHKR2(SQLNumResultCols, (odbc_stmt,a), SQL_HANDLE_STMT, odbc_stmt, res) #define CHKParamData(a,res) \ CHKR2(SQLParamData, (odbc_stmt,a), SQL_HANDLE_STMT, odbc_stmt, res) #define CHKParamOptions(a,b,res) \ CHKR2(SQLParamOptions, (odbc_stmt,a,b), SQL_HANDLE_STMT, odbc_stmt, res) #define CHKPrepare(a,b,res) \ CHKR2(SQLPrepare, (odbc_stmt,a,b), SQL_HANDLE_STMT, odbc_stmt, res) #define CHKPutData(a,b,res) \ CHKR2(SQLPutData, (odbc_stmt,a,b), SQL_HANDLE_STMT, odbc_stmt, res) #define CHKRowCount(a,res) \ CHKR2(SQLRowCount, (odbc_stmt,a), SQL_HANDLE_STMT, odbc_stmt, res) #define CHKSetConnectAttr(a,b,c,res) \ CHKR2(SQLSetConnectAttr, (odbc_conn,a,b,c), SQL_HANDLE_DBC, odbc_conn, res) #define CHKSetCursorName(a,b,res) \ CHKR2(SQLSetCursorName, (odbc_stmt,a,b), SQL_HANDLE_STMT, odbc_stmt, res) #define CHKSetPos(a,b,c,res) \ CHKR2(SQLSetPos, (odbc_stmt,a,b,c), SQL_HANDLE_STMT, odbc_stmt, res) #define CHKSetStmtAttr(a,b,c,res) \ CHKR2(SQLSetStmtAttr, (odbc_stmt,a,b,c), SQL_HANDLE_STMT, odbc_stmt, res) #define CHKSetStmtOption(a,b,res) \ CHKR2(SQLSetStmtOption, (odbc_stmt,a,b), SQL_HANDLE_STMT, odbc_stmt, res) #define CHKTables(a,b,c,d,e,f,g,h,res) \ CHKR2(SQLTables, (odbc_stmt,a,b,c,d,e,f,g,h), SQL_HANDLE_STMT, odbc_stmt, res) #define CHKProcedureColumns(a,b,c,d,e,f,g,h,res) \ CHKR2(SQLProcedureColumns, (odbc_stmt,a,b,c,d,e,f,g,h), SQL_HANDLE_STMT, odbc_stmt, res) #define CHKColumns(a,b,c,d,e,f,g,h,res) \ CHKR2(SQLColumns, (odbc_stmt,a,b,c,d,e,f,g,h), SQL_HANDLE_STMT, odbc_stmt, res) #define CHKGetDescRec(a,b,c,d,e,f,g,h,i,j,res) \ CHKR2(SQLGetDescRec, (Descriptor,a,b,c,d,e,f,g,h,i,j), SQL_HANDLE_STMT, Descriptor, res) int odbc_connect(void); int odbc_disconnect(void); SQLRETURN odbc_command_proc(HSTMT stmt, const char *command, const char *file, int line, const char *res); #define odbc_command(cmd) odbc_command_proc(odbc_stmt, cmd, __FILE__, __LINE__, "SNo") #define odbc_command2(cmd, res) odbc_command_proc(odbc_stmt, cmd, __FILE__, __LINE__, res) SQLRETURN odbc_command_with_result(HSTMT stmt, const char *command); int odbc_db_is_microsoft(void); const char *odbc_db_version(void); unsigned int odbc_db_version_int(void); int odbc_driver_is_freetds(void); int odbc_tds_version(void); #define ODBC_VECTOR_SIZE(x) (sizeof(x)/sizeof(x[0])) #define int2ptr(i) ((void*)(((char*)0)+(i))) #define ptr2int(p) ((int)(((char*)(p))-((char*)0))) #if !HAVE_SETENV void odbc_setenv(const char *name, const char *value, int overwrite); #define setenv odbc_setenv #endif void odbc_mark_sockets_opened(void); TDS_SYS_SOCKET odbc_find_last_socket(void); /** * Converts an ODBC result into a string. * There is no check on destination length, use a buffer big enough. */ void odbc_c2string(char *out, SQLSMALLINT out_c_type, const void *in, size_t in_len); int odbc_to_sqlwchar(SQLWCHAR *dst, const char *src, int n); int odbc_from_sqlwchar(char *dst, const SQLWCHAR *src, int n); typedef struct odbc_buf{ struct odbc_buf *next; void *buf; } ODBC_BUF; extern ODBC_BUF *odbc_buf; void *odbc_buf_get(ODBC_BUF** buf, size_t s); void odbc_buf_free(ODBC_BUF** buf); #define ODBC_GET(s) odbc_buf_get(&odbc_buf, s) #define ODBC_FREE() odbc_buf_free(&odbc_buf) SQLWCHAR *odbc_get_sqlwchar(ODBC_BUF** buf, const char *s); char *odbc_get_sqlchar(ODBC_BUF** buf, SQLWCHAR *s); #undef T #ifdef UNICODE /* char to TCHAR */ #define T(s) odbc_get_sqlwchar(&odbc_buf, (s)) /* TCHAR to char */ #define C(s) odbc_get_sqlchar(&odbc_buf, (s)) #else #define T(s) ((SQLCHAR*)(s)) #define C(s) ((char*)(s)) #endif freetds-1.00.82/src/odbc/unittests/array_error.c100644 025423 025423 00000002203 12522201763 0015256#undef NDEBUG #include "common.h" #include /* Test for a bug executing after a not successfully execute */ int main(int argc, char *argv[]) { SQLSMALLINT num_params; SQLLEN sql_nts = SQL_NTS; char string[20]; SQLINTEGER id; odbc_use_version3 = 1; odbc_connect(); odbc_command("create table #tester (id int not null primary key, name varchar(20) not null)"); odbc_command("insert into #tester(id, name) values(1, 'abc')"); odbc_command("insert into #tester(id, name) values(2, 'duck')"); odbc_reset_statement(); CHKPrepare(T("insert into #tester(id, name) values(?,?)"), SQL_NTS, "S"); CHKR(SQLNumParams, (odbc_stmt, &num_params), "S"); assert(num_params == 2); /* now this is going to fail as id is duplicated, causing statement to not be prepared */ id = 1; CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &id, 0, &sql_nts, "S"); strcpy(string, "test"); CHKBindParameter(2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, sizeof(string), 0, string, 0, &sql_nts, "S"); CHKExecute("E"); /* this should success */ id = 4; strcpy(string, "test2"); CHKExecute("S"); odbc_disconnect(); return 0; } freetds-1.00.82/src/odbc/unittests/array_out.c100644 025423 025423 00000010217 12717145107 0014745#include "common.h" #include /* Test using array binding */ static const char *test_query = NULL; static int trunc = 0; static int record_bind = 0; typedef struct { SQLUINTEGER id; SQLLEN id_len; SQLLEN desc_len; } Record; static void query_test(const char* expected, const char *expected_status) { #define ARRAY_SIZE 10 ODBC_BUF *odbc_buf = NULL; SQLUINTEGER *ids; SQLCHAR *descs; SQLLEN *id_lens, *desc_lens; SQLULEN processed; SQLUSMALLINT i, statuses[ARRAY_SIZE]; int desc_len = trunc ? 4 : 51; int rec_size = 0; Record *rec = NULL; char status[20]; assert(odbc_stmt != SQL_NULL_HSTMT); odbc_reset_statement(); SQLSetStmtAttr(odbc_stmt, SQL_ATTR_ROW_STATUS_PTR, statuses, 0); SQLSetStmtAttr(odbc_stmt, SQL_ATTR_ROW_ARRAY_SIZE, (void *) ARRAY_SIZE, 0); SQLSetStmtAttr(odbc_stmt, SQL_ATTR_ROWS_FETCHED_PTR, &processed, 0); SQLSetStmtAttr(odbc_stmt, SQL_ATTR_ROW_BIND_TYPE, SQL_BIND_BY_COLUMN, 0); if (!record_bind) { ids = (SQLUINTEGER *) ODBC_GET(sizeof(SQLUINTEGER) * ARRAY_SIZE); descs = (SQLCHAR *) ODBC_GET(sizeof(SQLCHAR) * ARRAY_SIZE * desc_len); desc_lens = (SQLLEN *) ODBC_GET(sizeof(SQLLEN) * ARRAY_SIZE); id_lens = (SQLLEN *) ODBC_GET(sizeof(SQLLEN) * ARRAY_SIZE); assert(descs && ids && desc_lens && id_lens); } else { rec_size = (sizeof(Record) + (sizeof(SQLCHAR) * desc_len + sizeof(SQLLEN) - 1)) & ~(sizeof(SQLLEN) - 1); SQLSetStmtAttr(odbc_stmt, SQL_ATTR_ROW_BIND_TYPE, int2ptr(rec_size), 0); rec = (Record *) ODBC_GET(rec_size * ARRAY_SIZE); ids = &rec->id; id_lens = &rec->id_len; desc_lens = &rec->desc_len; descs = (SQLCHAR *) (((char *) rec) + sizeof(Record)); } #define REC(f,n) (((char*)f)+rec_size*(n)) #define DESCS(n) (rec ? (SQLCHAR*)REC(descs,n): (descs+(n)*desc_len)) #define IDS(n) *(rec ? (SQLUINTEGER*)REC(ids,n) : &ids[n]) #define ID_LENS(n) *(rec ? (SQLLEN*)REC(id_lens,n) : &id_lens[n]) #define DESC_LENS(n) *(rec ? (SQLLEN*)REC(desc_lens,n) : &desc_lens[n]) processed = ARRAY_SIZE + 1; for (i = 0; i < ARRAY_SIZE; i++) { statuses[i] = SQL_ROW_UPDATED; IDS(i) = i * 132; sprintf((char *) DESCS(i), "aaa"); ID_LENS(i) = 0; DESC_LENS(i) = -i; } SQLBindCol(odbc_stmt, 1, SQL_C_ULONG, &IDS(0), 0, &ID_LENS(0)); SQLBindCol(odbc_stmt, 2, SQL_C_CHAR, DESCS(0), desc_len, &DESC_LENS(0)); CHKExecDirect(T(test_query), SQL_NTS, "S"); CHKFetch(expected); assert(processed <= ARRAY_SIZE); for (i = 0; i < processed; ++i) { char buf[128]; sprintf(buf, "%crow number %d", 'a' + i, i * 13); if (trunc) buf[3] = 0; if (IDS(i) != i + 1 || strcmp((char *) DESCS(i), buf) != 0) { fprintf(stderr, "Invalid result\n\tgot '%d|%s'\n\texpected '%d|%s'\n", (int) IDS(i), DESCS(i), i + 1, buf); exit(1); } switch (statuses[i]) { case SQL_ROW_SUCCESS: status[i] = 'V'; break; case SQL_ROW_SUCCESS_WITH_INFO: status[i] = 'v'; break; case SQL_ROW_ERROR: status[i] = '!'; break; case SQL_ROW_NOROW: status[i] = ' '; break; default: fprintf(stderr, "Invalid status returned\n"); exit(1); } } status[i] = 0; if (expected_status && strcmp(expected_status, status) != 0) { fprintf(stderr, "Invalid status\n\tgot '%s'\n\texpected '%s'\n", status, expected_status); exit(1); } ODBC_FREE(); } int main(int argc, char *argv[]) { int i; odbc_use_version3 = 1; odbc_connect(); odbc_command("CREATE TABLE #odbc_test(i INT, t TEXT)"); for (i = 0; i < 10; ++i) { char buf[128]; sprintf(buf, "INSERT INTO #odbc_test(i, t) VALUES(%d, '%crow number %d')", i + 1, 'a' + i, i * 13); odbc_command(buf); } odbc_reset_statement(); test_query = "SELECT * FROM #odbc_test ORDER BY i"; printf("test line %d\n", __LINE__); query_test("S", "VVVVVVVVVV"); test_query = "SELECT * FROM #odbc_test WHERE i < 7 ORDER BY i"; printf("test line %d\n", __LINE__); query_test("S", "VVVVVV"); /* binding row */ test_query = "SELECT * FROM #odbc_test ORDER BY i"; record_bind = 1; printf("test line %d\n", __LINE__); query_test("S", "VVVVVVVVVV"); /* row and truncation */ trunc = 1; printf("test line %d\n", __LINE__); query_test("I", "!!!!!!!!!!"); /* TODO bind offset, SQLGetData, no bind, error */ odbc_disconnect(); printf("Success!.\n"); return 0; } freetds-1.00.82/src/odbc/unittests/attributes.c100644 025423 025423 00000020732 12717145107 0015131#include "common.h" #include /* * SQLSetStmtAttr */ static int g_result = 0; static unsigned int line_num; static void fatal(const char *msg, ...) { va_list ap; va_start(ap, msg); vfprintf(stderr, msg, ap); va_end(ap); exit(1); } static int get_int(const char *s) { char *end; long l; if (!s) fatal("Line %u: NULL int\n", line_num); l = strtol(s, &end, 0); if (end[0]) fatal("Line %u: Invalid int\n", line_num); return (int) l; } struct lookup_int { const char *name; int value; }; static int lookup(const char *name, const struct lookup_int *table) { if (!table) return get_int(name); for (; table->name; ++table) if (strcmp(table->name, name) == 0) return table->value; return get_int(name); } static const char * unlookup(int value, const struct lookup_int *table) { if (!table) return "??"; for (; table->name; ++table) if (table->value == value) return table->name; return "??"; } static struct lookup_int concurrency[] = { #define TYPE(s) { #s, s } TYPE(SQL_CONCUR_READ_ONLY), TYPE(SQL_CONCUR_LOCK), TYPE(SQL_CONCUR_ROWVER), TYPE(SQL_CONCUR_VALUES), #undef TYPE { NULL, 0 } }; static struct lookup_int scrollable[] = { #define TYPE(s) { #s, s } TYPE(SQL_NONSCROLLABLE), TYPE(SQL_SCROLLABLE), #undef TYPE { NULL, 0 } }; static struct lookup_int sensitivity[] = { #define TYPE(s) { #s, s } TYPE(SQL_UNSPECIFIED), TYPE(SQL_INSENSITIVE), TYPE(SQL_SENSITIVE), #undef TYPE { NULL, 0 } }; static struct lookup_int cursor_type[] = { #define TYPE(s) { #s, s } TYPE(SQL_CURSOR_FORWARD_ONLY), TYPE(SQL_CURSOR_STATIC), TYPE(SQL_CURSOR_KEYSET_DRIVEN), TYPE(SQL_CURSOR_DYNAMIC), #undef TYPE { NULL, 0 } }; static struct lookup_int noscan[] = { #define TYPE(s) { #s, s } TYPE(SQL_NOSCAN_OFF), TYPE(SQL_NOSCAN_ON), #undef TYPE { NULL, 0 } }; static struct lookup_int retrieve_data[] = { #define TYPE(s) { #s, s } TYPE(SQL_RD_ON), TYPE(SQL_RD_OFF), #undef TYPE { NULL, 0 } }; static struct lookup_int simulate_cursor[] = { #define TYPE(s) { #s, s } TYPE(SQL_SC_NON_UNIQUE), TYPE(SQL_SC_TRY_UNIQUE), TYPE(SQL_SC_UNIQUE), #undef TYPE { NULL, 0 } }; static struct lookup_int use_bookmarks[] = { #define TYPE(s) { #s, s } TYPE(SQL_UB_OFF), TYPE(SQL_UB_VARIABLE), TYPE(SQL_UB_FIXED), #undef TYPE { NULL, 0 } }; typedef enum { type_INTEGER, type_UINTEGER, type_SMALLINT, type_LEN, type_CHARP, type_DESC, type_VOIDP } test_type_t; struct attribute { const char *name; int value; test_type_t type; const struct lookup_int *lookup; }; static const struct attribute attributes[] = { #define ATTR(s,t) { #s, s, type_##t, NULL } #define ATTR2(s,t,l) { #s, s, type_##t, l } ATTR(SQL_ATTR_APP_PARAM_DESC, DESC), ATTR(SQL_ATTR_APP_ROW_DESC, DESC), ATTR(SQL_ATTR_ASYNC_ENABLE, UINTEGER), ATTR2(SQL_ATTR_CONCURRENCY, UINTEGER, concurrency), ATTR2(SQL_ATTR_CURSOR_SCROLLABLE, UINTEGER, scrollable), ATTR2(SQL_ATTR_CURSOR_SENSITIVITY, UINTEGER, sensitivity), ATTR2(SQL_ATTR_CURSOR_TYPE, UINTEGER, cursor_type), ATTR(SQL_ATTR_ENABLE_AUTO_IPD, UINTEGER), ATTR(SQL_ATTR_FETCH_BOOKMARK_PTR, VOIDP), ATTR(SQL_ATTR_IMP_PARAM_DESC, DESC), ATTR(SQL_ATTR_IMP_ROW_DESC, DESC), ATTR(SQL_ATTR_KEYSET_SIZE, UINTEGER), ATTR(SQL_ATTR_MAX_LENGTH, UINTEGER), ATTR(SQL_ATTR_MAX_ROWS, UINTEGER), ATTR(SQL_ATTR_METADATA_ID, UINTEGER), ATTR2(SQL_ATTR_NOSCAN, UINTEGER, noscan), ATTR(SQL_ATTR_PARAM_BIND_OFFSET_PTR, VOIDP), ATTR(SQL_ATTR_PARAM_BIND_OFFSET_PTR, VOIDP), ATTR(SQL_ATTR_PARAM_BIND_TYPE, UINTEGER), ATTR(SQL_ATTR_PARAM_OPERATION_PTR, VOIDP), ATTR(SQL_ATTR_PARAM_STATUS_PTR, VOIDP), ATTR(SQL_ATTR_PARAMS_PROCESSED_PTR, VOIDP), ATTR(SQL_ATTR_PARAMSET_SIZE, UINTEGER), ATTR(SQL_ATTR_QUERY_TIMEOUT, UINTEGER), ATTR2(SQL_ATTR_RETRIEVE_DATA, UINTEGER, retrieve_data), ATTR(SQL_ATTR_ROW_ARRAY_SIZE, UINTEGER), ATTR(SQL_ATTR_ROW_BIND_OFFSET_PTR, VOIDP), ATTR(SQL_ATTR_ROW_BIND_TYPE, UINTEGER), ATTR(SQL_ATTR_ROW_NUMBER, UINTEGER), ATTR(SQL_ATTR_ROW_OPERATION_PTR, VOIDP), ATTR(SQL_ATTR_ROW_STATUS_PTR, VOIDP), ATTR(SQL_ATTR_ROWS_FETCHED_PTR, VOIDP), ATTR2(SQL_ATTR_SIMULATE_CURSOR, UINTEGER, simulate_cursor), ATTR2(SQL_ATTR_USE_BOOKMARKS, UINTEGER, use_bookmarks), #undef ATTR2 #undef ATTR }; static const struct attribute * lookup_attr(const char *name) { unsigned int i; if (!name) fatal("Line %u: NULL attribute\n", line_num); for (i = 0; i < sizeof(attributes) / sizeof(attributes[0]); ++i) if (strcmp(attributes[i].name, name) == 0 || strcmp(attributes[i].name + 4, name) == 0) return &attributes[i]; fatal("Line %u: attribute %s not found\n", line_num, name); return NULL; } #define SEP " \t\n" #define ATTR_PARAMS const struct attribute *attr, int expected typedef int (*get_attr_t) (ATTR_PARAMS); static int get_attr_stmt(ATTR_PARAMS) { SQLINTEGER i, ind; SQLSMALLINT si; SQLLEN li; SQLRETURN ret; ret = SQL_ERROR; switch (attr->type) { case type_INTEGER: case type_UINTEGER: i = 0xdeadbeef; ret = SQLGetStmtAttr(odbc_stmt, attr->value, (SQLPOINTER) & i, sizeof(SQLINTEGER), &ind); break; case type_SMALLINT: si = 0xbeef; ret = SQLGetStmtAttr(odbc_stmt, attr->value, (SQLPOINTER) & si, sizeof(SQLSMALLINT), &ind); i = si; break; case type_LEN: li = 0xdeadbeef; ret = SQLGetStmtAttr(odbc_stmt, attr->value, (SQLPOINTER) & li, sizeof(SQLLEN), &ind); i = li; break; case type_VOIDP: case type_DESC: case type_CHARP: fatal("Line %u: CHAR* check still not supported\n", line_num); break; } if (!SQL_SUCCEEDED(ret)) fatal("Line %u: failure not expected\n", line_num); return i; } #if 0 /* do not retry any attribute just return expected value so to make caller happy */ static int get_attr_none(ATTR_PARAMS) { return expected; } #endif int main(int argc, char *argv[]) { #define TEST_FILE "attributes.in" const char *in_file = FREETDS_SRCDIR "/" TEST_FILE; FILE *f; char buf[256]; SQLINTEGER i; SQLLEN len; get_attr_t get_attr_p = get_attr_stmt; odbc_connect(); /* TODO find another way */ odbc_check_cursor(); odbc_command("SET TEXTSIZE 4096"); SQLBindCol(odbc_stmt, 1, SQL_C_SLONG, &i, sizeof(i), &len); f = fopen(in_file, "r"); if (!f) f = fopen(TEST_FILE, "r"); if (!f) { fprintf(stderr, "error opening test file\n"); exit(1); } line_num = 0; while (fgets(buf, sizeof(buf), f)) { char *p = buf, *cmd; ++line_num; while (isspace((unsigned char) *p)) ++p; cmd = strtok(p, SEP); /* skip comments */ if (!cmd || cmd[0] == '#' || cmd[0] == 0 || cmd[0] == '\n') continue; if (strcmp(cmd, "odbc") == 0) { int odbc3 = get_int(strtok(NULL, SEP)) == 3 ? 1 : 0; if (odbc_use_version3 != odbc3) { odbc_use_version3 = odbc3; odbc_disconnect(); odbc_connect(); odbc_command("SET TEXTSIZE 4096"); SQLBindCol(odbc_stmt, 1, SQL_C_SLONG, &i, sizeof(i), &len); } continue; } /* set attribute */ if (strcmp(cmd, "set") == 0) { const struct attribute *attr = lookup_attr(strtok(NULL, SEP)); char *value = strtok(NULL, SEP); SQLRETURN ret; if (!value) fatal("Line %u: value not defined\n", line_num); ret = SQL_ERROR; switch (attr->type) { case type_UINTEGER: case type_INTEGER: ret = SQLSetStmtAttr(odbc_stmt, attr->value, int2ptr(lookup(value, attr->lookup)), sizeof(SQLINTEGER)); break; case type_SMALLINT: ret = SQLSetStmtAttr(odbc_stmt, attr->value, int2ptr(lookup(value, attr->lookup)), sizeof(SQLSMALLINT)); break; case type_LEN: ret = SQLSetStmtAttr(odbc_stmt, attr->value, int2ptr(lookup(value, attr->lookup)), sizeof(SQLLEN)); break; case type_CHARP: ret = SQLSetStmtAttr(odbc_stmt, attr->value, (SQLPOINTER) value, SQL_NTS); break; case type_VOIDP: case type_DESC: fatal("Line %u: not implemented\n"); } if (!SQL_SUCCEEDED(ret)) fatal("Line %u: failure not expected setting statement attribute\n", line_num); get_attr_p = get_attr_stmt; continue; } /* test attribute */ if (strcmp(cmd, "attr") == 0) { const struct attribute *attr = lookup_attr(strtok(NULL, SEP)); char *value = strtok(NULL, SEP); int i, expected = lookup(value, attr->lookup); if (!value) fatal("Line %u: value not defined\n", line_num); i = get_attr_p(attr, expected); if (i != expected) { g_result = 1; fprintf(stderr, "Line %u: invalid %s got %d(%s) expected %s\n", line_num, attr->name, i, unlookup(i, attr->lookup), value); } continue; } if (strcmp(cmd, "reset") == 0) { odbc_reset_statement(); continue; } fatal("Line %u: command '%s' not handled\n", line_num, cmd); } fclose(f); odbc_disconnect(); printf("Done.\n"); return g_result; } freetds-1.00.82/src/odbc/unittests/bcp.c100644 025423 025423 00000030113 12717145107 0013501#include "common.h" #define TDSODBC_BCP #include #include #ifdef UNICODE typedef SQLWCHAR bcp_init_char_t; #else typedef char bcp_init_char_t; #endif struct prefixed_int { ODBCINT64 prefix; int value; }; struct prefixed_str { ODBCINT64 prefix; char value[64]; }; /* * Static data for insertion */ static struct prefixed_int not_null_bit = {4, 1}; static struct prefixed_str not_null_char = {64, "a char"}; static struct prefixed_str not_null_varchar = {64, "a varchar"}; static struct prefixed_str not_null_datetime = {64, "2003-12-17 15:44:00.000"}; static struct prefixed_str not_null_smalldatetime = {64, "2003-12-17 15:44:00"}; static struct prefixed_str not_null_money = {64, "12.34"}; static struct prefixed_str not_null_smallmoney = {64, "12.34"}; static struct prefixed_str not_null_float = {64, "12.34"}; static struct prefixed_str not_null_real = {64, "12.34"}; static struct prefixed_str not_null_decimal = {64, "12.34"}; static struct prefixed_str not_null_numeric = {64, "12.34"}; static struct prefixed_int not_null_int = {4, 1234}; static struct prefixed_int not_null_smallint = {4, 1234}; static struct prefixed_int not_null_tinyint = {4, 123}; static struct prefixed_str not_null_nvarchar = {64, "a wide var"}; static ODBCINT64 null_prefix = -1; static const char *expected[] = { "1", "a char ","a varchar","2003-12-17 15:44:00.000","2003-12-17 15:44:00", "12.34","12.34","12.34","12.3400002","12.34","12.34", "1234","1234","123", "a wide var", }; static const int total_cols = 29; static const char *expected_special[] = { "2015-03-14 15:26:53.000", "2015-03-14 15:26:53.589793", "3.141593000", "3.141593", /* MS driver has "3141593" here. Bug? Should we be bug-compatible? */ "", }; static int tds_version; static void init(void) { odbc_command("if exists (select 1 from sysobjects where type = 'U' and name = 'all_types_bcp_unittest') drop table all_types_bcp_unittest"); odbc_command("if exists (select 1 from sysobjects where type = 'U' and name = 'special_types_bcp_unittest') drop table special_types_bcp_unittest"); odbc_command("CREATE TABLE all_types_bcp_unittest (" " not_null_bit bit NOT NULL" "" ", not_null_char char(10) NOT NULL" ", not_null_varchar varchar(10) NOT NULL" "" ", not_null_datetime datetime NOT NULL" ", not_null_smalldatetime smalldatetime NOT NULL" "" ", not_null_money money NOT NULL" ", not_null_smallmoney smallmoney NOT NULL" "" ", not_null_float float NOT NULL" ", not_null_real real NOT NULL" "" ", not_null_decimal decimal(5,2) NOT NULL" ", not_null_numeric numeric(5,2) NOT NULL" "" ", not_null_int int NOT NULL" ", not_null_smallint smallint NOT NULL" ", not_null_tinyint tinyint NOT NULL" ", not_null_nvarchar nvarchar(10) NOT NULL" "" ", nullable_char char(10) NULL" ", nullable_varchar varchar(10) NULL" "" ", nullable_datetime datetime NULL" ", nullable_smalldatetime smalldatetime NULL" "" ", nullable_money money NULL" ", nullable_smallmoney smallmoney NULL" "" ", nullable_float float NULL" ", nullable_real real NULL" "" ", nullable_decimal decimal(5,2) NULL" ", nullable_numeric numeric(5,2) NULL" "" ", nullable_int int NULL" ", nullable_smallint smallint NULL" ", nullable_tinyint tinyint NULL" ", nullable_nvarchar nvarchar(10) NULL" ")"); if (tds_version < 0x703) return; /* Excludes: * binary * image * uniqueidentifier * varbinary * text * timestamp * nchar * ntext * nvarchar */ odbc_command("CREATE TABLE special_types_bcp_unittest (" "dt datetime not null," "dt2 datetime2(6) not null," "num decimal(19,9) not null," "numstr varchar(64) not null," "empty varchar(64) not null," "bitnull bit null" ")"); } #define VARCHAR_BIND(x) \ bcp_bind( odbc_conn, (unsigned char *) (prefixlen == 0 ? (void*)&x.value : &x), prefixlen, strlen(x.value), NULL, termlen, BCP_TYPE_SQLVARCHAR, col++ ) #define INT_BIND(x) \ bcp_bind( odbc_conn, (unsigned char *) (prefixlen == 0 ? (void*)&x.value : &x), prefixlen, SQL_VARLEN_DATA, NULL, termlen, BCP_TYPE_SQLINT4, col++ ) #define NULL_BIND(x, type) \ bcp_bind( odbc_conn, (unsigned char *) (prefixlen == 0 ? (void*)&x.value : &null_prefix), prefixlen, prefixlen == 0 ? SQL_NULL_DATA : SQL_VARLEN_DATA, NULL, termlen, type, col++ ) static void test_bind(int prefixlen) { enum { termlen = 0 }; RETCODE fOK; int col=1; /* non nulls */ fOK = INT_BIND(not_null_bit); assert(fOK == SUCCEED); fOK = VARCHAR_BIND(not_null_char); assert(fOK == SUCCEED); fOK = VARCHAR_BIND(not_null_varchar); assert(fOK == SUCCEED); fOK = VARCHAR_BIND(not_null_datetime); assert(fOK == SUCCEED); fOK = VARCHAR_BIND(not_null_smalldatetime); assert(fOK == SUCCEED); fOK = VARCHAR_BIND(not_null_money); assert(fOK == SUCCEED); fOK = VARCHAR_BIND(not_null_smallmoney); assert(fOK == SUCCEED); fOK = VARCHAR_BIND(not_null_float); assert(fOK == SUCCEED); fOK = VARCHAR_BIND(not_null_real); assert(fOK == SUCCEED); fOK = VARCHAR_BIND(not_null_decimal); assert(fOK == SUCCEED); fOK = VARCHAR_BIND(not_null_numeric); assert(fOK == SUCCEED); fOK = INT_BIND(not_null_int); assert(fOK == SUCCEED); fOK = INT_BIND(not_null_smallint); assert(fOK == SUCCEED); fOK = INT_BIND(not_null_tinyint); assert(fOK == SUCCEED); fOK = VARCHAR_BIND(not_null_nvarchar); assert(fOK == SUCCEED); /* nulls */ assert(fOK == SUCCEED); fOK = NULL_BIND(not_null_char, BCP_TYPE_SQLVARCHAR); assert(fOK == SUCCEED); fOK = NULL_BIND(not_null_varchar, BCP_TYPE_SQLVARCHAR); assert(fOK == SUCCEED); fOK = NULL_BIND(not_null_datetime, BCP_TYPE_SQLVARCHAR); assert(fOK == SUCCEED); fOK = NULL_BIND(not_null_smalldatetime, BCP_TYPE_SQLVARCHAR); assert(fOK == SUCCEED); fOK = NULL_BIND(not_null_money, BCP_TYPE_SQLVARCHAR); assert(fOK == SUCCEED); fOK = NULL_BIND(not_null_smallmoney, BCP_TYPE_SQLVARCHAR); assert(fOK == SUCCEED); fOK = NULL_BIND(not_null_float, BCP_TYPE_SQLVARCHAR); assert(fOK == SUCCEED); fOK = NULL_BIND(not_null_real, BCP_TYPE_SQLVARCHAR); assert(fOK == SUCCEED); fOK = NULL_BIND(not_null_decimal, BCP_TYPE_SQLVARCHAR); assert(fOK == SUCCEED); fOK = NULL_BIND(not_null_numeric, BCP_TYPE_SQLVARCHAR); assert(fOK == SUCCEED); fOK = NULL_BIND(not_null_int, BCP_TYPE_SQLINT4); assert(fOK == SUCCEED); fOK = NULL_BIND(not_null_smallint, BCP_TYPE_SQLINT4); assert(fOK == SUCCEED); fOK = NULL_BIND(not_null_tinyint, BCP_TYPE_SQLINT4); assert(fOK == SUCCEED); fOK = NULL_BIND(not_null_nvarchar, BCP_TYPE_SQLVARCHAR); assert(fOK == SUCCEED); } static void set_attr(void) { SQLSetConnectAttr(odbc_conn, SQL_COPT_SS_BCP, (SQLPOINTER)SQL_BCP_ON, 0); } static void report_bcp_error(const char *errmsg, int line, const char *file) { odbc_stmt = NULL; odbc_report_error(errmsg, line, file); } static void normal_inserts(int prefixlen); static void normal_select(void); static void special_inserts(void); static void special_select(void); static const char table_name[] = "all_types_bcp_unittest"; int main(int argc, char *argv[]) { const char *s; odbc_set_conn_attr = set_attr; odbc_connect(); tds_version = odbc_tds_version(); init(); normal_inserts(0); if (tds_version >= 0x703) special_inserts(); normal_select(); if (tds_version >= 0x703) special_select(); odbc_command("delete from all_types_bcp_unittest"); normal_inserts(8); normal_select(); if ((s = getenv("BCP")) != NULL && 0 == strcmp(s, "nodrop")) { fprintf(stdout, "BCP=nodrop: '%s' kept\n", table_name); } else { fprintf(stdout, "Dropping table %s\n", table_name); odbc_command("drop table all_types_bcp_unittest"); if (tds_version >= 0x703) odbc_command("drop table special_types_bcp_unittest"); } odbc_disconnect(); printf("Done.\n"); return 0; } static void normal_inserts(int prefixlen) { int i; int rows_sent; /* set up and send the bcp */ fprintf(stdout, "preparing to insert into %s ... ", table_name); if (bcp_init(odbc_conn, (bcp_init_char_t *) T(table_name), NULL, NULL, BCP_DIRECTION_IN) == FAIL) report_bcp_error("bcp_init", __LINE__, __FILE__); fprintf(stdout, "OK\n"); test_bind(prefixlen); fprintf(stdout, "Sending same row 10 times... \n"); for (i=0; i<10; i++) if (bcp_sendrow(odbc_conn) == FAIL) report_bcp_error("bcp_sendrow", __LINE__, __FILE__); #if 1 rows_sent = bcp_batch(odbc_conn); if (rows_sent == -1) report_bcp_error("bcp_batch", __LINE__, __FILE__); #endif printf("OK\n"); /* end bcp. */ rows_sent = bcp_done(odbc_conn); if (rows_sent != 0) report_bcp_error("bcp_done", __LINE__, __FILE__); else printf("%d rows copied.\n", rows_sent); printf("done\n"); } static void special_inserts(void) { int rows_sent; SQL_TIMESTAMP_STRUCT timestamp; DBDATETIME datetime; SQL_NUMERIC_STRUCT numeric; printf("sending special types\n"); rows_sent = 0; if (bcp_init(odbc_conn, (bcp_init_char_t *) T("special_types_bcp_unittest"), NULL, NULL, BCP_DIRECTION_IN) == FAIL) report_bcp_error("bcp_init", __LINE__, __FILE__); printf("OK\n"); datetime.dtdays = 42075; datetime.dttime = 16683900; timestamp.year = 2015; timestamp.month = 3; timestamp.day = 14; timestamp.hour = 15; timestamp.minute = 26; timestamp.second = 53; timestamp.fraction = 589793238; memset(&numeric, 0, sizeof(numeric)); numeric.precision = 19; numeric.scale = 6; numeric.sign = 1; numeric.val[0] = 0xd9; numeric.val[1] = 0xef; numeric.val[2] = 0x2f; bcp_bind(odbc_conn, (unsigned char *) &datetime, 0, sizeof(datetime), NULL, 0, BCP_TYPE_SQLDATETIME, 1); bcp_bind(odbc_conn, (unsigned char *) ×tamp, 0, sizeof(timestamp), NULL, 0, BCP_TYPE_SQLDATETIME2, 2); bcp_bind(odbc_conn, (unsigned char *) &numeric, 0, sizeof(numeric), NULL, 0, BCP_TYPE_SQLDECIMAL, 3); bcp_bind(odbc_conn, (unsigned char *) &numeric, 0, sizeof(numeric), NULL, 0, BCP_TYPE_SQLDECIMAL, 4); bcp_bind(odbc_conn, (unsigned char *) "", 0, 0, NULL, 0, BCP_TYPE_SQLVARCHAR, 5); bcp_bind(odbc_conn, (unsigned char *) ¬_null_bit, 0, SQL_NULL_DATA, NULL, 0, BCP_TYPE_SQLINT4, 6); if (bcp_sendrow(odbc_conn) == FAIL) report_bcp_error("bcp_sendrow", __LINE__, __FILE__); rows_sent = bcp_batch(odbc_conn); if (rows_sent != 1) report_bcp_error("bcp_batch", __LINE__, __FILE__); printf("OK\n"); /* end bcp. */ rows_sent = bcp_done(odbc_conn); if (rows_sent != 0) report_bcp_error("bcp_done", __LINE__, __FILE__); else printf("%d rows copied.\n", rows_sent); printf("done\n"); } static void normal_select(void) { int ok = 1, i; odbc_command("select * from all_types_bcp_unittest"); CHKFetch("SI"); /* first columns have values */ for (i = 0; i < sizeof(expected)/sizeof(expected[0]); ++i) { char output[128]; SQLLEN dataSize; CHKGetData(i + 1, SQL_C_CHAR, output, sizeof(output), &dataSize, "S"); if (strcmp(output, expected[i]) || dataSize <= 0) { fprintf(stderr, "Invalid returned col %d: '%s'!='%s'\n", i, expected[i], output); ok = 0; } } /* others are NULL */ for (; i < total_cols; ++i) { char output[128]; SQLLEN dataSize; CHKGetData(i + 1, SQL_C_CHAR, output, sizeof(output), &dataSize, "S"); if (dataSize != SQL_NULL_DATA) { fprintf(stderr, "Invalid returned col %d: should be NULL'\n", i); ok = 0; } } if (!ok) exit(1); CHKCloseCursor("SI"); } static void special_select(void) { int ok = 1, i; odbc_command("select top 1 * from special_types_bcp_unittest"); CHKFetch("SI"); for (i = 0; i < sizeof(expected_special)/sizeof(expected_special[0]); ++i) { char output[128]; SQLLEN dataSize; CHKGetData(i + 1, SQL_C_CHAR, output, sizeof(output), &dataSize, "S"); if (strcmp(output, expected_special[i]) || (dataSize <= 0 && expected_special[i][0] != '\0')) { fprintf(stderr, "Invalid returned col %d: '%s'!='%s'\n", i, expected_special[i], output); ok = 0; } } if (!ok) exit(1); CHKCloseCursor("SI"); } freetds-1.00.82/src/odbc/unittests/binary_test.c100644 025423 025423 00000007006 12717145107 0015265/** * Summary: Freetds binary patch test. * Author: Gerhard Esterhuizen * Date: April 2003 */ #include "common.h" #include #define ERR_BUF_SIZE 256 /* Name of table used by the test. Should contain single column, of IMAGE type and should contain NO rows at time of program invocation. */ #define TEST_TABLE_NAME "#binary_test" /* Size (in bytes) of the test pattern written to and read from the database. */ #define TEST_BUF_LEN (1024*128) static unsigned char *buf; static void show_error(const char *where, const char *what) { printf("ERROR in %s: %s.\n", where, what); } static void clean_up(void) { free(buf); odbc_disconnect(); } static int test_insert(void *buf, SQLLEN buflen) { SQLHSTMT odbc_stmt = SQL_NULL_HSTMT; SQLLEN strlen_or_ind; const char *qstr = "insert into " TEST_TABLE_NAME " values (?)"; assert(odbc_conn); assert(odbc_env); /* allocate new statement handle */ CHKAllocHandle(SQL_HANDLE_STMT, odbc_conn, &odbc_stmt, "SI"); /* execute query */ CHKPrepare(T(qstr), SQL_NTS, "SI"); strlen_or_ind = buflen; CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_LONGVARBINARY, (SQLUINTEGER) (-1), 0, buf, buflen, &strlen_or_ind, "SI"); CHKExecute("SI"); /* this command shouldn't fail */ odbc_command("DECLARE @i INT"); SQLFreeHandle(SQL_HANDLE_STMT, odbc_stmt); return 0; } static int test_select(void *buf, SQLINTEGER buflen, SQLLEN * bytes_returned) { SQLHSTMT odbc_stmt = SQL_NULL_HSTMT; SQLLEN strlen_or_ind = 0; const char *qstr = "select * from " TEST_TABLE_NAME; assert(odbc_conn); assert(odbc_env); /* allocate new statement handle */ CHKAllocHandle(SQL_HANDLE_STMT, odbc_conn, &odbc_stmt, "SI"); /* execute query */ CHKExecDirect(T(qstr), SQL_NTS, "SINo"); /* fetch first page of first result row of unbound column */ CHKFetch("S"); strlen_or_ind = 0; CHKGetData(1, SQL_C_BINARY, buf, buflen, &strlen_or_ind, "SINo"); *bytes_returned = ((strlen_or_ind > buflen || (strlen_or_ind == SQL_NO_TOTAL)) ? buflen : strlen_or_ind); /* ensure that this was the only row */ CHKFetch("No"); SQLFreeHandle(SQL_HANDLE_STMT, odbc_stmt); ODBC_FREE(); return 0; } #define BYTE_AT(n) (((n) * 123) & 0xff) int main(int argc, char **argv) { int i; SQLLEN bytes_returned; /* do not allocate so big memory in stack */ buf = (unsigned char *) malloc(TEST_BUF_LEN); odbc_connect(); odbc_command("create table " TEST_TABLE_NAME " (im IMAGE)"); odbc_command("SET TEXTSIZE 1000000"); /* populate test buffer with ramp */ for (i = 0; i < TEST_BUF_LEN; i++) { buf[i] = BYTE_AT(i); } /* insert test pattern into database */ if (test_insert(buf, TEST_BUF_LEN) == -1) { clean_up(); return -1; } memset(buf, 0, TEST_BUF_LEN); /* read test pattern from database */ if (test_select(buf, TEST_BUF_LEN, &bytes_returned) == -1) { clean_up(); return -1; } /* compare inserted and read back test patterns */ if (bytes_returned != TEST_BUF_LEN) { show_error("main(): comparing buffers", "Mismatch in input and output pattern sizes."); printf("Expected %lu got %lu\n", (unsigned long) TEST_BUF_LEN, (unsigned long) bytes_returned); clean_up(); return -1; } for (i = 0; i < TEST_BUF_LEN; ++i) { if (buf[i] != BYTE_AT(i)) { printf("mismatch at pos %d %d != %d\n", i, buf[i], BYTE_AT(i)); show_error("main(): comparing buffers", "Mismatch in input and output patterns."); clean_up(); return -1; } } printf("Input and output buffers of length %d match.\nTest passed.\n", TEST_BUF_LEN); clean_up(); return 0; } freetds-1.00.82/src/odbc/unittests/blob1.c100644 025423 025423 00000023027 12717145107 0013742/* Testing large objects */ /* Test from Sebastien Flaesch */ #include "common.h" #include #include #define NBYTES 10000u static int failed = 0; static void fill_chars(char *buf, size_t len, unsigned int start, unsigned int step) { size_t n; for (n = 0; n < len; ++n) buf[n] = 'a' + ((start+n) * step % ('z' - 'a' + 1)); } static void fill_hex(char *buf, size_t len, unsigned int start, unsigned int step) { size_t n; for (n = 0; n < len; ++n) sprintf(buf + 2*n, "%2x", (unsigned int)('a' + ((start+n) * step % ('z' - 'a' + 1)))); } static int check_chars(const char *buf, size_t len, unsigned int start, unsigned int step) { size_t n; for (n = 0; n < len; ++n) if (buf[n] != 'a' + ((start+n) * step % ('z' - 'a' + 1))) return 0; return 1; } static int check_hex(const char *buf, size_t len, unsigned int start, unsigned int step) { size_t n; char symbol[3]; for (n = 0; n < len; ++n) { sprintf(symbol, "%2x", (unsigned int)('a' + ((start+n) / 2 * step % ('z' - 'a' + 1)))); if (tolower((unsigned char) buf[n]) != symbol[(start+n) % 2]) return 0; } return 1; } #define MAX_TESTS 10 typedef struct { unsigned num; SQLSMALLINT c_type, sql_type; const char *db_type; unsigned gen1, gen2; SQLLEN vind; char *buf; } test_info; static test_info test_infos[MAX_TESTS]; static unsigned num_tests = 0; static void dump(FILE* out, const char* start, void* buf, unsigned len) { unsigned n; char s[17]; if (len >= 16) len = 16; fprintf(out, "%s", start); for (n = 0; n < len; ++n) { unsigned char c = ((unsigned char*)buf)[n]; fprintf(out, " %02X", c); s[n] = (c >= 0x20 && c < 127) ? (char) c : '.'; } s[len] = 0; fprintf(out, " - %s\n", s); } static void readBlob(test_info *t) { SQLRETURN rc; char buf[4096]; SQLLEN len, total = 0; int i = 0; int check; printf(">> readBlob field %d\n", t->num); while (1) { i++; rc = CHKGetData(t->num, SQL_C_BINARY, (SQLPOINTER) buf, (SQLINTEGER) sizeof(buf), &len, "SINo"); if (rc == SQL_NO_DATA || len <= 0) break; if (len > (SQLLEN) sizeof(buf)) len = (SQLLEN) sizeof(buf); printf(">> step %d: %d bytes readed\n", i, (int) len); check = check_chars(buf, len, t->gen1 + total, t->gen2); if (!check) { fprintf(stderr, "Wrong buffer content\n"); dump(stderr, " buf ", buf, len); failed = 1; } total += len; } printf(">> total bytes read = %d \n", (int) total); if (total != 10000) { fprintf(stderr, "Wrong buffer length, expected 20000\n"); failed = 1; } } static void readBlobAsChar(test_info *t, int step, int wide) { SQLRETURN rc = SQL_SUCCESS_WITH_INFO; char buf[8192]; SQLLEN len, total = 0, len2; int i = 0; int check; int bufsize; SQLSMALLINT type = SQL_C_CHAR; unsigned int char_len = 1; if (wide) { char_len = sizeof(SQLWCHAR); type = SQL_C_WCHAR; } if (step%2) bufsize = sizeof(buf) - char_len; else bufsize = sizeof(buf); printf(">> readBlobAsChar field %d\n", t->num); while (rc == SQL_SUCCESS_WITH_INFO) { i++; rc = CHKGetData(t->num, type, (SQLPOINTER) buf, (SQLINTEGER) bufsize, &len, "SINo"); if (rc == SQL_SUCCESS_WITH_INFO && len == SQL_NO_TOTAL) { len = bufsize - char_len; rc = SQL_SUCCESS; } if (rc == SQL_NO_DATA || len <= 0) break; rc = CHKGetData(t->num, type, (SQLPOINTER) buf, 0, &len2, "SINo"); if (rc == SQL_SUCCESS_WITH_INFO && len2 != SQL_NO_TOTAL) len = len - len2; #if 0 if (len > (SQLLEN) (bufsize - char_len)) len = (SQLLEN) (bufsize - char_len); len -= len % (2u * char_len); #endif printf(">> step %d: %d bytes readed\n", i, (int) len); if (wide) { len /= sizeof(SQLWCHAR); odbc_from_sqlwchar((char *) buf, (SQLWCHAR *) buf, len + 1); } check = check_hex(buf, len, 2*t->gen1 + total, t->gen2); if (!check) { fprintf(stderr, "Wrong buffer content\n"); dump(stderr, " buf ", buf, len); failed = 1; } total += len; } printf(">> total bytes read = %d \n", (int) total); if (total != 20000) { fprintf(stderr, "Wrong buffer length, expected 20000\n"); failed = 1; } } static void add_test(SQLSMALLINT c_type, SQLSMALLINT sql_type, const char *db_type, unsigned gen1, unsigned gen2) { test_info *t = NULL; size_t buf_len; if (num_tests >= MAX_TESTS) { fprintf(stderr, "too max tests\n"); exit(1); } t = &test_infos[num_tests++]; t->num = num_tests; t->c_type = c_type; t->sql_type = sql_type; t->db_type = db_type; t->gen1 = gen1; t->gen2 = gen2; t->vind = 0; switch (c_type) { case SQL_C_CHAR: buf_len = NBYTES*2+1; break; case SQL_C_WCHAR: buf_len = (NBYTES*2+1) * sizeof(SQLWCHAR); break; default: buf_len = NBYTES; } t->buf = (char*) malloc(buf_len); if (!t->buf) { fprintf(stderr, "memory error\n"); exit(1); } if (c_type != SQL_C_CHAR && c_type != SQL_C_WCHAR) fill_chars(t->buf, NBYTES, t->gen1, t->gen2); else memset(t->buf, 0, buf_len); t->vind = SQL_LEN_DATA_AT_EXEC((SQLLEN) buf_len); } static void free_tests(void) { while (num_tests > 0) { test_info *t = &test_infos[--num_tests]; free(t->buf); t->buf = NULL; } } int main(int argc, char **argv) { SQLRETURN RetCode; SQLHSTMT old_odbc_stmt = SQL_NULL_HSTMT; int i; int key; SQLLEN vind0; int cnt = 2, wide; char sql[256]; test_info *t = NULL; odbc_use_version3 = 1; odbc_connect(); /* tests (W)CHAR/BINARY -> (W)CHAR/BINARY (9 cases) */ add_test(SQL_C_BINARY, SQL_LONGVARCHAR, "TEXT", 123, 1 ); add_test(SQL_C_BINARY, SQL_LONGVARBINARY, "IMAGE", 987, 25); add_test(SQL_C_CHAR, SQL_LONGVARBINARY, "IMAGE", 987, 25); add_test(SQL_C_CHAR, SQL_LONGVARCHAR, "TEXT", 343, 47); add_test(SQL_C_WCHAR, SQL_LONGVARBINARY, "IMAGE", 561, 29); add_test(SQL_C_WCHAR, SQL_LONGVARCHAR, "TEXT", 698, 24); if (odbc_db_is_microsoft()) { add_test(SQL_C_BINARY, SQL_WLONGVARCHAR, "NTEXT", 765, 12); add_test(SQL_C_CHAR, SQL_WLONGVARCHAR, "NTEXT", 237, 71); add_test(SQL_C_WCHAR, SQL_WLONGVARCHAR, "NTEXT", 687, 68); } strcpy(sql, "CREATE TABLE #tt(k INT"); for (t = test_infos; t < test_infos+num_tests; ++t) sprintf(strchr(sql, 0), ",f%u %s", t->num, t->db_type); strcat(sql, ",v INT)"); odbc_command(sql); old_odbc_stmt = odbc_stmt; odbc_stmt = SQL_NULL_HSTMT; /* Insert rows ... */ for (i = 0; i < cnt; i++) { /* MS do not save correctly char -> binary */ if (!odbc_driver_is_freetds() && i) continue; CHKAllocHandle(SQL_HANDLE_STMT, odbc_conn, &odbc_stmt, "S"); strcpy(sql, "INSERT INTO #tt VALUES(?"); for (t = test_infos; t < test_infos+num_tests; ++t) strcat(sql, ",?"); strcat(sql, ",?)"); CHKPrepare(T(sql), SQL_NTS, "S"); CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &key, 0, &vind0, "S"); for (t = test_infos; t < test_infos+num_tests; ++t) CHKBindParameter(t->num+1, SQL_PARAM_INPUT, t->c_type, t->sql_type, 0x10000000, 0, t->buf, 0, &t->vind, "S"); CHKBindParameter(num_tests+2, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &key, 0, &vind0, "S"); key = i; vind0 = 0; printf(">> insert... %d\n", i); RetCode = CHKExecute("SINe"); while (RetCode == SQL_NEED_DATA) { char *p; RetCode = CHKParamData((SQLPOINTER *) & p, "SINe"); printf(">> SQLParamData: ptr = %p RetCode = %d\n", (void *) p, RetCode); if (RetCode == SQL_NEED_DATA) { for (t = test_infos; t < test_infos+num_tests && t->buf != p; ++t) ; assert(t < test_infos+num_tests); if (t->c_type == SQL_C_CHAR || t->c_type == SQL_C_WCHAR) { unsigned char_len = 1; fill_hex(p, NBYTES, t->gen1, t->gen2); if (t->c_type == SQL_C_WCHAR) { char_len = sizeof(SQLWCHAR); odbc_to_sqlwchar((SQLWCHAR*) p, p, NBYTES * 2); } CHKPutData(p, (NBYTES - (i&1)) * char_len, "S"); printf(">> param %p: total bytes written = %d\n", (void *) p, NBYTES - (i&1)); CHKPutData(p + (NBYTES - (i&1)) * char_len, (NBYTES + (i&1)) * char_len, "S"); printf(">> param %p: total bytes written = %d\n", (void *) p, NBYTES + (i&1)); } else { CHKPutData(p, NBYTES, "S"); printf(">> param %p: total bytes written = %d\n", (void *) p, NBYTES); } } } CHKFreeHandle(SQL_HANDLE_STMT, (SQLHANDLE) odbc_stmt, "S"); odbc_stmt = SQL_NULL_HSTMT; } /* Now fetch rows ... */ for (wide = 0; wide < 2; ++wide) for (i = 0; i < cnt; i++) { /* MS do not save correctly char -> binary */ if (!odbc_driver_is_freetds() && i) continue; CHKAllocHandle(SQL_HANDLE_STMT, odbc_conn, &odbc_stmt, "S"); if (odbc_db_is_microsoft()) { CHKSetStmtAttr(SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_NONSCROLLABLE, SQL_IS_UINTEGER, "S"); CHKSetStmtAttr(SQL_ATTR_CURSOR_SENSITIVITY, (SQLPOINTER) SQL_SENSITIVE, SQL_IS_UINTEGER, "S"); } strcpy(sql, "SELECT "); for (t = test_infos; t < test_infos+num_tests; ++t) sprintf(strchr(sql, 0), "f%u,", t->num); strcat(sql, "v FROM #tt WHERE k = ?"); CHKPrepare(T(sql), SQL_NTS, "S"); CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &i, 0, &vind0, "S"); for (t = test_infos; t < test_infos+num_tests; ++t) { t->vind = SQL_DATA_AT_EXEC; CHKBindCol(t->num, SQL_C_BINARY, NULL, 0, &t->vind, "S"); } CHKBindCol(num_tests+1, SQL_C_LONG, &key, 0, &vind0, "S"); vind0 = 0; CHKExecute("S"); CHKFetchScroll(SQL_FETCH_NEXT, 0, "S"); printf(">> fetch... %d\n", i); for (t = test_infos; t < test_infos+num_tests; ++t) { if (t->c_type == SQL_C_CHAR || t->c_type == SQL_C_WCHAR) readBlobAsChar(t, i, wide); else readBlob(t); } CHKCloseCursor("S"); CHKFreeHandle(SQL_HANDLE_STMT, (SQLHANDLE) odbc_stmt, "S"); odbc_stmt = SQL_NULL_HSTMT; } odbc_stmt = old_odbc_stmt; free_tests(); odbc_disconnect(); if (!failed) printf("ok!\n"); return failed ? 1 : 0; } freetds-1.00.82/src/odbc/unittests/cancel.c100644 025423 025423 00000007774 12717145107 0014203/* Testing SQLCancel() */ #include "common.h" #include #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #include #include "replacements.h" #if TDS_HAVE_MUTEX #ifdef _WIN32 #undef HAVE_ALARM #endif static SQLTCHAR sqlstate[SQL_SQLSTATE_SIZE + 1]; static tds_mutex mtx; static void getErrorInfo(SQLSMALLINT sqlhdltype, SQLHANDLE sqlhandle) { SQLINTEGER naterror = 0; SQLTCHAR msgtext[SQL_MAX_MESSAGE_LENGTH + 1]; SQLSMALLINT msgtextl = 0; msgtext[0] = 0; SQLGetDiagRec(sqlhdltype, (SQLHANDLE) sqlhandle, 1, sqlstate, &naterror, msgtext, (SQLSMALLINT) ODBC_VECTOR_SIZE(msgtext), &msgtextl); sqlstate[ODBC_VECTOR_SIZE(sqlstate)-1] = 0; fprintf(stderr, "Diagnostic info:\n"); fprintf(stderr, " SQL State: %s\n", C(sqlstate)); fprintf(stderr, " SQL code : %d\n", (int) naterror); fprintf(stderr, " Message : %s\n", C(msgtext)); } static void exit_forced(int s) { exit(1); } #if HAVE_ALARM static void sigalrm_handler(int s) { printf(">>>> SQLCancel() ...\n"); CHKCancel("S"); printf(">>>> ... SQLCancel done\n"); alarm(4); signal(SIGALRM, exit_forced); } #else #define alarm(x) return; #define signal(sig,h) #endif volatile int exit_thread; static TDS_THREAD_PROC_DECLARE(wait_thread_proc, arg) { int n; tds_sleep_s(4); printf(">>>> SQLCancel() ...\n"); CHKCancel("S"); printf(">>>> ... SQLCancel done\n"); for (n = 0; n < 4; ++n) { tds_sleep_s(1); tds_mutex_lock(&mtx); if (exit_thread) { tds_mutex_unlock(&mtx); return NULL; } tds_mutex_unlock(&mtx); } exit_forced(0); return NULL; } static void Test(int use_threads, int return_data) { tds_thread wait_thread; #if !HAVE_ALARM if (!use_threads) return; #endif printf("testing with %s\n", use_threads ? "threads" : "signals"); printf(">> Wait 5 minutes...\n"); if (!use_threads) { alarm(4); signal(SIGALRM, sigalrm_handler); } else { int err; exit_thread = 0; err = tds_thread_create(&wait_thread, wait_thread_proc, NULL); if (err != 0) { perror("tds_thread_create"); exit(1); } } if (!return_data) CHKExecDirect(T("WAITFOR DELAY '000:05:00'"), SQL_NTS, "E"); else odbc_command2("SELECT MAX(p1.k + p2.k * p3.k ^ p4.k) FROM tab1 p1, tab1 p2, tab1 p3, tab1 p4", "E"); tds_mutex_lock(&mtx); exit_thread = 1; tds_mutex_unlock(&mtx); if (!use_threads) { alarm(0); } else { tds_thread_join(wait_thread, NULL); } getErrorInfo(SQL_HANDLE_STMT, odbc_stmt); if (strcmp(C(sqlstate), "HY008") != 0) { fprintf(stderr, "Unexpected sql state returned\n"); odbc_disconnect(); exit(1); } odbc_reset_statement(); odbc_command("SELECT name FROM sysobjects WHERE 0=1"); } int main(int argc, char **argv) { if (tds_mutex_init(&mtx)) return 1; if (odbc_read_login_info()) exit(1); /* * prepare our odbcinst.ini * is better to do it before connect cause uniODBC cache INIs * the name must be odbcinst.ini cause unixODBC accept only this name */ if (odbc_driver[0]) { FILE *f = fopen("odbcinst.ini", "w"); if (f) { fprintf(f, "[FreeTDS]\nDriver = %s\nThreading = 0\n", odbc_driver); fclose(f); /* force iODBC */ setenv("ODBCINSTINI", "./odbcinst.ini", 1); setenv("SYSODBCINSTINI", "./odbcinst.ini", 1); /* force unixODBC (only directory) */ setenv("ODBCSYSINI", ".", 1); } } odbc_use_version3 = 1; odbc_connect(); odbc_command("IF OBJECT_ID('tab1') IS NOT NULL DROP TABLE tab1"); odbc_command("CREATE TABLE tab1 ( k INT, vc VARCHAR(200) )"); printf(">> Creating tab1...\n"); odbc_command("DECLARE @i INT\n" "SET @i = 1\n" "WHILE @i <= 2000 BEGIN\n" "INSERT INTO tab1 VALUES ( @i, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' )\n" "SET @i = @i + 1\n" "END"); while (CHKMoreResults("SNo") == SQL_SUCCESS) continue; printf(">> ...done.\n"); odbc_reset_statement(); Test(0, 0); Test(1, 0); Test(0, 1); Test(1, 1); odbc_command("DROP TABLE tab1"); odbc_disconnect(); return 0; } #else int main(void) { printf("Not possible for this platform.\n"); return 0; } #endif freetds-1.00.82/src/odbc/unittests/closestmt.c100644 025423 025423 00000002520 12527260163 0014752#include "common.h" /* * This test attempt to test if closing a statement with prepared query * success if there are a pending query on the same connection from * another statement. */ #define SWAP_STMT(b) do { SQLHSTMT xyz = odbc_stmt; odbc_stmt = b; b = xyz; } while(0) int main(int argc, char *argv[]) { char sql[128]; int i; SQLHSTMT stmt; SQLINTEGER num; odbc_use_version3 = 1; odbc_connect(); /* create a table with some rows */ odbc_command("create table #tmp (i int, c varchar(100))"); odbc_command("insert into #tmp values(1, 'some data')"); for (i = 0; i < 8; ++i) { sprintf(sql, "insert into #tmp select i+%d, c from #tmp where i <= %d", 1 << i, 1 << i); odbc_command(sql); } /* execute a prepared query on the connection and get all rows */ CHKPrepare(T("select i from #tmp where i < ?"), SQL_NTS, "S"); num = 5; CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &num, 0, NULL, "S"); CHKExecute("S"); for (i = 1; i < 5; ++i) CHKFetch("S"); CHKFetch("No"); CHKMoreResults("No"); /* start getting some data from another statement */ CHKAllocStmt(&stmt, "S"); SWAP_STMT(stmt); CHKExecDirect(T("select * from #tmp"), SQL_NTS, "S"); /* close first statement with data pending on second */ SWAP_STMT(stmt); CHKFreeStmt(SQL_DROP, "S"); SWAP_STMT(stmt); odbc_disconnect(); return 0; } freetds-1.00.82/src/odbc/unittests/compute.c100644 025423 025423 00000012164 12717145107 0014417#include "common.h" #include /* Test compute results */ /* * This it's quite important cause it test different result types * mssql odbc have also some extension not supported by FreeTDS * and declared in odbcss.h */ static char col1[256], col2[256]; static SQLLEN ind1, ind2; static int main_line; static void TestName(SQLSMALLINT index, const char *expected_name) { SQLTCHAR name[128]; char buf[256]; SQLSMALLINT len, type; #define NAME_TEST \ do { \ if (strcmp(C(name), expected_name) != 0) \ { \ sprintf(buf, "line %d: wrong name in column %d expected '%s' got '%s'", \ main_line, index, expected_name, C(name)); \ ODBC_REPORT_ERROR(buf); \ } \ } while(0) /* retrieve with SQLDescribeCol */ CHKDescribeCol(index, name, ODBC_VECTOR_SIZE(name), &len, &type, NULL, NULL, NULL, "S"); NAME_TEST; /* retrieve with SQLColAttribute */ CHKColAttribute(index, SQL_DESC_NAME, name, ODBC_VECTOR_SIZE(name), &len, NULL, "S"); if (odbc_db_is_microsoft()) NAME_TEST; CHKColAttribute(index, SQL_DESC_LABEL, name, ODBC_VECTOR_SIZE(name), &len, NULL, "S"); NAME_TEST; } static void CheckFetch(const char *c1name, const char *c1, const char *c2) { int error = 0; TestName(1, c1name); CHKFetch("S"); if (strlen(c1) != ind1 || strcmp(c1, col1) != 0) { fprintf(stderr, "%s:%d: Column 1 error '%s' (%d) expected '%s' (%d)\n", __FILE__, main_line, col1, (int) ind1, c1, (int) strlen(c1)); error = 1; } if (strlen(c2) != ind2 || strcmp(c2, col2) != 0) { fprintf(stderr, "%s:%d: Column 2 error '%s' (%d) expected '%s' (%d)\n", __FILE__, main_line, col2, (int) ind2, c2, (int) strlen(c2)); error = 1; } if (error) exit(1); } #define CheckFetch main_line = __LINE__; CheckFetch int main(int argc, char *argv[]) { odbc_connect(); /* MSSQL 2012+, compute not supported */ if (odbc_db_is_microsoft() && odbc_db_version_int() >= 0x0b000000u) { odbc_disconnect(); return 0; } odbc_command("create table #tmp1 (c varchar(20), i int)"); odbc_command("insert into #tmp1 values('pippo', 12)"); odbc_command("insert into #tmp1 values('pippo', 34)"); odbc_command("insert into #tmp1 values('pluto', 1)"); odbc_command("insert into #tmp1 values('pluto', 2)"); odbc_command("insert into #tmp1 values('pluto', 3)"); /* * TODO skip rows/column on compute (compute.c) * TODO check rows/column after moreresults after compute */ /* select * from #tmp1 compute sum(i) */ SQLBindCol(odbc_stmt, 1, SQL_C_CHAR, col1, sizeof(col1), &ind1); SQLBindCol(odbc_stmt, 2, SQL_C_CHAR, col2, sizeof(col2), &ind2); odbc_command("select * from #tmp1 order by c, i compute sum(i)"); CheckFetch("c", "pippo", "12"); CheckFetch("c", "pippo", "34"); CheckFetch("c", "pluto", "1"); CheckFetch("c", "pluto", "2"); CheckFetch("c", "pluto", "3"); CHKFetch("No"); CHKMoreResults("S"); /* why I need to rebind ?? ms bug of feature ?? */ SQLBindCol(odbc_stmt, 1, SQL_C_CHAR, col1, sizeof(col1), &ind1); SQLBindCol(odbc_stmt, 2, SQL_C_CHAR, col2, sizeof(col2), &ind2); col2[0] = '@'; CheckFetch("sum", "52", "@"); CHKFetch("No"); CHKMoreResults("No"); /* select * from #tmp1 order by c compute sum(i) by c */ SQLBindCol(odbc_stmt, 1, SQL_C_CHAR, col1, sizeof(col1), &ind1); SQLBindCol(odbc_stmt, 2, SQL_C_CHAR, col2, sizeof(col2), &ind2); odbc_command("select c as mao, i from #tmp1 order by c, i compute sum(i) by c compute max(i)"); CheckFetch("mao", "pippo", "12"); CheckFetch("mao", "pippo", "34"); CHKFetch("No"); CHKMoreResults("S"); SQLBindCol(odbc_stmt, 1, SQL_C_CHAR, col1, sizeof(col1), &ind1); SQLBindCol(odbc_stmt, 2, SQL_C_CHAR, col2, sizeof(col2), &ind2); strcpy(col2, "##"); CheckFetch("sum", "46", "##"); CHKFetch("No"); CHKMoreResults("S"); SQLBindCol(odbc_stmt, 1, SQL_C_CHAR, col1, sizeof(col1), &ind1); SQLBindCol(odbc_stmt, 2, SQL_C_CHAR, col2, sizeof(col2), &ind2); CheckFetch("mao", "pluto", "1"); CheckFetch("mao", "pluto", "2"); CheckFetch("mao", "pluto", "3"); CHKFetch("No"); CHKMoreResults("S"); SQLBindCol(odbc_stmt, 1, SQL_C_CHAR, col1, sizeof(col1), &ind1); SQLBindCol(odbc_stmt, 2, SQL_C_CHAR, col2, sizeof(col2), &ind2); strcpy(col2, "%"); CheckFetch("sum", "6", "%"); CHKFetch("No"); CHKMoreResults("S"); SQLBindCol(odbc_stmt, 1, SQL_C_CHAR, col1, sizeof(col1), &ind1); SQLBindCol(odbc_stmt, 2, SQL_C_CHAR, col2, sizeof(col2), &ind2); strcpy(col2, "&"); CheckFetch("max", "34", "&"); CHKFetch("No"); CHKMoreResults("No"); /* test skip recordset with computed rows */ /* select * from #tmp1 where i = 2 compute min(i) */ SQLBindCol(odbc_stmt, 1, SQL_C_CHAR, col1, sizeof(col1), &ind1); SQLBindCol(odbc_stmt, 2, SQL_C_CHAR, col2, sizeof(col2), &ind2); odbc_command("select * from #tmp1 where i = 2 or i = 34 order by c, i compute min(i) by c"); CheckFetch("c", "pippo", "34"); CHKFetch("No"); CHKMoreResults("S"); /* here just skip results, before a row */ CHKMoreResults("S"); SQLBindCol(odbc_stmt, 1, SQL_C_CHAR, col1, sizeof(col1), &ind1); SQLBindCol(odbc_stmt, 2, SQL_C_CHAR, col2, sizeof(col2), &ind2); CheckFetch("c", "pluto", "2"); CHKFetch("No"); CHKMoreResults("S"); /* here just skip results, before done */ CHKMoreResults("No"); odbc_disconnect(); return 0; } freetds-1.00.82/src/odbc/unittests/connect.c100644 025423 025423 00000007050 12717145107 0014372#include "common.h" static void init_connect(void); static void init_connect(void) { CHKAllocEnv(&odbc_env, "S"); CHKAllocConnect(&odbc_conn, "S"); } #ifdef _WIN32 #include static char *entry = NULL; static char * get_entry(const char *key) { static char buf[256]; entry = NULL; if (SQLGetPrivateProfileString(odbc_server, key, "", buf, sizeof(buf), "odbc.ini") > 0) entry = buf; return entry; } #endif int main(int argc, char *argv[]) { char tmp[2048]; SQLSMALLINT len; int succeeded = 0; int is_freetds = 1; SQLRETURN rc; if (odbc_read_login_info()) exit(1); /* * prepare our odbcinst.ini * is better to do it before connect cause uniODBC cache INIs * the name must be odbcinst.ini cause unixODBC accept only this name */ if (odbc_driver[0]) { FILE *f = fopen("odbcinst.ini", "w"); if (f) { fprintf(f, "[FreeTDS]\nDriver = %s\n", odbc_driver); fclose(f); /* force iODBC */ setenv("ODBCINSTINI", "./odbcinst.ini", 1); setenv("SYSODBCINSTINI", "./odbcinst.ini", 1); /* force unixODBC (only directory) */ setenv("ODBCSYSINI", ".", 1); } } printf("SQLConnect connect..\n"); odbc_connect(); if (!odbc_driver_is_freetds()) is_freetds = 0; odbc_disconnect(); ++succeeded; if (!is_freetds) { printf("Driver is not FreeTDS, exiting\n"); return 0; } /* try connect string with using DSN */ printf("connect string DSN connect..\n"); init_connect(); sprintf(tmp, "DSN=%s;UID=%s;PWD=%s;DATABASE=%s;", odbc_server, odbc_user, odbc_password, odbc_database); CHKDriverConnect(NULL, T(tmp), SQL_NTS, (SQLTCHAR *) tmp, sizeof(tmp)/sizeof(SQLTCHAR), &len, SQL_DRIVER_NOPROMPT, "SI"); odbc_disconnect(); ++succeeded; /* try connect string using old SERVERNAME specification */ printf("connect string SERVERNAME connect..\n"); printf("odbcinst.ini must be configured with FreeTDS driver..\n"); /* this is expected to work with unixODBC */ init_connect(); sprintf(tmp, "DRIVER=FreeTDS;SERVERNAME=%s;UID=%s;PWD=%s;DATABASE=%s;", odbc_server, odbc_user, odbc_password, odbc_database); rc = CHKDriverConnect(NULL, T(tmp), SQL_NTS, (SQLTCHAR *) tmp, sizeof(tmp)/sizeof(SQLTCHAR), &len, SQL_DRIVER_NOPROMPT, "SIE"); if (rc == SQL_ERROR) { printf("Unable to open data source (ret=%d)\n", rc); } else { ++succeeded; } odbc_disconnect(); /* this is expected to work with iODBC * (passing shared object name as driver) */ if (odbc_driver[0]) { init_connect(); sprintf(tmp, "DRIVER=%s;SERVERNAME=%s;UID=%s;PWD=%s;DATABASE=%s;", odbc_driver, odbc_server, odbc_user, odbc_password, odbc_database); rc = CHKDriverConnect(NULL, T(tmp), SQL_NTS, (SQLTCHAR *) tmp, sizeof(tmp)/sizeof(SQLTCHAR), &len, SQL_DRIVER_NOPROMPT, "SIE"); if (rc == SQL_ERROR) { printf("Unable to open data source (ret=%d)\n", rc); } else { ++succeeded; } odbc_disconnect(); } #ifdef _WIN32 if (get_entry("SERVER")) { init_connect(); sprintf(tmp, "DRIVER=FreeTDS;SERVER=%s;UID=%s;PWD=%s;DATABASE=%s;", entry, odbc_user, odbc_password, odbc_database); if (get_entry("TDS_Version")) sprintf(strchr(tmp, 0), "TDS_Version=%s;", entry); if (get_entry("Port")) sprintf(strchr(tmp, 0), "Port=%s;", entry); rc = CHKDriverConnect(NULL, T(tmp), SQL_NTS, (SQLTCHAR *) tmp, sizeof(tmp)/sizeof(SQLTCHAR), &len, SQL_DRIVER_NOPROMPT, "SIE"); if (rc == SQL_ERROR) { printf("Unable to open data source (ret=%d)\n", rc); } else { ++succeeded; } odbc_disconnect(); } #endif /* at least one should success.. */ if (succeeded < 3) { ODBC_REPORT_ERROR("Too few successes"); exit(1); } printf("Done.\n"); return 0; } freetds-1.00.82/src/odbc/unittests/connect2.c100644 025423 025423 00000005261 12717145107 0014456#include "common.h" /* * Test setting current "catalog" before and after connection using * either SQLConnect and SQLDriverConnect */ static int failed = 0; static void init_connect(void); static void init_connect(void) { CHKAllocEnv(&odbc_env, "S"); CHKAllocConnect(&odbc_conn, "S"); } static void normal_connect(void) { CHKConnect(T(odbc_server), SQL_NTS, T(odbc_user), SQL_NTS, T(odbc_password), SQL_NTS, "SI"); } static void driver_connect(const char *conn_str) { SQLTCHAR tmp[1024]; SQLSMALLINT len; CHKDriverConnect(NULL, T(conn_str), SQL_NTS, tmp, ODBC_VECTOR_SIZE(tmp), &len, SQL_DRIVER_NOPROMPT, "SI"); } static void check_dbname(const char *dbname) { SQLINTEGER len; SQLTCHAR out[512]; char sql[1024]; len = sizeof(out); CHKGetConnectAttr(SQL_ATTR_CURRENT_CATALOG, (SQLPOINTER) out, sizeof(out), &len, "SI"); if (strcmp(C(out), dbname) != 0) { fprintf(stderr, "Current database (%s) is not %s\n", C(out), dbname); failed = 1; } sprintf(sql, "IF DB_NAME() <> '%s' SELECT 1", dbname); CHKAllocStmt(&odbc_stmt, "S"); odbc_check_no_row(sql); SQLFreeStmt(odbc_stmt, SQL_DROP); odbc_stmt = SQL_NULL_HSTMT; } static void set_dbname(const char *dbname) { CHKSetConnectAttr(SQL_ATTR_CURRENT_CATALOG, (SQLPOINTER) T(dbname), strlen(dbname)*sizeof(SQLTCHAR), "SI"); } int main(int argc, char *argv[]) { char tmp[1024]; if (odbc_read_login_info()) exit(1); /* try setting db name before connect */ printf("SQLConnect before 1..\n"); init_connect(); set_dbname("master"); normal_connect(); check_dbname("master"); /* check change after connection */ printf("SQLConnect after..\n"); set_dbname("tempdb"); check_dbname("tempdb"); printf("SQLConnect after not existing..\n"); strcpy(tmp, "IDontExist"); CHKSetConnectAttr(SQL_ATTR_CURRENT_CATALOG, (SQLPOINTER) tmp, strlen(tmp), "E"); check_dbname("tempdb"); odbc_disconnect(); /* try setting db name before connect */ printf("SQLConnect before 2..\n"); init_connect(); set_dbname("tempdb"); normal_connect(); check_dbname("tempdb"); odbc_disconnect(); /* try connect string with using DSN */ printf("SQLDriverConnect before 1..\n"); sprintf(tmp, "DSN=%s;UID=%s;PWD=%s;DATABASE=%s;", odbc_server, odbc_user, odbc_password, odbc_database); init_connect(); set_dbname("master"); driver_connect(tmp); check_dbname(odbc_database); odbc_disconnect(); /* try connect string with using DSN */ printf("SQLDriverConnect before 2..\n"); sprintf(tmp, "DSN=%s;UID=%s;PWD=%s;", odbc_server, odbc_user, odbc_password); init_connect(); set_dbname("tempdb"); driver_connect(tmp); check_dbname("tempdb"); odbc_disconnect(); if (failed) { printf("Some tests failed\n"); return 1; } printf("Done.\n"); return 0; } freetds-1.00.82/src/odbc/unittests/const_params.c100644 025423 025423 00000006763 12522201763 0015437#include "common.h" /* Test for {?=call store(?,123,'foo')} syntax and run */ static char software_version[] = "$Id: const_params.c,v 1.19 2011-07-12 10:16:59 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; int main(int argc, char *argv[]) { SQLINTEGER input, output; SQLINTEGER out1; SQLLEN ind, ind2, ind3; odbc_connect(); if (odbc_command_with_result(odbc_stmt, "drop proc const_param") != SQL_SUCCESS) printf("Unable to execute statement\n"); odbc_command("create proc const_param @in1 int, @in2 int, @in3 datetime, @in4 varchar(10), @out int output as\n" "begin\n" " set nocount on\n" " select @out = 7654321\n" " if (@in1 <> @in2 and @in2 is not null) or @in3 <> convert(datetime, '2004-10-15 12:09:08') or @in4 <> 'foo'\n" " select @out = 1234567\n" " return 24680\n" "end"); CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &input, 0, &ind, "S"); CHKBindParameter(2, SQL_PARAM_OUTPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &out1, 0, &ind2, "S"); /* TODO use {ts ...} for date */ CHKPrepare(T("{call const_param(?, 13579, '2004-10-15 12:09:08', 'foo', ?)}"), SQL_NTS, "S"); input = 13579; ind = sizeof(input); out1 = output = 0xdeadbeef; CHKExecute("S"); if (out1 != 7654321) { fprintf(stderr, "Invalid output %d (0x%x)\n", (int) out1, (int) out1); return 1; } /* just to reset some possible buffers */ odbc_command("DECLARE @i INT"); /* MS ODBC don't support empty parameters altough documented so avoid this test */ if (odbc_driver_is_freetds()) { CHKBindParameter(1, SQL_PARAM_OUTPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &output, 0, &ind, "S"); CHKBindParameter(2, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &input, 0, &ind2, "S"); CHKBindParameter(3, SQL_PARAM_OUTPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &out1, 0, &ind3, "S"); /* TODO use {ts ...} for date */ CHKPrepare(T("{?=call const_param(?, , '2004-10-15 12:09:08', 'foo', ?)}"), SQL_NTS, "S"); input = 13579; ind2 = sizeof(input); out1 = output = 0xdeadbeef; CHKExecute("S"); if (out1 != 7654321) { fprintf(stderr, "Invalid output %d (0x%x)\n", (int) out1, (int) out1); return 1; } if (output != 24680) { fprintf(stderr, "Invalid result %d (0x%x) expected 24680\n", (int) output, (int) output); return 1; } } odbc_command("IF OBJECT_ID('const_param') IS NOT NULL DROP PROC const_param"); odbc_command("create proc const_param @in1 float, @in2 varbinary(100) as\n" "begin\n" " if @in1 <> 12.5 or @in2 <> 0x0102030405060708\n" " return 12345\n" " return 54321\n" "end"); CHKBindParameter(1, SQL_PARAM_OUTPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &output, 0, &ind, "S"); CHKPrepare(T("{?=call const_param(12.5, 0x0102030405060708)}"), SQL_NTS, "S"); output = 0xdeadbeef; CHKExecute("S"); if (output != 54321) { fprintf(stderr, "Invalid result %d (0x%x) expected 54321\n", (int) output, (int) output); return 1; } odbc_command("drop proc const_param"); odbc_command("create proc const_param @in varchar(20) as\n" "begin\n" " if @in = 'value' select 8421\n" " select 1248\n" "end"); /* catch problem reported by Peter Deacon */ output = 0xdeadbeef; odbc_command("{CALL const_param('value')}"); CHKBindCol(1, SQL_C_SLONG, &output, 0, &ind, "S"); SQLFetch(odbc_stmt); if (output != 8421) { fprintf(stderr, "Invalid result %d (0x%x)\n", (int) output, (int) output); return 1; } odbc_reset_statement(); odbc_command("drop proc const_param"); odbc_disconnect(); printf("Done.\n"); return 0; } freetds-1.00.82/src/odbc/unittests/convert_error.c100644 025423 025423 00000003236 12522201763 0015627/* * test SQLBindParameter with text and Sybase * test from Keith Woodard (bug #885122) */ #include "common.h" static char software_version[] = "$Id: convert_error.c,v 1.12 2011-07-12 10:16:59 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static int test_num = 0; static void Test(const char *bind1, SQLSMALLINT type1, const char *bind2, SQLSMALLINT type2) { char sql[512]; char *val = "test"; SQLLEN ind = 4; int id = 1; ODBC_BUF *odbc_buf = NULL; SQLFreeStmt(odbc_stmt, SQL_RESET_PARAMS); ++test_num; sprintf(sql, "insert into #test_output values (%s, %s)", bind1, bind2); CHKPrepare(T(sql), strlen(sql), "S"); if (bind1[0] == '?') CHKBindParameter(id++, SQL_PARAM_INPUT, SQL_C_LONG, type1, 3, 0, &test_num, 0, &ind, "S"); if (bind2[0] == '?') CHKBindParameter(id++, SQL_PARAM_INPUT, SQL_C_CHAR, type2, strlen(val) + 1, 0, (SQLCHAR *) val, 0, &ind, "S"); CHKExecute("S"); ODBC_FREE(); } int main(int argc, char **argv) { odbc_use_version3 = 1; odbc_connect(); odbc_command("create table #test_output (id int, msg text)"); Test("?", SQL_INTEGER, "?", SQL_LONGVARCHAR); Test("123", SQL_INTEGER, "?", SQL_LONGVARCHAR); Test("?", SQL_INTEGER, "'foo'", SQL_LONGVARCHAR); Test("?", SQL_INTEGER, "?", SQL_VARCHAR); /* * Sybase cannot pass this test without complicated query parsing. * Query with blob columns cannot be prepared so prepared query must * be emulated loosing column informations from server and Sybase do * not convert implicitly VARCHAR to INT */ if (odbc_db_is_microsoft()) Test("?", SQL_VARCHAR, "?", SQL_LONGVARCHAR); else ++test_num; odbc_disconnect(); return 0; } freetds-1.00.82/src/odbc/unittests/copydesc.c100644 025423 025423 00000001712 12522201763 0014544#include "common.h" /* Test SQLCopyDesc and SQLAllocHandle(SQL_HANDLE_DESC) */ static char software_version[] = "$Id: copydesc.c,v 1.7 2010-07-05 09:20:32 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; int main(int argc, char *argv[]) { SQLHDESC ard, ard2, ard3; SQLINTEGER id; SQLLEN ind1, ind2; char name[64]; odbc_connect(); CHKGetStmtAttr(SQL_ATTR_APP_ROW_DESC, &ard, 0, NULL, "S"); CHKBindCol(1, SQL_C_SLONG, &id, sizeof(SQLINTEGER), &ind1, "S"); CHKBindCol(2, SQL_C_CHAR, name, sizeof(name), &ind2, "S"); CHKAllocHandle(SQL_HANDLE_DESC, odbc_conn, &ard2, "S"); /* * this is an additional test to test additional allocation * As of 0.64 for a bug in SQLAllocDesc we only allow to allocate one */ CHKAllocHandle(SQL_HANDLE_DESC, odbc_conn, &ard3, "S"); CHKR(SQLCopyDesc, (ard, ard2), "S"); CHKFreeHandle(SQL_HANDLE_DESC, ard3, "S"); odbc_disconnect(); printf("Done.\n"); return 0; } freetds-1.00.82/src/odbc/unittests/cursor1.c100644 025423 025423 00000011270 12717145107 0014336#include "common.h" /* Test cursors */ #define SWAP_STMT(b) do { SQLHSTMT xyz = odbc_stmt; odbc_stmt = b; b = xyz; } while(0) static int mssql2005 = 0; static void Test0(int use_sql, const char *create_sql, const char *insert_sql, const char *select_sql) { #define ROWS 4 #define C_LEN 10 SQLUINTEGER n[ROWS]; char c[ROWS][C_LEN]; SQLLEN c_len[ROWS], n_len[ROWS]; SQLUSMALLINT statuses[ROWS]; SQLUSMALLINT i; SQLULEN num_row; SQLHSTMT stmt2; /* create test table */ odbc_command("IF OBJECT_ID('tempdb..#test') IS NOT NULL DROP TABLE #test"); odbc_command(create_sql); for (i = 1; i <= 6; ++i) { char sql_buf[80], data[10]; memset(data, 'a' + (i - 1), sizeof(data)); data[i] = 0; sprintf(sql_buf, insert_sql, data, i); odbc_command(sql_buf); } /* set cursor options */ odbc_reset_statement(); CHKSetStmtAttr(SQL_ATTR_CONCURRENCY, (SQLPOINTER) SQL_CONCUR_ROWVER, 0, "S"); CHKSetStmtAttr(SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_DYNAMIC, 0, "S"); CHKSetStmtAttr(SQL_ATTR_ROW_ARRAY_SIZE, (SQLPOINTER) ROWS, 0, "S"); CHKSetStmtAttr(SQL_ATTR_ROW_STATUS_PTR, (SQLPOINTER) statuses, 0, "S"); CHKSetStmtAttr(SQL_ATTR_ROWS_FETCHED_PTR, &num_row, 0, "S"); CHKSetCursorName(T("C1"), SQL_NTS, "S"); /* */ CHKExecDirect(T(select_sql), SQL_NTS, "S"); /* bind some rows at a time */ CHKBindCol(1, SQL_C_ULONG, n, 0, n_len, "S"); CHKBindCol(2, SQL_C_CHAR, c, C_LEN, c_len, "S"); /* allocate an additional statement */ CHKAllocStmt(&stmt2, "S"); while (CHKFetchScroll(SQL_FETCH_NEXT, 0, "SNo") == SQL_SUCCESS) { /* print, just for debug */ for (i = 0; i < num_row; ++i) printf("row %d i %d c %s\n", (int) (i + 1), (int) n[i], c[i]); printf("---\n"); /* delete a row */ i = 1; if (i > 0 && i <= num_row) { CHKSetPos(i, use_sql ? SQL_POSITION : SQL_DELETE, SQL_LOCK_NO_CHANGE, mssql2005 ? "SI": "S"); if (use_sql) { SWAP_STMT(stmt2); CHKPrepare(T("DELETE FROM #test WHERE CURRENT OF C1"), SQL_NTS, "S"); CHKExecute("S"); SWAP_STMT(stmt2); } } /* update another row */ i = 2; if (i > 0 && i <= num_row) { strcpy(c[i - 1], "foo"); c_len[i - 1] = 3; if (strstr(select_sql, "#a") == NULL || use_sql) { CHKSetPos(i, use_sql ? SQL_POSITION : SQL_UPDATE, SQL_LOCK_NO_CHANGE, "S"); } else { SQLTCHAR sqlstate[6]; SQLTCHAR msg[256]; n[i - 1] = 321; CHKSetPos(i, use_sql ? SQL_POSITION : SQL_UPDATE, SQL_LOCK_NO_CHANGE, "E"); CHKGetDiagRec(SQL_HANDLE_STMT, odbc_stmt, 1, sqlstate, NULL, msg, ODBC_VECTOR_SIZE(msg), NULL, "S"); if (strstr(C(msg), "Invalid column name 'c'") == NULL) { fprintf(stderr, "Expected message not found at line %d\n", __LINE__); exit(1); } } if (use_sql) { SWAP_STMT(stmt2); CHKPrepare(T("UPDATE #test SET c=? WHERE CURRENT OF C1"), SQL_NTS, "S"); CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, C_LEN, 0, c[i - 1], 0, NULL, "S"); CHKExecute("S"); /* FIXME this is not necessary for mssql driver */ SQLMoreResults(odbc_stmt); SWAP_STMT(stmt2); } } } SWAP_STMT(stmt2); CHKFreeStmt(SQL_DROP, "S"); SWAP_STMT(stmt2); odbc_reset_statement(); /* test values */ odbc_check_no_row("IF (SELECT COUNT(*) FROM #test) <> 4 SELECT 1"); odbc_check_no_row("IF NOT EXISTS(SELECT * FROM #test WHERE i = 3 AND c = 'ccc') SELECT 1"); odbc_check_no_row("IF NOT EXISTS(SELECT * FROM #test WHERE i = 4 AND c = 'dddd') SELECT 1"); if (strstr(select_sql, "#a") == NULL || use_sql) { odbc_check_no_row("IF NOT EXISTS(SELECT * FROM #test WHERE i = 2 AND c = 'foo') SELECT 1"); odbc_check_no_row("IF NOT EXISTS(SELECT * FROM #test WHERE i = 6 AND c = 'foo') SELECT 1"); } } static void Test(int use_sql) { odbc_command_with_result(odbc_stmt, "DROP TABLE #a"); odbc_command("CREATE TABLE #a(x int)"); odbc_command("INSERT INTO #a VALUES(123)"); Test0(use_sql, "CREATE TABLE #test(i int, c varchar(6))", "INSERT INTO #test(c, i) VALUES('%s', %d)", "SELECT x AS i, c FROM #test, #a"); Test0(use_sql, "CREATE TABLE #test(i int, c varchar(6))", "INSERT INTO #test(c, i) VALUES('%s', %d)", "SELECT i, c FROM #test"); if (odbc_db_is_microsoft()) { Test0(use_sql, "CREATE TABLE #test(i int identity(1,1), c varchar(6))", "INSERT INTO #test(c) VALUES('%s')", "SELECT i, c FROM #test"); Test0(use_sql, "CREATE TABLE #test(i int primary key, c varchar(6))", "INSERT INTO #test(c, i) VALUES('%s', %d)", "SELECT i, c FROM #test"); } Test0(use_sql, "CREATE TABLE #test(i int, c varchar(6))", "INSERT INTO #test(c, i) VALUES('%s', %d)", "SELECT i, c, c + 'xxx' FROM #test"); } int main(int argc, char *argv[]) { odbc_connect(); odbc_check_cursor(); if (odbc_db_is_microsoft() && odbc_db_version_int() >= 0x09000000u) mssql2005 = 1; Test(1); Test(0); odbc_disconnect(); return 0; } freetds-1.00.82/src/odbc/unittests/cursor2.c100644 025423 025423 00000002450 12522201763 0014332#include "common.h" /* * 1) Test cursor do not give error for statement that do not return rows * 2) Test cursor returns results on language RPCs */ static char software_version[] = "$Id: cursor2.c,v 1.12 2011-07-12 10:16:59 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; int main(int argc, char *argv[]) { SQLTCHAR sqlstate[6]; SQLTCHAR msg[256]; odbc_connect(); odbc_check_cursor(); odbc_command("CREATE TABLE #cursor2_test (i INT)"); odbc_reset_statement(); CHKSetStmtAttr(SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_DYNAMIC, SQL_IS_INTEGER, "S"); /* this should not fail or return warnings */ odbc_command("DROP TABLE #cursor2_test"); CHKGetDiagRec(SQL_HANDLE_STMT, odbc_stmt, 1, sqlstate, NULL, msg, ODBC_VECTOR_SIZE(msg), NULL, "No"); odbc_reset_statement(); odbc_command_with_result(odbc_stmt, "if object_id('sp_test') is not null drop proc sp_test"); odbc_command("create proc sp_test @name varchar(30) as select 0 as pippo select 1 as 'test', @name as 'nome'"); odbc_reset_statement(); CHKSetStmtAttr(SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_STATIC, SQL_IS_INTEGER, "S"); odbc_command(" exec sp_test 'ciao'"); CHKFetch("S"); odbc_reset_statement(); odbc_command("drop proc sp_test"); odbc_disconnect(); return 0; } freetds-1.00.82/src/odbc/unittests/cursor3.c100644 025423 025423 00000006131 12522201763 0014333/* Tests 2 active statements */ #include "common.h" static char software_version[] = "$Id: cursor3.c,v 1.11 2011-07-12 10:16:59 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; int main(int argc, char **argv) { SQLHSTMT stmt1 = SQL_NULL_HSTMT; SQLHSTMT stmt2 = SQL_NULL_HSTMT; SQLHSTMT old_odbc_stmt; char buff[64]; SQLLEN ind; odbc_use_version3 = 1; odbc_connect(); odbc_check_cursor(); odbc_command("CREATE TABLE #t1 ( k INT, c VARCHAR(20))"); odbc_command("INSERT INTO #t1 VALUES (1, 'aaa')"); odbc_command("INSERT INTO #t1 VALUES (2, 'bbbbb')"); odbc_command("INSERT INTO #t1 VALUES (3, 'ccccccccc')"); odbc_command("INSERT INTO #t1 VALUES (4, 'dd')"); old_odbc_stmt = odbc_stmt; CHKAllocHandle(SQL_HANDLE_STMT, odbc_conn, &stmt1, "S"); CHKAllocHandle(SQL_HANDLE_STMT, odbc_conn, &stmt2, "S"); odbc_stmt = stmt1; /* CHKSetStmtAttr(SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_NONSCROLLABLE, SQL_IS_UINTEGER, "S"); */ CHKSetStmtAttr(SQL_ATTR_CURSOR_SENSITIVITY, (SQLPOINTER) SQL_SENSITIVE, SQL_IS_UINTEGER, "S"); /* CHKSetStmtAttr(SQL_ATTR_CONCURRENCY, (SQLPOINTER) SQL_CONCUR_LOCK, SQL_IS_UINTEGER, "S"); */ odbc_stmt = stmt2; /* CHKSetStmtAttr(SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_NONSCROLLABLE, SQL_IS_UINTEGER, "S"); */ CHKSetStmtAttr(SQL_ATTR_CURSOR_SENSITIVITY, (SQLPOINTER) SQL_SENSITIVE, SQL_IS_UINTEGER, "S"); /* CHKSetStmtAttr(SQL_ATTR_CONCURRENCY, (SQLPOINTER) SQL_CONCUR_LOCK, SQL_IS_UINTEGER, "S"); */ odbc_stmt = stmt1; CHKSetCursorName(T("c1"), SQL_NTS, "S"); odbc_stmt = stmt2; CHKSetCursorName(T("c2"), SQL_NTS, "S"); odbc_stmt = stmt1; CHKPrepare(T("SELECT * FROM #t1 ORDER BY k"), SQL_NTS, "S"); odbc_stmt = stmt2; CHKPrepare(T("SELECT * FROM #t1 ORDER BY k DESC"), SQL_NTS, "S"); odbc_stmt = stmt1; CHKExecute("S"); odbc_stmt = stmt2; CHKExecute("S"); odbc_stmt = stmt1; CHKFetch("S"); CHKGetData(2, SQL_C_CHAR, (SQLPOINTER) buff, sizeof(buff), &ind, "S"); printf(">> Fetch from 1: [%s]\n", buff); odbc_stmt = stmt2; CHKFetch("S"); CHKGetData(2, SQL_C_CHAR, (SQLPOINTER) buff, sizeof(buff), &ind, "S"); printf(">> Fetch from 2: [%s]\n", buff); /* * this should check a problem with SQLGetData * fetch a data on stmt2 than fetch on stmt1 and try to get data on first one */ CHKFetch("S"); /* "ccccccccc" */ odbc_stmt = stmt1; CHKFetch("S"); /* "bbbbb" */ odbc_stmt = stmt2; CHKGetData(2, SQL_C_CHAR, (SQLPOINTER) buff, sizeof(buff), &ind, "S"); printf(">> Fetch from 2: [%s]\n", buff); if (strcmp(buff, "ccccccccc") != 0) ODBC_REPORT_ERROR("Invalid results from SQLGetData"); odbc_stmt = stmt1; CHKGetData(2, SQL_C_CHAR, (SQLPOINTER) buff, sizeof(buff), &ind, "S"); printf(">> Fetch from 1: [%s]\n", buff); if (strcmp(buff, "bbbbb") != 0) ODBC_REPORT_ERROR("Invalid results from SQLGetData"); odbc_stmt = stmt1; CHKCloseCursor("SI"); odbc_stmt = stmt2; CHKCloseCursor("SI"); odbc_stmt = stmt1; CHKFreeHandle(SQL_HANDLE_STMT, (SQLHANDLE) stmt1, "S"); odbc_stmt = stmt2; CHKFreeHandle(SQL_HANDLE_STMT, (SQLHANDLE) stmt2, "S"); odbc_stmt = old_odbc_stmt; odbc_disconnect(); return 0; } freetds-1.00.82/src/odbc/unittests/cursor4.c100644 025423 025423 00000003133 12717145107 0014340/* Test sp_cursorprepare / sp_cursorexecute usage to support SELECT FOR UPDATE * This test compiles and works fine with SQL Server Native Client, and uses * the sp_cursor* API Server Cursors ... */ #include "common.h" static void exec_direct(const char *stmt) { SQLHSTMT odbc_stmt = SQL_NULL_HSTMT; CHKAllocHandle(SQL_HANDLE_STMT, (SQLHANDLE) odbc_conn, (SQLHANDLE *) & odbc_stmt, "S"); odbc_command(stmt); CHKFreeHandle(SQL_HANDLE_STMT, (SQLHANDLE) odbc_stmt, "S"); } int main(int argc, char **argv) { char buff[64]; SQLLEN ind; odbc_use_version3 = 1; odbc_connect(); odbc_check_cursor(); exec_direct("CREATE TABLE #t1 ( k INT, c VARCHAR(20))"); exec_direct("INSERT INTO #t1 VALUES (1, 'aaa')"); odbc_reset_statement(); CHKSetStmtAttr(SQL_ATTR_CONCURRENCY, (SQLPOINTER) SQL_CONCUR_LOCK, SQL_IS_UINTEGER, "S"); CHKSetCursorName(T("c112"), SQL_NTS, "S"); CHKSetConnectAttr(SQL_ATTR_AUTOCOMMIT, int2ptr(SQL_AUTOCOMMIT_OFF), 0, "S"); CHKPrepare(T("SELECT * FROM #t1 FOR UPDATE"), SQL_NTS, "S"); CHKExecute("S"); CHKFetch("S"); exec_direct("UPDATE #t1 SET c = 'xxx' WHERE CURRENT OF c112"); CHKCloseCursor("SI"); CHKEndTran(SQL_HANDLE_DBC, odbc_conn, SQL_COMMIT, "S"); CHKSetConnectAttr(SQL_ATTR_AUTOCOMMIT, int2ptr(SQL_AUTOCOMMIT_ON), 0, "S"); CHKExecDirect(T("SELECT c FROM #t1 WHERE k = 1"), SQL_NTS, "S"); CHKFetch("S"); CHKGetData(1, SQL_C_CHAR, buff, sizeof(buff), &ind, "S"); printf(">> New value after update = [%s] (should be [xxx]) \n", buff); CHKFreeHandle(SQL_HANDLE_STMT, (SQLHANDLE) odbc_stmt, "S"); odbc_stmt = SQL_NULL_HSTMT; odbc_disconnect(); return 0; } freetds-1.00.82/src/odbc/unittests/cursor5.c100644 025423 025423 00000003666 12522201763 0014347#include "common.h" static SQLINTEGER v_int_3; static SQLLEN v_ind_3_1; static char v_char_3[21]; static SQLLEN v_ind_3_2; static int result = 0; static void doFetch(int dir, int pos, int expected) { SQLRETURN RetCode; RetCode = CHKFetchScroll(dir, pos, "SINo"); if (RetCode != SQL_NO_DATA) printf(">> fetch %2d %10d : %d [%s]\n", dir, pos, v_ind_3_1 ? (int) v_int_3 : -1, v_ind_3_2 ? v_char_3 : "null"); else printf(">> fetch %2d %10d : no data found\n", dir, pos); if (expected != (RetCode == SQL_NO_DATA ? -1 : v_int_3)) result = 1; } int main(int argc, char **argv) { odbc_use_version3 = 1; odbc_connect(); odbc_check_cursor(); CHKSetConnectAttr(SQL_ATTR_AUTOCOMMIT, (SQLPOINTER) SQL_AUTOCOMMIT_ON, SQL_IS_UINTEGER, "S"); odbc_command("create table #mytab1 (k int, c char(30))"); odbc_command("insert into #mytab1 values (1,'aaa')"); odbc_command("insert into #mytab1 values (2,'bbb')"); odbc_command("insert into #mytab1 values (3,'ccc')"); odbc_reset_statement(); /* CHKSetStmtAttr(SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_STATIC, 0, "S"); */ CHKSetStmtAttr(SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_SCROLLABLE, SQL_IS_UINTEGER, "S"); CHKPrepare(T("select k, c from #mytab1 order by k"), SQL_NTS, "SI"); CHKBindCol(1, SQL_C_LONG, &v_int_3, 0, &v_ind_3_1, "S"); CHKBindCol(2, SQL_C_CHAR, v_char_3, sizeof(v_char_3), &v_ind_3_2, "S"); CHKExecute("SI"); doFetch(SQL_FETCH_LAST, 0, 3); doFetch(SQL_FETCH_PRIOR, 0, 2); doFetch(SQL_FETCH_PRIOR, 0, 1); doFetch(SQL_FETCH_PRIOR, 0, -1); doFetch(SQL_FETCH_NEXT, 0, 1); doFetch(SQL_FETCH_NEXT, 0, 2); doFetch(SQL_FETCH_NEXT, 0, 3); doFetch(SQL_FETCH_NEXT, 0, -1); doFetch(SQL_FETCH_FIRST, 0, 1); doFetch(SQL_FETCH_NEXT, 0, 2); doFetch(SQL_FETCH_NEXT, 0, 3); doFetch(SQL_FETCH_ABSOLUTE, 3, 3); doFetch(SQL_FETCH_RELATIVE, -2, 1); doFetch(SQL_FETCH_RELATIVE, -2, -1); doFetch(SQL_FETCH_RELATIVE, 5, -1); CHKCloseCursor("SI"); odbc_disconnect(); return result; } freetds-1.00.82/src/odbc/unittests/cursor6.c100644 025423 025423 00000005167 12717145107 0014353#include "common.h" /* Test SQLFetchScroll with no bound columns */ static int bind_all = 0; static int normal_fetch = 0; static int use_cursors = 1; static void Test(void) { #define ROWS 5 struct data_t { SQLINTEGER i; SQLLEN ind_i; char c[20]; SQLLEN ind_c; } data[ROWS]; SQLUSMALLINT statuses[ROWS]; SQLLEN num_row; odbc_reset_statement(); /* this should not fail or return warnings */ if (use_cursors) { CHKSetStmtAttr(SQL_ATTR_CONCURRENCY, int2ptr(SQL_CONCUR_READ_ONLY), 0, "S"); CHKSetStmtAttr(SQL_ATTR_CURSOR_TYPE, int2ptr(SQL_CURSOR_STATIC), 0, "S"); } CHKPrepare(T("SELECT c, i FROM #cursor6_test"), SQL_NTS, "S"); CHKExecute("S"); CHKSetStmtAttr(SQL_ATTR_ROW_BIND_TYPE, int2ptr(sizeof(data[0])), 0, "S"); CHKSetStmtAttr(SQL_ATTR_ROW_ARRAY_SIZE, int2ptr(ROWS), 0, "S"); CHKSetStmtAttr(SQL_ATTR_ROW_STATUS_PTR, statuses, 0, "S"); CHKSetStmtAttr(SQL_ATTR_ROWS_FETCHED_PTR, &num_row, 0, "S"); if (bind_all) CHKBindCol(1, SQL_C_CHAR, &data[0].c, sizeof(data[0].c), &data[0].ind_c, "S"); CHKBindCol(2, SQL_C_LONG, &data[0].i, sizeof(data[0].i), &data[0].ind_i, "S"); #define FILL(s, n) do { \ int _n; for (_n = 0; _n < sizeof(s)/sizeof(s[0]); ++_n) s[_n] = n; \ } while(0) FILL(statuses, 9876); num_row = -3; data[0].i = (SQLINTEGER) 0xdeadbeef; data[1].i = (SQLINTEGER) 0xdeadbeef; if (normal_fetch) CHKFetch("S"); else CHKFetchScroll(SQL_FETCH_NEXT, 0, "S"); /* now check row numbers */ printf("num_row %ld statuses[0] %d statuses[1] %d odbc3 %d\n", (long int) num_row, (int) statuses[0], (int) statuses[1], odbc_use_version3); if (odbc_use_version3 || !normal_fetch) { if (num_row != ROWS || statuses[0] != SQL_ROW_SUCCESS || statuses[1] != SQL_ROW_SUCCESS) { fprintf(stderr, "result error 1\n"); exit(1); } } else { if (data[0].i != 1 || data[1].i != 0xdeadbeef) { fprintf(stderr, "result error 2\n"); exit(1); } } FILL(statuses, 8765); num_row = -3; if (normal_fetch) CHKFetch("S"); else CHKFetchScroll(SQL_FETCH_NEXT, 0, "S"); } static void Init(void) { int i; char sql[128]; odbc_command("CREATE TABLE #cursor6_test (i INT, c VARCHAR(20))"); for (i = 1; i <= 10; ++i) { sprintf(sql, "INSERT INTO #cursor6_test(i,c) VALUES(%d, 'a%db%dc%d')", i, i, i, i); odbc_command(sql); } } int main(int argc, char *argv[]) { odbc_use_version3 = 1; odbc_connect(); odbc_check_cursor(); Init(); #define ALL(n) for (n = 0; n < 2; ++n) ALL(use_cursors) ALL(bind_all) ALL(normal_fetch) Test(); odbc_disconnect(); odbc_use_version3 = 0; odbc_connect(); Init(); ALL(use_cursors) ALL(bind_all) ALL(normal_fetch) Test(); odbc_disconnect(); return 0; } freetds-1.00.82/src/odbc/unittests/cursor7.c100644 025423 025423 00000004705 12522201763 0014344#include "common.h" /* Test SQLFetchScroll with a non-unitary rowset, using bottom-up direction */ static char software_version[] = "$Id: cursor7.c,v 1.10 2011-07-12 10:16:59 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static void Test(void) { enum { ROWS=5 }; struct data_t { SQLINTEGER i; SQLLEN ind_i; char c[20]; SQLLEN ind_c; } data[ROWS]; SQLUSMALLINT statuses[ROWS]; SQLULEN num_row; int i; SQLRETURN RetCode; odbc_reset_statement(); CHKSetStmtAttr(SQL_ATTR_CONCURRENCY, int2ptr(SQL_CONCUR_READ_ONLY), 0, "S"); CHKSetStmtAttr(SQL_ATTR_CURSOR_TYPE, int2ptr(SQL_CURSOR_STATIC), 0, "S"); CHKPrepare(T("SELECT c, i FROM #cursor7_test"), SQL_NTS, "S"); CHKExecute("S"); CHKSetStmtAttr(SQL_ATTR_ROW_BIND_TYPE, int2ptr(sizeof(data[0])), 0, "S"); CHKSetStmtAttr(SQL_ATTR_ROW_ARRAY_SIZE, int2ptr(ROWS), 0, "S"); CHKSetStmtAttr(SQL_ATTR_ROW_STATUS_PTR, statuses, 0, "S"); CHKSetStmtAttr(SQL_ATTR_ROWS_FETCHED_PTR, &num_row, 0, "S"); CHKBindCol(1, SQL_C_CHAR, &data[0].c, sizeof(data[0].c), &data[0].ind_c, "S"); CHKBindCol(2, SQL_C_LONG, &data[0].i, sizeof(data[0].i), &data[0].ind_i, "S"); /* Read records from last to first */ printf("\n\nReading records from last to first:\n"); RetCode = CHKFetchScroll(SQL_FETCH_LAST, -ROWS, "SINo"); while (RetCode != SQL_NO_DATA) { SQLULEN RowNumber; /* Print this set of rows */ for (i = ROWS - 1; i >= 0; i--) { if (statuses[i] != SQL_ROW_NOROW) printf("\t %d, %s\n", (int) data[i].i, data[i].c); } printf("\n"); CHKGetStmtAttr(SQL_ROW_NUMBER, (SQLPOINTER)(&RowNumber), sizeof(RowNumber), NULL, "S"); printf("---> We are in record No: %u\n", (unsigned int) RowNumber); /* Read next rowset */ if ( (RowNumber>1) && (RowNumber #include #include "parser.h" /* * This test is useful to test odbc_tds2sql function * odbc_tds2sql have some particular cases: * (1) numeric -> binary numeric is different in ODBC * (2) * -> binary dependent from libTDS representation and ODBC one * (3) binary -> char TODO * (4) date -> char different format * Also we have to check normal char and wide char */ static int result = 0; static int ignore_select_error = 0; static int ignore_result = 0; static void Test(const char *type, const char *value_to_convert, SQLSMALLINT out_c_type, const char *expected) { char sbuf[1024]; unsigned char out_buf[256]; SQLLEN out_len = 0; SQLFreeStmt(odbc_stmt, SQL_UNBIND); SQLFreeStmt(odbc_stmt, SQL_RESET_PARAMS); /* execute a select to get data as wire */ sprintf(sbuf, "SELECT CONVERT(%s, '%s') AS data", type, value_to_convert); if (strncmp(value_to_convert, "0x", 2) == 0) sprintf(sbuf, "SELECT CONVERT(%s, %s) COLLATE Latin1_General_CI_AS AS data", type, value_to_convert); else if (strcmp(type, "SQL_VARIANT") == 0) sprintf(sbuf, "SELECT CONVERT(SQL_VARIANT, %s) AS data", value_to_convert); else if (strncmp(value_to_convert, "u&'", 3) == 0) sprintf(sbuf, "SELECT CONVERT(%s, %s) AS data", type, value_to_convert); if (ignore_select_error) { if (odbc_command2(sbuf, "SENo") == SQL_ERROR) { odbc_reset_statement(); ignore_select_error = 0; ignore_result = 0; return; } } else { odbc_command(sbuf); } SQLBindCol(odbc_stmt, 1, out_c_type, out_buf, sizeof(out_buf), &out_len); CHKFetch("S"); CHKFetch("No"); CHKMoreResults("No"); /* test results */ odbc_c2string(sbuf, out_c_type, out_buf, out_len); if (!ignore_result && strcmp(sbuf, expected) != 0) { fprintf(stderr, "Wrong result\n Got: %s\n Expected: %s\n", sbuf, expected); result = 1; } ignore_select_error = 0; ignore_result = 0; } static int get_int(const char *s) { char *end; long l; if (!s) odbc_fatal(": NULL int\n"); l = strtol(s, &end, 0); if (end[0]) odbc_fatal(": Invalid int\n"); return (int) l; } struct lookup_int { const char *name; int value; }; static int lookup(const char *name, const struct lookup_int *table) { if (!table) return get_int(name); for (; table->name; ++table) if (strcmp(table->name, name) == 0) return table->value; return get_int(name); } static struct lookup_int sql_c_types[] = { #define TYPE(s) { #s, s } TYPE(SQL_C_NUMERIC), TYPE(SQL_C_BINARY), TYPE(SQL_C_CHAR), TYPE(SQL_C_WCHAR), TYPE(SQL_C_LONG), TYPE(SQL_C_SBIGINT), TYPE(SQL_C_SHORT), TYPE(SQL_C_TIMESTAMP), #undef TYPE { NULL, 0 } }; int main(int argc, char *argv[]) { int cond = 1; #define TEST_FILE "data.in" const char *in_file = FREETDS_SRCDIR "/" TEST_FILE; FILE *f; odbc_connect(); odbc_init_bools(); f = fopen(in_file, "r"); if (!f) f = fopen(TEST_FILE, "r"); if (!f) { fprintf(stderr, "error opening test file\n"); exit(1); } odbc_init_parser(f); for (;;) { char *p; const char *cmd = odbc_get_cmd_line(&p, &cond); if (!cmd) break; /* select type */ if (!strcmp(cmd, "select")) { const char *type = odbc_get_tok(&p); const char *value = odbc_get_str(&p); int c_type = lookup(odbc_get_tok(&p), sql_c_types); const char *expected = odbc_get_str(&p); if (!cond) continue; ignore_select_error = 1; Test(type, value, c_type, expected); continue; } /* select type setting condition */ if (!strcmp(cmd, "select_cond")) { const char *bool_name = odbc_get_tok(&p); const char *type = odbc_get_tok(&p); const char *value = odbc_get_str(&p); int c_type = lookup(odbc_get_tok(&p), sql_c_types); const char *expected = odbc_get_str(&p); int save_result = result; if (!bool_name) odbc_fatal(": no condition name\n"); if (!cond) continue; ignore_select_error = 1; ignore_result = 1; result = 0; Test(type, value, c_type, expected); odbc_set_bool(bool_name, result == 0); result = save_result; continue; } /* execute a sql command */ if (!strcmp(cmd, "sql")) { const char *sql = odbc_get_str(&p); if (!cond) continue; odbc_command(sql); continue; } if (!strcmp(cmd, "sql_cond")) { const char *bool_name = odbc_get_tok(&p); const char *sql = odbc_get_str(&p); if (!cond) continue; odbc_set_bool(bool_name, odbc_command2(sql, "SENo") != SQL_ERROR); continue; } odbc_fatal(": unknown command\n"); } odbc_clear_bools(); fclose(f); printf("\n"); odbc_disconnect(); if (!result) printf("Done successfully!\n"); return result; } freetds-1.00.82/src/odbc/unittests/c2string.c100644 025423 025423 00000004431 12717145107 0014474#include "common.h" #include static char * add_char(char *s, SQLWCHAR ch) { if (ch == '\\') s += sprintf(s, "\\\\"); else if (ch == '\t') s += sprintf(s, "\\t"); else if (ch == '\r') s += sprintf(s, "\\r"); else if (ch == '\n') s += sprintf(s, "\\n"); else if ((unsigned int) ch < 32u) s += sprintf(s, "\\x%02x", (unsigned int) ch); else if ((unsigned int) ch < 256u) s += sprintf(s, "%c", (char) ch); else s += sprintf(s, "\\u%04x", (unsigned int) ch); return s; } void odbc_c2string(char *out, SQLSMALLINT out_c_type, const void *in, size_t in_len) { typedef union { unsigned char bin[256]; char s[256]; SQLWCHAR ws[256/sizeof(SQLWCHAR)]; SQLINTEGER i; SQLBIGINT bi; SQLSMALLINT si; SQL_NUMERIC_STRUCT num; SQL_TIMESTAMP_STRUCT ts; } buf_t; #undef IN #define IN (*((const buf_t*) in)) int i; const SQL_NUMERIC_STRUCT *num; char *s; out[0] = 0; s = out; switch (out_c_type) { case SQL_C_NUMERIC: num = &IN.num; s += sprintf(s, "%d %d %d ", num->precision, num->scale, num->sign); i = SQL_MAX_NUMERIC_LEN; for (; i > 0 && !num->val[--i];) continue; for (; i >= 0; --i) s += sprintf(s, "%02X", num->val[i]); break; case SQL_C_BINARY: assert(in_len >= 0); for (i = 0; i < in_len; ++i) s += sprintf(s, "%02X", IN.bin[i]); break; case SQL_C_CHAR: assert(IN.s[in_len] == 0); s += sprintf(s, "%u ", (unsigned int) in_len); for (i = 0; i < in_len; ++i) s = add_char(s, (unsigned char) IN.s[i]); *s = 0; break; case SQL_C_WCHAR: assert(in_len >=0 && (in_len % sizeof(SQLWCHAR)) == 0); s += sprintf(s, "%u ", (unsigned int) (in_len / sizeof(SQLWCHAR))); for (i = 0; i < in_len / sizeof(SQLWCHAR); ++i) s = add_char(s, IN.ws[i]); *s = 0; break; case SQL_C_LONG: assert(in_len == sizeof(SQLINTEGER)); sprintf(s, "%ld", (long int) IN.i); break; case SQL_C_SBIGINT: assert(in_len == sizeof(SQLBIGINT)); sprintf(s, "%" PRId64, IN.bi); break; case SQL_C_SHORT: assert(in_len == sizeof(SQLSMALLINT)); sprintf(s, "%d", (int) IN.si); break; case SQL_C_TIMESTAMP: sprintf(s, "%04d-%02u-%02u %02u:%02u:%02u.%03u", IN.ts.year, IN.ts.month, IN.ts.day, IN.ts.hour, IN.ts.minute, IN.ts.second, (unsigned) (IN.ts.fraction / 1000000u)); break; default: /* not supported */ assert(0); break; } } freetds-1.00.82/src/odbc/unittests/parser.c100644 025423 025423 00000013025 12717145107 0014234/* * Test reading data with SQLBindCol */ #include "common.h" #include #include #include "parser.h" unsigned int odbc_line_num; void odbc_fatal(const char *msg, ...) { va_list ap; va_start(ap, msg); if (msg[0] == ':') fprintf(stderr, "Line %u", odbc_line_num); vfprintf(stderr, msg, ap); va_end(ap); exit(1); } #define SEP " \t\n" const char * odbc_get_tok(char **p) { char *s = *p, *end; s += strspn(s, SEP); if (!*s) return NULL; end = s + strcspn(s, SEP); *end = 0; *p = end+1; return s; } static void parse_cstr(char *s) { char hexbuf[4]; char *d = s; while (*s) { if (*s != '\\') { *d++ = *s++; continue; } switch (*++s) { case '\"': *d++ = *s++; break; case '\\': *d++ = *s++; break; case 'x': if (strlen(s) < 3) odbc_fatal(": wrong string format\n"); memcpy(hexbuf, ++s, 2); hexbuf[2] = 0; *d++ = (char) strtoul(hexbuf, NULL, 16); s += 2; break; default: odbc_fatal(": wrong string format\n"); } } *d = 0; } const char * odbc_get_str(char **p) { char *s = *p, *end; s += strspn(s, SEP); if (!*s) odbc_fatal(": unable to get string\n"); if (strncmp(s, "\"\"\"", 3) == 0) { s += 3; end = strstr(s, "\"\"\""); if (!end) odbc_fatal(": string not terminated\n"); *end = 0; *p = end+3; } else if (s[0] == '\"') { ++s; end = strchr(s, '\"'); if (!end) odbc_fatal(": string not terminated\n"); *end = 0; parse_cstr(s); *p = end+1; } else { return odbc_get_tok(p); } return s; } enum { MAX_BOOLS = 64 }; typedef struct { char *name; int value; } bool_t; static bool_t bools[MAX_BOOLS]; void odbc_set_bool(const char *name, int value) { unsigned n; value = !!value; for (n = 0; n < MAX_BOOLS && bools[n].name; ++n) if (!strcmp(bools[n].name, name)) { bools[n]. value = value; return; } if (n == MAX_BOOLS) odbc_fatal(": no more boolean variable free\n"); bools[n].name = strdup(name); if (!bools[n].name) odbc_fatal(": out of memory\n"); bools[n].value = value; } static int get_bool(const char *name) { unsigned n; if (!name) odbc_fatal(": boolean variable not provided\n"); for (n = 0; n < MAX_BOOLS && bools[n].name; ++n) if (!strcmp(bools[n].name, name)) return bools[n]. value; odbc_fatal(": boolean variable %s not found\n", name); return 0; } /** initialize booleans, call after connection */ void odbc_init_bools(void) { int big_endian = 1; if (((char *) &big_endian)[0] == 1) big_endian = 0; odbc_set_bool("bigendian", big_endian); odbc_set_bool("msdb", odbc_db_is_microsoft()); odbc_set_bool("freetds", odbc_driver_is_freetds()); } void odbc_clear_bools(void) { unsigned n; for (n = 0; n < MAX_BOOLS && bools[n].name; ++n) { free(bools[n].name); bools[n].name = NULL; } } enum { MAX_CONDITIONS = 32 }; static char conds[MAX_CONDITIONS]; static unsigned cond_level = 0; static int pop_condition(void) { if (cond_level == 0) odbc_fatal(": no related if\n"); return conds[--cond_level]; } static void push_condition(int cond) { if (cond != 0 && cond != 1) odbc_fatal(": invalid cond value %d\n", cond); if (cond_level >= MAX_CONDITIONS) odbc_fatal(": too much nested conditions\n"); conds[cond_level++] = cond; } static int get_not_cond(char **p) { int cond; const char *tok = odbc_get_tok(p); if (!tok) odbc_fatal(": wrong condition syntax\n"); if (!strcmp(tok, "not")) cond = !get_bool(odbc_get_tok(p)); else cond = get_bool(tok); return cond; } static int get_condition(char **p) { int cond1 = get_not_cond(p), cond2; const char *tok; while ((tok=odbc_get_tok(p)) != NULL) { cond2 = get_not_cond(p); if (!strcmp(tok, "or")) cond1 = cond1 || cond2; else if (!strcmp(tok, "and")) cond1 = cond1 && cond2; else odbc_fatal(": wrong condition syntax\n"); } return cond1; } static FILE *parse_file; static char line_buf[1024]; void odbc_init_parser(FILE *f) { if (parse_file) odbc_fatal("parser file already setup\n"); parse_file = f; odbc_line_num = 0; odbc_tds_version(); } const char * odbc_get_cmd_line(char **p_s, int *cond) { while (fgets(line_buf, sizeof(line_buf), parse_file)) { char *p = line_buf; const char *cmd; ++odbc_line_num; cmd = odbc_get_tok(&p); /* skip comments */ if (!cmd || cmd[0] == '#' || cmd[0] == 0 || cmd[0] == '\n') continue; /* conditional statement */ if (!strcmp(cmd, "else")) { int c = pop_condition(); push_condition(c); *cond = c && !*cond; continue; } if (!strcmp(cmd, "endif")) { *cond = pop_condition(); continue; } if (!strcmp(cmd, "if")) { push_condition(*cond); if (*cond) *cond = get_condition(&p); continue; } if (strcmp(cmd, "tds_version_cmp") == 0) { const char *bool_name = odbc_get_tok(&p); const char *cmp = odbc_get_tok(&p); const char *s_ver = odbc_get_tok(&p); int ver = odbc_tds_version(); int expected; int res; unsigned M, m; if (!cmp || !s_ver) odbc_fatal(": missing parameters\n"); if (sscanf(s_ver, "%u.%u", &M, &m) != 2) odbc_fatal(": invalid version %s\n", s_ver); expected = M * 0x100u + m; if (strcmp(cmp, ">") == 0) res = ver > expected; else if (strcmp(cmp, ">=") == 0) res = ver >= expected; else if (strcmp(cmp, "<") == 0) res = ver < expected; else if (strcmp(cmp, "<=") == 0) res = ver <= expected; else if (strcmp(cmp, "==") == 0) res = ver == expected; else if (strcmp(cmp, "!=") == 0) res = ver != expected; else odbc_fatal(": invalid operator %s\n", cmp); if (*cond) odbc_set_bool(bool_name, res); continue; } *p_s = p; return cmd; } return NULL; } freetds-1.00.82/src/odbc/unittests/parser.h100644 025423 025423 00000000617 12522201763 0014237#include extern unsigned int odbc_line_num; void odbc_fatal(const char *msg, ...); const char *odbc_get_tok(char **p); const char *odbc_get_str(char **p); void odbc_set_bool(const char *name, int value); void odbc_init_bools(void); void odbc_clear_bools(void); void odbc_init_parser(FILE *f); const char *odbc_get_cmd_line(char **p, int *cond); #include freetds-1.00.82/src/odbc/unittests/date.c100644 025423 025423 00000002317 12522201763 0013652#include "common.h" static char software_version[] = "$Id: date.c,v 1.14 2011-07-12 10:16:59 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static void DoTest(int n) { SQLCHAR output[256]; SQLSMALLINT colType; SQLULEN colSize; SQLSMALLINT colScale, colNullable; SQLLEN dataSize; TIMESTAMP_STRUCT ts; odbc_command("select convert(datetime, '2002-12-27 18:43:21')"); CHKFetch("SI"); CHKDescribeCol(1, (SQLTCHAR*)output, sizeof(output)/sizeof(SQLWCHAR), NULL, &colType, &colSize, &colScale, &colNullable, "S"); if (n == 0) { memset(&ts, 0, sizeof(ts)); CHKGetData(1, SQL_C_TIMESTAMP, &ts, sizeof(ts), &dataSize, "S"); sprintf((char *) output, "%04d-%02d-%02d %02d:%02d:%02d.000", ts.year, ts.month, ts.day, ts.hour, ts.minute, ts.second); } else { CHKGetData(1, SQL_C_CHAR, output, sizeof(output), &dataSize, "S"); } printf("Date returned: %s\n", output); if (strcmp((char *) output, "2002-12-27 18:43:21.000") != 0) { fprintf(stderr, "Invalid returned date\n"); exit(1); } CHKFetch("No"); CHKCloseCursor("SI"); } int main(int argc, char *argv[]) { odbc_connect(); DoTest(0); DoTest(1); odbc_disconnect(); printf("Done.\n"); return 0; } freetds-1.00.82/src/odbc/unittests/descrec.c100644 025423 025423 00000002254 12522201763 0014345/* test SQLGetDescRec */ #include "common.h" static char software_version[] = "$Id: descrec.c,v 1.3 2011-07-12 10:16:59 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; int main(void) { SQLHDESC Descriptor; SQLINTEGER ind; SQLTCHAR name[128]; SQLSMALLINT si; odbc_use_version3 = 1; odbc_connect(); odbc_command("create table #tmp1 (i int)"); /* get IRD */ CHKGetStmtAttr(SQL_ATTR_IMP_ROW_DESC, &Descriptor, sizeof(Descriptor), &ind, "S"); CHKGetDescRec(-1, name, ODBC_VECTOR_SIZE(name), &si, NULL, NULL, NULL, NULL, NULL, NULL, "E"); /* TODO here should be NO_DATA cause we are requesting bookmark */ /* CHKGetDescRec(0, name, sizeof(name), &si, NULL, NULL, NULL, NULL, NULL, NULL, "No"); */ CHKGetDescRec(1, name, ODBC_VECTOR_SIZE(name), &si, NULL /*Type*/, NULL /*SubType*/, NULL /*Length*/, NULL/*Precision*/, NULL /*Scale*/, NULL /*Nullable*/, "No"); odbc_command("SELECT name FROM sysobjects"); CHKGetDescRec(1, name, ODBC_VECTOR_SIZE(name), &si, NULL /*Type*/, NULL /*SubType*/, NULL /*Length*/, NULL/*Precision*/, NULL /*Scale*/, NULL /*Nullable*/, "S"); odbc_disconnect(); ODBC_FREE(); return 0; } freetds-1.00.82/src/odbc/unittests/describecol.c100644 025423 025423 00000022211 12717145107 0015213#include "common.h" #include #include "parser.h" #include /* * SQLDescribeCol test for precision * test what say SQLDescribeCol about precision using some type */ static int g_result = 0; static int get_int(const char *s) { char *end; long l; if (!s) odbc_fatal(": NULL int\n"); l = strtol(s, &end, 0); if (end[0]) odbc_fatal(": Invalid int\n"); return (int) l; } struct lookup_int { const char *name; int value; }; static int lookup(const char *name, const struct lookup_int *table) { if (!table) return get_int(name); for (; table->name; ++table) if (strcmp(table->name, name) == 0) return table->value; return get_int(name); } static const char* unlookup(long int value, const struct lookup_int *table) { static char buf[32]; sprintf(buf, "%ld", value); if (!table) return buf; for (; table->name; ++table) if (table->value == value) return table->name; return buf; } static struct lookup_int sql_types[] = { #define TYPE(s) { #s, s } TYPE(SQL_CHAR), TYPE(SQL_VARCHAR), TYPE(SQL_LONGVARCHAR), TYPE(SQL_WCHAR), TYPE(SQL_WVARCHAR), TYPE(SQL_WLONGVARCHAR), TYPE(SQL_DECIMAL), TYPE(SQL_NUMERIC), TYPE(SQL_SMALLINT), TYPE(SQL_INTEGER), TYPE(SQL_REAL), TYPE(SQL_FLOAT), TYPE(SQL_DOUBLE), TYPE(SQL_BIT), TYPE(SQL_TINYINT), TYPE(SQL_BIGINT), TYPE(SQL_BINARY), TYPE(SQL_VARBINARY), TYPE(SQL_LONGVARBINARY), TYPE(SQL_DATE), TYPE(SQL_TIME), TYPE(SQL_TIMESTAMP), TYPE(SQL_TYPE_DATE), TYPE(SQL_TYPE_TIME), TYPE(SQL_TYPE_TIMESTAMP), TYPE(SQL_DATETIME), TYPE(SQL_SS_VARIANT), TYPE(SQL_SS_UDT), TYPE(SQL_SS_XML), TYPE(SQL_SS_TABLE), TYPE(SQL_SS_TIME2), TYPE(SQL_SS_TIMESTAMPOFFSET), #undef TYPE { NULL, 0 } }; static struct lookup_int sql_bools[] = { { "SQL_TRUE", SQL_TRUE }, { "SQL_FALSE", SQL_FALSE }, { NULL, 0 } }; typedef enum { type_INTEGER, type_SMALLINT, type_LEN, type_CHARP } test_type_t; struct attribute { const char *name; int value; test_type_t type; const struct lookup_int *lookup; }; static const struct attribute attributes[] = { #define ATTR(s,t) { #s, s, type_##t, NULL } #define ATTR2(s,t,l) { #s, s, type_##t, l } ATTR(SQL_COLUMN_LENGTH, INTEGER), ATTR(SQL_COLUMN_PRECISION, INTEGER), ATTR(SQL_COLUMN_SCALE, INTEGER), ATTR(SQL_DESC_LENGTH, LEN), ATTR(SQL_DESC_OCTET_LENGTH, LEN), ATTR(SQL_DESC_PRECISION, SMALLINT), ATTR(SQL_DESC_SCALE, SMALLINT), ATTR(SQL_DESC_DISPLAY_SIZE, INTEGER), ATTR(SQL_DESC_TYPE_NAME, CHARP), ATTR2(SQL_DESC_CONCISE_TYPE, SMALLINT, sql_types), ATTR2(SQL_DESC_TYPE, SMALLINT, sql_types), ATTR2(SQL_DESC_UNSIGNED, SMALLINT, sql_bools) #undef ATTR2 #undef ATTR }; static const struct attribute * lookup_attr(const char *name) { unsigned int i; if (!name) odbc_fatal(": NULL attribute\n"); for (i = 0; i < sizeof(attributes) / sizeof(attributes[0]); ++i) if (strcmp(attributes[i].name, name) == 0 || strcmp(attributes[i].name + 4, name) == 0) return &attributes[i]; odbc_fatal(": attribute %s not found\n", name); return NULL; } #define ATTR_PARAMS const struct attribute *attr, const char *expected_value typedef void (*check_attr_t) (ATTR_PARAMS); static void check_attr_ird(ATTR_PARAMS) { SQLLEN i; SQLRETURN ret; if (attr->type == type_CHARP) { char buf[256]; SQLSMALLINT len; ret = SQLColAttribute(odbc_stmt, 1, attr->value, buf, sizeof(buf), &len, NULL); if (!SQL_SUCCEEDED(ret)) odbc_fatal(": failure not expected\n"); buf[sizeof(buf)-1] = 0; if (strcmp(C((SQLTCHAR*) buf), expected_value) != 0) { g_result = 1; fprintf(stderr, "Line %u: invalid %s got %s expected %s\n", odbc_line_num, attr->name, buf, expected_value); } return; } i = 0xdeadbeef; ret = SQLColAttribute(odbc_stmt, 1, attr->value, NULL, SQL_IS_INTEGER, NULL, &i); if (!SQL_SUCCEEDED(ret)) odbc_fatal(": failure not expected\n"); /* SQL_DESC_LENGTH is the same of SQLDescribeCol len */ if (attr->value == SQL_DESC_LENGTH) { SQLSMALLINT scale, si; SQLULEN prec; CHKDescribeCol(1, NULL, 0, NULL, &si, &prec, &scale, &si, "S"); if (i != prec) odbc_fatal(": attr %s SQLDescribeCol len %ld != SQLColAttribute len %ld\n", attr->name, (long) prec, (long) i); } if (attr->value == SQL_DESC_SCALE) { SQLSMALLINT scale, si; SQLULEN prec; CHKDescribeCol(1, NULL, 0, NULL, &si, &prec, &scale, &si, "S"); if (i != scale) odbc_fatal(": attr %s SQLDescribeCol scale %ld != SQLColAttribute len %ld\n", attr->name, (long) scale, (long) i); } if (i != lookup(expected_value, attr->lookup)) { g_result = 1; fprintf(stderr, "Line %u: invalid %s got %s expected %s\n", odbc_line_num, attr->name, unlookup(i, attr->lookup), expected_value); } } static void check_attr_ard(ATTR_PARAMS) { SQLINTEGER i, ind; SQLSMALLINT si; SQLLEN li; SQLRETURN ret; SQLHDESC desc = SQL_NULL_HDESC; char buf[256]; /* get ARD */ SQLGetStmtAttr(odbc_stmt, SQL_ATTR_APP_ROW_DESC, &desc, sizeof(desc), &ind); ret = SQL_ERROR; switch (attr->type) { case type_INTEGER: i = 0xdeadbeef; ret = SQLGetDescField(desc, 1, attr->value, (SQLPOINTER) & i, sizeof(SQLINTEGER), &ind); li = i; break; case type_SMALLINT: si = 0xbeef; ret = SQLGetDescField(desc, 1, attr->value, (SQLPOINTER) & si, sizeof(SQLSMALLINT), &ind); li = si; break; case type_LEN: li = 0xdeadbeef; ret = SQLGetDescField(desc, 1, attr->value, (SQLPOINTER) & li, sizeof(SQLLEN), &ind); break; case type_CHARP: ret = SQLGetDescField(desc, 1, attr->value, buf, sizeof(buf), &ind); if (!SQL_SUCCEEDED(ret)) odbc_fatal(": failure not expected\n"); if (strcmp(C((SQLTCHAR*) buf), expected_value) != 0) { g_result = 1; fprintf(stderr, "Line %u: invalid %s got %s expected %s\n", odbc_line_num, attr->name, buf, expected_value); } return; } if (!SQL_SUCCEEDED(ret)) odbc_fatal(": failure not expected\n"); if (li != lookup(expected_value, attr->lookup)) { g_result = 1; fprintf(stderr, "Line %u: invalid %s got %s expected %s\n", odbc_line_num, attr->name, unlookup(i, attr->lookup), expected_value); } } /* do not retry any attribute just return expected value so to make caller happy */ static void check_attr_none(ATTR_PARAMS) { } int main(int argc, char *argv[]) { int cond = 1; #define TEST_FILE "describecol.in" const char *in_file = FREETDS_SRCDIR "/" TEST_FILE; FILE *f; SQLINTEGER i; SQLLEN len; check_attr_t check_attr_p = check_attr_none; odbc_connect(); odbc_init_bools(); odbc_command("SET TEXTSIZE 4096"); SQLBindCol(odbc_stmt, 1, SQL_C_SLONG, &i, sizeof(i), &len); f = fopen(in_file, "r"); if (!f) f = fopen(TEST_FILE, "r"); if (!f) { fprintf(stderr, "error opening test file\n"); exit(1); } odbc_init_parser(f); for (;;) { char *p; const char *cmd; cmd = odbc_get_cmd_line(&p, &cond); if (!cmd) break; ODBC_FREE(); if (strcmp(cmd, "odbc") == 0) { int odbc3 = get_int(odbc_get_tok(&p)) == 3 ? 1 : 0; if (!cond) continue; if (odbc_use_version3 != odbc3) { odbc_use_version3 = odbc3; odbc_disconnect(); odbc_connect(); odbc_command("SET TEXTSIZE 4096"); SQLBindCol(odbc_stmt, 1, SQL_C_SLONG, &i, sizeof(i), &len); } } /* select type */ if (strcmp(cmd, "select") == 0) { const char *type = odbc_get_str(&p); const char *value = odbc_get_str(&p); char sql[1024]; if (!cond) continue; SQLMoreResults(odbc_stmt); odbc_reset_statement(); snprintf(sql, sizeof(sql), "SELECT CONVERT(%s, %s) AS col", type, value); /* ignore error, we only need precision of known types */ check_attr_p = check_attr_none; if (odbc_command_with_result(odbc_stmt, sql) != SQL_SUCCESS) { odbc_reset_statement(); SQLBindCol(odbc_stmt, 1, SQL_C_SLONG, &i, sizeof(i), &len); continue; } CHKFetch("SI"); SQLBindCol(odbc_stmt, 1, SQL_C_SLONG, &i, sizeof(i), &len); check_attr_p = check_attr_ird; } /* set attribute */ if (strcmp(cmd, "set") == 0) { const struct attribute *attr = lookup_attr(odbc_get_tok(&p)); const char *value = odbc_get_str(&p); SQLHDESC desc; SQLRETURN ret; SQLINTEGER ind; if (!value) odbc_fatal(": value not defined\n"); if (!cond) continue; /* get ARD */ SQLGetStmtAttr(odbc_stmt, SQL_ATTR_APP_ROW_DESC, &desc, sizeof(desc), &ind); ret = SQL_ERROR; switch (attr->type) { case type_INTEGER: ret = SQLSetDescField(desc, 1, attr->value, int2ptr(lookup(value, attr->lookup)), sizeof(SQLINTEGER)); break; case type_SMALLINT: ret = SQLSetDescField(desc, 1, attr->value, int2ptr(lookup(value, attr->lookup)), sizeof(SQLSMALLINT)); break; case type_LEN: ret = SQLSetDescField(desc, 1, attr->value, int2ptr(lookup(value, attr->lookup)), sizeof(SQLLEN)); break; case type_CHARP: ret = SQLSetDescField(desc, 1, attr->value, (SQLPOINTER) value, SQL_NTS); break; } if (!SQL_SUCCEEDED(ret)) odbc_fatal(": failure not expected setting ARD attribute\n"); check_attr_p = check_attr_ard; } /* test attribute */ if (strcmp(cmd, "attr") == 0) { const struct attribute *attr = lookup_attr(odbc_get_tok(&p)); const char *expected = odbc_get_str(&p); if (!cond) continue; if (!expected) odbc_fatal(": value not defined\n"); check_attr_p(attr, expected); } } fclose(f); odbc_clear_bools(); odbc_disconnect(); printf("Done.\n"); return g_result; } freetds-1.00.82/src/odbc/unittests/describecol2.c100644 025423 025423 00000002523 12522201763 0015274#include "common.h" #include /* * SQLDescribeCol test */ static int g_result = 0; static void do_check(int c, const char *test, int line) { if (c) return; fprintf(stderr, "Failed check %s at line %d\n", test, line); g_result = 1; } #define check(s) do_check(s, #s, __LINE__) int main(int argc, char *argv[]) { SQLSMALLINT len, type; SQLTCHAR name[128]; odbc_connect(); odbc_command("create table #dc (col_name int, name2 varchar(100))"); odbc_command("select * from #dc"); len = 0x1234; CHKDescribeCol(1, NULL, 0, &len, &type, NULL, NULL, NULL, "S"); check(len == 8); len = 0x1234; CHKDescribeCol(2, name, 0, &len, &type, NULL, NULL, NULL, "I"); check(len == 5); len = 0x1234; CHKDescribeCol(1, NULL, 2, &len, &type, NULL, NULL, NULL, "S"); check(len == 8); len = 0x1234; strcpy((char *) name, "xxx"); CHKDescribeCol(2, name, 3, &len, &type, NULL, NULL, NULL, "I"); check(len == 5 && strcmp(C(name), "na") == 0); len = 0x1234; strcpy((char *) name, "xxx"); CHKDescribeCol(1, name, 1, &len, &type, NULL, NULL, NULL, "I"); check(len == 8 && strcmp(C(name), "") == 0); len = 0x1234; strcpy((char *) name, "xxx"); CHKDescribeCol(2, name, 6, &len, &type, NULL, NULL, NULL, "S"); check(len == 5 && strcmp(C(name), "name2") == 0); odbc_disconnect(); if (g_result == 0) printf("Done.\n"); return g_result; } freetds-1.00.82/src/odbc/unittests/earlybind.c100644 025423 025423 00000003076 12522201763 0014711#include "common.h" static char software_version[] = "$Id: earlybind.c,v 1.5 2010-07-05 09:20:33 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; int main(int argc, char *argv[]) { SQLINTEGER id; SQLLEN ind1, ind2; char name[64]; odbc_connect(); odbc_command("CREATE TABLE #test(id INT, name VARCHAR(100))"); odbc_command("INSERT INTO #test(id, name) VALUES(8, 'sysobjects')"); /* bind before select */ SQLBindCol(odbc_stmt, 1, SQL_C_SLONG, &id, sizeof(SQLINTEGER), &ind1); SQLBindCol(odbc_stmt, 2, SQL_C_CHAR, name, sizeof(name), &ind2); /* do select */ odbc_command("SELECT id, name FROM #test WHERE name = 'sysobjects' SELECT 123, 'foo'"); /* get results */ id = -1; memset(name, 0, sizeof(name)); SQLFetch(odbc_stmt); if (id == -1 || strcmp(name, "sysobjects") != 0) { fprintf(stderr, "wrong results\n"); return 1; } /* discard others data */ SQLFetch(odbc_stmt); SQLMoreResults(odbc_stmt); id = -1; memset(name, 0, sizeof(name)); SQLFetch(odbc_stmt); if (id != 123 || strcmp(name, "foo") != 0) { fprintf(stderr, "wrong results\n"); return 1; } /* discard others data */ SQLFetch(odbc_stmt); SQLMoreResults(odbc_stmt); /* other select */ odbc_command("SELECT 321, 'minni'"); /* get results */ id = -1; memset(name, 0, sizeof(name)); SQLFetch(odbc_stmt); if (id != 321 || strcmp(name, "minni") != 0) { fprintf(stderr, "wrong results\n"); return 1; } /* discard others data */ SQLFetch(odbc_stmt); SQLMoreResults(odbc_stmt); odbc_disconnect(); printf("Done.\n"); return 0; } freetds-1.00.82/src/odbc/unittests/error.c100644 025423 025423 00000002533 12717145107 0014073#include "common.h" /* some tests on error reporting */ int main(int argc, char *argv[]) { SQLRETURN RetCode; HSTMT stmt; odbc_connect(); /* create a test table */ odbc_command("create table #tmp (i int)"); odbc_command("insert into #tmp values(3)"); odbc_command("insert into #tmp values(4)"); odbc_command("insert into #tmp values(5)"); odbc_command("insert into #tmp values(6)"); odbc_command("insert into #tmp values(7)"); /* issue our command */ RetCode = odbc_command2("select 100 / (i - 5) from #tmp order by i", "SE"); /* special case, early Sybase detect error early */ if (RetCode != SQL_ERROR) { /* TODO when multiple row fetch available test for error on some columns */ CHKFetch("S"); CHKFetch("S"); CHKFetch("E"); } odbc_read_error(); if (!strstr(odbc_err, "zero")) { fprintf(stderr, "Message invalid\n"); return 1; } SQLFetch(odbc_stmt); SQLFetch(odbc_stmt); SQLFetch(odbc_stmt); SQLMoreResults(odbc_stmt); CHKAllocStmt(&stmt, "S"); odbc_command("SELECT * FROM sysobjects"); odbc_stmt = stmt; /* a statement is already active so you get error... */ if (odbc_command2("SELECT * FROM sysobjects", "SE") == SQL_SUCCESS) { SQLMoreResults(odbc_stmt); /* ...or we are using MARS! */ odbc_command2("BEGIN TRANSACTION", "E"); } odbc_read_error(); odbc_disconnect(); printf("Done.\n"); return 0; } freetds-1.00.82/src/odbc/unittests/freeclose.c100644 025423 025423 00000024273 12717145107 0014716#include "common.h" #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #include #if HAVE_ERRNO_H #include #endif /* HAVE_ERRNO_H */ #if HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #if HAVE_SYS_STAT_H #include #endif /* HAVE_SYS_STAT_H */ #if HAVE_SYS_IOCTL_H #include #endif /* HAVE_SYS_IOCTL_H */ #if HAVE_SYS_WAIT_H #include #endif /* HAVE_SYS_WAIT_H */ #if HAVE_NETINET_IN_H #include #endif /* HAVE_NETINET_IN_H */ #if (!defined(TDS_NO_THREADSAFE) && HAVE_ALARM && HAVE_FSTAT && defined(S_IFSOCK)) || defined(_WIN32) #include #include #include /* this crazy test test that we do not send too much prepare ... */ static tds_mutex mtx; typedef union { struct sockaddr sa; struct sockaddr_in sin; char dummy[256]; } long_sockaddr; static long_sockaddr remote_addr; static socklen_t remote_addr_len; static TDS_SYS_SOCKET fake_sock; static tds_thread fake_thread; #ifdef _WIN32 #define alarm(n) do { ; } while(0) #endif static TDS_THREAD_PROC_DECLARE(fake_thread_proc, arg); static int init_fake_server(int ip_port) { struct sockaddr_in sin; TDS_SYS_SOCKET s; memset(&sin, 0, sizeof(sin)); sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); sin.sin_port = htons((short) ip_port); sin.sin_family = AF_INET; if (TDS_IS_SOCKET_INVALID(s = socket(AF_INET, SOCK_STREAM, 0))) { perror("socket"); exit(1); } if (bind(s, (struct sockaddr *) &sin, sizeof(sin)) < 0) { perror("bind"); CLOSESOCKET(s); return 1; } if (listen(s, 5) < 0) { perror("listen"); CLOSESOCKET(s); return 1; } if (tds_thread_create(&fake_thread, fake_thread_proc, int2ptr(s)) != 0) { perror("tds_thread_create"); exit(1); } return 0; } static void write_all(TDS_SYS_SOCKET s, const void *buf, size_t len) { int res, l; fd_set fds_write; for (; len > 0;) { FD_ZERO(&fds_write); FD_SET(s, &fds_write); res = select(s + 1, NULL, &fds_write, NULL, NULL); if (res <= 0) { if (errno == EINTR) continue; perror("select"); exit(1); } l = WRITESOCKET(s, buf, len); if (l <= 0) { perror("write socket"); exit(1); } buf = ((const char *) buf) + l; len -= l; } } static unsigned int inserts = 0; static char insert_buf[256] = ""; static void count_insert(const char* buf, size_t len) { static const char search[] = "insert into"; static unsigned char prev = 'x'; char *p; unsigned char c; size_t insert_len; /* add to buffer */ for (p = strchr(insert_buf, 0); len > 0; --len, ++buf) { c = (unsigned char) buf[0]; if (prev == 0 || c != 0) *p++ = (c >= ' ' && c < 128) ? tolower(c) : '_'; prev = c; } *p = 0; /* check it */ while ((p=strstr(insert_buf, search)) != NULL) { tds_mutex_lock(&mtx); ++inserts; tds_mutex_unlock(&mtx); /* do not find again */ p[0] = '_'; } /* avoid buffer too long */ insert_len = strlen(insert_buf); if (insert_len > sizeof(search)) { p = insert_buf + insert_len - sizeof(search); memmove(insert_buf, p, strlen(p) + 1); } } static unsigned int round_trips = 0; static enum { sending, receiving } flow = sending; static TDS_THREAD_PROC_DECLARE(fake_thread_proc, arg) { TDS_SYS_SOCKET s = ptr2int(arg), server_sock; socklen_t sock_len; int len; char buf[128]; struct sockaddr_in sin; fd_set fds_read, fds_write, fds_error; TDS_SYS_SOCKET max_fd = 0; memset(&sin, 0, sizeof(sin)); sock_len = sizeof(sin); alarm(30); fprintf(stderr, "waiting connect...\n"); if ((fake_sock = tds_accept(s, (struct sockaddr *) &sin, &sock_len)) < 0) { perror("accept"); exit(1); } CLOSESOCKET(s); if (TDS_IS_SOCKET_INVALID(server_sock = socket(remote_addr.sa.sa_family, SOCK_STREAM, 0))) { perror("socket"); exit(1); } fprintf(stderr, "connecting to server...\n"); if (remote_addr.sa.sa_family == AF_INET) { fprintf(stderr, "connecting to %x:%d\n", (unsigned int) remote_addr.sin.sin_addr.s_addr, ntohs(remote_addr.sin.sin_port)); } if (connect(server_sock, &remote_addr.sa, remote_addr_len)) { perror("connect"); exit(1); } alarm(0); if (fake_sock > max_fd) max_fd = fake_sock; if (server_sock > max_fd) max_fd = server_sock; for (;;) { int res; FD_ZERO(&fds_read); FD_SET(fake_sock, &fds_read); FD_SET(server_sock, &fds_read); FD_ZERO(&fds_write); FD_ZERO(&fds_error); FD_SET(fake_sock, &fds_error); FD_SET(server_sock, &fds_error); alarm(30); res = select(max_fd + 1, &fds_read, &fds_write, &fds_error, NULL); alarm(0); if (res < 0) { if (sock_errno == TDSSOCK_EINTR) continue; perror("select"); exit(1); } if (FD_ISSET(fake_sock, &fds_error) || FD_ISSET(server_sock, &fds_error)) { fprintf(stderr, "error in select\n"); exit(1); } /* just read and forward */ if (FD_ISSET(fake_sock, &fds_read)) { if (flow != sending) { tds_mutex_lock(&mtx); ++round_trips; tds_mutex_unlock(&mtx); } flow = sending; len = READSOCKET(fake_sock, buf, sizeof(buf)); if (len == 0) { fprintf(stderr, "client connection closed\n"); break; } if (len < 0 && sock_errno != TDSSOCK_EINPROGRESS) { fprintf(stderr, "read client error %d\n", sock_errno); break; } count_insert(buf, len); write_all(server_sock, buf, len); } if (FD_ISSET(server_sock, &fds_read)) { if (flow != receiving) { tds_mutex_lock(&mtx); ++round_trips; tds_mutex_unlock(&mtx); } flow = receiving; len = READSOCKET(server_sock, buf, sizeof(buf)); if (len == 0) { fprintf(stderr, "server connection closed\n"); break; } if (len < 0 && sock_errno != TDSSOCK_EINPROGRESS) { fprintf(stderr, "read server error %d\n", sock_errno); break; } write_all(fake_sock, buf, len); } } CLOSESOCKET(fake_sock); CLOSESOCKET(server_sock); return NULL; } int main(int argc, char **argv) { SQLLEN sql_nts = SQL_NTS; const char *query; SQLINTEGER id = 0; char string[64]; TDS_SYS_SOCKET last_socket; int port; const int num_inserts = 20; int is_freetds; #ifdef _WIN32 WSADATA wsaData; WSAStartup(MAKEWORD(1, 1), &wsaData); #endif if (tds_mutex_init(&mtx)) return 1; odbc_mark_sockets_opened(); odbc_connect(); /* * this does not work if server is not connected with socket * (ie ms driver connected locally) */ last_socket = odbc_find_last_socket(); if (TDS_IS_SOCKET_INVALID(last_socket)) { fprintf(stderr, "Error finding last socket opened\n"); return 1; } remote_addr_len = sizeof(remote_addr); if (tds_getpeername(last_socket, &remote_addr.sa, &remote_addr_len)) { fprintf(stderr, "Unable to get remote address\n"); return 1; } is_freetds = odbc_driver_is_freetds(); odbc_disconnect(); /* init fake server, behave like a proxy */ for (port = 12340; port < 12350; ++port) if (!init_fake_server(port)) break; if (port == 12350) { fprintf(stderr, "Cannot bind to a port\n"); return 1; } printf("Fake server bound at port %d\n", port); /* override connections */ if (is_freetds) { setenv("TDSHOST", "127.0.0.1", 1); sprintf(string, "%d", port); setenv("TDSPORT", string, 1); odbc_connect(); } else { char tmp[2048]; SQLSMALLINT len; CHKAllocEnv(&odbc_env, "S"); CHKAllocConnect(&odbc_conn, "S"); sprintf(tmp, "DRIVER={SQL Server};SERVER=127.0.0.1,%d;UID=%s;PWD=%s;DATABASE=%s;Network=DBMSSOCN;", port, odbc_user, odbc_password, odbc_database); printf("connection string: %s\n", tmp); CHKDriverConnect(NULL, T(tmp), SQL_NTS, (SQLTCHAR *) tmp, sizeof(tmp)/sizeof(SQLTCHAR), &len, SQL_DRIVER_NOPROMPT, "SI"); CHKAllocStmt(&odbc_stmt, "S"); } /* real test */ odbc_command("CREATE TABLE #test(i int, c varchar(40))"); odbc_reset_statement(); /* do not take into account connection statistics */ tds_mutex_lock(&mtx); round_trips = 0; inserts = 0; tds_mutex_unlock(&mtx); query = "insert into #test values (?, ?)"; CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, sizeof(id), 0, &id, 0, &sql_nts, "SI"); CHKBindParameter(2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, sizeof(string), 0, string, 0, &sql_nts, "SI"); CHKPrepare(T(query), SQL_NTS, "SI"); tds_mutex_lock(&mtx); printf("%u round trips %u inserts\n", round_trips, inserts); tds_mutex_unlock(&mtx); for (id = 0; id < num_inserts; id++) { sprintf(string, "This is a test (%d)", (int) id); CHKExecute("SI"); CHKFreeStmt(SQL_CLOSE, "S"); } tds_mutex_lock(&mtx); printf("%u round trips %u inserts\n", round_trips, inserts); tds_mutex_unlock(&mtx); odbc_reset_statement(); tds_mutex_lock(&mtx); if (inserts > 1 || round_trips > (unsigned) (num_inserts * 2 + 6)) { fprintf(stderr, "Too much round trips (%u) or insert (%u) !!!\n", round_trips, inserts); tds_mutex_unlock(&mtx); return 1; } printf("%u round trips %u inserts\n", round_trips, inserts); tds_mutex_unlock(&mtx); #ifdef ENABLE_DEVELOPING /* check for SQL_RESET_PARAMS */ tds_mutex_lock(&mtx); round_trips = 0; inserts = 0; tds_mutex_unlock(&mtx); CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, sizeof(id), 0, &id, 0, &sql_nts, "SI"); CHKBindParameter(2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, sizeof(string), 0, string, 0, &sql_nts, "SI"); CHKPrepare((SQLCHAR *) query, SQL_NTS, "SI"); tds_mutex_lock(&mtx); printf("%u round trips %u inserts\n", round_trips, inserts); tds_mutex_unlock(&mtx); for (id = 0; id < num_inserts; id++) { CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, sizeof(id), 0, &id, 0, &sql_nts, "SI"); CHKBindParameter(2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, sizeof(string), 0, string, 0, &sql_nts, "SI"); sprintf(string, "This is a test (%d)", (int) id); CHKExecute("SI"); CHKFreeStmt(SQL_RESET_PARAMS, "S"); } tds_mutex_lock(&mtx); printf("%u round trips %u inserts\n", round_trips, inserts); tds_mutex_unlock(&mtx); odbc_reset_statement(); tds_mutex_lock(&mtx); if (inserts > 1 || round_trips > num_inserts * 2 + 6) { fprintf(stderr, "Too much round trips (%u) or insert (%u) !!!\n", round_trips, inserts); tds_mutex_unlock(&mtx); return 1; } printf("%u round trips %u inserts\n", round_trips, inserts); tds_mutex_unlock(&mtx); #endif odbc_disconnect(); alarm(10); tds_thread_join(fake_thread, NULL); return 0; } #else int main(void) { printf("Not possible for this platform.\n"); odbc_test_skipped(); return 0; } #endif freetds-1.00.82/src/odbc/unittests/funccall.c100644 025423 025423 00000014760 13142276621 0014535#include "common.h" /* Test for {?=call store(?)} syntax and run */ static void test_with_conversions(void); static void test_with_dbname(void); int main(int argc, char *argv[]) { SQLINTEGER input, output; SQLLEN ind, ind2, ind3, ind4; SQLINTEGER out1; char out2[30]; odbc_connect(); odbc_command("IF OBJECT_ID('simpleresult') IS NOT NULL DROP PROC simpleresult"); odbc_command("create proc simpleresult @i int as begin return @i end"); CHKBindParameter(2, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &input, 0, &ind2, "S"); CHKBindParameter(1, SQL_PARAM_OUTPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &output, 0, &ind, "S"); CHKPrepare(T("{ \n?\t\r= call simpleresult(?)}"), SQL_NTS, "S"); input = 123; ind2 = sizeof(input); output = 0xdeadbeef; CHKExecute("S"); if (output != 123) { printf("Invalid result\n"); exit(1); } /* should return "Invalid cursor state" */ if (SQLFetch(odbc_stmt) != SQL_ERROR) { printf("Data not expected\n"); exit(1); } ODBC_CHECK_COLS(0); /* just to reset some possible buffers */ odbc_command("DECLARE @i INT"); /* same test but with SQLExecDirect and same bindings */ input = 567; ind2 = sizeof(input); output = 0xdeadbeef; CHKExecDirect(T("{?=call simpleresult(?)}"), SQL_NTS, "S"); if (output != 567) { fprintf(stderr, "Invalid result\n"); exit(1); } /* should return "Invalid cursor state" */ CHKFetch("E"); odbc_command("drop proc simpleresult"); odbc_command("IF OBJECT_ID('simpleresult2') IS NOT NULL DROP PROC simpleresult2"); /* force cursor close */ SQLCloseCursor(odbc_stmt); /* test output parameter */ odbc_command("create proc simpleresult2 @i int, @x int output, @y varchar(20) output as begin select @x = 6789 select @y = 'test foo' return @i end"); CHKBindParameter(1, SQL_PARAM_OUTPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &output, 0, &ind, "S"); CHKBindParameter(2, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &input, 0, &ind2, "S"); CHKBindParameter(3, SQL_PARAM_OUTPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &out1, 0, &ind3, "S"); CHKBindParameter(4, SQL_PARAM_OUTPUT, SQL_C_CHAR, SQL_VARCHAR, 20, 0, out2, sizeof(out2), &ind4, "S"); CHKPrepare(T("{ \n?\t\r= call simpleresult2(?,?,?)}"), SQL_NTS, "S"); input = 987; ind2 = sizeof(input); out1 = 888; output = 0xdeadbeef; ind3 = SQL_DATA_AT_EXEC; ind4 = SQL_DEFAULT_PARAM; strcpy(out2, "bad!"); CHKExecute("S"); if (output != 987 || ind3 <= 0 || ind4 <= 0 || out1 != 6789 || strcmp(out2, "test foo") != 0) { printf("ouput = %d ind3 = %d ind4 = %d out1 = %d out2 = %s\n", (int) output, (int) ind3, (int) ind4, (int) out1, out2); printf("Invalid result\n"); exit(1); } /* should return "Invalid cursor state" */ CHKFetch("E"); ODBC_CHECK_COLS(0); odbc_command("drop proc simpleresult2"); /* * test from shiv kumar * Cfr ML 2006-11-21 "specifying a 0 for the StrLen_or_IndPtr in the * SQLBindParameter call is not working on AIX" */ odbc_command("IF OBJECT_ID('rpc_read') IS NOT NULL DROP PROC rpc_read"); odbc_reset_statement(); odbc_command("create proc rpc_read @i int, @x timestamp as begin select 1 return 1234 end"); SQLCloseCursor(odbc_stmt); CHKPrepare(T("{ ? = CALL rpc_read ( ?, ? ) }"), SQL_NTS, "S"); ind = 0; CHKBindParameter(1, SQL_PARAM_OUTPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &output, 0, &ind, "S"); ind2 = 0; CHKBindParameter(2, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &input, 0, &ind2, "S"); ind3 = 8; CHKBindParameter(3, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_VARBINARY, 8, 0, out2, 8, &ind3, "S"); CHKExecute("S"); CHKFetch("S"); CHKFetch("No"); odbc_reset_statement(); odbc_command("drop proc rpc_read"); /* * Test from Joao Amaral * This test SQLExecute where a store procedure returns no result * This seems similar to a previous one but use set instead of select * (with is supported only by mssql and do not return all stuff as * select does) */ if (odbc_db_is_microsoft()) { odbc_reset_statement(); odbc_command("IF OBJECT_ID('sp_test') IS NOT NULL DROP PROC sp_test"); odbc_command("create proc sp_test @res int output as set @res = 456"); odbc_reset_statement(); CHKPrepare(T("{ call sp_test(?)}"), SQL_NTS, "S"); CHKBindParameter(1, SQL_PARAM_OUTPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &output, 0, &ind, "S"); output = 0xdeadbeef; CHKExecute("S"); if (output != 456) { fprintf(stderr, "Invalid result %d(%x)\n", (int) output, (int) output); return 1; } odbc_command("drop proc sp_test"); } odbc_disconnect(); if (odbc_db_is_microsoft()) { odbc_use_version3 = 1; odbc_connect(); test_with_conversions(); test_with_dbname(); odbc_disconnect(); } printf("Done.\n"); return 0; } static void test_with_conversions(void) { SQLLEN ind, ind2, ind3; char out2[30]; /* * test from Bower, Wayne * Cfr ML 2012-03-02 "[freetds] [unixODBC][Driver Manager]Function sequence error (SQL-HY010)" */ odbc_command("IF OBJECT_ID('TMP_SP_Test_ODBC') IS NOT NULL DROP PROC TMP_SP_Test_ODBC"); odbc_command("create proc TMP_SP_Test_ODBC @i int,\n@o int output\nas\nset nocount on\nselect @o = 55\nreturn 9\n"); odbc_reset_statement(); CHKPrepare(T("{ ? = call TMP_SP_Test_ODBC (?, ?) }"), SQL_NTS, "S"); ind2 = 2; CHKBindParameter(2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 80, 0, "10", 2, &ind2, "S"); ind3 = SQL_NULL_DATA; strcpy(out2, " "); CHKBindParameter(3, SQL_PARAM_INPUT_OUTPUT, SQL_C_CHAR, SQL_VARCHAR, 0, 1, out2, 29, &ind3, "S"); ind = 1; CHKBindParameter(1, SQL_PARAM_INPUT_OUTPUT, SQL_C_CHAR, SQL_VARCHAR, 0, 1, out2, 29, &ind, "S"); /* mssql returns SUCCESS */ CHKExecute("No"); ODBC_CHECK_COLS(0); odbc_reset_statement(); odbc_command("drop proc TMP_SP_Test_ODBC"); } static void test_with_dbname(void) { SQLINTEGER len; SQLTCHAR out[512]; char sql[1024]; SQLINTEGER output; SQLLEN ind; ODBC_BUF *odbc_buf = NULL; len = sizeof(out); CHKGetConnectAttr(SQL_ATTR_CURRENT_CATALOG, (SQLPOINTER) out, sizeof(out), &len, "SI"); odbc_command("IF OBJECT_ID('TMP_SP_Test_ODBC') IS NOT NULL DROP PROC TMP_SP_Test_ODBC"); odbc_command("create proc TMP_SP_Test_ODBC @o int output\nas\nset @o=55\nreturn 3\n"); odbc_reset_statement(); sprintf(sql, "{call [%s]..TMP_SP_Test_ODBC(?)}", C(out)); CHKBindParameter(1, SQL_PARAM_OUTPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &output, 0, &ind, "S"); CHKPrepare(T(sql), SQL_NTS, "S"); output = 123; ind = sizeof(output); CHKExecute("S"); if (output != 55) { printf("Invalid result\n"); exit(1); } odbc_reset_statement(); odbc_command("drop proc TMP_SP_Test_ODBC"); ODBC_FREE(); } freetds-1.00.82/src/odbc/unittests/genparams.c100644 025423 025423 00000044001 12717145107 0014713#include "common.h" #include #include /* Test various type from odbc and to odbc */ /* * This test is useful to test odbc_sql2tds function using TestInput * odbc_sql2tds have some particular cases: * (1) char -> char handled differently with encoding problems * (2) date -> * different format TODO * (3) numeric -> * different format * (4) * -> numeric take precision and scale from ipd TODO * (5) * -> char test wide * (6) * -> blob test wchar and ntext * (7) * -> binary test also with wchar * (8) binary -> * test also with wchar * Also we have to check normal char and wide char */ #ifdef TDS_NO_DM static const char tds_no_dm = 1; #else static const char tds_no_dm = 0; #endif static char precision = 18; static char exec_direct = 0; static char prepare_before = 0; static char use_cursors = 0; static int only_test = 0; static int TestOutput(const char *type, const char *value_to_convert, SQLSMALLINT out_c_type, SQLSMALLINT out_sql_type, const char *expected) { char sbuf[1024]; unsigned char out_buf[256]; SQLLEN out_len = 0; const char *sep; odbc_reset_statement(); /* build store procedure to test */ odbc_command("IF OBJECT_ID('spTestProc') IS NOT NULL DROP PROC spTestProc"); sep = "'"; if (strncmp(value_to_convert, "0x", 2) == 0) sep = ""; sprintf(sbuf, "CREATE PROC spTestProc @i %s OUTPUT AS SELECT @i = CONVERT(%s, %s%s%s)", type, type, sep, value_to_convert, sep); odbc_command(sbuf); memset(out_buf, 0, sizeof(out_buf)); if (use_cursors) { odbc_reset_statement(); CHKSetStmtAttr(SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_SCROLLABLE, 0, "S"); CHKSetStmtAttr(SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_DYNAMIC, 0, "S"); } /* bind parameter */ if (exec_direct) { CHKBindParameter(1, SQL_PARAM_OUTPUT, out_c_type, out_sql_type, precision, 0, out_buf, sizeof(out_buf), &out_len, "S"); /* call store procedure */ CHKExecDirect(T("{call spTestProc(?)}"), SQL_NTS, "S"); } else { if (prepare_before) CHKPrepare(T("{call spTestProc(?)}"), SQL_NTS, "S"); CHKBindParameter(1, SQL_PARAM_OUTPUT, out_c_type, out_sql_type, precision, 0, out_buf, sizeof(out_buf), &out_len, "S"); if (!prepare_before) CHKPrepare(T("{call spTestProc(?)}"), SQL_NTS, "S"); CHKExecute("S"); } /* * MS OBDC requires it cause first recordset is a recordset with a * warning caused by the way it execute RPC (via EXEC statement) */ if (use_cursors && !odbc_driver_is_freetds()) SQLMoreResults(odbc_stmt); /* test results */ odbc_c2string(sbuf, out_c_type, out_buf, out_len); if (strcmp(sbuf, expected) != 0) { if (only_test) { odbc_command("drop proc spTestProc"); ODBC_FREE(); return 1; } fprintf(stderr, "Wrong result\n Got: %s\n Expected: %s\n", sbuf, expected); exit(1); } only_test = 0; odbc_command("drop proc spTestProc"); ODBC_FREE(); return 0; } static char check_truncation = 0; static char use_nts = 0; static void TestInput(SQLSMALLINT out_c_type, const char *type, SQLSMALLINT out_sql_type, const char *param_type, const char *value_to_convert) { char sbuf[1024]; unsigned char out_buf[256]; SQLLEN out_len = 0; const char *expected = value_to_convert; size_t value_len = strlen(value_to_convert); const char *p; const char *sep = "'"; odbc_reset_statement(); /* execute a select to get data as wire */ if ((p = strstr(value_to_convert, " -> ")) != NULL) { value_len = p - value_to_convert; expected = p + 4; } if (value_len >= 2 && strncmp(value_to_convert, "0x", 2) == 0) sep = ""; sprintf(sbuf, "SELECT CONVERT(%s, %s%.*s%s)", type, sep, (int) value_len, value_to_convert, sep); odbc_command(sbuf); SQLBindCol(odbc_stmt, 1, out_c_type, out_buf, sizeof(out_buf), &out_len); CHKFetch("SI"); CHKFetch("No"); CHKMoreResults("No"); if (use_nts) { out_len = SQL_NTS; use_nts = 0; } /* create a table with a column of that type */ odbc_reset_statement(); sprintf(sbuf, "CREATE TABLE #tmp_insert (col %s)", param_type); odbc_command(sbuf); if (use_cursors) { odbc_reset_statement(); CHKSetStmtAttr(SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_SCROLLABLE, 0, "S"); CHKSetStmtAttr(SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_DYNAMIC, 0, "S"); } /* insert data using prepared statements */ sprintf(sbuf, "INSERT INTO #tmp_insert VALUES(?)"); if (exec_direct) { CHKBindParameter(1, SQL_PARAM_INPUT, out_c_type, out_sql_type, 20, 0, out_buf, sizeof(out_buf), &out_len, "S"); if (check_truncation) CHKExecDirect(T(sbuf), SQL_NTS, "E"); else CHKExecDirect(T(sbuf), SQL_NTS, "SNo"); } else { if (prepare_before) CHKPrepare(T(sbuf), SQL_NTS, "S"); CHKBindParameter(1, SQL_PARAM_INPUT, out_c_type, out_sql_type, 20, 0, out_buf, sizeof(out_buf), &out_len, "S"); if (!prepare_before) CHKPrepare(T(sbuf), SQL_NTS, "S"); if (check_truncation) CHKExecute("E"); else CHKExecute("SNo"); } /* check if row is present */ if (!check_truncation) { odbc_reset_statement(); sep = "'"; if (strncmp(expected, "0x", 2) == 0) sep = ""; if (strcmp(param_type, "TEXT") == 0) sprintf(sbuf, "SELECT * FROM #tmp_insert WHERE CONVERT(VARCHAR(255), col) = CONVERT(VARCHAR(255), %s%s%s)", sep, expected, sep); else if (strcmp(param_type, "NTEXT") == 0) sprintf(sbuf, "SELECT * FROM #tmp_insert WHERE CONVERT(NVARCHAR(2000), col) = CONVERT(NVARCHAR(2000), %s%s%s)", sep, expected, sep); else if (strcmp(param_type, "IMAGE") == 0) sprintf(sbuf, "SELECT * FROM #tmp_insert WHERE CONVERT(VARBINARY(255), col) = CONVERT(VARBINARY(255), %s%s%s)", sep, expected, sep); else sprintf(sbuf, "SELECT * FROM #tmp_insert WHERE col = CONVERT(%s, %s%s%s)", param_type, sep, expected, sep); odbc_command(sbuf); CHKFetch("S"); CHKFetch("No"); CHKMoreResults("No"); } check_truncation = 0; odbc_command("DROP TABLE #tmp_insert"); ODBC_FREE(); } /* stripped down version of TestInput for NULLs */ static void NullInput(SQLSMALLINT out_c_type, SQLSMALLINT out_sql_type, const char *param_type) { char sbuf[1024]; SQLLEN out_len = SQL_NULL_DATA; odbc_reset_statement(); /* create a table with a column of that type */ odbc_reset_statement(); sprintf(sbuf, "CREATE TABLE #tmp_insert (col %s NULL)", param_type); odbc_command(sbuf); if (use_cursors) { odbc_reset_statement(); CHKSetStmtAttr(SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_SCROLLABLE, 0, "S"); CHKSetStmtAttr(SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_DYNAMIC, 0, "S"); } /* insert data using prepared statements */ sprintf(sbuf, "INSERT INTO #tmp_insert VALUES(?)"); if (exec_direct) { CHKBindParameter(1, SQL_PARAM_INPUT, out_c_type, out_sql_type, 20, 0, NULL, 1, &out_len, "S"); CHKExecDirect(T(sbuf), SQL_NTS, "SNo"); } else { if (prepare_before) CHKPrepare(T(sbuf), SQL_NTS, "S"); CHKBindParameter(1, SQL_PARAM_INPUT, out_c_type, out_sql_type, 20, 0, NULL, 1, &out_len, "S"); if (!prepare_before) CHKPrepare(T(sbuf), SQL_NTS, "S"); CHKExecute("SNo"); } /* check if row is present */ odbc_reset_statement(); if (!odbc_db_is_microsoft() && strcmp(param_type, "TEXT") == 0) odbc_command("SELECT * FROM #tmp_insert WHERE DATALENGTH(col) = 0 OR DATALENGTH(col) IS NULL"); else odbc_command("SELECT * FROM #tmp_insert WHERE col IS NULL"); CHKFetch("S"); CHKFetch("No"); CHKMoreResults("No"); odbc_command("DROP TABLE #tmp_insert"); ODBC_FREE(); } static int big_endian = 1; static const char* pack(const char *fmt, ...) { static char out[80]; char *p = out; va_list v; va_start(v, fmt); for (; *fmt; ++fmt) { unsigned n = va_arg(v, unsigned); int i, l = 2; assert(p - out + 8 < sizeof(out)); switch (*fmt) { case 'l': l += 2; case 's': for (i = 0; i < l; ++i) { sprintf(p, "%02X", (n >> (8*(big_endian ? l-1-i : i))) & 0xffu); p += 2; } break; default: assert(0); } } *p = 0; va_end(v); return out; } static void AllTests(void) { struct tm *ltime; char buf[80]; time_t curr_time; SQLINTEGER y, m, d; char date[128]; printf("use_cursors %d exec_direct %d prepare_before %d\n", use_cursors, exec_direct, prepare_before); /* test some NULLs */ NullInput(SQL_C_CHAR, SQL_VARCHAR, "VARCHAR(100)"); NullInput(SQL_C_CHAR, SQL_LONGVARCHAR, "TEXT"); NullInput(SQL_C_LONG, SQL_INTEGER, "INTEGER"); NullInput(SQL_C_LONG, SQL_LONGVARCHAR, "TEXT"); NullInput(SQL_C_TYPE_TIMESTAMP, SQL_TYPE_TIMESTAMP, "DATETIME"); NullInput(SQL_C_FLOAT, SQL_REAL, "FLOAT"); NullInput(SQL_C_NUMERIC, SQL_LONGVARCHAR, "TEXT"); if (odbc_db_is_microsoft() && odbc_db_version_int() >= 0x08000000u) NullInput(SQL_C_BIT, SQL_BIT, "BIT"); NullInput(SQL_C_DOUBLE, SQL_DOUBLE, "MONEY"); /* FIXME why should return 38 0 as precision and scale ?? correct ?? */ precision = 18; TestOutput("NUMERIC(18,2)", "123", SQL_C_NUMERIC, SQL_NUMERIC, "18 0 1 7B"); TestOutput("DECIMAL(18,2)", "123", SQL_C_NUMERIC, SQL_DECIMAL, "18 0 1 7B"); precision = 38; TestOutput("NUMERIC(18,2)", "123", SQL_C_NUMERIC, SQL_NUMERIC, "38 0 1 7B"); TestInput(SQL_C_LONG, "INTEGER", SQL_VARCHAR, "VARCHAR(20)", "12345"); TestInput(SQL_C_LONG, "INTEGER", SQL_LONGVARCHAR, "TEXT", "12345"); /* * MS driver behavior for output parameters is different * former returns "313233" while newer "333133323333" */ if (odbc_driver_is_freetds()) TestOutput("VARCHAR(20)", "313233", SQL_C_BINARY, SQL_VARCHAR, "333133323333"); only_test = 1; precision = 3; if (TestOutput("DATETIME", "2004-02-24 15:16:17", SQL_C_BINARY, SQL_TIMESTAMP, pack("ssssssl", 2004, 2, 24, 15, 16, 17, 0))) { /* FIXME our driver ignore precision for date */ precision = 3; /* Some MS driver incorrectly prepare with smalldatetime*/ if (!use_cursors || odbc_driver_is_freetds()) { TestOutput("DATETIME", "2004-02-24 15:16:17", SQL_C_BINARY, SQL_TIMESTAMP, pack("ll", 0x9497, 0xFBAA2C)); } TestOutput("SMALLDATETIME", "2004-02-24 15:16:17", SQL_C_BINARY, SQL_TIMESTAMP, pack("ll", 0x9497, 0xFB9640)); } else { TestOutput("SMALLDATETIME", "2004-02-24 15:16:17", SQL_C_BINARY, SQL_TIMESTAMP, pack("ssssssl", 2004, 2, 24, 15, 16, 0, 0)); } TestInput(SQL_C_TYPE_TIMESTAMP, "DATETIME", SQL_TYPE_TIMESTAMP, "DATETIME", "2005-07-22 09:51:34"); /* test timestamp millisecond round off */ TestInput(SQL_C_TYPE_TIMESTAMP, "DATETIME", SQL_TYPE_TIMESTAMP, "DATETIME", "2005-07-22 09:51:34.001 -> 2005-07-22 09:51:34.000"); TestInput(SQL_C_TYPE_TIMESTAMP, "DATETIME", SQL_TYPE_TIMESTAMP, "DATETIME", "2005-07-22 09:51:34.002 -> 2005-07-22 09:51:34.003"); TestInput(SQL_C_TYPE_TIMESTAMP, "DATETIME", SQL_TYPE_TIMESTAMP, "DATETIME", "2005-07-22 09:51:34.003 -> 2005-07-22 09:51:34.003"); TestInput(SQL_C_TYPE_TIMESTAMP, "DATETIME", SQL_TYPE_TIMESTAMP, "DATETIME", "2005-07-22 09:51:34.004 -> 2005-07-22 09:51:34.003"); TestInput(SQL_C_TYPE_TIMESTAMP, "DATETIME", SQL_TYPE_TIMESTAMP, "DATETIME", "2005-07-22 09:51:34.005 -> 2005-07-22 09:51:34.007"); TestInput(SQL_C_TYPE_TIMESTAMP, "DATETIME", SQL_TYPE_TIMESTAMP, "DATETIME", "2005-07-22 09:51:34.006 -> 2005-07-22 09:51:34.007"); /* FIXME on ms driver first SQLFetch return SUCCESS_WITH_INFO for truncation error */ TestInput(SQL_C_TYPE_DATE, "DATETIME", SQL_TYPE_TIMESTAMP, "DATETIME", "2005-07-22 13:02:03 -> 2005-07-22 00:00:00"); /* replace date information with current date */ time(&curr_time); ltime = localtime(&curr_time); y = ltime->tm_year + 1900; m = ltime->tm_mon + 1; d = ltime->tm_mday; /* server concept of data can be different so try ask to server */ odbc_command("SELECT GETDATE()"); SQLBindCol(odbc_stmt, 1, SQL_C_CHAR, date, sizeof(date), NULL); if (SQLFetch(odbc_stmt) == SQL_SUCCESS) { int a, b, c; if (sscanf(date, "%d-%d-%d", &a, &b, &c) == 3) { y = a; m = b; d = c; } } SQLFetch(odbc_stmt); SQLMoreResults(odbc_stmt); SQLFreeStmt(odbc_stmt, SQL_UNBIND); sprintf(buf, "2003-07-22 13:02:03 -> %04d-%02d-%02d 13:02:03", (int) y, (int) m, (int) d); TestInput(SQL_C_TYPE_TIME, "DATETIME", SQL_TYPE_TIMESTAMP, "DATETIME", buf); TestInput(SQL_C_FLOAT, "FLOAT", SQL_REAL, "FLOAT", "1234.25"); TestInput(SQL_C_DOUBLE, "REAL", SQL_REAL, "FLOAT", "-1234.25"); TestInput(SQL_C_FLOAT, "REAL", SQL_REAL, "FLOAT", "1234.25"); TestInput(SQL_C_DOUBLE, "FLOAT", SQL_REAL, "FLOAT", "-1234.25"); TestInput(SQL_C_FLOAT, "FLOAT", SQL_FLOAT, "FLOAT", "1234.25"); TestInput(SQL_C_DOUBLE, "REAL", SQL_FLOAT, "FLOAT", "-1234.25"); TestInput(SQL_C_FLOAT, "FLOAT", SQL_DOUBLE, "FLOAT", "1234.25"); TestInput(SQL_C_DOUBLE, "REAL", SQL_DOUBLE, "FLOAT", "-1234.25"); TestInput(SQL_C_UTINYINT, "TINYINT", SQL_TINYINT, "TINYINT", "231"); TestInput(SQL_C_NUMERIC, "NUMERIC(20,3)", SQL_NUMERIC, "NUMERIC(20,3)", "765432.2 -> 765432"); TestInput(SQL_C_NUMERIC, "NUMERIC(20,3)", SQL_VARCHAR, "VARCHAR(20)", "578246.234 -> 578246"); TestInput(SQL_C_NUMERIC, "NUMERIC(20,3)", SQL_LONGVARCHAR, "TEXT", "578246.234 -> 578246"); TestInput(SQL_C_CHAR, "VARCHAR(100)", SQL_VARBINARY, "VARBINARY(20)", "4145544F -> AETO"); TestInput(SQL_C_CHAR, "TEXT", SQL_VARBINARY, "VARBINARY(20)", "4145544F -> AETO"); TestInput(SQL_C_CHAR, "VARCHAR(100)", SQL_LONGVARBINARY, "IMAGE", "4145544F -> AETO"); TestInput(SQL_C_BINARY, "VARBINARY(100)", SQL_VARCHAR, "VARCHAR(20)", "0x4145544F -> AETO"); TestInput(SQL_C_BINARY, "IMAGE", SQL_VARCHAR, "VARCHAR(20)", "0x4145544F -> AETO"); TestInput(SQL_C_BIT, "BIT", SQL_BIT, "BIT", "0"); TestInput(SQL_C_BIT, "BIT", SQL_BIT, "BIT", "1"); TestInput(SQL_C_DOUBLE, "MONEY", SQL_DOUBLE, "MONEY", "123.34"); TestInput(SQL_C_CHAR, "VARCHAR(20)", SQL_VARCHAR, "VARCHAR(20)", "1EasyTest"); TestInput(SQL_C_CHAR, "VARCHAR(20)", SQL_LONGVARCHAR, "TEXT", "1EasyTest"); TestInput(SQL_C_WCHAR, "VARCHAR(10)", SQL_VARCHAR, "VARCHAR(10)", "Test 12345"); TestInput(SQL_C_WCHAR, "VARCHAR(10)", SQL_LONGVARCHAR, "TEXT", "Test 12345"); /* TODO use collate in syntax if available */ TestInput(SQL_C_CHAR, "VARCHAR(20)", SQL_VARCHAR, "VARCHAR(20)", "me\xf4"); TestInput(SQL_C_CHAR, "VARCHAR(20)", SQL_LONGVARCHAR, "TEXT", "me\xf4"); precision = 6; /* output from char with conversions */ TestOutput("VARCHAR(20)", "foo test", SQL_C_CHAR, SQL_VARCHAR, "6 foo te"); /* TODO use collate in sintax if available */ /* while usually on Microsoft database this encoding is valid on Sybase the database * could use UTF-8 encoding where \xf8\xf9 is an invalid encoded string */ if (odbc_db_is_microsoft() && odbc_tds_version() > 0x700) TestOutput("VARCHAR(20)", "0xf8f9", SQL_C_CHAR, SQL_VARCHAR, "2 \xf8\xf9"); if ((odbc_db_is_microsoft() && odbc_db_version_int() >= 0x08000000u && odbc_tds_version() > 0x700) || (!odbc_db_is_microsoft() && strncmp(odbc_db_version(), "15.00.", 6) >= 0)) { TestOutput("BIGINT", "-987654321065432", SQL_C_BINARY, SQL_BIGINT, big_endian ? "FFFC7DBBCF083228" : "283208CFBB7DFCFF"); TestInput(SQL_C_SBIGINT, "BIGINT", SQL_BIGINT, "BIGINT", "-12345678901234"); } if (odbc_db_is_microsoft() && odbc_db_version_int() >= 0x08000000u) { TestInput(SQL_C_CHAR, "NVARCHAR(100)", SQL_WCHAR, "NVARCHAR(100)", "test"); TestInput(SQL_C_CHAR, "NVARCHAR(100)", SQL_WLONGVARCHAR, "NTEXT", "test"); /* test for invalid stream due to truncation*/ TestInput(SQL_C_CHAR, "NVARCHAR(100)", SQL_WCHAR, "NVARCHAR(100)", "01234567890"); TestInput(SQL_C_CHAR, "NVARCHAR(100)", SQL_WLONGVARCHAR, "NTEXT", "01234567890"); #ifdef ENABLE_DEVELOPING check_truncation = 1; TestInput(SQL_C_CHAR, "NVARCHAR(100)", SQL_WCHAR, "NVARCHAR(100)", "012345678901234567890"); check_truncation = 1; TestInput(SQL_C_CHAR, "NVARCHAR(100)", SQL_WLONGVARCHAR, "NTEXT", "012345678901234567890"); #endif TestInput(SQL_C_CHAR, "NVARCHAR(100)", SQL_WCHAR, "NVARCHAR(100)", "\xa3h\xf9 -> 0xA3006800f900"); TestInput(SQL_C_CHAR, "NVARCHAR(100)", SQL_WLONGVARCHAR, "NTEXT", "\xa3h\xf9 -> 0xA3006800f900"); TestInput(SQL_C_CHAR, "NVARCHAR(100)", SQL_WCHAR, "NVARCHAR(100)", "0xA3006800f900 -> \xa3h\xf9"); TestInput(SQL_C_CHAR, "NVARCHAR(100)", SQL_WLONGVARCHAR, "NTEXT", "0xA3006800f900 -> \xa3h\xf9"); TestInput(SQL_C_LONG, "INT", SQL_WVARCHAR, "NVARCHAR(100)", "45236"); TestInput(SQL_C_LONG, "INT", SQL_WLONGVARCHAR, "NTEXT", "45236"); precision = 6; TestOutput("NVARCHAR(20)", "foo test", SQL_C_CHAR, SQL_WVARCHAR, "6 foo te"); precision = 12; TestOutput("NVARCHAR(20)", "foo test", SQL_C_CHAR, SQL_WVARCHAR, "8 foo test"); /* TODO use collate in sintax if available */ TestOutput("NVARCHAR(20)", "0xf800f900", SQL_C_CHAR, SQL_WVARCHAR, "2 \xf8\xf9"); TestInput(SQL_C_WCHAR, "NVARCHAR(10)", SQL_WVARCHAR, "NVARCHAR(10)", "1EasyTest2"); TestInput(SQL_C_WCHAR, "NVARCHAR(10)", SQL_WLONGVARCHAR, "NTEXT", "1EasyTest2"); use_nts = 1; TestInput(SQL_C_WCHAR, "NVARCHAR(10)", SQL_WVARCHAR, "NVARCHAR(10)", "1EasyTest3"); use_nts = 1; TestInput(SQL_C_WCHAR, "NVARCHAR(10)", SQL_WLONGVARCHAR, "NTEXT", "1EasyTest3"); TestInput(SQL_C_WCHAR, "NVARCHAR(3)", SQL_WVARCHAR, "NVARCHAR(3)", "0xf800a300bc06"); TestInput(SQL_C_WCHAR, "NVARCHAR(3)", SQL_WLONGVARCHAR, "NTEXT", "0xf800a300bc06"); TestInput(SQL_C_WCHAR, "NVARCHAR(10)", SQL_INTEGER, "INT", " -423785 -> -423785"); TestInput(SQL_C_CHAR, "NVARCHAR(100)", SQL_VARBINARY, "VARBINARY(20)", "4145544F -> AETO"); TestInput(SQL_C_CHAR, "NTEXT", SQL_VARBINARY, "VARBINARY(20)", "4145544F -> AETO"); TestInput(SQL_C_BINARY, "VARBINARY(100)", SQL_WVARCHAR, "NVARCHAR(20)", "0x4100450054004F00 -> AETO"); TestInput(SQL_C_BINARY, "IMAGE", SQL_WVARCHAR, "NVARCHAR(20)", "0x4100450054004F00 -> AETO"); } if (odbc_db_is_microsoft() && odbc_db_version_int() >= 0x09000000u) { TestInput(SQL_C_CHAR, "VARCHAR(20)", SQL_LONGVARCHAR, "VARCHAR(MAX)", "1EasyTest"); TestInput(SQL_C_BINARY, "VARBINARY(20)", SQL_LONGVARBINARY, "VARBINARY(MAX)", "Anything will suite!"); } } int main(int argc, char *argv[]) { odbc_use_version3 = 1; odbc_connect(); if (((char *) &big_endian)[0] == 1) big_endian = 0; for (use_cursors = 0; use_cursors <= 1; ++use_cursors) { if (use_cursors) { if (!tds_no_dm || !odbc_driver_is_freetds()) odbc_reset_statement(); /* if connection does not support cursors returns success */ setenv("TDS_SKIP_SUCCESS", "1", 1); odbc_check_cursor(); } exec_direct = 1; AllTests(); exec_direct = 0; prepare_before = 1; AllTests(); prepare_before = 0; AllTests(); } odbc_disconnect(); printf("Done successfully!\n"); return 0; } freetds-1.00.82/src/odbc/unittests/getdata.c100644 025423 025423 00000015770 12717145107 0014362/* * Test reading data with SQLGetData */ #include "common.h" #include static void test_err(const char *data, int c_type, const char *state) { char sql[128]; SQLLEN ind; const unsigned int buf_size = 128; char *buf = (char *) malloc(buf_size); sprintf(sql, "SELECT '%s'", data); odbc_command(sql); SQLFetch(odbc_stmt); CHKGetData(1, c_type, buf, buf_size, &ind, "E"); free(buf); odbc_read_error(); if (strcmp(odbc_sqlstate, state) != 0) { fprintf(stderr, "Unexpected sql state returned\n"); odbc_disconnect(); exit(1); } odbc_reset_statement(); } static int lc; static int type; static int mycmp(const char *s1, const char *s2) { SQLWCHAR buf[128], *wp; unsigned l; if (type == SQL_C_CHAR) return strcmp(s1, s2); l = strlen(s2); assert(l < (sizeof(buf)/sizeof(buf[0]))); wp = buf; do { *wp++ = *s2; } while (*s2++); return memcmp(s1, buf, l * lc + lc); } static void test_split(const char *n_flag) { #define CheckLen(x) do { \ if (len != (x)) { \ fprintf(stderr, "Wrong len %ld at line %d expected %d\n", (long int) len, __LINE__, (x)); \ exit(1); \ } \ } while(0) char sql[80]; char *buf = NULL; SQLLEN len; /* TODO test with VARCHAR too */ sprintf(sql, "SELECT CONVERT(%sTEXT,'Prova' + REPLICATE('x',500))", n_flag); odbc_command(sql); CHKFetch("S"); /* these 2 tests test an old severe BUG in FreeTDS */ buf = (char *) ODBC_GET(1); CHKGetData(1, type, buf, 0, &len, "I"); if (len != SQL_NO_TOTAL) CheckLen(505*lc); CHKGetData(1, type, buf, 0, &len, "I"); if (len != SQL_NO_TOTAL) CheckLen(505*lc); buf = (char *) ODBC_GET(3*lc); CHKGetData(1, type, buf, 3 * lc, &len, "I"); if (len != SQL_NO_TOTAL) CheckLen(505*lc); if (mycmp(buf, "Pr") != 0) { printf("Wrong data result 1\n"); exit(1); } buf = (char *) ODBC_GET(16*lc); CHKGetData(1, type, buf, 16 * lc, &len, "I"); if (len != SQL_NO_TOTAL) CheckLen(503*lc); if (mycmp(buf, "ovaxxxxxxxxxxxx") != 0) { printf("Wrong data result 2 res = '%s'\n", buf); exit(1); } buf = (char *) ODBC_GET(256*lc); CHKGetData(1, type, buf, 256 * lc, &len, "I"); if (len != SQL_NO_TOTAL) CheckLen(488*lc); CHKGetData(1, type, buf, 256 * lc, &len, "S"); CheckLen(233*lc); CHKGetData(1, type, buf, 256 * lc, &len, "No"); odbc_reset_statement(); /* test with varchar, not blob but variable */ sprintf(sql, "SELECT CONVERT(%sVARCHAR(100), 'Other test')", n_flag); odbc_command(sql); CHKFetch("S"); buf = (char *) ODBC_GET(7*lc); CHKGetData(1, type, buf, 7 * lc, NULL, "I"); if (mycmp(buf, "Other ") != 0) { printf("Wrong data result 1\n"); exit(1); } buf = (char *) ODBC_GET(5*lc); CHKGetData(1, type, buf, 20, NULL, "S"); if (mycmp(buf, "test") != 0) { printf("Wrong data result 2 res = '%s'\n", buf); exit(1); } ODBC_FREE(); odbc_reset_statement(); } int main(int argc, char *argv[]) { char buf[32]; SQLINTEGER int_buf; SQLLEN len; SQLRETURN rc; odbc_connect(); lc = 1; type = SQL_C_CHAR; test_split(""); lc = sizeof(SQLWCHAR); type = SQL_C_WCHAR; test_split(""); if (odbc_db_is_microsoft() && odbc_db_version_int() >= 0x07000000u) { lc = 1; type = SQL_C_CHAR; test_split("N"); lc = sizeof(SQLWCHAR); type = SQL_C_WCHAR; test_split("N"); } /* test with fixed length */ odbc_command("SELECT CONVERT(INT, 12345)"); CHKFetch("S"); int_buf = 0xdeadbeef; CHKGetData(1, SQL_C_SLONG, &int_buf, 0, NULL, "S"); if (int_buf != 12345) { printf("Wrong data result\n"); exit(1); } CHKGetData(1, SQL_C_SLONG, &int_buf, 0, NULL, "No"); if (int_buf != 12345) { printf("Wrong data result 2 res = %d\n", (int) int_buf); exit(1); } odbc_reset_statement(); /* test with numeric */ odbc_command("SELECT CONVERT(NUMERIC(18,5), 1850000000000)"); CHKFetch("S"); memset(buf, 'x', sizeof(buf)); CHKGetData(1, SQL_C_CHAR, buf, 14, NULL, "S"); buf[sizeof(buf)-1] = 0; if (strcmp(buf, "1850000000000") != 0) { printf("Wrong data result: %s\n", buf); exit(1); } /* should give NO DATA */ CHKGetData(1, SQL_C_CHAR, buf, 14, NULL, "No"); buf[sizeof(buf)-1] = 0; if (strcmp(buf, "1850000000000") != 0) { printf("Wrong data result 3 res = %s\n", buf); exit(1); } odbc_reset_statement(); /* test int to truncated string */ odbc_command("SELECT CONVERT(INTEGER, 12345)"); CHKFetch("S"); /* error 22003 */ memset(buf, 'x', sizeof(buf)); CHKGetData(1, SQL_C_CHAR, buf, 4, NULL, "E"); #ifdef ENABLE_DEVELOPING buf[4] = 0; if (strcmp(buf, "xxxx") != 0) { fprintf(stderr, "Wrong buffer result buf = %s\n", buf); exit(1); } #endif odbc_read_error(); if (strcmp(odbc_sqlstate, "22003") != 0) { fprintf(stderr, "Unexpected sql state %s returned\n", odbc_sqlstate); odbc_disconnect(); exit(1); } CHKGetData(1, SQL_C_CHAR, buf, 2, NULL, "No"); odbc_reset_statement(); /* test unique identifier to truncated string */ rc = odbc_command2("SELECT CONVERT(UNIQUEIDENTIFIER, 'AA7DF450-F119-11CD-8465-00AA00425D90')", "SENo"); if (rc != SQL_ERROR) { CHKFetch("S"); /* error 22003 */ CHKGetData(1, SQL_C_CHAR, buf, 17, NULL, "E"); odbc_read_error(); if (strcmp(odbc_sqlstate, "22003") != 0) { fprintf(stderr, "Unexpected sql state %s returned\n", odbc_sqlstate); odbc_disconnect(); exit(1); } CHKGetData(1, SQL_C_CHAR, buf, 2, NULL, "No"); } odbc_reset_statement(); odbc_disconnect(); odbc_use_version3 = 1; odbc_connect(); /* test error from SQLGetData */ /* wrong constant, SQL_VARCHAR is invalid as C type */ test_err("prova 123", SQL_VARCHAR, "HY003"); /* use ARD but no ARD data column */ test_err("prova 123", SQL_ARD_TYPE, "07009"); /* wrong conversion, int */ test_err("prova 123", SQL_C_LONG, "22018"); /* wrong conversion, date */ test_err("prova 123", SQL_C_TIMESTAMP, "22018"); /* overflow */ test_err("1234567890123456789", SQL_C_LONG, "22003"); /* test for empty string from mssql */ if (odbc_db_is_microsoft()) { lc = 1; type = SQL_C_CHAR; for (;;) { void *buf = ODBC_GET(lc); odbc_command("SELECT CONVERT(TEXT,'')"); CHKFetch("S"); len = 1234; CHKGetData(1, type, buf, lc, &len, "S"); if (len != 0) { fprintf(stderr, "Wrong len returned, returned %ld\n", (long) len); return 1; } CHKGetData(1, type, buf, lc, NULL, "No"); odbc_reset_statement(); ODBC_FREE(); buf = ODBC_GET(4096*lc); odbc_command("SELECT CONVERT(TEXT,'')"); CHKFetch("S"); len = 1234; CHKGetData(1, type, buf, lc*4096, &len, "S"); if (len != 0) { fprintf(stderr, "Wrong len returned, returned %ld\n", (long) len); return 1; } CHKGetData(1, type, buf, lc*4096, NULL, "No"); odbc_reset_statement(); ODBC_FREE(); if (type != SQL_C_CHAR) break; lc = sizeof(SQLWCHAR); type = SQL_C_WCHAR; } odbc_command("SELECT CONVERT(TEXT,'')"); CHKFetch("S"); len = 1234; CHKGetData(1, SQL_C_BINARY, buf, 1, &len, "S"); if (len != 0) { fprintf(stderr, "Wrong len returned, returned %ld\n", (long) len); return 1; } CHKGetData(1, SQL_C_BINARY, buf, 1, NULL, "No"); } odbc_disconnect(); printf("Done.\n"); return 0; } freetds-1.00.82/src/odbc/unittests/hidden.c100644 025423 025423 00000002273 12717145107 0014176/* Testing result column numbers having hidden columns */ /* Test from Sebastien Flaesch */ #include "common.h" int main(int argc, char **argv) { SQLSMALLINT cnt = 0; int failed = 0; odbc_use_version3 = 1; odbc_connect(); odbc_command("CREATE TABLE #t1 ( k INT, c CHAR(10), vc VARCHAR(10) )"); odbc_command("CREATE TABLE #tmp1 (i NUMERIC(10,0) IDENTITY PRIMARY KEY, b VARCHAR(20) NULL, c INT NOT NULL)"); /* test hidden column with FOR BROWSE */ odbc_reset_statement(); odbc_command("SELECT c, b FROM #tmp1"); CHKNumResultCols(&cnt, "S"); if (cnt != 2) { fprintf(stderr, "Wrong number of columns in result set: %d\n", (int) cnt); failed = 1; } odbc_reset_statement(); /* test hidden column with cursors*/ odbc_check_cursor(); CHKSetStmtAttr(SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_NONSCROLLABLE, SQL_IS_UINTEGER, "S"); CHKSetStmtAttr(SQL_ATTR_CURSOR_SENSITIVITY, (SQLPOINTER) SQL_SENSITIVE, SQL_IS_UINTEGER, "S"); CHKPrepare(T("SELECT * FROM #t1"), SQL_NTS, "S"); CHKExecute("S"); CHKNumResultCols(&cnt, "S"); if (cnt != 3) { fprintf(stderr, "Wrong number of columns in result set: %d\n", (int) cnt); failed = 1; } odbc_disconnect(); return failed ? 1: 0; } freetds-1.00.82/src/odbc/unittests/insert_speed.c100644 025423 025423 00000004032 12522201763 0015415#include "common.h" #include static char software_version[] = "$Id: insert_speed.c,v 1.10 2011-07-12 10:16:59 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #define SQL_QUERY_LENGTH 80 /* test correctly inserted data after insert */ /* I don't remember where this test came ... - freddy77 */ static void insert_test_auto(void) { SQLLEN sql_nts = SQL_NTS; SQLINTEGER id = 0; char string[64]; odbc_reset_statement(); CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, sizeof(id), 0, &id, 0, &sql_nts, "SI"); CHKBindParameter(2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, sizeof(string), 0, string, 0, &sql_nts, "SI"); CHKPrepare(T("insert into test values (?, ?)"), SQL_NTS, "SI"); for (id = 0; id < 20; id++) { sprintf(string, "This is a test (%d)", (int) id); CHKExecute("SI"); } odbc_reset_statement(); } static void insert_test_man(void) { SQLLEN sql_nts = SQL_NTS; SQLINTEGER commit_off = SQL_AUTOCOMMIT_OFF; SQLINTEGER commit_on = SQL_AUTOCOMMIT_ON; SQLINTEGER id = 0; char string[64]; CHKSetConnectAttr(SQL_ATTR_AUTOCOMMIT, int2ptr(commit_off), SQL_IS_INTEGER, "SI"); odbc_reset_statement(); CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, sizeof(id), 0, &id, 0, &sql_nts, "SI"); CHKBindParameter(2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, sizeof(string), 0, string, 0, &sql_nts, "SI"); CHKPrepare(T("insert into test values (?, ?)"), SQL_NTS, "SI"); for (id = 0; id < 20; id++) { sprintf(string, "This is a test (%d)", (int) id); CHKExecute("SI"); } SQLEndTran(SQL_HANDLE_DBC, odbc_conn, SQL_COMMIT); SQLSetConnectAttr(odbc_conn, SQL_ATTR_AUTOCOMMIT, int2ptr(commit_on), SQL_IS_INTEGER); odbc_reset_statement(); } int main(int argc, char **argv) { odbc_connect(); odbc_command_with_result(odbc_stmt, "DROP TABLE test"); odbc_command("CREATE TABLE test(i int, c varchar(40))"); insert_test_man(); odbc_command("DELETE FROM test"); insert_test_auto(); odbc_command("DROP TABLE test"); odbc_disconnect(); return 0; } freetds-1.00.82/src/odbc/unittests/lang_error.c100644 025423 025423 00000000753 12522201763 0015071#include "common.h" /* Test if SQLExecDirect return error if a error in row is returned */ static char software_version[] = "$Id: lang_error.c,v 1.6 2010-07-05 09:20:33 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; int main(int argc, char *argv[]) { odbc_connect(); /* issue print statement and test message returned */ odbc_command2("SELECT DATEADD(dd,-100000,getdate())", "E"); odbc_disconnect(); printf("Done.\n"); return 0; } freetds-1.00.82/src/odbc/unittests/long_error.c100644 025423 025423 00000005047 12527260163 0015114#include "common.h" /* Demonstration of triggered assert when invoking this stored procedure using FreeTDS odbc driver: create procedure proc_longerror as begin raiserror('reallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylongreallylong error', 16, 1) end */ static void extract_error(SQLHANDLE handle, SQLSMALLINT type); int main(void) { int i; char cmd[128 + 110*10]; printf("SQLWCHAR size is: %d\n", (int) sizeof(SQLWCHAR)); odbc_use_version3 = 1; odbc_connect(); /* this test do not work with Sybase */ if (!odbc_db_is_microsoft()) { odbc_disconnect(); return 0; } strcpy(cmd, "create procedure #proc_longerror as\nbegin\nraiserror('"); for (i = 0; i < 110; ++i) strcat(cmd, "reallylong"); strcat(cmd, " error', 16, 1)\nend\n"); odbc_command(cmd); CHKR2(SQLExecDirectW, (odbc_stmt, odbc_get_sqlwchar(&odbc_buf, "{CALL #proc_longerror}"), SQL_NTS), SQL_HANDLE_STMT, odbc_stmt, "E"); extract_error(odbc_stmt, SQL_HANDLE_STMT); odbc_disconnect(); return 0; } static void extract_error(SQLHANDLE handle, SQLSMALLINT type) { SQLINTEGER i = 0; SQLINTEGER native; SQLWCHAR state[7]; SQLWCHAR text[256]; SQLSMALLINT len; SQLRETURN ret; fprintf(stderr, "\n" "The driver reported the following diagnostics\n"); do { ret = SQLGetDiagRecW(type, handle, ++i, state, &native, text, 256, &len); state[5] = 0; if (SQL_SUCCEEDED(ret)) printf("%s:%ld:%ld:%s\n", odbc_get_sqlchar(&odbc_buf, state), (long) i, (long) native, odbc_get_sqlchar(&odbc_buf, text)); } while (ret == SQL_SUCCESS); } freetds-1.00.82/src/odbc/unittests/mars1.c100644 025423 025423 00000005610 12717145107 0013764#include "common.h" /* first MARS test, test 2 concurrent recordset */ #define SET_STMT(n) do { \ if (pcur_stmt != &n) { \ if (pcur_stmt) *pcur_stmt = odbc_stmt; \ pcur_stmt = &n; \ odbc_stmt = *pcur_stmt; \ } \ } while(0) static void AutoCommit(int onoff) { CHKSetConnectAttr(SQL_ATTR_AUTOCOMMIT, int2ptr(onoff), 0, "S"); } static void EndTransaction(SQLSMALLINT type) { CHKEndTran(SQL_HANDLE_DBC, odbc_conn, type, "S"); } static void my_attrs(void) { SQLSetConnectAttr(odbc_conn, 1224 /*SQL_COPT_SS_MARS_ENABLED*/, (SQLPOINTER) 1 /*SQL_MARS_ENABLED_YES*/, SQL_IS_UINTEGER); } int main(int argc, char *argv[]) { SQLINTEGER len, out; int i; SQLHSTMT stmt1, stmt2; SQLHSTMT *pcur_stmt = NULL; odbc_use_version3 = 1; odbc_set_conn_attr = my_attrs; odbc_connect(); stmt1 = odbc_stmt; out = 0; len = sizeof(out); CHKGetConnectAttr(1224, (SQLPOINTER) &out, sizeof(out), &len, "SE"); /* test we really support MARS on this connection */ /* TODO should out be correct ?? */ printf("Following row can contain an error due to MARS detection (is expected)\n"); if (!out || odbc_command2("BEGIN TRANSACTION", "SNoE") != SQL_ERROR) { printf("MARS not supported for this connection\n"); odbc_disconnect(); odbc_test_skipped(); return 0; } odbc_read_error(); if (!strstr(odbc_err, "MARS")) { printf("Error message invalid \"%s\"\n", odbc_err); return 1; } /* create a test table with some data */ odbc_command("create table #mars1 (n int, v varchar(100))"); for (i = 0; i < 60; ++i) { char cmd[120], buf[80]; memset(buf, 'a' + (i % 26), sizeof(buf)); buf[i * 7 % 73] = 0; sprintf(cmd, "insert into #mars1 values(%d, '%s')", i, buf); odbc_command(cmd); } /* and another to avid locking problems */ odbc_command("create table #mars2 (n int, v varchar(100))"); AutoCommit(SQL_AUTOCOMMIT_OFF); /* try to do a select which return a lot of data (to test server didn't cache everything) */ odbc_command("select a.n, b.n, a.v from #mars1 a, #mars1 b order by a.n, b.n"); CHKFetch("S"); /* try to do other commands */ CHKAllocStmt(&stmt2, "S"); SET_STMT(stmt2); odbc_command("insert into #mars2 values(1, 'foo')"); SET_STMT(stmt1); CHKFetch("S"); /* reset statements */ odbc_reset_statement(); SET_STMT(stmt2); odbc_reset_statement(); /* now to 2 select with prepare/execute */ CHKPrepare(T("select a.n, b.n, a.v from #mars1 a, #mars1 b order by a.n, b.n"), SQL_NTS, "S"); SET_STMT(stmt1); CHKPrepare(T("select a.n, b.n, a.v from #mars1 a, #mars1 b order by a.n desc, b.n"), SQL_NTS, "S"); SET_STMT(stmt2); CHKExecute("S"); SET_STMT(stmt1); CHKExecute("S"); SET_STMT(stmt2); CHKFetch("S"); SET_STMT(stmt1); CHKFetch("S"); SET_STMT(stmt2); CHKFetch("S"); odbc_reset_statement(); SET_STMT(stmt1); CHKFetch("S"); odbc_reset_statement(); EndTransaction(SQL_COMMIT); /* TODO test receiving large data should not take much memory */ odbc_disconnect(); return 0; } freetds-1.00.82/src/odbc/unittests/moreandcount.c100644 025423 025423 00000004671 12522201763 0015440#include "common.h" /* Test for SQLMoreResults and SQLRowCount on batch */ static char software_version[] = "$Id: moreandcount.c,v 1.20 2011-07-12 10:16:59 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static void DoTest(int prepare) { int n = 0; static const char query[] = /* on prepared this recordset should be skipped */ "DECLARE @b INT SELECT @b = 25 " "SELECT * FROM #tmp1 WHERE i <= 3 " /* on prepare we cannot distinguish these recordset */ "INSERT INTO #tmp2 SELECT * FROM #tmp1 WHERE i = 1 " "INSERT INTO #tmp2 SELECT * FROM #tmp1 WHERE i <= 3 " "SELECT * FROM #tmp1 WHERE i = 1 " /* but FreeTDS can detect last recordset */ "UPDATE #tmp1 SET i=i+1 WHERE i >= 2"; if (prepare) { CHKPrepare(T(query), SQL_NTS, "S"); CHKExecute("S"); } else { /* execute a batch command select insert insert select and check rows */ CHKExecDirect(T(query), SQL_NTS, "S"); } if (!prepare) { printf("Result %d\n", ++n); ODBC_CHECK_COLS(0); ODBC_CHECK_ROWS(1); CHKMoreResults("S"); } printf("Result %d\n", ++n); ODBC_CHECK_COLS(1); ODBC_CHECK_ROWS(-1); CHKFetch("S"); CHKFetch("S"); ODBC_CHECK_COLS(1); ODBC_CHECK_ROWS(-1); CHKFetch("No"); ODBC_CHECK_COLS(1); ODBC_CHECK_ROWS(2); CHKMoreResults("S"); if (!prepare) { printf("Result %d\n", ++n); ODBC_CHECK_COLS(0); ODBC_CHECK_ROWS(1); CHKMoreResults("S"); printf("Result %d\n", ++n); ODBC_CHECK_COLS(0); ODBC_CHECK_ROWS(2); CHKMoreResults("S"); } printf("Result %d\n", ++n); ODBC_CHECK_COLS(1); ODBC_CHECK_ROWS(-1); CHKFetch("S"); ODBC_CHECK_COLS(1); ODBC_CHECK_ROWS(-1); CHKFetch("No"); ODBC_CHECK_COLS(1); if (prepare) { /* collapse 2 recordset... after a lot of testing this is the behavior! */ if (odbc_driver_is_freetds()) ODBC_CHECK_ROWS(2); } else { ODBC_CHECK_ROWS(1); CHKMoreResults("S"); ODBC_CHECK_COLS(0); ODBC_CHECK_ROWS(2); } CHKMoreResults("No"); #ifndef TDS_NO_DM if (!prepare) ODBC_CHECK_COLS(-1); ODBC_CHECK_ROWS(-2); #endif ODBC_FREE(); } int main(int argc, char *argv[]) { odbc_connect(); odbc_command("create table #tmp1 (i int)"); odbc_command("create table #tmp2 (i int)"); odbc_command("insert into #tmp1 values(1)"); odbc_command("insert into #tmp1 values(2)"); odbc_command("insert into #tmp1 values(5)"); printf("Use direct statement\n"); DoTest(0); printf("Use prepared statement\n"); DoTest(1); odbc_disconnect(); printf("Done.\n"); return 0; } freetds-1.00.82/src/odbc/unittests/norowset.c100644 025423 025423 00000002001 12522201763 0014603#include "common.h" static char software_version[] = "$Id: norowset.c,v 1.9 2010-07-05 09:20:33 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; /* Test that a select following a store procedure execution return results */ int main(int argc, char *argv[]) { char output[256]; SQLLEN dataSize; odbc_connect(); odbc_command_with_result(odbc_stmt, "drop proc sp_norowset_test"); odbc_command("create proc sp_norowset_test as begin declare @i int end"); odbc_command("exec sp_norowset_test"); /* note, mssql 2005 seems to not return row for tempdb, use always master */ odbc_command("select name from master..sysobjects where name = 'sysobjects'"); CHKFetch("S"); CHKGetData(1, SQL_C_CHAR, output, sizeof(output), &dataSize, "S"); if (strcmp(output, "sysobjects") != 0) { printf("Unexpected result\n"); exit(1); } CHKFetch("No"); CHKMoreResults("No"); odbc_command("drop proc sp_norowset_test"); odbc_disconnect(); printf("Done.\n"); return 0; } freetds-1.00.82/src/odbc/unittests/oldpwd.c100644 025423 025423 00000000552 12717145107 0014232#include "common.h" /* change password on server */ static void my_attrs(void) { SQLSetConnectAttr(odbc_conn, 1226 /*SQL_COPT_SS_OLDPWD */, (SQLPOINTER) odbc_password, SQL_NTS); strcpy(odbc_password, "testpwd$"); } int main(int argc, char *argv[]) { odbc_use_version3 = 1; odbc_set_conn_attr = my_attrs; odbc_connect(); odbc_disconnect(); return 0; } freetds-1.00.82/src/odbc/unittests/paramcore.c100644 025423 025423 00000003256 12522201763 0014711#include "common.h" /* * Try to make core dump using SQLBindParameter */ static char software_version[] = "$Id: paramcore.c,v 1.9 2011-07-12 10:16:59 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #define SP_TEXT "{call sp_paramcore_test(?)}" #define OUTSTRING_LEN 20 int main(int argc, char *argv[]) { SQLLEN cb = SQL_NTS; odbc_use_version3 = 1; odbc_connect(); odbc_command_with_result(odbc_stmt, "drop proc sp_paramcore_test"); odbc_command("create proc sp_paramcore_test @s varchar(100) output as select @s = '12345'"); /* here we pass a NULL buffer for input SQL_NTS */ CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, OUTSTRING_LEN, 0, NULL, OUTSTRING_LEN, &cb, "S"); cb = SQL_NTS; CHKExecDirect(T(SP_TEXT), SQL_NTS, "E"); odbc_reset_statement(); /* here we pass a NULL buffer for input */ CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_VARCHAR, 18, 0, NULL, OUTSTRING_LEN, &cb, "S"); cb = 1; CHKExecDirect(T(SP_TEXT), SQL_NTS, "E"); odbc_reset_statement(); odbc_command("drop proc sp_paramcore_test"); odbc_command("create proc sp_paramcore_test @s numeric(10,2) output as select @s = 12345.6"); odbc_reset_statement(); #if 0 /* this fails even on native platforms */ /* here we pass a NULL buffer for output */ cb = sizeof(SQL_NUMERIC_STRUCT); SQLBindParameter(odbc_stmt, 1, SQL_PARAM_OUTPUT, SQL_C_NUMERIC, SQL_NUMERIC, 18, 0, NULL, OUTSTRING_LEN, &cb); odbc_read_error(); cb = 1; odbc_command_with_result(odbc_stmt, SP_TEXT); odbc_read_error(); odbc_reset_statement(); #endif odbc_command("drop proc sp_paramcore_test"); odbc_disconnect(); printf("Done successfully!\n"); return 0; } freetds-1.00.82/src/odbc/unittests/params.c100644 025423 025423 00000004610 12522201763 0014216#include "common.h" /* Test for store procedure and params */ /* Test from Tom Rogers */ static char software_version[] = "$Id: params.c,v 1.13 2011-07-12 10:16:59 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; /* SP definition */ static const char sp_define[] = "CREATE PROCEDURE spTestProc\n" " @InParam int,\n" " @OutParam int OUTPUT,\n" " @OutString varchar(20) OUTPUT\n" "AS\n" " SELECT @OutParam = @InParam\n" " SELECT @OutString = 'This is cool!'\n" " IF @InParam < 10\n" " RETURN (0)\n" " ELSE\n" " RETURN (1)\n"; #define SP_TEXT "{?=call spTestProc(?,?,?)}" #define OUTSTRING_LEN 20 static int Test(int bind_before) { SQLSMALLINT ReturnCode = 0; SQLSMALLINT InParam = 5; SQLSMALLINT OutParam = 1; char OutString[OUTSTRING_LEN]; SQLLEN cbReturnCode = 0, cbInParam = 0, cbOutParam = 0; SQLLEN cbOutString = SQL_NTS; odbc_connect(); /* drop proc */ odbc_command("IF OBJECT_ID('spTestProc') IS NOT NULL DROP PROC spTestProc"); /* create proc */ odbc_command(sp_define); if (!bind_before) CHKPrepare(T(SP_TEXT), strlen(SP_TEXT), "S"); CHKBindParameter(1, SQL_PARAM_OUTPUT, SQL_C_SSHORT, SQL_INTEGER, 0, 0, &ReturnCode, 0, &cbReturnCode, "S"); CHKBindParameter(2, SQL_PARAM_INPUT, SQL_C_SSHORT, SQL_INTEGER, 0, 0, &InParam, 0, &cbInParam, "S"); CHKBindParameter(3, SQL_PARAM_OUTPUT, SQL_C_SSHORT, SQL_INTEGER, 0, 0, &OutParam, 0, &cbOutParam, "S"); OutString[0] = '\0'; strcpy(OutString, "Test"); /* Comment this line and we get an error! Why? */ CHKBindParameter(4, SQL_PARAM_OUTPUT, SQL_C_CHAR, SQL_VARCHAR, OUTSTRING_LEN, 0, OutString, OUTSTRING_LEN, &cbOutString, "S"); if (bind_before) CHKPrepare(T(SP_TEXT), strlen(SP_TEXT), "S"); CHKExecute("S"); odbc_command("DROP PROC spTestProc"); printf("Output:\n"); printf(" Return Code = %d\n", (int) ReturnCode); printf(" InParam = %d\n", (int) InParam); printf(" OutParam = %d\n", (int) OutParam); printf(" OutString = %s\n", OutString); if (InParam != OutParam) { fprintf(stderr, "InParam != OutParam\n"); return 1; } if (strcmp(OutString, "This is cool!") != 0) { fprintf(stderr, "Bad string returned\n"); return 1; } odbc_disconnect(); ODBC_FREE(); return 0; } int main(int argc, char *argv[]) { if (Test(0)) return 1; if (Test(1)) return 1; printf("Done successfully!\n"); return 0; } freetds-1.00.82/src/odbc/unittests/peter.c100644 025423 025423 00000002141 12522201763 0014047#undef NDEBUG #include "common.h" #include /* Test SQLNumResultCols after SQLFreeStmt This test on Sybase should not raise an error */ static char software_version[] = "$Id: peter.c,v 1.2 2011-07-12 10:16:59 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; int main(int argc, char *argv[]) { SQLSMALLINT num_params, cols; SQLLEN count; SQLINTEGER id; odbc_use_version3 = 1; odbc_connect(); odbc_command("create table #tester (id int not null, name varchar(20) not null)"); odbc_command("insert into #tester(id, name) values(1, 'abc')"); odbc_command("insert into #tester(id, name) values(2, 'duck')"); CHKPrepare(T("SELECT * FROM #tester WHERE id = ?"), SQL_NTS, "S"); CHKR(SQLNumParams, (odbc_stmt, &num_params), "S"); assert(num_params == 1); id = 1; CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &id, sizeof(id), NULL, "S"); CHKExecute("S"); CHKR(SQLFreeStmt, (odbc_stmt, SQL_RESET_PARAMS), "S"); CHKRowCount(&count, "S"); CHKNumResultCols(&cols, "S"); assert(cols == 2); odbc_disconnect(); return 0; } freetds-1.00.82/src/odbc/unittests/prepare_results.c100644 025423 025423 00000006742 12522201763 0016162#include "common.h" /* Test for data format returned from SQLPrepare */ static char software_version[] = "$Id: prepare_results.c,v 1.15 2011-07-12 10:16:59 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static void Test(int use_ird) { SQLSMALLINT count, namelen, type, digits, nullable; SQLULEN size; SQLHDESC desc; SQLINTEGER ind; SQLTCHAR name[128]; char *cname = NULL; /* test query returns column information */ CHKPrepare(T("select * from #odbctestdata select * from #odbctestdata"), SQL_NTS, "S"); SQLNumParams(odbc_stmt, &count); if (count != 0) { fprintf(stderr, "Wrong number of params returned. Got %d expected 0\n", (int) count); exit(1); } if (use_ird) { /* get IRD */ CHKGetStmtAttr(SQL_ATTR_IMP_ROW_DESC, &desc, sizeof(desc), &ind, "S"); CHKR(SQLGetDescField, (desc, 0, SQL_DESC_COUNT, &count, sizeof(count), &ind), "S"); } else { CHKNumResultCols(&count, "S"); } if (count != 3) { fprintf(stderr, "Wrong number of columns returned. Got %d expected 3\n", (int) count); exit(1); } CHKDescribeCol(1, name, ODBC_VECTOR_SIZE(name), &namelen, &type, &size, &digits, &nullable, "S"); cname = (char*) C(name); if (type != SQL_INTEGER || strcmp(cname, "i") != 0) { fprintf(stderr, "wrong column 1 informations (type %d name '%s' size %d)\n", (int) type, cname, (int) size); exit(1); } CHKDescribeCol(2, name, ODBC_VECTOR_SIZE(name), &namelen, &type, &size, &digits, &nullable, "S"); cname = (char*) C(name); if (type != SQL_CHAR || strcmp(cname, "c") != 0 || (size != 20 && (odbc_db_is_microsoft() || size != 40))) { fprintf(stderr, "wrong column 2 informations (type %d name '%s' size %d)\n", (int) type, cname, (int) size); exit(1); } CHKDescribeCol(3, name, ODBC_VECTOR_SIZE(name), &namelen, &type, &size, &digits, &nullable, "S"); cname = (char*) C(name); if (type != SQL_NUMERIC || strcmp(cname, "n") != 0 || size != 34 || digits != 12) { fprintf(stderr, "wrong column 3 informations (type %d name '%s' size %d)\n", (int) type, cname, (int) size); exit(1); } ODBC_FREE(); } int main(int argc, char *argv[]) { SQLSMALLINT count; odbc_connect(); odbc_command("create table #odbctestdata (i int, c char(20), n numeric(34,12) )"); /* reset state */ odbc_command("select * from #odbctestdata"); SQLFetch(odbc_stmt); SQLMoreResults(odbc_stmt); /* test query returns column information for select without param */ odbc_reset_statement(); CHKPrepare(T("select * from #odbctestdata"), SQL_NTS, "S"); count = -1; CHKNumResultCols(&count, "S"); if (count != 3) { fprintf(stderr, "Wrong number of columns returned. Got %d expected 3\n", (int) count); exit(1); } /* test query returns column information for select with param */ odbc_reset_statement(); CHKPrepare(T("select c,n from #odbctestdata where i=?"), SQL_NTS, "S"); count = -1; CHKNumResultCols(&count, "S"); if (count != 2) { fprintf(stderr, "Wrong number of columns returned. Got %d expected 2\n", (int) count); exit(1); } /* test query returns column information for update */ odbc_reset_statement(); CHKPrepare(T("update #odbctestdata set i = 20"), SQL_NTS, "S"); count = -1; CHKNumResultCols(&count, "S"); if (count != 0) { fprintf(stderr, "Wrong number of columns returned. Got %d expected 0\n", (int) count); exit(1); } Test(0); odbc_reset_statement(); Test(1); /* TODO test SQLDescribeParam (when implemented) */ odbc_command("drop table #odbctestdata"); odbc_disconnect(); printf("Done.\n"); return 0; } freetds-1.00.82/src/odbc/unittests/prepare_warn.c100644 025423 025423 00000003313 12717145107 0015424/* * Author : sf@4js.com * FreeTDS version : 0.91RC2 (20110429) * Platform : Linux 32b (Debian Lenny) * Fetching when there is a NULL value in table gives invalid cursor state error. * Is this because of Warning SQLSTATE 01003? */ #include "common.h" int main(int argc, char **argv) { #define ARRAY_SIZE 10 SQLCHAR v_dec[ARRAY_SIZE][21]; SQLLEN v_ind[ARRAY_SIZE]; SQLULEN nrows; odbc_use_version3 = 1; odbc_connect(); odbc_check_cursor(); odbc_command("IF OBJECT_ID('mytab1') IS NOT NULL DROP TABLE mytab1"); odbc_command("CREATE TABLE mytab1 ( k INT, d DECIMAL(10,2))"); odbc_command("INSERT INTO mytab1 VALUES ( 201, 111.11 )"); /*SQLExecDirect(m_hstmt, (SQLCHAR *) "insert into mytab1 values ( 202, 222.22 )", SQL_NTS); */ odbc_command("INSERT INTO mytab1 VALUES ( 202, null )"); odbc_reset_statement(); CHKSetStmtAttr(SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_NONSCROLLABLE, SQL_IS_UINTEGER, "S"); CHKSetStmtAttr(SQL_ATTR_CURSOR_SENSITIVITY, (SQLPOINTER) SQL_SENSITIVE, SQL_IS_UINTEGER, "S"); CHKSetStmtAttr(SQL_ATTR_ROW_BIND_TYPE, (SQLPOINTER) SQL_BIND_BY_COLUMN, SQL_IS_UINTEGER, "S"); CHKSetStmtAttr(SQL_ATTR_ROW_ARRAY_SIZE, (SQLPOINTER) ARRAY_SIZE, SQL_IS_UINTEGER, "S"); CHKSetStmtAttr(SQL_ATTR_ROWS_FETCHED_PTR, (SQLPOINTER) & (nrows), SQL_IS_UINTEGER, "S"); CHKPrepare(T("SELECT SUM(d) FROM mytab1"), SQL_NTS, "S"); CHKExecute("I"); #if 0 CHKMoreResults("S"); /* skip warning*/ #endif CHKBindCol(1, SQL_C_CHAR, v_dec, 21, v_ind, "S"); CHKFetch("S"); printf("fetch 1: rows fetched = %d\n", (int) nrows); printf("fetch 1: value = [%s]\n", v_dec[0]); CHKFetch("No"); CHKMoreResults("No"); odbc_command("drop table mytab1"); odbc_disconnect(); return 0; } freetds-1.00.82/src/odbc/unittests/prepclose.c100644 025423 025423 00000003670 12717145107 0014741#include "common.h" #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #if HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #if HAVE_SYS_STAT_H #include #endif /* HAVE_SYS_STAT_H */ #if HAVE_SYS_IOCTL_H #include #endif /* HAVE_SYS_IOCTL_H */ #if HAVE_SYS_WAIT_H #include #endif /* HAVE_SYS_WAIT_H */ /* * test error on connection close * With a trick we simulate a connection close then we try to * prepare or execute a query. This should fail and return an error message. */ #if HAVE_FSTAT && defined(S_IFSOCK) static int close_last_socket(void) { TDS_SYS_SOCKET max_socket = odbc_find_last_socket(); TDS_SYS_SOCKET sockets[2]; if (max_socket < 0) { fprintf(stderr, "Error finding last socket\n"); return 0; } /* replace socket with a new one */ if (socketpair(AF_UNIX, SOCK_STREAM, 0, sockets) < 0) return 0; /* substitute socket */ close(max_socket); dup2(sockets[0], max_socket); /* close connection */ close(sockets[0]); close(sockets[1]); return 1; } static int Test(int direct) { SQLTCHAR buf[256]; SQLTCHAR sqlstate[6]; odbc_mark_sockets_opened(); odbc_connect(); if (!close_last_socket()) { fprintf(stderr, "Error closing connection\n"); return 1; } /* force disconnection closing socket */ if (direct) { CHKExecDirect(T("SELECT 1"), SQL_NTS, "E"); } else { SQLSMALLINT cols; /* use prepare, force dialog with server */ if (CHKPrepare(T("SELECT 1"), SQL_NTS, "SE") == SQL_SUCCESS) CHKNumResultCols(&cols, "E"); } CHKGetDiagRec(SQL_HANDLE_STMT, odbc_stmt, 1, sqlstate, NULL, buf, ODBC_VECTOR_SIZE(buf), NULL, "SI"); sqlstate[5] = 0; printf("state=%s err=%s\n", C(sqlstate), C(buf)); odbc_disconnect(); printf("Done.\n"); return 0; } int main(void) { if (Test(0) || Test(1)) return 1; return 0; } #else int main(void) { printf("Not possible for this platform.\n"); odbc_test_skipped(); return 0; } #endif freetds-1.00.82/src/odbc/unittests/preperror.c100644 025423 025423 00000002700 12522201763 0014751#include "common.h" /* test error on prepared statement, from Nathaniel Talbott test */ static char software_version[] = "$Id: preperror.c,v 1.10 2011-07-12 10:16:59 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; int main(int argc, char *argv[]) { SQLLEN cbInString = SQL_NTS; char buf[256]; SQLTCHAR msg[256]; SQLTCHAR sqlstate[6]; odbc_connect(); odbc_command("CREATE TABLE #urls ( recdate DATETIME ) "); /* test implicit conversion error */ CHKExecDirect(T("INSERT INTO #urls ( recdate ) VALUES ( '2003-10-1 10:11:1 0' )"), SQL_NTS, "E"); /* test prepared implicit conversion error */ CHKPrepare(T("INSERT INTO #urls ( recdate ) VALUES ( ? )"), SQL_NTS, "SI"); strcpy(buf, "2003-10-1 10:11:1 0"); CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 128, 0, buf, sizeof(buf), &cbInString, "SI"); CHKExecute("E"); CHKGetDiagRec(SQL_HANDLE_STMT, odbc_stmt, 1, sqlstate, NULL, msg, ODBC_VECTOR_SIZE(buf), NULL, "SI"); printf("err=%s\n", C(msg)); /* assure initial state */ odbc_reset_statement(); /* try to prepare and execute a statement with error (from DBD::ODBC test) */ if (CHKPrepare(T("SELECT XXNOTCOLUMN FROM sysobjects"), SQL_NTS, "SE") == SQL_SUCCESS) CHKExecute("E"); CHKGetDiagRec(SQL_HANDLE_STMT, odbc_stmt, 1, sqlstate, NULL, msg, ODBC_VECTOR_SIZE(buf), NULL, "SI"); printf("err=%s\n", C(msg)); odbc_disconnect(); printf("Done.\n"); ODBC_FREE(); return 0; } freetds-1.00.82/src/odbc/unittests/print.c100644 025423 025423 00000003575 12717145107 0014105#include "common.h" static SQLCHAR output[256]; #ifdef TDS_NO_DM static const int tds_no_dm = 1; #else static const int tds_no_dm = 0; #endif static int test(int odbc3) { SQLLEN cnamesize; const char *query; odbc_use_version3 = odbc3; odbc_connect(); /* issue print statement and test message returned */ output[0] = 0; query = "print 'START' select count(*) from sysobjects where name='sysobjects' print 'END'"; odbc_command2(query, "I"); odbc_read_error(); if (!strstr(odbc_err, "START")) { printf("Message invalid\n"); return 1; } odbc_err[0] = 0; if (odbc3) { ODBC_CHECK_COLS(0); ODBC_CHECK_ROWS(-1); CHKFetch("E"); CHKMoreResults("S"); } ODBC_CHECK_COLS(1); ODBC_CHECK_ROWS(-1); CHKFetch("S"); ODBC_CHECK_COLS(1); ODBC_CHECK_ROWS(-1); /* check no data */ CHKFetch("No"); ODBC_CHECK_COLS(1); ODBC_CHECK_ROWS(1); /* SQLMoreResults return NO DATA or SUCCESS WITH INFO ... */ if (tds_no_dm && !odbc3) CHKMoreResults("No"); else if (odbc3) CHKMoreResults("I"); else CHKMoreResults("INo"); /* * ... but read error * (unixODBC till 2.2.11 do not read errors on NO DATA, skip test) */ if (tds_no_dm || odbc3) { odbc_read_error(); if (!strstr(odbc_err, "END")) { printf("Message invalid\n"); return 1; } odbc_err[0] = 0; } if (odbc3) { ODBC_CHECK_COLS(0); ODBC_CHECK_ROWS(-1); CHKMoreResults("No"); } /* issue invalid command and test error */ odbc_command2("SELECT donotexistsfield FROM donotexiststable", "E"); odbc_read_error(); /* test no data returned */ CHKFetch("E"); odbc_read_error(); CHKGetData(1, SQL_C_CHAR, output, sizeof(output), &cnamesize, "E"); odbc_read_error(); odbc_disconnect(); return 0; } int main(int argc, char *argv[]) { int ret; /* ODBC 2 */ ret = test(0); if (ret != 0) return ret; /* ODBC 3 */ ret = test(1); if (ret != 0) return ret; printf("Done.\n"); return 0; } freetds-1.00.82/src/odbc/unittests/putdata.c100644 025423 025423 00000011400 12717145107 0014375#include "common.h" /* Test for SQLPutData */ static const char test_text[] = "Nel mezzo del cammin di nostra vita\n" "mi ritrovai per una selva oscura\n" "che' la diritta via era smarrita."; #define BYTE_AT(n) (((n) * 245 + 123) & 0xff) static int to_sqlwchar(SQLWCHAR *dst, const char *src, int n) { int i; for (i = 0; i < n; ++i) dst[i] = src[i]; return n * sizeof(SQLWCHAR); } static char sql[1024]; int main(int argc, char *argv[]) { SQLLEN ind; int len = strlen(test_text), n, i; const char *p; char *pp; SQLPOINTER ptr; unsigned char buf[256], *pb; SQLRETURN RetCode; int type, lc, sql_type; odbc_connect(); /* create table to hold data */ odbc_command("CREATE TABLE #putdata (c TEXT NULL, b IMAGE NULL)"); sql_type = SQL_LONGVARCHAR; type = SQL_C_CHAR; lc = 1; for (;;) { CHKBindParameter(1, SQL_PARAM_INPUT, type, sql_type, 0, 0, (SQLPOINTER) 123, 0, &ind, "S"); /* length required */ ind = SQL_LEN_DATA_AT_EXEC(len * lc); /* * test for char */ CHKPrepare(T("INSERT INTO #putdata(c) VALUES(?)"), SQL_NTS, "S"); CHKExecute("Ne"); p = test_text; n = 5; CHKParamData(&ptr, "Ne"); if (ptr != (SQLPOINTER) 123) ODBC_REPORT_ERROR("Wrong pointer from SQLParamData"); while (*p) { int l = strlen(p); if (l < n) n = l; if (type == SQL_C_CHAR) { CHKPutData((char *) p, n, "S"); } else { SQLWCHAR buf[256]; CHKPutData((char *) buf, to_sqlwchar(buf, p, n), "S"); } p += n; n *= 2; } CHKParamData(&ptr, "S"); CHKParamData(&ptr, "E"); /* check state and reset some possible buffers */ odbc_command("DECLARE @i INT"); /* use server ntext if available */ if (sql_type == SQL_LONGVARCHAR && odbc_db_is_microsoft() && odbc_db_version_int() >= 0x08000000u) { sql_type = SQL_WLONGVARCHAR; continue; } if (type != SQL_C_CHAR) break; sql_type = SQL_LONGVARCHAR; type = SQL_C_WCHAR; lc = sizeof(SQLWCHAR); } /* update row setting binary field */ for (i = 0; i < 255; ++i) buf[i] = BYTE_AT(i); /* * test for binary */ CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_BINARY, SQL_LONGVARBINARY, 0, 0, (SQLPOINTER) 4567, 0, &ind, "S"); ind = SQL_LEN_DATA_AT_EXEC(254); CHKPrepare(T("UPDATE #putdata SET b = ?"), SQL_NTS, "S"); CHKExecute("Ne"); pb = buf; n = 7; CHKParamData(&ptr, "Ne"); if (ptr != (SQLPOINTER) 4567) ODBC_REPORT_ERROR("Wrong pointer from SQLParamData"); while (pb != (buf + 254)) { int l = buf + 254 - pb; if (l < n) n = l; CHKPutData((char *) pb, n, "S"); pb += n; n *= 2; } CHKParamData(&ptr, "S"); CHKParamData(&ptr, "E"); /* check state and reset some possible buffers */ odbc_command("DECLARE @i2 INT"); CHKFreeStmt(SQL_RESET_PARAMS, "S"); /* check inserts ... there should be all equal rows */ strcpy(sql, "IF EXISTS(SELECT * FROM #putdata WHERE CONVERT(VARBINARY(255),b) <> 0x"); /* append binary */ for (i = 0; i < 254; ++i) sprintf(strchr(sql, 0), "%02x", buf[i]); strcat(sql, " OR CONVERT(VARCHAR(255),c) <> '"); /* append string */ pp = strchr(sql, 0); p = test_text; do { *pp++ = *p; if (*p == '\'') *pp++ = *p; } while(*p++); strcat(sql, "') SELECT 1"); odbc_check_no_row(sql); odbc_command("DELETE FROM #putdata"); /* test len == 0 case from ML */ type = SQL_C_CHAR; for (;;) { CHKPrepare(T("INSERT INTO #putdata(c) VALUES(?)"), SQL_NTS, "S"); CHKBindParameter(1, SQL_PARAM_INPUT, type, SQL_LONGVARCHAR, 0, 0, (PTR) 2, 0, &ind, "S"); ind = SQL_LEN_DATA_AT_EXEC(0); RetCode = CHKExecute("Ne"); while (RetCode == SQL_NEED_DATA) { RetCode = SQLParamData(odbc_stmt, &ptr); if (RetCode == SQL_NEED_DATA) { if (type == SQL_C_CHAR) { CHKPutData("abc", 3, "S"); } else { SQLWCHAR buf[10]; CHKPutData(buf, to_sqlwchar(buf, "abc", 3), "S"); } } } if (type != SQL_C_CHAR) break; type = SQL_C_WCHAR; odbc_reset_statement(); } /* check inserts ... */ odbc_check_no_row("IF EXISTS(SELECT * FROM #putdata WHERE c NOT LIKE 'abc') SELECT 1"); odbc_command("DELETE FROM #putdata"); /* test putting 0 bytes from Sebastien Flaesch */ if (odbc_db_is_microsoft()) { type = SQL_C_CHAR; for (;;) { CHKPrepare(T("INSERT INTO #putdata(c) VALUES(?)"), SQL_NTS, "S"); CHKBindParameter(1, SQL_PARAM_INPUT, type, SQL_LONGVARCHAR, 10, 0, (PTR) 2, 10, &ind, "S"); ind = SQL_DATA_AT_EXEC; RetCode = CHKExecute("Ne"); while (RetCode == SQL_NEED_DATA) { RetCode = SQLParamData(odbc_stmt, &ptr); if (RetCode == SQL_NEED_DATA) CHKPutData("", 0, "S"); } if (type != SQL_C_CHAR) break; type = SQL_C_WCHAR; odbc_reset_statement(); } /* check inserts ... */ odbc_check_no_row("IF EXISTS(SELECT * FROM #putdata WHERE c NOT LIKE '') SELECT 1"); } /* TODO test cancel inside SQLExecute */ odbc_disconnect(); printf("Done.\n"); return 0; } freetds-1.00.82/src/odbc/unittests/raiserror.c100644 025423 025423 00000017216 12717145107 0014756#include "common.h" /* test RAISERROR in a store procedure, from Tom Rogers tests */ /* TODO add support for Sybase */ #define SP_TEXT "{?=call #tmp1(?,?,?)}" #define OUTSTRING_LEN 20 #define INVALID_RETURN (-12345) static const char create_proc[] = "CREATE PROCEDURE #tmp1\n" " @InParam int,\n" " @OutParam int OUTPUT,\n" " @OutString varchar(20) OUTPUT\n" "AS\n" "%s" " SET @OutParam = @InParam\n" " SET @OutString = 'This is bogus!'\n" " SELECT 'Here is the first row' AS FirstResult\n" " RAISERROR('An error occurred.', @InParam, 1)\n" "%s" " RETURN (0)"; static SQLSMALLINT ReturnCode; static char OutString[OUTSTRING_LEN]; static int g_nocount, g_second_select; #ifdef TDS_NO_DM static const int tds_no_dm = 1; #else static const int tds_no_dm = 0; #endif static void TestResult(SQLRETURN result0, int level, const char *func) { ODBC_BUF *odbc_buf = NULL; SQLTCHAR SqlState[6]; SQLINTEGER NativeError; SQLTCHAR MessageText[1000]; SQLSMALLINT TextLength; SQLRETURN result = result0, rc; if (result == SQL_NO_DATA && strcmp(func, "SQLFetch") == 0) result = SQL_SUCCESS_WITH_INFO; if ((level <= 10 && result != SQL_SUCCESS_WITH_INFO) || (level > 10 && result != SQL_ERROR) || ReturnCode != INVALID_RETURN) { fprintf(stderr, "%s failed!\n", func); exit(1); } /* * unixODBC till 2.2.11 do not support getting error if SQL_NO_DATA */ if (!tds_no_dm && result0 == SQL_NO_DATA && strcmp(func, "SQLFetch") == 0) return; SqlState[0] = 0; MessageText[0] = 0; NativeError = 0; rc = CHKGetDiagRec(SQL_HANDLE_STMT, odbc_stmt, 1, SqlState, &NativeError, MessageText, ODBC_VECTOR_SIZE(MessageText), &TextLength, "SI"); printf("Func=%s Result=%d DIAG REC 1: State=%s Error=%d: %s\n", func, (int) rc, C(SqlState), (int) NativeError, C(MessageText)); if (strstr(C(MessageText), "An error occurred") == NULL) { fprintf(stderr, "Wrong error returned!\n"); fprintf(stderr, "Error returned: %s\n", C(MessageText)); exit(1); } ODBC_FREE(); } #define MY_ERROR(msg) odbc_report_error(msg, line, __FILE__) static void CheckData(const char *s, int line) { char buf[80]; SQLLEN ind; SQLRETURN rc; rc = CHKGetData(1, SQL_C_CHAR, buf, sizeof(buf), &ind, "SE"); if (rc == SQL_ERROR) { buf[0] = 0; ind = 0; } if (strlen(s) != ind || strcmp(buf, s) != 0) MY_ERROR("Invalid result"); } #define CheckData(s) CheckData(s, __LINE__) static void CheckReturnCode(SQLRETURN result, SQLSMALLINT expected, int line) { if (ReturnCode == expected && (expected != INVALID_RETURN || strcmp(OutString, "Invalid!") == 0) && (expected == INVALID_RETURN || strcmp(OutString, "This is bogus!") == 0)) return; printf("SpDateTest Output:\n"); printf(" Result = %d\n", (int) result); printf(" Return Code = %d\n", (int) ReturnCode); printf(" OutString = \"%s\"\n", OutString); MY_ERROR("Invalid ReturnCode"); } #define CheckReturnCode(res, exp) CheckReturnCode(res, exp, __LINE__) static void Test(int level) { SQLRETURN result; SQLSMALLINT InParam = level; SQLSMALLINT OutParam = 1; SQLLEN cbReturnCode = 0, cbInParam = 0, cbOutParam = 0; SQLLEN cbOutString = SQL_NTS; char sql[80]; printf("ODBC %d nocount %s select %s level %d\n", odbc_use_version3 ? 3 : 2, g_nocount ? "yes" : "no", g_second_select ? "yes" : "no", level); ReturnCode = INVALID_RETURN; memset(&OutString, 0, sizeof(OutString)); /* test with SQLExecDirect */ sprintf(sql, "RAISERROR('An error occurred.', %d, 1)", level); result = odbc_command_with_result(odbc_stmt, sql); TestResult(result, level, "SQLExecDirect"); /* test with SQLPrepare/SQLExecute */ if (!SQL_SUCCEEDED(SQLPrepare(odbc_stmt, T(SP_TEXT), strlen(SP_TEXT)))) { fprintf(stderr, "SQLPrepare failure!\n"); exit(1); } SQLBindParameter(odbc_stmt, 1, SQL_PARAM_OUTPUT, SQL_C_SSHORT, SQL_INTEGER, 0, 0, &ReturnCode, 0, &cbReturnCode); SQLBindParameter(odbc_stmt, 2, SQL_PARAM_INPUT, SQL_C_SSHORT, SQL_INTEGER, 0, 0, &InParam, 0, &cbInParam); SQLBindParameter(odbc_stmt, 3, SQL_PARAM_OUTPUT, SQL_C_SSHORT, SQL_INTEGER, 0, 0, &OutParam, 0, &cbOutParam); strcpy(OutString, "Invalid!"); SQLBindParameter(odbc_stmt, 4, SQL_PARAM_OUTPUT, SQL_C_CHAR, SQL_VARCHAR, OUTSTRING_LEN, 0, OutString, OUTSTRING_LEN, &cbOutString); CHKExecute("S"); /* first select, check data are returned. * SET statements before does not affect results */ CheckData(""); CHKFetch("S"); CheckData("Here is the first row"); result = SQLFetch(odbc_stmt); if (odbc_use_version3) { SQLTCHAR SqlState[6]; SQLINTEGER NativeError; SQLTCHAR MessageText[1000]; SQLSMALLINT TextLength; SQLRETURN expected; SQLLEN rows; if (result != SQL_NO_DATA) ODBC_REPORT_ERROR("SQLFetch should return NO DATA"); CHKGetDiagRec(SQL_HANDLE_STMT, odbc_stmt, 1, SqlState, &NativeError, MessageText, ODBC_VECTOR_SIZE(MessageText), &TextLength, "No"); result = SQLMoreResults(odbc_stmt); expected = level > 10 ? SQL_ERROR : SQL_SUCCESS_WITH_INFO; if (result != expected) ODBC_REPORT_ERROR("SQLMoreResults returned unexpected result"); if (!g_second_select && g_nocount) { if (ReturnCode == INVALID_RETURN) { result = SQLMoreResults(odbc_stmt); } else { CheckReturnCode(result, 0); ReturnCode = INVALID_RETURN; TestResult(result, level, "SQLMoreResults"); ReturnCode = 0; } } else { TestResult(result, level, "SQLMoreResults"); } /* a recordset with only warnings/errors do not contains rows */ if (CHKRowCount(&rows, "SE") == SQL_SUCCESS && rows != -1) ODBC_REPORT_ERROR("SQLRowCount returned some rows"); } else { /* in ODBC 2 errors/warnings are not handled as different recordset */ TestResult(result, level, "SQLFetch"); } if (odbc_driver_is_freetds()) CheckData(""); if (!g_second_select) { SQLLEN rows; if (CHKRowCount(&rows, "SE") == SQL_SUCCESS && rows != -1) ODBC_REPORT_ERROR("SQLRowCount returned some rows"); CheckReturnCode(result, g_nocount ? 0 : INVALID_RETURN); result = SQLMoreResults(odbc_stmt); #ifdef ENABLE_DEVELOPING if (result != SQL_NO_DATA) ODBC_REPORT_ERROR("SQLMoreResults should return NO DATA"); ODBC_CHECK_ROWS(-2); #endif CheckReturnCode(result, 0); return; } if (!odbc_use_version3 || !g_nocount) { /* mssql 2008 return SUCCESS_WITH_INFO with previous error */ CHKMoreResults("S"); result = SQL_SUCCESS; } CheckReturnCode(result, INVALID_RETURN); CheckData(""); if (g_nocount && odbc_use_version3 && g_second_select && level >= 10) { if (CHKFetch("SE") == SQL_ERROR) { SQLMoreResults(odbc_stmt); CHKFetch("S"); } } else { CHKFetch("S"); } CheckData("Here is the last row"); CHKFetch("No"); CheckData(""); if (!odbc_use_version3 || g_nocount) CheckReturnCode(result, 0); #ifdef ENABLE_DEVELOPING else CheckReturnCode(result, INVALID_RETURN); #endif /* FIXME how to handle return in store procedure ?? */ result = SQLMoreResults(odbc_stmt); #ifdef ENABLE_DEVELOPING if (result != SQL_NO_DATA) ODBC_REPORT_ERROR("SQLMoreResults return other data"); #endif CheckReturnCode(result, 0); CheckData(""); ODBC_FREE(); } static void Test2(int nocount, int second_select) { char sql[512]; g_nocount = nocount; g_second_select = second_select; /* this test do not work with Sybase */ if (!odbc_db_is_microsoft()) return; sprintf(sql, create_proc, nocount ? " SET NOCOUNT ON\n" : "", second_select ? " SELECT 'Here is the last row' AS LastResult\n" : ""); odbc_command(sql); Test(5); Test(11); odbc_command("DROP PROC #tmp1"); } int main(int argc, char *argv[]) { odbc_connect(); Test2(0, 1); Test2(1, 1); odbc_disconnect(); odbc_use_version3 = 1; odbc_connect(); Test2(0, 1); Test2(1, 1); Test2(0, 0); Test2(1, 0); odbc_disconnect(); printf("Done.\n"); return 0; } freetds-1.00.82/src/odbc/unittests/rebindpar.c100644 025423 025423 00000003366 12522201763 0014710#include "common.h" /* Test for executing SQLExecute and rebinding parameters */ static char software_version[] = "$Id: rebindpar.c,v 1.11 2011-07-12 10:16:59 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #define SWAP_STMT(b) do { SQLHSTMT xyz = odbc_stmt; odbc_stmt = b; b = xyz; } while(0) static HSTMT stmt; static void TestInsert(char *buf) { SQLLEN ind; int l = strlen(buf); char sql[200]; /* insert some data and test success */ CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, l, 0, buf, l, &ind, "S"); ind = l; CHKExecute("S"); SWAP_STMT(stmt); sprintf(sql, "SELECT 1 FROM #tmp1 WHERE c = '%s'", buf); odbc_command(sql); CHKFetch("S"); CHKFetch("No"); CHKMoreResults("No"); SWAP_STMT(stmt); } static void Test(int prebind) { ODBC_BUF *odbc_buf = NULL; SQLLEN ind; int i; char buf[100]; /* build a string longer than 80 character (80 it's the default) */ buf[0] = 0; for (i = 0; i < 21; ++i) strcat(buf, "miao"); odbc_command("DELETE FROM #tmp1"); CHKAllocStmt(&stmt, "S"); SWAP_STMT(stmt); if (prebind) CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 1, 0, buf, 1, &ind, "S"); CHKPrepare(T("INSERT INTO #tmp1(c) VALUES(?)"), SQL_NTS, "S"); /* try to insert an empty string, should not fail */ /* NOTE this is currently the only test for insert a empty string using rpc */ if (odbc_db_is_microsoft()) TestInsert(""); TestInsert("a"); TestInsert("bb"); TestInsert(buf); CHKFreeStmt(SQL_DROP, "S"); odbc_stmt = SQL_NULL_HSTMT; SWAP_STMT(stmt); ODBC_FREE(); } int main(int argc, char *argv[]) { odbc_connect(); odbc_command("CREATE TABLE #tmp1 (c VARCHAR(200))"); Test(1); Test(0); odbc_disconnect(); printf("Done.\n"); return 0; } freetds-1.00.82/src/odbc/unittests/rowset.c100644 025423 025423 00000003746 12522201763 0014267#include "common.h" static char software_version[] = "$Id: rowset.c,v 1.8 2011-07-12 10:16:59 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static void test_err(int n) { CHKSetStmtAttr(SQL_ROWSET_SIZE, (SQLPOINTER) int2ptr(n), 0, "E"); odbc_read_error(); if (strcmp(odbc_sqlstate, "HY024") != 0) { fprintf(stderr, "Unexpected sql state returned\n"); odbc_disconnect(); exit(1); } } int main(int argc, char *argv[]) { int i; SQLLEN len; #ifdef HAVE_SQLROWSETSIZE SQLROWSETSIZE row_count; #else SQLULEN row_count; #endif SQLUSMALLINT statuses[10]; char buf[32]; odbc_use_version3 = 1; odbc_connect(); /* initial value should be 1 */ CHKGetStmtAttr(SQL_ROWSET_SIZE, &len, sizeof(len), NULL, "S"); if (len != 1) { fprintf(stderr, "len should be 1\n"); odbc_disconnect(); return 1; } /* check invalid parameter values */ test_err(-123); test_err(-1); test_err(0); odbc_check_cursor(); /* set some correct values */ CHKSetStmtAttr(SQL_ROWSET_SIZE, (SQLPOINTER) int2ptr(2), 0, "S"); CHKSetStmtAttr(SQL_ROWSET_SIZE, (SQLPOINTER) int2ptr(1), 0, "S"); /* now check that SQLExtendedFetch works as expected */ odbc_command("CREATE TABLE #rowset(n INTEGER, c VARCHAR(20))"); for (i = 0; i < 10; ++i) { char s[10]; char sql[128]; memset(s, 'a' + i, 9); s[9] = 0; sprintf(sql, "INSERT INTO #rowset(n,c) VALUES(%d,'%s')", i+1, s); odbc_command(sql); } odbc_reset_statement(); CHKSetStmtOption(SQL_ATTR_CURSOR_TYPE, SQL_CURSOR_DYNAMIC, "S"); CHKExecDirect(T("SELECT * FROM #rowset ORDER BY n"), SQL_NTS, "SI"); CHKBindCol(2, SQL_C_CHAR, buf, sizeof(buf), &len, "S"); row_count = 0xdeadbeef; memset(statuses, 0x55, sizeof(statuses)); CHKExtendedFetch(SQL_FETCH_NEXT, 1, &row_count, statuses, "S"); if (row_count != 1 || statuses[0] != SQL_ROW_SUCCESS || strcmp(buf, "aaaaaaaaa") != 0) { fprintf(stderr, "Invalid result\n"); odbc_disconnect(); return 1; } odbc_disconnect(); printf("Done.\n"); return 0; } freetds-1.00.82/src/odbc/unittests/rpc.c100644 025423 025423 00000015471 12717145107 0013533/* * Purpose: Test remote procedure calls * Functions: */ #include "common.h" #include static const char procedure_sql[] = "CREATE PROCEDURE %s \n" " @null_input varchar(30) OUTPUT \n" ", @first_type varchar(30) OUTPUT \n" ", @nullout int OUTPUT\n" ", @nrows int OUTPUT \n" ", @c varchar(20)\n" "AS \n" "BEGIN \n" "select @null_input = max(convert(varchar(30), name)) from systypes \n" "select @first_type = min(convert(varchar(30), name)) from systypes \n" /* #1 empty result set: */ "select name from sysobjects where 0=1\n" /* #2 3 rows: */ "select distinct convert(varchar(30), name) as 'type' from systypes \n" "where name in ('int', 'char', 'text') \n" "select @nrows = @@rowcount \n" /* #3 many rows: */ "select distinct convert(varchar(30), name) as name from systypes \n" "return 42 \n" "END \n"; static void init_proc(const char *name) { static char cmd[4096]; if (name[0] != '#') { printf("Dropping procedure %s\n", name); sprintf(cmd, "if exists (select 1 from sysobjects where name = '%s' and type = 'P') " "DROP PROCEDURE %s", name, name); CHKExecDirect(T(cmd), SQL_NTS, "SI"); } printf("Creating procedure %s\n", name); sprintf(cmd, procedure_sql, name); /* create procedure. Fails if wrong permission or not MSSQL */ CHKExecDirect(T(cmd), SQL_NTS, "SI"); } static void Test(const char *name) { int iresults=0, data_errors=0; int ipar=0; HSTMT odbc_stmt = SQL_NULL_HSTMT; char call_cmd[128]; struct Argument { SQLSMALLINT InputOutputType; /* fParamType */ SQLSMALLINT ValueType; /* fCType */ SQLSMALLINT ParameterType; /* fSqlType */ SQLUINTEGER ColumnSize; /* cbColDef */ SQLSMALLINT DecimalDigits; /* ibScale */ SQLPOINTER ParameterValuePtr;/* rgbValue */ SQLINTEGER BufferLength; /* cbValueMax */ SQLLEN ind; /* pcbValue */ }; struct Argument args[] = { /* InputOutputType ValueType ParamType ColumnSize | DecimalDigits | | ParameterValuePtr | | | BufferLength | | | | ind */ { SQL_PARAM_OUTPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, 0, 4, 3 }, /* return status */ { SQL_PARAM_INPUT_OUTPUT, SQL_C_CHAR, SQL_VARCHAR, 30, 0, 0, 30, SQL_NULL_DATA }, /* @null_input varchar(30) OUTPUT */ { SQL_PARAM_INPUT_OUTPUT, SQL_C_CHAR, SQL_VARCHAR, 30, 0, 0, 30, 3 }, /* @first_type varchar(30) OUTPUT */ { SQL_PARAM_INPUT_OUTPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, 0, 4, 4 }, /* @nullout int OUTPUT\ */ { SQL_PARAM_INPUT_OUTPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, 0, 4, 4 }, /* @nrows int OUTPUT */ { SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 20, 0, 0, 20, 3 } /* @c varchar(20) */ }; printf("executing SQLAllocStmt\n"); CHKAllocStmt(&odbc_stmt, "S"); for( ipar=0; ipar < sizeof(args)/sizeof(args[0]); ipar++ ) { printf("executing SQLBindParameter for parameter %d\n", 1+ipar); if( args[ipar].BufferLength > 0 ) { args[ipar].ParameterValuePtr = (SQLPOINTER) ODBC_GET(args[ipar].BufferLength); assert(args[ipar].ParameterValuePtr != NULL); memset(args[ipar].ParameterValuePtr, 0, args[ipar].BufferLength); memset(args[ipar].ParameterValuePtr, 'a', args[ipar].BufferLength - 1); } CHKBindParameter ( 1+ipar , args[ipar].InputOutputType , args[ipar].ValueType , args[ipar].ParameterType , args[ipar].ColumnSize , args[ipar].DecimalDigits , args[ipar].ParameterValuePtr , args[ipar].BufferLength , &args[ipar].ind , "S" ); } sprintf(call_cmd, "{?=call %s(?,?,?,?,?)}", name ); printf("executing SQLPrepare: %s\n", call_cmd); CHKPrepare(T(call_cmd), SQL_NTS, "S"); printf("executing SQLExecute\n"); CHKExecute("SI"); do { static const char dashes[] = "------------------------------"; int nrows; SQLSMALLINT icol, ncols; SQLTCHAR name[256] = {0}; SQLSMALLINT namelen; SQLSMALLINT type; SQLSMALLINT scale; SQLSMALLINT nullable; printf("executing SQLNumResultCols for result set %d\n", ++iresults); CHKNumResultCols(&ncols, "S"); printf("executing SQLDescribeCol for %d column%c\n", ncols, (ncols == 1? ' ' : 's')); printf("%-5.5s %-15.15s %5.5s %5.5s %5.5s %8.8s\n", "col", "name", "type", "size", "scale", "nullable"); printf("%-5.5s %-15.15s %5.5s %5.5s %5.5s %8.8s\n", dashes, dashes, dashes, dashes, dashes, dashes); for (icol=ncols; icol > 0; icol--) { SQLULEN size; CHKDescribeCol(icol, name, ODBC_VECTOR_SIZE(name), &namelen, &type, &size, &scale, &nullable, "S"); printf("%-5d %-15s %5d %5ld %5d %8c\n", icol, C(name), type, (long int)size, scale, (nullable? 'Y' : 'N')); } printf("executing SQLFetch...\n"); printf("\t%-30s\n\t%s\n", C(name), dashes); for (nrows=0; CHKFetch("SNo") == SQL_SUCCESS; nrows++) { const SQLINTEGER icol = 1; char buf[60]; SQLLEN len; CHKGetData( icol , SQL_C_CHAR /* fCType */ , buf /* rgbValue */ , sizeof(buf) /* cbValueMax */ , &len /* pcbValue */ , "SI" ); printf("\t%-30s\t(%2d bytes)\n", buf, (int) len); } printf("done.\n"); switch (iresults) { case 1: printf("0 rows expected, %d found\n", nrows); data_errors += (nrows == 0)? 0 : 1; break;; case 2: printf("3 rows expected, %d found\n", nrows); data_errors += (nrows == 3)? 0 : 1; break;; case 3: printf("at least 15 rows expected, %d found\n", nrows); data_errors += (nrows > 15)? 0 : 1; break;; } printf("executing SQLMoreResults...\n"); } while (CHKMoreResults("SNo") == SQL_SUCCESS); printf("done.\n"); for( ipar=0; ipar < sizeof(args)/sizeof(args[0]); ipar++ ) { if (args[ipar].InputOutputType == SQL_PARAM_INPUT) continue; printf("bound data for parameter %d is %ld bytes: ", 1+ipar, (long int)args[ipar].ind); switch( args[ipar].ValueType ) { case SQL_C_LONG: printf("%d.\n", (int)(*(SQLINTEGER *)args[ipar].ParameterValuePtr)); break; case SQL_C_CHAR: printf("'%s'.\n", (char*)args[ipar].ParameterValuePtr); break; default: printf("type unsupported in this test\n"); assert(0); break; } } printf("executing SQLFreeStmt\n"); CHKFreeStmt(SQL_DROP, "S"); odbc_stmt = SQL_NULL_HSTMT; ODBC_FREE(); if (data_errors) { fprintf(stderr, "%d errors found in expected row count\n", data_errors); exit(1); } } int main(int argc, char *argv[]) { const char proc_name[] = "freetds_odbc_rpc_test"; char drop_proc[256] = "DROP PROCEDURE "; strcat(drop_proc, proc_name); printf("connecting\n"); odbc_connect(); init_proc(proc_name); printf("running test\n"); Test(proc_name); printf("dropping procedure\n"); odbc_command(drop_proc); odbc_disconnect(); printf("Done.\n"); ODBC_FREE(); return 0; } freetds-1.00.82/src/odbc/unittests/scroll.c100644 025423 025423 00000006312 12522201763 0014232#include "common.h" /* Test cursors */ static char software_version[] = "$Id: scroll.c,v 1.11 2011-07-12 10:16:59 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; int main(int argc, char *argv[]) { #define ROWS 3 #define C_LEN 10 SQLUINTEGER n[ROWS]; char c[ROWS][C_LEN]; SQLLEN c_len[ROWS], n_len[ROWS]; SQLUSMALLINT statuses[ROWS]; SQLUSMALLINT i; SQLULEN num_row; int i_test; typedef struct _test { SQLUSMALLINT type; SQLINTEGER irow; int start; int num; } TEST; static const TEST tests[] = { {SQL_FETCH_NEXT, 0, 1, 3}, {SQL_FETCH_NEXT, 0, 4, 2}, {SQL_FETCH_PRIOR, 0, 1, 3}, {SQL_FETCH_NEXT, 0, 4, 2}, {SQL_FETCH_NEXT, 0, -1, -1}, {SQL_FETCH_FIRST, 0, 1, 3}, {SQL_FETCH_ABSOLUTE, 3, 3, 3}, {SQL_FETCH_RELATIVE, 1, 4, 2}, {SQL_FETCH_LAST, 0, 3, 3} }; const int num_tests = sizeof(tests) / sizeof(TEST); odbc_use_version3 = 1; odbc_connect(); odbc_check_cursor(); /* create test table */ odbc_command("IF OBJECT_ID('tempdb..#test') IS NOT NULL DROP TABLE #test"); odbc_command("CREATE TABLE #test(i int, c varchar(6))"); odbc_command("INSERT INTO #test(i, c) VALUES(1, 'a')"); odbc_command("INSERT INTO #test(i, c) VALUES(2, 'bb')"); odbc_command("INSERT INTO #test(i, c) VALUES(3, 'ccc')"); odbc_command("INSERT INTO #test(i, c) VALUES(4, 'dddd')"); odbc_command("INSERT INTO #test(i, c) VALUES(5, 'eeeee')"); /* set cursor options */ odbc_reset_statement(); CHKSetStmtAttr(SQL_ATTR_CONCURRENCY, (SQLPOINTER) SQL_CONCUR_ROWVER, 0, "S"); CHKSetStmtAttr(SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_SCROLLABLE, 0, "S"); CHKSetStmtAttr(SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_DYNAMIC, 0, "S"); CHKSetStmtAttr(SQL_ATTR_ROW_ARRAY_SIZE, (SQLPOINTER) ROWS, 0, "S"); CHKSetStmtAttr(SQL_ATTR_ROW_STATUS_PTR, (SQLPOINTER) statuses, 0, "S"); CHKSetStmtAttr(SQL_ATTR_ROWS_FETCHED_PTR, &num_row, 0, "S"); /* */ CHKExecDirect(T("SELECT i, c FROM #test"), SQL_NTS, "S"); /* bind some rows at a time */ CHKBindCol(1, SQL_C_ULONG, n, 0, n_len, "S"); CHKBindCol(2, SQL_C_CHAR, c, C_LEN, c_len, "S"); for (i_test = 0; i_test < num_tests; ++i_test) { const TEST *t = &tests[i_test]; printf("Test %d\n", i_test + 1); if (t->start == -1) { CHKFetchScroll(t->type, t->irow, "No"); } else { CHKFetchScroll(t->type, t->irow, "S"); if (t->start < 1) { fprintf(stderr, "Rows not expected\n"); exit(1); } /* print, just for debug */ for (i = 0; i < num_row; ++i) printf("row %d i %d c %s\n", (int) (i + 1), (int) n[i], c[i]); printf("---\n"); if (num_row != t->num) { fprintf(stderr, "Expected %d rows, got %d\n", t->num, (int) num_row); exit(1); } for (i = 0; i < num_row; ++i) { char name[10]; memset(name, 0, sizeof(name)); memset(name, 'a' - 1 + i + t->start, i + t->start); if (n[i] != i + t->start || c_len[i] != strlen(name) || strcmp(c[i], name) != 0) { fprintf(stderr, "Wrong row returned\n"); fprintf(stderr, "\tn %d %d\n", (int) n[i], i + t->start); fprintf(stderr, "\tc len %d %d\n", (int) c_len[i], (int) strlen(name)); fprintf(stderr, "\tc %s %s\n", c[i], name); exit(1); } } } } odbc_reset_statement(); odbc_disconnect(); return 0; } freetds-1.00.82/src/odbc/unittests/stats.c100644 025423 025423 00000004426 12522201763 0014076#include "common.h" static char software_version[] = "$Id: stats.c,v 1.4 2011-07-12 10:16:59 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static SQLLEN cnamesize; static char output[256]; static void ReadCol(int i) { memset(output, 'x', sizeof(output)); strcpy(output, "NULL"); CHKGetData(i, SQL_C_CHAR, output, sizeof(output), &cnamesize, "S"); } static const char *catalog = NULL; static const char *schema = NULL; static const char *proc = "stat_proc"; static const char *table = "stat_proc"; static const char *column = "@t"; #define LEN(x) (x) ? strlen(x) : 0 static void TestProc(const char *type, const char *expected) { char sql[256]; odbc_command("IF OBJECT_ID('stat_proc') IS NOT NULL DROP PROC stat_proc"); sprintf(sql, "CREATE PROC stat_proc(@t %s) AS RETURN 0", type); odbc_command(sql); column = "@t"; CHKProcedureColumns(T(catalog), LEN(catalog), T(schema), LEN(schema), T(proc), LEN(proc), T(column), LEN(column), "SI"); CHKFetch("SI"); ReadCol(6); if (strcmp(output, expected) != 0) { fprintf(stderr, "Got \"%s\" expected \"%s\"\n", output, expected); odbc_disconnect(); exit(1); } CHKCloseCursor("SI"); ODBC_FREE(); } static void TestTable(const char *type, const char *expected) { char sql[256]; odbc_command("IF OBJECT_ID('stat_t') IS NOT NULL DROP TABLE stat_t"); sprintf(sql, "CREATE TABLE stat_t(t %s)", type); odbc_command(sql); column = "t"; table = "stat_t"; CHKColumns(T(catalog), LEN(catalog), T(schema), LEN(schema), T(table), LEN(table), T(column), LEN(column), "SI"); CHKFetch("SI"); ReadCol(5); if (strcmp(output, expected) != 0) { fprintf(stderr, "Got \"%s\" expected \"%s\"\n", output, expected); odbc_disconnect(); exit(1); } CHKCloseCursor("SI"); ODBC_FREE(); } #define STR(n) str(int_buf, n) static const char * str(char *buf, int n) { sprintf(buf, "%d", n); return buf; } int main(int argc, char *argv[]) { char int_buf[32]; odbc_use_version3 = 0; odbc_connect(); TestProc("DATETIME", STR(SQL_TIMESTAMP)); TestTable("DATETIME", STR(SQL_TIMESTAMP)); odbc_disconnect(); odbc_use_version3 = 1; odbc_connect(); TestProc("DATETIME", STR(SQL_TYPE_TIMESTAMP)); TestTable("DATETIME", STR(SQL_TYPE_TIMESTAMP)); odbc_disconnect(); printf("Done.\n"); return 0; } freetds-1.00.82/src/odbc/unittests/t0001.c100644 025423 025423 00000002365 12522201763 0013504#include "common.h" static char software_version[] = "$Id: t0001.c,v 1.19 2010-07-05 09:20:33 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; int main(int argc, char *argv[]) { int i; SQLLEN cnamesize; const char *command; SQLCHAR output[256]; odbc_connect(); odbc_command("if object_id('tempdb..#odbctestdata') is not null drop table #odbctestdata"); command = "create table #odbctestdata (" "col1 varchar(30) not null," "col2 int not null," "col3 float not null," "col4 numeric(18,6) not null," "col5 datetime not null," "col6 text not null)"; odbc_command(command); command = "insert #odbctestdata values (" "'ABCDEFGHIJKLMNOP'," "123456," "1234.56," "123456.78," "'Sep 11 2001 10:00AM'," "'just to check returned length...')"; odbc_command(command); odbc_command("select * from #odbctestdata"); CHKFetch("SI"); for (i = 1; i <= 6; i++) { CHKGetData(i, SQL_C_CHAR, output, sizeof(output), &cnamesize, "S"); printf("output data >%s< len_or_ind = %d\n", output, (int) cnamesize); if (cnamesize != strlen((char *) output)) return 1; } CHKFetch("No"); CHKCloseCursor("SI"); odbc_command("drop table #odbctestdata"); odbc_disconnect(); printf("Done.\n"); return 0; } freetds-1.00.82/src/odbc/unittests/t0002.c100644 025423 025423 00000002160 12717145107 0013503#include "common.h" #define SWAP_STMT() do { SQLHSTMT xyz = odbc_stmt; \ odbc_stmt = old_odbc_stmt; old_odbc_stmt = xyz; } while(0) int main(int argc, char *argv[]) { HSTMT old_odbc_stmt = SQL_NULL_HSTMT; odbc_connect(); odbc_command("if object_id('tempdb..#odbctestdata') is not null drop table #odbctestdata"); odbc_command("create table #odbctestdata (i int)"); odbc_command("insert #odbctestdata values (123)"); /* * now we allocate another statement, select, get all results * then make another query with first select and drop this statement * result should not disappear (required for DBD::ODBC) */ SWAP_STMT(); CHKAllocStmt(&odbc_stmt, "S"); odbc_command("select * from #odbctestdata where 0=1"); CHKFetch("No"); CHKCloseCursor("SI"); SWAP_STMT(); odbc_command("select * from #odbctestdata"); SWAP_STMT(); /* drop first statement .. data should not disappear */ CHKFreeStmt(SQL_DROP, "S"); odbc_stmt = SQL_NULL_HSTMT; SWAP_STMT(); CHKFetch("SI"); CHKFetch("No"); CHKCloseCursor("SI"); odbc_command("drop table #odbctestdata"); odbc_disconnect(); printf("Done.\n"); return 0; } freetds-1.00.82/src/odbc/unittests/t0003.c100644 025423 025423 00000002515 12522201763 0013503#include "common.h" /* Test for SQLMoreResults */ static char software_version[] = "$Id: t0003.c,v 1.21 2011-07-12 10:16:59 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static void DoTest(int prepared) { odbc_command("create table #odbctestdata (i int)"); /* test that 2 empty result set are returned correctly */ if (!prepared) { odbc_command("select * from #odbctestdata select * from #odbctestdata"); } else { CHKPrepare(T("select * from #odbctestdata select * from #odbctestdata"), SQL_NTS, "S"); CHKExecute("S"); } CHKFetch("No"); CHKMoreResults("S"); printf("Getting next recordset\n"); CHKFetch("No"); CHKMoreResults("No"); /* test that skipping a no empty result go to other result set */ odbc_command("insert into #odbctestdata values(123)"); if (!prepared) { odbc_command("select * from #odbctestdata select * from #odbctestdata"); } else { CHKPrepare(T("select * from #odbctestdata select * from #odbctestdata"), SQL_NTS, "S"); CHKExecute("S"); } CHKMoreResults("S"); printf("Getting next recordset\n"); CHKFetch("S"); CHKFetch("No"); CHKMoreResults("No"); odbc_command("drop table #odbctestdata"); ODBC_FREE(); } int main(int argc, char *argv[]) { odbc_connect(); DoTest(0); DoTest(1); odbc_disconnect(); printf("Done.\n"); return 0; } freetds-1.00.82/src/odbc/unittests/t0004.c100644 025423 025423 00000001644 12522201763 0013506#include "common.h" /* Test for SQLMoreResults */ static char software_version[] = "$Id: t0004.c,v 1.19 2011-07-12 10:16:59 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static void Test(int use_indicator) { char buf[128]; SQLLEN ind; SQLLEN *pind = use_indicator ? &ind : NULL; strcpy(buf, "I don't exist"); ind = strlen(buf); CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_VARCHAR, 20, 0, buf, 128, pind, "S"); CHKPrepare(T("SELECT id, name FROM master..sysobjects WHERE name = ?"), SQL_NTS, "S"); CHKExecute("S"); CHKFetch("No"); CHKMoreResults("No"); /* use same binding above */ strcpy(buf, "sysobjects"); ind = strlen(buf); CHKExecute("S"); CHKFetch("S"); CHKFetch("No"); CHKMoreResults("No"); ODBC_FREE(); } int main(int argc, char *argv[]) { odbc_connect(); Test(1); Test(0); odbc_disconnect(); printf("Done.\n"); return 0; } freetds-1.00.82/src/odbc/unittests/tables.c100644 025423 025423 00000010631 12522201763 0014205#include "common.h" static char software_version[] = "$Id: tables.c,v 1.21 2011-07-12 10:16:59 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; #ifdef _WIN32 #undef strcasecmp #define strcasecmp stricmp #endif static SQLLEN cnamesize; static char output[256]; static void ReadCol(int i) { strcpy(output, "NULL"); CHKGetData(i, SQL_C_CHAR, output, sizeof(output), &cnamesize, "S"); } static void TestName(int index, const char *expected_name) { SQLTCHAR name[128]; char buf[256]; SQLSMALLINT len, type; #define NAME_TEST \ do { \ if (strcmp(C(name), expected_name) != 0) \ { \ sprintf(buf, "wrong name in column %d expected '%s' got '%s'", index, expected_name, C(name)); \ ODBC_REPORT_ERROR(buf); \ } \ } while(0) /* retrieve with SQLDescribeCol */ CHKDescribeCol(index, name, ODBC_VECTOR_SIZE(name), &len, &type, NULL, NULL, NULL, "S"); NAME_TEST; /* retrieve with SQLColAttribute */ CHKColAttribute(index, SQL_DESC_NAME, name, ODBC_VECTOR_SIZE(name), &len, NULL, "S"); if (odbc_db_is_microsoft()) NAME_TEST; CHKColAttribute(index, SQL_DESC_LABEL, name, ODBC_VECTOR_SIZE(name), &len, NULL, "S"); NAME_TEST; } static const char *catalog = NULL; static const char *schema = NULL; static const char *table = "sysobjects"; static const char *expect = NULL; static int expect_col = 3; static char expected_type[20] = "SYSTEM TABLE"; static void DoTest(const char *type, int row_returned, int line) { int table_len = SQL_NULL_DATA; char table_buf[80]; int found = 0; #define LEN(x) (x) ? strlen(x) : SQL_NULL_DATA if (table) { strcpy(table_buf, table); strcat(table_buf, "garbage"); table_len = strlen(table); } printf("Test type '%s' %s row at line %d\n", type ? type : "", row_returned ? "with" : "without", line); CHKTables(T(catalog), LEN(catalog), T(schema), LEN(schema), T(table_buf), table_len, T(type), LEN(type), "SI"); /* test column name (for DBD::ODBC) */ TestName(1, odbc_use_version3 || !odbc_driver_is_freetds() ? "TABLE_CAT" : "TABLE_QUALIFIER"); TestName(2, odbc_use_version3 || !odbc_driver_is_freetds() ? "TABLE_SCHEM" : "TABLE_OWNER"); TestName(3, "TABLE_NAME"); TestName(4, "TABLE_TYPE"); TestName(5, "REMARKS"); if (row_returned) { CHKFetch("SI"); if (!expect) { ReadCol(1); ReadCol(2); ReadCol(3); if (strcasecmp(output, "sysobjects") != 0) { printf("wrong table %s\n", output); exit(1); } ReadCol(4); /* under mssql2k5 is a view */ if (strcmp(output, expected_type) != 0) { printf("wrong table type %s\n", output); exit(1); } ReadCol(5); } } if (expect) { ReadCol(expect_col); if (strcmp(output, expect) == 0) found = 1; } while (CHKFetch("SNo") == SQL_SUCCESS && row_returned > 1) { if (expect) { ReadCol(expect_col); if (strcmp(output, expect) == 0) found = 1; } if (row_returned < 2) break; } if (expect && !found) { printf("expected row not found\n"); exit(1); } CHKCloseCursor("SI"); expect = NULL; expect_col = 3; } #define DoTest(a,b) DoTest(a,b,__LINE__) int main(int argc, char *argv[]) { char type[32]; int mssql2005 = 0; odbc_use_version3 = 0; odbc_connect(); if (odbc_db_is_microsoft() && odbc_db_version_int() >= 0x09000000u) { mssql2005 = 1; strcpy(expected_type, "VIEW"); odbc_command_with_result(odbc_stmt, "USE master"); } DoTest(NULL, 1); sprintf(type, "'%s'", expected_type); DoTest(type, 1); DoTest("'TABLE'", 0); DoTest(type, 1); DoTest("TABLE", 0); DoTest("TABLE,VIEW", mssql2005 ? 1 : 0); DoTest("SYSTEM TABLE,'TABLE'", mssql2005 ? 0 : 1); sprintf(type, "TABLE,'%s'", expected_type); DoTest(type, 1); odbc_disconnect(); odbc_use_version3 = 1; odbc_connect(); if (mssql2005) odbc_command_with_result(odbc_stmt, "USE master"); sprintf(type, "'%s'", expected_type); DoTest(type, 1); /* TODO this should work even for Sybase and mssql 2005 */ if (odbc_db_is_microsoft()) { /* here table is a name of table */ catalog = "%"; schema = NULL; DoTest(NULL, 2); } /* * tests for Jdbc compatiblity */ /* enum tables */ catalog = NULL; schema = NULL; table = "%"; expect = "sysobjects"; DoTest(NULL, 2); /* enum catalogs */ catalog = "%"; schema = ""; table = ""; expect = "master"; expect_col = 1; DoTest(NULL, 2); /* enum schemas (owners) */ catalog = ""; schema = "%"; table = ""; expect = "dbo"; expect_col = 2; DoTest(NULL, 2); odbc_disconnect(); printf("Done.\n"); return 0; } freetds-1.00.82/src/odbc/unittests/test64.c100644 025423 025423 00000013016 12717145107 0014071/* test win64 consistency */ #include "common.h" /* set ipd processed_ptr with SQLParamOptions/SQLSetDescField/SQL_ATTR_PARAMS_PROCESSED_PTR check always same value IPD->processed_ptr attr */ static void check_ipd_params(void) { void *ptr, *ptr2; SQLHDESC desc; SQLINTEGER ind; CHKGetStmtAttr(SQL_ATTR_PARAMS_PROCESSED_PTR, &ptr, sizeof(ptr), NULL, "S"); /* get IPD */ CHKGetStmtAttr(SQL_ATTR_IMP_PARAM_DESC, &desc, sizeof(desc), &ind, "S"); CHKR(SQLGetDescField, (desc, 0, SQL_DESC_ROWS_PROCESSED_PTR, &ptr2, sizeof(ptr2), &ind), "S"); if (ptr != ptr2) { fprintf(stderr, "IPD inconsistency ptr %p ptr2 %p\n", ptr, ptr2); exit(1); } } static void set_ipd_params1(SQLULEN *ptr) { CHKSetStmtAttr(SQL_ATTR_PARAMS_PROCESSED_PTR, ptr, 0, "S"); } static void set_ipd_params2(SQLULEN *ptr) { SQLHDESC desc; SQLINTEGER ind; /* get IPD */ CHKGetStmtAttr(SQL_ATTR_IMP_PARAM_DESC, &desc, sizeof(desc), &ind, "S"); CHKR(SQLSetDescField, (desc, 1, SQL_DESC_ROWS_PROCESSED_PTR, ptr, 0), "S"); } static void set_ipd_params3(SQLULEN *ptr) { CHKParamOptions(2, ptr, "S"); } typedef void (*rows_set_t)(SQLULEN*); static const rows_set_t param_set[] = { set_ipd_params1, set_ipd_params2, set_ipd_params3, NULL }; #define MALLOC_N(t, n) (t*) malloc(n*sizeof(t)) static void test_params(void) { #define ARRAY_SIZE 2 const rows_set_t *p; SQLULEN len; SQLUINTEGER *ids = MALLOC_N(SQLUINTEGER,ARRAY_SIZE); SQLLEN *id_lens = MALLOC_N(SQLLEN,ARRAY_SIZE); unsigned long int h, l; unsigned int n; for (n = 0; n < ARRAY_SIZE; ++n) { ids[n] = n; id_lens[n] = 0; } /* test setting just some test pointers */ set_ipd_params1((SQLULEN *) int2ptr(0x01020304)); check_ipd_params(); set_ipd_params2((SQLULEN *) int2ptr(0xabcdef12)); check_ipd_params(); set_ipd_params3((SQLULEN *) int2ptr(0x87654321)); check_ipd_params(); /* now see results */ for (p = param_set; *p != NULL; ++p) { odbc_reset_statement(); len = 0xdeadbeef; len <<= 16; len <<= 16; len |= 12345678; (*p)(&len); check_ipd_params(); CHKSetStmtAttr(SQL_ATTR_PARAMSET_SIZE, (void *) int2ptr(ARRAY_SIZE), 0, "S"); CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_ULONG, SQL_INTEGER, 5, 0, ids, 0, id_lens, "S"); odbc_command("INSERT INTO #tmp1(i) VALUES(?)"); SQLMoreResults(odbc_stmt); for (n = 0; n < ARRAY_SIZE; ++n) SQLMoreResults(odbc_stmt); l = len; len >>= 16; h = len >> 16; l &= 0xfffffffflu; if (h != 0 || l != 2) { fprintf(stderr, "Wrong number returned in param rows high %lu low %lu\n", h, l); exit(1); } } free(ids); free(id_lens); } /* set ird processed_ptr with SQLExtendedFetch/SQLSetDescField/SQL_ATTR_ROWS_FETCHED_PTR check always same value IRD->processed_ptr attr */ static void check_ird_params(void) { void *ptr, *ptr2; SQLHDESC desc; SQLINTEGER ind; CHKGetStmtAttr(SQL_ATTR_ROWS_FETCHED_PTR, &ptr, sizeof(ptr), NULL, "S"); /* get IRD */ CHKGetStmtAttr(SQL_ATTR_IMP_ROW_DESC, &desc, sizeof(desc), &ind, "S"); CHKR(SQLGetDescField, (desc, 0, SQL_DESC_ROWS_PROCESSED_PTR, &ptr2, sizeof(ptr2), &ind), "S"); if (ptr != ptr2) { fprintf(stderr, "IRD inconsistency ptr %p ptr2 %p\n", ptr, ptr2); exit(1); } } static void set_ird_params1(SQLULEN *ptr) { CHKSetStmtAttr(SQL_ATTR_ROWS_FETCHED_PTR, ptr, 0, "S"); } static void set_ird_params2(SQLULEN *ptr) { SQLHDESC desc; SQLINTEGER ind; /* get IRD */ CHKGetStmtAttr(SQL_ATTR_IMP_ROW_DESC, &desc, sizeof(desc), &ind, "S"); CHKR(SQLSetDescField, (desc, 1, SQL_DESC_ROWS_PROCESSED_PTR, ptr, 0), "S"); } static const rows_set_t row_set[] = { set_ird_params1, set_ird_params2, NULL }; #define MALLOC_N(t, n) (t*) malloc(n*sizeof(t)) static void test_rows(void) { const rows_set_t *p; SQLULEN len; SQLUINTEGER *ids = MALLOC_N(SQLUINTEGER,ARRAY_SIZE); SQLLEN *id_lens = MALLOC_N(SQLLEN,ARRAY_SIZE); unsigned long int h, l; unsigned int n; for (n = 0; n < ARRAY_SIZE; ++n) { ids[n] = n; id_lens[n] = 0; } /* test setting just some test pointers */ set_ird_params1((SQLULEN *) int2ptr(0x01020304)); check_ird_params(); set_ird_params2((SQLULEN *) int2ptr(0xabcdef12)); check_ird_params(); /* now see results */ for (p = row_set; ; ++p) { const char *test_name = NULL; odbc_reset_statement(); len = 0xdeadbeef; len <<= 16; len <<= 16; len |= 12345678; if (*p) (*p)(&len); check_ird_params(); #if 0 CHKSetStmtAttr(SQL_ATTR_PARAMSET_SIZE, (void *) int2ptr(ARRAY_SIZE), 0, "S"); CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_ULONG, SQL_INTEGER, 5, 0, ids, 0, id_lens, "S"); #endif CHKBindCol(1, SQL_C_ULONG, ids, 0, id_lens, "S"); if (*p) { CHKSetStmtAttr(SQL_ATTR_ROW_ARRAY_SIZE, (void *) int2ptr(ARRAY_SIZE), 0, "S"); odbc_command("SELECT DISTINCT i FROM #tmp1"); SQLFetch(odbc_stmt); test_name = "SQLSetStmtAttr"; } else { CHKSetStmtAttr(SQL_ROWSET_SIZE, (void *) int2ptr(ARRAY_SIZE), 0, "S"); odbc_command("SELECT DISTINCT i FROM #tmp1"); CHKExtendedFetch(SQL_FETCH_NEXT, 0, &len, NULL, "S"); test_name = "SQLExtendedFetch"; } SQLMoreResults(odbc_stmt); l = len; len >>= 16; h = len >> 16; l &= 0xfffffffflu; if (h != 0 || l != 2) { fprintf(stderr, "Wrong number returned in rows high %lu(0x%lx) low %lu(0x%lx) test %s\n", h, h, l, l, test_name); exit(1); } if (!*p) break; } free(ids); free(id_lens); } int main(void) { if (sizeof(SQLLEN) != 8) { printf("Not possible for this platform.\n"); odbc_test_skipped(); return 0; } odbc_use_version3 = 1; odbc_connect(); odbc_command("create table #tmp1 (i int)"); test_params(); test_rows(); odbc_disconnect(); printf("Done\n"); return 0; } freetds-1.00.82/src/odbc/unittests/testodbc.c100644 025423 025423 00000030301 12717145107 0014543/* * Code to test ODBC implementation. * - David Fraser, Abelon Systems 2003. */ /* * TODO * remove Northwind dependency */ #include "common.h" #ifdef DEBUG # define AB_FUNCT(x) do { printf x; printf("\n"); } while(0) # define AB_PRINT(x) do { printf x; printf("\n"); } while(0) #else # define AB_FUNCT(x) # define AB_PRINT(x) #endif #define AB_ERROR(x) do { printf("ERROR: "); printf x; printf("\n"); } while(0) #undef TRUE #undef FALSE enum { FALSE, TRUE }; typedef int DbTestFn(void); static int RunTests(void); typedef struct { DbTestFn *testFn; const char *description; } DbTestEntry; /* * Test that makes a parameterized ODBC query using SQLPrepare and SQLExecute */ static int TestRawODBCPreparedQuery(void) { SQLTCHAR *queryString; SQLLEN lenOrInd = 0; SQLSMALLINT supplierId = 4; int count; AB_FUNCT(("TestRawODBCPreparedQuery (in)")); /* INIT */ odbc_connect(); /* MAKE QUERY */ odbc_command("CREATE TABLE #Products (" "ProductID int NOT NULL ," "ProductName varchar (40) ," "SupplierID int NULL ," "CategoryID int NULL ," "QuantityPerUnit varchar (20) ," "UnitPrice money NULL ," "UnitsInStock smallint NULL ," "UnitsOnOrder smallint NULL ," "ReorderLevel smallint NULL ," "Discontinued bit NOT NULL " ") " "INSERT INTO #Products(ProductID,ProductName,SupplierID,CategoryID,QuantityPerUnit,UnitPrice,UnitsInStock,UnitsOnOrder,ReorderLevel,Discontinued) VALUES(9,'Mishi Kobe Niku',4,6,'18 - 500 g pkgs.',97.00,29,0,0,1) " "INSERT INTO #Products(ProductID,ProductName,SupplierID,CategoryID,QuantityPerUnit,UnitPrice,UnitsInStock,UnitsOnOrder,ReorderLevel,Discontinued) VALUES(10,'Ikura',4,8,'12 - 200 ml jars',31.00,31,0,0,0) " "INSERT INTO #Products(ProductID,ProductName,SupplierID,CategoryID,QuantityPerUnit,UnitPrice,UnitsInStock,UnitsOnOrder,ReorderLevel,Discontinued) VALUES(74,'Longlife Tofu',4,7,'5 kg pkg.',10.00,4,20,5,0) " "INSERT INTO #Products(ProductID,ProductName,SupplierID,CategoryID,QuantityPerUnit,UnitPrice,UnitsInStock,UnitsOnOrder,ReorderLevel,Discontinued) VALUES(11,'Queso Cabrales',5,4,'1 kg pkg.',21.00,22,30,30,0) " "INSERT INTO #Products(ProductID,ProductName,SupplierID,CategoryID,QuantityPerUnit,UnitPrice,UnitsInStock,UnitsOnOrder,ReorderLevel,Discontinued) VALUES(12,'Queso Manchego La Pastora',5,4,'10 - 500 g pkgs.',38.00,86,0,0,0)"); while (SQLMoreResults(odbc_stmt) == SQL_SUCCESS) continue; queryString = T("SELECT * FROM #Products WHERE SupplierID = ?"); CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_SSHORT, SQL_INTEGER, 0, 0, &supplierId, 0, &lenOrInd, "S"); CHKPrepare(queryString, SQL_NTS, "S"); CHKExecute("S"); count = 0; while (SQLFetch(odbc_stmt) == SQL_SUCCESS) { count++; } AB_PRINT(("Got %d rows", count)); if (count != 3) { /* * OK - so 3 is a magic number - it's the number of rows matching * this query from the MS sample Northwind database and is a constant. */ AB_ERROR(("Expected %d rows - but got %d rows", 3, count)); AB_FUNCT(("TestRawODBCPreparedQuery (out): error")); return FALSE; } /* CLOSEDOWN */ odbc_disconnect(); AB_FUNCT(("TestRawODBCPreparedQuery (out): ok")); return TRUE; } /* * Test that makes a parameterized ODBC query using SQLExecDirect. */ static int TestRawODBCDirectQuery(void) { SQLLEN lenOrInd = 0; SQLSMALLINT supplierId = 1; int count; AB_FUNCT(("TestRawODBCDirectQuery (in)")); /* INIT */ odbc_connect(); /* MAKE QUERY */ odbc_command("CREATE TABLE #Products (" "ProductID int NOT NULL ," "ProductName varchar (40) ," "SupplierID int NULL ," "CategoryID int NULL ," "QuantityPerUnit varchar (20) ," "UnitPrice money NULL ," "UnitsInStock smallint NULL ," "UnitsOnOrder smallint NULL ," "ReorderLevel smallint NULL ," "Discontinued bit NOT NULL " ") " "INSERT INTO #Products(ProductID,ProductName,SupplierID,CategoryID,QuantityPerUnit,UnitPrice,UnitsInStock,UnitsOnOrder,ReorderLevel,Discontinued) VALUES(1,'Chai',1,1,'10 boxes x 20 bags',18.00,39,0,10,0) " "INSERT INTO #Products(ProductID,ProductName,SupplierID,CategoryID,QuantityPerUnit,UnitPrice,UnitsInStock,UnitsOnOrder,ReorderLevel,Discontinued) VALUES(2,'Chang',1,1,'24 - 12 oz bottles',19.00,17,40,25,0) " "INSERT INTO #Products(ProductID,ProductName,SupplierID,CategoryID,QuantityPerUnit,UnitPrice,UnitsInStock,UnitsOnOrder,ReorderLevel,Discontinued) VALUES(3,'Aniseed Syrup',1,2,'12 - 550 ml bottles',10.00,13,70,25,0) " "INSERT INTO #Products(ProductID,ProductName,SupplierID,CategoryID,QuantityPerUnit,UnitPrice,UnitsInStock,UnitsOnOrder,ReorderLevel,Discontinued) VALUES(4,'Chef Anton''s Cajun Seasoning',2,2,'48 - 6 oz jars',22.00,53,0,0,0) " "INSERT INTO #Products(ProductID,ProductName,SupplierID,CategoryID,QuantityPerUnit,UnitPrice,UnitsInStock,UnitsOnOrder,ReorderLevel,Discontinued) VALUES(5,'Chef Anton''s Gumbo Mix',2,2,'36 boxes',21.35,0,0,0,1) "); while (SQLMoreResults(odbc_stmt) == SQL_SUCCESS) continue; CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_SSHORT, SQL_INTEGER, 0, 0, &supplierId, 0, &lenOrInd, "S"); CHKExecDirect(T("SELECT * FROM #Products WHERE SupplierID = ?"), SQL_NTS, "S"); count = 0; while (SQLFetch(odbc_stmt) == SQL_SUCCESS) { count++; } AB_PRINT(("Got %d rows", count)); if (count != 3) { /* * OK - so 3 is a magic number - it's the number of rows matching * this query from the MS sample Northwind database and is a constant. */ AB_ERROR(("Expected %d rows - but got %d rows", 3, count)); AB_FUNCT(("TestRawODBCDirectQuery (out): error")); return FALSE; } /* CLOSEDOWN */ odbc_disconnect(); AB_FUNCT(("TestRawODBCDirectQuery (out): ok")); return TRUE; } /* * Test that show what works and what doesn't for the poorly * documented GUID. */ static int TestRawODBCGuid(void) { SQLRETURN status; const char *queryString; SQLLEN lenOrInd; SQLSMALLINT age; char guid[40]; SQLCHAR name[20]; SQLGUID sqlguid; int count = 0; AB_FUNCT(("TestRawODBCGuid (in)")); odbc_connect(); if (!odbc_db_is_microsoft()) { odbc_disconnect(); return TRUE; } AB_PRINT(("Creating #pet table")); queryString = "CREATE TABLE #pet (name VARCHAR(20), owner VARCHAR(20), " "species VARCHAR(20), sex CHAR(1), age INTEGER, " "guid UNIQUEIDENTIFIER DEFAULT NEWID() ); "; CHKExecDirect(T(queryString), SQL_NTS, "SNo"); odbc_command_with_result(odbc_stmt, "DROP PROC GetGUIDRows"); AB_PRINT(("Creating stored proc GetGUIDRows")); queryString = "CREATE PROCEDURE GetGUIDRows (@guidpar uniqueidentifier) AS \ SELECT name, guid FROM #pet WHERE guid = @guidpar"; CHKExecDirect(T(queryString), SQL_NTS, "SNo"); AB_PRINT(("Insert row 1")); queryString = "INSERT INTO #pet( name, owner, species, sex, age ) \ VALUES ( 'Fang', 'Mike', 'dog', 'm', 12 );"; CHKExecDirect(T(queryString), SQL_NTS, "S"); AB_PRINT(("Insert row 2")); /* * Ok - new row with explicit GUID, but parameterised age. */ queryString = "INSERT INTO #pet( name, owner, species, sex, age, guid ) \ VALUES ( 'Splash', 'Dan', 'fish', 'm', ?, \ '12345678-1234-1234-1234-123456789012' );"; lenOrInd = 0; age = 3; CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_SSHORT, SQL_INTEGER, 0, 0, &age, 0, &lenOrInd, "S"); CHKExecDirect(T(queryString), SQL_NTS, "S"); CHKFreeStmt(SQL_CLOSE, "S"); AB_PRINT(("Insert row 3")); /* * Ok - new row with parameterised GUID. */ queryString = "INSERT INTO #pet( name, owner, species, sex, age, guid ) \ VALUES ( 'Woof', 'Tom', 'cat', 'f', 2, ? );"; lenOrInd = SQL_NTS; strcpy(guid, "87654321-4321-4321-4321-123456789abc"); CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_GUID, 0, 0, guid, 0, &lenOrInd, "S"); CHKExecDirect(T(queryString), SQL_NTS, "S"); AB_PRINT(("Insert row 4")); /* * Ok - new row with parameterised GUID. */ queryString = "INSERT INTO #pet( name, owner, species, sex, age, guid ) \ VALUES ( 'Spike', 'Diane', 'pig', 'f', 4, ? );"; lenOrInd = SQL_NTS; strcpy(guid, "1234abcd-abcd-abcd-abcd-123456789abc"); CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 36, 0, guid, 0, &lenOrInd, "S"); CHKExecDirect(T(queryString), SQL_NTS, "S"); AB_PRINT(("Insert row 5")); /* * Ok - new row with parameterised GUID. */ queryString = "INSERT INTO #pet( name, owner, species, sex, age, guid ) \ VALUES ( 'Fluffy', 'Sam', 'dragon', 'm', 16, ? );"; sqlguid.Data1 = 0xaabbccdd; sqlguid.Data2 = 0xeeff; sqlguid.Data3 = 0x1122; sqlguid.Data4[0] = 0x11; sqlguid.Data4[1] = 0x22; sqlguid.Data4[2] = 0x33; sqlguid.Data4[3] = 0x44; sqlguid.Data4[4] = 0x55; sqlguid.Data4[5] = 0x66; sqlguid.Data4[6] = 0x77; sqlguid.Data4[7] = 0x88; lenOrInd = 16; strcpy(guid, "1234abcd-abcd-abcd-abcd-123456789abc"); CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_GUID, SQL_GUID, 16, 0, &sqlguid, 16, &lenOrInd, "S"); status = SQLExecDirect(odbc_stmt, T(queryString), SQL_NTS); if (status != SQL_SUCCESS) { AB_ERROR(("Insert row 5 failed")); AB_ERROR(("Sadly this was expected in *nix ODBC. Carry on.")); } /* * Now retrieve rows - especially GUID column values. */ AB_PRINT(("retrieving name and guid")); queryString = "SELECT name, guid FROM #pet"; CHKExecDirect(T(queryString), SQL_NTS, "S"); while (SQLFetch(odbc_stmt) == SQL_SUCCESS) { count++; CHKGetData(1, SQL_CHAR, name, 20, 0, "S"); CHKGetData(2, SQL_CHAR, guid, 37, 0, "S"); AB_PRINT(("name: %-10s guid: %s", name, guid)); } /* * Realloc cursor handle - (Windows ODBC considers it an invalid cursor * state if we try SELECT again). */ odbc_reset_statement(); /* * Now retrieve rows - especially GUID column values. */ AB_PRINT(("retrieving name and guid again")); queryString = "SELECT name, guid FROM #pet"; CHKExecDirect(T(queryString), SQL_NTS, "S"); while (CHKFetch("SNo") == SQL_SUCCESS) { count++; CHKGetData(1, SQL_CHAR, name, 20, 0, "S"); CHKGetData(2, SQL_GUID, &sqlguid, 16, 0, "S"); AB_PRINT(("%-10s %08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", name, (int) (sqlguid.Data1), sqlguid.Data2, sqlguid.Data3, sqlguid.Data4[0], sqlguid.Data4[1], sqlguid.Data4[2], sqlguid.Data4[3], sqlguid.Data4[4], sqlguid.Data4[5], sqlguid.Data4[6], sqlguid.Data4[7])); } /* * Realloc cursor handle - (Windows ODBC considers it an invalid cursor * state if we try SELECT again). */ odbc_reset_statement(); /* * Now retrieve rows via stored procedure passing GUID as param. */ AB_PRINT(("retrieving name and guid")); queryString = "{call GetGUIDRows(?)}"; lenOrInd = SQL_NTS; strcpy(guid, "87654321-4321-4321-4321-123456789abc"); CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_GUID, 0, 0, guid, 0, &lenOrInd, "S"); CHKExecDirect(T(queryString), SQL_NTS, "S"); while (SQLFetch(odbc_stmt) == SQL_SUCCESS) { count++; CHKGetData(1, SQL_CHAR, name, 20, 0, "S"); CHKGetData(2, SQL_CHAR, guid, 37, 0, "S"); AB_PRINT(("%-10s %s", name, guid)); } /* * Realloc cursor handle - (Windows ODBC considers it an invalid cursor * state after a previous SELECT has occurred). */ odbc_reset_statement(); /* cleanup */ odbc_command_with_result(odbc_stmt, "DROP PROC GetGUIDRows"); /* CLOSEDOWN */ odbc_disconnect(); AB_FUNCT(("TestRawODBCGuid (out): ok")); return TRUE; } /** * Array of tests. */ static DbTestEntry _dbTests[] = { /* 1 */ {TestRawODBCDirectQuery, "Raw ODBC direct query"}, /* 2 */ {TestRawODBCPreparedQuery, "Raw ODBC prepared query"}, /* 3 */ {TestRawODBCGuid, "Raw ODBC GUID"}, /* end */ {0, 0} }; static DbTestEntry *tests = _dbTests; /** * Code to iterate through all tests to run. * * \return * TRUE if all tests pass, FALSE if any tests fail. */ static int RunTests(void) { unsigned int i; unsigned int passes = 0; unsigned int fails = 0; i = 0; while (tests[i].testFn) { printf("Running test %2d: %s... ", i + 1, tests[i].description); fflush(stdout); if (tests[i].testFn()) { printf("pass\n"); passes++; } else { printf("fail\n"); fails++; } i++; ODBC_FREE(); } if (fails == 0) { printf("\nAll %d tests passed.\n\n", passes); } else { printf("\nTest passes: %d, test fails: %d\n\n", passes, fails); } /* Return TRUE if there are no failures */ return (!fails); } int main(int argc, char *argv[]) { odbc_use_version3 = 1; if (RunTests()) return 0; /* Success */ return 1; /* Error code */ } freetds-1.00.82/src/odbc/unittests/timeout.c100644 025423 025423 00000003641 12522201763 0014424#include "common.h" #include /* Test timeout of query */ static char software_version[] = "$Id: timeout.c,v 1.14 2011-07-12 10:16:59 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static void AutoCommit(int onoff) { CHKSetConnectAttr(SQL_ATTR_AUTOCOMMIT, int2ptr(onoff), 0, "S"); } static void EndTransaction(SQLSMALLINT type) { CHKEndTran(SQL_HANDLE_DBC, odbc_conn, type, "S"); } int main(int argc, char *argv[]) { HENV env; HDBC dbc; HSTMT stmt; SQLINTEGER i; odbc_connect(); /* here we can't use temporary table cause we use two connection */ odbc_command_with_result(odbc_stmt, "drop table test_timeout"); odbc_command("create table test_timeout(n numeric(18,0) primary key, t varchar(30))"); AutoCommit(SQL_AUTOCOMMIT_OFF); odbc_command("insert into test_timeout(n, t) values(1, 'initial')"); EndTransaction(SQL_COMMIT); odbc_command("update test_timeout set t = 'second' where n = 1"); /* save this connection and do another */ env = odbc_env; dbc = odbc_conn; stmt = odbc_stmt; odbc_env = SQL_NULL_HENV; odbc_conn = SQL_NULL_HDBC; odbc_stmt = SQL_NULL_HSTMT; odbc_connect(); AutoCommit(SQL_AUTOCOMMIT_OFF); CHKSetStmtAttr(SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER) 2, 0, "S"); i = 1; CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &i, 0, NULL, "S"); CHKPrepare(T("update test_timeout set t = 'bad' where n = ?"), SQL_NTS, "S"); CHKExecute("E"); EndTransaction(SQL_ROLLBACK); /* TODO should return error S1T00 Timeout expired, test error message */ odbc_command2("update test_timeout set t = 'bad' where n = 1", "E"); EndTransaction(SQL_ROLLBACK); odbc_disconnect(); odbc_env = env; odbc_conn = dbc; odbc_stmt = stmt; EndTransaction(SQL_COMMIT); /* Sybase do not accept DROP TABLE during a transaction */ AutoCommit(SQL_AUTOCOMMIT_ON); odbc_command("drop table test_timeout"); odbc_disconnect(); return 0; } freetds-1.00.82/src/odbc/unittests/timeout2.c100644 025423 025423 00000002140 12522201763 0014477#include "common.h" #ifdef HAVE_UNISTD_H #include #endif #include #include "replacements.h" /* * Test timeout on prepare * It execute a query wait for timeout and then try to issue a new prepare/execute * This test a BUG where second prepare timeouts * * Test from Ou Liu, cf "Query Time Out", 2006-08-08 */ int main(int argc, char *argv[]) { int i; odbc_connect(); odbc_command("create table #timeout(i int)"); odbc_command("insert into #timeout values(1)"); for (i = 0; i < 2; ++i) { printf("Loop %d\n", i); CHKSetStmtAttr(SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER) 10, SQL_IS_UINTEGER, "S"); CHKPrepare(T("select * from #timeout"), SQL_NTS, "S"); CHKExecute("S"); do { while (CHKFetch("SNo") == SQL_SUCCESS) ; } while (CHKMoreResults("SNo") == SQL_SUCCESS); if (i == 0) { printf("Sleep 15 seconds to test if timeout occurs\n"); tds_sleep_s(15); } SQLFreeStmt(odbc_stmt, SQL_CLOSE); SQLFreeStmt(odbc_stmt, SQL_UNBIND); SQLFreeStmt(odbc_stmt, SQL_RESET_PARAMS); SQLCloseCursor(odbc_stmt); } odbc_disconnect(); ODBC_FREE(); return 0; } freetds-1.00.82/src/odbc/unittests/timeout3.c100644 025423 025423 00000011505 12607665421 0014516/* * Test connection timeout */ #include "common.h" #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #include #if HAVE_ERRNO_H #include #endif /* HAVE_ERRNO_H */ #if HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #if HAVE_NETINET_IN_H #include #endif /* HAVE_NETINET_IN_H */ #if HAVE_POLL_H #include #endif /* HAVE_POLL_H */ #include #include #include "replacements.h" #if TDS_HAVE_MUTEX static void init_connect(void); static void init_connect(void) { CHKAllocEnv(&odbc_env, "S"); SQLSetEnvAttr(odbc_env, SQL_ATTR_ODBC_VERSION, (SQLPOINTER) (SQL_OV_ODBC3), SQL_IS_UINTEGER); CHKAllocConnect(&odbc_conn, "S"); } static tds_thread fake_thread; static tds_mutex mtx; static TDS_SYS_SOCKET fake_sock; static TDS_THREAD_PROC_DECLARE(fake_thread_proc, arg); /* build a listening socket to connect to */ static int init_fake_server(int ip_port) { struct sockaddr_in sin; TDS_SYS_SOCKET s; int err; memset(&sin, 0, sizeof(sin)); sin.sin_addr.s_addr = INADDR_ANY; sin.sin_port = htons((short) ip_port); sin.sin_family = AF_INET; if (TDS_IS_SOCKET_INVALID(s = socket(AF_INET, SOCK_STREAM, 0))) { perror("socket"); exit(1); } if (bind(s, (struct sockaddr *) &sin, sizeof(sin)) < 0) { perror("bind"); CLOSESOCKET(s); return 1; } listen(s, 5); err = tds_thread_create(&fake_thread, fake_thread_proc, int2ptr(s)); if (err != 0) { perror("tds_thread_create"); exit(1); } return 0; } /* accept a socket and read data as much as you can */ static TDS_THREAD_PROC_DECLARE(fake_thread_proc, arg) { TDS_SYS_SOCKET s = ptr2int(arg), sock; socklen_t len; char buf[128]; struct sockaddr_in sin; struct pollfd fd; memset(&sin, 0, sizeof(sin)); len = sizeof(sin); fd.fd = s; fd.events = POLLIN; fd.revents = 0; if (poll(&fd, 1, 30000) <= 0) { perror("poll"); exit(1); } if (TDS_IS_SOCKET_INVALID(sock = tds_accept(s, (struct sockaddr *) &sin, &len))) { perror("accept"); exit(1); } tds_mutex_lock(&mtx); fake_sock = sock; tds_mutex_unlock(&mtx); CLOSESOCKET(s); for (;;) { int len; fd.fd = sock; fd.events = POLLIN; fd.revents = 0; if (poll(&fd, 1, 30000) <= 0) { perror("poll"); exit(1); } /* just read and discard */ len = READSOCKET(sock, buf, sizeof(buf)); if (len == 0) break; if (len < 0 && sock_errno != TDSSOCK_EINPROGRESS) break; } return NULL; } int main(int argc, char *argv[]) { SQLTCHAR tmp[2048]; char conn[128]; SQLTCHAR sqlstate[6]; SQLSMALLINT len; int port; time_t start_time, end_time; #ifdef _WIN32 WSADATA wsaData; WSAStartup(MAKEWORD(1, 1), &wsaData); #endif if (tds_mutex_init(&mtx)) return 1; if (odbc_read_login_info()) exit(1); /* * prepare our odbcinst.ini * is better to do it before connect cause uniODBC cache INIs * the name must be odbcinst.ini cause unixODBC accept only this name */ if (odbc_driver[0]) { FILE *f = fopen("odbcinst.ini", "w"); if (f) { fprintf(f, "[FreeTDS]\nDriver = %s\n", odbc_driver); fclose(f); /* force iODBC */ setenv("ODBCINSTINI", "./odbcinst.ini", 1); setenv("SYSODBCINSTINI", "./odbcinst.ini", 1); /* force unixODBC (only directory) */ setenv("ODBCSYSINI", ".", 1); } } for (port = 12340; port < 12350; ++port) if (!init_fake_server(port)) break; if (port == 12350) { fprintf(stderr, "Cannot bind to a port\n"); return 1; } printf("Fake server bound at port %d\n", port); init_connect(); CHKSetConnectAttr(SQL_ATTR_CONNECTION_TIMEOUT, (SQLPOINTER) 10, sizeof(SQLINTEGER), "SI"); CHKSetConnectAttr(SQL_ATTR_LOGIN_TIMEOUT, (SQLPOINTER) 10, SQL_IS_UINTEGER, "SI"); /* this is expected to work with unixODBC */ printf("try to connect to our port just to check connection timeout\n"); sprintf(conn, "DRIVER=FreeTDS;SERVER=127.0.0.1;Port=%d;TDS_Version=7.0;UID=test;PWD=test;DATABASE=tempdb;", port); start_time = time(NULL); CHKDriverConnect(NULL, T(conn), SQL_NTS, tmp, ODBC_VECTOR_SIZE(tmp), &len, SQL_DRIVER_NOPROMPT, "E"); end_time = time(NULL); memset(sqlstate, 'X', sizeof(sqlstate)); tmp[0] = 0; CHKGetDiagRec(SQL_HANDLE_DBC, odbc_conn, 1, sqlstate, NULL, tmp, ODBC_VECTOR_SIZE(tmp), NULL, "SI"); odbc_disconnect(); tds_mutex_lock(&mtx); CLOSESOCKET(fake_sock); tds_mutex_unlock(&mtx); tds_thread_join(fake_thread, NULL); printf("Message: %s - %s\n", C(sqlstate), C(tmp)); if (strcmp(C(sqlstate), "HYT00") || !strstr(C(tmp), "Timeout")) { fprintf(stderr, "Invalid timeout message\n"); return 1; } if (end_time - start_time < 10 || end_time - start_time > 16) { fprintf(stderr, "Unexpected connect timeout (%d)\n", (int) (end_time - start_time)); return 1; } printf("Done.\n"); ODBC_FREE(); return 0; } #else /* !TDS_HAVE_MUTEX */ int main(void) { printf("Not possible for this platform.\n"); odbc_test_skipped(); return 0; } #endif freetds-1.00.82/src/odbc/unittests/timeout4.c100644 025423 025423 00000004743 12717145107 0014521#include "common.h" #if HAVE_UNISTD_H #include #endif /* HAVE_UNISTD_H */ #include #if HAVE_SYS_SOCKET_H #include #endif /* HAVE_SYS_SOCKET_H */ #if HAVE_SYS_STAT_H #include #endif /* HAVE_SYS_STAT_H */ #if HAVE_SYS_IOCTL_H #include #endif /* HAVE_SYS_IOCTL_H */ #if HAVE_SYS_WAIT_H #include #endif /* HAVE_SYS_WAIT_H */ /* * test error on connection close * With a trick we simulate a connection close then we try to * prepare or execute a query. This should fail and return an error message. */ #if HAVE_FSTAT && defined(S_IFSOCK) static int end_socket = -1; static int shutdown_last_socket(void) { TDS_SYS_SOCKET max_socket = odbc_find_last_socket(); TDS_SYS_SOCKET sockets[2]; if (max_socket < 0) return 0; /* replace socket with a new one */ if (socketpair(AF_UNIX, SOCK_STREAM, 0, sockets) < 0) return 0; /* substitute socket */ close(max_socket); dup2(sockets[0], max_socket); /* close connection */ close(sockets[0]); end_socket = sockets[1]; return 1; } static int Test(int direct) { SQLTCHAR buf[256]; SQLTCHAR sqlstate[6]; time_t start_time, end_time; odbc_mark_sockets_opened(); odbc_connect(); if (!shutdown_last_socket()) { fprintf(stderr, "Error shutting down connection\n"); return 1; } CHKSetStmtAttr(SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER) 10, SQL_IS_UINTEGER, "S"); alarm(30); start_time = time(NULL); if (direct) { CHKExecDirect(T("SELECT 1"), SQL_NTS, "E"); } else { SQLSMALLINT cols; /* force dialog with server */ if (CHKPrepare(T("SELECT 1"), SQL_NTS, "SE") == SQL_SUCCESS) CHKNumResultCols(&cols, "E"); } end_time = time(NULL); alarm(0); memset(sqlstate, 'X', sizeof(sqlstate)); CHKGetDiagRec(SQL_HANDLE_STMT, odbc_stmt, 1, sqlstate, NULL, buf, ODBC_VECTOR_SIZE(buf), NULL, "SI"); sqlstate[5] = 0; printf("Message: %s - %s\n", C(sqlstate), C(buf)); if (strcmp(C(sqlstate), "HYT00") || !strstr(C(buf), "Timeout")) { fprintf(stderr, "Invalid timeout message\n"); return 1; } if (end_time - start_time < 10 || end_time - start_time > 26) { fprintf(stderr, "Unexpected connect timeout (%d)\n", (int) (end_time - start_time)); return 1; } odbc_disconnect(); if (end_socket >= 0) close(end_socket); printf("Done.\n"); return 0; } int main(void) { odbc_use_version3 = 1; if (Test(0) || Test(1)) return 1; return 0; } #else int main(void) { printf("Not possible for this platform.\n"); odbc_test_skipped(); return 0; } #endif freetds-1.00.82/src/odbc/unittests/transaction.c100644 025423 025423 00000005662 12522201763 0015270#include "common.h" static char software_version[] = "$Id: transaction.c,v 1.18 2011-07-12 10:16:59 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static int Test(int discard_test) { ODBC_BUF *odbc_buf = NULL; SQLINTEGER out_buf; SQLLEN out_len; SQLLEN rows; int retcode = 0; SQLTCHAR buf[512]; SQLTCHAR sqlstate[6]; const char *createErrorProcedure = "CREATE PROCEDURE testerror AS\n" "SELECT value FROM TestTransaction\n" "SELECT value / (value-value) FROM TestTransaction\n"; /* select after insert is required to test data discarding */ char createProcedure[512]; sprintf(createProcedure, "CREATE PROCEDURE testinsert @value INT AS\n" "INSERT INTO TestTransaction VALUES ( @value )\n%s", discard_test ? "SELECT * FROM TestTransaction\n" : ""); /* create stored proc */ odbc_command_with_result(odbc_stmt, "DROP PROCEDURE testinsert"); odbc_command(createProcedure); /* create stored proc that generates an error */ odbc_command_with_result(odbc_stmt, "DROP PROCEDURE testerror"); odbc_command(createErrorProcedure); /* Start transaction */ CHKSetConnectAttr(SQL_ATTR_AUTOCOMMIT, (void *) SQL_AUTOCOMMIT_OFF, 0, "S"); /* Insert a value */ odbc_command("EXEC testinsert 1"); /* we should be able to read row count */ CHKRowCount(&rows, "S"); /* Commit transaction */ CHKEndTran(SQL_HANDLE_DBC, odbc_conn, SQL_COMMIT, "S"); SQLCloseCursor(odbc_stmt); /* Start transaction */ CHKSetConnectAttr(SQL_ATTR_AUTOCOMMIT, (void *) SQL_AUTOCOMMIT_OFF, 0, "S"); /* Insert another value */ odbc_command("EXEC testinsert 2"); /* Roll back transaction */ CHKEndTran(SQL_HANDLE_DBC, odbc_conn, SQL_ROLLBACK, "S"); /* TODO test row inserted */ CHKSetConnectAttr(SQL_ATTR_AUTOCOMMIT, (void *) SQL_AUTOCOMMIT_ON, 0, "S"); /* generate an error */ odbc_command("EXEC testerror"); CHKBindCol(1, SQL_C_SLONG, &out_buf, sizeof(out_buf), &out_len, "S"); while (CHKFetch("SNo") == SQL_SUCCESS) { printf("\t%ld\n", (long int) out_buf); if (out_buf != 1) { fprintf(stderr, "error: expected to select 1 got %ld\n", (long int) out_buf); retcode = 1; goto cleanup; } } CHKMoreResults("E"); CHKGetDiagRec(SQL_HANDLE_STMT, odbc_stmt, 1, sqlstate, NULL, buf, ODBC_VECTOR_SIZE(buf), NULL, "SI"); printf("err=%s\n", C(buf)); CHKMoreResults("No"); cleanup: /* drop table */ odbc_command_with_result(odbc_stmt, "DROP PROCEDURE testinsert"); odbc_command_with_result(odbc_stmt, "DROP PROCEDURE testerror"); ODBC_FREE(); return retcode; } int main(int argc, char *argv[]) { int retcode = 0; odbc_connect(); /* create table */ odbc_command_with_result(odbc_stmt, "DROP TABLE TestTransaction"); odbc_command("CREATE TABLE TestTransaction ( value INT )"); if (!retcode) retcode = Test(1); if (!retcode) retcode = Test(0); /* drop table */ odbc_command_with_result(odbc_stmt, "DROP TABLE TestTransaction"); odbc_disconnect(); printf("Done.\n"); return retcode; } freetds-1.00.82/src/odbc/unittests/transaction2.c100644 025423 025423 00000016026 12717145107 0015353#include "common.h" #include /* Test transaction types */ static void ReadErrorConn(void) { ODBC_BUF *odbc_buf = NULL; SQLTCHAR *err = (SQLTCHAR *) ODBC_GET(sizeof(odbc_err)*sizeof(SQLTCHAR)); SQLTCHAR *state = (SQLTCHAR *) ODBC_GET(sizeof(odbc_sqlstate)*sizeof(SQLTCHAR)); memset(odbc_err, 0, sizeof(odbc_err)); memset(odbc_sqlstate, 0, sizeof(odbc_sqlstate)); CHKGetDiagRec(SQL_HANDLE_DBC, odbc_conn, 1, state, NULL, err, sizeof(odbc_err), NULL, "SI"); strcpy(odbc_err, C(err)); strcpy(odbc_sqlstate, C(state)); ODBC_FREE(); printf("Message: '%s' %s\n", odbc_sqlstate, odbc_err); } static void AutoCommit(int onoff) { CHKSetConnectAttr(SQL_ATTR_AUTOCOMMIT, int2ptr(onoff), 0, "S"); } static void EndTransaction(SQLSMALLINT type) { CHKEndTran(SQL_HANDLE_DBC, odbc_conn, type, "S"); } #define SWAP(t,a,b) do { t xyz = a; a = b; b = xyz; } while(0) #define SWAP_CONN() do { SWAP(HENV,env,odbc_env); SWAP(HDBC,dbc,odbc_conn); SWAP(HSTMT,stmt,odbc_stmt);} while(0) static HENV env = SQL_NULL_HENV; static HDBC dbc = SQL_NULL_HDBC; static HSTMT stmt = SQL_NULL_HSTMT; static int CheckDirtyRead(void) { SQLRETURN RetCode; /* transaction 1 try to change a row but not commit */ odbc_command("UPDATE test_transaction SET t = 'second' WHERE n = 1"); SWAP_CONN(); /* second transaction try to fetch uncommited row */ RetCode = odbc_command2("SELECT * FROM test_transaction WHERE t = 'second' AND n = 1", "SE"); if (RetCode == SQL_ERROR) { EndTransaction(SQL_ROLLBACK); SWAP_CONN(); EndTransaction(SQL_ROLLBACK); return 0; /* no dirty read */ } CHKFetch("S"); CHKFetch("No"); SQLMoreResults(odbc_stmt); EndTransaction(SQL_ROLLBACK); SWAP_CONN(); EndTransaction(SQL_ROLLBACK); return 1; } static int CheckNonrepeatableRead(void) { SQLRETURN RetCode; /* transaction 2 read a row */ SWAP_CONN(); odbc_command("SELECT * FROM test_transaction WHERE t = 'initial' AND n = 1"); SQLMoreResults(odbc_stmt); /* transaction 1 change a row and commit */ SWAP_CONN(); RetCode = odbc_command2("UPDATE test_transaction SET t = 'second' WHERE n = 1", "SE"); if (RetCode == SQL_ERROR) { EndTransaction(SQL_ROLLBACK); SWAP_CONN(); EndTransaction(SQL_ROLLBACK); SWAP_CONN(); return 0; /* no dirty read */ } EndTransaction(SQL_COMMIT); SWAP_CONN(); /* second transaction try to fetch commited row */ odbc_command("SELECT * FROM test_transaction WHERE t = 'second' AND n = 1"); CHKFetch("S"); CHKFetch("No"); SQLMoreResults(odbc_stmt); EndTransaction(SQL_ROLLBACK); SWAP_CONN(); odbc_command("UPDATE test_transaction SET t = 'initial' WHERE n = 1"); EndTransaction(SQL_COMMIT); return 1; } static int CheckPhantom(void) { SQLRETURN RetCode; /* transaction 2 read a row */ SWAP_CONN(); odbc_command("SELECT * FROM test_transaction WHERE t = 'initial'"); SQLMoreResults(odbc_stmt); /* transaction 1 insert a row that match critera */ SWAP_CONN(); RetCode = odbc_command2("INSERT INTO test_transaction(n, t) VALUES(2, 'initial')", "SE"); if (RetCode == SQL_ERROR) { EndTransaction(SQL_ROLLBACK); SWAP_CONN(); EndTransaction(SQL_ROLLBACK); SWAP_CONN(); return 0; /* no dirty read */ } EndTransaction(SQL_COMMIT); SWAP_CONN(); /* second transaction try to fetch commited row */ odbc_command("SELECT * FROM test_transaction WHERE t = 'initial'"); CHKFetch("S"); CHKFetch("S"); CHKFetch("No"); SQLMoreResults(odbc_stmt); EndTransaction(SQL_ROLLBACK); SWAP_CONN(); odbc_command("DELETE test_transaction WHERE n = 2"); EndTransaction(SQL_COMMIT); return 1; } static int test_with_connect = 0; static int global_txn; static int hide_error; static void my_attrs(void) { CHKSetConnectAttr(SQL_ATTR_TXN_ISOLATION, int2ptr(global_txn), 0, "S"); AutoCommit(SQL_AUTOCOMMIT_OFF); } static void ConnectWithTxn(int txn) { global_txn = txn; odbc_set_conn_attr = my_attrs; odbc_connect(); odbc_set_conn_attr = NULL; } static int Test(int txn, const char *expected) { int dirty, repeatable, phantom; char buf[128]; SWAP_CONN(); if (test_with_connect) { odbc_disconnect(); ConnectWithTxn(txn); CHKSetStmtAttr(SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER) 2, 0, "S"); } else { CHKSetConnectAttr(SQL_ATTR_TXN_ISOLATION, int2ptr(txn), 0, "S"); } SWAP_CONN(); dirty = CheckDirtyRead(); repeatable = CheckNonrepeatableRead(); phantom = CheckPhantom(); sprintf(buf, "dirty %d non repeatable %d phantom %d", dirty, repeatable, phantom); if (strcmp(buf, expected) != 0) { if (hide_error) { hide_error = 0; return 0; } fprintf(stderr, "detected wrong TXN\nexpected '%s' got '%s'\n", expected, buf); exit(1); } hide_error = 0; return 1; } int main(int argc, char *argv[]) { odbc_use_version3 = 1; odbc_connect(); /* Invalid argument value */ CHKSetConnectAttr(SQL_ATTR_TXN_ISOLATION, int2ptr(SQL_TXN_REPEATABLE_READ | SQL_TXN_READ_COMMITTED), 0, "E"); ReadErrorConn(); if (strcmp(odbc_sqlstate, "HY024") != 0) { odbc_disconnect(); fprintf(stderr, "Unexpected success\n"); return 1; } /* here we can't use temporary table cause we use two connection */ odbc_command("IF OBJECT_ID('test_transaction') IS NOT NULL DROP TABLE test_transaction"); odbc_command("CREATE TABLE test_transaction(n NUMERIC(18,0) PRIMARY KEY, t VARCHAR(30))"); CHKSetStmtAttr(SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER) 2, 0, "S"); AutoCommit(SQL_AUTOCOMMIT_OFF); odbc_command("INSERT INTO test_transaction(n, t) VALUES(1, 'initial')"); #ifdef ENABLE_DEVELOPING /* test setting with active transaction "Operation invalid at this time" */ CHKSetConnectAttr(SQL_ATTR_TXN_ISOLATION, int2ptr(SQL_TXN_REPEATABLE_READ), 0, "E"); ReadErrorConn(); if (strcmp(odbc_sqlstate, "HY011") != 0) { odbc_disconnect(); fprintf(stderr, "Unexpected success\n"); return 1; } #endif EndTransaction(SQL_COMMIT); odbc_command("SELECT * FROM test_transaction"); /* test setting with pending data */ CHKSetConnectAttr(SQL_ATTR_TXN_ISOLATION, int2ptr(SQL_TXN_REPEATABLE_READ), 0, "E"); ReadErrorConn(); if (strcmp(odbc_sqlstate, "HY011") != 0) { odbc_disconnect(); fprintf(stderr, "Unexpected success\n"); return 1; } SQLMoreResults(odbc_stmt); EndTransaction(SQL_COMMIT); /* save this connection and do another */ SWAP_CONN(); odbc_connect(); CHKSetStmtAttr(SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER) 2, 0, "S"); AutoCommit(SQL_AUTOCOMMIT_OFF); SWAP_CONN(); for (test_with_connect = 0; test_with_connect <= 1; ++test_with_connect) { Test(SQL_TXN_READ_UNCOMMITTED, "dirty 1 non repeatable 1 phantom 1"); Test(SQL_TXN_READ_COMMITTED, "dirty 0 non repeatable 1 phantom 1"); if (odbc_db_is_microsoft()) { Test(SQL_TXN_REPEATABLE_READ, "dirty 0 non repeatable 0 phantom 1"); } else { hide_error = 1; if (!Test(SQL_TXN_REPEATABLE_READ, "dirty 0 non repeatable 0 phantom 1")) Test(SQL_TXN_REPEATABLE_READ, "dirty 0 non repeatable 0 phantom 0"); } Test(SQL_TXN_SERIALIZABLE, "dirty 0 non repeatable 0 phantom 0"); } odbc_disconnect(); SWAP_CONN(); EndTransaction(SQL_COMMIT); /* Sybase do not accept DROP TABLE during a transaction */ AutoCommit(SQL_AUTOCOMMIT_ON); odbc_command("DROP TABLE test_transaction"); odbc_disconnect(); return 0; } freetds-1.00.82/src/odbc/unittests/type.c100644 025423 025423 00000013061 12717145107 0013721#include "common.h" #include struct type { SQLSMALLINT type; const char *name; unsigned flags; }; #define FLAG_C 1 #define FLAG_SQL 2 #define TYPE_C(s) {s, #s, FLAG_C } #define TYPE_SQL(s) {s, #s, FLAG_SQL } #define TYPE_BOTH(s,s2) {s, #s, FLAG_SQL|FLAG_C } /* * Same define with test for constants * #define TYPE_BOTH(s,s2) {s, #s, (FLAG_SQL|FLAG_C)+((1/!(s-s2))-1) } */ static const struct type types[] = { TYPE_BOTH(SQL_C_CHAR, SQL_CHAR), TYPE_BOTH(SQL_C_LONG, SQL_INTEGER), TYPE_BOTH(SQL_C_SHORT, SQL_SMALLINT), TYPE_BOTH(SQL_C_FLOAT, SQL_REAL), TYPE_BOTH(SQL_C_DOUBLE, SQL_DOUBLE), TYPE_BOTH(SQL_C_NUMERIC, SQL_NUMERIC), TYPE_C(SQL_C_DEFAULT), TYPE_C(SQL_C_DATE), TYPE_C(SQL_C_TIME), /* MS ODBC do not support SQL_TIMESTAMP for IPD type while we support it */ /* TYPE_C(SQL_C_TIMESTAMP), */ TYPE_BOTH(SQL_C_TIMESTAMP, SQL_TIMESTAMP), TYPE_BOTH(SQL_C_TYPE_DATE, SQL_TYPE_DATE), TYPE_C(SQL_C_TYPE_TIME), TYPE_BOTH(SQL_C_TYPE_TIMESTAMP, SQL_TYPE_TIMESTAMP), TYPE_C(SQL_C_INTERVAL_YEAR), TYPE_C(SQL_C_INTERVAL_MONTH), TYPE_C(SQL_C_INTERVAL_DAY), TYPE_C(SQL_C_INTERVAL_HOUR), TYPE_C(SQL_C_INTERVAL_MINUTE), TYPE_C(SQL_C_INTERVAL_SECOND), TYPE_C(SQL_C_INTERVAL_YEAR_TO_MONTH), TYPE_C(SQL_C_INTERVAL_DAY_TO_HOUR), TYPE_C(SQL_C_INTERVAL_DAY_TO_MINUTE), TYPE_C(SQL_C_INTERVAL_DAY_TO_SECOND), TYPE_C(SQL_C_INTERVAL_HOUR_TO_MINUTE), TYPE_C(SQL_C_INTERVAL_HOUR_TO_SECOND), TYPE_C(SQL_C_INTERVAL_MINUTE_TO_SECOND), TYPE_BOTH(SQL_C_BINARY, SQL_BINARY), TYPE_BOTH(SQL_C_BIT, SQL_BIT), TYPE_C(SQL_C_SBIGINT), TYPE_C(SQL_C_UBIGINT), TYPE_BOTH(SQL_C_TINYINT, SQL_TINYINT), TYPE_C(SQL_C_SLONG), TYPE_C(SQL_C_SSHORT), TYPE_C(SQL_C_STINYINT), TYPE_C(SQL_C_ULONG), TYPE_C(SQL_C_USHORT), TYPE_C(SQL_C_UTINYINT), TYPE_BOTH(SQL_C_GUID, SQL_GUID), TYPE_SQL(SQL_BIGINT), TYPE_SQL(SQL_VARBINARY), TYPE_SQL(SQL_LONGVARBINARY), TYPE_SQL(SQL_VARCHAR), TYPE_SQL(SQL_LONGVARCHAR), TYPE_SQL(SQL_DECIMAL), TYPE_SQL(SQL_FLOAT), {0, NULL} }; static const char * get_type_name(SQLSMALLINT type) { const struct type *p = types; for (; p->name; ++p) if (p->type == type) return p->name; return "(unknown)"; } static int result = 0; static void check_msg(int check, const char *msg) { if (check) return; fprintf(stderr, "Check failed: %s\n", msg); result = 1; } int main(int argc, char **argv) { const struct type *p; char buf[16]; SQLINTEGER ind; SQLLEN lind; SQLHDESC desc; odbc_connect(); /* * test setting two time a descriptor * success all user allocated are ARD or APD so type cheching can be done * TODO freeing descriptor dissociate it from statements */ /* test C types */ for (p = types; p->name; ++p) { if (SQL_SUCCEEDED (SQLBindParameter(odbc_stmt, 1, SQL_PARAM_INPUT, p->type, SQL_VARCHAR, (SQLUINTEGER) (-1), 0, buf, 16, &lind))) { SQLSMALLINT concise_type, type, code; SQLHDESC desc; concise_type = type = code = 0; /* get APD */ SQLGetStmtAttr(odbc_stmt, SQL_ATTR_APP_PARAM_DESC, &desc, sizeof(desc), &ind); SQLGetDescField(desc, 1, SQL_DESC_TYPE, &type, sizeof(SQLSMALLINT), &ind); SQLGetDescField(desc, 1, SQL_DESC_CONCISE_TYPE, &concise_type, sizeof(SQLSMALLINT), &ind); SQLGetDescField(desc, 1, SQL_DESC_DATETIME_INTERVAL_CODE, &code, sizeof(SQLSMALLINT), &ind); printf("Setted type %s -> [%d (%s), %d (%s), %d]\n", p->name, (int) concise_type, get_type_name(concise_type), (int) type, get_type_name(type), code); check_msg(p->flags & FLAG_C, "Type not C successed to be set in APD"); } else { SQLSMALLINT concise_type, type, code; SQLHDESC desc; concise_type = type = code = 0; fprintf(stderr, "Error setting type %d (%s)\n", (int) p->type, p->name); concise_type = p->type; SQLGetStmtAttr(odbc_stmt, SQL_ATTR_APP_PARAM_DESC, &desc, sizeof(desc), &ind); if (SQL_SUCCEEDED (SQLSetDescField(desc, 1, SQL_DESC_CONCISE_TYPE, int2ptr(concise_type), sizeof(SQLSMALLINT)))) { SQLGetDescField(desc, 1, SQL_DESC_TYPE, &type, sizeof(SQLSMALLINT), &ind); SQLGetDescField(desc, 1, SQL_DESC_CONCISE_TYPE, &concise_type, sizeof(SQLSMALLINT), &ind); SQLGetDescField(desc, 1, SQL_DESC_DATETIME_INTERVAL_CODE, &code, sizeof(SQLSMALLINT), &ind); printf("Setted type %s -> [%d (%s), %d (%s), %d]\n", p->name, (int) concise_type, get_type_name(concise_type), (int) type, get_type_name(type), code); check_msg(p->flags & FLAG_C, "Type not C successed to be set in APD"); } else { check_msg(!(p->flags & FLAG_C), "Type C failed to be set in APD"); } } } printf("\n\n"); /* test SQL types */ SQLGetStmtAttr(odbc_stmt, SQL_ATTR_IMP_PARAM_DESC, &desc, sizeof(desc), &ind); for (p = types; p->name; ++p) { SQLSMALLINT concise_type = p->type; if (SQL_SUCCEEDED (SQLSetDescField(desc, 1, SQL_DESC_CONCISE_TYPE, int2ptr(concise_type), sizeof(SQLSMALLINT)))) { SQLSMALLINT concise_type, type, code; concise_type = type = code = 0; SQLGetDescField(desc, 1, SQL_DESC_TYPE, &type, sizeof(SQLSMALLINT), &ind); SQLGetDescField(desc, 1, SQL_DESC_CONCISE_TYPE, &concise_type, sizeof(SQLSMALLINT), &ind); SQLGetDescField(desc, 1, SQL_DESC_DATETIME_INTERVAL_CODE, &code, sizeof(SQLSMALLINT), &ind); printf("Setted type %s -> [%d (%s), %d (%s), %d]\n", p->name, (int) concise_type, get_type_name(concise_type), (int) type, get_type_name(type), code); check_msg(p->flags & FLAG_SQL, "Type not SQL successed to be set in IPD"); } else { fprintf(stderr, "Error setting type %d (%s)\n", (int) p->type, p->name); check_msg(!(p->flags & FLAG_SQL), "Type SQL failed to be set in IPD"); } } odbc_disconnect(); return result; } freetds-1.00.82/src/odbc/unittests/typeinfo.c100644 025423 025423 00000013225 12717145107 0014577#include "common.h" static void TestName(int index, const char *expected_name) { ODBC_BUF *odbc_buf = NULL; SQLTCHAR name[128]; char buf[256]; SQLSMALLINT len, type; #define NAME_TEST \ do { \ if (strcmp(C(name), expected_name) != 0) \ { \ sprintf(buf, "wrong name in column %d expected '%s' got '%s'", index, expected_name, C(name)); \ ODBC_REPORT_ERROR(buf); \ } \ } while(0) /* retrieve with SQLDescribeCol */ CHKDescribeCol(index, name, ODBC_VECTOR_SIZE(name), &len, &type, NULL, NULL, NULL, "S"); NAME_TEST; /* retrieve with SQLColAttribute */ CHKColAttribute(index, SQL_DESC_NAME, name, sizeof(name), &len, NULL, "S"); if (odbc_db_is_microsoft()) NAME_TEST; CHKColAttribute(index, SQL_DESC_LABEL, name, sizeof(name), &len, NULL, "S"); NAME_TEST; ODBC_FREE(); } static void Flushodbc_stmt(void) { while (CHKFetch("SNo") == SQL_SUCCESS) ; /* Sybase store procedure seems to return extra empty results */ while (CHKMoreResults("SNo") == SQL_SUCCESS) ; } static void CheckType(SQLSMALLINT type, SQLSMALLINT expected, const char *string_type, int line) { SQLSMALLINT out_type; SQLLEN ind; SQLRETURN RetCode; printf("CheckType %d\n", line); CHKBindCol(2, SQL_C_SSHORT, &out_type, 0, &ind, "SI"); CHKGetTypeInfo(type, "SI"); RetCode = CHKFetch("SNo"); switch (RetCode) { case SQL_SUCCESS: if (expected == SQL_UNKNOWN_TYPE) { fprintf(stderr, "Data not expected (type %d - %s) line %d\n", type, string_type, line); odbc_disconnect(); exit(1); } if (expected != out_type) { fprintf(stderr, "Got type %d expected %d. Input type %d - %s line %d\n", out_type, expected, type, string_type, line); odbc_disconnect(); exit(1); } break; case SQL_NO_DATA: if (expected != SQL_UNKNOWN_TYPE) { fprintf(stderr, "Data expected. Input type %d - %s line %d\n", type, string_type, line); odbc_disconnect(); exit(1); } break; } SQLFreeStmt(odbc_stmt, SQL_UNBIND); Flushodbc_stmt(); } static void DoTest(int version3) { char name[128], params[128]; SQLSMALLINT type, is_unsigned; SQLINTEGER col_size, min_scale; SQLLEN ind1, ind2, ind3, ind4, ind5, ind6; int date_time_supported = 0; int name_version3; int tdsver; odbc_use_version3 = version3; name_version3 = version3; odbc_connect(); printf("Using ODBC version %d\n", version3 ? 3 : 2); tdsver = odbc_tds_version(); /* test column name */ /* MS ODBC use always ODBC 3 names even in ODBC 2 mode */ if (!odbc_driver_is_freetds()) name_version3 = 1; CHKGetTypeInfo(SQL_ALL_TYPES, "SI"); TestName(1, "TYPE_NAME"); TestName(2, "DATA_TYPE"); TestName(3, name_version3 ? "COLUMN_SIZE" : "PRECISION"); TestName(4, "LITERAL_PREFIX"); TestName(5, "LITERAL_SUFFIX"); TestName(6, "CREATE_PARAMS"); TestName(7, "NULLABLE"); TestName(8, "CASE_SENSITIVE"); TestName(9, "SEARCHABLE"); TestName(10, "UNSIGNED_ATTRIBUTE"); TestName(11, name_version3 ? "FIXED_PREC_SCALE" : "MONEY"); TestName(12, name_version3 ? "AUTO_UNIQUE_VALUE" : "AUTO_INCREMENT"); TestName(13, "LOCAL_TYPE_NAME"); TestName(14, "MINIMUM_SCALE"); TestName(15, "MAXIMUM_SCALE"); /* TODO test these column for ODBC 3 */ /* ODBC 3.0 SQL_DATA_TYPE SQL_DATETIME_SUB NUM_PREC_RADIX INTERVAL_PRECISION */ Flushodbc_stmt(); /* TODO test if SQL_ALL_TYPES returns right numeric type for timestamp */ /* numeric type for data */ /* test for date/time support */ if (odbc_command_with_result(odbc_stmt, "select cast(getdate() as date)") == SQL_SUCCESS) date_time_supported = 1; if (odbc_db_is_microsoft() && tdsver < 0x703) date_time_supported = 0; SQLCloseCursor(odbc_stmt); #define CHECK_TYPE(in,out) CheckType(in, out, #in, __LINE__) /* under Sybase this type require extra handling, check it */ CHECK_TYPE(SQL_VARCHAR, SQL_VARCHAR); if (version3) { /* MS ODBC returns S1004 (HY004), TODO support it */ CHECK_TYPE(SQL_TYPE_DATE, date_time_supported ? SQL_TYPE_DATE : SQL_UNKNOWN_TYPE); if (!odbc_db_is_microsoft()) CHECK_TYPE(SQL_TYPE_TIME, date_time_supported ? SQL_TYPE_TIME : SQL_UNKNOWN_TYPE); /* MS ODBC returns S1004 (HY004), TODO support it */ CHECK_TYPE(SQL_TYPE_TIMESTAMP, SQL_TYPE_TIMESTAMP); } else { CHECK_TYPE(SQL_DATE, date_time_supported ? SQL_DATE : SQL_UNKNOWN_TYPE); if (!odbc_db_is_microsoft()) CHECK_TYPE(SQL_TIME, date_time_supported ? SQL_TIME : SQL_UNKNOWN_TYPE); /* TODO MS ODBC handle SQL_TIMESTAMP even for ODBC 3 */ CHECK_TYPE(SQL_TIMESTAMP, SQL_TIMESTAMP); } /* TODO implement this part of test */ /* varchar/nvarchar before sysname */ /* test binding (not all column, required for Oracle) */ CHKGetTypeInfo(SQL_ALL_TYPES, "SI"); CHKBindCol(1, SQL_C_CHAR, name, sizeof(name), &ind1, "SI"); CHKBindCol(2, SQL_C_SSHORT, &type, 0, &ind2, "SI"); CHKBindCol(3, SQL_C_SLONG, &col_size, 0, &ind3, "SI"); CHKBindCol(6, SQL_C_CHAR, params, sizeof(params), &ind4, "SI"); CHKBindCol(10, SQL_C_SSHORT, &is_unsigned, 0, &ind5, "SI"); CHKBindCol(14, SQL_C_SSHORT, &min_scale, 0, &ind6, "SI"); while (CHKFetch("SNo") == SQL_SUCCESS) ; SQLFreeStmt(odbc_stmt, SQL_UNBIND); Flushodbc_stmt(); /* check WVARCHAR for no pending data */ if (odbc_db_is_microsoft() || strncmp(odbc_db_version(), "15.00.", 6) >= 0) { CHKGetTypeInfo(SQL_WVARCHAR, "SI"); CHKFetch("S"); /* mssql returns SYSNAME as NVARCHAR */ if (odbc_db_is_microsoft()) CHKFetch("S"); /* mssql 2008 can return a lot of NVARCHAR as new type (ie DATE) * are converted automatically to NVARCHAR with former protocol */ if (!odbc_db_is_microsoft() || tdsver >= 0x703 || odbc_db_version_int() < 0x0a000000) CHKFetch("No"); CHKMoreResults("No"); CHKGetTypeInfo(SQL_BINARY, "SI"); } odbc_disconnect(); } int main(int argc, char *argv[]) { DoTest(0); DoTest(1); printf("Done.\n"); return 0; } freetds-1.00.82/src/odbc/unittests/utf8.c100644 025423 025423 00000010162 12717145107 0013625#include "common.h" /* test binding with UTF-8 encoding */ #ifndef _WIN32 static void init_connect(void); static void init_connect(void) { CHKAllocEnv(&odbc_env, "S"); SQLSetEnvAttr(odbc_env, SQL_ATTR_ODBC_VERSION, (SQLPOINTER) (SQL_OV_ODBC3), SQL_IS_UINTEGER); CHKAllocConnect(&odbc_conn, "S"); } /* test table name, it contains two japanese characters */ static const char table_name[] = "mytab\xe7\x8e\x8b\xe9\xb4\xbb"; static const char * const strings[] = { /* ascii */ "aaa", "aaa", /* latin 1*/ "abc\xc3\xa9\xc3\xa1\xc3\xb4", "abc\xc3\xa9\xc3\xae\xc3\xb4", /* Japanese... */ "abc\xe7\x8e\x8b\xe9\xb4\xbb", "abc\xe7\x8e\x8b\xe9\xb4\xbb\xe5\x82\x91\xe7\x8e\x8b\xe9\xb4\xbb\xe5\x82\x91", NULL, NULL }; /* same strings in hex */ static const char * const strings_hex[] = { /* ascii */ "0x610061006100", "0x610061006100", /* latin 1*/ "0x610062006300e900e100f400", "0x610062006300e900ee00f400", /* Japanese... */ "0x6100620063008b733b9d", "0x6100620063008b733b9d91508b733b9d9150", NULL, NULL }; static char tmp[2048]; static void TestBinding(int minimun) { const char * const*p; SQLINTEGER n; SQLLEN n_len; sprintf(tmp, "DELETE FROM %s", table_name); odbc_command(tmp); /* insert with SQLPrepare/SQLBindParameter/SQLExecute */ sprintf(tmp, "INSERT INTO %s VALUES(?,?,?)", table_name); CHKPrepare(T(tmp), SQL_NTS, "S"); CHKBindParameter(1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &n, 0, &n_len, "S"); n_len = sizeof(n); for (n = 1, p = strings; p[0] && p[1]; p += 2, ++n) { SQLLEN s1_len, s2_len; unsigned int len; len = minimun ? (strlen(strings_hex[p-strings]) - 2) /4 : 40; CHKBindParameter(2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_WCHAR, len, 0, (void *) p[0], 0, &s1_len, "S"); len = minimun ? (strlen(strings_hex[p+1-strings]) - 2) /4 : 40; /* FIXME this with SQL_VARCHAR produce wrong protocol data */ CHKBindParameter(3, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_WVARCHAR, len, 0, (void *) p[1], 0, &s2_len, "S"); s1_len = strlen(p[0]); s2_len = strlen(p[1]); printf("insert #%d\n", (int) n); CHKExecute("S"); } /* check rows */ for (n = 1, p = strings_hex; p[0] && p[1]; p += 2, ++n) { sprintf(tmp, "IF NOT EXISTS(SELECT * FROM %s WHERE k = %d AND c = %s AND vc = %s) SELECT 1", table_name, (int) n, p[0], p[1]); odbc_check_no_row(tmp); } odbc_reset_statement(); } int main(int argc, char *argv[]) { SQLSMALLINT len; const char * const*p; SQLINTEGER n; if (odbc_read_login_info()) exit(1); /* connect string using DSN */ init_connect(); sprintf(tmp, "DSN=%s;UID=%s;PWD=%s;DATABASE=%s;ClientCharset=UTF-8;", odbc_server, odbc_user, odbc_password, odbc_database); CHKDriverConnect(NULL, T(tmp), SQL_NTS, (SQLTCHAR *) tmp, sizeof(tmp)/sizeof(SQLTCHAR), &len, SQL_DRIVER_NOPROMPT, "SI"); if (!odbc_driver_is_freetds()) { odbc_disconnect(); printf("Driver is not FreeTDS, exiting\n"); odbc_test_skipped(); return 0; } if (!odbc_db_is_microsoft() || odbc_db_version_int() < 0x08000000u) { odbc_disconnect(); printf("Test for MSSQL only\n"); odbc_test_skipped(); return 0; } CHKAllocStmt(&odbc_stmt, "S"); /* create test table */ sprintf(tmp, "IF OBJECT_ID(N'%s') IS NOT NULL DROP TABLE %s", table_name, table_name); odbc_command(tmp); sprintf(tmp, "CREATE TABLE %s (k int, c NCHAR(10), vc NVARCHAR(10))", table_name); odbc_command(tmp); /* insert with INSERT statements */ for (n = 1, p = strings; p[0] && p[1]; p += 2, ++n) { sprintf(tmp, "INSERT INTO %s VALUES (%d,N'%s',N'%s')", table_name, (int) n, p[0], p[1]); odbc_command(tmp); } /* check rows */ for (n = 1, p = strings_hex; p[0] && p[1]; p += 2, ++n) { sprintf(tmp, "IF NOT EXISTS(SELECT * FROM %s WHERE k = %d AND c = %s AND vc = %s) SELECT 1", table_name, (int) n, p[0], p[1]); odbc_check_no_row(tmp); } TestBinding(0); TestBinding(1); /* cleanup */ sprintf(tmp, "IF OBJECT_ID(N'%s') IS NOT NULL DROP TABLE %s", table_name, table_name); odbc_command(tmp); odbc_disconnect(); printf("Done.\n"); return 0; } #else int main(void) { /* on Windows SQLExecDirect is always converted to SQLExecDirectW by the DM */ printf("Not possible for this platform.\n"); odbc_test_skipped(); return 0; } #endif freetds-1.00.82/src/odbc/unittests/utf8_2.c100644 025423 025423 00000004526 12717145107 0014055#include "common.h" /* test conversion of Hebrew characters (which have shift sequences) */ static void init_connect(void); static void init_connect(void) { CHKAllocEnv(&odbc_env, "S"); SQLSetEnvAttr(odbc_env, SQL_ATTR_ODBC_VERSION, (SQLPOINTER) (SQL_OV_ODBC3), SQL_IS_UINTEGER); CHKAllocConnect(&odbc_conn, "S"); } static const char * const strings[] = { "\xd7\x9e\xd7\x99\xd7\x93\xd7\xa2", "info", "\xd7\x98\xd7\xa7\xd7\xa1\xd7\x98", "\xd7\x90\xd7\x91\xd7\x9b", NULL }; /* same strings in hex */ static const char * const strings_hex[] = { "0xde05d905d305e205", "0x69006e0066006f00", "0xd805e705e105d805", "0xd005d105db05", NULL }; int main(int argc, char *argv[]) { char tmp[512]; char out[32]; SQLLEN n_len; SQLSMALLINT len; const char * const*p; int n; if (odbc_read_login_info()) exit(1); /* connect string using DSN */ init_connect(); sprintf(tmp, "DSN=%s;UID=%s;PWD=%s;DATABASE=%s;ClientCharset=UTF-8;", odbc_server, odbc_user, odbc_password, odbc_database); CHKDriverConnect(NULL, T(tmp), SQL_NTS, (SQLTCHAR *) tmp, sizeof(tmp)/sizeof(SQLTCHAR), &len, SQL_DRIVER_NOPROMPT, "SI"); if (!odbc_driver_is_freetds()) { odbc_disconnect(); printf("Driver is not FreeTDS, exiting\n"); odbc_test_skipped(); return 0; } if (!odbc_db_is_microsoft() || odbc_db_version_int() < 0x08000000u || odbc_tds_version() < 0x701) { odbc_disconnect(); /* protocol till 7.1 does not support telling encoding so we * cannot understand how the string is encoded */ printf("Test for MSSQL only using protocol 7.1\n"); odbc_test_skipped(); return 0; } CHKAllocStmt(&odbc_stmt, "S"); /* create test table */ odbc_command("CREATE TABLE #tmpHebrew (i INT, v VARCHAR(10) COLLATE Hebrew_CI_AI)"); /* insert with INSERT statements */ for (n = 0, p = strings_hex; p[n]; ++n) { sprintf(tmp, "INSERT INTO #tmpHebrew VALUES(%d, CAST(%s AS NVARCHAR(10)))", n+1, p[n]); odbc_command(tmp); } /* test conversions in libTDS */ odbc_command("SELECT v FROM #tmpHebrew"); /* insert with SQLPrepare/SQLBindParameter/SQLExecute */ CHKBindCol(1, SQL_C_CHAR, out, sizeof(out), &n_len, "S"); for (n = 0, p = strings; p[n]; ++n) { CHKFetch("S"); if (n_len != strlen(p[n]) || strcmp(p[n], out) != 0) { fprintf(stderr, "Wrong row %d %s\n", n, out); odbc_disconnect(); return 1; } } odbc_disconnect(); printf("Done.\n"); return 0; } freetds-1.00.82/src/odbc/unittests/warning.c100644 025423 025423 00000003641 12522201763 0014403#include "common.h" /* * Test originally written by John K. Hohm * (cfr "Warning return as copy of last result row (was: Warning: Null value * is eliminated by an aggregate or other SET operation.)" July 15th 2006) * * Contains also similar test by Jeff Dahl * (cfr "Warning: Null value is eliminated by an aggregate or other SET * operation." March 24th 2006 * * This test wrong SQLFetch results with warning inside select * Is different from raiserror test cause in raiserror error is not * inside recordset * Sybase do not return warning but test works the same */ static char software_version[] = "$Id: warning.c,v 1.11 2011-07-12 10:16:59 freddy77 Exp $"; static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; static const char one_null_with_warning[] = "select max(a) as foo from (select convert(int, null) as a) as test"; #ifdef TDS_NO_DM static const int tds_no_dm = 1; #else static const int tds_no_dm = 0; #endif static void Test(const char *query) { CHKPrepare(T(query), SQL_NTS, "S"); CHKExecute("S"); CHKFetch("SI"); CHKFetch("No"); /* * Microsoft SQL Server 2000 provides a diagnostic record * associated with the second SQLFetch (which returns * SQL_NO_DATA) saying "Warning: Null value is eliminated by * an aggregate or other SET operation." * We check for "NO DM" cause unixODBC till 2.2.11 do not read * errors on SQL_NO_DATA */ if (odbc_db_is_microsoft() && tds_no_dm) { SQLTCHAR output[256]; CHKGetDiagRec(SQL_HANDLE_STMT, odbc_stmt, 1, NULL, NULL, output, ODBC_VECTOR_SIZE(output), NULL, "SI"); printf("Message: %s\n", C(output)); } odbc_reset_statement(); } int main(void) { odbc_connect(); odbc_command("CREATE TABLE #warning(name varchar(20), value int null)"); odbc_command("INSERT INTO #warning VALUES('a', NULL)"); Test(one_null_with_warning); Test("SELECT SUM(value) FROM #warning"); odbc_disconnect(); printf("Done.\n"); return 0; } freetds-1.00.82/src/odbc/unittests/wchar.c100644 025423 025423 00000001327 12717145107 0014046#include "common.h" /* test SQL_C_DEFAULT with NCHAR type */ int main(int argc, char *argv[]) { char buf[102]; SQLLEN ind; int failed = 0; odbc_use_version3 = 1; odbc_connect(); CHKBindCol(1, SQL_C_DEFAULT, buf, 100, &ind, "S"); odbc_command("SELECT CONVERT(NCHAR(10), 'Pippo 123')"); /* get data */ memset(buf, 0, sizeof(buf)); CHKFetch("S"); SQLMoreResults(odbc_stmt); SQLMoreResults(odbc_stmt); odbc_disconnect(); /* the second string could came from Sybase configured with UTF-8 */ if (strcmp(buf, "Pippo 123 ") != 0 && (odbc_db_is_microsoft() || strcmp(buf, "Pippo 123 ") != 0)) { fprintf(stderr, "Wrong results '%s'\n", buf); failed = 1; } return failed ? 1 : 0; } freetds-1.00.82/src/odbc/unittests/data.in100644 025423 025423 00000024710 12717145107 0014040select NUMERIC(18,2) "123" SQL_C_NUMERIC """38 0 1 7B""" # some binary # select CHAR(7) pippo SQL_C_BINARY 706970706F2020 select TEXT mickey SQL_C_BINARY 6D69636B6579 select VARCHAR(20) foo SQL_C_BINARY 666F6F select TIMESTAMP "abcdefghi" SQL_C_BINARY "6162636465666768" select BINARY(5) qwer SQL_C_BINARY 7177657200 select IMAGE cricetone SQL_C_BINARY 6372696365746F6E65 select VARBINARY(20) teo SQL_C_BINARY 74656F select_cond bigint BIGINT 87654 SQL_C_CHAR "5 87654" if bigint select_cond cond1 BIGINT 123456789012345 SQL_C_BINARY 13000179DF0D86487000000000000000000000 if not cond1 and bigendian select BIGINT "123456789012345" SQL_C_BINARY "00007048860DDF79" endif if not cond1 and not bigendian select BIGINT "123456789012345" SQL_C_BINARY "79DF0D8648700000" endif endif if bigendian select DATETIME "2004-02-24 15:16:17" SQL_C_BINARY "0000949700FBAA2C" select SMALLDATETIME "2004-02-24 15:16:17" SQL_C_BINARY "94970394" select SMALLINT "4321" SQL_C_BINARY "10E1" select INT "1234567" SQL_C_BINARY "0012D687" select FLOAT "1234.5678" SQL_C_BINARY "40934A456D5CFAAD" select REAL "8765.4321" SQL_C_BINARY "4608F5BA" select SMALLMONEY "765.4321" SQL_C_BINARY "0074CBB1" select MONEY "4321234.5678" SQL_C_BINARY "0000000A0FA8114E" select UNIQUEIDENTIFIER "0DDF3B64-E692-11D1-AB06-00AA00BDD685" SQL_C_BINARY "0DDF3B64E69211D1AB0600AA00BDD685" else select DATETIME "2004-02-24 15:16:17" SQL_C_BINARY "979400002CAAFB00" select SMALLDATETIME "2004-02-24 15:16:17" SQL_C_BINARY "97949403" select SMALLINT "4321" SQL_C_BINARY "E110" select INT "1234567" SQL_C_BINARY "87D61200" select FLOAT "1234.5678" SQL_C_BINARY "ADFA5C6D454A9340" select REAL "8765.4321" SQL_C_BINARY "BAF50846" select SMALLMONEY "765.4321" SQL_C_BINARY "B1CB7400" select MONEY "4321234.5678" SQL_C_BINARY "0A0000004E11A80F" select UNIQUEIDENTIFIER "0DDF3B64-E692-11D1-AB06-00AA00BDD685" SQL_C_BINARY "643BDF0D92E6D111AB0600AA00BDD685" endif select BIT 1 SQL_C_BINARY 01 select BIT 0 SQL_C_BINARY 00 select TINYINT 231 SQL_C_BINARY E7 select DECIMAL 1234.5678 SQL_C_BINARY 120001D3040000000000000000000000000000 select NUMERIC 8765.4321 SQL_C_BINARY 1200013D220000000000000000000000000000 # behavior is different from MS ODBC, Sybase does not handle N types with unicode if msdb select NCHAR(7) "donald" SQL_C_BINARY "64006F006E0061006C0064002000" select NTEXT "duck" SQL_C_BINARY "6400750063006B00" select NVARCHAR(20) "daffy" SQL_C_BINARY "64006100660066007900" endif # others select INT -123 SQL_C_CHAR "4 -123" select INT 78654 SQL_C_WCHAR "5 78654" select VARCHAR(10) " 51245 " SQL_C_LONG 51245 select VARCHAR(20) " 15 " SQL_C_NUMERIC "38 0 1 0F" select UNIVARCHAR(10) """u&'\06A4\FBA5'""" SQL_C_WCHAR """2 \u06a4\ufba5""" select VARCHAR(20) test SQL_C_WCHAR "4 test" # date to char # select DATETIME "2006-06-09 11:22:44" SQL_C_CHAR "23 2006-06-09 11:22:44.000" select DATETIME "2106-06-09 11:22:44" SQL_C_CHAR "23 2106-06-09 11:22:44.000" select DATETIME "2206-06-09 11:22:44" SQL_C_CHAR "23 2206-06-09 11:22:44.000" select DATETIME "2306-06-09 11:22:44" SQL_C_CHAR "23 2306-06-09 11:22:44.000" select DATETIME "3806-06-09 11:22:44" SQL_C_CHAR "23 3806-06-09 11:22:44.000" select SMALLDATETIME "2006-06-12 22:37:21" SQL_C_CHAR "19 2006-06-12 22:37:00" select DATETIME "2006-06-09 11:22:44" SQL_C_WCHAR "23 2006-06-09 11:22:44.000" select SMALLDATETIME "2006-06-12 22:37:21" SQL_C_WCHAR "19 2006-06-12 22:37:00" select DATETIME "2006-06-09 11:22:44" SQL_C_TIMESTAMP "2006-06-09 11:22:44.000" select SMALLDATETIME "2006-06-12 22:37:21" SQL_C_TIMESTAMP "2006-06-12 22:37:00.000" if msdb sql_cond cond1 "SELECT CAST('test' AS NVARCHAR(10)) WHERE 0=1" if cond1 # nvarchar without extended characters select NVARCHAR(20) "test" SQL_C_CHAR "4 test" # nvarchar with extended characters # don't test with MS which usually have a not compatible encoding if freetds select NVARCHAR(20) 0x830068006900f200 SQL_C_CHAR "4 \x83hi\xf2" endif # nvarchar with extended characters select NVARCHAR(20) "0x830068006900f200" SQL_C_WCHAR "4 \x83hi\xf2" select NVARCHAR(20) "0xA406A5FB" SQL_C_WCHAR """2 \u06a4\ufba5""" # NVARCHAR -> SQL_C_LONG select NVARCHAR(20) "-24785 " SQL_C_LONG "-24785" endif # check variant existence sql_cond cond1 "SELECT CAST(123 AS SQL_VARIANT) WHERE 0=1" if cond1 select SQL_VARIANT "CAST('123' AS INT)" SQL_C_CHAR "3 123" select SQL_VARIANT "CAST('hello' AS CHAR(6))" SQL_C_CHAR "6 hello " select SQL_VARIANT "CAST('ciao' AS VARCHAR(10))" SQL_C_CHAR "4 ciao" select SQL_VARIANT "CAST('foo' AS NVARCHAR(10))" SQL_C_CHAR "3 foo" select SQL_VARIANT "CAST('Super' AS NCHAR(8))" SQL_C_CHAR "8 Super " # using protocol version 7.0 server returns NVARCHAR instead of NVARBINARY so test it select_cond bug SQL_VARIANT "CAST(0x330032003100 AS VARBINARY(10))" SQL_C_CHAR "3 321" if not bug select SQL_VARIANT "CAST(0x333231 AS VARBINARY(10))" SQL_C_CHAR "6 333231" endif # for some reasons MS ODBC seems to convert -123.4 to -123.40000000000001 select SQL_VARIANT "CAST('-123.5' AS FLOAT)" SQL_C_CHAR "6 -123.5" select SQL_VARIANT "CAST('-123.4' AS NUMERIC(10,2))" SQL_C_CHAR "7 -123.40" select SQL_VARIANT "CAST('0DDF3B64-E692-11D1-AB06-00AA00BDD685' AS UNIQUEIDENTIFIER)" SQL_C_CHAR "36 0DDF3B64-E692-11D1-AB06-00AA00BDD685" endif # mssql2005 varchar(max) sql_cond cond1 "SELECT CAST('test' AS VARCHAR(MAX)) WHERE 0=1" if cond1 select VARCHAR(MAX) "goodbye!" SQL_C_CHAR "8 goodbye!" select NVARCHAR(MAX) "Micio mao" SQL_C_CHAR "9 Micio mao" select VARBINARY(MAX) "ciao" SQL_C_BINARY "6369616F" select XML """ciaohi""" SQL_C_CHAR """28 ciaohi""" # XML with schema sql "IF EXISTS(SELECT * FROM sys.xml_schema_collections WHERE [name] = 'test_schema') DROP XML SCHEMA COLLECTION test_schema" sql """CREATE XML SCHEMA COLLECTION test_schema AS ''""" select XML(test_schema) "ciao" SQL_C_CHAR "17 ciao" sql "DROP XML SCHEMA COLLECTION test_schema" endif # mssql 2008 date/time sql_cond cond1 "SELECT CAST('1923-12-02' AS DATE) WHERE 0=1" if cond1 select DATE "1923-12-02" SQL_C_CHAR "10 1923-12-02" select TIME "12:23:45" SQL_C_CHAR "16 12:23:45.0000000" select TIME(4) "12:23:45.765" SQL_C_CHAR "13 12:23:45.7650" select TIME(0) "12:23:45.765" SQL_C_CHAR "8 12:23:46" select DATETIME2 "2011-08-10 12:23:45" SQL_C_CHAR "27 2011-08-10 12:23:45.0000000" select DATETIME2(4) "12:23:45.345888" SQL_C_CHAR "24 1900-01-01 12:23:45.3459" select DATETIME2(0) "2011-08-10 12:23:45.93" SQL_C_CHAR "19 2011-08-10 12:23:46" select DATETIMEOFFSET "12:23:45 -02:30" SQL_C_CHAR "34 1900-01-01 12:23:45.0000000 -02:30" select DATETIMEOFFSET(4) "12:23:45" SQL_C_CHAR "31 1900-01-01 12:23:45.0000 +00:00" # test we are using mssql2008 protocol (7.3) select_cond cond1 DATE "1923-12-02" SQL_C_BINARY "31003900320033002D00310032002D0030003200" if not cond1 and bigendian select DATE "1923-12-02" SQL_C_BINARY "0783000C0002" select TIME "12:23:45" SQL_C_BINARY "000C0017002D000000000000" select TIME(4) "12:23:45.765" SQL_C_BINARY "000C0017002D00002D98F940" select DATETIME2 "2011-08-10 12:23:45" SQL_C_BINARY "07DB0008000A000C0017002D00000000" select DATETIME2(4) "12:23:45" SQL_C_BINARY "076C00010001000C0017002D00000000" select DATETIMEOFFSET "12:23:45 -08:30" SQL_C_BINARY "076C00010001000C0017002D00000000FFF8FFE2" select DATETIMEOFFSET(4) "12:23:45" SQL_C_BINARY "076C00010001000C0017002D0000000000000000" endif if not cond1 and not bigendian select DATE "1923-12-02" SQL_C_BINARY "83070C000200" select TIME "12:23:45" SQL_C_BINARY "0C0017002D00000000000000" select TIME(4) "12:23:45.765" SQL_C_BINARY "0C0017002D00000040F9982D" select DATETIME2 "2011-08-10 12:23:45" SQL_C_BINARY "DB0708000A000C0017002D0000000000" select DATETIME2(4) "12:23:45" SQL_C_BINARY "6C07010001000C0017002D0000000000" select DATETIMEOFFSET "12:23:45 -08:30" SQL_C_BINARY "6C07010001000C0017002D0000000000F8FFE2FF" select DATETIMEOFFSET(4) "12:23:45" SQL_C_BINARY "6C07010001000C0017002D000000000000000000" endif # new date/time types embedded into variant types tds_version_cmp tds71p >= 7.1 if tds71p select SQL_VARIANT "CAST('2014-04-15 20:23:56' AS DATETIME2)" SQL_C_CHAR "27 2014-04-15 20:23:56.0000000" select SQL_VARIANT "CAST('2014-04-15 20:23:56' AS DATETIME2(3))" SQL_C_CHAR "23 2014-04-15 20:23:56.000" select SQL_VARIANT "CAST('2014-04-15 20:23:56' AS TIME)" SQL_C_CHAR "16 20:23:56.0000000" select SQL_VARIANT "CAST('2014-04-15 20:23:56' AS TIME(3))" SQL_C_CHAR "12 20:23:56.000" select SQL_VARIANT "CAST('2014-04-15' AS DATE)" SQL_C_CHAR "10 2014-04-15" endif endif # mssql 2008 hierarchyid select HIERARCHYID "/" SQL_C_BINARY "" select HIERARCHYID "/1.2/" SQL_C_BINARY "6340" endif # test sybase date/time types if not msdb # FIXME sure ?? with date and time always ?? sql_cond cond1 "SELECT CAST('1923-12-02' AS DATE) WHERE 0=1" if cond1 select DATE "1923-12-02" SQL_C_CHAR "10 1923-12-02" select TIME "12:23:45" SQL_C_CHAR "12 12:23:45.000" select TIME "12:23:45.983" SQL_C_CHAR "12 12:23:45.983" # TODO binary endif endif # check for Sybase big(date)time sql_cond cond1 "SELECT CAST('2015-10-10' AS BIGDATETIME) WHERE 0=1" if cond1 if bigendian select BIGTIME "2004-02-24 15:16:17" SQL_C_BINARY "000F00100011000000000000" select BIGDATETIME "2004-02-24 15:16:17" SQL_C_BINARY "07D400020018000F0010001100000000" else select BIGTIME "2004-02-24 15:16:17" SQL_C_BINARY "0F0010001100000000000000" select BIGDATETIME "2004-02-24 15:16:17" SQL_C_BINARY "D407020018000F001000110000000000" endif select BIGTIME "21:51:38.73973" SQL_C_CHAR "15 21:51:38.739730" select BIGDATETIME "1998-02-17 21:54:38.73973" SQL_C_CHAR "26 1998-02-17 21:54:38.739730" select BIGTIME "2006-06-12 22:37:21.372" SQL_C_TIMESTAMP "1900-01-01 22:37:21.372" select BIGDATETIME "2006-06-09 11:22:44" SQL_C_TIMESTAMP "2006-06-09 11:22:44.000" endif select VARCHAR(20) " 15.0000 " SQL_C_NUMERIC "38 0 1 0F" select VARCHAR(20) " 15.0000 " SQL_C_LONG "15" if bigint select VARCHAR(20) " 13.0000 " SQL_C_SBIGINT "13" endif # mssql 2008 give a warning for truncation (01004) if freetds select VARCHAR(20) " 15.1245 " SQL_C_NUMERIC "38 0 1 0F" select VARCHAR(20) " 15.1234 " SQL_C_LONG "15" if bigint select VARCHAR(20) " 12.98 " SQL_C_SBIGINT "12" endif endif freetds-1.00.82/src/odbc/unittests/describecol.in100644 025423 025423 00000044650 12717145107 0015412# test all types using ODBC 2 select "unsigned smallint" 123 attr SQL_COLUMN_LENGTH 2 attr SQL_COLUMN_PRECISION 5 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 5 attr SQL_DESC_OCTET_LENGTH 2 attr SQL_DESC_PRECISION 5 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 5 attr SQL_DESC_UNSIGNED SQL_TRUE select "unsigned int" 12356 attr SQL_COLUMN_LENGTH 4 attr SQL_COLUMN_PRECISION 10 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 10 attr SQL_DESC_OCTET_LENGTH 4 attr SQL_DESC_PRECISION 10 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 10 attr SQL_DESC_UNSIGNED SQL_TRUE select "unsigned bigint" 1235678901234 attr SQL_COLUMN_LENGTH 8 attr SQL_COLUMN_PRECISION 20 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 20 attr SQL_DESC_OCTET_LENGTH 8 attr SQL_DESC_PRECISION 20 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 20 attr SQL_DESC_UNSIGNED SQL_TRUE select bit 0 attr SQL_COLUMN_LENGTH 1 attr SQL_COLUMN_PRECISION 1 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 1 attr SQL_DESC_OCTET_LENGTH 1 attr SQL_DESC_PRECISION 1 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 1 attr SQL_DESC_TYPE_NAME bit attr SQL_DESC_UNSIGNED SQL_TRUE select tinyint 0 attr SQL_COLUMN_LENGTH 1 attr SQL_COLUMN_PRECISION 3 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 3 attr SQL_DESC_OCTET_LENGTH 1 attr SQL_DESC_PRECISION 3 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 3 attr SQL_DESC_UNSIGNED SQL_TRUE select smallint 0 attr SQL_COLUMN_LENGTH 2 attr SQL_COLUMN_PRECISION 5 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 5 attr SQL_DESC_OCTET_LENGTH 2 attr SQL_DESC_PRECISION 5 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 6 attr SQL_DESC_UNSIGNED SQL_FALSE select int 0 attr SQL_COLUMN_LENGTH 4 attr SQL_COLUMN_PRECISION 10 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 10 attr SQL_DESC_OCTET_LENGTH 4 attr SQL_DESC_PRECISION 10 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 11 attr SQL_DESC_UNSIGNED SQL_FALSE tds_version_cmp tds70 == 7.0 if not tds70 select bigint 0 attr SQL_COLUMN_LENGTH 8 attr SQL_COLUMN_PRECISION 19 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 19 attr SQL_DESC_OCTET_LENGTH 8 attr SQL_DESC_PRECISION 19 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 20 attr SQL_DESC_UNSIGNED SQL_FALSE endif select real 0 attr SQL_COLUMN_LENGTH 4 attr SQL_COLUMN_PRECISION 7 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 7 attr SQL_DESC_OCTET_LENGTH 4 attr SQL_DESC_PRECISION 7 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 14 attr SQL_DESC_UNSIGNED SQL_FALSE select float 0 attr SQL_COLUMN_LENGTH 8 attr SQL_COLUMN_PRECISION 15 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 15 attr SQL_DESC_OCTET_LENGTH 8 attr SQL_DESC_PRECISION 15 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 24 attr SQL_DESC_UNSIGNED SQL_FALSE select smallmoney 0 attr SQL_COLUMN_LENGTH 12 attr SQL_COLUMN_PRECISION 10 attr SQL_COLUMN_SCALE 4 attr SQL_DESC_LENGTH 10 attr SQL_DESC_OCTET_LENGTH 12 attr SQL_DESC_PRECISION 10 attr SQL_DESC_SCALE 4 attr SQL_DESC_DISPLAY_SIZE 12 attr SQL_DESC_CONCISE_TYPE SQL_DECIMAL attr SQL_DESC_UNSIGNED SQL_FALSE select money 0 attr SQL_COLUMN_LENGTH 21 attr SQL_COLUMN_PRECISION 19 attr SQL_COLUMN_SCALE 4 attr SQL_DESC_LENGTH 19 attr SQL_DESC_OCTET_LENGTH 21 attr SQL_DESC_PRECISION 19 attr SQL_DESC_SCALE 4 attr SQL_DESC_DISPLAY_SIZE 21 attr SQL_DESC_CONCISE_TYPE SQL_DECIMAL attr SQL_DESC_UNSIGNED SQL_FALSE select numeric(10,2) 0 attr SQL_COLUMN_LENGTH 12 attr SQL_COLUMN_PRECISION 10 attr SQL_COLUMN_SCALE 2 attr SQL_DESC_LENGTH 10 attr SQL_DESC_OCTET_LENGTH 12 attr SQL_DESC_PRECISION 10 attr SQL_DESC_SCALE 2 attr SQL_DESC_DISPLAY_SIZE 12 attr SQL_DESC_UNSIGNED SQL_FALSE select numeric(23,4) 0 attr SQL_COLUMN_LENGTH 25 attr SQL_COLUMN_PRECISION 23 attr SQL_COLUMN_SCALE 4 attr SQL_DESC_LENGTH 23 attr SQL_DESC_OCTET_LENGTH 25 attr SQL_DESC_PRECISION 23 attr SQL_DESC_SCALE 4 attr SQL_DESC_DISPLAY_SIZE 25 attr SQL_DESC_UNSIGNED SQL_FALSE select datetime '2006-04-14' attr SQL_COLUMN_LENGTH 16 attr SQL_COLUMN_PRECISION 23 attr SQL_COLUMN_SCALE 3 attr SQL_DESC_LENGTH 23 attr SQL_DESC_OCTET_LENGTH 16 attr SQL_DESC_PRECISION 3 attr SQL_DESC_SCALE 3 attr SQL_DESC_DISPLAY_SIZE 23 attr SQL_DESC_CONCISE_TYPE SQL_TIMESTAMP select smalldatetime '2006-04-14' attr SQL_COLUMN_LENGTH 16 attr SQL_COLUMN_PRECISION 16 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 16 attr SQL_DESC_OCTET_LENGTH 16 attr SQL_DESC_PRECISION 0 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 19 attr SQL_DESC_CONCISE_TYPE SQL_TIMESTAMP select char(10) 'hi!' attr SQL_COLUMN_LENGTH 10 attr SQL_COLUMN_PRECISION 10 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 10 attr SQL_DESC_OCTET_LENGTH 10 attr SQL_DESC_PRECISION 10 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 10 attr SQL_DESC_TYPE_NAME char select varchar(11) 'hi!' attr SQL_COLUMN_LENGTH 11 attr SQL_COLUMN_PRECISION 11 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 11 attr SQL_DESC_OCTET_LENGTH 11 attr SQL_DESC_PRECISION 11 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 11 attr SQL_DESC_TYPE_NAME varchar select nchar(12) 'hi!'+nchar(10) attr SQL_COLUMN_LENGTH 24 attr SQL_COLUMN_PRECISION 12 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 12 attr SQL_DESC_OCTET_LENGTH 24 attr SQL_DESC_PRECISION 12 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 12 attr SQL_DESC_TYPE_NAME nchar select nvarchar(13) 'hi!'+nchar(10) attr SQL_COLUMN_LENGTH 26 attr SQL_COLUMN_PRECISION 13 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 13 attr SQL_DESC_OCTET_LENGTH 26 attr SQL_DESC_PRECISION 13 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 13 attr SQL_DESC_TYPE_NAME nvarchar select text 'hi!' attr SQL_COLUMN_LENGTH 4096 attr SQL_COLUMN_PRECISION 4096 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 4096 attr SQL_DESC_OCTET_LENGTH 4096 attr SQL_DESC_PRECISION 4096 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 4096 attr SQL_DESC_TYPE_NAME text select ntext 'hi!' attr SQL_COLUMN_LENGTH 4096 attr SQL_COLUMN_PRECISION 2048 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 2048 attr SQL_DESC_OCTET_LENGTH 4096 attr SQL_DESC_PRECISION 2048 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 2048 attr SQL_DESC_TYPE_NAME ntext select binary(10) 'hi!' attr SQL_COLUMN_LENGTH 10 attr SQL_COLUMN_PRECISION 10 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 10 attr SQL_DESC_OCTET_LENGTH 10 attr SQL_DESC_PRECISION 10 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 20 select varbinary(11) 'hi!' attr SQL_COLUMN_LENGTH 11 attr SQL_COLUMN_PRECISION 11 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 11 attr SQL_DESC_OCTET_LENGTH 11 attr SQL_DESC_PRECISION 11 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 22 select image 'hi!' attr SQL_COLUMN_LENGTH 4096 attr SQL_COLUMN_PRECISION 4096 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 4096 attr SQL_DESC_OCTET_LENGTH 4096 attr SQL_DESC_PRECISION 4096 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 8192 # test all types using ODBC 3 odbc 3 select "unsigned smallint" 123 attr SQL_COLUMN_LENGTH 2 attr SQL_COLUMN_PRECISION 5 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 5 attr SQL_DESC_OCTET_LENGTH 2 attr SQL_DESC_PRECISION 5 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 5 select bit 0 attr SQL_COLUMN_LENGTH 1 attr SQL_COLUMN_PRECISION 1 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 1 attr SQL_DESC_OCTET_LENGTH 1 attr SQL_DESC_PRECISION 1 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 1 select tinyint 0 attr SQL_COLUMN_LENGTH 1 attr SQL_COLUMN_PRECISION 3 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 3 attr SQL_DESC_OCTET_LENGTH 1 attr SQL_DESC_PRECISION 3 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 3 select smallint 0 attr SQL_COLUMN_LENGTH 2 attr SQL_COLUMN_PRECISION 5 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 5 attr SQL_DESC_OCTET_LENGTH 2 attr SQL_DESC_PRECISION 5 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 6 select int 0 attr SQL_COLUMN_LENGTH 4 attr SQL_COLUMN_PRECISION 10 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 10 attr SQL_DESC_OCTET_LENGTH 4 attr SQL_DESC_PRECISION 10 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 11 if not tds70 select bigint 0 attr SQL_COLUMN_LENGTH 8 attr SQL_COLUMN_PRECISION 19 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 19 attr SQL_DESC_OCTET_LENGTH 8 attr SQL_DESC_PRECISION 19 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 20 endif select real 0 attr SQL_COLUMN_LENGTH 4 attr SQL_COLUMN_PRECISION 7 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 24 attr SQL_DESC_OCTET_LENGTH 4 attr SQL_DESC_PRECISION 24 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 14 select float 0 attr SQL_COLUMN_LENGTH 8 attr SQL_COLUMN_PRECISION 15 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 53 attr SQL_DESC_OCTET_LENGTH 8 attr SQL_DESC_PRECISION 53 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 24 select smallmoney 0 attr SQL_COLUMN_LENGTH 12 attr SQL_COLUMN_PRECISION 10 attr SQL_COLUMN_SCALE 4 attr SQL_DESC_LENGTH 10 attr SQL_DESC_OCTET_LENGTH 12 attr SQL_DESC_PRECISION 10 attr SQL_DESC_SCALE 4 attr SQL_DESC_DISPLAY_SIZE 12 attr SQL_DESC_CONCISE_TYPE SQL_DECIMAL select money 0 attr SQL_COLUMN_LENGTH 21 attr SQL_COLUMN_PRECISION 19 attr SQL_COLUMN_SCALE 4 attr SQL_DESC_LENGTH 19 attr SQL_DESC_OCTET_LENGTH 21 attr SQL_DESC_PRECISION 19 attr SQL_DESC_SCALE 4 attr SQL_DESC_DISPLAY_SIZE 21 attr SQL_DESC_CONCISE_TYPE SQL_DECIMAL select numeric(10,2) 0 attr SQL_COLUMN_LENGTH 12 attr SQL_COLUMN_PRECISION 10 attr SQL_COLUMN_SCALE 2 attr SQL_DESC_LENGTH 10 attr SQL_DESC_OCTET_LENGTH 12 attr SQL_DESC_PRECISION 10 attr SQL_DESC_SCALE 2 attr SQL_DESC_DISPLAY_SIZE 12 select numeric(23,4) 0 attr SQL_COLUMN_LENGTH 25 attr SQL_COLUMN_PRECISION 23 attr SQL_COLUMN_SCALE 4 attr SQL_DESC_LENGTH 23 attr SQL_DESC_OCTET_LENGTH 25 attr SQL_DESC_PRECISION 23 attr SQL_DESC_SCALE 4 attr SQL_DESC_DISPLAY_SIZE 25 select datetime '2006-04-14' attr SQL_COLUMN_LENGTH 16 attr SQL_COLUMN_PRECISION 23 attr SQL_COLUMN_SCALE 3 attr SQL_DESC_LENGTH 23 attr SQL_DESC_OCTET_LENGTH 16 attr SQL_DESC_PRECISION 3 attr SQL_DESC_SCALE 3 attr SQL_DESC_DISPLAY_SIZE 23 attr SQL_DESC_CONCISE_TYPE SQL_TYPE_TIMESTAMP select smalldatetime '2006-04-14' attr SQL_COLUMN_LENGTH 16 attr SQL_COLUMN_PRECISION 16 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 16 attr SQL_DESC_OCTET_LENGTH 16 attr SQL_DESC_PRECISION 0 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 19 attr SQL_DESC_CONCISE_TYPE SQL_TYPE_TIMESTAMP select char(10) 'hi!' attr SQL_COLUMN_LENGTH 10 attr SQL_COLUMN_PRECISION 10 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 10 attr SQL_DESC_OCTET_LENGTH 10 attr SQL_DESC_PRECISION 10 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 10 select varchar(11) 'hi!' attr SQL_COLUMN_LENGTH 11 attr SQL_COLUMN_PRECISION 11 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 11 attr SQL_DESC_OCTET_LENGTH 11 attr SQL_DESC_PRECISION 11 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 11 select nchar(12) 'hi!'+nchar(10) attr SQL_COLUMN_LENGTH 24 attr SQL_COLUMN_PRECISION 12 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 12 attr SQL_DESC_OCTET_LENGTH 24 attr SQL_DESC_PRECISION 12 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 12 attr SQL_DESC_TYPE_NAME nchar select nvarchar(13) 'hi!'+nchar(10) attr SQL_COLUMN_LENGTH 26 attr SQL_COLUMN_PRECISION 13 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 13 attr SQL_DESC_OCTET_LENGTH 26 attr SQL_DESC_PRECISION 13 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 13 attr SQL_DESC_TYPE_NAME nvarchar select text 'hi!' attr SQL_COLUMN_LENGTH 4096 attr SQL_COLUMN_PRECISION 4096 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 4096 attr SQL_DESC_OCTET_LENGTH 4096 attr SQL_DESC_PRECISION 4096 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 4096 select ntext 'hi!' attr SQL_COLUMN_LENGTH 4096 attr SQL_COLUMN_PRECISION 2048 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 2048 attr SQL_DESC_OCTET_LENGTH 4096 attr SQL_DESC_PRECISION 2048 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 2048 attr SQL_DESC_TYPE_NAME ntext select binary(10) 'hi!' attr SQL_COLUMN_LENGTH 10 attr SQL_COLUMN_PRECISION 10 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 10 attr SQL_DESC_OCTET_LENGTH 10 attr SQL_DESC_PRECISION 10 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 20 select varbinary(11) 'hi!' attr SQL_COLUMN_LENGTH 11 attr SQL_COLUMN_PRECISION 11 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 11 attr SQL_DESC_OCTET_LENGTH 11 attr SQL_DESC_PRECISION 11 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 22 select image 'hi!' attr SQL_COLUMN_LENGTH 4096 attr SQL_COLUMN_PRECISION 4096 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 4096 attr SQL_DESC_OCTET_LENGTH 4096 attr SQL_DESC_PRECISION 4096 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 8192 select uniqueidentifier 'AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE' attr SQL_COLUMN_LENGTH 16 attr SQL_COLUMN_PRECISION 36 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 36 attr SQL_DESC_OCTET_LENGTH 16 attr SQL_DESC_PRECISION 36 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 36 attr SQL_DESC_TYPE_NAME uniqueidentifier tds_version_cmp tds71p >= 7.1 if tds71p select sql_variant 'hello' attr SQL_DESC_CONCISE_TYPE SQL_SS_VARIANT attr SQL_DESC_TYPE SQL_SS_VARIANT attr SQL_COLUMN_LENGTH 0 attr SQL_COLUMN_PRECISION 8000 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 8000 attr SQL_DESC_OCTET_LENGTH 0 attr SQL_DESC_PRECISION 8000 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 8000 attr SQL_DESC_TYPE_NAME sql_variant select int 654 select sql_variant 123 attr SQL_DESC_CONCISE_TYPE SQL_SS_VARIANT attr SQL_DESC_TYPE SQL_SS_VARIANT attr SQL_COLUMN_LENGTH 0 attr SQL_COLUMN_PRECISION 8000 attr SQL_COLUMN_SCALE 0 attr SQL_DESC_LENGTH 8000 attr SQL_DESC_OCTET_LENGTH 0 attr SQL_DESC_PRECISION 8000 attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 8000 attr SQL_DESC_TYPE_NAME sql_variant endif # check for mssql 2008 date/time types tds_version_cmp tds73p >= 7.3 if tds73p set DESC_PRECISION 2 set DESC_SCALE 2 select time(4) '12:34:56' attr SQL_DESC_SCALE 4 attr SQL_DESC_LENGTH 13 attr SQL_DESC_PRECISION 4 attr SQL_DESC_CONCISE_TYPE SQL_SS_TIME2 attr SQL_DESC_TYPE SQL_SS_TIME2 attr SQL_DESC_DISPLAY_SIZE 13 attr SQL_DESC_OCTET_LENGTH 12 set DESC_PRECISION 2 set DESC_SCALE 2 select datetime2(4) '12:34:56' attr SQL_DESC_SCALE 4 attr SQL_DESC_LENGTH 24 attr SQL_DESC_PRECISION 4 attr SQL_DESC_CONCISE_TYPE SQL_TYPE_TIMESTAMP attr SQL_DESC_TYPE SQL_DATETIME attr SQL_DESC_TYPE_NAME datetime2 attr SQL_DESC_DISPLAY_SIZE 24 attr SQL_DESC_OCTET_LENGTH 16 set DESC_PRECISION 2 set DESC_SCALE 2 select datetimeoffset(4) '12:34:56' attr SQL_DESC_SCALE 4 attr SQL_DESC_LENGTH 31 attr SQL_DESC_PRECISION 4 attr SQL_DESC_CONCISE_TYPE SQL_SS_TIMESTAMPOFFSET attr SQL_DESC_TYPE SQL_SS_TIMESTAMPOFFSET attr SQL_DESC_TYPE_NAME datetimeoffset attr SQL_DESC_DISPLAY_SIZE 31 attr SQL_DESC_OCTET_LENGTH 20 set DESC_PRECISION 2 set DESC_SCALE 2 select time(3) '12:34:56' attr SQL_DESC_SCALE 3 attr SQL_DESC_LENGTH 12 attr SQL_DESC_PRECISION 3 attr SQL_DESC_CONCISE_TYPE SQL_SS_TIME2 attr SQL_DESC_TYPE SQL_SS_TIME2 attr SQL_DESC_DISPLAY_SIZE 12 attr SQL_DESC_OCTET_LENGTH 12 set DESC_PRECISION 2 set DESC_SCALE 2 select datetime2(3) '12:34:56' attr SQL_DESC_SCALE 3 attr SQL_DESC_LENGTH 23 attr SQL_DESC_PRECISION 3 attr SQL_DESC_CONCISE_TYPE SQL_TYPE_TIMESTAMP attr SQL_DESC_TYPE SQL_DATETIME attr SQL_DESC_TYPE_NAME datetime2 attr SQL_DESC_DISPLAY_SIZE 23 attr SQL_DESC_OCTET_LENGTH 16 set DESC_PRECISION 2 set DESC_SCALE 2 # select datetime2 '2015-09-09 12:23:34' select datetime2 '12:23:34' attr SQL_DESC_SCALE 7 attr SQL_DESC_LENGTH 27 attr SQL_DESC_PRECISION 7 attr SQL_DESC_CONCISE_TYPE SQL_TYPE_TIMESTAMP attr SQL_DESC_TYPE SQL_DATETIME attr SQL_DESC_TYPE_NAME datetime2 attr SQL_DESC_DISPLAY_SIZE 27 attr SQL_DESC_OCTET_LENGTH 16 set DESC_PRECISION 2 set DESC_SCALE 2 select datetimeoffset(3) '12:34:56' attr SQL_DESC_SCALE 3 attr SQL_DESC_LENGTH 30 attr SQL_DESC_PRECISION 3 attr SQL_DESC_CONCISE_TYPE SQL_SS_TIMESTAMPOFFSET attr SQL_DESC_TYPE SQL_SS_TIMESTAMPOFFSET attr SQL_DESC_TYPE_NAME datetimeoffset attr SQL_DESC_DISPLAY_SIZE 30 attr SQL_DESC_OCTET_LENGTH 20 set DESC_PRECISION 2 set DESC_SCALE 2 select date '2011-08-06' attr SQL_DESC_SCALE 0 attr SQL_DESC_LENGTH 10 attr SQL_DESC_PRECISION 0 attr SQL_DESC_CONCISE_TYPE SQL_TYPE_DATE attr SQL_DESC_TYPE SQL_TYPE_DATE attr SQL_DESC_TYPE_NAME date attr SQL_DESC_DISPLAY_SIZE 10 attr SQL_DESC_OCTET_LENGTH 6 endif tds_version_cmp tds72p >= 7.2 if tds72p select varchar(max) 'test' attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 0 attr SQL_DESC_LENGTH 0 attr SQL_DESC_OCTET_LENGTH 0 attr SQL_DESC_PRECISION 0 attr SQL_DESC_CONCISE_TYPE SQL_VARCHAR select nvarchar(max) 'test' attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 0 attr SQL_DESC_LENGTH 0 attr SQL_DESC_OCTET_LENGTH 0 attr SQL_DESC_PRECISION 0 attr SQL_DESC_CONCISE_TYPE SQL_WVARCHAR select varbinary(max) '4142434445' attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 0 attr SQL_DESC_LENGTH 0 attr SQL_DESC_OCTET_LENGTH 0 attr SQL_DESC_PRECISION 0 attr SQL_DESC_CONCISE_TYPE SQL_VARBINARY select xml """'ciaohi'""" attr SQL_DESC_CONCISE_TYPE SQL_SS_XML attr SQL_DESC_TYPE SQL_SS_XML attr SQL_DESC_SCALE 0 attr SQL_DESC_DISPLAY_SIZE 0 attr SQL_DESC_LENGTH 0 attr SQL_DESC_OCTET_LENGTH 0 attr SQL_DESC_PRECISION 0 endif tds_version_cmp tds50 == 5.0 if tds50 set DESC_PRECISION 2 set DESC_SCALE 2 select time '12:34:56.543' attr SQL_DESC_SCALE 3 attr SQL_DESC_LENGTH 12 attr SQL_DESC_PRECISION 3 attr SQL_DESC_CONCISE_TYPE SQL_SS_TIME2 attr SQL_DESC_TYPE SQL_SS_TIME2 attr SQL_DESC_TYPE_NAME time attr SQL_COLUMN_SCALE 3 attr SQL_DESC_OCTET_LENGTH 12 attr SQL_DESC_DISPLAY_SIZE 12 set DESC_PRECISION 2 set DESC_SCALE 2 select date '2011-08-06' attr SQL_DESC_SCALE 0 attr SQL_DESC_LENGTH 10 attr SQL_DESC_PRECISION 0 attr SQL_DESC_CONCISE_TYPE SQL_TYPE_DATE attr SQL_DESC_TYPE SQL_TYPE_DATE attr SQL_DESC_TYPE_NAME date attr SQL_COLUMN_SCALE 0 attr SQL_DESC_OCTET_LENGTH 6 attr SQL_DESC_DISPLAY_SIZE 10 set DESC_PRECISION 2 set DESC_SCALE 2 select bigtime '12:34:56.543765' attr SQL_DESC_SCALE 6 attr SQL_DESC_LENGTH 15 attr SQL_DESC_PRECISION 6 attr SQL_DESC_CONCISE_TYPE SQL_SS_TIME2 attr SQL_DESC_TYPE SQL_SS_TIME2 attr SQL_DESC_TYPE_NAME bigtime attr SQL_DESC_OCTET_LENGTH 12 attr SQL_DESC_DISPLAY_SIZE 15 set DESC_PRECISION 2 set DESC_SCALE 2 select bigdatetime '2011-08-06 12:34:56.543' attr SQL_DESC_SCALE 6 attr SQL_DESC_LENGTH 26 attr SQL_DESC_PRECISION 6 attr SQL_DESC_CONCISE_TYPE SQL_TYPE_TIMESTAMP attr SQL_DESC_TYPE SQL_DATETIME attr SQL_DESC_TYPE_NAME bigdatetime attr SQL_DESC_OCTET_LENGTH 16 attr SQL_DESC_DISPLAY_SIZE 26 endif # some additional tests using ARD set DESC_CONCISE_TYPE SQL_NUMERIC set DESC_PRECISION 4 set DESC_SCALE 2 set DESC_CONCISE_TYPE SQL_INTEGER attr DESC_TYPE SQL_INTEGER # TODO #attr DESC_LENGTH 4 #attr DESC_PRECISION 4 #attr DESC_SCALE 2 freetds-1.00.82/src/odbc/unittests/attributes.in100755 025423 025423 00000001002 12522201763 0015300# some cursor attributes odbc 3 reset attr SQL_ATTR_CURSOR_TYPE SQL_CURSOR_FORWARD_ONLY attr SQL_ATTR_CURSOR_SCROLLABLE SQL_NONSCROLLABLE attr SQL_ATTR_CONCURRENCY SQL_CONCUR_READ_ONLY attr SQL_ATTR_CURSOR_SENSITIVITY SQL_INSENSITIVE set SQL_ATTR_CURSOR_SENSITIVITY SQL_SENSITIVE attr SQL_ATTR_CURSOR_TYPE SQL_CURSOR_FORWARD_ONLY attr SQL_ATTR_CURSOR_SCROLLABLE SQL_NONSCROLLABLE attr SQL_ATTR_CONCURRENCY SQL_CONCUR_ROWVER attr SQL_ATTR_CURSOR_SENSITIVITY SQL_SENSITIVE freetds-1.00.82/src/odbc/unittests/CMakeLists.txt100644 025423 025423 00000002342 12607665421 0015340include_directories(..) set(tests t0001 t0002 t0003 t0004 connect print date norowset funccall lang_error tables binary_test moreandcount earlybind putdata params raiserror getdata transaction type genparams preperror prepare_results testodbc data error rebindpar rpc convert_error typeinfo const_params insert_speed compute timeout array array_out cursor1 scroll cursor2 describecol copydesc prepclose warning paramcore timeout2 timeout3 connect2 timeout4 freeclose cursor3 cursor4 cursor5 attributes hidden blob1 cancel wchar rowset transaction2 cursor6 cursor7 utf8 utf8_2 stats descrec peter test64 prepare_warn long_error mars1 array_error closestmt ) if(WIN32) set(libs odbc32 ${lib_ODBCINST}) else() set(libs tdsodbc ${lib_ODBCINST}) endif() add_library(o_common STATIC common.c common.h c2string.c parser.c parser.h) foreach(target ${tests}) add_executable(o_${target} EXCLUDE_FROM_ALL ${target}.c) set_target_properties(o_${target} PROPERTIES OUTPUT_NAME ${target}) target_link_libraries(o_${target} o_common replacements ${libs} ${lib_NETWORK} ${lib_BASE}) add_test(NAME o_${target} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${target}) add_dependencies(check o_${target}) endforeach(target) freetds-1.00.82/PWD.in100644 025423 025423 00000001372 12522201763 0010013# $Id: PWD.in,v 1.1 2002-09-12 15:24:20 castellano Exp $ # # This file was taken from DBD::Sybase :-) It is used by 'make check' to test # the installation # # UID: the username of a user to connect with # PWD: the password for that user # SRV: the symbolic server name from the freetds.conf (or interfaces) file. # Note: if you use a hostname/IP here instead, freetds will attempt to # connect using the compiletime default port (4000 for TDS 5.0, 1433 for # 4.2 or 7.0) which is usually not right. # DB: Database in which to create tables used in the tests. For those new to # Sybase or MS SQL server, there may be many database per server. tempdb # is a good default choice if unsure. # UID=guest PWD=sybase SRV=JDBC DB=tempdb freetds-1.00.82/BUGS100644 025423 025423 00000000465 12717145107 0007523 Needs Fixing ------------ 1. Fix formatting of dbprhead/dbprrow...its a little off (Anybody care?) 2. ct-lib placeholders do not work with TDS 7.0+. To fix this requires either an SQL parser or API modification, because the library has to determine the SQL datatype of the placeholder variable. freetds-1.00.82/freetds.conf100644 025423 025423 00000002401 13045564621 0011334# $Id: freetds.conf,v 1.12 2007-12-25 06:02:36 jklowden Exp $ # # This file is installed by FreeTDS if no file by the same # name is found in the installation directory. # # For information about the layout of this file and its settings, # see the freetds.conf manpage "man freetds.conf". # Global settings are overridden by those in a database # server specific section [global] # TDS protocol version tds version = auto # Whether to write a TDSDUMP file for diagnostic purposes # (setting this to /tmp is insecure on a multi-user system) ; dump file = /tmp/freetds.log ; debug flags = 0xffff # Command and connection timeouts ; timeout = 10 ; connect timeout = 10 # If you get out-of-memory errors, it may mean that your client # is trying to allocate a huge buffer for a TEXT field. # Try setting 'text size' to a more reasonable limit text size = 64512 # If you experience TLS handshake errors and are using openssl, # try adjusting the cipher list (don't surround in double or single quotes) # openssl ciphers = HIGH:!SSLv2:!aNULL:-DH # A typical Sybase server [egServer50] host = symachine.domain.com port = 5000 tds version = 5.0 # A typical Microsoft server [egServer70] host = ntmachine.domain.com port = 1433 tds version = 7.0 freetds-1.00.82/locales.conf100644 025423 025423 00000000562 12522201763 0011322[default] date format = %b %e %Y %I:%M:%S:%z%p [en_US] date format = %b %e %Y %I:%M:%S:%z%p language = us_english charset = iso_1 [es_ES] date format = %b %d %Y %I:%M%p language = spanish charset = iso_1 [pt_BR] date format = %d/%m/%Y %H:%M language = Portuguese charset = iso_1 [it_IT] date format = %d/%m/%Y %H:%M language = Italiano charset = iso_1 freetds-1.00.82/autogen.sh100755 025423 025423 00000003050 12522201763 0011025#!/bin/sh # Run this to generate all the initial makefiles, etc. # $Id: autogen.sh,v 1.10 2011-03-22 17:54:04 jklowden Exp $ # From automake.info: # # Many packages come with a script called `bootstrap.sh' or # `autogen.sh', that will just call `aclocal', `libtoolize', `gettextize' # or `autopoint', `autoconf', `autoheader', and `automake' in the right # order. Actually this is precisely what `autoreconf' can do for you. # If your package has such a `bootstrap.sh' or `autogen.sh' script, # consider using `autoreconf'. That should simplify its logic a lot # (less things to maintain, yum!), it's even likely you will not need the # script anymore, and more to the point you will not call `aclocal' # directly anymore. srcdir=`dirname $0` PKG_NAME="FreeTDS." # If autoreconf encounters an error, it might be because this is the # very first time it was run, meaning that some files e.g. config.sub # are missing. We retry with --install (and perhaps we should # try --force, too). # # Revision 1.6 was the last one not to use autoreconf. If you can't get # this (simpler) one to work, you might try that one. ( cd $srcdir echo running `which autoreconf` in `pwd`: autoreconf || autoreconf --install ) || exit #conf_flags="--enable-maintainer-mode --enable-compile-warnings" #--enable-iso-c if test x$NOCONFIGURE = x; then echo Running $srcdir/configure $conf_flags "$@" '...' \ | tr ' ' \\n \ | sed 's/^-/ &/' $srcdir/configure $conf_flags "$@" \ && echo Now type \`make\' to compile $PKG_NAME else echo Skipping configure process. fi freetds-1.00.82/freetds.spec100644 025423 025423 00000010420 13242511125 0011327%define name freetds %define version 1.00.82 # compute some additional dependency from vendor name # # SUSE %define tds_dep_suse glibc-locale %undefine tds_builddep %{expand:%%{expand:%%{?tds_builddep_%{?_vendor}:%%%%define tds_builddep %%{?tds_builddep_%{?_vendor}}}}} %undefine tds_dep %{expand:%%{expand:%%{?tds_dep_%{?_vendor}:%%%%define tds_dep %%{?tds_dep_%{?_vendor}}}}} Name: %{name} Version: %{version} Release: 1 Vendor: www.freetds.org License: LGPL Group: System Environment/Libraries Source: http://ibiblio.org/pub/Linux/ALPHA/freetds/stable/%{name}-%{version}.tar.bz2 BuildRoot: %{_tmppath}/%{name}-buildroot BuildRequires: unixODBC-devel >= 2.0.0 gnutls-devel %{?tds_builddep} Requires: gnutls %{?tds_dep} Summary: FreeTDS is a free re-implementation of the TDS (Tabular DataStream) protocol that is used by Sybase and Microsoft for their database products. %description FreeTDS is a project to document and implement the TDS (Tabular DataStream) protocol. TDS is used by Sybase and Microsoft for client to database server communications. FreeTDS includes call level interfaces for DB-Lib, CT-Lib, and ODBC. %package devel Group: Development/Libraries Summary: Include files needed for development with FreeTDS Requires: freetds = %{version} %package unixodbc Group: System Environment/Libraries Summary: FreeTDS ODBC Driver for unixODBC Requires: unixODBC >= 2.0.0 %{?tds_dep:Requires: %tds_dep} %package doc Group: Documentation Summary: User documentation for FreeTDS %description devel The freetds-devel package contains the files necessary for development with the FreeTDS libraries. %description unixodbc The freetds-unixodbc package contains ODBC driver build for unixODBC. %description doc The freetds-doc package contains the useguide and reference of FreeTDS and can be installed even if FreeTDS main package is not installed %prep %setup %build ODBCDIR=`odbc_config --prefix || true` if test ! -r "$ODBCDIR/include/sql.h"; then ODBCDIR=/usr/local fi if test ! -r "$ODBCDIR/include/sql.h"; then ODBCDIR=/usr fi %configure --with-tdsver=auto --with-unixodbc="$ODBCDIR" --with-gnutls make RPM_OPT_FLAGS="$RPM_OPT_FLAGS" %install rm -rf "$RPM_BUILD_ROOT" make DESTDIR="$RPM_BUILD_ROOT" install rm -rf "$RPM_BUILD_ROOT/%{_datadir}/doc/freetds" %post /sbin/ldconfig 2> /dev/null %postun /sbin/ldconfig 2> /dev/null %post unixodbc echo "[FreeTDS] Description = FreeTDS unixODBC Driver Driver = %{_libdir}/libtdsodbc.so.0 Setup = %{_libdir}/libtdsodbc.so.0" | odbcinst -i -d -r > /dev/null 2>&1 || true echo "[SQL Server] Description = FreeTDS unixODBC Driver Driver = %{_libdir}/libtdsodbc.so.0 Setup = %{_libdir}/libtdsodbc.so.0" | odbcinst -i -d -r > /dev/null 2>&1 || true %preun unixodbc odbcinst -u -d -n 'FreeTDS' > /dev/null 2>&1 || true odbcinst -u -d -n 'SQL Server' > /dev/null 2>&1 || true %clean rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root) %doc AUTHORS BUGS COPYING* ChangeLog INSTALL NEWS README TODO %{_bindir}/* %{_mandir}/man?/* %{_libdir}/libct.so.* %{_libdir}/libsybdb.so.* %config %{_sysconfdir}/* %files devel %defattr (-,root,root) %{_libdir}/*.a %{_libdir}/*.la %{_libdir}/*.so %{_includedir}/* %files unixodbc %defattr(-,root,root) %{_libdir}/libtdsodbc.so* %files doc %defattr (-,root,root) %doc doc/userguide doc/images doc/reference %changelog * Fri Nov 13 2015 Frediano Ziglio - set default protocol version to "auto" (automatic) - enable gnutls in RPM packages * Wed Mar 28 2007 Frediano Ziglio - removed libtdssrv * Thu Sep 09 2004 Frediano Ziglio - remove dependency from freetds-unixodbc - fix field name (Copyright instead of License) - updated URL * Sun Mar 30 2003 Frediano Ziglio - add reference to doc package * Wed Feb 5 2003 Ian Grant - 0.61 tweaked. Added libtdssrv libraries and tools in /usr/bin + man pages * Mon Dec 30 2002 David Hollis - 0.60 tweaked. Move .a & .la files to -devel package * Thu Dec 20 2001 Brian Bruns - Modifications for 0.53 ver and removing interfaces file * Fri Jun 28 2001 Brian Bruns - Modifications for 0.52 ver and ODBC drivers * Wed Feb 14 2001 David Hollis - First stab at RPM for 0.51 ver freetds-1.00.82/tds.dox100644 025423 025423 00000001474 12717145107 0010347#$Id: tds.dox,v 1.9 2005-06-26 14:25:19 jklowden Exp $ PROJECT_NAME = "FreeTDS API" OUTPUT_DIRECTORY = doc/reference GENERATE_LATEX = NO GENERATE_MAN = NO GENERATE_RTF = NO CASE_SENSE_NAMES = NO INPUT = $(SRCDIR)/src \ $(SRCDIR)/include \ $(SRCDIR)/win32 \ $(SRCDIR)/vms EXCLUDE_PATTERNS = */unittests/* RECURSIVE = YES QUIET = YES SHORT_NAMES = YES JAVADOC_AUTOBRIEF = YES PREDEFINED = HAVE_SSL INTERNAL_DOCS = YES EXAMPLE_PATH = $(SRCDIR)/src/tds/example SORT_BRIEF_DOCS = YES EXTRACT_STATIC = YES ALIASES += tds="@param tds A pointer to the TDSSOCKET structure managing a client/server operation." ALIASES += commit{1}="commit id \1" CALL_GRAPH = YES CALLER_GRAPH = YES HAVE_DOT = YES MAX_DOT_GRAPH_DEPTH = 3 DOT_IMAGE_FORMAT = svg freetds-1.00.82/CMakeLists.txt100644 025423 025423 00000034650 13116461621 0011577project(FreeTDS) cmake_minimum_required(VERSION 2.6) option(WITH_OPENSSL "Link in OpenSSL if found" ON) option(ENABLE_ODBC_WIDE "Enable ODBC wide character support" ON) option(ENABLE_KRB5 "Enable Kerberos support" OFF) option(ENABLE_ODBC_MARS "Enable MARS" OFF) option(ENABLE_EXTRA_CHECKS "Enable internal extra checks, DO NOT USE in production" OFF) if(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) cmake_policy(SET CMP0005 NEW) endif(COMMAND cmake_policy) set(PACKAGE freetds) unset(VERSION) if(EXISTS "${CMAKE_SOURCE_DIR}/configure") file(STRINGS "${CMAKE_SOURCE_DIR}/configure" VER LIMIT_COUNT 1 REGEX "^[ ]*VERSION[ ]*=.*0") if(VER MATCHES "VERSION[ ]*=[ ]*'?([^' ]+)") set(VERSION ${CMAKE_MATCH_1}) endif() else() file(STRINGS "${CMAKE_SOURCE_DIR}/configure.ac" VER LIMIT_COUNT 1 REGEX "^AC_INIT\\(FreeTDS,[ ]*1[.].*\\)$") if(VER MATCHES "AC_INIT\\(FreeTDS,[ ]*(.+)\\)$") set(VERSION ${CMAKE_MATCH_1}) endif() endif() if(DEFINED VERSION) # versions to test # set(VERSION "0.92.dev.esyscmd(printf $(date +\"%Y%m%d\"))") # set(VERSION "0.92.dev.esyscmd(printf $(date +\"%y%m%d\"))") # FAIL # set(VERSION "0.95rc1") # set(VERSION "0.95") # set(VERSION "0.95.1") string(TIMESTAMP DATE "%Y%m%d") string(REPLACE ".esyscmd(printf $(date +\"%Y%m%d\"))" ".${DATE}" VERSION ${VERSION}) string(REGEX REPLACE "^([0-9]+\\.[0-9]+)(rc|RC)" "\\1.dev." VER "${VERSION}") string(REPLACE ".dev." ".9999." VER ${VER}) if(VER MATCHES "[^0-9.]" OR VER MATCHES "\\.\\.") message(FATAL_ERROR "wrong VERSION format (${VERSION}) --> (${VER})") endif() if("${VER}.0" MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+)") set(MAJOR ${CMAKE_MATCH_1}) set(MINOR ${CMAKE_MATCH_2}) set(SUBVERSION ${CMAKE_MATCH_3}) if(SUBVERSION STREQUAL "9999") math(EXPR MINOR "${MINOR} - 1") endif() else() message(FATAL_ERROR "wrong VERSION format (${VERSION}) --> (${VER})") endif() # message(FATAL_ERROR "DEBUG ${MAJOR} ${MINOR} ${SUBVERSION}") else() message(FATAL_ERROR "VERSION not found or wrong format") endif() # get build number from date # use same formula used in configure.ac unset(BUILD_NUMBER) string(TIMESTAMP BUILD_NUMBER "( %Y - 2000 ) * 366 + 1%j - 1000") math(EXPR BUILD_NUMBER "${BUILD_NUMBER}") set(FREETDS_TOPDIR ${CMAKE_CURRENT_LIST_DIR}) enable_testing() set(CMAKE_CTEST_COMMAND ctest) add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}) # TODO depends on configure add_definitions(-D_REENTRANT -D_THREAD_SAFE) include(CheckIncludeFile) include(CheckIncludeFiles) include(CheckTypeSize) include(CheckFunctionExists) include(CheckLibraryExists) include(CheckStructHasMember) include(CheckPrototypeDefinition) find_package(Perl) macro(config_write str) file(APPEND "${CMAKE_BINARY_DIR}/include/config.h.in" "${str}") endmacro() file(WRITE "${CMAKE_BINARY_DIR}/include/config.h.in" "/* Automatic generated by cmake */\n\n") foreach(fn arpa/inet.h com_err.h dirent.h errno.h getopt.h inttypes.h langinfo.h libgen.h limits.h locale.h malloc.h netdb.h netinet/in.h netinet/tcp.h paths.h poll.h roken.h signal.h sql.h sqlext.h stddef.h stdlib.h stdint.h string.h strings.h sys/eventfd.h sys/ioctl.h sys/param.h sys/resource.h sys/select.h sys/socket.h sys/stat.h sys/time.h sys/types.h sys/wait.h unistd.h fcntl.h wchar.h windows.h) string(REGEX REPLACE "[/.]" "_" var "${fn}") string(TOUPPER "HAVE_${var}" var) CHECK_INCLUDE_FILE(${fn} ${var}) config_write("/* Define to 1 if you have the <${fn}> header file. */\n") config_write("#cmakedefine ${var} 1\n\n") endforeach(fn) if(WITH_OPENSSL) find_package(OpenSSL) endif(WITH_OPENSSL) if(OPENSSL_FOUND) config_write("#define HAVE_OPENSSL 1\n\n") include_directories(${OPENSSL_INCLUDE_DIR}) endif(OPENSSL_FOUND) set(CMAKE_THREAD_PREFER_PTHREAD ON) find_package(Threads REQUIRED) if(HAVE_WINDOWS_H) if(NOT HAVE_SQL_H) unset(HAVE_SQL_H CACHE) CHECK_INCLUDE_FILES("windows.h;sql.h" HAVE_SQL_H) endif() if(HAVE_SQL_H AND NOT HAVE_SQLEXT_H) unset(HAVE_SQLEXT_H CACHE) CHECK_INCLUDE_FILES("windows.h;sql.h;sqlext.h" HAVE_SQLEXT_H) endif() if(NOT HAVE_ODBCSS_H) unset(HAVE_ODBCSS_H CACHE) CHECK_INCLUDE_FILES("windows.h;sqltypes.h;odbcss.h" HAVE_ODBCSS_H) endif() endif(HAVE_WINDOWS_H) # find types macro(ADD_HEADER VAR FN) if(${VAR}) set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES} ${FN}) endif() endmacro(ADD_HEADER) add_header(HAVE_WCHAR_H wchar.h) add_header(HAVE_WINDOWS_H windows.h) add_header(HAVE_SQL_H sql.h) add_header(HAVE_SQLEXT_H sqlext.h) foreach(fn char double float int short long "long double" "long long" "SQLWCHAR" "void *" wchar_t __int64 SQLLEN SQLROWOFFSET SQLROWSETSIZE SQLSETPOSIROW) string(REGEX REPLACE "[/. ]" "_" var "${fn}") string(REPLACE "*" "P" var "${var}") string(TOUPPER "HAVE_${var}" have) string(TOUPPER "SIZEOF_${var}" var) CHECK_TYPE_SIZE(${fn} ${var}) if(HAVE_${var}) set(${have} 1 CACHE INTERNAL "Have type ${fn}") else() set(${var} 0) endif() config_write("#define ${var} \\@${var}\\@\n\n") endforeach(fn) foreach(fn SQLLEN SQLROWOFFSET SQLROWSETSIZE SQLSETPOSIROW) config_write("/* Define to 1 if you have type <${fn}>. */\n#cmakedefine HAVE_${fn} 1\n\n") endforeach(fn) check_prototype_definition(SQLColAttribute "SQLRETURN SQL_API SQLColAttribute (SQLHSTMT StatementHandle, SQLUSMALLINT ColumnNumber, SQLUSMALLINT FieldIdentifier, SQLPOINTER CharacterAttribute, SQLSMALLINT BufferLength, SQLSMALLINT *StringLength, SQLLEN * NumericAttribute)" SQL_SUCCESS "${CMAKE_EXTRA_INCLUDE_FILES}" TDS_SQLCOLATTRIBUTE_SQLLEN) config_write("/* Define to 1 if last argument of SQLColAttribute it's SQLLEN * */\n#cmakedefine TDS_SQLCOLATTRIBUTE_SQLLEN 1\n\n") check_prototype_definition(SQLParamOptions "SQLRETURN SQL_API SQLParamOptions(SQLHSTMT hstmt, SQLULEN crow, SQLULEN *pirow)" SQL_SUCCESS "${CMAKE_EXTRA_INCLUDE_FILES}" TDS_SQLPARAMOPTIONS_SQLLEN) config_write("/* Define to 1 if SQLParamOptions accept SQLULEN as arguments */\n#cmakedefine TDS_SQLPARAMOPTIONS_SQLLEN 1\n\n") set(CMAKE_EXTRA_INCLUDE_FILES) macro(SELECT_TYPE VAR SIZE TYPES ERROR) set(${VAR} "") foreach(t ${TYPES}) string(REGEX REPLACE "[/. ]" "_" var "${t}") string(REPLACE "*" "P" var "${var}") string(TOUPPER "SIZEOF_${var}" var) if(${${var}} EQUAL ${SIZE}) set(${VAR} ${t}) break() endif() endforeach(t) if(${VAR} STREQUAL "") message(FATAL_ERROR ${ERROR}) endif() endmacro(SELECT_TYPE) SELECT_TYPE(tds_sysdep_int16_type 2 "short;int" "No 16-bit int found.") SELECT_TYPE(tds_sysdep_int32_type 4 "short;int;long" "No 32-bit int found.") SELECT_TYPE(tds_sysdep_int64_type 8 "long;long long;__int64" "No 64-bit int found.") SELECT_TYPE(tds_sysdep_real32_type 4 "float;double" "No 32-bit real found.") SELECT_TYPE(tds_sysdep_real64_type 8 "float;double;long double" "No 64-bit real found.") SELECT_TYPE(tds_sysdep_intptr_type ${SIZEOF_VOID_P} "short;int;long;__int64" "No intptr type found.") # find functions set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) set(FUNCS asprintf vasprintf strtok_r readpassphrase strlcpy strlcat basename getopt strsep vsnprintf _vsnprintf snprintf _snprintf _vscprintf gettimeofday nl_langinfo locale_charset setenv putenv getuid getpwuid getpwuid_r fstat alarm fork gethrtime localtime_r setitimer _fseeki64 _ftelli64 setrlimit inet_ntoa_r getipnodebyaddr getipnodebyname getaddrinfo inet_ntop gethostname poll socketpair clock_gettime fseeko pthread_cond_timedwait pthread_cond_timedwait_relative_np pthread_condattr_setclock _lock_file _unlock_file usleep nanosleep readdir_r eventfd daemon) macro(CHECK_FUNCTION_EXISTS_DEFINE func) string(TOUPPER "HAVE_${func}" var) check_function_exists(${func} ${var}) config_write("/* Define to 1 if you have function <${func}>. */\n") config_write("#cmakedefine ${var} 1\n\n") endmacro() # TODO set(HAVE_GETADDRINFO 1 CACHE INTERNAL "") foreach(func ${FUNCS}) check_function_exists_define(${func}) endforeach(func) macro(CHECK_STDIO_FUNCTION_EXISTS FUNCTION) string(TOUPPER "HAVE_${FUNCTION}" VARIABLE) string(TOUPPER "CHECK_${FUNCTION}" CHECK) if (NOT ${VARIABLE}) set(MACRO_CHECK_FUNCTION_DEFINITIONS "-D${CHECK}=1 ${CMAKE_REQUIRED_FLAGS}") message(STATUS "Looking for ${FUNCTION}") try_compile(${VARIABLE} ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/misc/cmake_checks.c COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} OUTPUT_VARIABLE OUTPUT) if(${VARIABLE}) set(${VARIABLE} 1 CACHE INTERNAL "Have function ${FUNCTION}") message(STATUS "Looking for ${FUNCTION} - found") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Determining if the function ${FUNCTION} exists passed with the following output:\n" "${OUTPUT}\n\n") else() message(STATUS "Looking for ${FUNCTION} - not found") set(${VARIABLE} "" CACHE INTERNAL "Have function ${FUNCTION}") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if the function ${FUNCTION} exists failed with the following output:\n" "${OUTPUT}\n\n") endif() endif() endmacro() foreach(func asprintf vasprintf vsnprintf _vsnprintf snprintf _snprintf _vscprintf) check_stdio_function_exists(${func}) endforeach(func) set(CMAKE_REQUIRED_LIBRARIES) check_struct_has_member("struct tm" "tm_zone" "time.h" HAVE_STRUCT_TM_TM_ZONE) config_write("#cmakedefine HAVE_STRUCT_TM_TM_ZONE 1\n\n") macro(SEARCH_LIBRARY FUNC HAVE VAR LIBS) foreach(lib ${LIBS}) if(NOT ${HAVE}) unset(${HAVE} CACHE) check_library_exists(${lib} ${FUNC} "" ${HAVE}) if(${HAVE}) unset(${VAR} CACHE) set(${VAR} ${lib} CACHE INTERNAL "") endif() endif() endforeach(lib) endmacro(SEARCH_LIBRARY) check_library_exists(readline readline "" HAVE_READLINE) if(HAVE_READLINE) config_write("#cmakedefine HAVE_READLINE 1\n\n") search_library(tgetent HAVE_TGETENT lib_READLINE "readline;ncurses;curses;termcap") set(lib_READLINE readline ${lib_READLINE}) endif(HAVE_READLINE) config_write("#cmakedefine HAVE_SQLGETPRIVATEPROFILESTRING 1\n\n") if(WIN32) set(lib_ODBCINST odbccp32) check_library_exists(legacy_stdio_definitions _vsnwprintf_s "" LEGACY_STDIO) if(LEGACY_STDIO) set(lib_ODBCINST ${lib_ODBCINST} legacy_stdio_definitions) endif(LEGACY_STDIO) else() search_library(SQLGetPrivateProfileString HAVE_SQLGETPRIVATEPROFILESTRING lib_ODBCINST "odbcinst;iodbcinst") endif() # flags foreach(flag ODBC_WIDE EXTRA_CHECKS KRB5 ODBC_MARS) config_write("#cmakedefine ENABLE_${flag} 1\n\n") endforeach(flag) config_write("#define VERSION \"\\@VERSION\\@\"\n\n") config_write("#define FREETDS_TOPDIR \"${FREETDS_TOPDIR}\"\n\n") # TODO make it configure option config_write("#define TDS70 1\n\n") config_write("#ifdef _MSC_VER # define inline __inline # define _CRT_SECURE_NO_WARNINGS 1 #endif\n\n") if(WIN32) config_write("/* Define to 1 if you want to use SSPI for Win32 */\n#define HAVE_SSPI 1\n\n") config_write("/* define to format string used for 64bit integers */\n#define TDS_I64_PREFIX \"I64\"\n\n") config_write("/* Define to 1 if you have the SQLGetPrivateProfileString function. */\n#define HAVE_SQLGETPRIVATEPROFILESTRING 1\n\n") else(WIN32) # this section make just work on Linux, many definition are not checked config_write("#define HAVE_FUNC_GETPWUID_R_5 1\n\n") config_write("#define HAVE_FUNC_LOCALTIME_R_TM 1\n\n") config_write("/* define to format string used for 64bit integers */\n#define TDS_I64_PREFIX \"ll\"\n\n") config_write("#define UNIXODBC 1\n\n#define _GNU_SOURCE 1\n\n") if(NOT OPENSSL_FOUND) include(FindGnuTLS) if(GNUTLS_FOUND) config_write("#define HAVE_GNUTLS 1\n") set(CMAKE_REQUIRED_LIBRARIES ${GNUTLS_LIBRARIES}) check_function_exists_define(gnutls_certificate_set_verify_function) check_function_exists_define(gnutls_record_disable_padding) check_function_exists_define(gnutls_rnd) set(CMAKE_REQUIRED_LIBRARIES) pkg_check_modules(NETTLEDEP gnutls) if (";${NETTLEDEP_STATIC_LIBRARIES};" MATCHES ";nettle;") set(lib_GNUTLS ${GNUTLS_LIBRARIES}) config_write("#define GNUTLS_USE_NETTLE 1\n\n") pkg_check_modules(NETTLE nettle) if(NETTLE_FOUND) set(lib_GNUTLS ${GNUTLS_LIBRARIES} ${NETTLE_LIBRARIES}) config_write("#define HAVE_NETTLE 1\n\n") if (";${NETTLEDEP_STATIC_LIBRARIES};" MATCHES ";hogweed;") set(lib_GNUTLS ${lib_GNUTLS} hogweed) endif() if (";${NETTLEDEP_STATIC_LIBRARIES};" MATCHES ";gmp;") set(lib_GNUTLS ${lib_GNUTLS} gmp) config_write("#define HAVE_GMP 1\n\n") endif() endif(NETTLE_FOUND) else() set(lib_GNUTLS ${GNUTLS_LIBRARIES} gcrypt tasn1) endif() endif(GNUTLS_FOUND) endif(NOT OPENSSL_FOUND) if(NOT HAVE_CLOCK_GETTIME AND NOT HAVE_GETHRTIME) search_library(clock_gettime HAVE_CLOCK_GETTIME lib_RT "rt;posix4") config_write("#cmakedefine HAVE_CLOCK_GETTIME 1\n\n") endif(NOT HAVE_CLOCK_GETTIME AND NOT HAVE_GETHRTIME) if(CMAKE_USE_PTHREADS_INIT) config_write("#define HAVE_PTHREAD 1\n\n") config_write("#define TDS_HAVE_PTHREAD_MUTEX 1\n\n") endif(CMAKE_USE_PTHREADS_INIT) config_write(" #define TIME_WITH_SYS_TIME 1 //#define _ALL_SOURCE 1 #define __EXTENSIONS__ 1 // readline #define HAVE_RL_INHIBIT_COMPLETION 1 #define HAVE_RL_ON_NEW_LINE 1 #define HAVE_RL_RESET_LINE_STATE 1 // iconv #define HAVE_ICONV 1 #define ICONV_CONST ") endif(WIN32) set(lib_BASE ${lib_RT} ${CMAKE_THREAD_LIBS_INIT}) if(EXISTS "${CMAKE_SOURCE_DIR}/iconv/lib/iconv.lib") set(lib_BASE ${lib_BASE} ${CMAKE_THREAD_LIBS_INIT} "${CMAKE_SOURCE_DIR}/iconv/lib/iconv.lib") config_write("#define HAVE_ICONV 1\n\n") config_write("#define ICONV_CONST \n\n") endif() if(WIN32) set(lib_NETWORK ws2_32) else(WIN32) # TODO check libraries set(lib_NETWORK gssapi_krb5) endif(WIN32) if(OPENSSL_FOUND) set(lib_NETWORK ${lib_NETWORK} ${OPENSSL_LIBRARIES}) elseif(GNUTLS_FOUND) set(lib_NETWORK ${lib_NETWORK} ${lib_GNUTLS}) endif(OPENSSL_FOUND) include_directories(${CMAKE_BINARY_DIR}/include include win32 iconv/include) add_subdirectory(src/replacements) add_subdirectory(src/tds) add_subdirectory(src/ctlib) add_subdirectory(src/dblib) add_subdirectory(src/odbc) add_subdirectory(src/apps) configure_file(${CMAKE_BINARY_DIR}/include/config.h.in ${CMAKE_BINARY_DIR}/include/config.h) configure_file(${CMAKE_SOURCE_DIR}/include/tds_sysdep_public.h.in ${CMAKE_BINARY_DIR}/include/tds_sysdep_public.h) configure_file(${CMAKE_SOURCE_DIR}/include/freetds/version.h.in ${CMAKE_BINARY_DIR}/include/freetds/version.h) if(NOT EXISTS "${CMAKE_SOURCE_DIR}/configure") configure_file(${CMAKE_SOURCE_DIR}/src/odbc/version.rc.in ${CMAKE_SOURCE_DIR}/src/odbc/version.rc) endif(NOT EXISTS "${CMAKE_SOURCE_DIR}/configure") freetds-1.00.82/Thanks-1.0100644 025423 025423 00000002030 12717145107 0010475- Bill D Thompson - help fixing packet corruption - Christos Zoulas - server maintainer - Craig A. Berry - updated VMS support - Jan Baumgarten - reported a problem with CMake - John Kendall - fixed compatibility with old sql server - Johnny C. Lam - reported a problem in userguide - Joshua Lang - reported some issues - fixed reading server SPID - Ken Collins - reported different issues and helped fixing them - Lars Kanis - minor header cleanup - Mark Brand - fix a compile issue - Matthew Green - support for Sybase date/time - Mike Jetzer - reported some issue using HP-UX and tested the fix - Noel Diaz - reported bug causing a corrupted packet - Ondrej Holecek - fix a problem with affected row compatibility in CT-Library - Ramiro Morales - improved AppVeyor support - fixed some compiler issue - CMake improvements - Randy Syring - updated some userguid - Richard Hughes - added support for BCP in ODBC - Sergio NNX - fixed a problem with IPv6 - Zoltan Kozma - patch for protocol compatibility freetds-1.00.82/include/replacements/poll.h100644 025423 025423 00000003402 12717145107 0014256/** \file * \brief Provide poll call where missing */ #if !defined(_REPLACEMENTS_POLL_H) && !defined(HAVE_POLL) #define _REPLACEMENTS_POLL_H #include #if HAVE_LIMITS_H #include #endif #if HAVE_SYS_SELECT_H #include #endif #if defined(_WIN32) #include #endif #if defined(__VMS) #include /* FD_SETSIZE is in here */ #endif #if !defined(FD_SETSIZE) # if !defined(OPEN_MAX) # error cannot establish FD_SETSIZE # endif #define FD_SETSIZE OPEN_MAX #endif #include #ifndef _WIN32 /* poll flags */ # define POLLIN 0x0001 # define POLLOUT 0x0004 # define POLLERR 0x0008 /* synonyms */ # define POLLNORM POLLIN # define POLLPRI POLLIN # define POLLRDNORM POLLIN # define POLLRDBAND POLLIN # define POLLWRNORM POLLOUT # define POLLWRBAND POLLOUT /* ignored */ # define POLLHUP 0x0010 # define POLLNVAL 0x0020 typedef struct pollfd { int fd; /* file descriptor to poll */ short events; /* events of interest on fd */ short revents; /* events that occurred on fd */ } pollfd_t; #else /* Windows */ /* * Windows use different constants then Unix * Newer version have a WSAPoll which is equal to Unix poll */ # if !defined(POLLRDNORM) && !defined(POLLWRNORM) # define POLLIN 0x0300 # define POLLOUT 0x0010 # define POLLERR 0x0001 # define POLLRDNORM 0x0100 # define POLLWRNORM 0x0010 typedef struct pollfd { SOCKET fd; /* file descriptor to poll */ short events; /* events of interest on fd */ short revents; /* events that occurred on fd */ } pollfd_t; # else typedef struct pollfd pollfd_t; # endif #endif #undef poll int tds_poll(struct pollfd fds[], int nfds, int timeout); #define poll(fds, nfds, timeout) tds_poll(fds, nfds, timeout) #include #endif freetds-1.00.82/include/replacements/readpassphrase.h100644 025423 025423 00000004641 12717145107 0016323/* OPENBSD ORIGINAL: include/readpassphrase.h */ /* $OpenBSD: readpassphrase.h,v 1.3 2002/06/28 12:32:22 millert Exp $ */ /* * Copyright (c) 2000 Todd C. Miller * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef FREETDS_READPASSPHRASE_H_ #define FREETDS_READPASSPHRASE_H_ #ifdef HAVE_READPASSPHRASE # include #else /* !HAVE_READPASSPHRASE */ #include #define RPP_ECHO_OFF 0x00 /* Turn off echo (default). */ #define RPP_ECHO_ON 0x01 /* Leave echo on. */ #define RPP_REQUIRE_TTY 0x02 /* Fail if there is no tty. */ #define RPP_FORCELOWER 0x04 /* Force input to lower case. */ #define RPP_FORCEUPPER 0x08 /* Force input to upper case. */ #define RPP_SEVENBIT 0x10 /* Strip the high bit from input. */ #define RPP_STDIN 0x20 /* Read from stdin, not /dev/tty */ #undef readpassphrase char * tds_readpassphrase(const char *, char *, size_t, int); #define readpassphrase tds_readpassphrase #include #endif /* !HAVE_READPASSPHRASE */ #endif /* !FREETDS_READPASSPHRASE_H_ */ freetds-1.00.82/include/Makefile.am100644 025423 025423 00000000646 12717145107 0012520AUTOMAKE_OPTIONS = 1.5.3 SUBDIRS = freetds include_HEADERS = bkpublic.h \ cspublic.h cstypes.h ctpublic.h \ sqldb.h sqlfront.h \ sybdb.h sybfront.h \ syberror.h odbcss.h nodist_include_HEADERS = tds_sysdep_public.h noinst_HEADERS = ctlib.h \ dblib.h \ md4.h md5.h des.h hmac_md5.h \ replacements.h \ replacements/poll.h \ replacements/readpassphrase.h DISTCLEANFILES = tds_sysdep_public.h freetds-1.00.82/include/bkpublic.h100644 025423 025423 00000005756 12522201763 0012432/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-1999 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef _bkpublic_h_ #define _bkpublic_h_ static const char rcsid_bkpublic_h[] = "$Id: bkpublic.h,v 1.5 2004-10-28 12:42:11 freddy77 Exp $"; static const void *const no_unused_bkpublic_h_warn[] = { rcsid_bkpublic_h, no_unused_bkpublic_h_warn }; /* seperate this stuff out later */ #include #ifdef __cplusplus extern "C" { #if 0 } #endif #endif /* buld properties start with 1 i guess */ #define BLK_IDENTITY 1 CS_RETCODE blk_alloc(CS_CONNECTION * connection, CS_INT version, CS_BLKDESC ** blk_pointer); CS_RETCODE blk_bind(CS_BLKDESC * blkdesc, CS_INT colnum, CS_DATAFMT * datafmt, CS_VOID * buffer, CS_INT * datalen, CS_SMALLINT * indicator); CS_RETCODE blk_colval(SRV_PROC * srvproc, CS_BLKDESC * blkdescp, CS_BLK_ROW * rowp, CS_INT colnum, CS_VOID * valuep, CS_INT valuelen, CS_INT * outlenp); CS_RETCODE blk_default(CS_BLKDESC * blkdesc, CS_INT colnum, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen); CS_RETCODE blk_describe(CS_BLKDESC * blkdesc, CS_INT colnum, CS_DATAFMT * datafmt); CS_RETCODE blk_done(CS_BLKDESC * blkdesc, CS_INT type, CS_INT * outrow); CS_RETCODE blk_drop(CS_BLKDESC * blkdesc); CS_RETCODE blk_getrow(SRV_PROC * srvproc, CS_BLKDESC * blkdescp, CS_BLK_ROW * rowp); CS_RETCODE blk_gettext(SRV_PROC * srvproc, CS_BLKDESC * blkdescp, CS_BLK_ROW * rowp, CS_INT bufsize, CS_INT * outlenp); CS_RETCODE blk_init(CS_BLKDESC * blkdesc, CS_INT direction, CS_CHAR * tablename, CS_INT tnamelen); CS_RETCODE blk_props(CS_BLKDESC * blkdesc, CS_INT action, CS_INT property, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen); CS_RETCODE blk_rowalloc(SRV_PROC * srvproc, CS_BLK_ROW ** row); CS_RETCODE blk_rowdrop(SRV_PROC * srvproc, CS_BLK_ROW * row); CS_RETCODE blk_rowxfer(CS_BLKDESC * blkdesc); CS_RETCODE blk_rowxfer_mult(CS_BLKDESC * blkdesc, CS_INT * row_count); CS_RETCODE blk_sendrow(CS_BLKDESC * blkdesc, CS_BLK_ROW * row); CS_RETCODE blk_sendtext(CS_BLKDESC * blkdesc, CS_BLK_ROW * row, CS_BYTE * buffer, CS_INT buflen); CS_RETCODE blk_srvinit(SRV_PROC * srvproc, CS_BLKDESC * blkdescp); CS_RETCODE blk_textxfer(CS_BLKDESC * blkdesc, CS_BYTE * buffer, CS_INT buflen, CS_INT * outlen); #ifdef __cplusplus #if 0 { #endif } #endif #endif freetds-1.00.82/include/cspublic.h100644 025423 025423 00000053017 12743366021 0012440/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef _cspublic_h_ #define _cspublic_h_ #include #undef TDS_STATIC_CAST #ifdef __cplusplus #define TDS_STATIC_CAST(type, a) static_cast(a) extern "C" { #if 0 } #endif #else #define TDS_STATIC_CAST(type, a) ((type)(a)) #endif #define CS_PUBLIC #define CS_STATIC static #define CS_SUCCEED 1 #define CS_FAIL 0 #define CS_MEM_ERROR -1 #define CS_PENDING -2 #define CS_QUIET -3 #define CS_BUSY -4 #define CS_INTERRUPT -5 #define CS_BLK_HAS_TEXT -6 #define CS_CONTINUE -7 #define CS_FATAL -8 #define CS_RET_HAFAILOVER -9 #define CS_UNSUPPORTED -10 #define CS_CANCELED -202 #define CS_ROW_FAIL -203 #define CS_END_DATA -204 #define CS_END_RESULTS -205 #define CS_END_ITEM -206 #define CS_NOMSG -207 #define CS_TIMED_OUT -208 #define CS_SIZEOF(x) sizeof(x) #define CS_LAYER(x) (((x) >> 24) & 0xFF) #define CS_ORIGIN(x) (((x) >> 16) & 0xFF) #define CS_SEVERITY(x) (((x) >> 8) & 0xFF) #define CS_NUMBER(x) ((x) & 0xFF) /* forward declarations */ typedef CS_RETCODE(*CS_CSLIBMSG_FUNC) (CS_CONTEXT *, CS_CLIENTMSG *); typedef CS_RETCODE(*CS_CLIENTMSG_FUNC) (CS_CONTEXT *, CS_CONNECTION *, CS_CLIENTMSG *); typedef CS_RETCODE(*CS_SERVERMSG_FUNC) (CS_CONTEXT *, CS_CONNECTION *, CS_SERVERMSG *); #define CS_IODATA TDS_STATIC_CAST(CS_INT, 1600) #define CS_SRC_VALUE -2562 /* status bits for CS_SERVERMSG */ #define CS_HASEED 0x01 typedef struct _cs_blkdesc CS_BLKDESC; /* CS_CAP_REQUEST values */ #define CS_REQ_LANG 1 #define CS_REQ_RPC 2 #define CS_REQ_NOTIF 3 #define CS_REQ_MSTMT 4 #define CS_REQ_BCP 5 #define CS_REQ_CURSOR 6 #define CS_REQ_DYN 7 #define CS_REQ_MSG 8 #define CS_REQ_PARAM 9 #define CS_DATA_INT1 10 #define CS_DATA_INT2 11 #define CS_DATA_INT4 12 #define CS_DATA_BIT 13 #define CS_DATA_CHAR 14 #define CS_DATA_VCHAR 15 #define CS_DATA_BIN 16 #define CS_DATA_VBIN 17 #define CS_DATA_MNY8 18 #define CS_DATA_MNY4 19 #define CS_DATA_DATE8 20 #define CS_DATA_DATE4 21 #define CS_DATA_FLT4 22 #define CS_DATA_FLT8 23 #define CS_DATA_NUM 24 #define CS_DATA_TEXT 25 #define CS_DATA_IMAGE 26 #define CS_DATA_DEC 27 #define CS_DATA_LCHAR 28 #define CS_DATA_LBIN 29 #define CS_DATA_INTN 30 #define CS_DATA_DATETIMEN 31 #define CS_DATA_MONEYN 32 #define CS_CSR_PREV 33 #define CS_CSR_FIRST 34 #define CS_CSR_LAST 35 #define CS_CSR_ABS 36 #define CS_CSR_REL 37 #define CS_CSR_MULTI 38 #define CS_CON_OOB 39 #define CS_CON_INBAND 40 #define CS_CON_LOGICAL 41 #define CS_PROTO_TEXT 42 #define CS_PROTO_BULK 43 #define CS_REQ_URGNOTIF 44 #define CS_DATA_SENSITIVITY 45 #define CS_DATA_BOUNDARY 46 #define CS_PROTO_DYNAMIC 47 #define CS_PROTO_DYNPROC 48 #define CS_DATA_FLTN 49 #define CS_DATA_BITN 50 #define CS_OPTION_GET 51 #define CS_DATA_INT8 52 #define CS_DATA_VOID 53 /* CS_CAP_RESPONSE values */ #define CS_RES_NOMSG 1 #define CS_RES_NOEED 2 #define CS_RES_NOPARAM 3 #define CS_DATA_NOINT1 4 #define CS_DATA_NOINT2 5 #define CS_DATA_NOINT4 6 #define CS_DATA_NOBIT 7 #define CS_DATA_NOCHAR 8 #define CS_DATA_NOVCHAR 9 #define CS_DATA_NOBIN 10 #define CS_DATA_NOVBIN 11 #define CS_DATA_NOMNY8 12 #define CS_DATA_NOMNY4 13 #define CS_DATA_NODATE8 14 #define CS_DATA_NODATE4 15 #define CS_DATA_NOFLT4 16 #define CS_DATA_NOFLT8 17 #define CS_DATA_NONUM 18 #define CS_DATA_NOTEXT 19 #define CS_DATA_NOIMAGE 20 #define CS_DATA_NODEC 21 #define CS_DATA_NOLCHAR 22 #define CS_DATA_NOLBIN 23 #define CS_DATA_NOINTN 24 #define CS_DATA_NODATETIMEN 25 #define CS_DATA_NOMONEYN 26 #define CS_CON_NOOOB 27 #define CS_CON_NOINBAND 28 #define CS_PROTO_NOTEXT 29 #define CS_PROTO_NOBULK 30 #define CS_DATA_NOSENSITIVITY 31 #define CS_DATA_NOBOUNDARY 32 #define CS_RES_NOTDSDEBUG 33 #define CS_RES_NOSTRIPBLANKS 34 #define CS_DATA_NOINT8 35 /* Properties */ enum { /* * These defines looks weird but programs can test support for defines, * compiler can check enum and there are no define side effecs */ CS_USERNAME = 9100, #define CS_USERNAME CS_USERNAME CS_PASSWORD = 9101, #define CS_PASSWORD CS_PASSWORD CS_APPNAME = 9102, #define CS_APPNAME CS_APPNAME CS_HOSTNAME = 9103, #define CS_HOSTNAME CS_HOSTNAME CS_LOGIN_STATUS = 9104, #define CS_LOGIN_STATUS CS_LOGIN_STATUS CS_TDS_VERSION = 9105, #define CS_TDS_VERSION CS_TDS_VERSION CS_CHARSETCNV = 9106, #define CS_CHARSETCNV CS_CHARSETCNV CS_PACKETSIZE = 9107, #define CS_PACKETSIZE CS_PACKETSIZE CS_USERDATA = 9108, #define CS_USERDATA CS_USERDATA CS_NETIO = 9110, #define CS_NETIO CS_NETIO CS_TEXTLIMIT = 9112, #define CS_TEXTLIMIT CS_TEXTLIMIT CS_HIDDEN_KEYS = 9113, #define CS_HIDDEN_KEYS CS_HIDDEN_KEYS CS_VERSION = 9114, #define CS_VERSION CS_VERSION CS_IFILE = 9115, #define CS_IFILE CS_IFILE CS_LOGIN_TIMEOUT = 9116, #define CS_LOGIN_TIMEOUT CS_LOGIN_TIMEOUT CS_TIMEOUT = 9117, #define CS_TIMEOUT CS_TIMEOUT CS_MAX_CONNECT = 9118, #define CS_MAX_CONNECT CS_MAX_CONNECT CS_EXPOSE_FMTS = 9120, #define CS_EXPOSE_FMTS CS_EXPOSE_FMTS CS_EXTRA_INF = 9121, #define CS_EXTRA_INF CS_EXTRA_INF CS_ANSI_BINDS = 9123, #define CS_ANSI_BINDS CS_ANSI_BINDS CS_BULK_LOGIN = 9124, #define CS_BULK_LOGIN CS_BULK_LOGIN CS_LOC_PROP = 9125, #define CS_LOC_PROP CS_LOC_PROP CS_PARENT_HANDLE = 9130, #define CS_PARENT_HANDLE CS_PARENT_HANDLE CS_EED_CMD = 9131, #define CS_EED_CMD CS_EED_CMD CS_DIAG_TIMEOUT = 9132, #define CS_DIAG_TIMEOUT CS_DIAG_TIMEOUT CS_DISABLE_POLL = 9133, #define CS_DISABLE_POLL CS_DISABLE_POLL CS_SEC_ENCRYPTION = 9135, #define CS_SEC_ENCRYPTION CS_SEC_ENCRYPTION CS_SEC_CHALLENGE = 9136, #define CS_SEC_CHALLENGE CS_SEC_CHALLENGE CS_SEC_NEGOTIATE = 9137, #define CS_SEC_NEGOTIATE CS_SEC_NEGOTIATE CS_CON_STATUS = 9143, #define CS_CON_STATUS CS_CON_STATUS CS_VER_STRING = 9144, #define CS_VER_STRING CS_VER_STRING CS_SERVERNAME = 9146, #define CS_SERVERNAME CS_SERVERNAME CS_SEC_APPDEFINED = 9149, #define CS_SEC_APPDEFINED CS_SEC_APPDEFINED CS_STICKY_BINDS = 9151, #define CS_STICKY_BINDS CS_STICKY_BINDS CS_SERVERADDR = 9206, #define CS_SERVERADDR CS_SERVERADDR CS_PORT = 9300 #define CS_PORT CS_PORT }; /* Arbitrary precision math operators */ enum { CS_ADD = 1, CS_SUB, CS_MULT, CS_DIV }; enum { CS_TDS_40 = 7360, CS_TDS_42, CS_TDS_46, CS_TDS_495, CS_TDS_50, CS_TDS_70, CS_TDS_71, CS_TDS_72, CS_TDS_73, CS_TDS_74, }; /* bit mask values used by CS_DATAFMT.status */ #define CS_HIDDEN (1 << 0) #define CS_KEY (1 << 1) #define CS_VERSION_KEY (1 << 2) #define CS_NODATA (1 << 3) #define CS_UPDATABLE (1 << 4) #define CS_CANBENULL (1 << 5) #define CS_DESCIN (1 << 6) #define CS_DESCOUT (1 << 7) #define CS_INPUTVALUE (1 << 8) #define CS_UPDATECOL (1 << 9) #define CS_RETURN (1 << 10) #define CS_TIMESTAMP (1 << 13) #define CS_NODEFAULT (1 << 14) #define CS_IDENTITY (1 << 15) /* * DBD::Sybase compares indicator to CS_NULLDATA so this is -1 * (the documentation states -1) */ #define CS_GOODDATA 0 #define CS_NULLDATA (-1) /* CS_CON_STATUS read-only property bit mask values */ #define CS_CONSTAT_CONNECTED 0x01 #define CS_CONSTAT_DEAD 0x02 /* * Code added for CURSOR support * types accepted by ct_cursor */ #define CS_CURSOR_DECLARE 700 #define CS_CURSOR_OPEN 701 #define CS_CURSOR_ROWS 703 #define CS_CURSOR_UPDATE 704 #define CS_CURSOR_DELETE 705 #define CS_CURSOR_CLOSE 706 #define CS_CURSOR_DEALLOC 707 #define CS_CURSOR_OPTION 725 #define CS_FOR_UPDATE TDS_STATIC_CAST(CS_INT, 0x1) #define CS_READ_ONLY TDS_STATIC_CAST(CS_INT, 0x2) #define CS_RESTORE_OPEN TDS_STATIC_CAST(CS_INT, 0x8) #define CS_IMPLICIT_CURSOR TDS_STATIC_CAST(CS_INT, 0x40) #define CS_CURSTAT_NONE TDS_STATIC_CAST(CS_INT, 0x0) #define CS_CURSTAT_DECLARED TDS_STATIC_CAST(CS_INT, 0x1) #define CS_CURSTAT_OPEN TDS_STATIC_CAST(CS_INT, 0x2) #define CS_CURSTAT_CLOSED TDS_STATIC_CAST(CS_INT, 0x4) #define CS_CURSTAT_RDONLY TDS_STATIC_CAST(CS_INT, 0x8) #define CS_CURSTAT_UPDATABLE TDS_STATIC_CAST(CS_INT, 0x10) #define CS_CURSTAT_ROWCOUNT TDS_STATIC_CAST(CS_INT, 0x20) #define CS_CURSTAT_DEALLOC TDS_STATIC_CAST(CS_INT, 0x40) #define CS_CUR_STATUS TDS_STATIC_CAST(CS_INT, 9126) #define CS_CUR_ID TDS_STATIC_CAST(CS_INT, 9127) #define CS_CUR_NAME TDS_STATIC_CAST(CS_INT, 9128) #define CS_CUR_ROWCOUNT TDS_STATIC_CAST(CS_INT, 9129) /* options accepted by ct_options() */ #define CS_OPT_DATEFIRST 5001 #define CS_OPT_TEXTSIZE 5002 #define CS_OPT_STATS_TIME 5003 #define CS_OPT_STATS_IO 5004 #define CS_OPT_ROWCOUNT 5005 #define CS_OPT_DATEFORMAT 5007 #define CS_OPT_ISOLATION 5008 #define CS_OPT_AUTHON 5009 #define CS_OPT_SHOWPLAN 5013 #define CS_OPT_NOEXEC 5014 #define CS_OPT_ARITHIGNORE 5015 #define CS_OPT_TRUNCIGNORE 5016 #define CS_OPT_ARITHABORT 5017 #define CS_OPT_PARSEONLY 5018 #define CS_OPT_GETDATA 5020 #define CS_OPT_NOCOUNT 5021 #define CS_OPT_FORCEPLAN 5023 #define CS_OPT_FORMATONLY 5024 #define CS_OPT_CHAINXACTS 5025 #define CS_OPT_CURCLOSEONXACT 5026 #define CS_OPT_FIPSFLAG 5027 #define CS_OPT_RESTREES 5028 #define CS_OPT_IDENTITYON 5029 #define CS_OPT_CURREAD 5030 #define CS_OPT_CURWRITE 5031 #define CS_OPT_IDENTITYOFF 5032 #define CS_OPT_AUTHOFF 5033 #define CS_OPT_ANSINULL 5034 #define CS_OPT_QUOTED_IDENT 5035 #define CS_OPT_ANSIPERM 5036 #define CS_OPT_STR_RTRUNC 5037 /* options accepted by ct_command() */ enum ct_command_options { CS_MORE = 16, CS_END = 32, CS_RECOMPILE = 188, CS_NO_RECOMPILE, CS_BULK_INIT, CS_BULK_CONT, CS_BULK_DATA, CS_COLUMN_DATA }; /* * bind formats, should be mapped to TDS types * can be a combination of bit */ enum { CS_FMT_UNUSED = 0, #define CS_FMT_UNUSED CS_FMT_UNUSED CS_FMT_NULLTERM = 1, #define CS_FMT_NULLTERM CS_FMT_NULLTERM CS_FMT_PADNULL = 2, #define CS_FMT_PADBLANK CS_FMT_PADBLANK CS_FMT_PADBLANK = 4, #define CS_FMT_PADNULL CS_FMT_PADNULL CS_FMT_JUSTIFY_RT = 8 #define CS_FMT_JUSTIFY_RT CS_FMT_JUSTIFY_RT }; /* callbacks */ #define CS_COMPLETION_CB 1 #define CS_SERVERMSG_CB 2 #define CS_CLIENTMSG_CB 3 #define CS_NOTIF_CB 4 #define CS_ENCRYPT_CB 5 #define CS_CHALLENGE_CB 6 #define CS_DS_LOOKUP_CB 7 #define CS_SECSESSION_CB 8 #define CS_SIGNAL_CB 100 #define CS_MESSAGE_CB 9119 /* string types */ #define CS_NULLTERM -9 #define CS_WILDCARD -99 #define CS_NO_LIMIT -9999 #define CS_UNUSED -99999 /* other */ #define CS_GET 33 #define CS_SET 34 #define CS_CLEAR 35 #define CS_INIT 36 #define CS_STATUS 37 #define CS_MSGLIMIT 38 #define CS_SUPPORTED 40 #define CS_CMD_DONE 4046 #define CS_CMD_SUCCEED 4047 #define CS_CMD_FAIL 4048 /* commands */ #define CS_LANG_CMD 148 #define CS_RPC_CMD 149 #define CS_SEND_DATA_CMD 151 #define CS_SEND_BULK_CMD 153 #define CS_VERSION_100 112 #define CS_VERSION_110 1100 #define CS_VERSION_120 1100 #define CS_VERSION_125 12500 #define CS_VERSION_150 15000 #define BLK_VERSION_100 CS_VERSION_100 #define BLK_VERSION_110 CS_VERSION_110 #define BLK_VERSION_120 CS_VERSION_120 #define BLK_VERSION_125 CS_VERSION_125 #define BLK_VERSION_150 CS_VERSION_150 #define CS_FORCE_EXIT 300 #define CS_FORCE_CLOSE 301 #define CS_SYNC_IO 8111 #define CS_ASYNC_IO 8112 #define CS_DEFER_IO 8113 #define CS_CANCEL_CURRENT 6000 #define CS_CANCEL_ALL 6001 #define CS_CANCEL_ATTN 6002 #define CS_ROW_COUNT 800 #define CS_CMD_NUMBER 801 #define CS_NUM_COMPUTES 802 #define CS_NUMDATA 803 #define CS_NUMORDERCOLS 805 #define CS_MSGTYPE 806 #define CS_BROWSE_INFO 807 #define CS_TRANS_STATE 808 #define CS_TRAN_UNDEFINED 0 #define CS_TRAN_IN_PROGRESS 1 #define CS_TRAN_COMPLETED 2 #define CS_TRAN_FAIL 3 #define CS_TRAN_STMT_FAIL 4 #define CS_COMP_OP 5350 #define CS_COMP_ID 5351 #define CS_COMP_COLID 5352 #define CS_COMP_BYLIST 5353 #define CS_BYLIST_LEN 5354 #define CS_NO_COUNT -1 #define CS_OP_SUM 5370 #define CS_OP_AVG 5371 #define CS_OP_COUNT 5372 #define CS_OP_MIN 5373 #define CS_OP_MAX 5374 #define CS_CAP_REQUEST 1 #define CS_CAP_RESPONSE 2 #define CS_PREPARE 717 #define CS_EXECUTE 718 #define CS_DESCRIBE_INPUT 720 #define CS_DESCRIBE_OUTPUT 721 #define CS_DEALLOC 711 #define CS_LC_ALL 7 #define CS_SYB_LANG 8 #define CS_SYB_CHARSET 9 #define CS_SYB_SORTORDER 10 #define CS_SYB_COLLATE CS_SYB_SORTORDER #define CS_SYB_LANG_CHARSET 11 #define CS_BLK_IN 1 #define CS_BLK_OUT 2 #define CS_BLK_BATCH 1 #define CS_BLK_ALL 2 #define CS_BLK_CANCEL 3 /* to do support these */ #define CS_BLK_ARRAY_MAXLEN 0x1000 #define CS_DEF_PREC 18 /* Error Severities */ #define CS_SV_INFORM TDS_STATIC_CAST(CS_INT, 0) #define CS_SV_API_FAIL TDS_STATIC_CAST(CS_INT, 1) #define CS_SV_RETRY_FAIL TDS_STATIC_CAST(CS_INT, 2) #define CS_SV_RESOURCE_FAIL TDS_STATIC_CAST(CS_INT, 3) #define CS_SV_CONFIG_FAIL TDS_STATIC_CAST(CS_INT, 4) #define CS_SV_COMM_FAIL TDS_STATIC_CAST(CS_INT, 5) #define CS_SV_INTERNAL_FAIL TDS_STATIC_CAST(CS_INT, 6) #define CS_SV_FATAL TDS_STATIC_CAST(CS_INT, 7) /* result_types */ #define CS_COMPUTE_RESULT 4045 #define CS_CURSOR_RESULT 4041 #define CS_PARAM_RESULT 4042 #define CS_ROW_RESULT 4040 #define CS_STATUS_RESULT 4043 #define CS_COMPUTEFMT_RESULT 4050 #define CS_ROWFMT_RESULT 4049 #define CS_MSG_RESULT 4044 #define CS_DESCRIBE_RESULT 4051 /* bind types */ #define CS_ILLEGAL_TYPE TDS_STATIC_CAST(CS_INT, -1) #define CS_CHAR_TYPE TDS_STATIC_CAST(CS_INT, 0) #define CS_BINARY_TYPE TDS_STATIC_CAST(CS_INT, 1) #define CS_LONGCHAR_TYPE TDS_STATIC_CAST(CS_INT, 2) #define CS_LONGBINARY_TYPE TDS_STATIC_CAST(CS_INT, 3) #define CS_TEXT_TYPE TDS_STATIC_CAST(CS_INT, 4) #define CS_IMAGE_TYPE TDS_STATIC_CAST(CS_INT, 5) #define CS_TINYINT_TYPE TDS_STATIC_CAST(CS_INT, 6) #define CS_SMALLINT_TYPE TDS_STATIC_CAST(CS_INT, 7) #define CS_INT_TYPE TDS_STATIC_CAST(CS_INT, 8) #define CS_REAL_TYPE TDS_STATIC_CAST(CS_INT, 9) #define CS_FLOAT_TYPE TDS_STATIC_CAST(CS_INT, 10) #define CS_BIT_TYPE TDS_STATIC_CAST(CS_INT, 11) #define CS_DATETIME_TYPE TDS_STATIC_CAST(CS_INT, 12) #define CS_DATETIME4_TYPE TDS_STATIC_CAST(CS_INT, 13) #define CS_MONEY_TYPE TDS_STATIC_CAST(CS_INT, 14) #define CS_MONEY4_TYPE TDS_STATIC_CAST(CS_INT, 15) #define CS_NUMERIC_TYPE TDS_STATIC_CAST(CS_INT, 16) #define CS_DECIMAL_TYPE TDS_STATIC_CAST(CS_INT, 17) #define CS_VARCHAR_TYPE TDS_STATIC_CAST(CS_INT, 18) #define CS_VARBINARY_TYPE TDS_STATIC_CAST(CS_INT, 19) #define CS_LONG_TYPE TDS_STATIC_CAST(CS_INT, 20) #define CS_SENSITIVITY_TYPE TDS_STATIC_CAST(CS_INT, 21) #define CS_BOUNDARY_TYPE TDS_STATIC_CAST(CS_INT, 22) #define CS_VOID_TYPE TDS_STATIC_CAST(CS_INT, 23) #define CS_USHORT_TYPE TDS_STATIC_CAST(CS_INT, 24) #define CS_UNICHAR_TYPE TDS_STATIC_CAST(CS_INT, 25) #define CS_BLOB_TYPE TDS_STATIC_CAST(CS_INT, 26) #define CS_DATE_TYPE TDS_STATIC_CAST(CS_INT, 27) #define CS_TIME_TYPE TDS_STATIC_CAST(CS_INT, 28) #define CS_UNITEXT_TYPE TDS_STATIC_CAST(CS_INT, 29) #define CS_BIGINT_TYPE TDS_STATIC_CAST(CS_INT, 30) #define CS_USMALLINT_TYPE TDS_STATIC_CAST(CS_INT, 31) #define CS_UINT_TYPE TDS_STATIC_CAST(CS_INT, 32) #define CS_UBIGINT_TYPE TDS_STATIC_CAST(CS_INT, 33) #define CS_XML_TYPE TDS_STATIC_CAST(CS_INT, 34) #define CS_BIGDATETIME_TYPE TDS_STATIC_CAST(CS_INT, 35) #define CS_BIGTIME_TYPE TDS_STATIC_CAST(CS_INT, 36) #define CS_UNIQUE_TYPE TDS_STATIC_CAST(CS_INT, 40) #define CS_USER_TYPE TDS_STATIC_CAST(CS_INT, 100) /* cs_dt_info type values */ enum { CS_MONTH = 7340, #define CS_MONTH CS_MONTH CS_SHORTMONTH, #define CS_SHORTMONTH CS_SHORTMONTH CS_DAYNAME, #define CS_DAYNAME CS_DAYNAME CS_DATEORDER, #define CS_DATEORDER CS_DATEORDER CS_12HOUR, #define CS_12HOUR CS_12HOUR CS_DT_CONVFMT #define CS_DT_CONVFMT CS_DT_CONVFMT }; /* DT_CONVFMT types */ enum { CS_DATES_SHORT = 0, #define CS_DATES_SHORT CS_DATES_SHORT CS_DATES_MDY1, #define CS_DATES_MDY1 CS_DATES_MDY1 CS_DATES_YMD1, #define CS_DATES_YMD1 CS_DATES_YMD1 CS_DATES_DMY1, #define CS_DATES_DMY1 CS_DATES_DMY1 CS_DATES_DMY2, #define CS_DATES_DMY2 CS_DATES_DMY2 CS_DATES_DMY3, #define CS_DATES_DMY3 CS_DATES_DMY3 CS_DATES_DMY4, #define CS_DATES_DMY4 CS_DATES_DMY4 CS_DATES_MDY2, #define CS_DATES_MDY2 CS_DATES_MDY2 CS_DATES_HMS, #define CS_DATES_HMS CS_DATES_HMS CS_DATES_LONG, #define CS_DATES_LONG CS_DATES_LONG CS_DATES_MDY3, #define CS_DATES_MDY3 CS_DATES_MDY3 CS_DATES_YMD2, #define CS_DATES_YMD2 CS_DATES_YMD2 CS_DATES_YMD3, #define CS_DATES_YMD3 CS_DATES_YMD3 CS_DATES_YDM1, #define CS_DATES_YDM1 CS_DATES_YDM1 CS_DATES_MYD1, #define CS_DATES_MYD1 CS_DATES_MYD1 CS_DATES_DYM1, #define CS_DATES_DYM1 CS_DATES_DYM1 CS_DATES_MDY1_YYYY = 101, #define CS_DATES_MDY1_YYYY CS_DATES_MDY1_YYYY CS_DATES_YMD1_YYYY, #define CS_DATES_YMD1_YYYY CS_DATES_YMD1_YYYY CS_DATES_DMY1_YYYY, #define CS_DATES_DMY1_YYYY CS_DATES_DMY1_YYYY CS_DATES_DMY2_YYYY, #define CS_DATES_DMY2_YYYY CS_DATES_DMY2_YYYY CS_DATES_DMY3_YYYY, #define CS_DATES_DMY3_YYYY CS_DATES_DMY3_YYYY CS_DATES_DMY4_YYYY, #define CS_DATES_DMY4_YYYY CS_DATES_DMY4_YYYY CS_DATES_MDY2_YYYY, #define CS_DATES_MDY2_YYYY CS_DATES_MDY2_YYYY CS_DATES_MDY3_YYYY = 110, #define CS_DATES_MDY3_YYYY CS_DATES_MDY3_YYYY CS_DATES_YMD2_YYYY, #define CS_DATES_YMD2_YYYY CS_DATES_YMD2_YYYY CS_DATES_YMD3_YYYY #define CS_DATES_YMD3_YYYY CS_DATES_YMD3_YYYY }; typedef CS_RETCODE(*CS_CONV_FUNC) (CS_CONTEXT * context, CS_DATAFMT * srcfmt, CS_VOID * src, CS_DATAFMT * detsfmt, CS_VOID * dest, CS_INT * destlen); typedef struct _cs_objname { CS_BOOL thinkexists; CS_INT object_type; CS_CHAR last_name[CS_MAX_NAME]; CS_INT lnlen; CS_CHAR first_name[CS_MAX_NAME]; CS_INT fnlen; CS_VOID *scope; CS_INT scopelen; CS_VOID *thread; CS_INT threadlen; } CS_OBJNAME; typedef struct _cs_objdata { CS_BOOL actuallyexists; CS_CONNECTION *connection; CS_COMMAND *command; CS_VOID *buffer; CS_INT buflen; } CS_OBJDATA; /* Eventually, these should be in terms of TDS values */ enum { CS_OPT_MONDAY = 1, CS_OPT_TUESDAY, CS_OPT_WEDNESDAY, CS_OPT_THURSDAY, CS_OPT_FRIDAY, CS_OPT_SATURDAY, CS_OPT_SUNDAY }; enum { CS_OPT_FMTMDY = 1, CS_OPT_FMTDMY, CS_OPT_FMTYMD, CS_OPT_FMTYDM, CS_OPT_FMTMYD, CS_OPT_FMTDYM }; enum { CS_OPT_LEVEL0 = 0, CS_OPT_LEVEL1, CS_OPT_LEVEL2, CS_OPT_LEVEL3 }; #define CS_FALSE 0 #define CS_TRUE 1 #define SRV_PROC CS_VOID /* constants required for ct_diag (not jet implemented) */ #define CS_CLIENTMSG_TYPE 4700 #define CS_SERVERMSG_TYPE 4701 #define CS_ALLMSG_TYPE 4702 CS_RETCODE cs_convert(CS_CONTEXT * ctx, CS_DATAFMT * srcfmt, CS_VOID * srcdata, CS_DATAFMT * destfmt, CS_VOID * destdata, CS_INT * resultlen); CS_RETCODE cs_ctx_alloc(CS_INT version, CS_CONTEXT ** ctx); CS_RETCODE cs_ctx_global(CS_INT version, CS_CONTEXT ** ctx); CS_RETCODE cs_ctx_drop(CS_CONTEXT * ctx); CS_RETCODE cs_config(CS_CONTEXT * ctx, CS_INT action, CS_INT property, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen); CS_RETCODE cs_strbuild(CS_CONTEXT * ctx, CS_CHAR * buffer, CS_INT buflen, CS_INT * resultlen, CS_CHAR * text, CS_INT textlen, CS_CHAR * formats, CS_INT formatlen, ...); #undef cs_dt_crack CS_RETCODE cs_dt_crack(CS_CONTEXT * ctx, CS_INT datetype, CS_VOID * dateval, CS_DATEREC * daterec); CS_RETCODE cs_dt_crack_v2(CS_CONTEXT * ctx, CS_INT datetype, CS_VOID * dateval, CS_DATEREC * daterec); #define cs_dt_crack cs_dt_crack_v2 CS_RETCODE cs_loc_alloc(CS_CONTEXT * ctx, CS_LOCALE ** locptr); CS_RETCODE cs_loc_drop(CS_CONTEXT * ctx, CS_LOCALE * locale); CS_RETCODE cs_locale(CS_CONTEXT * ctx, CS_INT action, CS_LOCALE * locale, CS_INT type, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen); CS_RETCODE cs_dt_info(CS_CONTEXT * ctx, CS_INT action, CS_LOCALE * locale, CS_INT type, CS_INT item, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen); CS_RETCODE cs_calc(CS_CONTEXT * ctx, CS_INT op, CS_INT datatype, CS_VOID * var1, CS_VOID * var2, CS_VOID * dest); CS_RETCODE cs_cmp(CS_CONTEXT * ctx, CS_INT datatype, CS_VOID * var1, CS_VOID * var2, CS_INT * result); CS_RETCODE cs_conv_mult(CS_CONTEXT * ctx, CS_LOCALE * srcloc, CS_LOCALE * destloc, CS_INT * conv_multiplier); CS_RETCODE cs_diag(CS_CONTEXT * ctx, CS_INT operation, CS_INT type, CS_INT idx, CS_VOID * buffer); CS_RETCODE cs_manage_convert(CS_CONTEXT * ctx, CS_INT action, CS_INT srctype, CS_CHAR * srcname, CS_INT srcnamelen, CS_INT desttype, CS_CHAR * destname, CS_INT destnamelen, CS_INT * conv_multiplier, CS_CONV_FUNC * func); CS_RETCODE cs_objects(CS_CONTEXT * ctx, CS_INT action, CS_OBJNAME * objname, CS_OBJDATA * objdata); CS_RETCODE cs_set_convert(CS_CONTEXT * ctx, CS_INT action, CS_INT srctype, CS_INT desttype, CS_CONV_FUNC * func); CS_RETCODE cs_setnull(CS_CONTEXT * ctx, CS_DATAFMT * datafmt, CS_VOID * buffer, CS_INT buflen); CS_RETCODE cs_strcmp(CS_CONTEXT * ctx, CS_LOCALE * locale, CS_INT type, CS_CHAR * str1, CS_INT len1, CS_CHAR * str2, CS_INT len2, CS_INT * result); CS_RETCODE cs_time(CS_CONTEXT * ctx, CS_LOCALE * locale, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen, CS_DATEREC * daterec); CS_RETCODE cs_will_convert(CS_CONTEXT * ctx, CS_INT srctype, CS_INT desttype, CS_BOOL * result); const char * cs_prretcode(int retcode); #ifdef __cplusplus #if 0 { #endif } #endif #endif freetds-1.00.82/include/cstypes.h100644 025423 025423 00000011534 13164127222 0012320/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-1999 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef _cstypes_h_ #define _cstypes_h_ #include "tds_sysdep_public.h" #ifdef __cplusplus extern "C" { #if 0 } #endif #endif static const char rcsid_cstypes_h[] = "$Id: cstypes.h,v 1.7 2008-05-06 00:14:02 jklowden Exp $"; static const void *const no_unused_cstypes_h_warn[] = { rcsid_cstypes_h, no_unused_cstypes_h_warn }; typedef tds_sysdep_int32_type CS_INT; typedef unsigned tds_sysdep_int32_type CS_UINT; typedef tds_sysdep_int64_type CS_BIGINT; typedef unsigned tds_sysdep_int64_type CS_UBIGINT; typedef tds_sysdep_int16_type CS_SMALLINT; typedef unsigned tds_sysdep_int16_type CS_USMALLINT; typedef unsigned char CS_TINYINT; typedef char CS_CHAR; typedef unsigned char CS_BYTE; typedef tds_sysdep_real32_type CS_REAL; typedef tds_sysdep_real64_type CS_FLOAT; typedef tds_sysdep_int32_type CS_BOOL; typedef void CS_VOID; typedef unsigned char CS_IMAGE; typedef unsigned char CS_TEXT; typedef unsigned char CS_LONGBINARY; typedef unsigned char CS_LONGCHAR; typedef long CS_LONG; typedef unsigned char CS_BINARY; typedef unsigned tds_sysdep_int16_type CS_USHORT; typedef unsigned char CS_BIT; typedef CS_INT CS_RETCODE; #define CS_MAX_NAME 132 #define CS_MAX_SCALE 77 #define CS_MAX_PREC 77 /* used by php */ #define CS_MAX_NUMLEN 33 /* used by roguewave */ #define CS_MAX_MSG 1024 #define CS_SQLSTATE_SIZE 8 #define CS_OBJ_NAME 400 #define CS_TP_SIZE 16 /* text pointer */ #define CS_TS_SIZE 8 /* length of timestamp */ typedef struct _cs_numeric { unsigned char precision; unsigned char scale; unsigned char array[CS_MAX_NUMLEN]; } CS_NUMERIC; typedef CS_NUMERIC CS_DECIMAL; typedef struct _cs_varbinary { CS_SMALLINT len; CS_CHAR array[256]; } CS_VARBINARY; typedef struct _cs_varchar { CS_SMALLINT len; /* length of the string */ CS_CHAR str[256]; /* string, no NULL terminator */ } CS_VARCHAR; typedef struct _cs_config CS_CONFIG; typedef struct _cs_context CS_CONTEXT; typedef struct _cs_connection CS_CONNECTION; typedef struct _cs_locale CS_LOCALE; typedef struct _cs_command CS_COMMAND; typedef struct _cs_blk_row CS_BLK_ROW; typedef struct _cs_iodesc { CS_INT iotype; CS_INT datatype; CS_LOCALE *locale; CS_INT usertype; CS_INT total_txtlen; CS_INT offset; CS_BOOL log_on_update; CS_CHAR name[CS_OBJ_NAME]; CS_INT namelen; CS_BYTE timestamp[CS_TS_SIZE]; CS_INT timestamplen; CS_BYTE textptr[CS_TP_SIZE]; CS_INT textptrlen; } CS_IODESC; typedef struct _cs_datafmt { CS_CHAR name[CS_MAX_NAME]; CS_INT namelen; CS_INT datatype; CS_INT format; CS_INT maxlength; CS_INT scale; CS_INT precision; CS_INT status; CS_INT count; CS_INT usertype; CS_LOCALE *locale; } CS_DATAFMT; typedef struct _cs_money { CS_INT mnyhigh; CS_UINT mnylow; } CS_MONEY; typedef struct _cs_money4 { CS_INT mny4; } CS_MONEY4; typedef CS_INT CS_DATE; typedef CS_INT CS_TIME; typedef CS_UBIGINT CS_BIGDATETIME; typedef CS_UBIGINT CS_BIGTIME; typedef struct _cs_datetime { CS_INT dtdays; CS_INT dttime; } CS_DATETIME; typedef struct _cs_datetime4 { CS_USHORT days; CS_USHORT minutes; } CS_DATETIME4; typedef struct _cs_daterec { CS_INT dateyear; CS_INT datemonth; CS_INT datedmonth; CS_INT datedyear; CS_INT datedweek; CS_INT datehour; CS_INT dateminute; CS_INT datesecond; CS_INT datemsecond; CS_INT datetzone; CS_INT datesecfrac; CS_INT datesecprec; } CS_DATEREC; typedef CS_INT CS_MSGNUM; typedef struct _cs_clientmsg { CS_INT severity; CS_MSGNUM msgnumber; CS_CHAR msgstring[CS_MAX_MSG]; CS_INT msgstringlen; CS_INT osnumber; CS_CHAR osstring[CS_MAX_MSG]; CS_INT osstringlen; CS_INT status; CS_BYTE sqlstate[CS_SQLSTATE_SIZE]; CS_INT sqlstatelen; } CS_CLIENTMSG; typedef struct _cs_servermsg { CS_MSGNUM msgnumber; CS_INT state; CS_INT severity; CS_CHAR text[CS_MAX_MSG]; CS_INT textlen; CS_CHAR svrname[CS_MAX_NAME]; CS_INT svrnlen; CS_CHAR proc[CS_MAX_NAME]; CS_INT proclen; CS_INT line; CS_INT status; CS_BYTE sqlstate[CS_SQLSTATE_SIZE]; CS_INT sqlstatelen; } CS_SERVERMSG; #ifdef __cplusplus #if 0 { #endif } #endif #endif freetds-1.00.82/include/ctpublic.h100644 025423 025423 00000016227 12522201763 0012437/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-1999 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef _ctpublic_h_ #define _ctpublic_h_ #include #undef TDS_STATIC_CAST #ifdef __cplusplus #define TDS_STATIC_CAST(type, a) static_cast(a) extern "C" { #if 0 } #endif #else #define TDS_STATIC_CAST(type, a) ((type)(a)) #endif /* ** define for each CT-Lib API */ #define CT_BIND TDS_STATIC_CAST(CS_INT, 0) #define CT_BR_COLUMN TDS_STATIC_CAST(CS_INT, 1) #define CT_BR_TABLE TDS_STATIC_CAST(CS_INT, 2) #define CT_CALLBACK TDS_STATIC_CAST(CS_INT, 3) #define CT_CANCEL TDS_STATIC_CAST(CS_INT, 4) #define CT_CAPABILITY TDS_STATIC_CAST(CS_INT, 5) #define CT_CLOSE TDS_STATIC_CAST(CS_INT, 6) #define CT_CMD_ALLOC TDS_STATIC_CAST(CS_INT, 7) #define CT_CMD_DROP TDS_STATIC_CAST(CS_INT, 8) #define CT_CMD_PROPS TDS_STATIC_CAST(CS_INT, 9) #define CT_COMMAND TDS_STATIC_CAST(CS_INT, 10) #define CT_COMPUTE_INFO TDS_STATIC_CAST(CS_INT, 11) #define CT_CON_ALLOC TDS_STATIC_CAST(CS_INT, 12) #define CT_CON_DROP TDS_STATIC_CAST(CS_INT, 13) #define CT_CON_PROPS TDS_STATIC_CAST(CS_INT, 14) #define CT_CON_XFER TDS_STATIC_CAST(CS_INT, 15) #define CT_CONFIG TDS_STATIC_CAST(CS_INT, 16) #define CT_CONNECT TDS_STATIC_CAST(CS_INT, 17) #define CT_CURSOR TDS_STATIC_CAST(CS_INT, 18) #define CT_DATA_INFO TDS_STATIC_CAST(CS_INT, 19) #define CT_DEBUG TDS_STATIC_CAST(CS_INT, 20) #define CT_DESCRIBE TDS_STATIC_CAST(CS_INT, 21) #define CT_DIAG TDS_STATIC_CAST(CS_INT, 22) #define CT_DYNAMIC TDS_STATIC_CAST(CS_INT, 23) #define CT_DYNDESC TDS_STATIC_CAST(CS_INT, 24) #define CT_EXIT TDS_STATIC_CAST(CS_INT, 25) #define CT_FETCH TDS_STATIC_CAST(CS_INT, 26) #define CT_GET_DATA TDS_STATIC_CAST(CS_INT, 27) #define CT_GETFORMAT TDS_STATIC_CAST(CS_INT, 28) #define CT_GETLOGINFO TDS_STATIC_CAST(CS_INT, 29) #define CT_INIT TDS_STATIC_CAST(CS_INT, 30) #define CT_KEYDATA TDS_STATIC_CAST(CS_INT, 31) #define CT_OPTIONS TDS_STATIC_CAST(CS_INT, 32) #define CT_PARAM TDS_STATIC_CAST(CS_INT, 33) #define CT_POLL TDS_STATIC_CAST(CS_INT, 34) #define CT_RECVPASSTHRU TDS_STATIC_CAST(CS_INT, 35) #define CT_REMOTE_PWD TDS_STATIC_CAST(CS_INT, 36) #define CT_RES_INFO TDS_STATIC_CAST(CS_INT, 37) #define CT_RESULTS TDS_STATIC_CAST(CS_INT, 38) #define CT_SEND TDS_STATIC_CAST(CS_INT, 39) #define CT_SEND_DATA TDS_STATIC_CAST(CS_INT, 40) #define CT_SENDPASSTHRU TDS_STATIC_CAST(CS_INT, 41) #define CT_SETLOGINFO TDS_STATIC_CAST(CS_INT, 42) #define CT_WAKEUP TDS_STATIC_CAST(CS_INT, 43) #define CT_LABELS TDS_STATIC_CAST(CS_INT, 44) #define CT_DS_LOOKUP TDS_STATIC_CAST(CS_INT, 45) #define CT_DS_DROP TDS_STATIC_CAST(CS_INT, 46) #define CT_DS_OBJINFO TDS_STATIC_CAST(CS_INT, 47) #define CT_SETPARAM TDS_STATIC_CAST(CS_INT, 48) #define CT_DYNSQLDA TDS_STATIC_CAST(CS_INT, 49) #define CT_NOTIFICATION TDS_STATIC_CAST(CS_INT, 1000) static const char rcsid_ctpublic_h[] = "$Id: ctpublic.h,v 1.14 2005-05-28 10:48:26 freddy77 Exp $"; static const void *const no_unused_ctpublic_h_warn[] = { rcsid_ctpublic_h, no_unused_ctpublic_h_warn }; CS_RETCODE ct_init(CS_CONTEXT * ctx, CS_INT version); CS_RETCODE ct_con_alloc(CS_CONTEXT * ctx, CS_CONNECTION ** con); CS_RETCODE ct_con_props(CS_CONNECTION * con, CS_INT action, CS_INT property, CS_VOID * buffer, CS_INT buflen, CS_INT * out_len); CS_RETCODE ct_connect(CS_CONNECTION * con, CS_CHAR * servername, CS_INT snamelen); CS_RETCODE ct_cmd_alloc(CS_CONNECTION * con, CS_COMMAND ** cmd); CS_RETCODE ct_cancel(CS_CONNECTION * conn, CS_COMMAND * cmd, CS_INT type); CS_RETCODE ct_cmd_drop(CS_COMMAND * cmd); CS_RETCODE ct_close(CS_CONNECTION * con, CS_INT option); CS_RETCODE ct_con_drop(CS_CONNECTION * con); CS_RETCODE ct_exit(CS_CONTEXT * ctx, CS_INT unused); CS_RETCODE ct_command(CS_COMMAND * cmd, CS_INT type, const CS_VOID * buffer, CS_INT buflen, CS_INT option); CS_RETCODE ct_send(CS_COMMAND * cmd); CS_RETCODE ct_results(CS_COMMAND * cmd, CS_INT * result_type); CS_RETCODE ct_bind(CS_COMMAND * cmd, CS_INT item, CS_DATAFMT * datafmt, CS_VOID * buffer, CS_INT * copied, CS_SMALLINT * indicator); CS_RETCODE ct_fetch(CS_COMMAND * cmd, CS_INT type, CS_INT offset, CS_INT option, CS_INT * rows_read); CS_RETCODE ct_res_info_dyn(CS_COMMAND * cmd, CS_INT type, CS_VOID * buffer, CS_INT buflen, CS_INT * out_len); CS_RETCODE ct_res_info(CS_COMMAND * cmd, CS_INT type, CS_VOID * buffer, CS_INT buflen, CS_INT * out_len); CS_RETCODE ct_describe(CS_COMMAND * cmd, CS_INT item, CS_DATAFMT * datafmt); CS_RETCODE ct_callback(CS_CONTEXT * ctx, CS_CONNECTION * con, CS_INT action, CS_INT type, CS_VOID * func); CS_RETCODE ct_send_dyn(CS_COMMAND * cmd); CS_RETCODE ct_results_dyn(CS_COMMAND * cmd, CS_INT * result_type); CS_RETCODE ct_config(CS_CONTEXT * ctx, CS_INT action, CS_INT property, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen); CS_RETCODE ct_cmd_props(CS_COMMAND * cmd, CS_INT action, CS_INT property, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen); CS_RETCODE ct_compute_info(CS_COMMAND * cmd, CS_INT type, CS_INT colnum, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen); CS_RETCODE ct_get_data(CS_COMMAND * cmd, CS_INT item, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen); CS_RETCODE ct_send_data(CS_COMMAND * cmd, CS_VOID * buffer, CS_INT buflen); CS_RETCODE ct_data_info(CS_COMMAND * cmd, CS_INT action, CS_INT colnum, CS_IODESC * iodesc); CS_RETCODE ct_capability(CS_CONNECTION * con, CS_INT action, CS_INT type, CS_INT capability, CS_VOID * value); CS_RETCODE ct_dynamic(CS_COMMAND * cmd, CS_INT type, CS_CHAR * id, CS_INT idlen, CS_CHAR * buffer, CS_INT buflen); CS_RETCODE ct_param(CS_COMMAND * cmd, CS_DATAFMT * datafmt, CS_VOID * data, CS_INT datalen, CS_SMALLINT indicator); CS_RETCODE ct_setparam(CS_COMMAND * cmd, CS_DATAFMT * datafmt, CS_VOID * data, CS_INT * datalen, CS_SMALLINT * indicator); CS_RETCODE ct_options(CS_CONNECTION * con, CS_INT action, CS_INT option, CS_VOID * param, CS_INT paramlen, CS_INT * outlen); CS_RETCODE ct_poll(CS_CONTEXT * ctx, CS_CONNECTION * connection, CS_INT milliseconds, CS_CONNECTION ** compconn, CS_COMMAND ** compcmd, CS_INT * compid, CS_INT * compstatus); CS_RETCODE ct_cursor(CS_COMMAND * cmd, CS_INT type, CS_CHAR * name, CS_INT namelen, CS_CHAR * text, CS_INT tlen, CS_INT option); CS_RETCODE ct_diag(CS_CONNECTION * conn, CS_INT operation, CS_INT type, CS_INT idx, CS_VOID * buffer); #ifdef __cplusplus #if 0 { #endif } #endif #endif freetds-1.00.82/include/sqldb.h100644 025423 025423 00000011736 12522201763 0011737/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-1999 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef SQLDB_h #define SQLDB_h #include "./sybdb.h" #define SQLCHAR SYBCHAR #define SQLVARCHAR SYBVARCHAR #define SQLINTN SYBINTN #define SQLINT1 SYBINT1 #define SQLINT2 SYBINT2 #define SQLINT4 SYBINT4 #define SQLINT8 SYBINT8 #define SQLFLT8 SYBFLT8 #define SQLDATETIME SYBDATETIME #define SQLBIT SYBBIT #define SQLTEXT SYBTEXT #define SQLIMAGE SYBIMAGE #define SQLMONEY4 SYBMONEY4 #define SQLMONEY SYBMONEY #define SQLDATETIM4 SYBDATETIME4 #define SQLFLT4 SYBREAL #define SQLBINARY SYBBINARY #define SQLVARBINARY SYBVARBINARY #define SQLNUMERIC SYBNUMERIC #define SQLDECIMAL SYBDECIMAL #define SQLFLTN SYBFLTN #define SQLMONEYN SYBMONEYN #define SQLDATETIMN SYBDATETIMN #define SQLVOID SYBVOID #define SMALLDATETIBIND SMALLDATETIMEBIND #define DBERRHANDLE_PROC EHANDLEFUNC #define DBMSGHANDLE_PROC MHANDLEFUNC /* DB-Library errors as defined by Microsoft */ #define SQLEMEM SYBEMEM #define SQLENULL SYBENULL #define SQLENLOG SYBENLOG #define SQLEPWD SYBEPWD #define SQLECONN SYBECONN #define SQLEDDNE SYBEDDNE #define SQLENULLO SYBENULLO #define SQLESMSG SYBESMSG #define SQLEBTOK SYBEBTOK #define SQLENSPE SYBENSPE #define SQLEREAD SYBEREAD #define SQLECNOR SYBECNOR #define SQLETSIT SYBETSIT #define SQLEPARM SYBEPARM #define SQLEAUTN SYBEAUTN #define SQLECOFL SYBECOFL #define SQLERDCN SYBERDCN #define SQLEICN SYBEICN #define SQLECLOS SYBECLOS #define SQLENTXT SYBENTXT #define SQLEDNTI SYBEDNTI #define SQLETMTD SYBETMTD #define SQLEASEC SYBEASEC #define SQLENTLL SYBENTLL #define SQLETIME SYBETIME #define SQLEWRIT SYBEWRIT #define SQLEMODE SYBEMODE #define SQLEOOB SYBEOOB #define SQLEITIM SYBEITIM #define SQLEDBPS SYBEDBPS #define SQLEIOPT SYBEIOPT #define SQLEASNL SYBEASNL #define SQLEASUL SYBEASUL #define SQLENPRM SYBENPRM #define SQLEDBOP SYBEDBOP #define SQLENSIP SYBENSIP #define SQLECNULL SYBECNULL #define SQLESEOF SYBESEOF #define SQLERPND SYBERPND #define SQLECSYN SYBECSYN #define SQLENONET SYBENONET #define SQLEBTYP SYBEBTYP #define SQLEABNC SYBEABNC #define SQLEABMT SYBEABMT #define SQLEABNP SYBEABNP #define SQLEBNCR SYBEBNCR #define SQLEAAMT SYBEAAMT #define SQLENXID SYBENXID #define SQLEIFNB SYBEIFNB #define SQLEKBCO SYBEKBCO #define SQLEBBCI SYBEBBCI #define SQLEKBCI SYBEKBCI #define SQLEBCWE SYBEBCWE #define SQLEBCNN SYBEBCNN #define SQLEBCOR SYBEBCOR #define SQLEBCPI SYBEBCPI #define SQLEBCPN SYBEBCPN #define SQLEBCPB SYBEBCPB #define SQLEVDPT SYBEVDPT #define SQLEBIVI SYBEBIVI #define SQLEBCBC SYBEBCBC #define SQLEBCFO SYBEBCFO #define SQLEBCVH SYBEBCVH #define SQLEBCUO SYBEBCUO #define SQLEBUOE SYBEBUOE #define SQLEBWEF SYBEBWEF #define SQLEBTMT SYBEBTMT #define SQLEBEOF SYBEBEOF #define SQLEBCSI SYBEBCSI #define SQLEPNUL SYBEPNUL #define SQLEBSKERR SYBEBSKERR #define SQLEBDIO SYBEBDIO #define SQLEBCNT SYBEBCNT #define SQLEMDBP SYBEMDBP #define SQLINIT SYBINIT #define SQLCRSINV SYBCRSINV #define SQLCRSCMD SYBCRSCMD #define SQLCRSNOIND SYBCRSNOIND #define SQLCRSDIS SYBCRSDIS #define SQLCRSAGR SYBCRSAGR #define SQLCRSORD SYBCRSORD #define SQLCRSMEM SYBCRSMEM #define SQLCRSBSKEY SYBCRSBSKEY #define SQLCRSNORES SYBCRSNORES #define SQLCRSVIEW SYBCRSVIEW #define SQLCRSBUFR SYBCRSBUFR #define SQLCRSFROWN SYBCRSFROWN #define SQLCRSBROL SYBCRSBROL #define SQLCRSFRAND SYBCRSFRAND #define SQLCRSFLAST SYBCRSFLAST #define SQLCRSRO SYBCRSRO #define SQLCRSTAB SYBCRSTAB #define SQLCRSUPDTAB SYBCRSUPDTAB #define SQLCRSUPDNB SYBCRSUPDNB #define SQLCRSVIIND SYBCRSVIIND #define SQLCRSNOUPD SYBCRSNOUPD #define SQLCRSOS SYBCRSOS #define SQLEBCSA SYBEBCSA #define SQLEBCRO SYBEBCRO #define SQLEBCNE SYBEBCNE #define SQLEBCSK SYBEBCSK #define SQLEUVBF SYBEUVBF #define SQLEBIHC SYBEBIHC #define SQLEBWFF SYBEBWFF #define SQLNUMVAL SYBNUMVAL #define SQLEOLDVR SYBEOLDVR #define SQLEBCPS SYBEBCPS #define SQLEDTC SYBEDTC #define SQLENOTIMPL SYBENOTIMPL #define SQLENONFLOAT SYBENONFLOAT #define SQLECONNFB SYBECONNFB #define dbfreelogin(x) dbloginfree((x)) #define dbprocerrhandle(p, h) dberrhandle((h)) #define dbprocmsghandle(p, h) dbmsghandle((h)) #define dbwinexit() static const char rcsid_sqldb_h[] = "$Id: sqldb.h,v 1.6 2009-12-02 22:35:18 jklowden Exp $"; static const void *const no_unused_sqldb_h_warn[] = { rcsid_sqldb_h, no_unused_sqldb_h_warn }; #endif freetds-1.00.82/include/sqlfront.h100644 025423 025423 00000003745 12522201763 0012503/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-1999 Brian Bruns * Copyright (C) 2011 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef SQLFRONT_h #define SQLFRONT_h #include "./sybfront.h" static const char rcsid_sqlfront_h[] = "$Id: sqlfront.h,v 1.10 2011-07-13 11:06:31 freddy77 Exp $"; static const void *const no_unused_sqlfront_h_warn[] = { rcsid_sqlfront_h, no_unused_sqlfront_h_warn }; typedef DBPROCESS * PDBPROCESS; typedef LOGINREC * PLOGINREC; typedef DBCURSOR * PDBCURSOR; typedef int * LPINT; typedef char * LPSTR; #if !defined(PHP_MSSQL_H) || !defined(PHP_MSSQL_API) typedef BYTE * LPBYTE; #endif typedef void * LPVOID; typedef const char * LPCSTR; typedef const LPINT LPCINT; #ifndef _LPCBYTE_DEFINED #define _LPCBYTE_DEFINED typedef const BYTE * LPCBYTE; #endif typedef USHORT * LPUSHORT; typedef const LPUSHORT LPCUSHORT; typedef DBINT * LPDBINT; typedef const LPDBINT LPCDBINT; typedef DBBINARY * LPDBBINARY; typedef const LPDBBINARY LPCDBBINARY; typedef DBDATEREC * LPDBDATEREC; typedef const LPDBDATEREC LPCDBDATEREC; typedef DBDATETIME * LPDBDATETIME; typedef const LPDBDATETIME LPCDBDATETIME; #endif freetds-1.00.82/include/sybdb.h100644 025423 025423 00000176316 13203773221 0011743/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Brian Bruns * Copyright (C) 2010, 2011 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /** \file ../include/sybdb.h * \brief Primary include file for db-lib applications. * * Declares macros, functions, enumerated types, and defined tokens * used by the db-lib API. */ #ifndef _sybdb_h_ #define _sybdb_h_ #include "tds_sysdep_public.h" #undef TDS_STATIC_CAST #ifdef __cplusplus #define TDS_STATIC_CAST(type, a) static_cast(a) extern "C" { #if 0 } #endif #else #define TDS_STATIC_CAST(type, a) ((type)(a)) #endif #ifdef FALSE #undef FALSE #endif #ifdef TRUE #undef TRUE #endif #define FALSE 0 #define TRUE 1 #define DBSAVE 1 #define DBNOSAVE 0 #define DBNOERR -1 #define INT_EXIT 0 #define INT_CONTINUE 1 #define INT_CANCEL 2 #define INT_TIMEOUT 3 #define DBMAXNUMLEN 33 /* https://msdn.microsoft.com/en-us/library/ms176061.aspx */ #define DBMAXNAME 128 /** * DBVERSION_xxx are used with dbsetversion() */ #define DBVERSION_UNKNOWN 0 #define DBVERSION_46 1 #define DBVERSION_100 2 #define DBVERSION_42 3 #define DBVERSION_70 4 #define DBVERSION_71 5 #define DBVERSION_72 6 #define DBVERSION_73 7 #define DBVERSION_74 8 /* these two are defined by Microsoft for dbsetlversion() */ #define DBVER42 DBVERSION_42 #define DBVER60 DBVERSION_70 /* our best approximation */ /** * DBTDS_xxx are returned by DBTDS() * The integer values of the constants are poorly chosen. */ #define DBTDS_UNKNOWN 0 #define DBTDS_2_0 1 /* pre 4.0 SQL Server */ #define DBTDS_3_4 2 /* Microsoft SQL Server (3.0) */ #define DBTDS_4_0 3 /* 4.0 SQL Server */ #define DBTDS_4_2 4 /* 4.2 SQL Server */ #define DBTDS_4_6 5 /* 2.0 OpenServer and 4.6 SQL Server. */ #define DBTDS_4_9_5 6 /* 4.9.5 (NCR) SQL Server */ #define DBTDS_5_0 7 /* 5.0 SQL Server */ #define DBTDS_7_0 8 /* Microsoft SQL Server 7.0 */ #define DBTDS_8_0 9 /* Microsoft SQL Server 2000 */ #define DBTDS_9_0 10 /* Microsoft SQL Server 2005 */ #define DBTDS_7_1 9 /* Microsoft SQL Server 2000 */ #define DBTDS_7_2 10 /* Microsoft SQL Server 2005 */ #define DBTDS_7_3 11 /* Microsoft SQL Server 2008 */ #define DBTDS_7_4 12 /* Microsoft SQL Server 2012/2014 */ #define DBTXPLEN 16 #define BCPMAXERRS 1 #define BCPFIRST 2 #define BCPLAST 3 #define BCPBATCH 4 #define BCPKEEPIDENTITY 8 #define BCPLABELED 5 #define BCPHINTS 6 #define DBCMDNONE 0 #define DBCMDPEND 1 #define DBCMDSENT 2 typedef int RETCODE; typedef void DBCURSOR; typedef void DBXLATE; typedef void DBSORTORDER; typedef void DBLOGINFO; typedef void *DBVOIDPTR; typedef short SHORT; typedef unsigned short USHORT; typedef int (*INTFUNCPTR) (void *, ...); typedef int (*DBWAITFUNC) (void); typedef DBWAITFUNC(*DB_DBBUSY_FUNC) (void *dbproc); typedef void (*DB_DBIDLE_FUNC) (DBWAITFUNC dfunc, void *dbproc); typedef int (*DB_DBCHKINTR_FUNC) (void *dbproc); typedef int (*DB_DBHNDLINTR_FUNC) (void *dbproc); #ifndef __INCvxWorksh /* VxWorks already defines STATUS and BOOL. Compiler gets mad if you ** redefine them. */ /* __INCvxWorksh will get #defined by std. include files included from tds.h */ #ifdef STATUS /* On DU4.0d we get a conflicting STATUS definition from arpa/nameser.h when _REENTRANT is defined. */ #undef STATUS #endif typedef int STATUS; #if !defined(_WINDEF_) && !defined(_WINDEF_H) && !defined(DOS32X) typedef int BOOL; #endif #endif #ifndef _tds_h_ /* copied from tds.h */ /* TODO find a best way... */ enum { SYBCHAR = 47, /* 0x2F */ #define SYBCHAR SYBCHAR SYBVARCHAR = 39, /* 0x27 */ #define SYBVARCHAR SYBVARCHAR SYBINTN = 38, /* 0x26 */ #define SYBINTN SYBINTN SYBINT1 = 48, /* 0x30 */ #define SYBINT1 SYBINT1 SYBINT2 = 52, /* 0x34 */ #define SYBINT2 SYBINT2 SYBINT4 = 56, /* 0x38 */ #define SYBINT4 SYBINT4 SYBINT8 = 127, /* 0x7F */ #define SYBINT8 SYBINT8 SYBFLT8 = 62, /* 0x3E */ #define SYBFLT8 SYBFLT8 SYBDATETIME = 61, /* 0x3D */ #define SYBDATETIME SYBDATETIME SYBBIT = 50, /* 0x32 */ #define SYBBIT SYBBIT SYBBITN = 104, /* 0x68 */ #define SYBBITN SYBBITN SYBTEXT = 35, /* 0x23 */ #define SYBTEXT SYBTEXT SYBNTEXT = 99, /* 0x63 */ #define SYBNTEXT SYBNTEXT SYBIMAGE = 34, /* 0x22 */ #define SYBIMAGE SYBIMAGE SYBMONEY4 = 122, /* 0x7A */ #define SYBMONEY4 SYBMONEY4 SYBMONEY = 60, /* 0x3C */ #define SYBMONEY SYBMONEY SYBDATETIME4 = 58, /* 0x3A */ #define SYBDATETIME4 SYBDATETIME4 SYBREAL = 59, /* 0x3B */ #define SYBREAL SYBREAL SYBBINARY = 45, /* 0x2D */ #define SYBBINARY SYBBINARY SYBVOID = 31, /* 0x1F */ #define SYBVOID SYBVOID SYBVARBINARY = 37, /* 0x25 */ #define SYBVARBINARY SYBVARBINARY SYBNUMERIC = 108, /* 0x6C */ #define SYBNUMERIC SYBNUMERIC SYBDECIMAL = 106, /* 0x6A */ #define SYBDECIMAL SYBDECIMAL SYBFLTN = 109, /* 0x6D */ #define SYBFLTN SYBFLTN SYBMONEYN = 110, /* 0x6E */ #define SYBMONEYN SYBMONEYN SYBDATETIMN = 111, /* 0x6F */ #define SYBDATETIMN SYBDATETIMN SYBNVARCHAR = 103, /* 0x67 */ #define SYBNVARCHAR SYBNVARCHAR SYBDATE = 49, /* 0x31 */ #define SYBDATE SYBDATE SYBTIME = 51, /* 0x33 */ #define SYBTIME SYBTIME SYBBIGDATETIME = 187, /* 0xBB */ #define SYBBIGDATETIME SYBBIGDATETIME SYBBIGTIME = 188, /* 0xBC */ #define SYBBIGTIME SYBBIGTIME SYBMSDATE = 40, /* 0x28 */ #define SYBMSDATE SYBMSDATE SYBMSTIME = 41, /* 0x29 */ #define SYBMSTIME SYBMSTIME SYBMSDATETIME2 = 42, /* 0x2A */ #define SYBMSDATETIME2 SYBMSDATETIME2 SYBMSDATETIMEOFFSET = 43, /* 0x2B */ #define SYBMSDATETIMEOFFSET SYBMSDATETIMEOFFSET }; #define SYBAOPCNT 0x4b #define SYBAOPCNTU 0x4c #define SYBAOPSUM 0x4d #define SYBAOPSUMU 0x4e #define SYBAOPAVG 0x4f #define SYBAOPAVGU 0x50 #define SYBAOPMIN 0x51 #define SYBAOPMAX 0x52 /* mssql2k compute operator */ #define SYBAOPCNT_BIG 0x09 #define SYBAOPSTDEV 0x30 #define SYBAOPSTDEVP 0x31 #define SYBAOPVAR 0x32 #define SYBAOPVARP 0x33 #define SYBAOPCHECKSUM_AGG 0x72 #endif typedef unsigned char DBBOOL; typedef char DBCHAR; typedef unsigned char DBBIT; typedef unsigned char DBTINYINT; typedef tds_sysdep_int16_type DBSMALLINT; typedef tds_sysdep_int32_type DBINT; typedef tds_sysdep_int64_type DBBIGINT; typedef unsigned char DBBINARY; typedef tds_sysdep_real32_type DBREAL; typedef tds_sysdep_real64_type DBFLT8; typedef unsigned tds_sysdep_int16_type DBUSMALLINT; typedef unsigned tds_sysdep_int32_type DBUINT; typedef unsigned tds_sysdep_int64_type DBUBIGINT; typedef struct { DBSMALLINT len; char str[256]; } DBVARYCHAR; typedef struct { DBSMALLINT len; unsigned char array[256]; } DBVARYBIN; typedef struct { unsigned char precision; unsigned char scale; unsigned char array[33]; } DBNUMERIC; typedef DBNUMERIC DBDECIMAL; typedef struct { DBINT mnyhigh; unsigned tds_sysdep_int32_type mnylow; } DBMONEY; typedef struct { DBINT mny4; } DBMONEY4; typedef struct { DBINT dtdays; DBINT dttime; } DBDATETIME; typedef struct { DBUSMALLINT days; /* days since Jan-1-1900 */ DBUSMALLINT minutes; /* minutes since midnight */ } DBDATETIME4; typedef struct { DBUBIGINT time; /**< time, 7 digit precision */ DBINT date; /**< date, 0 = 1900-01-01 */ DBSMALLINT offset; /**< time offset */ DBUSMALLINT time_prec:3; // fix a problem with some public headers defining _res #undef _res DBUSMALLINT _res:10; DBUSMALLINT has_time:1; DBUSMALLINT has_date:1; DBUSMALLINT has_offset:1; } DBDATETIMEALL; #ifdef MSDBLIB # define SQLCHAR SYBCHAR typedef struct { DBUSMALLINT numdays; DBUSMALLINT nummins; } DBDATETIM4; #endif typedef struct tds_dblib_loginrec LOGINREC; #ifndef DOS32X typedef unsigned char BYTE; #endif typedef struct dbtypeinfo { DBINT precision; DBINT scale; } DBTYPEINFO; struct dbstring { BYTE *strtext; DBINT strtotlen; struct dbstring *strnext; }; typedef struct dbstring DBSTRING; /* Used by dbcolinfo */ enum { MAXCOLNAMELEN = 512 }; /* duplicates TDS_SYSNAME_SIZE */ typedef enum { CI_REGULAR=1, CI_ALTERNATE=2, CI_CURSOR=3 } CI_TYPE; typedef struct { DBINT SizeOfStruct; DBCHAR Name[MAXCOLNAMELEN+2]; DBCHAR ActualName[MAXCOLNAMELEN+2]; DBCHAR TableName[MAXCOLNAMELEN+2]; SHORT Type; DBINT UserType; DBINT MaxLength; BYTE Precision; BYTE Scale; BOOL VarLength; BYTE Null; BYTE CaseSensitive; BYTE Updatable; BOOL Identity; } DBCOL; typedef struct { DBINT SizeOfStruct; DBCHAR Name[MAXCOLNAMELEN+2]; DBCHAR ActualName[MAXCOLNAMELEN+2]; DBCHAR TableName[MAXCOLNAMELEN+2]; SHORT Type; DBINT UserType; DBINT MaxLength; BYTE Precision; BYTE Scale; BOOL VarLength; BYTE Null; BYTE CaseSensitive; BYTE Updatable; BOOL Identity; SHORT ServerType; DBINT ServerMaxLength; DBCHAR ServerTypeDeclaration[256]; } DBCOL2; /* end dbcolinfo stuff */ /* a large list of options, DBTEXTSIZE is needed by sybtcl */ #define DBPARSEONLY 0 #define DBESTIMATE 1 #define DBSHOWPLAN 2 #define DBNOEXEC 3 #define DBARITHIGNORE 4 #define DBNOCOUNT 5 #define DBARITHABORT 6 #define DBTEXTLIMIT 7 #define DBBROWSE 8 #define DBOFFSET 9 #define DBSTAT 10 #define DBERRLVL 11 #define DBCONFIRM 12 #define DBSTORPROCID 13 #define DBBUFFER 14 #define DBNOAUTOFREE 15 #define DBROWCOUNT 16 #define DBTEXTSIZE 17 #define DBNATLANG 18 #define DBDATEFORMAT 19 #define DBPRPAD 20 #define DBPRCOLSEP 21 #define DBPRLINELEN 22 #define DBPRLINESEP 23 #define DBLFCONVERT 24 #define DBDATEFIRST 25 #define DBCHAINXACTS 26 #define DBFIPSFLAG 27 #define DBISOLATION 28 #define DBAUTH 29 #define DBIDENTITY 30 #define DBNOIDCOL 31 #define DBDATESHORT 32 #define DBCLIENTCURSORS 33 #define DBSETTIME 34 #define DBQUOTEDIDENT 35 #define DBNUMOPTIONS 36 #define DBPADOFF 0 #define DBPADON 1 #define OFF 0 #define ON 1 #define NOSUCHOPTION 2 #define MAXOPTTEXT 32 typedef struct tds_dblib_dbprocess DBPROCESS; /* * Sybase & Microsoft use different names for the dbdaterec members. * Keep these two structures physically identical in memory. * dbdatecrack() casts one to the other for ease of implementation. * * Giving credit where credit is due, we can acknowledge that * Microsoft chose the better names here, hands down. ("datedmonth"?!) */ struct tds_microsoft_dbdaterec { DBINT year; /* 1753 - 9999 */ DBINT quarter; /* 1 - 4 */ DBINT month; /* 1 - 12 */ DBINT day; /* 1 - 31 */ DBINT dayofyear; /* 1 - 366 */ DBINT week; /* 1 - 54 (for leap years) */ DBINT weekday; /* 1 - 7 (Mon. - Sun.) */ DBINT hour; /* 0 - 23 */ DBINT minute; /* 0 - 59 */ DBINT second; /* 0 - 59 */ DBINT millisecond; /* 0 - 999 */ DBINT tzone; /* -840 - 840 */ }; struct tds_sybase_dbdaterec { DBINT dateyear; /* 1900 and counting */ DBINT quarter; /* 0 - 3 (Microsoft only) */ DBINT datemonth; /* 0 - 11 */ DBINT datedmonth; /* 1 - 31 */ DBINT datedyear; /* 1 - 366 */ DBINT week; /* 1 - 54 (Microsoft only) */ DBINT datedweek; /* 0 - 6 */ DBINT datehour; /* 0 - 23 */ DBINT dateminute; /* 0 - 59 */ DBINT datesecond; /* 0 - 59 */ DBINT datemsecond; /* 0 - 999 */ DBINT datetzone; /* -840 - 840 */ }; struct tds_microsoft_dbdaterec2 { DBINT year; /* 1753 - 9999 */ DBINT quarter; /* 1 - 4 */ DBINT month; /* 1 - 12 */ DBINT day; /* 1 - 31 */ DBINT dayofyear; /* 1 - 366 */ DBINT week; /* 1 - 54 (for leap years) */ DBINT weekday; /* 1 - 7 (Mon. - Sun.) */ DBINT hour; /* 0 - 23 */ DBINT minute; /* 0 - 59 */ DBINT second; /* 0 - 59 */ DBINT nanosecond; /* 0 - 999999999 */ DBINT tzone; /* 0 - 127 (Sybase only) */ }; struct tds_sybase_dbdaterec2 { DBINT dateyear; /* 1900 and counting */ DBINT quarter; /* 0 - 3 (Microsoft only) */ DBINT datemonth; /* 0 - 11 */ DBINT datedmonth; /* 1 - 31 */ DBINT datedyear; /* 1 - 366 */ DBINT week; /* 1 - 54 (Microsoft only) */ DBINT datedweek; /* 0 - 6 */ DBINT datehour; /* 0 - 23 */ DBINT dateminute; /* 0 - 59 */ DBINT datesecond; /* 0 - 59 */ DBINT datensecond; /* 0 - 999999999 */ DBINT datetzone; /* 0 - 127 */ }; #ifdef MSDBLIB typedef struct tds_microsoft_dbdaterec DBDATEREC; typedef struct tds_microsoft_dbdaterec2 DBDATEREC2; #else typedef struct tds_sybase_dbdaterec DBDATEREC; typedef struct tds_sybase_dbdaterec2 DBDATEREC2; #endif typedef int (*EHANDLEFUNC) (DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr); typedef int (*MHANDLEFUNC) (DBPROCESS * dbproc, DBINT msgno, int msgstate, int severity, char *msgtext, char *srvname, char *proc, int line); /* dbpoll() result codes, sybtcl needs DBRESULT */ #define DBRESULT 1 #define DBNOTIFICATION 2 #define DBTIMEOUT 3 #define DBINTERRUPT 4 /* more sybtcl needs: */ #define DBTXTSLEN 8 /* bind types */ #define CHARBIND 0 #define STRINGBIND 1 #define NTBSTRINGBIND 2 #define VARYCHARBIND 3 #define VARYBINBIND 4 #define TINYBIND 6 #define SMALLBIND 7 #define INTBIND 8 #define FLT8BIND 9 #define REALBIND 10 #define DATETIMEBIND 11 #define SMALLDATETIMEBIND 12 #define MONEYBIND 13 #define SMALLMONEYBIND 14 #define BINARYBIND 15 #define BITBIND 16 #define NUMERICBIND 17 #define DECIMALBIND 18 #define SRCNUMERICBIND 19 #define SRCDECIMALBIND 20 #define DATEBIND 21 #define TIMEBIND 22 #define BIGDATETIMEBIND 23 #define BIGTIMEBIND 24 #define BIGINTBIND 30 #define DATETIME2BIND 31 #define MAXBINDTYPES 32 /* keep last */ #define DBPRCOLSEP 21 #define DBPRLINELEN 22 #define DBRPCRETURN 1 #define DBRPCDEFAULT 2 #define REG_ROW -1 #define MORE_ROWS -1 #define NO_MORE_ROWS -2 #define BUF_FULL -3 #define NO_MORE_RESULTS 2 #define SUCCEED 1 #define FAIL 0 #define DB_IN 1 #define DB_OUT 2 #define DB_QUERYOUT 3 #define DBSINGLE 0 #define DBDOUBLE 1 #define DBBOTH 2 /* remote procedure call (rpc) options */ #define DBRPCRECOMPILE TDS_STATIC_CAST(DBSMALLINT, 0x0001) #define DBRPCRESET TDS_STATIC_CAST(DBSMALLINT, 0x0002) #define DBRPCCURSOR TDS_STATIC_CAST(DBSMALLINT, 0x0008) #if defined(DBLIB_UNIMPLEMENTED) DBBOOL db12hour(DBPROCESS * dbprocess, const char language[]); DBBOOL dbcolbrowse(DBPROCESS * dbprocess, int colnum); RETCODE dbcursor(DBCURSOR * hc, DBINT optype, DBINT bufno, BYTE * table, BYTE * values); RETCODE dbcursorbind(DBCURSOR * hc, int col, int vartype, DBINT varlen, DBINT * poutlen, BYTE * pvaraddr, DBTYPEINFO * typeinfo); void dbcursorclose(DBCURSOR * hc); RETCODE dbcursorcolinfo(DBCURSOR * hc, DBINT column, DBCHAR * colname, DBINT * coltype, DBINT * collen, DBINT * usertype); RETCODE dbcursorfetch(DBCURSOR * hc, DBINT fetchtype, DBINT rownum); RETCODE dbcursorinfo(DBCURSOR * hc, DBINT * ncols, DBINT * nrows); DBCURSOR *dbcursoropen(DBPROCESS * dbprocess, BYTE * stmt, SHORT scollopt, SHORT concuropt, USHORT nrows, DBINT * pstatus); int dbdate4cmp(DBPROCESS * dbprocess, DBDATETIME4 * d1, DBDATETIME4 * d2); RETCODE dbdate4zero(DBPROCESS * dbprocess, DBDATETIME4 * d1); RETCODE dbdatechar(DBPROCESS * dbprocess, char *buf, int datepart, int value); int dbdatename(DBPROCESS * dbprocess, char *buf, int date, DBDATETIME * datetime); char *dateorder(DBPROCESS * dbprocess, char *language); DBINT dbdatepart(DBPROCESS * dbprocess, int datepart, DBDATETIME * datetime); RETCODE dbdatezero(DBPROCESS * dbprocess, DBDATETIME * d1); char *dbdayname(DBPROCESS * dbprocess, char *language, int daynum); int dbgetoff(DBPROCESS * dbprocess, DBUSMALLINT offtype, int startfrom); char *dbqual(DBPROCESS * dbprocess, int tabnum, char *tabname); void dbfreequal(char *qualptr); DBSORTORDER *dbloadsort(DBPROCESS * dbprocess); RETCODE dbfreesort(DBPROCESS * dbprocess, DBSORTORDER * sortorder); RETCODE dbload_xlate(DBPROCESS * dbprocess, char *srv_charset, char *clt_name, DBXLATE ** xlt_tosrv, DBXLATE ** xlt_todisp); RETCODE dbmny4divide(DBPROCESS * dbproc, DBMONEY4 * m1, DBMONEY4 * m2, DBMONEY4 * quotient); RETCODE dbmny4mul(DBPROCESS * dbproc, DBMONEY4 * m1, DBMONEY4 * m2, DBMONEY4 * prod); RETCODE dbmnyadd(DBPROCESS * dbproc, DBMONEY * m1, DBMONEY * m2, DBMONEY * sum); RETCODE dbmnydivide(DBPROCESS * dbproc, DBMONEY * m1, DBMONEY * m2, DBMONEY * quotient); RETCODE dbmnydown(DBPROCESS * dbproc, DBMONEY * mnyptr, int divisor, int *remainder); RETCODE dbmnyinit(DBPROCESS * dbproc, DBMONEY * mnyptr, int trim, DBBOOL * negative); RETCODE dbmnyndigit(DBPROCESS * dbproc, DBMONEY * mnyptr, DBCHAR * value, DBBOOL * zero); RETCODE dbmnymul(DBPROCESS * dbproc, DBMONEY * m1, DBMONEY * m2, DBMONEY * prod); RETCODE dbmnydigit(DBPROCESS * dbprocess, DBMONEY * m1, DBCHAR * value, DBBOOL * zero); RETCODE dbmnyscale(DBPROCESS * dbproc, DBMONEY * dest, int multiplier, int addend); RETCODE dbnpcreate(DBPROCESS * dbprocess); RETCODE dbnpdefine(DBPROCESS * dbprocess, DBCHAR * procedure_name, DBSMALLINT namelen); int DBNUMORDERS(DBPROCESS * dbprocess); RETCODE dbpoll(DBPROCESS * dbproc, long milliseconds, DBPROCESS ** ready_dbproc, int *return_reason); int dbordercol(DBPROCESS * dbprocess, int order); RETCODE dbregdrop(DBPROCESS * dbprocess, DBCHAR * procnm, DBSMALLINT namelen); RETCODE dbregexec(DBPROCESS * dbproc, DBUSMALLINT options); RETCODE dbreghandle(DBPROCESS * dbprocess, DBCHAR * procnm, DBSMALLINT namelen, INTFUNCPTR handler); RETCODE dbreginit(DBPROCESS * dbproc, DBCHAR * procedure_name, DBSMALLINT namelen); RETCODE dbreglist(DBPROCESS * dbproc); RETCODE dbregnowatch(DBPROCESS * dbprocess, DBCHAR * procnm, DBSMALLINT namelen); RETCODE dbregparam(DBPROCESS * dbproc, char *param_name, int type, DBINT datalen, BYTE * data); RETCODE dbregwatch(DBPROCESS * dbprocess, DBCHAR * procnm, DBSMALLINT namelen, DBUSMALLINT options); RETCODE dbregwatchlist(DBPROCESS * dbprocess); void dbrpwclr(LOGINREC * login); RETCODE dbrpwset(LOGINREC * login, char *srvname, char *password, int pwlen); DBINT dbreadpage(DBPROCESS * dbprocess, char *p_dbname, DBINT pageno, BYTE * buf); RETCODE dbwritepage(DBPROCESS * dbprocess, char *p_dbname, DBINT pageno, DBINT size, BYTE * buf); RETCODE dbsetdeflang(char *language); int dbstrcmp(DBPROCESS * dbprocess, char *s1, int l1, char *s2, int l2, DBSORTORDER * sort); int dbstrsort(DBPROCESS * dbprocess, char *s1, int l1, char *s2, int l2, DBSORTORDER * sort); DBBOOL dbtabbrowse(DBPROCESS * dbprocess, int tabnum); int dbtabcount(DBPROCESS * dbprocess); char *dbtabname(DBPROCESS * dbprocess, int tabnum); char *dbtabsource(DBPROCESS * dbprocess, int colnum, int *tabnum); RETCODE dbsendpassthru(DBPROCESS * dbprocess, DBVOIDPTR bufp); RETCODE dbrecvpassthru(DBPROCESS * dbprocess, DBVOIDPTR * bufp); RETCODE dbgetloginfo(DBPROCESS * dbprocess, DBLOGINFO ** loginfo); RETCODE dbsetloginfo(LOGINREC * loginrec, DBLOGINFO * loginfo); int dbtsnewlen(DBPROCESS * dbprocess); DBBINARY *dbtsnewval(DBPROCESS * dbprocess); RETCODE dbtsput(DBPROCESS * dbprocess, DBBINARY * newts, int newtslen, int tabnum, char *tabname); RETCODE dbfree_xlate(DBPROCESS * dbprocess, DBXLATE * xlt_tosrv, DBXLATE * clt_todisp); int dbxlate(DBPROCESS * dbprocess, char *src, int srclen, char *dest, int destlen, DBXLATE * xlt, int *srcbytes_used, DBBOOL srcend, int status); RETCODE bcp_moretext(DBPROCESS * dbproc, DBINT size, BYTE * text); RETCODE bcp_writefmt(DBPROCESS * dbproc, const char filename[]); void build_xact_string(char *xact_name, char *service_name, DBINT commid, char *result); RETCODE remove_xact(DBPROCESS * connect, DBINT commid, int n); RETCODE abort_xact(DBPROCESS * connect, DBINT commid); void close_commit(DBPROCESS * connect); RETCODE commit_xact(DBPROCESS * connect, DBINT commid); DBPROCESS *open_commit(LOGINREC * login, char *servername); RETCODE scan_xact(DBPROCESS * connect, DBINT commid); DBINT start_xact(DBPROCESS * connect, char *application_name, char *xact_name, int site_count); DBINT stat_xact(DBPROCESS * connect, DBINT commid); #endif /* define unimplemented */ BYTE *dbadata(DBPROCESS * dbproc, int computeid, int column); DBINT dbadlen(DBPROCESS * dbproc, int computeid, int column); RETCODE dbaltbind(DBPROCESS * dbprocess, int computeid, int column, int vartype, DBINT varlen, BYTE * varaddr); RETCODE dbaltbind_ps(DBPROCESS * dbprocess, int computeid, int column, int vartype, DBINT varlen, BYTE * varaddr, DBTYPEINFO * typeinfo); int dbaltcolid(DBPROCESS * dbproc, int computeid, int column); DBINT dbaltlen(DBPROCESS * dbproc, int computeid, int column); int dbaltop(DBPROCESS * dbproc, int computeid, int column); int dbalttype(DBPROCESS * dbproc, int computeid, int column); DBINT dbaltutype(DBPROCESS * dbproc, int computeid, int column); RETCODE dbanullbind(DBPROCESS * dbprocess, int computeid, int column, DBINT * indicator); RETCODE dbbind(DBPROCESS * dbproc, int column, int vartype, DBINT varlen, BYTE * varaddr); RETCODE dbbind_ps(DBPROCESS * dbprocess, int column, int vartype, DBINT varlen, BYTE * varaddr, DBTYPEINFO * typeinfo); int dbbufsize(DBPROCESS * dbprocess); BYTE *dbbylist(DBPROCESS * dbproc, int computeid, int *size); RETCODE dbcancel(DBPROCESS * dbproc); RETCODE dbcanquery(DBPROCESS * dbproc); char *dbchange(DBPROCESS * dbprocess); DBBOOL dbcharsetconv(DBPROCESS * dbprocess); void dbclose(DBPROCESS * dbproc); void dbclrbuf(DBPROCESS * dbproc, DBINT n); RETCODE dbclropt(DBPROCESS * dbproc, int option, const char param[]); RETCODE dbcmd(DBPROCESS * dbproc, const char cmdstring[]); RETCODE dbcmdrow(DBPROCESS * dbproc); #define DBCMDROW(x) dbcmdrow((x)) RETCODE dbtablecolinfo (DBPROCESS *dbproc, DBINT column, DBCOL *pdbcol ); RETCODE dbcolinfo (DBPROCESS *dbproc, CI_TYPE type, DBINT column, DBINT computeid, DBCOL *pdbcol); DBINT dbcollen(DBPROCESS * dbproc, int column); char *dbcolname(DBPROCESS * dbproc, int column); char *dbcolsource(DBPROCESS * dbproc, int colnum); int dbcoltype(DBPROCESS * dbproc, int column); DBTYPEINFO *dbcoltypeinfo(DBPROCESS * dbproc, int column); DBINT dbcolutype(DBPROCESS * dbprocess, int column); DBINT dbconvert(DBPROCESS * dbproc, int srctype, const BYTE * src, DBINT srclen, int desttype, BYTE * dest, DBINT destlen); DBINT dbconvert_ps(DBPROCESS * dbprocess, int srctype, const BYTE * src, DBINT srclen, int desttype, BYTE * dest, DBINT destlen, DBTYPEINFO * typeinfo); BOOL dbiscount(DBPROCESS * dbproc); DBINT dbcount(DBPROCESS * dbproc); #define DBCOUNT(x) dbcount((x)) int dbcurcmd(DBPROCESS * dbproc); #define DBCURCMD(x) dbcurcmd((x)) DBINT dbcurrow(DBPROCESS * dbproc); #define DBCURROW(x) dbcurrow((x)) BYTE *dbdata(DBPROCESS * dbproc, int column); int dbdatecmp(DBPROCESS * dbproc, DBDATETIME * d1, DBDATETIME * d2); RETCODE dbdatecrack(DBPROCESS * dbproc, DBDATEREC * di, DBDATETIME * dt); RETCODE dbanydatecrack(DBPROCESS * dbproc, DBDATEREC2 * di, int type, const void *data); DBINT dbdatlen(DBPROCESS * dbproc, int column); DBBOOL dbdead(DBPROCESS * dbproc); #define DBDEAD(x) dbdead((x)) EHANDLEFUNC dberrhandle(EHANDLEFUNC handler); void dbexit(void); RETCODE dbfcmd(DBPROCESS * dbproc, const char *fmt, ...); DBINT dbfirstrow(DBPROCESS * dbproc); #define DBFIRSTROW(x) dbfirstrow((x)) void dbfreebuf(DBPROCESS * dbproc); char *dbgetchar(DBPROCESS * dbprocess, int n); char *dbgetcharset(DBPROCESS * dbprocess); int dbgetlusername(LOGINREC * login, BYTE * name_buffer, int buffer_len); int dbgetmaxprocs(void); char *dbgetnatlanf(DBPROCESS * dbprocess); int dbgetpacket(DBPROCESS * dbproc); RETCODE dbgetrow(DBPROCESS * dbproc, DBINT row); int dbgettime(void); #define DBGETTIME dbgettime BYTE *dbgetuserdata(DBPROCESS * dbproc); DBBOOL dbhasretstat(DBPROCESS * dbproc); RETCODE dbinit(void); int dbiordesc(DBPROCESS * dbproc); #define DBIORDESC(x) dbiordesc((x)) int dbiowdesc(DBPROCESS * dbproc); #define DBIOWDESC(x) dbiowdesc((x)) DBBOOL dbisavail(DBPROCESS * dbprocess); #define DBISAVAIL(x) dbisavail((x)) DBBOOL dbisopt(DBPROCESS * dbproc, int option, const char param[]); DBINT dblastrow(DBPROCESS * dbproc); #define DBLASTROW(x) dblastrow((x)) LOGINREC *dblogin(void); void dbloginfree(LOGINREC * login); int dbmny4cmp(DBPROCESS * dbproc, DBMONEY4 * m1, DBMONEY4 * m2); int dbmnycmp(DBPROCESS * dbproc, DBMONEY * m1, DBMONEY * m2); RETCODE dbmny4add(DBPROCESS * dbproc, DBMONEY4 * m1, DBMONEY4 * m2, DBMONEY4 * sum); RETCODE dbmnydec(DBPROCESS * dbproc, DBMONEY * mnyptr); RETCODE dbmnyinc(DBPROCESS * dbproc, DBMONEY * mnyptr); RETCODE dbmnymaxpos(DBPROCESS * dbproc, DBMONEY * dest); RETCODE dbmnymaxneg(DBPROCESS * dbproc, DBMONEY * dest); RETCODE dbmny4minus(DBPROCESS * dbproc, DBMONEY4 * src, DBMONEY4 * dest); RETCODE dbmnyminus(DBPROCESS * dbproc, DBMONEY * src, DBMONEY * dest); RETCODE dbmny4sub(DBPROCESS * dbproc, DBMONEY4 * m1, DBMONEY4 * m2, DBMONEY4 * diff); RETCODE dbmnysub(DBPROCESS * dbproc, DBMONEY * m1, DBMONEY * m2, DBMONEY * diff); RETCODE dbmny4copy(DBPROCESS * dbprocess, DBMONEY4 * m1, DBMONEY4 * m2); RETCODE dbmnycopy(DBPROCESS * dbproc, DBMONEY * src, DBMONEY * dest); RETCODE dbmny4zero(DBPROCESS * dbproc, DBMONEY4 * dest); RETCODE dbmnyzero(DBPROCESS * dbproc, DBMONEY * dest); const char *dbmonthname(DBPROCESS * dbproc, char *language, int monthnum, DBBOOL shortform); RETCODE dbmorecmds(DBPROCESS * dbproc); #define DBMORECMDS(x) dbmorecmds((x)) RETCODE dbmoretext(DBPROCESS * dbproc, DBINT size, const BYTE text[]); MHANDLEFUNC dbmsghandle(MHANDLEFUNC handler); char *dbname(DBPROCESS * dbproc); STATUS dbnextrow(DBPROCESS * dbproc); RETCODE dbnullbind(DBPROCESS * dbproc, int column, DBINT * indicator); int dbnumalts(DBPROCESS * dbproc, int computeid); int dbnumcols(DBPROCESS * dbproc); int dbnumcompute(DBPROCESS * dbprocess); int dbnumrets(DBPROCESS * dbproc); DBPROCESS *tdsdbopen(LOGINREC * login, const char *server, int msdblib); DBPROCESS *dbopen(LOGINREC * login, const char *server); /* pivot functions */ struct col_t; void dbpivot_count (struct col_t *output, const struct col_t *input); void dbpivot_sum (struct col_t *output, const struct col_t *input); void dbpivot_min (struct col_t *output, const struct col_t *input); void dbpivot_max (struct col_t *output, const struct col_t *input); struct pivot_t; typedef void (*DBPIVOT_FUNC)(struct col_t *output, const struct col_t *input); struct pivot_t * dbrows_pivoted(DBPROCESS *dbproc); STATUS dbnextrow_pivoted(DBPROCESS *dbproc, struct pivot_t *pp); RETCODE dbpivot(DBPROCESS *dbproc, int nkeys, int *keys, int ncols, int *cols, DBPIVOT_FUNC func, int val); DBPIVOT_FUNC dbpivot_lookup_name( const char name[] ); #ifdef MSDBLIB #define dbopen(x,y) tdsdbopen((x),(y), 1) #else #define dbopen(x,y) tdsdbopen((x),(y), 0) #endif /* fix PHP problem */ #ifdef PHP_SYBASE_DBOPEN #undef PHP_SYBASE_DBOPEN #define PHP_SYBASE_DBOPEN dbopen #endif void dbprhead(DBPROCESS * dbproc); DBINT dbprcollen(DBPROCESS * dbproc, int column); RETCODE dbprrow(DBPROCESS * dbproc); const char *dbprtype(int token); DBBOOL DRBUF(DBPROCESS * dbprocess); STATUS dbreadtext(DBPROCESS * dbproc, void *buf, DBINT bufsize); void dbrecftos(const char filename[]); RETCODE dbresults(DBPROCESS * dbproc); RETCODE dbresults_r(DBPROCESS * dbproc, int recursive); BYTE *dbretdata(DBPROCESS * dbproc, int retnum); int dbretlen(DBPROCESS * dbproc, int retnum); char *dbretname(DBPROCESS * dbproc, int retnum); DBINT dbretstatus(DBPROCESS * dbproc); int dbrettype(DBPROCESS * dbproc, int retnum); RETCODE dbrows(DBPROCESS * dbproc); #define DBROWS(x) dbrows((x)) STATUS dbrowtype(DBPROCESS * dbprocess); #define DBROWTYPE(x) dbrowtype((x)) RETCODE dbrpcinit(DBPROCESS * dbproc, const char rpcname[], DBSMALLINT options); RETCODE dbrpcparam(DBPROCESS * dbproc, const char paramname[], BYTE status, int type, DBINT maxlen, DBINT datalen, BYTE * value); RETCODE dbrpcsend(DBPROCESS * dbproc); RETCODE dbsafestr(DBPROCESS * dbproc, const char *src, DBINT srclen, char *dest, DBINT destlen, int quotetype); RETCODE *dbsechandle(DBINT type, INTFUNCPTR handler); char *dbservcharset(DBPROCESS * dbprocess); void dbsetavail(DBPROCESS * dbprocess); void dbsetbusy(DBPROCESS * dbprocess, DB_DBBUSY_FUNC busyfunc); RETCODE dbsetdefcharset(char *charset); void dbsetidle(DBPROCESS * dbprocess, DB_DBIDLE_FUNC idlefunc); void dbsetifile(char *filename); void dbsetinterrupt(DBPROCESS * dbproc, DB_DBCHKINTR_FUNC chkintr, DB_DBHNDLINTR_FUNC hndlintr); RETCODE dbsetlogintime(int seconds); RETCODE dbsetmaxprocs(int maxprocs); RETCODE dbsetnull(DBPROCESS * dbprocess, int bindtype, int bindlen, BYTE * bindval); RETCODE dbsetopt(DBPROCESS * dbproc, int option, const char *char_param, int int_param); STATUS dbsetrow(DBPROCESS * dbprocess, DBINT row); RETCODE dbsettime(int seconds); void dbsetuserdata(DBPROCESS * dbproc, BYTE * ptr); RETCODE dbsetversion(DBINT version); int dbspid(DBPROCESS * dbproc); RETCODE dbspr1row(DBPROCESS * dbproc, char *buffer, DBINT buf_len); DBINT dbspr1rowlen(DBPROCESS * dbproc); RETCODE dbsprhead(DBPROCESS * dbproc, char *buffer, DBINT buf_len); RETCODE dbsprline(DBPROCESS * dbproc, char *buffer, DBINT buf_len, DBCHAR line_char); RETCODE dbsqlexec(DBPROCESS * dbproc); RETCODE dbsqlok(DBPROCESS * dbproc); RETCODE dbsqlsend(DBPROCESS * dbproc); int dbstrbuild(DBPROCESS * dbproc, char *charbuf, int bufsize, char *text, char *formats, ...); RETCODE dbstrcpy(DBPROCESS * dbproc, int start, int numbytes, char *dest); int dbstrlen(DBPROCESS * dbproc); DBINT dbvarylen(DBPROCESS * dbproc, int column); #define SYBEVERDOWN 100 /* TDS version downgraded . */ #define SYBEICONVIU 2400 /* Some character(s) could not be converted into client's character set. */ #define SYBEICONVAVAIL 2401 /* Character set conversion is not available between client character set '%.*s' and server character set '%.*s'.*/ #define SYBEICONVO 2402 /* Error converting characters into server's character set. Some character(s) could not be converted.*/ #define SYBEICONVI 2403 /* Some character(s) could not be converted into client's character set. Unconverted bytes were changed to question marks ('?').*/ #define SYBEICONV2BIG 2404 /* Buffer overflow converting characters from client into server's character set.*/ /* cf. doc/dblib_errors.txt for more iconv error values. */ /* Reserve a few slots for other iconv-related issues. */ #define SYBETDSVER 2410 /* Cannot bcp with TDSVER < 5.0 */ #define SYBEPORT 2500 /* Both port and instance specified */ #define SYBESYNC 20001 /* Read attempted while out of synchronization with SQL Server. */ #define SYBEFCON 20002 /* SQL Server connection failed. */ #define SYBETIME 20003 /* SQL Server connection timed out. */ #define SYBEREAD 20004 /* Read from SQL Server failed. */ #define SYBEBUFL 20005 /* DB-LIBRARY internal error - send buffer length corrupted. */ #define SYBEWRIT 20006 /* Write to SQL Server failed. */ #define SYBEVMS 20007 /* Sendflush: VMS I/O error. */ #define SYBESOCK 20008 /* Unable to open socket */ #define SYBECONN 20009 /* Unable to connect socket -- SQL Server is unavailable or does not exist. */ #define SYBEMEM 20010 /* Unable to allocate sufficient memory */ #define SYBEDBPS 20011 /* Maximum number of DBPROCESSes already allocated. */ #define SYBEINTF 20012 /* Server name not found in interface file */ #define SYBEUHST 20013 /* Unknown host machine name */ #define SYBEPWD 20014 /* Incorrect password. */ #define SYBEOPIN 20015 /* Could not open interface file. */ #define SYBEINLN 20016 /* Interface file: unexpected end-of-line. */ #define SYBESEOF 20017 /* Unexpected EOF from SQL Server. */ #define SYBESMSG 20018 /* General SQL Server error: Check messages from the SQL Server. */ #define SYBERPND 20019 /* Attempt to initiate a new SQL Server operation with results pending. */ #define SYBEBTOK 20020 /* Bad token from SQL Server: Data-stream processing out of sync. */ #define SYBEITIM 20021 /* Illegal timeout value specified. */ #define SYBEOOB 20022 /* Error in sending out-of-band data to SQL Server. */ #define SYBEBTYP 20023 /* Unknown bind type passed to DB-LIBRARY function. */ #define SYBEBNCR 20024 /* Attempt to bind user variable to a non-existent compute row. */ #define SYBEIICL 20025 /* Illegal integer column length returned by SQL Server. Legal integer lengths are 1, 2, and 4 bytes. */ #define SYBECNOR 20026 /* Column number out of range. */ #define SYBENPRM 20027 /* NULL parameter not allowed for this dboption. */ #define SYBEUVDT 20028 /* Unknown variable-length datatype encountered. */ #define SYBEUFDT 20029 /* Unknown fixed-length datatype encountered. */ #define SYBEWAID 20030 /* DB-LIBRARY internal error: ALTFMT following ALTNAME has wrong id. */ #define SYBECDNS 20031 /* Datastream indicates that a compute column is derived from a non-existent select-list member. */ #define SYBEABNC 20032 /* Attempt to bind to a non-existent column. */ #define SYBEABMT 20033 /* User attempted a dbbind() with mismatched column and variable types. */ #define SYBEABNP 20034 /* Attempt to bind using NULL pointers. */ #define SYBEAAMT 20035 /* User attempted a dbaltbind() with mismatched column and variable types. */ #define SYBENXID 20036 /* The Server did not grant us a distributed-transaction ID. */ #define SYBERXID 20037 /* The Server did not recognize our distributed-transaction ID. */ #define SYBEICN 20038 /* Invalid computeid or compute column number. */ #define SYBENMOB 20039 /* No such member of 'order by' clause. */ #define SYBEAPUT 20040 /* Attempt to print unknown token. */ #define SYBEASNL 20041 /* Attempt to set fields in a null loginrec. */ #define SYBENTLL 20042 /* Name too long for loginrec field. */ #define SYBEASUL 20043 /* Attempt to set unknown loginrec field. */ #define SYBERDNR 20044 /* Attempt to retrieve data from a non-existent row. */ #define SYBENSIP 20045 /* Negative starting index passed to dbstrcpy(). */ #define SYBEABNV 20046 /* Attempt to bind to a NULL program variable. */ #define SYBEDDNE 20047 /* DBPROCESS is dead or not enabled. */ #define SYBECUFL 20048 /* Data-conversion resulted in underflow. */ #define SYBECOFL 20049 /* Data-conversion resulted in overflow. */ #define SYBECSYN 20050 /* Attempt to convert data stopped by syntax error in source field. */ #define SYBECLPR 20051 /* Data-conversion resulted in loss of precision. */ #define SYBECNOV 20052 /* Attempt to set variable to NULL resulted in overflow. */ #define SYBERDCN 20053 /* Requested data-conversion does not exist. */ #define SYBESFOV 20054 /* dbsafestr() overflowed its destination buffer. */ #define SYBEUNT 20055 /* Unknown network type found in interface file. */ #define SYBECLOS 20056 /* Error in closing network connection. */ #define SYBEUAVE 20057 /* Unable to allocate VMS event flag. */ #define SYBEUSCT 20058 /* Unable to set communications timer. */ #define SYBEEQVA 20059 /* Error in queueing VMS AST routine. */ #define SYBEUDTY 20060 /* Unknown datatype encountered. */ #define SYBETSIT 20061 /* Attempt to call dbtsput() with an invalid timestamp. */ #define SYBEAUTN 20062 /* Attempt to update the timestamp of a table which has no timestamp column. */ #define SYBEBDIO 20063 /* Bad bulk-copy direction. Must be either IN or OUT. */ #define SYBEBCNT 20064 /* Attempt to use Bulk Copy with a non-existent Server table. */ #define SYBEIFNB 20065 /* Illegal field number passed to bcp_control(). */ #define SYBETTS 20066 /* The table which bulk-copy is attempting to copy to a host-file is shorter than the number of rows which bulk-copy was instructed to skip. */ #define SYBEKBCO 20067 /* 1000 rows successfully bulk-copied to host-file. */ #define SYBEBBCI 20068 /* Batch successfully bulk-copied to SQL Server. */ #define SYBEKBCI 20069 /* Bcp: 1000 rows sent to SQL Server. */ #define SYBEBCRE 20070 /* I/O error while reading bcp data-file. */ #define SYBETPTN 20071 /* Syntax error: only two periods are permitted in table names. */ #define SYBEBCWE 20072 /* I/O error while writing bcp data-file. */ #define SYBEBCNN 20073 /* Attempt to bulk-copy a NULL value into Server column %d, which does not accept NULL values. */ #define SYBEBCOR 20074 /* Attempt to bulk-copy an oversized row to the SQL Server. */ #define SYBEBCIS 20075 /* Attempt to bulk-copy an illegally-sized column value to the SQL Server. */ #define SYBEBCPI 20076 /* bcp_init() must be called before any other bcp routines. */ #define SYBEBCPN 20077 /* bcp_bind(), bcp_collen(), bcp_colptr(), bcp_moretext() and bcp_sendrow() may be used only after bcp_init() has been called with the copy direction set to DB_IN. */ #define SYBEBCPB 20078 /* bcp_bind(), bcp_moretext() and bcp_sendrow() may NOT be used after bcp_init() has been passed a non-NULL input file name. */ #define SYBEVDPT 20079 /* For bulk copy, all variable-length data must have either a length-prefix or a terminator specified. */ #define SYBEBIVI 20080 /* bcp_columns(), bcp_colfmt() and bcp_colfmt_ps() may be used only after bcp_init() has been passed a valid input file. */ #define SYBEBCBC 20081 /* bcp_columns() must be called before bcp_colfmt() and bcp_colfmt_ps(). */ #define SYBEBCFO 20082 /* Bcp host-files must contain at least one column. */ #define SYBEBCVH 20083 /* bcp_exec() may be called only after bcp_init() has been passed a valid host file. */ #define SYBEBCUO 20084 /* Bcp: Unable to open host data-file. */ #define SYBEBCUC 20085 /* Bcp: Unable to close host data-file. */ #define SYBEBUOE 20086 /* Bcp: Unable to open error-file. */ #define SYBEBUCE 20087 /* Bcp: Unable to close error-file. */ #define SYBEBWEF 20088 /* I/O error while writing bcp error-file. */ #define SYBEASTF 20089 /* VMS: Unable to setmode for control_c ast. */ #define SYBEUACS 20090 /* VMS: Unable to assign channel to sys$command. */ #define SYBEASEC 20091 /* Attempt to send an empty command buffer to the SQL Server. */ #define SYBETMTD 20092 /* Attempt to send too much TEXT data via the dbmoretext() call. */ #define SYBENTTN 20093 /* Attempt to use dbtxtsput() to put a new text-timestamp into a non-existent data row. */ #define SYBEDNTI 20094 /* Attempt to use dbtxtsput() to put a new text-timestamp into a column whose datatype is neither SYBTEXT nor SYBIMAGE. */ #define SYBEBTMT 20095 /* Attempt to send too much TEXT data via the bcp_moretext() call. */ #define SYBEORPF 20096 /* Attempt to set remote password would overflow the login-record's remote-password field. */ #define SYBEUVBF 20097 /* Attempt to read an unknown version of BCP format-file. */ #define SYBEBUOF 20098 /* Bcp: Unable to open format-file. */ #define SYBEBUCF 20099 /* Bcp: Unable to close format-file. */ #define SYBEBRFF 20100 /* I/O error while reading bcp format-file. */ #define SYBEBWFF 20101 /* I/O error while writing bcp format-file. */ #define SYBEBUDF 20102 /* Bcp: Unrecognized datatype found in format-file. */ #define SYBEBIHC 20103 /* Incorrect host-column number found in bcp format-file. */ #define SYBEBEOF 20104 /* Unexpected EOF encountered in BCP data-file. */ #define SYBEBCNL 20105 /* Negative length-prefix found in BCP data-file. */ #define SYBEBCSI 20106 /* Host-file columns may be skipped only when copying INto the Server. */ #define SYBEBCIT 20107 /* It's illegal to use BCP terminators with program variables other than SYBCHAR, SYBBINARY, SYBTEXT, or SYBIMAGE. */ #define SYBEBCSA 20108 /* The BCP hostfile '%s' contains only %ld rows. Skipping all of these rows is not allowed. */ #define SYBENULL 20109 /* NULL DBPROCESS pointer passed to DB-Library. */ #define SYBEUNAM 20110 /* Unable to get current username from operating system. */ #define SYBEBCRO 20111 /* The BCP hostfile '%s' contains only %ld rows. It was impossible to read the requested %ld rows. */ #define SYBEMPLL 20112 /* Attempt to set maximum number of DBPROCESSes lower than 1. */ #define SYBERPIL 20113 /* It is illegal to pass -1 to dbrpcparam() for the datalen of parameters which are of type SYBCHAR, SYBVARCHAR, SYBBINARY, or SYBVARBINARY. */ #define SYBERPUL 20114 /* When passing a SYBINTN, SYBDATETIMN, SYBMONEYN, or SYBFLTN parameter via dbrpcparam(), it's necessary to specify the parameter's maximum or actual length, so that DB-Library can recognize it as a SYBINT1, SYBINT2, SYBINT4, SYBMONEY, or SYBMONEY4, etc. */ #define SYBEUNOP 20115 /* Unknown option passed to dbsetopt(). */ #define SYBECRNC 20116 /* The current row is not a result of compute clause %d, so it is illegal to attempt to extract that data from this row. */ #define SYBERTCC 20117 /* dbreadtext() may not be used to receive the results of a query which contains a COMPUTE clause. */ #define SYBERTSC 20118 /* dbreadtext() may only be used to receive the results of a query which contains a single result column. */ #define SYBEUCRR 20119 /* Internal software error: Unknown connection result reported by * dbpasswd(). */ #define SYBERPNA 20120 /* The RPC facility is available only when using a SQL Server whose version number is 4.0 or greater. */ #define SYBEOPNA 20121 /* The text/image facility is available only when using a SQL Server whose version number is 4.0 or greater. */ #define SYBEFGTL 20122 /* Bcp: Row number of the first row to be copied cannot be greater than the row number for the last row to be copied. */ #define SYBECWLL 20123 /* Attempt to set column width less than 1. */ #define SYBEUFDS 20124 /* Unrecognized format encountered in dbstrbuild(). */ #define SYBEUCPT 20125 /* Unrecognized custom-format parameter-type encountered in dbstrbuild(). */ #define SYBETMCF 20126 /* Attempt to install too many custom formats via dbfmtinstall(). */ #define SYBEAICF 20127 /* Error in attempting to install custom format. */ #define SYBEADST 20128 /* Error in attempting to determine the size of a pair of translation tables. */ #define SYBEALTT 20129 /* Error in attempting to load a pair of translation tables. */ #define SYBEAPCT 20130 /* Error in attempting to perform a character-set translation. */ #define SYBEXOCI 20131 /* A character-set translation overflowed its destination buffer while using bcp to copy data from a host-file to the SQL Server. */ #define SYBEFSHD 20132 /* Error in attempting to find the Sybase home directory. */ #define SYBEAOLF 20133 /* Error in attempting to open a localization file. */ #define SYBEARDI 20134 /* Error in attempting to read datetime information from a localization file. */ #define SYBEURCI 20135 /* Unable to read copyright information from the dblib localization file. */ #define SYBEARDL 20136 /* Error in attempting to read the dblib.loc localization file. */ #define SYBEURMI 20137 /* Unable to read money-format information from the dblib localization file. */ #define SYBEUREM 20138 /* Unable to read error mnemonic from the dblib localization file. */ #define SYBEURES 20139 /* Unable to read error string from the dblib localization file. */ #define SYBEUREI 20140 /* Unable to read error information from the dblib localization file. */ #define SYBEOREN 20141 /* Warning: an out-of-range error-number was encountered in dblib.loc. The maximum permissible error-number is defined as DBERRCOUNT in sybdb.h. */ #define SYBEISOI 20142 /* Invalid sort-order information found. */ #define SYBEIDCL 20143 /* Illegal datetime column length returned by DataServer. Legal datetime lengths are 4 and 8 bytes. */ #define SYBEIMCL 20144 /* Illegal money column length returned by DataServer. Legal money lengths are 4 and 8 bytes. */ #define SYBEIFCL 20145 /* Illegal floating-point column length returned by DataServer. Legal floating-point lengths are 4 and 8 bytes. */ #define SYBEUTDS 20146 /* Unrecognized TDS version received from SQL Server. */ #define SYBEBUFF 20147 /* Bcp: Unable to create format-file. */ #define SYBEACNV 20148 /* Attemp to do conversion with NULL destination variable. */ #define SYBEDPOR 20149 /* Out-of-range datepart constant. */ #define SYBENDC 20150 /* Cannot have negative component in date in numeric form. */ #define SYBEMVOR 20151 /* Month values must be between 1 and 12. */ #define SYBEDVOR 20152 /* Day values must be between 1 and 7. */ #define SYBENBVP 20153 /* Cannot pass dbsetnull() a NULL bindval pointer. */ #define SYBESPID 20154 /* Called dbspid() with a NULL dbproc. */ #define SYBENDTP 20155 /* Called dbdatecrack() with a NULL datetime parameter. */ #define SYBEXTN 20156 /* The xlt_todisp and xlt_tosrv parameters to dbfree_xlate() were NULL. */ #define SYBEXTDN 20157 /* Warning: the xlt_todisp parameter to dbfree_xlate() was NULL. The space associated with the xlt_tosrv parameter has been freed. */ #define SYBEXTSN 20158 /* Warning: the xlt_tosrv parameter to dbfree_xlate() was NULL. The space associated with the xlt_todisp parameter has been freed. */ #define SYBENUM 20159 /* Incorrect number of arguments given to DB-Library. */ #define SYBETYPE 20160 /* Invalid argument type given to DB-Library. */ #define SYBEGENOS 20161 /* General Operating System Error. */ #define SYBEPAGE 20162 /* wrong resource type or length given for dbpage() operation. */ #define SYBEOPTNO 20163 /* Option is not allowed or is unreconized */ #define SYBEETD 20164 /* Failure to send the expected amount of TEXT or IMAGE data via dbmoretext(). */ #define SYBERTYPE 20165 /* Invalid resource type given to DB-Library. */ #define SYBERFILE 20166 /* "Can not open resource file." */ #define SYBEFMODE 20167 /* Read/Write/Append mode denied on file. */ #define SYBESLCT 20168 /* Could not select or copy field specified */ #define SYBEZTXT 20169 /* Attempt to send zero length TEXT or IMAGE to dataserver via dbwritetext(). */ #define SYBENTST 20170 /* The file being opened must be a stream_lf. */ #define SYBEOSSL 20171 /* Operating system login level not in range of Secure SQL Server */ #define SYBEESSL 20172 /* Login security level entered does not agree with operating system level */ #define SYBENLNL 20173 /* Program not linked with specified network library. */ #define SYBENHAN 20174 /* called dbrecvpassthru() with a NULL handler parameter. */ #define SYBENBUF 20175 /* called dbsendpassthru() with a NULL buf pointer. */ #define SYBENULP 20176 /* Called %s with a NULL %s parameter. */ #define SYBENOTI 20177 /* No event handler installed. */ #define SYBEEVOP 20178 /* Called dbregwatch() with a bad options parameter. */ #define SYBENEHA 20179 /* Called dbreghandle() with a NULL handler parameter. */ #define SYBETRAN 20180 /* DBPROCESS is being used for another transaction. */ #define SYBEEVST 20181 /* Must initiate a transaction before calling dbregparam(). */ #define SYBEEINI 20182 /* Must call dbreginit() before dbregraise(). */ #define SYBEECRT 20183 /* Must call dbregdefine() before dbregcreate(). */ #define SYBEECAN 20184 /* Attempted to cancel unrequested event notification. */ #define SYBEEUNR 20185 /* Unsolicited event notification received. */ #define SYBERPCS 20186 /* Must call dbrpcinit() before dbrpcparam(). */ #define SYBETPAR 20187 /* No SYBTEXT or SYBIMAGE parameters were defined. */ #define SYBETEXS 20188 /* Called dbmoretext() with a bad size parameter. */ #define SYBETRAC 20189 /* Attempted to turn off a trace flag that was not on. */ #define SYBETRAS 20190 /* DB-Library internal error - trace structure not found. */ #define SYBEPRTF 20191 /* dbtracestring() may only be called from a printfunc(). */ #define SYBETRSN 20192 /* Bad numbytes parameter passed to dbtracestring(). */ #define SYBEBPKS 20193 /* In DBSETLPACKET(), the packet size parameter must be between 0 and 999999. */ #define SYBEIPV 20194 /* %1! is an illegal value for the %2! parameter of %3!. */ #define SYBEMOV 20195 /* Money arithmetic resulted in overflow in function %1!. */ #define SYBEDIVZ 20196 /* Attempt to divide by $0.00 in function %1!. */ #define SYBEASTL 20197 /* Synchronous I/O attempted at AST level. */ #define SYBESEFA 20198 /* DBSETNOTIFS cannot be called if connections are present. */ #define SYBEPOLL 20199 /* Only one dbpoll() can be active at a time. */ #define SYBENOEV 20200 /* dbpoll() cannot be called if registered procedure notifications have been disabled. */ #define SYBEBADPK 20201 /* Packet size of %1! not supported. -- size of %2! used instead. */ #define SYBESECURE 20202 /* Secure Server function not supported in this version. */ #define SYBECAP 20203 /* DB-Library capabilities not accepted by the Server. */ #define SYBEFUNC 20204 /* Functionality not supported at the specified version level. */ #define SYBERESP 20205 /* Response function address passed to dbresponse() must be non-NULL. */ #define SYBEIVERS 20206 /* Illegal version level specified. */ #define SYBEONCE 20207 /* Function can be called only once. */ #define SYBERPNULL 20208 /* value parameter for dbprcparam() can be NULL, only if the datalen parameter is 0 */ #define SYBERPTXTIM 20209 /* RPC parameters cannot be of type Text/Image. */ #define SYBENEG 20210 /* Negotiated login attempt failed. */ #define SYBELBLEN 20211 /* Security labels should be less than 256 characters long. */ #define SYBEUMSG 20212 /* Unknown message-id in MSG datastream. */ #define SYBECAPTYP 20213 /* Unexpected capability type in CAPABILITY datastream. */ #define SYBEBNUM 20214 /* Bad numbytes parameter passed to dbstrcpy() */ #define SYBEBBL 20215 /* Bad bindlen parameter passed to dbsetnull() */ #define SYBEBPREC 20216 /* Illegal precision specified */ #define SYBEBSCALE 20217 /* Illegal scale specified */ #define SYBECDOMAIN 20218 /* Source field value is not within the domain of legal values. */ #define SYBECINTERNAL 20219 /* Internal Conversion error. */ #define SYBEBTYPSRV 20220 /* Datatype is not supported by the server. */ #define SYBEBCSET 20221 /* Unknown character-set encountered." */ #define SYBEFENC 20222 /* Password Encryption failed." */ #define SYBEFRES 20223 /* Challenge-Response function failed.", */ #define SYBEISRVPREC 20224 /* Illegal precision value returned by the server. */ #define SYBEISRVSCL 20225 /* Illegal scale value returned by the server. */ #define SYBEINUMCL 20226 /* Invalid numeric column length returned by the server. */ #define SYBEIDECCL 20227 /* Invalid decimal column length returned by the server. */ #define SYBEBCMTXT 20228 /* bcp_moretext() may be used only when there is at least one text or image column in the server table. */ #define SYBEBCPREC 20229 /* Column %1!: Illegal precision value encountered. */ #define SYBEBCBNPR 20230 /* bcp_bind(): if varaddr is NULL, prefixlen must be 0 and no terminator should be specified. */ #define SYBEBCBNTYP 20231 /* bcp_bind(): if varaddr is NULL and varlen greater than 0, the table column type must be SYBTEXT or SYBIMAGE and the program variable type must be SYBTEXT, SYBCHAR, SYBIMAGE or SYBBINARY. */ #define SYBEBCSNTYP 20232 /* column number %1!: if varaddr is NULL and varlen greater than 0, the table column type must be SYBTEXT or SYBIMAGE and the program variable type must be SYBTEXT, SYBCHAR, SYBIMAGE or SYBBINARY. */ #define SYBEBCPCTYP 20233 /* bcp_colfmt(): If table_colnum is 0, host_type cannot be 0. */ #define SYBEBCVLEN 20234 /* varlen should be greater than or equal to -1. */ #define SYBEBCHLEN 20235 /* host_collen should be greater than or equal to -1. */ #define SYBEBCBPREF 20236 /* Illegal prefix length. Legal values are 0, 1, 2 or 4. */ #define SYBEBCPREF 20237 /* Illegal prefix length. Legal values are -1, 0, 1, 2 or 4. */ #define SYBEBCITBNM 20238 /* bcp_init(): tblname parameter cannot be NULL. */ #define SYBEBCITBLEN 20239 /* bcp_init(): tblname parameter is too long. */ #define SYBEBCSNDROW 20240 /* bcp_sendrow() may NOT be called unless all text data for the previous row has been sent using bcp_moretext(). */ #define SYBEBPROCOL 20241 /* bcp protocol error: returned column count differs from the actual number of columns received. */ #define SYBEBPRODEF 20242 /* bcp protocol error: expected default information and got none. */ #define SYBEBPRONUMDEF 20243 /* bcp protocol error: expected number of defaults differs from the actual number of defaults received. */ #define SYBEBPRODEFID 20244 /* bcp protocol error: default column id and actual column id are not same */ #define SYBEBPRONODEF 20245 /* bcp protocol error: default value received for column that does not have default. */ #define SYBEBPRODEFTYP 20246 /* bcp protocol error: default value datatype differs from column datatype. */ #define SYBEBPROEXTDEF 20247 /* bcp protocol error: more than one row of default information received. */ #define SYBEBPROEXTRES 20248 /* bcp protocol error: unexpected set of results received. */ #define SYBEBPROBADDEF 20249 /* bcp protocol error: illegal default column id received. */ #define SYBEBPROBADTYP 20250 /* bcp protocol error: unknown column datatype. */ #define SYBEBPROBADLEN 20251 /* bcp protocol error: illegal datatype length received. */ #define SYBEBPROBADPREC 20252 /* bcp protocol error: illegal precision value received. */ #define SYBEBPROBADSCL 20253 /* bcp protocol error: illegal scale value received. */ #define SYBEBADTYPE 20254 /* Illegal value for type parameter given to %1!. */ #define SYBECRSNORES 20255 /* Cursor statement generated no results. */ #define SYBECRSNOIND 20256 /* One of the tables involved in the cursor statement does not have a unique index. */ #define SYBECRSVIEW 20257 /* A view cannot be joined with another table or a view in a cursor statement. */ #define SYBECRSVIIND 20258 /* The view used in the cursor statement does not include all the unique index columns of the underlying tables. */ #define SYBECRSORD 20259 /* Only fully keyset driven cursors can have 'order by', ' group by', or 'having' phrases. */ #define SYBECRSBUFR 20260 /* Row buffering should not be turned on when using cursor APIs. */ #define SYBECRSNOFREE 20261 /* The DBNOAUTOFREE option should not be turned on when using cursor APIs. */ #define SYBECRSDIS 20262 /* Cursor statement contains one of the disallowed phrases 'compute', 'union', 'for browse', or 'select into'. */ #define SYBECRSAGR 20263 /* Aggregate functions are not allowed in a cursor statement. */ #define SYBECRSFRAND 20264 /* Fetch types RANDOM and RELATIVE can only be used within the keyset of keyset driven cursors. */ #define SYBECRSFLAST 20265 /* Fetch type LAST requires fully keyset driven cursors. */ #define SYBECRSBROL 20266 /* Backward scrolling cannot be used in a forward scrolling cursor. */ #define SYBECRSFROWN 20267 /* Row number to be fetched is outside valid range. */ #define SYBECRSBSKEY 20268 /* Keyset cannot be scrolled backward in mixed cursors with a previous fetch type. */ #define SYBECRSRO 20269 /* Data locking or modifications cannot be made in a READONLY cursor. */ #define SYBECRSNOCOUNT 20270 /* The DBNOCOUNT option should not be turned on when doing updates or deletes with dbcursor(). */ #define SYBECRSTAB 20271 /* Table name must be determined in operations involving data locking or modifications. */ #define SYBECRSUPDNB 20272 /* Update or insert operations cannot use bind variables when binding type is NOBIND. */ #define SYBECRSNOWHERE 20273 /* A WHERE clause is not allowed in a cursor update or insert. */ #define SYBECRSSET 20274 /* A SET clause is required for a cursor update or insert. */ #define SYBECRSUPDTAB 20275 /* Update or insert operations using bind variables require single table cursors. */ #define SYBECRSNOUPD 20276 /* Update or delete operation did not affect any rows. */ #define SYBECRSINV 20277 /* Invalid cursor statement. */ #define SYBECRSNOKEYS 20278 /* The entire keyset must be defined for KEYSET cursors. */ #define SYBECRSNOBIND 20279 /* Cursor bind must be called prior to updating cursor */ #define SYBECRSFTYPE 20280 /* Unknown fetch type. */ #define SYBECRSINVALID 20281 /* The cursor handle is invalid. */ #define SYBECRSMROWS 20282 /* Multiple rows are returned, only one is expected. */ #define SYBECRSNROWS 20283 /* No rows returned, at least one is expected. */ #define SYBECRSNOLEN 20284 /* No unique index found. */ #define SYBECRSNOPTCC 20285 /* No OPTCC was found. */ #define SYBECRSNORDER 20286 /* The order of clauses must be from, where, and order by. */ #define SYBECRSNOTABLE 20287 /* Table name is NULL. */ #define SYBECRSNUNIQUE 20288 /* No unique keys associated with this view. */ #define SYBECRSVAR 20289 /* There is no valid address associated with this bind. */ #define SYBENOVALUE 20290 /* Security labels require both a name and a value */ #define SYBEVOIDRET 20291 /* Parameter of type SYBVOID cannot be a return parameter. */ #define SYBECLOSEIN 20292 /* Unable to close interface file. */ #define SYBEBOOL 20293 /* Boolean parameters must be TRUE or FALSE. */ #define SYBEBCPOPT 20294 /* The option cannot be called while a bulk copy operation is progress. */ #define SYBEERRLABEL 20295 /* An illegal value was returned from the security label handler. */ #define SYBEATTNACK 20296 /* Timed out waiting for server to acknowledge attention." */ #define SYBEBBFL 20297 /* -001- Batch failed in bulk-copy to SQL Server */ #define SYBEDCL 20298 /* -004- DCL Error */ #define SYBECS 20299 /* -004- cs context Error */ #define SYBEBULKINSERT 20599 /* cannot build bulk insert statement */ #define SYBECOLSIZE 22000 /* Invalid column information structure size */ int dbtds(DBPROCESS * dbprocess); #define DBTDS(a) dbtds(a) DBINT dbtextsize(DBPROCESS * dbprocess); DBBINARY *dbtxptr(DBPROCESS * dbproc, int column); DBBINARY *dbtxtimestamp(DBPROCESS * dbproc, int column); DBBINARY *dbtxtsnewval(DBPROCESS * dbprocess); RETCODE dbtxtsput(DBPROCESS * dbprocess, DBBINARY newtxts, int colnum); RETCODE dbuse(DBPROCESS * dbproc, const char *name); const char *dbversion(void); DBBOOL dbwillconvert(int srctype, int desttype); RETCODE dbwritetext(DBPROCESS * dbproc, char *objname, DBBINARY * textptr, DBTINYINT textptrlen, DBBINARY * timestamp, DBBOOL log, DBINT size, BYTE * text); /* LOGINREC manipulation */ RETCODE dbsetlname(LOGINREC * login, const char *value, int which); RETCODE dbsetlbool(LOGINREC * login, int value, int which); RETCODE dbsetlshort(LOGINREC * login, int value, int which); RETCODE dbsetllong(LOGINREC * login, long value, int which); RETCODE dbsetlversion (LOGINREC * login, BYTE version); #define DBSETHOST 1 #define DBSETLHOST(x,y) dbsetlname((x), (y), DBSETHOST) #define dbsetlhost(x,y) dbsetlname((x), (y), DBSETHOST) #define DBSETUSER 2 #define DBSETLUSER(x,y) dbsetlname((x), (y), DBSETUSER) #define dbsetluser(x,y) dbsetlname((x), (y), DBSETUSER) #define DBSETPWD 3 #define DBSETLPWD(x,y) dbsetlname((x), (y), DBSETPWD) #define dbsetlpwd(x,y) dbsetlname((x), (y), DBSETPWD) #if defined(DBLIB_UNIMPLEMENTED) # define DBSETHID 4 /* not implemented */ # define DBSETLHID(x,y) dbsetlname((x), (y), DBSETHID) #endif #define DBSETAPP 5 #define DBSETLAPP(x,y) dbsetlname((x), (y), DBSETAPP) #define dbsetlapp(x,y) dbsetlname((x), (y), DBSETAPP) #define DBSETBCP 6 #define BCP_SETL(x,y) dbsetlbool((x), (y), DBSETBCP) #define DBSETLSECURE(x) dbsetlbool((x), (1), DBSETBCP) #define DBSETNATLANG 7 #define DBSETLNATLANG(x,y) dbsetlname((x), (y), DBSETNATLANG) #define dbsetlnatlang(x,y) dbsetlname((x), (y), DBSETNATLANG) #if defined(DBLIB_UNIMPLEMENTED) # define DBSETNOSHORT 8 /* not implemented */ # define DBSETLNOSHORT(x,y) dbsetlbool((x), (y), DBSETNOSHORT) # define DBSETHIER 9 /* not implemented */ # define DBSETLHIER(x,y) dbsetlshort((x), (y), DBSETHIER) #endif #define DBSETCHARSET 10 #define DBSETLCHARSET(x,y) dbsetlname((x), (y), DBSETCHARSET) #define DBSETPACKET 11 #define DBSETLPACKET(x,y) dbsetllong((x), (y), DBSETPACKET) #define dbsetlpacket(x,y) dbsetllong((x), (y), DBSETPACKET) #define DBSETENCRYPT 12 #define DBSETLENCRYPT(x,y) dbsetlbool((x), (y), DBSETENCRYPT) #define DBSETLABELED 13 #define DBSETLLABELED(x,y) dbsetlbool((x), (y), DBSETLABELED) #define BCP_SETLABELED(x,y) dbsetlbool((x), (y), DBSETLABELED) #define DBSETDBNAME 14 #define DBSETLDBNAME(x,y) dbsetlname((x), (y), DBSETDBNAME) #define DBSETLVERSION(login, version) dbsetlversion((login), (version)) /* settings from here are purely FreeTDS extensions */ #define DBSETUTF16 1001 #define DBSETLUTF16(x,y) dbsetlbool((x), (y), DBSETUTF16) #define DBSETNTLMV2 1002 #define DBSETLNTLMV2(x,y) dbsetlbool((x), (y), DBSETNTLMV2) #define DBSETREADONLY 1003 #define DBSETLREADONLY(x,y) dbsetlbool((x), (y), DBSETREADONLY) RETCODE bcp_init(DBPROCESS * dbproc, const char *tblname, const char *hfile, const char *errfile, int direction); DBINT bcp_done(DBPROCESS * dbproc); DBINT bcp_batch(DBPROCESS * dbproc); RETCODE bcp_bind(DBPROCESS * dbproc, BYTE * varaddr, int prefixlen, DBINT varlen, BYTE * terminator, int termlen, int type, int table_column); RETCODE bcp_collen(DBPROCESS * dbproc, DBINT varlen, int table_column); RETCODE bcp_columns(DBPROCESS * dbproc, int host_colcount); RETCODE bcp_colfmt(DBPROCESS * dbproc, int host_column, int host_type, int host_prefixlen, DBINT host_collen, const BYTE * host_term, int host_termlen, int colnum); RETCODE bcp_colfmt_ps(DBPROCESS * dbproc, int host_column, int host_type, int host_prefixlen, DBINT host_collen, BYTE * host_term, int host_termlen, int colnum, DBTYPEINFO * typeinfo); RETCODE bcp_colptr(DBPROCESS * dbproc, BYTE * colptr, int table_column); RETCODE bcp_control(DBPROCESS * dbproc, int field, DBINT value); int bcp_getbatchsize(DBPROCESS * dbproc); /* FreeTDS only */ RETCODE bcp_exec(DBPROCESS * dbproc, DBINT * rows_copied); DBBOOL bcp_getl(LOGINREC * login); RETCODE bcp_options(DBPROCESS * dbproc, int option, BYTE * value, int valuelen); RETCODE bcp_readfmt(DBPROCESS * dbproc, const char filename[]); RETCODE bcp_sendrow(DBPROCESS * dbproc); #ifdef __cplusplus #if 0 { #endif } #endif #endif freetds-1.00.82/include/sybfront.h100644 025423 025423 00000002323 12522201763 0012470/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-1999 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef SYBFRONT_h #define SYBFRONT_h #include "sybdb.h" #ifdef __cplusplus extern "C" { #if 0 } #endif #endif static const char rcsid_sybfront_h[] = "$Id: sybfront.h,v 1.3 2004-10-28 12:42:12 freddy77 Exp $"; static const void *const no_unused_sybfront_h_warn[] = { rcsid_sybfront_h, no_unused_sybfront_h_warn }; #ifdef __cplusplus #if 0 { #endif } #endif #endif freetds-1.00.82/include/syberror.h100644 025423 025423 00000002777 12522201763 0012506/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-1999 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef _syberror_h_ #define _syberror_h_ #ifdef __cplusplus extern "C" { #if 0 } #endif #endif static const char rcsid_syberror_h[] = "$Id: syberror.h,v 1.4 2004-10-28 12:42:12 freddy77 Exp $"; static const void *const no_unused_syberror_h_warn[] = { rcsid_syberror_h, no_unused_syberror_h_warn }; /* severity levels, gleaned from google */ #define EXINFO 1 #define EXUSER 2 #define EXNONFATAL 3 #define EXCONVERSION 4 #define EXSERVER 5 #define EXTIME 6 #define EXPROGRAM 7 #define EXRESOURCE 8 #define EXCOMM 9 #define EXFATAL 10 #define EXCONSISTENCY 11 #ifdef __cplusplus #if 0 { #endif } #endif #endif freetds-1.00.82/include/odbcss.h100644 025423 025423 00000024213 12726516341 0012110/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2008 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef _odbcss_h_ #define _odbcss_h_ #ifdef TDSODBC_BCP #include #endif #ifdef __cplusplus extern "C" { #endif #define SQL_DIAG_SS_MSGSTATE (-1150) #define SQL_DIAG_SS_LINE (-1154) #define SQL_SOPT_SS_QUERYNOTIFICATION_TIMEOUT 1233 #define SQL_SOPT_SS_QUERYNOTIFICATION_MSGTEXT 1234 #define SQL_SOPT_SS_QUERYNOTIFICATION_OPTIONS 1235 #ifndef SQL_SS_LENGTH_UNLIMITED #define SQL_SS_LENGTH_UNLIMITED 0 #endif #ifndef SQL_COPT_SS_BASE #define SQL_COPT_SS_BASE 1200 #endif #ifndef SQL_COPT_SS_MARS_ENABLED #define SQL_COPT_SS_MARS_ENABLED (SQL_COPT_SS_BASE+24) #endif #ifndef SQL_COPT_SS_OLDPWD #define SQL_COPT_SS_OLDPWD (SQL_COPT_SS_BASE+26) #endif #define SQL_INFO_FREETDS_TDS_VERSION 1300 #ifndef SQL_MARS_ENABLED_NO #define SQL_MARS_ENABLED_NO 0 #endif #ifndef SQL_MARS_ENABLED_YES #define SQL_MARS_ENABLED_YES 1 #endif #ifndef SQL_SS_VARIANT #define SQL_SS_VARIANT (-150) #endif #ifndef SQL_SS_UDT #define SQL_SS_UDT (-151) #endif #ifndef SQL_SS_XML #define SQL_SS_XML (-152) #endif #ifndef SQL_SS_TABLE #define SQL_SS_TABLE (-153) #endif #ifndef SQL_SS_TIME2 #define SQL_SS_TIME2 (-154) #endif #ifndef SQL_SS_TIMESTAMPOFFSET #define SQL_SS_TIMESTAMPOFFSET (-155) #endif /* * these types are used from conversion from client to server */ #ifndef SQL_C_SS_TIME2 #define SQL_C_SS_TIME2 (0x4000) #endif #ifndef SQL_C_SS_TIMESTAMPOFFSET #define SQL_C_SS_TIMESTAMPOFFSET (0x4001) #endif #ifndef SQL_CA_SS_BASE #define SQL_CA_SS_BASE 1200 #endif #ifndef SQL_CA_SS_UDT_CATALOG_NAME #define SQL_CA_SS_UDT_CATALOG_NAME (SQL_CA_SS_BASE+18) #endif #ifndef SQL_CA_SS_UDT_SCHEMA_NAME #define SQL_CA_SS_UDT_SCHEMA_NAME (SQL_CA_SS_BASE+19) #endif #ifndef SQL_CA_SS_UDT_TYPE_NAME #define SQL_CA_SS_UDT_TYPE_NAME (SQL_CA_SS_BASE+20) #endif #ifndef SQL_CA_SS_UDT_ASSEMBLY_TYPE_NAME #define SQL_CA_SS_UDT_ASSEMBLY_TYPE_NAME (SQL_CA_SS_BASE+21) #endif #ifndef SQL_CA_SS_XML_SCHEMACOLLECTION_CATALOG_NAME #define SQL_CA_SS_XML_SCHEMACOLLECTION_CATALOG_NAME (SQL_CA_SS_BASE+22) #endif #ifndef SQL_CA_SS_XML_SCHEMACOLLECTION_SCHEMA_NAME #define SQL_CA_SS_XML_SCHEMACOLLECTION_SCHEMA_NAME (SQL_CA_SS_BASE+23) #endif #ifndef SQL_CA_SS_XML_SCHEMACOLLECTION_NAME #define SQL_CA_SS_XML_SCHEMACOLLECTION_NAME (SQL_CA_SS_BASE+24) #endif typedef struct tagSS_TIME2_STRUCT { SQLUSMALLINT hour; SQLUSMALLINT minute; SQLUSMALLINT second; SQLUINTEGER fraction; } SQL_SS_TIME2_STRUCT; typedef struct tagSS_TIMESTAMPOFFSET_STRUCT { SQLSMALLINT year; SQLUSMALLINT month; SQLUSMALLINT day; SQLUSMALLINT hour; SQLUSMALLINT minute; SQLUSMALLINT second; SQLUINTEGER fraction; SQLSMALLINT timezone_hour; SQLSMALLINT timezone_minute; } SQL_SS_TIMESTAMPOFFSET_STRUCT; #ifdef TDSODBC_BCP #ifndef SUCCEED #define SUCCEED 1 #endif #ifndef FAIL #define FAIL 0 #endif #ifndef BCPKEEPIDENTITY #define BCPKEEPIDENTITY 8 #endif #ifndef BCPHINTS #define BCPHINTS 6 #endif #define BCP_DIRECTION_IN 1 #define SQL_COPT_SS_BCP (SQL_COPT_SS_BASE+19) #define SQL_BCP_OFF 0 #define SQL_BCP_ON 1 #define SQL_COPT_TDSODBC_IMPL_BASE 1500 #define SQL_COPT_TDSODBC_IMPL_BCP_INITA (SQL_COPT_TDSODBC_IMPL_BASE) #define SQL_COPT_TDSODBC_IMPL_BCP_CONTROL (SQL_COPT_TDSODBC_IMPL_BASE+1) #define SQL_COPT_TDSODBC_IMPL_BCP_COLPTR (SQL_COPT_TDSODBC_IMPL_BASE+2) #define SQL_COPT_TDSODBC_IMPL_BCP_SENDROW (SQL_COPT_TDSODBC_IMPL_BASE+3) #define SQL_COPT_TDSODBC_IMPL_BCP_BATCH (SQL_COPT_TDSODBC_IMPL_BASE+4) #define SQL_COPT_TDSODBC_IMPL_BCP_DONE (SQL_COPT_TDSODBC_IMPL_BASE+5) #define SQL_COPT_TDSODBC_IMPL_BCP_BIND (SQL_COPT_TDSODBC_IMPL_BASE+6) #define SQL_COPT_TDSODBC_IMPL_BCP_INITW (SQL_COPT_TDSODBC_IMPL_BASE+7) #define SQL_VARLEN_DATA -10 /* copied from sybdb.h which was copied from tds.h */ /* TODO find a much better way... */ enum { BCP_TYPE_SQLCHAR = 47, /* 0x2F */ #define BCP_TYPE_SQLCHAR BCP_TYPE_SQLCHAR BCP_TYPE_SQLVARCHAR = 39, /* 0x27 */ #define BCP_TYPE_SQLVARCHAR BCP_TYPE_SQLVARCHAR BCP_TYPE_SQLINTN = 38, /* 0x26 */ #define BCP_TYPE_SQLINTN BCP_TYPE_SQLINTN BCP_TYPE_SQLINT1 = 48, /* 0x30 */ #define BCP_TYPE_SQLINT1 BCP_TYPE_SQLINT1 BCP_TYPE_SQLINT2 = 52, /* 0x34 */ #define BCP_TYPE_SQLINT2 BCP_TYPE_SQLINT2 BCP_TYPE_SQLINT4 = 56, /* 0x38 */ #define BCP_TYPE_SQLINT4 BCP_TYPE_SQLINT4 BCP_TYPE_SQLINT8 = 127, /* 0x7F */ #define BCP_TYPE_SQLINT8 BCP_TYPE_SQLINT8 BCP_TYPE_SQLFLT8 = 62, /* 0x3E */ #define BCP_TYPE_SQLFLT8 BCP_TYPE_SQLFLT8 BCP_TYPE_SQLDATETIME = 61, /* 0x3D */ #define BCP_TYPE_SQLDATETIME BCP_TYPE_SQLDATETIME BCP_TYPE_SQLBIT = 50, /* 0x32 */ #define BCP_TYPE_SQLBIT BCP_TYPE_SQLBIT BCP_TYPE_SQLBITN = 104, /* 0x68 */ #define BCP_TYPE_SQLBITN BCP_TYPE_SQLBITN BCP_TYPE_SQLTEXT = 35, /* 0x23 */ #define BCP_TYPE_SQLTEXT BCP_TYPE_SQLTEXT BCP_TYPE_SQLNTEXT = 99, /* 0x63 */ #define BCP_TYPE_SQLNTEXT BCP_TYPE_SQLNTEXT BCP_TYPE_SQLIMAGE = 34, /* 0x22 */ #define BCP_TYPE_SQLIMAGE BCP_TYPE_SQLIMAGE BCP_TYPE_SQLMONEY4 = 122, /* 0x7A */ #define BCP_TYPE_SQLMONEY4 BCP_TYPE_SQLMONEY4 BCP_TYPE_SQLMONEY = 60, /* 0x3C */ #define BCP_TYPE_SQLMONEY BCP_TYPE_SQLMONEY BCP_TYPE_SQLDATETIME4 = 58, /* 0x3A */ #define BCP_TYPE_SQLDATETIME4 BCP_TYPE_SQLDATETIME4 BCP_TYPE_SQLREAL = 59, /* 0x3B */ BCP_TYPE_SQLFLT4 = 59, /* 0x3B */ #define BCP_TYPE_SQLREAL BCP_TYPE_SQLREAL #define BCP_TYPE_SQLFLT4 BCP_TYPE_SQLFLT4 BCP_TYPE_SQLBINARY = 45, /* 0x2D */ #define BCP_TYPE_SQLBINARY BCP_TYPE_SQLBINARY BCP_TYPE_SQLVOID = 31, /* 0x1F */ #define BCP_TYPE_SQLVOID BCP_TYPE_SQLVOID BCP_TYPE_SQLVARBINARY = 37, /* 0x25 */ #define BCP_TYPE_SQLVARBINARY BCP_TYPE_SQLVARBINARY BCP_TYPE_SQLNUMERIC = 108, /* 0x6C */ #define BCP_TYPE_SQLNUMERIC BCP_TYPE_SQLNUMERIC BCP_TYPE_SQLDECIMAL = 106, /* 0x6A */ #define BCP_TYPE_SQLDECIMAL BCP_TYPE_SQLDECIMAL BCP_TYPE_SQLFLTN = 109, /* 0x6D */ #define BCP_TYPE_SQLFLTN BCP_TYPE_SQLFLTN BCP_TYPE_SQLMONEYN = 110, /* 0x6E */ #define BCP_TYPE_SQLMONEYN BCP_TYPE_SQLMONEYN BCP_TYPE_SQLDATETIMN = 111, /* 0x6F */ #define BCP_TYPE_SQLDATETIMN BCP_TYPE_SQLDATETIMN BCP_TYPE_SQLNVARCHAR = 103, /* 0x67 */ #define BCP_TYPE_SQLNVARCHAR BCP_TYPE_SQLNVARCHAR BCP_TYPE_SQLUNIQUEID = 36, /* 0x24 */ #define BCP_TYPE_SQLUNIQUEID BCP_TYPE_SQLUNIQUEID BCP_TYPE_SQLDATETIME2 = 42, /* 0x2a */ #define BCP_TYPE_SQLDATETIME2 BCP_TYPE_SQLDATETIME2 }; typedef struct { int dtdays; int dttime; } DBDATETIME; #ifdef _MSC_VER #define TDSODBC_INLINE __inline #else #define TDSODBC_INLINE __inline__ #endif struct tdsodbc_impl_bcp_init_params { const void *tblname; const void *hfile; const void *errfile; int direction; }; static TDSODBC_INLINE RETCODE SQL_API bcp_initA(HDBC hdbc, const char *tblname, const char *hfile, const char *errfile, int direction) { struct tdsodbc_impl_bcp_init_params params = {tblname, hfile, errfile, direction}; return SQL_SUCCEEDED(SQLSetConnectAttr(hdbc, SQL_COPT_TDSODBC_IMPL_BCP_INITA, ¶ms, SQL_IS_POINTER)) ? SUCCEED : FAIL; } static TDSODBC_INLINE RETCODE SQL_API bcp_initW(HDBC hdbc, const SQLWCHAR *tblname, const SQLWCHAR *hfile, const SQLWCHAR *errfile, int direction) { struct tdsodbc_impl_bcp_init_params params = {tblname, hfile, errfile, direction}; return SQL_SUCCEEDED(SQLSetConnectAttr(hdbc, SQL_COPT_TDSODBC_IMPL_BCP_INITW, ¶ms, SQL_IS_POINTER)) ? SUCCEED : FAIL; } struct tdsodbc_impl_bcp_control_params { int field; void *value; }; static TDSODBC_INLINE RETCODE SQL_API bcp_control(HDBC hdbc, int field, void *value) { struct tdsodbc_impl_bcp_control_params params = {field, value}; return SQL_SUCCEEDED(SQLSetConnectAttr(hdbc, SQL_COPT_TDSODBC_IMPL_BCP_CONTROL, ¶ms, SQL_IS_POINTER)) ? SUCCEED : FAIL; } struct tdsodbc_impl_bcp_colptr_params { const unsigned char * colptr; int table_column; }; static TDSODBC_INLINE RETCODE SQL_API bcp_colptr(HDBC hdbc, const unsigned char * colptr, int table_column) { struct tdsodbc_impl_bcp_colptr_params params = {colptr, table_column}; return SQL_SUCCEEDED(SQLSetConnectAttr(hdbc, SQL_COPT_TDSODBC_IMPL_BCP_COLPTR, ¶ms, SQL_IS_POINTER)) ? SUCCEED : FAIL; } static TDSODBC_INLINE RETCODE SQL_API bcp_sendrow(HDBC hdbc) { return SQL_SUCCEEDED(SQLSetConnectAttr(hdbc, SQL_COPT_TDSODBC_IMPL_BCP_SENDROW, NULL, SQL_IS_POINTER)) ? SUCCEED : FAIL; } struct tdsodbc_impl_bcp_batch_params { int rows; }; static TDSODBC_INLINE int SQL_API bcp_batch(HDBC hdbc) { struct tdsodbc_impl_bcp_batch_params params = {-1}; return SQL_SUCCEEDED(SQLSetConnectAttr(hdbc, SQL_COPT_TDSODBC_IMPL_BCP_BATCH, ¶ms, SQL_IS_POINTER)) ? params.rows : -1; } struct tdsodbc_impl_bcp_done_params { int rows; }; static TDSODBC_INLINE int SQL_API bcp_done(HDBC hdbc) { struct tdsodbc_impl_bcp_done_params params = {-1}; return SQL_SUCCEEDED(SQLSetConnectAttr(hdbc, SQL_COPT_TDSODBC_IMPL_BCP_DONE, ¶ms, SQL_IS_POINTER)) ? params.rows : -1; } struct tdsodbc_impl_bcp_bind_params { const unsigned char * varaddr; int prefixlen; int varlen; const unsigned char * terminator; int termlen; int vartype; int table_column; }; static TDSODBC_INLINE RETCODE SQL_API bcp_bind(HDBC hdbc, const unsigned char * varaddr, int prefixlen, int varlen, const unsigned char * terminator, int termlen, int vartype, int table_column) { struct tdsodbc_impl_bcp_bind_params params = {varaddr, prefixlen, varlen, terminator, termlen, vartype, table_column}; return SQL_SUCCEEDED(SQLSetConnectAttr(hdbc, SQL_COPT_TDSODBC_IMPL_BCP_BIND, ¶ms, SQL_IS_POINTER)) ? SUCCEED : FAIL; } #ifdef UNICODE #define bcp_init bcp_initW #else #define bcp_init bcp_initA #endif #endif /* TDSODBC_BCP */ #ifdef __cplusplus } #endif #endif /* _odbcss_h_ */ freetds-1.00.82/include/ctlib.h100644 025423 025423 00000014250 13161421220 0011711/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef _ctlib_h_ #define _ctlib_h_ #include #include #include /* * Internal (not part of the exposed API) prototypes and such. */ #include #ifdef __cplusplus extern "C" { #if 0 } #endif #endif /* * internal types */ struct _cs_config { short cs_expose_formats; }; /* Code changed for error handling */ /* Code changes starts here - CT_DIAG - 01 */ /* This structure is used in CT_DIAG */ struct cs_diag_msg_client { CS_CLIENTMSG *clientmsg; struct cs_diag_msg_client *next; }; struct cs_diag_msg_svr { CS_SERVERMSG *servermsg; struct cs_diag_msg_svr *next; }; /* Code changes ends here - CT_DIAG - 01 */ struct cs_diag_msg { CS_CLIENTMSG *msg; struct cs_diag_msg *next; }; struct _cs_context { CS_INT date_convert_fmt; CS_INT cs_errhandletype; CS_INT cs_diag_msglimit; /* added for storing the maximum messages limit CT_DIAG */ /* code changes starts here - CT_DIAG - 02 */ CS_INT cs_diag_msglimit_client; CS_INT cs_diag_msglimit_server; CS_INT cs_diag_msglimit_total; struct cs_diag_msg_client *clientstore; struct cs_diag_msg_svr *svrstore; /* code changes ends here - CT_DIAG - 02 */ struct cs_diag_msg *msgstore; CS_CSLIBMSG_FUNC _cslibmsg_cb; CS_CLIENTMSG_FUNC _clientmsg_cb; CS_SERVERMSG_FUNC _servermsg_cb; /* code changes start here - CS_CONFIG - 01*/ void *userdata; int userdata_len; /* code changes end here - CS_CONFIG - 01*/ TDSCONTEXT *tds_ctx; CS_CONFIG config; }; /* * internal typedefs */ typedef struct _ct_colinfo { TDS_SMALLINT *indicator; } CT_COLINFO; typedef struct _cs_dynamic CS_DYNAMIC; struct _cs_connection { CS_CONTEXT *ctx; TDSLOGIN *tds_login; TDSSOCKET *tds_socket; CS_CLIENTMSG_FUNC _clientmsg_cb; CS_SERVERMSG_FUNC _servermsg_cb; void *userdata; int userdata_len; CS_LOCALE *locale; CS_COMMAND *cmds; CS_DYNAMIC *dynlist; char *server_addr; }; /* * Formerly CSREMOTE_PROC_PARAM, this structure can be used in other * places, too. */ typedef struct _cs_param { struct _cs_param *next; char *name; int status; int datatype; CS_INT maxlen; CS_INT scale; CS_INT precision; CS_INT *datalen; CS_SMALLINT *ind; CS_BYTE *value; int param_by_value; CS_INT datalen_value; CS_SMALLINT indicator_value; } CS_PARAM; /* * Code added for RPC functionality - SUHA * RPC Code changes starts here */ typedef CS_PARAM CSREMOTE_PROC_PARAM; typedef struct _csremote_proc { char *name; CS_SMALLINT options; CSREMOTE_PROC_PARAM *param_list; } CSREMOTE_PROC; /* * Structure CS_COMMAND changed for RPC functionality -SUHA * Added CSREMOTE_PROC *rpc to CS_COMMAND structure */ typedef CS_PARAM CS_DYNAMIC_PARAM; struct _cs_dynamic { struct _cs_dynamic *next; char *id; char *stmt; CS_DYNAMIC_PARAM *param_list; TDSDYNAMIC *tdsdyn; }; /* specific FreeTDS commands */ #define CS_DYNAMIC_CMD 160 #define CS_CUR_CMD 161 /* values for cs_command.results_state */ #define _CS_RES_NONE -1 #define _CS_RES_INIT 0 #define _CS_RES_RESULTSET_EMPTY 1 #define _CS_RES_RESULTSET_ROWS 2 #define _CS_RES_STATUS 3 #define _CS_RES_CMD_DONE 4 #define _CS_RES_CMD_SUCCEED 5 #define _CS_RES_END_RESULTS 6 #define _CS_RES_DESCRIBE_RESULT 7 /* values for cs_command.command_state */ #define _CS_COMMAND_IDLE 0 #define _CS_COMMAND_BUILDING 1 #define _CS_COMMAND_READY 2 #define _CS_COMMAND_SENT 3 /* values for cs_command.cancel_state */ #define _CS_CANCEL_NOCANCEL 0 #define _CS_CANCEL_PENDING 1 struct _cs_command { struct _cs_command *next; CS_INT command_state; CS_INT results_state; CS_INT cancel_state; CS_INT cursor_state; CS_CONNECTION *con; CS_INT command_type; CS_CHAR *query; short dynamic_cmd; CS_DYNAMIC *dyn; int row_prefetched; int curr_result_type; int bind_count; int get_data_item; int get_data_bytes_returned; CS_IODESC *iodesc; CS_INT send_data_started; CSREMOTE_PROC *rpc; CS_PARAM *input_params; CS_INT client_cursor_id; TDSCURSOR *cursor; void *userdata; int userdata_len; }; struct _cs_blkdesc { TDSBCPINFO bcpinfo; }; #define _CS_ERRHAND_INLINE 1 #define _CS_ERRHAND_CB 2 struct _cs_locale { char *language; char *charset; char *time; char *collate; }; /* internal defines for cursor processing */ #define _CS_CURS_TYPE_UNACTIONED 0 #define _CS_CURS_TYPE_REQUESTED 1 #define _CS_CURS_TYPE_SENT 2 /* * internal prototypes */ TDSRET _ct_handle_server_message(const TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE * msgptr); int _ct_handle_client_message(const TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE * msgptr); TDS_SERVER_TYPE _ct_get_server_type(TDSSOCKET *tds, int datatype); int _ct_bind_data(CS_CONTEXT *ctx, TDSRESULTINFO * resinfo, TDSRESULTINFO *bindinfo, CS_INT offset); int _ct_get_client_type(TDSCOLUMN *col); void _ctclient_msg(CS_CONNECTION * con, const char *funcname, int layer, int origin, int severity, int number, const char *fmt, ...); CS_INT _ct_diag_clearmsg(CS_CONTEXT * context, CS_INT type); void _cs_locale_free(CS_LOCALE *locale); CS_LOCALE *_cs_locale_copy(CS_LOCALE *orig); int _cs_locale_copy_inplace(CS_LOCALE *new_locale, CS_LOCALE *orig); int _cs_convert_not_client(CS_CONTEXT *ctx, TDSCOLUMN *curcol, CONV_RESULT *convert_buffer, unsigned char **p_src); #ifdef __cplusplus #if 0 { #endif } #endif #include #endif freetds-1.00.82/include/dblib.h100644 025423 025423 00000012513 12717145107 0011705/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef _dblib_h_ #define _dblib_h_ #include #ifdef __cplusplus extern "C" { #if 0 } #endif #endif typedef enum tag_DB_RESULT_STATE { _DB_RES_INIT , _DB_RES_RESULTSET_EMPTY , _DB_RES_RESULTSET_ROWS , _DB_RES_NEXT_RESULT , _DB_RES_NO_MORE_RESULTS , _DB_RES_SUCCEED } DB_RESULT_STATE; struct tds_dblib_loginrec { TDSLOGIN *tds_login; }; struct dblib_buffer_row; typedef struct tag_DBPROC_ROWBUF { int received; /* how many rows have been received for this result set */ int head; /* queue insertion point */ int tail; /* oldest item in queue */ int current; /* dbnextrow() reads this row */ int capacity; /* how many elements the queue can hold */ struct dblib_buffer_row *rows; /* pointer to the row storage */ } DBPROC_ROWBUF; typedef struct { int host_column; TDS_SERVER_TYPE datatype; int prefix_len; DBINT column_len; BYTE *terminator; int term_len; int tab_colnum; int column_error; } BCP_HOSTCOLINFO; typedef struct { TDS_CHAR *hostfile; TDS_CHAR *errorfile; FILE *bcp_errfileptr; TDS_INT host_colcount; BCP_HOSTCOLINFO **host_columns; TDS_INT firstrow; TDS_INT lastrow; TDS_INT maxerrs; TDS_INT batch; } BCP_HOSTFILEINFO; /* linked list of rpc parameters */ typedef struct _DBREMOTE_PROC_PARAM { struct _DBREMOTE_PROC_PARAM *next; char *name; BYTE status; TDS_SERVER_TYPE type; DBINT maxlen; DBINT datalen; BYTE *value; } DBREMOTE_PROC_PARAM; typedef struct _DBREMOTE_PROC { struct _DBREMOTE_PROC *next; char *name; DBSMALLINT options; DBREMOTE_PROC_PARAM *param_list; } DBREMOTE_PROC; typedef struct dboption { const char *text; DBSTRING *param; DBBOOL factive; } DBOPTION; typedef struct _null_representation { const BYTE *bindval; size_t len; } NULLREP; struct tds_dblib_dbprocess { TDSSOCKET *tds_socket; STATUS row_type; DBPROC_ROWBUF row_buf; int noautofree; int more_results; /* boolean. Are we expecting results? */ DB_RESULT_STATE dbresults_state; int dbresults_retcode; BYTE *user_data; /* see dbsetuserdata() and dbgetuserdata() */ unsigned char *dbbuf; /* is dynamic! */ int dbbufsz; int command_state; TDS_INT text_size; TDS_INT text_sent; DBTYPEINFO typeinfo; unsigned char avail_flag; DBOPTION *dbopts; DBSTRING *dboptcmd; BCP_HOSTFILEINFO *hostfileinfo; TDSBCPINFO *bcpinfo; DBREMOTE_PROC *rpc; DBUSMALLINT envchange_rcv; char dbcurdb[DBMAXNAME + 1]; char servcharset[DBMAXNAME + 1]; FILE *ftos; DB_DBCHKINTR_FUNC chkintr; DB_DBHNDLINTR_FUNC hndlintr; /** boolean use ms behaviour */ int msdblib; int ntimeouts; /** default null values **/ NULLREP nullreps[MAXBINDTYPES]; }; enum { #if MSDBLIB dblib_msdblib = 1 #else dblib_msdblib = 0 #endif }; /* * internal prototypes */ RETCODE dbgetnull(DBPROCESS *dbproc, int bindtype, int varlen, BYTE* varaddr); void copy_data_to_host_var(DBPROCESS * dbproc, TDS_SERVER_TYPE srctype, const BYTE * src, DBINT srclen, BYTE * dest, DBINT destlen, int bindtype, DBINT *indicator); int dbperror (DBPROCESS *dbproc, DBINT msgno, long errnum, ...); int _dblib_handle_info_message(const TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE* msgptr); int _dblib_handle_err_message(const TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE* msgptr); int _dblib_check_and_handle_interrupt(void * vdbproc); void _dblib_setTDS_version(TDSLOGIN * tds_login, DBINT version); void _dblib_convert_err(DBPROCESS * dbproc, TDS_INT len); DBINT _convert_char(int srctype, BYTE * src, int destype, BYTE * dest, DBINT destlen); DBINT _convert_intn(int srctype, BYTE * src, int destype, BYTE * dest, DBINT destlen); RETCODE _bcp_clear_storage(DBPROCESS * dbproc); RETCODE _bcp_get_prog_data(DBPROCESS * dbproc); extern MHANDLEFUNC _dblib_msg_handler; extern EHANDLEFUNC _dblib_err_handler; #define CHECK_PARAMETER(x, msg, ret) if (!(x)) { dbperror(dbproc, (msg), 0); return ret; } #define CHECK_NULP(x, func, param_num, ret) if (!(x)) { dbperror(dbproc, SYBENULP, 0, func, (int) param_num); return ret; } #define CHECK_PARAMETER_NOPROC(x, msg) if (!(x)) { dbperror(NULL, (msg), 0); return FAIL; } #define DBPERROR_RETURN(x, msg) if (x) { dbperror(dbproc, (msg), 0); return FAIL; } #define DBPERROR_RETURN3(x, msg, a, b, c) if (x) { dbperror(dbproc, (msg), 0, a, b, c); return FAIL; } #define CHECK_CONN(ret) do { CHECK_PARAMETER(dbproc, SYBENULL, (ret)); \ if (IS_TDSDEAD(dbproc->tds_socket)) { dbperror(dbproc, SYBEDDNE, 0); return (ret); } } while(0) #ifdef __cplusplus #if 0 { #endif } #endif #include #endif freetds-1.00.82/include/md4.h100644 025423 025423 00000001452 12717145107 0011315#ifndef MD4_H #define MD4_H #ifndef HAVE_NETTLE #include struct MD4Context { TDS_UINT buf[4]; TDS_UINT8 bytes; unsigned char in[64]; }; void MD4Init(struct MD4Context *context); void MD4Update(struct MD4Context *context, unsigned char const *buf, size_t len); void MD4Final(struct MD4Context *context, unsigned char *digest); typedef struct MD4Context MD4_CTX; #include #else #include typedef struct md4_ctx MD4_CTX; static inline void MD4Init(MD4_CTX *ctx) { nettle_md4_init(ctx); } static inline void MD4Update(MD4_CTX *ctx, unsigned char const *buf, size_t len) { nettle_md4_update(ctx, len, buf); } static inline void MD4Final(MD4_CTX *ctx, unsigned char *digest) { nettle_md4_digest(ctx, 16, digest); } #endif #endif /* !MD4_H */ freetds-1.00.82/include/md5.h100644 025423 025423 00000001561 12717145107 0011317#ifndef MD5_H #define MD5_H #ifndef HAVE_NETTLE #include struct MD5Context { TDS_UINT buf[4]; TDS_UINT8 bytes; unsigned char in[64]; }; void MD5Init(struct MD5Context *context); void MD5Update(struct MD5Context *context, unsigned char const *buf, size_t len); void MD5Final(struct MD5Context *context, unsigned char *digest); /* * This is needed to make RSAREF happy on some MS-DOS compilers. */ typedef struct MD5Context MD5_CTX; #include #else #include typedef struct md5_ctx MD5_CTX; static inline void MD5Init(MD5_CTX *ctx) { nettle_md5_init(ctx); } static inline void MD5Update(MD5_CTX *ctx, unsigned char const *buf, size_t len) { nettle_md5_update(ctx, len, buf); } static inline void MD5Final(MD5_CTX *ctx, unsigned char *digest) { nettle_md5_digest(ctx, 16, digest); } #endif #endif /* !MD5_H */ freetds-1.00.82/include/des.h100644 025423 025423 00000001714 12717145107 0011405#ifndef DES_H #define DES_H #ifdef HAVE_NETTLE #include typedef struct des_ctx DES_KEY; #endif #include typedef unsigned char des_cblock[8]; #ifndef HAVE_NETTLE typedef struct des_key { unsigned char kn[16][8]; TDS_UINT sp[8][64]; unsigned char iperm[16][16][8]; unsigned char fperm[16][16][8]; } DES_KEY; int tds_des_set_key(DES_KEY * dkey, const des_cblock user_key, int len); void tds_des_encrypt(DES_KEY * key, des_cblock block); #endif void tds_des_set_odd_parity(des_cblock key); int tds_des_ecb_encrypt(const void *plaintext, int len, DES_KEY * akey, unsigned char *output); #include #ifdef HAVE_NETTLE static inline void tds_des_encrypt(DES_KEY * key, des_cblock block) { nettle_des_encrypt(key, sizeof(des_cblock), block, block); } static inline int tds_des_set_key(DES_KEY * dkey, const des_cblock user_key, int len) { return nettle_des_set_key(dkey, user_key); } #endif #endif /* !DES_H */ freetds-1.00.82/include/hmac_md5.h100644 025423 025423 00000002124 12717145107 0012303/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2008 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef _hmac_md5_h_ #define _hmac_md5_h_ #include void hmac_md5(const unsigned char key[16], const unsigned char* data, size_t data_len, unsigned char* digest); #include #endif freetds-1.00.82/include/replacements.h100644 025423 025423 00000011777 13143020222 0013306/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-1999 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef _replacements_h_ #define _replacements_h_ #include #include "tds_sysdep_public.h" #include #include /* these headers are needed for basename */ #ifdef HAVE_STRING_H # include #endif #ifdef HAVE_LIBGEN_H # include #endif #ifdef HAVE_GETOPT_H # include #endif #if !HAVE_POLL #include #endif /* !HAVE_POLL */ #include #ifdef __cplusplus extern "C" { #endif #if !HAVE_ASPRINTF #undef asprintf int tds_asprintf(char **ret, const char *fmt, ...); #define asprintf tds_asprintf #endif /* !HAVE_ASPRINTF */ #if !HAVE_VASPRINTF #undef vasprintf int tds_vasprintf(char **ret, const char *fmt, va_list ap); #define vasprintf tds_vasprintf #endif /* !HAVE_VASPRINTF */ #if !HAVE_STRTOK_R /* Some MingW define strtok_r macro thread-safe but not reentrant but we need both so avoid using the macro */ #undef strtok_r char *tds_strtok_r(char *str, const char *sep, char **lasts); #define strtok_r tds_strtok_r #endif /* !HAVE_STRTOK_R */ #if !HAVE_STRSEP #undef strsep char *tds_strsep(char **stringp, const char *delim); #define strsep tds_strsep #endif /* !HAVE_STRSEP */ #if !HAVE_STRLCPY size_t tds_strlcpy(char *dest, const char *src, size_t len); #undef strlcpy #define strlcpy(d,s,l) tds_strlcpy(d,s,l) #endif #if !HAVE_GETADDRINFO typedef struct tds_addrinfo { int ai_flags; int ai_family; int ai_socktype; int ai_protocol; size_t ai_addrlen; struct sockaddr *ai_addr; char *ai_canonname; struct tds_addrinfo *ai_next; } tds_addrinfo; int tds_getaddrinfo(const char *node, const char *service, const struct tds_addrinfo *hints, struct tds_addrinfo **res); int tds_getnameinfo(const struct sockaddr *sa, size_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags); void tds_freeaddrinfo(struct tds_addrinfo *addr); #define addrinfo tds_addrinfo #define getaddrinfo(n,s,h,r) tds_getaddrinfo(n,s,h,r) #define getnameinfo(a,b,c,d,e,f,g) tds_getnameinfo(a,b,c,d,e,f,g) #define freeaddrinfo(a) tds_freeaddrinfo(a) #endif #ifndef AI_FQDN #define AI_FQDN 0 #endif #if !HAVE_STRLCAT size_t tds_strlcat(char *dest, const char *src, size_t len); #undef strlcat #define strlcat(d,s,l) tds_strlcat(d,s,l) #endif #if !HAVE_BASENAME char *tds_basename(char *path); #define basename(path) tds_basename(path) #endif /* * Microsoft's C Runtime library is missing strcasecmp and strncasecmp. * Other Win32 C runtime libraries, notably minwg, may define it. * There is no symbol uniquely defined in Microsoft's header files that * can be used by the preprocessor to know whether we're compiling for * Microsoft's library or not (or which version). Thus there's no * way to automatically decide whether or not to define strcasecmp * in terms of stricmp. * * The Microsoft *compiler* defines _MSC_VER. On the assumption that * anyone using their compiler is also using their library, the below * tests check _MSC_VER as a proxy. */ #if defined(_WIN32) # if !defined(strcasecmp) && defined(_MSC_VER) # define strcasecmp(A, B) stricmp((A), (B)) # endif # if !defined(strncasecmp) && defined(_MSC_VER) # define strncasecmp(x,y,z) strnicmp((x),(y),(z)) # endif #undef gettimeofday int tds_gettimeofday (struct timeval *tv, void *tz); #define gettimeofday tds_gettimeofday /* Older Mingw-w64 versions don't define these flags. */ #if defined(__MINGW32__) && !defined(AI_ADDRCONFIG) # define AI_ADDRCONFIG 0x00000400 #endif #if defined(__MINGW32__) && !defined(AI_V4MAPPED) # define AI_V4MAPPED 0x00000800 #endif #endif #if !HAVE_GETOPT #undef getopt int tds_getopt(int argc, char * const argv[], const char *optstring); #define getopt tds_getopt extern char *optarg; extern int optind, offset, opterr, optreset; #endif #if !HAVE_SOCKETPAIR int tds_socketpair(int domain, int type, int protocol, TDS_SYS_SOCKET sv[2]); #define socketpair(d,t,p,s) tds_socketpair(d,t,p,s) #endif #if !HAVE_DAEMON int tds_daemon(int no_chdir, int no_close); #define daemon(d,c) tds_daemon(d,c) #endif char *tds_getpassarg(char *arg); void tds_sleep_s(unsigned sec); void tds_sleep_ms(unsigned ms); #ifdef __cplusplus } #endif #include #endif freetds-1.00.82/include/Makefile.in100644 025423 025423 00000061133 13242511110 0012510# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = include ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = \ $(top_srcdir)/m4/ac_caolan_func_which_gethostbyname_r.m4 \ $(top_srcdir)/m4/ac_have_inaddr_none.m4 \ $(top_srcdir)/m4/ac_have_malloc_options.m4 \ $(top_srcdir)/m4/ac_nullzero.m4 \ $(top_srcdir)/m4/ac_raf_func_which_getservbyname_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_gethostbyaddr_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_getpwuid_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_localtime_r.m4 \ $(top_srcdir)/m4/acx_pthread.m4 \ $(top_srcdir)/m4/ax_cflags_gcc_option.m4 \ $(top_srcdir)/m4/check_openssl.m4 \ $(top_srcdir)/m4/gettimemilli.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/pushlibs.m4 \ $(top_srcdir)/m4/sprintf_i64_format.m4 \ $(top_srcdir)/m4/type_socklen_t.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(include_HEADERS) \ $(noinst_HEADERS) $(am__DIST_COMMON) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = tds_sysdep_public.h CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(includedir)" "$(DESTDIR)$(includedir)" HEADERS = $(include_HEADERS) $(nodist_include_HEADERS) \ $(noinst_HEADERS) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \ $(LISP)config.h.in # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in \ $(srcdir)/tds_sysdep_public.h.in $(top_srcdir)/mkinstalldirs DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BUILD_NUMBER = @BUILD_NUMBER@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOXYGEN = @DOXYGEN@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FREETDS_LIBGCC = @FREETDS_LIBGCC@ FREETDS_ODBC_MODULE = @FREETDS_ODBC_MODULE@ FREETDS_SYMBOLIC = @FREETDS_SYMBOLIC@ GCRYPT_CFLAGS = @GCRYPT_CFLAGS@ GCRYPT_LIBS = @GCRYPT_LIBS@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ HAVE_OPENSSL = @HAVE_OPENSSL@ HAVE_PERL_SOURCES = @HAVE_PERL_SOURCES@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBADD_DL = @LIBADD_DL@ LIBADD_DLD_LINK = @LIBADD_DLD_LINK@ LIBADD_DLOPEN = @LIBADD_DLOPEN@ LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@ LIBICONV = @LIBICONV@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBOBJS = @LTLIBOBJS@ LT_DLLOADERS = @LT_DLLOADERS@ LT_DLPREOPEN = @LT_DLPREOPEN@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ NETTLE_CFLAGS = @NETTLE_CFLAGS@ NETTLE_LIBS = @NETTLE_LIBS@ NETWORK_LIBS = @NETWORK_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ODBC = @ODBC@ ODBCINSTLIB = @ODBCINSTLIB@ ODBCLIB = @ODBCLIB@ ODBCNODMLIB = @ODBCNODMLIB@ ODBCNODMLIBAPP = @ODBCNODMLIBAPP@ ODBC_CONFIG = @ODBC_CONFIG@ ODBC_INC = @ODBC_INC@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ RC = @RC@ READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SUBVERSION = @SUBVERSION@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ dblib_define = @dblib_define@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ tds_sysdep_int16_type = @tds_sysdep_int16_type@ tds_sysdep_int32_type = @tds_sysdep_int32_type@ tds_sysdep_int64_type = @tds_sysdep_int64_type@ tds_sysdep_intptr_type = @tds_sysdep_intptr_type@ tds_sysdep_real32_type = @tds_sysdep_real32_type@ tds_sysdep_real64_type = @tds_sysdep_real64_type@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = 1.5.3 SUBDIRS = freetds include_HEADERS = bkpublic.h \ cspublic.h cstypes.h ctpublic.h \ sqldb.h sqlfront.h \ sybdb.h sybfront.h \ syberror.h odbcss.h nodist_include_HEADERS = tds_sysdep_public.h noinst_HEADERS = ctlib.h \ dblib.h \ md4.h md5.h des.h hmac_md5.h \ replacements.h \ replacements/poll.h \ replacements/readpassphrase.h DISTCLEANFILES = tds_sysdep_public.h all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu include/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu include/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): config.h: stamp-h1 @test -f $@ || rm -f stamp-h1 @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1 stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status include/config.h $(srcdir)/config.h.in: $(am__configure_deps) ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) rm -f stamp-h1 touch $@ distclean-hdr: -rm -f config.h stamp-h1 tds_sysdep_public.h: $(top_builddir)/config.status $(srcdir)/tds_sysdep_public.h.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs install-includeHEADERS: $(include_HEADERS) @$(NORMAL_INSTALL) @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \ $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \ $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \ done uninstall-includeHEADERS: @$(NORMAL_UNINSTALL) @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir) install-nodist_includeHEADERS: $(nodist_include_HEADERS) @$(NORMAL_INSTALL) @list='$(nodist_include_HEADERS)'; test -n "$(includedir)" || list=; \ if test -n "$$list"; then \ echo " $(MKDIR_P) '$(DESTDIR)$(includedir)'"; \ $(MKDIR_P) "$(DESTDIR)$(includedir)" || exit 1; \ fi; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \ $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \ done uninstall-nodist_includeHEADERS: @$(NORMAL_UNINSTALL) @list='$(nodist_include_HEADERS)'; test -n "$(includedir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(includedir)'; $(am__uninstall_files_from_dir) # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile $(HEADERS) config.h installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(includedir)" "$(DESTDIR)$(includedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-recursive -rm -f Makefile distclean-am: clean-am distclean-generic distclean-hdr distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-includeHEADERS install-nodist_includeHEADERS install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-includeHEADERS uninstall-nodist_includeHEADERS .MAKE: $(am__recursive_targets) all install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-generic clean-libtool cscopelist-am ctags \ ctags-am distclean 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-includeHEADERS install-info install-info-am \ install-man install-nodist_includeHEADERS install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs installdirs-am \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am uninstall-includeHEADERS \ uninstall-nodist_includeHEADERS .PRECIOUS: Makefile # 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: freetds-1.00.82/include/config.h.in100644 025423 025423 00000047340 13242511127 0012502/* include/config.h.in. Generated from configure.ac by autoheader. */ /* Define if building universal (internal helper macro) */ #undef AC_APPLE_UNIVERSAL_BUILD /* Define to 1 if you need BSD_COMP defined to get FIONBIO defined. */ #undef BSD_COMP /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP systems. This function is required for `alloca.c' support on those systems. */ #undef CRAY_STACKSEG_END /* Define to 1 if using `alloca.c'. */ #undef C_ALLOCA /* Define to enable work in progress code */ #undef ENABLE_DEVELOPING /* Define to enable extra checks on code */ #undef ENABLE_EXTRA_CHECKS /* Defined if --enable-krb5 used and library detected */ #undef ENABLE_KRB5 /* Define to enable MARS support */ #undef ENABLE_ODBC_MARS /* Define to enable ODBC wide string support */ #undef ENABLE_ODBC_WIDE /* Define to 1 if GNU tls use nettle as backend. */ #undef GNUTLS_USE_NETTLE /* Define to 1 if you have the `alarm' function. */ #undef HAVE_ALARM /* Define to 1 if you have `alloca', as a function or macro. */ #undef HAVE_ALLOCA /* Define to 1 if you have and it should be used (not on Ultrix). */ #undef HAVE_ALLOCA_H /* Define to 1 if you have the header file. */ #undef HAVE_ARPA_INET_H /* Define to 1 if you have the `asprintf' function. */ #undef HAVE_ASPRINTF /* Define to 1 if you have the `basename' function. */ #undef HAVE_BASENAME /* Define if you have the clock_gettime function. */ #undef HAVE_CLOCK_GETTIME /* Define to 1 if you have the header file. */ #undef HAVE_COM_ERR_H /* Define to 1 if you have the `daemon' function. */ #undef HAVE_DAEMON /* Define to 1 if you have the declaration of `cygwin_conv_path', and to 0 if you don't. */ #undef HAVE_DECL_CYGWIN_CONV_PATH /* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. */ #undef HAVE_DECL_TZNAME /* Define to 1 if you have the header file. */ #undef HAVE_DIRENT_H /* Define if you have the GNU dld library. */ #undef HAVE_DLD /* Define to 1 if you have the `dlerror' function. */ #undef HAVE_DLERROR /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H /* Define if you have the _dyld_func_lookup function. */ #undef HAVE_DYLD /* Define to 1 if you have the header file. */ #undef HAVE_ERRNO_H /* Define to 1 if you have the `error_message' function. */ #undef HAVE_ERROR_MESSAGE /* Define to 1 if you have the `eventfd' function. */ #undef HAVE_EVENTFD /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H /* Define to 1 if you have the `fork' function. */ #undef HAVE_FORK /* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ #undef HAVE_FSEEKO /* Define to 1 if you have the `fstat' function. */ #undef HAVE_FSTAT /* Define to 1 if your system provides the 5-parameter version of gethostbyaddr_r(). */ #undef HAVE_FUNC_GETHOSTBYADDR_R_5 /* Define to 1 if your system provides the 7-parameter version of gethostbyaddr_r(). */ #undef HAVE_FUNC_GETHOSTBYADDR_R_7 /* Define to 1 if your system provides the 8-parameter version of gethostbyaddr_r(). */ #undef HAVE_FUNC_GETHOSTBYADDR_R_8 /* Define to 1 if your system provides the 3-parameter version of gethostbyname_r(). */ #undef HAVE_FUNC_GETHOSTBYNAME_R_3 /* Define to 1 if your system provides the 5-parameter version of gethostbyname_r(). */ #undef HAVE_FUNC_GETHOSTBYNAME_R_5 /* Define to 1 if your system provides the 6-parameter version of gethostbyname_r(). */ #undef HAVE_FUNC_GETHOSTBYNAME_R_6 /* Define to 1 if your system provides the 4-parameter version of getpwuid_r(). */ #undef HAVE_FUNC_GETPWUID_R_4 /* Define to 1 if your system getpwuid_r() have 4 parameters and return struct passwd*. */ #undef HAVE_FUNC_GETPWUID_R_4_PW /* Define to 1 if your system provides the 5-parameter version of getpwuid_r(). */ #undef HAVE_FUNC_GETPWUID_R_5 /* Define to 1 if your system provides the 4-parameter version of getservbyname_r(). */ #undef HAVE_FUNC_GETSERVBYNAME_R_4 /* Define to 1 if your system provides the 5-parameter version of getservbyname_r(). */ #undef HAVE_FUNC_GETSERVBYNAME_R_5 /* Define to 1 if your system provides the 6-parameter version of getservbyname_r(). */ #undef HAVE_FUNC_GETSERVBYNAME_R_6 /* Define to 1 if your localtime_r return a int. */ #undef HAVE_FUNC_LOCALTIME_R_INT /* Define to 1 if your localtime_r return a struct tm*. */ #undef HAVE_FUNC_LOCALTIME_R_TM /* Define if you have getaddrinfo function */ #undef HAVE_GETADDRINFO /* Define to 1 if you have the `gethostname' function. */ #undef HAVE_GETHOSTNAME /* Define to 1 if you have the `gethrtime' function. */ #undef HAVE_GETHRTIME /* Define to 1 if you have the `getipnodebyaddr' function. */ #undef HAVE_GETIPNODEBYADDR /* Define to 1 if you have the `getipnodebyname' function. */ #undef HAVE_GETIPNODEBYNAME /* Define to 1 if you have the `getopt' function. */ #undef HAVE_GETOPT /* Define to 1 if you have the header file. */ #undef HAVE_GETOPT_H /* Define if your getopt(3) defines and uses optreset */ #undef HAVE_GETOPT_OPTRESET /* Define to 1 if you have the `getpwuid' function. */ #undef HAVE_GETPWUID /* Define to 1 if you have the `getpwuid_r' function. */ #undef HAVE_GETPWUID_R /* Define to 1 if you have the `gettimeofday' function. */ #undef HAVE_GETTIMEOFDAY /* Define to 1 if you have the `getuid' function. */ #undef HAVE_GETUID /* Define if you have GMP library */ #undef HAVE_GMP /* Define to 1 if you have GnuTLS. */ #undef HAVE_GNUTLS /* Define to 1 if you have the header file. */ #undef HAVE_GNUTLS_ABSTRACT_H /* Define to 1 if you have the `gnutls_certificate_set_verify_function' function. */ #undef HAVE_GNUTLS_CERTIFICATE_SET_VERIFY_FUNCTION /* Define to 1 if you have the `gnutls_record_disable_padding' function. */ #undef HAVE_GNUTLS_RECORD_DISABLE_PADDING /* Define to 1 if you have the `gnutls_rnd' function. */ #undef HAVE_GNUTLS_RND /* Define if you have the iconv() function and it works. */ #undef HAVE_ICONV /* Define to 1 if you have the `inet_ntoa_r' function. */ #undef HAVE_INET_NTOA_R /* Define to 1 if you have the `inet_ntop' function. */ #undef HAVE_INET_NTOP /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_IODBCINST_H /* Define to 1 if you have the header file. */ #undef HAVE_LANGINFO_H /* Define if you have the libdl library or equivalent. */ #undef HAVE_LIBDL /* Define if libdlloader will be built on this platform */ #undef HAVE_LIBDLLOADER /* Define to 1 if you have the header file. */ #undef HAVE_LIBGEN_H /* Define to 1 if you have the header file. */ #undef HAVE_LIMITS_H /* Define to 1 if you have the header file. */ #undef HAVE_LOCALCHARSET_H /* Define to 1 if you have the `locale_charset' function. */ #undef HAVE_LOCALE_CHARSET /* Define to 1 if you have the header file. */ #undef HAVE_LOCALE_H /* Define to 1 if you have the `localtime_r' function. */ #undef HAVE_LOCALTIME_R /* Define to 1 if you have the header file. */ #undef HAVE_MALLOC_H /* Define to 1 if your system provides the malloc_options variable. */ #undef HAVE_MALLOC_OPTIONS /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `nanosleep' function. */ #undef HAVE_NANOSLEEP /* Define to 1 if you have the header file. */ #undef HAVE_NETDB_H /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_IN_H /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_TCP_H /* Define to 1 if nettle is present. */ #undef HAVE_NETTLE /* Define to 1 if you have the `nl_langinfo' function. */ #undef HAVE_NL_LANGINFO /* Define if you have the OpenSSL. */ #undef HAVE_OPENSSL /* Define to 1 if you have the header file. */ #undef HAVE_PATHS_H /* Define to 1 if you have the `poll' function. */ #undef HAVE_POLL /* Define to 1 if you have the header file. */ #undef HAVE_POLL_H /* Define if you have POSIX threads libraries and header files. */ #undef HAVE_PTHREAD /* Define to 1 if you have the `pthread_condattr_setclock' function. */ #undef HAVE_PTHREAD_CONDATTR_SETCLOCK /* Define to 1 if you have the `pthread_cond_timedwait' function. */ #undef HAVE_PTHREAD_COND_TIMEDWAIT /* Define to 1 if you have the `pthread_cond_timedwait_relative_np' function. */ #undef HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP /* Define to 1 if you have the `putenv' function. */ #undef HAVE_PUTENV /* Define to 1 if you have the `readdir_r' function. */ #undef HAVE_READDIR_R /* Define to 1 if you have the GNU Readline library. */ #undef HAVE_READLINE /* Define to 1 if you have the `readpassphrase' function. */ #undef HAVE_READPASSPHRASE /* Define to 1 if you have rl_inhibit_completion. */ #undef HAVE_RL_INHIBIT_COMPLETION /* Define to 1 if you have the `rl_on_new_line' function. */ #undef HAVE_RL_ON_NEW_LINE /* Define to 1 if you have the `rl_reset_line_state' function. */ #undef HAVE_RL_RESET_LINE_STATE /* Define to 1 if you have the header file. */ #undef HAVE_ROKEN_H /* Define to 1 if you have the `setenv' function. */ #undef HAVE_SETENV /* Define to 1 if you have the `setitimer' function. */ #undef HAVE_SETITIMER /* Define to 1 if you have the `setrlimit' function. */ #undef HAVE_SETRLIMIT /* Define if you have the shl_load function. */ #undef HAVE_SHL_LOAD /* Define to 1 if you have the header file. */ #undef HAVE_SIGNAL_H /* Define to 1 if you have the `socketpair' function. */ #undef HAVE_SOCKETPAIR /* Define to 1 if you have the SQLGetPrivateProfileString function. */ #undef HAVE_SQLGETPRIVATEPROFILESTRING /* Define if sqltypes.h define SQLLEN */ #undef HAVE_SQLLEN /* Define to 1 if the system has the type `SQLROWOFFSET'. */ #undef HAVE_SQLROWOFFSET /* Define to 1 if the system has the type `SQLROWSETSIZE'. */ #undef HAVE_SQLROWSETSIZE /* Define to 1 if the system has the type `SQLSETPOSIROW'. */ #undef HAVE_SQLSETPOSIROW /* Define to 1 if you have the header file. */ #undef HAVE_SQL_H /* Defined if not --disable-sspi and SSPI detected */ #undef HAVE_SSPI /* Define to 1 if you have the header file. */ #undef HAVE_STDBOOL_H /* Define to 1 if you have the header file. */ #undef HAVE_STDDEF_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the `strlcat' function. */ #undef HAVE_STRLCAT /* Define to 1 if you have the `strlcpy' function. */ #undef HAVE_STRLCPY /* Define to 1 if you have the `strsep' function. */ #undef HAVE_STRSEP /* Define to 1 if you have the `strtok_r' function. */ #undef HAVE_STRTOK_R /* Define to 1 if `tm_zone' is a member of `struct tm'. */ #undef HAVE_STRUCT_TM_TM_ZONE /* Define to 1 if `__tm_zone' is a member of `struct tm'. */ #undef HAVE_STRUCT_TM___TM_ZONE /* Define to 1 if you have the header file. */ #undef HAVE_SYS_EVENTFD_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_IOCTL_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_PARAM_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_RESOURCE_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SELECT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SOCKET_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_WAIT_H /* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use `HAVE_STRUCT_TM_TM_ZONE' instead. */ #undef HAVE_TM_ZONE /* Define to 1 if you don't have `tm_zone' but do have the external array `tzname'. */ #undef HAVE_TZNAME /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have the `usleep' function. */ #undef HAVE_USLEEP /* Define to 1 if you have the header file. */ #undef HAVE_VALGRIND_MEMCHECK_H /* Define to 1 if you have the `vasprintf' function. */ #undef HAVE_VASPRINTF /* Define to 1 if you have the `vsnprintf' function. */ #undef HAVE_VSNPRINTF /* Define to 1 if you have the header file. */ #undef HAVE_WCHAR_H /* Define to 1 if you have the header file. */ #undef HAVE_WINDOWS_H /* Define to 1 if you have the header file. */ #undef HAVE_WINSOCK2_H /* Define to 1 if you have the `_fseeki64' function. */ #undef HAVE__FSEEKI64 /* Define to 1 if you have the `_ftelli64' function. */ #undef HAVE__FTELLI64 /* Define to 1 if you have the `_lock_file' function. */ #undef HAVE__LOCK_FILE /* Define to 1 if you have the `_unlock_file' function. */ #undef HAVE__UNLOCK_FILE /* Define to 1 if you have the `_vscprintf' function. */ #undef HAVE__VSCPRINTF /* Define to 1 if you have the `_vsnprintf' function. */ #undef HAVE__VSNPRINTF /* Define to 1 if you have the `_xpg_accept' function. */ #undef HAVE__XPG_ACCEPT /* Define to 1 if you have the `_xpg_getpeername' function. */ #undef HAVE__XPG_GETPEERNAME /* Define to 1 if you have the `_xpg_getsockname' function. */ #undef HAVE__XPG_GETSOCKNAME /* Define to 1 if you have the `_xpg_getsockopt' function. */ #undef HAVE__XPG_GETSOCKOPT /* Define to 1 if you have the `_xpg_recvfrom' function. */ #undef HAVE__XPG_RECVFROM /* Define to 1 if you have the `__accept' function. */ #undef HAVE___ACCEPT /* Define to 1 if you have the `__getpeername' function. */ #undef HAVE___GETPEERNAME /* Define to 1 if you have the `__getsockname' function. */ #undef HAVE___GETSOCKNAME /* Define to 1 if you have the `__getsockopt' function. */ #undef HAVE___GETSOCKOPT /* Define to 1 if you have the `__recvfrom' function. */ #undef HAVE___RECVFROM /* Define as const if the declaration of iconv() needs const. */ #undef ICONV_CONST /* Define to value of INADDR_NONE if not provided by your system header files. */ #undef INADDR_NONE /* Define to the sub-directory where libtool stores uninstalled libraries. */ #undef LT_OBJDIR /* Define to 1 if the BSD-style netdb interface is reentrant. */ #undef NETDB_REENTRANT /* Define to 1 if memset(0) sets pointers to NULL. */ #undef NULL_REP_IS_ZERO_BYTES /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to necessary symbol if this constant uses a non-standard name on your system. */ #undef PTHREAD_CREATE_JOINABLE /* The size of `char', as computed by sizeof. */ #undef SIZEOF_CHAR /* The size of `double', as computed by sizeof. */ #undef SIZEOF_DOUBLE /* The size of `float', as computed by sizeof. */ #undef SIZEOF_FLOAT /* The size of `int', as computed by sizeof. */ #undef SIZEOF_INT /* The size of `long', as computed by sizeof. */ #undef SIZEOF_LONG /* The size of `long double', as computed by sizeof. */ #undef SIZEOF_LONG_DOUBLE /* The size of `long long', as computed by sizeof. */ #undef SIZEOF_LONG_LONG /* The size of `short', as computed by sizeof. */ #undef SIZEOF_SHORT /* The size of `SQLWCHAR', as computed by sizeof. */ #undef SIZEOF_SQLWCHAR /* The size of `void *', as computed by sizeof. */ #undef SIZEOF_VOID_P /* The size of `wchar_t', as computed by sizeof. */ #undef SIZEOF_WCHAR_T /* The size of `__int64', as computed by sizeof. */ #undef SIZEOF___INT64 /* If using the C implementation of alloca, define if you know the direction of stack growth for your system; otherwise it will be automatically deduced at runtime. STACK_DIRECTION > 0 => grows toward higher addresses STACK_DIRECTION < 0 => grows toward lower addresses STACK_DIRECTION = 0 => direction of growth unknown */ #undef STACK_DIRECTION /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define to use TDS 4.2 by default */ #undef TDS42 /* Define to use TDS 4.6 by default */ #undef TDS46 /* Define to use TDS 5.0 by default */ #undef TDS50 /* Define to use TDS 7.0 by default */ #undef TDS70 /* Define to use TDS 7.1 by default */ #undef TDS71 /* Define to use TDS 7.2 by default */ #undef TDS72 /* Define to use TDS 7.3 by default */ #undef TDS73 /* Define to use TDS 7.4 by default */ #undef TDS74 /* Define to 1 if your compiler supports __attribute__((destructor)). */ #undef TDS_ATTRIBUTE_DESTRUCTOR /* define to constant to use for clock_gettime */ #undef TDS_GETTIMEMILLI_CONST /* Define if you have pthread with mutex support */ #undef TDS_HAVE_PTHREAD_MUTEX /* Define if stdio support locking */ #undef TDS_HAVE_STDIO_LOCKED /* define to prefix format string used for 64bit integers */ #undef TDS_I64_PREFIX /* Define if you don't care about thread safety */ #undef TDS_NO_THREADSAFE /* Define to 1 if last argument of SQLColAttribute it's SQLLEN * */ #undef TDS_SQLCOLATTRIBUTE_SQLLEN /* Define to 1 if SQLParamOptions accept SQLULEN as arguments */ #undef TDS_SQLPARAMOPTIONS_SQLLEN /* Defined if --enable-sybase-compat used */ #undef TDS_SYBASE_COMPAT /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Define to 1 if your declares `struct tm'. */ #undef TM_IN_SYS_TIME /* Enable extensions on AIX 3, Interix. */ #ifndef _ALL_SOURCE # undef _ALL_SOURCE #endif /* Enable GNU extensions on systems that have them. */ #ifndef _GNU_SOURCE # undef _GNU_SOURCE #endif /* Enable threading extensions on Solaris. */ #ifndef _POSIX_PTHREAD_SEMANTICS # undef _POSIX_PTHREAD_SEMANTICS #endif /* Enable extensions on HP NonStop. */ #ifndef _TANDEM_SOURCE # undef _TANDEM_SOURCE #endif /* Enable general extensions on Solaris. */ #ifndef __EXTENSIONS__ # undef __EXTENSIONS__ #endif /* Version number of package */ #undef VERSION /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel). */ #if defined AC_APPLE_UNIVERSAL_BUILD # if defined __BIG_ENDIAN__ # define WORDS_BIGENDIAN 1 # endif #else # ifndef WORDS_BIGENDIAN # undef WORDS_BIGENDIAN # endif #endif /* Enable large inode numbers on Mac OS X 10.5. */ #ifndef _DARWIN_USE_64_BIT_INODE # define _DARWIN_USE_64_BIT_INODE 1 #endif /* Number of bits in a file offset, on hosts where this is settable. */ #undef _FILE_OFFSET_BITS /* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */ #undef _LARGEFILE_SOURCE /* Define for large files, on AIX-style hosts. */ #undef _LARGE_FILES /* Define to 1 if on MINIX. */ #undef _MINIX /* Define to 2 if the system does not provide POSIX.1 features except with this defined. */ #undef _POSIX_1_SOURCE /* Define to 1 if you need to in order for `stat' and other things to work. */ #undef _POSIX_SOURCE /* Define to empty if `const' does not conform to ANSI C. */ #undef const /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ #ifndef __cplusplus #undef inline #endif /* Define to `unsigned int' if does not define. */ #undef size_t /* type to use in place of socklen_t if not defined */ #undef socklen_t freetds-1.00.82/include/tds_sysdep_public.h.in100644 025423 025423 00000005161 12717145107 0014756/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-2011 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef _tds_sysdep_public_h_ #define _tds_sysdep_public_h_ /* ** This is where platform-specific changes need to be made. */ #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) #include #include #include #define tds_sysdep_int16_type short /* 16-bit int */ #define tds_sysdep_int32_type int /* 32-bit int */ #define tds_sysdep_int64_type __int64 /* 64-bit int */ #define tds_sysdep_real32_type float /* 32-bit real */ #define tds_sysdep_real64_type double /* 64-bit real */ #if !defined(WIN64) && !defined(_WIN64) #define tds_sysdep_intptr_type int /* 32-bit int */ #else #define tds_sysdep_intptr_type __int64 /* 64-bit int */ #endif #endif /* defined(WIN32) || defined(_WIN32) || defined(__WIN32__) */ #ifndef tds_sysdep_int16_type #define tds_sysdep_int16_type @tds_sysdep_int16_type@ /* 16-bit int */ #endif /* !tds_sysdep_int16_type */ #ifndef tds_sysdep_int32_type #define tds_sysdep_int32_type @tds_sysdep_int32_type@ /* 32-bit int */ #endif /* !tds_sysdep_int32_type */ #ifndef tds_sysdep_int64_type #define tds_sysdep_int64_type @tds_sysdep_int64_type@ /* 64-bit int */ #endif /* !tds_sysdep_int64_type */ #ifndef tds_sysdep_real32_type #define tds_sysdep_real32_type @tds_sysdep_real32_type@ /* 32-bit real */ #endif /* !tds_sysdep_real32_type */ #ifndef tds_sysdep_real64_type #define tds_sysdep_real64_type @tds_sysdep_real64_type@ /* 64-bit real */ #endif /* !tds_sysdep_real64_type */ #ifndef tds_sysdep_intptr_type #define tds_sysdep_intptr_type @tds_sysdep_intptr_type@ #endif /* !tds_sysdep_intptr_type */ #if !defined(MSDBLIB) && !defined(SYBDBLIB) @dblib_define@ #endif #if defined(MSDBLIB) && defined(SYBDBLIB) #error MSDBLIB and SYBDBLIB cannot both be defined #endif #endif /* _tds_sysdep_public_h_ */ freetds-1.00.82/include/freetds/Makefile.am100644 025423 025423 00000000572 12717145107 0014152 noinst_HEADERS = iconv.h string.h convert.h bytes.h \ thread.h proto.h tds.h odbc.h version.h server.h \ configs.h enum_cap.h sysdep_private.h stream.h \ data.h pushvis.h popvis.h time.h tls.h bool.h \ checks.h dlist.h dlist.tmpl.h alloca.h DISTCLEANFILES = sysconfdir.h sysconfdir.h: Makefile echo '#define FREETDS_SYSCONFDIR "$(sysconfdir)"' >$@ all-am: sysconfdir.h freetds-1.00.82/include/freetds/iconv.h100644 025423 025423 00000006613 12717145107 0013407/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2002, 2003, 2004 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef _tds_iconv_h_ #define _tds_iconv_h_ #if HAVE_ICONV #include #else /* Define iconv_t for src/replacements/iconv.c. */ #undef iconv_t typedef void *iconv_t; #endif /* HAVE_ICONV */ #if HAVE_ERRNO_H #include #endif #if HAVE_WCHAR_H #include #endif /* The following EILSEQ advice is borrowed verbatim from GNU iconv. */ /* Some systems, like SunOS 4, don't have EILSEQ. Some systems, like BSD/OS, have EILSEQ in a different header. On these systems, define EILSEQ ourselves. */ #ifndef EILSEQ # define EILSEQ ENOENT #endif #if HAVE_STDLIB_H #include #endif /* HAVE_STDLIB_H */ #include #ifdef __cplusplus extern "C" { #endif #if ! HAVE_ICONV iconv_t tds_sys_iconv_open(const char *tocode, const char *fromcode); size_t tds_sys_iconv(iconv_t cd, const char **inbuf, size_t * inbytesleft, char **outbuf, size_t * outbytesleft); int tds_sys_iconv_close(iconv_t cd); #else #define tds_sys_iconv_open iconv_open #define tds_sys_iconv iconv #define tds_sys_iconv_close iconv_close #endif /* !HAVE_ICONV */ typedef enum { to_server, to_client } TDS_ICONV_DIRECTION; typedef struct _character_set_alias { const char *alias; int canonic; } CHARACTER_SET_ALIAS; typedef struct tds_errno_message_flags { unsigned int e2big:1; unsigned int eilseq:1; unsigned int einval:1; } TDS_ERRNO_MESSAGE_FLAGS; typedef struct tdsiconvdir { TDS_ENCODING charset; iconv_t cd; } TDSICONVDIR; struct tdsiconvinfo { struct tdsiconvdir to, from; #define TDS_ENCODING_MEMCPY 1 unsigned int flags; /* * Suppress error messages that would otherwise be emitted by tds_iconv(). * Functions that process large buffers ask tds_iconv to convert it in "chunks". * We don't want to emit spurious EILSEQ errors or multiple errors for one * buffer. tds_iconv() checks this structure before emiting a message, and * adds to it whenever it emits one. Callers that handle a particular situation themselves * can prepopulate it. */ TDS_ERRNO_MESSAGE_FLAGS suppress; }; /* We use ICONV_CONST for tds_iconv(), even if we don't have iconv() */ #ifndef ICONV_CONST # define ICONV_CONST const #endif size_t tds_iconv(TDSSOCKET * tds, TDSICONV * char_conv, TDS_ICONV_DIRECTION io, const char **inbuf, size_t * inbytesleft, char **outbuf, size_t * outbytesleft); const char *tds_canonical_charset_name(const char *charset_name); TDSICONV *tds_iconv_get(TDSCONNECTION * conn, const char *client_charset, const char *server_charset); #ifdef __cplusplus } #endif #include #endif /* _tds_iconv_h_ */ freetds-1.00.82/include/freetds/string.h100644 025423 025423 00000004761 12717145107 0013601/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef _tdsstring_h_ #define _tdsstring_h_ #include /** \addtogroup dstring * @{ */ /** Internal representation for an empty string */ extern const struct tds_dstr tds_str_empty; /** Initializer, used to initialize string like in the following example * @code * DSTR s = DSTR_INITIALIZER; * @endcode */ #define DSTR_INITIALIZER ((struct tds_dstr*) &tds_str_empty) /** init a string with empty */ static inline void tds_dstr_init(DSTR * s) { *(s) = DSTR_INITIALIZER; } /** test if string is empty */ static inline int tds_dstr_isempty(DSTR * s) { return (*s)->dstr_size == 0; } /** * Returns a buffer to edit the string. * Be careful to avoid buffer overflows and remember to * set the correct length at the end of the editing if changed. */ static inline char * tds_dstr_buf(DSTR * s) { return (*s)->dstr_s; } /** Returns a C version (NUL terminated string) of dstr */ static inline const char * tds_dstr_cstr(DSTR * s) { return (*s)->dstr_s; } /** Returns the length of the string in bytes */ static inline size_t tds_dstr_len(DSTR * s) { return (*s)->dstr_size; } /** Make a string empty */ #define tds_dstr_empty(s) \ tds_dstr_free(s) void tds_dstr_zero(DSTR * s); void tds_dstr_free(DSTR * s); DSTR* tds_dstr_dup(DSTR * s, const DSTR * src) TDS_WUR; DSTR* tds_dstr_copy(DSTR * s, const char *src) TDS_WUR; DSTR* tds_dstr_copyn(DSTR * s, const char *src, size_t length) TDS_WUR; DSTR* tds_dstr_set(DSTR * s, char *src) TDS_WUR; DSTR* tds_dstr_setlen(DSTR *s, size_t length); DSTR* tds_dstr_alloc(DSTR *s, size_t length) TDS_WUR; /** @} */ #include #endif /* _tdsstring_h_ */ freetds-1.00.82/include/freetds/convert.h100644 025423 025423 00000004770 12717145107 0013753/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-1999 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef _tdsconvert_h_ #define _tdsconvert_h_ #include #ifdef __cplusplus extern "C" { #if 0 } #endif #endif typedef union conv_result { /* fixed */ TDS_TINYINT ti; TDS_SMALLINT si; TDS_USMALLINT usi; TDS_INT i; TDS_UINT ui; TDS_INT8 bi; TDS_UINT8 ubi; TDS_FLOAT f; TDS_REAL r; TDS_MONEY m; TDS_MONEY4 m4; TDS_DATETIME dt; TDS_DATETIME4 dt4; TDS_DATETIMEALL dta; TDS_TIME time; TDS_DATE date; TDS_BIGTIME bigtime; TDS_BIGDATETIME bigdatetime; TDS_NUMERIC n; TDS_UNIQUE u; /* variable */ TDS_CHAR *c; TDS_CHAR *ib; /* sized buffer types */ struct cc_t { TDS_CHAR *c; TDS_UINT len; } cc; struct cb_t { TDS_CHAR *ib; TDS_UINT len; } cb; } CONV_RESULT; /* * Failure return codes for tds_convert() */ #define TDS_CONVERT_FAIL -1 /* unspecified failure */ #define TDS_CONVERT_NOAVAIL -2 /* conversion does not exist */ #define TDS_CONVERT_SYNTAX -3 /* syntax error in source field */ #define TDS_CONVERT_NOMEM -4 /* insufficient memory */ #define TDS_CONVERT_OVERFLOW -5 /* result too large */ /* sized types */ #define TDS_CONVERT_CHAR 256 #define TDS_CONVERT_BINARY 257 unsigned char tds_willconvert(int srctype, int desttype); TDS_SERVER_TYPE tds_get_null_type(TDS_SERVER_TYPE srctype); TDS_INT tds_char2hex(TDS_CHAR *dest, TDS_UINT destlen, const TDS_CHAR * src, TDS_UINT srclen); TDS_INT tds_convert(const TDSCONTEXT * context, int srctype, const TDS_CHAR * src, TDS_UINT srclen, int desttype, CONV_RESULT * cr); size_t tds_strftime(char *buf, size_t maxsize, const char *format, const TDSDATEREC * timeptr, int prec); #ifdef __cplusplus #if 0 { #endif } #endif #include #endif /* _tdsconvert_h_ */ freetds-1.00.82/include/freetds/bytes.h100644 025423 025423 00000021221 12717145107 0013407/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2005-2008 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef _tdsbytes_h_ #define _tdsbytes_h_ #ifndef _tds_h_ #error tds.h must be included before bytes.h #endif /* * read a word of n bytes aligned, architecture dependent endian * TDS_GET_An * read a word of n bytes aligned, little endian * TDS_GET_AnLE * read a word of n bytes aligned, big endian * TDS_GET_AnBE * read a word of n bytes unaligned, architecture dependent endian * TDS_GET_UAn * read a word of n bytes unaligned, little endian * TDS_GET_UAnLE * read a word of n bytes unaligned, big endian * TDS_GET_UAnBE */ /* TODO optimize (use swap, unaligned platforms) */ /* one byte, easy... */ #define TDS_GET_A1LE(ptr) (((TDS_UCHAR*)(ptr))[0]) #define TDS_GET_A1BE(ptr) TDS_GET_A1LE(ptr) #define TDS_GET_UA1LE(ptr) TDS_GET_A1LE(ptr) #define TDS_GET_UA1BE(ptr) TDS_GET_A1LE(ptr) #define TDS_PUT_A1LE(ptr,val) do { ((TDS_UCHAR*)(ptr))[0] = (val); } while(0) #define TDS_PUT_A1BE(ptr,val) TDS_PUT_A1LE(ptr,val) #define TDS_PUT_UA1LE(ptr,val) TDS_PUT_A1LE(ptr,val) #define TDS_PUT_UA1BE(ptr,val) TDS_PUT_A1LE(ptr,val) /* two bytes */ #define TDS_GET_UA2LE(ptr) (((TDS_UCHAR*)(ptr))[1] * 0x100u + ((TDS_UCHAR*)(ptr))[0]) #define TDS_GET_UA2BE(ptr) (((TDS_UCHAR*)(ptr))[0] * 0x100u + ((TDS_UCHAR*)(ptr))[1]) #define TDS_GET_A2LE(ptr) TDS_GET_UA2LE(ptr) #define TDS_GET_A2BE(ptr) TDS_GET_UA2BE(ptr) #define TDS_PUT_UA2LE(ptr,val) do {\ ((TDS_UCHAR*)(ptr))[1] = (TDS_UCHAR)((val)>>8); ((TDS_UCHAR*)(ptr))[0] = (TDS_UCHAR)(val); } while(0) #define TDS_PUT_UA2BE(ptr,val) do {\ ((TDS_UCHAR*)(ptr))[0] = (TDS_UCHAR)((val)>>8); ((TDS_UCHAR*)(ptr))[1] = (TDS_UCHAR)(val); } while(0) #define TDS_PUT_A2LE(ptr,val) TDS_PUT_UA2LE(ptr,val) #define TDS_PUT_A2BE(ptr,val) TDS_PUT_UA2BE(ptr,val) /* four bytes */ #define TDS_GET_UA4LE(ptr) \ (((TDS_UCHAR*)(ptr))[3] * 0x1000000u + ((TDS_UCHAR*)(ptr))[2] * 0x10000u +\ ((TDS_UCHAR*)(ptr))[1] * 0x100u + ((TDS_UCHAR*)(ptr))[0]) #define TDS_GET_UA4BE(ptr) \ (((TDS_UCHAR*)(ptr))[0] * 0x1000000u + ((TDS_UCHAR*)(ptr))[1] * 0x10000u +\ ((TDS_UCHAR*)(ptr))[2] * 0x100u + ((TDS_UCHAR*)(ptr))[3]) #define TDS_GET_A4LE(ptr) TDS_GET_UA4LE(ptr) #define TDS_GET_A4BE(ptr) TDS_GET_UA4BE(ptr) #define TDS_PUT_UA4LE(ptr,val) do {\ ((TDS_UCHAR*)(ptr))[3] = (TDS_UCHAR)((val)>>24); ((TDS_UCHAR*)(ptr))[2] = (TDS_UCHAR)((val)>>16);\ ((TDS_UCHAR*)(ptr))[1] = (TDS_UCHAR)((val)>>8); ((TDS_UCHAR*)(ptr))[0] = (TDS_UCHAR)(val); } while(0) #define TDS_PUT_UA4BE(ptr,val) do {\ ((TDS_UCHAR*)(ptr))[0] = (TDS_UCHAR)((val)>>24); ((TDS_UCHAR*)(ptr))[1] = (TDS_UCHAR)((val)>>16);\ ((TDS_UCHAR*)(ptr))[2] = (TDS_UCHAR)((val)>>8); ((TDS_UCHAR*)(ptr))[3] = (TDS_UCHAR)(val); } while(0) #define TDS_PUT_A4LE(ptr,val) TDS_PUT_UA4LE(ptr,val) #define TDS_PUT_A4BE(ptr,val) TDS_PUT_UA4BE(ptr,val) #if defined(__GNUC__) # define TDS_MAY_ALIAS __attribute__((__may_alias__)) #else # define TDS_MAY_ALIAS #endif typedef union { TDS_USMALLINT usi; TDS_UCHAR uc[2]; } TDS_MAY_ALIAS TDS_BYTE_CONVERT2; typedef union { TDS_UINT ui; TDS_UCHAR uc[4]; } TDS_MAY_ALIAS TDS_BYTE_CONVERT4; /* architecture dependent */ /* map to generic macros or redefine for aligned and same endianess */ #ifdef WORDS_BIGENDIAN # define TDS_GET_A1(ptr) TDS_GET_A1BE(ptr) # define TDS_GET_UA1(ptr) TDS_GET_UA1BE(ptr) # define TDS_GET_A2(ptr) TDS_GET_A2BE(ptr) # define TDS_GET_UA2(ptr) TDS_GET_UA2BE(ptr) # define TDS_GET_A4(ptr) TDS_GET_A4BE(ptr) # define TDS_GET_UA4(ptr) TDS_GET_UA4BE(ptr) # undef TDS_GET_A2BE # undef TDS_GET_A4BE # define TDS_GET_A2BE(ptr) (((TDS_BYTE_CONVERT2*)(ptr))->usi) # define TDS_GET_A4BE(ptr) (((TDS_BYTE_CONVERT4*)(ptr))->ui) # define TDS_PUT_A1(ptr,val) TDS_PUT_A1BE(ptr,val) # define TDS_PUT_UA1(ptr,val) TDS_PUT_UA1BE(ptr,val) # define TDS_PUT_A2(ptr,val) TDS_PUT_A2BE(ptr,val) # define TDS_PUT_UA2(ptr,val) TDS_PUT_UA2BE(ptr,val) # define TDS_PUT_A4(ptr,val) TDS_PUT_A4BE(ptr,val) # define TDS_PUT_UA4(ptr,val) TDS_PUT_UA4BE(ptr,val) # undef TDS_PUT_A2BE # undef TDS_PUT_A4BE # define TDS_PUT_A2BE(ptr,val) (((TDS_BYTE_CONVERT2*)(ptr))->usi = (val)) # define TDS_PUT_A4BE(ptr,val) (((TDS_BYTE_CONVERT4*)(ptr))->ui = (val)) # define TDS_HOST2LE(val) TDS_BYTE_SWAP16(val) # define TDS_HOST4LE(val) TDS_BYTE_SWAP32(val) # define TDS_HOST2BE(val) (val) # define TDS_HOST4BE(val) (val) #else # define TDS_GET_A1(ptr) TDS_GET_A1LE(ptr) # define TDS_GET_UA1(ptr) TDS_GET_UA1LE(ptr) # define TDS_GET_A2(ptr) TDS_GET_A2LE(ptr) # define TDS_GET_UA2(ptr) TDS_GET_UA2LE(ptr) # define TDS_GET_A4(ptr) TDS_GET_A4LE(ptr) # define TDS_GET_UA4(ptr) TDS_GET_UA4LE(ptr) # undef TDS_GET_A2LE # undef TDS_GET_A4LE # define TDS_GET_A2LE(ptr) (((TDS_BYTE_CONVERT2*)(ptr))->usi) # define TDS_GET_A4LE(ptr) (((TDS_BYTE_CONVERT4*)(ptr))->ui) # define TDS_PUT_A1(ptr,val) TDS_PUT_A1LE(ptr,val) # define TDS_PUT_UA1(ptr,val) TDS_PUT_UA1LE(ptr,val) # define TDS_PUT_A2(ptr,val) TDS_PUT_A2LE(ptr,val) # define TDS_PUT_UA2(ptr,val) TDS_PUT_UA2LE(ptr,val) # define TDS_PUT_A4(ptr,val) TDS_PUT_A4LE(ptr,val) # define TDS_PUT_UA4(ptr,val) TDS_PUT_UA4LE(ptr,val) # undef TDS_PUT_A2LE # undef TDS_PUT_A4LE # define TDS_PUT_A2LE(ptr,val) (((TDS_BYTE_CONVERT2*)(ptr))->usi = (val)) # define TDS_PUT_A4LE(ptr,val) (((TDS_BYTE_CONVERT4*)(ptr))->ui = (val)) # define TDS_HOST2LE(val) (val) # define TDS_HOST4LE(val) (val) # define TDS_HOST2BE(val) TDS_BYTE_SWAP16(val) # define TDS_HOST4BE(val) TDS_BYTE_SWAP32(val) #endif /* these platform support unaligned fetch/store */ /* map unaligned macro to aligned ones */ #if defined(__i386__) || defined(__amd64__) || defined(__CRIS__) ||\ defined(__powerpc__) || defined(__powerpc64__) || defined(__ppc__) || defined(__ppc64__) ||\ defined(__s390__) || defined(__s390x__) || defined(__m68k__) ||\ (defined(_MSC_VER) && (defined(_M_AMD64) || defined(_M_IX86) || defined(_M_X64))) ||\ defined(__ARM_FEATURE_UNALIGNED) ||\ defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_8__) ||\ (defined(_M_ARM) && (_M_ARM >= 7)) # ifdef WORDS_BIGENDIAN # undef TDS_GET_UA2BE # undef TDS_GET_UA4BE # define TDS_GET_UA2BE(ptr) TDS_GET_A2BE(ptr) # define TDS_GET_UA4BE(ptr) TDS_GET_A4BE(ptr) # undef TDS_PUT_UA2BE # undef TDS_PUT_UA4BE # define TDS_PUT_UA2BE(ptr,val) TDS_PUT_A2BE(ptr,val) # define TDS_PUT_UA4BE(ptr,val) TDS_PUT_A4BE(ptr,val) # else # undef TDS_GET_UA2LE # undef TDS_GET_UA4LE # define TDS_GET_UA2LE(ptr) TDS_GET_A2LE(ptr) # define TDS_GET_UA4LE(ptr) TDS_GET_A4LE(ptr) # undef TDS_PUT_UA2LE # undef TDS_PUT_UA4LE # define TDS_PUT_UA2LE(ptr,val) TDS_PUT_A2LE(ptr,val) # define TDS_PUT_UA4LE(ptr,val) TDS_PUT_A4LE(ptr,val) # endif #endif #if defined(__linux__) && defined(__GNUC__) && (defined(__i386__) || defined(__amd64__)) # include # undef TDS_GET_UA2BE # undef TDS_GET_UA4BE # define TDS_GET_UA2BE(ptr) ({ TDS_USMALLINT _tds_si = TDS_GET_UA2LE(ptr); bswap_16(_tds_si); }) # define TDS_GET_UA4BE(ptr) ({ TDS_UINT _tds_i = TDS_GET_UA4LE(ptr); bswap_32(_tds_i); }) # undef TDS_PUT_UA2BE # undef TDS_PUT_UA4BE # define TDS_PUT_UA2BE(ptr,val) do {\ TDS_USMALLINT _tds_si = bswap_16(val); TDS_PUT_UA2LE(ptr,_tds_si); } while(0) # define TDS_PUT_UA4BE(ptr,val) do {\ TDS_UINT _tds_i = bswap_32(val); TDS_PUT_UA4LE(ptr,_tds_i); } while(0) #endif #if defined(__GNUC__) && defined(__powerpc__) # undef TDS_GET_UA2LE # undef TDS_GET_UA4LE static inline TDS_USMALLINT TDS_GET_UA2LE(void *ptr) { unsigned long res; __asm__ ("lhbrx %0,0,%1\n" : "=r" (res) : "r" (ptr), "m"(*(TDS_USMALLINT*)ptr)); return (TDS_USMALLINT) res; } static inline TDS_UINT TDS_GET_UA4LE(void *ptr) { unsigned long res; __asm__ ("lwbrx %0,0,%1\n" : "=r" (res) : "r" (ptr), "m"(*(TDS_UINT*)ptr)); return (TDS_UINT) res; } # undef TDS_PUT_UA2LE # undef TDS_PUT_UA4LE static inline void TDS_PUT_UA2LE(void *ptr, unsigned data) { __asm__ ("sthbrx %1,0,%2\n" : "=m" (*(TDS_USMALLINT *)ptr) : "r" (data), "r" (ptr)); } static inline void TDS_PUT_UA4LE(void *ptr, unsigned data) { __asm__ ("stwbrx %1,0,%2\n" : "=m" (*(TDS_UINT *)ptr) : "r" (data), "r" (ptr)); } #endif #endif freetds-1.00.82/include/freetds/thread.h100644 025423 025423 00000022234 12717145107 0013535/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * * Copyright (C) 2005 Liam Widdowson * Copyright (C) 2010-2012 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef TDSTHREAD_H #define TDSTHREAD_H 1 #undef TDS_HAVE_MUTEX #if defined(_THREAD_SAFE) && defined(TDS_HAVE_PTHREAD_MUTEX) #include #include typedef pthread_mutex_t tds_raw_mutex; #define TDS_RAW_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER static inline void tds_raw_mutex_lock(tds_raw_mutex *mtx) { pthread_mutex_lock(mtx); } static inline int tds_raw_mutex_trylock(tds_raw_mutex *mtx) { return pthread_mutex_trylock(mtx); } static inline void tds_raw_mutex_unlock(tds_raw_mutex *mtx) { pthread_mutex_unlock(mtx); } static inline int tds_raw_mutex_init(tds_raw_mutex *mtx) { return pthread_mutex_init(mtx, NULL); } static inline void tds_raw_mutex_free(tds_raw_mutex *mtx) { pthread_mutex_destroy(mtx); } typedef pthread_cond_t tds_condition; int tds_raw_cond_init(tds_condition *cond); static inline int tds_raw_cond_destroy(tds_condition *cond) { return pthread_cond_destroy(cond); } static inline int tds_raw_cond_signal(tds_condition *cond) { return pthread_cond_signal(cond); } static inline int tds_raw_cond_wait(tds_condition *cond, tds_raw_mutex *mtx) { return pthread_cond_wait(cond, mtx); } int tds_raw_cond_timedwait(tds_condition *cond, tds_raw_mutex *mtx, int timeout_sec); #define TDS_HAVE_MUTEX 1 typedef pthread_t tds_thread; typedef pthread_t tds_thread_id; typedef void *(*tds_thread_proc)(void *arg); #define TDS_THREAD_PROC_DECLARE(name, arg) \ void *name(void *arg) static inline int tds_thread_create(tds_thread *ret, tds_thread_proc proc, void *arg) { return pthread_create(ret, NULL, proc, arg); } static inline int tds_thread_create_detached(tds_thread_proc proc, void *arg) { tds_thread th; int ret = pthread_create(&th, NULL, proc, arg); if (!ret) pthread_detach(th); return ret; } static inline int tds_thread_join(tds_thread th, void **ret) { return pthread_join(th, ret); } static inline tds_thread_id tds_thread_get_current_id(void) { return pthread_self(); } static inline int tds_thread_is_current(tds_thread_id th) { return pthread_equal(th, pthread_self()); } #include #elif defined(_WIN32) struct ptw32_mcs_node_t_; typedef struct { struct ptw32_mcs_node_t_ *lock; LONG done; CRITICAL_SECTION crit; } tds_raw_mutex; #define TDS_RAW_MUTEX_INITIALIZER { NULL, 0 } static inline int tds_raw_mutex_init(tds_raw_mutex *mtx) { mtx->lock = NULL; mtx->done = 0; return 0; } void tds_win_mutex_lock(tds_raw_mutex *mutex); static inline void tds_raw_mutex_lock(tds_raw_mutex *mtx) { if ((mtx)->done) EnterCriticalSection(&(mtx)->crit); else tds_win_mutex_lock(mtx); } int tds_raw_mutex_trylock(tds_raw_mutex *mtx); static inline void tds_raw_mutex_unlock(tds_raw_mutex *mtx) { LeaveCriticalSection(&(mtx)->crit); } static inline void tds_raw_mutex_free(tds_raw_mutex *mtx) { if ((mtx)->done) { DeleteCriticalSection(&(mtx)->crit); (mtx)->done = 0; } } #define TDS_HAVE_MUTEX 1 /* easy way, only single signal supported */ typedef void *TDS_CONDITION_VARIABLE; typedef union { HANDLE ev; TDS_CONDITION_VARIABLE cv; } tds_condition; extern int (*tds_raw_cond_init)(tds_condition *cond); extern int (*tds_raw_cond_destroy)(tds_condition *cond); extern int (*tds_raw_cond_signal)(tds_condition *cond); extern int (*tds_raw_cond_timedwait)(tds_condition *cond, tds_raw_mutex *mtx, int timeout_sec); static inline int tds_raw_cond_wait(tds_condition *cond, tds_raw_mutex *mtx) { return tds_raw_cond_timedwait(cond, mtx, -1); } typedef HANDLE tds_thread; typedef DWORD tds_thread_id; typedef void *(WINAPI *tds_thread_proc)(void *arg); #define TDS_THREAD_PROC_DECLARE(name, arg) \ void *WINAPI name(void *arg) static inline int tds_thread_create(tds_thread *ret, tds_thread_proc proc, void *arg) { *ret = CreateThread(NULL, 0, (DWORD (WINAPI *)(void*)) proc, arg, 0, NULL); return *ret != NULL ? 0 : 11 /* EAGAIN */; } static inline int tds_thread_create_detached(tds_thread_proc proc, void *arg) { HANDLE h = CreateThread(NULL, 0, (DWORD (WINAPI *)(void*)) proc, arg, 0, NULL); if (h) return 0; CloseHandle(h); return 11 /* EAGAIN */; } static inline int tds_thread_join(tds_thread th, void **ret) { if (WaitForSingleObject(th, INFINITE) == WAIT_OBJECT_0) { DWORD r; if (ret && GetExitCodeThread(th, &r)) *ret = (void*) (((char*)0) + r); CloseHandle(th); return 0; } CloseHandle(th); return 22 /* EINVAL */; } static inline tds_thread_id tds_thread_get_current_id(void) { return GetCurrentThreadId(); } static inline int tds_thread_is_current(tds_thread_id th) { return th == GetCurrentThreadId(); } #else /* define noops as "successful" */ typedef struct { } tds_raw_mutex; #define TDS_RAW_MUTEX_INITIALIZER {} static inline void tds_raw_mutex_lock(tds_raw_mutex *mtx) { } static inline int tds_raw_mutex_trylock(tds_raw_mutex *mtx) { return 0; } static inline void tds_raw_mutex_unlock(tds_raw_mutex *mtx) { } static inline int tds_raw_mutex_init(tds_raw_mutex *mtx) { return 0; } static inline void tds_raw_mutex_free(tds_raw_mutex *mtx) { } typedef struct { } tds_condition; static inline int tds_raw_cond_init(tds_condition *cond) { return 0; } static inline int tds_raw_cond_destroy(tds_condition *cond) { return 0; } #define tds_raw_cond_signal(cond) \ FreeTDS_Condition_not_compiled #define tds_raw_cond_wait(cond, mtx) \ FreeTDS_Condition_not_compiled #define tds_raw_cond_timedwait(cond, mtx, timeout_sec) \ FreeTDS_Condition_not_compiled typedef struct { } tds_thread; typedef int tds_thread_id; typedef void *(*tds_thread_proc)(void *arg); #define TDS_THREAD_PROC_DECLARE(name, arg) \ void *name(void *arg) #define tds_thread_create(ret, proc, arg) \ FreeTDS_Thread_not_compiled #define tds_thread_create_detached(proc, arg) \ FreeTDS_Thread_not_compiled #define tds_thread_join(th, ret) \ FreeTDS_Thread_not_compiled static inline tds_thread_id tds_thread_get_current_id(void) { return 0; } static inline int tds_thread_is_current(tds_thread_id th) { return 1; } #endif #ifdef TDS_HAVE_MUTEX # define tds_cond_init tds_raw_cond_init # define tds_cond_destroy tds_raw_cond_destroy # define tds_cond_signal tds_raw_cond_signal # if !ENABLE_EXTRA_CHECKS # define TDS_MUTEX_INITIALIZER TDS_RAW_MUTEX_INITIALIZER # define tds_mutex tds_raw_mutex # define tds_mutex_lock tds_raw_mutex_lock # define tds_mutex_trylock tds_raw_mutex_trylock # define tds_mutex_unlock tds_raw_mutex_unlock # define tds_mutex_check_owned(mtx) do {} while(0) # define tds_mutex_init tds_raw_mutex_init # define tds_mutex_free tds_raw_mutex_free # define tds_cond_wait tds_raw_cond_wait # define tds_cond_timedwait tds_raw_cond_timedwait # else # include typedef struct tds_mutex { tds_raw_mutex mtx; volatile int locked; volatile tds_thread_id locked_by; } tds_mutex; # define TDS_MUTEX_INITIALIZER { TDS_RAW_MUTEX_INITIALIZER, 0 } static inline void tds_mutex_lock(tds_mutex *mtx) { assert(mtx); tds_raw_mutex_lock(&mtx->mtx); assert(!mtx->locked); mtx->locked = 1; mtx->locked_by = tds_thread_get_current_id(); } static inline int tds_mutex_trylock(tds_mutex *mtx) { int ret; assert(mtx); ret = tds_raw_mutex_trylock(&mtx->mtx); if (!ret) { assert(!mtx->locked); mtx->locked = 1; mtx->locked_by = tds_thread_get_current_id(); } return ret; } static inline void tds_mutex_unlock(tds_mutex *mtx) { assert(mtx && mtx->locked); mtx->locked = 0; tds_raw_mutex_unlock(&mtx->mtx); } static inline void tds_mutex_check_owned(tds_mutex *mtx) { int ret; assert(mtx); ret = tds_raw_mutex_trylock(&mtx->mtx); assert(ret); assert(mtx->locked); assert(tds_thread_is_current(mtx->locked_by)); } static inline int tds_mutex_init(tds_mutex *mtx) { mtx->locked = 0; return tds_raw_mutex_init(&mtx->mtx); } static inline void tds_mutex_free(tds_mutex *mtx) { assert(mtx && !mtx->locked); tds_raw_mutex_free(&mtx->mtx); } static inline int tds_cond_wait(tds_condition *cond, tds_mutex *mtx) { int ret; assert(mtx && mtx->locked); mtx->locked = 0; ret = tds_raw_cond_wait(cond, &mtx->mtx); mtx->locked = 1; mtx->locked_by = tds_thread_get_current_id(); return ret; } static inline int tds_cond_timedwait(tds_condition *cond, tds_mutex *mtx, int timeout_sec) { int ret; assert(mtx && mtx->locked); mtx->locked = 0; ret = tds_raw_cond_timedwait(cond, &mtx->mtx, timeout_sec); mtx->locked = 1; mtx->locked_by = tds_thread_get_current_id(); return ret; } # endif #endif #endif freetds-1.00.82/include/freetds/proto.h100644 025423 025423 00000034740 13203773221 0013431/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns * Copyright (C) 2010, 2011 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /* * This file contains defines and structures strictly related to TDS protocol */ typedef struct tdsnumeric { unsigned char precision; unsigned char scale; unsigned char array[33]; } TDS_NUMERIC; typedef struct tdsoldmoney { TDS_INT mnyhigh; TDS_UINT mnylow; } TDS_OLD_MONEY; typedef union tdsmoney { TDS_OLD_MONEY tdsoldmoney; TDS_INT8 mny; } TDS_MONEY; typedef struct tdsmoney4 { TDS_INT mny4; } TDS_MONEY4; typedef struct tdsdatetime { TDS_INT dtdays; TDS_INT dttime; } TDS_DATETIME; typedef struct tdsdatetime4 { TDS_USMALLINT days; TDS_USMALLINT minutes; } TDS_DATETIME4; typedef struct tdsunique { TDS_UINT Data1; TDS_USMALLINT Data2; TDS_USMALLINT Data3; TDS_UCHAR Data4[8]; } TDS_UNIQUE; typedef TDS_INT TDS_DATE; typedef TDS_INT TDS_TIME; typedef TDS_UINT8 TDS_BIGTIME; typedef TDS_UINT8 TDS_BIGDATETIME; #define TDS5_PARAMFMT2_TOKEN 32 /* 0x20 */ #define TDS_LANGUAGE_TOKEN 33 /* 0x21 TDS 5.0 only */ #define TDS_ORDERBY2_TOKEN 34 /* 0x22 */ #define TDS_ROWFMT2_TOKEN 97 /* 0x61 TDS 5.0 only */ #define TDS_MSG_TOKEN 101 /* 0x65 TDS 5.0 only */ #define TDS_LOGOUT_TOKEN 113 /* 0x71 TDS 5.0 only? ct_close() */ #define TDS_RETURNSTATUS_TOKEN 121 /* 0x79 */ #define TDS_PROCID_TOKEN 124 /* 0x7C TDS 4.2 only - TDS_PROCID */ #define TDS7_RESULT_TOKEN 129 /* 0x81 TDS 7.0 only */ #define TDS7_COMPUTE_RESULT_TOKEN 136 /* 0x88 TDS 7.0 only */ #define TDS_COLNAME_TOKEN 160 /* 0xA0 TDS 4.2 only */ #define TDS_COLFMT_TOKEN 161 /* 0xA1 TDS 4.2 only - TDS_COLFMT */ #define TDS_DYNAMIC2_TOKEN 163 /* 0xA3 */ #define TDS_TABNAME_TOKEN 164 /* 0xA4 */ #define TDS_COLINFO_TOKEN 165 /* 0xA5 */ #define TDS_OPTIONCMD_TOKEN 166 /* 0xA6 */ #define TDS_COMPUTE_NAMES_TOKEN 167 /* 0xA7 */ #define TDS_COMPUTE_RESULT_TOKEN 168 /* 0xA8 */ #define TDS_ORDERBY_TOKEN 169 /* 0xA9 TDS_ORDER */ #define TDS_ERROR_TOKEN 170 /* 0xAA */ #define TDS_INFO_TOKEN 171 /* 0xAB */ #define TDS_PARAM_TOKEN 172 /* 0xAC RETURNVALUE? */ #define TDS_LOGINACK_TOKEN 173 /* 0xAD */ #define TDS_CONTROL_FEATUREEXTACK_TOKEN \ 174 /* 0xAE TDS_CONTROL/TDS_FEATUREEXTACK */ #define TDS_ROW_TOKEN 209 /* 0xD1 */ #define TDS_NBC_ROW_TOKEN 210 /* 0xD2 as of TDS 7.3.B */ #define TDS_CMP_ROW_TOKEN 211 /* 0xD3 */ #define TDS5_PARAMS_TOKEN 215 /* 0xD7 TDS 5.0 only */ #define TDS_CAPABILITY_TOKEN 226 /* 0xE2 */ #define TDS_ENVCHANGE_TOKEN 227 /* 0xE3 */ #define TDS_SESSIONSTATE_TOKEN 228 /* 0xE4 TDS 7.4 */ #define TDS_EED_TOKEN 229 /* 0xE5 */ #define TDS_DBRPC_TOKEN 230 /* 0xE6 TDS 5.0 only */ #define TDS5_DYNAMIC_TOKEN 231 /* 0xE7 TDS 5.0 only */ #define TDS5_PARAMFMT_TOKEN 236 /* 0xEC TDS 5.0 only */ #define TDS_AUTH_TOKEN 237 /* 0xED TDS 7.0 only */ #define TDS_RESULT_TOKEN 238 /* 0xEE */ #define TDS_DONE_TOKEN 253 /* 0xFD TDS_DONE */ #define TDS_DONEPROC_TOKEN 254 /* 0xFE TDS_DONEPROC */ #define TDS_DONEINPROC_TOKEN 255 /* 0xFF TDS_DONEINPROC */ /* CURSOR support: TDS 5.0 only*/ #define TDS_CURCLOSE_TOKEN 128 /* 0x80 TDS 5.0 only */ #define TDS_CURDELETE_TOKEN 129 /* 0x81 TDS 5.0 only */ #define TDS_CURFETCH_TOKEN 130 /* 0x82 TDS 5.0 only */ #define TDS_CURINFO_TOKEN 131 /* 0x83 TDS 5.0 only */ #define TDS_CUROPEN_TOKEN 132 /* 0x84 TDS 5.0 only */ #define TDS_CURDECLARE_TOKEN 134 /* 0x86 TDS 5.0 only */ /* environment type field */ #define TDS_ENV_DATABASE 1 #define TDS_ENV_LANG 2 #define TDS_ENV_CHARSET 3 #define TDS_ENV_PACKSIZE 4 #define TDS_ENV_LCID 5 #define TDS_ENV_SQLCOLLATION 7 #define TDS_ENV_BEGINTRANS 8 #define TDS_ENV_COMMITTRANS 9 #define TDS_ENV_ROLLBACKTRANS 10 #define TDS_ENV_ROUTING 20 /* Microsoft internal stored procedure id's */ #define TDS_SP_CURSOR 1 #define TDS_SP_CURSOROPEN 2 #define TDS_SP_CURSORPREPARE 3 #define TDS_SP_CURSOREXECUTE 4 #define TDS_SP_CURSORPREPEXEC 5 #define TDS_SP_CURSORUNPREPARE 6 #define TDS_SP_CURSORFETCH 7 #define TDS_SP_CURSOROPTION 8 #define TDS_SP_CURSORCLOSE 9 #define TDS_SP_EXECUTESQL 10 #define TDS_SP_PREPARE 11 #define TDS_SP_EXECUTE 12 #define TDS_SP_PREPEXEC 13 #define TDS_SP_PREPEXECRPC 14 #define TDS_SP_UNPREPARE 15 /* * Sybase does an awful job of this stuff, non null ints of size 1 2 * and 4 have there own codes but nullable ints are lumped into INTN * sheesh! */ typedef enum { SYBCHAR = 47, /* 0x2F */ SYBVARCHAR = 39, /* 0x27 */ SYBINTN = 38, /* 0x26 */ SYBINT1 = 48, /* 0x30 */ SYBINT2 = 52, /* 0x34 */ SYBINT4 = 56, /* 0x38 */ SYBFLT8 = 62, /* 0x3E */ SYBDATETIME = 61, /* 0x3D */ SYBBIT = 50, /* 0x32 */ SYBTEXT = 35, /* 0x23 */ SYBNTEXT = 99, /* 0x63 */ SYBIMAGE = 34, /* 0x22 */ SYBMONEY4 = 122, /* 0x7A */ SYBMONEY = 60, /* 0x3C */ SYBDATETIME4 = 58, /* 0x3A */ SYBREAL = 59, /* 0x3B */ SYBBINARY = 45, /* 0x2D */ SYBVOID = 31, /* 0x1F */ SYBVARBINARY = 37, /* 0x25 */ SYBBITN = 104, /* 0x68 */ SYBNUMERIC = 108, /* 0x6C */ SYBDECIMAL = 106, /* 0x6A */ SYBFLTN = 109, /* 0x6D */ SYBMONEYN = 110, /* 0x6E */ SYBDATETIMN = 111, /* 0x6F */ /* * MS only types */ SYBNVARCHAR = 103, /* 0x67 */ SYBINT8 = 127, /* 0x7F */ XSYBCHAR = 175, /* 0xAF */ XSYBVARCHAR = 167, /* 0xA7 */ XSYBNVARCHAR = 231, /* 0xE7 */ XSYBNCHAR = 239, /* 0xEF */ XSYBVARBINARY = 165, /* 0xA5 */ XSYBBINARY = 173, /* 0xAD */ SYBUNIQUE = 36, /* 0x24 */ SYBVARIANT = 98, /* 0x62 */ SYBMSUDT = 240, /* 0xF0 */ SYBMSXML = 241, /* 0xF1 */ SYBMSDATE = 40, /* 0x28 */ SYBMSTIME = 41, /* 0x29 */ SYBMSDATETIME2 = 42, /* 0x2a */ SYBMSDATETIMEOFFSET = 43,/* 0x2b */ /* * Sybase only types */ SYBLONGBINARY = 225, /* 0xE1 */ SYBUINT1 = 64, /* 0x40 */ SYBUINT2 = 65, /* 0x41 */ SYBUINT4 = 66, /* 0x42 */ SYBUINT8 = 67, /* 0x43 */ SYBBLOB = 36, /* 0x24 */ SYBBOUNDARY = 104, /* 0x68 */ SYBDATE = 49, /* 0x31 */ SYBDATEN = 123, /* 0x7B */ SYB5INT8 = 191, /* 0xBF */ SYBINTERVAL = 46, /* 0x2E */ SYBLONGCHAR = 175, /* 0xAF */ SYBSENSITIVITY = 103, /* 0x67 */ SYBSINT1 = 176, /* 0xB0 */ SYBTIME = 51, /* 0x33 */ SYBTIMEN = 147, /* 0x93 */ SYBUINTN = 68, /* 0x44 */ SYBUNITEXT = 174, /* 0xAE */ SYBXML = 163, /* 0xA3 */ SYB5BIGDATETIME = 187, /* 0xBB */ SYB5BIGTIME = 188, /* 0xBC */ } TDS_SERVER_TYPE; typedef enum { USER_UNICHAR_TYPE = 34, /* 0x22 */ USER_UNIVARCHAR_TYPE = 35 /* 0x23 */ } TDS_USER_TYPE; /* compute operator */ #define SYBAOPCNT 75 /* 0x4B */ #define SYBAOPCNTU 76 /* 0x4C, obsolete */ #define SYBAOPSUM 77 /* 0x4D */ #define SYBAOPSUMU 78 /* 0x4E, obsolete */ #define SYBAOPAVG 79 /* 0x4F */ #define SYBAOPAVGU 80 /* 0x50, obsolete */ #define SYBAOPMIN 81 /* 0x51 */ #define SYBAOPMAX 82 /* 0x52 */ /* mssql2k compute operator */ #define SYBAOPCNT_BIG 9 /* 0x09 */ #define SYBAOPSTDEV 48 /* 0x30 */ #define SYBAOPSTDEVP 49 /* 0x31 */ #define SYBAOPVAR 50 /* 0x32 */ #define SYBAOPVARP 51 /* 0x33 */ #define SYBAOPCHECKSUM_AGG 114 /* 0x72 */ /** * options that can be sent with a TDS_OPTIONCMD token */ typedef enum { TDS_OPT_SET = 1 /**< Set an option. */ , TDS_OPT_DEFAULT = 2 /**< Set option to its default value. */ , TDS_OPT_LIST = 3 /**< Request current setting of a specific option. */ , TDS_OPT_INFO = 4 /**< Report current setting of a specific option. */ } TDS_OPTION_CMD; typedef enum { TDS_OPT_DATEFIRST = 1 /* 0x01 */ , TDS_OPT_TEXTSIZE = 2 /* 0x02 */ , TDS_OPT_STAT_TIME = 3 /* 0x03 */ , TDS_OPT_STAT_IO = 4 /* 0x04 */ , TDS_OPT_ROWCOUNT = 5 /* 0x05 */ , TDS_OPT_NATLANG = 6 /* 0x06 */ , TDS_OPT_DATEFORMAT = 7 /* 0x07 */ , TDS_OPT_ISOLATION = 8 /* 0x08 */ , TDS_OPT_AUTHON = 9 /* 0x09 */ , TDS_OPT_CHARSET = 10 /* 0x0a */ , TDS_OPT_SHOWPLAN = 13 /* 0x0d */ , TDS_OPT_NOEXEC = 14 /* 0x0e */ , TDS_OPT_ARITHIGNOREON = 15 /* 0x0f */ , TDS_OPT_ARITHABORTON = 17 /* 0x11 */ , TDS_OPT_PARSEONLY = 18 /* 0x12 */ , TDS_OPT_GETDATA = 20 /* 0x14 */ , TDS_OPT_NOCOUNT = 21 /* 0x15 */ , TDS_OPT_FORCEPLAN = 23 /* 0x17 */ , TDS_OPT_FORMATONLY = 24 /* 0x18 */ , TDS_OPT_CHAINXACTS = 25 /* 0x19 */ , TDS_OPT_CURCLOSEONXACT = 26 /* 0x1a */ , TDS_OPT_FIPSFLAG = 27 /* 0x1b */ , TDS_OPT_RESTREES = 28 /* 0x1c */ , TDS_OPT_IDENTITYON = 29 /* 0x1d */ , TDS_OPT_CURREAD = 30 /* 0x1e */ , TDS_OPT_CURWRITE = 31 /* 0x1f */ , TDS_OPT_IDENTITYOFF = 32 /* 0x20 */ , TDS_OPT_AUTHOFF = 33 /* 0x21 */ , TDS_OPT_ANSINULL = 34 /* 0x22 */ , TDS_OPT_QUOTED_IDENT = 35 /* 0x23 */ , TDS_OPT_ARITHIGNOREOFF = 36 /* 0x24 */ , TDS_OPT_ARITHABORTOFF = 37 /* 0x25 */ , TDS_OPT_TRUNCABORT = 38 /* 0x26 */ } TDS_OPTION; enum { TDS_OPT_ARITHOVERFLOW = 0x01, TDS_OPT_NUMERICTRUNC = 0x02 }; enum TDS_OPT_DATEFIRST_CHOICE { TDS_OPT_MONDAY = 1, TDS_OPT_TUESDAY = 2, TDS_OPT_WEDNESDAY = 3, TDS_OPT_THURSDAY = 4, TDS_OPT_FRIDAY = 5, TDS_OPT_SATURDAY = 6, TDS_OPT_SUNDAY = 7 }; enum TDS_OPT_DATEFORMAT_CHOICE { TDS_OPT_FMTMDY = 1, TDS_OPT_FMTDMY = 2, TDS_OPT_FMTYMD = 3, TDS_OPT_FMTYDM = 4, TDS_OPT_FMTMYD = 5, TDS_OPT_FMTDYM = 6 }; enum TDS_OPT_ISOLATION_CHOICE { TDS_OPT_LEVEL0 = 0, TDS_OPT_LEVEL1 = 1, TDS_OPT_LEVEL2 = 2, TDS_OPT_LEVEL3 = 3 }; typedef enum tds_packet_type { TDS_QUERY = 1, TDS_LOGIN = 2, TDS_RPC = 3, TDS_REPLY = 4, TDS_CANCEL = 6, TDS_BULK = 7, TDS7_TRANS = 14, /* transaction management */ TDS_NORMAL = 15, TDS7_LOGIN = 16, TDS7_AUTH = 17, TDS71_PRELOGIN = 18, TDS72_SMP = 0x53 } TDS_PACKET_TYPE; /** * TDS 7.1 collation informations. */ typedef struct { TDS_USMALLINT locale_id; /* master..syslanguages.lcid */ TDS_USMALLINT flags; TDS_UCHAR charset_id; /* or zero */ } TDS71_COLLATION; /** * TDS 7.2 SMP packet header */ typedef struct { TDS_UCHAR signature; /* TDS72_SMP */ TDS_UCHAR type; TDS_USMALLINT sid; TDS_UINT size; TDS_UINT seq; TDS_UINT wnd; } TDS72_SMP_HEADER; enum { TDS_SMP_SYN = 1, TDS_SMP_ACK = 2, TDS_SMP_FIN = 4, TDS_SMP_DATA = 8, }; /* SF stands for "sort flag" */ #define TDS_SF_BIN (TDS_USMALLINT) 0x100 #define TDS_SF_WIDTH_INSENSITIVE (TDS_USMALLINT) 0x080 #define TDS_SF_KATATYPE_INSENSITIVE (TDS_USMALLINT) 0x040 #define TDS_SF_ACCENT_SENSITIVE (TDS_USMALLINT) 0x020 #define TDS_SF_CASE_INSENSITIVE (TDS_USMALLINT) 0x010 /* UT stands for user type */ #define TDS_UT_TIMESTAMP 80 /* mssql login options flags */ enum option_flag1_values { TDS_BYTE_ORDER_X86 = 0, TDS_CHARSET_ASCII = 0, TDS_DUMPLOAD_ON = 0, TDS_FLOAT_IEEE_754 = 0, TDS_INIT_DB_WARN = 0, TDS_SET_LANG_OFF = 0, TDS_USE_DB_SILENT = 0, TDS_BYTE_ORDER_68000 = 0x01, TDS_CHARSET_EBDDIC = 0x02, TDS_FLOAT_VAX = 0x04, TDS_FLOAT_ND5000 = 0x08, TDS_DUMPLOAD_OFF = 0x10, /* prevent BCP */ TDS_USE_DB_NOTIFY = 0x20, TDS_INIT_DB_FATAL = 0x40, TDS_SET_LANG_ON = 0x80 }; enum option_flag2_values { TDS_INIT_LANG_WARN = 0, TDS_INTEGRATED_SECURTY_OFF = 0, TDS_ODBC_OFF = 0, TDS_USER_NORMAL = 0, /* SQL Server login */ TDS_INIT_LANG_REQUIRED = 0x01, TDS_ODBC_ON = 0x02, TDS_TRANSACTION_BOUNDARY71 = 0x04, /* removed in TDS 7.2 */ TDS_CACHE_CONNECT71 = 0x08, /* removed in TDS 7.2 */ TDS_USER_SERVER = 0x10, /* reserved */ TDS_USER_REMUSER = 0x20, /* DQ login */ TDS_USER_SQLREPL = 0x40, /* replication login */ TDS_INTEGRATED_SECURITY_ON = 0x80 }; enum option_flag3_values { TDS_RESTRICTED_COLLATION = 0, TDS_CHANGE_PASSWORD = 0x01, /* TDS 7.2 */ TDS_SEND_YUKON_BINARY_XML = 0x02, /* TDS 7.2 */ TDS_REQUEST_USER_INSTANCE = 0x04, /* TDS 7.2 */ TDS_UNKNOWN_COLLATION_HANDLING = 0x08, /* TDS 7.3 */ TDS_EXTENSION = 0x10, /* TDS 7.4 */ }; enum type_flags { TDS_OLEDB_ON = 0x10, TDS_READONLY_INTENT = 0x20, }; /* Sybase dynamic types */ enum dynamic_types { TDS_DYN_PREPARE = 0x01, TDS_DYN_EXEC = 0x02, TDS_DYN_DEALLOC = 0x04, TDS_DYN_EXEC_IMMED = 0x08, TDS_DYN_PROCNAME = 0x10, TDS_DYN_ACK = 0x20, TDS_DYN_DESCIN = 0x40, TDS_DYN_DESCOUT = 0x80, }; /* http://jtds.sourceforge.net/apiCursors.html */ /* Cursor scroll option, must be one of 0x01 - 0x10, OR'd with other bits */ enum { TDS_CUR_TYPE_KEYSET = 0x0001, /* default */ TDS_CUR_TYPE_DYNAMIC = 0x0002, TDS_CUR_TYPE_FORWARD = 0x0004, TDS_CUR_TYPE_STATIC = 0x0008, TDS_CUR_TYPE_FASTFORWARDONLY = 0x0010, TDS_CUR_TYPE_PARAMETERIZED = 0x1000, TDS_CUR_TYPE_AUTO_FETCH = 0x2000 }; enum { TDS_CUR_CONCUR_READ_ONLY = 1, TDS_CUR_CONCUR_SCROLL_LOCKS = 2, TDS_CUR_CONCUR_OPTIMISTIC = 4, /* default */ TDS_CUR_CONCUR_OPTIMISTIC_VALUES = 8 }; /* TDS 4/5 login*/ #define TDS_MAXNAME 30 /* maximum login name lenghts */ #define TDS_PROGNLEN 10 /* maximum program lenght */ #define TDS_PKTLEN 6 /* maximum packet lenght in login */ /* TDS 5 login security flags */ enum { TDS5_SEC_LOG_ENCRYPT = 1, TDS5_SEC_LOG_CHALLENGE = 2, TDS5_SEC_LOG_LABELS = 4, TDS5_SEC_LOG_APPDEFINED = 8, TDS5_SEC_LOG_SECSESS = 16, TDS5_SEC_LOG_ENCRYPT2 = 32, TDS5_SEC_LOG_NONCE = 128 }; freetds-1.00.82/include/freetds/tds.h100644 025423 025423 00000156304 13203773221 0013061/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns * Copyright (C) 2010, 2011 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef _tds_h_ #define _tds_h_ #include #include #include #ifdef HAVE_STDDEF_H #include #endif #if HAVE_NETDB_H #include #endif /* HAVE_NETDB_H */ #if HAVE_NETINET_IN_H #include #endif /* HAVE_NET_INET_IN_H */ #if HAVE_ARPA_INET_H #include #endif /* HAVE_ARPA_INET_H */ /* forward declaration */ typedef struct tdsiconvinfo TDSICONV; typedef struct tds_connection TDSCONNECTION; typedef struct tds_socket TDSSOCKET; typedef struct tds_column TDSCOLUMN; typedef struct tds_bcpinfo TDSBCPINFO; #include #include "tds_sysdep_public.h" #include #include #include #include "replacements.h" #include #ifdef __cplusplus extern "C" { #if 0 } #endif #endif /** * A structure to hold all the compile-time settings. * This structure is returned by tds_get_compiletime_settings */ typedef struct tds_compiletime_settings { const char *freetds_version; /* release version of FreeTDS */ const char *sysconfdir; /* location of freetds.conf */ const char *last_update; /* latest software_version date among the modules */ int msdblib; /* for MS style dblib */ int sybase_compat; /* enable increased Open Client binary compatibility */ int threadsafe; /* compile for thread safety default=no */ int libiconv; /* search for libiconv in DIR/include and DIR/lib */ const char *tdsver; /* TDS protocol version (4.2/4.6/5.0/7.0/7.1) 5.0 */ int iodbc; /* build odbc driver against iODBC in DIR */ int unixodbc; /* build odbc driver against unixODBC in DIR */ int openssl; /* build against OpenSSL */ int gnutls; /* build against GnuTLS */ int mars; /* MARS enabled */ } TDS_COMPILETIME_SETTINGS; /** * Structure to hold a string. * Use tds_dstr_* functions/macros, do not access members directly. * There should be always a buffer. */ typedef struct tds_dstr { size_t dstr_size; char dstr_s[1]; } *DSTR; /** * @file tds.h * Main include file for libtds */ /** * \defgroup libtds LibTDS API * Callable functions in \c libtds. * * The \c libtds library is for use internal to \em FreeTDS. It is not * intended for use by applications. Although any use is \em permitted, you're * encouraged to use one of the established public APIs instead, because their * interfaces are stable and documented by the vendors. */ /* * All references to data that touch the wire should use the following typedefs. * * If you have problems on 64-bit machines and the code is * using a native datatype, please change it to use * these. (In the TDS layer only, the API layers have their * own typedefs which equate to these). */ typedef char TDS_CHAR; /* 8-bit char */ typedef unsigned char TDS_UCHAR; /* 8-bit uchar */ typedef unsigned char TDS_TINYINT; /* 8-bit unsigned */ typedef tds_sysdep_int16_type TDS_SMALLINT; /* 16-bit int */ typedef unsigned tds_sysdep_int16_type TDS_USMALLINT; /* 16-bit unsigned */ typedef tds_sysdep_int32_type TDS_INT; /* 32-bit int */ typedef unsigned tds_sysdep_int32_type TDS_UINT; /* 32-bit unsigned */ typedef tds_sysdep_real32_type TDS_REAL; /* 32-bit real */ typedef tds_sysdep_real64_type TDS_FLOAT; /* 64-bit real */ typedef tds_sysdep_int64_type TDS_INT8; /* 64-bit integer */ typedef unsigned tds_sysdep_int64_type TDS_UINT8; /* 64-bit unsigned */ typedef tds_sysdep_intptr_type TDS_INTPTR; typedef unsigned tds_sysdep_intptr_type TDS_UINTPTR; #include #define TDS_INVALID_TYPE ((TDS_SERVER_TYPE) 0) /** * this structure is not directed connected to a TDS protocol but * keeps any DATE/TIME information. */ typedef struct { TDS_UINT8 time; /**< time, 7 digit precision */ TDS_INT date; /**< date, 0 = 1900-01-01 */ TDS_SMALLINT offset; /**< time offset */ TDS_USMALLINT time_prec:3; TDS_USMALLINT _tds_reserved:10; TDS_USMALLINT has_time:1; TDS_USMALLINT has_date:1; TDS_USMALLINT has_offset:1; } TDS_DATETIMEALL; /** Used by tds_datecrack */ typedef struct tdsdaterec { TDS_INT year; /**< year */ TDS_INT quarter; /**< quarter (0-3) */ TDS_INT month; /**< month number (0-11) */ TDS_INT day; /**< day of month (1-31) */ TDS_INT dayofyear; /**< day of year (1-366) */ TDS_INT weekday; /**< day of week (0-6, 0 = sunday) */ TDS_INT hour; /**< 0-23 */ TDS_INT minute; /**< 0-59 */ TDS_INT second; /**< 0-59 */ TDS_INT decimicrosecond; /**< 0-9999999 */ TDS_INT timezone; /**< -840 - 840 minutes from UTC */ } TDSDATEREC; /** * The following little table is indexed by precision and will * tell us the number of bytes required to store the specified * precision. */ extern const int tds_numeric_bytes_per_prec[]; typedef int TDSRET; #define TDS_NO_MORE_RESULTS ((TDSRET)1) #define TDS_SUCCESS ((TDSRET)0) #define TDS_FAIL ((TDSRET)-1) #define TDS_CANCELLED ((TDSRET)-2) #define TDS_FAILED(rc) ((rc)<0) #define TDS_SUCCEED(rc) ((rc)>=0) #define TDS_INT_CONTINUE 1 #define TDS_INT_CANCEL 2 #define TDS_INT_TIMEOUT 3 #define TDS_NO_COUNT -1 #define TDS_ROW_RESULT 4040 #define TDS_PARAM_RESULT 4042 #define TDS_STATUS_RESULT 4043 #define TDS_MSG_RESULT 4044 #define TDS_COMPUTE_RESULT 4045 #define TDS_CMD_DONE 4046 #define TDS_CMD_SUCCEED 4047 #define TDS_CMD_FAIL 4048 #define TDS_ROWFMT_RESULT 4049 #define TDS_COMPUTEFMT_RESULT 4050 #define TDS_DESCRIBE_RESULT 4051 #define TDS_DONE_RESULT 4052 #define TDS_DONEPROC_RESULT 4053 #define TDS_DONEINPROC_RESULT 4054 #define TDS_OTHERS_RESULT 4055 enum tds_token_results { TDS_TOKEN_RES_OTHERS, TDS_TOKEN_RES_ROWFMT, TDS_TOKEN_RES_COMPUTEFMT, TDS_TOKEN_RES_PARAMFMT, TDS_TOKEN_RES_DONE, TDS_TOKEN_RES_ROW, TDS_TOKEN_RES_COMPUTE, TDS_TOKEN_RES_PROC, TDS_TOKEN_RES_MSG, TDS_TOKEN_RES_ENV, }; #define TDS_TOKEN_FLAG(flag) TDS_RETURN_##flag = (1 << (TDS_TOKEN_RES_##flag*2)), TDS_STOPAT_##flag = (2 << (TDS_TOKEN_RES_##flag*2)) enum tds_token_flags { TDS_HANDLE_ALL = 0, TDS_TOKEN_FLAG(OTHERS), TDS_TOKEN_FLAG(ROWFMT), TDS_TOKEN_FLAG(COMPUTEFMT), TDS_TOKEN_FLAG(PARAMFMT), TDS_TOKEN_FLAG(DONE), TDS_TOKEN_FLAG(ROW), TDS_TOKEN_FLAG(COMPUTE), TDS_TOKEN_FLAG(PROC), TDS_TOKEN_FLAG(MSG), TDS_TOKEN_FLAG(ENV), TDS_TOKEN_RESULTS = TDS_RETURN_ROWFMT|TDS_RETURN_COMPUTEFMT|TDS_RETURN_DONE|TDS_STOPAT_ROW|TDS_STOPAT_COMPUTE|TDS_RETURN_PROC, TDS_TOKEN_TRAILING = TDS_STOPAT_ROWFMT|TDS_STOPAT_COMPUTEFMT|TDS_STOPAT_ROW|TDS_STOPAT_COMPUTE|TDS_STOPAT_MSG|TDS_STOPAT_OTHERS }; /** * Flags returned in TDS_DONE token */ enum tds_end { TDS_DONE_FINAL = 0x00 /**< final result set, command completed successfully. */ , TDS_DONE_MORE_RESULTS = 0x01 /**< more results follow */ , TDS_DONE_ERROR = 0x02 /**< error occurred */ , TDS_DONE_INXACT = 0x04 /**< transaction in progress */ , TDS_DONE_PROC = 0x08 /**< results are from a stored procedure */ , TDS_DONE_COUNT = 0x10 /**< count field in packet is valid */ , TDS_DONE_CANCELLED = 0x20 /**< acknowledging an attention command (usually a cancel) */ , TDS_DONE_EVENT = 0x40 /* part of an event notification. */ , TDS_DONE_SRVERROR = 0x100 /**< SQL server server error */ /* after the above flags, a TDS_DONE packet has a field describing the state of the transaction */ , TDS_DONE_NO_TRAN = 0 /* No transaction in effect */ , TDS_DONE_TRAN_SUCCEED = 1 /* Transaction completed successfully */ , TDS_DONE_TRAN_PROGRESS= 2 /* Transaction in progress */ , TDS_DONE_STMT_ABORT = 3 /* A statement aborted */ , TDS_DONE_TRAN_ABORT = 4 /* Transaction aborted */ }; /* * TDSERRNO is emitted by libtds to the client library's error handler * (which may in turn call the client's error handler). * These match the db-lib msgno, because the same values have the same meaning * in db-lib and ODBC. ct-lib maps them to ct-lib numbers (todo). */ typedef enum { TDSEOK = TDS_SUCCESS, TDSEVERDOWN = 100, TDSEICONVIU = 2400, TDSEICONVAVAIL = 2401, TDSEICONVO = 2402, TDSEICONVI = 2403, TDSEICONV2BIG = 2404, TDSEPORTINSTANCE = 2500, TDSESYNC = 20001, TDSEFCON = 20002, TDSETIME = 20003, TDSEREAD = 20004, TDSEWRIT = 20006, TDSESOCK = 20008, TDSECONN = 20009, TDSEMEM = 20010, TDSEINTF = 20012, /* Server name not found in interface file */ TDSEUHST = 20013, /* Unknown host machine name. */ TDSEPWD = 20014, TDSESEOF = 20017, TDSERPND = 20019, TDSEBTOK = 20020, TDSEOOB = 20022, TDSECLOS = 20056, TDSEUSCT = 20058, TDSEUTDS = 20146, TDSEEUNR = 20185, TDSECAP = 20203, TDSENEG = 20210, TDSEUMSG = 20212, TDSECAPTYP = 20213, TDSECONF = 20214, TDSEBPROBADTYP = 20250, TDSECLOSEIN = 20292 } TDSERRNO; enum { TDS_CUR_ISTAT_UNUSED = 0x00, TDS_CUR_ISTAT_DECLARED = 0x01, TDS_CUR_ISTAT_OPEN = 0x02, TDS_CUR_ISTAT_CLOSED = 0x04, TDS_CUR_ISTAT_RDONLY = 0x08, TDS_CUR_ISTAT_UPDATABLE = 0x10, TDS_CUR_ISTAT_ROWCNT = 0x20, TDS_CUR_ISTAT_DEALLOC = 0x40 }; /* string types */ #define TDS_NULLTERM -9 typedef union tds_option_arg { TDS_TINYINT ti; TDS_INT i; TDS_CHAR *c; } TDS_OPTION_ARG; typedef enum tds_encryption_level { TDS_ENCRYPTION_OFF, TDS_ENCRYPTION_REQUEST, TDS_ENCRYPTION_REQUIRE } TDS_ENCRYPTION_LEVEL; #define TDS_ZERO_FREE(x) do {free((x)); (x) = NULL;} while(0) #define TDS_VECTOR_SIZE(x) (sizeof(x)/sizeof(x[0])) #ifdef offsetof #define TDS_OFFSET(str, field) offsetof(str, field) #else #define TDS_OFFSET(str, field) (((char*)&((str*)0)->field)-((char*)0)) #endif #if defined(__GNUC__) && __GNUC__ >= 3 # define TDS_LIKELY(x) __builtin_expect(!!(x), 1) # define TDS_UNLIKELY(x) __builtin_expect(!!(x), 0) #else # define TDS_LIKELY(x) (x) # define TDS_UNLIKELY(x) (x) #endif #if ENABLE_EXTRA_CHECKS # if defined(__GNUC__) && __GNUC__ >= 2 # define TDS_COMPILE_CHECK(name,check) \ extern int name[(check)?1:-1] __attribute__ ((unused)) # else # define TDS_COMPILE_CHECK(name,check) \ extern int name[(check)?1:-1] # endif # define TDS_EXTRA_CHECK(stmt) stmt #else # define TDS_COMPILE_CHECK(name,check) \ extern int disabled_check_##name # define TDS_EXTRA_CHECK(stmt) #endif #if ENABLE_EXTRA_CHECKS && defined(__GNUC__) && __GNUC__ >= 4 #define TDS_WUR __attribute__ ((__warn_unused_result__)) #else #define TDS_WUR #endif /* * TODO use system macros for optimization * See mcrypt for reference and linux kernel source for optimization * check if unaligned access and use fast write/read when implemented */ #define TDS_BYTE_SWAP16(value) \ (((((unsigned short)value)<<8) & 0xFF00) | \ ((((unsigned short)value)>>8) & 0x00FF)) #define TDS_BYTE_SWAP32(value) \ (((((unsigned long)value)<<24) & 0xFF000000) | \ ((((unsigned long)value)<< 8) & 0x00FF0000) | \ ((((unsigned long)value)>> 8) & 0x0000FF00) | \ ((((unsigned long)value)>>24) & 0x000000FF)) #define is_end_token(x) (x==TDS_DONE_TOKEN || \ x==TDS_DONEPROC_TOKEN || \ x==TDS_DONEINPROC_TOKEN) enum { TDS_TYPEFLAG_INVALID = 0, TDS_TYPEFLAG_NULLABLE = 1, TDS_TYPEFLAG_FIXED = 2, TDS_TYPEFLAG_VARIABLE = 4, TDS_TYPEFLAG_COLLATE = 8, TDS_TYPEFLAG_ASCII = 16, TDS_TYPEFLAG_UNICODE = 32, TDS_TYPEFLAG_NUMERIC = 64, TDS_TYPEFLAG_DATETIME = 128, }; extern const unsigned char tds_type_flags_ms[256]; #if 0 extern const unsigned char tds_type_flags_syb[256]; extern const char *const tds_type_names[256]; #endif #define is_fixed_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_FIXED) != 0) #define is_nullable_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_NULLABLE) != 0) #define is_variable_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_VARIABLE) != 0) #define is_blob_type(x) ((x)==SYBTEXT || (x)==SYBIMAGE || (x)==SYBNTEXT) #define is_blob_col(x) ((x)->column_varint_size > 2) /* large type means it has a two byte size field */ /* define is_large_type(x) (x>128) */ #define is_numeric_type(x) ((x)==SYBNUMERIC || (x)==SYBDECIMAL) /** return true if type is a datetime (but not date or time) */ #define is_datetime_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_DATETIME) != 0) #define is_unicode_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_UNICODE) != 0) #define is_collate_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_COLLATE) != 0) #define is_ascii_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_ASCII) != 0) #define is_char_type(x) ((tds_type_flags_ms[x] & (TDS_TYPEFLAG_ASCII|TDS_TYPEFLAG_UNICODE)) != 0) #define is_similar_type(x, y) (is_char_type(x) && is_char_type(y)) static inline bool is_tds_type_valid(int type) { return (unsigned) type < 256u && tds_type_flags_ms[type] != 0; } #define TDS_MAX_CAPABILITY 32 #define MAXPRECISION 77 #define TDS_MAX_CONN 4096 #define TDS_MAX_DYNID_LEN 30 /* defaults to use if no others are found */ #define TDS_DEF_SERVER "SYBASE" #define TDS_DEF_BLKSZ 512 #define TDS_DEF_CHARSET "iso_1" #define TDS_DEF_LANG "us_english" #if TDS42 #define TDS_DEFAULT_VERSION 0x402 #define TDS_DEF_PORT 1433 #elif TDS46 #define TDS_DEFAULT_VERSION 0x406 #define TDS_DEF_PORT 4000 #elif TDS50 #define TDS_DEFAULT_VERSION 0x500 #define TDS_DEF_PORT 4000 #elif TDS70 #define TDS_DEFAULT_VERSION 0x700 #define TDS_DEF_PORT 1433 #elif TDS71 #define TDS_DEFAULT_VERSION 0x701 #define TDS_DEF_PORT 1433 #elif TDS72 #define TDS_DEFAULT_VERSION 0x702 #define TDS_DEF_PORT 1433 #elif TDS73 #define TDS_DEFAULT_VERSION 0x703 #define TDS_DEF_PORT 1433 #elif TDS74 #define TDS_DEFAULT_VERSION 0x704 #define TDS_DEF_PORT 1433 #else #define TDS_DEFAULT_VERSION 0x000 #define TDS_DEF_PORT 1433 #endif /* normalized strings from freetds.conf file */ #define TDS_STR_VERSION "tds version" #define TDS_STR_BLKSZ "initial block size" #define TDS_STR_SWAPDT "swap broken dates" #define TDS_STR_DUMPFILE "dump file" #define TDS_STR_DEBUGLVL "debug level" #define TDS_STR_DEBUGFLAGS "debug flags" #define TDS_STR_TIMEOUT "timeout" #define TDS_STR_QUERY_TIMEOUT "query timeout" #define TDS_STR_CONNTIMEOUT "connect timeout" #define TDS_STR_HOSTNAME "hostname" #define TDS_STR_HOST "host" #define TDS_STR_PORT "port" #define TDS_STR_TEXTSZ "text size" /* for big endian hosts */ #define TDS_STR_EMUL_LE "emulate little endian" #define TDS_STR_CHARSET "charset" #define TDS_STR_CLCHARSET "client charset" #define TDS_STR_USE_UTF_16 "use utf-16" #define TDS_STR_LANGUAGE "language" #define TDS_STR_APPENDMODE "dump file append" #define TDS_STR_DATEFMT "date format" #define TDS_STR_INSTANCE "instance" #define TDS_STR_ASA_DATABASE "asa database" #define TDS_STR_DATABASE "database" #define TDS_STR_ENCRYPTION "encryption" #define TDS_STR_USENTLMV2 "use ntlmv2" #define TDS_STR_USELANMAN "use lanman" /* conf values */ #define TDS_STR_ENCRYPTION_OFF "off" #define TDS_STR_ENCRYPTION_REQUEST "request" #define TDS_STR_ENCRYPTION_REQUIRE "require" /* Defines to enable optional GSSAPI delegation */ #define TDS_GSSAPI_DELEGATION "enable gssapi delegation" /* Kerberos realm name */ #define TDS_STR_REALM "realm" /* Kerberos SPN */ #define TDS_STR_SPN "spn" /* CA file */ #define TDS_STR_CAFILE "ca file" /* CRL file */ #define TDS_STR_CRLFILE "crl file" /* check SSL hostname */ #define TDS_STR_CHECKSSLHOSTNAME "check certificate hostname" /* database filename to attach on login (MSSQL) */ #define TDS_STR_DBFILENAME "database filename" /* Application Intent MSSQL 2012 support */ #define TDS_STR_READONLY_INTENT "read-only intent" /* configurable cipher suite to send to openssl's SSL_set_cipher_list() function */ #define TLS_STR_OPENSSL_CIPHERS "openssl ciphers" /* TODO do a better check for alignment than this */ typedef union { void *p; int i; TDS_INT8 ui; } tds_align_struct; #define TDS_ALIGN_SIZE sizeof(tds_align_struct) typedef struct tds_capability_type { unsigned char type; unsigned char len; /* always sizeof(values) */ unsigned char values[TDS_MAX_CAPABILITY/2-2]; } TDS_CAPABILITY_TYPE; typedef struct tds_capabilities { TDS_CAPABILITY_TYPE types[2]; } TDS_CAPABILITIES; #define TDS_MAX_LOGIN_STR_SZ 128 typedef struct tds_login { DSTR server_name; /**< server name (in freetds.conf) */ int port; /**< port of database service */ TDS_USMALLINT tds_version; /**< TDS version */ int block_size; DSTR language; /* e.g. us-english */ DSTR server_charset; /**< charset of server e.g. iso_1 */ TDS_INT connect_timeout; DSTR client_host_name; DSTR server_host_name; DSTR server_realm_name; /**< server realm name (in freetds.conf) */ DSTR server_spn; /**< server SPN (in freetds.conf) */ DSTR db_filename; /**< database filename to attach (MSSQL) */ DSTR cafile; /**< certificate authorities file */ DSTR crlfile; /**< certificate revocation file */ DSTR openssl_ciphers; DSTR app_name; DSTR user_name; /**< account for login */ DSTR password; /**< password of account login */ DSTR new_password; /**< new password to set (TDS 7.2+) */ DSTR library; /* Ct-Library, DB-Library, TDS-Library or ODBC */ TDS_TINYINT encryption_level; TDS_INT query_timeout; TDS_CAPABILITIES capabilities; DSTR client_charset; DSTR database; struct addrinfo *ip_addrs; /**< ip(s) of server */ struct addrinfo *connected_addr; /* ip of connected server */ DSTR instance_name; DSTR dump_file; int debug_flags; int text_size; DSTR routing_address; TDS_USMALLINT routing_port; unsigned char option_flag2; unsigned int bulk_copy:1; /**< if bulk copy should be enabled */ unsigned int suppress_language:1; unsigned int emul_little_endian:1; unsigned int gssapi_use_delegation:1; unsigned int use_ntlmv2:1; unsigned int use_lanman:1; unsigned int mars:1; unsigned int use_utf16:1; unsigned int use_new_password:1; unsigned int valid_configuration:1; unsigned int check_ssl_hostname:1; unsigned int readonly_intent:1; } TDSLOGIN; typedef struct tds_headers { const char *qn_options; const char *qn_msgtext; TDS_INT qn_timeout; /* TDS 7.4+: trace activity ID char[20] */ } TDSHEADERS; typedef struct tds_locale { char *language; char *server_charset; char *date_fmt; } TDSLOCALE; /** * Information about blobs (e.g. text or image). * current_row contains this structure. */ typedef struct tds_blob { TDS_CHAR *textvalue; TDS_CHAR textptr[16]; TDS_CHAR timestamp[8]; unsigned char valid_ptr; } TDSBLOB; /** * Store variant informations */ typedef struct tds_variant { /* this MUST have same position and place of textvalue in tds_blob */ TDS_CHAR *data; TDS_INT size; TDS_INT data_len; TDS_SERVER_TYPE type; TDS_UCHAR collation[5]; } TDSVARIANT; /** * Information relevant to libiconv. The name is an iconv name, not * the same as found in master..syslanguages. */ typedef struct tds_encoding { /** name of the encoding (ie UTF-8) */ const char *name; unsigned char min_bytes_per_char; unsigned char max_bytes_per_char; /** internal numeric index into array of all encodings */ unsigned char canonic; } TDS_ENCODING; typedef struct tds_bcpcoldata { TDS_UCHAR *data; TDS_INT datalen; TDS_INT is_null; } BCPCOLDATA; typedef TDSRET tds_func_get_info(TDSSOCKET *tds, TDSCOLUMN *col); typedef TDSRET tds_func_get_data(TDSSOCKET *tds, TDSCOLUMN *col); typedef TDS_INT tds_func_row_len(TDSCOLUMN *col); typedef unsigned tds_func_put_info_len(TDSSOCKET *tds, TDSCOLUMN *col); typedef TDSRET tds_func_put_info(TDSSOCKET *tds, TDSCOLUMN *col); typedef TDSRET tds_func_put_data(TDSSOCKET *tds, TDSCOLUMN *col, int bcp7); typedef int tds_func_check(const TDSCOLUMN *col); typedef struct tds_column_funcs { tds_func_get_info *get_info; tds_func_get_data *get_data; tds_func_row_len *row_len; /** * Returns metadata column information size. * \tds * \param col column to send */ tds_func_put_info_len *put_info_len; /** * Send metadata column information to server. * \tds * \param col column to send */ tds_func_put_info *put_info; /** * Send column data to server. * Usually send parameters unless bcp7 is specified, in * this case send BCP for TDS7+ (Sybase use a completely * different format for BCP) * \tds * \param col column to send * \param bcp7 1 to send BCP column on TDS7+ */ tds_func_put_data *put_data; #if ENABLE_EXTRA_CHECKS /** * Check column is valid. * Some things should be checked: * - column_type and on_server.column_type; * - column_size and on_server.column_size; * - column_cur_size; * - column_prec and column_scale; * - is_XXXX_type macros/functions (nullable/fixed/blob/variable); * - tds_get_size_by_type; * - tds_get_conversion_type. * * \tds * \param col column to check */ tds_func_check *check; #endif #if 0 TDSRET (*convert)(TDSSOCKET *tds, TDSCOLUMN *col); #endif } TDSCOLUMNFUNCS; /** * Metadata about columns in regular and compute rows */ struct tds_column { const TDSCOLUMNFUNCS *funcs; TDS_INT column_usertype; TDS_INT column_flags; TDS_INT column_size; /**< maximun size of data. For fixed is the size. */ TDS_SERVER_TYPE column_type; /**< This type can be different from wire type because * conversion (e.g. UCS-2->Ascii) can be applied. * I'm beginning to wonder about the wisdom of this, however. * April 2003 jkl */ TDS_TINYINT column_varint_size; /**< size of length when reading from wire (0, 1, 2 or 4) */ TDS_TINYINT column_prec; /**< precision for decimal/numeric */ TDS_TINYINT column_scale; /**< scale for decimal/numeric */ struct { TDS_SERVER_TYPE column_type; /**< type of data, saved from wire */ TDS_INT column_size; } on_server; TDSICONV *char_conv; /**< refers to previously allocated iconv information */ DSTR table_name; DSTR column_name; DSTR table_column_name; unsigned char *column_data; void (*column_data_free)(struct tds_column *column); unsigned int column_nullable:1; unsigned int column_writeable:1; unsigned int column_identity:1; unsigned int column_key:1; unsigned int column_hidden:1; unsigned int column_output:1; unsigned int column_timestamp:1; TDS_UCHAR column_collation[5]; /* additional fields flags for compute results */ TDS_TINYINT column_operator; TDS_SMALLINT column_operand; /* FIXME this is data related, not column */ /** size written in variable (ie: char, text, binary). -1 if NULL. */ TDS_INT column_cur_size; /* related to binding or info stored by client libraries */ /* FIXME find a best place to store these data, some are unused */ TDS_SMALLINT column_bindtype; TDS_SMALLINT column_bindfmt; TDS_UINT column_bindlen; TDS_SMALLINT *column_nullbind; TDS_CHAR *column_varaddr; TDS_INT *column_lenbind; TDS_INT column_textpos; TDS_INT column_text_sqlgetdatapos; TDS_CHAR column_text_sqlputdatainfo; BCPCOLDATA *bcp_column_data; /** * The length, in bytes, of any length prefix this column may have. * For example, strings in some non-C programming languages are * made up of a one-byte length prefix, followed by the string * data itself. * If the data do not have a length prefix, set prefixlen to 0. * Currently not very used in code, however do not remove. */ TDS_INT bcp_prefix_len; TDS_INT bcp_term_len; TDS_CHAR *bcp_terminator; }; /** Hold information for any results */ typedef struct tds_result_info { /* TODO those fields can became a struct */ TDSCOLUMN **columns; TDS_USMALLINT num_cols; TDS_USMALLINT computeid; TDS_INT ref_count; TDSSOCKET *attached_to; unsigned char *current_row; void (*row_free)(struct tds_result_info* result, unsigned char *row); TDS_INT row_size; TDS_SMALLINT *bycolumns; TDS_USMALLINT by_cols; TDS_TINYINT rows_exist; /* TODO remove ?? used only in dblib */ TDS_TINYINT more_results; } TDSRESULTINFO; /** values for tds->state */ typedef enum tds_states { TDS_IDLE, /**< no data expected */ TDS_WRITING, /**< client is writing data */ TDS_SENDING, /**< client would send data */ TDS_PENDING, /**< cilent is waiting for data */ TDS_READING, /**< client is reading data */ TDS_DEAD /**< no connection */ } TDS_STATE; typedef enum tds_operations { TDS_OP_NONE = 0, /* mssql operations */ TDS_OP_CURSOR = TDS_SP_CURSOR, TDS_OP_CURSOROPEN = TDS_SP_CURSOROPEN, TDS_OP_CURSORPREPARE = TDS_SP_CURSORPREPARE, TDS_OP_CURSOREXECUTE = TDS_SP_CURSOREXECUTE, TDS_OP_CURSORPREPEXEC = TDS_SP_CURSORPREPEXEC, TDS_OP_CURSORUNPREPARE = TDS_SP_CURSORUNPREPARE, TDS_OP_CURSORFETCH = TDS_SP_CURSORFETCH, TDS_OP_CURSOROPTION = TDS_SP_CURSOROPTION, TDS_OP_CURSORCLOSE = TDS_SP_CURSORCLOSE, TDS_OP_EXECUTESQL = TDS_SP_EXECUTESQL, TDS_OP_PREPARE = TDS_SP_PREPARE, TDS_OP_EXECUTE = TDS_SP_EXECUTE, TDS_OP_PREPEXEC = TDS_SP_PREPEXEC, TDS_OP_PREPEXECRPC = TDS_SP_PREPEXECRPC, TDS_OP_UNPREPARE = TDS_SP_UNPREPARE, /* sybase operations */ TDS_OP_DYN_DEALLOC = 100, } TDS_OPERATION; #define TDS_DBG_LOGIN __FILE__, ((__LINE__ << 4) | 11) #define TDS_DBG_HEADER __FILE__, ((__LINE__ << 4) | 10) #define TDS_DBG_FUNC __FILE__, ((__LINE__ << 4) | 7) #define TDS_DBG_INFO2 __FILE__, ((__LINE__ << 4) | 6) #define TDS_DBG_INFO1 __FILE__, ((__LINE__ << 4) | 5) #define TDS_DBG_NETWORK __FILE__, ((__LINE__ << 4) | 4) #define TDS_DBG_WARN __FILE__, ((__LINE__ << 4) | 3) #define TDS_DBG_ERROR __FILE__, ((__LINE__ << 4) | 2) #define TDS_DBG_SEVERE __FILE__, ((__LINE__ << 4) | 1) #define TDS_DBGFLAG_FUNC 0x80 #define TDS_DBGFLAG_INFO2 0x40 #define TDS_DBGFLAG_INFO1 0x20 #define TDS_DBGFLAG_NETWORK 0x10 #define TDS_DBGFLAG_WARN 0x08 #define TDS_DBGFLAG_ERROR 0x04 #define TDS_DBGFLAG_SEVERE 0x02 #define TDS_DBGFLAG_ALL 0xfff #define TDS_DBGFLAG_LOGIN 0x0800 #define TDS_DBGFLAG_HEADER 0x0400 #define TDS_DBGFLAG_PID 0x1000 #define TDS_DBGFLAG_TIME 0x2000 #define TDS_DBGFLAG_SOURCE 0x4000 #define TDS_DBGFLAG_THREAD 0x8000 #if 0 /** * An attempt at better logging. * Using these bitmapped values, various logging features can be turned on and off. * It can be especially helpful to turn packet data on/off for security reasons. */ enum TDS_DBG_LOG_STATE { TDS_DBG_LOGIN = (1 << 0) /**< for diagnosing login problems; otherwise the username/password information is suppressed. */ , TDS_DBG_API = (1 << 1) /**< Log calls to client libraries */ , TDS_DBG_ASYNC = (1 << 2) /**< Log asynchronous function starts or completes. */ , TDS_DBG_DIAG = (1 << 3) /**< Log client- and server-generated messages */ , TDS_DBG_error = (1 << 4) /* TODO: ^^^^^ make upper case when old #defines (above) are removed */ /* Log FreeTDS runtime/logic error occurs. */ , TDS_DBG_PACKET = (1 << 5) /**< Log hex dump of packets to/from the server. */ , TDS_DBG_LIBTDS = (1 << 6) /**< Log calls to (and in) libtds */ , TDS_DBG_CONFIG = (1 << 7) /**< replaces TDSDUMPCONFIG */ , TDS_DBG_DEFAULT = 0xFE /**< all above except login packets */ }; #endif typedef struct tds_result_info TDSCOMPUTEINFO; typedef TDSRESULTINFO TDSPARAMINFO; typedef struct tds_message { TDS_CHAR *server; TDS_CHAR *message; TDS_CHAR *proc_name; TDS_CHAR *sql_state; TDS_INT msgno; TDS_INT line_number; /* -1 .. 255 */ TDS_SMALLINT state; TDS_TINYINT priv_msg_type; TDS_TINYINT severity; /* for library-generated errors */ int oserr; } TDSMESSAGE; typedef struct tds_upd_col { struct tds_upd_col *next; TDS_INT colnamelength; char * columnname; } TDSUPDCOL; typedef enum { TDS_CURSOR_STATE_UNACTIONED = 0 /* initial value */ , TDS_CURSOR_STATE_REQUESTED = 1 /* called by ct_cursor */ , TDS_CURSOR_STATE_SENT = 2 /* sent to server */ , TDS_CURSOR_STATE_ACTIONED = 3 /* acknowledged by server */ } TDS_CURSOR_STATE; typedef struct tds_cursor_status { TDS_CURSOR_STATE declare; TDS_CURSOR_STATE cursor_row; TDS_CURSOR_STATE open; TDS_CURSOR_STATE fetch; TDS_CURSOR_STATE close; TDS_CURSOR_STATE dealloc; } TDS_CURSOR_STATUS; typedef enum tds_cursor_operation { TDS_CURSOR_POSITION = 0, TDS_CURSOR_UPDATE = 1, TDS_CURSOR_DELETE = 2, TDS_CURSOR_INSERT = 4 } TDS_CURSOR_OPERATION; typedef enum tds_cursor_fetch { TDS_CURSOR_FETCH_NEXT = 1, TDS_CURSOR_FETCH_PREV, TDS_CURSOR_FETCH_FIRST, TDS_CURSOR_FETCH_LAST, TDS_CURSOR_FETCH_ABSOLUTE, TDS_CURSOR_FETCH_RELATIVE } TDS_CURSOR_FETCH; /** * Holds informations about a cursor */ typedef struct tds_cursor { struct tds_cursor *next; /**< next in linked list, keep first */ TDS_INT ref_count; /**< reference counter so client can retain safely a pointer */ char *cursor_name; /**< name of the cursor */ TDS_INT cursor_id; /**< cursor id returned by the server after cursor declare */ TDS_TINYINT options; /**< read only|updatable TODO use it */ /** * true if cursor was marker to be closed when connection is idle */ TDS_TINYINT defer_close; char *query; /**< SQL query */ /* TODO for updatable columns */ /* TDS_TINYINT number_upd_cols; */ /**< number of updatable columns */ /* TDSUPDCOL *cur_col_list; */ /**< updatable column list */ TDS_INT cursor_rows; /**< number of cursor rows to fetch */ /* TDSPARAMINFO *params; */ /** cursor parameter */ TDS_CURSOR_STATUS status; TDS_USMALLINT srv_status; TDSRESULTINFO *res_info; /** row fetched from this cursor */ TDS_INT type, concurrency; } TDSCURSOR; /** * Current environment as reported by the server */ typedef struct tds_env { /** packet size (512-65535) */ int block_size; char *language; /** character set encoding */ char *charset; /** database name */ char *database; } TDSENV; /** * Holds information for a dynamic (also called prepared) query. */ typedef struct tds_dynamic { struct tds_dynamic *next; /**< next in linked list, keep first */ TDS_INT ref_count; /**< reference counter so client can retain safely a pointer */ /** numeric id for mssql7+*/ TDS_INT num_id; /** * id of dynamic. * Usually this id correspond to server one but if not specified * is generated automatically by libTDS */ char id[30]; /** * this dynamic query cannot be prepared so libTDS have to construct a simple query. * This can happen for instance is tds protocol doesn't support dynamics or trying * to prepare query under Sybase that have BLOBs as parameters. */ TDS_TINYINT emulated; /** * true if dynamic was marker to be closed when connection is idle */ TDS_TINYINT defer_close; /* int dyn_state; */ /* TODO use it */ TDSPARAMINFO *res_info; /**< query results */ /** * query parameters. * Mostly used executing query however is a good idea to prepare query * again if parameter type change in an incompatible way (ie different * types or larger size). Is also better to prepare a query knowing * parameter types earlier. */ TDSPARAMINFO *params; /** saved query, we need to know original query if prepare is impossible */ char *query; } TDSDYNAMIC; typedef enum { TDS_MULTIPLE_QUERY, TDS_MULTIPLE_EXECUTE, TDS_MULTIPLE_RPC } TDS_MULTIPLE_TYPE; typedef struct tds_multiple { TDS_MULTIPLE_TYPE type; unsigned int flags; } TDSMULTIPLE; /* forward declaration */ typedef struct tds_context TDSCONTEXT; typedef int (*err_handler_t) (const TDSCONTEXT *, TDSSOCKET *, TDSMESSAGE *); struct tds_context { TDSLOCALE *locale; void *parent; /* handlers */ int (*msg_handler) (const TDSCONTEXT *, TDSSOCKET *, TDSMESSAGE *); int (*err_handler) (const TDSCONTEXT *, TDSSOCKET *, TDSMESSAGE *); int (*int_handler) (void *); }; enum TDS_ICONV_ENTRY { client2ucs2 , client2server_chardata , initial_char_conv_count /* keep last */ }; typedef struct tds_authentication { TDS_UCHAR *packet; int packet_len; TDSRET (*free)(TDSCONNECTION* conn, struct tds_authentication * auth); TDSRET (*handle_next)(TDSSOCKET * tds, struct tds_authentication * auth, size_t len); } TDSAUTHENTICATION; typedef struct tds_packet { struct tds_packet *next; short sid; unsigned len, capacity; unsigned char buf[1]; } TDSPACKET; typedef struct tds_poll_wakeup { TDS_SYS_SOCKET s_signal, s_signaled; } TDSPOLLWAKEUP; /* field related to connection */ struct tds_connection { TDS_USMALLINT tds_version; TDS_UINT product_version; /**< version of product (Sybase/MS and full version) */ char *product_name; TDS_SYS_SOCKET s; /**< tcp socket, INVALID_SOCKET if not connected */ TDSPOLLWAKEUP wakeup; const TDSCONTEXT *tds_ctx; /** environment is shared between all sessions */ TDSENV env; /** * linked list of cursors allocated for this connection * contains only cursors allocated on the server */ TDSCURSOR *cursors; /** * list of dynamic allocated for this connection * contains only dynamic allocated on the server */ TDSDYNAMIC *dyns; int char_conv_count; TDSICONV **char_convs; TDS_UCHAR collation[5]; TDS_UCHAR tds72_transaction[8]; TDS_CAPABILITIES capabilities; unsigned int emul_little_endian:1; unsigned int use_iconv:1; unsigned int tds71rev1:1; unsigned int pending_close:1; /**< true is connection has pending closing (cursors or dynamic) */ unsigned int encrypt_single_packet:1; #if ENABLE_ODBC_MARS unsigned int mars:1; TDSSOCKET *in_net_tds; TDSPACKET *packets; TDSPACKET *recv_packet; TDSPACKET *send_packets; unsigned send_pos, recv_pos; tds_mutex list_mtx; #define BUSY_SOCKET ((TDSSOCKET*)(TDS_UINTPTR)1) #define TDSSOCKET_VALID(tds) (((TDS_UINTPTR)(tds)) > 1) struct tds_socket **sessions; unsigned num_sessions; unsigned num_cached_packets; TDSPACKET *packet_cache; #endif int spid; int client_spid; void *tls_session; #if defined(HAVE_GNUTLS) void *tls_credentials; #elif defined(HAVE_OPENSSL) void *tls_ctx; #else void *tls_dummy; #endif TDSAUTHENTICATION *authentication; char *server; }; /** * Information for a server connection */ struct tds_socket { #if ENABLE_ODBC_MARS TDSCONNECTION *conn; #else TDSCONNECTION conn[1]; #endif /** Input buffer. * Points to receiving packet buffer. * As input buffer contains just the raw packet actually this pointer * is the address of recv_packet->buf. */ unsigned char *in_buf; /** Output buffer. * Points to sending packet buffer. * Output buffer can contain additional data before the raw TDS packet * so this buffer can point some bytes after send_packet->buf. */ unsigned char *out_buf; /** Maximum size of packet pointed by out_buf. * The buffer is actually a bit larger to make possible to do some * optimizations (at least TDS_ADDITIONAL_SPACE bytes). */ unsigned int out_buf_max; unsigned in_pos; /**< current position in in_buf */ unsigned out_pos; /**< current position in out_buf */ unsigned in_len; /**< input buffer length */ unsigned char in_flag; /**< input buffer type */ unsigned char out_flag; /**< output buffer type */ void *parent; #if ENABLE_ODBC_MARS short sid; tds_condition packet_cond; TDS_UINT recv_seq; TDS_UINT send_seq; TDS_UINT recv_wnd; TDS_UINT send_wnd; #endif /* packet we received */ TDSPACKET *recv_packet; /** packet we are preparing to send */ TDSPACKET *send_packet; /** * Current query information. * Contains information in process, both normal and compute results. * This pointer shouldn't be freed; it's just an alias to another structure. */ TDSRESULTINFO *current_results; TDSRESULTINFO *res_info; TDS_UINT num_comp_info; TDSCOMPUTEINFO **comp_info; TDSPARAMINFO *param_info; TDSCURSOR *cur_cursor; /**< cursor in use */ TDS_TINYINT bulk_query; /**< true is query sent was a bulk query so we need to switch state to QUERYING */ TDS_TINYINT has_status; /**< true is ret_status is valid */ bool in_row; /**< true if we are getting rows */ TDS_INT ret_status; /**< return status from store procedure */ TDS_STATE state; volatile unsigned char in_cancel; /**< indicate we are waiting a cancel reply; discard tokens till acknowledge; 1 mean we have to send cancel packet, 2 already sent. */ TDS_INT8 rows_affected; /**< rows updated/deleted/inserted/selected, TDS_NO_COUNT if not valid */ TDS_INT query_timeout; TDSDYNAMIC *cur_dyn; /**< dynamic structure in use */ TDSLOGIN *login; /**< config for login stuff. After login this field is NULL */ void (*env_chg_func) (TDSSOCKET * tds, int type, char *oldval, char *newval); TDS_OPERATION current_op; int option_value; tds_mutex wire_mtx; }; #define tds_get_ctx(tds) ((tds)->conn->tds_ctx) #define tds_set_ctx(tds, val) do { ((tds)->conn->tds_ctx) = (val); } while(0) #define tds_get_parent(tds) ((tds)->parent) #define tds_set_parent(tds, val) do { ((tds)->parent) = (val); } while(0) #define tds_get_s(tds) ((tds)->conn->s) #define tds_set_s(tds, val) do { ((tds)->conn->s) = (val); } while(0) /* config.c */ const TDS_COMPILETIME_SETTINGS *tds_get_compiletime_settings(void); typedef void (*TDSCONFPARSE) (const char *option, const char *value, void *param); int tds_read_conf_section(FILE * in, const char *section, TDSCONFPARSE tds_conf_parse, void *parse_param); int tds_read_conf_file(TDSLOGIN * login, const char *server); void tds_parse_conf_section(const char *option, const char *value, void *param); TDSLOGIN *tds_read_config_info(TDSSOCKET * tds, TDSLOGIN * login, TDSLOCALE * locale); void tds_fix_login(TDSLOGIN* login); TDS_USMALLINT * tds_config_verstr(const char *tdsver, TDSLOGIN* login); struct addrinfo *tds_lookup_host(const char *servername); TDSRET tds_lookup_host_set(const char *servername, struct addrinfo **addr); const char *tds_addrinfo2str(struct addrinfo *addr, char *name, int namemax); TDSRET tds_set_interfaces_file_loc(const char *interfloc); extern const char STD_DATETIME_FMT[]; int tds_parse_boolean(const char *value, int default_value); int tds_config_boolean(const char *option, const char *value, TDSLOGIN * login); TDSLOCALE *tds_get_locale(void); TDSRET tds_alloc_row(TDSRESULTINFO * res_info); TDSRET tds_alloc_compute_row(TDSCOMPUTEINFO * res_info); BCPCOLDATA * tds_alloc_bcp_column_data(unsigned int column_size); TDSDYNAMIC *tds_lookup_dynamic(TDSCONNECTION * conn, const char *id); /*@observer@*/ const char *tds_prtype(int token); int tds_get_varint_size(TDSCONNECTION * conn, int datatype); TDS_SERVER_TYPE tds_get_cardinal_type(TDS_SERVER_TYPE datatype, int usertype); /* iconv.c */ TDSRET tds_iconv_open(TDSCONNECTION * conn, const char *charset, int use_utf16); void tds_iconv_close(TDSCONNECTION * conn); void tds_srv_charset_changed(TDSCONNECTION * conn, const char *charset); void tds7_srv_charset_changed(TDSCONNECTION * conn, int sql_collate, int lcid); int tds_iconv_alloc(TDSCONNECTION * conn); void tds_iconv_free(TDSCONNECTION * conn); TDSICONV *tds_iconv_from_collate(TDSCONNECTION * conn, TDS_UCHAR collate[5]); /* threadsafe.c */ char *tds_timestamp_str(char *str, int maxlen); struct tm *tds_localtime_r(const time_t *timep, struct tm *result); struct hostent *tds_gethostbyname_r(const char *servername, struct hostent *result, char *buffer, int buflen, int *h_errnop); int tds_getservice(const char *name); char *tds_get_homedir(void); /* mem.c */ void tds_free_socket(TDSSOCKET * tds); void tds_free_all_results(TDSSOCKET * tds); void tds_free_results(TDSRESULTINFO * res_info); void tds_free_param_results(TDSPARAMINFO * param_info); void tds_free_param_result(TDSPARAMINFO * param_info); void tds_free_msg(TDSMESSAGE * message); void tds_cursor_deallocated(TDSCONNECTION *conn, TDSCURSOR *cursor); void tds_release_cursor(TDSCURSOR **pcursor); void tds_free_bcp_column_data(BCPCOLDATA * coldata); TDSRESULTINFO *tds_alloc_results(TDS_USMALLINT num_cols); TDSCOMPUTEINFO **tds_alloc_compute_results(TDSSOCKET * tds, TDS_USMALLINT num_cols, TDS_USMALLINT by_cols); TDSCONTEXT *tds_alloc_context(void * parent); void tds_free_context(TDSCONTEXT * locale); TDSPARAMINFO *tds_alloc_param_result(TDSPARAMINFO * old_param); void tds_free_input_params(TDSDYNAMIC * dyn); void tds_release_dynamic(TDSDYNAMIC ** dyn); static inline void tds_release_cur_dyn(TDSSOCKET * tds) { tds_release_dynamic(&tds->cur_dyn); } void tds_dynamic_deallocated(TDSCONNECTION *conn, TDSDYNAMIC *dyn); void tds_set_cur_dyn(TDSSOCKET *tds, TDSDYNAMIC *dyn); TDSSOCKET *tds_realloc_socket(TDSSOCKET * tds, size_t bufsize); char *tds_alloc_client_sqlstate(int msgno); char *tds_alloc_lookup_sqlstate(TDSSOCKET * tds, int msgno); TDSLOGIN *tds_alloc_login(int use_environment); TDSDYNAMIC *tds_alloc_dynamic(TDSCONNECTION * conn, const char *id); void tds_free_login(TDSLOGIN * login); TDSLOGIN *tds_init_login(TDSLOGIN * login, TDSLOCALE * locale); TDSLOCALE *tds_alloc_locale(void); void *tds_alloc_param_data(TDSCOLUMN * curparam); void tds_free_locale(TDSLOCALE * locale); TDSCURSOR * tds_alloc_cursor(TDSSOCKET * tds, const char *name, TDS_INT namelen, const char *query, TDS_INT querylen); void tds_free_row(TDSRESULTINFO * res_info, unsigned char *row); TDSSOCKET *tds_alloc_socket(TDSCONTEXT * context, unsigned int bufsize); TDSSOCKET *tds_alloc_additional_socket(TDSCONNECTION *conn); void tds_set_current_results(TDSSOCKET *tds, TDSRESULTINFO *info); void tds_detach_results(TDSRESULTINFO *info); void * tds_realloc(void **pp, size_t new_size); #define TDS_RESIZE(p, n_elem) \ tds_realloc((void **) &(p), sizeof(*(p)) * (size_t) (n_elem)) #define tds_new(type, n) ((type *) malloc(sizeof(type) * (n))) #define tds_new0(type, n) ((type *) calloc(n, sizeof(type))) TDSPACKET *tds_alloc_packet(void *buf, unsigned len); TDSPACKET *tds_realloc_packet(TDSPACKET *packet, unsigned len); void tds_free_packets(TDSPACKET *packet); TDSBCPINFO *tds_alloc_bcpinfo(void); void tds_free_bcpinfo(TDSBCPINFO *bcpinfo); void tds_deinit_bcpinfo(TDSBCPINFO *bcpinfo); /* login.c */ void tds_set_packet(TDSLOGIN * tds_login, int packet_size); void tds_set_port(TDSLOGIN * tds_login, int port); bool tds_set_passwd(TDSLOGIN * tds_login, const char *password) TDS_WUR; void tds_set_bulk(TDSLOGIN * tds_login, TDS_TINYINT enabled); bool tds_set_user(TDSLOGIN * tds_login, const char *username) TDS_WUR; bool tds_set_app(TDSLOGIN * tds_login, const char *application) TDS_WUR; bool tds_set_host(TDSLOGIN * tds_login, const char *hostname) TDS_WUR; bool tds_set_library(TDSLOGIN * tds_login, const char *library) TDS_WUR; bool tds_set_server(TDSLOGIN * tds_login, const char *server) TDS_WUR; bool tds_set_client_charset(TDSLOGIN * tds_login, const char *charset) TDS_WUR; bool tds_set_language(TDSLOGIN * tds_login, const char *language) TDS_WUR; void tds_set_version(TDSLOGIN * tds_login, TDS_TINYINT major_ver, TDS_TINYINT minor_ver); int tds_connect_and_login(TDSSOCKET * tds, TDSLOGIN * login); /* query.c */ void tds_start_query(TDSSOCKET *tds, unsigned char packet_type); TDSRET tds_submit_query(TDSSOCKET * tds, const char *query); TDSRET tds_submit_query_params(TDSSOCKET * tds, const char *query, TDSPARAMINFO * params, TDSHEADERS * head); TDSRET tds_submit_queryf(TDSSOCKET * tds, const char *queryf, ...); TDSRET tds_submit_prepare(TDSSOCKET * tds, const char *query, const char *id, TDSDYNAMIC ** dyn_out, TDSPARAMINFO * params); TDSRET tds_submit_execdirect(TDSSOCKET * tds, const char *query, TDSPARAMINFO * params, TDSHEADERS * head); TDSRET tds71_submit_prepexec(TDSSOCKET * tds, const char *query, const char *id, TDSDYNAMIC ** dyn_out, TDSPARAMINFO * params); TDSRET tds_submit_execute(TDSSOCKET * tds, TDSDYNAMIC * dyn); TDSRET tds_send_cancel(TDSSOCKET * tds); const char *tds_next_placeholder(const char *start); int tds_count_placeholders(const char *query); int tds_needs_unprepare(TDSCONNECTION * conn, TDSDYNAMIC * dyn); TDSRET tds_deferred_unprepare(TDSCONNECTION * conn, TDSDYNAMIC * dyn); TDSRET tds_submit_unprepare(TDSSOCKET * tds, TDSDYNAMIC * dyn); TDSRET tds_submit_rpc(TDSSOCKET * tds, const char *rpc_name, TDSPARAMINFO * params, TDSHEADERS * head); TDSRET tds_submit_optioncmd(TDSSOCKET * tds, TDS_OPTION_CMD command, TDS_OPTION option, TDS_OPTION_ARG *param, TDS_INT param_size); TDSRET tds_submit_begin_tran(TDSSOCKET *tds); TDSRET tds_submit_rollback(TDSSOCKET *tds, int cont); TDSRET tds_submit_commit(TDSSOCKET *tds, int cont); TDSRET tds_disconnect(TDSSOCKET * tds); size_t tds_quote_id(TDSSOCKET * tds, char *buffer, const char *id, int idlen); size_t tds_quote_string(TDSSOCKET * tds, char *buffer, const char *str, int len); const char *tds_skip_comment(const char *s); const char *tds_skip_quoted(const char *s); size_t tds_fix_column_size(TDSSOCKET * tds, TDSCOLUMN * curcol); const char *tds_convert_string(TDSSOCKET * tds, TDSICONV * char_conv, const char *s, int len, size_t *out_len); void tds_convert_string_free(const char *original, const char *converted); #if !ENABLE_EXTRA_CHECKS #define tds_convert_string_free(original, converted) \ do { if (original != converted) free((char*) converted); } while(0) #endif TDSRET tds_get_column_declaration(TDSSOCKET * tds, TDSCOLUMN * curcol, char *out); TDSRET tds_cursor_declare(TDSSOCKET * tds, TDSCURSOR * cursor, TDSPARAMINFO *params, int *send); TDSRET tds_cursor_setrows(TDSSOCKET * tds, TDSCURSOR * cursor, int *send); TDSRET tds_cursor_open(TDSSOCKET * tds, TDSCURSOR * cursor, TDSPARAMINFO *params, int *send); TDSRET tds_cursor_fetch(TDSSOCKET * tds, TDSCURSOR * cursor, TDS_CURSOR_FETCH fetch_type, TDS_INT i_row); TDSRET tds_cursor_get_cursor_info(TDSSOCKET * tds, TDSCURSOR * cursor, TDS_UINT * row_number, TDS_UINT * row_count); TDSRET tds_cursor_close(TDSSOCKET * tds, TDSCURSOR * cursor); TDSRET tds_cursor_dealloc(TDSSOCKET * tds, TDSCURSOR * cursor); TDSRET tds_deferred_cursor_dealloc(TDSCONNECTION *conn, TDSCURSOR * cursor); TDSRET tds_cursor_update(TDSSOCKET * tds, TDSCURSOR * cursor, TDS_CURSOR_OPERATION op, TDS_INT i_row, TDSPARAMINFO * params); TDSRET tds_cursor_setname(TDSSOCKET * tds, TDSCURSOR * cursor); TDSRET tds_multiple_init(TDSSOCKET *tds, TDSMULTIPLE *multiple, TDS_MULTIPLE_TYPE type, TDSHEADERS * head); TDSRET tds_multiple_done(TDSSOCKET *tds, TDSMULTIPLE *multiple); TDSRET tds_multiple_query(TDSSOCKET *tds, TDSMULTIPLE *multiple, const char *query, TDSPARAMINFO * params); TDSRET tds_multiple_execute(TDSSOCKET *tds, TDSMULTIPLE *multiple, TDSDYNAMIC * dyn); /* token.c */ TDSRET tds_process_cancel(TDSSOCKET * tds); int tds_get_token_size(int marker); TDSRET tds_process_login_tokens(TDSSOCKET * tds); TDSRET tds_process_simple_query(TDSSOCKET * tds); int tds5_send_optioncmd(TDSSOCKET * tds, TDS_OPTION_CMD tds_command, TDS_OPTION tds_option, TDS_OPTION_ARG * tds_argument, TDS_INT * tds_argsize); TDSRET tds_process_tokens(TDSSOCKET * tds, /*@out@*/ TDS_INT * result_type, /*@out@*/ int *done_flags, unsigned flag); int determine_adjusted_size(const TDSICONV * char_conv, int size); /* data.c */ void tds_set_param_type(TDSCONNECTION * conn, TDSCOLUMN * curcol, TDS_SERVER_TYPE type); void tds_set_column_type(TDSCONNECTION * conn, TDSCOLUMN * curcol, TDS_SERVER_TYPE type); /* tds_convert.c */ TDSRET tds_datecrack(TDS_INT datetype, const void *di, TDSDATEREC * dr); TDS_SERVER_TYPE tds_get_conversion_type(TDS_SERVER_TYPE srctype, int colsize); extern const char tds_hex_digits[]; /* write.c */ int tds_init_write_buf(TDSSOCKET * tds); int tds_put_n(TDSSOCKET * tds, const void *buf, size_t n); int tds_put_string(TDSSOCKET * tds, const char *buf, int len); int tds_put_int(TDSSOCKET * tds, TDS_INT i); int tds_put_int8(TDSSOCKET * tds, TDS_INT8 i); int tds_put_smallint(TDSSOCKET * tds, TDS_SMALLINT si); /** Output a tinyint value */ #define tds_put_tinyint(tds, ti) tds_put_byte(tds,ti) int tds_put_byte(TDSSOCKET * tds, unsigned char c); TDSRET tds_flush_packet(TDSSOCKET * tds); int tds_put_buf(TDSSOCKET * tds, const unsigned char *buf, int dsize, int ssize); /* read.c */ unsigned char tds_get_byte(TDSSOCKET * tds); void tds_unget_byte(TDSSOCKET * tds); unsigned char tds_peek(TDSSOCKET * tds); TDS_USMALLINT tds_get_usmallint(TDSSOCKET * tds); #define tds_get_smallint(tds) ((TDS_SMALLINT) tds_get_usmallint(tds)) TDS_UINT tds_get_uint(TDSSOCKET * tds); #define tds_get_int(tds) ((TDS_INT) tds_get_uint(tds)) TDS_UINT8 tds_get_uint8(TDSSOCKET * tds); #define tds_get_int8(tds) ((TDS_INT8) tds_get_uint8(tds)) size_t tds_get_string(TDSSOCKET * tds, size_t string_len, char *dest, size_t dest_size); TDSRET tds_get_char_data(TDSSOCKET * tds, char *dest, size_t wire_size, TDSCOLUMN * curcol); void *tds_get_n(TDSSOCKET * tds, /*@out@*/ /*@null@*/ void *dest, size_t n); int tds_get_size_by_type(TDS_SERVER_TYPE servertype); DSTR* tds_dstr_get(TDSSOCKET * tds, DSTR * s, size_t len); /* util.c */ int tdserror (const TDSCONTEXT * tds_ctx, TDSSOCKET * tds, int msgno, int errnum); TDS_STATE tds_set_state(TDSSOCKET * tds, TDS_STATE state); void tds_swap_bytes(void *buf, int bytes); #ifdef ENABLE_DEVELOPING unsigned int tds_gettime_ms(void); #endif char *tds_strndup(const void *s, TDS_INTPTR len); /* log.c */ void tdsdump_off(void); void tdsdump_on(void); int tdsdump_isopen(void); #include int tdsdump_open(const char *filename); #include void tdsdump_close(void); void tdsdump_dump_buf(const char* file, unsigned int level_line, const char *msg, const void *buf, size_t length); void tdsdump_col(const TDSCOLUMN *col); #undef tdsdump_log void tdsdump_log(const char* file, unsigned int level_line, const char *fmt, ...) #if defined(__GNUC__) && __GNUC__ >= 2 #if defined(__MINGW32__) __attribute__ ((__format__ (ms_printf, 3, 4))) #else __attribute__ ((__format__ (__printf__, 3, 4))) #endif #endif ; #define TDSDUMP_LOG_FAST if (TDS_UNLIKELY(tds_write_dump)) tdsdump_log #define tdsdump_log TDSDUMP_LOG_FAST #define TDSDUMP_BUF_FAST if (TDS_UNLIKELY(tds_write_dump)) tdsdump_dump_buf #define tdsdump_dump_buf TDSDUMP_BUF_FAST extern int tds_write_dump; extern int tds_debug_flags; extern int tds_g_append_mode; /* net.c */ TDSERRNO tds_open_socket(TDSSOCKET * tds, struct addrinfo *ipaddr, unsigned int port, int timeout, int *p_oserr); void tds_close_socket(TDSSOCKET * tds); int tds7_get_instance_ports(FILE *output, struct addrinfo *addr); int tds7_get_instance_port(struct addrinfo *addr, const char *instance); char *tds_prwsaerror(int erc); void tds_prwsaerror_free(char *s); int tds_connection_read(TDSSOCKET * tds, unsigned char *buf, int buflen); int tds_connection_write(TDSSOCKET *tds, const unsigned char *buf, int buflen, int final); #define TDSSELREAD POLLIN #define TDSSELWRITE POLLOUT int tds_select(TDSSOCKET * tds, unsigned tds_sel, int timeout_seconds); void tds_connection_close(TDSCONNECTION *conn); int tds_goodread(TDSSOCKET * tds, unsigned char *buf, int buflen); int tds_goodwrite(TDSSOCKET * tds, const unsigned char *buffer, size_t buflen); void tds_socket_flush(TDS_SYS_SOCKET sock); int tds_socket_set_nonblocking(TDS_SYS_SOCKET sock); int tds_wakeup_init(TDSPOLLWAKEUP *wakeup); void tds_wakeup_close(TDSPOLLWAKEUP *wakeup); void tds_wakeup_send(TDSPOLLWAKEUP *wakeup, char cancel); static inline TDS_SYS_SOCKET tds_wakeup_get_fd(const TDSPOLLWAKEUP *wakeup) { return wakeup->s_signaled; } /* packet.c */ int tds_read_packet(TDSSOCKET * tds); TDSRET tds_write_packet(TDSSOCKET * tds, unsigned char final); #if ENABLE_ODBC_MARS int tds_append_cancel(TDSSOCKET *tds); TDSRET tds_append_fin(TDSSOCKET *tds); #else int tds_put_cancel(TDSSOCKET * tds); #endif /* vstrbuild.c */ TDSRET tds_vstrbuild(char *buffer, int buflen, int *resultlen, const char *text, int textlen, const char *formats, int formatlen, va_list ap); /* numeric.c */ char *tds_money_to_string(const TDS_MONEY * money, char *s); TDS_INT tds_numeric_to_string(const TDS_NUMERIC * numeric, char *s); TDS_INT tds_numeric_change_prec_scale(TDS_NUMERIC * numeric, unsigned char new_prec, unsigned char new_scale); /* getmac.c */ void tds_getmac(TDS_SYS_SOCKET s, unsigned char mac[6]); /* challenge.c */ #ifndef HAVE_SSPI TDSAUTHENTICATION * tds_ntlm_get_auth(TDSSOCKET * tds); TDSAUTHENTICATION * tds_gss_get_auth(TDSSOCKET * tds); #else TDSAUTHENTICATION * tds_sspi_get_auth(TDSSOCKET * tds); #endif /* random.c */ void tds_random_buffer(unsigned char *out, int len); /* sec_negotiate.c */ TDSAUTHENTICATION * tds5_negotiate_get_auth(TDSSOCKET * tds); void tds5_negotiate_set_msg_type(TDSSOCKET * tds, TDSAUTHENTICATION * auth, unsigned msg_type); /* bulk.c */ /** bcp direction */ enum tds_bcp_directions { TDS_BCP_IN = 1, TDS_BCP_OUT = 2, TDS_BCP_QUERYOUT = 3 }; struct tds_bcpinfo { const char *hint; void *parent; DSTR tablename; TDS_CHAR *insert_stmt; TDS_INT direction; TDS_INT identity_insert_on; TDS_INT xfer_init; TDS_INT bind_count; TDSRESULTINFO *bindinfo; }; TDSRET tds_bcp_init(TDSSOCKET *tds, TDSBCPINFO *bcpinfo); typedef TDSRET (*tds_bcp_get_col_data) (TDSBCPINFO *bulk, TDSCOLUMN *bcpcol, int offset); typedef void (*tds_bcp_null_error) (TDSBCPINFO *bulk, int index, int offset); TDSRET tds_bcp_send_record(TDSSOCKET *tds, TDSBCPINFO *bcpinfo, tds_bcp_get_col_data get_col_data, tds_bcp_null_error null_error, int offset); TDSRET tds_bcp_done(TDSSOCKET *tds, int *rows_copied); TDSRET tds_bcp_start(TDSSOCKET *tds, TDSBCPINFO *bcpinfo); TDSRET tds_bcp_start_copy_in(TDSSOCKET *tds, TDSBCPINFO *bcpinfo); TDSRET tds_bcp_fread(TDSSOCKET * tds, TDSICONV * conv, FILE * stream, const char *terminator, size_t term_len, char **outbuf, size_t * outbytes); TDSRET tds_writetext_start(TDSSOCKET *tds, const char *objname, const char *textptr, const char *timestamp, int with_log, TDS_UINT size); TDSRET tds_writetext_continue(TDSSOCKET *tds, const TDS_UCHAR *text, TDS_UINT size); TDSRET tds_writetext_end(TDSSOCKET *tds); static inline bool tds_capability_enabled(const TDS_CAPABILITY_TYPE *cap, unsigned cap_num) { return (cap->values[sizeof(cap->values)-1-(cap_num>>3)] >> (cap_num&7)) & 1; } #define tds_capability_has_req(conn, cap) \ tds_capability_enabled(&conn->capabilities.types[0], cap) #define IS_TDS42(x) (x->tds_version==0x402) #define IS_TDS46(x) (x->tds_version==0x406) #define IS_TDS50(x) (x->tds_version==0x500) #define IS_TDS70(x) (x->tds_version==0x700) #define IS_TDS71(x) (x->tds_version==0x701) #define IS_TDS72(x) (x->tds_version==0x702) #define IS_TDS73(x) (x->tds_version==0x703) #define IS_TDS50_PLUS(x) ((x)->tds_version>=0x500) #define IS_TDS7_PLUS(x) ((x)->tds_version>=0x700) #define IS_TDS71_PLUS(x) ((x)->tds_version>=0x701) #define IS_TDS72_PLUS(x) ((x)->tds_version>=0x702) #define IS_TDS73_PLUS(x) ((x)->tds_version>=0x703) #define IS_TDS74_PLUS(x) ((x)->tds_version>=0x704) #define TDS_MAJOR(x) ((x)->tds_version >> 8) #define TDS_MINOR(x) ((x)->tds_version & 0xff) #define IS_TDSDEAD(x) (((x) == NULL) || (x)->state == TDS_DEAD) /** Check if product is Sybase (such as Adaptive Server Enterrprice). x should be a TDSSOCKET*. */ #define TDS_IS_SYBASE(x) (!((x)->conn->product_version & 0x80000000u)) /** Check if product is Microsft SQL Server. x should be a TDSSOCKET*. */ #define TDS_IS_MSSQL(x) (((x)->conn->product_version & 0x80000000u)!=0) /** Calc a version number for mssql. Use with TDS_MS_VER(7,0,842). * For test for a range of version you can use check like * if (tds->product_version >= TDS_MS_VER(7,0,0) && tds->product_version < TDS_MS_VER(8,0,0)) */ #define TDS_MS_VER(maj,min,x) (0x80000000u|((maj)<<24)|((min)<<16)|(x)) /* TODO test if not similar to ms one*/ /** Calc a version number for Sybase. */ #define TDS_SYB_VER(maj,min,x) (((maj)<<24)|((min)<<16)|(x)<<8) #ifdef __cplusplus #if 0 { #endif } #endif #include #define TDS_PUT_INT(tds,v) tds_put_int((tds), ((TDS_INT)(v))) #define TDS_PUT_SMALLINT(tds,v) tds_put_smallint((tds), ((TDS_SMALLINT)(v))) #define TDS_PUT_BYTE(tds,v) tds_put_byte((tds), ((unsigned char)(v))) #endif /* _tds_h_ */ freetds-1.00.82/include/freetds/odbc.h100644 025423 025423 00000051620 13142276621 0013175/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns * Copyright (C) 2004-2010 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef _sql_h_ #define _sql_h_ #define TDS_DONT_DEFINE_DEFAULT_FUNCTIONS #include #include #include #if defined(UNIXODBC) || defined(_WIN32) || defined(TDS_NO_DM) #include #include #if defined(UNIXODBC) || defined(_WIN32) #include #endif #else /* IODBC */ #include #include #ifdef HAVE_IODBCINST_H #include #endif /* HAVE_IODBCINST_H */ #endif #ifndef HAVE_SQLLEN #ifndef SQLULEN #define SQLULEN SQLUINTEGER #endif #ifndef SQLLEN #define SQLLEN SQLINTEGER #endif #endif #ifndef HAVE_SQLSETPOSIROW #define SQLSETPOSIROW SQLUSMALLINT #endif #ifndef HAVE_SQLROWOFFSET #define SQLROWOFFSET SQLLEN #endif #ifndef HAVE_SQLROWSETSIZE #define SQLROWSETSIZE SQLULEN #endif #ifdef __cplusplus extern "C" { #if 0 } #endif #endif #include #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__) #define ODBC_API SQL_API __attribute__((externally_visible)) #else #define ODBC_API SQL_API #endif #if (defined(_WIN32) || defined(__CYGWIN__)) && defined(__GNUC__) # define ODBC_PUBLIC __attribute__((dllexport)) #else # define ODBC_PUBLIC #endif #define ODBC_MAX(a,b) ( (a) > (b) ? (a) : (b) ) #define ODBC_MIN(a,b) ( (a) < (b) ? (a) : (b) ) struct _sql_error { const char *msg; char state2[6]; char state3[6]; TDS_UINT native; char *server; int linenum; int msgstate; int row; }; struct _sql_errors { struct _sql_error *errs; int num_errors; SQLRETURN lastrc; char ranked; }; typedef struct _sql_errors TDS_ERRS; #if ENABLE_EXTRA_CHECKS void odbc_check_struct_extra(void *p); #else static inline void odbc_check_struct_extra(void *p) {} #endif #define ODBC_RETURN(handle, rc) \ do { odbc_check_struct_extra(handle); \ return handle->errs.lastrc = (rc); } while(0) #define ODBC_RETURN_(handle) \ do { odbc_check_struct_extra(handle); \ return handle->errs.lastrc; } while(0) #define ODBC_EXIT(handle, rc) \ do { SQLRETURN _odbc_rc = handle->errs.lastrc = (rc); \ odbc_check_struct_extra(handle); \ tds_mutex_unlock(&handle->mtx); \ return _odbc_rc; } while(0) #define ODBC_EXIT_(handle) \ do { SQLRETURN _odbc_rc = handle->errs.lastrc; \ odbc_check_struct_extra(handle); \ tds_mutex_unlock(&handle->mtx); \ return _odbc_rc; } while(0) /** reset errors */ void odbc_errs_reset(struct _sql_errors *errs); /** add an error to list */ void odbc_errs_add(struct _sql_errors *errs, const char *sqlstate, const char *msg); /** Add an error to list. This functions is for error that came from server */ void odbc_errs_add_rdbms(struct _sql_errors *errs, TDS_UINT native, const char *sqlstate, const char *msg, int linenum, int msgstate, const char *server, int row); struct _dheader { SQLSMALLINT sql_desc_alloc_type; SQLINTEGER sql_desc_bind_type; SQLULEN sql_desc_array_size; /* TODO SQLLEN ?? see http://support.microsoft.com/default.aspx?scid=kb;en-us;298678 */ SQLSMALLINT sql_desc_count; SQLUSMALLINT *sql_desc_array_status_ptr; SQLULEN *sql_desc_rows_processed_ptr; SQLLEN *sql_desc_bind_offset_ptr; }; struct _drecord { SQLUINTEGER sql_desc_auto_unique_value; DSTR sql_desc_base_column_name; DSTR sql_desc_base_table_name; SQLINTEGER sql_desc_case_sensitive; DSTR sql_desc_catalog_name; SQLSMALLINT sql_desc_concise_type; SQLPOINTER sql_desc_data_ptr; SQLSMALLINT sql_desc_datetime_interval_code; SQLINTEGER sql_desc_datetime_interval_precision; SQLLEN sql_desc_display_size; SQLSMALLINT sql_desc_fixed_prec_scale; SQLLEN *sql_desc_indicator_ptr; DSTR sql_desc_label; SQLULEN sql_desc_length; /* this point to a constant buffer, do not free or modify */ const char *sql_desc_literal_prefix; /* this point to a constant buffer, do not free or modify */ const char *sql_desc_literal_suffix; DSTR sql_desc_local_type_name; DSTR sql_desc_name; SQLSMALLINT sql_desc_nullable; SQLINTEGER sql_desc_num_prec_radix; SQLLEN sql_desc_octet_length; SQLLEN *sql_desc_octet_length_ptr; SQLSMALLINT sql_desc_parameter_type; SQLSMALLINT sql_desc_precision; SQLSMALLINT sql_desc_rowver; SQLSMALLINT sql_desc_scale; DSTR sql_desc_schema_name; SQLSMALLINT sql_desc_searchable; DSTR sql_desc_table_name; SQLSMALLINT sql_desc_type; /* this point to a constant buffer, do not free or modify */ const char *sql_desc_type_name; SQLSMALLINT sql_desc_unnamed; SQLSMALLINT sql_desc_unsigned; SQLSMALLINT sql_desc_updatable; }; struct _hdesc { SQLSMALLINT htype; /* do not reorder this field */ struct _sql_errors errs; /* do not reorder this field */ tds_mutex mtx; int type; SQLHANDLE parent; struct _dheader header; struct _drecord *records; }; typedef struct _hdesc TDS_DESC; #define DESC_IRD 1 #define DESC_IPD 2 #define DESC_ARD 3 #define DESC_APD 4 struct _heattr { SQLUINTEGER connection_pooling; SQLUINTEGER cp_match; SQLINTEGER odbc_version; SQLINTEGER output_nts; }; struct _hchk { SQLSMALLINT htype; /* do not reorder this field */ struct _sql_errors errs; /* do not reorder this field */ tds_mutex mtx; }; struct _henv { SQLSMALLINT htype; /* do not reorder this field */ struct _sql_errors errs; /* do not reorder this field */ tds_mutex mtx; TDSCONTEXT *tds_ctx; struct _heattr attr; }; struct _hcattr { SQLUINTEGER access_mode; SQLUINTEGER async_enable; SQLUINTEGER auto_ipd; SQLUINTEGER autocommit; SQLUINTEGER connection_dead; SQLUINTEGER connection_timeout; DSTR current_catalog; SQLUINTEGER login_timeout; SQLUINTEGER metadata_id; SQLUINTEGER odbc_cursors; SQLUINTEGER packet_size; SQLHWND quite_mode; DSTR translate_lib; SQLUINTEGER translate_option; SQLUINTEGER txn_isolation; SQLUINTEGER mars_enabled; SQLUINTEGER cursor_type; SQLUINTEGER bulk_enabled; #ifdef TDS_NO_DM SQLUINTEGER trace; DSTR tracefile; #endif }; #define TDS_MAX_APP_DESC 100 struct _hstmt; struct _hdbc { SQLSMALLINT htype; /* do not reorder this field */ struct _sql_errors errs; /* do not reorder this field */ tds_mutex mtx; struct _henv *env; TDSSOCKET *tds_socket; DSTR dsn; DSTR oldpwd; #ifdef ENABLE_ODBC_WIDE DSTR original_charset; TDSICONV *mb_conv; #endif /** * Statement executing. This should be set AFTER sending query * to avoid race condition and assure to not overwrite it if * another statement is executing a query. */ struct _hstmt *current_statement; /** list of all statements allocated from this connection */ struct _hstmt *stmt_list; struct _hcattr attr; /** descriptors associated to connection */ TDS_DESC *uad[TDS_MAX_APP_DESC]; /** <>0 if server handle cursors */ unsigned int cursor_support:1; unsigned int use_oldpwd:1; TDS_INT default_query_timeout; TDSBCPINFO *bcpinfo; char *bcphint; }; struct _hsattr { /* TODO remove IRD, ARD, IPD, APD from statement, do not duplicate */ /* TDS_DESC *app_row_desc; */ /* TDS_DESC *app_param_desc; */ SQLUINTEGER async_enable; SQLUINTEGER concurrency; SQLUINTEGER cursor_scrollable; SQLUINTEGER cursor_sensitivity; SQLUINTEGER cursor_type; SQLUINTEGER enable_auto_ipd; SQLPOINTER fetch_bookmark_ptr; SQLULEN keyset_size; SQLULEN max_length; SQLULEN max_rows; SQLUINTEGER metadata_id; SQLUINTEGER noscan; /* apd->sql_desc_bind_offset_ptr */ /* SQLUINTEGER *param_bind_offset_ptr; */ /* apd->sql_desc_bind_type */ /* SQLUINTEGER param_bind_type; */ /* apd->sql_desc_array_status_ptr */ /* SQLUSMALLINT *param_operation_ptr; */ /* ipd->sql_desc_array_status_ptr */ /* SQLUSMALLINT *param_status_ptr; */ /* ipd->sql_desc_rows_processed_ptr */ /* SQLUSMALLINT *params_processed_ptr; */ /* apd->sql_desc_array_size */ /* SQLUINTEGER paramset_size; */ SQLUINTEGER query_timeout; SQLUINTEGER retrieve_data; /* ard->sql_desc_bind_offset_ptr */ /* SQLUINTEGER *row_bind_offset_ptr; */ /* ard->sql_desc_array_size */ /* SQLUINTEGER row_array_size; */ /* ard->sql_desc_bind_type */ /* SQLUINTEGER row_bind_type; */ SQLULEN row_number; /* ard->sql_desc_array_status_ptr */ /* SQLUINTEGER *row_operation_ptr; */ /* ird->sql_desc_array_status_ptr */ /* SQLUINTEGER *row_status_ptr; */ /* ird->sql_desc_rows_processed_ptr */ /* SQLUINTEGER *rows_fetched_ptr; */ SQLUINTEGER simulate_cursor; SQLUINTEGER use_bookmarks; /* SQLGetStmtAttr only */ /* TDS_DESC *imp_row_desc; */ /* TDS_DESC *imp_param_desc; */ DSTR qn_msgtext; DSTR qn_options; SQLUINTEGER qn_timeout; }; typedef enum { NOT_IN_ROW, IN_NORMAL_ROW, IN_COMPUTE_ROW, AFTER_COMPUTE_ROW, PRE_NORMAL_ROW } TDS_ODBC_ROW_STATUS; typedef enum { ODBC_SPECIAL_NONE = 0, ODBC_SPECIAL_GETTYPEINFO = 1, ODBC_SPECIAL_COLUMNS = 2, ODBC_SPECIAL_PROCEDURECOLUMNS = 3, ODBC_SPECIAL_SPECIALCOLUMNS = 4 } TDS_ODBC_SPECIAL_ROWS; struct _hstmt { SQLSMALLINT htype; /* do not reorder this field */ struct _sql_errors errs; /* do not reorder this field */ tds_mutex mtx; struct _hdbc *dbc; /** query to execute */ DSTR query; /** socket (only if active) */ TDSSOCKET *tds; /** next in list */ struct _hstmt *next; /** previous in list */ struct _hstmt *prev; /* begin prepared query stuff */ unsigned is_prepared_query:1; unsigned prepared_query_is_func:1; unsigned prepared_query_is_rpc:1; unsigned need_reprepare:1; unsigned param_data_called:1; /* end prepared query stuff */ /** parameters saved */ TDSPARAMINFO *params; /** last valid parameter in params, it's a ODBC index (from 1 relative to descriptor) */ int param_num; /** position in prepared query to check parameters, used only in RPC */ char *prepared_pos; unsigned int curr_param_row, num_param_rows; /** number of parameter in current query */ unsigned int param_count; int row; /** row count to return */ TDS_INT8 row_count; /** status of row, it can happen that this flag mark that we are still parsing row, this it's normal */ TDS_ODBC_ROW_STATUS row_status; /* do NOT free dynamic, free from socket or attach to connection */ TDSDYNAMIC *dyn; TDS_DESC *ard, *ird, *apd, *ipd; TDS_DESC *orig_ard, *orig_apd; SQLULEN sql_rowset_size; struct _hsattr attr; DSTR cursor_name; /* auto generated cursor name */ TDS_ODBC_SPECIAL_ROWS special_row; /* do NOT free cursor, free from socket or attach to connection */ TDSCURSOR *cursor; }; typedef struct _henv TDS_ENV; typedef struct _hdbc TDS_DBC; typedef struct _hstmt TDS_STMT; typedef struct _hchk TDS_CHK; typedef struct { /* this must be the first member */ TDSCOLUMNFUNCS common; void (*set_type_info)(TDSCOLUMN *col, struct _drecord *drec, SQLINTEGER odbc_ver); } TDS_FUNCS; #define IS_HENV(x) (((TDS_CHK *)x)->htype == SQL_HANDLE_ENV) #define IS_HDBC(x) (((TDS_CHK *)x)->htype == SQL_HANDLE_DBC) #define IS_HSTMT(x) (((TDS_CHK *)x)->htype == SQL_HANDLE_STMT) #define IS_HDESC(x) (((TDS_CHK *)x)->htype == SQL_HANDLE_DESC) /* fix a bug in MingW headers */ #ifdef __MINGW32__ #if SQL_INTERVAL_YEAR == (100 + SQL_CODE_SECOND) #undef SQL_INTERVAL_YEAR #undef SQL_INTERVAL_MONTH #undef SQL_INTERVAL_DAY #undef SQL_INTERVAL_HOUR #undef SQL_INTERVAL_MINUTE #undef SQL_INTERVAL_SECOND #undef SQL_INTERVAL_YEAR_TO_MONTH #undef SQL_INTERVAL_DAY_TO_HOUR #undef SQL_INTERVAL_DAY_TO_MINUTE #undef SQL_INTERVAL_DAY_TO_SECOND #undef SQL_INTERVAL_HOUR_TO_MINUTE #undef SQL_INTERVAL_HOUR_TO_SECOND #undef SQL_INTERVAL_MINUTE_TO_SECOND #define SQL_INTERVAL_YEAR (100 + SQL_CODE_YEAR) #define SQL_INTERVAL_MONTH (100 + SQL_CODE_MONTH) #define SQL_INTERVAL_DAY (100 + SQL_CODE_DAY) #define SQL_INTERVAL_HOUR (100 + SQL_CODE_HOUR) #define SQL_INTERVAL_MINUTE (100 + SQL_CODE_MINUTE) #define SQL_INTERVAL_SECOND (100 + SQL_CODE_SECOND) #define SQL_INTERVAL_YEAR_TO_MONTH (100 + SQL_CODE_YEAR_TO_MONTH) #define SQL_INTERVAL_DAY_TO_HOUR (100 + SQL_CODE_DAY_TO_HOUR) #define SQL_INTERVAL_DAY_TO_MINUTE (100 + SQL_CODE_DAY_TO_MINUTE) #define SQL_INTERVAL_DAY_TO_SECOND (100 + SQL_CODE_DAY_TO_SECOND) #define SQL_INTERVAL_HOUR_TO_MINUTE (100 + SQL_CODE_HOUR_TO_MINUTE) #define SQL_INTERVAL_HOUR_TO_SECOND (100 + SQL_CODE_HOUR_TO_SECOND) #define SQL_INTERVAL_MINUTE_TO_SECOND (100 + SQL_CODE_MINUTE_TO_SECOND) #endif #endif #ifdef _WIN32 BOOL get_login_info(HWND hwndParent, TDSLOGIN * login); #endif #define ODBC_PARAM_LIST \ ODBC_PARAM(Servername) \ ODBC_PARAM(Server) \ ODBC_PARAM(DSN) \ ODBC_PARAM(UID) \ ODBC_PARAM(PWD) \ ODBC_PARAM(Address) \ ODBC_PARAM(Port) \ ODBC_PARAM(TDS_Version) \ ODBC_PARAM(Language) \ ODBC_PARAM(Database) \ ODBC_PARAM(TextSize) \ ODBC_PARAM(PacketSize) \ ODBC_PARAM(ClientCharset) \ ODBC_PARAM(DumpFile) \ ODBC_PARAM(DumpFileAppend) \ ODBC_PARAM(DebugFlags) \ ODBC_PARAM(Encryption) \ ODBC_PARAM(Trusted_Connection) \ ODBC_PARAM(APP) \ ODBC_PARAM(WSID) \ ODBC_PARAM(UseNTLMv2) \ ODBC_PARAM(MARS_Connection) \ ODBC_PARAM(REALM) \ ODBC_PARAM(ServerSPN) \ ODBC_PARAM(AttachDbFilename) \ ODBC_PARAM(ApplicationIntent) #define ODBC_PARAM(p) ODBC_PARAM_##p, enum { ODBC_PARAM_LIST ODBC_PARAM_SIZE }; #undef ODBC_PARAM /* * connectparams.h */ typedef struct { const char *p; size_t len; } TDS_PARSED_PARAM; /** * Parses a connection string for SQLDriverConnect(). * \param connect_string point to connection string * \param connect_string_end point to end of connection string * \param connection structure where to store informations * \return 0 if error, 1 otherwise */ int odbc_parse_connect_string(TDS_ERRS *errs, const char *connect_string, const char *connect_string_end, TDSLOGIN * login, TDS_PARSED_PARAM *parsed_params); int odbc_get_dsn_info(TDS_ERRS *errs, const char *DSN, TDSLOGIN * login); #ifdef _WIN32 int odbc_build_connect_string(TDS_ERRS *errs, TDS_PARSED_PARAM *params, char **out); #endif /* * convert_tds2sql.c */ SQLLEN odbc_tds2sql(TDS_STMT * stmt, TDSCOLUMN *curcol, int srctype, TDS_CHAR * src, TDS_UINT srclen, int desttype, TDS_CHAR * dest, SQLULEN destlen, const struct _drecord *drec_ixd); /* * descriptor.c */ TDS_DESC *desc_alloc(SQLHANDLE parent, int desc_type, int alloc_type); SQLRETURN desc_free(TDS_DESC * desc); SQLRETURN desc_alloc_records(TDS_DESC * desc, unsigned count); SQLRETURN desc_copy(TDS_DESC * dest, TDS_DESC * src); SQLRETURN desc_free_records(TDS_DESC * desc); TDS_DBC *desc_get_dbc(TDS_DESC *desc); /* * odbc.c */ SQLRETURN _SQLRowCount(SQLHSTMT hstmt, SQLLEN FAR * pcrow); /* * odbc_checks.h */ #if ENABLE_EXTRA_CHECKS /* macro */ #define CHECK_ENV_EXTRA(env) odbc_check_env_extra(env) #define CHECK_DBC_EXTRA(dbc) odbc_check_dbc_extra(dbc) #define CHECK_STMT_EXTRA(stmt) odbc_check_stmt_extra(stmt) #define CHECK_DESC_EXTRA(desc) odbc_check_desc_extra(desc) /* declarations*/ void odbc_check_env_extra(TDS_ENV * env); void odbc_check_dbc_extra(TDS_DBC * dbc); void odbc_check_stmt_extra(TDS_STMT * stmt); void odbc_check_desc_extra(TDS_DESC * desc); #else /* macro */ #define CHECK_ENV_EXTRA(env) #define CHECK_DBC_EXTRA(dbc) #define CHECK_STMT_EXTRA(stmt) #define CHECK_DESC_EXTRA(desc) #endif /* * odbc_util.h */ /* helpers for ODBC wide string support */ #undef _wide #undef _WIDE #ifdef ENABLE_ODBC_WIDE typedef union { char mb[1]; SQLWCHAR wide[1]; } ODBC_CHAR; # define _wide ,wide # define _wide0 ,0 # define _WIDE ,int wide #else # define _wide # define _wide0 # define _WIDE # define ODBC_CHAR SQLCHAR #endif int odbc_set_stmt_query(struct _hstmt *stmt, const ODBC_CHAR *sql, int sql_len _WIDE); void odbc_set_return_status(struct _hstmt *stmt, unsigned int n_row); void odbc_set_return_params(struct _hstmt *stmt, unsigned int n_row); void odbc_set_sql_type_info(TDSCOLUMN * col, struct _drecord *drec, SQLINTEGER odbc_ver); int odbc_sql_to_c_type_default(int sql_type); TDS_SERVER_TYPE odbc_sql_to_server_type(TDSCONNECTION * conn, int sql_type, int sql_unsigned); TDS_SERVER_TYPE odbc_c_to_server_type(int c_type); unsigned int odbc_get_string_size(int size, const ODBC_CHAR * str _WIDE); void odbc_rdbms_version(TDSSOCKET * tds_socket, char *pversion_string); SQLINTEGER odbc_get_param_len(const struct _drecord *drec_axd, const struct _drecord *drec_ixd, const TDS_DESC* axd, unsigned int n_row); #ifdef ENABLE_ODBC_WIDE DSTR* odbc_dstr_copy_flag(TDS_DBC *dbc, DSTR *s, int size, const ODBC_CHAR * str, int flag); #define odbc_dstr_copy(dbc, s, len, out) \ odbc_dstr_copy_flag(dbc, s, len, sizeof((out)->mb) ? (out) : (out), wide) #define odbc_dstr_copy_oct(dbc, s, len, out) \ odbc_dstr_copy_flag(dbc, s, len, out, wide|0x20) #else DSTR* odbc_dstr_copy(TDS_DBC *dbc, DSTR *s, int size, const ODBC_CHAR * str); #define odbc_dstr_copy_oct odbc_dstr_copy #endif SQLRETURN odbc_set_string_flag(TDS_DBC *dbc, SQLPOINTER buffer, SQLINTEGER cbBuffer, void FAR * pcbBuffer, const char *s, int len, int flag); #ifdef ENABLE_ODBC_WIDE #define odbc_set_string(dbc, buf, buf_len, out_len, s, s_len) \ odbc_set_string_flag(dbc, sizeof((buf)->mb) ? (buf) : (buf), buf_len, out_len, s, s_len, (wide) | (sizeof(*(out_len)) == sizeof(SQLSMALLINT)?0:0x10)) #define odbc_set_string_oct(dbc, buf, buf_len, out_len, s, s_len) \ odbc_set_string_flag(dbc, buf, buf_len, out_len, s, s_len, (wide) | (sizeof(*(out_len)) == sizeof(SQLSMALLINT)?0x20:0x30)) #else #define odbc_set_string(dbc, buf, buf_len, out_len, s, s_len) \ odbc_set_string_flag(dbc, buf, buf_len, out_len, s, s_len, (sizeof(*(out_len)) == sizeof(SQLSMALLINT)?0:0x10)) #define odbc_set_string_oct(dbc, buf, buf_len, out_len, s, s_len) \ odbc_set_string_flag(dbc, buf, buf_len, out_len, s, s_len, (sizeof(*(out_len)) == sizeof(SQLSMALLINT)?0x20:0x30)) #endif SQLSMALLINT odbc_get_concise_sql_type(SQLSMALLINT type, SQLSMALLINT interval); SQLRETURN odbc_set_concise_sql_type(SQLSMALLINT concise_type, struct _drecord *drec, int check_only); SQLSMALLINT odbc_get_concise_c_type(SQLSMALLINT type, SQLSMALLINT interval); SQLRETURN odbc_set_concise_c_type(SQLSMALLINT concise_type, struct _drecord *drec, int check_only); SQLLEN odbc_get_octet_len(int c_type, const struct _drecord *drec); void odbc_convert_err_set(struct _sql_errors *errs, TDS_INT err); /* * prepare_query.c */ SQLRETURN prepare_call(struct _hstmt *stmt); SQLRETURN native_sql(struct _hdbc *dbc, DSTR *s); int parse_prepared_query(struct _hstmt *stmt, int compute_row); int start_parse_prepared_query(struct _hstmt *stmt, int compute_row); int continue_parse_prepared_query(struct _hstmt *stmt, SQLPOINTER DataPtr, SQLLEN StrLen_or_Ind); const char *parse_const_param(const char * s, TDS_SERVER_TYPE *type); const char *odbc_skip_rpc_name(const char *s); /* * sql2tds.c */ SQLRETURN odbc_sql2tds(TDS_STMT * stmt, const struct _drecord *drec_ixd, const struct _drecord *drec_axd, TDSCOLUMN *curcol, int compute_row, const TDS_DESC* axd, unsigned int n_row); TDS_INT convert_datetime2server(int bindtype, const void *src, TDS_DATETIMEALL * dta); /* * bcp.c */ void odbc_bcp_free_storage(TDS_DBC *dbc); void odbc_bcp_init(TDS_DBC *dbc, const ODBC_CHAR *tblname, const ODBC_CHAR *hfile, const ODBC_CHAR *errfile, int direction _WIDE); void odbc_bcp_control(TDS_DBC *dbc, int field, void *value); void odbc_bcp_colptr(TDS_DBC *dbc, const void * colptr, int table_column); void odbc_bcp_sendrow(TDS_DBC *dbc); int odbc_bcp_batch(TDS_DBC *dbc); int odbc_bcp_done(TDS_DBC *dbc); void odbc_bcp_bind(TDS_DBC *dbc, const void * varaddr, int prefixlen, int varlen, const void * terminator, int termlen, int vartype, int table_column); /* * sqlwchar.c */ #if SIZEOF_SQLWCHAR != SIZEOF_WCHAR_T size_t sqlwcslen(const SQLWCHAR * s); typedef struct sqlwstr_buf { struct sqlwstr_buf *next; wchar_t buf[256]; } SQLWSTRBUF; const wchar_t *sqlwstr(const SQLWCHAR * s, SQLWSTRBUF **bufs); void sqlwstr_free(SQLWSTRBUF *bufs); #define SQLWSTR_BUFS(n) SQLWSTRBUF *bufs = NULL #define SQLWSTR(s) sqlwstr(s, &bufs) #define SQLWSTR_FREE() sqlwstr_free(bufs) #else #define sqlwcslen(s) wcslen(s) #define SQLWSTR_BUFS(n) do {} while(0) #define SQLWSTR(s) ((const wchar_t*)(s)) #define SQLWSTR_FREE() do {} while(0) #endif #if SIZEOF_SQLWCHAR == 2 # if WORDS_BIGENDIAN # define ODBC_WIDE_NAME "UCS-2BE" # define ODBC_WIDE_NAME_UTF "UTF-16BE" # else # define ODBC_WIDE_NAME "UCS-2LE" # define ODBC_WIDE_NAME_UTF "UTF-16LE" # endif const char *odbc_get_wide_name(TDSCONNECTION *conn); #elif SIZEOF_SQLWCHAR == 4 # if WORDS_BIGENDIAN # define ODBC_WIDE_NAME "UCS-4BE" # else # define ODBC_WIDE_NAME "UCS-4LE" # endif static inline const char * odbc_get_wide_name(TDSCONNECTION *conn) { return ODBC_WIDE_NAME; } #else #error SIZEOF_SQLWCHAR not supported !! #endif #include #ifdef __cplusplus #if 0 { #endif } #endif #endif freetds-1.00.82/include/freetds/version.h100644 025423 025423 00000002171 13242511125 0013740/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-1999 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef _tdsversion_h_ #define _tdsversion_h_ /* $Id: 9640daf619734147e3b5ff6a1dad56ad305ffa51 $ */ #define TDS_VERSION_NO "freetds v1.00.82" #define TDS_VERSION_MAJOR 1 #define TDS_VERSION_MINOR 00 #define TDS_VERSION_SUBVERSION 82 #define TDS_VERSION_BUILD_NUMBER 6638 #endif freetds-1.00.82/include/freetds/server.h100644 025423 025423 00000005310 12522201763 0013563/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-1999 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef _tdsserver_h_ #define _tdsserver_h_ #endif #ifdef __cplusplus extern "C" { #endif #if 0 } #endif /* login.c */ unsigned char *tds7_decrypt_pass(const unsigned char *crypt_pass, int len, unsigned char *clear_pass); TDSSOCKET *tds_listen(TDSCONTEXT * ctx, int ip_port); int tds_read_login(TDSSOCKET * tds, TDSLOGIN * login); int tds7_read_login(TDSSOCKET * tds, TDSLOGIN * login); TDSLOGIN *tds_alloc_read_login(TDSSOCKET * tds); /* query.c */ char *tds_get_query(TDSSOCKET * tds); char *tds_get_generic_query(TDSSOCKET * tds); /* server.c */ void tds_env_change(TDSSOCKET * tds, int type, const char *oldvalue, const char *newvalue); void tds_send_msg(TDSSOCKET * tds, int msgno, int msgstate, int severity, const char *msgtext, const char *srvname, const char *procname, int line); void tds_send_login_ack(TDSSOCKET * tds, const char *progname); void tds_send_eed(TDSSOCKET * tds, int msgno, int msgstate, int severity, char *msgtext, char *srvname, char *procname, int line); void tds_send_err(TDSSOCKET * tds, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr); void tds_send_capabilities_token(TDSSOCKET * tds); /* TODO remove, use tds_send_done */ void tds_send_done_token(TDSSOCKET * tds, TDS_SMALLINT flags, TDS_INT numrows); void tds_send_done(TDSSOCKET * tds, int token, TDS_SMALLINT flags, TDS_INT numrows); void tds_send_control_token(TDSSOCKET * tds, TDS_SMALLINT numcols); void tds_send_col_name(TDSSOCKET * tds, TDSRESULTINFO * resinfo); void tds_send_col_info(TDSSOCKET * tds, TDSRESULTINFO * resinfo); void tds_send_result(TDSSOCKET * tds, TDSRESULTINFO * resinfo); void tds7_send_result(TDSSOCKET * tds, TDSRESULTINFO * resinfo); void tds_send_table_header(TDSSOCKET * tds, TDSRESULTINFO * resinfo); void tds_send_row(TDSSOCKET * tds, TDSRESULTINFO * resinfo); void tds71_send_prelogin(TDSSOCKET * tds); #if 0 { #endif #ifdef __cplusplus } #endif freetds-1.00.82/include/freetds/configs.h100644 025423 025423 00000002665 12522201763 0013717/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-1999 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef _tds_configs_h_ #define _tds_configs_h_ /* $Id: tds_configs.h,v 1.21 2005-07-08 08:22:53 freddy77 Exp $ */ #include #ifndef _tds_h_ #error tds.h must be included before tds_configs.h #endif #ifdef __cplusplus extern "C" { #if 0 } #endif #endif #define FREETDS_SYSCONFFILE FREETDS_SYSCONFDIR TDS_SDIR_SEPARATOR "freetds.conf" #define FREETDS_POOLCONFFILE FREETDS_SYSCONFDIR TDS_SDIR_SEPARATOR "pool.conf" #define FREETDS_LOCALECONFFILE FREETDS_SYSCONFDIR TDS_SDIR_SEPARATOR "locales.conf" #ifdef __cplusplus #if 0 { #endif } #endif #endif /* _tds_configs_h_ */ freetds-1.00.82/include/freetds/enum_cap.h100644 025423 025423 00000014021 12717145107 0014050typedef enum tds_request_capability { TDS_REQ_LANG = 1 , TDS_REQ_RPC = 2 , TDS_REQ_EVT = 3 , TDS_REQ_MSTMT = 4 , TDS_REQ_BCP = 5 , TDS_REQ_CURSOR = 6 , TDS_REQ_DYNF = 7 , TDS_REQ_MSG = 8 , TDS_REQ_PARAM = 9 , TDS_REQ_DATA_INT1 = 10 , TDS_REQ_DATA_INT2 = 11 , TDS_REQ_DATA_INT4 = 12 , TDS_REQ_DATA_BIT = 13 , TDS_REQ_DATA_CHAR = 14 , TDS_REQ_DATA_VCHAR = 15 , TDS_REQ_DATA_BIN = 16 , TDS_REQ_DATA_VBIN = 17 , TDS_REQ_DATA_MNY8 = 18 , TDS_REQ_DATA_MNY4 = 19 , TDS_REQ_DATA_DATE8 = 20 , TDS_REQ_DATA_DATE4 = 21 , TDS_REQ_DATA_FLT4 = 22 , TDS_REQ_DATA_FLT8 = 23 , TDS_REQ_DATA_NUM = 24 , TDS_REQ_DATA_TEXT = 25 , TDS_REQ_DATA_IMAGE = 26 , TDS_REQ_DATA_DEC = 27 , TDS_REQ_DATA_LCHAR = 28 , TDS_REQ_DATA_LBIN = 29 , TDS_REQ_DATA_INTN = 30 , TDS_REQ_DATA_DATETIMEN = 31 , TDS_REQ_DATA_MONEYN = 32 , TDS_REQ_CSR_PREV = 33 , TDS_REQ_CSR_FIRST = 34 , TDS_REQ_CSR_LAST = 35 , TDS_REQ_CSR_ABS = 36 , TDS_REQ_CSR_REL = 37 , TDS_REQ_CSR_MULTI = 38 , TDS_REQ_CON_OOB = 39 , TDS_REQ_CON_INBAND = 40 , TDS_REQ_CON_LOGICAL = 41 , TDS_REQ_PROTO_TEXT = 42 , TDS_REQ_PROTO_BULK = 43 , TDS_REQ_URGEVT = 44 , TDS_REQ_DATA_SENSITIVITY = 45 , TDS_REQ_DATA_BOUNDARY = 46 , TDS_REQ_PROTO_DYNAMIC = 47 , TDS_REQ_PROTO_DYNPROC = 48 , TDS_REQ_DATA_FLTN = 49 , TDS_REQ_DATA_BITN = 50 , TDS_REQ_DATA_INT8 = 51 , TDS_REQ_DATA_VOID = 52 , TDS_REQ_DOL_BULK = 53 , TDS_REQ_OBJECT_JAVA1 = 54 , TDS_REQ_OBJECT_CHAR = 55 , TDS_REQ_OBJECT_BINARY = 57 , TDS_REQ_DATA_COLUMNSTATUS = 58 , TDS_REQ_WIDETABLE = 59 , TDS_REQ_DATA_UINT2 = 61 , TDS_REQ_DATA_UINT4 = 62 , TDS_REQ_DATA_UINT8 = 63 , TDS_REQ_DATA_UINTN = 64 , TDS_REQ_CUR_IMPLICIT = 65 , TDS_REQ_DATA_NLBIN = 66 , TDS_REQ_IMAGE_NCHAR = 67 , TDS_OBS_BLOB_NCHAR_16 = 68 /* obsolete */ , TDS_REQ_BLOB_NCHAR_8 = 69 , TDS_REQ_BLOB_NCHAR_SCSU = 70 , TDS_REQ_DATA_DATE = 71 , TDS_REQ_DATA_TIME = 72 , TDS_REQ_DATA_INTERVAL = 73 , TDS_REQ_CSR_SCROLL = 74 , TDS_REQ_CSR_SENSITIVE = 75 , TDS_REQ_CSR_INSENSITIVE = 76 , TDS_REQ_CSR_SEMISENSITIVE = 77 , TDS_REQ_CSR_KEYSETDRIVEN = 78 , TDS_REQ_SRVPKTSIZE = 79 , TDS_REQ_DATA_UNITEXT = 80 , TDS_REQ_CAP_CLUSTERFAILOVER = 81 , TDS_REQ_DATA_SINT1 = 82 , TDS_REQ_LARGEIDENT = 83 , TDS_REQ_BLOB_NCHAR_16 = 84 , TDS_REQ_DATA_XML = 85 , TDS_REQ_CURINFO3 = 86 , TDS_REQ_DBRPC2 = 87 , TDS_REQ_MIGRATE = 89 , TDS_REQ_DATA_BIGDATETIME = 93 , TDS_REQ_DATA_BIGTIME = 94 , TDS_REQ_CAP_MAX = 94 /* repeats last enum */ } TDS_REQUEST_CAPABILITY; typedef enum tds_response_capability { TDS_RES_NOMSG = 1 , TDS_RES_NOEED = 2 , TDS_RES_NOPARAM = 3 , TDS_RES_DATA_NOINT1 = 4 , TDS_RES_DATA_NOINT2 = 5 , TDS_RES_DATA_NOINT4 = 6 , TDS_RES_DATA_NOBIT = 7 , TDS_RES_DATA_NOCHAR = 8 , TDS_RES_DATA_NOVCHAR = 9 , TDS_RES_DATA_NOBIN = 10 , TDS_RES_DATA_NOVBIN = 11 , TDS_RES_DATA_NOMNY8 = 12 , TDS_RES_DATA_NOMNY4 = 13 , TDS_RES_DATA_NODATE8 = 14 , TDS_RES_DATA_NODATE4 = 15 , TDS_RES_DATA_NOFLT4 = 16 , TDS_RES_DATA_NOFLT8 = 17 , TDS_RES_DATA_NONUM = 18 , TDS_RES_DATA_NOTEXT = 19 , TDS_RES_DATA_NOIMAGE = 20 , TDS_RES_DATA_NODEC = 21 , TDS_RES_DATA_NOLCHAR = 22 , TDS_RES_DATA_NOLBIN = 23 , TDS_RES_DATA_INTN = 24 , TDS_RES_DATA_NODATETIMEN = 25 , TDS_RES_DATA_NOMONEYN = 26 , TDS_RES_CON_NOOOB = 27 , TDS_RES_CON_NOINBAND = 28 , TDS_RES_PROTO_NOTEXT = 29 , TDS_RES_PROTO_NOBULK = 30 , TDS_RES_DATA_NOSENSITIVITY = 31 , TDS_RES_DATA_NOBOUNDARY = 32 , TDS_RES_NOTDSDEBUG = 33 , TDS_RES_NOSTRIPBLANKS = 34 , TDS_RES_DATA_NOINT8 = 35 , TDS_RES_OBJECT_NOJAVA1 = 36 , TDS_RES_OBJECT_NOCHAR = 37 , TDS_RES_DATA_NOCOLUMNSTATUS = 38 , TDS_RES_OBJECT_NOBINARY = 39 , TDS_RES_DATA_NOUINT2 = 41 , TDS_RES_DATA_NOUINT4 = 42 , TDS_RES_DATA_NOUINT8 = 43 , TDS_RES_DATA_NOUINTN = 44 , TDS_RES_NO_WIDETABLES = 45 , TDS_RES_DATA_NONLBIN = 46 , TDS_RES_IMAGE_NONCHAR = 47 , TDS_RES_BLOB_NONCHAR_16 = 48 , TDS_RES_BLOB_NONCHAR_8 = 49 , TDS_RES_BLOB_NONCHAR_SCSU = 50 , TDS_RES_DATA_NODATE = 51 , TDS_RES_DATA_NOTIME = 52 , TDS_RES_DATA_NOINTERVAL = 53 , TDS_RES_DATA_NOUNITEXT = 54 , TDS_RES_DATA_NOSINT1 = 55 , TDS_RES_NO_LARGEIDENT = 56 , TDS_RES_NO_BLOB_NCHAR_16 = 57 , TDS_RES_NO_SRVPKTSIZE = 58 , TDS_RES_DATA_NOXML = 59 , TDS_RES_NONINT_RETURN_VALUE = 60 , TDS_RES_NOXNLDATA = 61 , TDS_RES_SUPPRESS_FMT = 62 , TDS_RES_SUPPRESS_DONEINPROC = 63 , TDS_RES_FORCE_ROWFMT2 = 64 , TDS_RES_CAP_MAX = 64 /* repeats last enum */ } TDS_RESPONSE_CAPABILITY; freetds-1.00.82/include/freetds/sysdep_private.h100644 025423 025423 00000015446 12717145107 0015336/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Brian Bruns * Copyright (C) 2010 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef _tds_sysdep_private_h_ #define _tds_sysdep_private_h_ #define TDS_ADDITIONAL_SPACE 16 #ifdef MSG_NOSIGNAL # define TDS_NOSIGNAL MSG_NOSIGNAL #else # define TDS_NOSIGNAL 0L #endif #ifdef __cplusplus extern "C" { #if 0 } #endif #endif #ifdef __INCvxWorksh #include /* for FIONBIO */ #endif /* __INCvxWorksh */ #if defined(DOS32X) #define READSOCKET(a,b,c) recv((a), (b), (c), TDS_NOSIGNAL) #define WRITESOCKET(a,b,c) send((a), (b), (c), TDS_NOSIGNAL) #define CLOSESOCKET(a) closesocket((a)) #define IOCTLSOCKET(a,b,c) ioctlsocket((a), (b), (char*)(c)) #define SOCKLEN_T int #define select select_s typedef int pid_t; #define strcasecmp stricmp #define strncasecmp strnicmp /* TODO this has nothing to do with ip ... */ #define getpid() _gethostid() #endif /* defined(DOS32X) */ #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(_WIN64) #include #include #include #define READSOCKET(a,b,c) recv((a), (char *) (b), (c), TDS_NOSIGNAL) #define WRITESOCKET(a,b,c) send((a), (const char *) (b), (c), TDS_NOSIGNAL) #define CLOSESOCKET(a) closesocket((a)) #define IOCTLSOCKET(a,b,c) ioctlsocket((a), (b), (c)) #define SOCKLEN_T int int tds_socket_init(void); #define INITSOCKET() tds_socket_init() void tds_socket_done(void); #define DONESOCKET() tds_socket_done() #define NETDB_REENTRANT 1 /* BSD-style netdb interface is reentrant */ #define TDSSOCK_EINTR WSAEINTR #define TDSSOCK_EINPROGRESS WSAEWOULDBLOCK #define TDSSOCK_ETIMEDOUT WSAETIMEDOUT #define TDSSOCK_WOULDBLOCK(e) ((e)==WSAEWOULDBLOCK) #define TDSSOCK_ECONNRESET WSAECONNRESET #define sock_errno WSAGetLastError() #define set_sock_errno(err) WSASetLastError(err) #define sock_strerror(n) tds_prwsaerror(n) #define sock_strerror_free(s) tds_prwsaerror_free(s) #ifndef __MINGW32__ typedef DWORD pid_t; #endif #undef strcasecmp #define strcasecmp stricmp #undef strncasecmp #define strncasecmp strnicmp #if defined(HAVE__SNPRINTF) && !defined(HAVE_SNPRINTF) #define snprintf _snprintf #endif #ifndef WIN32 #define WIN32 1 #endif #if defined(_WIN64) && !defined(WIN64) #define WIN64 1 #endif #define TDS_SDIR_SEPARATOR "\\" /* use macros to use new style names */ #if defined(__MSVCRT__) || defined(_MSC_VER) /* Use API as always present and not causing problems */ #undef getpid #define getpid() GetCurrentProcessId() #define strdup(s) _strdup(s) #define unlink(f) _unlink(f) #define putenv(s) _putenv(s) #undef fileno #define fileno(f) _fileno(f) #define stricmp(s1,s2) _stricmp(s1,s2) #define strnicmp(s1,s2,n) _strnicmp(s1,s2,n) #endif #endif /* defined(WIN32) || defined(_WIN32) || defined(__WIN32__) */ #ifndef sock_errno #define sock_errno errno #endif #ifndef set_sock_errno #define set_sock_errno(err) do { errno = (err); } while(0) #endif #ifndef sock_strerror #define sock_strerror(n) strerror(n) #define sock_strerror_free(s) do {} while(0) #endif #ifndef TDSSOCK_EINTR #define TDSSOCK_EINTR EINTR #endif #ifndef TDSSOCK_EINPROGRESS #define TDSSOCK_EINPROGRESS EINPROGRESS #endif #ifndef TDSSOCK_ETIMEDOUT #define TDSSOCK_ETIMEDOUT ETIMEDOUT #endif #ifndef TDSSOCK_WOULDBLOCK # if defined(EWOULDBLOCK) && EAGAIN != EWOULDBLOCK # define TDSSOCK_WOULDBLOCK(e) ((e)==EAGAIN||(e)==EWOULDBLOCK) # else # define TDSSOCK_WOULDBLOCK(e) ((e)==EAGAIN) # endif #endif #ifndef TDSSOCK_ECONNRESET #define TDSSOCK_ECONNRESET ECONNRESET #endif #ifndef INITSOCKET #define INITSOCKET() 0 #endif /* !INITSOCKET */ #ifndef DONESOCKET #define DONESOCKET() do { } while(0) #endif /* !DONESOCKET */ #ifndef READSOCKET # ifdef MSG_NOSIGNAL # define READSOCKET(s,b,l) recv((s), (b), (l), MSG_NOSIGNAL) # else # define READSOCKET(s,b,l) read((s), (b), (l)) # endif #endif /* !READSOCKET */ #ifndef WRITESOCKET # ifdef MSG_NOSIGNAL # define WRITESOCKET(s,b,l) send((s), (b), (l), MSG_NOSIGNAL) # else # define WRITESOCKET(s,b,l) write((s), (b), (l)) # endif #endif /* !WRITESOCKET */ #ifndef CLOSESOCKET #define CLOSESOCKET(s) close((s)) #endif /* !CLOSESOCKET */ #ifndef IOCTLSOCKET #define IOCTLSOCKET(s,b,l) ioctl((s), (b), (l)) #endif /* !IOCTLSOCKET */ #ifndef SOCKLEN_T # define SOCKLEN_T socklen_t #endif #if !defined(__WIN32__) && !defined(_WIN32) && !defined(WIN32) typedef int TDS_SYS_SOCKET; #define INVALID_SOCKET -1 #define TDS_IS_SOCKET_INVALID(s) ((s) < 0) #else typedef SOCKET TDS_SYS_SOCKET; #define TDS_IS_SOCKET_INVALID(s) ((s) == INVALID_SOCKET) #endif #define tds_accept accept #define tds_getpeername getpeername #define tds_getsockopt getsockopt #define tds_getsockname getsockname #define tds_recvfrom recvfrom #if defined(__hpux__) && SIZEOF_VOID_P == 8 && SIZEOF_INT == 4 # if HAVE__XPG_ACCEPT # undef tds_accept # define tds_accept _xpg_accept # elif HAVE___ACCEPT # undef tds_accept # define tds_accept __accept # endif # if HAVE__XPG_GETPEERNAME # undef tds_getpeername # define tds_getpeername _xpg_getpeername # elif HAVE___GETPEERNAME # undef tds_getpeername # define tds_getpeername __getpeername # endif # if HAVE__XPG_GETSOCKOPT # undef tds_getsockopt # define tds_getsockopt _xpg_getsockopt # elif HAVE___GETSOCKOPT # undef tds_getsockopt # define tds_getsockopt __getsockopt # endif # if HAVE__XPG_GETSOCKNAME # undef tds_getsockname # define tds_getsockname _xpg_getsockname # elif HAVE___GETSOCKNAME # undef tds_getsockname # define tds_getsockname __getsockname # endif # if HAVE__XPG_RECVFROM # undef tds_recvfrom # define tds_recvfrom _xpg_recvfrom # elif HAVE___RECVFROM # undef tds_recvfrom # define tds_recvfrom __recvfrom # endif #endif #ifndef TDS_SDIR_SEPARATOR #define TDS_SDIR_SEPARATOR "/" #endif /* !TDS_SDIR_SEPARATOR */ #ifdef HAVE_INTTYPES_H #include #endif #ifndef PRId64 #define PRId64 TDS_I64_PREFIX "d" #endif #ifndef PRIu64 #define PRIu64 TDS_I64_PREFIX "u" #endif #ifndef PRIx64 #define PRIx64 TDS_I64_PREFIX "x" #endif #ifdef __cplusplus #if 0 { #endif } #endif #endif /* _tds_sysdep_private_h_ */ freetds-1.00.82/include/freetds/stream.h100644 025423 025423 00000007217 12522201763 0013560/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2013 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef _freetds_stream_h_ #define _freetds_stream_h_ #ifndef _tds_h_ #error Include tds.h first #endif #include /** define a stream of data used for input */ typedef struct tds_input_stream { /** read some data * Return 0 if end of stream * Return <0 if error (actually not defined) */ int (*read)(struct tds_input_stream *stream, void *ptr, size_t len); } TDSINSTREAM; /** define a stream of data used for output */ typedef struct tds_output_stream { /** write len bytes from buffer, return <0 if error or len */ int (*write)(struct tds_output_stream *stream, size_t len); /** * write buffer. client will write data into this buffer. * not required that buffer is the result of any alloc function * so buffer pointer can point in the middle of another buffer. * client will write up to buf_len. * client should not cache buffer and buf_len before a call * to write as write can change these values. */ char *buffer; size_t buf_len; } TDSOUTSTREAM; /** Convert a stream from istream to ostream using a specific conversion */ TDSRET tds_convert_stream(TDSSOCKET * tds, TDSICONV * char_conv, TDS_ICONV_DIRECTION direction, TDSINSTREAM * istream, TDSOUTSTREAM *ostream); /** Copy data from a stream to another */ TDSRET tds_copy_stream(TDSSOCKET * tds, TDSINSTREAM * istream, TDSOUTSTREAM * ostream); /* Additional streams */ /** input stream to read data from tds protocol */ typedef struct tds_datain_stream { TDSINSTREAM stream; size_t wire_size; /**< bytes still to read */ TDSSOCKET *tds; } TDSDATAINSTREAM; void tds_datain_stream_init(TDSDATAINSTREAM * stream, TDSSOCKET * tds, size_t wire_size); /** output stream to write data to tds protocol */ typedef struct tds_dataout_stream { TDSOUTSTREAM stream; TDSSOCKET *tds; size_t written; } TDSDATAOUTSTREAM; void tds_dataout_stream_init(TDSDATAOUTSTREAM * stream, TDSSOCKET * tds); /** input stream to read data from a static buffer */ typedef struct tds_staticin_stream { TDSINSTREAM stream; const char *buffer; size_t buf_left; } TDSSTATICINSTREAM; void tds_staticin_stream_init(TDSSTATICINSTREAM * stream, const void *ptr, size_t len); /** output stream to write data to a static buffer. * stream.buffer contains the pointer where stream will write to. */ typedef struct tds_staticout_stream { TDSOUTSTREAM stream; } TDSSTATICOUTSTREAM; void tds_staticout_stream_init(TDSSTATICOUTSTREAM * stream, void *ptr, size_t len); /** output stream to write data to a dynamic buffer */ typedef struct tds_dynamic_stream { TDSOUTSTREAM stream; /** where is stored the pointer */ void **buf; /** currently allocated buffer */ size_t allocated; /** size of data inside buffer */ size_t size; } TDSDYNAMICSTREAM; TDSRET tds_dynamic_stream_init(TDSDYNAMICSTREAM * stream, void **ptr, size_t allocated); #include #endif freetds-1.00.82/include/freetds/data.h100644 025423 025423 00000007402 13101323621 0013162/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2014 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef _freetds_data_h_ #define _freetds_data_h_ #ifndef _tds_h_ # error Include tds.h before data.h #endif #include #define TDS_COMMON_FUNCS(name) \ { \ tds_ ## name ## _get_info, \ tds_ ## name ## _get, \ tds_ ## name ## _row_len, \ tds_ ## name ## _put_info_len, \ tds_ ## name ## _put_info, \ tds_ ## name ## _put, \ TDS_EXTRA_CHECK(tds_ ## name ## _check) \ } tds_func_get_info tds_invalid_get_info; tds_func_row_len tds_invalid_row_len; tds_func_get_data tds_invalid_get; tds_func_put_info_len tds_invalid_put_info_len; tds_func_put_info tds_invalid_put_info; tds_func_put_data tds_invalid_put; tds_func_check tds_invalid_check; tds_func_get_info tds_generic_get_info; tds_func_row_len tds_generic_row_len; tds_func_get_data tds_generic_get; tds_func_put_info_len tds_generic_put_info_len; tds_func_put_info tds_generic_put_info; tds_func_put_data tds_generic_put; tds_func_check tds_generic_check; tds_func_get_info tds_numeric_get_info; tds_func_row_len tds_numeric_row_len; tds_func_get_data tds_numeric_get; tds_func_put_info_len tds_numeric_put_info_len; tds_func_put_info tds_numeric_put_info; tds_func_put_data tds_numeric_put; tds_func_check tds_numeric_check; #define tds_variant_get_info tds_generic_get_info #define tds_variant_row_len tds_generic_row_len tds_func_get_data tds_variant_get; #define tds_variant_put_info_len tds_generic_put_info_len tds_func_put_info tds_variant_put_info; tds_func_put_data tds_variant_put; tds_func_check tds_variant_check; tds_func_get_info tds_msdatetime_get_info; tds_func_row_len tds_msdatetime_row_len; tds_func_get_data tds_msdatetime_get; #define tds_msdatetime_put_info_len tds_generic_put_info_len tds_func_put_info tds_msdatetime_put_info; tds_func_put_data tds_msdatetime_put; tds_func_check tds_msdatetime_check; tds_func_get_info tds_clrudt_get_info; tds_func_row_len tds_clrudt_row_len; #define tds_clrudt_get tds_generic_get #define tds_clrudt_put_info_len tds_generic_put_info_len tds_func_put_info tds_clrudt_put_info; #define tds_clrudt_put tds_generic_put tds_func_check tds_clrudt_check; tds_func_get_info tds_sybbigtime_get_info; tds_func_row_len tds_sybbigtime_row_len; tds_func_get_data tds_sybbigtime_get; tds_func_put_info_len tds_sybbigtime_put_info_len; tds_func_put_info tds_sybbigtime_put_info; tds_func_put_data tds_sybbigtime_put; tds_func_check tds_sybbigtime_check; /** * If TDS_DONT_DEFINE_DEFAULT_FUNCTIONS is no defined * define default implementations for these tables */ #ifndef TDS_DONT_DEFINE_DEFAULT_FUNCTIONS # define TDS_DEFINE_DEFAULT_FUNCS(name) \ const TDSCOLUMNFUNCS tds_ ## name ## _funcs = TDS_COMMON_FUNCS(name) TDS_DEFINE_DEFAULT_FUNCS(invalid); TDS_DEFINE_DEFAULT_FUNCS(generic); TDS_DEFINE_DEFAULT_FUNCS(numeric); TDS_DEFINE_DEFAULT_FUNCS(variant); TDS_DEFINE_DEFAULT_FUNCS(msdatetime); TDS_DEFINE_DEFAULT_FUNCS(clrudt); TDS_DEFINE_DEFAULT_FUNCS(sybbigtime); #endif #include #endif freetds-1.00.82/include/freetds/pushvis.h100644 025423 025423 00000000153 12522201763 0013756#if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__) #pragma GCC visibility push(hidden) #endif freetds-1.00.82/include/freetds/popvis.h100644 025423 025423 00000000142 12522201763 0013573#if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__) #pragma GCC visibility pop #endif freetds-1.00.82/include/freetds/time.h100644 025423 025423 00000000237 12522201763 0013216#if TIME_WITH_SYS_TIME # include # include #else # if HAVE_SYS_TIME_H # include # else # include # endif #endif freetds-1.00.82/include/freetds/tls.h100644 025423 025423 00000005507 12717145107 0013074/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2015 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef _freetds_tls_h_ #define _freetds_tls_h_ #ifndef _tds_h_ #error tds.h must be included before tls.h #endif #ifdef HAVE_GNUTLS # if defined(_THREAD_SAFE) && defined(TDS_HAVE_PTHREAD_MUTEX) # include # ifndef GNUTLS_USE_NETTLE # include # endif # endif # include # include #elif defined(HAVE_OPENSSL) # include # include #endif #include #if defined(HAVE_GNUTLS) || defined(HAVE_OPENSSL) TDSRET tds_ssl_init(TDSSOCKET *tds); void tds_ssl_deinit(TDSCONNECTION *conn); # ifdef HAVE_GNUTLS static inline int tds_ssl_pending(TDSCONNECTION *conn) { return gnutls_record_check_pending((gnutls_session_t) conn->tls_session); } static inline int tds_ssl_read(TDSCONNECTION *conn, unsigned char *buf, int buflen) { return gnutls_record_recv((gnutls_session_t) conn->tls_session, buf, buflen); } static inline int tds_ssl_write(TDSCONNECTION *conn, const unsigned char *buf, int buflen) { return gnutls_record_send((gnutls_session_t) conn->tls_session, buf, buflen); } # else static inline int tds_ssl_pending(TDSCONNECTION *conn) { return SSL_pending((SSL *) conn->tls_session); } static inline int tds_ssl_read(TDSCONNECTION *conn, unsigned char *buf, int buflen) { return SSL_read((SSL *) conn->tls_session, buf, buflen); } static inline int tds_ssl_write(TDSCONNECTION *conn, const unsigned char *buf, int buflen) { return SSL_write((SSL *) conn->tls_session, buf, buflen); } # endif #else static inline TDSRET tds_ssl_init(TDSSOCKET *tds) { return TDS_FAIL; } static inline void tds_ssl_deinit(TDSCONNECTION *conn) { } static inline int tds_ssl_pending(TDSCONNECTION *conn) { return 0; } static inline int tds_ssl_read(TDSCONNECTION *conn, unsigned char *buf, int buflen) { return -1; } static inline int tds_ssl_write(TDSCONNECTION *conn, const unsigned char *buf, int buflen) { return -1; } #endif #include #endif /* _freetds_tls_h_ */ freetds-1.00.82/include/freetds/bool.h100644 025423 025423 00000002133 12717145107 0013215/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2015 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef freetds_bool_h_ #define freetds_bool_h_ #ifndef __cplusplus #ifdef HAVE_STDBOOL_H #include #else #undef true #undef false #undef bool #define bool int #define true 1 #define false 0 #endif #endif #endif /* freetds_bool_h_ */ freetds-1.00.82/include/freetds/checks.h100644 025423 025423 00000004736 12717145107 0013535/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2004 Frediano Ziglio * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef TDS_CHECKS_H #define TDS_CHECKS_H #include #if ENABLE_EXTRA_CHECKS #define CHECK_STRUCT_EXTRA(func,s) func(s) #else #define CHECK_STRUCT_EXTRA(func,s) #endif #define CHECK_TDS_EXTRA(tds) CHECK_STRUCT_EXTRA(tds_check_tds_extra,tds) #define CHECK_CONTEXT_EXTRA(ctx) CHECK_STRUCT_EXTRA(tds_check_context_extra,ctx) #define CHECK_TDSENV_EXTRA(env) CHECK_STRUCT_EXTRA(tds_check_env_extra,env) #define CHECK_COLUMN_EXTRA(column) CHECK_STRUCT_EXTRA(tds_check_column_extra,column) #define CHECK_RESULTINFO_EXTRA(res_info) CHECK_STRUCT_EXTRA(tds_check_resultinfo_extra,res_info) #define CHECK_PARAMINFO_EXTRA(res_info) CHECK_STRUCT_EXTRA(tds_check_resultinfo_extra,res_info) #define CHECK_CURSOR_EXTRA(cursor) CHECK_STRUCT_EXTRA(tds_check_cursor_extra,cursor) #define CHECK_DYNAMIC_EXTRA(dynamic) CHECK_STRUCT_EXTRA(tds_check_dynamic_extra,dynamic) #define CHECK_CONN_EXTRA(conn) #if ENABLE_EXTRA_CHECKS void tds_check_tds_extra(const TDSSOCKET * tds); void tds_check_context_extra(const TDSCONTEXT * ctx); void tds_check_env_extra(const TDSENV * env); void tds_check_column_extra(const TDSCOLUMN * column); void tds_check_resultinfo_extra(const TDSRESULTINFO * res_info); void tds_check_cursor_extra(const TDSCURSOR * cursor); void tds_check_dynamic_extra(const TDSDYNAMIC * dynamic); #endif #if defined(HAVE_VALGRIND_MEMCHECK_H) && ENABLE_EXTRA_CHECKS # include # define TDS_MARK_UNDEFINED(ptr, len) VALGRIND_MAKE_MEM_UNDEFINED(ptr, len) #else # define TDS_MARK_UNDEFINED(ptr, len) do {} while(0) #endif #include #endif /* TDS_CHECKS_H */ freetds-1.00.82/include/freetds/dlist.h100644 025423 025423 00000002250 12717145107 0013401/* Dlist - dynamic list * Copyright (C) 2016 Frediano Ziglio * * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ifndef TDS_DLIST_H #define TDS_DLIST_H typedef struct dlist_ring { struct dlist_ring *next; struct dlist_ring *prev; } dlist_ring; #if ENABLE_EXTRA_CHECKS void dlist_ring_check(dlist_ring *ring); #endif #define DLIST_FIELDS(name) \ dlist_ring name #define DLIST_FOREACH(prefix, list, p) \ for (p = prefix ## _ ## first(list); p != NULL; p = prefix ## _ ## next(list, p)) #endif /* TDS_DLIST_H */ freetds-1.00.82/include/freetds/dlist.tmpl.h100644 025423 025423 00000007126 12717145107 0014363/* Dlist - dynamic list * Copyright (C) 2016 Frediano Ziglio * * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #if !defined(DLIST_NAME) || !defined(DLIST_TYPE) || !defined(DLIST_LIST_TYPE) #error Required defines missing! #endif typedef struct { dlist_ring ring; } DLIST_LIST_TYPE; #undef DLIST_ITEM #define DLIST_ITEM(ring) ((DLIST_TYPE *) (((char *) (ring)) - TDS_OFFSET(DLIST_TYPE, DLIST_NAME(item)))) static inline void DLIST_NAME(check)(DLIST_LIST_TYPE *list) { #if ENABLE_EXTRA_CHECKS assert(list != NULL); dlist_ring_check(&list->ring); #endif } static inline void DLIST_NAME(init)(DLIST_LIST_TYPE *list) { list->ring.next = list->ring.prev = &list->ring; DLIST_NAME(check)(list); } static inline DLIST_TYPE *DLIST_NAME(first)(DLIST_LIST_TYPE *list) { return list->ring.next == &list->ring ? NULL : DLIST_ITEM(list->ring.next); } static inline DLIST_TYPE *DLIST_NAME(last)(DLIST_LIST_TYPE *list) { return list->ring.prev == &list->ring ? NULL : DLIST_ITEM(list->ring.prev); } static inline DLIST_TYPE *DLIST_NAME(next)(DLIST_LIST_TYPE *list, DLIST_TYPE *item) { return item->DLIST_NAME(item).next == &list->ring ? NULL : DLIST_ITEM(item->DLIST_NAME(item).next); } static inline DLIST_TYPE *DLIST_NAME(prev)(DLIST_LIST_TYPE *list, DLIST_TYPE *item) { return item->DLIST_NAME(item).prev == &list->ring ? NULL : DLIST_ITEM(item->DLIST_NAME(item).prev); } static inline void DLIST_NAME(prepend)(DLIST_LIST_TYPE *list, DLIST_TYPE *item) { DLIST_NAME(check)(list); assert(item->DLIST_NAME(item).next == NULL && item->DLIST_NAME(item).prev == NULL); list->ring.next->prev = &item->DLIST_NAME(item); item->DLIST_NAME(item).next = list->ring.next; item->DLIST_NAME(item).prev = &list->ring; list->ring.next = &item->DLIST_NAME(item); assert(item->DLIST_NAME(item).next != NULL && item->DLIST_NAME(item).prev != NULL); DLIST_NAME(check)(list); } static inline void DLIST_NAME(append)(DLIST_LIST_TYPE *list, DLIST_TYPE *item) { DLIST_NAME(check)(list); assert(item->DLIST_NAME(item).next == NULL && item->DLIST_NAME(item).prev == NULL); list->ring.prev->next = &item->DLIST_NAME(item); item->DLIST_NAME(item).prev = list->ring.prev; item->DLIST_NAME(item).next = &list->ring; list->ring.prev = &item->DLIST_NAME(item); assert(item->DLIST_NAME(item).next != NULL && item->DLIST_NAME(item).prev != NULL); DLIST_NAME(check)(list); } static inline void DLIST_NAME(remove)(DLIST_LIST_TYPE *list, DLIST_TYPE *item) { dlist_ring *prev = item->DLIST_NAME(item).prev, *next = item->DLIST_NAME(item).next; DLIST_NAME(check)(list); if (prev) prev->next = next; if (next) next->prev = prev; item->DLIST_NAME(item).prev = NULL; item->DLIST_NAME(item).next = NULL; DLIST_NAME(check)(list); } static inline bool DLIST_NAME(in_list)(DLIST_LIST_TYPE *list, DLIST_TYPE *item) { DLIST_NAME(check)(list); return item->DLIST_NAME(item).prev != NULL || item->DLIST_NAME(item).next != NULL; } #undef DLIST_ITEM #undef DLIST_NAME #undef DLIST_TYPE #undef DLIST_LIST_TYPE freetds-1.00.82/include/freetds/alloca.h100644 025423 025423 00000000647 12676712621 0013532/* Cfr https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Particular-Functions.html */ #if HAVE_ALLOCA_H # include #elif defined __GNUC__ # define alloca __builtin_alloca #elif defined _AIX # define alloca __alloca #elif defined _MSC_VER # include # define alloca _alloca #else # include # ifdef __cplusplus extern "C" # endif void *alloca (size_t); #endif freetds-1.00.82/include/freetds/Makefile.in100644 025423 025423 00000041112 13242511110 0014137# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = include/freetds ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = \ $(top_srcdir)/m4/ac_caolan_func_which_gethostbyname_r.m4 \ $(top_srcdir)/m4/ac_have_inaddr_none.m4 \ $(top_srcdir)/m4/ac_have_malloc_options.m4 \ $(top_srcdir)/m4/ac_nullzero.m4 \ $(top_srcdir)/m4/ac_raf_func_which_getservbyname_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_gethostbyaddr_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_getpwuid_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_localtime_r.m4 \ $(top_srcdir)/m4/acx_pthread.m4 \ $(top_srcdir)/m4/ax_cflags_gcc_option.m4 \ $(top_srcdir)/m4/check_openssl.m4 \ $(top_srcdir)/m4/gettimemilli.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/pushlibs.m4 \ $(top_srcdir)/m4/sprintf_i64_format.m4 \ $(top_srcdir)/m4/type_socklen_t.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(noinst_HEADERS) \ $(am__DIST_COMMON) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = version.h CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac HEADERS = $(noinst_HEADERS) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/version.h.in \ $(top_srcdir)/mkinstalldirs DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BUILD_NUMBER = @BUILD_NUMBER@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOXYGEN = @DOXYGEN@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FREETDS_LIBGCC = @FREETDS_LIBGCC@ FREETDS_ODBC_MODULE = @FREETDS_ODBC_MODULE@ FREETDS_SYMBOLIC = @FREETDS_SYMBOLIC@ GCRYPT_CFLAGS = @GCRYPT_CFLAGS@ GCRYPT_LIBS = @GCRYPT_LIBS@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ HAVE_OPENSSL = @HAVE_OPENSSL@ HAVE_PERL_SOURCES = @HAVE_PERL_SOURCES@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBADD_DL = @LIBADD_DL@ LIBADD_DLD_LINK = @LIBADD_DLD_LINK@ LIBADD_DLOPEN = @LIBADD_DLOPEN@ LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@ LIBICONV = @LIBICONV@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBOBJS = @LTLIBOBJS@ LT_DLLOADERS = @LT_DLLOADERS@ LT_DLPREOPEN = @LT_DLPREOPEN@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ NETTLE_CFLAGS = @NETTLE_CFLAGS@ NETTLE_LIBS = @NETTLE_LIBS@ NETWORK_LIBS = @NETWORK_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ODBC = @ODBC@ ODBCINSTLIB = @ODBCINSTLIB@ ODBCLIB = @ODBCLIB@ ODBCNODMLIB = @ODBCNODMLIB@ ODBCNODMLIBAPP = @ODBCNODMLIBAPP@ ODBC_CONFIG = @ODBC_CONFIG@ ODBC_INC = @ODBC_INC@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ RC = @RC@ READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SUBVERSION = @SUBVERSION@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ dblib_define = @dblib_define@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ tds_sysdep_int16_type = @tds_sysdep_int16_type@ tds_sysdep_int32_type = @tds_sysdep_int32_type@ tds_sysdep_int64_type = @tds_sysdep_int64_type@ tds_sysdep_intptr_type = @tds_sysdep_intptr_type@ tds_sysdep_real32_type = @tds_sysdep_real32_type@ tds_sysdep_real64_type = @tds_sysdep_real64_type@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ noinst_HEADERS = iconv.h string.h convert.h bytes.h \ thread.h proto.h tds.h odbc.h version.h server.h \ configs.h enum_cap.h sysdep_private.h stream.h \ data.h pushvis.h popvis.h time.h tls.h bool.h \ checks.h dlist.h dlist.tmpl.h alloca.h DISTCLEANFILES = sysconfdir.h all: all-am .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu include/freetds/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu include/freetds/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): version.h: $(top_builddir)/config.status $(srcdir)/version.h.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(HEADERS) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool cscopelist-am ctags ctags-am distclean \ distclean-generic 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-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic \ mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ uninstall-am .PRECIOUS: Makefile sysconfdir.h: Makefile echo '#define FREETDS_SYSCONFDIR "$(sysconfdir)"' >$@ all-am: sysconfdir.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: freetds-1.00.82/include/freetds/version.h.in100644 025423 025423 00000002234 12522201763 0014351/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-1999 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef _tdsversion_h_ #define _tdsversion_h_ /* $Id: 9640daf619734147e3b5ff6a1dad56ad305ffa51 $ */ #define TDS_VERSION_NO "@PACKAGE@ v@VERSION@" #define TDS_VERSION_MAJOR @MAJOR@ #define TDS_VERSION_MINOR @MINOR@ #define TDS_VERSION_SUBVERSION @SUBVERSION@ #define TDS_VERSION_BUILD_NUMBER @BUILD_NUMBER@ #endif freetds-1.00.82/test-driver100755 025423 025423 00000011040 13242511046 0011216#! /bin/sh # test-driver - basic testsuite driver script. scriptversion=2013-07-13.22; # UTC # Copyright (C) 2011-2014 Free Software Foundation, Inc. # # 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, 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, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . # Make unconditional expansion of undefined variables an error. This # helps a lot in preventing typo-related bugs. set -u usage_error () { echo "$0: $*" >&2 print_usage >&2 exit 2 } print_usage () { cat <$log_file 2>&1 estatus=$? if test $enable_hard_errors = no && test $estatus -eq 99; then tweaked_estatus=1 else tweaked_estatus=$estatus fi case $tweaked_estatus:$expect_failure in 0:yes) col=$red res=XPASS recheck=yes gcopy=yes;; 0:*) col=$grn res=PASS recheck=no gcopy=no;; 77:*) col=$blu res=SKIP recheck=no gcopy=yes;; 99:*) col=$mgn res=ERROR recheck=yes gcopy=yes;; *:yes) col=$lgn res=XFAIL recheck=no gcopy=yes;; *:*) col=$red res=FAIL recheck=yes gcopy=yes;; esac # Report the test outcome and exit status in the logs, so that one can # know whether the test passed or failed simply by looking at the '.log' # file, without the need of also peaking into the corresponding '.trs' # file (automake bug#11814). echo "$res $test_name (exit status: $estatus)" >>$log_file # Report outcome to console. echo "${col}${res}${std}: $test_name" # Register the test result, and other relevant metadata. echo ":test-result: $res" > $trs_file echo ":global-test-result: $res" >> $trs_file echo ":recheck: $recheck" >> $trs_file echo ":copy-in-global-log: $gcopy" >> $trs_file # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: freetds-1.00.82/doc/Makefile.am100644 025423 025423 00000016623 12717145107 0011644# Converting DocBook to HTML (several small files) # http://www.freebsd.org/tutorials/docproj-primer/x3132.html#AEN3140 SHELL = /bin/sh DOCDIR = . TARGET_DOCDIR = $(DESTDIR)$(docdir) EXTRA_DIST = api_status.txt bcp.txt cap.txt getting_started.txt \ policy.txt CodingStyle tds.html \ userguide.dsl.in userguide.sgml userguide.css \ $(man_MANS) \ $(DOCDIR)/userguide $(DOCDIR)/reference \ images grep_sample_code tds_ssl.html \ freebcp.1.in tsql.1.in osql.1.in bsqldb.1.in bsqlodbc.1.in \ defncopy.1.in datacopy.1.in fisql.1.in freetds.conf.5.in \ userguide_desc.sgml man_MANS = freebcp.1 \ tsql.1 \ osql.1 \ bsqldb.1 \ bsqlodbc.1 \ defncopy.1 \ datacopy.1 \ fisql.1 \ freetds.conf.5 noinst_DATA = $(DOCDIR)/reference/index.html $(DOCDIR)/userguide/index.htm $(DOCDIR)/userguide: $(DOCDIR)/userguide/index.htm $(DOCDIR)/reference: $(DOCDIR)/reference/index.html doc: $(DOCDIR)/userguide $(DOCDIR)/reference dist: man man: $(man_MANS) INSTALLDIRS = $(TARGET_DOCDIR)/userguide \ $(TARGET_DOCDIR)/reference \ $(TARGET_DOCDIR)/images \ $(TARGET_DOCDIR)/images/callouts $(INSTALLDIRS) $(DOCDIR): $(MKDIR_P) $@ 2>&1 # If we built the documentation ourselves, install that, # else if we have access to distributed documentation, install that. install-data-local: $(INSTALLDIRS) $(noinst_DATA) $(MKDIR_P) $(DOCDIR) 2>&1 if test -r $(DOCDIR)/userguide ; then d=.; else d="$(srcdir)"; fi; \ find $$d/$(DOCDIR)/userguide \( -type f -o -type l \) \ -exec $(INSTALL) {} $(TARGET_DOCDIR)/userguide ';' if test -r $(DOCDIR)/reference ; then d=.; else d="$(srcdir)"; fi; \ find $$d/$(DOCDIR)/reference \( -type f -o -type l \) \ -exec $(INSTALL) {} $(TARGET_DOCDIR)/reference ';' cd $(srcdir) && find images -name \*.gif \ -exec $(INSTALL) {} $(TARGET_DOCDIR)/{} ';' uninstall-local: rm -rf $(TARGET_DOCDIR) clean-local: rm -rf userguide.dsl doxy.log \ dblib.api.sgml \ ctlib.api.sgml \ odbc.api.sgml ## In building the UG and reference manual, we confront several ## possible situations: ## 1. CVS user (or developer) with or without jade/doxygen installed. ## 2. Distribution user. The distribution includes pre-built ## documentation, ready to install. ## Either of these users may choose to build out-of-tree (e.g., in a ## build/ directory). We want to build the docs if we can, link to ## distributed ones if they exist, else create stub files pointing to ## the website. ## ## In the case of jade, we build the documentation only if the ## environment variable DOCBOOK_DSL is set. A user would define ## DOCBOOK_DSL only if he intends to build the UG. If the user builds ## FreeTDS out of tree, "make install" will put a symlink to the ## distributed UG HTML in the build directory, and install per usual. ## ## In the case of Doxygen, we detect its presence in the configure ## script, and invoke it if found. If it is not found, we try to link ## the build tree's reference manual HTML to the distribution. If ## that fails, we install a stub. DISTRIBUTED_UG_DIR = $(srcdir)/$(DOCDIR)/userguide UG_STUB = \

at www.freetds.org \ userguide_desc.sgml: userguide.sgml git log -1 '--pretty=format:%n%n' HEAD -- $< > $@~ mv -f $@~ $@ # To make the userguide, export DOCBOOK_DSL to point to docbook.dsl. $(DOCDIR)/userguide/index.htm: $(DOCDIR) userguide.sgml userguide_desc.sgml \ dblib.api.sgml ctlib.api.sgml odbc.api.sgml \ userguide.dsl.in api_status.txt sed -ne's!SYSTEM "docbook.dsl" CDATA!SYSTEM "${DOCBOOK_DSL}" CDATA!; p' \ $(srcdir)/userguide.dsl.in > .userguide.dsl mv .userguide.dsl userguide.dsl if test -h userguide; then rm userguide; fi $(MKDIR_P) $(DOCDIR)/userguide 2>&1 touch $(DOCDIR)/userguide/t.htm rm -rf $(DOCDIR)/userguide/* # if we're not using jade, copy the distribution's userguide if test -z "${DOCBOOK_DSL}" ; then \ if test -r $(DISTRIBUTED_UG_DIR) \ -a ! -r $(DOCDIR)/userguide ; then \ cp -R $(DISTRIBUTED_UG_DIR) $(DOCDIR); \ fi; \ fi # try jade ... (cd $(DOCDIR)/userguide && \ if test -n "${DOCBOOK_DSL}" ; then \ ## The crazy path is due to the above 'cd' command SRCDOC=../$(srcdir); \ if test ! -r userguide.sgml; then \ ln -s $${SRCDOC}/userguide.sgml userguide.sgml; \ fi; \ openjade -b utf-8 -w all -w no-empty -w no-unused-param \ -d ../userguide.dsl -t sgml userguide.sgml; \ if test -h userguide.sgml; then rm userguide.sgml; fi; \ ## and copy the stylesheet cp $${SRCDOC}/userguide.css .; \ fi) # if still no joy, create a stub @echo pwd is `pwd` -ls -ld `dirname $@` $@ if test ! -r $@ ; then \ echo '$(UG_STUB)' > .index.htm && mv .index.htm $@; \ fi test -f $(DOCDIR)/userguide/index.htm (cd $(DOCDIR)/userguide && \ if test ! -h index.html ; then ln -s index.htm index.html; fi) userguide: $(DOCDIR)/userguide/index.htm reference: $(DOCDIR)/reference/index.html DISTRIBUTED_REF_DIR = $(srcdir)/$(DOCDIR)/reference REF_STUB = \

at www.freetds.org \ $(DOCDIR)/reference/index.html: $(top_srcdir)/ChangeLog if test -h reference; then rm reference; fi $(MKDIR_P) $(DOCDIR)/reference 2>&1 (cd .. && $(MAKE) doxy 2> doc/doxy.log) # If "make doxy" doesn't create anything, # try to copy the distributed manual's HTML if test -r $(DISTRIBUTED_REF_DIR)/index.html -a ! $@ ; then \ cp -R $(DISTRIBUTED_REF_DIR) $(DOCDIR); \ fi # If we don't find the source, generate a stub. if test ! -r $@ ; then \ (cd $(DOCDIR)/reference && \ echo '$(REF_STUB)' \ > .index.html && \ mv .index.html index.html); \ fi # # The following sections generate API implementation reference tables # as SGML "entities". # The entities are used a little bit like include files in the UG, e.g.: # # # and "dblibapisgml" is referred to later on: # # # db-lib API Implementation Summary # &dblibapisgml; # # # This lets us use the api_status.txt document in our SGML. # API_TABLE_HEADING = \ \ Category \ Function \ Status \ Comments \ API_FUNC_COL = Function API_DBLIB_FUNC_COLS = Microsoft nameSybase name API_PAGE_FMT = \ \ &%s; API Implementation Summary\n \ \n \ %s\n \ \n \ %s\n \
\n dblib.api.body ctlib.api.body odbc.api.body: $(srcdir)/api_status.txt NAME=`echo $@ | sed 's/\..*$$//'` && \ sed -ne "/^$${NAME}[ ]/ s!!!p" \ $(srcdir)/api_status.txt \ | sed -e's![ ][ ]*! !g' \ -e's!$$!!' > $@~ mv $@~ $@ dblib.api.sgml: dblib.api.body ctlib.api.sgml: ctlib.api.body odbc.api.sgml: odbc.api.body dblib.api.sgml ctlib.api.sgml odbc.api.sgml: NAME=`echo $@ | sed 's/\..*$$//'` && \ HEAD='$(API_TABLE_HEADING)' && \ if [ $${NAME} = dblib ]; then \ HEAD=`echo '$(API_TABLE_HEADING)' \ | sed 's!$(API_FUNC_COL)!$(API_DBLIB_FUNC_COLS)!'`; \ fi && \ BODY=`cat $(@:.sgml=.body)` && \ printf '$(API_PAGE_FMT)' $${NAME} $${NAME} "$${HEAD}" "$${BODY}" > $@~ mv $@~ $@ CLEANFILES = dblib.api.body ctlib.api.body odbc.api.body dblib.api.sgml ctlib.api.sgml odbc.api.sgml $(man_MANS) distclean-local: rm -rf $(DOCDIR)/userguide $(DOCDIR)/reference freetds-1.00.82/doc/Makefile.in100644 025423 025423 00000064752 13242511110 0011644# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # Converting DocBook to HTML (several small files) # http://www.freebsd.org/tutorials/docproj-primer/x3132.html#AEN3140 VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = doc ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = \ $(top_srcdir)/m4/ac_caolan_func_which_gethostbyname_r.m4 \ $(top_srcdir)/m4/ac_have_inaddr_none.m4 \ $(top_srcdir)/m4/ac_have_malloc_options.m4 \ $(top_srcdir)/m4/ac_nullzero.m4 \ $(top_srcdir)/m4/ac_raf_func_which_getservbyname_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_gethostbyaddr_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_getpwuid_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_localtime_r.m4 \ $(top_srcdir)/m4/acx_pthread.m4 \ $(top_srcdir)/m4/ax_cflags_gcc_option.m4 \ $(top_srcdir)/m4/check_openssl.m4 \ $(top_srcdir)/m4/gettimemilli.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/pushlibs.m4 \ $(top_srcdir)/m4/sprintf_i64_format.m4 \ $(top_srcdir)/m4/type_socklen_t.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = freebcp.1 tsql.1 osql.1 bsqldb.1 bsqlodbc.1 \ defncopy.1 datacopy.1 fisql.1 freetds.conf.5 CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } man1dir = $(mandir)/man1 am__installdirs = "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(man5dir)" man5dir = $(mandir)/man5 NROFF = nroff MANS = $(man_MANS) DATA = $(noinst_DATA) am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/bsqldb.1.in \ $(srcdir)/bsqlodbc.1.in $(srcdir)/datacopy.1.in \ $(srcdir)/defncopy.1.in $(srcdir)/fisql.1.in \ $(srcdir)/freebcp.1.in $(srcdir)/freetds.conf.5.in \ $(srcdir)/osql.1.in $(srcdir)/tsql.1.in \ $(top_srcdir)/mkinstalldirs DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BUILD_NUMBER = @BUILD_NUMBER@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOXYGEN = @DOXYGEN@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FREETDS_LIBGCC = @FREETDS_LIBGCC@ FREETDS_ODBC_MODULE = @FREETDS_ODBC_MODULE@ FREETDS_SYMBOLIC = @FREETDS_SYMBOLIC@ GCRYPT_CFLAGS = @GCRYPT_CFLAGS@ GCRYPT_LIBS = @GCRYPT_LIBS@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ HAVE_OPENSSL = @HAVE_OPENSSL@ HAVE_PERL_SOURCES = @HAVE_PERL_SOURCES@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBADD_DL = @LIBADD_DL@ LIBADD_DLD_LINK = @LIBADD_DLD_LINK@ LIBADD_DLOPEN = @LIBADD_DLOPEN@ LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@ LIBICONV = @LIBICONV@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBOBJS = @LTLIBOBJS@ LT_DLLOADERS = @LT_DLLOADERS@ LT_DLPREOPEN = @LT_DLPREOPEN@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ NETTLE_CFLAGS = @NETTLE_CFLAGS@ NETTLE_LIBS = @NETTLE_LIBS@ NETWORK_LIBS = @NETWORK_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ODBC = @ODBC@ ODBCINSTLIB = @ODBCINSTLIB@ ODBCLIB = @ODBCLIB@ ODBCNODMLIB = @ODBCNODMLIB@ ODBCNODMLIBAPP = @ODBCNODMLIBAPP@ ODBC_CONFIG = @ODBC_CONFIG@ ODBC_INC = @ODBC_INC@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ RC = @RC@ READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh STRIP = @STRIP@ SUBVERSION = @SUBVERSION@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ dblib_define = @dblib_define@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ tds_sysdep_int16_type = @tds_sysdep_int16_type@ tds_sysdep_int32_type = @tds_sysdep_int32_type@ tds_sysdep_int64_type = @tds_sysdep_int64_type@ tds_sysdep_intptr_type = @tds_sysdep_intptr_type@ tds_sysdep_real32_type = @tds_sysdep_real32_type@ tds_sysdep_real64_type = @tds_sysdep_real64_type@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ DOCDIR = . TARGET_DOCDIR = $(DESTDIR)$(docdir) EXTRA_DIST = api_status.txt bcp.txt cap.txt getting_started.txt \ policy.txt CodingStyle tds.html \ userguide.dsl.in userguide.sgml userguide.css \ $(man_MANS) \ $(DOCDIR)/userguide $(DOCDIR)/reference \ images grep_sample_code tds_ssl.html \ freebcp.1.in tsql.1.in osql.1.in bsqldb.1.in bsqlodbc.1.in \ defncopy.1.in datacopy.1.in fisql.1.in freetds.conf.5.in \ userguide_desc.sgml man_MANS = freebcp.1 \ tsql.1 \ osql.1 \ bsqldb.1 \ bsqlodbc.1 \ defncopy.1 \ datacopy.1 \ fisql.1 \ freetds.conf.5 noinst_DATA = $(DOCDIR)/reference/index.html $(DOCDIR)/userguide/index.htm INSTALLDIRS = $(TARGET_DOCDIR)/userguide \ $(TARGET_DOCDIR)/reference \ $(TARGET_DOCDIR)/images \ $(TARGET_DOCDIR)/images/callouts DISTRIBUTED_UG_DIR = $(srcdir)/$(DOCDIR)/userguide UG_STUB = \

at www.freetds.org \ DISTRIBUTED_REF_DIR = $(srcdir)/$(DOCDIR)/reference REF_STUB = \

at www.freetds.org \ # # The following sections generate API implementation reference tables # as SGML "entities". # The entities are used a little bit like include files in the UG, e.g.: # # # and "dblibapisgml" is referred to later on: # # # db-lib API Implementation Summary # &dblibapisgml; # # # This lets us use the api_status.txt document in our SGML. # API_TABLE_HEADING = \ \ Category \ Function \ Status \ Comments \ API_FUNC_COL = Function API_DBLIB_FUNC_COLS = Microsoft nameSybase name API_PAGE_FMT = \ \ &%s; API Implementation Summary\n \ \n \ %s\n \ \n \ %s\n \
\n CLEANFILES = dblib.api.body ctlib.api.body odbc.api.body dblib.api.sgml ctlib.api.sgml odbc.api.sgml $(man_MANS) all: all-am .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu doc/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu doc/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): freebcp.1: $(top_builddir)/config.status $(srcdir)/freebcp.1.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ tsql.1: $(top_builddir)/config.status $(srcdir)/tsql.1.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ osql.1: $(top_builddir)/config.status $(srcdir)/osql.1.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ bsqldb.1: $(top_builddir)/config.status $(srcdir)/bsqldb.1.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ bsqlodbc.1: $(top_builddir)/config.status $(srcdir)/bsqlodbc.1.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ defncopy.1: $(top_builddir)/config.status $(srcdir)/defncopy.1.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ datacopy.1: $(top_builddir)/config.status $(srcdir)/datacopy.1.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ fisql.1: $(top_builddir)/config.status $(srcdir)/fisql.1.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ freetds.conf.5: $(top_builddir)/config.status $(srcdir)/freetds.conf.5.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs install-man1: $(man_MANS) @$(NORMAL_INSTALL) @list1=''; \ list2='$(man_MANS)'; \ test -n "$(man1dir)" \ && test -n "`echo $$list1$$list2`" \ || exit 0; \ echo " $(MKDIR_P) '$(DESTDIR)$(man1dir)'"; \ $(MKDIR_P) "$(DESTDIR)$(man1dir)" || exit 1; \ { for i in $$list1; do echo "$$i"; done; \ if test -n "$$list2"; then \ for i in $$list2; do echo "$$i"; done \ | sed -n '/\.1[a-z]*$$/p'; \ fi; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ done | \ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ sed 'N;N;s,\n, ,g' | { \ list=; while read file base inst; do \ if test "$$base" = "$$inst"; then list="$$list $$file"; else \ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \ fi; \ done; \ for i in $$list; do echo "$$i"; done | $(am__base_list) | \ while read files; do \ test -z "$$files" || { \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \ done; } uninstall-man1: @$(NORMAL_UNINSTALL) @list=''; test -n "$(man1dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ sed -n '/\.1[a-z]*$$/p'; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ dir='$(DESTDIR)$(man1dir)'; $(am__uninstall_files_from_dir) install-man5: $(man_MANS) @$(NORMAL_INSTALL) @list1=''; \ list2='$(man_MANS)'; \ test -n "$(man5dir)" \ && test -n "`echo $$list1$$list2`" \ || exit 0; \ echo " $(MKDIR_P) '$(DESTDIR)$(man5dir)'"; \ $(MKDIR_P) "$(DESTDIR)$(man5dir)" || exit 1; \ { for i in $$list1; do echo "$$i"; done; \ if test -n "$$list2"; then \ for i in $$list2; do echo "$$i"; done \ | sed -n '/\.5[a-z]*$$/p'; \ fi; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ done | \ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^5][0-9a-z]*$$,5,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ sed 'N;N;s,\n, ,g' | { \ list=; while read file base inst; do \ if test "$$base" = "$$inst"; then list="$$list $$file"; else \ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man5dir)/$$inst'"; \ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man5dir)/$$inst" || exit $$?; \ fi; \ done; \ for i in $$list; do echo "$$i"; done | $(am__base_list) | \ while read files; do \ test -z "$$files" || { \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man5dir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(man5dir)" || exit $$?; }; \ done; } uninstall-man5: @$(NORMAL_UNINSTALL) @list=''; test -n "$(man5dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ sed -n '/\.5[a-z]*$$/p'; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^5][0-9a-z]*$$,5,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ dir='$(DESTDIR)$(man5dir)'; $(am__uninstall_files_from_dir) tags TAGS: ctags CTAGS: cscope cscopelist: distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(MANS) $(DATA) installdirs: for dir in "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(man5dir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-local mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic distclean-local dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-data-local install-man install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-man1 install-man5 install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-local uninstall-man uninstall-man: uninstall-man1 uninstall-man5 .MAKE: install-am install-strip .PHONY: all all-am check check-am clean clean-generic clean-libtool \ clean-local cscopelist-am ctags-am distclean distclean-generic \ distclean-libtool distclean-local distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-data-local install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-man1 \ install-man5 install-pdf install-pdf-am install-ps \ install-ps-am install-strip installcheck installcheck-am \ installdirs maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ ps ps-am tags-am uninstall uninstall-am uninstall-local \ uninstall-man uninstall-man1 uninstall-man5 .PRECIOUS: Makefile $(DOCDIR)/userguide: $(DOCDIR)/userguide/index.htm $(DOCDIR)/reference: $(DOCDIR)/reference/index.html doc: $(DOCDIR)/userguide $(DOCDIR)/reference dist: man man: $(man_MANS) $(INSTALLDIRS) $(DOCDIR): $(MKDIR_P) $@ 2>&1 # If we built the documentation ourselves, install that, # else if we have access to distributed documentation, install that. install-data-local: $(INSTALLDIRS) $(noinst_DATA) $(MKDIR_P) $(DOCDIR) 2>&1 if test -r $(DOCDIR)/userguide ; then d=.; else d="$(srcdir)"; fi; \ find $$d/$(DOCDIR)/userguide \( -type f -o -type l \) \ -exec $(INSTALL) {} $(TARGET_DOCDIR)/userguide ';' if test -r $(DOCDIR)/reference ; then d=.; else d="$(srcdir)"; fi; \ find $$d/$(DOCDIR)/reference \( -type f -o -type l \) \ -exec $(INSTALL) {} $(TARGET_DOCDIR)/reference ';' cd $(srcdir) && find images -name \*.gif \ -exec $(INSTALL) {} $(TARGET_DOCDIR)/{} ';' uninstall-local: rm -rf $(TARGET_DOCDIR) clean-local: rm -rf userguide.dsl doxy.log \ dblib.api.sgml \ ctlib.api.sgml \ odbc.api.sgml userguide_desc.sgml: userguide.sgml git log -1 '--pretty=format:%n%n' HEAD -- $< > $@~ mv -f $@~ $@ # To make the userguide, export DOCBOOK_DSL to point to docbook.dsl. $(DOCDIR)/userguide/index.htm: $(DOCDIR) userguide.sgml userguide_desc.sgml \ dblib.api.sgml ctlib.api.sgml odbc.api.sgml \ userguide.dsl.in api_status.txt sed -ne's!SYSTEM "docbook.dsl" CDATA!SYSTEM "${DOCBOOK_DSL}" CDATA!; p' \ $(srcdir)/userguide.dsl.in > .userguide.dsl mv .userguide.dsl userguide.dsl if test -h userguide; then rm userguide; fi $(MKDIR_P) $(DOCDIR)/userguide 2>&1 touch $(DOCDIR)/userguide/t.htm rm -rf $(DOCDIR)/userguide/* # if we're not using jade, copy the distribution's userguide if test -z "${DOCBOOK_DSL}" ; then \ if test -r $(DISTRIBUTED_UG_DIR) \ -a ! -r $(DOCDIR)/userguide ; then \ cp -R $(DISTRIBUTED_UG_DIR) $(DOCDIR); \ fi; \ fi # try jade ... (cd $(DOCDIR)/userguide && \ if test -n "${DOCBOOK_DSL}" ; then \ SRCDOC=../$(srcdir); \ if test ! -r userguide.sgml; then \ ln -s $${SRCDOC}/userguide.sgml userguide.sgml; \ fi; \ openjade -b utf-8 -w all -w no-empty -w no-unused-param \ -d ../userguide.dsl -t sgml userguide.sgml; \ if test -h userguide.sgml; then rm userguide.sgml; fi; \ cp $${SRCDOC}/userguide.css .; \ fi) # if still no joy, create a stub @echo pwd is `pwd` -ls -ld `dirname $@` $@ if test ! -r $@ ; then \ echo '$(UG_STUB)' > .index.htm && mv .index.htm $@; \ fi test -f $(DOCDIR)/userguide/index.htm (cd $(DOCDIR)/userguide && \ if test ! -h index.html ; then ln -s index.htm index.html; fi) userguide: $(DOCDIR)/userguide/index.htm reference: $(DOCDIR)/reference/index.html $(DOCDIR)/reference/index.html: $(top_srcdir)/ChangeLog if test -h reference; then rm reference; fi $(MKDIR_P) $(DOCDIR)/reference 2>&1 (cd .. && $(MAKE) doxy 2> doc/doxy.log) # If "make doxy" doesn't create anything, # try to copy the distributed manual's HTML if test -r $(DISTRIBUTED_REF_DIR)/index.html -a ! $@ ; then \ cp -R $(DISTRIBUTED_REF_DIR) $(DOCDIR); \ fi # If we don't find the source, generate a stub. if test ! -r $@ ; then \ (cd $(DOCDIR)/reference && \ echo '$(REF_STUB)' \ > .index.html && \ mv .index.html index.html); \ fi dblib.api.body ctlib.api.body odbc.api.body: $(srcdir)/api_status.txt NAME=`echo $@ | sed 's/\..*$$//'` && \ sed -ne "/^$${NAME}[ ]/ s!!!p" \ $(srcdir)/api_status.txt \ | sed -e's![ ][ ]*! !g' \ -e's!$$!!' > $@~ mv $@~ $@ dblib.api.sgml: dblib.api.body ctlib.api.sgml: ctlib.api.body odbc.api.sgml: odbc.api.body dblib.api.sgml ctlib.api.sgml odbc.api.sgml: NAME=`echo $@ | sed 's/\..*$$//'` && \ HEAD='$(API_TABLE_HEADING)' && \ if [ $${NAME} = dblib ]; then \ HEAD=`echo '$(API_TABLE_HEADING)' \ | sed 's!$(API_FUNC_COL)!$(API_DBLIB_FUNC_COLS)!'`; \ fi && \ BODY=`cat $(@:.sgml=.body)` && \ printf '$(API_PAGE_FMT)' $${NAME} $${NAME} "$${HEAD}" "$${BODY}" > $@~ mv $@~ $@ distclean-local: rm -rf $(DOCDIR)/userguide $(DOCDIR)/reference # 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: freetds-1.00.82/doc/bsqldb.1.in100644 025423 025423 00000006672 12522201763 0011544.\" cf. groff_mdoc .Dd March 26, 2015 .Dt BSQLDB 1 .Os FreeTDS @VERSION@ .Sh NAME .Nm bsqldb .Nd batch SQL script processor using DB-Library .Sh SYNOPSIS .Nm .Op Fl hqv .Op Fl S Ar servername .Op Fl D Ar database .Op Fl U Ar username .Op Fl P Ar password .Op Fl i Ar input_file .Op Fl o Ar output_file .Op Fl e Ar error_file .Op Fl H Ar hostname .Op Fl t Ar field_term .Op Fl R Ar pivot_description .\" .Sh DESCRIPTION .Nm is a utility program distributed with FreeTDS. .Nm is a non-interactive equivalent of the "isql" utility programs distributed by Sybase and Microsoft. Like them, .Nm uses the command "go" on a line by itself as a separator between batches. The last batch need not be followed by "go". .Nm makes use of the DB-Library API provided by FreeTDS. This API is of course also available to application developers. .Sh OPTIONS .Bl -tag -width indent .It Fl D Ar database Database to use. .It Fl H Ar hostname hostname Override name of client sent to server. .It Fl P Ar password Database server password. .It Fl S Ar servername Database server to which to connect. .It Fl U Ar username Database server login name. If username is not provided, a domain login is attempted for TDS 7+ connections. .It Fl e Ar error_file Name of file for errors. .It Fl h Print column headers with the data to the same file. .It Fl i Ar input_file Name of script file, containing SQL. .It Fl o Ar output_file Name of output file, holding result data. .It Fl q Do not print column metadata, return status, or rowcount. Overrides .Fl h Ns . .It Fl t Ar field_term Specifies the field terminator. Default is two spaces (' '). Recognized escape sequences are tab ('\\t'), carriage return ('\\r'), newline ('\\n'), and backslash ('\\\\'). .It Fl v Verbose mode, for more information about the DB-Library interaction. This also reports the result set metadata, including and return code. All verbose data are written to standard error (or .Fl e Ns ), so as not to interfere with the data stream. .It Fl R Ar pivot_description Specify pivot trasformation. The format is .Ao Ar down\ columns Ac .Ao Ar across\ columns Ac .Ao Ar function Ac .Ao Ar value Ac . Columns are specified but numbers. The format of .Ar down columns and .Ar across columns is a comma separated list of columns. .Ar function is either count, sum, min or max. .El .\" .Sh ENVIRONMENT .Ev DSQUERY default .Ar servername .\" .Sh NOTES .Nm is a filter; it reads from standard input, writes to standard output, and writes errors to standard error. The .Fl i Ns , Fl o Ns , and Fl e options override these defaults. .Pp The source code for .Nm is intended as a model for DB-Library users. DB-Library has a rich set of functions, and it can be hard sometimes to understand how to use them, particularly the first time. If you find something about the source code unclear, you are encouraged to email the author your comments. .\" .Sh EXIT STATUS .Nm exits 0 on success, and >0 if the server cannot process the query. .Pp For messages with severity > 10, .Nm calls exit(3) with the severity level. For example, if the severity level is 16, .Nm will return an exit status of 16 to the shell. .\" .Sh HISTORY .Nm first appeared in FreeTDS 0.63. .\" .Sh AUTHORS The .Nm utility was written by .An "James K. Lowden" Aq jklowden@freetds.org . .\" .Sh BUGS Microsoft servers as of SQL Server 7.0 SP 3 do not return output parameters unless the RPC functions are used. This means .Nm cannot return output parameters for stored procedures with these servers. freetds-1.00.82/doc/bsqlodbc.1.in100644 025423 025423 00000004523 12522201763 0012057.\" cf. groff_mdoc .Dd March 25, 2015 .Os FreeTDS @VERSION@ .Dt BSQLODBC FreeTDS "FreeTDS Reference Manual" .\" .Sh NAME .Nm bsqlodbc .Nd batch SQL script processor using ODBC .\" .Sh SYNOPSIS .Pp .Nm .Op Fl hqv .Op Fl U Ar username .Op Fl P Ar password .Op Fl S Ar server .Op Fl D Ar database .Op Fl i Ar input_file .Op Fl o Ar output_file .Op Fl e Ar error_file .Op Fl t Ar field_term .Op Fl V Ar odbc_version .\" .Sh DESCRIPTION .Pp .Nm is a utility program distributed with FreeTDS. .Pp .Nm is a non-interactive equivalent of the .Ql isql utility programs distributed by Sybase and Microsoft. Like them, .Nm uses the command .Ql go on a line by itself as a separator between batches. The last batch need not be followed by .Ql go . .Pp .Nm makes use of the ODBC API provided by FreeTDS. This API is of course also available to application developers. .\" .Sh OPTIONS .Bl -tag -width indent .It Fl U Ar username Database server login name. .It Fl P Ar password Database server password. .It Fl S Ar server Database server to which to connect. .It Fl D Ar database Database to use. .It Fl i Ar input_file Name of script file, containing SQL. .It Fl o Ar output_file Name of output file, holding result data. .It Fl e Ar error_file Name of file for errors. .It Fl t Ar field_term Specifies the field terminator. Default is two spaces ( .Ql \ \ .Ns ). Recognized escape sequences are tab ( .Ql \et .Ns ), carriage return ( .Ql \er .Ns ), newline ( .Ql \en .Ns ), and backslash ( .Ql \e\e .Ns ). .It Fl h Print column headers with the data to the same file. .It Fl q Do not print column metadata, return status, or rowcount. Overrides .Fl h . .It Fl v Verbose mode, for more information about the ODBC interaction. This also reports the result set metadata, including and return code. All verbose data are written to standard error (or .Fl e Ns ), so as not to interfere with the data stream. .It Fl V Ar odbc_version Specify ODBC version (2 or 3). .El .\" .Sh NOTES .Pp .Nm is a filter; it reads from standard input, writes to standard output, and writes errors to standard error. The .Fl i , .Fl o , and .Fl e options override these defaults. .Sh EXIT STATUS .Nm exits 0 on success, and >0 if the server cannot process the query. .\" .Sh HISTORY .Nm first appeared in FreeTDS 0.65. .\" .Sh AUTHORS The .Nm utility was written by .An James K. Lowden Aq jklowden@freetds.org . freetds-1.00.82/doc/datacopy.1.in100644 025423 025423 00000004563 12522201763 0012076.\" cf. groff_mdoc .Dd March 25, 2015 .Os FreeTDS @VERSION@ .Dt DATACOPY FreeTDS "FreeTDS Reference Manual" .\" .Sh NAME .Nm datacopy .Nd move table data between two servers .\" .Sh SYNOPSIS .Nm .Op Fl vdE .Bro .Fl t | .Fl a | .Fl c .Ar owner .Brc .Op Fl b Ar batchsize .Op Fl p Ar packetsize .Op Fl S Ar server/username/password/database/table_or_view .Op Fl D Ar server/username/password/database/table .Op Fl T Ar textsize .\" .Sh DESCRIPTION .Nm is a utility distributed with FreeTDS. .Nm will move table data from one server to another without the need for intermediate files. .Nm is much faster and more efficient than is freebcp out/in. .Pp .Nm makes use of the db-lib bcp API built into FreeTDS. This API is also available to application developers. .Pp .Nm can be used to migrate data between Sybase ASE and SQL Server or vice versa. .\" .Sh OPTIONS .Bl -tag -width indent .It Fl t Truncate target table before loading data. .It Fl a Append data to target table. .It Fl c Ar owner Create the target table with the same schema as the source table. .Nm will submit a .Ql CREATE TABLE command on the target server using the specified owner in the command, e.g. .Ql CREATE TABLE owner.table (.\|.\|.\&). .It Fl b Ar batchsize The number of rows per batch of data copied. Each batch of data is effectively 'committed' to the database. The default is 1000. .It Fl p Ar packetsize The number of bytes, per network packet, sent to and from the servers. Increased packet size can enhance performance. .It Fl T Ar textsize Specify size of TEXT/IMAGE column from network. .It Fl v Produce verbose output, including diagnostic timings. .It Fl d Produce freetds TDSDUMP output. (Serious debug only!) .It Fl S Ar server/username/password/database/table_or_view The connection information for the source server and the location/name of the table (or view) to be copied. If not specified, .Nm prompts the user for the information. .It Fl D Ar server/username/password/database/table The connection information for the destination server and the location/name of the target table. If not specified, .Nm prompts the user for the information. .It Fl E Keep identity values. .Sh SEE ALSO .Xr freebcp 1 , Xr defncopy 1 , Xr bsqldb 1 , Xr tsql 1 , .%B FreeTDS User Guide. .\" .Sh HISTORY .Pp .Nm first appeared in FreeTDS 0.64. .\" .Sh AUTHORS The .Nm utility was written by .An Bill Thompson Aq thompbil@exchange.uk.ml.com . freetds-1.00.82/doc/defncopy.1.in100644 025423 025423 00000005077 12522201763 0012102.\" cf. groff_mdoc .Dd April 26, 2012 .Os FreeTDS @VERSION@ .Dt DEFNCOPY FreeTDS "FreeTDS Reference Manual" .\" .Sh NAME .Nm defncopy .Nd extract procedures and views from a Microsoft server. .\" .Sh SYNOPSIS .Pp .Nm .Op Fl v .Op Fl U Ar username .Op Fl P Ar password .Op Fl S Ar server .Op Fl D Ar database .Op Fl i Ar input_file .Op Fl o Ar output_file .Bo .Ar owner.object_name .\" Elipsis according to Werner Lemberg: .\" http://www.mail-archive.com/groff@gnu.org/msg03122.html .Op Ar owner.object_name .\|.\|.\& .Bc .\" .Sh DESCRIPTION .Pp .Nm is a utility program distributed with FreeTDS. It replaces a similar program of the same name distributed by Sybase. .Pp .Nm reads the text of a stored procedure or view, and writes a script suitable for recreating the procedure or view. For tables, it reads the output of sp_help and constructs a .Ql CREATE TABLE statement, complete with .Ql CREATE INDEX Ns , too. .\" .Ar owner is optional if you or the database owner is the owner of the procedure/view being copied. .Ar object_name is the name of the system object you wish to extract. .\" .Sh OPTIONS .Bl -tag -width indent .It Fl U Ar username database server login name. .It Fl P Ar password database server password. .It Fl S Ar server database server to which to connect. .It Fl D Ar database database to use. Optional if the procedure/view being extracted is in your default database. .It Fl i Ar input_file a script to apply to the database. Not currently implemented. .It Fl o Ar output_file a file to hold the script, defaults to standard output. .It Fl v Show version information and copyright notice. .El .\" .Sh NOTES .Nm is a filter; it reads from standard input, writes to standard output, and writes errors to standard error. The .Fl i , .Fl o , and .Fl e options override these defaults. .Pp .Nm makes use of the db-lib API provided by FreeTDS. This API is of course also available to application developers. .Sh EXIT STATUS .Pp .Nm exits 0 on success, and >0 if the server cannot process the query. .Pp .Nm will report any errors returned by the server, but will continue processing. .\" .Sh HISTORY .Pp .Nm first appeared in FreeTDS 0.63. .\" .Sh AUTHORS The .Nm utility was written by .An James K. Lowden Aq jklowden@schemamania.org. .\" .Sh BUGS Works only with Microsoft servers and ancient Sybase servers. Does not create primary keys. Many options are defined by Sybase that this version does not implement. Feel free to correct this situation. In theory, .Nm could apply/produce DDL for any system object, but at present only tables, procedures and views are supported, and only for extraction. freetds-1.00.82/doc/fisql.1.in100644 025423 025423 00000010074 12522201763 0011402.\" cf. groff_mdoc .Dd March 25, 2015 .Os FreeTDS @VERSION@ .Dt FISQL FreeTDS "FreeTDS Reference Manual" .\" .Sh NAME .Nm fisql .Nd interactive SQL shell .\" .Sh SYNOPSIS .Pp .Nm .Op Fl eFgpnvXY .Op Fl a Ar display_charset .Op Fl A Ar packet_size .Op Fl c Ar cmdend .Op Fl D Ar database .Op Fl E Ar editor .Op Fl h Ar headers .Op Fl H Ar hostname .Op Fl i Ar inputfile .Op Fl I Ar interfaces_file .Op Fl J Ar client_charset .Op Fl l Ar login_timeout .Op Fl m Ar errorlevel .Op Fl o Ar outputfile .Op Fl P Ar password .Op Fl s Ar colseparator .Op Fl S Ar server .Op Fl t Ar timeout .Op Fl U Ar username .Op Fl w Ar width .Op Fl y Ar sybase_dir .Op Fl z Ar language .\" .Sh DESCRIPTION .Pp .Nm is very similar to the .Ql isql utility programs distributed by Sybase and Microsoft. Like them, .Nm uses the command .Ql go on a line by itself as a separator between batches. .\" .Sh OPTIONS .Bl -tag -width indent .It Fl a Ar display_charset The client charset name. Not implemented. .It Fl A Ar packet_size Set protocol packet size. You should not need to set this parameter. .It Fl c Ar cmdend Command terminator, defaults to .Ql go Ns . .It Fl D Database name on the server to use. .It Fl e Echo SQL input (usually in outputfile) .It Fl E Ar editor Specify an editor to invoke. Defaults to vi. .It Fl F FIPS mode ON. Server returns a message (but processes the query anyway) when it encounters a non-standard SQL command. .It Fl g Display a brief help message .It Fl h Ar headers Number of rows after which to repeat the column headers. Default is once per resultset. .It Fl H Ar hostname Hostname of the client machine as it will be told to the server. .It Fl I Ar interfaces_file Name of the interfaces or freetds.conf file to use. .It Fl i Ar inputfile Name of script file, containing SQL. .It Fl J Ar client_charset Not implemented. .It Fl l Ar login_timeout How long to wait for the server to acknowledge a login attempt. .It Fl m Ar errorlevel For errors of the severity level specified or higher, print only the message number, state, and error level. Below that level, print nothing. .It Fl n Suppress line numbers in echoed output. .It Fl o Ar outputfile Name of output file, holding result data. .It Fl p Prints performance statistics. Not implemented. .It Fl P Ar password Database server password. .It Fl s Ar colseparator The column separator. Default is space. Shell metacharacters require quoting. .It Fl S Ar server Database server to which to connect. .It Fl t Ar timeout The query timeout, in seconds. How long to wait for a query to be processed. The default is indefinitely, or as determined by freetds.conf. .It Fl U Ar username Database server login name. .It Fl v Display version and copyright. .It Fl w Ar width How many characters wide to print the output. Defaults to 80. .It Fl X Use encrypted login. Not implemented in FreeTDS. .It Fl y Pa sybase_dir Sets the .Ev SYBASE environment variable. Not used by FreeTDS. .It Fl Y Use chained transactions. .It Fl z Ar language Name of a language for fisql's prompts and messages. Cf. DBSETLNATLANG. .El .\" .Sh NOTES .Nm is a filter; it reads from standard input, writes to standard output, and writes errors to standard error. The .Fl i Ns , .FL o Ns , and .Fl e options override these defaults. .Pp .Nm uses the DB-Library API provided by FreeTDS. It was first implemented using Sybase's own library and continues to work with it. Before (and after) modifying it, it would be well to test it with Sybase's library to assure compatibility between it and FreeTDS. EXIT STATUS .Pp .Nm exits 0 on success, and >0 if the server cannot process the query. .Pp .Nm will report any errors returned by the server, but will continue processing. In a production environment, this behavior may be insufficiently stringent. To make it extremely intolerant of errors, change the message and error handlers to call exit(3). .\" .Sh HISTORY .Nm first appeared in FreeTDS 0.65. .\" .Sh AUTHORS The .Nm utility was written by .An Nicholas S. Castellano Aq entropy@freetds.org Ns , who contributed it to the FreeTDS project under the terms of the GPL. .\" .Sh BUGS Requires the GNU readline library. freetds-1.00.82/doc/freebcp.1.in100644 025423 025423 00000014323 12522201763 0011673.\" cf. groff_mdoc .Dd March 25, 2015 .Os FreeTDS @VERSION@ .Dt FREEBCP 1 .Sh NAME .Nm freebcp .Nd bulk loading utility for Sybase and Microsoft databases .Sh SYNOPSIS .Nm .Bo Bo Ao Ar database Ac Ns . Bc Ns Ao Ar owner Ac Ns . Bc Ns Aq Ar object_name .Bro .Ar in | .Ar [query] Ns Ar out .Brc .Ar datafile .Bro .Fl c | .Fl n | .Fl f Ar formatfile .Brc .Op Fl S Ar servername .Op Fl D Ar dbname .Op Fl U Ar username .Op Fl P Ar password .Op Fl b Ar batchsize .Op Fl F Ar firstrow .Op Fl L Ar lastrow .Op Fl e Ar errfile .Op Fl I Ar interfaces .Op Fl m Ar maxerror .Op Fl t Ar field_term .Op Fl r Ar row_term .Op Fl h Ar hints .Op Fl T Ar textsize .Op Fl A Ar packet_size .Op Fl O Ar options .Op Fl i Ar inputfile .Op Fl o Ar outputfile .Op Fl C Ar charset .Op Fl EdVv .\" .Sh DESCRIPTION .Nm is a utility program distributed with FreeTDS. .Nm replicates (in part at least) the functionality of the bcp utility programs distributed by Sybase and Microsoft. .Nm makes use of the DB-Library bcp API provided by FreeTDS. This API is also available to application developers. .Pp The manual pages or online help for Sybase or SQL Server can be referenced for more detailed information on bcp functionality. .\" .Sh TABLES\ AND\ FILES .Bl -tag -width indent .It Ar database The name of the database containing object to be copied. Optional if the table/view is in the default database for .Ar username . .It Ar schema The schema of the object being copied. If not provided, the default schema for .Ar username is used. .It Ar object The name of the database object you wish to access, typically a table. It can also be a view. All views can be read; some can be written, subject to constraints. With .Ar queryout Ns , Ar object can also be an SQL query. .It Ar in Copy data from a host file to a database table. .It Ar out Copy data from a database table to a host file. .It Ar queryout indicates that .Ar table_name is in fact SQL, rather than a database object. .Nm will execute the query and write the results to a file. (It is a good idea to have the query return one and only one result set.) .It Ar datafile The name of an operating system file. .El .\" .Sh OPTIONS .Bl -tag -width indent .It Fl A Ar packet_size Set the size of a TDS packet to packet_size. Not sure why you would want to do this, except as an experiment. .It Fl D Ar dbname The name of the default database to use. Overrides default database associated with the login account. Causes .Nm to issue a .Ic USE Ar dbname command immediately after logging in, before commencing BCP operations. .It Fl E Write the data in datafile to the table's IDENTITY column. Without this flag, the identity data present in the datafile will be ignored, and new IDENTITY values will be generated for the imported rows. .It Fl F Ar firstrow The first row to copy from the input file or database table. The default is the first row, row 1. .It Fl I Ar interfaces The name and location of the .Pa interfaces file to search when connecting to servername. Overrides .Pa freetds.conf. .It Fl L Ar lastrow The last row to copy from an input file or database table. The default is the last row. .It Fl O Ar options SQL text to set connection options prior to the bcp operation. If .Ar options is a valid filename, the SQL is read from the file instead. Sometimes needed for .Ar queryout . Example: .Li -O `SET QUOTED_IDENTIFIER ON' Ns . .It Fl P Ar password The password associated with .Ar username . .It Fl S Ar servername The name of the Database Server to which to connect. .It Fl T Ar textsize For text or image columns, set the maximum number of characters to request from the server. Defaults to the setting in .Pa freetds.conf . If not specified anywhere, defaults to the full size of the data. .It Fl U Ar username A database login name. For TDS\ 7+ connections, a domain login is attempted if .Ar username is not provided. .It Fl b Ar batchsize The number of rows per batch of data copied. Batching applies only when you are bulk copying into the database. Each batch of data is effectively .Dq committed into the database. The default value for .Ar batchsize is 1000. .It Fl c The host data file is (or will be) in "character" format, i.e., a text file. Encoding is determined by the client charset attribute in .Pa freetds.conf . .It Fl d Turn off any logging. (Unintuitive, perhaps.) .It Fl e Ar errfile Write errors to .Ar errfile . For uploads. Includes line and column information, and the row data. .It Fl f Ar formatfile The format of the host data file is described by .Ar formatfile . The layout of .Ar formatfile is identical to that understood by the Sybase and Microsoft bcp utilities, but is too complicated to describe here. .It Fl h Ar hints Set bcp hints. For valid values, cf. .Fn bcp_options in the FreeTDS Reference Manual. .It Fl m Ar maxerror Stop after encountering .Ar maxerror errors. Default 10. .It Fl n The host data file is in .Dq native format. This is a format that .Nm will be able to process, but is not portable or readable. .It Fl r Ar row_term The row terminator for a character file. May be more than one character. Default is newline ('\\n'). Cf\&. .Fl c Ns , above. .It Fl t Ar field_term The field terminator for character file. Also known as a column delimiter. May be more than one character. Default is tab ('\\t'). Cf\&. .Fl c Ns , above. .It Fl v .It Fl V Print the version information and exit. .It Fl i Ar inputfile Read input data from file specified. .It Fl o Ar outputfile Write output data to file specified. .It Fl C Ar charset Specify character set to use to talk to server. .El .Sh ENVIRONMENT .Ev DSQUERY default .Ar servername .\" .Sh NOTES When connecting to a Sybase database server, it is required that the TDS 5.0 protocol be used. When connecting to a Microsoft SQL Server 2000 database server, the TDS\ 7 (or later) protocol is required. .Pp Sybase and Microsoft define different versions of the bcp portion of TDS 4.2. Because FreeTDS has no way of knowing which type of server it's connected to, .Nm does not support version 4.2 of the TDS protocol. .\" .Sh HISTORY .Nm first appeared in FreeTDS 0.60 .Sh AUTHORS The .Nm utility was written by .An Bill Thompson Aq thompbil@exchange.uk.ml.com .Sh BUGS Currently, there is no support for text data types in .Nm Ns , when SQL Server 2000 is the target server. freetds-1.00.82/doc/freetds.conf.5.in100644 025423 025423 00000014523 12522201763 0012653.\" $Id: freetds.conf.5,v 1.4 2009-12-14 01:02:27 jklowden Exp $ .Dd December 23, 2007 .Os FreeTDS @VERSION@ .Dt FREETDS.CONF "FreeTDS 5" "FreeTDS Reference Manual" . .Sh NAME .Nm freetds.conf .Nd configuration file for FreeTDS . .Sh SYNOPSIS The .Pa freetds.conf file describes Sybase and Microsoft database servers to the FreeTDS library. It comprises sections headed by a servername, followed by a list of connection properties denoted as name-value pairs. Defaults are defined via a .Bq global section. This file supersedes the .Pa interfaces file that Sybase defines for the same purpose, although the latter is still supported. . .Sh DESCRIPTION A section begins with a servername \(em the name of the server \(em in square brackets. The servername is chosen at the client's descretion. (One exception: with Sybase ASA the servername must match the database name to be used.) .Pp Sections contain properties, one per line, in the form .Pp .Dl name = value .Pp where .Ar name is the connection property to be described. Servernames and properties are not case sensitive. Values are case-preserving i.e., copied literally. Comments begin with either a semicolon .Pq So ; Sc or pound sign .Pq So # Sc and continue to end of line. Blank lines are ignored. Whitespace surrounding the .So = Sc is ignored. . .Sh PROPERTIES .Bl -tag -width "emulate little endian" -compact . .It client charset encoding of client data; overrides locale(1) settings .Bl -tag -width "default:" -compact .It Domain: iconv character set names .It Default: ISO-8859-1 .El . .It connect timeout seconds to wait for response from connect request .Bl -tag -width "default:" -compact .It Domain: 0 to MAX_INT .It Default: none .El . .It debug flags logging granularity .Bl -tag -width "default:" -compact .It Domain: 32-bit integer .It Default: 0x4fff .El . .It dump file specifies location of a logfile and turns on logging .Bl -tag -width "default:" -compact .It Domain: valid file name .It Default: none .El . .It dump file append log data appended to file instead of re-writing for each connection .Bl -tag -width "default:" -compact .It Domain: yes/no .It Default: no .El . .It emulate little endian forces big endian machines to act as little endian to communicate with Microsoft Servers .Bl -tag -width "default:" -compact .It Domain: yes/no .It Default: no .El . .It encryption .Bl -tag -compact .It Em off disables encryption (default) .It Em request use if available .It Em required allow encrypted connections only .El . .It host Name of the host the server is running on. .Bl -tag -width "default:" -compact .It Domain: host name or IP address .It Default: SYBASE .El . .It initial block size maximum size of a protocol block .Bl -tag -width "default:" -compact .It Domain: multiple of 512 .It Default: 512 .El . .It instance name of Microsoft SQL Server instance to connect to (supersedes .Em port ) .Bl -tag -width "default:" -compact .It Domain: instance name .It Default: none .El . .It port port number that the server is listening to .Bl -tag -width "default:" -compact .It Domain: any valid port .It Default: TDS 5.0, 5000; TDS 7.0 and up, 1433 .El . .It tds version TDS protocol version to use .Bl -tag -width "default:" -compact .It Domain: 4.2, 5.0, 7.0, 7.1, 7.2 .It Default: .Fl -with-tdsver value (5.0 if unspecified) .El . .It text size default value of TEXTSIZE, in bytes .Bl -tag -width "default:" -compact .It Domain: 0 to 4,294,967,295 .It Default: 4,294,967,295 .El . .It timeout seconds to wait for response to a query .Bl -tag -width "default:" -compact .It Domain: 0 to MAX_INT .It Default: none (wait forever) .El . .El .Pp Do not define both .Fa port and .Fa instance Ns \&. One implies the other. .Pp Boolean property values may be denoted as on/off, true/false, or 1/0. . .Ss DEBUG FLAGS The log's granularity can be controlled with the .Em debug flags property. .Bl -column -offset indent ".Sy 0x8000" ".Sy show source level info (source file and line)" .It Sy Value Ta Sy Meaning .It Li \ \ 0x02 severe error .It Li \ \ 0x04 error .It Li \ \ 0x08 warning .It Li \ \ 0x10 network .It Li \ \ 0x20 information level 1 .It Li \ \ 0x40 information level 2 .It Li \ \ 0x80 function trace and info .It Li 0x1000 show pid .It Li 0x2000 show time .It Li 0x4000 show source level info (source file and line) .It Li 0x8000 thread id (not implemented). .El . .Sh NAMES AND LOCATIONS The file is normally named .Pa /etc/freetds.conf or .Pa ${HOME}/.freetds.conf . That name can be overridden with the FREETDSCONF environment variable. .Pp FreeTDS will search conf files for a servername in the following order: .Bl -enum -offset indent -compact .It a filename set programatically via dbsetifile() that is in .conf format .It a filename in the environment variable FREETDSCONF that is in .conf format .It .Pa ${HOME}/.freetds.conf if extant .It .Pa @sysconfdir@/freetds.conf .El .Pp The search stops with the first file containing the servername. .Pp If no conf file is found, FreeTDS searches for an .Pa interfaces file in the following order: .Bl -enum -offset indent -compact .It a filename set programatically via dbsetifile() that is in .Pa interfaces format .It .Pa ${HOME}/.interfaces .It .Pa $SYBASE/interfaces (where .Ev $SYBASE is an environment variable) .El .Pp If the requested servername is not found in any configuration file, the fallback mechanism is: .Bl -enum -offset indent -compact .It attempt to convert the name to an IP address with inet_addr(3), else .It attempt to convert the name to an IP address with gethostbyname(3), else .It attempt to look up the literal name .Dq SYBASE .El . .Sh ENVIRONMENT .Bl -tag -width "TDSDUMPCONFIG" -compact .It Ev FREETDSCONF overrides name and location of the system-wide conf file .It Ev TDSDUMP overrides the name and location of the FreeTDS log file .It Ev TDSDUMPCONFIG specifies a name and location of a file that logs the search of configuration files .It Ev TDSHOST overrides the host property .It Ev TDSPORT overrides the port property .It Ev TDSQUERY synonym for DSQUERY, the default servername .It Ev TDSVER overrides the version specified in the freetds.conf .El .Pp The environment variables .Ev TDSVER, Ev TDSDUMP, Ev TDSPORT, Ev TDSQUERY, and Ev TDSHOST override values set by a .conf or .Pa interfaces file. . .Sh FILES .Pa @sysconfdir@/freetds.conf , ${HOME}/.freetds.conf . .Sh SEE ALSO .%B FreeTDS User Guide . .Sh HISTORY \.conf files first appeared with version 0.53 of FreeTDS. freetds-1.00.82/doc/osql.1.in100644 025423 025423 00000003743 12522201763 0011247.\" cf. groff_mdoc .Dd April 26, 2012 .Os FreeTDS @VERSION@ .Dt OSQL FreeTDS "FreeTDS Reference Manual" .\" .Sh NAME .Nm osql .Nd utility to test FreeTDS connections and queries .\" .Sh SYNOPSIS .Pp .Nm .Fl S Ar dsn .Fl U Ar username .Fl P Ar password .Op Fl I Pa ini_directory .\" .Sh DESCRIPTION .Pp .Nm is a diagnostic tool provided as part of FreeTDS. It is a Bourne shell script that checks and reports on your configuration files. If everything checks out OK, it invokes isql. .Pp .Nm works only with the isql that comes with unixODBC. .\" .Sh OPTIONS .Bl -tag -width indent .It Fl S Ar dsn the Data Source Name to which to connect, as known to .Pa odbc.ini Ns . .It Fl U Ar username database login name. .It Fl P Ar password database password. .It Fl I Ar ini_dir override .Pa odbc.ini file location. .El .\" .Sh EXAMPLE If you have an .Pa odbc.ini with a section like this: .Bd -literal -offset indent .Bq myDSN servername = myserver TDS_Version = 5.0 .Ed .Pp You would invoke .Nm as: .Pp .Li osql -S myDSN .Op .\|.\|.\& .\" .Sh FILES .Pa odbc.ini .Pa freetds.conf .\" .Sh NOTES If you can connect with .Ql osql -S servername -U user -P passwd Ns , your FreeTDS ODBC installation is working. .Pp .Nm guesses where unixODBC might look for its .Pa odbc.ini by examining the binary. This is not always an effective approach. If it doesn't work, you'll receive a report of candidate strings. Kindly pass along the output to help improve the guessing. .Pp If .Nm cannot intuit your .Pa odbc.ini directory, you can force the issue with the .Fl I option. However, you're then instructing .Nm what to test, not where unixODBC will eventually look. Your override is therefore only as good as you are. Look carefully at the error output before overriding. .Pp If you have suggestions for ways to make .Nm more useful as a diagnostic tool, please post them to the FreeTDS mailing list. .\" .Sh HISTORY .Nm first appeared in FreeTDS 0.65. .\" .Sh AUTHORS The .Nm utility was written by .An James K. Lowden Ns . freetds-1.00.82/doc/tsql.1.in100644 025423 025423 00000006637 12522201763 0011261.\" cf. groff_mdoc .Dd March 25, 2015 .Os FreeTDS @VERSION@ .Dt TSQL FreeTDS "FreeTDS Reference Manual" .Sh NAME .Nm tsql .Nd utility to test FreeTDS connections and queries .Sh SYNOPSIS .Nm .Bro .Fl S Ar servername .Op Fl I Ar interface | .Fl H Ar hostname .Op Fl L .Op Fl p Ar port .Brc .Op Fl D Ar dbname .Op Fl U Ar username .Op Fl P Ar password .Op Fl o Ar options .Nm .Fl C .Sh DESCRIPTION .Nm is a FreeTDS diagnostic tool. It uses the TDS protocol to connect to a Sybase or Microsoft SQL Server, and lets the user issue queries. .Nm does not use the FreeTDS client libraries. Instead, it uses only the lowest level library, libtds, to test the protocol implementation. .Pp .Nm can be run in two ways, one which uses the freetds.conf and one which connects directly using the server's hostname and port. The .Fl H and .Fl p parameters are provided to let the user verify a server is listening on the named host and port. These parameters override any configuration files and environment variables. .Pl The .Fl S parameter can be used to test the local configuration. FreeTDS will use freetds.conf (or equivalent) and environment variables in the normal way to determine the server's IP address and port. You can use .Fl I to specify a filename, overriding FreeTDS's configuration file search algorithm. .Sh OPTIONS .Bl -tag -width indent .It Fl S Ar servername database server to which to connect. .It Fl D Ar dbname database to use. .It Fl I Ar interface freetds.conf or interfaces file describing servername. .It Fl H Ar hostname DNS hostname of the server. .It Fl p Ar port port at which SQL Server is listening. .It Fl U Ar username database login name. If username is not provided, a domain login is attempted for TDS 7+ connections. .It Fl P Ar password database password. .It Fl L list Microsoft server instances (with .Fl H Ns ). .It Fl C print some of the compile-time configuration parameters. .It Fl o Ar options apply the options specified to every command. .Bl -tag -width indent .It Fl f No footer .Bq result count .It Fl h No header .Bq titles .It Fl t Print time .It Fl v Print version .It Fl q Quiet .El .It Fl a Ar appname application name. .It Fl t Ar colterm column terminator. .It Fl r Ar rowterm row terminator. .It Fl r Ar rowterm row terminator. .It Fl J Ar charset character set. .It Fl v verbose mode. .El .\" .Sh NOTES If you can connect with .Ql tsql -S servername Ns , your basic FreeTDS installation is working. .Pp Typing .Ql exit Ns , .Ql quit Ns , or .Ql bye (or .Li ^D Ns ) exits .Nm Ns . .Pp Typing .Ql version displays the TDS protocol version. .Pp Command batches may be separated with .Ql go or .Ql GO Ns . If .Ql GO the version string is reported before executing the batch. .Pp After prompting for the password (if not provided with .Fl P Ns ), .Nm will attempt to connect to the remote server. .Nm displays a counter indicating the number of seconds elapsed during the connection attempt. Typically, .Nm immediately responds with a .Ql 1> prompt. If you see the counter (1, 2, 3, ...), most likely .Nm is unable to connect to the indicated server. .Pp .Nm is not a replacement for a complete isql such as sqsh (www.sqsh.org). If you have suggestions for ways to make .Nm more useful as a diagnostic tool, please post them to the FreeTDS mailing list for consideration. .Sh HISTORY .Nm first appeared in FreeTDS 0.60. .Sh AUTHORS The .Nm utility was written by .An Brian Bruns Ns . .Sh BUGS Several, to be sure, now that it's documented. :) freetds-1.00.82/doc/api_status.txt100644 025423 025423 00000054772 12522201763 0012527#!/usr/pkg/bin/perl # API status document # # $Id: api_status.txt,v 1.65 2010-12-31 16:34:15 jklowden Exp $s # # This tab-delimited file is a database of the "readiness" of the various # APIs. Please feel free to modify it if you notice something is missing or # wrong or incomplete. # # Format rules # # 1. Fields are delimited with one or more tab characters. # Multiple consecutive tabs make hand editing easier; they # do not delimit null fields. # 2. The first column must be one of: 'odbc', 'dblib', 'ctlib'. # Lines starting with *anything* else are ignored. # 3. Field definitions are: # Library: odbc, dblib, or ctlib # Category: chunk of api functionality (bcp/cursors/etc.) # Name[1,2]: self-explanatory # For db-lib, there are two names: # Name 1: Microsoft's name # Name 2: Sybase's name # Status: *OK thought to be working # *stub present but non-functional # *partial parts thought to be working # *(blank) Mentioned in vendor documentation but # not in the FreeTDS C code. # Other statuses are acceptable if you see a need. # Comments: Whatever you'd like to say about the function. # # This little bit of perl will produce a data file suitable for uploading into a table thus: # create table api # ( vendor char(15) NOT NULL # , name char(15) NOT NULL # , section char(15) NULL # , function varchar(30) NOT NULL # , status char(20) NULL # , comment varchar(160) NULL # ) # create view vapi # as # # select *, Total - OK as ToDo, 100 * OK / Total as 'Done%' # from ( # select name # , count(*) as Total # , sum(case status when 'OK' # then 1 else 0 end) as OK # , sum(case status when 'partial' # then 1 else 0 end) as Partial # , sum(case status when 'stub' # then 1 else 0 end) as Stub # from api # group by name # ) as API # # go # create view vapisection # as # # select *, Total - OK as ToDo, 100 * OK / Total as 'Done%' # from ( # select name # , section # , count(*) as Total # , sum(case status when 'OK' # then 1 else 0 end) as OK # , sum(case status when 'partial' # then 1 else 0 end) as Partial # , sum(case status when 'stub' # then 1 else 0 end) as Stub # from api # group by name, section # ) as API # # go while( ) { chomp; next if /^\s*$/; #skip blank lines @row = split /\t/, $_; $row[1] =~ s/\(all\)//; #nullify "all" if( $row[0] eq 'dblib' ) { @row = split /\t+/, $_; my @ms = ('Microsoft', @row[0,1,2, 4,5]); my @sy = ('Sybase', @row[0,1, 3,4,5]); $sy[3] = $ms[3] if $sy[3] eq '(same)'; Print( @ms ) unless $ms[3] eq 'n/a'; Print( @sy ) unless $sy[3] eq 'n/a'; next; } if( $row[0] eq 'ctlib' && @row < 5 ) { if( length($row[-1]) > 10 ) { # missing status pop @row; push @row, ("", $_); } } unshift @row, 'Microsoft' if $row[0] eq 'odbc'; unshift @row, 'Sybase' if $row[0] eq 'ctlib'; Print( @row ); } sub Print() { my @row = @_; while( @row < 6 ) { push @row, ""; } print join ("\t", @row), $/; } # edit the data below the following line __DATA__ odbc (all) SQLAllocConnect OK odbc (all) SQLAllocEnv OK odbc (all) SQLAllocHandle OK odbc (all) SQLAllocStmt OK odbc (all) SQLBindCol OK odbc (all) SQLBindParam OK odbc (all) SQLBindParameter OK odbc (all) SQLBrowseConnect odbc (all) SQLCancel OK odbc (all) SQLCloseCursor OK odbc (all) SQLColAttribute OK odbc (all) SQLColAttributes OK odbc (all) SQLColumnPrivileges OK odbc (all) SQLColumns OK odbc (all) SQLConnect OK odbc (all) SQLCopyDesc OK odbc (all) SQLDescribeCol OK odbc (all) SQLDescribeParam unimplemented odbc (all) SQLDisconnect OK odbc (all) SQLDriverConnect OK odbc (all) SQLEndTran OK odbc (all) SQLError OK odbc (all) SQLExecDirect OK odbc (all) SQLExecute OK odbc (all) SQLExtendedFetch OK odbc (all) SQLFetch OK odbc (all) SQLFetchScroll OK odbc (all) SQLForeignKeys OK odbc (all) SQLFreeConnect OK odbc (all) SQLFreeEnv OK odbc (all) SQLFreeHandle OK odbc (all) SQLFreeStmt OK odbc (all) SQLGetConnectAttr OK odbc (all) SQLGetConnectOption OK odbc (all) SQLGetCursorName OK odbc (all) SQLGetData OK odbc (all) SQLGetDescField OK odbc (all) SQLGetDescRec OK odbc (all) SQLGetDiagField OK odbc (all) SQLGetDiagRec OK odbc (all) SQLGetEnvAttr OK odbc (all) SQLGetFunctions OK odbc (all) SQLGetInfo OK odbc (all) SQLGetStmtAttr OK odbc (all) SQLGetStmtOption OK odbc (all) SQLGetTypeInfo OK odbc (all) SQLMoreResults OK odbc (all) SQLNativeSql partial odbc (all) SQLNumParams OK odbc (all) SQLNumResultCols OK odbc (all) SQLParamData OK odbc (all) SQLParamOptions OK odbc (all) SQLPrepare OK odbc (all) SQLPrimaryKeys OK odbc (all) SQLProcedureColumns OK odbc (all) SQLProcedures OK odbc (all) SQLPutData OK odbc (all) SQLRowCount OK odbc (all) SQLSetConnectAttr OK odbc (all) SQLSetConnectOption OK odbc (all) SQLSetCursorName OK odbc (all) SQLSetDescField OK odbc (all) SQLSetDescRec OK odbc (all) SQLSetEnvAttr partial odbc (all) SQLSetPos OK odbc (all) SQLSetParam OK odbc (all) SQLSetScrollOption OK odbc (all) SQLSetStmtAttr OK odbc (all) SQLSetStmtOption OK odbc (all) SQLSpecialColumns OK odbc (all) SQLStatistics OK odbc (all) SQLTablePrivileges OK odbc (all) SQLTables OK odbc (all) SQLTransact OK dblib (none) n/a db12hour dblib (none) n/a dbaltbind_ps dblib (none) n/a dbbind_ps dblib (none) n/a dbbufsize dblib (none) n/a dbcharsetconv dblib (none) n/a dbcoltypeinfo OK dblib (none) n/a dbconvert_ps OK dblib (none) n/a dbfreesort never dblib (none) n/a dbfree_xlate never dblib (none) n/a dbgetcharset dblib (none) n/a dbgetloginfo never dblib (none) n/a dbgetlusername dblib (none) n/a dbgetnatlang dblib (none) n/a DBIORDESC OK dblib (none) n/a DBIOWDESC OK dblib (none) n/a dbloadsort never dblib (none) n/a dbload_xlate never dblib (none) n/a dbnpcreate never dblib (none) n/a dbnpdefine never dblib (none) n/a dbpoll dblib (none) n/a DBRBUF never dblib (none) n/a dbreadpage never dblib (none) n/a dbrecftos OK dblib (none) n/a dbrecvpassthru never dblib (none) n/a dbregdrop never dblib (none) n/a dbregexec never dblib (none) n/a dbreghandle never dblib (none) n/a dbreginit never dblib (none) n/a dbreglist never dblib (none) n/a dbregnowatch never dblib (none) n/a dbregparam never dblib (none) n/a dbregwatch never dblib (none) n/a dbregwatchlist never dblib (none) n/a dbrpwclr never dblib (none) n/a dbrpwset never dblib (none) n/a dbsafestr OK dblib (none) n/a dbsechandle dblib (none) n/a dbsendpassthru never dblib (none) n/a dbsetbusy dblib (none) n/a dbsetdefcharset dblib (none) n/a dbsetdeflang dblib (none) n/a dbsetidle dblib (none) n/a dbsetifile OK dblib (none) n/a dbsetinterrupt OK dblib (none) n/a DBSETLCHARSET dblib (none) n/a DBSETLENCRYPT dblib (none) n/a dbsetloginfo never dblib (none) n/a dbsetrow OK dblib (none) n/a dbsetversion OK dblib (none) n/a dbspr1row OK dblib (none) n/a dbspr1rowlen OK dblib (none) n/a dbsprhead OK dblib (none) n/a dbsprline OK dblib (none) n/a dbstrcmp never dblib (none) n/a dbstrsort never dblib (none) n/a dbtextsize dblib (none) n/a dbwritepage never dblib (none) n/a dbxlate never dblib bcp bcp_batch (same) OK dblib bcp bcp_bind (same) OK dblib bcp bcp_colfmt (same) OK dblib bcp n/a bcp_colfmt_ps dblib bcp bcp_collen (same) OK dblib bcp bcp_colptr (same) OK dblib bcp bcp_columns (same) OK dblib bcp bcp_control (same) OK dblib bcp bcp_done (same) OK dblib bcp bcp_exec (same) OK dblib bcp n/a bcp_getl OK dblib bcp bcp_init (same) OK dblib bcp bcp_moretext (same) stub dblib bcp n/a bcp_options partial dblib bcp bcp_readfmt (same) OK dblib bcp bcp_sendrow (same) OK dblib bcp BCP_SETL (same) OK dblib bcp bcp_writefmt (same) dblib browse dbcolbrowse n/a never dblib browse dbcolsource n/a never dblib browse dbfreequal n/a never dblib browse dbqual n/a never dblib browse dbtabbrowse n/a never dblib browse dbtabcount n/a never dblib browse dbtabname n/a never dblib browse dbtabsource n/a never dblib browse dbtsnewlen n/a never dblib browse dbtsnewval n/a never dblib browse dbtsput n/a never dblib core dbadata (same) OK dblib core dbadlen (same) OK dblib core dbaltbind (same) OK dblib core dbaltcolid (same) OK dblib core dbaltlen (same) OK dblib core dbaltop (same) OK dblib core dbalttype (same) OK dblib core dbaltutype (same) OK dblib core dbanullbind (same) OK dblib core dbbind (same) OK dblib core dbbylist (same) OK dblib core dbcancel (same) OK dblib core dbcanquery (same) OK dblib core dbchange (same) OK dblib core dbclose (same) OK dblib core dbclrbuf (same) OK dblib core dbclropt (same) partial dblib core dbcmd (same) OK dblib core dbcmdrow DBCMDROW OK dblib core dbcolinfo n/a OK dblib core dbcollen (same) OK dblib core dbcolname (same) OK dblib core dbcoltype (same) OK dblib core dbcolutype (same) OK dblib core dbconvert (same) OK dblib core dbcount DBCOUNT OK dblib core dbcurcmd DBCURCMD stub dblib core dbcurrow DBCURROW stub dblib core dbdata (same) OK dblib core dbdataready n/a dblib core dbdatecrack (same) OK dblib core dbdatlen (same) OK dblib core dbdead DBDEAD OK dblib core dbenlisttrans n/a never dblib core dbenlistxatrans n/a never dblib core dberrhandle (same) OK dblib core dbexit (same) OK dblib core dbfcmd (same) OK dblib core dbfirstrow DBFIRSTROW OK dblib core dbfreebuf (same) OK dblib core dbgetchar (same) OK dblib core dbgetmaxprocs (same) OK dblib core dbgetoff (same) never dblib core dbgetpacket (same) OK dblib core dbgetrow (same) OK dblib core dbgettime DBGETTIME OK dblib core dbgetuserdata (same) OK dblib core dbinit (same) OK dblib core dbisavail DBISAVAIL OK dblib core dbiscount n/a OK dblib core dbisopt (same) partial dblib core dblastrow DBLASTROW OK dblib core dblogin (same) OK dblib core dbfreelogin dbloginfree OK dblib money n/a dbmny4add OK dblib money n/a dbmny4cmp OK dblib money n/a dbmny4copy OK dblib money n/a dbmny4divide stub dblib money n/a dbmny4minus OK dblib money n/a dbmny4mul stub dblib money n/a dbmny4sub OK dblib money n/a dbmny4zero OK dblib money n/a dbmnyadd stub dblib money n/a dbmnycmp OK dblib money n/a dbmnycopy OK dblib money n/a dbmnydec OK dblib money n/a dbmnydivide stub dblib money n/a dbmnydown stub dblib money n/a dbmnyinc OK dblib money n/a dbmnyinit stub dblib money n/a dbmnymaxneg OK dblib money n/a dbmnymaxpos OK dblib money n/a dbmnyminus OK dblib money n/a dbmnymul stub dblib money n/a dbmnyndigit stub dblib money n/a dbmnyscale stub dblib money n/a dbmnysub stub dblib money n/a dbmnyzero OK dblib core dbmorecmds DBMORECMDS OK dblib core dbmsghandle (same) OK dblib core dbname (same) OK dblib core dbnextrow (same) OK dblib core dbnullbind (same) OK dblib core dbnumalts (same) OK dblib core dbnumcols (same) OK dblib core dbnumcompute (same) OK dblib core dbnumorders DBNUMORDERS never dblib core dbopen (same) OK dblib core dbordercol (same) never dblib core dbprhead (same) OK dblib core dbprocerrhandle n/a aliases dberrhandle dblib core dbprocinfo n/a never dblib core dbprocmsghandle n/a aliases dbmsghandle dblib core dbprrow (same) OK dblib core dbprtype (same) OK dblib core dbresults (same) OK dblib core dbrows DBROWS OK dblib core dbrowtype DBROWTYPE OK dblib core n/a dbservcharset OK dblib core dbserverenum n/a never dblib core dbsetavail (same) OK dblib core dbsetlapp DBSETLAPP OK dblib core dbsetlfallback n/a never dblib core dbsetlhost DBSETLHOST OK dblib core dbsetlnatlang DBSETLNATLANG OK dblib core dbsetlogintime (same) OK dblib core dbsetlpacket DBSETLPACKET OK dblib core dbsetlpwd DBSETLPWD OK dblib core dbsetlsecure n/a dblib core dbsetltime n/a dblib core dbsetluser DBSETLUSER OK dblib core dbsetlversion n/a OK dblib core dbsetmaxprocs (same) OK dblib core dbsetnull (same) OK dblib core dbsetopt (same) partial dblib core dbsettime (same) OK dblib core dbsetuserdata (same) OK dblib core n/a dbspid OK dblib core dbsqlexec (same) OK dblib core dbsqlok (same) OK dblib core dbsqlsend (same) OK dblib core n/a dbstrbuild OK dblib core dbstrcpy (same) OK dblib core dbstrlen (same) OK dblib core n/a DBTDS OK dblib core dbuse (same) OK dblib core dbvarylen (same) OK dblib core n/a dbversion OK dblib core dbwillconvert (same) OK dblib core dbwinexit (Windows only) n/a no-op macro dblib cursor dbcursor (same) never dblib cursor dbcursorbind (same) never dblib cursor dbcursorclose (same) never dblib cursor dbcursorcolinfo (same) never dblib cursor dbcursorfetch (same) never dblib cursor dbcursorfetchex n/a never dblib cursor dbcursorinfo (same) never dblib cursor dbcursorinfoex n/a never dblib cursor dbcursoropen (same) never dblib datetime n/a dbdate4cmp never dblib datetime n/a dbdate4zero never dblib datetime n/a dbdatechar never dblib datetime n/a dbdatecmp OK dblib datetime n/a dbdatename never dblib datetime n/a dbdateorder never dblib datetime n/a dbdatepart never dblib datetime n/a dbdatezero never dblib datetime n/a dbdayname never dblib datetime n/a dbmonthname OK dblib procedure dbhasretstat (same) OK dblib procedure dbnumrets (same) OK dblib procedure dbretdata (same) OK dblib procedure dbretlen (same) OK dblib procedure dbretname (same) OK dblib procedure dbretstatus (same) OK dblib procedure dbrettype (same) OK dblib procedure dbrpcexec n/a dblib procedure dbrpcinit (same) OK dblib procedure dbrpcparam (same) OK dblib procedure dbrpcsend (same) OK dblib text dbmoretext (same) OK dblib text dbreadtext (same) OK dblib text dbtxptr (same) OK dblib text dbtxtimestamp (same) OK dblib text dbtxtsnewval (same) dblib text dbtxtsput (same) dblib text dbupdatetext n/a dblib text dbwritetext (same) OK ctlib (all) ct_bind OK Bind server results to program variables. ctlib (all) ct_br_column Retrieve information about a column generated by a browse mode select. ctlib (all) ct_br_table Return information about browse mode tables. ctlib (all) ct_callback OK Install or retrieve a Client-Library callback routine. ctlib (all) ct_cancel OK Cancel a command or the results of a command. ctlib (all) ct_capability OK Set or retrieve a client/server capability. ctlib (all) ct_close OK Close a server connection. ctlib (all) ct_cmd_alloc OK Allocate a CS_COMMAND structure. ctlib (all) ct_cmd_drop OK Deallocate a CS_COMMAND structure. ctlib (all) ct_cmd_props OK Set or retrieve command structure properties. For use by applications that resend commands. ctlib (all) ct_command OK Initiate a language, package, RPC, message, or send-data command. ctlib (all) ct_compute_info OK Retrieve compute result information. ctlib (all) ct_con_alloc OK Allocate a CS_CONNECTION structure. ctlib (all) ct_con_drop OK Deallocate a CS_CONNECTION structure. ctlib (all) ct_con_props OK Set or retrieve connection structure properties. ctlib (all) ct_config OK Set or retrieve context properties. ctlib (all) ct_connect OK Connect to a server. ctlib (all) ct_cursor OK Initiate a Client-Library cursor command. ctlib (all) ct_data_info OK Define or retrieve a data I/O descriptor structure. ctlib (all) ct_debug Manage debug library operations. ctlib (all) ct_describe OK Return a description of result data. ctlib (all) ct_diag OK Manage inline error handling. ctlib (all) ct_ds_dropobj Release the memory associated with a directory object. ctlib (all) ct_ds_lookup Initiate or cancel a directory lookup operation. ctlib (all) ct_ds_objinfo Retrieve information associated with a directory object. ctlib (all) ct_dynamic OK Initiate a dynamic SQL command. ctlib (all) ct_dyndesc Perform operations on a dynamic SQL descriptor area. ctlib (all) ct_dynsqlda Operate on a SQLDA structure. ctlib (all) ct_exit OK Exit Client-Library. ctlib (all) ct_fetch OK Fetch result data. ctlib (all) ct_get_data OK Read a chunk of data from the server. ctlib (all) ct_getformat Return the server user-defined format string associated with a result column. ctlib (all) ct_getloginfo Transfer TDS login response information from a CS_CONNECTION structure to a newly allocated CS_LOGINFO structure. ctlib (all) ct_init OK Initialize Client-Library for an application context. ctlib (all) ct_keydata Specify or extract the contents of a key column. ctlib (all) ct_labels Define a security label or clear security labels for a connection. ctlib (all) ct_options OK Set, retrieve, or clear the values of server query-processing options. ctlib (all) ct_param OK Supply values for a server command's input parameters. ctlib (all) ct_poll stub Poll connections for asynchronous operation completions and registered procedure notifications. ctlib (all) ct_recvpassthru Receive a TDS (Tabular Data Stream) packet from a server. ctlib (all) ct_remote_pwd Define or clear passwords to be used for server-to-server connections. ctlib (all) ct_res_info OK Retrieve current result set or command information. ctlib (all) ct_results OK Set up result data to be processed. ctlib (all) ct_send OK Send a command to the server. ctlib (all) ct_send_data OK Send a chunk of text or image data to the server. ctlib (all) ct_sendpassthru Send a Tabular Data Stream (TDS) packet to a server. ctlib (all) ct_setloginfo Transfer TDS login response information from a CS_LOGINFO structure to a CS_CONNECTION structure. ctlib (all) ct_setparam OK Specify source variables from which ct_send reads input parameter values for a server command. ctlib (all) ct_wakeup Call a connection's completion callback. ctlib (all) cs_calc Perform an arithmetic operation on two operands. ctlib (all) cs_cmp Compare two data values. ctlib (all) cs_config partial Set or retrieve CS-Library properties. ctlib (all) cs_conv_mult stub Retrieve the conversion multiplier for converting character data from one character set to another. ctlib (all) cs_convert OK Convert a data value from one datatype, locale, or format to another datatype, locale, or format. ctlib (all) cs_ctx_alloc OK Allocate a CS_CONTEXT structure. ctlib (all) cs_ctx_drop OK Deallocate a CS_CONTEXT structure. ctlib (all) cs_ctx_global OK Allocate or return a CS_CONTEXT structure. ctlib (all) cs_diag OK Manage inline error handling. ctlib (all) cs_dt_crack OK Convert a machine-readable datetime value into a user-accessible format. ctlib (all) cs_dt_info stub Set or retrieve language-specific datetime information. ctlib (all) cs_loc_alloc OK Allocate a CS_LOCALE structure. ctlib (all) cs_loc_drop OK Deallocate a CS_LOCALE structure. ctlib (all) cs_locale partial Load a CS_LOCALE structure with localization values or retrieve the locale name previously used to load a CS_LOCALE structure. ctlib (all) cs_manage_convert stub Install or retrieve a user-defined character set conversion routine. ctlib (all) cs_objects stub Save, retrieve, or clear objects and data associated with them. ctlib (all) cs_set_convert stub Install or retrieve a user-defined conversion routine. ctlib (all) cs_setnull stub Define a null substitution value to be used when binding or converting NULL data. ctlib (all) cs_strbuild OK Construct native language message strings. ctlib (all) cs_strcmp stub Compare two strings using a specified sort order. ctlib (all) cs_time stub Retrieve the current date and time. ctlib (all) cs_will_convert OK Indicate whether a specific datatype conversion is available in the Client/Server libraries. ctlib (all) blk_alloc OK Allocate a CS_BLKDESC structure. ctlib (all) blk_bind OK Bind a program variable and a database column. ctlib (all) blk_colval stub Server-side routine to obtain the column value from a formatted bulk copy row. ctlib (all) blk_default stub Retrieve a column's default value. ctlib (all) blk_describe OK Retrieve a description of a database column. ctlib (all) blk_done OK Mark a complete bulk copy operation or a complete bulk copy batch. ctlib (all) blk_drop OK Deallocate a CS_BLKDESC structure. ctlib (all) blk_getrow stub Server-side routine to retrieve and store a formatted bulk copy row. ctlib (all) blk_gettext stub Server-side routine to retrieve the text, image, sensitivity, or boundary portion of an incoming bulk copy formatted row. ctlib (all) blk_init OK Initiate a bulk copy operation. ctlib (all) blk_props OK Set or retrieve bulk descriptor structure properties. ctlib (all) blk_rowalloc stub Server-side routine to allocate space for a formatted bulk copy row. ctlib (all) blk_rowdrop stub Server-side routine to free space previously allocated for a formatted bulk copy row. ctlib (all) blk_rowxfer OK Transfer one or more rows during a bulk copy operation without specifying or receiving a row count. ctlib (all) blk_rowxfer_mult OK Transfer one or more rows during a bulk copy operation. ctlib (all) blk_sendrow stub Server-side routine to send a formatted bulk copy row obtained from blk_getrow. ctlib (all) blk_sendtext stub Server-side routine to send text, image, sensitivity, or boundary data in a formatted bulk copy row obtained from blk_sendtext. ctlib (all) blk_srvinit stub Server-side routine to copy descriptions of server table columns to the client, if required. ctlib (all) blk_textxfer stub Transfer a column's data in chunks during a bulk copy operation. freetds-1.00.82/doc/bcp.txt100644 025423 025423 00000001053 12522201763 0011077Bulk Copy --------- BCP Data Format +---------+-----+-----+---------------+----------+-------------+------------+ | | non | row | | | | size of | | size | var | num | fixed columns | row size | var columns | adjustment | | | cols| | | | | table | +---------+-----+-----+---------------+----------+-------------+------------+ +---------+------------+ | end of | offsets | | data | to varlen | | pointer | data | +---------+------------+ freetds-1.00.82/doc/cap.txt100644 025423 025423 00000012326 12522201763 0011103Capabilities ------------ The TDS_CAP_TOKEN token (decimal 226) in TDS is sent to the server immediately after the login sequence in TDS 5.0. It is sent back as part of the login acknowledgement stream. The client requests which capabilities it wants and the server sends back which ones it supports. I'm not certain but I believe a full 5.0 login sequence could be sent to an MS-SQL or Sybase 4.x server and if the 226 token is absent from the return stream then the protocol could default back to 4.2. This would eliminate the need for compiling two versions of the library, of course setting the proto version manually would not send the capabilities. I need someone to try this as I only have access to Sybase 11.x servers. The layout of the capabilities packet is: 1 byte 2 bytes n bytes +---------+---------------+---------------------+ | 226 | size of mask | capabilities field | +---------+---------------+---------------------+ The capabilities field looks like: 1 byte 1 byte n bytes +--------+--------+---------------+ | id | size | bitmask | +--------+--------+---------------+ 1) For id 1 seems to signify request capabilities and 2 is response capabilities. 2) The size represents the size of the bitmask (7 for all I've seen). 3) The bitmask is is a bitset mask denoting values set by ct_capability() or similar call. It is packed from the low order bit to high order bit. The first bit (low order bit...bit 0 of byte 6) is not used for a capability. It seems to be used by the protocol but its function is presently unknown. A listing of all known values for the bitmasks follows with its ctlib constant. Refer to the ctlib documentation for descriptions of these. REQUEST CAPABILITIES -------------------- byte 0: default ctlib value: 3 bit 0 (0x01): CS_PROTO_DYNPROC bit 1 (0x02): CS_DATA_FLTN bit 2 (0x04): CS_DATA_BITN bit 3 (0x08): CS_DATA_INT8 bit 4 (0x10): CS_DATA_VOID bit 5 (0x20): unknown bit 6 (0x40): unknown bit 7 (0x80): unknown byte 1: default ctlib value: 109 bit 0 (0x01): CS_CON_INBAND bit 1 (0x02): CS_CON_LOGICAL bit 2 (0x04): CS_PROTO_TEXT bit 3 (0x08): CS_PROTO_BULK bit 4 (0x10): CS_REQ_URGNOTIF bit 5 (0x20): CS_DATA_SENSITIVITY bit 6 (0x40): CS_DATA_BOUNDARY bit 7 (0x80): CS_PROTO_DYNAMIC byte 2: default ctlib value: 127 bit 0 (0x01): CS_DATA_MONEYN bit 1 (0x02): CS_CSR_PREV bit 2 (0x04): CS_CSR_FIRST bit 3 (0x08): CS_CSR_LAST bit 4 (0x10): CS_CSR_ABS bit 5 (0x20): CS_CSR_REL bit 6 (0x40): CS_CSR_MULTI bit 7 (0x80): CS_CON_OOB byte 3: default ctlib value: 255 bit 0 (0x01): CS_DATA_NUM bit 1 (0x02): CS_DATA_TEXT bit 2 (0x04): CS_DATA_IMAGE bit 3 (0x08): CS_DATA_DEC bit 4 (0x10): CS_DATA_LCHAR bit 5 (0x20): CS_DATA_LBIN bit 6 (0x40): CS_DATA_INTN bit 7 (0x80): CS_DATA_DATETIMEN byte 4: default ctlib value: 255 bit 0 (0x01): CS_DATA_BIN bit 1 (0x02): CS_DATA_VBIN bit 2 (0x04): CS_DATA_MNY8 bit 3 (0x08): CS_DATA_MNY4 bit 4 (0x10): CS_DATA_DATE8 bit 5 (0x20): CS_DATA_DATE4 bit 6 (0x40): CS_DATA_FLT4 bit 7 (0x80): CS_DATA_FLT8 byte 5: default ctlib value: 255 bit 0 (0x01): CS_REQ_MSG bit 1 (0x02): CS_REQ_PARAM bit 2 (0x04): CS_DATA_INT1 bit 3 (0x08): CS_DATA_INT2 bit 4 (0x10): CS_DATA_INT4 bit 5 (0x20): CS_DATA_BIT bit 6 (0x40): CS_DATA_CHAR bit 7 (0x80): CS_DATA_VCHAR byte 6: default ctlib value: 254 bit 0 (0x01): unknown bit 1 (0x02): CS_REQ_LANG bit 2 (0x04): CS_REQ_RPC bit 3 (0x08): CS_REQ_NOTIF bit 4 (0x10): CS_REQ_MSTMT bit 5 (0x20): CS_REQ_BCP bit 6 (0x40): CS_REQ_CURSOR bit 7 (0x80): CS_REQ_DYN RESPONSE CAPABILITIES --------------------- byte 0: default ctlib value: 0 bit 0 (0x01): unknown bit 1 (0x02): unknown bit 2 (0x04): unknown bit 3 (0x08): unknown bit 4 (0x10): unknown bit 5 (0x20): unknown bit 6 (0x40): unknown bit 7 (0x80): unknown byte 1: default ctlib value: 0 bit 0 (0x01): unknown bit 1 (0x02): unknown bit 2 (0x04): unknown bit 3 (0x08): unknown bit 4 (0x10): unknown bit 5 (0x20): unknown bit 6 (0x40): unknown bit 7 (0x80): unknown byte 2: (88) default ctlib value: 10 bit 0 (0x01): CS_DATA_NOBOUNDARY bit 1 (0x02): CS_DATA_NOTDSDEBUG bit 2 (0x04): CS_RES_NOSTRIPBLANKS bit 3 (0x08): CS_DATA_NOINT8 bit 4 (0x10): unknown bit 5 (0x20): unknown bit 6 (0x40): unknown bit 7 (0x80): unknown byte 3: (89) default ctlib value: 120 bit 0 (0x01): CS_DATA_NOINTN bit 1 (0x02): CS_DATA_NODATETIMEN bit 2 (0x04): CS_DATA_MONEYN bit 3 (0x08): CS_CON_NOOOB bit 4 (0x10): CS_CON_NOINBAND bit 5 (0x20): CS_PROTO_NOTEXT bit 6 (0x40): CS_PROTO_NOBULK bit 7 (0x80): CS_DATA_NOSENSITIVITY byte 4: (90) default ctlib value: 0 bit 0 (0x01): CS_DATA_NOFLT4 bit 1 (0x02): CS_DATA_NOFLT8 bit 2 (0x04): CS_DATA_NONUM bit 3 (0x08): CS_DATA_NOTEXT bit 4 (0x10): CS_DATA_IMAGE bit 5 (0x20): CS_DATA_NODEC bit 6 (0x40): CS_DATA_NOLCHAR bit 7 (0x80): CS_DATA_NOLBIN byte 5: (91) default ctlib value: 0 bit 0 (0x01): CS_DATA_NOCHAR bit 1 (0x02): CS_DATA_NOVCHAR bit 2 (0x04): CS_DATA_NOBIN bit 3 (0x08): CS_DATA_NOVBIN bit 4 (0x10): CS_DATA_NOMNY8 bit 5 (0x20): CS_DATA_NOMNY4 bit 6 (0x40): CS_DATA_NODATE8 bit 7 (0x80): CS_DATA_NODATE4 byte 6: (92) default ctlib value: 0 bit 0 (0x01): unknown bit 1 (0x02): CS_RES_NOMSG bit 2 (0x04): CS_RES_NOEED bit 3 (0x08): CS_RES_NOPARAM bit 4 (0x10): CS_DATA_NOINT1 bit 5 (0x20): CS_DATA_NOINT2 bit 6 (0x40): CS_DATA_NOINT4 bit 7 (0x80): CS_DATA_NOBIT freetds-1.00.82/doc/getting_started.txt100644 025423 025423 00000013310 12522201763 0013521Introduction ------------ This document is intended for people who want to help on the FreeTDS project and/or are interested in how the code works. TDS is a fairly simple request/response protocol. It comes in three major flavors: 4.2, 5.0 and 7.0. Microsoft SQL-Server versions through 6.5 still use the 4.2 version as do Sybase servers before 10.0. MS SQL 7.0 introduced TDS 7.0. No version of MS SQL uses 5.0 and Sybase does not use 7.0, but both still support 4.2. TDS 5.0 allows for negotiation of quite a few parameters at connection time, many of these are documented in the cap.txt file in this directory. +--------------------------------------------------------------------------+ | | MS SQL | Sybase ASE | Sybase ASA | +--------------------------------------------------------------------------+ |ver |6.5 |7.0 |2000|2005|2008|2012| <10.x | >11.0 |<5.5.03|5.5*|>6.0| +-----+----+----+----+----+----+----+---------+----------+-------+----+----+ | 4.2 | X | X | X | X | X | X | X | X | | | | | 5.0 | | | | | | | | X | | X | X | | 7.0 | | X | X | X | X | X | | | | | | | 7.1 | | | X | X | X | X | | | | | | | 7.2 | | | | X | X | X | | | | | | | 7.3 | | | | | X | X | | | | | | | 7.4 | | | | | | X | | | | | | +-----+----+----+----+----+----+----+---------+----------+-------+----+----+ * Sybase ASA 5.5 requires 5.5.03 or better with the OpenServer Gateway (OSG). Layers ------ The FreeTDS code is broken down into two layers. The TDS layer handles the bulk of the processing of the protocol and dealing with the network, etc... Any code dealing with protocol issues should reside in this directory (src/tds). A related directory src/server has routines that are used only for server side processes. Actually server is not updated. On top of this layer is a thin layer specific to the 'Call Level Interface' (CLI). A CLI is an API intended to be used by client programs. The core FreeTDS has three CLIs: dblib, the original Sybase API; ctlib, the newer Sybase API; and ODBC, the non-database specific API. Currently dblib and ODBC are the most robust CLIs we have, followed by ctlib, which is quite usable none-the-less. The ODBC CLI is built using a driver manager (either iODBC or unixODBC), so you will need one of those to build it with. Outside of these there is also a JDBC driver for Java and a DBI driver for Perl which do not reside atop the TDS layer. (FreeTDS/JDBC is a pure Java driver). This document does not currently cover these libraries. Those wishing to use Perl are also encouraged to look at DBD::Sybase which uses ctlib and works well with the FreeTDS libraries. The Nitty Gritty ---------------- The first thing a CLI does is allocate a login structure for TDS. Such as: TDS_LOGIN *login = tds_alloc_login(); It can then call any of the tds_set_*() functions to initialize this TDS_LOGIN structure. Please refer to src/tds/login.c for a complete listing of options. Once username, password, server, and other options are set a call can be made to tds_connect(). This will allocate a TDS_SOCKET structure and open a socket connection to the specified server (or NULL on failure). The TDS_SOCKET is then passed as an argument to all future TDS functions. At this point the only really useful thing to do is to call tds_submit_query() and then process the returning rows using tds_process_results() and company. This should get us to the routines in src/tds/token.c which are responsible for reading the results back from the server and doing something with them. The logic in these routines should not be hard to follow. The return stream is broken up into a series of 'messages' (not to be confused with actual messages returned from the server). Each one starts with a marker (marker is my word for it, not Sybase's or anyone else's). include/tds.h defines all the markers and in general there will be one tds_process_*() function for each marker unless it is not worth looking at, in which case tds_process_default_tokens() will read past it. libTDS ------ libTDS (src/tds) is the core of this projects Files details (not exaustive): * convert.c Handles conversion between types; * bulk.c Handles bulk transfer; * config.c Handles configuration files; * data.c Handles handling different column types; * numeric.c Handles specific numeric stuff; * net.c Low level network stuff including socket and SSL; * packet.c Handles network stream at packet level, all TDS communication is encapsulated in packets (TDS packets, do not confuse with network ones); * locale.c Deals with locale information; * log.c Handles logging; * mem.c Handles allocation and freeing of structures; * login.c Handles login with server (contains tds_connect); * read.c, write.c Handle reading and writing to TDS packets; * query.c Contains all routines to send requests; * token.c Contains all routines to get reply from server; * tds_checks.c, tds_checks.h Internal checks; * iconv.c, alternative_character_sets.h, character_sets.h and sybase_character_sets.h Handle character conversions; * tdsstring.c Dynamic string management; * challenge.c, des.c, gssapi.c, hmac_md5.c, md4.c, md5.c, sspi.c Deals with various authentications; * stream.c Deals with large stream of data; * threadsafe.c Utilities for thread safe. Misc ---- Please send fixes and updates to this document to the mailing list (you can find the link on www.freetds.org). I (Brian Bruns) realize it's a little rough right now but I wanted to at least put something out. freetds-1.00.82/doc/policy.txt100644 025423 025423 00000006345 12522201763 0011643Documentation Design Policy, User Guide versus FAQ. James Cameron, 9th November 2001. There are two primary documents in this project, the User Guide and the FAQ. They serve different purposes. The User Guide - is the FreeTDS 'product' documentation, - is specific to each release, - is included in the release, and on the FreeTDS web site, - is structured as a HOWTO, or a list of steps, to get the software working. The FAQ - is the FreeTDS Mailing List documentation, - is FreeTDS release independent, - is on the FreeTDS web site, - is structured as a list of questions. The risks we need to address are: - duplication of content, increasing cost of maintenance, - conflicts between the documents, causing mail traffic, - outdated content is left present, causing mail traffic, - insufficient content, causing mail traffic, - too much content and too little indexing, causing mail traffic. So some policy suggestions ... The FAQ should not duplicate content found in the User Guide, and vice versa. If they have access to the FAQ, they can read the User Guide. If they have access to the User Guide, they shouldn't need the FAQ, unless they hit a defect. To avoid duplication, the FAQ should point to the User Guide to address specific questions, unless the User Guide hasn't got the answer. The User Guide should only point to the FAQ base URL, and should never need to point to specific FAQ content. New content between releases should first go into the FAQ in CVS, with an effective date and FreeTDS version number. The FAQ maintainer will then transfer this to the FreeTDS web site. This new content for the FAQ may breed code changes, or new content for the User Guide. New content for the next release should be inserted into the User Guide in CVS. Once the User Guide is released (by nature of a FreeTDS release), old FAQ entries should be reviewed. -- Date: Fri, 9 Nov 2001 08:07:18 -0500 (EST) From: Brian Bruns To: Cc: Subject: Re: FreeTDS Documentation Design Policy, Draft In-Reply-To: <3BEB6E09.9BC32E58@stl.dec.com> Message-ID: My .02$ The FAQ is 1) A brief description of what freetds is/does (for completeness) as this is the first document many people see. 2) A pointer to other resources: mailing list, user guide, CVS, protocol docs 3) what is supported/not supported. ie Do you support feature X? Including 'are you planning...?' 4) Specific known bugs/build problems with work arounds or dates of fix I think what there is good, except we need to rip out the programming section in favor of the user guide, and section 5 (CVS) needs to go under a more general 'Other Resources' section. Problems Building/Problems Running (4 & 6) probably belong next to each other. I don't know quite where to put 'Which Perl library should I use' but it seems to me to be FAQ fodder, but it doesn't fit the criteria above. The user guide is more detailed. It should explain everything you ever wanted to know about TDS/FreeTDS, discuss its many options in detail, and detail steps for building each type of configuration. I'd personally like to add a section on porting MS dblib/ODBC programs to Unix/Linux. Brian freetds-1.00.82/doc/CodingStyle100644 025423 025423 00000017224 12522201763 0011750The FreeTDS coding style for C code is close to K&R/Linux kernel style. This document makes explicit the coding style found through most of the project. There are likely to be portions of code that do not follow this style, but ideally all would. We are of course not trying to dictate how you code, but patches or submissions to git should be converted to this style prior to committing. The indent program found on most Unix systems will do this nicely. Code Blocks ----------- Blocks of code should start with the { on the line with the control statement. For example, for (i=0;i TDS Protocol Documentation

TDS Protocol Documentation

This document attempts to cover the TDS protocol for:

TDS VersionSupported Products
4.2Sybase SQL Server < 10 and Microsoft SQL Server 6.5
5.0Sybase SQL Server >= 10
7.0Microsoft SQL Server 7.0
7.1Microsoft SQL Server 2000
7.2Microsoft SQL Server 2005

Contents

Common Terms

TDS protocol versions
  TDS 5.0    tds version 5.0
  TDS 7.0    tds version 7.0
  TDS 7.0+   tds version 7.0, 7.1 and 7.2
  TDS 5.0-   tds version 5.0 and previous

Variable types used in this document:
  CHAR      8-bit char
    CHAR[6]	string of 6 chars
    CHAR[n]     variable length string
  XCHAR    single byte (TDS 5.0-) or ucs2le (TDS 7.0+) characters
  INT8      8-bit int
  INT16    16-bit int
  INT32    32-bit int
  UCS2LE   Unicode in UCS2LE format

Note: FreeTDS uses TDS_TINYINT for INT8 and TDS_SMALLINT for INT16.

Typical Usage sequences

These are TDS 4.2 and not meant to be 100% correct, but I thought they might be helpful to get an overall view of what goes on.

--> Login
<-- Login acknowledgement

--> INSERT SQL statement
<-- Result Set Done

--> SELECT SQL statement
<-- Column Names
<-- Column Info
<-- Row Result
<-- Row Result
<-- Result Set Done

--> call stored procedure
<-- Column Names
<-- Column Info
<-- Row Result
<-- Row Result
<-- Done Inside Process
<-- Column Names
<-- Column Info
<-- Row Result
<-- Row Result
<-- Done Inside Process
<-- Return Status
<-- Process Done

The packet format

Every informations in TDS protocol (query, RPCs, responses and so on) is splitted in packets.

All packets start with the following 8 byte header.

 INT8       INT8          INT16      4 bytes
+----------+-------------+----------+--------------------+
|  packet  | last packet |  packet  |    unknown         |
|   type   |  indicator  |   size   |                    |
+----------+-------------+----------+--------------------+

Fields:
packet type 
     0x01 TDS 4.2 or 7.0 query
     0x02 TDS 4.2 or 5.0 login packet
     0x03 RPC
     0x04 responses from server
     0x06 cancels
     0x07 Used in Bulk Copy
     0x0F TDS 5.0 query
     0x10 TDS 7.0 login packet
     0x11 TDS 7.0 authentication packet
     0x12 TDS 8 prelogin packet
last packet indicator 
     0x00 if more packets
     0x01 if last packet
packet size
     (in network byte order)
unknown?
     always 0x00
     this has something to do with server to server communication/rpc stuff

The remainder of the packet depends on the type of information it is providing. As noted above, packets break down into the types query, login, response, and cancels. Response packets are further split into multiple sub-types denoted by the first byte (a.k.a. the token) following the above header.

Note: A TDS packet that is longer than 512 bytes is split on the 512 byte boundary and the "more packets" bit is set. The full TDS packet is reassembled from its component 512 byte packets with the 8-byte headers stripped out. 512 is the block_size in the login packet, so it could be set to a different values. In Sybase you can configure a range of valid block sizes. TDS 7.0+ use a default of 4096 as block size.


TDS 4.2 & 5.0 Login Packet

Packet type (first byte) is 2. The numbers on the left are decimal offsets including the 8 byte packet header.

byte   var type    description
------------------------------
   8   CHAR[30]    host_name
  38   INT8        host_name_length
  39   CHAR[30]    user_name
  69   INT8        user_name_length
  70   CHAR[30]    password
 100   INT8        password_length
 101   CHAR[30]    host_process
 131   INT8        host_process_length
 132   ?           magic1[6]          /* mystery stuff */
 138   INT8        bulk_copy 
 139   ?           magic2[9]          /* mystery stuff */
 148   CHAR[30]    app_name
 178   INT8        app_name_length
 179   CHAR[30]    server_name
 209   INT8        server_name_length
 210   ?           magic3[1]          /* 0, don't know this one either */
 211   INT8        password2_length
 212   CHAR[30]    password2
 242   CHAR[223]   magic4
 465   INT8        password2_length_plus2
 466   INT16       major_version      /* TDS version */
 468   INT16       minor_version      /* TDS version */
 470   CHAR        library_name[10]   /* "Ct-Library" or "DB-Library" */
 480   INT8        library_length
 481   INT16       major_version2     /* program version */
 483   INT16       minor_version2     /* program version */
 485   ?           magic6[3]          /* ? last two octets are 13 and 17 */
                                      /* bdw reports last two as 12 and 16 here  */
                                      /* possibly a bitset flag  */
 488   CHAR[30]    language           /* e.g. "us-english" */
 518   INT8        language_length
 519   ?           magic7[1]          /*  mystery stuff */
 520   INT16       old_secure         /* explanation? */
 522   INT8        encrypted          /*  1 means encrypted all password fields blank */
 523   ?           magic8[1]          /*  no clue... zeros */
 524   CHAR        sec_spare[9]       /* explanation? */
 533   CHAR[30]    char_set           /* e.g. "iso_1" */
 563   INT8        char_set_length
 564   INT8        magic9[1]          /* 1 */ 
 565   CHAR[6]     block_size         /*  in text */
 571   INT8        block_size_length 
 572   ?           magic10[25]        /* lots of stuff here...no clue */

Any help with the magic numbers would be most appreciated.


TDS 7.0+ Login Packet

byte  var type  description
---------------------------
  0   INT32	total packet size
  4   INT8[4]	TDS Version	
                	0x00000070 7.0
			0x01000071 7.1
                	0x02000972 7.2 (7.2.9?)
  8   INT32	packet size (default 4096)
 12   INT8[4]	client program version
 16   INT32	PID of client
 20   INT32	connection id (usually 0)
 24   INT8	option flags 1
                0x80 enable warning messages if SET LANGUAGE issued
                0x40 change to initial database must succeed
                0x20 enable warning messages if USE <database> issued
                0x10 enable BCP
		0x08 use ND5000 floating point format (untested)
		0x04 use VAX floating point format (untested)
		0x02 use EBCDIC encoding (untested)
		0x01 use big-endian byte order (untested)
 25   INT8	option flags 2
                0x80 enable domain login security
		0x40 "USER_SERVER - reserved" 
		0x20 user type is "DQ login"
		0x10 user type is "replication login"
		0x08 "fCacheConnect"
		0x04 "fTranBoundary"
                0x02 client is an ODBC driver
                0x01 change to initial language must succeed
 26   INT8	0x04 spawn user instance (TDS 7.2)
                0x02 XML data type instances are returned as binary XML (TDS 7.2)
                0x01 password change requested (TDS 7.2)
 27   INT8	0x01 SQL Type: 0 = use default, 1 = use T-SQL (TDS 7.2)
 28   INT8[4]	time zone (0x88ffffff ???)
 32   INT8[4]	collation information
 36   INT16	position of client hostname (86)
 38   INT16	hostname length
 40   INT16	position of username
 42   INT16	username length
 44   INT16	position of password
 46   INT16	password length
 48   INT16	position of app name
 50   INT16	app name length
 52   INT16	position of server name
 54   INT16	server name length
 56   INT16	position of remote server/password pairs
 58   INT16	remote server/password pairs length
 60   INT16	position of library name
 62   INT16	library name length
 64   INT16	position of language
 66   INT16	language name (for italian "Italiano", coded UCS2)
 68   INT16	position of database name
 70   INT16	database name length
 72   INT8[6]	MAC address of client
 78   INT16	position of auth portion
 80   INT16	NT authentication length
 82   INT16	next position (same as total packet size)
 84   INT16	0
 86   UCS2LE[n] hostname
      UCS2LE[n]	username
      UCS2LE[n]	encrypted password
      UCS2LE[n]	app name
      UCS2LE[n]	server name
      UCS2LE[n]	library name
      UCS2LE[n]	language name
      UCS2LE[n]	database name
      NT Authentication packet

NT Authentication packet
  0   CHAR[8]	authentication id "NTLMSSP\0"
  8   INT32     1  message type
 12   INT32	0xb201 flags
 16   INT16	domain length
 18   INT16     domain length
 20   INT32     domain offset
 24   INT16     hostname length
 26   INT16     hostname length
 28   INT32     hostname offset
 32   CHAR[n]   hostname
      CHAR[n]   domain
See documentation on Samba for detail (or search ntlm authentication for IIS)

For mssql 2005 before hostname (byte 86) you have
 86   INT16     next position,  or 
                position of file name for a database to be 
                attached during the connection process
 88   INT16     database filename length
 90   INT16     new password position
 92   INT16     new password length
 94   UCS2LE[n] hostname
      ... (as above)

"current pos" is the starting byte address for a Unicode string within the packet. The length of that Unicode string immediately follows. That implies there are at least 2 more strings that could be defined. (character set??)

Username and password are empty if domain authentication is used.

If the client uses an authentication packet, the server replies with an Authentication token followed by an Authentication packet.


TDS 7.0 Authentication Packet

 varies
+------+
| auth |
+------+

auth   authentication data
       for NTLM this message 3

This packet usually follows Authentication token.


Types

HEXDECtypeprotocolnullablesizecollate
0x1F31SYBVOID7+no0
0x2234SYBIMAGEyes4
0x2335SYBTEXTyes4yes
0x2436SYBUNIQUE7+yes1
0x2537SYBVARBINARYyes1
0x2638SYBINTNyes1
0x2739SYBVARCHARyes1
0x2D45SYBBINARYyes1
0x2F47SYBCHARyes1
0x3048SYBINT1no0
0x3250SYBBITno0
0x3452SYBINT2no0
0x3856SYBINT4no0
0x3A58SYBDATETIME4no0
0x3B59SYBREALno0
0x3C60SYBMONEYno0
0x3D61SYBDATETIMEno0
0x3E62SYBFLT8no0
0x4064SYBSINT15no0
0x4165SYBUINT25no0
0x4266SYBUINT45no0
0x4367SYBUINT85no0
0x6298SYBVARIANT7+yes4
0x6399SYBNTEXT7+yes4yes
0x67103SYBNVARCHAR7+yes1
0x68104SYBBITNyes1
0x6A106SYBDECIMALyes1
0x6C108SYBNUMERICyes1
0x6D109SYBFLTNyes1
0x6E110SYBMONEYNyes1
0x6F111SYBDATETIMNyes1
0x7A122SYBMONEY4no0
0x7F127SYBINT8no0
0xA5165XSYBVARBINARY7+yes2 *
0xA7167XSYBVARCHAR7+yes2 *yes
0xAD173XSYBBINARY7+yes2
0xAF175XSYBCHAR7+yes2yes
0xE1225SYBLONGBINARY5yes4
0xE7231XSYBNVARCHAR7+yes2 *yes
0xEF239XSYBNCHAR7+yes2yes

* Under TDS 7.2+ these types allow size to be -1, representing varchar(max), varbinary(max) and nvarchar(max). Data representation for them changes:

  • size is 64 (not 16) bits
  • size of -1 means NULL
  • size of -2 means the size is unknown
  • the data are split in chunks, where each chunk starts with a 32-bit size
  • a chunk with size <= 0 is the terminal chunk

Collation type - TDS 7.1

The collation structure contains information about the character set encoding and comparison method.

 INT16      INT16    INT8
+----------+--------+------------+
| codepage | flags  | charset_id |
+----------+--------+------------+

codepage    windows codepage (see http://www.microsoft.com/globaldev/nlsweb/)
            also specified in lcid column of master..syslanguages
flags       sort flags
            0x100 binary compare
            0x080 width insensitive
            0x040 Katatype insensitive
            0x020 accent insensitive
            0x010 case insensitive
            If binary flag is specified other flags are not present
            Low nibble of flags is a charset specifier (like chinese dialect)
charset_id  charset id in master..syscharsets table or zero for no SQL collations

Collations names can be obtained from select name from ::fn_helpcollations() query


Column Metadata

 INT8          XCHAR[n]       INT8    INT32   INT8
+-------------+--------------+-------+-------+---------+
| column name | column name  | flags |  user | column  |
|   length    |              |       |  type |  type   |
+-------------+--------------+-------+-------+---------+

 varies        INT8       INT8       INT16      XCHAR[n]     INT8     varies
+-------------+----------+----------+----------+------------+--------+--------+
| column size |precision |  scale   | t length | table name | locale | locale |
|             |          |          |          |            | length |  info  |
| (optional)  |(optional)|(optional)|(optional)| (optional) | (opt)  | (opt)  |
+-------------+----------+----------+----------+------------+--------+--------+

column name length 
column name        column name in result set, not necessarily db column name
flags              bit flags
                   0x1  hidden (TDS 5.0)
                   0x2  key
                   0x10 writable
                   0x20 can be NULL
                   0x40 identity
user type          usertype column from syscolumns
column type        column type
column size        not present for fixed size columns
precision          present only for SYBDECIMAL and SYBNUMERIC
scale              present only for SYBDECIMAL and SYBNUMERIC
t length           present only for SYBTEXT and SYBIMAGE, length of table name
table name         present only for SYBTEXT and SYBIMAGE
locale length      length of locale info (in bytes)
                   only for TDS 5.0 results (not for parameters)
locale info        unknown
                   only for TDS 5.0 results (not for parameters)

Client request

Normal tokens (contained in packets 0xF)

TODO

Special packets


Language packet (0x1 1)

This sample packet contain just SQL commands. It's supported by all TDS version (although TDS 5.0 have others token with similar use)

  XCHAR[n]
+---------+
| string  |
+---------+

string   SQL text

RPC packet (0x3 3)

Do not confuse an RPC packet with an RPC token. The RPC packet is supported by all version of TDS; the RPC token is supported only by TDS 5.0 (and has different format). This is the oldest (and the only one in mssql) way to call directly an RPC. Sybase also documents it, but as 0xE.

  INT16         XCHAR[n]   INT16  
+-------------+----------+-------+----------+
| name length | rpc name | flags | params   |
+-------------+----------+-------+----------+

name length   length of RPC name in characters. 
              mssql2k+ support some core RPC using numbers
              If a number is used instead of name name length is marked as -1
              (null) and a INT16 is used for the name.
                0x1  1  sp_cursor
                0x2  2  sp_cursoropen
                0x3  3  sp_cursorprepare
                0x4  4  sp_cursorexecute
                0x5  5  sp_cursorprepexec
                0x6  6  sp_cursorunprepare
                0x7  7  sp_cursorfetch
                0x8  8  sp_cursoroption
                0x9  9  sp_cursorclose
                0xA  10 sp_executesql
                0xB  11 sp_prepare
                0xC  12 sp_execute ???
                0xD  13 sp_prepexec
                0xE  14 sp_prepexecrpc
                0xF  15 sp_unprepare
              sp_execute seems to have some problems, even MS ODBC use name
              version instead of number.
rpc name      name of RPC.
flags         bit flags. 
               0x1 1 recompile procedure (TDS 7.0+/TDS 5.0)
               0x2 2 no metadata (TDS 7.0+)
                     (I don't know meaning of "no metadata" -- freddy77)
params        parameters. See below

Every parameter has the following structure

+-----------+------+
| data info | data |
+-----------+------+
data info    data information. See below
data         data. See results for detail

Data info structure

  INT8          XCHAR[n]     INT8    INT32
+-------------+------------+-------+--------------------+
| name length | param name | flags | usertype (TDS 5.0) |
+-------------+------------+-------+--------------------+
  INT8   varies  varies     INT8[5]         INT8
+------+-------+----------+---------------+------------------+
| type | size  | optional | collate       | locale           |
|      | (opt) | (opt)    | info(TDS 7.1) | length (TDS 5.0) |
+------+-------+----------+---------------+------------------+

name length   parameter name length (0 if unused)
param name    parameter name
flags         bit Name           Meaning
              0x1 TDS_RPC_OUTPUT output parameter
              0x2 TDS_RPC_NODEF  output parameter has no default value. 
                                 Valid only with TDS_RPC_OUTPUT.

usertype      usertype
type          param type
size          see Results
optional      see Results. Blobs DO NOT have 
              optional on input parameters (output blob parameters
              are not supported by any version of TDS).
collate info  only for type that want collate info and using TDS 7.1
locale length locale information length. Usually 0 (if not locale
              information follow, the structure is unknown)

Chained RPCs

Under TDS 7.0+ is possible to chain multiple RPCs together. This is useful to limit packets and round-trips with server. RPCs can be chained using byte 0x80 (TDS 7.0/TDS 7.1) or 0xFF (TDS 7.2).

       INT8                     INT8
+-----+------------------------+----------------+-----+
| RPC | 0x80 (TDS 7.0/TDS 7.1) | 0xFF (TDS 7.2) | RPC | ...
+-----+------------------------+----------------+-----+

Bulk Copy packet (0x7 7)

This documents a TDS 5.0 packet. It might be true for others....

BCP Packet Structure

 INT8       INT16          INT32                
+----------+-------------+--------------------+
|  packet  | last packet |  packet            |
| type = 7 |  indicator  |   size             |
+----------+-------------+--------------------+

		followed by N row buffers, 
		where N is computed by exhausting the packet size

BCP Packet Row Buffer

 INT16          INT8       INT8	      INT16	    
+--------------+----------+----------+--------------+
| size         |  ncols   |  zero    | size (again) |
+--------------+----------+----------+--------------+

	followed by column buffers (data), where 
		
		first, the fixed-size datatype columns

		 fixed size and count (determined by column definition)
		+--------------+
		|    data .... | [repeats once for each mandatory column]
		+--------------+

		then, the variable-size (including nullable) datatype columns

		 variable size and count
		+--------------+
		|    data .... | [repeats ncol times]
		+--------------+

		followed by two tables (!) to describe the column buffers

 Adjustment Table (optional)
 
 INT8       INT8        
+----------+----------+
| 1 + ncols| offset   | [repeats ncol + 1 times]
+----------+----------+

 Offset Table (mandatory)
 
 INT8       INT8        
+----------+----------+
| 1 + ncols| offset   | [repeats ncol + 1 times]
+----------+----------+

The BCP packet has a slightly different Packet header!?

Computation of Offset and Adjustment tables

The offset and adjustment tables describe the postion of the first byte of each variable-size column. The first element holds the count of elements in the offset/adjustment table. Thereafer, the offsets are arranged in reverse order: the last element — which is also the last byte of the row buffer — holds the offset from the start of the row of the first variable-size column. The next-to-last offset table element holds the starting position of the second variable-size column, and so on.

Offset Table Example

  1. 5
  2. 31
  3. 22
  4. 21
  5. 8
  6. 4

The first element is 5 because there are five elements in the list. There are 4 column data buffers with 5 endpoints. The first column's data begins at offset 4. Computations:

column 1
offset 4
length: 4 = 8 - 4
column 2
offset 8
length: 13 = 21 - 8
column 3
offset 21
length: 1 = 22 - 21
column 4
offset 22
length: 9 = 31 - 22

Any column not accounted for is implicitly NULL. To represent a NULL column between two dataful columns, the offset table will have adjacent entries of the same value.

Adjustment table

The so-called adjustment table provides for longer rows. The reader will note the Offset table has 8-bit elements, which would limit the width of the table: the last variable column would have to end less than 256 bytes from the start fo the row. Rather than changing the definition of the Offset table, a second table, the Adjustment table, was introduced. It holds high-order bytes for the column offsets.

In other words, to compute a variable column's offset from the start of the row buffer, the server looks up its offset table value, then consults the same position in the adjustment table, and splices them together.

Offset table commentary

The BCP packet is very dense. The data formats are governed by the table definition. Non-NULL columns of course must be present; there is no need to count them or compute their size. The NULL columns are undelimited; their boundaries are defined by the minimalist offset table.

The Adjustment table seems silly at first glance. Why not just make the offset table's elements 16 or or even 32 bits? The reason is overhead. Most rows will have less than 256 bytes of variable column data. By using the adjustment table, the BCP packet avoids adding one or even three empty bytes per column per row.

Why is the table in reverse order? Because that places the first offset at a known location: the end of each row gives the start of the first column. The server can work its way down the offset table and compute the column sizes. If they don't add up — if there are data between the (presumed) end of the last column and the start of the offset table — the server knows it should look for an adjustment table. Because the scheme is infinitely repeatable, rows could one day grow to terabyte widths without redefining the packet structure.


Server Responses

Responses from the server start with a single octet (token) identifying its type. If variable length, they generally have the length as the second and third bytes

Tokens encountered thus far:
HEXDECnamenote
0x2032Param Format 25.0 only
0x2133Language5.0 only, client-side
0x2234OrderBy 25.0 only??
0x6197Row Format 25.0 only
0x71113"Logout"5.0? ct_close(), client-side?
0x79121Return Status 
0x7C124Process ID4.2 only
0x80128Cursor Close5.0 only
0x81129Cursor Delete5.0 only
0x811297.0 Result7.0 only
0x82130Cursor Fetch5.0 only
0x83131Cursor Info5.0 only
0x84132Cursor Open5.0 only
0x86134Cursor Declare5.0 only
0x881367.0 Compute Result7.0 only
0xA0160Column Name4.2 only
0xA1161Column Format4.2 only
0xA3163Dynamic 25.0 only
0xA4164Table namesname of tables in a FOR BROWSE select
0xA5165Column Infocolumn information in a FOR BROWSE select
0xA6166Option Cmd5.0 only
0xA7167Compute Names 
0xA8168Compute Result 
0xA9169Order By 
0xAA170Error Message 
0xAB171Info Message 
0xAC172Output Parameters 
0xAD173Login Acknowledgement 
0xAE174Control 
0xD1209Data --- Row Result 
0xD3211Data --- Compute Result 
0xD7215Params5.0 only
0xE2226Capability5.0 only. Information on server
0xE3227Environment Change(database change, packet size, etc...)
0xE5229Extended Error Message 
0xE6230DBRPC5.0 only RPC calls
0xE7231Dynamic5.0 only
0xEC236Param Format5.0 only
0xED237Authentication7.0 only
0xEE238Result Set5.0 only
0xFD253Result Set Done 
0xFE254Process Done 
0xFF255Done inside Process 

Param Format 2 - TDS 5.0 (0x20 32)

TODO.  


Language - TDS 5.0 (0x21 33)

 INT32    INT8     CHAR[n]
+--------+--------+-------+
| length | status | query |
+--------+--------+-------+

length  total token length
status  0 no args
        1 has args (followed by PARAMFMT/PARAMS)
query   query (total length - 1)

Order By 2 (0x22 34)

TODO.  


Row Format 2 - TDS 5.0 (0x61 97)

TODO.  


"Logout" (0x71 113)

No information. (1 byte, value=0 ?)  


Return Status (0x79 121)

 INT32
+---------------+
| Return status |
+---------------+

The return value of a stored procedure.  

Process ID (0x7C 124)


 8 bytes
+----------------+
| process number |
+----------------+

Presumably the process ID number for an executing stored procedure. (I'm not sure how this would ever be used by a client. *mjs*)  


Cursor Close - TDS 5.0 (0x80 128)

TODO.  


Cursor Delete - TDS 5.0 (0x81 129)

TODO.  


Result - TDS 7.0+ (0x81 129)

 INT16  
+----------+-------------+
| #columns | column_info | 
+----------+-------------+

The TDS 7.0 column_info is formatted as follows for each column:

 INT16      INT16   INT8   varies  varies     INT8[5]         INT8          UCS2LE[n]
+----------+-------+------+-------+----------+---------------+-------------+---------+
| usertype | flags | type | size  | optional | collate       | name length | name    | 
|          |       |      | (opt) | (opt)    | info(TDS 7.1) |             |         |
+----------+-------+------+-------+----------+---------------+-------------+---------+

usertype	type modifier
flags		bit flags
		0x1  can be NULL
		0x8  can be written (it's not an expression)
		0x10 identity 
type		data type, values >128 indicate a large type
size		none for fixed size types
		4 bytes for blob and text
		2 bytes for large types
		1 byte for all others
optional
                               INT8        INT8
                              +-----------+-------+
  numeric/decimal types:      | precision | scale |
                              +-----------+-------+

                               INT16               UCS2LE[n]
                              +-------------------+------------+
  blob/text types:            | table name length | table name |
                              +-------------------+------------+

  collate info are available only using TDS 7.1 and for characters types (but not
  for old type like short VARCHAR, only 2byte length versions)

Cursor Fetch - TDS 5.0 (0x82 130)

TODO.

Cursor Info - TDS 5.0 (0x83 131)

TODO.

Cursor Open - TDS 5.0 (0x84 132)

TODO.

Cursor Declare - TDS 5.0 (0x86 134)

TODO.

Compute Result - TDS 7.0+ (0x88 136)

TODO.

Column Name (0xA0 160)

 INT16          INT8      CHAR[n]               INT8      CHAR[n] 
+--------------+---------+--------------+------+---------+--------------+
| total length | length1 | column1 name | .... | lengthN | columnN name |
+--------------+---------+--------------+------+---------+--------------+

This token is the first token that contain result informations. Is usually followed by Column Format token (0xA1 161)


Column Format (0xA1 161)

 INT16  
+--------------+-------------+
| total length | column_info | 
+--------------+-------------+

The number of columns is the same of previous Column Name token.

The TDS 4.2 column_info is formatted as follows for each column:

 INT8[4]     INT8   varies  varies
+-----------+------+-------+----------+
| usertype/ | type | size  | optional |
|   flags   |      | (opt) | (opt)    |
+-----------+------+-------+----------+

usertype/flags for Sybase

   INT32
  +----------+
  | usertype |
  +----------+

usertype/flags for MSSQL

   INT16
  +----------+-------+
  | usertype | flags |
  +----------+-------+

usertype	type modifier
flags		bit flags (only MSSQL)
		0x1  can be NULL
		0x8  can be written (it's not an expression)
		0x10 identity 
type		data type
size		none for fixed size types
		4 bytes for blob and text
		1 byte for all others
                (TDS 4.2 do not support large types)
optional
                               INT8        INT8
                              +-----------+-------+
  numeric/decimal types:      | precision | scale |
  (supported??)               +-----------+-------+

                               INT16               CHAR[n]
                              +-------------------+------------+
  blob/text types:            | table name length | table name |
                              +-------------------+------------+

Dynamic 2 - TDS 5.0 (0xA3 163)

TODO.

Option Cmd - TDS 5.0 (0xA6 166)

TODO.

Compute Result (0xA8 168)

 INT16          INT16        INT8       varies        INT8      INT8[n]
+--------------+------------+----------+-------------+---------+-------+
| total length | compute id | #columns | column info | #bycols | bycol |
+--------------+------------+----------+-------------+---------+-------+

column info:

 INT8       INT8      INT32      INT8     varies  INT8               varies
+----------+---------+----------+--------+-------+------------------+----------------+
| operator | operand | usertype | column | size  | locale length    | locale info    |
|          |         |          |  type  | (opt) |  info (TDS 5.0)  | (TDS 5.0)      |
+----------+---------+----------+--------+-------+------------------+----------------+

operator      operator
              0x4b COUNT
              0x4c UNSIGNED? COUNT
              0x4d SUM
              0x4e UNSIGNED? SUM
              0x4f AVG
              0x50 UNSIGNED? AVG
              0x51 MIN
              0x52 MAX
              0x09 COUNT_BIG (mssql2k)
              0x30 STDEV (mssql2k)
              0x31 STDEVP (mssql2k)
              0x32 VAR (mssql2k)
              0x33 VARP (mssql2k)
              0x72 CHECKSUM_AGG (mssql2k)
operand       ???
usertype      usertype
column type   data type
size          data size
locale length length of locale informations
locale info   locale informations (unknown)

Each bycol information contains column info for a specific column.

TODO: optional possible?? collate infos ??

TabName (0xA4 164)

TDS4/5/7:

 INT16          INT16         XCHAR[n]
+--------------+-------------+------------+
| total length | name length | table name | ...
+--------------+-------------+------------+

name length   table name length
table name    table name

TDS 7.1:

 INT16          varies
+--------------+-------------+
| total length | table names |
+--------------+-------------+

table name:
 INT8              INT16              XCHAR[n]
+-----------------+------------------+----------------+
| # of components | component length | component name |
+-----------------+------------------+----------------+

ie:
  name        -> 01  04 00  ucs2le "name"
  db..name    -> 03  02 00  ucs2le "db"  00 00  04 00  ucs2le "name"
  db.dbo.name -> 03  02 00  ucs2le "db"  03 00  ucs2le "dbo"  04 00  ucs2le "name"

Column Info (0xA5 165)

 INT16          varies
+--------------+--------------+
| total length | column infos |
+--------------+--------------+

column info:

 INT8    INT8          INT8    INT8          XCHAR[n]
+-------+-------------+-------+-------------+-------------+
| index | table index | flags | name length | column name |
|       |             |       |  (opt)      |  (opt)      |
+-------+-------------+-------+-------------+-------------+

index        index in result format (1-based)
table index  index in previous TabName (1-based)
             0 means no table (ie computed)
flags        set of flags
             0x04 expression
             0x08 key
             0x10 hidden
             0x20 column name present
name length  length of following column
column name  real column name (result contain the label)

This token follow TabName token    


compute "control" ? (0xA7 167)

"control" (0xAE 174)

Miscellaneous note (from *bdw* ?) found with 0xAE:

  has one byte for each column, 
  comes between result(238) and first row(209),
  I believe computed column info is stored here, need to investigate

Order By (0xA9 169)

 INT16    variable (1 byte per col)
+--------+---------+
| length | orders  |
+--------+---------+

length		Length of packet(and number of cols)
orders          one byte per order by indicating the
                column # in the output matching the
                order from Column Info and Column Names
                and data in following Row Data items.
                A 0 indicates the column is not in the
                resulting rows.

an example:
select first_name, last_name, number from employee
order by salary, number
assuming the columns are returned in the order
queried:
first_name then last_name, then number. we would have:
----------------
|  2   | 0 | 3 |
----------------
where length = 2 then the orders evaluate:
0 for salary, meaning there is no salary data returned
3 for number, meaning the 3rd data item corresponding
to a column is the number

 


Error Message (0xAA 170)

Non-error Message (0xAB 171)

Extended Error Message (0xE5 229)

 INT16    INT32        INT8    INT8    
+--------+------------+-------+-------+
| length | msg number | state | level |
+--------+------------+-------+-------+

 INT16      XCHAR[n]  INT8       XCHAR[n]  INT8       XCHAR[n]  INT16             INT32
+----------+---------+----------+---------+----------+---------+-----------------+-----------------+
| m length | message | s length | server  | p length | process | line#(TDS 7.1-) | line# (TDS 7.2) |
+----------+---------+----------+---------+----------+---------+-----------------+-----------------+

length		Length of packet
msg number	SQL message number
state		?
level		An error if level > 10, a message if level <= 10
m length	Length of message
message		Text of error/message
s length	Length of server name
server		Name of "server" ?
p length	Length of process name
process name	Stored procedure name, if any
line#		Line number of input which generated the message

Output Parameters (0xAC 172)

  Output parameters of a stored procedure.

 INT16    INT8       XCHAR[n]  INT8    INT32      INT8
+--------+----------+---------+-------+----------+----------+------+
| length | c length | colname | flags | usertype | datatype | .... | 
+--------+----------+---------+-------+----------+----------+------+

length		Length of packet
c length	Length of colname
colname		Name of column
flags		0x1 Nullable
usertype	cf. systypes table in database
datatype	Type of data returned

The trailing information depends on whether the datatype is
a fixed size datatype.
				 N bytes
				+---------+
  Datatype of fixed size N	| data    |
				+---------+

				 INT8          INT8            N bytes
				+-------------+---------------+--------+
  Otherwise			| column size | actual size N | data   |
				+-------------+---------------+--------+

Login Acknowledgement (0xAD 173)

 INT16    INT8    4 bytes   INT8       XCHAR[n] 4 bytes
+--------+-------+---------+----------+--------+----------+
| length |  ack  | version | t length |  text  | ser_ver  |
+--------+-------+---------+----------+--------+----------+

length		length of packet
ack		0x01 success	4.2
		0x05 success	5.0
		0x06 failure	5.0
version		TDS version 4 bytes:  major.minor.?.?
t length	length of text
text		server name (ie 'Microsoft SQL Server')
ser_ver		Server version
		(with strange encoding, differring from TDS version)

   


Data - Row Result (0xD1 209)

Data - Compute Result (0xD3 211)

 INT8       variable size
+----------+--------------------+
|  token   |   row data         |
+----------+--------------------+

Row data starts with one byte (decimal 209), for variable length types, a one byte length field precedes the data, for fixed length records just the data appears.
Note: nullable integers and floats are variable length.

For example: sp_who

The first field is spid, a smallint
The second field is status a char(12), in our example "recv sleep "

The row would look like this:

  byte  0 is the token
  bytes 1-2 are a smallint in low-endian
  byte  3 is the length of the char field
  bytes 4-15 is the char field

byte  0   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15
hex  D1  01  00  0C  72  65  63  76  20  73  6C  65  65  70  20  20
    209   1   0  12   r   e   c   v ' '   s   l   e   e   p ' ' ' '

Params - TDS 5.0 (0xD7 215)

TODO.

Capability - TDS 5.0 (0xE2 226)

 INT16    variable
+--------+--------------+
| length | capabilities |
+--------+--------------+

length		Length of capability string
capabilities	Server capabilities?  Related to login magic?

Environment change (0xE3 227)

 INT16    INT8       INT8        CHAR[n]   INT8        CHAR[n] 
+--------+----------+-----------+---------+-----------+---------+
| length | env code | t1 length |  text1  | t2 length |  text2  |
+--------+----------+-----------+---------+-----------+---------+

env code	Code for what part of environment changed
	0x01  database context
	0x02  language
	0x03  character set
	0x04  packet size
	0x05  TDS 7.0+ LCID
	0x06  TDS 7.0+ ??? (sort method? sql server encoding?)
	0x07  Collation info
text1		Old value
text2		New value

text1 and text2 are text information (coded in ucs2 in TDS 7.0+) except 
collation info that's a structure (see collation structure)

DBRPC - TDS 5.0 (0xE6 230)

TODO.

Dynamic - TDS 5.0 (0xE7 231)

TODO.

Param Format - TDS 5.0 (0xEC 236)

 INT16     INT16        variable size
+---------+------------+-------------------+
| length  | number of  | parameter info    |
|         | parameters |                   |
+---------+------------+-------------------+

length            	length of message following this field
number of parameters	number of parameter formats following
list of formats		I (*bdw*) imagine it uses the column format structure.

Authentication - TDS 7.0 (0xED 237)

 INT16     varies
+---------+------+
| length  | auth |
+---------+------+

length   length of authentication data following this field
auth     authentication data
         for NTLM this is message 2

Client reply with Authentication packet.

Result Set - TDS 5.0 (0xEE 238)

 INT16     INT16        variable size
+---------+------------+-----------------+
| length  | number of  | column info     |
|         | columns    |                 |
+---------+------------+-----------------+


Fields:
length             length of message following this field
number of columns  number of columns in the result set, this many column
                   information fields will follow.
column info        column info

Done Packets

Result Set Done (0xFD 253)
Process Done (0xFE 254)
Done Inside Process (0xFF 255)

 INT16       INT16     INT32                  INT64
+-----------+---------+----------------------+---------------------+
| bit flags | unknown | row count (TDS 7.1-) | row count (TDS 7.2) |
+-----------+---------+----------------------+---------------------+

Fields:
bit flags          0x01 more results
		   0x02 error (like invalid sql syntax)
		   0x10 row count is valid
		   0x20 cancelled
unknown            2,0  /* something to do with block size perhaps */
row count          number of rows affected / returned in the result set. 
                   row count is 64-bit using TDS 7.2.
		(FIXME check if "affected / returned" is correct)

"Result Set Complete" is the end of a query that doesn't create a process on the server. I.e., it doesn't call a stored procedure.
"Process Done" is the end of a stored procedure
"Done In Process" means that a query internal to a stored procedure has finished, but the stored procedure isn't done overall.


Acknowledgements

The following people have contributed to this document:

  • Brian Bruns (first draft, protocol discovery)
  • Brian Wheeler (protocol discovery)
  • Mark Schaal (second draft)
  • Frediano Ziglio

(short list)

Document Status

$Id: tds.html,v 1.41 2008-11-25 23:38:33 jklowden Exp $

Valid HTML 4.01 Strict

freetds-1.00.82/doc/userguide.dsl.in100644 025423 025423 00000006467 12522201763 0012715 ]> ;; Instructions can be found in ;; The Modular DocBook Stylesheets ;; by Norman Walsh ;; See Chapter 3, "Customizing the Stylesheets" ;; http://docbook.sourceforge.net/release/dsssl/current/doc/custom.html ;; $Id: userguide.dsl.in,v 1.4 2008-12-20 06:01:31 jklowden Exp $ ;; For note, tip, and warning: include little ;; gifs of a hand pointing a finger, or a yield sign, and so on. ;; Much prettier to look at than text. (define %admon-graphics% #t) ;;(define %admon-graphics-path% "../images/") ;; In generating names of HTML pages, use the ;; section's "id" attribute, if present, to form the name. (define %use-id-as-filename% #t) ;; The filename of the root HTML document (excluding the extension). (define %root-filename% "index") (define %graphic-extensions% ;; graphic extensions allowed '("gif" "png" "jpg" "jpeg" "tif" "tiff" "eps" "epsf" )) (define %graphic-default-extension% "gif") ;; Indent "screen" sections. ;; http://docbook.sourceforge.net/release/dsssl/current/doc/html/indent-screen-lines.html (define %indent-screen-lines% ;; Indent lines in a 'Screen'? #f) ;; If %html40% is true then the output more closely resembles HTML ;; 4.0. In particular, the HTML table module includes COL, THEAD, ;; TBODY, and TFOOT elements, and the output documents have a proper ;; doctype declaration. (define %html40% ;; Generate HTML 4.0 #t) (define %html-pubid% ;; REFENTRY html-pubid ;; PURP What public ID are you declaring your HTML compliant with? ;; DESC ;; The public ID used in output HTML files. If '#f', then no public ID ;; is produced. If both this and %html-sysid% are '#f', then no ;; doctype declaration is produced. ;; /DESC ;; AUTHOR N/A ;; /REFENTRY (if %html40% ;; "-//W3C//DTD HTML 4.01 Transitional//EN" "-//W3C//DTD HTML 4.01//EN" #f)) (define %html-sysid% ;; REFENTRY html-sysid ;; PURP What system ID are you declaring your HTML compliant with? ;; DESC ;; The system ID used in output HTML files. If '#f', then no system ID ;; is produced. If both this and %html-pubid% are '#f', then no ;; doctype declaration is produced. ;; /DESC ;; AUTHOR N/A ;; /REFENTRY (if %html40% ;; "http://www.w3.org/TR/html4/loose.dtd" "http://www.w3.org/TR/html4/strict.dtd" #f)) ;; Insert meta tag with encoding information into each generated HTML file. ;; cf. http://www.dpawson.co.uk/docbook/dsssl/dssslgeneral.html (define %html-header-tags% '(("META" ("HTTP-EQUIV" "Content-Type") ("CONTENT" "text/html; charset=utf-8")))) ;; Should the role attribute of emphasis be propagated to HTML as a ;; class attribute value? Source Code (define %emphasis-propagates-style% ;; Support propagating emphasis role attributes to HTML #t) ;; Generate links to the FreeTDS HTML stylesheet to control the ;; browswer's rendering of certain classes of elements e.g. < userinput >. ;; The stylesheets (version 1.57) wrapped userinput in < b >< /b >, but ;; version 1.79 doesn't. (define %stylesheet% "userguide.css") freetds-1.00.82/doc/userguide.sgml100644 025423 025423 00001145376 12717145107 0012501 %ug.desc; FreeTDS"> DB-Library'> CT-Library'> ODBC'> freetds.conf"> ]> &ug.date; &freetds; User Guide A Guide to Installing, Configuring, and Running &freetds; Brian Bruns James K. Lowden Frediano Ziglio 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 Brian Bruns and James K. Lowden 2015 Frediano Ziglio Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License. About this User Guide This User Guide describes &freetds; &version;. It is the product of (lots of) happy collaborative effort. Although Brian's name and mine are at the top of it, behind it are many others, who contributed thoughtful suggestions, bamboozled questions, stellar prose, and terse instructions. I don't mention this for the usual reasons (the enumeration of which I leave to you) but rather to emphasize that the purpose of our effort is to help you and those who come after you to have the easiest and most enjoyable time with &freetds;. It is surprisingly hard, after a while, to remember how it can be for someone newly approaching a project to use it. What seems as obvious as a fog horn to an old hand may be much more like the fog itself to the newcomer. That can make installing and setting up new software a puzzling or frustrating experience. You may have heard, It's easy if you know how. Indeed it is, and that's our purpose here: to make it easy, by letting you know how. This guide is here for you, and we hope that you will be here for it, that others might benefit from your experience or inexperience. The most recent version The version you're reading is: &ug.date; &ug.id; can be found on the &freetds; web site, where you will also find the most up to date FAQ, as well as links to the anonymous and browseable git repository. If you find something wrong, unclear, badly put, misleading, or incorrigible, I hope you will let us know. Post your musings or rants to the mailing list (see Helping). Patches to doc/userguide.sgml are especially welcome, of course. By taking the time let us know what you think, perhaps the path to enlightenment will be made a little smoother for the fellow behind you. A few technical notes. This guide is written in SGML DocBook format, specifications for which are found in the DocBook book. It was converted to HTML with OpenJade. The SGML text is distributed with the rest of the source code, and may be edited with your favorite or least favorite text editor. Enough. Let's begin. --jkl What is &freetds;? &freetds; is re-implementation of C libraries originally marketed by Sybase and Microsoft SQL Server. It allows many open source applications such as Perl and PHP (or your own C or C++ program) to connect to Sybase or Microsoft SQL Server. &freetds; provides drop-in replacements for Sybase's &dblib; and &ctlib; Microsoft's &dblib; (which differs in small details from Sybase's) the &odbc; drivers from both vendors interactive SQL and BCP utilities The TDS part of the name comes from name of the protocol used to communicate with such servers: the Tabular Data Stream. &freetds; is distributed in source code form, and is expected to compile on just about any operating system. That means every form of Unix® and Unix-like™ system (including notable variants such as Interix® and QNX®), as well as Win32®, VMS®, and OS X®. If it doesn't compile on your system — and you're not using MS-DOS® — it's probably considered a bug. Background: The <acronym>TDS</> Protocol and related <acronym>API</>s TDS is a protocol, a set of rules describing how to transmit data between two computers. Like any protocol, it defines the types of messages that can be sent, and the order in which they may be sent. Protocols describe the bits on the wire, how data flow. In reading this manual, it may be helpful to keep in mind that a protocol is not an API, although the two are related. The server recognizes and speaks a protocol; anything that can send it the correct combination of bytes in the right order can communicate with it. But programmers aren't generally in the business of sending bytes; that's the job of a library. Over the years, there have been a few libraries — each with its own API — that do the work of moving SQL through a TDS pipe. &odbc;, &dblib;, and &ctlib; have very different APIs, but they're all one to the server, because on the wire they speak TDS. The TDS protocol was designed and developed by Sybase Inc. for their Sybase SQL Server relational database engine in 1984. The problem Sybase faced then still exists: There was no commonly accepted application-level protocol to transfer data between a database server and its client. To encourage the use of their product, Sybase came up with &dblib;. &dblib; provided an API to the client program, and communicated with the server. What it sent to the server took the form of a stream of bytes meant for tables of data, a Tabular Data Stream. In 1990 Sybase entered into a technology sharing agreement with Microsoft which resulted in Microsoft marketing its own SQL Server. Microsoft kept the &dblib; API and added &odbc;. (Microsoft has since added other APIs, too. It no longer supports its own &dblib; implementation.) At about the same time, Sybase introduced a more powerful successor to &dblib;, called &ctlib;, and called the pair OpenClient. &ctlib;, &dblib;, and &odbc; are APIs that — however different their programming style may be — all communicate with the server in the same way. The language they use is TDS. The TDS protocol comes in several flavors, most of which were not openly documented. If anything, it was considered to be something like a trade secret, or at least proprietary technology. The exception is TDS 5.0, used exclusively by Sybase, for which documentation is available from Sybase. History of <acronym>TDS</> Versions At first, there was One Version of TDS common to both vendors but, in keeping with the broad history of private ventures, they soon diverged. Each vendor has subsequently brought out different versions, and neither supports the other's flavor. That is to say, each vendor's client libraries use the latest version of TDS offered by that vendor. You can't reliably use Microsoft's libraries to connect to Sybase, or Sybase's libraries to connect to Microsoft. In some cases you'll get a connection, but pretty soon you'll bump into some incompatibility. Versions of the <acronym>TDS</> protocol TDS 4.2 Sybase and Microsoft The version in use at the time of the Sybase/Microsoft split. TDS 5.0 Sybase Introduced for Sybase. Because TDS 5.0 includes negotiated capabilities through which protocol features can be expanded, we are unlikely to see a new TDS version from Sybase. TDS 7.0 Microsoft Introduced for SQL Server 7.0. Includes support for the extended datatypes in SQL Server 7.0 (such as char/varchar fields of more than 255 characters). It also includes support for Unicode. TDS 7.1 Microsoft was 8.0 Earlier &freetds; documentation referred to versions 7, 8 and 9. Microsoft subsequently published a protocol specification document denoting 7.1 and 7.2, and one finds scattered references using that scheme elsewhere, too. For that reason, &freetds; switched to Microsoft's nomenclature. Introduced for SQL Server 2000. Includes support for big integer (64-bit int) and variant datatypes. TDS 7.2 Microsoft was 9.0 Introduced for SQL Server 2005. Includes support for varchar(max), varbinary(max), xml datatypes and MARS. TDS 7.3 Microsoft Introduced for SQL Server 2008. Includes support for extended date/time, table as parameters. TDS 7.4 Microsoft Introduced for SQL Server 2012. Includes support for session recovery. History of &freetds; &freetds; was and is developed by observation and experimentation, which is to say, by trial and error. In early 1997, the only option for connecting to a Sybase server from Linux or other free systems was an aging Sybase-released version of OpenClient. Unfortunately it had a few problems. The original release was a.out-based, although Greg Thain did a great service in converting the library to ELF. Secondly, it included only the newer &ctlib; API. The older &dblib; API was missing. Brian Bruns, a Sybase DBA and originator of the &freetds; project, had some &dblib; programs he wanted to run under Linux, and thus began the &freetds; project. The original work focused on &dblib; and version 5.0 of the protocol, but quickly expanded to include a &ctlib; compatible layer and TDS version 4.2. Later support for &odbc; and TDS 7.0 and 7.1 was added. Craig Spannring wrote a Java JDBC driver which became FreeTDS/JDBC. As the project matured, it gained new participants. Frediano Ziglio greatly expanded the &odbc; driver, and continues to improve both it and the underlying TDS library. Bill Thompson wrote most of the present BCP system and added cursors to our &ctlib;. James K. Lowden joined the project to add documentation, and in 2002 became its maintainer. Such are the rewards for doing a good deed. There have been many other contributions. Please see the AUTHORS in the distribution for a (we hope) complete list. Current Projects, Language Bindings, and Alternatives Current Projects &freetds; consists of some C libraries. The &freetds; libraries support three separate APIs: &dblib;, &ctlib;, and &odbc;. Underlying these three is libtds, which handles the low-level details of the TDS protocol, such as sending, receiving, and datatype conversion. This document and the FreeTDS website are dedicated to these libraries. Status The libraries are portable, mature, and stable. They're expected to compile readily and normally do not crash or corrupt data. Extensive logging aids in diagnosing problems. While they do not include every feature provided by the vendors' libraries, they do faithfully implement a useful — and widely used — subset of their APIs. The &dblib; and &ctlib; APIs have been usable for several years. They have been successfully substituted for Sybase's own libraries in a variety of venues, including Perl and PHP. The ODBC driver should be fully ODBC 3.5 compliant. Basic API coverage information for all libraries may be found in this manual. It is maintained in doc/api_status.txt, included in the source distribution. For Microsoft servers, &freetds; now offers the best &dblib; for any OS on the planet (including Windows!) thanks not only to the hard work of its contributors, but also to Microsoft'sMicrosoft ceased enhancing &dblib; in 2001, advising customers to avoid using &dblib;. For Microsoft's unmaintained product, that's good advice. But if the &dblib; specification meets your needs, &freetds; permits you to keep using it with little loss (and some gain) of functionality. strategy. It is the only Win64 implementation of &dblib;, and the only Win32 implementation to support modern versions of the protocol. (SQL Server 2008 still accepts the TDS 4.2 connections that Microsoft's old library uses, but rejects BCP uploads with a spurious permission-denied message.) In addition to the core &dblib; API, &freetds; includes a full implementation of &dblib;'s bcp functions, as well as freebcp, a replacement for Sybase's bcp utility. How big is it? &freetds; has over 100,000 lines of C code, maintained by a handful of developers. Patches arrive irregularly, varying in size from one-liners to thousand-line monsters. Almost all are applied or used in some way. The mailing list has some 700 or so subscribers at this writing. Safe to say, &freetds;'s success so far lies somewhere between the Beetle and the Edsel. Who uses it? Oh, pretty much everyone. &freetds; users number in the tens of thousands. It's used by large corporations, by the U.S. federal government (e.g. Database Access Library at the National Center for Biotechnology Information) and, judging by the mailing list, by many webservers running Apache and PHP. Sybase recommends &freetds; for their EAServer product. Microsoft recommends &freetds; to their customers who want access to Microsoft SQL Server from non-Win32 clients. So do we. Languages besides C You may be wondering how these libraries fit with Perl, PHP, TCL, Python, or other popular scripting languages. Most of these languages have bindings to Sybase that use either the &dblib; or &ctlib; API, for which &freetds; is intended as a drop-in replacement. For instance, Michael Peppler's DBD::Sybase works very well using &freetds; to access Sybase or Microsoft SQL Servers. PHP has options for sybase (&dblib;) and sybase-ct (&ctlib;) APIs. Alternatives Should &freetds; not suit your needs, some alternatives jTDS If Java is your game, we refer you to the jTDS project on SourceForge. It is a fork of the FreeTDS/JDBC project, by Craig Spannring, and is a free, native 100% Java implementation of a Type 4 JDBC driver. Sybase OpenClient In the time since &freetds; was started, Sybase (as well as most major DBMS vendors) has released its database for the Intel GNU/Linux platform. The good: it is a solid product and supports TDS 4.2 and TDS 5.0. The bad: it doesn't support TDS 7.0 or Linux/*BSD on non-Intel platforms. The ugly: Microsoft broke date handling for big endian Sybase clients. Depending on platform, it may cost something. &odbc; bridge products They use the &odbc; driver on the NT box where your SQL Server runs so you'll never have trouble with new protocols and the like. On the downside, they can be costly and may be inefficient. We know of EasySoft ODBC-ODBC Bridge from EasySoft, Universal Data Access Driver from OpenLink Software, SequeLink from Merant, and &odbc; Router from August Software Corporation. Inline &odbc; driver Based on libtds, this is a native &odbc; driver for i386 *nix. It is free in price, but comes only as a binary at the present time. DBD::Proxy We have no direct experience with this Perl-only option. It has the same caveats as an &odbc; bridge except it's free. Build &freetds; If you build it they will come. The <acronym>GNU</> World &freetds; uses GNU Autoconf, Automake, and libtool Versions used for this release autoconf (GNU Autoconf) 2.69 automake (GNU automake) 1.15 ltmain.sh (GNU libtool) 2.4.2 to increase portability. For many people, the preceding sentence says it all (good or bad). If you're familiar with the GNU system, you can probably just download the tarball and get away with scanning the README impatiently and then following your instincts. Because everyone is a beginner once and no one is an expert at everything, we'll try to explain things in plain English where possible, and to define our terms as we go along. If the following nevertheless reads like gibberish, you might very well want to use something prepackaged (see Alternatives). If it reads like a vaguely intelligible alien script that might yield to intensive research, we've included links to some of the usual suspects at the end of this chapter. If it reads like a bad explanation of something you could explain better, please send us your version! What to build: Packages, Tarballs, and the <productname>git</productname> repository The latest &freetds; package is always available from ftp.freetds.org. Code changes by the developers are immediately available in the git repository. If you've run into a problem, you may want to check out from git to see if it's fixed there. No password is needed to obtain the current git copy of &freetds;; you need only have a git client installed on your machine. Then: $ git clone https://github.com/FreeTDS/freetds.git $ For those behind firewalls or otherwise unable to access git, nightly snapshots of git are rolled up into tarballs for your convenience. They can be downloaded from ftp.freetds.org. In general, the git master branch (the basis of the current nightly snapshot) works better and has more functionality than the release version. Bugs sometimes persist in the release version but are usually fixed in short order (once identified) in git master. As with any project of this sort, if you want to use the git master branch, it's a good idea to join the mailing list. How to build: Configure and make If you've built other GNU projects, building &freetds; is a fairly straightforward process. We have a terse and verbose description. &freetds; is known to build with GNU and BSD make. If you encounter a large number of build errors, and your operating system's make is not GNU make (as is the case on most non-GNU/Linux systems), you may wish to install GNU make from ftp.gnu.org. For Experts $ ./configure --prefix=/usr/local $ make $ su root Password: $ make install Building from git is described in the file INSTALL.GIT. For Everyone Else (&freetds; for Dummies?) The GNU development system can generate code for a wide variety of hardware architectures and operating systems, virtually all of which can run &freetds; in consequence. The work of building and installing the &freetds; libraries begins with the command configure, which generates the Makefile that governs how the code is compiled, linked, and installed. Once you've configured the project, make will manage the rest of the build. ODBC Preparation If you intend to build the &freetds; ODBC driver — and want to use a Driver Manager (DM), as most people do — install the Driver Manager before configuring &freetds;. configure will detect the the DM and use its header (.h) files for ODBC constants and such. If your DM is installed in an unusual directory, you may have to provide the directory name as a parameter to configure. &freetds; doesn't require a DM. You can build the ODBC driver without one, as long as you have the requisite header files: sql.h, sqlext.h and sqltypes.h. These can be taken from either the iODBC or UnixODBC distributions. Put them wherever you like (e.g., /usr/local/include). Because &freetds; won't detect your (missing) DM, it won't automatically build the ODBC driver, so you'll have to tell configure what to do and where to look. Cf. The simplest form of running configure is: $ ./configure and sometimes that's enough. configure accepts command-line arguments, too, and you may need to provide some, depending on your environment. There are a few optional arguments to configure that may be important to you. For a complete list, see configure --help. <command>configure</> options Directories and TDS version install architecture-independent files in PREFIX. When you run make install, libraries will be placed in PREFIX/lib, executables in PREFIX/bin, and so on. The default is /usr/local if this argument is not passed to configure. read-only single-machine data in DIR The default is PREFIX/etc (PREFIX being the value of , above) if this argument is not passed to configure. Specifies the location of the iconv library to use. configure will search for libiconv in the usual places; use if it's unsuccessful (assuming you want to use iconv, of course). Overridden by , below. Version 0.95 removed support for iconv which cannot convert from any encoding to any encoding. This affect potentially systems like Tru64 and HP-UX were iconv mainly convert from/to ucs2. It's recommended to use GNU libiconv in this case. Specifies the default TDS version. (There are a couple of ways to set the TDS version at run-time. This parameter takes effect if no run-time settings are provided.) Acceptable values of VER are 4.2, 4.6, 5.0, 7.0, 7.1, 7.2, 7.3 and 7.4. The default is 5.0 if this argument is not passed to configure. ODBC Driver Managers Specify directory of iODBC or unixODBC support, and use it as the Driver Manager. As of version 0.62, the ODBC Driver Manager is detected by configure, so use this parameter only if yours is installed in a nonstandard path. (Requires iODBC or unixODBC to have already been installed.) If you're building the ODBC driver and not using a Driver Manager, use this option to indicate the location of the .h files. configure will not cause the ODBC driver to be built unless this option is used or a DM is detected/specified. Things you can turn off Do not attempt to detect ODBC, and do not build the ODBC driver. In case you don't care about ODBC. Do not attempt to build applications like tsql. Do not attempt to build server stuff. Do not attempt to build pool stuff. By default, configure will search your system for an iconv library for use with Microsoft servers (because TDS 7.0 employs Unicode). This switch prevents that search. If no iconv library is used, &freetds; relies on its built-in iconv emulation, which is capable of converting ISO-8859-1 to UCS-2, sufficient for many applications. Force &freetds; not to use threadsafe versions of functions such as gethostbyname_r() where available. Rely instead on the older and non-threadsafe ones such as gethostbyname(). configure tests some of these functions. If the tests are successful, &freetds; will use threadsafe functions throughout. Threadsafe operation has been tested on Linux, FreeBSD, and HP-UX. It should work on Solaris, Tru64, and (reportedly) IRIX. Not expected to work on non-unixy systems. It is a good idea to enable threadsafe operation if you configure Apache with multi-threading support. Debug-mode compiles are enabled by default, and will remain so at least until version 1.0. You can speed things up ever so slightly by disabling it. Disable support for wide characaters in ODBC. Disable SSPI support. SSPI is a Micrsoft library that allows you to use your current logged-in account for authentication. With this option enabled (the default), &freetds; supports "trusted logins" for Win32/64, just as Microsoft's own implementations do. Things you can turn on Enable Microsoft behavior in the &dblib; API where it diverges from Sybase's. Use this option if you are replacing Microsoft's libraries with &freetds; This option specifies default behavior. Programs can change the default at compile time by defining MSDBLIB or SYBDBLIB (for Microsoft or Sybase behavior, respectively). Enable close compatibility with Sybase's ABI, at the expense of other features. Currently, this enables the generation of a dbopen() entry point in &dblib;, which may clash with the DBM function with the same name. Absolutely not required for use with other free software. Enable Kerberos support. With Kerberos you can connect to server using your stored Kerberos ticket. Obviously requires Kerberos be configured on the machine. Intended for debugging purposes, enables certain internal consistency checks against problems like memory corruption and buffer exhaustion. Enable some code still in development. Should be used only by a developer or a brave user :) Compile ODBC tests to use wide characters. Test will use wide versions. SSL support Enable SSL using GnuTLS. Use version 1.2.3 or newer. Enable SSL using OpenSSL. Unlike &freetds;, OpenSSL does not use the LGPL. Please read the OpenSSL license before distributing binaries compiled with this option. <command>Make</> Now you're ready to build. Follow these easy steps. Download the tarball and unpack it. Alternatively, get the latest build from git git users will need the GNU autotools: Autoconf, Automake, and libtool. . Change to the freetds directory. run ./configure with any options you need. make; make install; make clean You normally need to be root to make install, unless you used the With any luck, you've built and installed the &freetds; libraries. Two bits of advice, if you like to keep things tidy and keep track of what you did. Create a file to hold your configure options called, say, .build_options. Create a build directory for the binaries, and invoke ../configure $(cat ../.build_options). This approach lets you remove the binaries at any time and rebuild from scratch using the same options. OS-specific Issues If you've recently built and installed &freetds; and noticed steps peculiar to your OS, we'll happily include your comments here. One thing that can be said, if it's not too obvious: check with your vendor or favorite download site. &freetds; is routinely rolled up into OS install packages. We know of packages for Debian, Red Hat, FreeBSD, and NetBSD. The installation through the package management systems in these environments may well reduce your work to simply make install. Win32 and Win64 Officially &freetds; for Windows should be compiled using CMake. CMake is able to create project files for different development systems (like Visual C++). Install CMake on your box and point to the source directory to generate wanted files. Refer to CMake documentation on how to do it (I personally use CMake GUI passing source directory and a newly create build directory). Once project files are created you can open them with your environment. Other ways to build under Windows® MingW Download Windows® binaries You can download FreeTDS binaries for Windows from AppVeyor (the hosted CI platform used). There is a .zip file available as artifact of every sucessful build. The list of builds is at https://ci.appveyor.com/project/FreeTDS/freetds/history. You can find there builds of code in the master banch and (from time to time) builds from the post-1.0 release fixes-only Branch-1_00 branch. Every build matrix element generates its artifact. Ramiro Morales also maintains similar builds of the Branch-0_95 branch at https://github.com/ramiro/freetds/releases. ODBC driver registration If compiled correctly &freetds; ODBC driver supports component registration. Although an ODBC driver is not a Windows component you can register the driver with regsvr32 utility or you can use this feature with some installer and register the driver as a standard component. Once the ODBC driver is registered in the system you can configure it from Control Panel. VMS® &freetds; will probably build and run on most versions of OpenVMS Alpha 7.0 and later with DEC/Compaq C 6.0 or later. Other prerequisites: gunzip vmstar MMS or MMK Build Instructions Decompress and unpack the source archive using gunzip and vmstar. If you are untarring on an ODS-5 disk, you should use the /ODS2 or -o option to create universally VMS-friendly filenames; otherwise the build will fail to locate some files. Set default to the top-level source directory and run the configuration script: $ @[.vms]configure This creates a descrip.mms in the top-level source directory which you may execute by simply running MMS (if you have the Module Management System that is part of DECset) or MMK (a freeware MMS alternative available from www.madgoat.com). Further information can be found in the vms/README.vms in the source distribution. OS X® The regular distribution compiles on OS X. Possible linker problems On 18 April 2016, a problem was reported causing linker issues. Undefined symbols for architecture x86_64: "___strlcpy_chk", referenced from: _tdsdbopen in libsybdb_64.a(dblib.o) _db_env_chg in libsybdb_64.a(dblib.o) _dbcolinfo in libsybdb_64.a(dblib.o) _dbtablecolinfo in libsybdb_64.a(dblib.o) _tds_alloc_dynamic in libsybdb_64.a(mem.o) _tds7_get_instance_port in libsybdb_64.a(net.o) _tds_get_locale in libsybdb_64.a(locale.o) ... This is due to some mismatch on different project releases. To solve these issue set the target release like CFLAGS="-mmacosx-version-min=10.8" ./configure make or export MACOSX_DEPLOYMENT_TARGET=10.8 ./configure make AIX® AIX® can induce linker indigestion. libtool doesn't always understand that a .a file can be a shared library. One solution is to build only static libraries with the Another problem seems to be that the linker isn't asked to pull in all the requisite libraries. Cf. this helpful mailing list message. GNU/Linux distributions that use RPMs You may find it convenient to make an RPM from the source distribution, in which case you'll be glad to know it is easily done: $ rpmbuild -ta freetds-0.95.tar.bz2 Install &freetds; If you install it they will stay? Confusing terminology Configuring and installing don't have absolute, context-free definitions. In some circles, we install a product and then configure it. In the GNU world, we configure the package (generate the Makefiles), then we make install the package. In the case of a library package such as &freetds; To install the package is to copy the files the application developer will use to their canonical locations: header files to include, libraries to the lib, documentation and man pages share. Install targets were specified during the build process as arguments to configure, covered in the last chapter. For lack of a better term, this chapter describes installing the product. Put more specifically, once we're done with the package manager, we still have to tell &freetds; about your database servers, and we still have to tell your client programs about &freetds;. The local environment After &freetds; has been built and installed, it still doesn't know where your servers are or what particular version of Sybase or Microsoft software each one is using. The purpose of this section is to explain how to describe your servernames to &freetds;. &freetds; looks up your server's attributes in &freetdsconf;. Some of the attributes can be overridden by environment variables. One of the more important (and arcane) settings is the TDS protocol version, described next. Choosing a <acronym>TDS</> protocol version The TDS protocol version is probably something you'd rather not know even existed, much less something you'd have to choose. But there's not that much to it, really. Unless you run into an incompatibility, you're best off running with the highest protocol version supported by your server. That's what the vendors' own products do, which is why when you read the Sybase or Microsoft documentation you find no mention of TDS versions. Versions of the <acronym>TDS</> Protocol, by Product Product TDS Version Comment Sybase before System 10, Microsoft SQL Server 6.x 4.2 Still works with all products, subject to its limitations. Sybase System 10 and above 5.0 Still the most current protocol used by Sybase. Sybase System SQL Anywhere 5.0 only Originally Watcom SQL Server, a completely separate codebase. Our best information is that SQL Anywhere first supported TDS in version 5.5.03 using the OpenServer Gateway (OSG), and native TDS 5.0 support arrived with version 6.0. Microsoft SQL Server 7.0 7.0 Includes support for the extended datatypes in SQL Server 7.0 (such as char/varchar fields of more than 255 characters), and support for Unicode. Microsoft SQL Server 2000 7.1 Include support for bigint (64 bit integers), variant and collation on all fields. Collation is not widely used. Microsoft SQL Server 2005 7.2 Includes support for varchar(max), varbinary(max), xml datatypes and MARSMultiple Active Result Sets.. Microsoft SQL Server 2008 7.3 Includes support for time, date, datetime2, datetimeoffset. Microsoft SQL Server 2012 or 2014 7.4 Includes support for session recovery. N/A 8.0 &freetds; will alias this version to 7.1 for backwards compatibility reasons, but this should be avoided due to future compatibility concerns. See note below on obsolete versions.
For best results, use the highest version of the protocol supported by your server. If you encounter problems, try a lower version. If that works, though, please report it to the mailing list! Want to help? Try out the auto-protocol feature. &freetds; has experimental support for iteratively trying protocol connections until it finds one the server accepts. This is suitable when query responses are non-trivial (because the tiny delay in connecting is thus insignificant). Try setting your TDS version to 0 and report your results. TDS 4.2 has limitations ASCII only, of course. RPC is not supported. BCP is not supported. varchar fields are limited to 255 characters. If your table defines longer fields, they'll be truncated. dynamic queries (also called prepared statements) are not supported. The protocol version may also affect how database servers interpret commands. For example, Microsoft SQL Server 2000 is known to behave differently with versions 4.2 and 7.0. Version 7.0 is recommended for compatibility with SQL Server tools. Regarding obsolete versions In the earlier days of &freetds;, Microsoft did not release official specs for the TDS protocol. When MSSQL 2000 (product 8.0) was released, there was semi-official indications from the Microsoft community that the TDS protocol would be version 8.0. So the &freetds; developers adopted that version for &freetds;. Years later, when Microsoft started releasing official specs of the protocol, it became obvious that the TDS versions that &freetds; had labeled 8.0 and 9.0 were actually versions 7.1 and 7.2 respectively. For compatibility reasons version 8.0 is still handled by &freetds; but you should avoid using it as it could be removed in a future version of &freetds; or it could clash with a future SQL server version.
<replaceable>servername</> Lookup &freetds; converts the servername to an IP address by following the steps below, stopping when it succeeds. Name lookup sequence <footnote><para>This description applies to &dblib; and &ctlib;. ODBC lookup is different.</para></footnote> Find servername in &freetdsconf;. If a section with that name exists, use the hostname, port, and TDS version specified therein. Attempt to convert servername to an IP address with inet_addr(3). Request name-lookup from the operating system via gethostbyname(3) or similar. If the TDS version and port are not read from &freetdsconf;, they are derived from the compiled-in defaults and overridden by applicable environment variables. As you can see, if most of your servers use the same TDS version and answer to the default port, then you don't need to list them all in &freetdsconf;. You can simply compile in the right defaults — or set the TDSPORT and TDSVER environment variables — and rely on DNS for name resolution. The &freetdsconf; file What it does Just as DNS defines hostnames for network addresses, &freetdsconf; uses a servername to define the properties of your server. In general, the servername is arbitrary and local; it's used only by your client programs to tell &freetds; which server to connect to. You can choose any name you like. Sybase SQL Anywhere (a/k/a Sybase ASA), however, is fussy. Unless you use the ASA Database property, you must use the database's name as your servername. Otherwise, the server will refuse your connection. In particular, &freetds; needs to know: Primary Server Properties Hostname or IP address of the server Port number or Instance name (not both) TDS protocol version &freetds; also supports an older configuration file format, known as the interfaces file. Use &freetdsconf; unless interfaces is needed for your situation. It is easier to read, and it is where all the new options are being added. &freetds; looks for &freetdsconf; first, falling back on interfaces only if &freetdsconf; is not found. Should you need it, more information about interfaces can be found in the Appendix. Where it goes The default location of &freetdsconf; is determined by the --sysconfdir option of configure. If you don't specify anything, configure's default sysconfdir is /usr/local/etc. tsql -C reports the sysconfdir to let you confirm it. In addition, &freetds; will look for a file .freetds.conf in the user's home directory (${HOME}/.freetds.conf). The actual name and location of &freetdsconf; may be specified by the environment variable FREETDS (or FREETDSCONF, same effect). See Environment Variables, below. &freetds; reads the user's ${HOME}/.freetds.conf before resorting to the system-wide sysconfdir/&freetdsconf;. The file used is the first one that is readable and contains a section for the server. What it looks like The following information is also provided in the &freetdsconf; manual page, cf. man freetds.conf. The &freetdsconf; file format is similar to that of Samba's modified win.ini. It is composed of two types of sections: one [global] section, and a [servername] section for each servername. Settings in the [global] section affect all servernames, but can be overridden in a [servername] section. For example A &freetdsconf; file example [global] tds version = 4.2 [myserver] host = ntbox.mydomain.com port = 1433 [myserver2] host = unixbox.mydomain.com port = 4000 tds version = 5.0 [myserver3] host = instancebox.mydomain.com instance = foo tds version = 7.1 In this example, the default TDS version for all servernames is set to 4.2. It is then overridden for myserver2 (a Sybase server) which uses 5.0, and myserver3 (a MSSQL 2000 server) which uses 7.1. Usually, it is sufficient to state just the server's hostname and TDS protocol version. Everything else can be inferred, unless your setup (or your server's) strays from the defaults. Some people seem to feel safer using the IP address for the server, rather than its name. We don't recommend you do that. Use the name, and benefit from the inherent advantages. That's why DNS was invented in the first place, you know. It bears mentioning here that prior versions of &freetds; were quite fussy about domain logins, forcing users to make explicit per-server entries in &freetdsconf;. That is no longer the case. If the username has the form DOMAIN\username, &freetds; will automatically use a domain login. &freetdsconf; settings Name Possible Values Default Meaning tds version 4.2, 5.0, 7.0, 7.1, 7.2, 7.3, 7.4, auto --with-tdsver value (5.0 if unspecified) Overridden by TDSVER. The TDS protocol version to use when connecting. auto tells &freetds; to use an autodetection (trial-and-error) algorithm to choose the protocol version. host host name or IP address none The host that the servername is running on. port any valid port Product Version Default Port Sybase SQL Server prior to System 10 1433 Sybase SQL Server 10 and up 5000 Sybase SQL Anywhere 7 2638 Microsoft SQL Server all 1433 The port number that the servername is listening to. Please note: The "defaults" to the left are the server's default settings. &freetds; chooses its default port based on the TDS protocol version: 5000 for TDS 5.0, and 1433 for everything else. Mutually exclusive with instance, below. Overridden by TDSPORT. instance instance name none Name of Microsoft SQL Server instance to connect to. The port will be detected automatically. Mutually exclusive with port, above. Requires UDP connection to port 1434 on the server. ASA database valid database name servername [section] name Specifies the name of the default database when connecting to an ASA server. A TDS 5.0 login packet has a field called lservname. For most TDS servers, lservname is a user-defined string with no inherent meaning. ASA servers, however, requires that lservname contain a valid database name, and sets that as the default database for the connection. &freetds; normally fills lservname with the [section] text.. This entry instead sets the database name independently of the [section] name. database valid database name none Specifies the name of the default database. This is the name of the database container in the server you are connecting to. initial block size multiple of 512 512 Specifies the maximum size of a protocol block. Don't mess with unless you know what you are doing. dump file any valid file name none Overridden by TDSDUMP. Specifies the location of a tds dump file and turns on logging dump file append yes/no no Appends dump file instead of overwriting it. Useful for debugging when many processes are active. timeout 0- none Sets period to wait for response of query before timing out. connect timeout 0- none Sets period to wait for response from connect before timing out. emulate little endian yes/no no Forces big endian machines (Sparc, PPC, PARISC) to act as little endian to communicate with MS Servers. Set automatically for TDS 7.0 or above on big endian hosts client charset any valid iconv character set ISO-8859-1Valid for ISO 8859-1 character set. See Localization and TDS 7.0 for more information. Makes &freetds; use iconv to convert to and from the specified character set from UCS-2 in TDS 7.0 or above. &freetds; uses iconv to convert all character data, so there's no need to match the server's charset to insert any characters the server supports. text size 0 to 4,294,967,295 4,294,967,295 default value of TEXTSIZE, in bytes. For text and image datatypes, sets the maximum width of any returned column. Cf. set TEXTSIZE in the T-SQL documentation for your server. debug flags Any number even in hex or octal notation 0x4fff Sets granularity of logging. A bitmask. See table below for specification. encryption off/request/require off Specify if encryption is desired. Supported for Microsoft servers. off disables encryption (only if needed); request means use if available; require means create and allow encrypted connections only. enable gssapi delegation on/off off Enable delegation flag using Kerberos. realm any default Kerberos realm Specify Kerberos realm. SPN any MSSQLSvc/fqdn:port Specify Kerberos SPN. use ntlmv2 yes/no no Use NTLMv2. An alternative to the UseNTLMv2 option in odbc.ini. use lanman yes/no no Use LAN MANAGER for NTLM. This is a very old encryption. Should not be enabled unless you have a really old server. use utf-16 yes/no no Instead of using UCS-2 for database wide character encoding use UTF-16. Newer Windows versions use this encoding instead of UCS-2. This could result in some issues if clients assume that a character is always 2 bytes. ca file any filename or system none File that hold root certificates (in PEM format) to verify server certificate, used during an encrypted connection. If not specify or empty any certificate will be accepted from server. If you specify system &freetds; will use system wide certificate list. If a certiticate is not installed server can generate a self signed certificate, in this case is useful to disable certificate validation (which is the default). Note that is not possible to specify a directory as usually database servers does not use a certificate signed by a public global certification authority. crl file any filename none File that hold certificate revocation list. Only used if ca file is also specified. check certificate hostname yes/no yes Check is the hostname is valid in the certificate. Only used if ca file is also specified. read-only intent yes/no no Tell server we only intent to do read-only queries. This is supported from MSSQL 2012.
Overrides</> <para>Many settings in &freetdsconf; can be overridden by <link linkend="envvar">environment variables</link>.</para> <para>The servername can also be decorated adding the port or instance name using <link linkend="PortOverride">port override syntax</link>.</para> </sect3> <sect3> <title>Controlling log details</> <abstract><para>The logging capability has helped solve innumerable cases, some trivial and some very low-level bugs. Sometimes a developer needs very detailed information about one function, whereas someone else may interested only in whether or not a particular function is called, or even want to see only the SQL that was transmitted to the server.</para> </abstract> <para>The log's granularity can be controlled with the <literal>debug flags</> entry. The default value (<literal>4FFF</> hex) gives a level of detail that is useful for resolving problems via the mailing list.</para> <table id="tab.freetds.conf.debugflags"> <title>Valid bitmask values for <literal>debug flags</> entry in &freetdsconf; Value Meaning 0x80 function trace and info 0x40 information level 2 0x20 information level 1 0x10 network 0x08 warning 0x04 error 0x02 severe error 0x1000 show pid 0x2000 show time 0x4000 show source level info (source file and line) 0x8000 thread id (not implemented) For more about the wonderful world of &freetds; logs, see Logging. Deprecated options</> <para>The following options have long been deprecated.</para> <itemizedlist id="lst.freetds.conf.deprecated" spacing="compact"> <title>Deprecated &freetdsconf; settings try server login try domain login nt domain cross domain login debug level
The <filename>locales.conf</filename> file What it does For an English-speaking American, not much. &freetds; originated in the United States, and uses U.S. conventions if no locales.conf is present. The locales.conf provided with the installation also reflects these conventions. locales.conf will probably be dropped from &freetds; one day. Its only real purpose now is to control the format of date strings. The Right Way™ to deduce the appropriate default date format is from the application's locale settings, while allowing an override in &freetdsconf;. That's the direction we're headed. If your purpose is to affect the client charset description, use &freetdsconf; instead. Information on locales and locale strings is easily (even too easily!) found on the Internet, or see man locale for your system. &freetds; will examine its environment for a LOCALE string. If it finds one, it will look it up in locales.conf to find your preferred settings. If it fails to find one, it will use its defaults. Where it goes Like &freetdsconf;, the location of locales.conf is determined by the value of What it looks like The format of locales.conf is similar to that of &freetdsconf;. There is a [default] section, and a section for each locale. locales.conf controls three settings date format This entry will be passed (almost) literally to strftime(3) to convert dates to strings. For the most part, see you system documentation for strftime(3) (man 3 strftime). You will see there though that strftime(3) has no provision for milliseconds. The locales.conf format string uses %z for milliseconds. If your system's strftime(3) does employ %z for its own use, it will not be given that chance by &freetds;. &freetds; will consume the %z for its milliseconds needs, and will not pass it on to strftime(3). language The language that will be used for error/status messages from the server. A SQL Server client can specify a language for such messages at login time. &freetds; issues a few messages of its own. Messages from the server are called messages; those from the client library (i.e., from &freetds;) are called error messages. &freetds;-issued messages are not affected by locales.conf. charset Indicates to the server what character set should be used for communicating with the client. Environment variables What they're for You can use environment variables to Override some of the settings in &freetds;'s configuration file. Advertise the location of the &freetds; libraries to programs that want them. Control how logging is done. This section covers the first two items. For information about environment variables that control logging, see Logging In a typical system, no environment variables need be used. They're sometimes handy for testing, for instance setting TDSVER to check if a connection problem is due to using the wrong protocol version. And they have other uses, described below. But they're just knobs, so don't feel you have to turn every one, unless you're the sort that likes turning knobs. Environment Variables FREETDS may be used to specify the name and location of the &freetdsconf; file. In prior versions of &freetds; this variable was known as FREETDSCONF. TDSVER governs the version of the TDS protocol used to connect to your server. For a given server, &freetds; inspects four sources in the following order to determine which TDS protocol version to use, using the first one it finds. The value specified in TDSVER A &freetdsconf; file entry (see below) The interfaces file entry (see below) The TDSPORT specifies a TCP port number at which the servername is listening. It overrides the default port (1433 for TDS 4.2/7.0/7.1/7.2/7.3/7.4, 4000 for TDS 5.0) as well as any port specified in the &freetdsconf; file. SYBASE points to the &freetds; run-time directory. Use of this variable originated with Sybase (the company), and many programs still rely on SYBASE to discover the location of the SYBASE libraries. The primary use of SYBASE is to advertise the location of the &freetds; libraries. A secondary use is to point to the location of the interfaces file (if used, see the Appendix), which some programs examine directly. TDSQUERY DSQUERY provides a server name to connect to if none is specified by the application. DSQUERY is the historical Sybase name for this variable. TDSHOST overrides the host specified in the &freetdsconf;. Setting environment variables Of course, each shell is a little different. In the Bourne shell and variants such as ksh and bash, to set SYBASE and TDSVER do: $ export SYBASE=/usr/local/freetds # (or your favorite directory) $ export TDSVER=4.2 In csh: $ setenv SYBASE /usr/local/freetds $ setenv TDSVER 4.2 Checking your work When you're done, you should see something very like this: $ ls $SYBASE etc include interfaces lib Port/instance override syntax The port to which to connect can be overridden using a &freetds; extended syntax. A port may be appended to the servername in the form servername:port. &freetds; will attempt to connect to specified port. Please note port must be a number; a service name is not supported. If you specify servername\instance as servername during login, &freetds; will attempt to connect to specified instance. Only Microsoft SQL Server instances are supported. (This server feature was introduced with SQL Server 2000.) Note that other &freetdsconf; properties still apply. For the technically curious: each SQL Server instance appears on the network as a server listening at a port. The old way — and it still works — is to designate each instance in &freetdsconf; as a separate server. The new named instance notation, if we can call it that, instead uses the server to discover the port. The library sends a UDP packet containing the instance name to the server at a well known port, port 1434. The server responds with a port number. &freetds; then uses that number to connect in the usual way. Confirm the installation We want to make sure that when your application requests a connection to your server, it actually works. In detail, we want to know: &freetds; can find and read &freetdsconf; servername exists in &freetdsconf; a host property exists for servername host can be resolved to a network address the server is listening to the port or named instance the user can log in to the server Each of the above can be confirmed independently with tsql. Once you're sure you can connect and log in, you can run the unit tests to see if the software works as promised. <application>tsql</application> The tsql utility is provided as part of &freetds; expressly for troubleshooting. tsql is superficially similar to an isql, but uses libtds directly, bypassing the client libraries (e.g., &dblib;). It can also report where it looks for &freetdsconf; and other compile-time settings (with tsql -C). Show compile-time settings with <command>tsql</> $ tsql -C Password: Compile-time settings (established with the "configure" script) Version: freetds v0.&version; freetds.conf directory: /usr/local/etc MS db-lib source compatibility: no Sybase binary compatibility: no Thread safety: yes iconv library: no TDS version: 7.0 iODBC: no unixodbc: no SSPI "trusted" logins: no Keberos: no For details on the use of tsql, consult its man page. <replaceable>servername</> Lookup If all goes well, the first time you fire up tsql it connects and you can issue your first query. More often, though, the result is less joyous. Listed below for your troubleshooting pleasure are a variety of servername lookup failures and their corresponding messages. When servername cannot be converted to an address, up to two messages may result. Successful conversion (by any means) never produces an error message. Failure to find <replaceable>servername</> in &freetdsconf; $ tsql -S nobox -U sa Password: locale is "C" locale charset is "646" Password: Error 20012 (severity 2): Server name not found in configuration files. Error 20013 (severity 2): Unknown host machine name. There was a problem connecting to the server $ host nobox Host not found. In the above case message 20012 indicates nobox was not found in &freetdsconf;. The library then treated nobox as a network hostname but found it also not to be valid per DNS, leading to message 20013. If servername is found in the configuration files, but refers to an invalid hostname, only message 20013 is returned. Failure to resolve hostname for <replaceable>servername</> $ tsql -S nonesuch -U sa Password: locale is "C" locale charset is "646" Error 20013 (severity 2): Unknown host machine name. There was a problem connecting to the server Unfortunately, the host machine name (the right side of the host line in &freetdsconf;) isn't mentioned in the error message. Fortunately, this kind of setup problem is rarely encountered by users. Connecting to the Server If name lookup succeeds, &freetds; next attempts to connect to the server. To connect means to form at TCP connection by calling connect(2). A valid connection must exist before any information can be exchanged with the server. Specifically, we need a connection before we can log in. A few things can go wrong at this point. The address returned by DNS may not be that of the machine hosting the server, or indeed of any machine! The machine may be down. The server may not be running. The server may be running but not listening to the port &freetds; is attempting to connect to. In rare cases, both ends are correctly configured, but a firewall stands in the way. If no server accepts the connection, no connection can be established. It's difficult to know why, and the message is consequently vague. Failing to connect with tsql $ tsql -S emforester -U sa #only connect? Password: Msg 20009, Level 9, State -1, Server OpenClient, Line -1 Unable to connect: Adaptive Server is unavailable or does not exist There was a problem connecting to the server If you get message 20009, remember you haven't connected to the machine. It's a configuration or network issue, not a protocol failure. Verify the server is up, has the name and IP address &freetds; is using, and is listening to the configured port. Named instances provide another way for connections to fail. You can verify the instance name and the port the server is using with tsql -L. Getting instance information with tsql $ tsql -LH servername locale is "C" locale charset is "646" ServerName TITAN InstanceName MSSQLSERVER IsClustered No Version 8.00.194 tcp 1433 np \\TITAN\pipe\sql\query servername could be configured to use instance MSSQLSERVER or port 1433. After a valid connection is formed, &freetds; sends a login packet. The TDS protocol provides no way to interrogate the server for its TDS version. If you specify the wrong one, you'll get an error. Using the wrong protocol for the server $ tsql -S servername Password: Msg 20017, Level 9, State -1, Server OpenClient, Line -1 Unexpected EOF from the server Msg 20002, Level 9, State -1, Server OpenClient, Line -1 Adaptive Server connection failed There was a problem connecting to the server Unexpected EOF from the server seems to be a fairly common message when the wrong TDS version is used. Note that there's no complaint about the login. If the right TDS version is used, the server will accept the login packet and examine its contents to authenticate the user. If there's a problem, the server will say so. This is the first time we're receiving a message from the server. If you'd like to help the project and want to so something fairly easy but still useful, modify tsql to distinguish clearly between errors returned by the library, and those returned by the server. Errors should be marked error and don't return state or a line number, but can contain an error code (and message) from the operating system. Login failure $ tsql -S servername -U notme Password: Msg 18456, Level 14, State 1, Server [servername], Line 0 Login failed for user 'notme'. Msg 20002, Level 9, State -1, Server OpenClient, Line -1 Adaptive Server connection failed There was a problem connecting to the server Bypassing &freetdsconf;: tsql -H hostname -p port -U username -Ppassword -C Keep in mind that the TDS protocol version normally comes from &freetdsconf;. When using tsql this way, the library uses the compiled-in default (set by the configure script). If that's not what you want, override it using the TDSVER environment variable. Connect with <command>tsql</> using a hostname and port number $ TDSVER=7.0 tsql -H hillary -p 4100 -U sa Password: 1> For details on tsql, see the its man page. <application>Unit Tests</application> The source code directory of each &freetds; library includes a unittests directory. $ ls -d -1 src/*/unittests src/ctlib/unittests src/dblib/unittests src/odbc/unittests src/replacements/unittests src/tds/unittests The unit tests rely on the PWD file in root of the &freetds; source tree. PWD holds a username, password, servername, and database to be used for the unit tests. We try to make sure to leave nothing behind: any data and objects created are either temporary or removed at the end of the test. The tests should all work, subject to disclaimers in the directory's README. To invoke the tests, edit the PWD file and issue the command make check. In order to execute all tests successfully, you must indicate a working, available servername in PWD. Some tests require permission to create stored procedures on server. To complete successfully, the ODBC tests require some additional setup. In your PWD file, add a SRV entry specifying the DSN entry for your odbc.ini. The ODBC tests all build their own odbc.ini and try to redirect the Driver Manager to it, however this functionality is very DM dependent and may well fail unless you have either iODBC or unixODBC. The PWD provided by &freetds; includes usernames and passwords that probably don't exist on your server.
Preparing ODBC Background and Terminology To connect to a database server, a library such as &freetds; needs some information about the connection. By server, which IP address and port is do you mean? Which user is requesting the connection, and what authentication does he offer? Every database library needs a way to capture and convey that information. ODBC was conceived as a general interface definition, not tied to any particular database or access library. For that reason, ODBC also needs to know which driver to use with a given server. The original ODBC solution to this conundrum employed the odbc.ini file. odbc.ini stored information about a server, known generically as a Data Source Name (DSN). ODBC applications connected to the server by calling the function SQLConnect(DSN, UID, PWD), where DSN is the Data Source Name entry in odbc.ini, UID is the username, and PWD the password. Any and all information about the DSN was kept in odbc.ini. And all was right with the world. The ODBC 3.0 specification introduced a new function: SQLDriverConnect. The connection attributes are provided as a single argument, a string of concatenated name-value pairs. SQLDriverConnect subsumed the functionality of SQLConnect, in that the name-value pair string allowed the caller to pass — in addition the the original DSN, UID, and PWD — any other parameters the driver could accept. Moreover, the application can specify which driver to use. In effect, it became possible to specify the entire set of DSN properties as parameters to SQLDriverConnect, obviating the need for odbc.ini. This led to the use of the so-called DSN-less configuration, a setup with no odbc.ini. But &freetds; did not start out as an ODBC driver (remember &dblib; and &ctlib;), and has always had its own way to store server properties: &freetdsconf;. When Brian added the &freetds; ODBC driver, he began by supporting the old SQLConnect, using odbc.ini to describe the DSN. That choice complied with the expectations of the Driver Managers, and minimized the amount of duplicated information in the configuration files. But it can be a little confusing, too, because odbc.ini in effect points to &freetdsconf;. We call this configuration ODBC-combined, because it supports all three &freetds; libraries. As progress on the the &freetds; ODBC library progressed, the driver was made able to read the connection attributes directly from odbc.ini, rather than leaning on &freetdsconf;. For installations that don't need &dblib; and &ctlib;, this ODBC-only setup is simpler. More recently, SQLDriverConnect was added to &freetds;. As described above, this function allows the application to specify connection attributes with reference to either, or neither, configuration file. It's your choice. In making that choice, keep the following terms clear in your mind: Important &freetds; ODBC terms SERVERNAME specifies the [servername] entry in &freetdsconf;. SERVER specifies the real server i.e., the TCP/IP name of the machine hosting the database server. DSN Driver In your connection string, you can decide to use a DSN entry in odbc.ini using the DSN attribute, or to specify the driver you want with the Driver attribute. In sum, &freetds; supports three ODBC choices: ODBC configuration choices DSN-less No connection information is specified in odbc.ini. Advantageous if you're using more of &freetds; than just the ODBC driver. ODBC-only All connection information is specified in odbc.ini, without the need for &freetdsconf;. This is the traditional ODBC setup. ODBC-combined Connection information maintained in &freetdsconf;. odbc.ini contains DSN entries that refer to servernames in &freetdsconf;. Library or Driver? What's a library and what's a driver? Technically, they're the same thing: bodies of subroutines whose names are exported to a linker (static or runtime). By convention, a library is used directly by an application, whose programmer will require documentation and header files. A driver, by contrast, is defined by a binary API and is used in some kind of framework, hence printer driver and video driver. An ODBC driver is a hybrid. For the most part, an application relies on a driver manager to define manifest constants, and links to the DM's library. But because the ODBC specification leaves behavior up to the driver, the application is forced to include the driver's header files, too, to exploit driver-specific functions. Connection attributes The following tables define all possible ODBC connection attributes for the &freetds; ODBC driver. Which ones you'll need depends on how you set yourself up. They may appear in your connection string, or in odbc.ini. Connection attributes used only in connection strings Name Possible Values Default Meaning DSN A valid DSN entry none The DSN to which &freetds; should connect. &freetds; will search odbc.ini for entry. It lets you specify a connection as for SQLConnect, but using SQLDriverConnect. Do not use Servername and DSN together. UID Any valid username none The username to be used when connecting. To use domain authentication, specify the domain using the format domain\username. PWD Any empty The password to be used when connecting. WSID Any Computer name The name of the local computer, sent to server. Can be specified only for a DSN-less connection.
Connection attributes that may appear in <filename>odbc.ini</> Name Possible Values Default Meaning Servername A valid &freetdsconf; server section none A &freetdsconf; servername, not a hostname as known to DNS. If you want to use ODBC-only configuration, use Server instead. Server A server name or (ip) address none Hostname of a server. Used in an ODBC-only configuration. To specify a Microsoft SQL Server instance, use the form server\instance. Port Any TCP port Depends on the TDS version specified with configure The TCP port where the servername is listening. TDS_Version Any valid protocol version Depends on the TDS version specified with configure TDS protocol version to use (e.g., 5.0, 7.0). ClientCharset A name recognized by the iconv library linked to &freetds;. Corresponds to client charset in &freetdsconf;. ISO 8859-1 Character set (encoding) used by the client. APP Free form text, up to 30 characters. none Application name. Identifies the connecting application to the server. Language Any us_english (Human) language the server should use for error messages. Address Any none IP address of the servername. Useful if you want to specify a server by address, rather than by name. The format is ip,port or simply ip in standard dotted-decimal notation. Database Any none Specify which database you want to access. If the database does not exist or the user lacks permission to access it, the connection will fail. TextSize Any Server-dependent Maximum size returned from server for blobs. PacketSize Any Server-dependent Size of packets to server. Some users saw some performance gain by increasing this value. Normally you shouldn't set it. Trusted_Connection Yes/No No Use your current account instead of UID/PWD attributes. This option require SSPI or Kerberos and supersedes any UID/PWD attributes passed from the application. Encryption off/request/require off Specify encryption. See encryption on freetds.conf MARS_Connection Yes/No No Enable MARS for this connection. UseNTLMv2 Yes/No No Use NTLMv2 instead of normal NTLM. Use this option if your Windows domain have this setting. REALM Machine domain none Kerberos REALM. ServerSPN Any valid SPN MSSQLSvc/server FQDN:port Full server Kerberos SPN. AttachDbFilename server filename (mdf/sdf) none MSSQL allow to attach a database while connecting to a server. This setting allow to do it. You should specify Database attribute to set the name of the database that will be used. DumpFile Any File name where to dump logs. DumpFileAppend Yes/No No DumpFlags Any Debug flags. See freetds.conf entries. ApplicationIntent ReadWrite/ReadOnly ReadWrite Tell application intent. See read-only intent on freetds.conf.
DSN-less configuration In a DSN-less configuration, the odbc.ini file is not consulted for server connection properties. To connect to a servername, your application may refer to a servername entry in &freetdsconf;, or explicitly specify the servername's hostname (bypassing &freetdsconf;). Sample files for a DSN-less configuration The odbcinst.ini is quite brief: ; ; odbcinst.ini ; [FreeTDS] Driver = /usr/local/freetds/lib/libtdsodbc.so The &freetdsconf; might look something like: ; ; freetds.conf ; [JDBC] host = jdbc.sybase.com port = 4444 tds version = 5.0 Connecting with a DSN-less configuration /* * application call */ const char servername[] = "JDBC"; refers to the [JDBC] entry in &freetdsconf;. sprintf(tmp, "DRIVER=FreeTDSrefers to the [FreeTDS] entry in odbcinst.ini.;SERVERNAME=%s;UID=%s;PWD=%s;DATABASE=%s;", servername, username, password, dbname); res = SQLDriverConnect(Connection, NULL, (SQLCHAR *) tmp, SQL_NTS, (SQLCHAR *) tmp, sizeof(tmp), &len, SQL_DRIVER_NOPROMPT); if (!SQL_SUCCEEDED(res)) { printf("Unable to open data source (ret=%d)\n", res); exit(1); } You can even establish a connection without reference to either odbc.ini or freetd.conf. Connecting with a DSN-less configuration that does not use &freetdsconf; /* * application call */ const char servername[] = "jdbc.sybase.com"; refers to the real server name. sprintf(tmp, "DRIVER=FreeTDS;SERVER=%s;UID=%s;PWD=%s;DATABASE=%s;TDS_Version=5.0;Port=4444;", servername, username, password, dbname); res = SQLDriverConnect(Connection, NULL, (SQLCHAR *) tmp, SQL_NTS, (SQLCHAR *) tmp, sizeof(tmp), &len, SQL_DRIVER_NOPROMPT); if (!SQL_SUCCEEDED(res)) { printf("Unable to open data source (ret=%d)\n", res); exit(1); } ODBC-only configuration An ODBC-only configuration relies solely on odbc.ini for server properties. Other &freetds; libraries don't know about odbc.ini. Sample ODBC-only <filename>odbc.ini</filename> file [ODBC Data Sources]Several DSNs might be listed here. In this example, we have only one, JDBC. It matches the [JDBC] entry later in the file. JDBC = Sybase JDBC Server [JDBC] Driver = /usr/local/freetds/lib/libtdsodbc.so Description = Sybase JDBC Server Trace = No Server = jdbc.sybase.com Database = pubs2 Port = 4444 TDS_Version = 5.0 [Default] Driver = /usr/local/freetds/lib/libtdsodbc.so ODBC-combined configuration Like the DSN-less configuration, ODBC-combined keeps server properties in &freetdsconf;. The difference is that your applications can refer to the server by its DSN. To make that possible, the DSN entry in odbc.ini refers to the servername entry in &freetdsconf;. Sample ODBC-combined <filename>odbc.ini</filename> file [ODBC Data Sources]Several DSNs might be listed here. In this example, we have only one, JDBCdsn. It matches the [JDBCdsn] entry later in the file. JDBCdsn = Sybase JDBC Server [JDBCdsn] Driver = /usr/local/freetds/lib/libtdsodbc.so Description = Sybase JDBC Server Trace = No Servername = JDBCRefers to the [JDBC] entry in &freetdsconf;. Database = pubs2 [Default] Driver = /usr/local/freetds/lib/libtdsodbc.so Sample ODBC-combined &freetdsconf; file ; ; freetds.conf ; [JDBC] host = jdbc.sybase.com port = 4444 tds version = 5.0 With this arrangement, an application can connect to the server in two ways, via its DSN (JDBCdsn), or its servername (JDBC). Troubleshooting ODBC connections Supposing everything compiles and installs without trouble, how do you know if your ODBC setup works? Or, if you know it doesn't, what then? First, try to connect with tsql. If you're intending to use &freetdsconf;, exercise it with tsql -S servername. If not, use TDSVER=7.0 tsql -H hostname -p port If tsql works and isql doesn't, you've isolated the problem to the ODBC setup. &freetds; might have some interoperability problems, but mere connection to the database isn't one of them! If tsql doesn't work, turn on logging with TDSDUMP. The log will tell you what TCP/IP name (and address) &freetds; is attempting to connect to, and what version of the TDS protocol it's using. With iODBC iODBC comes with a sample command line query program called odbctest, located in the iodbc/samples directory. Using this program you can get a listing of DSNs, connect, and issue queries. For debugging purposes, you may wish to link a program such as odbctest directly to &freetds; instead of to the driver manager. Why? Once the program is started in the debugger, the driver entry points become viable breakpoints. Because the DM loads the driver dynamically with dlopen(3), no driver addresses even exist until the runtime linker loads it. To do so, compile and install the &odbc; driver with iODBC as normal When linking directly to &freetds; you still need the Driver Manager's header files., then compile and link the program: Compile <filename>odbctest</> without a driver manager. $ make odbctest.o $ gcc -g -o odbctest odbctest.o /usr/local/freetds/lib/libtdsodbc.a Now you can run gdb or another debugger and set breakpoints on functions in the library without the driver manager getting in the way. With unixODBC Try isql -v dsn username password, and have a look at the log. See if the right address and TDS version are being used. Adjust to taste. Use <command>osql</> The osql utility is a Bourne shell script that checks your ODBC configuration. If it approves, it invokes the unixODBC isql utility. Cf. man osql for details on its use. Use <command>osql</> to test the ODBC setup. $ osql -S machine -U mr_ed -P hayseed looking for odbc.ini and odbcinst.ini in /usr/local/etc reading "/usr/home/mr_ed/.odbc.ini" [machine] found in "/usr/home/mr_ed/.odbc.ini" found this section: [machine] Database = testdb Servername = machine Trace = Yes TraceFile = /tmp/unixodbc.trace looking for driver for DSN [machine] no driver mentioned for [machine] in .odbc.ini looking for driver for DSN [default] driver "FreeTDS" found for [default] in .odbc.ini found driver named "FreeTDS" FreeTDS is not a readable file looking for entry named [FreeTDS] in /usr/local/etc/odbcinst.ini driver "/usr/local/lib/libtdsodbc.so" found for [FreeTDS] in odbcinst.ini /usr/local/lib/libtdsodbc.so is a readable file Using ODBC-Combined strategy FreeTDS servername is "machine" (from /usr/home/mr_ed/.odbc.ini) looking for [machine] in /usr/home/mr_ed/.freetds.conf "/usr/home/mr_ed/.freetds.conf" is a readable file found this section: [machine] host = machine.example.com port = 2500 tds version = 7.1 machine.example.com has address 10.82.32.177 DSN: machine Driver: /usr/local/lib/libtdsodbc.so Server's hostname: machine.example.com Address: 10.82.32.177 Attempting connection as mr_ed ... + exec isql machine mr_ed hayseed -v +---------------------------------------+ | Connected! | | | | sql-statement | | help [tablename] | | quit | | | +---------------------------------------+ SQL> The reader is here advised that the isql that comes with many versions of unixODBC will truncate text and surprise in other ways without warning. If it behaves strangely, try &freetds;'s bsqlodbc before you decide you've found a &freetds; bug.
Advanced Configurations This chapter details some advanced configurations that need expanded explanation. Big Endian Clients with Buggy <productname>SQL Server</productname>s Several version of Microsoft SQL server have a bug that affects big endian clients. This includes 7.0 GA and 7.0 SP1. Furthermore, TDS Protocol version 7.0 is natively little endian. SQL Server 2000 is also reported not to work from big endian clients without little endian emulation turned on. The terms big endian and little endian come originally from Gulliver's Travels. In computer science they refer to the the integer byte-order for a processor. Big endian processors, such as Sparc and PowerPC store the most significant byte in the first memory location of a multi-byte integer. Little endian processors, such as Intel and Alpha do it the other way around. So the 16-bit number 258 would be 0x0102 on big endian and 0x0201 on little endian machines. In this example we want to force connections to a server named mssql to emulate a little endian client. We are using protocol version 4.2 here, version 7.0 or above will automatically emulate little endian mode regardless of the &freetdsconf; setting. You shouldn't use this option, set another protocol version instead (7.0, 7.1, 7.2, 7.3 or 7.4). Emulate Little Endian &freetdsconf; setting [mssql] host = ntbox.mydomain.com port = 1433 tds version = 4.2 emulate little endian = yes Localization and <acronym>TDS</> 7.0 TDS 7.0 uses 2-byte Unicode (technically, UCS-2, recently UTF-16) to transfer character data between servers and clients. Included in character data are query text (i.e., SQL), metadata (table names and such), and bona fide data of datatypes nchar, nvarchar, and ntext. (Background information on Unicode and how it affects &freetds; can be found in the appendix.) Because most Unix tools and environments do not support UCS-2, &freetds; provides for conversion by the client to other character sets. The mechanism used is determined by the configure script, which looks for a iconv(3) function, an implementation of the iconv standard. If no iconv library is found, or if it is explicitly disabled, &freetds; will use its built-in iconv substitute, and will be capable of converting among only ISO 8859-1, UTF-8, UCS-2, UTF-16 and UTF-16. To learn what character set the client wants, &freetds; prefers the applicable &freetdsconf; client charset property. If that is not set, it parses the LANG environment variable. In either case, the found string is passed to iconv(3) (or its built-in replacement). The built-in replacement expects GNU iconv names: ISO-8859-1, US-ASCII, or UTF-8.. If neither is found, UCS-2 data are converted to ISO 8859-1. To list all supported iconv character sets try iconv(1). GNU's does: $ iconv --list For other systems, consult your documentation (most likely man iconv will give you some hints). In this example a server named mssql will return data encoded in the GREEK character set. Configuring for GREEK &freetdsconf; setting [mssql] host = ntbox.mydomain.com port = 1433 tds version = 7.0 client charset = GREEK If &freetds; runs into a character it can not convert, its behavior varies according to the severity of the problem. On retrieving data from the server, &freetds; substitutes an ASCII '?' in the character's place, and emits a warning message stating that some characters could not be converted. On sending data to the server, &freetds; aborts the query and emits an error message. It is well to ensure that the data contained in the database is representable in the client's character set. If you have a mix of character data that can not be contained in a single-byte character set, you may wish to use UTF-8. UTF-8 is a variable length unicode encoding that is compatible with ASCII in the range 0 to 127. With UTF-8, you are guaranteed to never have an unconvertible character. &freetds; is not fully compatible with multi-byte character sets such as UCS-2. You must use an ASCII-extension charset (e.g., UTF-8, ISO-8859-*)not EBCDIC or other weird charsets. Great care should be taken testing applications using these encodings. Specifically, many applications do not expect the number of characters returned to exceed the column size (in bytes). In the following example, a server named mssql will return data encoded in the UTF-8 character set. Configuring for <acronym>UTF-8</> &freetdsconf; setting [mssql] host = ntbox.mydomain.com port = 1433 tds version = 7.0 client charset = UTF-8 It is also worth clarifying that TDS 7.0 and above do not accept any specified character set during login, as 4.2 does. A TDS 7.0 login packet uses UCS-2. Microsoft Server Note String literals in SQL must be prefixed with 'N' unless the enclosed string can be represented in the server's single-byte character set, irrespective of the column's datatype. For example, in the SQL statement INSERT INTO tablename (greeting) VALUES ('Hallå') the string is subject to somewhat surprising treatment by the server. When the server parses the SQL, it extracts the data values for insertion (or update, or comparison, etc.) Unprefixed strings are converted to the single-byte character set of the server/database.The precise rules are unknown to the author. Inserted data are then of course stored in the column. In the case of UCS-2 columns — nchar, nvarchar, and ntext — the value stored is that which results from a second conversion: from the single-byte form to the UCS-2 form. The only safe way to enclose strings in SQL text is with an 'N' prefix: INSERT INTO tablename (greeting) VALUES (N'Hallå') Commentary What's surprising about this? Versions 7.0 and later of the TDS protocol use UCS-2 to send SQL text. No matter how your local client is configured — with UCS-2 or ISO 8859-1 or anything else — it's converted to UCS-2 before it's sent to the server. And obviously arrives at the server as UCS-2. If the column into which it's being inserted is also UCS-2, there's no need of any conversion, much less two, and certainly no need to lose information. Why this happens is anyone's guess. Here's one: it makes the datatype of the column unimportant. Regardless of whether you use char/varchar/text or nchar/nvarchar/ntext or a mixture of the two, the arriving SQL (if naïvely written) will store exactly the same characters. Domain Logins Domain logins can be used only with TDS protocol versions 7.0 or above. As mentioned in the installation chapter, Microsoft SQL Server includes the ability to use domain The term domain in this context is a Microsoft term. It refers to what's sometimes called an NT domain. It's unrelated to the DNS domain. DNS domains are used for name resolution. NT domains are used for authentication. Authentication is done by the domain controller, often the Primary Domain Controller (PDC). The SQL Server machine may belong to an NT domain. &freetds; provides an encrypted password — a domain password, known to the domain controller — that the server will ask the domain controller to verify. logins instead of standard server logins. Passwords are encrypted on the wire using a challenge-response protocol. &freetds; plays nice with such logins. &freetds; supports single sign-on (connecting without prompting for a username & password) or not, depending on how it was configured. For Windows hosts (both 32- and 64-bit), if SSPI is enabled, &freetds; will log in using so-called trusted authentication. For non-Windows hosts, enabling Kerberos provides similar functionality. When neither option is enabled, &freetds; can still log in using the domain account, but the user must supply the username & password. To use domain logins without SSPI or Kerberos, use the 'DOMAIN\username' syntax for the username and use the domain password. Logging in with a domain login $ tsql -S camelot -U 'NOTTINGHAM\lancelot' -P roundtable locale is "C" locale charset is "646" Msg 5703, Level 0, State 1, Server CPRO200, Line 0 Changed language setting to middle_english. 1> When &freetds; sees the \ character, it automatically chooses a domain login. Implementation details Support for domain logins in &freetds; is limited to the TCP/IP network protocol stack. &freetds; does not currently implement support for Named Pipe-based SQL connections — that is, connections transported over the DCE/RPC interface, which uses TCP port 139, 445, or 135 on Win32 machines depending on the type of encapsulation used for DCE/RPC itself. Supporting this would require a fairly extensive DCE/RPC library for Unix. Samba has one that is licensed under the GPL and therefore not usable by LGPL-licensed projects such as &freetds; . For a technical description of the protocol used for domain logins, see http://davenport.sourceforge.net/ntlm.html Kerberos Support Perhaps surprisingly, Kerberos can be used to authenticate to Microsoft SQL Servers. It works because much of Active Directory is based on Kerberos. From each according to his ability; to each according to his needs. This affords single-signon (or, at most, double-signon) capability in non-Windows environment. To take advantage of Kerberos you have to set up your machine with keytab No, the author does not really know what he's talking about. from your Active Directory. You could use Samba or configure Kerberos directly (/etc/krb5.conf). configure includes options to define the location of your Kerberos installation (cf. ). By default UNIX does not initialize a Kerberos ticket with your login account. You must use kinit to initialize a ticket. You could also configure Kerberos in PAM to initialize a Kerberos ticket at login time. Threading in unixODBC unixODBC uses a strong thread-locking policy that causes big locks with the default configuration for &freetds;. Performance of multi-threaded applications can be affected because every operation is serialized. To avoid this problem, choose a threading model in odbcinst.ini. Sample <filename>odbcinst.ini</> for threading model [FreeTDS] Driver = /usr/local/freetds/lib/libtdsodbc.so Threading = 1 Sample <filename>odbc.ini</> for threading model [Server1] Driver = FreeTDS Server = myServer1 Port = 1433 TDS_Version = 7.2 You can use also a connection string e.g. DRIVER=FreeTDS;SERVER=myServer1;PORT=1433;TDS_Version=7.2;. Appending Dump Files When running &freetds; with applications such as Apache/PHP it is often difficult to get a usable log file. Since each of the many httpd children opens the file at the beginning of its connection and closes it on connection close, they tend to stomp all over each other. In append mode, the log file is opened for append each time it is written to and then immediately closed. If you are experiencing problems when running under Apache (or similar application) use append mode to generate useful logs. Turning on Dump File Append mode in &freetdsconf; [mssql] host = ntbox.mydomain.com port = 1433 tds version = 7.0 dump file = /tmp/freetds.log dump file append = yes In this example, the /tmp/freetds.log file will contain log entries for all processes using the Microsoft SQL Server server, identified by pid. Because there will be one log file being opened and closed more or less continuously, there is going to be a negative impact on performance. Also, be advised that the log file will grow quite large. As an alternative to &freetds; logging, you might also consider using tcpdump or wireshark to log network packets. While not as useful as a TDS log, it can also help to identify problems. TDS Connection Pooling The Connection Pooling server swims in the src/pool directory. The &freetds; connection pool is a server process; it emulates a SQL Server. Any program that can attach to a real SQL Server may instead elect to attach to the pool server. The pool in turn connects to the SQL Server and database you specify, and attempts to share these connections. See the src/pool/README for a more detailed description of its inner workings. To configure the pool server, first make sure &freetds; has a working entry for the real SQL Server by connecting to it with SQSH or another program. The &freetds; connection pool currently only supports TDS version 4.2. This restriction applies to both the client-to-pool and pool-to-server connections! After &freetds; has been installed, you will find an executable named tdspool in the /usr/local/bin directory (or whatever directory was specified with the configure Edit pool.conf in the &freetds;'s etc directory. The pool.conf file is formatted like &freetdsconf;, with a section name in brackets and options for each section in key/value pairs. Just as in &freetdsconf; there are two types of sections, a [global] section whose options affect all pools, and a section with the name of the pool for pool-specific options. The following options are supported and may appear in either section. pool.conf settings Name Possible Values Default Meaning user Any valid user none The username used to connect to the servername. password Any none The password of the user at the servername. server Any TDS 4.2 entry in the freetds.conf file none The alias from the freetds.conf file representing the servername that will be connected to. database Any valid database User's default database The database on the servername to use. port Any TCP port none Port on which tdspool will listen. min pool conn 1 or more none Minimum number of open connections to maintain to the servername. max pool conn 1 or more none Maximum number of open connections to open against the servername. max member age 0 (no limit) or a number of seconds 0 Maximum age of idle members before connection is closed.
Now, let's put this into practice. pool.conf [global] min pool conn = 5 max pool conn = 10 max member age = 120 [mypool] user = webuser password = secret database = ebiz server = fooserv max pool conn = 7 port = 5000 The [global] section defines that we will open 5 connections against the server initially, and will increase up to 10 as demand requires. These connections will be closed after being idle for 2 minutes (120 seconds), but only until there are 5 remaining open. The [mypool] section defines a pool named mypool that will listen on port 5000. It will login to a SQL Server named fooserv using the user webuser and the ever so clever password of secret. Once logged in, the connections will use the database ebiz instead of webuser's default database. Also, since this SQL Server has a limited number of CALs (Client Access Licenses), we are restricting the maximum number of connections to 7, which overrides the global setting of 10. Run tdspool with the name of the pool you are serving. $ tdspool mypool Before your clients connect to the pool, you must edit your &freetdsconf; to include the host and port of the pooling server, and point your clients at it.
stunnel HOWTO Contributed by Bradley Bell. To set up &freetds; over stunnel between a Linux webserver and a W2k SQL server: Get unencrypted &freetds; working Install openssl and stunnel on the Linux box: stunnel.org Download the stunnel binary and openssl dll's for Windows. Generate stunnel.pem (complete with Diffie-Hellman parameters) for placement on the W2k box. See instructions in the stunnel FAQ. Start stunnel on the W2k box: $ stunnel.exe -d 61666 -r localhost:1433 61666 is just an arbitrary port number. Start stunnel on the Linux box: $ stunnel -c -d 1433 -r win2kserver:61666 where win2kserver is the hostname or IP address of the W2k box. Set up &freetds; to use the tunnel. If this is your unencrypted entry in &freetdsconf;: Unencrypted entry in &freetdsconf; [win2kserver] host = win2kserver port = 1433 the encrypted equivalent uses: Encrypted entry in &freetdsconf; [win2kserver] host = localhost port = 1433
Use &freetds; &freetds; includes several utilities. Some are testing tools, some demonstration projects, some intended for day-to-day use. All have man pages. &freetds; Utilities</> <variablelist><title>(listed alphabetically) bsqldb A non-interactive equivalent of the isql utility programs distributed by Sybase and Microsoft. Like them, bsqldb uses the command go on a line by itself as a separator between batches. The last batch need not be followed by go. bsqldb makes use of the &dblib; API. Intended for production use. bsqlodbc A non-interactive equivalent of the isql utility programs distributed by Sybase and Microsoft. Like them, bsqlodbc uses the command go on a line by itself as a separator between batches. The last batch need not be followed by go. It uses the &odbc; API. bsqlodbc is a demonstration project, but can also aid in isolating problems. &odbc; applications typically have many layers, and it can be difficult to know if a problem arises in a layer, or in the interface between layers. By executing a query in bsqlodbc, you can see if the functionality of the &odbc; driver works when used as the folks who wrote the driver thought it would be used. datacopy A tool for migrating data between Sybase ASE and SQL Server or vice versa. datacopy will move table data from one server to another without the need for intermediate files. datacopy is much faster and more efficient than is freebcp out/in. datacopy makes use of the &dblib; bcp API. defncopy Replaces a similar program of the same name distributed by Sybase. defncopy reads the text of a stored procedure or view, and writes a script suitable for recreating the procedure or view. For tables, it reads the output of sp_help and constructs a CREATE TABLE statement, complete with CREATE INDEX, too. fisql A complete replacement of the isql utility programs distributed by Sybase and Microsoft. Like them, fisql uses the command go on a line by itself as a separator between batches. freebcp Replicates the functionality of the bcp utility programs distributed by Sybase and Microsoft. freebcp makes use of the &dblib; bcp API. The manual pages or online help for Sybase or SQL Server can be referenced for more detailed information on bcp functionality. osql A Bourne shell script that checks and reports on your configuration. tsql A diagnostic tool that uses uses the lowest level &freetds; library, libtds, as a way to isolate potential bugs in the protocol implementation. tsql is not a replacement for a complete isql. How to get what works with it working The following programs are known to work to some extent with &freetds;. Here you will find any special instructions for getting them compiled or running. <application>SQSH</application> SQSH is a command line based query tool written by Scott Gray to replace the isql utility that ships with Sybase ASE. It makes a great diagnostic tool for &freetds; as well. If you are having trouble, install SQSH (it's easy) and try getting that to work before more complicated arrangements. SQSH is an excellent tool. Because it uses &ctlib;, it works with &freetds;, but potentially — and with significant effort — it could be ported to ODBC and thus made useful for other server environments. Just a thought…. SQSH 2.1 includes direct support for &freetds;, so these instructions may not be necessary, but are still included just in case. After running configure in SQSH's directory (make sure you set the Sybase environment variable first), look for the Sybase_LIBS definition in the Makefile. Change the line to match this example. The <application>SQSH</application> Makefile # # The following set of CT-LIB libraries were determined automatically # by 'configure'. For most systems configure looks up the required # libraries by looking at the name of the OS (although this doesn't # mean it got them right), however if the line below ends with the # word "Guess", then 'configure' didn't have an entry for your operating # system and it took a best guess to figure out which libraries you # need. In either case, there may be problems, so look this line over # and if it doesn't work, compare it to the libraries located in # $SYBASE/samples/ct-library. # # The listings below show suggested libraries for Operating Systems # that frequently fail to be recognized by 'configure': # # SCO: -lblk -lct -lcs -lcomn -ltcl -ltli -lnsl_s -lintl -m -lsocket # Dynix: -lblk -lct -lcs -lcomn -ltcl -ltli -lnsl -lintl -lm -lseq # SYBASE_LIBS = -lct -ldl -lm At this point you can also enable readline support if you didn't specify it in the configure arguments. After that just type make and you are off and running. Perl There are a few ways to use Perl to connect to a SQL Server using &freetds;. DBD::Sybase The recommended choice is DBD::Sybase from Michael Peppler. Despite the name it works for any Sybase or Microsoft SQL Server. DBD::Sybase uses the &ctlib; API and works well. DBD::ODBC You may also use DBD::ODBC with the &freetds; &odbc; driver. You may find this attractive if you're familiar with DBD::ODBC. Sybperl Finally, you can use Sybperl. Scripts written against Sybperl will not run against other databases the way DBI scripts will. However, it will be familiar ground for those who know &dblib;. Building and using the Perl modules Building <systemitem class="library">DBD::Sybase</systemitem> $ cd DBD-Sybase-0.91 $ export SYBASE=/usr/local/freetds $ perl Makefile.PL $ make $ su root Password: $ make install There will be some output about missing libraries after perl Makefile.PL. These are normal. The following example will attach to Sybase's public JDBC server and run a simple query (it can be found in samples/test.pl): Connect to a server with <systemitem class="library">DBD::Sybase</systemitem> #!/usr/local/bin/perl # use DBI; my $dbh = DBI->connect("dbi:Sybase:server=JDBC", 'guest', 'sybase', {PrintError => 0}); die "Unable for connect to server $DBI::errstr" unless $dbh; my $rc; my $sth; $sth = $dbh->prepare("select \@\@servername"); if($sth->execute) { while(@dat = $sth->fetchrow) { print "@dat\n"; } } Building <systemitem class="library">DBD::ODBC</systemitem> $ cd DBD-ODBC-0.28 $ export SYBASE=/usr/local/freetds $ export ODBCHOME=/usr/local $ export DBI_DSN=dbi:ODBC:JDBC $ export DBI_USER=guest $ export DBI_PASS=sybase $ perl Makefile.PL $ make $ su root Password: $ make install We used the public JDBC server logins for our configuration here. You'll want to replace these with ones suitable to your environment. Connect to a server with <systemitem class="library">DBD::ODBC</systemitem> #!/usr/local/bin/perl # use DBI; my $dbh = DBI->connect("dbi:ODBC:JDBC", 'guest', 'sybase', {PrintError => 0}); die "Unable for connect to server $DBI::errstr" unless $dbh; my $rc; my $sth; $sth = $dbh->prepare("select \@\@servername"); if($sth->execute) { while(@dat = $sth->fetchrow) { print "@dat\n"; } } You'll note this is the same program as for DBD::Sybase with the exception of the connect statement. Welcome to the magic of DBI! PHP There are three options for building PHP with support for &freetds; corresponding to the three APIs that &freetds; supports: &dblib;, &ctlib;, and &odbc;. All these examples build the CGI version. Consult PHP's documentation for building the Apache module and including other extensions. &dblib; PHP can be configured with &dblib; access for a "Sybase" server (which also works with Microsoft servers), or with the mssql extension, intended exclusively for Microsoft servers. PHP and &dblib; for <quote>Sybase</> First build &freetds; normally. $ ./configure --prefix=/usr/local/freetds $ make $ su root Password: $ make install Then build PHP with support for Sybase $ cd php $ ./configure --with-sybase=/usr/local/freetds $ make $ su root Password: $ make install And that's it! &ctlib; Option 2 is to use the &ctlib; API. Again here, we run into minor difficulties at build time. Applications linking with Sybase's OpenClient have to link in a handful of libraries and these libraries vary slightly from platform to platform. When creating &freetds; it was decided that there would be only one library: libct. This saves a great deal of library naming conflicts that Sybase ran into (e.g. libtcl is used both by Sybase and the language TCL), however some applications like PHP assume that all the Sybase libraries will be present. So, some hand editing of the Makefile is necessary to remove these extra libs. Build &freetds; just as you would for &dblib; in with &dblib;, above. Then configure PHP with &ctlib;. $ cd php $ ./configure --with-sybase-ct=/usr/local/freetds Now edit the Zend/Makefile looking for the libZend_la_LDFLAGS line and remove -lsybtcl -lintl -lcomn and -lcs, leaving the -lct. Then proceed to make and install PHP. $ make $ su root Password: $ make install We hope an upcoming version of PHP will automatically detect the presence of &freetds; and include only the -lct library. &odbc; The third and newest option is to use the &freetds; &odbc; driver with PHP. First build the iODBC or unixODBC driver manager and &freetds; as detailed in . Then build PHP with support for ODBC. $ cd php $ ./configure --with-iodbc=/usr/local $ make $ su root Password: $ make install Now everything should run. There is a sample PHP script in the &freetds; samples directory called odbctest.php. Python pymssql The pymssql module is a simple database interface to Microsoft SQL Server for Python that builds on top of &freetds; to provide a Python DB-API v2 (PEP-249) interface to SQL Server. The 2.x branch of pymssql take advantage of recent releases (0.91 and newer) of &freetds; and by doing that removes many of the limitations previously found with older &freetds; versions and the 1.x branch. pymssql features include: Unicode friendly Python 3 friendly Works on most popular operating systems Written in Cython for performance Includes a supported and documented low-level module (_mssql) that you can use instead of the DB-API Supports stored procedures with both return values and output parameters A comprehensive test suite Please refer to the pymssql home page where you'll find complete documentation on how to obtain, install and use it. Sybase module You can obtain the Python Sybase module here. This example uses version 0.37, the most current at the time of this writing, please adjust accordingly if using a different version. $ tar xvfz sybase-0.37.tgz $ cd sybase-0.37 $ export SYBASE=/usr/local/freetds $ export CFLAGS="-DHAVE_FREETDS" $ export LD_LIBRARY_PATH=/usr/local/freetds/lib:${LD_LIBRARY_PATH} $ python setup.py install Edit the example.py and fix the bottom stuff, &freetds; lacks the 110 symbols for version use 100 $ python example.py Qt To access SQL Server databases using Qt use QODBC. There are some problems with wide character support on Qt because Qt assumes sizeof(SQLWCHAR) == 2. On some DMs, though — including iODBC, the default on Ubuntu — sizeof(SQLWCHAR) == 4, which could lead to invalid character conversion. ODBC on Unix &odbc; has some issues on Unix, mainly due to lack of clean specifications. ODBC and 64-bit ODBC was originally specified as 32-bitIn fact, the earliest versions were 16-bit.. Its evolution to 64-bit took place in the absence of a good specification which led to conflicting declarations and associated problems. For instance, some parameters are defined as SQLINTEGER but are used for pointer offsets. But SQLINTEGER was (and remains) 32-bit, while pointer offsets must be 64-bit. Also row numbers and some other formerly 32-bit quantities are now 64-bit. If you use unixODBC Frediano would recommend at least version 2.2.14. Earlier versions have issues if used on 64-bit environments. sizeof(SQLWCHAR) Under Windows sizeof(wchar_t) == sizeof(SQLWCHAR) == 2 but on many Unix systems you have sizeof(wchar_t) == 4. And some DMs decided to keep sizeof(SQLWCHAR) == 2 (including unixODBC) while in other DM sizeof(SQLWCHAR) == sizeof(wchar_t) == 4 (namely iODBC). This leads to incompatible ABIs between applications and drivers. If you compile the &freetds; ODBC driver using iODBC take care to ensure all drivers are compiled with the same header files. Alternatively, compile &freetds; with both includes and rename the library to use two ABIs (for instance having a libtdsiodbc.so and a libtdsuodbc.so). At the time of writing Ubuntu compiled Qt using iODBC but most packages use unixODBC. If you plan to use Qt with the &freetds; &odbc; driver, you should have an iODBC-compatible driver. Also be aware that the QODBC Qt driver has problems with iODBC and SQLWCHAR (see Qt). Due to these problems Frediano suggests not using this configuration (Qt database) on Ubuntu at this time. Default charset Character encoding is yet another trap. ODBC makes no provision for specifying client character encoding. By default many DM converting from multi-byte to wide characters assume the client uses ISO 8859-1. Even the &freetds; driver assumes ISO 8859-1 by default. Also some DM have problems converting multi-byte encodings (like UTF-8), by assuming a byte can be converted to a single wide character (and vice versa). That creates problems if you use multi-byte encoding for &freetds; driver. Troubleshooting Jason Mewes (Mall Rats) He's like motherf**king McGuiver, no he's better than McGuiver! Known Issues Porting Issues Date Structures and Offsets Microsoft and Sybase use different &dblib; date structures and conventions. Notably months can be in the range [0,11] or [1,12]. Pay careful attention to the results of dbdatecrack(). Floating Point Precision may surprise you if you pay attention. Microsoft's &dblib; promotes single-precision to double in dbbind() by appending zeros; C promotes it to the nearest double. &freetds; relies on the C compiler. Math libraries vary, too. If porting an application whose output uses functions such at log(3), expect differences in different implementations. Perfectly consistent results between OSes will require the use of a single math library. <type>Text</type> Fields Questions sometimes arise over large varchar types (anything larger than varchar(255)) that became available with Microsoft SQL Server 7.0. When accessing long varchars with TDS protocol version 4.2 or 5.0, these fields will be truncated to 255 characters, due to limitations inherent in the protocol definition. Your best bet in that case is to convert them to text types. In Microsoft SQL Server 7.0 and later, varchar types can hold up to 8000 bytes (8000 ASCII characters or 4000 Unicode characters). To move these large varchars through TDS 4.2, convert them with either a CONVERT as in, SELECT mycol = convert(mycol, text) FROM mytable or with the newer SQL92 CAST syntax e.g., SELECT CAST(mycol as TEXT) FROM mytable There is also a bug (Lions and tigers and bugs! Oh, my!) in Microsoft's implementation of text fields. Disregardless [sic] of their documentation, you must explicitly set the value of TEXTSIZE, else the text fields will be represented to have a maximum size of 4 gigabytes or so. If you encounter some spurious out of memory error try to set TEXTSIZE to some reasonable value before querying any TEXT fields. For example, in isql: 1> set TEXTSIZE 10000 2> go Another way to handle control the default TEXTSIZE is to use the setting in &freetdsconf;. As most of the time data contained in BLOBs fields are much smaller than larger supported fields, we try to avoid considering field sizes for BLOBs allocating memory as needed instead, so you should not have to reduce this value unless you really want the server to limit data returned by queries. Endianism If either your server or your client is a big endian system, pay careful attention to all references to endianism anywhere near &freetds;. See the section on Little Endian Emulation for details. <type>Datetime</type> and <type>Money</type> Big endian clients may experience difficulty with Microsoft servers. Some versions of SQL Server 7 did not handle these types on these machines correctly, according to the protocol. According to http://support.microsoft.com/support/kb/articles/Q254/1/23.ASP on the Microsoft support site, it's fixed as of service pack 3. Unfortunately, there's no direct way for &freetds; to know whether or not a service pack has been installed, and how/whether to support the buggy version is an outstanding issue. Your best bet is to apply their patch. The Knowledge Base article states The Sybase CT-Lib client is the only known big-endian client that can connect to SQL Server. Depends on who's doing the knowing, of course. Microsoft's <quote>Integrated Security</quote> &freetds; may be unable to connect to the server. The error message will be "Login failed for user 'example'. Reason: Not associated with a trusted SQL Server connection". To solve this, turn on SQL Server authentication: Open the SQL Server Enterprise Manager, Select the server, Right mouse click and choose Properties. A properties window will appear. Choose the Security tab. The security properties will be displayed. Change the Authentication field to SQL Server and Windows, Apply the changes and try again. These instructions apply to Microsoft SQL Server 7 and SQL Server 2000. &freetds; supports integrated security mode, too. If you have SQL Server running in integrated (domain) mode along with a Windows PDC, and wish to try it, see Domain Logins in the Advanced Configurations chapter. If you have Active Directory you can also use Kerberos, see Kerberos support. Is the server there? Start with <command>ping</> First ping the host to make sure you can talk to the machine the server resides on. Finding the server's host $ ping -c1 myhost PING myhost (127.0.0.1) from 127.0.0.1 : 56(84) bytes of data. 64 bytes from myhost (127.0.0.1): icmp_seq=0 ttl=255 time=250 usec A successful ping shows that your network isn't preventing you from reaching the machine hosting the server. Test with <command>telnet</> Attempt to telnet to the port, to verify that the servername is listening. Finding the server $ telnet myhost 1433 Trying 127.0.0.1... Connected to myhost. Escape character is '^]'. If you get output as above, the servername is listening. If you get a 'Connection Refused' message, you're talking to the wrong host, wrong port, or the servername is down. To exit telnet: When connected, telnet's command mode may be entered by typing the telnet escape character (initially Ctrl-], as above). Once in command mode, telnet may be exited with the command quit. Test with <command>tsql</> tsql can be run in two ways, one which uses &freetdsconf; and one which connects directly using the host and port. First attempt a connection using host and port. Connecting to the server, bypassing &freetdsconf; $ cd src/apps $ TDSVER=7.0 ./tsql -H myhost -p 1433 -U user If you receive a message of 'Login Failed.' then your connectivity is OK, but you have a authentication issue. If you receive a message like Msg. No.: 18450 Severity: 14 State: 1 Login failed- User: loginid Reason: Not defined as a valid user of a trusted SQL Server connection SQL Server is accepting only domain logins. This applies only to Microsoft SQL Server and you'll need to have your DBA verify that server logins are allowed, or use a domain login. Finally, if you received a prompt, then try tsql using the servername. Connecting to the server using &freetdsconf; $ ./tsql -S myserver -U user If this fails, &freetds; is either not finding your &freetdsconf; file, finding the wrong one, or there is an error in the file. Logging &freetds; has quite extensive logging capabilities. These are often invaluable in setting up new configurations, when it's hard to be sure precisely what configuration information is being used, and what communication is (not) working. Often such questions can be quickly resolved by turning on logging and examining the logs. Environment Variables that Control Logging TDSDUMP Log files can be turned on using the TDSDUMP environment variable. For instance, setting the location of a dumpfile $ export TDSDUMP=/tmp/freetds.log Will generate a log file named freetds.log in the /tmp directory. The filenames stdout and stderr are also supported. They can be handy if you want to intersperse the log output with your application's output, or if your application opens more than one connection. (The logfile is otherwise normally truncated each time the library connects to the server.) TDSDUMPCONFIG Set TDSDUMPCONFIG to a file to write information to on how the configuration information is being obtained, e.g. from environment variables, a &freetdsconf; file, or interfaces file. Sometimes it's unclear what source of information &freetds; is using to connect to a given servername. This variable can make that bright and clear. What if you were running Apache/PHP? Apache has many children. Setting the TDSDUMP (and/or TDSDUMPCONFIG) variable to a null string will cause &freetds; to open a log under every PID. $ export TDSDUMP="" The log files will be named /tmp/freetds.log.9999, where 9999 is the pid number of the process generating the log. A couple of important notes about using the logs with &freetds;. First, the logs tend to grow large, so trim or archive them often. Secondly, &freetds; will record certain network packets to the log, this includes login packets which can contain clear text or clear text equivalent passwords. So, if this is a concern (most likely is) make sure that the files are not world readable, and avoid posting them to mailing lists. Once in a while, someone writes to the mailing list, asking why &freetds; is so slow. It sometimes turns out that logging was left turned on. Don't you be the next victim! &freetds; logs are meant for development and debugging, not as a system monitoring tool. &freetdsconf; variables that Control Logging See Valid bitmask values for debug flags entry in &freetdsconf; The logfile is normally truncated each time &freetds; connects to the server. Logging in ODBC land (Tree-huggers need not worry) Many ODBC Driver Managers have their own support for logging. How logging is controlled, however, varies widely by implementation. The ODBC log is often very helpful because it provides a log of all calls made directly by the application. unixODBC unixODBC supports logging via some entries in odbcinst.ini. For example: [ODBC] Trace = Yes TraceFile = /tmp/sql.log ForceTrace = Yes Will generate a log file named sql.log in the /tmp directory. "Page contains no data" Web browsers display this error when the underlying script didn't return any information. The error could be in any of several places, of which &freetds; is one. To isolate the cause, turn on enough logs to see the query, and execute the query through SQSH. If that works, the problem lies further up the chain. If it doesn't, take a look at the known issues section. &freetds; under PHP executing within an Apache process may abort with a segmentation fault. The evidence of this is the words "Segmentation Fault" or "Bus Error" in the Apache error log, and a "Page contains no data" warning displayed by the web browser. The unexpected termination of the process causes the connection to the client to be closed before any buffered data is sent. To diagnose this sort of problem, follow this procedure; Compile PHP as a CGI binary. This should have been a side-effect of your build of PHP, look for an executable called php in the PHP build tree. If you are using a packaged binary, look for a php-cgi package. Make a reproducer. Make a PHP script that reliably reproduces the segmentation fault via the web server, but with no arguments. This is so that you can execute it using the PHP binary, thus excluding the web server as the cause of the problem. Reproduce on command line. Reproduce the segmentation fault using PHP on the command line, by activating PHP with the script as first argument. For example; % php file.php Segmentation fault % If this doesn't reproduce the segmentation fault, then there is something about the environment that differs, so look for the differences and resolve them. Check environment variables, assumptions made by the script, the UID you are executing under, and the current working directory. Reproduce using GDB. Now reproduce the segmentation fault using the debugger, GDB. Instead of aborting to the command line, GDB will stop executing the PHP program at the point of failure. Use the bt command to determine the details and context. This is called a backtrace. % gdb php gdb> run file.php gdb> bt Analyze the backtrace. Read the backtrace to determine what the cause of the problem is. Examine each line, assigning responsibility by component; some code is PHP, some is &freetds;, and some may be glibc. You will need the source code for each component, and software engineering debugging skills. If you cannot determine the cause yourself, send the backtrace to the mailing list, along with the PHP script. It helps to make the script as small as possible, but still fail. It also helps to report the version numbers of PHP, and &freetds;. Slow connection or data retrieval &freetds; is not slow. We know this because we've tested it. It's measurably slower than the vendors' products for some operations, but it's not noticeably slower and it's certainly no laggard. If your experience is different, if you're waiting 30 seconds for simple operations or minutes instead of seconds for for query results, something is up with your setup. There are two likely culprits. Logging. If everything seems a bit sluggish, check to make sure logging is turned off. TDSDUMP should not be defined, and there should be no dump file mentioned in &freetdsconf;. You can double-check by setting TDSDUMPCONFIG temporarily, which will log only the startup process. DNS. If connecting to the server takes 30 seconds or 1 minute, you could do worse than to check your resolv.conf. Use host or nslookup to confirm that &freetds; can actually resolve the name/address you provided in &freetdsconf;. Packet size. The default packet size setting in &freetdsconf; (see initial block size) is usually fine. Slowness can potentially be due to multiple packet to use. Under GNU/Linux system we use an optimization to reduce network traffic; you shouldn't see much difference using this system. Getting Help Beatles Help me if you can, I'm feeling down And I do appreciate you being 'round. Help me get my feet back on the ground, Won't you please, please help me? In the battle against frustration and wasted motion, this manual is our first defense. Our documentation is intended to make it possible for a knowledgeable user to, well, use &freetds; without further assistance. We strive to include all known features and behaviors here, so you can work quickly and anonymously, and go home before 5:00. Would that it were always thus. Reconfirm the installation For initial setup and login problems, review . Distinguish between network and server issues, between finding the server and logging into it. The TDSDUMPCONFIG log will show how the servername is being looked up, what address & port is being used, what TDS version is being used. The TDSDUMP log will show quite clearly whether or not the server accepted the connection, and whether or not the login succeeded. Remember compiled-in defaults can be displayed with tsql: $ tsql -C Compile-time settings (established with the "configure" script) Version: freetds v0.&version; freetds.conf directory: /usr/local/etc MS db-lib source compatibility: no Sybase binary compatibility: no Thread safety: yes iconv library: no TDS version: 7.0 iODBC: no unixodbc: no SSPI "trusted" logins: no Keberos: no For &odbc; setup issues, the osql script is intended to confirm the configuration files are all sane. If it fails to report a problem, please post a message describing the problem to the mailing list. Thanks. Isolate the cause Successful problem isolation will yield earliest resolution. You (believe it or not) have more information about your environment than anyone else does, and have the greatest motivation to solve your problem. The resources at your disposal will be much more useful if the problem is specific. (Sorry if this is obvious. If it is, you might be surprised how often it's not.) If you can demonstrate the problem with tsql or sqsh, you can expect a quick answer to your question, possibly even a fairly quick fix. (It has happened several times in the last few years that bug reports to small problems were fixed the same day. On a few occasions, new functions were added in a few days. Making &freetds; useful and bugless is the goal of the project, after all.) &freetds; being what it is, problems frequently arise amidst complex environments. It can be hard for both you and the list participants — who are your allies and best resource — to determine what's going wrong. If you can submit a script that they can use to try to reproduce your results, you have a much better chance of happy resolution. On the plus side, the list includes people with a variety of backgrounds, who frequently answer questions that aren't really about &freetds; per se. Clear questions have sometimes even led to submitting patches to other projects. Try a different client</> <para>&freetds; comes with its own utilities that use the various libraries. It's a good idea to run your query through one of them — the one that uses the same API you're using — to see if it produces the same behavior you're seeing. That helps eliminate your application (and the rest of the calling hierarchy) as a source of the problem.</para> </sect2> <sect2 id="help.permissions"> <title>Check permissions If your query works in tsql but not with Apache, make sure the account running Apache can find and read freetds.conf. Also consider security settings like firewalls, SELinux/AppArmor or similars. The Mailing List 3 Henry VI, I, ii, approximately In them I trust; for they are [hackers] Witty, courteous, liberal, full of spirit. The Archive The &freetds; mailing list archive is a good place to start. It is searchable. It should be considered the most up to date (and least edited) source of information. New developments between releases tend not to be announced on the website. The website is updated only intermittently, when we post a new release or &freetds; is somehow in the news, say. If you found a bug or need a feature, you may find it was announced/discussed/fixed by perusing the archive. Ask the list Many of the original authors and anyone maintaining or extending the code reads the list. The traffic tends to be bursty. It usually focuses on build problems and troubleshooting. Again, the more specific your question, the sooner you'll get a useful reply (if it comes). Please, do not email the authors directly. You may well be ignored because they're they type that gets a ton of mail. Anyone willing to address your question reads the list, and you don't want to offend anyone willing to help you by going about it the wrong way. What to include when asking for help Waddya got? It's important to convey your setup and configuration. SQL Server version &freetds; version (or snapshot date, if not a release) any options used with configure which client library you are using what language or Perl module, as appropriate, you're using your client OS and hardware architecture Attach a logfile If you're puzzled by some interaction with the server (often the case), it's a very good idea to set TDSDUMP and attach the log to your message. Messages are currently limited to 75 KB attachments, and the logs are quite detailed, so make your query as short as possible. If necessary, trim the log; gzip is also your friend here. It's always a good idea to post it on a website where people can fetch it if they're so inclined. Log files are especially important if you're not programming at the C level. Sometimes there are problems — an impedance mismatch, to coin a phrase — between &freetds; and the calling framework/language. But if you write to the list and say Why does my PHP foo() returns an empty string?, please keep in mind that your question might as well be in Urdu to someone familiar with the C library. Without knowing which C function was called, and with what data, it's impossible to even begin to try to answer the question. Think about it this way: If you attach a log no one reads, you wasted some bandwidth. If you don't attach one and someone asks you for it, you wasted a day. Like that. Show your work Great questions make the problem crystal clear to a tired developer after supper. Show what you did, and show what happened. Throughout this User Guide, you've seen examples of screenshots; in each case the first line was the command entered, followed by the machine's response. By showing verbatim what you did and saw, you give someone who knows what to do a chance to look over your shoulder. Across the Internet! How cool is that? Whether you're having a problem with your own application or with something at a higher level, you're well advised to try to reproduce it using one of the &freetds; utilities, preferably one that used the same client library you're using. If, say, bsqldb works and your program doesn't, that's a clue. By the same token, if bsqldb exhibits problems, too, chances are you found a bug. Or — how to say it? — a missing feature. It's always good to know about those. Helping Bertrand Russell The time you enjoy wasting is not wasted time. &freetds; is a cooperative, volunteer effort. Flame wars on the list are unknown and the signal to noise ratio is pretty high for its venue. Many people have contributed patches, and few have been turned away. Pick a weak spot and fix it. We don't have enough non-English speakers to test our character set conversion features. Anyone willing to participate in that way would be most welcome. Canonical examples of using the each library would be very helpful to newcomers. An isql Perl and PHP would all make debugging and testing easier for everyone. Send a patch Good patches are nearly always applied in short order. Patches uploaded to SourceForge trigger automatic notification to the &freetds; mailing list. Correct this User Guide Any corrections or suggestions, be they typographical, grammatical, structural, factual, or mineral are most welcome. Please send it to the &freetds; mailing list. The User Guide is maintained in SGML DocBook format; the file in your distibution is doc/userguide.sgml. It is a flat ASCII file that you can edit with any text editor. You don't have to know SGML to correct or add to the User Guide, however. Just open it up, find the place you're interested in, and type away. Do a diff -u old_version your_version and post your patch to the SourceForge site. Any errors or lackings in your markup will be graciously emended by yours truly. Document an <acronym>API</> We have just begun an independent reference manual to &freetds;; the main API documents are the work of the server vendors. We're using Doxygen, which extracts documentation directly from comments in the source code, and we're maybe 25% done. The TDS protocol is partly documented, as are the APIs to libtds and &dblib;, but much remains. Be the Webmaster The FAQ and in particular the news don't get updated often enough. If that's your thing, drop a line to the &freetds; mailing list. Light another's taper Every question you answer on the mailing list will save someone time and, if done well, will actually improve your own knowledge. The project's developers will often answer technical questions that require substantial understanding of the code or suggest a possible bug. Setup issues, though — connecting and logging in to the server, getting Apache going — are questions many experienced users can and do answer, thereby fostering the community on which the project depends. Your experience may well be more closely aligned with the question posed than that of anyone else reading the list that day. You may use that framework or language or OS, or have that particular server. No one, no matter how expert in the code, has used every configuration, version, OS, compiler, etc. Whether you simply confirm there's a problem in some particular arrangement, or say, dunno, works for me, you're adding information. Ambitious ideas If you want to get your hands really dirty, here are some big ideas to contemplate. <literal>libtds2</literal> After many years developing &freetds;, we've learned quite a bit about the protocol and how to write database libraries. Unfortunately, though, one of the things holding us back — and, obviously hampering the project — is the underlying utility library. This wouldn't be a from-scratch effort; most of the code is already written. What's needed is a more uniform API that better reflects the TDS protocol, and that does not attempt character set conversions immediately on receipt of the data. <literal>libstddb</literal> This would be a new client library modelled after stdio, a project to demonstrate what database programming should be like. Server code &freetds; includes a little stub of a server, but it could be much more useful. One idea would be to make it a front-end to SQLite, thereby creating for the first time a TDS client & server pair composed entirely of free software. Advocacy Out of ten people you know, it's a fair bet 10 never heard of &freetds; and nine don't understand the problem it solves. Lots of places have begun to use Microsoft SQL Servers in all sorts of ways, and if you adhere to the Microsoft line, there's only one way to connect to them: from a Microsoft OS. What can &freetds; do that can't be done any other way? Glad you asked. &freetds; can Connect to every version of either vendor's server, using the same binaries. Provide a &ctlib; for Microsoft SQL Server. This feature alone allows DBD::Sybase and sqsh, among others, to connect to Microsoft's product. Provide a modern &dblib; for Microsoft SQL Server: Win32/64, and TDS 7+. Provide a bcp-capable interface and command-line utility on unix-like operating systems for Microsoft SQL Server. Run on many more operating systems than either vendor's libraries do. Get fixed, instead of telling you to get stuffed. Amuse and inform. Also frustrate and infuriate, but we don't put that under Advocacy. If more people knew, fewer would be stuck. Programming TDS protocol reference Can be found on www.freetds.org API Reference Manual The reference manual is installed as part of &freetds;. It can be regenerated at any time using Doxygen with cd doc; make doc. The reference manual is a work in progress: only &dblib; is completely documented, and quite minimally at that. Should you find it inadequate, you may be interested to learn it's not hard to add to, technically. Doxygen generates a manual from encoded comments in the source code. Its markup syntax is not hard to learn. You can read more about it at the Doxygen website. Basic API coverage information for the db-lib, ct-lib, and ODBC client libraries is maintained in doc/api_status.txt, included in the source distribution. For your convenience and enjoyment, we include that file in the following sections. In each table, we note for the function Sybase and Microsoft sometimes use slightly different names for the same function. It is the intention of the the extent to which it is implemented. The Status field may be: &dblib; API function status domain (blank) Function is not implemented. stub Function is implemented as a stub. Some such functions return SUCCEED even though they have no effect, to satisfy upper layers. Partial Function is partly implemented. We haven't dealt with every possible option, for instance. OK Function is implemented. Completely, we claim. &dblib; API Implementation Summary Microsoft's version of &dblib; is online. Sybase's is both online and can be downloaded as a PDF file. Links such as these are quite perishable. Should you find them broken, please check the &freetds; User Guide posted on our website. If it's out of date, please let us know, so we can correct it. Thanks. &dblibapisgml; ct-lib API Implementation Summary Sybase ct-lib documentation can be found online and in PDF form. Links such as these are quite perishable. Should you find them broken, please check the &freetds; User Guide posted on our website. If it's out of date, please let us know, so we can correct it. Thanks. &ctlibapisgml; ODBC API Implementation Summary Microsoft's ODBC documentation is online. The functions are linked to the reference page on Microsoft's website. Links such as these are quite perishable. Should you find them broken, please check the &freetds; User Guide posted on our website. If it's out of date, please let us know, so we can correct it. Thanks. &odbcapisgml; DB-Library for the Tenderfoot Mark Twain Few things are harder to put up with than the annoyance of a good example. Below is a complete working &dblib; program, presented as a series of examples. Features of sample code Processes command-line options to select the server, database, username, and password Remaining arguments on the command line comprise the SQL query to execute Installs error and message handlers Illustrates correct row-processing Illustrates correct error detection and handling Other sample code may be found in the distribution, in the cleverly named samples directory. A complete program, heavily commented for your perusal, is apps/bsqldb.c. What's the big deal with errors? Correct handling of errors is extremely important in database applications because they involve two systems most others don't: the network and the database server. Both can give rise to errors that, if not detected and reported when they occur, let the application proceed blithely on until something truly mysterious happens. In the worst case, in the absence of a properly reported error, the application may seem to have updated the data, when in fact it did not. Every &dblib; application uses the network, making it subject to network failures. Database programs also almost always have very high data integrity requirements. It is necessary to know the row was absolutely, positively committed, once and only once, without error or exception. Without taking great care to trap and handle all error conditions, no statement about the program's reliability can be made with confidence. How to Get and Build the sample code Run doc/grep_sample_code to extract the C code from the User Guide SGML source. Compile Link Files Required to Build the Sample Code sybfront.h sybdb.h libsybdb.a or libsybdb.so Your library's extension may vary according to your operating system. The source code may be built with commands similar to these. The precise options and paths depend on your particular system. The commands below work with the GNU compiler and linker on an ELF system with dynamic linking, common on Linux and BSD systems. Building the Sample Code $ ../doc/grep_sample_code ../doc/userguide.sgml > sample.c $ cc -I /usr/local/include -Wl,-L/usr/local/lib -Wl,-R/usr/local/lib sample.c -lsybdb -o sample where /usr/local/include and /usr/local/lib are respectively the locations of your header files and libraries. We now proceed to the code proper. Header files We need two header files to use &dblib;. We need a few others to deal with I/O in C, as you know. Also declare the error and message handler functions, more about which later. Sample Code: &dblib; header files #include #include #include #include #include #include ]]> #include <sybfront.h> /* sybfront.h always comes first */ #include <sybdb.h> /* sybdb.h is the only other file you need */ int err_handler(DBPROCESS*, int, int, int, char*, char*); int msg_handler(DBPROCESS*, DBINT, int, int, char*, char*, char*, int); Prolog Nothing special here. Collect the command line parameters. We do this with the standard getopts(3) function. Cf. man 3 getopts for details. Sample Code: &dblib; prolog extern char *optarg; extern int optind; const static char syntax[] = "syntax: example -S server -D db -U user -P passwd\n"; struct { char *appname, *servername, *dbname, *username, *password; } options = {0,0,0,0,0}; int main(int argc, char *argv[]) { int i, ch; LOGINREC *login; DBPROCESS *dbproc; RETCODE erc; options.appname = basename(argv[0]); while ((ch = getopt(argc, argv, "U:P:S:D:")) != -1) { switch (ch) { case 'S': options.servername = strdup(optarg); break; case 'D': options.dbname = strdup(optarg); break; case 'U': options.username = strdup(optarg); break; case 'P': options.password = strdup(optarg); break; case '?': default: fprintf(stderr, syntax); exit(1); } } argc -= optind; argv += optind; if (! (options.servername && options.username && options.password)) { fprintf(stderr, syntax); exit(1); } Prolog Notes LOGINREC is a structure that describes the client. It's passed to the server at connect time. DBPROCESS is a structure that describes the connection. It is returned by dbopen(). RETCODE is the most common return code type for &dblib; functions. Initialize Initialize the library. Create and populate a LOGINREC record. Sample Code: &dblib; Initialize if (dbinit() == FAIL) { fprintf(stderr, "%s:%d: dbinit() failed\n", options.appname, __LINE__); exit(1); } dberrhandle(err_handler); dbmsghandle(msg_handler); if ((login = dblogin()) == NULL) { fprintf(stderr, "%s:%d: unable to allocate login structure\n", options.appname, __LINE__); exit(1); } DBSETLUSER(login, options.username); DBSETLPWD(login, options.password); Initialization Notes Always make dbinit() the first &dblib; call. Install the error- and mesage-handlers right away. They're explained in more detail later. dblogin() almost never fails. But check! No point in trying to use a null pointer. The LOGIN record isn't directly accessible. It's populated via macros like these. There are other fields, but these two are essential. Look for SETLsomething in the documentation. Connect to the server dbopen() forms a connection with the server. We pass our LOGINREC pointer (which describes the client end), and the name of the server. Then, optionally, we change to our favored database. If that step is skipped, the user lands in his default database. Sample Code: &dblib; Connect to the server if ((dbproc = dbopen(login, options.servername)) == NULL) { fprintf(stderr, "%s:%d: unable to connect to %s as %s\n", options.appname, __LINE__, options.servername, options.username); exit(1); } if (options.dbname && (erc = dbuse(dbproc, options.dbname)) == FAIL) { fprintf(stderr, "%s:%d: unable to use to database %s\n", options.appname, __LINE__, options.dbname); exit(1); } Send a query &dblib; maintains a command buffer to hold the SQL to be sent to the server. Two functions — dbcmd() and dbfcmd() — build up the query from strings of text. The command buffer is reset after the query is sent to the server. We left the SQL on the command line. We fetch it now and send it to the server. Sample Code: &dblib; Send a query for (i=0; i < argc; i++) { assert(argv[i]); printf("%s ", argv[i]); if ((erc = dbfcmd(dbproc, "%s ", argv[i])) == FAIL) { fprintf(stderr, "%s:%d: dbcmd() failed\n", options.appname, __LINE__); exit(1); } } printf("\n"); if ((erc = dbsqlexec(dbproc)) == FAIL) { fprintf(stderr, "%s:%d: dbsqlexec() failed\n", options.appname, __LINE__); exit(1); } Initialization Notes Failure at this juncture is rare. The library is merely allocating memory to hold the SQL. dbsqlexec() waits for the server to execute the query. Depending on the complexity of the query, that may take a while. dbsqlexec() will fail if something is grossly wrong with the query, e.g. incorrect syntax or a reference to nonexistent table. It's only the first of a few places where an error can crop up in processing the query, though. Just because dbsqlexec() succeeded doesn't mean you're in the clear. Fetch Results A query may produce zero, one, or more results. The application normally provides buffers to &dblib; to fill, and iterates over the results a row (and column) at a time. Kinds of Results Results is a special term: it means more than rows or no rows. To process the results means to gather the data returned by the server into the application's variables. Kinds of Results Type Metadata Regular Rows Compute Rows Return Status Example SQL None None None None None Any INSERT, UPDATE, or DELETE statement Empty 1 set None 0 or more None SELECT name FROM systypes WHERE 0 = 1 Simple 1 set 0 or more None None SELECT name FROM sysobjects Complex 2 or more 0 or more 1 or more None SELECT name FROM sysobjects COMPUTE COUNT(name) Stored Procedure 0 or more 0 or more 0 or more 1 or more EXEC sp_help sysobjects
As the above table shows, results can comprise ordinary rows and compute rows (resulting from a COMPUTE clause). Stored procedures may of course contain multiple SQL statements, some of which may be SELECT statements and might include COMPUTE clauses. In addition, they generate a return status (with a RETURN statement or else automatically) and perhaps OUTPUT parameters. Data and Metadata Observe that a row is set of columns, and each column has attributes such as type and size. The column attributes of a row are collectively known as metadata. The server always returns metadata before any data (even for a SELECT statement that produced no rows). Result-fetching functions Function Fetches Returns Comment dbresults() metadata SUCCEED, FAIL or, NO_MORE_RESULTS. SUCCEED indicates just that: the query executed successfully (whew!). There may be metadata (and perhaps data) and/or stored procedure outputs available. dbnextrow() data REG_ROW, compute_id, NO_MORE_ROWS, BUF_FULL, or FAIL. Places fetched data into bound columns, if any.
Binding Each time dbresults() returns SUCCEED, there is something to retrieve. &dblib; has different functions to deal with the different kinds of results. The functions are of two kinds: those that convert the data into a form desired by the application, known as binding, and those that return the data in native form. To understand binding, it may be easiest to examine two primitive functions, dbdata() and dbconvert(). dbdata() returns a pointer to the column's data. The data to which it points are in native form, 4 bytes for an INT, 8 bytes for a DATETIME and so on. dbconvert() converts between datatypes; you can hand it an integer and get back a character array (or a C double. You might think of dbconvert() as atoi(3) on steroids). dbbind() combines these two functions. The application indicates in what form it would like to use each column, and the library converts them on the fly as each row is read. To bind a column is to provide a buffer to &dblib; for it to fill, and indicate which datatype the buffer is meant to hold. This is the sort of thing C++'s type system does so much better It may be well to pause here to observe the three ways a datatype is described in a &dblib; program. &dblib; Datatype Descriptors Sever Datatype Describes the data as an abstract type, not representing any particular kind of storage. SYBREAL, for example, doesn't imply any particular arrangement of bits; it just means a floating-point datatype corresponding to the T-SQL REAL type on the server. These all begin with SYB, e.g. SYBINT4. Program Variable Datatype Defines a C variable in a machine-independent way. Because a C defines its int type according the CPU architecture, it may have 2, 4, 8, or some other number of bytes. A DBINT on the other hand, is guaranteed to be 4 bytes and, as such, assuredly will hold any value returned by the server from a T-SQL INT column. These all begin with DB, e.g. DBREAL. Bind Type Prescribes a conversion operation. Indicates to dbbind() the Program Variable Datatype defined by the target buffer. Sybase and Microsoft call this the vartype. These all end with BIND, e.g. STRINGBIND. Typically it's convenient to have &dblib; convert the data into the desired form. The function that does that is dbind(). So: after fetching the metadata, and before fetching the data, we usually prepare the bound columns. Fetching Data Data-fetching functions Type Regular rows Compute rows Return status OUTPUT parameters Meta dbnumcols() dbnumcompute(), dbnumalts(), dbaltop(), dbbylist() dbhasretstatus() dbnumrets() Binding dbbind(), dbnullbind() dbaltbind(), dbanullbind() dbretstatus() none Native dbdatlen(), dbdata() dbadlen(), dbalttype(), dbaltutype(), dbaltlen(), dbadata() none dbretdata(), dbretlen(), dbretname(), dbrettype()
The paradigm may now perhaps be clear: Query, fetch results, bind columns, fetch regular rows, fetch compute rows, fetch stored procedure outputs. Repeat as necessary. Putting it all together Step Function Once Per Many Times Per Query dbsqlexec() Query Program Fetch metadata dbresults() SQL statement Query Prepare variables dbbind() Column Statement Fetch regular data dbnextrow() Row Statement Fetch compute data dbnextrow() Compute column Statement Fetch output parameters dbretdata() output parameter Stored procedure Fetch return status dbretstatus() Stored procedure Program
Fetch All Rows! &dblib; doesn't insist every column — or even any column — be bound or otherwise retrieved into the application's variables. There is, however, one absolutely crucial, inflexible, unalterable requirement: the application must process all rows produced by the query. Before the DBPROCESS can be used for another query, the application must either fetch all rows, or cancel the results and receive an acknowledgement from the server. Cancelling is beyond the scope of this document, so for now fetch all rows. Now, at last, some sample code that fetches data. In the interest of simplicity, we don't bind anything except regular rows. Sample Code: &dblib; Fetch Results while ((erc = dbresults(dbproc)) != NO_MORE_RESULTS) { struct COL { char *name; char *buffer; int type, size, status; } *columns, *pcol; int ncols; int row_code; if (erc == FAIL) { fprintf(stderr, "%s:%d: dbresults failed\n", options.appname, __LINE__); exit(1); } ncols = dbnumcols(dbproc); if ((columns = calloc(ncols, sizeof(struct COL))) == NULL) { perror(NULL); exit(1); } /* * Read metadata and bind. */ for (pcol = columns; pcol - columns < ncols; pcol++) { int c = pcol - columns + 1; pcol->name = dbcolname(dbproc, c); pcol->type = dbcoltype(dbproc, c); pcol->size = dbcollen(dbproc, c); if (SYBCHAR != pcol->type) { pcol->size = dbprcollen(dbproc, c); if (pcol->size > 255) pcol->size = 255; } printf("%*s ", pcol->size, pcol->name); if ((pcol->buffer = calloc(1, pcol->size + 1)) == NULL){ perror(NULL); exit(1); } erc = dbbind(dbproc, c, NTBSTRINGBIND, pcol->size+1, (BYTE*)pcol->buffer); if (erc == FAIL) { fprintf(stderr, "%s:%d: dbbind(%d) failed\n", options.appname, __LINE__, c); exit(1); } status);]]> if (erc == FAIL) { fprintf(stderr, "%s:%d: dbnullbind(%d) failed\n", options.appname, __LINE__, c); exit(1); } } printf("\n"); /* * Print the data to stdout. */ while ((row_code = dbnextrow(dbproc)) != NO_MORE_ROWS){ switch (row_code) { case REG_ROW: for (pcol=columns; pcol - columns < ncols; pcol++) { char *buffer = pcol->status == -1? "NULL" : pcol->buffer; printf("%*s ", pcol->size, buffer); } printf("\n"); break; case BUF_FULL: assert(row_code != BUF_FULL); break; case FAIL: fprintf(stderr, "%s:%d: dbresults failed\n", options.appname, __LINE__); exit(1); break; default: printf("Data for computeid %d ignored\n", row_code); } } /* free metadata and data buffers */ for (pcol=columns; pcol - columns < ncols; pcol++) { free(pcol->buffer); } free(columns); /* * Get row count, if available. */ if (DBCOUNT(dbproc) > -1) fprintf(stderr, "%d rows affected\n", DBCOUNT(dbproc)); /* * Check return status */ if (dbhasretstat(dbproc) == TRUE) { printf("Procedure returned %d\n", dbretstatus(dbproc)); } } dbclose(dbproc); dbexit(); exit(0); } Data-fetching Notes As soon as dbresults() reports SUCCESS, the row's metadata are available. &dblib; columns start with 1. dbcollen() returns the sizeof the native data (e.g. 4 bytes for a T-SQL INT). We'll use dbbind() to convert everything to strings. If the column is [VAR]CHAR, we want the column's defined size, otherwise we want its maximum size when represented as a string. NTBSTRINGBIND null-terminates the character array for us. NTB might perhaps stand for null terminating byte. A zero-length string is not a NULL! dbnullbind() arranges for the passed buffer to be set to -1 whenever that column is NULL for a particular row. Each time dbnextrow() returns REG_ROW, it has filled the bound buffers with the converted values for the row. Computed rows are left as an exercise to the reader.
Messages and Errors Errors may originate on the server or in the library itself. The former are known as messages (because they are: they arrive as messages from the server); the latter are termed errors. Their handling is a little intimidating. It requires writing and installing a callback function (whose parameters are predefined by &dblib;), and thinking about how to handle different types of errors. Kinds of Errors Messages Messages arise because the server has something to say. Just one more way in which databases differ from files.. They usually describe some problem encountered executing the SQL. Perhaps the SQL refers to a nonexistent object or attempted to violate a constraint. But they can also be benign, indicating for instance merely that the default database has changed. Errors Errors arise either because the application has misused &dblib; in some way — say, passed a NULL DBPROCESS pointer or tried to issue a query while results were pending — or because some trouble cropped up in communicating with the server (couldn't find it, say, or didn't hear back from it). Why these two require distinct handling is lost in the mists of time. But it does help to keep them distinct in your mind, especially while reading the documentation. To have &dblib; use your handler, pass its name to the appropriate dberrhandle() or dbmsghandle() function immediately after calling dbinit(). Sample Code: &dblib; Error and Message handlers int msg_handler(DBPROCESS *dbproc, DBINT msgno, int msgstate, int severity, char *msgtext, char *srvname, char *procname, int line) { enum {changed_database = 5701, changed_language = 5703 }; if (msgno == changed_database || msgno == changed_language) return 0; if (msgno > 0) { fprintf(stderr, "Msg %ld, Level %d, State %d\n", (long) msgno, severity, msgstate); if (strlen(srvname) > 0) fprintf(stderr, "Server '%s', ", srvname); if (strlen(procname) > 0) fprintf(stderr, "Procedure '%s', ", procname); if (line > 0) fprintf(stderr, "Line %d", line); fprintf(stderr, "\n\t"); } fprintf(stderr, "%s\n", msgtext); if (severity > 10) { fprintf(stderr, "%s: error: severity %d > 10, exiting\n", options.appname, severity); exit(severity); } return 0; } int err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr) { if (dberr) { fprintf(stderr, "%s: Msg %d, Level %d\n", options.appname, dberr, severity); fprintf(stderr, "%s\n\n", dberrstr); } else { fprintf(stderr, "%s: DB-LIBRARY error:\n\t", options.appname); fprintf(stderr, "%s\n", dberrstr); } return INT_CANCEL; } Handlers are always called before the function that engendered them returns control to the application. Error Handling Notes When first writing a handler, pay careful attention to the precise type of each parameter. Only by carefully matching them will you convince a modern C compiler that the address of your function is of the type accepted by dbmsghandle(). Back in K&R days, that wasn't such a problem. But there were other problems, some much worse. Some messages don't convey much, as though the server gets lonely sometimes. You're not obliged to print every one. Severities are defined in the server documentation, and can be set by the T-SQL RAISERROR statement. Message handlers always and only ever return zero. When first writing the handler, pay careful attention to the precise type of each parameter. Only by carefully matching them will you convince a modern C compiler that the address of your function is of the type accepted by dberrhandle(). If that advice sounds familiar, it's because it bears repeating. Some messages are so severe they provoke &dblib; into calling the error handler, too! If you have both installed — and of course you do, right? — then you can skip those lacking an error number. While INT_CANCEL is the most common return code, it's not the only one. For one thing, the error handler's return code can control how long &dblib; keeps retrying timeout errors. See the documentation for details. No matter what the error handler says or does, it can't remedy the error. It's still an error and usually the best that can happen is that the function will return FAIL. The exception is timeout conditions, when the handler can stave off failure by requesting retries. You may be asking yourself, OK, fine, I can print the error message. But what if I want to communicate something back to the line in my program where the error occurred? How to do that? First of all, remember the calling function — that's your application — will learn of an error from the return code. If it needs more detail, though, there are two ways to pass it. Set a global variable. Use setuserdata() and getuserdata(). If your application is written in C++, you may be tempted to use throw(). Don't! Your handler is a C function and, more important, it's an extension of &dblib;. You can put a throw() in your handler and it will compile. But when it executes, it's going to rip through &dblib;'s stack. Your application will be unuseable at that point, if it doesn't cause a segment fault. Last Remarks We've reached the end of our &dblib; tour. The almost 300 lines of C above constitute program with these features: Sample Code features</> <listitem><para>Accepts command-line parameters and SQL.</para></listitem> <listitem><para>Checks for errors and server messages.</para></listitem> <listitem><para>Processes any number of results..</para></listitem> <listitem><para>Prints results in columns of suitable widths.</para></listitem> </itemizedlist> There are things it doesn't do, in the name of simplicity. <itemizedlist><title> Sample Code nonfeatures</> <listitem><para>No BCP (bulk copy) mode</para></listitem> <listitem><para>No RPC (remote procedure call) mode, preventing it from retrieving output parameters.</para></listitem> </itemizedlist> Your humble author hopes you found it worthwhile. Happy Hacking.</para> </sect2> </sect1> </chapter> <!-- ////////////////// CHAPTER /////////////////////// --> <chapter id="acknowledgments"> <title>Acknowledgments Codesmyths Many people, too many to mention, have contributed patches and located bugs. The primary names are: Brian Bruns (brian@bruns.org) Started this crazy thing Mihai Ibanescu (misa@dntis.ro) GNUified the packet Gregg Jensen (greggj@savvis.com) Message handlers and extra datatype support and some sybperl stuff James K. Lowden (jklowden@schemamania.org) Wrote most of the documentation. Helped out here and there. Steve Murphree (smurph@smcomp.com) Added more ODBC functionality. Arno Pedusaar (psaar@fenar.ee) Donated his TDS4.2 code to the cause Mark Schaal (mark@champ.tstonramp.com) Cleaned up message handling, more datatype support, bug fixes Craig Spannring (cts@internetcds.com) Wrote the JDBC and DBI drivers Bill Thompson (thompbil@exchange.uk.ml.com) Completer of the &dblib; bcp API and author of freebcp. Frediano Ziglio (freddy77@gmail.com) Extended the ODBC library, and added many, many fixes and enhancements to libtds. Contributors This user guide owes at least 100 words each to the following people. Brian Bruns James Cameron Allen Grace James K. Lowden Bill Thompson Frediano Ziglio
On Linkers &freetds; is a library, obviously, its functions invoked by an application. How the application finds the library can be mysterious. In the interest of making &freetds; easier to use, this appendix discusses how it all works. This appendix focusses on using &freetds; in your application. It isn't intended to help in building &freetds;, although the background information it provides might be useful.
What is a C function? A C function is a named bit of code. A C compiler recognizes function names in source code by parsing the C language. When it encounters a function name, it looks for a definition for the function — i.e. actual code implementing it — in the current file. If it finds one, it creates machine instructions to push any parameters on the stack, jump to the named address, and clear the stack after the functions returns. If it doesn't find one, it shrugsYou have to watch carefully. Modern compilers shrug quickly. and adds that name to the list of names to be resolved later. We'll get to what that means in a minute. The compiler's job ends where the linker's begins. Compiler's job Convert source code into object code Put in jumps to defined functions Create a list of defined functions, and their addresses Create a list of undefined functions The nm utility displays function names. Here are the ones defined by bsqldb.c (in bsqsldb.o): $ nm bsqldb.o | grep -wi t 0000000000000000 T err_handler 0000000000000270 T get_login 00000000000001d0 t get_printable_size 0000000000000940 T main 00000000000000a0 T msg_handler 00000000000007d0 t next_query 00000000000006c0 t set_format_string 0000000000000080 t usage GNU nm marks with a lower-case letter functions that are locally defined, not intended to be used outside the file. The C programmer marked those functions static. Note how closely the source code corresponds to the object code: $ grep ^static src/bsqldb.c static int next_query(DBPROCESS *dbproc); static void print_results(DBPROCESS *dbproc); static int get_printable_size(int type, int size); static void usage(const char invoked_as[]); static int set_format_string(struct METADATA * meta, const char separator[]); (Order doesn't matter. It's a set, not a list.) Here are some functions used, but not defined, by bsqldb.o: $ nm bsqldb.o | grep -w U | head U __assert_fail U __ctype_b_loc U __errno_location U __strdup U __xpg_basename U asprintf U calloc U dbaltbind U dbaltcolid U dbaltlen Two things to note. First, the functions defined by bsqldb.o have addresses, and undefined functions don't. Second, only the name identifies the function. It's been that way since about 1978, and it's one reason C libraries are so useful: to find a function, the tool need only resolve the name, i.e. convert the name into an address. The caller (the programmer, really) has to know the function's inputs and semantics (how it behaves), but the tool's job is bone simple. Which turns out to be quite handy.
What is a C library? A C library is a set of named functions, for example dbinit() or SQLConnect(). Or, for that matter, fopen(3)The Unix convention is to put in parentheses behind the name the section of the manual in which the function is documented. &freetds; functions don't get numbers because they're not in the manual. Yet. . Libraries come in two flavors: static and dynamic.
Static libraries Static libraries (also known as archives) have been around as long as C itself. Like a .zip file, they're just a bag of object files — containing functions, of course — with a table of contents in front giving the address of each nameOr, depending on how you look at it, the name of each address.. Static libraries are created from object files using a librarian utility of some kind. One such programs is ar, for archive. Static libraries are part of the build environment. Functions in static libraries are joined to a program's main module by a static linker at build time to produce an executable program. The executable incorporates the libraries' object code into its own body, making it completely self-sufficient.
Dynamic libraries Dynamic libraries are the new kid on the block, as these things go, arriving on the Unix scene circa 1985. Like a static library, a dynamic library is a collection of functions with a table of contents. They are referenced at build time to give the executatble information about how they will eventually be used, but they aren't used until run time. Dynamic libraries are part of the run-time environment. When a program is run, the run-time linker finds the dynamic libraries needed by the program, finds the addresses of the required functions, and assembles a runable image in memory. Missing libraries and/or missing functions — or the wrong versions of them — can lead to head-scratching and other amusing behavior. In Windows® dynamic libraries are called dynamic link libraries (DLLs). In Unix they're normally called shared objects. But they're roughly the same thing. What about <literal>.h</literal> files? C header files include functional prototypes, declarations (not definitions) of functions. Functional prototypes describe to the compiler each function's parameters, allowing the compiler to confirm that the function is being called correctly. Most of the functions declared in header files are implemented in libraries. However, there's no mechanical or automatic relationship between the functional prototypes in the header files and their implementation in a library. The .h file is maintained by hand, by the programmer, and is used to generate a library. The header file and associated library are distributed and installed together (one hopes), but correct installation and subsequent use by the compiler & linker require human beings to keep track of the pair. Failure to do so leads to interesting development and even run-time problems, especially with libraries whose functions' parameters change from version to version. For example, imagine a function f(int g) defined in library libf.so and declared in f.h. In a later version of libf.so, the function's parameter is changed to use a pointer, f(int *p), and f.h is likewise updated. Possible errors that cannot be prevented by the linker include: An old program could use the new library. Probably the integer it passes will be interpreted as an out-of-bounds address, resulting in a segmentation violation. A new program could use the old library, passing an address that the library interprets as an integer. Hillarity ensues. Existing source code could be compiled using the old header file but linked to the new library. If you've never done that, give it time. These errors are possible because C functions are identified to the linker by name only. On the upside, that makes the tools simple and easy to implement and, by the same token, simplifies the use of C libraries by other languages. The downside is that the work of ensuring that the right libraries are used becomes an administrative task instead of a technical one.
Checking if a Library Provides a Function A linker, any linker, knits together object files (some of which may be in libraries) such that every function needed by the program has a definition. If the linker fails to locate a definition for even one function, it will fail and the program will not run. Returning to bsqldb.o, we can use nm to see which functions are unresolved, and determine whether or not a particular library contains them. We'll ignore the symbols that start with an underscore, marking them per the C standard as being provided by the implementationWhy and how leading underscores enter into this discussion is just one more example of arcane historical practices one needs to know to master the subject. For our purposes, though, it's enough to know that implementation-provided functions like these — functions provided by the C standard library — often have an underscored prepended. , and focus on the last five in this abbreviated list. Some unresolved functions in <filename>bsqldb.o</filename> asprintf basename Normally provided by the standard C library, but if not by &freetds;'s replacements library: $ nm /usr/lib/libc.a | grep -w T | grep -E 'asprintf|basename' 0000000000000000 T _basename 0000000000000000 T _asprintf calloc Provided by the standard C library: $ nm /usr/lib/libc.a | grep -w T | grep calloc 0000000000004240 T calloc dbaltbind dbaltcolid Provided by &dblib;: $ nm libsybdb.a | grep -Ew 'dbaltbind|dbaltcolid' 0000000000007140 T dbaltbind 0000000000003590 T dbaltcolid Although these examples refer to static libraries, nm works just as well with dynamic libraries, too. There are other tools besides nm. Windows®, for instance, has dumpbin, and the GNU bintools include objdump.
How Dost Thy Linker Link? Now at last we come to how the linker performs its magic. Once again the discussion divides between static and dynamic linking.
Static Linker Static linking happens at build time. Object files are collected together; a distinct list of all function names is created, and the linker is tasked with finding a definition for each one. Different linkers have different command-line options to support OS-specific features. This document isn't intended to teach how to use any particular linker. Our task here is to understand the principles involved, so that you can apply them to your particular situation. The static linker needs three kinds of information: Static linker inputs Object modules to be linked, including libraries Locations of libraries Search order
Knitting together the object modules The static linker merges your object files into one executable. Your project's object files may refer freely (usually) to each other's functions, and the linker will match them up. It will catenate them together, compute every function's offset from the start of the executable, and replace every function reference with the actual address needed for the executable it's constructing. For library functions, definitions are copied from the library and appended to the output file (executable). The placeholder addresses left by the compiler are similarly replaced by offsets.
Specifying libraries An application programmer using &freetds; will need to mention the name fo the &freetds; library being used. Failure to do so will provoke the dread undefined reference linker error: Missing library name $ gcc -o bsqldb bsqldb.o bsqldb.o: In function `get_login': ../../../src/apps/bsqldb.c:816: undefined reference to `dblogin' ../../../src/apps/bsqldb.c:823: undefined reference to `dbsetlname' ../../../src/apps/bsqldb.c:874: undefined reference to `dbsetlname' ../../../src/apps/bsqldb.c:884: undefined reference to `dbsetlname' ../../../src/apps/bsqldb.c:889: undefined reference to `dbsetlname' …
Finding libraries Specifying the library is necessary but may be insufficient. The linker may need to be told where to look for the library. This is often the case for the application programmer using &freetds; because the &freetds; libraries may be installed in a location not on the linker's default search path. Linkers are usually pretty blunt about missing libraries: Library not found $ gcc -o bsqldb bsqldb.o -l sybdb ld: cannot find -lsybdb Order matters. Linkers tend to be fussy about library search order, some more than others. It's good practice to tell the linker to search project libraries first, third-party libraries (e.g. iconv or kerberos) next, and finally system libraries.
Dynamic Linker The dynamic linker — also known as the runtime linker — is, like the rest of dynamic linking, more complicated than its static counterpart. Whereas it's impossible even to generate an executable with missing static function references, an executable that uses dynamic libraries depends on the runtime environment to have its references satisfied. When a dynamically linked application is launched, the OS invokes the runtime linker to resolve any undefined references. Much as the static linker does, the runtime linker consults a list of dynamic libraries along its configured search path. The names of the libraries to search for are embedded in the executable. Sometimes, not always, the search path is found in the executable too. Usually any embedded path can be overridden.
Information in the executable Exactly what information is in the executable and how to display it depends on the format of the executable. Different OSes use different formats and most Unix derivatives actually support at least two. The most commonly encountered format for the &freetds; programmer is the ELF format. In the interest of your time and mine, that's the one we'll examine here. The GNU bintool utility readelf displays the information in the executable that is input to the runtime linker: $ readelf -d src/apps/.libs/bsqldb Dynamic section at offset 0x6028 contains 20 entries: Tag Type Name/Value 0x0000000000000001 (NEEDED) Shared library: [libsybdb.so.5] 0x0000000000000001 (NEEDED) Shared library: [libpthread.so.0] 0x0000000000000001 (NEEDED) Shared library: [libc.so.12] 0x000000000000000f (RPATH) Library rpath: [/usr/pkg/lib:/usr/local/lib] … What is this telling us? First, the bsqldb executable uses three shared libraries, namely sybdb for &dblib;, pthread for POSIX threads, and c, the C standard library. The runtime linker is going to have to find those somewhere, and it's going to use only those libraries to resolve unresolved references in the executable. Second, readelf displays the RPATH. The runtime linker searches for the required dynamic libraries in the directories listed in the RPATH, if extant. The RPATH is placed in the executable by the static linker. It can be thought of as a hint from the application builder to the system administrator. If an executable is built with an appropriate RPATH, the runtine linker will have all the information it needs to find the required libraries.
Information outside the executable Runtime linkers differ. The advice and observations that follow apply in many situations, but not all. The best way to know how yours works is to consult your system's documentation. RTFM! The NetBSD and GNU linkers both (as of this writing on machines used by the author) honor a configuration file and environment variables. They also have compiled-in default search locations. At a minimum, the default is /usr/lib. Sometimes a configuration file extends this to /usr/local/lib. The primary environment variable is LD_LIBRARY_PATH. On some systems this overrides the RPATH in the executable. In others it doesn't. Where ineffective, specific libraries (not their paths) can be forceably used with LD_PRELOAD.
Displaying what the Runtime linker will do The ldd(1) shows which dynamic libraries an executable requires and where, if at all, they'll be found: $ ldd $(command -v bsqldb) /usr/local/bin/bsqldb: -lc.12 => /usr/lib/libc.so.12 -lpthread.0 => /usr/lib/libpthread.so.0 -lsybdb.5 => /usr/local/lib/libsybdb.so.5 Important to understand: ldd is not figuring out this information by itself. It just reports the results of its interrogation of the runtime linker. As the configuration of the runtime linker is changed, so changes the output of ldd.
A Word about Windows® Windows executables use PE format (derived from the older COFF format), which has no provision for an RPATH. The runtime linker searches the PATH instead, after some built-in locations that usually include the current working directory. Neither ldd nor any similar utility is included in the basic product. It has been said that Unix is for programmers and Windows is for users, and perhaps that roughly describes the intention. But the Unix features listed above — RPATH and ldd — as well as a canonical filesystem hierarchy and dynamic library versioning, all promote a better user experience. Because of them, the problem of DLL conflicts in Windows hardly exists in Unix. Yet they are neither new nor secrect nor patented nor complicated; Microsoft could have adopted them years ago (as Apple finally did). We therefore know that the 20-year old phenomemon known as “DLL hell” is not inevitable, but a choice signifying nothing so much as Microsoft's indifference to its customers. Recently Microsoft added support to configure different search paths and other attributes based on Application Manifests and Application Configuration Files.
Advice for the lazy To avoid tinkering with your runtime linker, embed an RPATH in your executable commensurate with its intended runtime environment. If ldd doesn't show the libraries you want, or some are not found, use readelf to see which libraries are used and the RPATH. Relink with a better RPATH if needed. When testing with new libraries, use LD_PRELOAD to override the default, taking care that the semantics haven't changed.
Keep in Mind The compiler's job ends on the last line of each source code file. A header file describes a function for the compiler, not the linker. The linker, static or runtime, uses only the function's name to resolve references. Function parameters and semantics are invisible to it. The programmer and, to a lesser degree, the sysadmin direct the choice of which library to link to an executable. A missing function will prevent execution. A wrong function will promote wrong execution. Don't do that.
The <filename>interfaces</filename> File The interfaces file is retained for compatibility with Sybase environments. It is recommended that new users use the freetds.conf format instead. Where it came from Under Sybase OpenClient there is a file called interfaces that defines servers available to the software. &freetds; inherited this file structure with minor alterations. The interfaces remains supported for backward compatibility, and for those running in a mixed &freetds;/Sybase environment. The interfaces is not read by &freetds; unless it does not find &freetdsconf;. Note also that make install will install a skeleton &freetdsconf;, which you'll have to remove if you want to use interfaces instead. Where it goes Anywhere. The SYBASE environment variable must contain the location of interfaces; that is how &freetds; will find it. By the way before looking for $SYBASE/interfaces file FreeTDS try to open file specified programmatically (for instance by dbsetifile() using &dblib;) and .interfaces in your home directory. What it does The interfaces file aliases a servername to the hostname and port number of the servername's machine. When &freetds; receives a request to connect to a database server, it looks up the servername in interfaces. There, it finds the machine name (or address) and port number to connect to, that is, the port where the database server is listening. How's that again? The interfaces file sometimes trips people up. It seems innocuous enough, but it's also a pretty good example of it's easy if you know how. Keep in mind: The servername is the name of the database server. When a database client specifies the name of the server to connect to, it's the servername that is used. The host name is the name of the host (machine) where the database server is running. It has an IP address, and in almost any environment, you can ping the machine name to see if you've got it right. After it uses the servername to look up the host name, &freetds; will do the same thing ping does to get the IP address of the machine to connect to. Finally, the port number is frequently overlooked. From the network's point of view, knowing the IP address without the port number is a little like knowing the address of an apartment building without knowing the apartment number. In both cases, it will be hard to find what you came for. Make sure you know the port number, and that it's correctly entered in the interfaces file. What it looks like The format of the interfaces file is borrowed directly from that used by Sybase on Unix platforms (Windows has a different format). Additionally, we have overloaded one of the fields to add the ability to set the protocol version. An example interfaces file looks like this. An <filename>interfaces</filename> file example myserver query tcp 4.2 127.0.0.1 4000 master tcp ether 127.0.0.1 4000 The entry starts with the servername beginning in the first column (no whitespace preceding it). Following the servername are one or more services lines which must be indented with whitespace. &freetds; uses only the query line, although others may be present to retain compatibility with Sybase. The fields in the services lines are as follows. Services Line Name Example Meaning service query The only supported service transport tcp The transport protocol to use. Only tcp is supported by &freetds;. physical 4.2 Historically this field referred the physical/datalink layer, however it appears to simply a comment field. Therefore, &freetds; optionally uses it to specify the protocol version to connect with. hostname/IP 127.0.0.1 The hostname or IP address where the SQL Server resides. port 4000 The TCP port where the SQL Server is listening.
In the example above, the hostname was entered as an IP address. It needn't be; it could just as well be a name. &freetds; can use a name rather than an address; it will just let the network (specifically, the resolver get the address.
About Unicode, UCS-2, and UTF-8 For better or worse, &freetds; brings the otherwise innocent programmer into contact with the arcane business of how data are stored and transported. &freetds; is a data communications library that of course connects to databases, which are charged with storing information in a way that is neutral to all architectures and languages. On the surface, that might not seem very complex, even worth discussing. Under the surface, things are not so simple.
<acronym>ASCII</>: What everyone knows The world we are all familiar with, programmingwise, is ASCII. Our email (mostly), our text files, our web pages (mostly), all use ASCII to represent English (or English-like) text. Perhaps because ASCII was standardized back in 1972 by the ISO, it seems like the natural way to store information. But let's look under the hood a little bit, and examine our assumptions. Our so-called text files are nothing special, nothing but a little agreement we enter into with our operating system. The only reason we can read them with cat or vi is that the operating system and its tools are in on the agreement. A file is only a stream of bytes, after all, no more text than an executable. The only thing distinguishing a text file from any other, is our understanding to treat it like one. We agree that the number 65 will represent the letter A, 66, B, and so on, 127 values in all. See man ascii for further details. The important thing to understand is that the designation of 65 for A and so on is a choice. It's an encoding standard, made necessary by the old simple fact that computers store numbers, not letters. ASCII is so ubiquitous these days that it's hard sometimes to remember there was a time when it was but one of a set of competing encoding standards. Others you probably have heard of include EBCDIC and the Baudot systems, but they are by no means the only historical alternatives, nor the only modern ones.
The <acronym>ASCII</> Compact UNIX® and unix-like systems bought into ASCII big time. Program code, filenames, string constants (and variables), configuration files, everything but everything is encoded in ASCII. Practically every utility, command, and library assumes the text data will be ASCII. At the dawn of the 21st century, there is widespread recognition that ASCII will no longer suffice, but the art of upgrading all the computers and computer programmers is, well, an unfinished work.
ISO 8859: What everyone would like to forget ASCII won, it would seem, but the race goes not to the swift. ASCII has many limitations, the most egregious of which is, it's not much good for anything besides English. It encodes all the letters and punctuation (almost) of the English alphabet, but is useless for German, Russian, and Greek, to say nothing of Chinese. ASCII assigns one byte to every character, but deals with only 7 of the 8 available bits, the range 0-127 (with the high bit always zero). Demand for computers that could display and print languages besides English — even English with em dashes and cent (¢) signs — arrived soon enough, with the Marketing Department way out in front of the propeller heads. The predictable result was an array of 8-bit ASCII encoding standards for a wide variety of alphabets. Eventually, they were standardized (or at least enumerated and documented) by the ISO. These are what our friendly database vendors are referring to when they talk about character sets. More information on this subject can be found at webreference.com. The upshot is, there is no uniform standard, no agreement on the meaning of a byte, particularly if that byte's value is greater than 127. Let's say your client machine sends HELLO and your database stores it as 72 69 76 76 79. When another client retrieves that value, it will convert it into human-readable form by applying an encoding standard. If everything's tightly wrapped, it will use the very same encoding that your database used (and the same one you had in mind when you sent it), and that client will also see HELLO. If things are not so tightly wrapped but that client is fortunate enough to be using a similar standard to what you were using, say, ISO 8859-1, he'll still see HELLO. Most languages based on the Roman alphabet can be represented by ISO 8859-1, and are thus interchangeable. Beyond that, things get quickly messy. Greek clients, for one, are not so lucky: there are three ISO 8859 standards for Greek, all mutually incompatible. For more information, see ISO 8859 Alphabet Soup. Roman Czyborra's site is very informative; take your time there if you don't want your head to spin. Database servers need to know what encoding standard to employ, too. It's not obvious at first, but notions like uppercase and lowercase, trailing blanks, and collation rules all depend on what letter is meant by what number. (Collation even depends on what culture is interpreting the letters.)
Unicode: East meets West ASCII and its 8-bit cousins are on the way out, and with them the assumption that a character can be represented by a single byte. The new kid on the block is Unicode, similar to but not precisely the same as ISO 10646. Unicode (despite its name) is a set of standards. The most widely implemented is the 16-bit form, called UCS-2. As you might guess, UCS-2 uses two bytes per character, allowing it to encode most characters of most languages. Because most is far from all, there are nascent 32-bit forms, too, but they are neither complete nor in common use. In the same sense that 7-bit ASCII was extended to 8 bits, Unicode extends the most prevalent 8-bit ASCII, ISO 8859-1, to 16 and 32 bits. The first 256 values remain in Unicode as in ISO 8859-1: 65 is still A, except instead of being 8 bits (0x40), it's 16 bits (0x0040). Unlike the 8-bit extensions, Unicode has a unique 1:1 map of numbers to characters, so no language context or character set name is needed to decode a Unicode string. UCS-2 was the initial system employed by Microsoft NT-based systems while recent versions moved to UTF-16. Microsoft database servers store UCS-2/UTF-16 strings in nchar and nvarchar datatypes. Microsoft also designed version 7.0 (and up) of the TDS protocol around UCS-2/UTF-16: all metadata (table names and such) are encoded according to these encoding on the wire.
Unicode's Pluses and Minuses You will read from time to time that Unicode is not perfect. Surprise, surprise: it's true. From a linguistic point of view, Unicode is incomplete; in particular, UCS-2 is demonstrably too small (!) to hold all the forms of Chinese ideographs used over the centuries. (It is, however, quite useful and widely employed in representing modern Chinese.) Of more common concern to programmers are Unicode's technical problems, or rather, Unix's technical shortcomings vis-a-vis any encoding more complex than ISO 8859-x. The basic problem, from a programmer's perspective, is the ancient agreement Unix entered into 30 years ago, the ASCII Compact, alluded to earlier. Assumptions about ASCII are littered throughout Unix-like systems, beginning with C's convention of representing strings as arrays of characters ending in a zero. Returning to our HELLO example earlier, C will store HELLO as 72 69 76 76 79 0, in very nice ASCII. Many many parts of the operating system and its associated tools and applications will recognize that as a 5-letter word because it's terminated by a null (zero). In UCS-2 Unicode, though, that same HELLO uses 2 bytes for every character and becomes 72 0 69 0 76 0 76 0 79 0 0 0. Practically the whole OS will think that's a 1-letter word, H. Not a good thing. Even if every OS were magically rid of all ASCII assumptions and C strings, there would still be the problem of Endianism. Technical explanations on the subject are not hard to find. The long and short of it is, given a 16-bit integer (2 bytes), different hardware architectures will store the value differently. Asked to store our friend A, (0x41), for instance, a Sparc processor will put the least significant byte at the higher address (00 41) whereas an Intel processor will put it in the lower address (41 00). Put aside the questions of left, right, and wrong; architectures are a fact of life. Endianism shows up wherever integers are stored and retrieved in heterogeneous environments. The Unicode folks knew about Endianism, of course, and had to address it. A Unicode bytestream is supposed to begin with a byte-order mark. Needless to say, perhaps, many don't.
Unicode Transformation Format: UTF-8 The presence of nulls embedded in character data and of byte order issues make straight Unicode i.e., UCS-2 or UCS-4 hard to work with in a heterogeneous environment. Too many opportunities arise for the data to be truncated or misinterpreted, and too many systems would fail even to transmit such data. In short, when 16-bit data are thrust into a multi-architecture 8-bit world, it frequently bodes ill for the data. To answer that problem, to make Unicode transmissible and unambiguous to most machines, several transformation formats were adopted. Their goals were generally similar: to create a generally recognized format that would unambiguously and safely convey Unicode information between machines and across the Internet. To do that, they sought to remove nulls and endianism from the data stream. The most popular one — practically the only one used — is known as UTF-8. UTF-8 found wide acceptance for many reasons. UTF-8 represents any Unicode character as a combination of 1-4 bytes. The number of bytes required depends on the integer value of the Unicode character, and only one byte is used to represent the old ASCII range (0-127). UTF-8 does not use zero to represent any part of any character (except for the ASCII NUL). In consequence, UTF-8 is efficient with respect to space, has no endianism issues, and embeds no nulls. UTF-8 strings can be treated as plain old ASCII strings. These properties make UTF-8 data relatively easy for systems accustomed to processing ASCII data. Here's a small example showing the difference between UCS-2 and UTF-8. <quote>HELLO</quote> in UCS-2 and UTF-8 $ echo HELLO | iconv -f ascii -t UCS-2 | hexdump -C 00000000 00 48 00 45 00 4c 00 4c 00 4f 00 0a |.H.E.L.L.O..| 0000000c $ echo HELLO | iconv -f ascii -t utf-8 | hexdump -C 00000000 48 45 4c 4c 4f 0a |HELLO.| 00000006 $ echo HELLO | hexdump -C 00000000 48 45 4c 4c 4f 0a |HELLO.| 00000006 It is the similarity of the last two outputs that makes UTF-8 so attractive. It behaves like ASCII when ASCII's all that's needed. But it lacks ASCII's limitations. While UTF-8 solves many technical problems, it doesn't magically transform every ASCII-assuming system into a Unicode system. For example, to display Unicode data correctly — even Unicode data in UTF-8 format — the system still needs a suitable font. And it must distinguish the buffer size (and byte count) from the character count.
Unicode and &freetds; Microsoft servers using TDS 7.0 and above (anything since SQL Server 6.5) transmit their data in UCS-2 format (16-bit integers). Because most applications linked to &freetds; are not prepared to deal with UCS-2 data, &freetds; can convert the data to something more acceptable, including ASCII. To do so, it employs an iconv library. &freetds; determines the server's encoding from the TDS protocol and information reported by the server (generally per connection, but in the case of TDS 7.1, per result set column). It discovers the client's encoding in &freetdsconf;. &freetds; will happily convert and convey your data in any single-byte format that iconv can provide. In practice, this normally means some form of ISO 8859-x or UTF-8. At some future time, &freetds; aims to support Unicode and other multi-byte character sets. It does not do so at the current time, beside using wide functions in ODBC. Sybase servers, by the way, adhere to a server makes right policy: they transmit their data in whatever character set the client requested at login time. The list of available character sets is fairly short, but includes UTF-8. While &freetds; could convert Sybase data streams as easily as it does Microsoft data streams, to our knowledge no one is doing so. The Sybase server can perform the conversion itself, making &freetds;'s capability in this regard largely redundant and irrelevant.
For further information UTF-8 and Unicode FAQ for Unix/Linux, by Markus Kuhn. As the man says, very comprehensive. ASCII: American Standard Code for Information Infiltration, by Tom Jennings. Everything you ever wanted know about ASCII, but didn't know whom to ask. A Brief History of Character Codes, by Steven J. Searle. Includes useful references. Unicode Home Page.
GNU Free Documentation License Version 1.1, March 2000 PREAMBLE The purpose of this License is to make a manual, textbook, or other written document "free" in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it, with or without modifying it, either commercially or noncommercially. Secondarily, this License preserves for the author and publisher a way to get credit for their work, while not being considered responsible for modifications made by others. This License is a kind of "copyleft", which means that derivative works of the document must themselves be free in the same sense. It complements the GNU General Public License, which is a copyleft license designed for free software. We have designed this License in order to use it for manuals for free software, because free software needs free documentation: a free program should come with manuals providing the same freedoms that the software does. But this License is not limited to software manuals; it can be used for any textual work, regardless of subject matter or whether it is published as a printed book. We recommend this License principally for works whose purpose is instruction or reference. APPLICABILITY AND DEFINITIONS This License applies to any manual or other work that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License. The "Document", below, refers to any such manual or work. Any member of the public is a licensee, and is addressed as "you". A "Modified Version" of the Document means any work containing the Document or a portion of it, either copied verbatim, or with modifications and/or translated into another language. A "Secondary Section" is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Document's overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. (For example, if the Document is in part a textbook of mathematics, a Secondary Section may not explain any mathematics.) The relationship could be a matter of historical connection with the subject or with related matters, or of legal, commercial, philosophical, ethical or political position regarding them. The "Invariant Sections" are certain Secondary Sections whose titles are designated, as being those of Invariant Sections, in the notice that says that the Document is released under this License. The "Cover Texts" are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover Texts, in the notice that says that the Document is released under this License. A "Transparent" copy of the Document means a machine-readable copy, represented in a format whose specification is available to the general public, whose contents can be viewed and edited directly and straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent file format whose markup has been designed to thwart or discourage subsequent modification by readers is not Transparent. A copy that is not "Transparent" is called "Opaque". Examples of suitable formats for Transparent copies include plain ASCII without markup, Texinfo input format, LaTeX input format, SGML or XML using a publicly available DTD, and standard-conforming simple HTML designed for human modification. Opaque formats include PostScript, PDF, proprietary formats that can be read and edited only by proprietary word processors, SGML or XML for which the DTD and/or processing tools are not generally available, and the machine-generated HTML produced by some word processors for output purposes only. The "Title Page" means, for a printed book, the title page itself, plus such following pages as are needed to hold, legibly, the material this License requires to appear in the title page. For works in formats which do not have any title page as such, "Title Page" means the text near the most prominent appearance of the work's title, preceding the beginning of the body of the text. VERBATIM COPYING You may copy and distribute the Document in any medium, either commercially or noncommercially, provided that this License, the copyright notices, and the license notice saying this License applies to the Document are reproduced in all copies, and that you add no other conditions whatsoever to those of this License. You may not use technical measures to obstruct or control the reading or further copying of the copies you make or distribute. However, you may accept compensation in exchange for copies. If you distribute a large enough number of copies you must also follow the conditions in section 3. You may also lend copies, under the same conditions stated above, and you may publicly display copies. COPYING IN QUANTITY If you publish printed copies of the Document numbering more than 100, and the Document's license notice requires Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly and legibly identify you as the publisher of these copies. The front cover must present the full title with all words of the title equally prominent and visible. You may add other material on the covers in addition. Copying with changes limited to the covers, as long as they preserve the title of the Document and satisfy these conditions, can be treated as verbatim copying in other respects. If the required texts for either cover are too voluminous to fit legibly, you should put the first ones listed (as many as fit reasonably) on the actual cover, and continue the rest onto adjacent pages. If you publish or distribute Opaque copies of the Document numbering more than 100, you must either include a machine-readable Transparent copy along with each Opaque copy, or state in or with each Opaque copy a publicly-accessible computer-network location containing a complete Transparent copy of the Document, free of added material, which the general network-using public has access to download anonymously at no charge using public-standard network protocols. If you use the latter option, you must take reasonably prudent steps, when you begin distribution of Opaque copies in quantity, to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public. It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give them a chance to provide you with an updated version of the Document. MODIFICATIONS You may copy and distribute a Modified Version of the Document under the conditions of sections 2 and 3 above, provided that you release the Modified Version under precisely this License, with the Modified Version filling the role of the Document, thus licensing distribution and modification of the Modified Version to whoever possesses a copy of it. In addition, you must do these things in the Modified Version: Use in the Title Page (and on the covers, if any) a title distinct from that of the Document, and from those of previous versions (which should, if there were any, be listed in the History section of the Document). You may use the same title as a previous version if the original publisher of that version gives permission. List on the Title Page, as authors, one or more persons or entities responsible for authorship of the modifications in the Modified Version, together with at least five of the principal authors of the Document (all of its principal authors, if it has less than five). State on the Title page the name of the publisher of the Modified Version, as the publisher. Preserve all the copyright notices of the Document. Add an appropriate copyright notice for your modifications adjacent to the other copyright notices. Include, immediately after the copyright notices, a license notice giving the public permission to use the Modified Version under the terms of this License, in the form shown in the Addendum below. Preserve in that license notice the full lists of Invariant Sections and required Cover Texts given in the Document's license notice. Include an unaltered copy of this License. Preserve the section entitled "History", and its title, and add to it an item stating at least the title, year, new authors, and publisher of the Modified Version as given on the Title Page. If there is no section entitled "History" in the Document, create one stating the title, year, authors, and publisher of the Document as given on its Title Page, then add an item describing the Modified Version as stated in the previous sentence. Preserve the network location, if any, given in the Document for public access to a Transparent copy of the Document, and likewise the network locations given in the Document for previous versions it was based on. These may be placed in the "History" section. You may omit a network location for a work that was published at least four years before the Document itself, or if the original publisher of the version it refers to gives permission. In any section entitled "Acknowledgements" or "Dedications", preserve the section's title, and preserve in the section all the substance and tone of each of the contributor acknowledgements and/or dedications given therein. Preserve all the Invariant Sections of the Document, unaltered in their text and in their titles. Section numbers or the equivalent are not considered part of the section titles. Delete any section entitled "Endorsements". Such a section may not be included in the Modified Version. Do not retitle any existing section as "Endorsements" or to conflict in title with any Invariant Section. If the Modified Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document, you may at your option designate some or all of these sections as invariant. To do this, add their titles to the list of Invariant Sections in the Modified Version's license notice. These titles must be distinct from any other section titles. You may add a section entitled "Endorsements", provided it contains nothing but endorsements of your Modified Version by various parties--for example, statements of peer review or that the text has been approved by an organization as the authoritative definition of a standard. You may add a passage of up to five words as a Front-Cover Text, and a passage of up to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. If the Document already includes a cover text for the same cover, previously added by you or by arrangement made by the same entity you are acting on behalf of, you may not add another; but you may replace the old one, on explicit permission from the previous publisher that added the old one. The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version. COMBINING DOCUMENTS You may combine the Document with other documents released under this License, under the terms defined in section 4 above for modified versions, provided that you include in the combination all of the Invariant Sections of all of the original documents, unmodified, and list them all as Invariant Sections of your combined work in its license notice. The combined work need only contain one copy of this License, and multiple identical Invariant Sections may be replaced with a single copy. If there are multiple Invariant Sections with the same name but different contents, make the title of each such section unique by adding at the end of it, in parentheses, the name of the original author or publisher of that section if known, or else a unique number. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work. In the combination, you must combine any sections entitled "History" in the various original documents, forming one section entitled "History"; likewise combine any sections entitled "Acknowledgements", and any sections entitled "Dedications". You must delete all sections entitled "Endorsements." COLLECTIONS OF DOCUMENTS You may make a collection consisting of the Document and other documents released under this License, and replace the individual copies of this License in the various documents with a single copy that is included in the collection, provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects. You may extract a single document from such a collection, and distribute it individually under this License, provided you insert a copy of this License into the extracted document, and follow this License in all other respects regarding verbatim copying of that document. AGGREGATION WITH INDEPENDENT WORKS A compilation of the Document or its derivatives with other separate and independent documents or works, in or on a volume of a storage or distribution medium, does not as a whole count as a Modified Version of the Document, provided no compilation copyright is claimed for the compilation. Such a compilation is called an "aggregate", and this License does not apply to the other self-contained works thus compiled with the Document, on account of their being thus compiled, if they are not themselves derivative works of the Document. If the Cover Text requirement of section 3 is applicable to these copies of the Document, then if the Document is less than one quarter of the entire aggregate, the Document's Cover Texts may be placed on covers that surround only the Document within the aggregate. Otherwise they must appear on covers around the whole aggregate. TRANSLATION Translation is considered a kind of modification, so you may distribute translations of the Document under the terms of section 4. Replacing Invariant Sections with translations requires special permission from their copyright holders, but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. You may include a translation of this License provided that you also include the original English version of this License. In case of a disagreement between the translation and the original English version of this License, the original English version will prevail. TERMINATION You may not copy, modify, sublicense, or distribute the Document except as expressly provided for under this License. Any other attempt to copy, modify, sublicense or distribute the Document is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. FUTURE REVISIONS OF THIS LICENSE The Free Software Foundation may publish new, revised versions of the GNU Free Documentation License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. See http://www.gnu.org/copyleft/. Each version of the License is given a distinguishing version number. If the Document specifies that a particular numbered version of this License "or any later version" applies to it, you have the option of following the terms and conditions either of that specified version or of any later version that has been published (not as a draft) by the Free Software Foundation. If the Document does not specify a version number of this License, you may choose any version ever published (not as a draft) by the Free Software Foundation. How to use this License for your documents To use this License in a document you have written, include a copy of the License in the document and put the following copyright and license notices just after the title page: If you have no Invariant Sections, write "with no Invariant Sections" instead of saying which ones are invariant. If you have no Front-Cover Texts, write "no Front-Cover Texts" instead of "Front-Cover Texts being LIST"; likewise for Back-Cover Texts. If your document contains nontrivial examples of program code, we recommend releasing these examples in parallel under your choice of free software license, such as the GNU General Public License, to permit their use in free software.
freetds-1.00.82/doc/userguide.css100644 025423 025423 00000000447 12522201763 0012306/* * $Id: userguide.css,v 1.1 2005-10-03 02:52:29 jklowden Exp $ */ /* Set the screen background to gray */ .SCREEN { background-color: #F0F0F0; } /* Render user input as boldface */ .USERINPUT { font-weight: bold; } /* Make filenames green (why not?) */ .FILENAME { color: #007a00; } freetds-1.00.82/doc/freebcp.1100644 025423 025423 00000014321 13242511126 0011261.\" cf. groff_mdoc .Dd March 25, 2015 .Os FreeTDS 1.00.82 .Dt FREEBCP 1 .Sh NAME .Nm freebcp .Nd bulk loading utility for Sybase and Microsoft databases .Sh SYNOPSIS .Nm .Bo Bo Ao Ar database Ac Ns . Bc Ns Ao Ar owner Ac Ns . Bc Ns Aq Ar object_name .Bro .Ar in | .Ar [query] Ns Ar out .Brc .Ar datafile .Bro .Fl c | .Fl n | .Fl f Ar formatfile .Brc .Op Fl S Ar servername .Op Fl D Ar dbname .Op Fl U Ar username .Op Fl P Ar password .Op Fl b Ar batchsize .Op Fl F Ar firstrow .Op Fl L Ar lastrow .Op Fl e Ar errfile .Op Fl I Ar interfaces .Op Fl m Ar maxerror .Op Fl t Ar field_term .Op Fl r Ar row_term .Op Fl h Ar hints .Op Fl T Ar textsize .Op Fl A Ar packet_size .Op Fl O Ar options .Op Fl i Ar inputfile .Op Fl o Ar outputfile .Op Fl C Ar charset .Op Fl EdVv .\" .Sh DESCRIPTION .Nm is a utility program distributed with FreeTDS. .Nm replicates (in part at least) the functionality of the bcp utility programs distributed by Sybase and Microsoft. .Nm makes use of the DB-Library bcp API provided by FreeTDS. This API is also available to application developers. .Pp The manual pages or online help for Sybase or SQL Server can be referenced for more detailed information on bcp functionality. .\" .Sh TABLES\ AND\ FILES .Bl -tag -width indent .It Ar database The name of the database containing object to be copied. Optional if the table/view is in the default database for .Ar username . .It Ar schema The schema of the object being copied. If not provided, the default schema for .Ar username is used. .It Ar object The name of the database object you wish to access, typically a table. It can also be a view. All views can be read; some can be written, subject to constraints. With .Ar queryout Ns , Ar object can also be an SQL query. .It Ar in Copy data from a host file to a database table. .It Ar out Copy data from a database table to a host file. .It Ar queryout indicates that .Ar table_name is in fact SQL, rather than a database object. .Nm will execute the query and write the results to a file. (It is a good idea to have the query return one and only one result set.) .It Ar datafile The name of an operating system file. .El .\" .Sh OPTIONS .Bl -tag -width indent .It Fl A Ar packet_size Set the size of a TDS packet to packet_size. Not sure why you would want to do this, except as an experiment. .It Fl D Ar dbname The name of the default database to use. Overrides default database associated with the login account. Causes .Nm to issue a .Ic USE Ar dbname command immediately after logging in, before commencing BCP operations. .It Fl E Write the data in datafile to the table's IDENTITY column. Without this flag, the identity data present in the datafile will be ignored, and new IDENTITY values will be generated for the imported rows. .It Fl F Ar firstrow The first row to copy from the input file or database table. The default is the first row, row 1. .It Fl I Ar interfaces The name and location of the .Pa interfaces file to search when connecting to servername. Overrides .Pa freetds.conf. .It Fl L Ar lastrow The last row to copy from an input file or database table. The default is the last row. .It Fl O Ar options SQL text to set connection options prior to the bcp operation. If .Ar options is a valid filename, the SQL is read from the file instead. Sometimes needed for .Ar queryout . Example: .Li -O `SET QUOTED_IDENTIFIER ON' Ns . .It Fl P Ar password The password associated with .Ar username . .It Fl S Ar servername The name of the Database Server to which to connect. .It Fl T Ar textsize For text or image columns, set the maximum number of characters to request from the server. Defaults to the setting in .Pa freetds.conf . If not specified anywhere, defaults to the full size of the data. .It Fl U Ar username A database login name. For TDS\ 7+ connections, a domain login is attempted if .Ar username is not provided. .It Fl b Ar batchsize The number of rows per batch of data copied. Batching applies only when you are bulk copying into the database. Each batch of data is effectively .Dq committed into the database. The default value for .Ar batchsize is 1000. .It Fl c The host data file is (or will be) in "character" format, i.e., a text file. Encoding is determined by the client charset attribute in .Pa freetds.conf . .It Fl d Turn off any logging. (Unintuitive, perhaps.) .It Fl e Ar errfile Write errors to .Ar errfile . For uploads. Includes line and column information, and the row data. .It Fl f Ar formatfile The format of the host data file is described by .Ar formatfile . The layout of .Ar formatfile is identical to that understood by the Sybase and Microsoft bcp utilities, but is too complicated to describe here. .It Fl h Ar hints Set bcp hints. For valid values, cf. .Fn bcp_options in the FreeTDS Reference Manual. .It Fl m Ar maxerror Stop after encountering .Ar maxerror errors. Default 10. .It Fl n The host data file is in .Dq native format. This is a format that .Nm will be able to process, but is not portable or readable. .It Fl r Ar row_term The row terminator for a character file. May be more than one character. Default is newline ('\\n'). Cf\&. .Fl c Ns , above. .It Fl t Ar field_term The field terminator for character file. Also known as a column delimiter. May be more than one character. Default is tab ('\\t'). Cf\&. .Fl c Ns , above. .It Fl v .It Fl V Print the version information and exit. .It Fl i Ar inputfile Read input data from file specified. .It Fl o Ar outputfile Write output data to file specified. .It Fl C Ar charset Specify character set to use to talk to server. .El .Sh ENVIRONMENT .Ev DSQUERY default .Ar servername .\" .Sh NOTES When connecting to a Sybase database server, it is required that the TDS 5.0 protocol be used. When connecting to a Microsoft SQL Server 2000 database server, the TDS\ 7 (or later) protocol is required. .Pp Sybase and Microsoft define different versions of the bcp portion of TDS 4.2. Because FreeTDS has no way of knowing which type of server it's connected to, .Nm does not support version 4.2 of the TDS protocol. .\" .Sh HISTORY .Nm first appeared in FreeTDS 0.60 .Sh AUTHORS The .Nm utility was written by .An Bill Thompson Aq thompbil@exchange.uk.ml.com .Sh BUGS Currently, there is no support for text data types in .Nm Ns , when SQL Server 2000 is the target server. freetds-1.00.82/doc/tsql.1100644 025423 025423 00000006635 13242511126 0010647.\" cf. groff_mdoc .Dd March 25, 2015 .Os FreeTDS 1.00.82 .Dt TSQL FreeTDS "FreeTDS Reference Manual" .Sh NAME .Nm tsql .Nd utility to test FreeTDS connections and queries .Sh SYNOPSIS .Nm .Bro .Fl S Ar servername .Op Fl I Ar interface | .Fl H Ar hostname .Op Fl L .Op Fl p Ar port .Brc .Op Fl D Ar dbname .Op Fl U Ar username .Op Fl P Ar password .Op Fl o Ar options .Nm .Fl C .Sh DESCRIPTION .Nm is a FreeTDS diagnostic tool. It uses the TDS protocol to connect to a Sybase or Microsoft SQL Server, and lets the user issue queries. .Nm does not use the FreeTDS client libraries. Instead, it uses only the lowest level library, libtds, to test the protocol implementation. .Pp .Nm can be run in two ways, one which uses the freetds.conf and one which connects directly using the server's hostname and port. The .Fl H and .Fl p parameters are provided to let the user verify a server is listening on the named host and port. These parameters override any configuration files and environment variables. .Pl The .Fl S parameter can be used to test the local configuration. FreeTDS will use freetds.conf (or equivalent) and environment variables in the normal way to determine the server's IP address and port. You can use .Fl I to specify a filename, overriding FreeTDS's configuration file search algorithm. .Sh OPTIONS .Bl -tag -width indent .It Fl S Ar servername database server to which to connect. .It Fl D Ar dbname database to use. .It Fl I Ar interface freetds.conf or interfaces file describing servername. .It Fl H Ar hostname DNS hostname of the server. .It Fl p Ar port port at which SQL Server is listening. .It Fl U Ar username database login name. If username is not provided, a domain login is attempted for TDS 7+ connections. .It Fl P Ar password database password. .It Fl L list Microsoft server instances (with .Fl H Ns ). .It Fl C print some of the compile-time configuration parameters. .It Fl o Ar options apply the options specified to every command. .Bl -tag -width indent .It Fl f No footer .Bq result count .It Fl h No header .Bq titles .It Fl t Print time .It Fl v Print version .It Fl q Quiet .El .It Fl a Ar appname application name. .It Fl t Ar colterm column terminator. .It Fl r Ar rowterm row terminator. .It Fl r Ar rowterm row terminator. .It Fl J Ar charset character set. .It Fl v verbose mode. .El .\" .Sh NOTES If you can connect with .Ql tsql -S servername Ns , your basic FreeTDS installation is working. .Pp Typing .Ql exit Ns , .Ql quit Ns , or .Ql bye (or .Li ^D Ns ) exits .Nm Ns . .Pp Typing .Ql version displays the TDS protocol version. .Pp Command batches may be separated with .Ql go or .Ql GO Ns . If .Ql GO the version string is reported before executing the batch. .Pp After prompting for the password (if not provided with .Fl P Ns ), .Nm will attempt to connect to the remote server. .Nm displays a counter indicating the number of seconds elapsed during the connection attempt. Typically, .Nm immediately responds with a .Ql 1> prompt. If you see the counter (1, 2, 3, ...), most likely .Nm is unable to connect to the indicated server. .Pp .Nm is not a replacement for a complete isql such as sqsh (www.sqsh.org). If you have suggestions for ways to make .Nm more useful as a diagnostic tool, please post them to the FreeTDS mailing list for consideration. .Sh HISTORY .Nm first appeared in FreeTDS 0.60. .Sh AUTHORS The .Nm utility was written by .An Brian Bruns Ns . .Sh BUGS Several, to be sure, now that it's documented. :) freetds-1.00.82/doc/osql.1100644 025423 025423 00000003741 13242511126 0010635.\" cf. groff_mdoc .Dd April 26, 2012 .Os FreeTDS 1.00.82 .Dt OSQL FreeTDS "FreeTDS Reference Manual" .\" .Sh NAME .Nm osql .Nd utility to test FreeTDS connections and queries .\" .Sh SYNOPSIS .Pp .Nm .Fl S Ar dsn .Fl U Ar username .Fl P Ar password .Op Fl I Pa ini_directory .\" .Sh DESCRIPTION .Pp .Nm is a diagnostic tool provided as part of FreeTDS. It is a Bourne shell script that checks and reports on your configuration files. If everything checks out OK, it invokes isql. .Pp .Nm works only with the isql that comes with unixODBC. .\" .Sh OPTIONS .Bl -tag -width indent .It Fl S Ar dsn the Data Source Name to which to connect, as known to .Pa odbc.ini Ns . .It Fl U Ar username database login name. .It Fl P Ar password database password. .It Fl I Ar ini_dir override .Pa odbc.ini file location. .El .\" .Sh EXAMPLE If you have an .Pa odbc.ini with a section like this: .Bd -literal -offset indent .Bq myDSN servername = myserver TDS_Version = 5.0 .Ed .Pp You would invoke .Nm as: .Pp .Li osql -S myDSN .Op .\|.\|.\& .\" .Sh FILES .Pa odbc.ini .Pa freetds.conf .\" .Sh NOTES If you can connect with .Ql osql -S servername -U user -P passwd Ns , your FreeTDS ODBC installation is working. .Pp .Nm guesses where unixODBC might look for its .Pa odbc.ini by examining the binary. This is not always an effective approach. If it doesn't work, you'll receive a report of candidate strings. Kindly pass along the output to help improve the guessing. .Pp If .Nm cannot intuit your .Pa odbc.ini directory, you can force the issue with the .Fl I option. However, you're then instructing .Nm what to test, not where unixODBC will eventually look. Your override is therefore only as good as you are. Look carefully at the error output before overriding. .Pp If you have suggestions for ways to make .Nm more useful as a diagnostic tool, please post them to the FreeTDS mailing list. .\" .Sh HISTORY .Nm first appeared in FreeTDS 0.65. .\" .Sh AUTHORS The .Nm utility was written by .An James K. Lowden Ns . freetds-1.00.82/doc/bsqldb.1100644 025423 025423 00000006670 13242511126 0011132.\" cf. groff_mdoc .Dd March 26, 2015 .Dt BSQLDB 1 .Os FreeTDS 1.00.82 .Sh NAME .Nm bsqldb .Nd batch SQL script processor using DB-Library .Sh SYNOPSIS .Nm .Op Fl hqv .Op Fl S Ar servername .Op Fl D Ar database .Op Fl U Ar username .Op Fl P Ar password .Op Fl i Ar input_file .Op Fl o Ar output_file .Op Fl e Ar error_file .Op Fl H Ar hostname .Op Fl t Ar field_term .Op Fl R Ar pivot_description .\" .Sh DESCRIPTION .Nm is a utility program distributed with FreeTDS. .Nm is a non-interactive equivalent of the "isql" utility programs distributed by Sybase and Microsoft. Like them, .Nm uses the command "go" on a line by itself as a separator between batches. The last batch need not be followed by "go". .Nm makes use of the DB-Library API provided by FreeTDS. This API is of course also available to application developers. .Sh OPTIONS .Bl -tag -width indent .It Fl D Ar database Database to use. .It Fl H Ar hostname hostname Override name of client sent to server. .It Fl P Ar password Database server password. .It Fl S Ar servername Database server to which to connect. .It Fl U Ar username Database server login name. If username is not provided, a domain login is attempted for TDS 7+ connections. .It Fl e Ar error_file Name of file for errors. .It Fl h Print column headers with the data to the same file. .It Fl i Ar input_file Name of script file, containing SQL. .It Fl o Ar output_file Name of output file, holding result data. .It Fl q Do not print column metadata, return status, or rowcount. Overrides .Fl h Ns . .It Fl t Ar field_term Specifies the field terminator. Default is two spaces (' '). Recognized escape sequences are tab ('\\t'), carriage return ('\\r'), newline ('\\n'), and backslash ('\\\\'). .It Fl v Verbose mode, for more information about the DB-Library interaction. This also reports the result set metadata, including and return code. All verbose data are written to standard error (or .Fl e Ns ), so as not to interfere with the data stream. .It Fl R Ar pivot_description Specify pivot trasformation. The format is .Ao Ar down\ columns Ac .Ao Ar across\ columns Ac .Ao Ar function Ac .Ao Ar value Ac . Columns are specified but numbers. The format of .Ar down columns and .Ar across columns is a comma separated list of columns. .Ar function is either count, sum, min or max. .El .\" .Sh ENVIRONMENT .Ev DSQUERY default .Ar servername .\" .Sh NOTES .Nm is a filter; it reads from standard input, writes to standard output, and writes errors to standard error. The .Fl i Ns , Fl o Ns , and Fl e options override these defaults. .Pp The source code for .Nm is intended as a model for DB-Library users. DB-Library has a rich set of functions, and it can be hard sometimes to understand how to use them, particularly the first time. If you find something about the source code unclear, you are encouraged to email the author your comments. .\" .Sh EXIT STATUS .Nm exits 0 on success, and >0 if the server cannot process the query. .Pp For messages with severity > 10, .Nm calls exit(3) with the severity level. For example, if the severity level is 16, .Nm will return an exit status of 16 to the shell. .\" .Sh HISTORY .Nm first appeared in FreeTDS 0.63. .\" .Sh AUTHORS The .Nm utility was written by .An "James K. Lowden" Aq jklowden@freetds.org . .\" .Sh BUGS Microsoft servers as of SQL Server 7.0 SP 3 do not return output parameters unless the RPC functions are used. This means .Nm cannot return output parameters for stored procedures with these servers. freetds-1.00.82/doc/bsqlodbc.1100644 025423 025423 00000004521 13242511126 0011445.\" cf. groff_mdoc .Dd March 25, 2015 .Os FreeTDS 1.00.82 .Dt BSQLODBC FreeTDS "FreeTDS Reference Manual" .\" .Sh NAME .Nm bsqlodbc .Nd batch SQL script processor using ODBC .\" .Sh SYNOPSIS .Pp .Nm .Op Fl hqv .Op Fl U Ar username .Op Fl P Ar password .Op Fl S Ar server .Op Fl D Ar database .Op Fl i Ar input_file .Op Fl o Ar output_file .Op Fl e Ar error_file .Op Fl t Ar field_term .Op Fl V Ar odbc_version .\" .Sh DESCRIPTION .Pp .Nm is a utility program distributed with FreeTDS. .Pp .Nm is a non-interactive equivalent of the .Ql isql utility programs distributed by Sybase and Microsoft. Like them, .Nm uses the command .Ql go on a line by itself as a separator between batches. The last batch need not be followed by .Ql go . .Pp .Nm makes use of the ODBC API provided by FreeTDS. This API is of course also available to application developers. .\" .Sh OPTIONS .Bl -tag -width indent .It Fl U Ar username Database server login name. .It Fl P Ar password Database server password. .It Fl S Ar server Database server to which to connect. .It Fl D Ar database Database to use. .It Fl i Ar input_file Name of script file, containing SQL. .It Fl o Ar output_file Name of output file, holding result data. .It Fl e Ar error_file Name of file for errors. .It Fl t Ar field_term Specifies the field terminator. Default is two spaces ( .Ql \ \ .Ns ). Recognized escape sequences are tab ( .Ql \et .Ns ), carriage return ( .Ql \er .Ns ), newline ( .Ql \en .Ns ), and backslash ( .Ql \e\e .Ns ). .It Fl h Print column headers with the data to the same file. .It Fl q Do not print column metadata, return status, or rowcount. Overrides .Fl h . .It Fl v Verbose mode, for more information about the ODBC interaction. This also reports the result set metadata, including and return code. All verbose data are written to standard error (or .Fl e Ns ), so as not to interfere with the data stream. .It Fl V Ar odbc_version Specify ODBC version (2 or 3). .El .\" .Sh NOTES .Pp .Nm is a filter; it reads from standard input, writes to standard output, and writes errors to standard error. The .Fl i , .Fl o , and .Fl e options override these defaults. .Sh EXIT STATUS .Nm exits 0 on success, and >0 if the server cannot process the query. .\" .Sh HISTORY .Nm first appeared in FreeTDS 0.65. .\" .Sh AUTHORS The .Nm utility was written by .An James K. Lowden Aq jklowden@freetds.org . freetds-1.00.82/doc/defncopy.1100644 025423 025423 00000005075 13242511126 0011470.\" cf. groff_mdoc .Dd April 26, 2012 .Os FreeTDS 1.00.82 .Dt DEFNCOPY FreeTDS "FreeTDS Reference Manual" .\" .Sh NAME .Nm defncopy .Nd extract procedures and views from a Microsoft server. .\" .Sh SYNOPSIS .Pp .Nm .Op Fl v .Op Fl U Ar username .Op Fl P Ar password .Op Fl S Ar server .Op Fl D Ar database .Op Fl i Ar input_file .Op Fl o Ar output_file .Bo .Ar owner.object_name .\" Elipsis according to Werner Lemberg: .\" http://www.mail-archive.com/groff@gnu.org/msg03122.html .Op Ar owner.object_name .\|.\|.\& .Bc .\" .Sh DESCRIPTION .Pp .Nm is a utility program distributed with FreeTDS. It replaces a similar program of the same name distributed by Sybase. .Pp .Nm reads the text of a stored procedure or view, and writes a script suitable for recreating the procedure or view. For tables, it reads the output of sp_help and constructs a .Ql CREATE TABLE statement, complete with .Ql CREATE INDEX Ns , too. .\" .Ar owner is optional if you or the database owner is the owner of the procedure/view being copied. .Ar object_name is the name of the system object you wish to extract. .\" .Sh OPTIONS .Bl -tag -width indent .It Fl U Ar username database server login name. .It Fl P Ar password database server password. .It Fl S Ar server database server to which to connect. .It Fl D Ar database database to use. Optional if the procedure/view being extracted is in your default database. .It Fl i Ar input_file a script to apply to the database. Not currently implemented. .It Fl o Ar output_file a file to hold the script, defaults to standard output. .It Fl v Show version information and copyright notice. .El .\" .Sh NOTES .Nm is a filter; it reads from standard input, writes to standard output, and writes errors to standard error. The .Fl i , .Fl o , and .Fl e options override these defaults. .Pp .Nm makes use of the db-lib API provided by FreeTDS. This API is of course also available to application developers. .Sh EXIT STATUS .Pp .Nm exits 0 on success, and >0 if the server cannot process the query. .Pp .Nm will report any errors returned by the server, but will continue processing. .\" .Sh HISTORY .Pp .Nm first appeared in FreeTDS 0.63. .\" .Sh AUTHORS The .Nm utility was written by .An James K. Lowden Aq jklowden@schemamania.org. .\" .Sh BUGS Works only with Microsoft servers and ancient Sybase servers. Does not create primary keys. Many options are defined by Sybase that this version does not implement. Feel free to correct this situation. In theory, .Nm could apply/produce DDL for any system object, but at present only tables, procedures and views are supported, and only for extraction. freetds-1.00.82/doc/datacopy.1100644 025423 025423 00000004561 13242511126 0011464.\" cf. groff_mdoc .Dd March 25, 2015 .Os FreeTDS 1.00.82 .Dt DATACOPY FreeTDS "FreeTDS Reference Manual" .\" .Sh NAME .Nm datacopy .Nd move table data between two servers .\" .Sh SYNOPSIS .Nm .Op Fl vdE .Bro .Fl t | .Fl a | .Fl c .Ar owner .Brc .Op Fl b Ar batchsize .Op Fl p Ar packetsize .Op Fl S Ar server/username/password/database/table_or_view .Op Fl D Ar server/username/password/database/table .Op Fl T Ar textsize .\" .Sh DESCRIPTION .Nm is a utility distributed with FreeTDS. .Nm will move table data from one server to another without the need for intermediate files. .Nm is much faster and more efficient than is freebcp out/in. .Pp .Nm makes use of the db-lib bcp API built into FreeTDS. This API is also available to application developers. .Pp .Nm can be used to migrate data between Sybase ASE and SQL Server or vice versa. .\" .Sh OPTIONS .Bl -tag -width indent .It Fl t Truncate target table before loading data. .It Fl a Append data to target table. .It Fl c Ar owner Create the target table with the same schema as the source table. .Nm will submit a .Ql CREATE TABLE command on the target server using the specified owner in the command, e.g. .Ql CREATE TABLE owner.table (.\|.\|.\&). .It Fl b Ar batchsize The number of rows per batch of data copied. Each batch of data is effectively 'committed' to the database. The default is 1000. .It Fl p Ar packetsize The number of bytes, per network packet, sent to and from the servers. Increased packet size can enhance performance. .It Fl T Ar textsize Specify size of TEXT/IMAGE column from network. .It Fl v Produce verbose output, including diagnostic timings. .It Fl d Produce freetds TDSDUMP output. (Serious debug only!) .It Fl S Ar server/username/password/database/table_or_view The connection information for the source server and the location/name of the table (or view) to be copied. If not specified, .Nm prompts the user for the information. .It Fl D Ar server/username/password/database/table The connection information for the destination server and the location/name of the target table. If not specified, .Nm prompts the user for the information. .It Fl E Keep identity values. .Sh SEE ALSO .Xr freebcp 1 , Xr defncopy 1 , Xr bsqldb 1 , Xr tsql 1 , .%B FreeTDS User Guide. .\" .Sh HISTORY .Pp .Nm first appeared in FreeTDS 0.64. .\" .Sh AUTHORS The .Nm utility was written by .An Bill Thompson Aq thompbil@exchange.uk.ml.com . freetds-1.00.82/doc/fisql.1100644 025423 025423 00000010072 13242511126 0010770.\" cf. groff_mdoc .Dd March 25, 2015 .Os FreeTDS 1.00.82 .Dt FISQL FreeTDS "FreeTDS Reference Manual" .\" .Sh NAME .Nm fisql .Nd interactive SQL shell .\" .Sh SYNOPSIS .Pp .Nm .Op Fl eFgpnvXY .Op Fl a Ar display_charset .Op Fl A Ar packet_size .Op Fl c Ar cmdend .Op Fl D Ar database .Op Fl E Ar editor .Op Fl h Ar headers .Op Fl H Ar hostname .Op Fl i Ar inputfile .Op Fl I Ar interfaces_file .Op Fl J Ar client_charset .Op Fl l Ar login_timeout .Op Fl m Ar errorlevel .Op Fl o Ar outputfile .Op Fl P Ar password .Op Fl s Ar colseparator .Op Fl S Ar server .Op Fl t Ar timeout .Op Fl U Ar username .Op Fl w Ar width .Op Fl y Ar sybase_dir .Op Fl z Ar language .\" .Sh DESCRIPTION .Pp .Nm is very similar to the .Ql isql utility programs distributed by Sybase and Microsoft. Like them, .Nm uses the command .Ql go on a line by itself as a separator between batches. .\" .Sh OPTIONS .Bl -tag -width indent .It Fl a Ar display_charset The client charset name. Not implemented. .It Fl A Ar packet_size Set protocol packet size. You should not need to set this parameter. .It Fl c Ar cmdend Command terminator, defaults to .Ql go Ns . .It Fl D Database name on the server to use. .It Fl e Echo SQL input (usually in outputfile) .It Fl E Ar editor Specify an editor to invoke. Defaults to vi. .It Fl F FIPS mode ON. Server returns a message (but processes the query anyway) when it encounters a non-standard SQL command. .It Fl g Display a brief help message .It Fl h Ar headers Number of rows after which to repeat the column headers. Default is once per resultset. .It Fl H Ar hostname Hostname of the client machine as it will be told to the server. .It Fl I Ar interfaces_file Name of the interfaces or freetds.conf file to use. .It Fl i Ar inputfile Name of script file, containing SQL. .It Fl J Ar client_charset Not implemented. .It Fl l Ar login_timeout How long to wait for the server to acknowledge a login attempt. .It Fl m Ar errorlevel For errors of the severity level specified or higher, print only the message number, state, and error level. Below that level, print nothing. .It Fl n Suppress line numbers in echoed output. .It Fl o Ar outputfile Name of output file, holding result data. .It Fl p Prints performance statistics. Not implemented. .It Fl P Ar password Database server password. .It Fl s Ar colseparator The column separator. Default is space. Shell metacharacters require quoting. .It Fl S Ar server Database server to which to connect. .It Fl t Ar timeout The query timeout, in seconds. How long to wait for a query to be processed. The default is indefinitely, or as determined by freetds.conf. .It Fl U Ar username Database server login name. .It Fl v Display version and copyright. .It Fl w Ar width How many characters wide to print the output. Defaults to 80. .It Fl X Use encrypted login. Not implemented in FreeTDS. .It Fl y Pa sybase_dir Sets the .Ev SYBASE environment variable. Not used by FreeTDS. .It Fl Y Use chained transactions. .It Fl z Ar language Name of a language for fisql's prompts and messages. Cf. DBSETLNATLANG. .El .\" .Sh NOTES .Nm is a filter; it reads from standard input, writes to standard output, and writes errors to standard error. The .Fl i Ns , .FL o Ns , and .Fl e options override these defaults. .Pp .Nm uses the DB-Library API provided by FreeTDS. It was first implemented using Sybase's own library and continues to work with it. Before (and after) modifying it, it would be well to test it with Sybase's library to assure compatibility between it and FreeTDS. EXIT STATUS .Pp .Nm exits 0 on success, and >0 if the server cannot process the query. .Pp .Nm will report any errors returned by the server, but will continue processing. In a production environment, this behavior may be insufficiently stringent. To make it extremely intolerant of errors, change the message and error handlers to call exit(3). .\" .Sh HISTORY .Nm first appeared in FreeTDS 0.65. .\" .Sh AUTHORS The .Nm utility was written by .An Nicholas S. Castellano Aq entropy@freetds.org Ns , who contributed it to the FreeTDS project under the terms of the GPL. .\" .Sh BUGS Requires the GNU readline library. freetds-1.00.82/doc/freetds.conf.5100644 025423 025423 00000014523 13242511126 0012243.\" $Id: freetds.conf.5,v 1.4 2009-12-14 01:02:27 jklowden Exp $ .Dd December 23, 2007 .Os FreeTDS 1.00.82 .Dt FREETDS.CONF "FreeTDS 5" "FreeTDS Reference Manual" . .Sh NAME .Nm freetds.conf .Nd configuration file for FreeTDS . .Sh SYNOPSIS The .Pa freetds.conf file describes Sybase and Microsoft database servers to the FreeTDS library. It comprises sections headed by a servername, followed by a list of connection properties denoted as name-value pairs. Defaults are defined via a .Bq global section. This file supersedes the .Pa interfaces file that Sybase defines for the same purpose, although the latter is still supported. . .Sh DESCRIPTION A section begins with a servername \(em the name of the server \(em in square brackets. The servername is chosen at the client's descretion. (One exception: with Sybase ASA the servername must match the database name to be used.) .Pp Sections contain properties, one per line, in the form .Pp .Dl name = value .Pp where .Ar name is the connection property to be described. Servernames and properties are not case sensitive. Values are case-preserving i.e., copied literally. Comments begin with either a semicolon .Pq So ; Sc or pound sign .Pq So # Sc and continue to end of line. Blank lines are ignored. Whitespace surrounding the .So = Sc is ignored. . .Sh PROPERTIES .Bl -tag -width "emulate little endian" -compact . .It client charset encoding of client data; overrides locale(1) settings .Bl -tag -width "default:" -compact .It Domain: iconv character set names .It Default: ISO-8859-1 .El . .It connect timeout seconds to wait for response from connect request .Bl -tag -width "default:" -compact .It Domain: 0 to MAX_INT .It Default: none .El . .It debug flags logging granularity .Bl -tag -width "default:" -compact .It Domain: 32-bit integer .It Default: 0x4fff .El . .It dump file specifies location of a logfile and turns on logging .Bl -tag -width "default:" -compact .It Domain: valid file name .It Default: none .El . .It dump file append log data appended to file instead of re-writing for each connection .Bl -tag -width "default:" -compact .It Domain: yes/no .It Default: no .El . .It emulate little endian forces big endian machines to act as little endian to communicate with Microsoft Servers .Bl -tag -width "default:" -compact .It Domain: yes/no .It Default: no .El . .It encryption .Bl -tag -compact .It Em off disables encryption (default) .It Em request use if available .It Em required allow encrypted connections only .El . .It host Name of the host the server is running on. .Bl -tag -width "default:" -compact .It Domain: host name or IP address .It Default: SYBASE .El . .It initial block size maximum size of a protocol block .Bl -tag -width "default:" -compact .It Domain: multiple of 512 .It Default: 512 .El . .It instance name of Microsoft SQL Server instance to connect to (supersedes .Em port ) .Bl -tag -width "default:" -compact .It Domain: instance name .It Default: none .El . .It port port number that the server is listening to .Bl -tag -width "default:" -compact .It Domain: any valid port .It Default: TDS 5.0, 5000; TDS 7.0 and up, 1433 .El . .It tds version TDS protocol version to use .Bl -tag -width "default:" -compact .It Domain: 4.2, 5.0, 7.0, 7.1, 7.2 .It Default: .Fl -with-tdsver value (5.0 if unspecified) .El . .It text size default value of TEXTSIZE, in bytes .Bl -tag -width "default:" -compact .It Domain: 0 to 4,294,967,295 .It Default: 4,294,967,295 .El . .It timeout seconds to wait for response to a query .Bl -tag -width "default:" -compact .It Domain: 0 to MAX_INT .It Default: none (wait forever) .El . .El .Pp Do not define both .Fa port and .Fa instance Ns \&. One implies the other. .Pp Boolean property values may be denoted as on/off, true/false, or 1/0. . .Ss DEBUG FLAGS The log's granularity can be controlled with the .Em debug flags property. .Bl -column -offset indent ".Sy 0x8000" ".Sy show source level info (source file and line)" .It Sy Value Ta Sy Meaning .It Li \ \ 0x02 severe error .It Li \ \ 0x04 error .It Li \ \ 0x08 warning .It Li \ \ 0x10 network .It Li \ \ 0x20 information level 1 .It Li \ \ 0x40 information level 2 .It Li \ \ 0x80 function trace and info .It Li 0x1000 show pid .It Li 0x2000 show time .It Li 0x4000 show source level info (source file and line) .It Li 0x8000 thread id (not implemented). .El . .Sh NAMES AND LOCATIONS The file is normally named .Pa /etc/freetds.conf or .Pa ${HOME}/.freetds.conf . That name can be overridden with the FREETDSCONF environment variable. .Pp FreeTDS will search conf files for a servername in the following order: .Bl -enum -offset indent -compact .It a filename set programatically via dbsetifile() that is in .conf format .It a filename in the environment variable FREETDSCONF that is in .conf format .It .Pa ${HOME}/.freetds.conf if extant .It .Pa ${prefix}/etc/freetds.conf .El .Pp The search stops with the first file containing the servername. .Pp If no conf file is found, FreeTDS searches for an .Pa interfaces file in the following order: .Bl -enum -offset indent -compact .It a filename set programatically via dbsetifile() that is in .Pa interfaces format .It .Pa ${HOME}/.interfaces .It .Pa $SYBASE/interfaces (where .Ev $SYBASE is an environment variable) .El .Pp If the requested servername is not found in any configuration file, the fallback mechanism is: .Bl -enum -offset indent -compact .It attempt to convert the name to an IP address with inet_addr(3), else .It attempt to convert the name to an IP address with gethostbyname(3), else .It attempt to look up the literal name .Dq SYBASE .El . .Sh ENVIRONMENT .Bl -tag -width "TDSDUMPCONFIG" -compact .It Ev FREETDSCONF overrides name and location of the system-wide conf file .It Ev TDSDUMP overrides the name and location of the FreeTDS log file .It Ev TDSDUMPCONFIG specifies a name and location of a file that logs the search of configuration files .It Ev TDSHOST overrides the host property .It Ev TDSPORT overrides the port property .It Ev TDSQUERY synonym for DSQUERY, the default servername .It Ev TDSVER overrides the version specified in the freetds.conf .El .Pp The environment variables .Ev TDSVER, Ev TDSDUMP, Ev TDSPORT, Ev TDSQUERY, and Ev TDSHOST override values set by a .conf or .Pa interfaces file. . .Sh FILES .Pa ${prefix}/etc/freetds.conf , ${HOME}/.freetds.conf . .Sh SEE ALSO .%B FreeTDS User Guide . .Sh HISTORY \.conf files first appeared with version 0.53 of FreeTDS. freetds-1.00.82/doc/userguide/userguide.css100644 025423 025423 00000000447 13242511130 0014272/* * $Id: userguide.css,v 1.1 2005-10-03 02:52:29 jklowden Exp $ */ /* Set the screen background to gray */ .SCREEN { background-color: #F0F0F0; } /* Render user input as boldface */ .USERINPUT { font-weight: bold; } /* Make filenames green (why not?) */ .FILENAME { color: #007a00; } freetds-1.00.82/doc/userguide/index.htm100644 025423 025423 00000000127 13242511130 0013400

at www.freetds.org freetds-1.00.82/doc/userguide/index.html100644 025423 025423 00000000127 13242511130 0013554

at www.freetds.org freetds-1.00.82/doc/reference/a00023_source.html100644 025423 025423 00000014026 13242511132 0014601 FreeTDS API: src/apps/fisql/edit.h Source File

FreeTDS API
edit.h
1 /* Free ISQL - An isql for DB-Library (C) 2007 Nicholas S. Castellano
2  *
3  * This program is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU General Public
5  * License as published by the Free Software Foundation; either
6  * version 2 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Library General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public
14  * License along with this library; if not, write to the
15  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16  * Boston, MA 02111-1307, USA.
17  */
18 
19 /* $Id: edit.h,v 1.3 2007-01-20 06:32:27 castellano Exp $ */
20 int edit(const char *editor, const char *arg);
freetds-1.00.82/doc/reference/a00032_source.html100644 025423 025423 00000016354 13242511132 0014607 FreeTDS API: src/apps/fisql/handlers.h Source File
FreeTDS API
handlers.h
1 /* Free ISQL - An isql for DB-Library (C) 2007 Nicholas S. Castellano
2  *
3  * This program is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU General Public
5  * License as published by the Free Software Foundation; either
6  * version 2 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Library General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public
14  * License along with this library; if not, write to the
15  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16  * Boston, MA 02111-1307, USA.
17  */
18 
19 /* $Id: handlers.h,v 1.4 2007-01-20 06:32:27 castellano Exp $ */
20 extern int global_errorlevel;
21 
22 int err_handler(DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr);
23 
24 int msg_handler(DBPROCESS * dbproc, DBINT msgno, int msgstate,
25  int severity, char *msgtext, char *srvname, char *procname, int line);
Definition: dblib.h:120
freetds-1.00.82/doc/reference/a00038_source.html100644 025423 025423 00000016144 13242511132 0014612 FreeTDS API: src/apps/fisql/interrupt.h Source File
FreeTDS API
interrupt.h
1 /* Free ISQL - An isql for DB-Library (C) 2007 Nicholas S. Castellano
2  *
3  * This program is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU General Public
5  * License as published by the Free Software Foundation; either
6  * version 2 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Library General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public
14  * License along with this library; if not, write to the
15  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16  * Boston, MA 02111-1307, USA.
17  */
18 
19 /* $Id: interrupt.h,v 1.4 2007-01-20 06:32:27 castellano Exp $ */
20 extern sigjmp_buf restart;
21 
22 void inactive_interrupt_handler(int sig);
23 void active_interrupt_handler(int sig);
24 void maybe_handle_active_interrupt(void);
25 int active_interrupt_pending(DBPROCESS * dbproc);
26 int active_interrupt_servhandler(DBPROCESS * dbproc);
Definition: dblib.h:120
freetds-1.00.82/doc/reference/a00044_source.html100644 025423 025423 00000014410 13242511132 0014601 FreeTDS API: src/apps/fisql/terminal.h Source File
FreeTDS API
terminal.h
1 /* Free ISQL - An isql for DB-Library (C) 2007 Nicholas S. Castellano
2  *
3  * This program is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU General Public
5  * License as published by the Free Software Foundation; either
6  * version 2 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Library General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public
14  * License along with this library; if not, write to the
15  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16  * Boston, MA 02111-1307, USA.
17  */
18 
19 /* $Id: terminal.h,v 1.4 2007-01-20 06:32:27 castellano Exp $ */
20 int save_term(void);
21 int set_term_noecho(void);
22 int reset_term(void);
freetds-1.00.82/doc/reference/a00050_source.html100644 025423 025423 00000027247 13242511132 0014612 FreeTDS API: src/apps/freebcp.h Source File
FreeTDS API
freebcp.h
1 enum states
2 {
3  GET_NEXTARG,
4  GET_MAXERRORS,
5  GET_FORMATFILE,
6  GET_ERRORFILE,
7  GET_FIRSTROW,
8  GET_LASTROW,
9  GET_BATCHSIZE,
10  GET_FIELDTERM,
11  GET_ROWTERM,
12  GET_USER,
13  GET_PASS,
14  GET_INTERFACESFILE,
15  GET_SERVER,
16  GET_DISPLAYCHARSET,
17  GET_DATAFILECHARSET,
18  GET_LANGUAGE,
19  GET_PACKETSIZE,
20  GET_CLIENTCHARSET,
21  GET_TEXTSIZE,
22  GET_SYBASEDIR,
23  GET_FROMLABEL,
24  GET_TOLABEL,
25  GET_HINT
26 };
27 
28 typedef struct pd
29 {
30  char *dbobject;
31  char dbdirection[10];
32  DBINT direction;
33  char *hostfilename;
34  char *formatfile;
35  char *errorfile;
36  char *interfacesfile;
37  int firstrow;
38  int lastrow;
39  int batchsize;
40  int maxerrors;
41  int textsize;
42  char *fieldterm;
43  int fieldtermlen;
44  char *rowterm;
45  int rowtermlen;
46  char *user;
47  char *pass;
48  char *server;
49  char *dbname;
50  char *hint;
51  char *options;
52  char *charset;
53  int packetsize;
54  int mflag;
55  int fflag;
56  int eflag;
57  int Fflag;
58  int Lflag;
59  int bflag;
60  int nflag;
61  int cflag;
62  int tflag;
63  int rflag;
64  int Uflag;
65  int Iflag;
66  int Sflag;
67  int Pflag;
68  int Tflag;
69  int Aflag;
70  int Eflag;
71  char *inputfile;
72  char *outputfile;
73 }
Definition: datacopy.c:61
freetds-1.00.82/doc/reference/a00074_source.html100644 025423 025423 00000223065 13242511132 0014614 FreeTDS API: src/dblib/buffering.h Source File
FreeTDS API
buffering.h
1 typedef struct dblib_buffer_row {
5  unsigned char *row_data;
7  DBINT row;
9  TDS_INT *sizes;
11 
12 static void buffer_struct_print(const DBPROC_ROWBUF *buf);
13 static RETCODE buffer_save_row(DBPROCESS *dbproc);
14 static DBLIB_BUFFER_ROW* buffer_row_address(const DBPROC_ROWBUF * buf, int idx);
15 
16 #if ENABLE_EXTRA_CHECKS
17 static void buffer_check(const DBPROC_ROWBUF *buf)
18 {
19  int i;
20 
21  /* no buffering */
22  if (buf->capacity == 0 || buf->capacity == 1) {
23  assert(buf->head == 0);
24  assert(buf->tail == 0 || buf->tail == 1);
25  assert(buf->capacity == 1 || buf->rows == NULL);
26  return;
27  }
28 
29  assert(buf->capacity > 0);
30  assert(buf->head >= 0);
31  assert(buf->tail >= 0);
32  assert(buf->head < buf->capacity);
33  assert(buf->tail <= buf->capacity);
34 
35  /* check empty */
36  if (buf->tail == buf->capacity) {
37  assert(buf->head == 0);
38  for (i = 0; buf->rows && i < buf->capacity; ++i) {
39  assert(buf->rows[i].resinfo == NULL);
40  assert(buf->rows[i].row_data == NULL);
41  assert(buf->rows[i].sizes == NULL);
42  assert(buf->rows[i].row == 0);
43  }
44  return;
45  }
46 
47  if (buf->rows == NULL)
48  return;
49 
50  /* check filled part */
51  i = buf->tail;
52  do {
53  assert(i >= 0 && i < buf->capacity);
54  assert(buf->rows[i].resinfo != NULL);
55  assert(buf->rows[i].row > 0);
56  assert(buf->rows[i].row <= buf->received);
57  ++i;
58  if (i == buf->capacity)
59  i = 0;
60  } while (i != buf->head);
61 
62  /* check empty part */
63  if (buf->head != buf->tail) {
64  i = buf->head;
65  do {
66  assert(i >= 0 && i < buf->capacity);
67  assert(buf->rows[i].resinfo == NULL);
68  assert(buf->rows[i].row_data == NULL);
69  assert(buf->rows[i].sizes == NULL);
70  assert(buf->rows[i].row == 0);
71  ++i;
72  if (i == buf->capacity)
73  i = 0;
74  } while (i != buf->tail);
75  }
76 }
77 #define BUFFER_CHECK(buf) buffer_check(buf)
78 #else
79 #define BUFFER_CHECK(buf) do {} while(0)
80 #endif
81 
110 static int
111 buffer_count(const DBPROC_ROWBUF *buf)
112 {
113  BUFFER_CHECK(buf);
114  return (buf->head > buf->tail) ?
115  buf->head - buf->tail : /* |...TddddH....| */
116  buf->capacity - (buf->tail - buf->head); /* |ddddH....Tddd| */
117 }
118 
122 static int
123 buffer_is_full(const DBPROC_ROWBUF *buf)
124 {
125  BUFFER_CHECK(buf);
126  return buf->capacity == buffer_count(buf) && buf->capacity > 1;
127 }
128 
129 #ifndef NDEBUG
130 static int
131 buffer_index_valid(const DBPROC_ROWBUF *buf, int idx)
132 {
133  BUFFER_CHECK(buf);
134  if (buf->tail <= buf->head)
135  if (buf->head <= idx && idx <= buf->tail)
136  return 1;
137 
138  if (0 <= idx && idx <= buf->head)
139  return 1;
140 
141  if (buf->tail <= idx && idx < buf->capacity)
142  return 1;
143 #if 0
144  printf("buffer_index_valid: idx = %d\n", idx);
145  buffer_struct_print(buf);
146 #endif
147  return 0;
148 }
149 #endif
150 
151 static void
152 buffer_free_row(DBLIB_BUFFER_ROW *row)
153 {
154  if (row->sizes)
155  TDS_ZERO_FREE(row->sizes);
156  if (row->row_data) {
157  tds_free_row(row->resinfo, row->row_data);
158  row->row_data = NULL;
159  }
160  tds_free_results(row->resinfo);
161  row->resinfo = NULL;
162  row->row = 0;
163 }
164 
165 /*
166  * Buffer is freed at slightly odd points, whenever
167  * capacity changes:
168  *
169  * 1. When setting capacity, to release prior buffer.
170  * 2. By dbresults. When called the second time, it has to
171  * release prior storage because the new resultset will have
172  * a different width.
173  * 3. By dbclose(), else open/close/open would leak.
174  */
175 static void
176 buffer_free(DBPROC_ROWBUF *buf)
177 {
178  BUFFER_CHECK(buf);
179  if (buf->rows != NULL) {
180  int i;
181  for (i = 0; i < buf->capacity; ++i)
182  buffer_free_row(&buf->rows[i]);
183  TDS_ZERO_FREE(buf->rows);
184  }
185  BUFFER_CHECK(buf);
186 }
187 
188 /*
189  * When no rows are currently buffered (and the buffer is allocated)
190  * set the indices to their initial positions.
191  */
192 static void
193 buffer_reset(DBPROC_ROWBUF *buf)
194 {
195  buf->head = 0;
196  buf->current = buf->tail = buf->capacity;
197  BUFFER_CHECK(buf);
198 }
199 
200 static int
201 buffer_idx_increment(const DBPROC_ROWBUF *buf, int idx)
202 {
203  if (++idx >= buf->capacity) {
204  idx = 0;
205  }
206  return idx;
207 }
208 
213 static DBLIB_BUFFER_ROW*
214 buffer_row_address(const DBPROC_ROWBUF * buf, int idx)
215 {
216  BUFFER_CHECK(buf);
217  if (idx < 0 || idx >= buf->capacity) {
218  printf("idx is %d:\n", idx);
219  buffer_struct_print(buf);
220  return NULL;
221  }
222 
223  return &(buf->rows[idx]);
224 }
225 
229 static DBINT
230 buffer_idx2row(const DBPROC_ROWBUF *buf, int idx)
231 {
232  BUFFER_CHECK(buf);
233  return buffer_row_address(buf, idx)->row;
234 }
235 
239 static int
240 buffer_row2idx(const DBPROC_ROWBUF *buf, int row_number)
241 {
242  int i = buf->tail;
243 #ifndef NDEBUG
244  int ii = 0;
245 #endif
246 
247  BUFFER_CHECK(buf);
248  if (i == buf->capacity) {
249  assert (buf->head == 0);
250  return -1; /* no rows buffered */
251  }
252 
253  /*
254  * March through the buffers from tail to head, stop if we find our row.
255  * A full queue is indicated by tail == head (which means we can't write).
256  */
257  do {
258  if (buffer_idx2row(buf, i) == row_number)
259  return i;
260 
261  assert(ii++ < buf->capacity); /* prevent infinite loop */
262 
263  i = buffer_idx_increment(buf, i);
264  } while (i != buf->head);
265 
266  return -1;
267 }
268 
273 static void
274 buffer_delete_rows(DBPROC_ROWBUF * buf, int count)
275 {
276  int i;
277 
278  BUFFER_CHECK(buf);
279  if (count < 0 || count > buffer_count(buf)) {
280  count = buffer_count(buf);
281  }
282 
283  for (i=0; i < count; i++) {
284  if (buf->tail < buf->capacity)
285  buffer_free_row(&buf->rows[buf->tail]);
286  buf->tail = buffer_idx_increment(buf, buf->tail);
287  /*
288  * If deleting rows from the buffer catches the tail to the head,
289  * return to the initial position. Otherwise, it will look full.
290  */
291  if (buf->tail == buf->head) {
292  buffer_reset(buf);
293  break;
294  }
295  }
296 #if 0
297  buffer_struct_print(buf);
298 #endif
299  BUFFER_CHECK(buf);
300 }
301 
302 static void
303 buffer_transfer_bound_data(DBPROC_ROWBUF *buf, TDS_INT res_type, TDS_INT compute_id, DBPROCESS * dbproc, int idx)
304 {
305  int i;
306  BYTE *src;
307  const DBLIB_BUFFER_ROW *row;
308 
309  tdsdump_log(TDS_DBG_FUNC, "buffer_transfer_bound_data(%p %d %d %p %d)\n", buf, res_type, compute_id, dbproc, idx);
310  BUFFER_CHECK(buf);
311  assert(buffer_index_valid(buf, idx));
312 
313  row = buffer_row_address(buf, idx);
314  assert(row->resinfo);
315 
316  for (i = 0; i < row->resinfo->num_cols; i++) {
317  TDS_SERVER_TYPE srctype;
318  DBINT srclen;
319  TDSCOLUMN *curcol = row->resinfo->columns[i];
320 
321  if (row->sizes)
322  curcol->column_cur_size = row->sizes[i];
323 
324  srclen = curcol->column_cur_size;
325 
326  if (curcol->column_nullbind) {
327  if (srclen < 0) {
328  *(DBINT *)(curcol->column_nullbind) = -1;
329  } else {
330  *(DBINT *)(curcol->column_nullbind) = 0;
331  }
332  }
333  if (!curcol->column_varaddr)
334  continue;
335 
336  if (srclen <= 0) {
337  if (srclen == 0 || !curcol->column_nullbind)
338  dbgetnull(dbproc, curcol->column_bindtype, curcol->column_bindlen,
339  (BYTE *) curcol->column_varaddr);
340  continue;
341  }
342 
343  srctype = tds_get_conversion_type(curcol->column_type, curcol->column_size);
344 
345  if (row->row_data)
346  src = &row->row_data[curcol->column_data - row->resinfo->current_row];
347  else
348  src = curcol->column_data;
349  if (is_blob_col(curcol))
350  src = (BYTE *) ((TDSBLOB *) src)->textvalue;
351 
352  copy_data_to_host_var(dbproc, srctype, src, srclen,
353  (BYTE *) curcol->column_varaddr, curcol->column_bindlen,
354  curcol->column_bindtype, (DBINT*) curcol->column_nullbind);
355  }
356 
357  /*
358  * This function always bumps current. Usually, it's called
359  * by dbnextrow(), so bumping current is a pretty obvious choice.
360  * It can also be called by dbgetrow(), but that function also
361  * causes the bump. If you call dbgetrow() for row N, a subsequent
362  * call to dbnextrow() yields N+1.
363  */
364  buf->current = buffer_idx_increment(buf, buf->current);
365 
366 } /* end buffer_transfer_bound_data() */
367 
368 static void
369 buffer_struct_print(const DBPROC_ROWBUF *buf)
370 {
371  assert(buf);
372 
373  printf("\t%d rows in buffer\n", buffer_count(buf));
374 
375  printf("\thead = %d\t", buf->head);
376  printf("\ttail = %d\t", buf->tail);
377  printf("\tcurrent = %d\n", buf->current);
378  printf("\tcapacity = %d\t", buf->capacity);
379  printf("\thead row number = %d\n", buf->received);
380 }
381 
382 /* * * Functions called only by public db-lib API take DBPROCESS* * */
383 
400 static int
401 buffer_current_index(const DBPROCESS *dbproc)
402 {
403  const DBPROC_ROWBUF *buf = &dbproc->row_buf;
404 #if 0
405  buffer_struct_print(buf);
406 #endif
407  if (buf->capacity <= 1) /* no buffering */
408  return -1;
409  if (buf->current == buf->head || buf->current == buf->capacity)
410  return -1;
411 
412  assert(buf->current >= 0);
413  assert(buf->current < buf->capacity);
414 
415  if( buf->tail < buf->head) {
416  assert(buf->tail < buf->current);
417  assert(buf->current < buf->head);
418  } else {
419  if (buf->current > buf->head)
420  assert(buf->current > buf->tail);
421  }
422  return buf->current;
423 }
424 
425 /*
426  * Normally called by dbsetopt() to prepare for buffering
427  * Called with nrows == 0 by dbopen to safely set buf->rows to NULL.
428  */
429 static void
430 buffer_set_capacity(DBPROCESS *dbproc, int nrows)
431 {
432  DBPROC_ROWBUF *buf = &dbproc->row_buf;
433 
434  buffer_free(buf);
435 
436  memset(buf, 0, sizeof(DBPROC_ROWBUF));
437 
438  if (0 == nrows) {
439  buf->capacity = 1;
440  BUFFER_CHECK(buf);
441  return;
442  }
443 
444  assert(0 < nrows);
445 
446  buf->capacity = nrows;
447  BUFFER_CHECK(buf);
448 }
449 
450 /*
451  * Called only by dbresults(); capacity must be >= 1.
452  * Sybase's documents say dbresults() cannot return FAIL if the prior calls worked,
453  * which is a little strange, because (for FreeTDS, at least), dbresults
454  * is when we learn about the result set's width. Without that information, we
455  * can't allocate memory for the buffer. But if we *fail* to allocate memory,
456  * we're not to communicate it back to the caller?
457  */
458 static void
459 buffer_alloc(DBPROCESS *dbproc)
460 {
461  DBPROC_ROWBUF *buf = &dbproc->row_buf;
462 
463  /* Call this function only after setting capacity. */
464 
465  assert(buf);
466  assert(buf->capacity > 0);
467  assert(buf->rows == NULL);
468 
469  buf->rows = tds_new0(DBLIB_BUFFER_ROW, buf->capacity);
470 
471  assert(buf->rows);
472 
473  buffer_reset(buf);
474 
475  buf->received = 0;
476 }
477 
482 static int
483 buffer_add_row(DBPROCESS *dbproc, TDSRESULTINFO *resinfo)
484 {
485  DBPROC_ROWBUF *buf = &dbproc->row_buf;
487  int i;
488 
489  assert(buf->capacity >= 0);
490 
491  if (buffer_is_full(buf))
492  return -1;
493 
494  row = buffer_row_address(buf, buf->head);
495 
496  /* bump the row number, write it, and move the data to head */
497  if (row->resinfo) {
498  tds_free_row(row->resinfo, row->row_data);
499  tds_free_results(row->resinfo);
500  }
501  row->row = ++buf->received;
502  ++resinfo->ref_count;
503  row->resinfo = resinfo;
504  row->row_data = NULL;
505  if (row->sizes)
506  free(row->sizes);
507  row->sizes = tds_new0(TDS_INT, resinfo->num_cols);
508  for (i = 0; i < resinfo->num_cols; ++i)
509  row->sizes[i] = resinfo->columns[i]->column_cur_size;
510 
511  /* initial condition is head == 0 and tail == capacity */
512  if (buf->tail == buf->capacity) {
513  /* bumping this tail will set it to zero */
514  assert(buf->head == 0);
515  buf->tail = 0;
516  }
517 
518  /* update current, bump the head */
519  buf->current = buf->head;
520  buf->head = buffer_idx_increment(buf, buf->head);
521 
522  return buf->current;
523 }
524 
525 static RETCODE
526 buffer_save_row(DBPROCESS *dbproc)
527 {
528  DBPROC_ROWBUF *buf = &dbproc->row_buf;
530  int idx = buf->head - 1;
531 
532  if (buf->capacity <= 1)
533  return SUCCEED;
534 
535  if (idx < 0)
536  idx = buf->capacity - 1;
537  if (idx >= 0 && idx < buf->capacity) {
538  row = &buf->rows[idx];
539 
540  if (row->resinfo && !row->row_data) {
541  row->row_data = row->resinfo->current_row;
542  tds_alloc_row(row->resinfo);
543  }
544  }
545 
546  return SUCCEED;
547 }
548 
TDS_INT column_size
maximun size of data.
Definition: tds.h:732
Definition: dblib.h:120
RETCODE dbgetnull(DBPROCESS *dbproc, int bindtype, int varlen, BYTE *varaddr)
Definition: dblib.c:540
TDS_SERVER_TYPE column_type
This type can be different from wire type because conversion (e.g.
Definition: tds.h:734
Hold information for any results.
Definition: tds.h:803
TDS_INT * sizes
save old sizes
Definition: buffering.h:9
Definition: buffering.h:1
TDSRESULTINFO * resinfo
pointer to result informations
Definition: buffering.h:3
void tdsdump_log(const char *file, unsigned int level_line, const char *fmt,...)
Write a message to the debug log.
Definition: log.c:353
DBINT row
row number
Definition: buffering.h:7
Information about blobs (e.g.
Definition: tds.h:623
TDSRET tds_alloc_row(TDSRESULTINFO *res_info)
Allocate space for row store return NULL on out of memory.
Definition: mem.c:521
Metadata about columns in regular and compute rows.
Definition: tds.h:726
unsigned char * row_data
row data, NULL for resinfo->current_row
Definition: buffering.h:5
TDS_INT column_cur_size
size written in variable (ie: char, text, binary).
Definition: tds.h:773
Definition: dblib.h:49
TDS_SERVER_TYPE tds_get_conversion_type(TDS_SERVER_TYPE srctype, int colsize)
Return type suitable for conversions (convert all nullable types to fixed type)
Definition: tds_types.h:125
freetds-1.00.82/doc/reference/a00077.html100644 025423 025423 00000405447 13242511136 0013251 FreeTDS API: src/dblib/dblib.c File Reference
FreeTDS API
dblib.c File Reference

Main implementation file for db-lib. More...

#include <config.h>
#include <stdarg.h>
#include <freetds/time.h>
#include <assert.h>
#include <stdio.h>
#include <freetds/tds.h>
#include <freetds/thread.h>
#include <freetds/convert.h>
#include <freetds/string.h>
#include <freetds/data.h>
#include <replacements.h>
#include <sybfront.h>
#include <sybdb.h>
#include <syberror.h>
#include <dblib.h>
#include "buffering.h"
Include dependency graph for dblib.c:

Classes

struct  _dblib_error_message
 
struct  dblib_context
 

Typedefs

typedef struct _dblib_error_message DBLIB_ERROR_MESSAGE
 
typedef struct dblib_context DBLIBCONTEXT
 
typedef char prbuf_t[24]
 

Functions

static BYTE * _dbcoldata (TDSCOLUMN *colinfo)
 Return data from a column. More...
 
static int _dbnullable (DBPROCESS *dbproc, int column)
 
static char * _dbprdate (char *timestr)
 
static RETCODE _dbresults (DBPROCESS *dbproc)
 
static int _get_printable_size (TDSCOLUMN *colinfo)
 
void copy_data_to_host_var (DBPROCESS *, TDS_SERVER_TYPE, const BYTE *, int, BYTE *, DBINT, int, DBINT *)
 
void copy_data_to_host_var (DBPROCESS *dbproc, TDS_SERVER_TYPE srctype, const BYTE *src, DBINT srclen, BYTE *dest, DBINT destlen, int bindtype, DBINT *indicator)
 
static void db_env_chg (TDSSOCKET *tds, int type, char *oldval, char *newval)
 
static TDSCOLUMNdbacolptr (DBPROCESS *dbproc, int computeid, int column, int is_bind)
 
BYTE * dbadata (DBPROCESS *dbproc, int computeid, int column)
 Get address of compute column data. More...
 
DBINT dbadlen (DBPROCESS *dbproc, int computeid, int column)
 Get size of data in a compute column. More...
 
RETCODE dbaltbind (DBPROCESS *dbproc, int computeid, int column, int vartype, DBINT varlen, BYTE *varaddr)
 Bind a compute column to a program variable. More...
 
int dbaltcolid (DBPROCESS *dbproc, int computeid, int column)
 Get column ID of a compute column. More...
 
DBINT dbaltlen (DBPROCESS *dbproc, int computeid, int column)
 Get size of data in compute column. More...
 
int dbaltop (DBPROCESS *dbproc, int computeid, int column)
 Get aggregation operator for a compute column. More...
 
int dbalttype (DBPROCESS *dbproc, int computeid, int column)
 Get datatype for a compute column. More...
 
DBINT dbaltutype (DBPROCESS *dbproc, int computeid, int column)
 Get user-defined datatype of a compute column. More...
 
RETCODE dbanullbind (DBPROCESS *dbproc, int computeid, int column, DBINT *indicator)
 Tie a null-indicator to a compute result column. More...
 
RETCODE dbanydatecrack (DBPROCESS *dbproc, DBDATEREC2 *di, int type, const void *data)
 Break any kind of date or time value into useful pieces. More...
 
RETCODE dbbind (DBPROCESS *dbproc, int column, int vartype, DBINT varlen, BYTE *varaddr)
 Tie a host variable to a resultset column. More...
 
static int dbbindtype (int datatype)
 
BYTE * dbbylist (DBPROCESS *dbproc, int computeid, int *size)
 Get bylist for a compute row. More...
 
RETCODE dbcancel (DBPROCESS *dbproc)
 Cancel the current command batch. More...
 
RETCODE dbcanquery (DBPROCESS *dbproc)
 Cancel the query currently being retrieved, discarding all pending rows. More...
 
char * dbchange (DBPROCESS *dbproc)
 See if a command caused the current database to change. More...
 
void dbclose (DBPROCESS *dbproc)
 Close a connection to the server and free associated resources. More...
 
void dbclrbuf (DBPROCESS *dbproc, DBINT n)
 Clear n rows from the row buffer. More...
 
RETCODE dbclropt (DBPROCESS *dbproc, int option, const char param[])
 Reset an option. More...
 
RETCODE dbcmd (DBPROCESS *dbproc, const char cmdstring[])
 Append SQL to the command buffer. More...
 
RETCODE dbcmdrow (DBPROCESS *dbproc)
 See if the current command can return rows. More...
 
RETCODE dbcolinfo (DBPROCESS *dbproc, CI_TYPE type, DBINT column, DBINT computeid, DBCOL *pdbcol)
 Get a bunch of column attributes with a single call (Microsoft-compatibility feature). More...
 
DBINT dbcollen (DBPROCESS *dbproc, int column)
 Get size of a regular result column. More...
 
char * dbcolname (DBPROCESS *dbproc, int column)
 Return name of a regular result column. More...
 
static TDSCOLUMNdbcolptr (DBPROCESS *dbproc, int column)
 Sanity checks for column-oriented functions. More...
 
char * dbcolsource (DBPROCESS *dbproc, int column)
 Get base database column name for a result set column. More...
 
int dbcoltype (DBPROCESS *dbproc, int column)
 Get the datatype of a regular result set column. More...
 
DBTYPEINFOdbcoltypeinfo (DBPROCESS *dbproc, int column)
 Get precision and scale information for a regular result column. More...
 
int dbcolutype (DBPROCESS *dbproc, int column)
 Get user-defined datatype of a regular result column. More...
 
DBINT dbconvert (DBPROCESS *dbproc, int srctype, const BYTE *src, DBINT srclen, int desttype, BYTE *dest, DBINT destlen)
 cf. More...
 
DBINT dbconvert_ps (DBPROCESS *dbproc, int db_srctype, const BYTE *src, DBINT srclen, int db_desttype, BYTE *dest, DBINT destlen, DBTYPEINFO *typeinfo)
 Convert one datatype to another. More...
 
DBINT dbcount (DBPROCESS *dbproc)
 Get count of rows processed. More...
 
int dbcurcmd (DBPROCESS *dbproc)
 Get number of the row just returned. More...
 
DBINT dbcurrow (DBPROCESS *dbproc)
 Get number of the row currently being read. More...
 
BYTE * dbdata (DBPROCESS *dbproc, int column)
 Get address of data in a regular result column. More...
 
int dbdatecmp (DBPROCESS *dbproc, DBDATETIME *d1, DBDATETIME *d2)
 Compare DBDATETIME values, similar to strcmp(3). More...
 
RETCODE dbdatecrack (DBPROCESS *dbproc, DBDATEREC *di, DBDATETIME *datetime)
 Break a DBDATETIME value into useful pieces. More...
 
DBINT dbdatlen (DBPROCESS *dbproc, int column)
 Get size of current row's data in a regular result column. More...
 
DBBOOL dbdead (DBPROCESS *dbproc)
 Check if dbproc is an ex-parrot. More...
 
EHANDLEFUNC dberrhandle (EHANDLEFUNC handler)
 Set an error handler, for messages from db-lib. More...
 
void dbexit ()
 Close server connections and free all related structures. More...
 
RETCODE dbfcmd (DBPROCESS *dbproc, const char *fmt,...)
 printf-like way to form SQL to send to the server. More...
 
DBINT dbfirstrow (DBPROCESS *dbproc)
 See if a server response has arrived. More...
 
void dbfreebuf (DBPROCESS *dbproc)
 Erase the command buffer, in case DBNOAUTOFREE was set with dbsetopt(). More...
 
char * dbgetchar (DBPROCESS *dbproc, int pos)
 Get address of a position in the command buffer. More...
 
int dbgetmaxprocs (void)
 get maximum simultaneous connections db-lib will open to the server. More...
 
RETCODE dbgetnull (DBPROCESS *dbproc, int bindtype, int varlen, BYTE *varaddr)
 
int dbgetpacket (DBPROCESS *dbproc)
 Get TDS packet size for the connection. More...
 
RETCODE dbgetrow (DBPROCESS *dbproc, DBINT row)
 Read a row from the row buffer. More...
 
int dbgettime (void)
 Get maximum seconds db-lib waits for a server response to query. More...
 
BYTE * dbgetuserdata (DBPROCESS *dbproc)
 Get address of user-allocated data from a DBPROCESS. More...
 
DBBOOL dbhasretstat (DBPROCESS *dbproc)
 Determine if query generated a return status number. More...
 
RETCODE dbinit (void)
 Initialize db-lib. More...
 
int dbiordesc (DBPROCESS *dbproc)
 Get file descriptor of the socket used by a DBPROCESS to read data coming from the server. (!) More...
 
int dbiowdesc (DBPROCESS *dbproc)
 Get file descriptor of the socket used by a DBPROCESS to write data coming to the server. (!) More...
 
DBBOOL dbisavail (DBPROCESS *dbproc)
 
BOOL dbiscount (DBPROCESS *dbproc)
 Indicates whether or not the count returned by dbcount is real (Microsoft-compatibility feature). More...
 
DBBOOL dbisopt (DBPROCESS *dbproc, int option, const char param[])
 Get value of an option. More...
 
DBINT dblastrow (DBPROCESS *dbproc)
 Get number of the last row in the row buffer. More...
 
static int dblib_add_connection (DBLIBCONTEXT *ctx, TDSSOCKET *tds)
 
static TDS_SERVER_TYPE dblib_bound_type (int bindtype)
 
static RETCODE dblib_datecrack (DBPROCESS *dbproc, BOOL nano_precision, DBDATEREC *output, int type, const void *data)
 
static void dblib_del_connection (DBLIBCONTEXT *ctx, TDSSOCKET *tds)
 
static TDSCONTEXTdblib_get_tds_ctx (void)
 
static void dblib_release_tds_ctx (int count)
 
LOGINRECdblogin (void)
 Allocate a LOGINREC structure. More...
 
void dbloginfree (LOGINREC *login)
 free the LOGINREC More...
 
RETCODE dbmny4add (DBPROCESS *dbproc, DBMONEY4 *m1, DBMONEY4 *m2, DBMONEY4 *sum)
 Add two DBMONEY4 values. More...
 
int dbmny4cmp (DBPROCESS *dbproc, DBMONEY4 *m1, DBMONEY4 *m2)
 Compare two DBMONEY4 values. More...
 
RETCODE dbmny4copy (DBPROCESS *dbproc, DBMONEY4 *src, DBMONEY4 *dest)
 Copy a DBMONEY4 value. More...
 
RETCODE dbmny4minus (DBPROCESS *dbproc, DBMONEY4 *src, DBMONEY4 *dest)
 Negate a DBMONEY4 value. More...
 
RETCODE dbmny4sub (DBPROCESS *dbproc, DBMONEY4 *m1, DBMONEY4 *m2, DBMONEY4 *diff)
 Subtract two DBMONEY4 values. More...
 
RETCODE dbmny4zero (DBPROCESS *dbproc, DBMONEY4 *dest)
 Zero a DBMONEY4 value. More...
 
int dbmnycmp (DBPROCESS *dbproc, DBMONEY *m1, DBMONEY *m2)
 Compare two DBMONEY values. More...
 
RETCODE dbmnycopy (DBPROCESS *dbproc, DBMONEY *src, DBMONEY *dest)
 Copy a DBMONEY value. More...
 
RETCODE dbmnydec (DBPROCESS *dbproc, DBMONEY *amount)
 Subtract $0.0001 from a DBMONEY value. More...
 
RETCODE dbmnyinc (DBPROCESS *dbproc, DBMONEY *amount)
 Add $0.0001 to a DBMONEY value. More...
 
RETCODE dbmnymaxneg (DBPROCESS *dbproc, DBMONEY *amount)
 Get maximum negative DBMONEY value supported. More...
 
RETCODE dbmnymaxpos (DBPROCESS *dbproc, DBMONEY *amount)
 Get maximum positive DBMONEY value supported. More...
 
RETCODE dbmnyminus (DBPROCESS *dbproc, DBMONEY *src, DBMONEY *dest)
 Negate a DBMONEY value. More...
 
RETCODE dbmnyzero (DBPROCESS *dbproc, DBMONEY *dest)
 Set a DBMONEY value to zero. More...
 
const char * dbmonthname (DBPROCESS *dbproc, char *language, int monthnum, DBBOOL shortform)
 Get name of a month, in some human language. More...
 
RETCODE dbmorecmds (DBPROCESS *dbproc)
 See if more commands are to be processed. More...
 
RETCODE dbmoretext (DBPROCESS *dbproc, DBINT size, const BYTE text[])
 Send chunk of a text/image value to the server. More...
 
MHANDLEFUNC dbmsghandle (MHANDLEFUNC handler)
 Set a message handler, for messages from the server. More...
 
char * dbname (DBPROCESS *dbproc)
 Get name of current database. More...
 
STATUS dbnextrow (DBPROCESS *dbproc)
 
RETCODE dbnullbind (DBPROCESS *dbproc, int column, DBINT *indicator)
 Tie a null-indicator to a regular result column. More...
 
int dbnumalts (DBPROCESS *dbproc, int computeid)
 Get count of columns in a compute row. More...
 
int dbnumcols (DBPROCESS *dbproc)
 Return number of regular columns in a result set. More...
 
int dbnumcompute (DBPROCESS *dbproc)
 Get count of COMPUTE clauses for a result set. More...
 
int dbnumrets (DBPROCESS *dbproc)
 Get count of output parameters filled by a stored procedure. More...
 
int dbperror (DBPROCESS *dbproc, DBINT msgno, long errnum,...)
 Call client-installed error handler. More...
 
DBINT dbprcollen (DBPROCESS *dbproc, int column)
 Get size of a result column needed to print column. More...
 
void dbprhead (DBPROCESS *dbproc)
 Print result set headings to stdout. More...
 
RETCODE dbprrow (DBPROCESS *dbproc)
 Print a result set to stdout. More...
 
const char * dbprtype (int token)
 Print a token value's name to a buffer. More...
 
STATUS dbreadtext (DBPROCESS *dbproc, void *buf, DBINT bufsize)
 Fetch part of a text or image value from the server. More...
 
void dbrecftos (const char filename[])
 Record to a file all SQL commands sent to the server. More...
 
RETCODE dbresults (DBPROCESS *dbproc)
 Set up query results. More...
 
BYTE * dbretdata (DBPROCESS *dbproc, int retnum)
 Get value of an output parameter filled by a stored procedure. More...
 
int dbretlen (DBPROCESS *dbproc, int retnum)
 Get size of an output parameter filled by a stored procedure. More...
 
char * dbretname (DBPROCESS *dbproc, int retnum)
 Get name of an output parameter filled by a stored procedure. More...
 
DBINT dbretstatus (DBPROCESS *dbproc)
 Fetch status value returned by query or remote procedure call. More...
 
int dbrettype (DBPROCESS *dbproc, int retnum)
 Get datatype of a stored procedure's return parameter. More...
 
RETCODE dbrows (DBPROCESS *dbproc)
 Indicate whether a query returned rows. More...
 
STATUS dbrowtype (DBPROCESS *dbproc)
 Get returned row's type. More...
 
RETCODE dbsafestr (DBPROCESS *dbproc, const char *src, DBINT srclen, char *dest, DBINT destlen, int quotetype)
 safely quotes character values in SQL text. More...
 
char * dbservcharset (DBPROCESS *dbproc)
 Get syscharset name of the server character set. More...
 
void dbsetavail (DBPROCESS *dbproc)
 Mark a DBPROCESS as "available". More...
 
void dbsetifile (char *filename)
 set name and location of the interfaces file FreeTDS should use to look up a servername. More...
 
void dbsetinterrupt (DBPROCESS *dbproc, DB_DBCHKINTR_FUNC chkintr, DB_DBHNDLINTR_FUNC hndlintr)
 Set interrupt handler for db-lib to use while blocked against a read from the server. More...
 
RETCODE dbsetlbool (LOGINREC *login, int value, int which)
 Set a boolean value in a LOGINREC structure. More...
 
RETCODE dbsetllong (LOGINREC *login, long value, int which)
 Set an integer value in a LOGINREC structure. More...
 
RETCODE dbsetlname (LOGINREC *login, const char *value, int which)
 Set the value of a string in a LOGINREC structure. More...
 
RETCODE dbsetlogintime (int seconds)
 Set maximum seconds db-lib waits for a server response to a login attempt. More...
 
RETCODE dbsetlversion (LOGINREC *login, BYTE version)
 Set TDS version for future connections. More...
 
RETCODE dbsetmaxprocs (int maxprocs)
 Set maximum simultaneous connections db-lib will open to the server. More...
 
RETCODE dbsetnull (DBPROCESS *dbproc, int bindtype, int bindlen, BYTE *bindval)
 Define substitution values to be used when binding null values. More...
 
RETCODE dbsetopt (DBPROCESS *dbproc, int option, const char *char_param, int int_param)
 Set db-lib or server option. More...
 
STATUS dbsetrow (DBPROCESS *dbproc, DBINT row)
 Make a buffered row "current" without fetching it into bound variables. More...
 
RETCODE dbsettime (int seconds)
 Set maximum seconds db-lib waits for a server response to query. More...
 
void dbsetuserdata (DBPROCESS *dbproc, BYTE *ptr)
 Associate client-allocated (and defined) data with a DBPROCESS. More...
 
RETCODE dbsetversion (DBINT version)
 Specify a db-lib version level. More...
 
int dbspid (DBPROCESS *dbproc)
 Get server process ID for a DBPROCESS. More...
 
RETCODE dbspr1row (DBPROCESS *dbproc, char *buffer, DBINT buf_len)
 Print a regular result row to a buffer. More...
 
DBINT dbspr1rowlen (DBPROCESS *dbproc)
 Determine size buffer required to hold the results returned by dbsprhead(), dbsprline(), and dbspr1row(). More...
 
RETCODE dbsprhead (DBPROCESS *dbproc, char *buffer, DBINT buf_len)
 Print result set headings to a buffer. More...
 
RETCODE dbsprline (DBPROCESS *dbproc, char *buffer, DBINT buf_len, DBCHAR line_char)
 Get formatted string for underlining dbsprhead() column names. More...
 
RETCODE dbsqlexec (DBPROCESS *dbproc)
 send the SQL command to the server and wait for an answer. More...
 
RETCODE dbsqlok (DBPROCESS *dbproc)
 Wait for results of a query from the server. More...
 
RETCODE dbsqlsend (DBPROCESS *dbproc)
 Transmit the command buffer to the server. More...
 
RETCODE dbstrbuild (DBPROCESS *dbproc, char *charbuf, int bufsize, char *text, char *formats,...)
 Build a printable string from text containing placeholders for variables. More...
 
RETCODE dbstrcpy (DBPROCESS *dbproc, int start, int numbytes, char *dest)
 Get a copy of a chunk of the command buffer. More...
 
static RETCODE dbstring_assign (DBSTRING **dbstrp, const char *p)
 
static RETCODE dbstring_concat (DBSTRING **dbstrp, const char *p)
 
static void dbstring_free (DBSTRING **dbstrp)
 
static char * dbstring_get (DBSTRING *dbstr)
 
static int dbstring_getchar (DBSTRING *dbstr, int i)
 
static DBINT dbstring_length (DBSTRING *dbstr)
 
int dbstrlen (DBPROCESS *dbproc)
 Get size of the command buffer, in bytes. More...
 
RETCODE dbtablecolinfo (DBPROCESS *dbproc, DBINT column, DBCOL *pdbcol)
 describe table column attributes with a single call (Freetds-only API function modelled on dbcolinfo) More...
 
int dbtds (DBPROCESS *dbproc)
 Get the TDS version in use for dbproc. More...
 
DBBINARY * dbtxptr (DBPROCESS *dbproc, int column)
 Get text pointer for a column in the current row. More...
 
DBBINARY * dbtxtimestamp (DBPROCESS *dbproc, int column)
 Get text timestamp for a column in the current row. More...
 
RETCODE dbuse (DBPROCESS *dbproc, const char *name)
 Change current database. More...
 
DBINT dbvarylen (DBPROCESS *dbproc, int column)
 Determine whether a column can vary in size. More...
 
const char * dbversion ()
 See which version of db-lib is in use. More...
 
DBBOOL dbwillconvert (int srctype, int desttype)
 Test whether or not a datatype can be converted to another datatype. More...
 
RETCODE dbwritetext (DBPROCESS *dbproc, char *objname, DBBINARY *textptr, DBTINYINT textptrlen, DBBINARY *timestamp, DBBOOL log, DBINT size, BYTE *text)
 Send text or image data to the server. More...
 
static int default_err_handler (DBPROCESS *dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr)
 default error handler for db-lib (handles library-generated errors) More...
 
static DBOPTIONinit_dboptions (void)
 
static const char * prdbresults_state (int retcode, prbuf_t buf)
 
static const char * prdbretcode (RETCODE retcode, prbuf_t buf)
 
static const char * prresult_type (int result_type, prbuf_t buf)
 
static const char * prretcode (int retcode, prbuf_t buf)
 
static const char * tds_prdatatype (int datatype_token)
 Returns type in string. More...
 
DBPROCESStdsdbopen (LOGINREC *login, const char *server, int msdblib)
 Form a connection with the server. More...
 

Variables

EHANDLEFUNC _dblib_err_handler = default_err_handler
 
MHANDLEFUNC _dblib_msg_handler = NULL
 
static const DBLIB_ERROR_MESSAGE dblib_error_messages []
 
static tds_mutex dblib_mutex = TDS_MUTEX_INITIALIZER
 
static NULLREP default_null_representations [MAXBINDTYPES]
 
static DBLIBCONTEXT g_dblib_ctx
 
static int g_dblib_version
 
static const DBBIGINT null_BIGINT = 0
 
static const DBBINARY null_BINARY = 0
 
static const DBBIT null_BIT = 0
 
static const DBCHAR null_CHAR = '\0'
 
static const DBDATETIME null_DATETIME = { 0, 0 }
 
static const TDS_DATETIMEALL null_DATETIMEALL = { 0, 0, 0, 0 }
 
static const DBFLT8 null_FLT8 = 0
 
static const DBINT null_INT = 0
 
static const DBMONEY null_MONEY = { 0, 0 }
 
static const DBNUMERIC null_NUMERIC = { 0, 0, {0} }
 
static const DBREAL null_REAL = 0
 
static const DBDATETIME4 null_SMALLDATETIME = { 0, 0 }
 
static const DBSMALLINT null_SMALLINT = 0
 
static const DBMONEY4 null_SMALLMONEY = {0}
 
static const DBTINYINT null_TINYINT = 0
 
static const DBVARYCHAR null_VARYCHAR = { 0, {0} }
 
static const char *const opttext [DBNUMOPTIONS]
 

Detailed Description

Main implementation file for db-lib.

Typedef Documentation

§ DBLIBCONTEXT

typedef struct dblib_context DBLIBCONTEXT
Remarks
A db-lib connection has an implicit TDS context.

Function Documentation

§ dbcolinfo()

RETCODE dbcolinfo ( DBPROCESS dbproc,
CI_TYPE  type,
DBINT  column,
DBINT  computeid,
DBCOL pdbcol 
)

Get a bunch of column attributes with a single call (Microsoft-compatibility feature).

Parameters
dbproccontains all information needed by db-lib to manage communications with the server.
typemust be CI_REGULAR or CI_ALTERNATE (CI_CURSOR is defined by the vendor, but is not yet implemented).
columnNth in the result set, starting from 1.
computeid(ignored)
pdbcoladdress of structure to be populated by this function.
Returns
SUCCEED or FAIL.
See also
dbcolbrowse(), dbqual(), dbtabbrowse(), dbtabcount(), dbtabname(), dbtabsource(), dbtsnewlen(), dbtsnewval(), dbtsput().
Todo:
Support cursor rows.
Here is the call graph for this function:

§ dbgetnull()

RETCODE dbgetnull ( DBPROCESS dbproc,
int  bindtype,
int  varlen,
BYTE *  varaddr 
)

dbbind() says: "Note that if varlen is 0, no padding takes place" dbgetnull() will not pad varaddr unless varlen is positive. Vartype Program Type Padding Terminator


CHARBIND DBCHAR blanks none STRINGBIND DBCHAR blanks \0 NTBSTRINGBIND DBCHAR none \0 VARYCHARBIND DBVARYCHAR none none BOUNDARYBIND DBCHAR none \0 SENSITIVITYBIND DBCHAR none \0

Here is the call graph for this function:

§ tds_prdatatype()

static const char * tds_prdatatype ( int  datatype_token)
static

Returns type in string.

Used for debugging purpose

Variable Documentation

§ g_dblib_version

int g_dblib_version
static
Initial value:
=
#define DBVERSION_UNKNOWN
DBVERSION_xxx are used with dbsetversion()
Definition: sybdb.h:70
freetds-1.00.82/doc/reference/a00077_a9b73fd1afa2c3ccfca481635212d2e43_cgraph.map100644 025423 025423 00000000313 13242511134 0021305 freetds-1.00.82/doc/reference/a00077_a9b73fd1afa2c3ccfca481635212d2e43_cgraph.md5100644 025423 025423 00000000040 13242511133 0021211214a36c80c247fb3fccfe97d55de1efffreetds-1.00.82/doc/reference/a00077_a9b73fd1afa2c3ccfca481635212d2e43_cgraph.svg100644 025423 025423 00000003110 13242511136 0021327 dbcolinfo Node0 dbcolinfo Node1 tdsdump_log Node0->Node1 freetds-1.00.82/doc/reference/a00077_aea6a865806d454280126de940478c214_cgraph.map100644 025423 025423 00000000313 13242511134 0020610 freetds-1.00.82/doc/reference/a00078.map100644 025423 025423 00000005165 13242511134 0013052 freetds-1.00.82/doc/reference/a00078.md5100644 025423 025423 00000000040 13242511133 00127444c450a1d61d2954c684403ad81b67050freetds-1.00.82/doc/reference/a00078.svg100644 025423 025423 00000073020 13242511136 0013071 src/dblib/dblib.c Node0 src/dblib/dblib.c Node1 config.h Node0->Node1 Node2 stdarg.h Node0->Node2 Node3 freetds/time.h Node0->Node3 Node4 assert.h Node0->Node4 Node5 stdio.h Node0->Node5 Node6 freetds/tds.h Node0->Node6 Node10 freetds/thread.h Node0->Node10 Node12 replacements.h Node0->Node12 Node18 freetds/convert.h Node0->Node18 Node19 freetds/string.h Node0->Node19 Node20 freetds/data.h Node0->Node20 Node21 sybfront.h Node0->Node21 Node22 sybdb.h Node0->Node22 Node23 syberror.h Node0->Node23 Node24 dblib.h Node0->Node24 Node25 buffering.h Node0->Node25 Node3->Node3 Node6->Node2 Node6->Node3 Node6->Node5 Node7 freetds/version.h Node6->Node7 Node8 tds_sysdep_public.h Node6->Node8 Node9 freetds/sysdep_private.h Node6->Node9 Node6->Node10 Node11 freetds/bool.h Node6->Node11 Node6->Node12 Node14 freetds/pushvis.h Node6->Node14 Node15 freetds/popvis.h Node6->Node15 Node17 freetds/proto.h Node6->Node17 Node12->Node2 Node12->Node8 Node12->Node9 Node13 replacements/readpassphrase.h Node12->Node13 Node12->Node14 Node12->Node15 Node16 replacements/poll.h Node12->Node16 Node13->Node14 Node13->Node15 Node16->Node1 Node16->Node14 Node16->Node15 Node18->Node14 Node18->Node15 Node19->Node14 Node19->Node15 Node20->Node14 Node20->Node15 Node21->Node22 Node22->Node8 Node24->Node14 Node24->Node15 freetds-1.00.82/doc/reference/a00077_aea6a865806d454280126de940478c214_cgraph.md5100644 025423 025423 00000000040 13242511133 0020514f5370e2c876246c3efa402baadbc0e0afreetds-1.00.82/doc/reference/a00077_aea6a865806d454280126de940478c214_cgraph.svg100644 025423 025423 00000003110 13242511136 0020632 dbgetnull Node3 dbgetnull Node4 tdsdump_log Node3->Node4 freetds-1.00.82/doc/reference/a00089_source.html100644 025423 025423 00000213620 13242511132 0014616 FreeTDS API: src/dblib/error_table.h Source File
FreeTDS API
error_table.h
1 { SYBEICONVI, EXINFO, "WARNING! Some character(s) could not be converted into client's character set. Unconverted bytes were changed to question marks ('?')."},
2 { SYBEICONVO, EXUSER, "Error converting client characters into server's character set. Some character(s) could not be converted."},
3 { SYBEAAMT, EXPROGRAM, "User attempted a dbaltbind() with mismatched column and variable types."},
4 { SYBEABMT, EXPROGRAM, "User attempted a dbbind() with mismatched column and variable types."},
5 { SYBEABNC, EXPROGRAM, "Attempt to bind to a non-existent column."},
6 { SYBEABNP, EXPROGRAM, "Attempt to bind using NULL pointers."},
7 { SYBEABNV, EXPROGRAM, "Attempt to bind to a NULL program variable."},
8 { SYBEACNV, EXCONVERSION, "Attemp to do conversion with NULL destination variable."},
9 { SYBEADST, EXCONSISTENCY, "Error in attempting to determine the size of a pair of translation tables."},
10 { SYBEAICF, EXCONSISTENCY, "Error in attempting to install custom format."},
11 { SYBEALTT, EXCONSISTENCY, "Error in attempting to load a pair of translation tables."},
12 { SYBEAOLF, EXRESOURCE, "Error in attempting to open a localization file."},
13 { SYBEAPCT, EXCONSISTENCY, "Error in attempting to perform a character-set translation."},
14 { SYBEAPUT, EXPROGRAM, "Attempt to print unknown token."},
15 { SYBEARDI, EXRESOURCE, "Error in attempting to read datetime information from a localization file."},
16 { SYBEARDL, EXRESOURCE, "Error in attempting to read the dblib.loc localization file."},
17 { SYBEASEC, EXPROGRAM, "Attempt to send an empty command buffer to the SQL Server."},
18 { SYBEASNL, EXPROGRAM, "Attempt to set fields in a null loginrec."},
19 { SYBEASTF, 1, "VMS: Unable to setmode for control_c ast."},
20 { SYBEASTL, EXPROGRAM, "Synchronous IO attempted at AST level."},
21 { SYBEASUL, EXPROGRAM, "Attempt to set unknown loginrec field."},
22 { SYBEATTNACK, 1, "Timed out waiting for server to acknowledge attention."},
23 { SYBEAUTN, EXPROGRAM, "Attempt to update the timestamp of a table which has no timestamp column."},
24 { SYBEBADPK, EXINFO, "Packet size of %1! not supported. -- size of %2! used instead."},
25 { SYBEBADTYPE, 1, "Illegal value for type parameter given to %1!."},
26 { SYBEBBCI, EXINFO, "Batch successfully bulk-copied to SQL Server."},
27 { SYBEBBFL, 1, "-001- Batch failed in bulk-copy to SQL Server."},
28 { SYBEBBL, EXPROGRAM, "Bad bindlen parameter passed to dbsetnull()."},
29 { SYBEBCBC, EXPROGRAM, "bcp_columns() must be called before bcp_colfmt() and bcp_colfmt_ps()."},
30 { SYBEBCBNPR, EXPROGRAM, "bcp_bind(): if varaddr is NULL, prefixlen must be 0 and no terminator should be specified."},
31 { SYBEBCBNTYP, EXPROGRAM, "bcp_bind(): if varaddr is NULL and varlen greater than 0, the table column type must be SYBTEXT or SYBIMAGE and the program variable type must be SYBTEXT, SYBCHAR, SYBIMAGE or SYBBINARY."},
32 { SYBEBCBPREF, EXPROGRAM, "Illegal prefix length. Legal values are 0, 1, 2 or 4."},
33 { SYBEBCFO, EXUSER, "Bcp host-files must contain at least one column."},
34 { SYBEBCHLEN, EXPROGRAM, "host_collen should be greater than or equal to -1."},
35 { SYBEBCIS, EXCONSISTENCY, "Attempt to bulk-copy an illegally-sized column value to the SQL Server."},
36 { SYBEBCIT, EXPROGRAM, "It's illegal to use BCP terminators with program variables other than SYBCHAR, SYBBINARY, SYBTEXT, or SYBIMAGE."},
37 { SYBEBCITBLEN, EXPROGRAM, "bcp_init(): tblname parameter is too long."},
38 { SYBEBCITBNM, EXPROGRAM, "bcp_init(): tblname parameter cannot be NULL."},
39 { SYBEBCMTXT, EXPROGRAM, "bcp_moretext() may be used only when there is at least one text or image column in the server table."},
40 { SYBEBCNL, EXNONFATAL, "Negative length-prefix found in BCP data-file."},
41 { SYBEBCNN, EXUSER, "Attempt to bulk-copy a NULL value into Server column 0, which does not accept NULL values."},
42 { SYBEBCNT, EXUSER, "Attempt to use Bulk Copy with a non-existent Server table."},
43 { SYBEBCOR, EXCONSISTENCY, "Attempt to bulk-copy an oversized row to the SQL Server."},
44 { SYBEBCPB, EXPROGRAM, "bcp_bind(), bcp_moretext() and bcp_sendrow() may NOT be used after bcp_init() has been passed a non-NULL input file name."},
45 { SYBEBCPCTYP, EXPROGRAM, "bcp_colfmt(): If table_colnum is 0, host_type cannot be 0."},
46 { SYBEBCPI, EXPROGRAM, "bcp_init() must be called before any other bcp routines."},
47 { SYBEBCPN, EXPROGRAM, "bcp_bind(), bcp_collen(), bcp_colptr(), bcp_moretext() and bcp_sendrow() may be used only after bcp_init() has been called with the copy direction set to DB_IN."},
48 { SYBEBCPOPT, 1, "The option cannot be called while a bulk copy operation is progress."},
49 { SYBEBCPREC, EXNONFATAL, "Column %1!: Illegal precision value encountered."},
50 { SYBEBCPREF, EXPROGRAM, "Illegal prefix length. Legal values are -1, 0, 1, 2 or 4."},
51 { SYBEBCRE, EXNONFATAL, "IO error while reading bcp data-file."},
52 { SYBEBCRO, EXINFO, "The BCP hostfile '' contains only 0 rows. It was impossible to read the requested 0 rows."},
53 { SYBEBCSA, EXUSER, "The BCP hostfile '' contains only 0 rows. Skipping all of these rows is not allowed."},
54 { SYBEBCSET, EXCONSISTENCY, "Unknown character-set encountered."},
55 { SYBEBCSI, EXPROGRAM, "Host-file columns may be skipped only when copying INto the Server."},
56 { SYBEBCSNDROW, EXPROGRAM, "bcp_sendrow() may NOT be called unless all text data for the previous row has been sent using bcp_moretext()."},
57 { SYBEBCSNTYP, EXPROGRAM, "column number %1!: if varaddr is NULL and varlen greater than 0, the table column type must be SYBTEXT or SYBIMAGE and the program variable type must be SYBTEXT, SYBCHAR, SYBIMAGE or SYBBINARY."},
58 { SYBEBCUC, EXRESOURCE, "Bcp: Unable to close host data-file."},
59 { SYBEBCUO, EXRESOURCE, "Bcp: Unable to open host data-file."},
60 { SYBEBCVH, EXPROGRAM, "bcp_exec() may be called only after bcp_init() has been passed a valid host file."},
61 { SYBEBCVLEN, EXPROGRAM, "varlen should be greater than or equal to -1."},
62 { SYBEBCWE, EXNONFATAL, "IO error while writing bcp data-file."},
63 { SYBEBDIO, EXPROGRAM, "Bad bulk-copy direction. Must be either IN or OUT."},
64 { SYBEBEOF, EXNONFATAL, "Unexpected EOF encountered in BCP data-file."},
65 { SYBEBIHC, EXPROGRAM, "Incorrect host-column number found in bcp format-file."},
66 { SYBEBIVI, EXPROGRAM, "bcp_columns(), bcp_colfmt() and bcp_colfmt_ps() may be used only after bcp_init() has been passed a valid input file."},
67 { SYBEBNCR, EXPROGRAM, "Attempt to bind user variable to a non-existent compute row."},
68 { SYBEBNUM, EXPROGRAM, "Bad numbytes parameter passed to dbstrcpy()."},
69 { SYBEBOOL, 1, "Boolean parameters must be TRUE or FALSE."},
70 { SYBEBPKS, EXPROGRAM, "In DBSETLPACKET(), the packet size parameter must be between 0 and 999999."},
71 { SYBEBPREC, EXPROGRAM, "Illegal precision specified."},
72 { SYBEBPROBADDEF, EXCONSISTENCY, "bcp protocol error: illegal default column id received."},
73 { SYBEBPROBADLEN, 1, "bcp protocol error: illegal datatype length received."},
74 { SYBEBPROBADPREC, 1, "bcp protocol error: illegal precision value received."},
75 { SYBEBPROBADSCL, 1, "bcp protocol error: illegal scale value received."},
76 { SYBEBPROBADTYP, 1, "bcp protocol error: unknown column datatype."},
77 { SYBEBPROCOL, EXCONSISTENCY, "bcp protocol error: returned column count differs from the actual number of columns received."},
78 { SYBEBPRODEF, EXCONSISTENCY, "bcp protocol error: expected default information and got none."},
79 { SYBEBPRODEFID, EXCONSISTENCY, "bcp protocol error: default column id and actual column id are not same."},
80 { SYBEBPRODEFTYP, EXCONSISTENCY, "bcp protocol error: default value datatype differs from column datatype."},
81 { SYBEBPROEXTDEF, EXCONSISTENCY, "bcp protocol error: more than one row of default information received."},
82 { SYBEBPROEXTRES, EXCONSISTENCY, "bcp protocol error: unexpected set of results received."},
83 { SYBEBPRONODEF, EXCONSISTENCY, "bcp protocol error: default value received for column that does not have default."},
84 { SYBEBPRONUMDEF, EXCONSISTENCY, "bcp protocol error: expected number of defaults differs from the actual number of defaults received."},
85 { SYBEBRFF, EXRESOURCE, "IO error while reading bcp format-file."},
86 { SYBEBSCALE, EXPROGRAM, "Illegal scale specified."},
87 { SYBEBTMT, EXPROGRAM, "Attempt to send too much TEXT data via the bcp_moretext() call."},
88 { SYBEBTOK, EXCOMM, "Bad token from SQL Server: Data-stream processing out of sync."},
89 { SYBEBTYP, EXPROGRAM, "Unknown bind type passed to DB-LIBRARY function."},
90 { SYBEBTYPSRV, EXPROGRAM, "Datatype is not supported by the server."},
91 { SYBEBUCE, EXRESOURCE, "Bcp: Unable to close error-file."},
92 { SYBEBUCF, EXPROGRAM, "Bcp: Unable to close format-file."},
93 { SYBEBUDF, EXPROGRAM, "Bcp: Unrecognized datatype found in format-file."},
94 { SYBEBUFF, EXPROGRAM, "Bcp: Unable to create format-file."},
95 { SYBEBUFL, EXCONSISTENCY, "DB-LIBRARY internal error - send buffer length corrupted."},
96 { SYBEBUOE, EXRESOURCE, "Bcp: Unable to open error-file."},
97 { SYBEBUOF, EXPROGRAM, "Bcp: Unable to open format-file."},
98 { SYBEBWEF, EXNONFATAL, "IO error while writing bcp error-file."},
99 { SYBEBWFF, EXRESOURCE, "IO error while writing bcp format-file."},
100 { SYBECAP, EXCOMM, "DB-Library capabilities not accepted by the Server."},
101 { SYBECAPTYP, EXCOMM, "Unexpected capability type in CAPABILITY datastream."},
102 { SYBECDNS, EXCONSISTENCY, "Datastream indicates that a compute column is derived from a non-existent select-list member."},
103 { SYBECDOMAIN, EXCONVERSION, "Source field value is not within the domain of legal values."},
104 { SYBECINTERNAL, EXCONVERSION, "Internal Conversion error."},
105 { SYBECLOS, EXCOMM, "Error in closing network connection."},
106 { SYBECLOSEIN, 1, "Unable to close interface file."},
107 { SYBECLPR, EXCONVERSION, "Data-conversion resulted in loss of precision."},
108 { SYBECNOR, EXPROGRAM, "Column number out of range."},
109 { SYBECNOV, EXCONVERSION, "Attempt to set variable to NULL resulted in overflow."},
110 { SYBECOFL, EXCONVERSION, "Data-conversion resulted in overflow."},
111 { SYBECONN, EXCOMM, "Unable to connect socket -- SQL Server is unavailable or does not exist."},
112 { SYBECRNC, EXPROGRAM, "The current row is not a result of compute clause 0, so it is illegal to attempt to extract that data from this row."},
113 { SYBECRSAGR, EXPROGRAM, "Aggregate functions are not allowed in a cursor statement."},
114 { SYBECRSBROL, EXPROGRAM, "Backward scrolling cannot be used in a forward scrolling cursor."},
115 { SYBECRSBSKEY, EXPROGRAM, "Keyset cannot be scrolled backward in mixed cursors with a previous fetch type."},
116 { SYBECRSBUFR, EXPROGRAM, "Row buffering should not be turned on when using cursor APIs."},
117 { SYBECRSDIS, EXPROGRAM, "Cursor statement contains one of the disallowed phrases 'compute', 'union', 'for browse', or 'select into'."},
118 { SYBECRSFLAST, EXPROGRAM, "Fetch type LAST requires fully keyset driven cursors."},
119 { SYBECRSFRAND, EXPROGRAM, "Fetch types RANDOM and RELATIVE can only be used within the keyset of keyset driven cursors."},
120 { SYBECRSFROWN, EXPROGRAM, "Row number to be fetched is outside valid range."},
121 { SYBECRSFTYPE, EXRESOURCE, "Unknown fetch type."},
122 { SYBECRSINV, EXPROGRAM, "Invalid cursor statement."},
123 { SYBECRSINVALID, EXRESOURCE, "The cursor handle is invalid."},
124 { SYBECRSMROWS, EXRESOURCE, "Multiple rows are returned, only one is expected."},
125 { SYBECRSNOBIND, EXPROGRAM, "Cursor bind must be called prior to updating cursor."},
126 { SYBECRSNOCOUNT, EXPROGRAM, "The DBNOCOUNT option should not be turned on when doing updates or deletes with dbcursor()."},
127 { SYBECRSNOFREE, EXPROGRAM, "The DBNOAUTOFREE option should not be turned on when using cursor APIs."},
128 { SYBECRSNOIND, EXPROGRAM, "One of the tables involved in the cursor statement does not have a unique index."},
129 { SYBECRSNOKEYS, EXRESOURCE, "The entire keyset must be defined for KEYSET cursors."},
130 { SYBECRSNOLEN, EXRESOURCE, "No unique index found."},
131 { SYBECRSNOPTCC, EXRESOURCE, "No OPTCC was found."},
132 { SYBECRSNORDER, EXRESOURCE, "The order of clauses must be from, where, and order by."},
133 { SYBECRSNORES, EXPROGRAM, "Cursor statement generated no results."},
134 { SYBECRSNOTABLE, EXRESOURCE, "Table name is NULL."},
135 { SYBECRSNOUPD, EXPROGRAM, "Update or delete operation did not affect any rows."},
136 { SYBECRSNOWHERE, EXPROGRAM, "A WHERE clause is not allowed in a cursor update or insert."},
137 { SYBECRSNROWS, EXRESOURCE, "No rows returned, at least one is expected."},
138 { SYBECRSNUNIQUE, EXRESOURCE, "No unique keys associated with this view."},
139 { SYBECRSORD, EXPROGRAM, "Only fully keyset driven cursors can have 'order by', ' group by', or 'having' phrases."},
140 { SYBECRSRO, EXPROGRAM, "Data locking or modifications cannot be made in a READONLY cursor."},
141 { SYBECRSSET, EXPROGRAM, "A SET clause is required for a cursor update or insert."},
142 { SYBECRSTAB, EXPROGRAM, "Table name must be determined in operations involving data locking or modifications."},
143 { SYBECRSUPDNB, EXPROGRAM, "Update or insert operations cannot use bind variables when binding type is NOBIND."},
144 { SYBECRSUPDTAB, EXPROGRAM, "Update or insert operations using bind variables require single table cursors."},
145 { SYBECRSVAR, EXRESOURCE, "There is no valid address associated with this bind."},
146 { SYBECRSVIEW, EXPROGRAM, "A view cannot be joined with another table or a view in a cursor statement."},
147 { SYBECRSVIIND, EXPROGRAM, "The view used in the cursor statement does not include all the unique index columns of the underlying tables."},
148 { SYBECS, 1, "-004- cs context Error."},
149 { SYBECSYN, EXCONVERSION, "Attempt to convert data stopped by syntax error in source field."},
150 { SYBECUFL, EXCONVERSION, "Data-conversion resulted in underflow."},
151 { SYBECWLL, 1, "Attempt to set column width less than 1."},
152 { SYBEDBPS, EXRESOURCE, "Maximum number of DBPROCESSes already allocated."},
153 { SYBEDCL, 1, "-004- DCL Error."},
154 { SYBEDDNE, EXINFO, "DBPROCESS is dead or not enabled."},
155 { SYBEDIVZ, EXUSER, "Attempt to divide by $0.00 in function %1!."},
156 { SYBEDNTI, EXPROGRAM, "Attempt to use dbtxtsput() to put a new text-timestamp into a column whose datatype is neither SYBTEXT nor SYBIMAGE."},
157 { SYBEDPOR, EXPROGRAM, "Out-of-range datepart constant."},
158 { SYBEDVOR, EXPROGRAM, "Day values must be between 1 and 7."},
159 { SYBEECAN, EXINFO, "Attempted to cancel unrequested event notification."},
160 { SYBEECRT, 1, "Must call dbregdefine() before dbregcreate()."},
161 { SYBEEINI, EXINFO, "Must call dbreginit() before dbregraise()."},
162 { SYBEEQVA, 1, "Error in queueing VMS AST routine."},
163 { SYBEERRLABEL, 1, "An illegal value was returned from the security label handler."},
164 { SYBEESSL, 1, "Login security level entered does not agree with operating system level."},
165 { SYBEETD, EXPROGRAM, "Failure to send the expected amount of TEXT or IMAGE data via dbmoretext()."},
166 { SYBEEUNR, EXCOMM, "Unsolicited event notification received."},
167 { SYBEEVOP, EXINFO, "Called dbregwatch() with a bad options parameter."},
168 { SYBEEVST, EXINFO, "Must initiate a transaction before calling dbregparam()."},
169 { SYBEFCON, EXCOMM, "SQL Server connection failed."},
170 { SYBEFENC, 1, "Password Encryption failed."},
171 { SYBEFGTL, 1, "Bcp: Row number of the first row to be copied cannot be greater than the row number for the last row to be copied."},
172 { SYBEFMODE, 1, "ReadWriteAppend mode denied on file."},
173 { SYBEFRES, EXFATAL, "Challenge-Response function failed."},
174 { SYBEFSHD, EXRESOURCE, "Error in attempting to find the Sybase home directory."},
175 { SYBEFUNC, EXPROGRAM, "Functionality not supported at the specified version level."},
176 { SYBEGENOS, 1, "General Operating System Error."},
177 { SYBEICN, EXPROGRAM, "Invalid computeid or compute column number."},
178 { SYBEIDCL, EXCONSISTENCY, "Illegal datetime column length returned by DataServer. Legal datetime lengths are 4 and 8 bytes."},
179 { SYBEIDECCL, EXCONSISTENCY, "Invalid decimal column length returned by the server."},
180 { SYBEIFCL, EXCONSISTENCY, "Illegal floating-point column length returned by DataServer. Legal floating-point lengths are 4 and 8 bytes."},
181 { SYBEIFNB, EXPROGRAM, "Illegal field number passed to bcp_control()."},
182 { SYBEIICL, EXCONSISTENCY, "Illegal integer column length returned by SQL Server. Legal integer lengths are 1, 2, and 4 bytes."},
183 { SYBEIMCL, EXCONSISTENCY, "Illegal money column length returned by DataServer. Legal money lengths are 4 and 8 bytes."},
184 { SYBEINLN, EXUSER, "Interface file: unexpected end-of-line."},
185 { SYBEINTF, EXUSER, "Server name not found in interface file."},
186 { SYBEINUMCL, EXCONSISTENCY, "Invalid numeric column length returned by the server."},
187 { SYBEIPV, EXINFO, "%1! is an illegal value for the %2! parameter of %3!."},
188 { SYBEISOI, EXCONSISTENCY, "Invalid sort-order information found."},
189 { SYBEISRVPREC, EXCONSISTENCY, "Illegal precision value returned by the server."},
190 { SYBEISRVSCL, EXCONSISTENCY, "Illegal scale value returned by the server."},
191 { SYBEITIM, EXPROGRAM, "Illegal timeout value specified."},
192 { SYBEIVERS, EXPROGRAM, "Illegal version level specified."},
193 { SYBEKBCI, EXINFO, "Bcp: 1000 rows sent to SQL Server."},
194 { SYBEKBCO, EXINFO, "1000 rows successfully bulk-copied to host-file."},
195 { SYBELBLEN, 1, "Security labels should be less than 256 characters long."},
196 { SYBEMEM, EXRESOURCE, "Unable to allocate sufficient memory."},
197 { SYBEMOV, EXUSER, "Money arithmetic resulted in overflow in function %1!."},
198 { SYBEMPLL, EXUSER, "Attempt to set maximum number of DBPROCESSes lower than 1."},
199 { SYBEMVOR, EXPROGRAM, "Month values must be between 1 and 12."},
200 { SYBENBUF, EXINFO, "called dbsendpassthru() with a NULL buf pointer."},
201 { SYBENBVP, EXPROGRAM, "Cannot pass dbsetnull() a NULL bindval pointer."},
202 { SYBENDC, EXPROGRAM, "Cannot have negative component in date in numeric form."},
203 { SYBENDTP, EXPROGRAM, "Called dbdatecrack() with a NULL datetime parameter."},
204 { SYBENEG, EXCOMM, "Negotiated login attempt failed."},
205 { SYBENEHA, 1, "Called dbreghandle() with a NULL handler parameter."},
206 { SYBENHAN, EXINFO, "called dbrecvpassthru() with a NULL handler parameter."},
207 { SYBENLNL, 1, "Program not linked with specified network library."},
208 { SYBENMOB, EXPROGRAM, "No such member of 'order by' clause."},
209 { SYBENOEV, EXINFO, "dbpoll() cannot be called if registered procedure notifications have been disabled."},
210 { SYBENOTI, 1, "No event handler installed."},
211 { SYBENOVALUE, 1, "Security labels require both a name and a value."},
212 { SYBENPRM, EXPROGRAM, "NULL parameter not allowed for this dboption."},
213 { SYBENSIP, EXPROGRAM, "Negative starting index passed to dbstrcpy()."},
214 { SYBENTLL, EXUSER, "Name too long for loginrec field."},
215 { SYBENTST, 1, "The file being opened must be a stream_lf."},
216 { SYBENTTN, EXPROGRAM, "Attempt to use dbtxtsput() to put a new text-timestamp into a non-existent data row."},
217 { SYBENULL, EXINFO, "NULL DBPROCESS pointer passed to DB-Library."},
218 { SYBENULP, EXPROGRAM, "Called with a NULL parameter."},
219 { SYBENUM, 1, "Incorrect number of arguments given to DB-Library."},
220 { SYBENXID, EXNONFATAL, "The Server did not grant us a distributed-transaction ID."},
221 { SYBEONCE, EXPROGRAM, "Function can be called only once."},
222 { SYBEOOB, EXCOMM, "Error in sending out-of-band data to SQL Server."},
223 { SYBEOPIN, EXNONFATAL, "Could not open interface file."},
224 { SYBEOPNA, EXNONFATAL, "The textimage facility is available only when using a SQL Server whose version number is 4.0 or greater."},
225 { SYBEOPTNO, 1, "Option is not allowed or is unreconized."},
226 { SYBEOREN, EXINFO, "Warning: an out-of-range error-number was encountered in dblib.loc. The maximum permissible error-number is defined as DBERRCOUNT in sybdb.h."},
227 { SYBEORPF, EXUSER, "Attempt to set remote password would overflow the login-record's remote-password field."},
228 { SYBEOSSL, 1, "Operating system login level not in range of Secure SQL Server."},
229 { SYBEPAGE, 1, "wrong resource type or length given for dbpage() operation."},
230 { SYBEPOLL, EXINFO, "Only one dbpoll() can be active at a time."},
231 { SYBEPRTF, EXINFO, "dbtracestring() may only be called from a printfunc()."},
232 { SYBEPWD, EXUSER, "Incorrect password."},
233 { SYBERDCN, EXCONVERSION, "Requested data-conversion does not exist."},
234 { SYBERDNR, EXPROGRAM, "Attempt to retrieve data from a non-existent row."},
235 { SYBEREAD, EXCOMM, "Read from SQL Server failed."},
236 { SYBERESP, EXPROGRAM, "Response function address passed to dbresponse() must be non-NULL."},
237 { SYBERFILE, 1, "Can not open resource file."},
238 { SYBERPCS, EXINFO, "Must call dbrpcinit() before dbrpcparam()."},
239 { SYBERPIL, EXPROGRAM, "It is illegal to pass -1 to dbrpcparam() for the datalen of parameters which are of type SYBCHAR, SYBVARCHAR, SYBBINARY, or SYBVARBINARY."},
240 { SYBERPNA, EXNONFATAL, "The RPC facility is available only when using a SQL Server whose version number is 4.0 or greater."},
241 { SYBERPND, EXPROGRAM, "Attempt to initiate a new SQL Server operation with results pending."},
242 { SYBERPNULL, EXPROGRAM, "value parameter for dbprcparam() can be NULL, only if the datalen parameter is 0."},
243 { SYBERPTXTIM, EXPROGRAM, "RPC parameters cannot be of type TextImage."},
244 { SYBERPUL, EXPROGRAM, "When passing a SYBINTN, SYBDATETIMN, SYBMONEYN, or SYBFLTN parameter via dbrpcparam(), it's necessary to specify the parameter's maximum or actual length, so that DB-Library can recognize it as a SYBINT1, SYBINT2, SYBINT4, SYBMONEY, or SYBMONEY4, etc."},
245 { SYBERTCC, EXPROGRAM, "dbreadtext() may not be used to receive the results of a query which contains a COMPUTE clause."},
246 { SYBERTSC, EXPROGRAM, "dbreadtext() may only be used to receive the results of a query which contains a single result column."},
247 { SYBERTYPE, 1, "Invalid resource type given to DB-Library."},
248 { SYBERXID, EXNONFATAL, "The Server did not recognize our distributed-transaction ID."},
249 { SYBESECURE, EXPROGRAM, "Secure Server function not supported in this version."},
250 { SYBESEFA, EXPROGRAM, "DBSETNOTIFS cannot be called if connections are present."},
251 { SYBESEOF, EXCOMM, "Unexpected EOF from SQL Server."},
252 { SYBESFOV, EXPROGRAM, "dbsafestr() overflowed its destination buffer."},
253 { SYBESLCT, 1, "Could not select or copy field specified."},
254 { SYBESMSG, EXSERVER, "General SQL Server error: Check messages from the SQL Server."},
255 { SYBESOCK, EXCOMM, "Unable to open socket."},
256 { SYBESPID, EXPROGRAM, "Called dbspid() with a NULL dbproc."},
257 { SYBESYNC, EXCOMM, "Read attempted while out of synchronization with SQL Server."},
258 { SYBETEXS, EXINFO, "Called dbmoretext() with a bad size parameter."},
259 { SYBETIME, EXTIME, "SQL Server connection timed out."},
260 { SYBETMCF, EXPROGRAM, "Attempt to install too many custom formats via dbfmtinstall()."},
261 { SYBETMTD, EXPROGRAM, "Attempt to send too much TEXT data via the dbmoretext() call."},
262 { SYBETPAR, EXPROGRAM, "No SYBTEXT or SYBIMAGE parameters were defined."},
263 { SYBETPTN, EXUSER, "Syntax error: only two periods are permitted in table names."},
264 { SYBETRAC, EXINFO, "Attempted to turn off a trace flag that was not on."},
265 { SYBETRAN, EXINFO, "DBPROCESS is being used for another transaction."},
266 { SYBETRAS, EXINFO, "DB-Library internal error - trace structure not found."},
267 { SYBETRSN, EXINFO, "Bad numbytes parameter passed to dbtracestring()."},
268 { SYBETSIT, EXINFO, "Attempt to call dbtsput() with an invalid timestamp."},
269 { SYBETTS, EXUSER, "The table which bulk-copy is attempting to copy to a host-file is shorter than the number of rows which bulk-copy was instructed to skip."},
270 { SYBETYPE, EXINFO, "Invalid argument type given to DB-Library."},
271 { SYBEUACS, 1, "VMS: Unable to assign channel to sys$command."},
272 { SYBEUAVE, 1, "Unable to allocate VMS event flag."},
273 { SYBEUCPT, EXUSER, "Unrecognized custom-format parameter-type encountered in dbstrbuild()."},
274 { SYBEUCRR, EXCONSISTENCY, "Internal software error: Unknown connection result reported by dbpasswd()."},
275 { SYBEUDTY, EXCONSISTENCY, "Unknown datatype encountered."},
276 { SYBEUFDS, EXUSER, "Unrecognized format encountered in dbstrbuild()."},
277 { SYBEUFDT, EXCONSISTENCY, "Unknown fixed-length datatype encountered."},
278 { SYBEUHST, EXUSER, "Unknown host machine name."},
279 { SYBEUMSG, EXCOMM, "Unknown message-id in MSG datastream."},
280 { SYBEUNAM, EXFATAL, "Unable to get current username from operating system."},
281 { SYBEUNOP, EXNONFATAL, "Unknown option passed to dbsetopt()."},
282 { SYBEUNT, EXUSER, "Unknown network type found in interface file."},
283 { SYBEURCI, EXRESOURCE, "Unable to read copyright information from the dblib localization file."},
284 { SYBEUREI, EXRESOURCE, "Unable to read error information from the dblib localization file."},
285 { SYBEUREM, EXRESOURCE, "Unable to read error mnemonic from the dblib localization file."},
286 { SYBEURES, EXRESOURCE, "Unable to read error string from the dblib localization file."},
287 { SYBEURMI, EXRESOURCE, "Unable to read money-format information from the dblib localization file."},
288 { SYBEUSCT, EXCOMM, "Unable to set communications timer."},
289 { SYBEUTDS, EXCOMM, "Unrecognized TDS version received from SQL Server."},
290 { SYBEUVBF, EXPROGRAM, "Attempt to read an unknown version of BCP format-file."},
291 { SYBEUVDT, EXCONSISTENCY, "Unknown variable-length datatype encountered."},
292 { SYBEVDPT, EXUSER, "For bulk copy, all variable-length data must have either a length-prefix or a terminator specified."},
293 { SYBEVMS, 1, "Sendflush: VMS IO error."},
294 { SYBEVOIDRET, 1, "Parameter of type SYBVOID cannot be a return parameter."},
295 { SYBEWAID, EXCONSISTENCY, "DB-LIBRARY internal error: ALTFMT following ALTNAME has wrong id."},
296 { SYBEWRIT, EXCOMM, "Write to SQL Server failed."},
297 { SYBEXOCI, EXNONFATAL, "A character-set translation overflowed its destination buffer while using bcp to copy data from a host-file to the SQL Server."},
298 { SYBEXTDN, EXPROGRAM, "Warning: the xlt_todisp parameter to dbfree_xlate() was NULL. The space associated with the xlt_tosrv parameter has been freed."},
299 { SYBEXTN, EXPROGRAM, "The xlt_todisp and xlt_tosrv parameters to dbfree_xlate() were NULL."},
300 { SYBEXTSN, EXPROGRAM, "Warning: the xlt_tosrv parameter to dbfree_xlate() was NULL. The space associated with the xlt_todisp parameter has been freed."},
301 { SYBEZTXT, EXINFO, "Attempt to send zero length TEXT or IMAGE to dataserver via dbwritetext()."},
302 { 0, 0, "Please add a description for this error to src/tds/error_table.h"}
freetds-1.00.82/doc/reference/a00110_source.html100644 025423 025423 00000065012 13242511132 0014577 FreeTDS API: src/odbc/error_export.h Source File
FreeTDS API
error_export.h
1 #undef tdsdump_log
2 
3 #ifdef ENABLE_ODBC_WIDE
4 static SQLRETURN _SQLGetDiagRec(SQLSMALLINT handleType,
5  SQLHANDLE handle,
6  SQLSMALLINT numRecord,
7  ODBC_CHAR * szSqlStat,
8  SQLINTEGER * pfNativeError,
9  ODBC_CHAR * szErrorMsg, SQLSMALLINT cbErrorMsgMax, SQLSMALLINT FAR* pcbErrorMsg, int wide);
10 
11 SQLRETURN ODBC_PUBLIC ODBC_API SQLGetDiagRecW(
12  SQLSMALLINT handleType,
13  SQLHANDLE handle,
14  SQLSMALLINT numRecord,
15  SQLWCHAR * szSqlStat,
16  SQLINTEGER * pfNativeError,
17  SQLWCHAR * szErrorMsg, SQLSMALLINT cbErrorMsgMax, SQLSMALLINT FAR* pcbErrorMsg)
18 {
19  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLGetDiagRecW(%d, %p, %d, %p, %p, %p, %d, %p)\n",
20  (int) handleType,
21  handle,
22  (int) numRecord,
23  szSqlStat,
24  pfNativeError,
25  szErrorMsg, (int) cbErrorMsgMax, pcbErrorMsg);
26  return _SQLGetDiagRec(handleType,
27  handle,
28  numRecord,
29  (ODBC_CHAR*) szSqlStat,
30  pfNativeError,
31  (ODBC_CHAR*) szErrorMsg, cbErrorMsgMax, pcbErrorMsg, 1);
32 }
33 #endif
34 
35 SQLRETURN ODBC_PUBLIC ODBC_API SQLGetDiagRec(
36  SQLSMALLINT handleType,
37  SQLHANDLE handle,
38  SQLSMALLINT numRecord,
39  SQLCHAR * szSqlStat,
40  SQLINTEGER * pfNativeError,
41  SQLCHAR * szErrorMsg, SQLSMALLINT cbErrorMsgMax, SQLSMALLINT FAR* pcbErrorMsg)
42 {
43  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLGetDiagRec(%d, %p, %d, %p, %p, %p, %d, %p)\n",
44  (int) handleType,
45  handle,
46  (int) numRecord,
47  szSqlStat,
48  pfNativeError,
49  szErrorMsg, (int) cbErrorMsgMax, pcbErrorMsg);
50 #ifdef ENABLE_ODBC_WIDE
51  return _SQLGetDiagRec(handleType,
52  handle,
53  numRecord,
54  (ODBC_CHAR*) szSqlStat,
55  pfNativeError,
56  (ODBC_CHAR*) szErrorMsg, cbErrorMsgMax, pcbErrorMsg, 0);
57 #else
58  return _SQLGetDiagRec(handleType,
59  handle,
60  numRecord,
61  szSqlStat,
62  pfNativeError,
63  szErrorMsg, cbErrorMsgMax, pcbErrorMsg);
64 #endif
65 }
66 
67 #ifdef ENABLE_ODBC_WIDE
68 static SQLRETURN _SQLError(SQLHENV henv,
69  SQLHDBC hdbc,
70  SQLHSTMT hstmt,
71  ODBC_CHAR * szSqlStat,
72  SQLINTEGER * pfNativeError,
73  ODBC_CHAR * szErrorMsg, SQLSMALLINT cbErrorMsgMax, SQLSMALLINT FAR* pcbErrorMsg, int wide);
74 
75 SQLRETURN ODBC_PUBLIC ODBC_API SQLErrorW(
76  SQLHENV henv,
77  SQLHDBC hdbc,
78  SQLHSTMT hstmt,
79  SQLWCHAR * szSqlStat,
80  SQLINTEGER * pfNativeError,
81  SQLWCHAR * szErrorMsg, SQLSMALLINT cbErrorMsgMax, SQLSMALLINT FAR* pcbErrorMsg)
82 {
83  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLErrorW(%p, %p, %p, %p, %p, %p, %d, %p)\n",
84  henv,
85  hdbc,
86  hstmt,
87  szSqlStat,
88  pfNativeError,
89  szErrorMsg, (int) cbErrorMsgMax, pcbErrorMsg);
90  return _SQLError(henv,
91  hdbc,
92  hstmt,
93  (ODBC_CHAR*) szSqlStat,
94  pfNativeError,
95  (ODBC_CHAR*) szErrorMsg, cbErrorMsgMax, pcbErrorMsg, 1);
96 }
97 #endif
98 
99 SQLRETURN ODBC_PUBLIC ODBC_API SQLError(
100  SQLHENV henv,
101  SQLHDBC hdbc,
102  SQLHSTMT hstmt,
103  SQLCHAR * szSqlStat,
104  SQLINTEGER * pfNativeError,
105  SQLCHAR * szErrorMsg, SQLSMALLINT cbErrorMsgMax, SQLSMALLINT FAR* pcbErrorMsg)
106 {
107  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLError(%p, %p, %p, %p, %p, %p, %d, %p)\n",
108  henv,
109  hdbc,
110  hstmt,
111  szSqlStat,
112  pfNativeError,
113  szErrorMsg, (int) cbErrorMsgMax, pcbErrorMsg);
114 #ifdef ENABLE_ODBC_WIDE
115  return _SQLError(henv,
116  hdbc,
117  hstmt,
118  (ODBC_CHAR*) szSqlStat,
119  pfNativeError,
120  (ODBC_CHAR*) szErrorMsg, cbErrorMsgMax, pcbErrorMsg, 0);
121 #else
122  return _SQLError(henv,
123  hdbc,
124  hstmt,
125  szSqlStat,
126  pfNativeError,
127  szErrorMsg, cbErrorMsgMax, pcbErrorMsg);
128 #endif
129 }
130 
131 #ifdef ENABLE_ODBC_WIDE
132 static SQLRETURN _SQLGetDiagField(SQLSMALLINT handleType,
133  SQLHANDLE handle,
134  SQLSMALLINT numRecord,
135  SQLSMALLINT diagIdentifier,
136  SQLPOINTER buffer,
137  SQLSMALLINT cbBuffer,
138  SQLSMALLINT * pcbBuffer, int wide);
139 
140 SQLRETURN ODBC_PUBLIC ODBC_API SQLGetDiagFieldW(
141  SQLSMALLINT handleType,
142  SQLHANDLE handle,
143  SQLSMALLINT numRecord,
144  SQLSMALLINT diagIdentifier,
145  SQLPOINTER buffer,
146  SQLSMALLINT cbBuffer,
147  SQLSMALLINT * pcbBuffer)
148 {
149  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLGetDiagFieldW(%d, %p, %d, %d, %p, %d, %p)\n",
150  (int) handleType,
151  handle,
152  (int) numRecord,
153  (int) diagIdentifier,
154  buffer,
155  (int) cbBuffer,
156  pcbBuffer);
157  return _SQLGetDiagField(handleType,
158  handle,
159  numRecord,
160  diagIdentifier,
161  buffer,
162  cbBuffer,
163  pcbBuffer, 1);
164 }
165 #endif
166 
167 SQLRETURN ODBC_PUBLIC ODBC_API SQLGetDiagField(
168  SQLSMALLINT handleType,
169  SQLHANDLE handle,
170  SQLSMALLINT numRecord,
171  SQLSMALLINT diagIdentifier,
172  SQLPOINTER buffer,
173  SQLSMALLINT cbBuffer,
174  SQLSMALLINT * pcbBuffer)
175 {
176  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLGetDiagField(%d, %p, %d, %d, %p, %d, %p)\n",
177  (int) handleType,
178  handle,
179  (int) numRecord,
180  (int) diagIdentifier,
181  buffer,
182  (int) cbBuffer,
183  pcbBuffer);
184 #ifdef ENABLE_ODBC_WIDE
185  return _SQLGetDiagField(handleType,
186  handle,
187  numRecord,
188  diagIdentifier,
189  buffer,
190  cbBuffer,
191  pcbBuffer, 0);
192 #else
193  return _SQLGetDiagField(handleType,
194  handle,
195  numRecord,
196  diagIdentifier,
197  buffer,
198  cbBuffer,
199  pcbBuffer);
200 #endif
201 }
202 
203 #define tdsdump_log TDSDUMP_LOG_FAST
freetds-1.00.82/doc/reference/a00125_source.html100644 025423 025423 00000524443 13242511132 0014615 FreeTDS API: src/odbc/odbc_export.h Source File
FreeTDS API
odbc_export.h
1 #undef tdsdump_log
2 
3 #ifdef ENABLE_ODBC_WIDE
4 static SQLRETURN _SQLDriverConnect(SQLHDBC hdbc,
5  SQLHWND hwnd,
6  ODBC_CHAR * szConnStrIn, SQLSMALLINT cbConnStrIn,
7  ODBC_CHAR * szConnStrOut, SQLSMALLINT cbConnStrOutMax, SQLSMALLINT FAR* pcbConnStrOut,
8  SQLUSMALLINT fDriverCompletion, int wide);
9 
10 SQLRETURN ODBC_PUBLIC ODBC_API SQLDriverConnectW(
11  SQLHDBC hdbc,
12  SQLHWND hwnd,
13  SQLWCHAR * szConnStrIn, SQLSMALLINT cbConnStrIn,
14  SQLWCHAR * szConnStrOut, SQLSMALLINT cbConnStrOutMax, SQLSMALLINT FAR* pcbConnStrOut,
15  SQLUSMALLINT fDriverCompletion)
16 {
17  if (TDS_UNLIKELY(tds_write_dump)) {
18  SQLWSTR_BUFS(1);
19  tdsdump_log(TDS_DBG_FUNC, "SQLDriverConnectW(%p, %p, %ls, %d, %p, %d, %p, %u)\n",
20  hdbc,
21  hwnd,
22  SQLWSTR(szConnStrIn), (int) cbConnStrIn,
23  szConnStrOut, (int) cbConnStrOutMax, pcbConnStrOut,
24  (unsigned int) fDriverCompletion);
25  SQLWSTR_FREE();
26  }
27  return _SQLDriverConnect(hdbc,
28  hwnd,
29  (ODBC_CHAR*) szConnStrIn, cbConnStrIn,
30  (ODBC_CHAR*) szConnStrOut, cbConnStrOutMax, pcbConnStrOut,
31  fDriverCompletion, 1);
32 }
33 #endif
34 
35 SQLRETURN ODBC_PUBLIC ODBC_API SQLDriverConnect(
36  SQLHDBC hdbc,
37  SQLHWND hwnd,
38  SQLCHAR * szConnStrIn, SQLSMALLINT cbConnStrIn,
39  SQLCHAR * szConnStrOut, SQLSMALLINT cbConnStrOutMax, SQLSMALLINT FAR* pcbConnStrOut,
40  SQLUSMALLINT fDriverCompletion)
41 {
42  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLDriverConnect(%p, %p, %s, %d, %p, %d, %p, %u)\n",
43  hdbc,
44  hwnd,
45  (const char*) szConnStrIn, (int) cbConnStrIn,
46  szConnStrOut, (int) cbConnStrOutMax, pcbConnStrOut,
47  (unsigned int) fDriverCompletion);
48 #ifdef ENABLE_ODBC_WIDE
49  return _SQLDriverConnect(hdbc,
50  hwnd,
51  (ODBC_CHAR*) szConnStrIn, cbConnStrIn,
52  (ODBC_CHAR*) szConnStrOut, cbConnStrOutMax, pcbConnStrOut,
53  fDriverCompletion, 0);
54 #else
55  return _SQLDriverConnect(hdbc,
56  hwnd,
57  szConnStrIn, cbConnStrIn,
58  szConnStrOut, cbConnStrOutMax, pcbConnStrOut,
59  fDriverCompletion);
60 #endif
61 }
62 
63 #ifdef ENABLE_ODBC_WIDE
64 static SQLRETURN _SQLColumnPrivileges(SQLHSTMT hstmt,
65  ODBC_CHAR * szCatalogName, SQLSMALLINT cbCatalogName,
66  ODBC_CHAR * szSchemaName, SQLSMALLINT cbSchemaName,
67  ODBC_CHAR * szTableName, SQLSMALLINT cbTableName,
68  ODBC_CHAR * szColumnName, SQLSMALLINT cbColumnName, int wide);
69 
70 SQLRETURN ODBC_PUBLIC ODBC_API SQLColumnPrivilegesW(
71  SQLHSTMT hstmt,
72  SQLWCHAR * szCatalogName, SQLSMALLINT cbCatalogName,
73  SQLWCHAR * szSchemaName, SQLSMALLINT cbSchemaName,
74  SQLWCHAR * szTableName, SQLSMALLINT cbTableName,
75  SQLWCHAR * szColumnName, SQLSMALLINT cbColumnName)
76 {
77  if (TDS_UNLIKELY(tds_write_dump)) {
78  SQLWSTR_BUFS(4);
79  tdsdump_log(TDS_DBG_FUNC, "SQLColumnPrivilegesW(%p, %ls, %d, %ls, %d, %ls, %d, %ls, %d)\n",
80  hstmt,
81  SQLWSTR(szCatalogName), (int) cbCatalogName,
82  SQLWSTR(szSchemaName), (int) cbSchemaName,
83  SQLWSTR(szTableName), (int) cbTableName,
84  SQLWSTR(szColumnName), (int) cbColumnName);
85  SQLWSTR_FREE();
86  }
87  return _SQLColumnPrivileges(hstmt,
88  (ODBC_CHAR*) szCatalogName, cbCatalogName,
89  (ODBC_CHAR*) szSchemaName, cbSchemaName,
90  (ODBC_CHAR*) szTableName, cbTableName,
91  (ODBC_CHAR*) szColumnName, cbColumnName, 1);
92 }
93 #endif
94 
95 SQLRETURN ODBC_PUBLIC ODBC_API SQLColumnPrivileges(
96  SQLHSTMT hstmt,
97  SQLCHAR * szCatalogName, SQLSMALLINT cbCatalogName,
98  SQLCHAR * szSchemaName, SQLSMALLINT cbSchemaName,
99  SQLCHAR * szTableName, SQLSMALLINT cbTableName,
100  SQLCHAR * szColumnName, SQLSMALLINT cbColumnName)
101 {
102  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLColumnPrivileges(%p, %s, %d, %s, %d, %s, %d, %s, %d)\n",
103  hstmt,
104  (const char*) szCatalogName, (int) cbCatalogName,
105  (const char*) szSchemaName, (int) cbSchemaName,
106  (const char*) szTableName, (int) cbTableName,
107  (const char*) szColumnName, (int) cbColumnName);
108 #ifdef ENABLE_ODBC_WIDE
109  return _SQLColumnPrivileges(hstmt,
110  (ODBC_CHAR*) szCatalogName, cbCatalogName,
111  (ODBC_CHAR*) szSchemaName, cbSchemaName,
112  (ODBC_CHAR*) szTableName, cbTableName,
113  (ODBC_CHAR*) szColumnName, cbColumnName, 0);
114 #else
115  return _SQLColumnPrivileges(hstmt,
116  szCatalogName, cbCatalogName,
117  szSchemaName, cbSchemaName,
118  szTableName, cbTableName,
119  szColumnName, cbColumnName);
120 #endif
121 }
122 
123 #ifdef ENABLE_ODBC_WIDE
124 static SQLRETURN _SQLForeignKeys(SQLHSTMT hstmt,
125  ODBC_CHAR * szPkCatalogName, SQLSMALLINT cbPkCatalogName,
126  ODBC_CHAR * szPkSchemaName, SQLSMALLINT cbPkSchemaName,
127  ODBC_CHAR * szPkTableName, SQLSMALLINT cbPkTableName,
128  ODBC_CHAR * szFkCatalogName, SQLSMALLINT cbFkCatalogName,
129  ODBC_CHAR * szFkSchemaName, SQLSMALLINT cbFkSchemaName,
130  ODBC_CHAR * szFkTableName, SQLSMALLINT cbFkTableName, int wide);
131 
132 SQLRETURN ODBC_PUBLIC ODBC_API SQLForeignKeysW(
133  SQLHSTMT hstmt,
134  SQLWCHAR * szPkCatalogName, SQLSMALLINT cbPkCatalogName,
135  SQLWCHAR * szPkSchemaName, SQLSMALLINT cbPkSchemaName,
136  SQLWCHAR * szPkTableName, SQLSMALLINT cbPkTableName,
137  SQLWCHAR * szFkCatalogName, SQLSMALLINT cbFkCatalogName,
138  SQLWCHAR * szFkSchemaName, SQLSMALLINT cbFkSchemaName,
139  SQLWCHAR * szFkTableName, SQLSMALLINT cbFkTableName)
140 {
141  if (TDS_UNLIKELY(tds_write_dump)) {
142  SQLWSTR_BUFS(6);
143  tdsdump_log(TDS_DBG_FUNC, "SQLForeignKeysW(%p, %ls, %d, %ls, %d, %ls, %d, %ls, %d, %ls, %d, %ls, %d)\n",
144  hstmt,
145  SQLWSTR(szPkCatalogName), (int) cbPkCatalogName,
146  SQLWSTR(szPkSchemaName), (int) cbPkSchemaName,
147  SQLWSTR(szPkTableName), (int) cbPkTableName,
148  SQLWSTR(szFkCatalogName), (int) cbFkCatalogName,
149  SQLWSTR(szFkSchemaName), (int) cbFkSchemaName,
150  SQLWSTR(szFkTableName), (int) cbFkTableName);
151  SQLWSTR_FREE();
152  }
153  return _SQLForeignKeys(hstmt,
154  (ODBC_CHAR*) szPkCatalogName, cbPkCatalogName,
155  (ODBC_CHAR*) szPkSchemaName, cbPkSchemaName,
156  (ODBC_CHAR*) szPkTableName, cbPkTableName,
157  (ODBC_CHAR*) szFkCatalogName, cbFkCatalogName,
158  (ODBC_CHAR*) szFkSchemaName, cbFkSchemaName,
159  (ODBC_CHAR*) szFkTableName, cbFkTableName, 1);
160 }
161 #endif
162 
163 SQLRETURN ODBC_PUBLIC ODBC_API SQLForeignKeys(
164  SQLHSTMT hstmt,
165  SQLCHAR * szPkCatalogName, SQLSMALLINT cbPkCatalogName,
166  SQLCHAR * szPkSchemaName, SQLSMALLINT cbPkSchemaName,
167  SQLCHAR * szPkTableName, SQLSMALLINT cbPkTableName,
168  SQLCHAR * szFkCatalogName, SQLSMALLINT cbFkCatalogName,
169  SQLCHAR * szFkSchemaName, SQLSMALLINT cbFkSchemaName,
170  SQLCHAR * szFkTableName, SQLSMALLINT cbFkTableName)
171 {
172  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLForeignKeys(%p, %s, %d, %s, %d, %s, %d, %s, %d, %s, %d, %s, %d)\n",
173  hstmt,
174  (const char*) szPkCatalogName, (int) cbPkCatalogName,
175  (const char*) szPkSchemaName, (int) cbPkSchemaName,
176  (const char*) szPkTableName, (int) cbPkTableName,
177  (const char*) szFkCatalogName, (int) cbFkCatalogName,
178  (const char*) szFkSchemaName, (int) cbFkSchemaName,
179  (const char*) szFkTableName, (int) cbFkTableName);
180 #ifdef ENABLE_ODBC_WIDE
181  return _SQLForeignKeys(hstmt,
182  (ODBC_CHAR*) szPkCatalogName, cbPkCatalogName,
183  (ODBC_CHAR*) szPkSchemaName, cbPkSchemaName,
184  (ODBC_CHAR*) szPkTableName, cbPkTableName,
185  (ODBC_CHAR*) szFkCatalogName, cbFkCatalogName,
186  (ODBC_CHAR*) szFkSchemaName, cbFkSchemaName,
187  (ODBC_CHAR*) szFkTableName, cbFkTableName, 0);
188 #else
189  return _SQLForeignKeys(hstmt,
190  szPkCatalogName, cbPkCatalogName,
191  szPkSchemaName, cbPkSchemaName,
192  szPkTableName, cbPkTableName,
193  szFkCatalogName, cbFkCatalogName,
194  szFkSchemaName, cbFkSchemaName,
195  szFkTableName, cbFkTableName);
196 #endif
197 }
198 
199 #ifdef ENABLE_ODBC_WIDE
200 static SQLRETURN _SQLNativeSql(SQLHDBC hdbc,
201  ODBC_CHAR * szSqlStrIn, SQLINTEGER cbSqlStrIn,
202  ODBC_CHAR * szSqlStr, SQLINTEGER cbSqlStrMax, SQLINTEGER FAR* pcbSqlStr, int wide);
203 
204 SQLRETURN ODBC_PUBLIC ODBC_API SQLNativeSqlW(
205  SQLHDBC hdbc,
206  SQLWCHAR * szSqlStrIn, SQLINTEGER cbSqlStrIn,
207  SQLWCHAR * szSqlStr, SQLINTEGER cbSqlStrMax, SQLINTEGER FAR* pcbSqlStr)
208 {
209  if (TDS_UNLIKELY(tds_write_dump)) {
210  SQLWSTR_BUFS(1);
211  tdsdump_log(TDS_DBG_FUNC, "SQLNativeSqlW(%p, %ls, %d, %p, %d, %p)\n",
212  hdbc,
213  SQLWSTR(szSqlStrIn), (int) cbSqlStrIn,
214  szSqlStr, (int) cbSqlStrMax, pcbSqlStr);
215  SQLWSTR_FREE();
216  }
217  return _SQLNativeSql(hdbc,
218  (ODBC_CHAR*) szSqlStrIn, cbSqlStrIn,
219  (ODBC_CHAR*) szSqlStr, cbSqlStrMax, pcbSqlStr, 1);
220 }
221 #endif
222 
223 SQLRETURN ODBC_PUBLIC ODBC_API SQLNativeSql(
224  SQLHDBC hdbc,
225  SQLCHAR * szSqlStrIn, SQLINTEGER cbSqlStrIn,
226  SQLCHAR * szSqlStr, SQLINTEGER cbSqlStrMax, SQLINTEGER FAR* pcbSqlStr)
227 {
228  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLNativeSql(%p, %s, %d, %p, %d, %p)\n",
229  hdbc,
230  (const char*) szSqlStrIn, (int) cbSqlStrIn,
231  szSqlStr, (int) cbSqlStrMax, pcbSqlStr);
232 #ifdef ENABLE_ODBC_WIDE
233  return _SQLNativeSql(hdbc,
234  (ODBC_CHAR*) szSqlStrIn, cbSqlStrIn,
235  (ODBC_CHAR*) szSqlStr, cbSqlStrMax, pcbSqlStr, 0);
236 #else
237  return _SQLNativeSql(hdbc,
238  szSqlStrIn, cbSqlStrIn,
239  szSqlStr, cbSqlStrMax, pcbSqlStr);
240 #endif
241 }
242 
243 #ifdef ENABLE_ODBC_WIDE
244 static SQLRETURN _SQLPrimaryKeys(SQLHSTMT hstmt,
245  ODBC_CHAR * szCatalogName, SQLSMALLINT cbCatalogName,
246  ODBC_CHAR * szSchemaName, SQLSMALLINT cbSchemaName,
247  ODBC_CHAR * szTableName, SQLSMALLINT cbTableName, int wide);
248 
249 SQLRETURN ODBC_PUBLIC ODBC_API SQLPrimaryKeysW(
250  SQLHSTMT hstmt,
251  SQLWCHAR * szCatalogName, SQLSMALLINT cbCatalogName,
252  SQLWCHAR * szSchemaName, SQLSMALLINT cbSchemaName,
253  SQLWCHAR * szTableName, SQLSMALLINT cbTableName)
254 {
255  if (TDS_UNLIKELY(tds_write_dump)) {
256  SQLWSTR_BUFS(3);
257  tdsdump_log(TDS_DBG_FUNC, "SQLPrimaryKeysW(%p, %ls, %d, %ls, %d, %ls, %d)\n",
258  hstmt,
259  SQLWSTR(szCatalogName), (int) cbCatalogName,
260  SQLWSTR(szSchemaName), (int) cbSchemaName,
261  SQLWSTR(szTableName), (int) cbTableName);
262  SQLWSTR_FREE();
263  }
264  return _SQLPrimaryKeys(hstmt,
265  (ODBC_CHAR*) szCatalogName, cbCatalogName,
266  (ODBC_CHAR*) szSchemaName, cbSchemaName,
267  (ODBC_CHAR*) szTableName, cbTableName, 1);
268 }
269 #endif
270 
271 SQLRETURN ODBC_PUBLIC ODBC_API SQLPrimaryKeys(
272  SQLHSTMT hstmt,
273  SQLCHAR * szCatalogName, SQLSMALLINT cbCatalogName,
274  SQLCHAR * szSchemaName, SQLSMALLINT cbSchemaName,
275  SQLCHAR * szTableName, SQLSMALLINT cbTableName)
276 {
277  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLPrimaryKeys(%p, %s, %d, %s, %d, %s, %d)\n",
278  hstmt,
279  (const char*) szCatalogName, (int) cbCatalogName,
280  (const char*) szSchemaName, (int) cbSchemaName,
281  (const char*) szTableName, (int) cbTableName);
282 #ifdef ENABLE_ODBC_WIDE
283  return _SQLPrimaryKeys(hstmt,
284  (ODBC_CHAR*) szCatalogName, cbCatalogName,
285  (ODBC_CHAR*) szSchemaName, cbSchemaName,
286  (ODBC_CHAR*) szTableName, cbTableName, 0);
287 #else
288  return _SQLPrimaryKeys(hstmt,
289  szCatalogName, cbCatalogName,
290  szSchemaName, cbSchemaName,
291  szTableName, cbTableName);
292 #endif
293 }
294 
295 #ifdef ENABLE_ODBC_WIDE
296 static SQLRETURN _SQLProcedureColumns(SQLHSTMT hstmt,
297  ODBC_CHAR * szCatalogName, SQLSMALLINT cbCatalogName,
298  ODBC_CHAR * szSchemaName, SQLSMALLINT cbSchemaName,
299  ODBC_CHAR * szProcName, SQLSMALLINT cbProcName,
300  ODBC_CHAR * szColumnName, SQLSMALLINT cbColumnName, int wide);
301 
302 SQLRETURN ODBC_PUBLIC ODBC_API SQLProcedureColumnsW(
303  SQLHSTMT hstmt,
304  SQLWCHAR * szCatalogName, SQLSMALLINT cbCatalogName,
305  SQLWCHAR * szSchemaName, SQLSMALLINT cbSchemaName,
306  SQLWCHAR * szProcName, SQLSMALLINT cbProcName,
307  SQLWCHAR * szColumnName, SQLSMALLINT cbColumnName)
308 {
309  if (TDS_UNLIKELY(tds_write_dump)) {
310  SQLWSTR_BUFS(4);
311  tdsdump_log(TDS_DBG_FUNC, "SQLProcedureColumnsW(%p, %ls, %d, %ls, %d, %ls, %d, %ls, %d)\n",
312  hstmt,
313  SQLWSTR(szCatalogName), (int) cbCatalogName,
314  SQLWSTR(szSchemaName), (int) cbSchemaName,
315  SQLWSTR(szProcName), (int) cbProcName,
316  SQLWSTR(szColumnName), (int) cbColumnName);
317  SQLWSTR_FREE();
318  }
319  return _SQLProcedureColumns(hstmt,
320  (ODBC_CHAR*) szCatalogName, cbCatalogName,
321  (ODBC_CHAR*) szSchemaName, cbSchemaName,
322  (ODBC_CHAR*) szProcName, cbProcName,
323  (ODBC_CHAR*) szColumnName, cbColumnName, 1);
324 }
325 #endif
326 
327 SQLRETURN ODBC_PUBLIC ODBC_API SQLProcedureColumns(
328  SQLHSTMT hstmt,
329  SQLCHAR * szCatalogName, SQLSMALLINT cbCatalogName,
330  SQLCHAR * szSchemaName, SQLSMALLINT cbSchemaName,
331  SQLCHAR * szProcName, SQLSMALLINT cbProcName,
332  SQLCHAR * szColumnName, SQLSMALLINT cbColumnName)
333 {
334  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLProcedureColumns(%p, %s, %d, %s, %d, %s, %d, %s, %d)\n",
335  hstmt,
336  (const char*) szCatalogName, (int) cbCatalogName,
337  (const char*) szSchemaName, (int) cbSchemaName,
338  (const char*) szProcName, (int) cbProcName,
339  (const char*) szColumnName, (int) cbColumnName);
340 #ifdef ENABLE_ODBC_WIDE
341  return _SQLProcedureColumns(hstmt,
342  (ODBC_CHAR*) szCatalogName, cbCatalogName,
343  (ODBC_CHAR*) szSchemaName, cbSchemaName,
344  (ODBC_CHAR*) szProcName, cbProcName,
345  (ODBC_CHAR*) szColumnName, cbColumnName, 0);
346 #else
347  return _SQLProcedureColumns(hstmt,
348  szCatalogName, cbCatalogName,
349  szSchemaName, cbSchemaName,
350  szProcName, cbProcName,
351  szColumnName, cbColumnName);
352 #endif
353 }
354 
355 #ifdef ENABLE_ODBC_WIDE
356 static SQLRETURN _SQLProcedures(SQLHSTMT hstmt,
357  ODBC_CHAR * szCatalogName, SQLSMALLINT cbCatalogName,
358  ODBC_CHAR * szSchemaName, SQLSMALLINT cbSchemaName,
359  ODBC_CHAR * szProcName, SQLSMALLINT cbProcName, int wide);
360 
361 SQLRETURN ODBC_PUBLIC ODBC_API SQLProceduresW(
362  SQLHSTMT hstmt,
363  SQLWCHAR * szCatalogName, SQLSMALLINT cbCatalogName,
364  SQLWCHAR * szSchemaName, SQLSMALLINT cbSchemaName,
365  SQLWCHAR * szProcName, SQLSMALLINT cbProcName)
366 {
367  if (TDS_UNLIKELY(tds_write_dump)) {
368  SQLWSTR_BUFS(3);
369  tdsdump_log(TDS_DBG_FUNC, "SQLProceduresW(%p, %ls, %d, %ls, %d, %ls, %d)\n",
370  hstmt,
371  SQLWSTR(szCatalogName), (int) cbCatalogName,
372  SQLWSTR(szSchemaName), (int) cbSchemaName,
373  SQLWSTR(szProcName), (int) cbProcName);
374  SQLWSTR_FREE();
375  }
376  return _SQLProcedures(hstmt,
377  (ODBC_CHAR*) szCatalogName, cbCatalogName,
378  (ODBC_CHAR*) szSchemaName, cbSchemaName,
379  (ODBC_CHAR*) szProcName, cbProcName, 1);
380 }
381 #endif
382 
383 SQLRETURN ODBC_PUBLIC ODBC_API SQLProcedures(
384  SQLHSTMT hstmt,
385  SQLCHAR * szCatalogName, SQLSMALLINT cbCatalogName,
386  SQLCHAR * szSchemaName, SQLSMALLINT cbSchemaName,
387  SQLCHAR * szProcName, SQLSMALLINT cbProcName)
388 {
389  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLProcedures(%p, %s, %d, %s, %d, %s, %d)\n",
390  hstmt,
391  (const char*) szCatalogName, (int) cbCatalogName,
392  (const char*) szSchemaName, (int) cbSchemaName,
393  (const char*) szProcName, (int) cbProcName);
394 #ifdef ENABLE_ODBC_WIDE
395  return _SQLProcedures(hstmt,
396  (ODBC_CHAR*) szCatalogName, cbCatalogName,
397  (ODBC_CHAR*) szSchemaName, cbSchemaName,
398  (ODBC_CHAR*) szProcName, cbProcName, 0);
399 #else
400  return _SQLProcedures(hstmt,
401  szCatalogName, cbCatalogName,
402  szSchemaName, cbSchemaName,
403  szProcName, cbProcName);
404 #endif
405 }
406 
407 #ifdef ENABLE_ODBC_WIDE
408 static SQLRETURN _SQLTablePrivileges(SQLHSTMT hstmt,
409  ODBC_CHAR * szCatalogName, SQLSMALLINT cbCatalogName,
410  ODBC_CHAR * szSchemaName, SQLSMALLINT cbSchemaName,
411  ODBC_CHAR * szTableName, SQLSMALLINT cbTableName, int wide);
412 
413 SQLRETURN ODBC_PUBLIC ODBC_API SQLTablePrivilegesW(
414  SQLHSTMT hstmt,
415  SQLWCHAR * szCatalogName, SQLSMALLINT cbCatalogName,
416  SQLWCHAR * szSchemaName, SQLSMALLINT cbSchemaName,
417  SQLWCHAR * szTableName, SQLSMALLINT cbTableName)
418 {
419  if (TDS_UNLIKELY(tds_write_dump)) {
420  SQLWSTR_BUFS(3);
421  tdsdump_log(TDS_DBG_FUNC, "SQLTablePrivilegesW(%p, %ls, %d, %ls, %d, %ls, %d)\n",
422  hstmt,
423  SQLWSTR(szCatalogName), (int) cbCatalogName,
424  SQLWSTR(szSchemaName), (int) cbSchemaName,
425  SQLWSTR(szTableName), (int) cbTableName);
426  SQLWSTR_FREE();
427  }
428  return _SQLTablePrivileges(hstmt,
429  (ODBC_CHAR*) szCatalogName, cbCatalogName,
430  (ODBC_CHAR*) szSchemaName, cbSchemaName,
431  (ODBC_CHAR*) szTableName, cbTableName, 1);
432 }
433 #endif
434 
435 SQLRETURN ODBC_PUBLIC ODBC_API SQLTablePrivileges(
436  SQLHSTMT hstmt,
437  SQLCHAR * szCatalogName, SQLSMALLINT cbCatalogName,
438  SQLCHAR * szSchemaName, SQLSMALLINT cbSchemaName,
439  SQLCHAR * szTableName, SQLSMALLINT cbTableName)
440 {
441  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLTablePrivileges(%p, %s, %d, %s, %d, %s, %d)\n",
442  hstmt,
443  (const char*) szCatalogName, (int) cbCatalogName,
444  (const char*) szSchemaName, (int) cbSchemaName,
445  (const char*) szTableName, (int) cbTableName);
446 #ifdef ENABLE_ODBC_WIDE
447  return _SQLTablePrivileges(hstmt,
448  (ODBC_CHAR*) szCatalogName, cbCatalogName,
449  (ODBC_CHAR*) szSchemaName, cbSchemaName,
450  (ODBC_CHAR*) szTableName, cbTableName, 0);
451 #else
452  return _SQLTablePrivileges(hstmt,
453  szCatalogName, cbCatalogName,
454  szSchemaName, cbSchemaName,
455  szTableName, cbTableName);
456 #endif
457 }
458 
459 #ifdef ENABLE_ODBC_WIDE
460 static SQLRETURN _SQLConnect(SQLHDBC hdbc,
461  ODBC_CHAR * szDSN, SQLSMALLINT cbDSN,
462  ODBC_CHAR * szUID, SQLSMALLINT cbUID,
463  ODBC_CHAR * szAuthStr, SQLSMALLINT cbAuthStr, int wide);
464 
465 SQLRETURN ODBC_PUBLIC ODBC_API SQLConnectW(
466  SQLHDBC hdbc,
467  SQLWCHAR * szDSN, SQLSMALLINT cbDSN,
468  SQLWCHAR * szUID, SQLSMALLINT cbUID,
469  SQLWCHAR * szAuthStr, SQLSMALLINT cbAuthStr)
470 {
471  if (TDS_UNLIKELY(tds_write_dump)) {
472  SQLWSTR_BUFS(3);
473  tdsdump_log(TDS_DBG_FUNC, "SQLConnectW(%p, %ls, %d, %ls, %d, %ls, %d)\n",
474  hdbc,
475  SQLWSTR(szDSN), (int) cbDSN,
476  SQLWSTR(szUID), (int) cbUID,
477  SQLWSTR(szAuthStr), (int) cbAuthStr);
478  SQLWSTR_FREE();
479  }
480  return _SQLConnect(hdbc,
481  (ODBC_CHAR*) szDSN, cbDSN,
482  (ODBC_CHAR*) szUID, cbUID,
483  (ODBC_CHAR*) szAuthStr, cbAuthStr, 1);
484 }
485 #endif
486 
487 SQLRETURN ODBC_PUBLIC ODBC_API SQLConnect(
488  SQLHDBC hdbc,
489  SQLCHAR * szDSN, SQLSMALLINT cbDSN,
490  SQLCHAR * szUID, SQLSMALLINT cbUID,
491  SQLCHAR * szAuthStr, SQLSMALLINT cbAuthStr)
492 {
493  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLConnect(%p, %s, %d, %s, %d, %s, %d)\n",
494  hdbc,
495  (const char*) szDSN, (int) cbDSN,
496  (const char*) szUID, (int) cbUID,
497  (const char*) szAuthStr, (int) cbAuthStr);
498 #ifdef ENABLE_ODBC_WIDE
499  return _SQLConnect(hdbc,
500  (ODBC_CHAR*) szDSN, cbDSN,
501  (ODBC_CHAR*) szUID, cbUID,
502  (ODBC_CHAR*) szAuthStr, cbAuthStr, 0);
503 #else
504  return _SQLConnect(hdbc,
505  szDSN, cbDSN,
506  szUID, cbUID,
507  szAuthStr, cbAuthStr);
508 #endif
509 }
510 
511 #ifdef ENABLE_ODBC_WIDE
512 static SQLRETURN _SQLDescribeCol(SQLHSTMT hstmt,
513  SQLUSMALLINT icol,
514  ODBC_CHAR * szColName, SQLSMALLINT cbColNameMax, SQLSMALLINT FAR* pcbColName,
515  SQLSMALLINT * pfSqlType,
516  SQLULEN * pcbColDef,
517  SQLSMALLINT * pibScale,
518  SQLSMALLINT * pfNullable, int wide);
519 
520 SQLRETURN ODBC_PUBLIC ODBC_API SQLDescribeColW(
521  SQLHSTMT hstmt,
522  SQLUSMALLINT icol,
523  SQLWCHAR * szColName, SQLSMALLINT cbColNameMax, SQLSMALLINT FAR* pcbColName,
524  SQLSMALLINT * pfSqlType,
525  SQLULEN * pcbColDef,
526  SQLSMALLINT * pibScale,
527  SQLSMALLINT * pfNullable)
528 {
529  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLDescribeColW(%p, %u, %p, %d, %p, %p, %p, %p, %p)\n",
530  hstmt,
531  (unsigned int) icol,
532  szColName, (int) cbColNameMax, pcbColName,
533  pfSqlType,
534  pcbColDef,
535  pibScale,
536  pfNullable);
537  return _SQLDescribeCol(hstmt,
538  icol,
539  (ODBC_CHAR*) szColName, cbColNameMax, pcbColName,
540  pfSqlType,
541  pcbColDef,
542  pibScale,
543  pfNullable, 1);
544 }
545 #endif
546 
547 SQLRETURN ODBC_PUBLIC ODBC_API SQLDescribeCol(
548  SQLHSTMT hstmt,
549  SQLUSMALLINT icol,
550  SQLCHAR * szColName, SQLSMALLINT cbColNameMax, SQLSMALLINT FAR* pcbColName,
551  SQLSMALLINT * pfSqlType,
552  SQLULEN * pcbColDef,
553  SQLSMALLINT * pibScale,
554  SQLSMALLINT * pfNullable)
555 {
556  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLDescribeCol(%p, %u, %p, %d, %p, %p, %p, %p, %p)\n",
557  hstmt,
558  (unsigned int) icol,
559  szColName, (int) cbColNameMax, pcbColName,
560  pfSqlType,
561  pcbColDef,
562  pibScale,
563  pfNullable);
564 #ifdef ENABLE_ODBC_WIDE
565  return _SQLDescribeCol(hstmt,
566  icol,
567  (ODBC_CHAR*) szColName, cbColNameMax, pcbColName,
568  pfSqlType,
569  pcbColDef,
570  pibScale,
571  pfNullable, 0);
572 #else
573  return _SQLDescribeCol(hstmt,
574  icol,
575  szColName, cbColNameMax, pcbColName,
576  pfSqlType,
577  pcbColDef,
578  pibScale,
579  pfNullable);
580 #endif
581 }
582 
583 #ifdef ENABLE_ODBC_WIDE
584 static SQLRETURN _SQLGetDescRec(SQLHDESC hdesc,
585  SQLSMALLINT RecordNumber,
586  ODBC_CHAR * szName, SQLSMALLINT cbNameMax, SQLSMALLINT FAR* pcbName,
587  SQLSMALLINT * Type,
588  SQLSMALLINT * SubType,
589  SQLLEN * Length,
590  SQLSMALLINT * Precision,
591  SQLSMALLINT * Scale,
592  SQLSMALLINT * Nullable, int wide);
593 
594 SQLRETURN ODBC_PUBLIC ODBC_API SQLGetDescRecW(
595  SQLHDESC hdesc,
596  SQLSMALLINT RecordNumber,
597  SQLWCHAR * szName, SQLSMALLINT cbNameMax, SQLSMALLINT FAR* pcbName,
598  SQLSMALLINT * Type,
599  SQLSMALLINT * SubType,
600  SQLLEN * Length,
601  SQLSMALLINT * Precision,
602  SQLSMALLINT * Scale,
603  SQLSMALLINT * Nullable)
604 {
605  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLGetDescRecW(%p, %d, %p, %d, %p, %p, %p, %p, %p, %p, %p)\n",
606  hdesc,
607  (int) RecordNumber,
608  szName, (int) cbNameMax, pcbName,
609  Type,
610  SubType,
611  Length,
612  Precision,
613  Scale,
614  Nullable);
615  return _SQLGetDescRec(hdesc,
616  RecordNumber,
617  (ODBC_CHAR*) szName, cbNameMax, pcbName,
618  Type,
619  SubType,
620  Length,
621  Precision,
622  Scale,
623  Nullable, 1);
624 }
625 #endif
626 
627 SQLRETURN ODBC_PUBLIC ODBC_API SQLGetDescRec(
628  SQLHDESC hdesc,
629  SQLSMALLINT RecordNumber,
630  SQLCHAR * szName, SQLSMALLINT cbNameMax, SQLSMALLINT FAR* pcbName,
631  SQLSMALLINT * Type,
632  SQLSMALLINT * SubType,
633  SQLLEN * Length,
634  SQLSMALLINT * Precision,
635  SQLSMALLINT * Scale,
636  SQLSMALLINT * Nullable)
637 {
638  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLGetDescRec(%p, %d, %p, %d, %p, %p, %p, %p, %p, %p, %p)\n",
639  hdesc,
640  (int) RecordNumber,
641  szName, (int) cbNameMax, pcbName,
642  Type,
643  SubType,
644  Length,
645  Precision,
646  Scale,
647  Nullable);
648 #ifdef ENABLE_ODBC_WIDE
649  return _SQLGetDescRec(hdesc,
650  RecordNumber,
651  (ODBC_CHAR*) szName, cbNameMax, pcbName,
652  Type,
653  SubType,
654  Length,
655  Precision,
656  Scale,
657  Nullable, 0);
658 #else
659  return _SQLGetDescRec(hdesc,
660  RecordNumber,
661  szName, cbNameMax, pcbName,
662  Type,
663  SubType,
664  Length,
665  Precision,
666  Scale,
667  Nullable);
668 #endif
669 }
670 
671 #ifdef ENABLE_ODBC_WIDE
672 static SQLRETURN _SQLGetDescField(SQLHDESC hdesc,
673  SQLSMALLINT icol,
674  SQLSMALLINT fDescType,
675  SQLPOINTER Value,
676  SQLINTEGER BufferLength,
677  SQLINTEGER * StringLength, int wide);
678 
679 SQLRETURN ODBC_PUBLIC ODBC_API SQLGetDescFieldW(
680  SQLHDESC hdesc,
681  SQLSMALLINT icol,
682  SQLSMALLINT fDescType,
683  SQLPOINTER Value,
684  SQLINTEGER BufferLength,
685  SQLINTEGER * StringLength)
686 {
687  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLGetDescFieldW(%p, %d, %d, %p, %d, %p)\n",
688  hdesc,
689  (int) icol,
690  (int) fDescType,
691  Value,
692  (int) BufferLength,
693  StringLength);
694  return _SQLGetDescField(hdesc,
695  icol,
696  fDescType,
697  Value,
698  BufferLength,
699  StringLength, 1);
700 }
701 #endif
702 
703 SQLRETURN ODBC_PUBLIC ODBC_API SQLGetDescField(
704  SQLHDESC hdesc,
705  SQLSMALLINT icol,
706  SQLSMALLINT fDescType,
707  SQLPOINTER Value,
708  SQLINTEGER BufferLength,
709  SQLINTEGER * StringLength)
710 {
711  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLGetDescField(%p, %d, %d, %p, %d, %p)\n",
712  hdesc,
713  (int) icol,
714  (int) fDescType,
715  Value,
716  (int) BufferLength,
717  StringLength);
718 #ifdef ENABLE_ODBC_WIDE
719  return _SQLGetDescField(hdesc,
720  icol,
721  fDescType,
722  Value,
723  BufferLength,
724  StringLength, 0);
725 #else
726  return _SQLGetDescField(hdesc,
727  icol,
728  fDescType,
729  Value,
730  BufferLength,
731  StringLength);
732 #endif
733 }
734 
735 #ifdef ENABLE_ODBC_WIDE
736 static SQLRETURN _SQLSetDescField(SQLHDESC hdesc,
737  SQLSMALLINT icol,
738  SQLSMALLINT fDescType,
739  SQLPOINTER Value,
740  SQLINTEGER BufferLength, int wide);
741 
742 SQLRETURN ODBC_PUBLIC ODBC_API SQLSetDescFieldW(
743  SQLHDESC hdesc,
744  SQLSMALLINT icol,
745  SQLSMALLINT fDescType,
746  SQLPOINTER Value,
747  SQLINTEGER BufferLength)
748 {
749  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLSetDescFieldW(%p, %d, %d, %p, %d)\n",
750  hdesc,
751  (int) icol,
752  (int) fDescType,
753  Value,
754  (int) BufferLength);
755  return _SQLSetDescField(hdesc,
756  icol,
757  fDescType,
758  Value,
759  BufferLength, 1);
760 }
761 #endif
762 
763 SQLRETURN ODBC_PUBLIC ODBC_API SQLSetDescField(
764  SQLHDESC hdesc,
765  SQLSMALLINT icol,
766  SQLSMALLINT fDescType,
767  SQLPOINTER Value,
768  SQLINTEGER BufferLength)
769 {
770  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLSetDescField(%p, %d, %d, %p, %d)\n",
771  hdesc,
772  (int) icol,
773  (int) fDescType,
774  Value,
775  (int) BufferLength);
776 #ifdef ENABLE_ODBC_WIDE
777  return _SQLSetDescField(hdesc,
778  icol,
779  fDescType,
780  Value,
781  BufferLength, 0);
782 #else
783  return _SQLSetDescField(hdesc,
784  icol,
785  fDescType,
786  Value,
787  BufferLength);
788 #endif
789 }
790 
791 #ifdef ENABLE_ODBC_WIDE
792 static SQLRETURN _SQLExecDirect(SQLHSTMT hstmt,
793  ODBC_CHAR * szSqlStr, SQLINTEGER cbSqlStr, int wide);
794 
795 SQLRETURN ODBC_PUBLIC ODBC_API SQLExecDirectW(
796  SQLHSTMT hstmt,
797  SQLWCHAR * szSqlStr, SQLINTEGER cbSqlStr)
798 {
799  if (TDS_UNLIKELY(tds_write_dump)) {
800  SQLWSTR_BUFS(1);
801  tdsdump_log(TDS_DBG_FUNC, "SQLExecDirectW(%p, %ls, %d)\n",
802  hstmt,
803  SQLWSTR(szSqlStr), (int) cbSqlStr);
804  SQLWSTR_FREE();
805  }
806  return _SQLExecDirect(hstmt,
807  (ODBC_CHAR*) szSqlStr, cbSqlStr, 1);
808 }
809 #endif
810 
811 SQLRETURN ODBC_PUBLIC ODBC_API SQLExecDirect(
812  SQLHSTMT hstmt,
813  SQLCHAR * szSqlStr, SQLINTEGER cbSqlStr)
814 {
815  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLExecDirect(%p, %s, %d)\n",
816  hstmt,
817  (const char*) szSqlStr, (int) cbSqlStr);
818 #ifdef ENABLE_ODBC_WIDE
819  return _SQLExecDirect(hstmt,
820  (ODBC_CHAR*) szSqlStr, cbSqlStr, 0);
821 #else
822  return _SQLExecDirect(hstmt,
823  szSqlStr, cbSqlStr);
824 #endif
825 }
826 
827 #ifdef ENABLE_ODBC_WIDE
828 static SQLRETURN _SQLPrepare(SQLHSTMT hstmt,
829  ODBC_CHAR * szSqlStr, SQLINTEGER cbSqlStr, int wide);
830 
831 SQLRETURN ODBC_PUBLIC ODBC_API SQLPrepareW(
832  SQLHSTMT hstmt,
833  SQLWCHAR * szSqlStr, SQLINTEGER cbSqlStr)
834 {
835  if (TDS_UNLIKELY(tds_write_dump)) {
836  SQLWSTR_BUFS(1);
837  tdsdump_log(TDS_DBG_FUNC, "SQLPrepareW(%p, %ls, %d)\n",
838  hstmt,
839  SQLWSTR(szSqlStr), (int) cbSqlStr);
840  SQLWSTR_FREE();
841  }
842  return _SQLPrepare(hstmt,
843  (ODBC_CHAR*) szSqlStr, cbSqlStr, 1);
844 }
845 #endif
846 
847 SQLRETURN ODBC_PUBLIC ODBC_API SQLPrepare(
848  SQLHSTMT hstmt,
849  SQLCHAR * szSqlStr, SQLINTEGER cbSqlStr)
850 {
851  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLPrepare(%p, %s, %d)\n",
852  hstmt,
853  (const char*) szSqlStr, (int) cbSqlStr);
854 #ifdef ENABLE_ODBC_WIDE
855  return _SQLPrepare(hstmt,
856  (ODBC_CHAR*) szSqlStr, cbSqlStr, 0);
857 #else
858  return _SQLPrepare(hstmt,
859  szSqlStr, cbSqlStr);
860 #endif
861 }
862 
863 #ifdef ENABLE_ODBC_WIDE
864 static SQLRETURN _SQLSetCursorName(SQLHSTMT hstmt,
865  ODBC_CHAR * szCursor, SQLSMALLINT cbCursor, int wide);
866 
867 SQLRETURN ODBC_PUBLIC ODBC_API SQLSetCursorNameW(
868  SQLHSTMT hstmt,
869  SQLWCHAR * szCursor, SQLSMALLINT cbCursor)
870 {
871  if (TDS_UNLIKELY(tds_write_dump)) {
872  SQLWSTR_BUFS(1);
873  tdsdump_log(TDS_DBG_FUNC, "SQLSetCursorNameW(%p, %ls, %d)\n",
874  hstmt,
875  SQLWSTR(szCursor), (int) cbCursor);
876  SQLWSTR_FREE();
877  }
878  return _SQLSetCursorName(hstmt,
879  (ODBC_CHAR*) szCursor, cbCursor, 1);
880 }
881 #endif
882 
883 SQLRETURN ODBC_PUBLIC ODBC_API SQLSetCursorName(
884  SQLHSTMT hstmt,
885  SQLCHAR * szCursor, SQLSMALLINT cbCursor)
886 {
887  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLSetCursorName(%p, %s, %d)\n",
888  hstmt,
889  (const char*) szCursor, (int) cbCursor);
890 #ifdef ENABLE_ODBC_WIDE
891  return _SQLSetCursorName(hstmt,
892  (ODBC_CHAR*) szCursor, cbCursor, 0);
893 #else
894  return _SQLSetCursorName(hstmt,
895  szCursor, cbCursor);
896 #endif
897 }
898 
899 #ifdef ENABLE_ODBC_WIDE
900 static SQLRETURN _SQLGetCursorName(SQLHSTMT hstmt,
901  ODBC_CHAR * szCursor, SQLSMALLINT cbCursorMax, SQLSMALLINT FAR* pcbCursor, int wide);
902 
903 SQLRETURN ODBC_PUBLIC ODBC_API SQLGetCursorNameW(
904  SQLHSTMT hstmt,
905  SQLWCHAR * szCursor, SQLSMALLINT cbCursorMax, SQLSMALLINT FAR* pcbCursor)
906 {
907  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLGetCursorNameW(%p, %p, %d, %p)\n",
908  hstmt,
909  szCursor, (int) cbCursorMax, pcbCursor);
910  return _SQLGetCursorName(hstmt,
911  (ODBC_CHAR*) szCursor, cbCursorMax, pcbCursor, 1);
912 }
913 #endif
914 
915 SQLRETURN ODBC_PUBLIC ODBC_API SQLGetCursorName(
916  SQLHSTMT hstmt,
917  SQLCHAR * szCursor, SQLSMALLINT cbCursorMax, SQLSMALLINT FAR* pcbCursor)
918 {
919  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLGetCursorName(%p, %p, %d, %p)\n",
920  hstmt,
921  szCursor, (int) cbCursorMax, pcbCursor);
922 #ifdef ENABLE_ODBC_WIDE
923  return _SQLGetCursorName(hstmt,
924  (ODBC_CHAR*) szCursor, cbCursorMax, pcbCursor, 0);
925 #else
926  return _SQLGetCursorName(hstmt,
927  szCursor, cbCursorMax, pcbCursor);
928 #endif
929 }
930 
931 #ifdef ENABLE_ODBC_WIDE
932 static SQLRETURN _SQLColumns(SQLHSTMT hstmt,
933  ODBC_CHAR * szCatalogName, SQLSMALLINT cbCatalogName,
934  ODBC_CHAR * szSchemaName, SQLSMALLINT cbSchemaName,
935  ODBC_CHAR * szTableName, SQLSMALLINT cbTableName,
936  ODBC_CHAR * szColumnName, SQLSMALLINT cbColumnName, int wide);
937 
938 SQLRETURN ODBC_PUBLIC ODBC_API SQLColumnsW(
939  SQLHSTMT hstmt,
940  SQLWCHAR * szCatalogName, SQLSMALLINT cbCatalogName,
941  SQLWCHAR * szSchemaName, SQLSMALLINT cbSchemaName,
942  SQLWCHAR * szTableName, SQLSMALLINT cbTableName,
943  SQLWCHAR * szColumnName, SQLSMALLINT cbColumnName)
944 {
945  if (TDS_UNLIKELY(tds_write_dump)) {
946  SQLWSTR_BUFS(4);
947  tdsdump_log(TDS_DBG_FUNC, "SQLColumnsW(%p, %ls, %d, %ls, %d, %ls, %d, %ls, %d)\n",
948  hstmt,
949  SQLWSTR(szCatalogName), (int) cbCatalogName,
950  SQLWSTR(szSchemaName), (int) cbSchemaName,
951  SQLWSTR(szTableName), (int) cbTableName,
952  SQLWSTR(szColumnName), (int) cbColumnName);
953  SQLWSTR_FREE();
954  }
955  return _SQLColumns(hstmt,
956  (ODBC_CHAR*) szCatalogName, cbCatalogName,
957  (ODBC_CHAR*) szSchemaName, cbSchemaName,
958  (ODBC_CHAR*) szTableName, cbTableName,
959  (ODBC_CHAR*) szColumnName, cbColumnName, 1);
960 }
961 #endif
962 
963 SQLRETURN ODBC_PUBLIC ODBC_API SQLColumns(
964  SQLHSTMT hstmt,
965  SQLCHAR * szCatalogName, SQLSMALLINT cbCatalogName,
966  SQLCHAR * szSchemaName, SQLSMALLINT cbSchemaName,
967  SQLCHAR * szTableName, SQLSMALLINT cbTableName,
968  SQLCHAR * szColumnName, SQLSMALLINT cbColumnName)
969 {
970  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLColumns(%p, %s, %d, %s, %d, %s, %d, %s, %d)\n",
971  hstmt,
972  (const char*) szCatalogName, (int) cbCatalogName,
973  (const char*) szSchemaName, (int) cbSchemaName,
974  (const char*) szTableName, (int) cbTableName,
975  (const char*) szColumnName, (int) cbColumnName);
976 #ifdef ENABLE_ODBC_WIDE
977  return _SQLColumns(hstmt,
978  (ODBC_CHAR*) szCatalogName, cbCatalogName,
979  (ODBC_CHAR*) szSchemaName, cbSchemaName,
980  (ODBC_CHAR*) szTableName, cbTableName,
981  (ODBC_CHAR*) szColumnName, cbColumnName, 0);
982 #else
983  return _SQLColumns(hstmt,
984  szCatalogName, cbCatalogName,
985  szSchemaName, cbSchemaName,
986  szTableName, cbTableName,
987  szColumnName, cbColumnName);
988 #endif
989 }
990 
991 #ifdef ENABLE_ODBC_WIDE
992 static SQLRETURN _SQLGetConnectAttr(SQLHDBC hdbc,
993  SQLINTEGER Attribute,
994  SQLPOINTER Value,
995  SQLINTEGER BufferLength,
996  SQLINTEGER * StringLength, int wide);
997 
998 SQLRETURN ODBC_PUBLIC ODBC_API SQLGetConnectAttrW(
999  SQLHDBC hdbc,
1000  SQLINTEGER Attribute,
1001  SQLPOINTER Value,
1002  SQLINTEGER BufferLength,
1003  SQLINTEGER * StringLength)
1004 {
1005  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLGetConnectAttrW(%p, %d, %p, %d, %p)\n",
1006  hdbc,
1007  (int) Attribute,
1008  Value,
1009  (int) BufferLength,
1010  StringLength);
1011  return _SQLGetConnectAttr(hdbc,
1012  Attribute,
1013  Value,
1014  BufferLength,
1015  StringLength, 1);
1016 }
1017 #endif
1018 
1019 SQLRETURN ODBC_PUBLIC ODBC_API SQLGetConnectAttr(
1020  SQLHDBC hdbc,
1021  SQLINTEGER Attribute,
1022  SQLPOINTER Value,
1023  SQLINTEGER BufferLength,
1024  SQLINTEGER * StringLength)
1025 {
1026  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLGetConnectAttr(%p, %d, %p, %d, %p)\n",
1027  hdbc,
1028  (int) Attribute,
1029  Value,
1030  (int) BufferLength,
1031  StringLength);
1032 #ifdef ENABLE_ODBC_WIDE
1033  return _SQLGetConnectAttr(hdbc,
1034  Attribute,
1035  Value,
1036  BufferLength,
1037  StringLength, 0);
1038 #else
1039  return _SQLGetConnectAttr(hdbc,
1040  Attribute,
1041  Value,
1042  BufferLength,
1043  StringLength);
1044 #endif
1045 }
1046 
1047 #ifdef ENABLE_ODBC_WIDE
1048 static SQLRETURN _SQLSetConnectAttr(SQLHDBC hdbc,
1049  SQLINTEGER Attribute,
1050  SQLPOINTER ValuePtr,
1051  SQLINTEGER StringLength, int wide);
1052 
1053 SQLRETURN ODBC_PUBLIC ODBC_API SQLSetConnectAttrW(
1054  SQLHDBC hdbc,
1055  SQLINTEGER Attribute,
1056  SQLPOINTER ValuePtr,
1057  SQLINTEGER StringLength)
1058 {
1059  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLSetConnectAttrW(%p, %d, %p, %d)\n",
1060  hdbc,
1061  (int) Attribute,
1062  ValuePtr,
1063  (int) StringLength);
1064  return _SQLSetConnectAttr(hdbc,
1065  Attribute,
1066  ValuePtr,
1067  StringLength, 1);
1068 }
1069 #endif
1070 
1071 SQLRETURN ODBC_PUBLIC ODBC_API SQLSetConnectAttr(
1072  SQLHDBC hdbc,
1073  SQLINTEGER Attribute,
1074  SQLPOINTER ValuePtr,
1075  SQLINTEGER StringLength)
1076 {
1077  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLSetConnectAttr(%p, %d, %p, %d)\n",
1078  hdbc,
1079  (int) Attribute,
1080  ValuePtr,
1081  (int) StringLength);
1082 #ifdef ENABLE_ODBC_WIDE
1083  return _SQLSetConnectAttr(hdbc,
1084  Attribute,
1085  ValuePtr,
1086  StringLength, 0);
1087 #else
1088  return _SQLSetConnectAttr(hdbc,
1089  Attribute,
1090  ValuePtr,
1091  StringLength);
1092 #endif
1093 }
1094 
1095 #ifdef ENABLE_ODBC_WIDE
1096 static SQLRETURN _SQLSpecialColumns(SQLHSTMT hstmt,
1097  SQLUSMALLINT fColType,
1098  ODBC_CHAR * szCatalogName, SQLSMALLINT cbCatalogName,
1099  ODBC_CHAR * szSchemaName, SQLSMALLINT cbSchemaName,
1100  ODBC_CHAR * szTableName, SQLSMALLINT cbTableName,
1101  SQLUSMALLINT fScope,
1102  SQLUSMALLINT fNullable, int wide);
1103 
1104 SQLRETURN ODBC_PUBLIC ODBC_API SQLSpecialColumnsW(
1105  SQLHSTMT hstmt,
1106  SQLUSMALLINT fColType,
1107  SQLWCHAR * szCatalogName, SQLSMALLINT cbCatalogName,
1108  SQLWCHAR * szSchemaName, SQLSMALLINT cbSchemaName,
1109  SQLWCHAR * szTableName, SQLSMALLINT cbTableName,
1110  SQLUSMALLINT fScope,
1111  SQLUSMALLINT fNullable)
1112 {
1113  if (TDS_UNLIKELY(tds_write_dump)) {
1114  SQLWSTR_BUFS(3);
1115  tdsdump_log(TDS_DBG_FUNC, "SQLSpecialColumnsW(%p, %u, %ls, %d, %ls, %d, %ls, %d, %u, %u)\n",
1116  hstmt,
1117  (unsigned int) fColType,
1118  SQLWSTR(szCatalogName), (int) cbCatalogName,
1119  SQLWSTR(szSchemaName), (int) cbSchemaName,
1120  SQLWSTR(szTableName), (int) cbTableName,
1121  (unsigned int) fScope,
1122  (unsigned int) fNullable);
1123  SQLWSTR_FREE();
1124  }
1125  return _SQLSpecialColumns(hstmt,
1126  fColType,
1127  (ODBC_CHAR*) szCatalogName, cbCatalogName,
1128  (ODBC_CHAR*) szSchemaName, cbSchemaName,
1129  (ODBC_CHAR*) szTableName, cbTableName,
1130  fScope,
1131  fNullable, 1);
1132 }
1133 #endif
1134 
1135 SQLRETURN ODBC_PUBLIC ODBC_API SQLSpecialColumns(
1136  SQLHSTMT hstmt,
1137  SQLUSMALLINT fColType,
1138  SQLCHAR * szCatalogName, SQLSMALLINT cbCatalogName,
1139  SQLCHAR * szSchemaName, SQLSMALLINT cbSchemaName,
1140  SQLCHAR * szTableName, SQLSMALLINT cbTableName,
1141  SQLUSMALLINT fScope,
1142  SQLUSMALLINT fNullable)
1143 {
1144  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLSpecialColumns(%p, %u, %s, %d, %s, %d, %s, %d, %u, %u)\n",
1145  hstmt,
1146  (unsigned int) fColType,
1147  (const char*) szCatalogName, (int) cbCatalogName,
1148  (const char*) szSchemaName, (int) cbSchemaName,
1149  (const char*) szTableName, (int) cbTableName,
1150  (unsigned int) fScope,
1151  (unsigned int) fNullable);
1152 #ifdef ENABLE_ODBC_WIDE
1153  return _SQLSpecialColumns(hstmt,
1154  fColType,
1155  (ODBC_CHAR*) szCatalogName, cbCatalogName,
1156  (ODBC_CHAR*) szSchemaName, cbSchemaName,
1157  (ODBC_CHAR*) szTableName, cbTableName,
1158  fScope,
1159  fNullable, 0);
1160 #else
1161  return _SQLSpecialColumns(hstmt,
1162  fColType,
1163  szCatalogName, cbCatalogName,
1164  szSchemaName, cbSchemaName,
1165  szTableName, cbTableName,
1166  fScope,
1167  fNullable);
1168 #endif
1169 }
1170 
1171 #ifdef ENABLE_ODBC_WIDE
1172 static SQLRETURN _SQLStatistics(SQLHSTMT hstmt,
1173  ODBC_CHAR * szCatalogName, SQLSMALLINT cbCatalogName,
1174  ODBC_CHAR * szSchemaName, SQLSMALLINT cbSchemaName,
1175  ODBC_CHAR * szTableName, SQLSMALLINT cbTableName,
1176  SQLUSMALLINT fUnique,
1177  SQLUSMALLINT fAccuracy, int wide);
1178 
1179 SQLRETURN ODBC_PUBLIC ODBC_API SQLStatisticsW(
1180  SQLHSTMT hstmt,
1181  SQLWCHAR * szCatalogName, SQLSMALLINT cbCatalogName,
1182  SQLWCHAR * szSchemaName, SQLSMALLINT cbSchemaName,
1183  SQLWCHAR * szTableName, SQLSMALLINT cbTableName,
1184  SQLUSMALLINT fUnique,
1185  SQLUSMALLINT fAccuracy)
1186 {
1187  if (TDS_UNLIKELY(tds_write_dump)) {
1188  SQLWSTR_BUFS(3);
1189  tdsdump_log(TDS_DBG_FUNC, "SQLStatisticsW(%p, %ls, %d, %ls, %d, %ls, %d, %u, %u)\n",
1190  hstmt,
1191  SQLWSTR(szCatalogName), (int) cbCatalogName,
1192  SQLWSTR(szSchemaName), (int) cbSchemaName,
1193  SQLWSTR(szTableName), (int) cbTableName,
1194  (unsigned int) fUnique,
1195  (unsigned int) fAccuracy);
1196  SQLWSTR_FREE();
1197  }
1198  return _SQLStatistics(hstmt,
1199  (ODBC_CHAR*) szCatalogName, cbCatalogName,
1200  (ODBC_CHAR*) szSchemaName, cbSchemaName,
1201  (ODBC_CHAR*) szTableName, cbTableName,
1202  fUnique,
1203  fAccuracy, 1);
1204 }
1205 #endif
1206 
1207 SQLRETURN ODBC_PUBLIC ODBC_API SQLStatistics(
1208  SQLHSTMT hstmt,
1209  SQLCHAR * szCatalogName, SQLSMALLINT cbCatalogName,
1210  SQLCHAR * szSchemaName, SQLSMALLINT cbSchemaName,
1211  SQLCHAR * szTableName, SQLSMALLINT cbTableName,
1212  SQLUSMALLINT fUnique,
1213  SQLUSMALLINT fAccuracy)
1214 {
1215  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLStatistics(%p, %s, %d, %s, %d, %s, %d, %u, %u)\n",
1216  hstmt,
1217  (const char*) szCatalogName, (int) cbCatalogName,
1218  (const char*) szSchemaName, (int) cbSchemaName,
1219  (const char*) szTableName, (int) cbTableName,
1220  (unsigned int) fUnique,
1221  (unsigned int) fAccuracy);
1222 #ifdef ENABLE_ODBC_WIDE
1223  return _SQLStatistics(hstmt,
1224  (ODBC_CHAR*) szCatalogName, cbCatalogName,
1225  (ODBC_CHAR*) szSchemaName, cbSchemaName,
1226  (ODBC_CHAR*) szTableName, cbTableName,
1227  fUnique,
1228  fAccuracy, 0);
1229 #else
1230  return _SQLStatistics(hstmt,
1231  szCatalogName, cbCatalogName,
1232  szSchemaName, cbSchemaName,
1233  szTableName, cbTableName,
1234  fUnique,
1235  fAccuracy);
1236 #endif
1237 }
1238 
1239 #ifdef ENABLE_ODBC_WIDE
1240 static SQLRETURN _SQLTables(SQLHSTMT hstmt,
1241  ODBC_CHAR * szCatalogName, SQLSMALLINT cbCatalogName,
1242  ODBC_CHAR * szSchemaName, SQLSMALLINT cbSchemaName,
1243  ODBC_CHAR * szTableName, SQLSMALLINT cbTableName,
1244  ODBC_CHAR * szTableType, SQLSMALLINT cbTableType, int wide);
1245 
1246 SQLRETURN ODBC_PUBLIC ODBC_API SQLTablesW(
1247  SQLHSTMT hstmt,
1248  SQLWCHAR * szCatalogName, SQLSMALLINT cbCatalogName,
1249  SQLWCHAR * szSchemaName, SQLSMALLINT cbSchemaName,
1250  SQLWCHAR * szTableName, SQLSMALLINT cbTableName,
1251  SQLWCHAR * szTableType, SQLSMALLINT cbTableType)
1252 {
1253  if (TDS_UNLIKELY(tds_write_dump)) {
1254  SQLWSTR_BUFS(4);
1255  tdsdump_log(TDS_DBG_FUNC, "SQLTablesW(%p, %ls, %d, %ls, %d, %ls, %d, %ls, %d)\n",
1256  hstmt,
1257  SQLWSTR(szCatalogName), (int) cbCatalogName,
1258  SQLWSTR(szSchemaName), (int) cbSchemaName,
1259  SQLWSTR(szTableName), (int) cbTableName,
1260  SQLWSTR(szTableType), (int) cbTableType);
1261  SQLWSTR_FREE();
1262  }
1263  return _SQLTables(hstmt,
1264  (ODBC_CHAR*) szCatalogName, cbCatalogName,
1265  (ODBC_CHAR*) szSchemaName, cbSchemaName,
1266  (ODBC_CHAR*) szTableName, cbTableName,
1267  (ODBC_CHAR*) szTableType, cbTableType, 1);
1268 }
1269 #endif
1270 
1271 SQLRETURN ODBC_PUBLIC ODBC_API SQLTables(
1272  SQLHSTMT hstmt,
1273  SQLCHAR * szCatalogName, SQLSMALLINT cbCatalogName,
1274  SQLCHAR * szSchemaName, SQLSMALLINT cbSchemaName,
1275  SQLCHAR * szTableName, SQLSMALLINT cbTableName,
1276  SQLCHAR * szTableType, SQLSMALLINT cbTableType)
1277 {
1278  TDSDUMP_LOG_FAST(TDS_DBG_FUNC, "SQLTables(%p, %s, %d, %s, %d, %s, %d, %s, %d)\n",
1279  hstmt,
1280  (const char*) szCatalogName, (int) cbCatalogName,
1281  (const char*) szSchemaName, (int) cbSchemaName,
1282  (const char*) szTableName, (int) cbTableName,
1283  (const char*) szTableType, (int) cbTableType);
1284 #ifdef ENABLE_ODBC_WIDE
1285  return _SQLTables(hstmt,
1286  (ODBC_CHAR*) szCatalogName, cbCatalogName,
1287  (ODBC_CHAR*) szSchemaName, cbSchemaName,
1288  (ODBC_CHAR*) szTableName, cbTableName,
1289  (ODBC_CHAR*) szTableType, cbTableType, 0);
1290 #else
1291  return _SQLTables(hstmt,
1292  szCatalogName, cbCatalogName,
1293  szSchemaName, cbSchemaName,
1294  szTableName, cbTableName,
1295  szTableType, cbTableType);
1296 #endif
1297 }
1298 
1299 #define tdsdump_log TDSDUMP_LOG_FAST
int tds_write_dump
Tell if TDS debug logging is turned on or off.
Definition: log.c:57
void tdsdump_log(const char *file, unsigned int level_line, const char *fmt,...)
Write a message to the debug log.
Definition: log.c:353
freetds-1.00.82/doc/reference/a00134_source.html100644 025423 025423 00000015327 13242511132 0014611 FreeTDS API: src/odbc/resource.h Source File
FreeTDS API
resource.h
1 //{{NO_DEPENDENCIES}}
2 // Microsoft Developer Studio generated include file.
3 // Used by setup.rc
4 //
5 #define IDD_LOGIN 102
6 #define IDD_DSN 106
7 #define IDC_PROTOCOL 1003
8 #define IDC_ADDRESS 1004
9 #define IDC_PORT 1005
10 #define IDC_DATABASE 1011
11 #define IDC_DSNNAME 1015
12 #define IDC_HINT 1017
13 #define IDC_LOGINSERVER 1020
14 #define IDC_LOGINUID 1021
15 #define IDC_LOGINPWD 1022
16 #define IDC_LOGINDUMP 1023
17 
18 // Next default values for new objects
19 //
20 #ifdef APSTUDIO_INVOKED
21 #ifndef APSTUDIO_READONLY_SYMBOLS
22 #define _APS_NEXT_RESOURCE_VALUE 103
23 #define _APS_NEXT_COMMAND_VALUE 40001
24 #define _APS_NEXT_CONTROL_VALUE 1024
25 #define _APS_NEXT_SYMED_VALUE 101
26 #endif
27 #endif
freetds-1.00.82/doc/reference/a00143_source.html100644 025423 025423 00000013731 13242511132 0014606 FreeTDS API: src/odbc/sqlwparams.h Source File
FreeTDS API
sqlwparams.h
1 #if 0
2 # ODBC_FUNC(SQLTest, (P(SQLSMALLINT, x), PCHAR(y) WIDE))
3 #endif
4 
5 #undef WIDE
6 #undef P
7 #undef PCHAR
8 #undef PCHARIN
9 #undef PCHAROUT
10 
11 #ifdef ENABLE_ODBC_WIDE
12 # define WIDE , int wide
13 # define PCHAR(a) ODBC_CHAR* a
14 #else
15 # define WIDE
16 # define PCHAR(a) SQLCHAR* a
17 #endif
18 
19 #define P(a,b) a b
20 #define PCHARIN(n,t) PCHAR(sz ## n), P(t, cb ## n)
21 #define PCHAROUT(n,t) PCHAR(sz ## n), P(t, cb ## n ## Max), P(t FAR*, pcb ## n)
22 
23 #define ODBC_FUNC(name, params) \
24  static SQLRETURN _ ## name params
25 
freetds-1.00.82/doc/reference/a00161_source.html100644 025423 025423 00000071625 13242511132 0014614 FreeTDS API: src/pool/pool.h Source File
FreeTDS API
pool.h
1 /* TDSPool - Connection pooling for TDS based databases
2  * Copyright (C) 2001 Brian Bruns
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  */
19 
20 #ifndef _pool_h_
21 #define _pool_h_
22 
23 #include <assert.h>
24 
25 #if HAVE_SYS_TYPES_H
26 #include <sys/types.h>
27 #endif
28 
29 #if HAVE_NETINET_IN_H
30 #include <netinet/in.h>
31 #endif
32 
33 /*
34  * POSIX says fd_set type may be defined in either sys/select.h or sys/time.h.
35  */
36 #if HAVE_SYS_TIME_H
37 #include <sys/time.h>
38 #endif
39 
40 #include <freetds/tds.h>
41 #include <freetds/dlist.h>
42 
43 /* defines */
44 #define PGSIZ 2048
45 #define BLOCKSIZ 512
46 #define MAX_POOL_USERS 1024
47 
48 /* enums and typedefs */
49 typedef enum
50 {
51  TDS_SRV_WAIT, /* if no members are free wait */
52  TDS_SRV_QUERY,
53 } TDS_USER_STATE;
54 
55 /* forward declaration */
56 typedef struct tds_pool_event TDS_POOL_EVENT;
57 typedef struct tds_pool_socket TDS_POOL_SOCKET;
58 typedef struct tds_pool_member TDS_POOL_MEMBER;
59 typedef struct tds_pool_user TDS_POOL_USER;
60 typedef struct tds_pool TDS_POOL;
61 typedef void (*TDS_POOL_EXECUTE)(TDS_POOL_EVENT *event);
62 
64 {
65  TDS_POOL_EVENT *next;
66  TDS_POOL_EXECUTE execute;
67 };
68 
70 {
71  TDSSOCKET *tds;
72  bool poll_recv;
73  bool poll_send;
74 };
75 
77 {
78  TDS_POOL_SOCKET sock;
79  DLIST_FIELDS(dlist_user_item);
80  TDSLOGIN *login;
81  TDS_USER_STATE user_state;
82  TDS_POOL_MEMBER *assigned_member;
83 };
84 
86 {
87  TDS_POOL_SOCKET sock;
88  DLIST_FIELDS(dlist_member_item);
89  bool doing_async;
90  time_t last_used_tm;
91  TDS_POOL_USER *current_user;
92 };
93 
94 #define DLIST_NAME(suffix) dlist_member_ ## suffix
95 #define DLIST_LIST_TYPE dlist_members
96 #define DLIST_TYPE TDS_POOL_MEMBER
97 #include <freetds/dlist.tmpl.h>
98 
99 #define DLIST_NAME(suffix) dlist_user_ ## suffix
100 #define DLIST_LIST_TYPE dlist_users
101 #define DLIST_TYPE TDS_POOL_USER
102 #include <freetds/dlist.tmpl.h>
103 
104 struct tds_pool
105 {
106  char *name;
107  char *user;
108  char *password;
109  char *server;
110  char *database;
111  int port;
112  int max_member_age; /* in seconds */
113  int min_open_conn;
114  int max_open_conn;
115  tds_mutex events_mtx;
116  TDS_SYS_SOCKET listen_fd;
117  TDS_SYS_SOCKET wakeup_fd;
118  TDS_SYS_SOCKET event_fd;
119  TDS_POOL_EVENT *events;
120 
121  int num_active_members;
122  dlist_members active_members;
123  dlist_members idle_members;
124 
126  dlist_users waiters;
127  int num_users;
128  dlist_users users;
129  TDSCONTEXT *ctx;
130 
131  unsigned long user_logins;
132  unsigned long member_logins;
133 };
134 
135 /* prototypes */
136 
137 /* member.c */
138 void pool_process_members(TDS_POOL * pool, fd_set * rfds, fd_set * wfds);
139 TDS_POOL_MEMBER *pool_assign_idle_member(TDS_POOL * pool, TDS_POOL_USER *user);
140 void pool_mbr_init(TDS_POOL * pool);
141 void pool_mbr_destroy(TDS_POOL * pool);
142 void pool_free_member(TDS_POOL *pool, TDS_POOL_MEMBER * pmbr);
143 void pool_assign_member(TDS_POOL *pool, TDS_POOL_MEMBER * pmbr, TDS_POOL_USER *puser);
144 void pool_deassign_member(TDS_POOL *pool, TDS_POOL_MEMBER * pmbr);
145 void pool_reset_member(TDS_POOL *pool, TDS_POOL_MEMBER * pmbr);
146 bool pool_packet_read(TDSSOCKET * tds);
147 
148 /* user.c */
149 void pool_process_users(TDS_POOL * pool, fd_set * rfds, fd_set * wfds);
150 void pool_user_init(TDS_POOL * pool);
151 void pool_user_destroy(TDS_POOL * pool);
152 TDS_POOL_USER *pool_user_create(TDS_POOL * pool, TDS_SYS_SOCKET s);
153 void pool_free_user(TDS_POOL * pool, TDS_POOL_USER * puser);
154 void pool_user_query(TDS_POOL * pool, TDS_POOL_USER * puser);
155 bool pool_user_send_login_ack(TDS_POOL * pool, TDS_POOL_USER * puser);
156 void pool_user_finish_login(TDS_POOL * pool, TDS_POOL_USER * puser);
157 
158 /* util.c */
159 void dump_login(TDSLOGIN * login);
160 void pool_event_add(TDS_POOL *pool, TDS_POOL_EVENT *ev, TDS_POOL_EXECUTE execute);
161 int pool_write(TDS_SYS_SOCKET sock, const void *buf, size_t len);
162 bool pool_write_data(TDS_POOL_SOCKET *from, TDS_POOL_SOCKET *to);
163 
164 /* config.c */
165 int pool_read_conf_file(const char *poolname, TDS_POOL * pool, char **err);
166 
167 
168 #endif
Definition: tds.h:1063
dlist_users waiters
users in wait state
Definition: pool.h:126
Information for a server connection.
Definition: tds.h:1174
Definition: tds.h:549
Definition: pool.h:76
Main include file for libtds.
Definition: pool.h:104
Definition: pool.h:69
Definition: pool.h:85
Definition: pool.h:63
freetds-1.00.82/doc/reference/a00245_source.html100644 025423 025423 00000273507 13242511132 0014622 FreeTDS API: src/tds/alternative_character_sets.h Source File
FreeTDS API
alternative_character_sets.h
1 /*
2  * Copyright 2003 James K. Lowden <jklowden@schemamania.org>
3  * Redistribution and use in source and binary forms, with or without
4  * modification, are permitted, provided that redistributions of source
5  * code retain the above copyright notice.
6  */
7 
8  /*
9  * The purpose of this file is to help look up character set names.
10  *
11  * Any given encoding may be known by several (usually similar) aliases.
12  * For example, a system using ASCII encoding may report the character set as
13  * "ASCII", "US-ASCII", or "ISO646-US", among others. For details on what your system
14  * uses, you may wish to consult the nl_langinfo(3) manual page.
15  *
16  * GNU iconv converts a byte sequence from one encoding to another, but before it can do
17  * so, it must be told which is which. In the list below, the preferred GNU iconv(3) name
18  * is on the left and an alias is on the right. It is a simple exercise, left to the reader,
19  * to write a function that uses these data to look up the canonical name when provided
20  * an alias.
21  */
22 
23 #ifndef _ALTERNATIVE_CHARACTER_SETS_H_
24 #define _ALTERNATIVE_CHARACTER_SETS_H_
25 
26 /*
27  * $Id: alternative_character_sets.h,v 1.10 2005-02-26 13:08:32 freddy77 Exp $
28  */
29 
30 /*
31  * This list is sorted alphabetically, except that the most
32  * commonly used character sets are first.
33  */
34  /* ASCII */
35  { "US-ASCII", "US-ASCII" }
36  , { "US-ASCII", "ANSI_X3.4-1968" }
37  , { "US-ASCII", "ANSI_X3.4-1986" }
38  , { "US-ASCII", "ASCII" }
39  , { "US-ASCII", "CP367" }
40  , { "US-ASCII", "CSASCII" }
41  , { "US-ASCII", "IBM367" }
42  , { "US-ASCII", "ISO-IR-6" }
43  , { "US-ASCII", "ISO646-US" }
44  , { "US-ASCII", "ISO_646.IRV:1991" }
45  , { "US-ASCII", "US" }
46  , { "US-ASCII", "646" } /* NetBSD default */
47  /* ISO_8859-1 */
48  , { "ISO-8859-1", "ISO-8859-1" }
49  , { "ISO-8859-1", "CP819" }
50  , { "ISO-8859-1", "CSISOLATIN1" }
51  , { "ISO-8859-1", "IBM819" }
52  , { "ISO-8859-1", "ISO-IR-100" }
53  , { "ISO-8859-1", "ISO8859-1" }
54  , { "ISO-8859-1", "ISO_8859-1" }
55  , { "ISO-8859-1", "ISO_8859-1:1987" }
56  , { "ISO-8859-1", "L1" }
57  , { "ISO-8859-1", "LATIN1" }
58  , { "ISO-8859-1", "iso81" }
59  , { "ISO-8859-1", "iso88591" }
60  /* UCS-2 */
61  , { "UCS-2", "UCS-2" }
62  , { "UCS-2", "CSUNICODE" }
63  , { "UCS-2", "ISO-10646-UCS-2" }
64  , { "UCS-2", "UCS2" }
65  , { "UCS-2", "ucs2" }
66  , { "UCS-2-INTERNAL", "UCS-2-INTERNAL" }
67  , { "UCS-2-SWAPPED", "UCS-2-SWAPPED" }
68  , { "UCS-2BE", "UCS-2BE" }
69  , { "UCS-2BE", "CSUNICODE11" }
70  , { "UCS-2BE", "UNICODE-1-1" }
71  , { "UCS-2BE", "UNICODEBIG" }
72  , { "UCS-2LE", "UCS-2LE" }
73  , { "UCS-2LE", "UNICODELITTLE" }
74  /* UTF-8 */
75  , { "UTF-8", "UTF-8" }
76  , { "UTF-8", "UTF8" }
77  , { "UTF-8", "utf8" }
78 
79  /* Basically alphabetical from here */
80  , { "ARMSCII-8", "ARMSCII-8" }
81  , { "BIG-5", "BIG-5" }
82  , { "BIG-5", "BIG-FIVE" }
83  , { "BIG-5", "BIG5" }
84  , { "BIG-5", "BIGFIVE" }
85  , { "BIG-5", "CN-BIG5" }
86  , { "BIG-5", "CSBIG5" }
87  , { "BIG-5", "big5" }
88  , { "BIG5-HKSCS", "BIG5-HKSCS" }
89  , { "BIG5-HKSCS", "BIG5HKSCS" }
90  , { "C99", "C99" }
91  , { "CHINESE", "CHINESE" }
92  , { "CHINESE", "CSISO58GB231280" }
93  , { "CHINESE", "GB_2312-80" }
94  , { "CHINESE", "ISO-IR-58" }
95  , { "CHINESE", "hp15CN" }
96  , { "CN", "CN" }
97  , { "CN", "CSISO57GB1988" }
98  , { "CN", "GB_1988-80" }
99  , { "CN", "ISO-IR-57" }
100  , { "CN", "ISO646-CN" }
101  , { "CN-GB", "CN-GB" }
102  , { "CN-GB", "CSGB2312" }
103  , { "CN-GB", "EUC-CN" }
104  , { "CN-GB", "EUCCN" }
105  , { "CN-GB", "GB2312" }
106  , { "CN-GB-ISOIR165", "CN-GB-ISOIR165" }
107  , { "CN-GB-ISOIR165", "ISO-IR-165" }
108  , { "CP1133", "CP1133" }
109  , { "CP1133", "IBM-CP1133" }
110  , { "CP1250", "CP1250" }
111  , { "CP1250", "MS-EE" }
112  , { "CP1250", "WINDOWS-1250" }
113  , { "CP1250", "cp1250" }
114  , { "CP1251", "CP1251" }
115  , { "CP1251", "MS-CYRL" }
116  , { "CP1251", "WINDOWS-1251" }
117  , { "CP1251", "cp1251" }
118  , { "CP1252", "CP1252" }
119  , { "CP1252", "MS-ANSI" }
120  , { "CP1252", "WINDOWS-1252" }
121  , { "CP1252", "cp1252" }
122  , { "CP1253", "CP1253" }
123  , { "CP1253", "MS-GREEK" }
124  , { "CP1253", "WINDOWS-1253" }
125  , { "CP1253", "cp1253" }
126  , { "CP1254", "CP1254" }
127  , { "CP1254", "MS-TURK" }
128  , { "CP1254", "WINDOWS-1254" }
129  , { "CP1254", "cp1254" }
130  , { "CP1255", "CP1255" }
131  , { "CP1255", "MS-HEBR" }
132  , { "CP1255", "WINDOWS-1255" }
133  , { "CP1255", "cp1255" }
134  , { "CP1256", "CP1256" }
135  , { "CP1256", "MS-ARAB" }
136  , { "CP1256", "WINDOWS-1256" }
137  , { "CP1256", "cp1256" }
138  , { "CP1257", "CP1257" }
139  , { "CP1257", "WINBALTRIM" }
140  , { "CP1257", "WINDOWS-1257" }
141  , { "CP1257", "cp1257" }
142  , { "CP1258", "CP1258" }
143  , { "CP1258", "WINDOWS-1258" }
144  , { "CP1258", "cp1258" }
145  , { "CP1361", "CP1361" }
146  , { "CP1361", "JOHAB" }
147  , { "CP850", "CP850" }
148  , { "CP850", "850" }
149  , { "CP850", "CSPC850MULTILINGUAL" }
150  , { "CP850", "IBM850" }
151  , { "CP850", "cp850" }
152  , { "CP862", "CP862" }
153  , { "CP862", "862" }
154  , { "CP862", "CSPC862LATINHEBREW" }
155  , { "CP862", "IBM862" }
156  , { "CP862", "cp862" }
157  , { "CP866", "CP866" }
158  , { "CP866", "866" }
159  , { "CP866", "CSIBM866" }
160  , { "CP866", "IBM866" }
161  , { "CP866", "cp866" }
162  , { "CP874", "CP874" }
163  , { "CP874", "WINDOWS-874" }
164  , { "CP874", "cp874" }
165  , { "CP932", "CP932" }
166  , { "CP936", "CP936" }
167  , { "CP936", "GBK" }
168  , { "CP949", "CP949" }
169  , { "CP949", "UHC" }
170  , { "CP950", "CP950" }
171  , { "CP437", "CP437" }
172  , { "CP437", "cp437" }
173  , { "CP437", "IBM437" }
174  , { "EUC-JP", "EUC-JP" }
175  , { "EUC-JP", "CSEUCPKDFMTJAPANESE" }
176  , { "EUC-JP", "EUCJP" }
177  , { "EUC-JP", "EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE"}
178  , { "EUC-JP", "eucJP" }
179  , { "EUC-KR", "EUC-KR" }
180  , { "EUC-KR", "CSEUCKR" }
181  , { "EUC-KR", "EUCKR" }
182  , { "EUC-KR", "eucKR" }
183  , { "EUC-TW", "CSEUCTW" }
184  , { "EUC-TW", "EUC-TW" }
185  , { "EUC-TW", "EUCTW" }
186  , { "EUC-TW", "eucTW" }
187  , { "GB18030", "GB18030" }
188  , { "GEORGIAN-ACADEMY", "GEORGIAN-ACADEMY" }
189  , { "GEORGIAN-PS", "GEORGIAN-PS" }
190  , { "HZ", "HZ" }
191  , { "HZ", "HZ-GB-2312" }
192  , { "ISO-2022-CN", "ISO-2022-CN" }
193  , { "ISO-2022-CN", "CSISO2022CN" }
194  , { "ISO-2022-CN-EXT", "ISO-2022-CN-EXT" }
195  , { "ISO-2022-JP", "ISO-2022-JP" }
196  , { "ISO-2022-JP", "CSISO2022JP" }
197  , { "ISO-2022-JP-1", "ISO-2022-JP-1" }
198  , { "ISO-2022-JP-2", "ISO-2022-JP-2" }
199  , { "ISO-2022-JP-2", "CSISO2022JP2" }
200  , { "ISO-2022-KR", "ISO-2022-KR" }
201  , { "ISO-2022-KR", "CSISO2022KR" }
202  , { "ISO-8859-10", "ISO-8859-10" }
203  , { "ISO-8859-10", "CSISOLATIN6" }
204  , { "ISO-8859-10", "ISO-IR-157" }
205  , { "ISO-8859-10", "ISO8859-10" }
206  , { "ISO-8859-10", "ISO_8859-10" }
207  , { "ISO-8859-10", "ISO_8859-10:1992" }
208  , { "ISO-8859-10", "L6" }
209  , { "ISO-8859-10", "LATIN6" }
210  , { "ISO-8859-13", "ISO-8859-13" }
211  , { "ISO-8859-13", "ISO-IR-179" }
212  , { "ISO-8859-13", "ISO_8859-13" }
213  , { "ISO-8859-13", "L7" }
214  , { "ISO-8859-13", "LATIN7" }
215  , { "ISO-8859-14", "ISO-8859-14" }
216  , { "ISO-8859-14", "ISO-CELTIC" }
217  , { "ISO-8859-14", "ISO-IR-199" }
218  , { "ISO-8859-14", "ISO_8859-14" }
219  , { "ISO-8859-14", "ISO_8859-14:1998" }
220  , { "ISO-8859-14", "L8" }
221  , { "ISO-8859-14", "LATIN8" }
222  , { "ISO-8859-15", "ISO8859-15" }
223  , { "ISO-8859-15", "ISO-8859-15" }
224  , { "ISO-8859-15", "ISO-IR-203" }
225  , { "ISO-8859-15", "ISO_8859-15" }
226  , { "ISO-8859-15", "ISO_8859-15:1998" }
227  , { "ISO-8859-15", "iso815" }
228  , { "ISO-8859-15", "iso885915" }
229  , { "ISO-8859-16", "ISO-8859-16" }
230  , { "ISO-8859-16", "ISO-IR-226" }
231  , { "ISO-8859-16", "ISO_8859-16" }
232  , { "ISO-8859-16", "ISO_8859-16:2000" }
233  , { "ISO-8859-2", "ISO-8859-2" }
234  , { "ISO-8859-2", "CSISOLATIN2" }
235  , { "ISO-8859-2", "ISO8859-2" }
236  , { "ISO-8859-2", "ISO-IR-101" }
237  , { "ISO-8859-2", "ISO_8859-2" }
238  , { "ISO-8859-2", "ISO_8859-2:1987" }
239  , { "ISO-8859-2", "L2" }
240  , { "ISO-8859-2", "LATIN2" }
241  , { "ISO-8859-2", "iso82" }
242  , { "ISO-8859-2", "iso88592" }
243  , { "ISO-8859-3", "ISO-8859-3" }
244  , { "ISO-8859-3", "CSISOLATIN3" }
245  , { "ISO-8859-3", "ISO-IR-109" }
246  , { "ISO-8859-3", "ISO_8859-3" }
247  , { "ISO-8859-3", "ISO_8859-3:1988" }
248  , { "ISO-8859-3", "L3" }
249  , { "ISO-8859-3", "LATIN3" }
250  , { "ISO-8859-3", "iso83" }
251  , { "ISO-8859-3", "iso88593" }
252  , { "ISO-8859-4", "ISO8859-4" }
253  , { "ISO-8859-4", "CSISOLATIN4" }
254  , { "ISO-8859-4", "ISO-8859-4" }
255  , { "ISO-8859-4", "ISO-IR-110" }
256  , { "ISO-8859-4", "ISO_8859-4" }
257  , { "ISO-8859-4", "ISO_8859-4:1988" }
258  , { "ISO-8859-4", "L4" }
259  , { "ISO-8859-4", "LATIN4" }
260  , { "ISO-8859-4", "iso84" }
261  , { "ISO-8859-4", "iso88594" }
262  , { "ISO-8859-5", "ISO-8859-5" }
263  , { "ISO-8859-5", "CSISOLATINCYRILLIC" }
264  , { "ISO-8859-5", "CYRILLIC" }
265  , { "ISO-8859-5", "ISO8859-5" }
266  , { "ISO-8859-5", "ISO-IR-144" }
267  , { "ISO-8859-5", "ISO8859-5" }
268  , { "ISO-8859-5", "ISO_8859-5" }
269  , { "ISO-8859-5", "ISO_8859-5:1988" }
270  , { "ISO-8859-5", "iso85" }
271  , { "ISO-8859-5", "iso88595" }
272  , { "ISO-8859-6", "ISO-8859-6" }
273  , { "ISO-8859-6", "ARABIC" }
274  , { "ISO-8859-6", "ASMO-708" }
275  , { "ISO-8859-6", "CSISOLATINARABIC" }
276  , { "ISO-8859-6", "ECMA-114" }
277  , { "ISO-8859-6", "ISO-IR-127" }
278  , { "ISO-8859-6", "ISO8859-6" }
279  , { "ISO-8859-6", "ISO_8859-6" }
280  , { "ISO-8859-6", "ISO_8859-6:1987" }
281  , { "ISO-8859-6", "iso86" }
282  , { "ISO-8859-6", "iso88596" }
283  , { "ISO-8859-7", "ISO-8859-7" }
284  , { "ISO-8859-7", "CSISOLATINGREEK" }
285  , { "ISO-8859-7", "ECMA-118" }
286  , { "ISO-8859-7", "ELOT_928" }
287  , { "ISO-8859-7", "GREEK" }
288  , { "ISO-8859-7", "GREEK8" }
289  , { "ISO-8859-7", "ISO-IR-126" }
290  , { "ISO-8859-7", "ISO8859-7" }
291  , { "ISO-8859-7", "ISO_8859-7" }
292  , { "ISO-8859-7", "ISO_8859-7:1987" }
293  , { "ISO-8859-7", "iso87" }
294  , { "ISO-8859-7", "iso88597" }
295  , { "ISO-8859-8", "ISO-8859-8" }
296  , { "ISO-8859-8", "CSISOLATINHEBREW" }
297  , { "ISO-8859-8", "HEBREW" }
298  , { "ISO-8859-8", "ISO8859-8" }
299  , { "ISO-8859-8", "ISO-IR-138" }
300  , { "ISO-8859-8", "ISO_8859-8" }
301  , { "ISO-8859-8", "ISO_8859-8:1988" }
302  , { "ISO-8859-8", "iso88" }
303  , { "ISO-8859-8", "iso88598" }
304  , { "ISO-8859-9", "ISO-8859-9" }
305  , { "ISO-8859-9", "CSISOLATIN5" }
306  , { "ISO-8859-9", "ISO-IR-148" }
307  , { "ISO-8859-9", "ISO8859-9" }
308  , { "ISO-8859-9", "ISO_8859-9" }
309  , { "ISO-8859-9", "ISO_8859-9:1989" }
310  , { "ISO-8859-9", "L5" }
311  , { "ISO-8859-9", "LATIN5" }
312  , { "ISO-8859-9", "iso88599" }
313  , { "ISO-8859-9", "iso89" }
314  , { "ISO-IR-14", "ISO-IR-14" }
315  , { "ISO-IR-14", "CSISO14JISC6220RO" }
316  , { "ISO-IR-14", "ISO646-JP" }
317  , { "ISO-IR-14", "JIS_C6220-1969-RO" }
318  , { "ISO-IR-14", "JP" }
319  , { "ISO-IR-149", "ISO-IR-149" }
320  , { "ISO-IR-149", "CSKSC56011987" }
321  , { "ISO-IR-149", "KOREAN" }
322  , { "ISO-IR-149", "KSC_5601" }
323  , { "ISO-IR-149", "KS_C_5601-1987" }
324  , { "ISO-IR-149", "KS_C_5601-1989" }
325  , { "ISO-IR-159", "ISO-IR-159" }
326  , { "ISO-IR-159", "CSISO159JISX02121990" }
327  , { "ISO-IR-159", "JIS_X0212" }
328  , { "ISO-IR-159", "JIS_X0212-1990" }
329  , { "ISO-IR-159", "JIS_X0212.1990-0" }
330  , { "ISO-IR-159", "X0212" }
331  , { "ISO-IR-166", "ISO-IR-166" }
332  , { "ISO-IR-166", "TIS-620" }
333  , { "ISO-IR-166", "TIS620" }
334  , { "ISO-IR-166", "TIS620-0" }
335  , { "ISO-IR-166", "TIS620.2529-1" }
336  , { "ISO-IR-166", "TIS620.2533-0" }
337  , { "ISO-IR-166", "TIS620.2533-1" }
338  , { "ISO-IR-166", "thai8" }
339  , { "ISO-IR-166", "tis620" }
340  , { "ISO-IR-87", "ISO-IR-87" }
341  , { "ISO-IR-87", "CSISO87JISX0208" }
342  , { "ISO-IR-87", "JIS0208" }
343  , { "ISO-IR-87", "JIS_C6226-1983" }
344  , { "ISO-IR-87", "JIS_X0208" }
345  , { "ISO-IR-87", "JIS_X0208-1983" }
346  , { "ISO-IR-87", "JIS_X0208-1990" }
347  , { "ISO-IR-87", "X0208" }
348  , { "JAVA", "JAVA" }
349  , { "JISX0201-1976", "JISX0201-1976" }
350  , { "JISX0201-1976", "CSHALFWIDTHKATAKANA" }
351  , { "JISX0201-1976", "JIS_X0201" }
352  , { "JISX0201-1976", "X0201" }
353  , { "KOI8-R", "KOI8-R" }
354  , { "KOI8-R", "CSKOI8R" }
355  , { "KOI8-RU", "KOI8-RU" }
356  , { "KOI8-T", "KOI8-T" }
357  , { "KOI8-U", "KOI8-U" }
358  , { "MAC", "MAC" }
359  , { "MAC", "CSMACINTOSH" }
360  , { "MAC", "MACINTOSH" }
361  , { "MAC", "MACROMAN" }
362  , { "MACARABIC", "MACARABIC" }
363  , { "MACCENTRALEUROPE", "MACCENTRALEUROPE" }
364  , { "MACCROATIAN", "MACCROATIAN" }
365  , { "MACCYRILLIC", "MACCYRILLIC" }
366  , { "MACGREEK", "MACGREEK" }
367  , { "MACHEBREW", "MACHEBREW" }
368  , { "MACICELAND", "MACICELAND" }
369  , { "MACROMANIA", "MACROMANIA" }
370  , { "MACTHAI", "MACTHAI" }
371  , { "MACTURKISH", "MACTURKISH" }
372  , { "MACUKRAINE", "MACUKRAINE" }
373  , { "MULELAO-1", "MULELAO-1" }
374  , { "NEXTSTEP", "NEXTSTEP" }
375  , { "ROMAN8", "ROMAN8" }
376  , { "ROMAN8", "CSHPROMAN8" }
377  , { "ROMAN8", "HP-ROMAN8" }
378  , { "ROMAN8", "R8" }
379  , { "ROMAN8", "roma8" }
380  , { "ROMAN8", "roman8" }
381  , { "SJIS", "SJIS" }
382  , { "SJIS", "CSSHIFTJIS" }
383  , { "SJIS", "MS_KANJI" }
384  , { "SJIS", "SHIFT-JIS" }
385  , { "SJIS", "SHIFT_JIS" }
386  , { "SJIS", "sjis" }
387  , { "TCVN", "TCVN" }
388  , { "TCVN", "TCVN-5712" }
389  , { "TCVN", "TCVN5712-1" }
390  , { "TCVN", "TCVN5712-1:1993" }
391  , { "UCS-4", "UCS-4" }
392  , { "UCS-4", "CSUCS4" }
393  , { "UCS-4", "ISO-10646-UCS-4" }
394  , { "UCS-4", "UCS4" }
395  , { "UCS-4", "ucs4" }
396  , { "UCS-4-INTERNAL", "UCS-4-INTERNAL" }
397  , { "UCS-4-SWAPPED", "UCS-4-SWAPPED" }
398  , { "UCS-4BE", "UCS-4BE" }
399  , { "UCS-4LE", "UCS-4LE" }
400  , { "UTF-16", "UTF-16" }
401  , { "UTF-16", "UTF16" }
402  , { "UTF-16BE", "UTF-16BE" }
403  , { "UTF-16LE", "UTF-16LE" }
404  , { "UTF-32", "UTF-32" }
405  , { "UTF-32BE", "UTF-32BE" }
406  , { "UTF-32LE", "UTF-32LE" }
407  , { "UTF-7", "UTF-7" }
408  , { "UTF-7", "CSUNICODE11UTF7" }
409  , { "UTF-7", "UNICODE-1-1-UTF-7" }
410  , { "UTF-7", "UTF7" }
411  , { "VISCII", "VISCII" }
412  , { "VISCII", "CSVISCII" }
413  , { "VISCII", "VISCII1.1-1" }
414 
415  /*
416  * The following are noted in Tru64 manuals, but
417  * have no canonical names in FreeTDS
418  *
419  * TACTIS TACTIS codeset
420  * dechanyu DEC Hanyu codeset
421  * dechanzi DEC Hanzi codeset
422  * deckanji DEC Kanji codeset
423  * deckorean DEC Korean codeset
424  * sdeckanji Super DEC Kanji codeset
425  */
426 
427  /* no stopper row; add your own */
428 #endif
freetds-1.00.82/doc/reference/a00248.html100644 025423 025423 00000140135 13242511136 0013237 FreeTDS API: src/tds/bulk.c File Reference
FreeTDS API
bulk.c File Reference

Handle bulk copy. More...

#include <config.h>
#include <assert.h>
#include <freetds/tds.h>
#include <freetds/checks.h>
#include <freetds/bytes.h>
#include <freetds/iconv.h>
#include <freetds/stream.h>
#include <freetds/string.h>
#include "replacements.h"
Include dependency graph for bulk.c:

Classes

struct  tds_file_stream
 input stream to read a file More...
 
struct  tds_pbcb
 Holds clause buffer. More...
 

Typedefs

typedef struct tds_file_stream TDSFILESTREAM
 input stream to read a file
 
typedef struct tds_pbcb TDSPBCB
 Holds clause buffer.
 

Functions

static TDSRET tds7_bcp_send_colmetadata (TDSSOCKET *tds, TDSBCPINFO *bcpinfo)
 Send BCP metadata to server. More...
 
static TDSRET tds7_build_bulk_insert_stmt (TDSSOCKET *tds, TDSPBCB *clause, TDSCOLUMN *bcpcol, int first)
 Help to build query to be sent to server. More...
 
static int tds_bcp_add_fixed_columns (TDSBCPINFO *bcpinfo, tds_bcp_get_col_data get_col_data, tds_bcp_null_error ignored, int offset, unsigned char *rowbuffer, int start)
 Add fixed size columns to the row. More...
 
static int tds_bcp_add_variable_columns (TDSBCPINFO *bcpinfo, tds_bcp_get_col_data get_col_data, tds_bcp_null_error null_error, int offset, TDS_UCHAR *rowbuffer, int start, int *pncols)
 Add variable size columns to the row. More...
 
TDSRET tds_bcp_done (TDSSOCKET *tds, int *rows_copied)
 Tell we finished sending BCP data to server. More...
 
TDSRET tds_bcp_fread (TDSSOCKET *tds, TDSICONV *char_conv, FILE *stream, const char *terminator, size_t term_len, char **outbuf, size_t *outbytes)
 Read a data file, passing the data through iconv(). More...
 
TDSRET tds_bcp_init (TDSSOCKET *tds, TDSBCPINFO *bcpinfo)
 Initialize BCP information. More...
 
static void tds_bcp_row_free (TDSRESULTINFO *result, unsigned char *row)
 Free row data allocated in the result set.
 
TDSRET tds_bcp_send_record (TDSSOCKET *tds, TDSBCPINFO *bcpinfo, tds_bcp_get_col_data get_col_data, tds_bcp_null_error ignored, int offset)
 Send one row of data to server. More...
 
TDSRET tds_bcp_start (TDSSOCKET *tds, TDSBCPINFO *bcpinfo)
 Start sending BCP data to server. More...
 
TDSRET tds_bcp_start_copy_in (TDSSOCKET *tds, TDSBCPINFO *bcpinfo)
 Start bulk copy to server. More...
 
static TDSRET tds_bcp_start_insert_stmt (TDSSOCKET *tds, TDSBCPINFO *bcpinfo)
 Prepare the query to be sent to server to request BCP information. More...
 
static int tds_file_stream_read (TDSINSTREAM *stream, void *ptr, size_t len)
 Reads a chunk of data from file stream checking for terminator. More...
 
TDSRET tds_writetext_continue (TDSSOCKET *tds, const TDS_UCHAR *text, TDS_UINT size)
 Send some data in the writetext request started by tds_writetext_start. More...
 
TDSRET tds_writetext_end (TDSSOCKET *tds)
 Finish sending writetext data. More...
 
TDSRET tds_writetext_start (TDSSOCKET *tds, const char *objname, const char *textptr, const char *timestamp, int with_log, TDS_UINT size)
 Start writing writetext request. More...
 

Detailed Description

Handle bulk copy.

Function Documentation

§ tds7_bcp_send_colmetadata()

static TDSRET tds7_bcp_send_colmetadata ( TDSSOCKET tds,
TDSBCPINFO bcpinfo 
)
static

Send BCP metadata to server.

Only for TDS 7.0+.

Parameters
tdsA pointer to the TDSSOCKET structure managing a client/server operation.
bcpinfoBCP information
Returns
TDS_SUCCESS or TDS_FAIL.
Here is the call graph for this function:

§ tds7_build_bulk_insert_stmt()

static TDSRET tds7_build_bulk_insert_stmt ( TDSSOCKET tds,
TDSPBCB clause,
TDSCOLUMN bcpcol,
int  first 
)
static

Help to build query to be sent to server.

Append column declaration to the query. Only for TDS 7.0+.

Parameters
tdsA pointer to the TDSSOCKET structure managing a client/server operation.
[out]clauseoutput string
bcpcolcolumn to append
firsttrue if column is the first
Returns
TDS_SUCCESS or TDS_FAIL.
Here is the call graph for this function:

§ tds_bcp_add_fixed_columns()

static int tds_bcp_add_fixed_columns ( TDSBCPINFO bcpinfo,
tds_bcp_get_col_data  get_col_data,
tds_bcp_null_error  ignored,
int  offset,
unsigned char *  rowbuffer,
int  start 
)
static

Add fixed size columns to the row.

Parameters
bcpinfoBCP information
get_col_datafunction to call to retrieve data to be sent
ignoredfunction to call if we try to send NULL if not allowed (not used)
offsetpassed to get_col_data and null_error to specify the row to get
rowbufferrow buffer to write to
startrow buffer last end position
Returns
new row length or -1 on error.

§ tds_bcp_add_variable_columns()

static int tds_bcp_add_variable_columns ( TDSBCPINFO bcpinfo,
tds_bcp_get_col_data  get_col_data,
tds_bcp_null_error  null_error,
int  offset,
TDS_UCHAR *  rowbuffer,
int  start,
int *  pncols 
)
static

Add variable size columns to the row.

Parameters
bcpinfoBCP information already prepared
get_col_datafunction to call to retrieve data to be sent
null_errorfunction to call if we try to send NULL if not allowed
offsetpassed to get_col_data and null_error to specify the row to get
rowbufferThe row image that will be sent to the server.
startWhere to begin copying data into the rowbuffer.
pncolsAddress of output variable holding the count of columns added to the rowbuffer.
Returns
length of (potentially modified) rowbuffer, or -1.

§ tds_bcp_done()

TDSRET tds_bcp_done ( TDSSOCKET tds,
int *  rows_copied 
)

Tell we finished sending BCP data to server.

Parameters
tdsA pointer to the TDSSOCKET structure managing a client/server operation.
[out]rows_copiednumber of rows copied to server
Here is the call graph for this function:

§ tds_bcp_fread()

TDSRET tds_bcp_fread ( TDSSOCKET tds,
TDSICONV char_conv,
FILE *  stream,
const char *  terminator,
size_t  term_len,
char **  outbuf,
size_t *  outbytes 
)

Read a data file, passing the data through iconv().

Return values
TDS_SUCCESSsuccess
TDS_FAILerror reading the column
TDS_NO_MORE_RESULTSend of file detected
Here is the call graph for this function:

§ tds_bcp_init()

TDSRET tds_bcp_init ( TDSSOCKET tds,
TDSBCPINFO bcpinfo 
)

Initialize BCP information.

Query structure of the table to server.

Parameters
tdsA pointer to the TDSSOCKET structure managing a client/server operation.
bcpinfoBCP information to initialize. Structure should be allocate and table name and direction should be already set.

§ tds_bcp_send_record()

TDSRET tds_bcp_send_record ( TDSSOCKET tds,
TDSBCPINFO bcpinfo,
tds_bcp_get_col_data  get_col_data,
tds_bcp_null_error  ignored,
int  offset 
)

Send one row of data to server.

Parameters
tdsA pointer to the TDSSOCKET structure managing a client/server operation.
bcpinfoBCP information
get_col_datafunction to call to retrieve data to be sent
ignoredfunction to call if we try to send NULL if not allowed (not used)
offsetpassed to get_col_data and null_error to specify the row to get
Returns
TDS_SUCCESS or TDS_FAIL.

§ tds_bcp_start()

TDSRET tds_bcp_start ( TDSSOCKET tds,
TDSBCPINFO bcpinfo 
)

Start sending BCP data to server.

Initialize stream to accept data.

Parameters
tdsA pointer to the TDSSOCKET structure managing a client/server operation.
bcpinfoBCP information already prepared
Here is the call graph for this function:

§ tds_bcp_start_copy_in()

TDSRET tds_bcp_start_copy_in ( TDSSOCKET tds,
TDSBCPINFO bcpinfo 
)

Start bulk copy to server.

Parameters
tdsA pointer to the TDSSOCKET structure managing a client/server operation.
bcpinfoBCP information already prepared
Here is the call graph for this function:

§ tds_bcp_start_insert_stmt()

static TDSRET tds_bcp_start_insert_stmt ( TDSSOCKET tds,
TDSBCPINFO bcpinfo 
)
static

Prepare the query to be sent to server to request BCP information.

Parameters
tdsA pointer to the TDSSOCKET structure managing a client/server operation.
bcpinfoBCP information

§ tds_file_stream_read()

static int tds_file_stream_read ( TDSINSTREAM stream,
void *  ptr,
size_t  len 
)
static

Reads a chunk of data from file stream checking for terminator.

Parameters
streamfile stream
ptrbuffer where to read data
lenlength of buffer
Here is the caller graph for this function:

§ tds_writetext_continue()

TDSRET tds_writetext_continue ( TDSSOCKET tds,
const TDS_UCHAR *  text,
TDS_UINT  size 
)

Send some data in the writetext request started by tds_writetext_start.

You should write in total (with multiple calls to this function) all bytes declared calling tds_writetext_start.

Parameters
tdsA pointer to the TDSSOCKET structure managing a client/server operation.
textdata to write
sizedata size in bytes
Here is the call graph for this function:

§ tds_writetext_end()

TDSRET tds_writetext_end ( TDSSOCKET tds)

Finish sending writetext data.

Parameters
tdsA pointer to the TDSSOCKET structure managing a client/server operation.
Here is the call graph for this function:

§ tds_writetext_start()

TDSRET tds_writetext_start ( TDSSOCKET tds,
const char *  objname,
const char *  textptr,
const char *  timestamp,
int  with_log,
TDS_UINT  size 
)

Start writing writetext request.

This request start a bulk session.

Parameters
tdsA pointer to the TDSSOCKET structure managing a client/server operation.
objnametable name
textptrTEXTPTR (see sql documentation)
timestampdata timestamp
with_logis log is enabled during insert
sizebytes to be inserted
Here is the call graph for this function:
freetds-1.00.82/doc/reference/a00248_a1b83c9db016b481aa1fa0352f976d50d_icgraph.map100644 025423 025423 00000000363 13242511134 0021324 freetds-1.00.82/doc/reference/a00248_a1b83c9db016b481aa1fa0352f976d50d_icgraph.md5100644 025423 025423 00000000040 13242511133 00212238eafaaa637af8a5a7cf87b0623cd0c35freetds-1.00.82/doc/reference/a00249.map100644 025423 025423 00000004401 13242511134 0013042 freetds-1.00.82/doc/reference/a00249.md5100644 025423 025423 00000000040 13242511133 0012744aa304c9f5e179cd85f2a9084a4911ba3freetds-1.00.82/doc/reference/a00248_a1b83c9db016b481aa1fa0352f976d50d_icgraph.svg100644 025423 025423 00000003207 13242511136 0021350 tds_file_stream_read Node29 tds_file_stream_read Node30 tds_bcp_fread Node29->Node30 freetds-1.00.82/doc/reference/a00248_a3118c7232bc9c3e47f8ba872bb39e967_cgraph.map100644 025423 025423 00000000357 13242511134 0021132 freetds-1.00.82/doc/reference/a00248_a3118c7232bc9c3e47f8ba872bb39e967_cgraph.md5100644 025423 025423 00000000040 13242511133 002102669a40c67558ef29d54de7d2912333377freetds-1.00.82/doc/reference/a00248_a3118c7232bc9c3e47f8ba872bb39e967_cgraph.svg100644 025423 025423 00000003203 13242511136 0021147 tds7_build_bulk_insert_stmt Node3 tds7_build_bulk_insert_stmt Node4 tdsdump_log Node3->Node4 freetds-1.00.82/doc/reference/a00248_a4daaa551e54dbd978650e2eef89e09ff_cgraph.map100644 025423 025423 00000000353 13242511134 0021432 freetds-1.00.82/doc/reference/a00248_a4daaa551e54dbd978650e2eef89e09ff_cgraph.md5100644 025423 025423 00000000040 13242511133 002133274e87682ba94795356c70e7e46e13bc2freetds-1.00.82/doc/reference/a00248_a4daaa551e54dbd978650e2eef89e09ff_cgraph.svg100644 025423 025423 00000003173 13242511136 0021461 tds7_bcp_send_colmetadata Node0 tds7_bcp_send_colmetadata Node1 tdsdump_log Node0->Node1 freetds-1.00.82/doc/reference/a00248_a5eec23828b0610c58de248c4edb53879_cgraph.map100644 025423 025423 00000000343 13242511134 0021121 freetds-1.00.82/doc/reference/a00249.svg100644 025423 025423 00000061747 13242511136 0013106 src/tds/bulk.c Node0 src/tds/bulk.c Node1 config.h Node0->Node1 Node2 assert.h Node0->Node2 Node3 freetds/tds.h Node0->Node3 Node12 replacements.h Node0->Node12 Node18 freetds/checks.h Node0->Node18 Node19 freetds/bytes.h Node0->Node19 Node20 freetds/iconv.h Node0->Node20 Node21 freetds/stream.h Node0->Node21 Node22 freetds/string.h Node0->Node22 Node4 stdarg.h Node3->Node4 Node5 stdio.h Node3->Node5 Node6 time.h Node3->Node6 Node7 freetds/version.h Node3->Node7 Node8 tds_sysdep_public.h Node3->Node8 Node9 freetds/sysdep_private.h Node3->Node9 Node10 freetds/thread.h Node3->Node10 Node11 freetds/bool.h Node3->Node11 Node3->Node12 Node14 freetds/pushvis.h Node3->Node14 Node15 freetds/popvis.h Node3->Node15 Node17 freetds/proto.h Node3->Node17 Node6->Node6 Node12->Node4 Node12->Node8 Node12->Node9 Node13 replacements/readpassphrase.h Node12->Node13 Node12->Node14 Node12->Node15 Node16 replacements/poll.h Node12->Node16 Node13->Node14 Node13->Node15 Node16->Node1 Node16->Node14 Node16->Node15 Node18->Node14 Node18->Node15 Node20->Node14 Node20->Node15 Node21->Node14 Node21->Node15 Node22->Node14 Node22->Node15 freetds-1.00.82/doc/reference/a00248_a5eec23828b0610c58de248c4edb53879_cgraph.md5100644 025423 025423 00000000040 13242511133 0021022a1ab91e8b0f298fb28c766f7cea9982ffreetds-1.00.82/doc/reference/a00248_a5eec23828b0610c58de248c4edb53879_cgraph.svg100644 025423 025423 00000003173 13242511136 0021151 tds_bcp_start_copy_in Node23 tds_bcp_start_copy_in Node24 tdsdump_log Node23->Node24 freetds-1.00.82/doc/reference/a00248_a7711612cc544a7da2c7aa212b870acb2_cgraph.map100644 025423 025423 00000000331 13242511134 0021130 freetds-1.00.82/doc/reference/a00248_a7711612cc544a7da2c7aa212b870acb2_cgraph.md5100644 025423 025423 00000000040 13242511133 00210343bde1f3243088082a1baf2343e1f282dfreetds-1.00.82/doc/reference/a00248_a7711612cc544a7da2c7aa212b870acb2_cgraph.svg100644 025423 025423 00000003163 13242511136 0021162 tds_writetext_start Node37 tds_writetext_start Node38 tds_submit_queryf Node37->Node38 freetds-1.00.82/doc/reference/a00248_a8208eef2a3974ae1f0cf3c8c8ab011ce_cgraph.map100644 025423 025423 00000000323 13242511134 0021374 freetds-1.00.82/doc/reference/a00248_a8208eef2a3974ae1f0cf3c8c8ab011ce_cgraph.md5100644 025423 025423 00000000040 13242511133 00212770b84e0c65590b50722bacb4a3f74704efreetds-1.00.82/doc/reference/a00248_a8208eef2a3974ae1f0cf3c8c8ab011ce_cgraph.svg100644 025423 025423 00000003136 13242511136 0021425 tds_bcp_start Node20 tds_bcp_start Node21 tdsdump_log Node20->Node21 freetds-1.00.82/doc/reference/a00254_source.html100644 025423 025423 00000054654 13242511132 0014622 FreeTDS API: src/tds/character_sets.h Source File
FreeTDS API
character_sets.h
1 /*
2  * These are the canonical names for character sets accepted by GNU iconv.
3  * See its documentation for the standard it follows.
4  *
5  * GNU iconv accepts other character set names, too, and your favorite operating system
6  * very likely uses still other names to represent the _same_ character set.
7  *
8  * Alternative character set names are mapped to these canonical ones in
9  * alternative_character_sets.h and are accessed with canonical_charset();
10  */
11  {"ISO-8859-1", 1, 1}
12  , {"UTF-8", 1, 4}
13  , {"UCS-2LE", 2, 2}
14  , {"UCS-2BE", 2, 2}
15  , {"UCS-2", 2, 2}
16  , {"US-ASCII", 1, 1}
17  , {"UCS-4", 4, 4}
18  , {"UCS-4BE", 4, 4}
19  , {"UCS-4LE", 4, 4}
20  , {"UTF-16", 2, 4}
21  , {"UTF-16BE", 2, 4}
22  , {"UTF-16LE", 2, 4}
23  , {"UTF-32", 4, 4}
24  , {"UTF-32BE", 4, 4}
25  , {"UTF-32LE", 4, 4}
26  , {"UTF-7", 1, 4}
27  , {"UCS-2-INTERNAL", 2, 2}
28  , {"UCS-2-SWAPPED", 2, 2}
29  , {"UCS-4-INTERNAL", 4, 4}
30  , {"UCS-4-SWAPPED", 4, 4}
31  , {"C99", 1, 1}
32  , {"JAVA", 1, 1}
33  , {"ISO-8859-2", 1, 1}
34  , {"ISO-8859-3", 1, 1}
35  , {"ISO-8859-4", 1, 1}
36  , {"ISO-8859-5", 1, 1}
37  , {"ISO-8859-6", 1, 1}
38  , {"ISO-8859-7", 1, 1}
39  , {"ISO-8859-8", 1, 1}
40  , {"ISO-8859-9", 1, 1}
41  , {"ISO-8859-10", 1, 1}
42  , {"ISO-8859-13", 1, 1}
43  , {"ISO-8859-14", 1, 1}
44  , {"ISO-8859-15", 1, 1}
45  , {"ISO-8859-16", 1, 1}
46  , {"KOI8-R", 1, 1}
47  , {"KOI8-U", 1, 1}
48  , {"KOI8-RU", 1, 1}
49  , {"CP1250", 1, 1}
50  , {"CP1251", 1, 1}
51  , {"CP1252", 1, 1}
52  , {"CP1253", 1, 1}
53  , {"CP1254", 1, 1}
54  , {"CP1255", 1, 1}
55  , {"CP1256", 1, 1}
56  , {"CP1257", 1, 1}
57  , {"CP1258", 1, 1}
58  , {"CP850", 1, 1}
59  , {"CP862", 1, 1}
60  , {"CP866", 1, 1}
61  , {"CP437", 1, 1}
62  , {"MAC", 1, 1}
63  , {"MACCENTRALEUROPE", 1, 1}
64  , {"MACICELAND", 1, 1}
65  , {"MACCROATIAN", 1, 1}
66  , {"MACROMANIA", 1, 1}
67  , {"MACCYRILLIC", 1, 1}
68  , {"MACUKRAINE", 1, 1}
69  , {"MACGREEK", 1, 1}
70  , {"MACTURKISH", 1, 1}
71  , {"MACHEBREW", 1, 1}
72  , {"MACARABIC", 1, 1}
73  , {"MACTHAI", 1, 1}
74  , {"ROMAN8", 1, 1}
75  , {"NEXTSTEP", 1, 1}
76  , {"ARMSCII-8", 1, 1}
77  , {"GEORGIAN-ACADEMY", 1, 1}
78  , {"GEORGIAN-PS", 1, 1}
79  , {"KOI8-T", 1, 1}
80  , {"MULELAO-1", 1, 1}
81  , {"CP1133", 1, 1}
82  , {"ISO-IR-166", 1, 1}
83  , {"CP874", 1, 1}
84  , {"CP936", 1, 2}
85  , {"CN", 1, 1}
86  , {"CP932", 1, 2}
87  , {"CN-GB", 1, 2}
88  , {"CP950", 1, 2}
89  , {"CP949", 1, 2}
90  , {"CP1361", 1, 2}
91  , {"BIG-5", 1, 2}
92  , {"BIG5-HKSCS", 1, 2}
93  , {"SJIS", 1, 2}
94  , {"EUC-KR", 1, 2}
95  , {"VISCII", 1, 1}
96  , {"ISO-IR-14", 1, 1}
97  , {"EUC-JP", 1, 3}
98  , {"EUC-TW", 1, 4}
99  , {"ISO-2022-JP", 1, 1}
100  , {"ISO-2022-KR", 1, 2}
101  , {"ISO-2022-CN", 1, 4}
102  , {"ISO-2022-CN-EXT", 1, 4}
103  , {"ISO-2022-JP-2", 1, 1}
104  , {"GB18030", 1, 4}
105  /*
106  * Beyond this point, I don't know the right answers.
107  * If you can provide the correct min/max (byte/char) values, please
108  * correct them if necessary and move them above the stopper row.
109  * Will the person vetting the last unknown row please turn off the lights?
110  * --jkl April 2003
111  */
112  , {"", 0, 0} /* stopper row */
113 
114  , {"TCVN", 1, 1}
115  , {"JISX0201-1976", 1, 1}
116  , {"ISO-IR-87", 1, 1}
117  , {"ISO-IR-159", 1, 1}
118  , {"CHINESE", 1, 1}
119  , {"CN-GB-ISOIR165", 1, 1}
120  , {"ISO-IR-149", 1, 1}
121  , {"ISO-2022-JP-1", 1, 1}
122  , {"HZ", 1, 1}
123  /* stopper row */
124  , {"", 0, 0}
125 
freetds-1.00.82/doc/reference/a00248_a86ac92bd8a3c61a413d27150ec9bc202_cgraph.map100644 025423 025423 00000000361 13242511134 0021145 freetds-1.00.82/doc/reference/a00248_a86ac92bd8a3c61a413d27150ec9bc202_cgraph.md5100644 025423 025423 00000000040 13242511133 0021046d0f7139f4f013f03ac7837a2b5851c07freetds-1.00.82/doc/reference/a00248_a86ac92bd8a3c61a413d27150ec9bc202_cgraph.svg100644 025423 025423 00000003204 13242511136 0021170 tds_bcp_fread Node13 tds_bcp_fread Node14 tds_file_stream_read Node13->Node14 freetds-1.00.82/doc/reference/a00248_ab68dead99a2ebec55895a10cd3db5202_cgraph.map100644 025423 025423 00000000373 13242511134 0021406 freetds-1.00.82/doc/reference/a00248_ab68dead99a2ebec55895a10cd3db5202_cgraph.md5100644 025423 025423 00000000040 13242511133 0021304ddac41abc40c31e9d4e2327e07282080freetds-1.00.82/doc/reference/a00248_ab68dead99a2ebec55895a10cd3db5202_cgraph.svg100644 025423 025423 00000003222 13242511136 0021426 tds_writetext_continue Node31 tds_writetext_continue Node32 tds_set_state Node31->Node32 freetds-1.00.82/doc/reference/a00248_ac1e460551f1188620ea478238864ac4b_cgraph.map100644 025423 025423 00000000361 13242511134 0020666 freetds-1.00.82/doc/reference/a00248_ac1e460551f1188620ea478238864ac4b_cgraph.md5100644 025423 025423 00000000040 13242511133 0020567e9a5fb63e87f3aef85b2b2fd953dee52freetds-1.00.82/doc/reference/a00260.html100644 025423 025423 00000122500 13242511136 0013225 FreeTDS API: src/tds/data.c File Reference
FreeTDS API
data.c File Reference

Handle different data handling from network. More...

#include <config.h>
#include <stdarg.h>
#include <stdio.h>
#include <assert.h>
#include <freetds/tds.h>
#include <freetds/bytes.h>
#include <freetds/iconv.h>
#include <freetds/checks.h>
#include <freetds/stream.h>
#include <freetds/data.h>
#include <freetds/pushvis.h>
#include <freetds/popvis.h>
#include "tds_types.h"
Include dependency graph for data.c:

Classes

struct  tds_varmax_stream
 

Macros

#define MAX(a, b)   (((a) > (b)) ? (a) : (b))
 
#define MIN(a, b)   (((a) < (b)) ? (a) : (b))
 
#define TDS_DECLARE_FUNCS(name)   extern const TDSCOLUMNFUNCS tds_ ## name ## _funcs
 
#define TDS_DONT_DEFINE_DEFAULT_FUNCTIONS
 
#define USE_ICONV   (tds->conn->use_iconv)
 

Typedefs

typedef struct tds_varmax_stream TDSVARMAXSTREAM
 

Functions

static TDSRET tds72_get_varmax (TDSSOCKET *tds, TDSCOLUMN *curcol)
 
TDSRET tds_clrudt_get_info (TDSSOCKET *tds, TDSCOLUMN *col)
 
TDSRET tds_clrudt_put_info (TDSSOCKET *tds, TDSCOLUMN *col)
 
TDS_INT tds_clrudt_row_len (TDSCOLUMN *col)
 
 TDS_COMPILE_CHECK (variant_size, sizeof(TDSBLOB) >=sizeof(TDSVARIANT))
 
 TDS_COMPILE_CHECK (tds_variant_size, sizeof(((TDSVARIANT *) 0) ->data)==sizeof(((TDSBLOB *) 0) ->textvalue))
 
 TDS_COMPILE_CHECK (tds_variant_offset, TDS_OFFSET(TDSVARIANT, data)==TDS_OFFSET(TDSBLOB, textvalue))
 
 TDS_DECLARE_FUNCS (generic)
 
 TDS_DECLARE_FUNCS (numeric)
 
 TDS_DECLARE_FUNCS (variant)
 
 TDS_DECLARE_FUNCS (msdatetime)
 
 TDS_DECLARE_FUNCS (clrudt)
 
 TDS_DECLARE_FUNCS (sybbigtime)
 
 TDS_DECLARE_FUNCS (invalid)
 
TDSRET tds_generic_get (TDSSOCKET *tds, TDSCOLUMN *curcol)
 Read a data from wire. More...
 
TDSRET tds_generic_get_info (TDSSOCKET *tds, TDSCOLUMN *col)
 
TDSRET tds_generic_put (TDSSOCKET *tds, TDSCOLUMN *curcol, int bcp7)
 Write data to wire. More...
 
TDSRET tds_generic_put_info (TDSSOCKET *tds, TDSCOLUMN *col)
 Put data information to wire. More...
 
unsigned tds_generic_put_info_len (TDSSOCKET *tds, TDSCOLUMN *col)
 
TDS_INT tds_generic_row_len (TDSCOLUMN *col)
 
TDS_SERVER_TYPE tds_get_cardinal_type (TDS_SERVER_TYPE datatype, int usertype)
 
static TDSRET tds_get_char_dynamic (TDSSOCKET *tds, TDSCOLUMN *curcol, void **pp, size_t allocated, TDSINSTREAM *r_stream)
 
static const TDSCOLUMNFUNCStds_get_column_funcs (TDSCONNECTION *conn, int type)
 
TDSRET tds_invalid_get (TDSSOCKET *tds, TDSCOLUMN *col)
 
TDSRET tds_invalid_get_info (TDSSOCKET *tds, TDSCOLUMN *col)
 
TDSRET tds_invalid_put (TDSSOCKET *tds, TDSCOLUMN *col, int bcp7)
 
TDSRET tds_invalid_put_info (TDSSOCKET *tds, TDSCOLUMN *col)
 
unsigned tds_invalid_put_info_len (TDSSOCKET *tds, TDSCOLUMN *col)
 
TDS_INT tds_invalid_row_len (TDSCOLUMN *col)
 
TDSRET tds_msdatetime_get (TDSSOCKET *tds, TDSCOLUMN *col)
 
TDSRET tds_msdatetime_get_info (TDSSOCKET *tds, TDSCOLUMN *col)
 
TDSRET tds_msdatetime_put (TDSSOCKET *tds, TDSCOLUMN *col, int bcp7)
 
TDSRET tds_msdatetime_put_info (TDSSOCKET *tds, TDSCOLUMN *col)
 
TDS_INT tds_msdatetime_row_len (TDSCOLUMN *col)
 
TDSRET tds_numeric_get (TDSSOCKET *tds, TDSCOLUMN *curcol)
 
TDSRET tds_numeric_get_info (TDSSOCKET *tds, TDSCOLUMN *col)
 
TDSRET tds_numeric_put (TDSSOCKET *tds, TDSCOLUMN *col, int bcp7)
 
TDSRET tds_numeric_put_info (TDSSOCKET *tds, TDSCOLUMN *col)
 
unsigned tds_numeric_put_info_len (TDSSOCKET *tds, TDSCOLUMN *col)
 
TDS_INT tds_numeric_row_len (TDSCOLUMN *col)
 
void tds_set_column_type (TDSCONNECTION *conn, TDSCOLUMN *curcol, TDS_SERVER_TYPE type)
 Set type of column initializing all dependency. More...
 
void tds_set_param_type (TDSCONNECTION *conn, TDSCOLUMN *curcol, TDS_SERVER_TYPE type)
 Set type of column initializing all dependency. More...
 
static void tds_swap_numeric (TDS_NUMERIC *num)
 Converts numeric from Microsoft representation to internal one (Sybase). More...
 
TDSRET tds_sybbigtime_get (TDSSOCKET *tds, TDSCOLUMN *col)
 
TDSRET tds_sybbigtime_get_info (TDSSOCKET *tds, TDSCOLUMN *col)
 
TDSRET tds_sybbigtime_put (TDSSOCKET *tds, TDSCOLUMN *col, int bcp7)
 
TDSRET tds_sybbigtime_put_info (TDSSOCKET *tds, TDSCOLUMN *col)
 
unsigned tds_sybbigtime_put_info_len (TDSSOCKET *tds, TDSCOLUMN *col)
 
TDS_INT tds_sybbigtime_row_len (TDSCOLUMN *col)
 
TDSRET tds_variant_get (TDSSOCKET *tds, TDSCOLUMN *curcol)
 
TDSRET tds_variant_put (TDSSOCKET *tds, TDSCOLUMN *col, int bcp7)
 
TDSRET tds_variant_put_info (TDSSOCKET *tds, TDSCOLUMN *col)
 
static int tds_varmax_stream_read (TDSINSTREAM *stream, void *ptr, size_t len)
 

Detailed Description

Handle different data handling from network.

Function Documentation

§ tds_generic_get()

TDSRET tds_generic_get ( TDSSOCKET tds,
TDSCOLUMN curcol 
)

Read a data from wire.

Parameters
tdsstate information for the socket and the TDS protocol
curcolcolumn where store column information
Returns
TDS_FAIL on error or TDS_SUCCESS
Here is the call graph for this function:

§ tds_generic_put()

TDSRET tds_generic_put ( TDSSOCKET tds,
TDSCOLUMN curcol,
int  bcp7 
)

Write data to wire.

Parameters
tdsstate information for the socket and the TDS protocol
curcolcolumn where store column information
Returns
TDS_FAIL on error or TDS_SUCCESS
Here is the call graph for this function:

§ tds_generic_put_info()

TDSRET tds_generic_put_info ( TDSSOCKET tds,
TDSCOLUMN col 
)

Put data information to wire.

Parameters
tdsstate information for the socket and the TDS protocol
colcolumn where to store information
Returns
TDS_SUCCESS or TDS_FAIL
Here is the call graph for this function:

§ tds_set_column_type()

void tds_set_column_type ( TDSCONNECTION conn,
TDSCOLUMN curcol,
TDS_SERVER_TYPE  type 
)

Set type of column initializing all dependency.

Parameters
curcolcolumn to set
typetype to set

§ tds_set_param_type()

void tds_set_param_type ( TDSCONNECTION conn,
TDSCOLUMN curcol,
TDS_SERVER_TYPE  type 
)

Set type of column initializing all dependency.

Parameters
tdsstate information for the socket and the TDS protocol
curcolcolumn to set
typetype to set

§ tds_swap_numeric()

static void tds_swap_numeric ( TDS_NUMERIC num)
static

Converts numeric from Microsoft representation to internal one (Sybase).

Parameters
numnumeric data to convert
freetds-1.00.82/doc/reference/a00248_ac1e460551f1188620ea478238864ac4b_cgraph.svg100644 025423 025423 00000003201 13242511136 0020706 tds_writetext_end Node34 tds_writetext_end Node35 tds_set_state Node34->Node35 freetds-1.00.82/doc/reference/a00248_ade7df2db455b61edc83819ad60edb339_cgraph.map100644 025423 025423 00000000321 13242511134 0021411 freetds-1.00.82/doc/reference/a00248_ade7df2db455b61edc83819ad60edb339_cgraph.md5100644 025423 025423 00000000040 13242511133 00213161735df9313e08829850bb5839a6cc331freetds-1.00.82/doc/reference/a00248_ade7df2db455b61edc83819ad60edb339_cgraph.svg100644 025423 025423 00000003136 13242511136 0021444 tds_bcp_done Node10 tds_bcp_done Node11 tdsdump_log Node10->Node11 freetds-1.00.82/doc/reference/a00260_a84e17808683ba2dd956e811a42e23176_cgraph.map100644 025423 025423 00000000327 13242511134 0020673 freetds-1.00.82/doc/reference/a00260_a84e17808683ba2dd956e811a42e23176_cgraph.md5100644 025423 025423 00000000040 13242511133 00205724377b08670aa3ca5a95bbe9822aaebd5freetds-1.00.82/doc/reference/a00260_a84e17808683ba2dd956e811a42e23176_cgraph.svg100644 025423 025423 00000003135 13242511136 0020717 tds_generic_put Node3 tds_generic_put Node4 tdsdump_log Node3->Node4 freetds-1.00.82/doc/reference/a00260_aabd0e5f15615b5c141c525b76e746520_cgraph.map100644 025423 025423 00000000332 13242511134 0021002 freetds-1.00.82/doc/reference/a00261.map100644 025423 025423 00000004560 13242511134 0013042 freetds-1.00.82/doc/reference/a00260_aabd0e5f15615b5c141c525b76e746520_cgraph.md5100644 025423 025423 00000000040 13242511133 00207055b3c98b4ea42eb95210d2b04dea2da6bfreetds-1.00.82/doc/reference/a00260_aabd0e5f15615b5c141c525b76e746520_cgraph.svg100644 025423 025423 00000003157 13242511136 0021036 tds_generic_put_info Node6 tds_generic_put_info Node7 tds_fix_column_size Node6->Node7 freetds-1.00.82/doc/reference/a00260_abac4d689e0e31e80587f89247c6395a4_cgraph.map100644 025423 025423 00000000327 13242511134 0021051 freetds-1.00.82/doc/reference/a00260_abac4d689e0e31e80587f89247c6395a4_cgraph.md5100644 025423 025423 00000000040 13242511133 0020750e499e85195fc102f5414c4fd35ab468cfreetds-1.00.82/doc/reference/a00260_abac4d689e0e31e80587f89247c6395a4_cgraph.svg100644 025423 025423 00000003137 13242511136 0021077 tds_generic_get Node0 tds_generic_get Node1 tdsdump_log Node0->Node1 freetds-1.00.82/doc/reference/a00261.md5100644 025423 025423 00000000040 13242511133 00127364da5d103a456537ea30a394de672a280freetds-1.00.82/doc/reference/a00261.svg100644 025423 025423 00000065673 13242511136 0013102 src/tds/data.c Node0 src/tds/data.c Node1 config.h Node0->Node1 Node2 stdarg.h Node0->Node2 Node3 stdio.h Node0->Node3 Node4 assert.h Node0->Node4 Node5 freetds/tds.h Node0->Node5 Node14 freetds/pushvis.h Node0->Node14 Node15 freetds/popvis.h Node0->Node15 Node18 freetds/bytes.h Node0->Node18 Node19 freetds/iconv.h Node0->Node19 Node20 freetds/checks.h Node0->Node20 Node21 freetds/stream.h Node0->Node21 Node22 freetds/data.h Node0->Node22 Node23 tds_types.h Node0->Node23 Node5->Node2 Node5->Node3 Node6 time.h Node5->Node6 Node7 freetds/version.h Node5->Node7 Node8 tds_sysdep_public.h Node5->Node8 Node9 freetds/sysdep_private.h Node5->Node9 Node10 freetds/thread.h Node5->Node10 Node11 freetds/bool.h Node5->Node11 Node12 replacements.h Node5->Node12 Node5->Node14 Node5->Node15 Node17 freetds/proto.h Node5->Node17 Node6->Node6 Node12->Node2 Node12->Node8 Node12->Node9 Node13 replacements/readpassphrase.h Node12->Node13 Node12->Node14 Node12->Node15 Node16 replacements/poll.h Node12->Node16 Node13->Node14 Node13->Node15 Node16->Node1 Node16->Node14 Node16->Node15 Node19->Node14 Node19->Node15 Node20->Node14 Node20->Node15 Node21->Node14 Node21->Node15 Node22->Node14 Node22->Node15 freetds-1.00.82/doc/reference/a00269_source.html100644 025423 025423 00000326415 13242511132 0014625 FreeTDS API: src/tds/encodings.h Source File
FreeTDS API
encodings.h
1 /*
2  * This file produced from ./encodings.pl on Mon Feb 19 09:01:11 2018
3  * $Id: encodings.pl,v 1.12 2010-11-26 19:46:55 freddy77 Exp $
4  */
5 #ifdef TDS_ICONV_ENCODING_TABLES
6 
7 static const TDS_ENCODING canonic_charsets[] = {
8  { "ISO-8859-1", 1, 1, 0}, /* 0 */
9  { "UTF-8", 1, 4, 1}, /* 1 */
10  { "UCS-2LE", 2, 2, 2}, /* 2 */
11  { "UCS-2BE", 2, 2, 3}, /* 3 */
12  { "ARMSCII-8", 1, 1, 4}, /* 4 */
13  { "BIG-5", 1, 2, 5}, /* 5 */
14  { "BIG5-HKSCS", 1, 2, 6}, /* 6 */
15  { "C99", 1, 1, 7}, /* 7 */
16  { "CHINESE", 1, 1, 8}, /* 8 */
17  { "CN", 1, 1, 9}, /* 9 */
18  { "CN-GB", 1, 2, 10}, /* 10 */
19  { "CN-GB-ISOIR165", 1, 1, 11}, /* 11 */
20  { "CP1133", 1, 1, 12}, /* 12 */
21  { "CP1250", 1, 1, 13}, /* 13 */
22  { "CP1251", 1, 1, 14}, /* 14 */
23  { "CP1252", 1, 1, 15}, /* 15 */
24  { "CP1253", 1, 1, 16}, /* 16 */
25  { "CP1254", 1, 1, 17}, /* 17 */
26  { "CP1255", 1, 1, 18}, /* 18 */
27  { "CP1256", 1, 1, 19}, /* 19 */
28  { "CP1257", 1, 1, 20}, /* 20 */
29  { "CP1258", 1, 1, 21}, /* 21 */
30  { "CP1361", 1, 2, 22}, /* 22 */
31  { "CP437", 1, 1, 23}, /* 23 */
32  { "CP850", 1, 1, 24}, /* 24 */
33  { "CP862", 1, 1, 25}, /* 25 */
34  { "CP866", 1, 1, 26}, /* 26 */
35  { "CP874", 1, 1, 27}, /* 27 */
36  { "CP932", 1, 2, 28}, /* 28 */
37  { "CP936", 1, 2, 29}, /* 29 */
38  { "CP949", 1, 2, 30}, /* 30 */
39  { "CP950", 1, 2, 31}, /* 31 */
40  { "EUC-JP", 1, 3, 32}, /* 32 */
41  { "EUC-KR", 1, 2, 33}, /* 33 */
42  { "EUC-TW", 1, 4, 34}, /* 34 */
43  { "GB18030", 1, 4, 35}, /* 35 */
44  { "GEORGIAN-ACADEMY", 1, 1, 36}, /* 36 */
45  { "GEORGIAN-PS", 1, 1, 37}, /* 37 */
46  { "HZ", 1, 1, 38}, /* 38 */
47  { "ISO-2022-CN", 1, 4, 39}, /* 39 */
48  { "ISO-2022-CN-EXT", 1, 4, 40}, /* 40 */
49  { "ISO-2022-JP", 1, 1, 41}, /* 41 */
50  { "ISO-2022-JP-1", 1, 1, 42}, /* 42 */
51  { "ISO-2022-JP-2", 1, 1, 43}, /* 43 */
52  { "ISO-2022-KR", 1, 2, 44}, /* 44 */
53  { "ISO-8859-10", 1, 1, 45}, /* 45 */
54  { "ISO-8859-13", 1, 1, 46}, /* 46 */
55  { "ISO-8859-14", 1, 1, 47}, /* 47 */
56  { "ISO-8859-15", 1, 1, 48}, /* 48 */
57  { "ISO-8859-16", 1, 1, 49}, /* 49 */
58  { "ISO-8859-2", 1, 1, 50}, /* 50 */
59  { "ISO-8859-3", 1, 1, 51}, /* 51 */
60  { "ISO-8859-4", 1, 1, 52}, /* 52 */
61  { "ISO-8859-5", 1, 1, 53}, /* 53 */
62  { "ISO-8859-6", 1, 1, 54}, /* 54 */
63  { "ISO-8859-7", 1, 1, 55}, /* 55 */
64  { "ISO-8859-8", 1, 1, 56}, /* 56 */
65  { "ISO-8859-9", 1, 1, 57}, /* 57 */
66  { "ISO-IR-14", 1, 1, 58}, /* 58 */
67  { "ISO-IR-149", 1, 1, 59}, /* 59 */
68  { "ISO-IR-159", 1, 1, 60}, /* 60 */
69  { "ISO-IR-166", 1, 1, 61}, /* 61 */
70  { "ISO-IR-87", 1, 1, 62}, /* 62 */
71  { "JAVA", 1, 1, 63}, /* 63 */
72  { "JISX0201-1976", 1, 1, 64}, /* 64 */
73  { "KOI8-R", 1, 1, 65}, /* 65 */
74  { "KOI8-RU", 1, 1, 66}, /* 66 */
75  { "KOI8-T", 1, 1, 67}, /* 67 */
76  { "KOI8-U", 1, 1, 68}, /* 68 */
77  { "MAC", 1, 1, 69}, /* 69 */
78  { "MACARABIC", 1, 1, 70}, /* 70 */
79  { "MACCENTRALEUROPE", 1, 1, 71}, /* 71 */
80  { "MACCROATIAN", 1, 1, 72}, /* 72 */
81  { "MACCYRILLIC", 1, 1, 73}, /* 73 */
82  { "MACGREEK", 1, 1, 74}, /* 74 */
83  { "MACHEBREW", 1, 1, 75}, /* 75 */
84  { "MACICELAND", 1, 1, 76}, /* 76 */
85  { "MACROMANIA", 1, 1, 77}, /* 77 */
86  { "MACTHAI", 1, 1, 78}, /* 78 */
87  { "MACTURKISH", 1, 1, 79}, /* 79 */
88  { "MACUKRAINE", 1, 1, 80}, /* 80 */
89  { "MULELAO-1", 1, 1, 81}, /* 81 */
90  { "NEXTSTEP", 1, 1, 82}, /* 82 */
91  { "ROMAN8", 1, 1, 83}, /* 83 */
92  { "SJIS", 1, 2, 84}, /* 84 */
93  { "TCVN", 1, 1, 85}, /* 85 */
94  { "UCS-2", 2, 2, 86}, /* 86 */
95  { "UCS-2-INTERNAL", 2, 2, 87}, /* 87 */
96  { "UCS-2-SWAPPED", 2, 2, 88}, /* 88 */
97  { "UCS-4", 4, 4, 89}, /* 89 */
98  { "UCS-4-INTERNAL", 4, 4, 90}, /* 90 */
99  { "UCS-4-SWAPPED", 4, 4, 91}, /* 91 */
100  { "UCS-4BE", 4, 4, 92}, /* 92 */
101  { "UCS-4LE", 4, 4, 93}, /* 93 */
102  { "US-ASCII", 1, 1, 94}, /* 94 */
103  { "UTF-16", 2, 4, 95}, /* 95 */
104  { "UTF-16BE", 2, 4, 96}, /* 96 */
105  { "UTF-16LE", 2, 4, 97}, /* 97 */
106  { "UTF-32", 4, 4, 98}, /* 98 */
107  { "UTF-32BE", 4, 4, 99}, /* 99 */
108  { "UTF-32LE", 4, 4, 100}, /* 100 */
109  { "UTF-7", 1, 4, 101}, /* 101 */
110  { "VISCII", 1, 1, 102}, /* 102 */
111 };
112 
113 static const CHARACTER_SET_ALIAS iconv_aliases[] = {
114  { "646", 94 },
115  { "850", 24 },
116  { "862", 25 },
117  { "866", 26 },
118  { "ANSI_X3.4-1968", 94 },
119  { "ANSI_X3.4-1986", 94 },
120  { "ARABIC", 54 },
121  { "ARMSCII-8", 4 },
122  { "ASCII", 94 },
123  { "ASMO-708", 54 },
124  { "BIG-5", 5 },
125  { "BIG-FIVE", 5 },
126  { "BIG5", 5 },
127  { "BIG5-HKSCS", 6 },
128  { "BIG5HKSCS", 6 },
129  { "BIGFIVE", 5 },
130  { "C99", 7 },
131  { "CHINESE", 8 },
132  { "CN", 9 },
133  { "CN-BIG5", 5 },
134  { "CN-GB", 10 },
135  { "CN-GB-ISOIR165", 11 },
136  { "CP1133", 12 },
137  { "CP1250", 13 },
138  { "CP1251", 14 },
139  { "CP1252", 15 },
140  { "CP1253", 16 },
141  { "CP1254", 17 },
142  { "CP1255", 18 },
143  { "CP1256", 19 },
144  { "CP1257", 20 },
145  { "CP1258", 21 },
146  { "CP1361", 22 },
147  { "CP367", 94 },
148  { "CP437", 23 },
149  { "CP819", 0 },
150  { "CP850", 24 },
151  { "CP862", 25 },
152  { "CP866", 26 },
153  { "CP874", 27 },
154  { "CP932", 28 },
155  { "CP936", 29 },
156  { "CP949", 30 },
157  { "CP950", 31 },
158  { "CSASCII", 94 },
159  { "CSBIG5", 5 },
160  { "CSEUCKR", 33 },
161  { "CSEUCPKDFMTJAPANESE", 32 },
162  { "CSEUCTW", 34 },
163  { "CSGB2312", 10 },
164  { "CSHALFWIDTHKATAKANA", 64 },
165  { "CSHPROMAN8", 83 },
166  { "CSIBM866", 26 },
167  { "CSISO14JISC6220RO", 58 },
168  { "CSISO159JISX02121990", 60 },
169  { "CSISO2022CN", 39 },
170  { "CSISO2022JP", 41 },
171  { "CSISO2022JP2", 43 },
172  { "CSISO2022KR", 44 },
173  { "CSISO57GB1988", 9 },
174  { "CSISO58GB231280", 8 },
175  { "CSISO87JISX0208", 62 },
176  { "CSISOLATIN1", 0 },
177  { "CSISOLATIN2", 50 },
178  { "CSISOLATIN3", 51 },
179  { "CSISOLATIN4", 52 },
180  { "CSISOLATIN5", 57 },
181  { "CSISOLATIN6", 45 },
182  { "CSISOLATINARABIC", 54 },
183  { "CSISOLATINCYRILLIC", 53 },
184  { "CSISOLATINGREEK", 55 },
185  { "CSISOLATINHEBREW", 56 },
186  { "CSKOI8R", 65 },
187  { "CSKSC56011987", 59 },
188  { "CSMACINTOSH", 69 },
189  { "CSPC850MULTILINGUAL", 24 },
190  { "CSPC862LATINHEBREW", 25 },
191  { "CSSHIFTJIS", 84 },
192  { "CSUCS4", 89 },
193  { "CSUNICODE", 86 },
194  { "CSUNICODE11", 3 },
195  { "CSUNICODE11UTF7", 101 },
196  { "CSVISCII", 102 },
197  { "CYRILLIC", 53 },
198  { "ECMA-114", 54 },
199  { "ECMA-118", 55 },
200  { "ELOT_928", 55 },
201  { "EUC-CN", 10 },
202  { "EUC-JP", 32 },
203  { "EUC-KR", 33 },
204  { "EUC-TW", 34 },
205  { "EUCCN", 10 },
206  { "EUCJP", 32 },
207  { "EUCKR", 33 },
208  { "EUCTW", 34 },
209  {"EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE", 32 },
210  { "GB18030", 35 },
211  { "GB2312", 10 },
212  { "GBK", 29 },
213  { "GB_1988-80", 9 },
214  { "GB_2312-80", 8 },
215  { "GEORGIAN-ACADEMY", 36 },
216  { "GEORGIAN-PS", 37 },
217  { "GREEK", 55 },
218  { "GREEK8", 55 },
219  { "HEBREW", 56 },
220  { "HP-ROMAN8", 83 },
221  { "HZ", 38 },
222  { "HZ-GB-2312", 38 },
223  { "IBM-CP1133", 12 },
224  { "IBM367", 94 },
225  { "IBM437", 23 },
226  { "IBM819", 0 },
227  { "IBM850", 24 },
228  { "IBM862", 25 },
229  { "IBM866", 26 },
230  { "ISO-10646-UCS-2", 86 },
231  { "ISO-10646-UCS-4", 89 },
232  { "ISO-2022-CN", 39 },
233  { "ISO-2022-CN-EXT", 40 },
234  { "ISO-2022-JP", 41 },
235  { "ISO-2022-JP-1", 42 },
236  { "ISO-2022-JP-2", 43 },
237  { "ISO-2022-KR", 44 },
238  { "ISO-8859-1", 0 },
239  { "ISO-8859-10", 45 },
240  { "ISO-8859-13", 46 },
241  { "ISO-8859-14", 47 },
242  { "ISO-8859-15", 48 },
243  { "ISO-8859-16", 49 },
244  { "ISO-8859-2", 50 },
245  { "ISO-8859-3", 51 },
246  { "ISO-8859-4", 52 },
247  { "ISO-8859-5", 53 },
248  { "ISO-8859-6", 54 },
249  { "ISO-8859-7", 55 },
250  { "ISO-8859-8", 56 },
251  { "ISO-8859-9", 57 },
252  { "ISO-CELTIC", 47 },
253  { "ISO-IR-100", 0 },
254  { "ISO-IR-101", 50 },
255  { "ISO-IR-109", 51 },
256  { "ISO-IR-110", 52 },
257  { "ISO-IR-126", 55 },
258  { "ISO-IR-127", 54 },
259  { "ISO-IR-138", 56 },
260  { "ISO-IR-14", 58 },
261  { "ISO-IR-144", 53 },
262  { "ISO-IR-148", 57 },
263  { "ISO-IR-149", 59 },
264  { "ISO-IR-157", 45 },
265  { "ISO-IR-159", 60 },
266  { "ISO-IR-165", 11 },
267  { "ISO-IR-166", 61 },
268  { "ISO-IR-179", 46 },
269  { "ISO-IR-199", 47 },
270  { "ISO-IR-203", 48 },
271  { "ISO-IR-226", 49 },
272  { "ISO-IR-57", 9 },
273  { "ISO-IR-58", 8 },
274  { "ISO-IR-6", 94 },
275  { "ISO-IR-87", 62 },
276  { "ISO646-CN", 9 },
277  { "ISO646-JP", 58 },
278  { "ISO646-US", 94 },
279  { "ISO8859-1", 0 },
280  { "ISO8859-10", 45 },
281  { "ISO8859-15", 48 },
282  { "ISO8859-2", 50 },
283  { "ISO8859-4", 52 },
284  { "ISO8859-5", 53 },
285  { "ISO8859-6", 54 },
286  { "ISO8859-7", 55 },
287  { "ISO8859-8", 56 },
288  { "ISO8859-9", 57 },
289  { "ISO_646.IRV:1991", 94 },
290  { "ISO_8859-1", 0 },
291  { "ISO_8859-10", 45 },
292  { "ISO_8859-10:1992", 45 },
293  { "ISO_8859-13", 46 },
294  { "ISO_8859-14", 47 },
295  { "ISO_8859-14:1998", 47 },
296  { "ISO_8859-15", 48 },
297  { "ISO_8859-15:1998", 48 },
298  { "ISO_8859-16", 49 },
299  { "ISO_8859-16:2000", 49 },
300  { "ISO_8859-1:1987", 0 },
301  { "ISO_8859-2", 50 },
302  { "ISO_8859-2:1987", 50 },
303  { "ISO_8859-3", 51 },
304  { "ISO_8859-3:1988", 51 },
305  { "ISO_8859-4", 52 },
306  { "ISO_8859-4:1988", 52 },
307  { "ISO_8859-5", 53 },
308  { "ISO_8859-5:1988", 53 },
309  { "ISO_8859-6", 54 },
310  { "ISO_8859-6:1987", 54 },
311  { "ISO_8859-7", 55 },
312  { "ISO_8859-7:1987", 55 },
313  { "ISO_8859-8", 56 },
314  { "ISO_8859-8:1988", 56 },
315  { "ISO_8859-9", 57 },
316  { "ISO_8859-9:1989", 57 },
317  { "JAVA", 63 },
318  { "JIS0208", 62 },
319  { "JISX0201-1976", 64 },
320  { "JIS_C6220-1969-RO", 58 },
321  { "JIS_C6226-1983", 62 },
322  { "JIS_X0201", 64 },
323  { "JIS_X0208", 62 },
324  { "JIS_X0208-1983", 62 },
325  { "JIS_X0208-1990", 62 },
326  { "JIS_X0212", 60 },
327  { "JIS_X0212-1990", 60 },
328  { "JIS_X0212.1990-0", 60 },
329  { "JOHAB", 22 },
330  { "JP", 58 },
331  { "KOI8-R", 65 },
332  { "KOI8-RU", 66 },
333  { "KOI8-T", 67 },
334  { "KOI8-U", 68 },
335  { "KOREAN", 59 },
336  { "KSC_5601", 59 },
337  { "KS_C_5601-1987", 59 },
338  { "KS_C_5601-1989", 59 },
339  { "L1", 0 },
340  { "L2", 50 },
341  { "L3", 51 },
342  { "L4", 52 },
343  { "L5", 57 },
344  { "L6", 45 },
345  { "L7", 46 },
346  { "L8", 47 },
347  { "LATIN1", 0 },
348  { "LATIN2", 50 },
349  { "LATIN3", 51 },
350  { "LATIN4", 52 },
351  { "LATIN5", 57 },
352  { "LATIN6", 45 },
353  { "LATIN7", 46 },
354  { "LATIN8", 47 },
355  { "MAC", 69 },
356  { "MACARABIC", 70 },
357  { "MACCENTRALEUROPE", 71 },
358  { "MACCROATIAN", 72 },
359  { "MACCYRILLIC", 73 },
360  { "MACGREEK", 74 },
361  { "MACHEBREW", 75 },
362  { "MACICELAND", 76 },
363  { "MACINTOSH", 69 },
364  { "MACROMAN", 69 },
365  { "MACROMANIA", 77 },
366  { "MACTHAI", 78 },
367  { "MACTURKISH", 79 },
368  { "MACUKRAINE", 80 },
369  { "MS-ANSI", 15 },
370  { "MS-ARAB", 19 },
371  { "MS-CYRL", 14 },
372  { "MS-EE", 13 },
373  { "MS-GREEK", 16 },
374  { "MS-HEBR", 18 },
375  { "MS-TURK", 17 },
376  { "MS_KANJI", 84 },
377  { "MULELAO-1", 81 },
378  { "NEXTSTEP", 82 },
379  { "R8", 83 },
380  { "ROMAN8", 83 },
381  { "SHIFT-JIS", 84 },
382  { "SHIFT_JIS", 84 },
383  { "SJIS", 84 },
384  { "TCVN", 85 },
385  { "TCVN-5712", 85 },
386  { "TCVN5712-1", 85 },
387  { "TCVN5712-1:1993", 85 },
388  { "TIS-620", 61 },
389  { "TIS620", 61 },
390  { "TIS620-0", 61 },
391  { "TIS620.2529-1", 61 },
392  { "TIS620.2533-0", 61 },
393  { "TIS620.2533-1", 61 },
394  { "UCS-2", 86 },
395  { "UCS-2-INTERNAL", 87 },
396  { "UCS-2-SWAPPED", 88 },
397  { "UCS-2BE", 3 },
398  { "UCS-2LE", 2 },
399  { "UCS-4", 89 },
400  { "UCS-4-INTERNAL", 90 },
401  { "UCS-4-SWAPPED", 91 },
402  { "UCS-4BE", 92 },
403  { "UCS-4LE", 93 },
404  { "UCS2", 86 },
405  { "UCS4", 89 },
406  { "UHC", 30 },
407  { "UNICODE-1-1", 3 },
408  { "UNICODE-1-1-UTF-7", 101 },
409  { "UNICODEBIG", 3 },
410  { "UNICODELITTLE", 2 },
411  { "US", 94 },
412  { "US-ASCII", 94 },
413  { "UTF-16", 95 },
414  { "UTF-16BE", 96 },
415  { "UTF-16LE", 97 },
416  { "UTF-32", 98 },
417  { "UTF-32BE", 99 },
418  { "UTF-32LE", 100 },
419  { "UTF-7", 101 },
420  { "UTF-8", 1 },
421  { "UTF16", 95 },
422  { "UTF7", 101 },
423  { "UTF8", 1 },
424  { "VISCII", 102 },
425  { "VISCII1.1-1", 102 },
426  { "WINBALTRIM", 20 },
427  { "WINDOWS-1250", 13 },
428  { "WINDOWS-1251", 14 },
429  { "WINDOWS-1252", 15 },
430  { "WINDOWS-1253", 16 },
431  { "WINDOWS-1254", 17 },
432  { "WINDOWS-1255", 18 },
433  { "WINDOWS-1256", 19 },
434  { "WINDOWS-1257", 20 },
435  { "WINDOWS-1258", 21 },
436  { "WINDOWS-874", 27 },
437  { "X0201", 64 },
438  { "X0208", 62 },
439  { "X0212", 60 },
440  { "big5", 5 },
441  { "cp1250", 13 },
442  { "cp1251", 14 },
443  { "cp1252", 15 },
444  { "cp1253", 16 },
445  { "cp1254", 17 },
446  { "cp1255", 18 },
447  { "cp1256", 19 },
448  { "cp1257", 20 },
449  { "cp1258", 21 },
450  { "cp437", 23 },
451  { "cp850", 24 },
452  { "cp862", 25 },
453  { "cp866", 26 },
454  { "cp874", 27 },
455  { "eucJP", 32 },
456  { "eucKR", 33 },
457  { "eucTW", 34 },
458  { "hp15CN", 8 },
459  { "iso81", 0 },
460  { "iso815", 48 },
461  { "iso82", 50 },
462  { "iso83", 51 },
463  { "iso84", 52 },
464  { "iso85", 53 },
465  { "iso86", 54 },
466  { "iso87", 55 },
467  { "iso88", 56 },
468  { "iso88591", 0 },
469  { "iso885915", 48 },
470  { "iso88592", 50 },
471  { "iso88593", 51 },
472  { "iso88594", 52 },
473  { "iso88595", 53 },
474  { "iso88596", 54 },
475  { "iso88597", 55 },
476  { "iso88598", 56 },
477  { "iso88599", 57 },
478  { "iso89", 57 },
479  { "roma8", 83 },
480  { "roman8", 83 },
481  { "sjis", 84 },
482  { "thai8", 61 },
483  { "tis620", 61 },
484  { "ucs2", 86 },
485  { "ucs4", 89 },
486  { "utf8", 1 },
487  {NULL, 0}
488 };
489 
490 static const CHARACTER_SET_ALIAS sybase_aliases[] = {
491  { "ascii_8", 0 },
492  { "big5", 5 },
493  { "cp1250", 13 },
494  { "cp1251", 14 },
495  { "cp1252", 15 },
496  { "cp1253", 16 },
497  { "cp1254", 17 },
498  { "cp1255", 18 },
499  { "cp1256", 19 },
500  { "cp1257", 20 },
501  { "cp1258", 21 },
502  { "cp437", 23 },
503  { "cp850", 24 },
504  { "cp862", 25 },
505  { "cp866", 26 },
506  { "cp874", 27 },
507  { "cp932", 28 },
508  { "cp936", 29 },
509  { "cp949", 30 },
510  { "cp950", 31 },
511  { "greek8", 55 },
512  { "iso10", 45 },
513  { "iso13", 46 },
514  { "iso14", 47 },
515  { "iso15", 48 },
516  { "iso646", 94 },
517  { "iso88592", 50 },
518  { "iso88595", 53 },
519  { "iso88596", 54 },
520  { "iso88597", 55 },
521  { "iso88598", 56 },
522  { "iso88599", 57 },
523  { "iso_1", 0 },
524  { "koi8", 65 },
525  { "mac", 69 },
526  { "mac_cyr", 73 },
527  { "macgreek", 74 },
528  { "macthai", 78 },
529  { "macturk", 79 },
530  { "roman8", 83 },
531  { "sjis", 84 },
532  { "tis620", 61 },
533  { "utf8", 1 },
534  {NULL, 0}
535 };
536 #endif
537 
538 enum {
539  TDS_CHARSET_ISO_8859_1 = 0,
540  TDS_CHARSET_UTF_8 = 1,
541  TDS_CHARSET_UCS_2LE = 2,
542  TDS_CHARSET_UCS_2BE = 3,
543  TDS_CHARSET_ARMSCII_8 = 4,
544  TDS_CHARSET_BIG_5 = 5,
545  TDS_CHARSET_BIG5_HKSCS = 6,
546  TDS_CHARSET_C99 = 7,
547  TDS_CHARSET_CHINESE = 8,
548  TDS_CHARSET_CN = 9,
549  TDS_CHARSET_CN_GB = 10,
550  TDS_CHARSET_CN_GB_ISOIR165 = 11,
551  TDS_CHARSET_CP1133 = 12,
552  TDS_CHARSET_CP1250 = 13,
553  TDS_CHARSET_CP1251 = 14,
554  TDS_CHARSET_CP1252 = 15,
555  TDS_CHARSET_CP1253 = 16,
556  TDS_CHARSET_CP1254 = 17,
557  TDS_CHARSET_CP1255 = 18,
558  TDS_CHARSET_CP1256 = 19,
559  TDS_CHARSET_CP1257 = 20,
560  TDS_CHARSET_CP1258 = 21,
561  TDS_CHARSET_CP1361 = 22,
562  TDS_CHARSET_CP437 = 23,
563  TDS_CHARSET_CP850 = 24,
564  TDS_CHARSET_CP862 = 25,
565  TDS_CHARSET_CP866 = 26,
566  TDS_CHARSET_CP874 = 27,
567  TDS_CHARSET_CP932 = 28,
568  TDS_CHARSET_CP936 = 29,
569  TDS_CHARSET_CP949 = 30,
570  TDS_CHARSET_CP950 = 31,
571  TDS_CHARSET_EUC_JP = 32,
572  TDS_CHARSET_EUC_KR = 33,
573  TDS_CHARSET_EUC_TW = 34,
574  TDS_CHARSET_GB18030 = 35,
575  TDS_CHARSET_GEORGIAN_ACADEMY = 36,
576  TDS_CHARSET_GEORGIAN_PS = 37,
577  TDS_CHARSET_HZ = 38,
578  TDS_CHARSET_ISO_2022_CN = 39,
579  TDS_CHARSET_ISO_2022_CN_EXT = 40,
580  TDS_CHARSET_ISO_2022_JP = 41,
581  TDS_CHARSET_ISO_2022_JP_1 = 42,
582  TDS_CHARSET_ISO_2022_JP_2 = 43,
583  TDS_CHARSET_ISO_2022_KR = 44,
584  TDS_CHARSET_ISO_8859_10 = 45,
585  TDS_CHARSET_ISO_8859_13 = 46,
586  TDS_CHARSET_ISO_8859_14 = 47,
587  TDS_CHARSET_ISO_8859_15 = 48,
588  TDS_CHARSET_ISO_8859_16 = 49,
589  TDS_CHARSET_ISO_8859_2 = 50,
590  TDS_CHARSET_ISO_8859_3 = 51,
591  TDS_CHARSET_ISO_8859_4 = 52,
592  TDS_CHARSET_ISO_8859_5 = 53,
593  TDS_CHARSET_ISO_8859_6 = 54,
594  TDS_CHARSET_ISO_8859_7 = 55,
595  TDS_CHARSET_ISO_8859_8 = 56,
596  TDS_CHARSET_ISO_8859_9 = 57,
597  TDS_CHARSET_ISO_IR_14 = 58,
598  TDS_CHARSET_ISO_IR_149 = 59,
599  TDS_CHARSET_ISO_IR_159 = 60,
600  TDS_CHARSET_ISO_IR_166 = 61,
601  TDS_CHARSET_ISO_IR_87 = 62,
602  TDS_CHARSET_JAVA = 63,
603  TDS_CHARSET_JISX0201_1976 = 64,
604  TDS_CHARSET_KOI8_R = 65,
605  TDS_CHARSET_KOI8_RU = 66,
606  TDS_CHARSET_KOI8_T = 67,
607  TDS_CHARSET_KOI8_U = 68,
608  TDS_CHARSET_MAC = 69,
609  TDS_CHARSET_MACARABIC = 70,
610  TDS_CHARSET_MACCENTRALEUROPE = 71,
611  TDS_CHARSET_MACCROATIAN = 72,
612  TDS_CHARSET_MACCYRILLIC = 73,
613  TDS_CHARSET_MACGREEK = 74,
614  TDS_CHARSET_MACHEBREW = 75,
615  TDS_CHARSET_MACICELAND = 76,
616  TDS_CHARSET_MACROMANIA = 77,
617  TDS_CHARSET_MACTHAI = 78,
618  TDS_CHARSET_MACTURKISH = 79,
619  TDS_CHARSET_MACUKRAINE = 80,
620  TDS_CHARSET_MULELAO_1 = 81,
621  TDS_CHARSET_NEXTSTEP = 82,
622  TDS_CHARSET_ROMAN8 = 83,
623  TDS_CHARSET_SJIS = 84,
624  TDS_CHARSET_TCVN = 85,
625  TDS_CHARSET_UCS_2 = 86,
626  TDS_CHARSET_UCS_2_INTERNAL = 87,
627  TDS_CHARSET_UCS_2_SWAPPED = 88,
628  TDS_CHARSET_UCS_4 = 89,
629  TDS_CHARSET_UCS_4_INTERNAL = 90,
630  TDS_CHARSET_UCS_4_SWAPPED = 91,
631  TDS_CHARSET_UCS_4BE = 92,
632  TDS_CHARSET_UCS_4LE = 93,
633  TDS_CHARSET_US_ASCII = 94,
634  TDS_CHARSET_UTF_16 = 95,
635  TDS_CHARSET_UTF_16BE = 96,
636  TDS_CHARSET_UTF_16LE = 97,
637  TDS_CHARSET_UTF_32 = 98,
638  TDS_CHARSET_UTF_32BE = 99,
639  TDS_CHARSET_UTF_32LE = 100,
640  TDS_CHARSET_UTF_7 = 101,
641  TDS_CHARSET_VISCII = 102,
642  TDS_NUM_CHARSETS = 103
643 };
644 
Information relevant to libiconv.
Definition: tds.h:648
Definition: iconv.h:72
freetds-1.00.82/doc/reference/a00299_source.html100644 025423 025423 00000154427 13242511132 0014632 FreeTDS API: src/tds/num_limits.h Source File
FreeTDS API
num_limits.h
1 #define LIMIT_INDEXES_ADJUST 4
2 
3 static const signed char limit_indexes[79]= {
4  0, /* 0 */
5  -3, /* 1 */
6  -6, /* 2 */
7  -9, /* 3 */
8  -12, /* 4 */
9  -15, /* 5 */
10  -18, /* 6 */
11  -21, /* 7 */
12  -24, /* 8 */
13  -27, /* 9 */
14  -30, /* 10 */
15  -32, /* 11 */
16  -34, /* 12 */
17  -36, /* 13 */
18  -38, /* 14 */
19  -40, /* 15 */
20  -42, /* 16 */
21  -44, /* 17 */
22  -46, /* 18 */
23  -48, /* 19 */
24  -50, /* 20 */
25  -51, /* 21 */
26  -52, /* 22 */
27  -53, /* 23 */
28  -54, /* 24 */
29  -55, /* 25 */
30  -56, /* 26 */
31  -57, /* 27 */
32  -58, /* 28 */
33  -59, /* 29 */
34  -59, /* 30 */
35  -59, /* 31 */
36  -59, /* 32 */
37  -60, /* 33 */
38  -61, /* 34 */
39  -62, /* 35 */
40  -63, /* 36 */
41  -64, /* 37 */
42  -65, /* 38 */
43  -66, /* 39 */
44  -66, /* 40 */
45  -66, /* 41 */
46  -66, /* 42 */
47  -66, /* 43 */
48  -66, /* 44 */
49  -66, /* 45 */
50  -66, /* 46 */
51  -66, /* 47 */
52  -66, /* 48 */
53  -66, /* 49 */
54  -65, /* 50 */
55  -64, /* 51 */
56  -63, /* 52 */
57  -62, /* 53 */
58  -61, /* 54 */
59  -60, /* 55 */
60  -59, /* 56 */
61  -58, /* 57 */
62  -57, /* 58 */
63  -55, /* 59 */
64  -53, /* 60 */
65  -51, /* 61 */
66  -49, /* 62 */
67  -47, /* 63 */
68  -45, /* 64 */
69  -44, /* 65 */
70  -43, /* 66 */
71  -42, /* 67 */
72  -41, /* 68 */
73  -39, /* 69 */
74  -37, /* 70 */
75  -35, /* 71 */
76  -33, /* 72 */
77  -31, /* 73 */
78  -29, /* 74 */
79  -27, /* 75 */
80  -25, /* 76 */
81  -23, /* 77 */
82  -21, /* 78 */
83 };
84 
85 static const TDS_WORD limits[]= {
86  0x00000001u, /* 0 */
87  0x0000000au, /* 1 */
88  0x00000064u, /* 2 */
89  0x000003e8u, /* 3 */
90  0x00002710u, /* 4 */
91  0x000186a0u, /* 5 */
92  0x000f4240u, /* 6 */
93  0x00989680u, /* 7 */
94  0x05f5e100u, /* 8 */
95  0x3b9aca00u, /* 9 */
96  0x00000002u, /* 10 */
97  0x540be400u, /* 11 */
98  0x00000017u, /* 12 */
99  0x4876e800u, /* 13 */
100  0x000000e8u, /* 14 */
101  0xd4a51000u, /* 15 */
102  0x00000918u, /* 16 */
103  0x4e72a000u, /* 17 */
104  0x00005af3u, /* 18 */
105  0x107a4000u, /* 19 */
106  0x00038d7eu, /* 20 */
107  0xa4c68000u, /* 21 */
108  0x002386f2u, /* 22 */
109  0x6fc10000u, /* 23 */
110  0x01634578u, /* 24 */
111  0x5d8a0000u, /* 25 */
112  0x0de0b6b3u, /* 26 */
113  0xa7640000u, /* 27 */
114  0x8ac72304u, /* 28 */
115  0x89e80000u, /* 29 */
116  0x00000005u, /* 30 */
117  0x6bc75e2du, /* 31 */
118  0x63100000u, /* 32 */
119  0x00000036u, /* 33 */
120  0x35c9adc5u, /* 34 */
121  0xdea00000u, /* 35 */
122  0x0000021eu, /* 36 */
123  0x19e0c9bau, /* 37 */
124  0xb2400000u, /* 38 */
125  0x0000152du, /* 39 */
126  0x02c7e14au, /* 40 */
127  0xf6800000u, /* 41 */
128  0x0000d3c2u, /* 42 */
129  0x1bceccedu, /* 43 */
130  0xa1000000u, /* 44 */
131  0x00084595u, /* 45 */
132  0x16140148u, /* 46 */
133  0x4a000000u, /* 47 */
134  0x0052b7d2u, /* 48 */
135  0xdcc80cd2u, /* 49 */
136  0xe4000000u, /* 50 */
137  0x033b2e3cu, /* 51 */
138  0x9fd0803cu, /* 52 */
139  0xe8000000u, /* 53 */
140  0x204fce5eu, /* 54 */
141  0x3e250261u, /* 55 */
142  0x10000000u, /* 56 */
143  0x00000001u, /* 57 */
144  0x431e0faeu, /* 58 */
145  0x6d7217cau, /* 59 */
146  0xa0000000u, /* 60 */
147  0x0000000cu, /* 61 */
148  0x9f2c9cd0u, /* 62 */
149  0x4674edeau, /* 63 */
150  0x40000000u, /* 64 */
151  0x0000007eu, /* 65 */
152  0x37be2022u, /* 66 */
153  0xc0914b26u, /* 67 */
154  0x80000000u, /* 68 */
155  0x000004eeu, /* 69 */
156  0x2d6d415bu, /* 70 */
157  0x85acef81u, /* 71 */
158  0x0000314du, /* 72 */
159  0xc6448d93u, /* 73 */
160  0x38c15b0au, /* 74 */
161  0x0001ed09u, /* 75 */
162  0xbead87c0u, /* 76 */
163  0x378d8e64u, /* 77 */
164  0x00134261u, /* 78 */
165  0x72c74d82u, /* 79 */
166  0x2b878fe8u, /* 80 */
167  0x00c097ceu, /* 81 */
168  0x7bc90715u, /* 82 */
169  0xb34b9f10u, /* 83 */
170  0x0785ee10u, /* 84 */
171  0xd5da46d9u, /* 85 */
172  0x00f436a0u, /* 86 */
173  0x4b3b4ca8u, /* 87 */
174  0x5a86c47au, /* 88 */
175  0x098a2240u, /* 89 */
176  0x00000002u, /* 90 */
177  0xf050fe93u, /* 91 */
178  0x8943acc4u, /* 92 */
179  0x5f655680u, /* 93 */
180  0x0000001du, /* 94 */
181  0x6329f1c3u, /* 95 */
182  0x5ca4bfabu, /* 96 */
183  0xb9f56100u, /* 97 */
184  0x00000125u, /* 98 */
185  0xdfa371a1u, /* 99 */
186  0x9e6f7cb5u, /* 100 */
187  0x4395ca00u, /* 101 */
188  0x00000b7au, /* 102 */
189  0xbc627050u, /* 103 */
190  0x305adf14u, /* 104 */
191  0xa3d9e400u, /* 105 */
192  0x000072cbu, /* 106 */
193  0x5bd86321u, /* 107 */
194  0xe38cb6ceu, /* 108 */
195  0x6682e800u, /* 109 */
196  0x00047bf1u, /* 110 */
197  0x9673df52u, /* 111 */
198  0xe37f2410u, /* 112 */
199  0x011d1000u, /* 113 */
200  0x002cd76fu, /* 114 */
201  0xe086b93cu, /* 115 */
202  0xe2f768a0u, /* 116 */
203  0x0b22a000u, /* 117 */
204  0x01c06a5eu, /* 118 */
205  0xc5433c60u, /* 119 */
206  0xddaa1640u, /* 120 */
207  0x6f5a4000u, /* 121 */
208  0x118427b3u, /* 122 */
209  0xb4a05bc8u, /* 123 */
210  0xa8a4de84u, /* 124 */
211  0x59868000u, /* 125 */
212  0xaf298d05u, /* 126 */
213  0x0e4395d6u, /* 127 */
214  0x9670b12bu, /* 128 */
215  0x7f410000u, /* 129 */
216  0x00000006u, /* 130 */
217  0xd79f8232u, /* 131 */
218  0x8ea3da61u, /* 132 */
219  0xe066ebb2u, /* 133 */
220  0xf88a0000u, /* 134 */
221  0x00000044u, /* 135 */
222  0x6c3b15f9u, /* 136 */
223  0x926687d2u, /* 137 */
224  0xc40534fdu, /* 138 */
225  0xb5640000u, /* 139 */
226  0x000002acu, /* 140 */
227  0x3a4edbbfu, /* 141 */
228  0xb8014e3bu, /* 142 */
229  0xa83411e9u, /* 143 */
230  0x15e80000u, /* 144 */
231  0x00001abau, /* 145 */
232  0x4714957du, /* 146 */
233  0x300d0e54u, /* 147 */
234  0x9208b31au, /* 148 */
235  0xdb100000u, /* 149 */
236  0x00010b46u, /* 150 */
237  0xc6cdd6e3u, /* 151 */
238  0xe0828f4du, /* 152 */
239  0xb456ff0cu, /* 153 */
240  0x8ea00000u, /* 154 */
241  0x000a70c3u, /* 155 */
242  0xc40a64e6u, /* 156 */
243  0xc5199909u, /* 157 */
244  0x0b65f67du, /* 158 */
245  0x92400000u, /* 159 */
246  0x006867a5u, /* 160 */
247  0xa867f103u, /* 161 */
248  0xb2fffa5au, /* 162 */
249  0x71fba0e7u, /* 163 */
250  0xb6800000u, /* 164 */
251  0x04140c78u, /* 165 */
252  0x940f6a24u, /* 166 */
253  0xfdffc788u, /* 167 */
254  0x73d4490du, /* 168 */
255  0x21000000u, /* 169 */
256  0x28c87cb5u, /* 170 */
257  0xc89a2571u, /* 171 */
258  0xebfdcb54u, /* 172 */
259  0x864ada83u, /* 173 */
260  0x4a000000u, /* 174 */
261  0x00000001u, /* 175 */
262  0x97d4df19u, /* 176 */
263  0xd6057673u, /* 177 */
264  0x37e9f14du, /* 178 */
265  0x3eec8920u, /* 179 */
266  0xe4000000u, /* 180 */
267  0x0000000fu, /* 181 */
268  0xee50b702u, /* 182 */
269  0x5c36a080u, /* 183 */
270  0x2f236d04u, /* 184 */
271  0x753d5b48u, /* 185 */
272  0xe8000000u, /* 186 */
273  0x0000009fu, /* 187 */
274  0x4f272617u, /* 188 */
275  0x9a224501u, /* 189 */
276  0xd762422cu, /* 190 */
277  0x946590d9u, /* 191 */
278  0x10000000u, /* 192 */
279  0x00000639u, /* 193 */
280  0x17877cecu, /* 194 */
281  0x0556b212u, /* 195 */
282  0x69d695bdu, /* 196 */
283  0xcbf7a87au, /* 197 */
284  0xa0000000u, /* 198 */
285  0x00003e3au, /* 199 */
286  0xeb4ae138u, /* 200 */
287  0x3562f4b8u, /* 201 */
288  0x2261d969u, /* 202 */
289  0xf7ac94cau, /* 203 */
290  0x40000000u, /* 204 */
291  0x00026e4du, /* 205 */
292  0x30eccc32u, /* 206 */
293  0x15dd8f31u, /* 207 */
294  0x57d27e23u, /* 208 */
295  0xacbdcfe6u, /* 209 */
296  0x80000000u, /* 210 */
297  0x00184f03u, /* 211 */
298  0xe93ff9f4u, /* 212 */
299  0xdaa797edu, /* 213 */
300  0x6e38ed64u, /* 214 */
301  0xbf6a1f01u, /* 215 */
302  0x00f31627u, /* 216 */
303  0x1c7fc390u, /* 217 */
304  0x8a8bef46u, /* 218 */
305  0x4e3945efu, /* 219 */
306  0x7a25360au, /* 220 */
307  0x097edd87u, /* 221 */
308  0x1cfda3a5u, /* 222 */
309  0x697758bfu, /* 223 */
310  0x0e3cbb5au, /* 224 */
311  0xc5741c64u, /* 225 */
312  0x5ef4a747u, /* 226 */
313  0x21e86476u, /* 227 */
314  0x1ea97776u, /* 228 */
315  0x8e5f518bu, /* 229 */
316  0xb6891be8u, /* 230 */
317  0x00000003u, /* 231 */
318  0xb58e88c7u, /* 232 */
319  0x5313ec9du, /* 233 */
320  0x329eaaa1u, /* 234 */
321  0x8fb92f75u, /* 235 */
322  0x215b1710u, /* 236 */
323  0x00000025u, /* 237 */
324  0x179157c9u, /* 238 */
325  0x3ec73e23u, /* 239 */
326  0xfa32aa4fu, /* 240 */
327  0x9d3bda93u, /* 241 */
328  0x4d8ee6a0u, /* 242 */
329  0x00000172u, /* 243 */
330  0xebad6ddcu, /* 244 */
331  0x73c86d67u, /* 245 */
332  0xc5faa71cu, /* 246 */
333  0x245689c1u, /* 247 */
334  0x07950240u, /* 248 */
335  0x00000e7du, /* 249 */
336  0x34c64a9cu, /* 250 */
337  0x85d4460du, /* 251 */
338  0xbbca8719u, /* 252 */
339  0x6b61618au, /* 253 */
340  0x4bd21680u, /* 254 */
341  0x000090e4u, /* 255 */
342  0x0fbeea1du, /* 256 */
343  0x3a4abc89u, /* 257 */
344  0x55e946feu, /* 258 */
345  0x31cdcf66u, /* 259 */
346  0xf634e100u, /* 260 */
347  0x0005a8e8u, /* 261 */
348  0x9d752524u, /* 262 */
349  0x46eb5d5du, /* 263 */
350  0x5b1cc5edu, /* 264 */
351  0xf20a1a05u, /* 265 */
352  0x9e10ca00u, /* 266 */
353  0x00389916u, /* 267 */
354  0x2693736au, /* 268 */
355  0xc531a5a5u, /* 269 */
356  0x8f1fbb4bu, /* 270 */
357  0x74650438u, /* 271 */
358  0x2ca7e400u, /* 272 */
359  0x0235faddu, /* 273 */
360  0x81c2822bu, /* 274 */
361  0xb3f07877u, /* 275 */
362  0x973d50f2u, /* 276 */
363  0x8bf22a31u, /* 277 */
364  0xbe8ee800u, /* 278 */
365  0x161bcca7u, /* 279 */
366  0x119915b5u, /* 280 */
367  0x0764b4abu, /* 281 */
368  0xe8652979u, /* 282 */
369  0x7775a5f1u, /* 283 */
370  0x71951000u, /* 284 */
371  0xdd15fe86u, /* 285 */
372  0xaffad912u, /* 286 */
373  0x49ef0eb7u, /* 287 */
374  0x13f39ebeu, /* 288 */
375  0xaa987b6eu, /* 289 */
376  0x6fd2a000u, /* 290 */
377 };
freetds-1.00.82/doc/reference/a00311.html100644 025423 025423 00000027346 13242511136 0013236 FreeTDS API: src/tds/read.c File Reference
FreeTDS API
read.c File Reference

Grab data from TDS packets. More...

#include <config.h>
#include <assert.h>
#include <freetds/tds.h>
#include <freetds/iconv.h>
#include <freetds/bytes.h>
#include <freetds/stream.h>
#include <freetds/string.h>
#include <freetds/checks.h>
Include dependency graph for read.c:

Functions

static size_t read_and_convert (TDSSOCKET *tds, TDSICONV *char_conv, size_t *wire_size, char *outbuf, size_t outbytesleft)
 For UTF-8 and similar, tds_iconv() may encounter a partial sequence when the chunk boundary is not aligned with the character boundary. More...
 
DSTRtds_dstr_get (TDSSOCKET *tds, DSTR *s, size_t len)
 Reads a string from wire and put in a DSTR. More...
 
unsigned char tds_get_byte (TDSSOCKET *tds)
 Return a single byte from the input buffer. More...
 
TDSRET tds_get_char_data (TDSSOCKET *tds, char *row_buffer, size_t wire_size, TDSCOLUMN *curcol)
 Fetch character data the wire. More...
 
void * tds_get_n (TDSSOCKET *tds, void *dest, size_t need)
 Get N bytes from the buffer and return them in the already allocated space given to us. More...
 
size_t tds_get_string (TDSSOCKET *tds, size_t string_len, char *dest, size_t dest_size)
 Fetch a string from the wire. More...
 
TDS_UINT tds_get_uint (TDSSOCKET *tds)
 Get an int32 from the server. More...
 
TDS_UINT8 tds_get_uint8 (TDSSOCKET *tds)
 Get an uint64 from the server. More...
 
TDS_USMALLINT tds_get_usmallint (TDSSOCKET *tds)
 Get an int16 from the server.
 
unsigned char tds_peek (TDSSOCKET *tds)
 Reads a byte from the TDS stream without removing it. More...
 
void tds_unget_byte (TDSSOCKET *tds)
 Unget will always work as long as you don't call it twice in a row. More...
 

Detailed Description

Grab data from TDS packets.

freetds-1.00.82/doc/reference/a00312.map100644 025423 025423 00000004371 13242511134 0013037 freetds-1.00.82/doc/reference/a00312.md5100644 025423 025423 00000000040 13242511133 0012733a7d428f2acbe7187c0203b7b227d4116freetds-1.00.82/doc/reference/a00312.svg100644 025423 025423 00000060742 13242511136 0013067 src/tds/read.c Node0 src/tds/read.c Node1 config.h Node0->Node1 Node2 assert.h Node0->Node2 Node3 freetds/tds.h Node0->Node3 Node18 freetds/iconv.h Node0->Node18 Node19 freetds/bytes.h Node0->Node19 Node20 freetds/stream.h Node0->Node20 Node21 freetds/string.h Node0->Node21 Node22 freetds/checks.h Node0->Node22 Node4 stdarg.h Node3->Node4 Node5 stdio.h Node3->Node5 Node6 time.h Node3->Node6 Node7 freetds/version.h Node3->Node7 Node8 tds_sysdep_public.h Node3->Node8 Node9 freetds/sysdep_private.h Node3->Node9 Node10 freetds/thread.h Node3->Node10 Node11 freetds/bool.h Node3->Node11 Node12 replacements.h Node3->Node12 Node14 freetds/pushvis.h Node3->Node14 Node15 freetds/popvis.h Node3->Node15 Node17 freetds/proto.h Node3->Node17 Node6->Node6 Node12->Node4 Node12->Node8 Node12->Node9 Node13 replacements/readpassphrase.h Node12->Node13 Node12->Node14 Node12->Node15 Node16 replacements/poll.h Node12->Node16 Node13->Node14 Node13->Node15 Node16->Node1 Node16->Node14 Node16->Node15 Node18->Node14 Node18->Node15 Node20->Node14 Node20->Node15 Node21->Node14 Node21->Node15 Node22->Node14 Node22->Node15 freetds-1.00.82/doc/reference/doc.png100644 025423 025423 00000001352 13242511136 0013003‰PNG  IHDRÚ}\ˆ±IDATxíMOS[…Ÿžsúa?-XZ(PD4‚ AWbu`b 77wäHFÆCËÔÂÿà/`vo„ˆAPòq‹P @ ­ûÝè980 îà¤+»§Ýy×^ïZï9SW¹\83g‰3'°Nâçl¹¸_b¯p ïåûÆVÜÖ¡€Ÿ×"¬Ö†X€d]Ðà3“ÉÃÄÌ™xŸ ßMàœ[<çSPkvc—hÈ'…™˜^Åm™hØ7 `Û™¦ èÀåráq›‘œ¾!daeKŸþÆÕ˜:Ì*³_דâèi?I–eP*B7Ÿ¿åô!¹Ýgr6Ër6oKbëþãðôrI”ËTˆüªŒ¨xóö=›ù¢&‰(e+ßóÄkýÇ`ëÁÜb.“¸ÐW×w0¥°jÑzN™¬|©WEãµ¢a¯6[öX†AkÓù*/œ¨‰€ÉY­ ÿV’§–u²jÂ>1W *½·°PGŽzÿ¨/Eg{ ŸÇâaoŠÁVú:è¿™¤1$ôR§W,–ªà¨@ŠË56¾ÀÔÜ-¾,mê¸Î/æè¹– òr5¥T*S(Vf8ö9u’ Õ£w›ùóa=Í<{Ò¡UŒ÷r¯+ÉådDÏF$è°…£é¿`zþ»ÎúöN‘µÜ®0Q3£~_^Ëóâ¯N=ˆvpTà±LžT}ˆîkq†Òm<¼ÎÓ?Zh¿X£ï_þÝ¥[)ƒ `gêÃa_Ô*äÔ2`'=õ´Fÿ2EâÁPú ÷»›l=8‹Wv°%THqÉ¿<"¤ïG¾ÆxH{#ÆÖ«aÔJÕÞ‡—m‹„ çñKsÿàñVŠØ¡°·MâÒ^ TÁ– Ý›r¥ß½ømüÿ_™?ªWİ÷#uIEND®B`‚freetds-1.00.82/doc/reference/a00344.html100644 025423 025423 00000115637 13242511136 0013245 FreeTDS API: src/tds/token.c File Reference
FreeTDS API
token.c File Reference

Contains all routines to get replies from server. More...

#include <config.h>
#include <assert.h>
#include <freetds/tds.h>
#include <freetds/string.h>
#include <freetds/convert.h>
#include <freetds/iconv.h>
#include <freetds/checks.h>
#include <freetds/bytes.h>
#include <freetds/alloca.h>
#include "replacements.h"
Include dependency graph for token.c:

Classes

struct  namelist
 Holds list of names. More...
 

Functions

static void adjust_character_column_size (TDSSOCKET *tds, TDSCOLUMN *curcol)
 Adjust column size according to client's encoding. More...
 
int determine_adjusted_size (const TDSICONV *char_conv, int size)
 Allow for maximum possible size of converted data, while being careful about integer division truncation. More...
 
static TDSRET tds5_process_dyn_result2 (TDSSOCKET *tds)
 Process new TDS 5.0 token for describing output parameters. More...
 
static TDSRET tds5_process_optioncmd (TDSSOCKET *tds)
 Process option cmd results. More...
 
static TDSRET tds5_process_result (TDSSOCKET *tds)
 tds5_process_result() is the TDS 5.0 result set processing routine. More...
 
static TDSRET tds5_process_result2 (TDSSOCKET *tds)
 tds5_process_result2() is the new TDS 5.0 result set processing routine. More...
 
static int tds71_read_table_names (TDSSOCKET *tds, int remainder, struct namelist **p_head)
 Reads table names for TDS 7.1+. More...
 
static TDSRET tds7_get_data_info (TDSSOCKET *tds, TDSCOLUMN *curcol)
 Reads data information from wire. More...
 
static TDSRET tds7_process_compute_result (TDSSOCKET *tds)
 tds7_process_compute_result() processes compute result sets for TDS 7/8. More...
 
static TDSRET tds7_process_result (TDSSOCKET *tds)
 tds7_process_result() is the TDS 7.0 result set processing routine. More...
 
static int tds_alloc_get_string (TDSSOCKET *tds, char **string, size_t len)
 Reads a string from wire in a new allocated buffer. More...
 
static void tds_free_namelist (struct namelist *head)
 Frees list of names. More...
 
static TDSRET tds_get_data_info (TDSSOCKET *tds, TDSCOLUMN *curcol, int is_param)
 Reads data metadata from wire. More...
 
int tds_get_token_size (int marker)
 tds_get_token_size() returns the size of a fixed length token used by tds_process_cancel() to determine how to read past a token More...
 
TDSDYNAMICtds_lookup_dynamic (TDSCONNECTION *conn, const char *id)
 Finds a dynamic given string id. More...
 
static const char * tds_pr_op (int op)
 Returns string representation for a given operation. More...
 
static TDSRET tds_process_auth (TDSSOCKET *tds)
 Process authentication token. More...
 
TDSRET tds_process_cancel (TDSSOCKET *tds)
 
static TDSRET tds_process_col_fmt (TDSSOCKET *tds)
 tds_process_col_fmt() is the other half of result set processing under TDS 4.2. More...
 
static TDSRET tds_process_col_name (TDSSOCKET *tds)
 tds_process_col_name() is one half of the result set under TDS 4.2 it contains all the column names, a TDS_COLFMT_TOKEN should immediately follow this token with the datatype/size information This is a 4.2 only function More...
 
static TDSRET tds_process_colinfo (TDSSOCKET *tds, char **names, int num_names)
 Reads column information. More...
 
static TDSRET tds_process_compute (TDSSOCKET *tds)
 tds_process_compute() processes compute rows and places them in the row buffer. More...
 
static TDSRET tds_process_compute_names (TDSSOCKET *tds)
 tds_process_compute_names() processes compute result sets. More...
 
static TDSRET tds_process_compute_result (TDSSOCKET *tds)
 tds_process_compute_result() processes compute result sets. More...
 
static TDSRET tds_process_cursor_tokens (TDSSOCKET *tds)
 Reads cursor command results. More...
 
static TDSRET tds_process_default_tokens (TDSSOCKET *tds, int marker)
 tds_process_default_tokens() is a catch all function that is called to process tokens not known to other tds_process_* routines More...
 
static TDSRET tds_process_dyn_result (TDSSOCKET *tds)
 Process results from dynamic. More...
 
static TDSDYNAMICtds_process_dynamic (TDSSOCKET *tds)
 tds_process_dynamic() finds the element of the dyns array for the id More...
 
static TDSRET tds_process_end (TDSSOCKET *tds, int marker, int *flags_parm)
 tds_process_end() processes any of the DONE, DONEPROC, or DONEINPROC tokens. More...
 
static TDSRET tds_process_env_chg (TDSSOCKET *tds)
 tds_process_env_chg() when ever certain things change on the server, such as database, character set, language, or block size. More...
 
static TDSRET tds_process_env_routing (TDSSOCKET *tds)
 
static TDSRET tds_process_featureextack (TDSSOCKET *tds)
 
static TDSRET tds_process_info (TDSSOCKET *tds, int marker)
 tds_process_info() is called for INFO, ERR, or EED tokens and is responsible for calling the CLI's message handling routine More...
 
TDSRET tds_process_login_tokens (TDSSOCKET *tds)
 tds_process_login_tokens() is called after sending the login packet to the server. More...
 
static TDSRET tds_process_nbcrow (TDSSOCKET *tds)
 tds_process_nbcrow() processes rows and places them in the row buffer.
 
static TDSRET tds_process_param_result (TDSSOCKET *tds, TDSPARAMINFO **pinfo)
 process output parameters of a stored procedure. More...
 
static TDSRET tds_process_param_result_tokens (TDSSOCKET *tds)
 Process parameters from networks. More...
 
static TDSRET tds_process_params_result_token (TDSSOCKET *tds)
 tds_process_params_result_token() processes params on TDS5. More...
 
static void tds_process_pending_closes (TDSSOCKET *tds)
 Attempt to close all deferred closes (dynamics and cursors). More...
 
static TDSRET tds_process_row (TDSSOCKET *tds)
 tds_process_row() processes rows and places them in the row buffer. More...
 
TDSRET tds_process_simple_query (TDSSOCKET *tds)
 Process results for simple query as "SET TEXTSIZE" or "USE dbname" If the statement returns results, beware they are discarded. More...
 
static TDSRET tds_process_tabname (TDSSOCKET *tds)
 Process list of table from network. More...
 
TDSRET tds_process_tokens (TDSSOCKET *tds, TDS_INT *result_type, int *done_flags, unsigned flag)
 process all streams. More...
 
const char * tds_prtype (int type)
 Returns string representation of the given type. More...
 
static int tds_read_namelist (TDSSOCKET *tds, int remainder, struct namelist **p_head, int large)
 Reads list of names (usually table names) More...
 
static const char * tds_token_name (unsigned char marker)
 Returns string representation for a given token type. More...
 

Detailed Description

Contains all routines to get replies from server.

freetds-1.00.82/doc/reference/a00317_source.html100644 025423 025423 00000145417 13242511133 0014621 FreeTDS API: src/tds/sec_negotiate_gnutls.h Source File
FreeTDS API
sec_negotiate_gnutls.h
1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2  * Copyright (C) 2015 Frediano Ziglio
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 
20 #include <gnutls/gnutls.h>
21 #include <gnutls/crypto.h>
22 #ifdef HAVE_GNUTLS_ABSTRACT_H
23 # include <gnutls/abstract.h>
24 #endif
25 
26 #if !defined(HAVE_NETTLE) || !defined(HAVE_GMP) || !defined(HAVE_GNUTLS_RND)
27 # include <gcrypt.h>
28 #endif
29 
30 #ifndef HAVE_NETTLE
31 # include <libtasn1.h>
32 #endif
33 
34 #ifdef HAVE_NETTLE
35 # include <nettle/asn1.h>
36 # include <nettle/rsa.h>
37 # include <nettle/bignum.h>
38 #endif
39 
51 #ifndef HAVE_GNUTLS
52 #error HAVE_GNUTLS not defines, this file should not be included
53 #endif
54 
55 /* emulate GMP if not present */
56 #ifndef HAVE_GMP
57 #define HAVE_GMP 1
58 
59 typedef struct {
60  gcry_mpi_t num;
61 } mpz_t[1];
62 
63 #define mpz_powm(w,n,e,m) \
64  gcry_mpi_powm((w)->num, (n)->num, (e)->num, (m)->num);
65 #define mpz_init(n) do { (n)->num = NULL; } while(0)
66 #define mpz_clear(n) gcry_mpi_release((n)->num)
67 
68 #endif
69 
70 
71 /* emulate Nettle is not present */
72 #ifndef HAVE_NETTLE
73 #define HAVE_NETTLE 1
74 
75 typedef void nettle_random_func(void *ctx, size_t len, uint8_t *out);
76 
77 static inline void
78 nettle_mpz_set_str_256_u(mpz_t x, unsigned length, const uint8_t *s)
79 {
80  gcry_mpi_scan(&x->num, GCRYMPI_FMT_USG, s, length, NULL);
81 }
82 
83 static inline void
84 nettle_mpz_get_str_256(unsigned length, uint8_t *s, const mpz_t x)
85 {
86  gcry_mpi_print(GCRYMPI_FMT_USG, s, length, NULL, x->num);
87 }
88 
90  const unsigned char *data, *data_end;
91  unsigned long length;
92  unsigned long type;
93 };
94 
95 enum asn1_iterator_result {
96  ASN1_ITERATOR_ERROR,
97  ASN1_ITERATOR_PRIMITIVE,
98  ASN1_ITERATOR_CONSTRUCTED,
99  ASN1_ITERATOR_END,
100 };
101 
102 enum {
103  ASN1_SEQUENCE = ASN1_TAG_SEQUENCE,
104 };
105 
106 static enum asn1_iterator_result
107 asn1_der_iterator_next(struct asn1_der_iterator *der)
108 {
109  unsigned char cls;
110  unsigned long tag;
111  int len;
112  long l;
113 
114  if (asn1_get_tag_der(der->data, der->data_end - der->data, &cls, &len, &tag) != ASN1_SUCCESS)
115  return ASN1_ITERATOR_ERROR;
116  der->type = tag;
117  der->data += len;
118  l = asn1_get_length_der(der->data, der->data_end - der->data, &len);
119  if (l < 0)
120  return ASN1_ITERATOR_ERROR;
121  der->data += len;
122  der->length = l;
123  if (cls == ASN1_CLASS_STRUCTURED)
124  return ASN1_ITERATOR_CONSTRUCTED;
125  return ASN1_ITERATOR_PRIMITIVE;
126 }
127 
128 static enum asn1_iterator_result
129 asn1_der_iterator_first(struct asn1_der_iterator *der, int size, const void *der_buf)
130 {
131  der->data = (const unsigned char *) der_buf;
132  der->data_end = der->data + size;
133 
134  return asn1_der_iterator_next(der);
135 }
136 
138  unsigned size;
139  mpz_t n, e;
140 };
141 
142 static void
143 rsa_public_key_init(struct rsa_public_key *key)
144 {
145  key->size = 0;
146  mpz_init(key->n);
147  mpz_init(key->e);
148 }
149 
150 static void
151 rsa_public_key_clear(struct rsa_public_key *key)
152 {
153  mpz_clear(key->n);
154  mpz_clear(key->e);
155 }
156 
157 static int
158 rsa_public_key_from_der_iterator(struct rsa_public_key *key, unsigned key_bits, struct asn1_der_iterator *der)
159 {
160  enum asn1_iterator_result ret;
161 
162  ret = asn1_der_iterator_next(der);
163  if (ret != ASN1_ITERATOR_PRIMITIVE || der->type != ASN1_TAG_INTEGER)
164  return 0;
165  gcry_mpi_scan(&key->n->num, GCRYMPI_FMT_USG, der->data, der->length, NULL);
166  key->size = (gcry_mpi_get_nbits(key->n->num)+7)/8;
167  der->data += der->length;
168 
169  ret = asn1_der_iterator_next(der);
170  if (ret != ASN1_ITERATOR_PRIMITIVE || der->type != ASN1_TAG_INTEGER)
171  return 0;
172  gcry_mpi_scan(&key->e->num, GCRYMPI_FMT_USG, der->data, der->length, NULL);
173 
174  return 1;
175 }
176 
177 static void
178 sha1(uint8_t *hash, const void *data, size_t len)
179 {
180  gcry_md_hash_buffer(GCRY_MD_SHA1, hash, data, len);
181 }
182 #else
183 static void
184 sha1(uint8_t *hash, const void *data, size_t len)
185 {
186  struct sha1_ctx ctx;
187  sha1_init(&ctx);
188  sha1_update(&ctx, len, (const uint8_t *) data);
189  sha1_digest(&ctx, 20, hash);
190 }
191 #endif
192 
193 
194 static void
195 rnd_func(void *ctx, size_t len, uint8_t * out)
196 {
197  tds_random_buffer(out, len);
198 }
199 
200 #define dumpl(b,l) tdsdump_dump_buf(TDS_DBG_INFO1, #b, b, l)
201 #ifndef dumpl
202 #define dumpl(b,l) do {} while(0)
203 #endif
204 #define dump(b) dumpl(b, sizeof(b))
205 
206 /* OAEP configuration parameters */
207 #define hash_func sha1
208 enum { hash_len = 20 }; /* sha1 length */
209 enum { key_size_max = 1024 }; /* max key in bytes */
210 static const char label[] = "";
211 
212 static void
213 memxor(uint8_t *dest, const uint8_t *src, size_t len)
214 {
215  size_t n;
216  for (n = 0; n < len; ++n)
217  dest[n] = dest[n] ^ src[n];
218 }
219 
220 static void
221 mgf_mask(uint8_t *dest, size_t dest_len, const uint8_t *mask, size_t mask_len)
222 {
223  unsigned n = 0;
224  uint8_t hash[hash_len];
225  uint8_t seed[mask_len + 4];
226 
227  memcpy(seed, mask, mask_len);
228  /* we always have some data and check is done internally */
229  for (;;) {
230  TDS_PUT_UA4BE(seed+mask_len, n);
231 
232  hash_func(hash, seed, sizeof(seed));
233  if (dest_len <= hash_len) {
234  memxor(dest, hash, dest_len);
235  break;
236  }
237 
238  memxor(dest, hash, hash_len);
239  dest += hash_len;
240  dest_len -= hash_len;
241  ++n;
242  }
243 }
244 
245 static int
246 oaep_encrypt(size_t key_size, void *random_ctx, nettle_random_func *random,
247  size_t length, const uint8_t *message, mpz_t m)
248 {
249  /* EM: 0x00 ROS (HASH 0x00.. 0x01 message) */
250  struct {
251  uint8_t all[1]; /* zero but used to access all data */
252  uint8_t ros[hash_len];
253  uint8_t db[key_size_max - hash_len - 1];
254  } em;
255  const unsigned db_len = key_size - hash_len - 1;
256 
257  if (length + hash_len * 2 + 2 > key_size)
258  /* Message too long for this key. */
259  return 0;
260 
261  /* create db */
262  memset(&em, 0, sizeof(em));
263  hash_func(em.db, label, strlen(label));
264  em.all[key_size - length - 1] = 0x1;
265  memcpy(em.all+(key_size - length), message, length);
266  dumpl(em.db, db_len);
267 
268  /* create ros */
269  random(random_ctx, hash_len, em.ros);
270  dump(em.ros);
271 
272  /* mask db */
273  mgf_mask(em.db, db_len, em.ros, hash_len);
274  dumpl(em.db, db_len);
275 
276  /* mask ros */
277  mgf_mask(em.ros, hash_len, em.db, db_len);
278  dump(em.ros);
279 
280  nettle_mpz_set_str_256_u(m, key_size, em.all);
281 
282  return 1;
283 }
284 
285 static int
286 rsa_encrypt_oaep(const struct rsa_public_key *key, void *random_ctx, nettle_random_func *random,
287  size_t length, const uint8_t *message, mpz_t gibberish)
288 {
289  if (!oaep_encrypt(key->size, random_ctx, random, length, message, gibberish))
290  return 0;
291 
292  mpz_powm(gibberish, gibberish, key->e, key->n);
293  return 1;
294 }
295 
296 static void*
297 tds5_rsa_encrypt(const void *key, size_t key_len, const void *nonce, size_t nonce_len, const char *pwd, size_t *em_size)
298 {
299  int ret;
300  mpz_t p;
301  gnutls_datum_t pubkey_datum = { (unsigned char *) key, key_len };
302  struct asn1_der_iterator der;
303  struct rsa_public_key pubkey;
304  uint8_t *message;
305  size_t message_len, pwd_len;
306  uint8_t *em = NULL;
307  unsigned char der_buf[2048];
308  size_t size = sizeof(der_buf);
309 
310  mpz_init(p);
311  rsa_public_key_init(&pubkey);
312 
313  pwd_len = strlen(pwd);
314  message_len = nonce_len + pwd_len;
315  message = tds_new(uint8_t, message_len);
316  if (!message)
317  return NULL;
318  memcpy(message, nonce, nonce_len);
319  memcpy(message + nonce_len, pwd, pwd_len);
320 
321  /* use nettle directly */
322  /* parse PEM, get DER */
323  ret = gnutls_pem_base64_decode("RSA PUBLIC KEY", &pubkey_datum, der_buf, &size);
324  if (ret) {
325  tdsdump_log(TDS_DBG_ERROR, "Error %d decoding public key: %s\n", ret, gnutls_strerror(ret));
326  goto error;
327  }
328 
329  /* get key with nettle using DER */
330  ret = asn1_der_iterator_first(&der, size, der_buf);
331  if (ret != ASN1_ITERATOR_CONSTRUCTED || der.type != ASN1_SEQUENCE) {
332  tdsdump_log(TDS_DBG_ERROR, "Invalid DER content\n");
333  goto error;
334  }
335 
336  ret = rsa_public_key_from_der_iterator(&pubkey, key_size_max * 8, &der);
337  if (!ret) {
338  tdsdump_log(TDS_DBG_ERROR, "Invalid DER content\n");
339  goto error;
340  }
341 
342  /* get password encrypted */
343  ret = rsa_encrypt_oaep(&pubkey, NULL, rnd_func, message_len, message, p);
344  if (!ret) {
345  tdsdump_log(TDS_DBG_ERROR, "Error encrypting message\n");
346  goto error;
347  }
348 
349  em = tds_new(uint8_t, pubkey.size);
350  *em_size = pubkey.size;
351  if (!em)
352  goto error;
353 
354  nettle_mpz_get_str_256(pubkey.size, em, p);
355 
356  tdsdump_dump_buf(TDS_DBG_INFO1, "em", em, pubkey.size);
357 
358 error:
359  free(message);
360  rsa_public_key_clear(&pubkey);
361  mpz_clear(p);
362  return em;
363 }
364 
Definition: sec_negotiate_gnutls.h:89
Definition: sec_negotiate_gnutls.h:59
void tdsdump_log(const char *file, unsigned int level_line, const char *fmt,...)
Write a message to the debug log.
Definition: log.c:353
Definition: sec_negotiate_gnutls.h:137
void tdsdump_dump_buf(const char *file, unsigned int level_line, const char *msg, const void *buf, size_t length)
Dump the contents of data into the log file in a human readable format.
Definition: log.c:255
freetds-1.00.82/doc/reference/a00320_source.html100644 025423 025423 00000034712 13242511133 0014606 FreeTDS API: src/tds/sec_negotiate_openssl.h Source File
FreeTDS API
sec_negotiate_openssl.h
1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2  * Copyright (C) 2015 Frediano Ziglio
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 
20 #include <openssl/rand.h>
21 #include <openssl/bio.h>
22 #include <openssl/pem.h>
23 #include <openssl/err.h>
24 
36 #ifndef HAVE_OPENSSL
37 #error HAVE_OPENSSL not defines, this file should not be included
38 #endif
39 
40 static inline const BIGNUM*
41 rsa_get_n(const RSA *rsa)
42 {
43 #if OPENSSL_VERSION_NUMBER >= 0x1010000FL
44  const BIGNUM *n, *e, *d;
45  RSA_get0_key(rsa, &n, &e, &d);
46  return n;
47 #else
48  return rsa->n;
49 #endif
50 }
51 
52 static void*
53 tds5_rsa_encrypt(const void *key, size_t key_len, const void *nonce, size_t nonce_len, const char *pwd, size_t *em_size)
54 {
55  RSA *rsa = NULL;
56  BIO *keybio;
57 
58  TDS_UCHAR *message = NULL;
59  size_t message_len, pwd_len;
60  TDS_UCHAR *em = NULL;
61 
62  int result;
63 
64  keybio = BIO_new_mem_buf((void*) key, key_len);
65  if (keybio == NULL)
66  goto error;
67 
68  rsa = PEM_read_bio_RSAPublicKey(keybio, &rsa, NULL, NULL);
69  if (!rsa)
70  goto error;
71 
72  pwd_len = strlen(pwd);
73  message_len = nonce_len + pwd_len;
74  message = tds_new(TDS_UCHAR, message_len);
75  if (!message)
76  goto error;
77  memcpy(message, nonce, nonce_len);
78  memcpy(message + nonce_len, pwd, pwd_len);
79 
80  em = tds_new(TDS_UCHAR, BN_num_bytes(rsa_get_n(rsa)));
81  if (!em)
82  goto error;
83 
84  result = RSA_public_encrypt(message_len, message, em, rsa, RSA_PKCS1_OAEP_PADDING);
85  if (result < 0)
86  goto error;
87 
88  free(message);
89  RSA_free(rsa);
90  BIO_free(keybio);
91 
92  *em_size = result;
93  return em;
94 
95 error:
96  free(message);
97  free(em);
98  RSA_free(rsa);
99  BIO_free(keybio);
100  return NULL;
101 }
102 
freetds-1.00.82/doc/reference/a00329_source.html100644 025423 025423 00000501711 13242511133 0014615 FreeTDS API: src/tds/tds_types.h Source File
FreeTDS API
tds_types.h
1 /*
2  * This file produced from ./types.pl
3  */
4 
8 int
9 tds_get_size_by_type(TDS_SERVER_TYPE servertype)
10 {
11  switch (servertype) {
12  case SYBVOID:
13  return 0;
14  case SYBBIT:
15  case SYBBITN:
16  case SYBINT1:
17  case SYBSINT1:
18  case SYBUINT1:
19  return 1;
20  case SYBINT2:
21  case SYBUINT2:
22  return 2;
23  case SYBMSDATE:
24  return 3;
25  case SYBDATE:
26  case SYBDATEN:
27  case SYBDATETIME4:
28  case SYBINT4:
29  case SYBMONEY4:
30  case SYBREAL:
31  case SYBTIME:
32  case SYBTIMEN:
33  case SYBUINT4:
34  return 4;
35  case SYB5BIGDATETIME:
36  case SYB5BIGTIME:
37  case SYB5INT8:
38  case SYBDATETIME:
39  case SYBFLT8:
40  case SYBINT8:
41  case SYBINTERVAL:
42  case SYBMONEY:
43  case SYBUINT8:
44  return 8;
45  case SYBUNIQUE:
46  return 16;
47  default:
48  return 0;
49  }
50 }
51 
56 int
57 tds_get_varint_size(TDSCONNECTION * conn, int datatype)
58 {
59  switch (datatype) {
60  case SYBBIT:
61  case SYBDATETIME:
62  case SYBDATETIME4:
63  case SYBFLT8:
64  case SYBINT1:
65  case SYBINT2:
66  case SYBINT4:
67  case SYBMONEY:
68  case SYBMONEY4:
69  case SYBREAL:
70  case SYBVOID:
71  return 0;
72  case SYBIMAGE:
73  case SYBTEXT:
74  return 4;
75  }
76 
77  if (IS_TDS7_PLUS(conn)) {
78  switch (datatype) {
79  case SYBINT8:
80  return 0;
81  case XSYBBINARY:
82  case XSYBCHAR:
83  case XSYBNCHAR:
84  case XSYBNVARCHAR:
85  case XSYBVARBINARY:
86  case XSYBVARCHAR:
87  return 2;
88  case SYBNTEXT:
89  case SYBVARIANT:
90  return 4;
91  case SYBMSUDT:
92  case SYBMSXML:
93  return 8;
94  }
95  } else if (IS_TDS50(conn)) {
96  switch (datatype) {
97  case SYB5INT8:
98  case SYBDATE:
99  case SYBINTERVAL:
100  case SYBSINT1:
101  case SYBTIME:
102  case SYBUINT1:
103  case SYBUINT2:
104  case SYBUINT4:
105  case SYBUINT8:
106  return 0;
107  case SYBUNITEXT:
108  case SYBXML:
109  return 4;
110  case SYBLONGBINARY:
111  case SYBLONGCHAR:
112  return 5;
113  }
114  }
115  return 1;
116 }
117 
124 TDS_SERVER_TYPE
125 tds_get_conversion_type(TDS_SERVER_TYPE srctype, int colsize)
126 {
127  switch (srctype) {
128  case SYBBITN:
129  return SYBBIT;
130  case SYBDATEN:
131  return SYBDATE;
132  case SYBDATETIMN:
133  switch (colsize) {
134  case 8:
135  return SYBDATETIME;
136  case 4:
137  return SYBDATETIME4;
138  }
139  break;
140  case SYBFLTN:
141  switch (colsize) {
142  case 8:
143  return SYBFLT8;
144  case 4:
145  return SYBREAL;
146  }
147  break;
148  case SYBINTN:
149  switch (colsize) {
150  case 8:
151  return SYBINT8;
152  case 4:
153  return SYBINT4;
154  case 2:
155  return SYBINT2;
156  case 1:
157  return SYBINT1;
158  }
159  break;
160  case SYBMONEYN:
161  switch (colsize) {
162  case 8:
163  return SYBMONEY;
164  case 4:
165  return SYBMONEY4;
166  }
167  break;
168  case SYBTIMEN:
169  return SYBTIME;
170  case SYBUINTN:
171  switch (colsize) {
172  case 8:
173  return SYBUINT8;
174  case 4:
175  return SYBUINT4;
176  case 2:
177  return SYBUINT2;
178  case 1:
179  return SYBUINT1;
180  }
181  break;
182  case SYB5INT8:
183  return SYBINT8;
184  default:
185  break;
186  }
187  return srctype;
188 }
189 
190 const unsigned char tds_type_flags_ms[256] = {
191  /* 0 empty */ TDS_TYPEFLAG_INVALID,
192  /* 1 empty */ TDS_TYPEFLAG_INVALID,
193  /* 2 empty */ TDS_TYPEFLAG_INVALID,
194  /* 3 empty */ TDS_TYPEFLAG_INVALID,
195  /* 4 empty */ TDS_TYPEFLAG_INVALID,
196  /* 5 empty */ TDS_TYPEFLAG_INVALID,
197  /* 6 empty */ TDS_TYPEFLAG_INVALID,
198  /* 7 empty */ TDS_TYPEFLAG_INVALID,
199  /* 8 empty */ TDS_TYPEFLAG_INVALID,
200  /* 9 empty */ TDS_TYPEFLAG_INVALID,
201  /* 10 empty */ TDS_TYPEFLAG_INVALID,
202  /* 11 empty */ TDS_TYPEFLAG_INVALID,
203  /* 12 empty */ TDS_TYPEFLAG_INVALID,
204  /* 13 empty */ TDS_TYPEFLAG_INVALID,
205  /* 14 empty */ TDS_TYPEFLAG_INVALID,
206  /* 15 empty */ TDS_TYPEFLAG_INVALID,
207  /* 16 empty */ TDS_TYPEFLAG_INVALID,
208  /* 17 empty */ TDS_TYPEFLAG_INVALID,
209  /* 18 empty */ TDS_TYPEFLAG_INVALID,
210  /* 19 empty */ TDS_TYPEFLAG_INVALID,
211  /* 20 empty */ TDS_TYPEFLAG_INVALID,
212  /* 21 empty */ TDS_TYPEFLAG_INVALID,
213  /* 22 empty */ TDS_TYPEFLAG_INVALID,
214  /* 23 empty */ TDS_TYPEFLAG_INVALID,
215  /* 24 empty */ TDS_TYPEFLAG_INVALID,
216  /* 25 empty */ TDS_TYPEFLAG_INVALID,
217  /* 26 empty */ TDS_TYPEFLAG_INVALID,
218  /* 27 empty */ TDS_TYPEFLAG_INVALID,
219  /* 28 empty */ TDS_TYPEFLAG_INVALID,
220  /* 29 empty */ TDS_TYPEFLAG_INVALID,
221  /* 30 empty */ TDS_TYPEFLAG_INVALID,
222  /* 31 SYBVOID */ TDS_TYPEFLAG_FIXED,
223  /* 32 empty */ TDS_TYPEFLAG_INVALID,
224  /* 33 empty */ TDS_TYPEFLAG_INVALID,
225  /* 34 SYBIMAGE */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE,
226  /* 35 SYBTEXT */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_COLLATE|TDS_TYPEFLAG_ASCII,
227  /* 36 SYBUNIQUE */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_FIXED,
228  /* 37 SYBVARBINARY */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE,
229  /* 38 SYBINTN */ TDS_TYPEFLAG_NULLABLE,
230  /* 39 SYBVARCHAR */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_ASCII,
231  /* 40 SYBMSDATE */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_FIXED|TDS_TYPEFLAG_DATETIME,
232  /* 41 SYBMSTIME */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_DATETIME,
233  /* 42 SYBMSDATETIME2 */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_DATETIME,
234  /* 43 SYBMSDATETIMEOFFSET */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_DATETIME,
235  /* 44 empty */ TDS_TYPEFLAG_INVALID,
236  /* 45 SYBBINARY */ TDS_TYPEFLAG_VARIABLE,
237  /* 46 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_FIXED,
238  /* 47 SYBCHAR */ TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_ASCII,
239  /* 48 SYBINT1 */ TDS_TYPEFLAG_FIXED,
240  /* 49 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_FIXED|TDS_TYPEFLAG_DATETIME,
241  /* 50 SYBBIT */ TDS_TYPEFLAG_FIXED,
242  /* 51 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_FIXED|TDS_TYPEFLAG_DATETIME,
243  /* 52 SYBINT2 */ TDS_TYPEFLAG_FIXED,
244  /* 53 empty */ TDS_TYPEFLAG_INVALID,
245  /* 54 empty */ TDS_TYPEFLAG_INVALID,
246  /* 55 empty */ TDS_TYPEFLAG_INVALID,
247  /* 56 SYBINT4 */ TDS_TYPEFLAG_FIXED,
248  /* 57 empty */ TDS_TYPEFLAG_INVALID,
249  /* 58 SYBDATETIME4 */ TDS_TYPEFLAG_FIXED|TDS_TYPEFLAG_DATETIME,
250  /* 59 SYBREAL */ TDS_TYPEFLAG_FIXED,
251  /* 60 SYBMONEY */ TDS_TYPEFLAG_FIXED,
252  /* 61 SYBDATETIME */ TDS_TYPEFLAG_FIXED|TDS_TYPEFLAG_DATETIME,
253  /* 62 SYBFLT8 */ TDS_TYPEFLAG_FIXED,
254  /* 63 empty */ TDS_TYPEFLAG_INVALID,
255  /* 64 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_FIXED,
256  /* 65 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_FIXED,
257  /* 66 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_FIXED,
258  /* 67 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_FIXED,
259  /* 68 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE,
260  /* 69 empty */ TDS_TYPEFLAG_INVALID,
261  /* 70 empty */ TDS_TYPEFLAG_INVALID,
262  /* 71 empty */ TDS_TYPEFLAG_INVALID,
263  /* 72 empty */ TDS_TYPEFLAG_INVALID,
264  /* 73 empty */ TDS_TYPEFLAG_INVALID,
265  /* 74 empty */ TDS_TYPEFLAG_INVALID,
266  /* 75 empty */ TDS_TYPEFLAG_INVALID,
267  /* 76 empty */ TDS_TYPEFLAG_INVALID,
268  /* 77 empty */ TDS_TYPEFLAG_INVALID,
269  /* 78 empty */ TDS_TYPEFLAG_INVALID,
270  /* 79 empty */ TDS_TYPEFLAG_INVALID,
271  /* 80 empty */ TDS_TYPEFLAG_INVALID,
272  /* 81 empty */ TDS_TYPEFLAG_INVALID,
273  /* 82 empty */ TDS_TYPEFLAG_INVALID,
274  /* 83 empty */ TDS_TYPEFLAG_INVALID,
275  /* 84 empty */ TDS_TYPEFLAG_INVALID,
276  /* 85 empty */ TDS_TYPEFLAG_INVALID,
277  /* 86 empty */ TDS_TYPEFLAG_INVALID,
278  /* 87 empty */ TDS_TYPEFLAG_INVALID,
279  /* 88 empty */ TDS_TYPEFLAG_INVALID,
280  /* 89 empty */ TDS_TYPEFLAG_INVALID,
281  /* 90 empty */ TDS_TYPEFLAG_INVALID,
282  /* 91 empty */ TDS_TYPEFLAG_INVALID,
283  /* 92 empty */ TDS_TYPEFLAG_INVALID,
284  /* 93 empty */ TDS_TYPEFLAG_INVALID,
285  /* 94 empty */ TDS_TYPEFLAG_INVALID,
286  /* 95 empty */ TDS_TYPEFLAG_INVALID,
287  /* 96 empty */ TDS_TYPEFLAG_INVALID,
288  /* 97 empty */ TDS_TYPEFLAG_INVALID,
289  /* 98 SYBVARIANT */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE,
290  /* 99 SYBNTEXT */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_COLLATE|TDS_TYPEFLAG_UNICODE,
291  /* 100 empty */ TDS_TYPEFLAG_INVALID,
292  /* 101 empty */ TDS_TYPEFLAG_INVALID,
293  /* 102 empty */ TDS_TYPEFLAG_INVALID,
294  /* 103 SYBNVARCHAR */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_UNICODE,
295  /* 104 SYBBITN */ TDS_TYPEFLAG_NULLABLE,
296  /* 105 empty */ TDS_TYPEFLAG_INVALID,
297  /* 106 SYBDECIMAL */ TDS_TYPEFLAG_NUMERIC,
298  /* 107 empty */ TDS_TYPEFLAG_INVALID,
299  /* 108 SYBNUMERIC */ TDS_TYPEFLAG_NUMERIC,
300  /* 109 SYBFLTN */ TDS_TYPEFLAG_NULLABLE,
301  /* 110 SYBMONEYN */ TDS_TYPEFLAG_NULLABLE,
302  /* 111 SYBDATETIMN */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_DATETIME,
303  /* 112 empty */ TDS_TYPEFLAG_INVALID,
304  /* 113 empty */ TDS_TYPEFLAG_INVALID,
305  /* 114 empty */ TDS_TYPEFLAG_INVALID,
306  /* 115 empty */ TDS_TYPEFLAG_INVALID,
307  /* 116 empty */ TDS_TYPEFLAG_INVALID,
308  /* 117 empty */ TDS_TYPEFLAG_INVALID,
309  /* 118 empty */ TDS_TYPEFLAG_INVALID,
310  /* 119 empty */ TDS_TYPEFLAG_INVALID,
311  /* 120 empty */ TDS_TYPEFLAG_INVALID,
312  /* 121 empty */ TDS_TYPEFLAG_INVALID,
313  /* 122 SYBMONEY4 */ TDS_TYPEFLAG_FIXED,
314  /* 123 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_DATETIME,
315  /* 124 empty */ TDS_TYPEFLAG_INVALID,
316  /* 125 empty */ TDS_TYPEFLAG_INVALID,
317  /* 126 empty */ TDS_TYPEFLAG_INVALID,
318  /* 127 SYBINT8 */ TDS_TYPEFLAG_FIXED,
319  /* 128 empty */ TDS_TYPEFLAG_INVALID,
320  /* 129 empty */ TDS_TYPEFLAG_INVALID,
321  /* 130 empty */ TDS_TYPEFLAG_INVALID,
322  /* 131 empty */ TDS_TYPEFLAG_INVALID,
323  /* 132 empty */ TDS_TYPEFLAG_INVALID,
324  /* 133 empty */ TDS_TYPEFLAG_INVALID,
325  /* 134 empty */ TDS_TYPEFLAG_INVALID,
326  /* 135 empty */ TDS_TYPEFLAG_INVALID,
327  /* 136 empty */ TDS_TYPEFLAG_INVALID,
328  /* 137 empty */ TDS_TYPEFLAG_INVALID,
329  /* 138 empty */ TDS_TYPEFLAG_INVALID,
330  /* 139 empty */ TDS_TYPEFLAG_INVALID,
331  /* 140 empty */ TDS_TYPEFLAG_INVALID,
332  /* 141 empty */ TDS_TYPEFLAG_INVALID,
333  /* 142 empty */ TDS_TYPEFLAG_INVALID,
334  /* 143 empty */ TDS_TYPEFLAG_INVALID,
335  /* 144 empty */ TDS_TYPEFLAG_INVALID,
336  /* 145 empty */ TDS_TYPEFLAG_INVALID,
337  /* 146 empty */ TDS_TYPEFLAG_INVALID,
338  /* 147 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_DATETIME,
339  /* 148 empty */ TDS_TYPEFLAG_INVALID,
340  /* 149 empty */ TDS_TYPEFLAG_INVALID,
341  /* 150 empty */ TDS_TYPEFLAG_INVALID,
342  /* 151 empty */ TDS_TYPEFLAG_INVALID,
343  /* 152 empty */ TDS_TYPEFLAG_INVALID,
344  /* 153 empty */ TDS_TYPEFLAG_INVALID,
345  /* 154 empty */ TDS_TYPEFLAG_INVALID,
346  /* 155 empty */ TDS_TYPEFLAG_INVALID,
347  /* 156 empty */ TDS_TYPEFLAG_INVALID,
348  /* 157 empty */ TDS_TYPEFLAG_INVALID,
349  /* 158 empty */ TDS_TYPEFLAG_INVALID,
350  /* 159 empty */ TDS_TYPEFLAG_INVALID,
351  /* 160 empty */ TDS_TYPEFLAG_INVALID,
352  /* 161 empty */ TDS_TYPEFLAG_INVALID,
353  /* 162 empty */ TDS_TYPEFLAG_INVALID,
354  /* 163 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE,
355  /* 164 empty */ TDS_TYPEFLAG_INVALID,
356  /* 165 XSYBVARBINARY */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE,
357  /* 166 empty */ TDS_TYPEFLAG_INVALID,
358  /* 167 XSYBVARCHAR */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_COLLATE|TDS_TYPEFLAG_ASCII,
359  /* 168 empty */ TDS_TYPEFLAG_INVALID,
360  /* 169 empty */ TDS_TYPEFLAG_INVALID,
361  /* 170 empty */ TDS_TYPEFLAG_INVALID,
362  /* 171 empty */ TDS_TYPEFLAG_INVALID,
363  /* 172 empty */ TDS_TYPEFLAG_INVALID,
364  /* 173 XSYBBINARY */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE,
365  /* 174 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_UNICODE,
366  /* 175 XSYBCHAR */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_COLLATE|TDS_TYPEFLAG_ASCII,
367  /* 176 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_FIXED,
368  /* 177 empty */ TDS_TYPEFLAG_INVALID,
369  /* 178 empty */ TDS_TYPEFLAG_INVALID,
370  /* 179 empty */ TDS_TYPEFLAG_INVALID,
371  /* 180 empty */ TDS_TYPEFLAG_INVALID,
372  /* 181 empty */ TDS_TYPEFLAG_INVALID,
373  /* 182 empty */ TDS_TYPEFLAG_INVALID,
374  /* 183 empty */ TDS_TYPEFLAG_INVALID,
375  /* 184 empty */ TDS_TYPEFLAG_INVALID,
376  /* 185 empty */ TDS_TYPEFLAG_INVALID,
377  /* 186 empty */ TDS_TYPEFLAG_INVALID,
378  /* 187 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_DATETIME,
379  /* 188 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_DATETIME,
380  /* 189 empty */ TDS_TYPEFLAG_INVALID,
381  /* 190 empty */ TDS_TYPEFLAG_INVALID,
382  /* 191 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_FIXED,
383  /* 192 empty */ TDS_TYPEFLAG_INVALID,
384  /* 193 empty */ TDS_TYPEFLAG_INVALID,
385  /* 194 empty */ TDS_TYPEFLAG_INVALID,
386  /* 195 empty */ TDS_TYPEFLAG_INVALID,
387  /* 196 empty */ TDS_TYPEFLAG_INVALID,
388  /* 197 empty */ TDS_TYPEFLAG_INVALID,
389  /* 198 empty */ TDS_TYPEFLAG_INVALID,
390  /* 199 empty */ TDS_TYPEFLAG_INVALID,
391  /* 200 empty */ TDS_TYPEFLAG_INVALID,
392  /* 201 empty */ TDS_TYPEFLAG_INVALID,
393  /* 202 empty */ TDS_TYPEFLAG_INVALID,
394  /* 203 empty */ TDS_TYPEFLAG_INVALID,
395  /* 204 empty */ TDS_TYPEFLAG_INVALID,
396  /* 205 empty */ TDS_TYPEFLAG_INVALID,
397  /* 206 empty */ TDS_TYPEFLAG_INVALID,
398  /* 207 empty */ TDS_TYPEFLAG_INVALID,
399  /* 208 empty */ TDS_TYPEFLAG_INVALID,
400  /* 209 empty */ TDS_TYPEFLAG_INVALID,
401  /* 210 empty */ TDS_TYPEFLAG_INVALID,
402  /* 211 empty */ TDS_TYPEFLAG_INVALID,
403  /* 212 empty */ TDS_TYPEFLAG_INVALID,
404  /* 213 empty */ TDS_TYPEFLAG_INVALID,
405  /* 214 empty */ TDS_TYPEFLAG_INVALID,
406  /* 215 empty */ TDS_TYPEFLAG_INVALID,
407  /* 216 empty */ TDS_TYPEFLAG_INVALID,
408  /* 217 empty */ TDS_TYPEFLAG_INVALID,
409  /* 218 empty */ TDS_TYPEFLAG_INVALID,
410  /* 219 empty */ TDS_TYPEFLAG_INVALID,
411  /* 220 empty */ TDS_TYPEFLAG_INVALID,
412  /* 221 empty */ TDS_TYPEFLAG_INVALID,
413  /* 222 empty */ TDS_TYPEFLAG_INVALID,
414  /* 223 empty */ TDS_TYPEFLAG_INVALID,
415  /* 224 empty */ TDS_TYPEFLAG_INVALID,
416  /* 225 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE,
417  /* 226 empty */ TDS_TYPEFLAG_INVALID,
418  /* 227 empty */ TDS_TYPEFLAG_INVALID,
419  /* 228 empty */ TDS_TYPEFLAG_INVALID,
420  /* 229 empty */ TDS_TYPEFLAG_INVALID,
421  /* 230 empty */ TDS_TYPEFLAG_INVALID,
422  /* 231 XSYBNVARCHAR */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_COLLATE|TDS_TYPEFLAG_UNICODE,
423  /* 232 empty */ TDS_TYPEFLAG_INVALID,
424  /* 233 empty */ TDS_TYPEFLAG_INVALID,
425  /* 234 empty */ TDS_TYPEFLAG_INVALID,
426  /* 235 empty */ TDS_TYPEFLAG_INVALID,
427  /* 236 empty */ TDS_TYPEFLAG_INVALID,
428  /* 237 empty */ TDS_TYPEFLAG_INVALID,
429  /* 238 empty */ TDS_TYPEFLAG_INVALID,
430  /* 239 XSYBNCHAR */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_COLLATE|TDS_TYPEFLAG_UNICODE,
431  /* 240 SYBMSUDT */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE,
432  /* 241 SYBMSXML */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_UNICODE,
433  /* 242 empty */ TDS_TYPEFLAG_INVALID,
434  /* 243 empty */ TDS_TYPEFLAG_INVALID,
435  /* 244 empty */ TDS_TYPEFLAG_INVALID,
436  /* 245 empty */ TDS_TYPEFLAG_INVALID,
437  /* 246 empty */ TDS_TYPEFLAG_INVALID,
438  /* 247 empty */ TDS_TYPEFLAG_INVALID,
439  /* 248 empty */ TDS_TYPEFLAG_INVALID,
440  /* 249 empty */ TDS_TYPEFLAG_INVALID,
441  /* 250 empty */ TDS_TYPEFLAG_INVALID,
442  /* 251 empty */ TDS_TYPEFLAG_INVALID,
443  /* 252 empty */ TDS_TYPEFLAG_INVALID,
444  /* 253 empty */ TDS_TYPEFLAG_INVALID,
445  /* 254 empty */ TDS_TYPEFLAG_INVALID,
446  /* 255 empty */ TDS_TYPEFLAG_INVALID,
447 };
448 
449 #if 0
450 const unsigned char tds_type_flags_syb[256] = {
451  /* 0 empty */ TDS_TYPEFLAG_INVALID,
452  /* 1 empty */ TDS_TYPEFLAG_INVALID,
453  /* 2 empty */ TDS_TYPEFLAG_INVALID,
454  /* 3 empty */ TDS_TYPEFLAG_INVALID,
455  /* 4 empty */ TDS_TYPEFLAG_INVALID,
456  /* 5 empty */ TDS_TYPEFLAG_INVALID,
457  /* 6 empty */ TDS_TYPEFLAG_INVALID,
458  /* 7 empty */ TDS_TYPEFLAG_INVALID,
459  /* 8 empty */ TDS_TYPEFLAG_INVALID,
460  /* 9 empty */ TDS_TYPEFLAG_INVALID,
461  /* 10 empty */ TDS_TYPEFLAG_INVALID,
462  /* 11 empty */ TDS_TYPEFLAG_INVALID,
463  /* 12 empty */ TDS_TYPEFLAG_INVALID,
464  /* 13 empty */ TDS_TYPEFLAG_INVALID,
465  /* 14 empty */ TDS_TYPEFLAG_INVALID,
466  /* 15 empty */ TDS_TYPEFLAG_INVALID,
467  /* 16 empty */ TDS_TYPEFLAG_INVALID,
468  /* 17 empty */ TDS_TYPEFLAG_INVALID,
469  /* 18 empty */ TDS_TYPEFLAG_INVALID,
470  /* 19 empty */ TDS_TYPEFLAG_INVALID,
471  /* 20 empty */ TDS_TYPEFLAG_INVALID,
472  /* 21 empty */ TDS_TYPEFLAG_INVALID,
473  /* 22 empty */ TDS_TYPEFLAG_INVALID,
474  /* 23 empty */ TDS_TYPEFLAG_INVALID,
475  /* 24 empty */ TDS_TYPEFLAG_INVALID,
476  /* 25 empty */ TDS_TYPEFLAG_INVALID,
477  /* 26 empty */ TDS_TYPEFLAG_INVALID,
478  /* 27 empty */ TDS_TYPEFLAG_INVALID,
479  /* 28 empty */ TDS_TYPEFLAG_INVALID,
480  /* 29 empty */ TDS_TYPEFLAG_INVALID,
481  /* 30 empty */ TDS_TYPEFLAG_INVALID,
482  /* 31 SYBVOID */ TDS_TYPEFLAG_FIXED,
483  /* 32 empty */ TDS_TYPEFLAG_INVALID,
484  /* 33 empty */ TDS_TYPEFLAG_INVALID,
485  /* 34 SYBIMAGE */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE,
486  /* 35 SYBTEXT */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_COLLATE|TDS_TYPEFLAG_ASCII,
487  /* 36 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_FIXED|TDS_TYPEFLAG_NULLABLE,
488  /* 37 SYBVARBINARY */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE,
489  /* 38 SYBINTN */ TDS_TYPEFLAG_NULLABLE,
490  /* 39 SYBVARCHAR */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_ASCII,
491  /* 40 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_FIXED|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_DATETIME,
492  /* 41 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_DATETIME,
493  /* 42 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_DATETIME,
494  /* 43 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_DATETIME,
495  /* 44 empty */ TDS_TYPEFLAG_INVALID,
496  /* 45 SYBBINARY */ TDS_TYPEFLAG_VARIABLE,
497  /* 46 SYBINTERVAL */ TDS_TYPEFLAG_FIXED,
498  /* 47 SYBCHAR */ TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_ASCII,
499  /* 48 SYBINT1 */ TDS_TYPEFLAG_FIXED,
500  /* 49 SYBDATE */ TDS_TYPEFLAG_FIXED|TDS_TYPEFLAG_DATETIME,
501  /* 50 SYBBIT */ TDS_TYPEFLAG_FIXED,
502  /* 51 SYBTIME */ TDS_TYPEFLAG_FIXED|TDS_TYPEFLAG_DATETIME,
503  /* 52 SYBINT2 */ TDS_TYPEFLAG_FIXED,
504  /* 53 empty */ TDS_TYPEFLAG_INVALID,
505  /* 54 empty */ TDS_TYPEFLAG_INVALID,
506  /* 55 empty */ TDS_TYPEFLAG_INVALID,
507  /* 56 SYBINT4 */ TDS_TYPEFLAG_FIXED,
508  /* 57 empty */ TDS_TYPEFLAG_INVALID,
509  /* 58 SYBDATETIME4 */ TDS_TYPEFLAG_FIXED|TDS_TYPEFLAG_DATETIME,
510  /* 59 SYBREAL */ TDS_TYPEFLAG_FIXED,
511  /* 60 SYBMONEY */ TDS_TYPEFLAG_FIXED,
512  /* 61 SYBDATETIME */ TDS_TYPEFLAG_FIXED|TDS_TYPEFLAG_DATETIME,
513  /* 62 SYBFLT8 */ TDS_TYPEFLAG_FIXED,
514  /* 63 empty */ TDS_TYPEFLAG_INVALID,
515  /* 64 SYBUINT1 */ TDS_TYPEFLAG_FIXED,
516  /* 65 SYBUINT2 */ TDS_TYPEFLAG_FIXED,
517  /* 66 SYBUINT4 */ TDS_TYPEFLAG_FIXED,
518  /* 67 SYBUINT8 */ TDS_TYPEFLAG_FIXED,
519  /* 68 SYBUINTN */ TDS_TYPEFLAG_NULLABLE,
520  /* 69 empty */ TDS_TYPEFLAG_INVALID,
521  /* 70 empty */ TDS_TYPEFLAG_INVALID,
522  /* 71 empty */ TDS_TYPEFLAG_INVALID,
523  /* 72 empty */ TDS_TYPEFLAG_INVALID,
524  /* 73 empty */ TDS_TYPEFLAG_INVALID,
525  /* 74 empty */ TDS_TYPEFLAG_INVALID,
526  /* 75 empty */ TDS_TYPEFLAG_INVALID,
527  /* 76 empty */ TDS_TYPEFLAG_INVALID,
528  /* 77 empty */ TDS_TYPEFLAG_INVALID,
529  /* 78 empty */ TDS_TYPEFLAG_INVALID,
530  /* 79 empty */ TDS_TYPEFLAG_INVALID,
531  /* 80 empty */ TDS_TYPEFLAG_INVALID,
532  /* 81 empty */ TDS_TYPEFLAG_INVALID,
533  /* 82 empty */ TDS_TYPEFLAG_INVALID,
534  /* 83 empty */ TDS_TYPEFLAG_INVALID,
535  /* 84 empty */ TDS_TYPEFLAG_INVALID,
536  /* 85 empty */ TDS_TYPEFLAG_INVALID,
537  /* 86 empty */ TDS_TYPEFLAG_INVALID,
538  /* 87 empty */ TDS_TYPEFLAG_INVALID,
539  /* 88 empty */ TDS_TYPEFLAG_INVALID,
540  /* 89 empty */ TDS_TYPEFLAG_INVALID,
541  /* 90 empty */ TDS_TYPEFLAG_INVALID,
542  /* 91 empty */ TDS_TYPEFLAG_INVALID,
543  /* 92 empty */ TDS_TYPEFLAG_INVALID,
544  /* 93 empty */ TDS_TYPEFLAG_INVALID,
545  /* 94 empty */ TDS_TYPEFLAG_INVALID,
546  /* 95 empty */ TDS_TYPEFLAG_INVALID,
547  /* 96 empty */ TDS_TYPEFLAG_INVALID,
548  /* 97 empty */ TDS_TYPEFLAG_INVALID,
549  /* 98 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE,
550  /* 99 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_UNICODE,
551  /* 100 empty */ TDS_TYPEFLAG_INVALID,
552  /* 101 empty */ TDS_TYPEFLAG_INVALID,
553  /* 102 empty */ TDS_TYPEFLAG_INVALID,
554  /* 103 SYBSENSITIVITY */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_ASCII,
555  /* 104 SYBBOUNDARY */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_ASCII,
556  /* 105 empty */ TDS_TYPEFLAG_INVALID,
557  /* 106 SYBDECIMAL */ TDS_TYPEFLAG_NUMERIC,
558  /* 107 empty */ TDS_TYPEFLAG_INVALID,
559  /* 108 SYBNUMERIC */ TDS_TYPEFLAG_NUMERIC,
560  /* 109 SYBFLTN */ TDS_TYPEFLAG_NULLABLE,
561  /* 110 SYBMONEYN */ TDS_TYPEFLAG_NULLABLE,
562  /* 111 SYBDATETIMN */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_DATETIME,
563  /* 112 empty */ TDS_TYPEFLAG_INVALID,
564  /* 113 empty */ TDS_TYPEFLAG_INVALID,
565  /* 114 empty */ TDS_TYPEFLAG_INVALID,
566  /* 115 empty */ TDS_TYPEFLAG_INVALID,
567  /* 116 empty */ TDS_TYPEFLAG_INVALID,
568  /* 117 empty */ TDS_TYPEFLAG_INVALID,
569  /* 118 empty */ TDS_TYPEFLAG_INVALID,
570  /* 119 empty */ TDS_TYPEFLAG_INVALID,
571  /* 120 empty */ TDS_TYPEFLAG_INVALID,
572  /* 121 empty */ TDS_TYPEFLAG_INVALID,
573  /* 122 SYBMONEY4 */ TDS_TYPEFLAG_FIXED,
574  /* 123 SYBDATEN */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_DATETIME,
575  /* 124 empty */ TDS_TYPEFLAG_INVALID,
576  /* 125 empty */ TDS_TYPEFLAG_INVALID,
577  /* 126 empty */ TDS_TYPEFLAG_INVALID,
578  /* 127 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_FIXED,
579  /* 128 empty */ TDS_TYPEFLAG_INVALID,
580  /* 129 empty */ TDS_TYPEFLAG_INVALID,
581  /* 130 empty */ TDS_TYPEFLAG_INVALID,
582  /* 131 empty */ TDS_TYPEFLAG_INVALID,
583  /* 132 empty */ TDS_TYPEFLAG_INVALID,
584  /* 133 empty */ TDS_TYPEFLAG_INVALID,
585  /* 134 empty */ TDS_TYPEFLAG_INVALID,
586  /* 135 empty */ TDS_TYPEFLAG_INVALID,
587  /* 136 empty */ TDS_TYPEFLAG_INVALID,
588  /* 137 empty */ TDS_TYPEFLAG_INVALID,
589  /* 138 empty */ TDS_TYPEFLAG_INVALID,
590  /* 139 empty */ TDS_TYPEFLAG_INVALID,
591  /* 140 empty */ TDS_TYPEFLAG_INVALID,
592  /* 141 empty */ TDS_TYPEFLAG_INVALID,
593  /* 142 empty */ TDS_TYPEFLAG_INVALID,
594  /* 143 empty */ TDS_TYPEFLAG_INVALID,
595  /* 144 empty */ TDS_TYPEFLAG_INVALID,
596  /* 145 empty */ TDS_TYPEFLAG_INVALID,
597  /* 146 empty */ TDS_TYPEFLAG_INVALID,
598  /* 147 SYBTIMEN */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_DATETIME,
599  /* 148 empty */ TDS_TYPEFLAG_INVALID,
600  /* 149 empty */ TDS_TYPEFLAG_INVALID,
601  /* 150 empty */ TDS_TYPEFLAG_INVALID,
602  /* 151 empty */ TDS_TYPEFLAG_INVALID,
603  /* 152 empty */ TDS_TYPEFLAG_INVALID,
604  /* 153 empty */ TDS_TYPEFLAG_INVALID,
605  /* 154 empty */ TDS_TYPEFLAG_INVALID,
606  /* 155 empty */ TDS_TYPEFLAG_INVALID,
607  /* 156 empty */ TDS_TYPEFLAG_INVALID,
608  /* 157 empty */ TDS_TYPEFLAG_INVALID,
609  /* 158 empty */ TDS_TYPEFLAG_INVALID,
610  /* 159 empty */ TDS_TYPEFLAG_INVALID,
611  /* 160 empty */ TDS_TYPEFLAG_INVALID,
612  /* 161 empty */ TDS_TYPEFLAG_INVALID,
613  /* 162 empty */ TDS_TYPEFLAG_INVALID,
614  /* 163 SYBXML */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE,
615  /* 164 empty */ TDS_TYPEFLAG_INVALID,
616  /* 165 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE,
617  /* 166 empty */ TDS_TYPEFLAG_INVALID,
618  /* 167 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE,
619  /* 168 empty */ TDS_TYPEFLAG_INVALID,
620  /* 169 empty */ TDS_TYPEFLAG_INVALID,
621  /* 170 empty */ TDS_TYPEFLAG_INVALID,
622  /* 171 empty */ TDS_TYPEFLAG_INVALID,
623  /* 172 empty */ TDS_TYPEFLAG_INVALID,
624  /* 173 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE,
625  /* 174 SYBUNITEXT */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_UNICODE,
626  /* 175 SYBLONGCHAR */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_ASCII,
627  /* 176 SYBSINT1 */ TDS_TYPEFLAG_FIXED,
628  /* 177 empty */ TDS_TYPEFLAG_INVALID,
629  /* 178 empty */ TDS_TYPEFLAG_INVALID,
630  /* 179 empty */ TDS_TYPEFLAG_INVALID,
631  /* 180 empty */ TDS_TYPEFLAG_INVALID,
632  /* 181 empty */ TDS_TYPEFLAG_INVALID,
633  /* 182 empty */ TDS_TYPEFLAG_INVALID,
634  /* 183 empty */ TDS_TYPEFLAG_INVALID,
635  /* 184 empty */ TDS_TYPEFLAG_INVALID,
636  /* 185 empty */ TDS_TYPEFLAG_INVALID,
637  /* 186 empty */ TDS_TYPEFLAG_INVALID,
638  /* 187 SYB5BIGDATETIME */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_DATETIME,
639  /* 188 SYB5BIGTIME */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_DATETIME,
640  /* 189 empty */ TDS_TYPEFLAG_INVALID,
641  /* 190 empty */ TDS_TYPEFLAG_INVALID,
642  /* 191 SYB5INT8 */ TDS_TYPEFLAG_FIXED,
643  /* 192 empty */ TDS_TYPEFLAG_INVALID,
644  /* 193 empty */ TDS_TYPEFLAG_INVALID,
645  /* 194 empty */ TDS_TYPEFLAG_INVALID,
646  /* 195 empty */ TDS_TYPEFLAG_INVALID,
647  /* 196 empty */ TDS_TYPEFLAG_INVALID,
648  /* 197 empty */ TDS_TYPEFLAG_INVALID,
649  /* 198 empty */ TDS_TYPEFLAG_INVALID,
650  /* 199 empty */ TDS_TYPEFLAG_INVALID,
651  /* 200 empty */ TDS_TYPEFLAG_INVALID,
652  /* 201 empty */ TDS_TYPEFLAG_INVALID,
653  /* 202 empty */ TDS_TYPEFLAG_INVALID,
654  /* 203 empty */ TDS_TYPEFLAG_INVALID,
655  /* 204 empty */ TDS_TYPEFLAG_INVALID,
656  /* 205 empty */ TDS_TYPEFLAG_INVALID,
657  /* 206 empty */ TDS_TYPEFLAG_INVALID,
658  /* 207 empty */ TDS_TYPEFLAG_INVALID,
659  /* 208 empty */ TDS_TYPEFLAG_INVALID,
660  /* 209 empty */ TDS_TYPEFLAG_INVALID,
661  /* 210 empty */ TDS_TYPEFLAG_INVALID,
662  /* 211 empty */ TDS_TYPEFLAG_INVALID,
663  /* 212 empty */ TDS_TYPEFLAG_INVALID,
664  /* 213 empty */ TDS_TYPEFLAG_INVALID,
665  /* 214 empty */ TDS_TYPEFLAG_INVALID,
666  /* 215 empty */ TDS_TYPEFLAG_INVALID,
667  /* 216 empty */ TDS_TYPEFLAG_INVALID,
668  /* 217 empty */ TDS_TYPEFLAG_INVALID,
669  /* 218 empty */ TDS_TYPEFLAG_INVALID,
670  /* 219 empty */ TDS_TYPEFLAG_INVALID,
671  /* 220 empty */ TDS_TYPEFLAG_INVALID,
672  /* 221 empty */ TDS_TYPEFLAG_INVALID,
673  /* 222 empty */ TDS_TYPEFLAG_INVALID,
674  /* 223 empty */ TDS_TYPEFLAG_INVALID,
675  /* 224 empty */ TDS_TYPEFLAG_INVALID,
676  /* 225 SYBLONGBINARY */ TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE,
677  /* 226 empty */ TDS_TYPEFLAG_INVALID,
678  /* 227 empty */ TDS_TYPEFLAG_INVALID,
679  /* 228 empty */ TDS_TYPEFLAG_INVALID,
680  /* 229 empty */ TDS_TYPEFLAG_INVALID,
681  /* 230 empty */ TDS_TYPEFLAG_INVALID,
682  /* 231 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_UNICODE,
683  /* 232 empty */ TDS_TYPEFLAG_INVALID,
684  /* 233 empty */ TDS_TYPEFLAG_INVALID,
685  /* 234 empty */ TDS_TYPEFLAG_INVALID,
686  /* 235 empty */ TDS_TYPEFLAG_INVALID,
687  /* 236 empty */ TDS_TYPEFLAG_INVALID,
688  /* 237 empty */ TDS_TYPEFLAG_INVALID,
689  /* 238 empty */ TDS_TYPEFLAG_INVALID,
690  /* 239 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_UNICODE,
691  /* 240 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE,
692  /* 241 empty */ TDS_TYPEFLAG_INVALID|TDS_TYPEFLAG_NULLABLE|TDS_TYPEFLAG_VARIABLE|TDS_TYPEFLAG_UNICODE,
693  /* 242 empty */ TDS_TYPEFLAG_INVALID,
694  /* 243 empty */ TDS_TYPEFLAG_INVALID,
695  /* 244 empty */ TDS_TYPEFLAG_INVALID,
696  /* 245 empty */ TDS_TYPEFLAG_INVALID,
697  /* 246 empty */ TDS_TYPEFLAG_INVALID,
698  /* 247 empty */ TDS_TYPEFLAG_INVALID,
699  /* 248 empty */ TDS_TYPEFLAG_INVALID,
700  /* 249 empty */ TDS_TYPEFLAG_INVALID,
701  /* 250 empty */ TDS_TYPEFLAG_INVALID,
702  /* 251 empty */ TDS_TYPEFLAG_INVALID,
703  /* 252 empty */ TDS_TYPEFLAG_INVALID,
704  /* 253 empty */ TDS_TYPEFLAG_INVALID,
705  /* 254 empty */ TDS_TYPEFLAG_INVALID,
706  /* 255 empty */ TDS_TYPEFLAG_INVALID,
707 };
708 
709 const char *const tds_type_names[256] = {
710  /* 0 */ "",
711  /* 1 */ "",
712  /* 2 */ "",
713  /* 3 */ "",
714  /* 4 */ "",
715  /* 5 */ "",
716  /* 6 */ "",
717  /* 7 */ "",
718  /* 8 */ "",
719  /* 9 */ "",
720  /* 10 */ "",
721  /* 11 */ "",
722  /* 12 */ "",
723  /* 13 */ "",
724  /* 14 */ "",
725  /* 15 */ "",
726  /* 16 */ "",
727  /* 17 */ "",
728  /* 18 */ "",
729  /* 19 */ "",
730  /* 20 */ "",
731  /* 21 */ "",
732  /* 22 */ "",
733  /* 23 */ "",
734  /* 24 */ "",
735  /* 25 */ "",
736  /* 26 */ "",
737  /* 27 */ "",
738  /* 28 */ "",
739  /* 29 */ "",
740  /* 30 */ "",
741  /* 31 */ "SYBVOID",
742  /* 32 */ "",
743  /* 33 */ "",
744  /* 34 */ "SYBIMAGE",
745  /* 35 */ "SYBTEXT",
746  /* 36 */ "SYBUNIQUE",
747  /* 37 */ "SYBVARBINARY",
748  /* 38 */ "SYBINTN",
749  /* 39 */ "SYBVARCHAR",
750  /* 40 */ "SYBMSDATE",
751  /* 41 */ "SYBMSTIME",
752  /* 42 */ "SYBMSDATETIME2",
753  /* 43 */ "SYBMSDATETIMEOFFSET",
754  /* 44 */ "",
755  /* 45 */ "SYBBINARY",
756  /* 46 */ "SYBINTERVAL",
757  /* 47 */ "SYBCHAR",
758  /* 48 */ "SYBINT1",
759  /* 49 */ "SYBDATE",
760  /* 50 */ "SYBBIT",
761  /* 51 */ "SYBTIME",
762  /* 52 */ "SYBINT2",
763  /* 53 */ "",
764  /* 54 */ "",
765  /* 55 */ "",
766  /* 56 */ "SYBINT4",
767  /* 57 */ "",
768  /* 58 */ "SYBDATETIME4",
769  /* 59 */ "SYBREAL",
770  /* 60 */ "SYBMONEY",
771  /* 61 */ "SYBDATETIME",
772  /* 62 */ "SYBFLT8",
773  /* 63 */ "",
774  /* 64 */ "SYBUINT1",
775  /* 65 */ "SYBUINT2",
776  /* 66 */ "SYBUINT4",
777  /* 67 */ "SYBUINT8",
778  /* 68 */ "SYBUINTN",
779  /* 69 */ "",
780  /* 70 */ "",
781  /* 71 */ "",
782  /* 72 */ "",
783  /* 73 */ "",
784  /* 74 */ "",
785  /* 75 */ "",
786  /* 76 */ "",
787  /* 77 */ "",
788  /* 78 */ "",
789  /* 79 */ "",
790  /* 80 */ "",
791  /* 81 */ "",
792  /* 82 */ "",
793  /* 83 */ "",
794  /* 84 */ "",
795  /* 85 */ "",
796  /* 86 */ "",
797  /* 87 */ "",
798  /* 88 */ "",
799  /* 89 */ "",
800  /* 90 */ "",
801  /* 91 */ "",
802  /* 92 */ "",
803  /* 93 */ "",
804  /* 94 */ "",
805  /* 95 */ "",
806  /* 96 */ "",
807  /* 97 */ "",
808  /* 98 */ "SYBVARIANT",
809  /* 99 */ "SYBNTEXT",
810  /* 100 */ "",
811  /* 101 */ "",
812  /* 102 */ "",
813  /* 103 */ "SYBNVARCHAR or SYBSENSITIVITY",
814  /* 104 */ "SYBBITN or SYBBOUNDARY",
815  /* 105 */ "",
816  /* 106 */ "SYBDECIMAL",
817  /* 107 */ "",
818  /* 108 */ "SYBNUMERIC",
819  /* 109 */ "SYBFLTN",
820  /* 110 */ "SYBMONEYN",
821  /* 111 */ "SYBDATETIMN",
822  /* 112 */ "",
823  /* 113 */ "",
824  /* 114 */ "",
825  /* 115 */ "",
826  /* 116 */ "",
827  /* 117 */ "",
828  /* 118 */ "",
829  /* 119 */ "",
830  /* 120 */ "",
831  /* 121 */ "",
832  /* 122 */ "SYBMONEY4",
833  /* 123 */ "SYBDATEN",
834  /* 124 */ "",
835  /* 125 */ "",
836  /* 126 */ "",
837  /* 127 */ "SYBINT8",
838  /* 128 */ "",
839  /* 129 */ "",
840  /* 130 */ "",
841  /* 131 */ "",
842  /* 132 */ "",
843  /* 133 */ "",
844  /* 134 */ "",
845  /* 135 */ "",
846  /* 136 */ "",
847  /* 137 */ "",
848  /* 138 */ "",
849  /* 139 */ "",
850  /* 140 */ "",
851  /* 141 */ "",
852  /* 142 */ "",
853  /* 143 */ "",
854  /* 144 */ "",
855  /* 145 */ "",
856  /* 146 */ "",
857  /* 147 */ "SYBTIMEN",
858  /* 148 */ "",
859  /* 149 */ "",
860  /* 150 */ "",
861  /* 151 */ "",
862  /* 152 */ "",
863  /* 153 */ "",
864  /* 154 */ "",
865  /* 155 */ "",
866  /* 156 */ "",
867  /* 157 */ "",
868  /* 158 */ "",
869  /* 159 */ "",
870  /* 160 */ "",
871  /* 161 */ "",
872  /* 162 */ "",
873  /* 163 */ "SYBXML",
874  /* 164 */ "",
875  /* 165 */ "XSYBVARBINARY",
876  /* 166 */ "",
877  /* 167 */ "XSYBVARCHAR",
878  /* 168 */ "",
879  /* 169 */ "",
880  /* 170 */ "",
881  /* 171 */ "",
882  /* 172 */ "",
883  /* 173 */ "XSYBBINARY",
884  /* 174 */ "SYBUNITEXT",
885  /* 175 */ "XSYBCHAR or SYBLONGCHAR",
886  /* 176 */ "SYBSINT1",
887  /* 177 */ "",
888  /* 178 */ "",
889  /* 179 */ "",
890  /* 180 */ "",
891  /* 181 */ "",
892  /* 182 */ "",
893  /* 183 */ "",
894  /* 184 */ "",
895  /* 185 */ "",
896  /* 186 */ "",
897  /* 187 */ "SYB5BIGDATETIME",
898  /* 188 */ "SYB5BIGTIME",
899  /* 189 */ "",
900  /* 190 */ "",
901  /* 191 */ "SYB5INT8",
902  /* 192 */ "",
903  /* 193 */ "",
904  /* 194 */ "",
905  /* 195 */ "",
906  /* 196 */ "",
907  /* 197 */ "",
908  /* 198 */ "",
909  /* 199 */ "",
910  /* 200 */ "",
911  /* 201 */ "",
912  /* 202 */ "",
913  /* 203 */ "",
914  /* 204 */ "",
915  /* 205 */ "",
916  /* 206 */ "",
917  /* 207 */ "",
918  /* 208 */ "",
919  /* 209 */ "",
920  /* 210 */ "",
921  /* 211 */ "",
922  /* 212 */ "",
923  /* 213 */ "",
924  /* 214 */ "",
925  /* 215 */ "",
926  /* 216 */ "",
927  /* 217 */ "",
928  /* 218 */ "",
929  /* 219 */ "",
930  /* 220 */ "",
931  /* 221 */ "",
932  /* 222 */ "",
933  /* 223 */ "",
934  /* 224 */ "",
935  /* 225 */ "SYBLONGBINARY",
936  /* 226 */ "",
937  /* 227 */ "",
938  /* 228 */ "",
939  /* 229 */ "",
940  /* 230 */ "",
941  /* 231 */ "XSYBNVARCHAR",
942  /* 232 */ "",
943  /* 233 */ "",
944  /* 234 */ "",
945  /* 235 */ "",
946  /* 236 */ "",
947  /* 237 */ "",
948  /* 238 */ "",
949  /* 239 */ "XSYBNCHAR",
950  /* 240 */ "SYBMSUDT",
951  /* 241 */ "SYBMSXML",
952  /* 242 */ "",
953  /* 243 */ "",
954  /* 244 */ "",
955  /* 245 */ "",
956  /* 246 */ "",
957  /* 247 */ "",
958  /* 248 */ "",
959  /* 249 */ "",
960  /* 250 */ "",
961  /* 251 */ "",
962  /* 252 */ "",
963  /* 253 */ "",
964  /* 254 */ "",
965  /* 255 */ "",
966 };
967 #endif
int tds_get_varint_size(TDSCONNECTION *conn, int datatype)
tds_get_varint_size() returns the size of a variable length integer returned in a TDS 7...
Definition: tds_types.h:57
int tds_get_size_by_type(TDS_SERVER_TYPE servertype)
Return the number of bytes needed by specified type.
Definition: tds_types.h:9
Definition: tds.h:1102
TDS_SERVER_TYPE tds_get_conversion_type(TDS_SERVER_TYPE srctype, int colsize)
Return type suitable for conversions (convert all nullable types to fixed type)
Definition: tds_types.h:125
freetds-1.00.82/doc/reference/a00332_source.html100644 025423 025423 00000113753 13242511133 0014614 FreeTDS API: src/tds/tds_willconvert.h Source File
FreeTDS API
tds_willconvert.h
1 /*** Please do not edit this file! ***/
2 /*** It was generated with 'perl tds_willconvert.pl > tds_willconvert.h' ***/
3 /*** It is much easier to edit the __DATA__ table than this file. ***/
4 /*** ***/
5 /*** Thank you. ***/
6 
7 static const TDS_TINYINT type2category[256] = {
8  0, /* 0 */
9  0, /* 1 */
10  0, /* 2 */
11  0, /* 3 */
12  0, /* 4 */
13  0, /* 5 */
14  0, /* 6 */
15  0, /* 7 */
16  0, /* 8 */
17  0, /* 9 */
18  0, /* 10 */
19  0, /* 11 */
20  0, /* 12 */
21  0, /* 13 */
22  0, /* 14 */
23  0, /* 15 */
24  0, /* 16 */
25  0, /* 17 */
26  0, /* 18 */
27  0, /* 19 */
28  0, /* 20 */
29  0, /* 21 */
30  0, /* 22 */
31  0, /* 23 */
32  0, /* 24 */
33  0, /* 25 */
34  0, /* 26 */
35  0, /* 27 */
36  0, /* 28 */
37  0, /* 29 */
38  0, /* 30 */
39  0, /* SYBVOID */
40  0, /* 32 */
41  0, /* 33 */
42  3, /* SYBIMAGE */
43  1, /* SYBTEXT */
44  5, /* SYBBLOB */
45  3, /* SYBVARBINARY */
46  0, /* SYBINTN */
47  1, /* SYBVARCHAR */
48  7, /* SYBMSDATE */
49  7, /* SYBMSTIME */
50  7, /* SYBMSDATETIME2 */
51  7, /* SYBMSDATETIMEOFFSET */
52  0, /* 44 */
53  3, /* SYBBINARY */
54  0, /* SYBINTERVAL */
55  1, /* SYBCHAR */
56  6, /* SYBINT1 */
57  7, /* SYBDATE */
58  2, /* SYBBIT */
59  7, /* SYBTIME */
60  6, /* SYBINT2 */
61  0, /* 53 */
62  0, /* 54 */
63  0, /* 55 */
64  6, /* SYBINT4 */
65  0, /* 57 */
66  7, /* SYBDATETIME4 */
67  6, /* SYBREAL */
68  6, /* SYBMONEY */
69  7, /* SYBDATETIME */
70  6, /* SYBFLT8 */
71  0, /* 63 */
72  6, /* SYBUINT1 */
73  6, /* SYBUINT2 */
74  6, /* SYBUINT4 */
75  6, /* SYBUINT8 */
76  0, /* SYBUINTN */
77  0, /* 69 */
78  0, /* 70 */
79  0, /* 71 */
80  0, /* 72 */
81  0, /* 73 */
82  0, /* 74 */
83  0, /* 75 */
84  0, /* 76 */
85  0, /* 77 */
86  0, /* 78 */
87  0, /* 79 */
88  0, /* 80 */
89  0, /* 81 */
90  0, /* 82 */
91  0, /* 83 */
92  0, /* 84 */
93  0, /* 85 */
94  0, /* 86 */
95  0, /* 87 */
96  0, /* 88 */
97  0, /* 89 */
98  0, /* 90 */
99  0, /* 91 */
100  0, /* 92 */
101  0, /* 93 */
102  0, /* 94 */
103  0, /* 95 */
104  0, /* 96 */
105  0, /* 97 */
106  0, /* SYBVARIANT */
107  0, /* SYBNTEXT */
108  0, /* 100 */
109  0, /* 101 */
110  0, /* 102 */
111  4, /* SYBSENSITIVITY */
112  2, /* SYBBOUNDARY */
113  0, /* 105 */
114  2, /* SYBDECIMAL */
115  0, /* 107 */
116  2, /* SYBNUMERIC */
117  0, /* SYBFLTN */
118  0, /* SYBMONEYN */
119  0, /* SYBDATETIMN */
120  0, /* 112 */
121  0, /* 113 */
122  0, /* 114 */
123  0, /* 115 */
124  0, /* 116 */
125  0, /* 117 */
126  0, /* 118 */
127  0, /* 119 */
128  0, /* 120 */
129  0, /* 121 */
130  6, /* SYBMONEY4 */
131  0, /* SYBDATEN */
132  0, /* 124 */
133  0, /* 125 */
134  0, /* 126 */
135  6, /* SYBINT8 */
136  0, /* 128 */
137  0, /* 129 */
138  0, /* 130 */
139  0, /* 131 */
140  0, /* 132 */
141  0, /* 133 */
142  0, /* 134 */
143  0, /* 135 */
144  0, /* 136 */
145  0, /* 137 */
146  0, /* 138 */
147  0, /* 139 */
148  0, /* 140 */
149  0, /* 141 */
150  0, /* 142 */
151  0, /* 143 */
152  0, /* 144 */
153  0, /* 145 */
154  0, /* 146 */
155  0, /* SYBTIMEN */
156  0, /* 148 */
157  0, /* 149 */
158  0, /* 150 */
159  0, /* 151 */
160  0, /* 152 */
161  0, /* 153 */
162  0, /* 154 */
163  0, /* 155 */
164  0, /* 156 */
165  0, /* 157 */
166  0, /* 158 */
167  0, /* 159 */
168  0, /* 160 */
169  0, /* 161 */
170  0, /* 162 */
171  0, /* SYBXML */
172  0, /* 164 */
173  3, /* XSYBVARBINARY */
174  0, /* 166 */
175  1, /* XSYBVARCHAR */
176  0, /* 168 */
177  0, /* 169 */
178  0, /* 170 */
179  0, /* 171 */
180  0, /* 172 */
181  3, /* XSYBBINARY */
182  0, /* SYBUNITEXT */
183  1, /* SYBLONGCHAR */
184  0, /* SYBSINT1 */
185  0, /* 177 */
186  0, /* 178 */
187  0, /* 179 */
188  0, /* 180 */
189  0, /* 181 */
190  0, /* 182 */
191  0, /* 183 */
192  0, /* 184 */
193  0, /* 185 */
194  0, /* 186 */
195  7, /* SYB5BIGDATETIME */
196  7, /* SYB5BIGTIME */
197  0, /* 189 */
198  0, /* 190 */
199  0, /* SYB5INT8 */
200  0, /* 192 */
201  0, /* 193 */
202  0, /* 194 */
203  0, /* 195 */
204  0, /* 196 */
205  0, /* 197 */
206  0, /* 198 */
207  0, /* 199 */
208  0, /* 200 */
209  0, /* 201 */
210  0, /* 202 */
211  0, /* 203 */
212  0, /* 204 */
213  0, /* 205 */
214  0, /* 206 */
215  0, /* 207 */
216  0, /* 208 */
217  0, /* 209 */
218  0, /* 210 */
219  0, /* 211 */
220  0, /* 212 */
221  0, /* 213 */
222  0, /* 214 */
223  0, /* 215 */
224  0, /* 216 */
225  0, /* 217 */
226  0, /* 218 */
227  0, /* 219 */
228  0, /* 220 */
229  0, /* 221 */
230  0, /* 222 */
231  0, /* 223 */
232  0, /* 224 */
233  3, /* SYBLONGBINARY */
234  0, /* 226 */
235  0, /* 227 */
236  0, /* 228 */
237  0, /* 229 */
238  0, /* 230 */
239  0, /* XSYBNVARCHAR */
240  0, /* 232 */
241  0, /* 233 */
242  0, /* 234 */
243  0, /* 235 */
244  0, /* 236 */
245  0, /* 237 */
246  0, /* 238 */
247  0, /* XSYBNCHAR */
248  0, /* SYBMSUDT */
249  0, /* SYBMSXML */
250  0, /* 242 */
251  0, /* 243 */
252  0, /* 244 */
253  0, /* 245 */
254  0, /* 246 */
255  0, /* 247 */
256  0, /* 248 */
257  0, /* 249 */
258  0, /* 250 */
259  0, /* 251 */
260  0, /* 252 */
261  0, /* 253 */
262  0, /* 254 */
263  0, /* 255 */
264 };
265 
266 static const TDS_UINT category_conversion[] = {
267  0,
268  238, /* SYBTEXT */
269  78, /* SYBBIT */
270  74, /* SYBIMAGE */
271  0, /* SYBSENSITIVITY */
272  42, /* SYBUNIQUE */
273  78, /* SYBINT1 */
274  138, /* SYBMSDATE */
275 };
freetds-1.00.82/doc/reference/a00345.map100644 025423 025423 00000004566 13242511134 0013053 freetds-1.00.82/doc/reference/a00345.md5100644 025423 025423 00000000040 13242511133 00127412d2237ccf8d898fca558d52a2214132ffreetds-1.00.82/doc/reference/a00345.svg100644 025423 025423 00000065213 13242511136 0013073 src/tds/token.c Node0 src/tds/token.c Node1 config.h Node0->Node1 Node2 assert.h Node0->Node2 Node3 freetds/tds.h Node0->Node3 Node12 replacements.h Node0->Node12 Node18 freetds/string.h Node0->Node18 Node19 freetds/convert.h Node0->Node19 Node20 freetds/iconv.h Node0->Node20 Node21 freetds/checks.h Node0->Node21 Node22 freetds/bytes.h Node0->Node22 Node23 freetds/alloca.h Node0->Node23 Node4 stdarg.h Node3->Node4 Node5 stdio.h Node3->Node5 Node6 time.h Node3->Node6 Node7 freetds/version.h Node3->Node7 Node8 tds_sysdep_public.h Node3->Node8 Node9 freetds/sysdep_private.h Node3->Node9 Node10 freetds/thread.h Node3->Node10 Node11 freetds/bool.h Node3->Node11 Node3->Node12 Node14 freetds/pushvis.h Node3->Node14 Node15 freetds/popvis.h Node3->Node15 Node17 freetds/proto.h Node3->Node17 Node6->Node6 Node12->Node4 Node12->Node8 Node12->Node9 Node13 replacements/readpassphrase.h Node12->Node13 Node12->Node14 Node12->Node15 Node16 replacements/poll.h Node12->Node16 Node13->Node14 Node13->Node15 Node16->Node1 Node16->Node14 Node16->Node15 Node18->Node14 Node18->Node15 Node19->Node14 Node19->Node15 Node20->Node14 Node20->Node15 Node21->Node14 Node21->Node15 Node24 stddef.h Node23->Node24 freetds-1.00.82/doc/reference/a00353_source.html100644 025423 025423 00000033556 13242511131 0014617 FreeTDS API: include/bkpublic.h Source File
FreeTDS API
bkpublic.h
1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2  * Copyright (C) 1998-1999 Brian Bruns
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 
20 #ifndef _bkpublic_h_
21 #define _bkpublic_h_
22 
23 static const char rcsid_bkpublic_h[] = "$Id: bkpublic.h,v 1.5 2004-10-28 12:42:11 freddy77 Exp $";
24 static const void *const no_unused_bkpublic_h_warn[] = { rcsid_bkpublic_h, no_unused_bkpublic_h_warn };
25 
26 /* seperate this stuff out later */
27 #include <cspublic.h>
28 
29 #ifdef __cplusplus
30 extern "C"
31 {
32 #if 0
33 }
34 #endif
35 #endif
36 
37 /* buld properties start with 1 i guess */
38 #define BLK_IDENTITY 1
39 
40 CS_RETCODE blk_alloc(CS_CONNECTION * connection, CS_INT version, CS_BLKDESC ** blk_pointer);
41 CS_RETCODE blk_bind(CS_BLKDESC * blkdesc, CS_INT colnum, CS_DATAFMT * datafmt, CS_VOID * buffer, CS_INT * datalen,
42  CS_SMALLINT * indicator);
43 CS_RETCODE blk_colval(SRV_PROC * srvproc, CS_BLKDESC * blkdescp, CS_BLK_ROW * rowp, CS_INT colnum, CS_VOID * valuep,
44  CS_INT valuelen, CS_INT * outlenp);
45 CS_RETCODE blk_default(CS_BLKDESC * blkdesc, CS_INT colnum, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen);
46 CS_RETCODE blk_describe(CS_BLKDESC * blkdesc, CS_INT colnum, CS_DATAFMT * datafmt);
47 CS_RETCODE blk_done(CS_BLKDESC * blkdesc, CS_INT type, CS_INT * outrow);
48 CS_RETCODE blk_drop(CS_BLKDESC * blkdesc);
49 CS_RETCODE blk_getrow(SRV_PROC * srvproc, CS_BLKDESC * blkdescp, CS_BLK_ROW * rowp);
50 CS_RETCODE blk_gettext(SRV_PROC * srvproc, CS_BLKDESC * blkdescp, CS_BLK_ROW * rowp, CS_INT bufsize, CS_INT * outlenp);
51 CS_RETCODE blk_init(CS_BLKDESC * blkdesc, CS_INT direction, CS_CHAR * tablename, CS_INT tnamelen);
52 CS_RETCODE blk_props(CS_BLKDESC * blkdesc, CS_INT action, CS_INT property, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen);
53 CS_RETCODE blk_rowalloc(SRV_PROC * srvproc, CS_BLK_ROW ** row);
54 CS_RETCODE blk_rowdrop(SRV_PROC * srvproc, CS_BLK_ROW * row);
55 CS_RETCODE blk_rowxfer(CS_BLKDESC * blkdesc);
56 CS_RETCODE blk_rowxfer_mult(CS_BLKDESC * blkdesc, CS_INT * row_count);
57 CS_RETCODE blk_sendrow(CS_BLKDESC * blkdesc, CS_BLK_ROW * row);
58 CS_RETCODE blk_sendtext(CS_BLKDESC * blkdesc, CS_BLK_ROW * row, CS_BYTE * buffer, CS_INT buflen);
59 CS_RETCODE blk_srvinit(SRV_PROC * srvproc, CS_BLKDESC * blkdescp);
60 CS_RETCODE blk_textxfer(CS_BLKDESC * blkdesc, CS_BYTE * buffer, CS_INT buflen, CS_INT * outlen);
61 
62 #ifdef __cplusplus
63 #if 0
64 {
65 #endif
66 }
67 #endif
68 
69 #endif
Definition: ctlib.h:114
Definition: ctlib.h:235
Definition: cstypes.h:116
freetds-1.00.82/doc/reference/a00356_source.html100644 025423 025423 00000307047 13242511131 0014621 FreeTDS API: include/config.h Source File
FreeTDS API
config.h
1 /* include/config.h. Generated from config.h.in by configure. */
2 /* include/config.h.in. Generated from configure.ac by autoheader. */
3 
4 /* Define if building universal (internal helper macro) */
5 /* #undef AC_APPLE_UNIVERSAL_BUILD */
6 
7 /* Define to 1 if you need BSD_COMP defined to get FIONBIO defined. */
8 /* #undef BSD_COMP */
9 
10 /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
11  systems. This function is required for `alloca.c' support on those systems.
12  */
13 /* #undef CRAY_STACKSEG_END */
14 
15 /* Define to 1 if using `alloca.c'. */
16 /* #undef C_ALLOCA */
17 
18 /* Define to enable work in progress code */
19 /* #undef ENABLE_DEVELOPING */
20 
21 /* Define to enable extra checks on code */
22 /* #undef ENABLE_EXTRA_CHECKS */
23 
24 /* Defined if --enable-krb5 used and library detected */
25 /* #undef ENABLE_KRB5 */
26 
27 /* Define to enable MARS support */
28 /* #undef ENABLE_ODBC_MARS */
29 
30 /* Define to enable ODBC wide string support */
31 #define ENABLE_ODBC_WIDE 1
32 
33 /* Define to 1 if GNU tls use nettle as backend. */
34 /* #undef GNUTLS_USE_NETTLE */
35 
36 /* Define to 1 if you have the `alarm' function. */
37 #define HAVE_ALARM 1
38 
39 /* Define to 1 if you have `alloca', as a function or macro. */
40 #define HAVE_ALLOCA 1
41 
42 /* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
43  */
44 /* #undef HAVE_ALLOCA_H */
45 
46 /* Define to 1 if you have the <arpa/inet.h> header file. */
47 #define HAVE_ARPA_INET_H 1
48 
49 /* Define to 1 if you have the `asprintf' function. */
50 #define HAVE_ASPRINTF 1
51 
52 /* Define to 1 if you have the `basename' function. */
53 #define HAVE_BASENAME 1
54 
55 /* Define if you have the clock_gettime function. */
56 #define HAVE_CLOCK_GETTIME 1
57 
58 /* Define to 1 if you have the <com_err.h> header file. */
59 /* #undef HAVE_COM_ERR_H */
60 
61 /* Define to 1 if you have the `daemon' function. */
62 #define HAVE_DAEMON 1
63 
64 /* Define to 1 if you have the declaration of `cygwin_conv_path', and to 0 if
65  you don't. */
66 /* #undef HAVE_DECL_CYGWIN_CONV_PATH */
67 
68 /* Define to 1 if you have the declaration of `tzname', and to 0 if you don't.
69  */
70 /* #undef HAVE_DECL_TZNAME */
71 
72 /* Define to 1 if you have the <dirent.h> header file. */
73 #define HAVE_DIRENT_H 1
74 
75 /* Define if you have the GNU dld library. */
76 /* #undef HAVE_DLD */
77 
78 /* Define to 1 if you have the `dlerror' function. */
79 #define HAVE_DLERROR 1
80 
81 /* Define to 1 if you have the <dlfcn.h> header file. */
82 #define HAVE_DLFCN_H 1
83 
84 /* Define if you have the _dyld_func_lookup function. */
85 /* #undef HAVE_DYLD */
86 
87 /* Define to 1 if you have the <errno.h> header file. */
88 #define HAVE_ERRNO_H 1
89 
90 /* Define to 1 if you have the `error_message' function. */
91 /* #undef HAVE_ERROR_MESSAGE */
92 
93 /* Define to 1 if you have the `eventfd' function. */
94 /* #undef HAVE_EVENTFD */
95 
96 /* Define to 1 if you have the <fcntl.h> header file. */
97 #define HAVE_FCNTL_H 1
98 
99 /* Define to 1 if you have the `fork' function. */
100 #define HAVE_FORK 1
101 
102 /* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
103 #define HAVE_FSEEKO 1
104 
105 /* Define to 1 if you have the `fstat' function. */
106 #define HAVE_FSTAT 1
107 
108 /* Define to 1 if your system provides the 5-parameter version of
109  gethostbyaddr_r(). */
110 /* #undef HAVE_FUNC_GETHOSTBYADDR_R_5 */
111 
112 /* Define to 1 if your system provides the 7-parameter version of
113  gethostbyaddr_r(). */
114 #define HAVE_FUNC_GETHOSTBYADDR_R_7 1
115 
116 /* Define to 1 if your system provides the 8-parameter version of
117  gethostbyaddr_r(). */
118 /* #undef HAVE_FUNC_GETHOSTBYADDR_R_8 */
119 
120 /* Define to 1 if your system provides the 3-parameter version of
121  gethostbyname_r(). */
122 /* #undef HAVE_FUNC_GETHOSTBYNAME_R_3 */
123 
124 /* Define to 1 if your system provides the 5-parameter version of
125  gethostbyname_r(). */
126 /* #undef HAVE_FUNC_GETHOSTBYNAME_R_5 */
127 
128 /* Define to 1 if your system provides the 6-parameter version of
129  gethostbyname_r(). */
130 #define HAVE_FUNC_GETHOSTBYNAME_R_6 1
131 
132 /* Define to 1 if your system provides the 4-parameter version of
133  getpwuid_r(). */
134 /* #undef HAVE_FUNC_GETPWUID_R_4 */
135 
136 /* Define to 1 if your system getpwuid_r() have 4 parameters and return struct
137  passwd*. */
138 /* #undef HAVE_FUNC_GETPWUID_R_4_PW */
139 
140 /* Define to 1 if your system provides the 5-parameter version of
141  getpwuid_r(). */
142 #define HAVE_FUNC_GETPWUID_R_5 1
143 
144 /* Define to 1 if your system provides the 4-parameter version of
145  getservbyname_r(). */
146 /* #undef HAVE_FUNC_GETSERVBYNAME_R_4 */
147 
148 /* Define to 1 if your system provides the 5-parameter version of
149  getservbyname_r(). */
150 /* #undef HAVE_FUNC_GETSERVBYNAME_R_5 */
151 
152 /* Define to 1 if your system provides the 6-parameter version of
153  getservbyname_r(). */
154 #define HAVE_FUNC_GETSERVBYNAME_R_6 1
155 
156 /* Define to 1 if your localtime_r return a int. */
157 /* #undef HAVE_FUNC_LOCALTIME_R_INT */
158 
159 /* Define to 1 if your localtime_r return a struct tm*. */
160 #define HAVE_FUNC_LOCALTIME_R_TM 1
161 
162 /* Define if you have getaddrinfo function */
163 #define HAVE_GETADDRINFO 1
164 
165 /* Define to 1 if you have the `gethostname' function. */
166 #define HAVE_GETHOSTNAME 1
167 
168 /* Define to 1 if you have the `gethrtime' function. */
169 /* #undef HAVE_GETHRTIME */
170 
171 /* Define to 1 if you have the `getipnodebyaddr' function. */
172 /* #undef HAVE_GETIPNODEBYADDR */
173 
174 /* Define to 1 if you have the `getipnodebyname' function. */
175 /* #undef HAVE_GETIPNODEBYNAME */
176 
177 /* Define to 1 if you have the `getopt' function. */
178 #define HAVE_GETOPT 1
179 
180 /* Define to 1 if you have the <getopt.h> header file. */
181 #define HAVE_GETOPT_H 1
182 
183 /* Define if your getopt(3) defines and uses optreset */
184 #define HAVE_GETOPT_OPTRESET 1
185 
186 /* Define to 1 if you have the `getpwuid' function. */
187 #define HAVE_GETPWUID 1
188 
189 /* Define to 1 if you have the `getpwuid_r' function. */
190 #define HAVE_GETPWUID_R 1
191 
192 /* Define to 1 if you have the `gettimeofday' function. */
193 #define HAVE_GETTIMEOFDAY 1
194 
195 /* Define to 1 if you have the `getuid' function. */
196 #define HAVE_GETUID 1
197 
198 /* Define if you have GMP library */
199 /* #undef HAVE_GMP */
200 
201 /* Define to 1 if you have GnuTLS. */
202 /* #undef HAVE_GNUTLS */
203 
204 /* Define to 1 if you have the <gnutls/abstract.h> header file. */
205 /* #undef HAVE_GNUTLS_ABSTRACT_H */
206 
207 /* Define to 1 if you have the `gnutls_certificate_set_verify_function'
208  function. */
209 /* #undef HAVE_GNUTLS_CERTIFICATE_SET_VERIFY_FUNCTION */
210 
211 /* Define to 1 if you have the `gnutls_record_disable_padding' function. */
212 /* #undef HAVE_GNUTLS_RECORD_DISABLE_PADDING */
213 
214 /* Define to 1 if you have the `gnutls_rnd' function. */
215 /* #undef HAVE_GNUTLS_RND */
216 
217 /* Define if you have the iconv() function and it works. */
218 #define HAVE_ICONV 1
219 
220 /* Define to 1 if you have the `inet_ntoa_r' function. */
221 /* #undef HAVE_INET_NTOA_R */
222 
223 /* Define to 1 if you have the `inet_ntop' function. */
224 #define HAVE_INET_NTOP 1
225 
226 /* Define to 1 if you have the <inttypes.h> header file. */
227 #define HAVE_INTTYPES_H 1
228 
229 /* Define to 1 if you have the <iodbcinst.h> header file. */
230 /* #undef HAVE_IODBCINST_H */
231 
232 /* Define to 1 if you have the <langinfo.h> header file. */
233 #define HAVE_LANGINFO_H 1
234 
235 /* Define if you have the libdl library or equivalent. */
236 #define HAVE_LIBDL 1
237 
238 /* Define if libdlloader will be built on this platform */
239 #define HAVE_LIBDLLOADER 1
240 
241 /* Define to 1 if you have the <libgen.h> header file. */
242 #define HAVE_LIBGEN_H 1
243 
244 /* Define to 1 if you have the <limits.h> header file. */
245 #define HAVE_LIMITS_H 1
246 
247 /* Define to 1 if you have the <localcharset.h> header file. */
248 /* #undef HAVE_LOCALCHARSET_H */
249 
250 /* Define to 1 if you have the `locale_charset' function. */
251 /* #undef HAVE_LOCALE_CHARSET */
252 
253 /* Define to 1 if you have the <locale.h> header file. */
254 #define HAVE_LOCALE_H 1
255 
256 /* Define to 1 if you have the `localtime_r' function. */
257 #define HAVE_LOCALTIME_R 1
258 
259 /* Define to 1 if you have the <malloc.h> header file. */
260 #define HAVE_MALLOC_H 1
261 
262 /* Define to 1 if your system provides the malloc_options variable. */
263 /* #undef HAVE_MALLOC_OPTIONS */
264 
265 /* Define to 1 if you have the <memory.h> header file. */
266 #define HAVE_MEMORY_H 1
267 
268 /* Define to 1 if you have the `nanosleep' function. */
269 #define HAVE_NANOSLEEP 1
270 
271 /* Define to 1 if you have the <netdb.h> header file. */
272 #define HAVE_NETDB_H 1
273 
274 /* Define to 1 if you have the <netinet/in.h> header file. */
275 #define HAVE_NETINET_IN_H 1
276 
277 /* Define to 1 if you have the <netinet/tcp.h> header file. */
278 #define HAVE_NETINET_TCP_H 1
279 
280 /* Define to 1 if nettle is present. */
281 /* #undef HAVE_NETTLE */
282 
283 /* Define to 1 if you have the `nl_langinfo' function. */
284 #define HAVE_NL_LANGINFO 1
285 
286 /* Define if you have the OpenSSL. */
287 #define HAVE_OPENSSL 1
288 
289 /* Define to 1 if you have the <paths.h> header file. */
290 #define HAVE_PATHS_H 1
291 
292 /* Define to 1 if you have the `poll' function. */
293 #define HAVE_POLL 1
294 
295 /* Define to 1 if you have the <poll.h> header file. */
296 #define HAVE_POLL_H 1
297 
298 /* Define if you have POSIX threads libraries and header files. */
299 #define HAVE_PTHREAD 1
300 
301 /* Define to 1 if you have the `pthread_condattr_setclock' function. */
302 #define HAVE_PTHREAD_CONDATTR_SETCLOCK 1
303 
304 /* Define to 1 if you have the `pthread_cond_timedwait' function. */
305 #define HAVE_PTHREAD_COND_TIMEDWAIT 1
306 
307 /* Define to 1 if you have the `pthread_cond_timedwait_relative_np' function.
308  */
309 /* #undef HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE_NP */
310 
311 /* Define to 1 if you have the `putenv' function. */
312 #define HAVE_PUTENV 1
313 
314 /* Define to 1 if you have the `readdir_r' function. */
315 #define HAVE_READDIR_R 1
316 
317 /* Define to 1 if you have the GNU Readline library. */
318 /* #undef HAVE_READLINE */
319 
320 /* Define to 1 if you have the `readpassphrase' function. */
321 /* #undef HAVE_READPASSPHRASE */
322 
323 /* Define to 1 if you have rl_inhibit_completion. */
324 /* #undef HAVE_RL_INHIBIT_COMPLETION */
325 
326 /* Define to 1 if you have the `rl_on_new_line' function. */
327 /* #undef HAVE_RL_ON_NEW_LINE */
328 
329 /* Define to 1 if you have the `rl_reset_line_state' function. */
330 /* #undef HAVE_RL_RESET_LINE_STATE */
331 
332 /* Define to 1 if you have the <roken.h> header file. */
333 /* #undef HAVE_ROKEN_H */
334 
335 /* Define to 1 if you have the `setenv' function. */
336 #define HAVE_SETENV 1
337 
338 /* Define to 1 if you have the `setitimer' function. */
339 #define HAVE_SETITIMER 1
340 
341 /* Define to 1 if you have the `setrlimit' function. */
342 #define HAVE_SETRLIMIT 1
343 
344 /* Define if you have the shl_load function. */
345 /* #undef HAVE_SHL_LOAD */
346 
347 /* Define to 1 if you have the <signal.h> header file. */
348 #define HAVE_SIGNAL_H 1
349 
350 /* Define to 1 if you have the `socketpair' function. */
351 #define HAVE_SOCKETPAIR 1
352 
353 /* Define to 1 if you have the SQLGetPrivateProfileString function. */
354 /* #undef HAVE_SQLGETPRIVATEPROFILESTRING */
355 
356 /* Define if sqltypes.h define SQLLEN */
357 /* #undef HAVE_SQLLEN */
358 
359 /* Define to 1 if the system has the type `SQLROWOFFSET'. */
360 /* #undef HAVE_SQLROWOFFSET */
361 
362 /* Define to 1 if the system has the type `SQLROWSETSIZE'. */
363 /* #undef HAVE_SQLROWSETSIZE */
364 
365 /* Define to 1 if the system has the type `SQLSETPOSIROW'. */
366 /* #undef HAVE_SQLSETPOSIROW */
367 
368 /* Define to 1 if you have the <sql.h> header file. */
369 /* #undef HAVE_SQL_H */
370 
371 /* Defined if not --disable-sspi and SSPI detected */
372 /* #undef HAVE_SSPI */
373 
374 /* Define to 1 if you have the <stdbool.h> header file. */
375 #define HAVE_STDBOOL_H 1
376 
377 /* Define to 1 if you have the <stddef.h> header file. */
378 #define HAVE_STDDEF_H 1
379 
380 /* Define to 1 if you have the <stdint.h> header file. */
381 #define HAVE_STDINT_H 1
382 
383 /* Define to 1 if you have the <stdlib.h> header file. */
384 #define HAVE_STDLIB_H 1
385 
386 /* Define to 1 if you have the <strings.h> header file. */
387 #define HAVE_STRINGS_H 1
388 
389 /* Define to 1 if you have the <string.h> header file. */
390 #define HAVE_STRING_H 1
391 
392 /* Define to 1 if you have the `strlcat' function. */
393 #define HAVE_STRLCAT 1
394 
395 /* Define to 1 if you have the `strlcpy' function. */
396 #define HAVE_STRLCPY 1
397 
398 /* Define to 1 if you have the `strsep' function. */
399 #define HAVE_STRSEP 1
400 
401 /* Define to 1 if you have the `strtok_r' function. */
402 #define HAVE_STRTOK_R 1
403 
404 /* Define to 1 if `tm_zone' is a member of `struct tm'. */
405 #define HAVE_STRUCT_TM_TM_ZONE 1
406 
407 /* Define to 1 if `__tm_zone' is a member of `struct tm'. */
408 /* #undef HAVE_STRUCT_TM___TM_ZONE */
409 
410 /* Define to 1 if you have the <sys/eventfd.h> header file. */
411 /* #undef HAVE_SYS_EVENTFD_H */
412 
413 /* Define to 1 if you have the <sys/ioctl.h> header file. */
414 #define HAVE_SYS_IOCTL_H 1
415 
416 /* Define to 1 if you have the <sys/param.h> header file. */
417 #define HAVE_SYS_PARAM_H 1
418 
419 /* Define to 1 if you have the <sys/resource.h> header file. */
420 #define HAVE_SYS_RESOURCE_H 1
421 
422 /* Define to 1 if you have the <sys/select.h> header file. */
423 #define HAVE_SYS_SELECT_H 1
424 
425 /* Define to 1 if you have the <sys/socket.h> header file. */
426 #define HAVE_SYS_SOCKET_H 1
427 
428 /* Define to 1 if you have the <sys/stat.h> header file. */
429 #define HAVE_SYS_STAT_H 1
430 
431 /* Define to 1 if you have the <sys/time.h> header file. */
432 #define HAVE_SYS_TIME_H 1
433 
434 /* Define to 1 if you have the <sys/types.h> header file. */
435 #define HAVE_SYS_TYPES_H 1
436 
437 /* Define to 1 if you have the <sys/wait.h> header file. */
438 #define HAVE_SYS_WAIT_H 1
439 
440 /* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use
441  `HAVE_STRUCT_TM_TM_ZONE' instead. */
442 #define HAVE_TM_ZONE 1
443 
444 /* Define to 1 if you don't have `tm_zone' but do have the external array
445  `tzname'. */
446 /* #undef HAVE_TZNAME */
447 
448 /* Define to 1 if you have the <unistd.h> header file. */
449 #define HAVE_UNISTD_H 1
450 
451 /* Define to 1 if you have the `usleep' function. */
452 #define HAVE_USLEEP 1
453 
454 /* Define to 1 if you have the <valgrind/memcheck.h> header file. */
455 /* #undef HAVE_VALGRIND_MEMCHECK_H */
456 
457 /* Define to 1 if you have the `vasprintf' function. */
458 #define HAVE_VASPRINTF 1
459 
460 /* Define to 1 if you have the `vsnprintf' function. */
461 #define HAVE_VSNPRINTF 1
462 
463 /* Define to 1 if you have the <wchar.h> header file. */
464 #define HAVE_WCHAR_H 1
465 
466 /* Define to 1 if you have the <windows.h> header file. */
467 /* #undef HAVE_WINDOWS_H */
468 
469 /* Define to 1 if you have the <winsock2.h> header file. */
470 /* #undef HAVE_WINSOCK2_H */
471 
472 /* Define to 1 if you have the `_fseeki64' function. */
473 /* #undef HAVE__FSEEKI64 */
474 
475 /* Define to 1 if you have the `_ftelli64' function. */
476 /* #undef HAVE__FTELLI64 */
477 
478 /* Define to 1 if you have the `_lock_file' function. */
479 /* #undef HAVE__LOCK_FILE */
480 
481 /* Define to 1 if you have the `_unlock_file' function. */
482 /* #undef HAVE__UNLOCK_FILE */
483 
484 /* Define to 1 if you have the `_vscprintf' function. */
485 /* #undef HAVE__VSCPRINTF */
486 
487 /* Define to 1 if you have the `_vsnprintf' function. */
488 #define HAVE__VSNPRINTF 1
489 
490 /* Define to 1 if you have the `_xpg_accept' function. */
491 /* #undef HAVE__XPG_ACCEPT */
492 
493 /* Define to 1 if you have the `_xpg_getpeername' function. */
494 /* #undef HAVE__XPG_GETPEERNAME */
495 
496 /* Define to 1 if you have the `_xpg_getsockname' function. */
497 /* #undef HAVE__XPG_GETSOCKNAME */
498 
499 /* Define to 1 if you have the `_xpg_getsockopt' function. */
500 /* #undef HAVE__XPG_GETSOCKOPT */
501 
502 /* Define to 1 if you have the `_xpg_recvfrom' function. */
503 /* #undef HAVE__XPG_RECVFROM */
504 
505 /* Define to 1 if you have the `__accept' function. */
506 /* #undef HAVE___ACCEPT */
507 
508 /* Define to 1 if you have the `__getpeername' function. */
509 /* #undef HAVE___GETPEERNAME */
510 
511 /* Define to 1 if you have the `__getsockname' function. */
512 /* #undef HAVE___GETSOCKNAME */
513 
514 /* Define to 1 if you have the `__getsockopt' function. */
515 /* #undef HAVE___GETSOCKOPT */
516 
517 /* Define to 1 if you have the `__recvfrom' function. */
518 /* #undef HAVE___RECVFROM */
519 
520 /* Define as const if the declaration of iconv() needs const. */
521 #define ICONV_CONST const
522 
523 /* Define to value of INADDR_NONE if not provided by your system header files.
524  */
525 /* #undef INADDR_NONE */
526 
527 /* Define to the sub-directory where libtool stores uninstalled libraries. */
528 #define LT_OBJDIR ".libs/"
529 
530 /* Define to 1 if the BSD-style netdb interface is reentrant. */
531 /* #undef NETDB_REENTRANT */
532 
533 /* Define to 1 if memset(0) sets pointers to NULL. */
534 #define NULL_REP_IS_ZERO_BYTES 1
535 
536 /* Name of package */
537 #define PACKAGE "freetds"
538 
539 /* Define to the address where bug reports for this package should be sent. */
540 #define PACKAGE_BUGREPORT ""
541 
542 /* Define to the full name of this package. */
543 #define PACKAGE_NAME "FreeTDS"
544 
545 /* Define to the full name and version of this package. */
546 #define PACKAGE_STRING "FreeTDS 1.00.82"
547 
548 /* Define to the one symbol short name of this package. */
549 #define PACKAGE_TARNAME "freetds"
550 
551 /* Define to the home page for this package. */
552 #define PACKAGE_URL ""
553 
554 /* Define to the version of this package. */
555 #define PACKAGE_VERSION "1.00.82"
556 
557 /* Define to necessary symbol if this constant uses a non-standard name on
558  your system. */
559 /* #undef PTHREAD_CREATE_JOINABLE */
560 
561 /* The size of `char', as computed by sizeof. */
562 #define SIZEOF_CHAR 1
563 
564 /* The size of `double', as computed by sizeof. */
565 #define SIZEOF_DOUBLE 8
566 
567 /* The size of `float', as computed by sizeof. */
568 #define SIZEOF_FLOAT 4
569 
570 /* The size of `int', as computed by sizeof. */
571 #define SIZEOF_INT 4
572 
573 /* The size of `long', as computed by sizeof. */
574 #define SIZEOF_LONG 8
575 
576 /* The size of `long double', as computed by sizeof. */
577 #define SIZEOF_LONG_DOUBLE 16
578 
579 /* The size of `long long', as computed by sizeof. */
580 #define SIZEOF_LONG_LONG 8
581 
582 /* The size of `short', as computed by sizeof. */
583 #define SIZEOF_SHORT 2
584 
585 /* The size of `SQLWCHAR', as computed by sizeof. */
586 #define SIZEOF_SQLWCHAR 0
587 
588 /* The size of `void *', as computed by sizeof. */
589 #define SIZEOF_VOID_P 8
590 
591 /* The size of `wchar_t', as computed by sizeof. */
592 #define SIZEOF_WCHAR_T 4
593 
594 /* The size of `__int64', as computed by sizeof. */
595 #define SIZEOF___INT64 0
596 
597 /* If using the C implementation of alloca, define if you know the
598  direction of stack growth for your system; otherwise it will be
599  automatically deduced at runtime.
600  STACK_DIRECTION > 0 => grows toward higher addresses
601  STACK_DIRECTION < 0 => grows toward lower addresses
602  STACK_DIRECTION = 0 => direction of growth unknown */
603 /* #undef STACK_DIRECTION */
604 
605 /* Define to 1 if you have the ANSI C header files. */
606 #define STDC_HEADERS 1
607 
608 /* Define to use TDS 4.2 by default */
609 /* #undef TDS42 */
610 
611 /* Define to use TDS 4.6 by default */
612 /* #undef TDS46 */
613 
614 /* Define to use TDS 5.0 by default */
615 /* #undef TDS50 */
616 
617 /* Define to use TDS 7.0 by default */
618 /* #undef TDS70 */
619 
620 /* Define to use TDS 7.1 by default */
621 /* #undef TDS71 */
622 
623 /* Define to use TDS 7.2 by default */
624 /* #undef TDS72 */
625 
626 /* Define to use TDS 7.3 by default */
627 /* #undef TDS73 */
628 
629 /* Define to use TDS 7.4 by default */
630 /* #undef TDS74 */
631 
632 /* Define to 1 if your compiler supports __attribute__((destructor)). */
633 #define TDS_ATTRIBUTE_DESTRUCTOR 1
634 
635 /* define to constant to use for clock_gettime */
636 #define TDS_GETTIMEMILLI_CONST CLOCK_MONOTONIC
637 
638 /* Define if you have pthread with mutex support */
639 #define TDS_HAVE_PTHREAD_MUTEX 1
640 
641 /* Define if stdio support locking */
642 #define TDS_HAVE_STDIO_LOCKED 1
643 
644 /* define to prefix format string used for 64bit integers */
645 #define TDS_I64_PREFIX "l"
646 
647 /* Define if you don't care about thread safety */
648 /* #undef TDS_NO_THREADSAFE */
649 
650 /* Define to 1 if last argument of SQLColAttribute it's SQLLEN * */
651 /* #undef TDS_SQLCOLATTRIBUTE_SQLLEN */
652 
653 /* Define to 1 if SQLParamOptions accept SQLULEN as arguments */
654 /* #undef TDS_SQLPARAMOPTIONS_SQLLEN */
655 
656 /* Defined if --enable-sybase-compat used */
657 /* #undef TDS_SYBASE_COMPAT */
658 
659 /* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
660 #define TIME_WITH_SYS_TIME 1
661 
662 /* Define to 1 if your <sys/time.h> declares `struct tm'. */
663 /* #undef TM_IN_SYS_TIME */
664 
665 /* Enable extensions on AIX 3, Interix. */
666 #ifndef _ALL_SOURCE
667 # define _ALL_SOURCE 1
668 #endif
669 /* Enable GNU extensions on systems that have them. */
670 #ifndef _GNU_SOURCE
671 # define _GNU_SOURCE 1
672 #endif
673 /* Enable threading extensions on Solaris. */
674 #ifndef _POSIX_PTHREAD_SEMANTICS
675 # define _POSIX_PTHREAD_SEMANTICS 1
676 #endif
677 /* Enable extensions on HP NonStop. */
678 #ifndef _TANDEM_SOURCE
679 # define _TANDEM_SOURCE 1
680 #endif
681 /* Enable general extensions on Solaris. */
682 #ifndef __EXTENSIONS__
683 # define __EXTENSIONS__ 1
684 #endif
685 
686 
687 /* Version number of package */
688 #define VERSION "1.00.82"
689 
690 /* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
691  significant byte first (like Motorola and SPARC, unlike Intel). */
692 #if defined AC_APPLE_UNIVERSAL_BUILD
693 # if defined __BIG_ENDIAN__
694 # define WORDS_BIGENDIAN 1
695 # endif
696 #else
697 # ifndef WORDS_BIGENDIAN
698 /* # undef WORDS_BIGENDIAN */
699 # endif
700 #endif
701 
702 /* Enable large inode numbers on Mac OS X 10.5. */
703 #ifndef _DARWIN_USE_64_BIT_INODE
704 # define _DARWIN_USE_64_BIT_INODE 1
705 #endif
706 
707 /* Number of bits in a file offset, on hosts where this is settable. */
708 /* #undef _FILE_OFFSET_BITS */
709 
710 /* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */
711 /* #undef _LARGEFILE_SOURCE */
712 
713 /* Define for large files, on AIX-style hosts. */
714 /* #undef _LARGE_FILES */
715 
716 /* Define to 1 if on MINIX. */
717 /* #undef _MINIX */
718 
719 /* Define to 2 if the system does not provide POSIX.1 features except with
720  this defined. */
721 /* #undef _POSIX_1_SOURCE */
722 
723 /* Define to 1 if you need to in order for `stat' and other things to work. */
724 /* #undef _POSIX_SOURCE */
725 
726 /* Define to empty if `const' does not conform to ANSI C. */
727 /* #undef const */
728 
729 /* Define to `__inline__' or `__inline' if that's what the C compiler
730  calls it, or to nothing if 'inline' is not supported under any name. */
731 #ifndef __cplusplus
732 /* #undef inline */
733 #endif
734 
735 /* Define to `unsigned int' if <sys/types.h> does not define. */
736 /* #undef size_t */
737 
738 /* type to use in place of socklen_t if not defined */
739 /* #undef socklen_t */
freetds-1.00.82/doc/reference/a00359_source.html100644 025423 025423 00000330032 13242511131 0014612 FreeTDS API: include/cspublic.h Source File
FreeTDS API
cspublic.h
1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2  * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Brian Bruns
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 
20 #ifndef _cspublic_h_
21 #define _cspublic_h_
22 
23 #include <cstypes.h>
24 
25 #undef TDS_STATIC_CAST
26 #ifdef __cplusplus
27 #define TDS_STATIC_CAST(type, a) static_cast<type>(a)
28 extern "C"
29 {
30 #if 0
31 }
32 #endif
33 #else
34 #define TDS_STATIC_CAST(type, a) ((type)(a))
35 #endif
36 
37 #define CS_PUBLIC
38 #define CS_STATIC static
39 
40 #define CS_SUCCEED 1
41 #define CS_FAIL 0
42 #define CS_MEM_ERROR -1
43 #define CS_PENDING -2
44 #define CS_QUIET -3
45 #define CS_BUSY -4
46 #define CS_INTERRUPT -5
47 #define CS_BLK_HAS_TEXT -6
48 #define CS_CONTINUE -7
49 #define CS_FATAL -8
50 #define CS_RET_HAFAILOVER -9
51 #define CS_UNSUPPORTED -10
52 
53 #define CS_CANCELED -202
54 #define CS_ROW_FAIL -203
55 #define CS_END_DATA -204
56 #define CS_END_RESULTS -205
57 #define CS_END_ITEM -206
58 #define CS_NOMSG -207
59 #define CS_TIMED_OUT -208
60 
61 #define CS_SIZEOF(x) sizeof(x)
62 
63 #define CS_LAYER(x) (((x) >> 24) & 0xFF)
64 #define CS_ORIGIN(x) (((x) >> 16) & 0xFF)
65 #define CS_SEVERITY(x) (((x) >> 8) & 0xFF)
66 #define CS_NUMBER(x) ((x) & 0xFF)
67 
68 /* forward declarations */
69 typedef CS_RETCODE(*CS_CSLIBMSG_FUNC) (CS_CONTEXT *, CS_CLIENTMSG *);
70 typedef CS_RETCODE(*CS_CLIENTMSG_FUNC) (CS_CONTEXT *, CS_CONNECTION *, CS_CLIENTMSG *);
71 typedef CS_RETCODE(*CS_SERVERMSG_FUNC) (CS_CONTEXT *, CS_CONNECTION *, CS_SERVERMSG *);
72 
73 
74 #define CS_IODATA TDS_STATIC_CAST(CS_INT, 1600)
75 #define CS_SRC_VALUE -2562
76 
77 
78 
79 /* status bits for CS_SERVERMSG */
80 #define CS_HASEED 0x01
81 
82 typedef struct _cs_blkdesc CS_BLKDESC;
83 
84 /* CS_CAP_REQUEST values */
85 #define CS_REQ_LANG 1
86 #define CS_REQ_RPC 2
87 #define CS_REQ_NOTIF 3
88 #define CS_REQ_MSTMT 4
89 #define CS_REQ_BCP 5
90 #define CS_REQ_CURSOR 6
91 #define CS_REQ_DYN 7
92 #define CS_REQ_MSG 8
93 #define CS_REQ_PARAM 9
94 #define CS_DATA_INT1 10
95 #define CS_DATA_INT2 11
96 #define CS_DATA_INT4 12
97 #define CS_DATA_BIT 13
98 #define CS_DATA_CHAR 14
99 #define CS_DATA_VCHAR 15
100 #define CS_DATA_BIN 16
101 #define CS_DATA_VBIN 17
102 #define CS_DATA_MNY8 18
103 #define CS_DATA_MNY4 19
104 #define CS_DATA_DATE8 20
105 #define CS_DATA_DATE4 21
106 #define CS_DATA_FLT4 22
107 #define CS_DATA_FLT8 23
108 #define CS_DATA_NUM 24
109 #define CS_DATA_TEXT 25
110 #define CS_DATA_IMAGE 26
111 #define CS_DATA_DEC 27
112 #define CS_DATA_LCHAR 28
113 #define CS_DATA_LBIN 29
114 #define CS_DATA_INTN 30
115 #define CS_DATA_DATETIMEN 31
116 #define CS_DATA_MONEYN 32
117 #define CS_CSR_PREV 33
118 #define CS_CSR_FIRST 34
119 #define CS_CSR_LAST 35
120 #define CS_CSR_ABS 36
121 #define CS_CSR_REL 37
122 #define CS_CSR_MULTI 38
123 #define CS_CON_OOB 39
124 #define CS_CON_INBAND 40
125 #define CS_CON_LOGICAL 41
126 #define CS_PROTO_TEXT 42
127 #define CS_PROTO_BULK 43
128 #define CS_REQ_URGNOTIF 44
129 #define CS_DATA_SENSITIVITY 45
130 #define CS_DATA_BOUNDARY 46
131 #define CS_PROTO_DYNAMIC 47
132 #define CS_PROTO_DYNPROC 48
133 #define CS_DATA_FLTN 49
134 #define CS_DATA_BITN 50
135 #define CS_OPTION_GET 51
136 #define CS_DATA_INT8 52
137 #define CS_DATA_VOID 53
138 
139 /* CS_CAP_RESPONSE values */
140 #define CS_RES_NOMSG 1
141 #define CS_RES_NOEED 2
142 #define CS_RES_NOPARAM 3
143 #define CS_DATA_NOINT1 4
144 #define CS_DATA_NOINT2 5
145 #define CS_DATA_NOINT4 6
146 #define CS_DATA_NOBIT 7
147 #define CS_DATA_NOCHAR 8
148 #define CS_DATA_NOVCHAR 9
149 #define CS_DATA_NOBIN 10
150 #define CS_DATA_NOVBIN 11
151 #define CS_DATA_NOMNY8 12
152 #define CS_DATA_NOMNY4 13
153 #define CS_DATA_NODATE8 14
154 #define CS_DATA_NODATE4 15
155 #define CS_DATA_NOFLT4 16
156 #define CS_DATA_NOFLT8 17
157 #define CS_DATA_NONUM 18
158 #define CS_DATA_NOTEXT 19
159 #define CS_DATA_NOIMAGE 20
160 #define CS_DATA_NODEC 21
161 #define CS_DATA_NOLCHAR 22
162 #define CS_DATA_NOLBIN 23
163 #define CS_DATA_NOINTN 24
164 #define CS_DATA_NODATETIMEN 25
165 #define CS_DATA_NOMONEYN 26
166 #define CS_CON_NOOOB 27
167 #define CS_CON_NOINBAND 28
168 #define CS_PROTO_NOTEXT 29
169 #define CS_PROTO_NOBULK 30
170 #define CS_DATA_NOSENSITIVITY 31
171 #define CS_DATA_NOBOUNDARY 32
172 #define CS_RES_NOTDSDEBUG 33
173 #define CS_RES_NOSTRIPBLANKS 34
174 #define CS_DATA_NOINT8 35
175 
176 /* Properties */
177 enum
178 {
179 /*
180  * These defines looks weird but programs can test support for defines,
181  * compiler can check enum and there are no define side effecs
182  */
183  CS_USERNAME = 9100,
184 #define CS_USERNAME CS_USERNAME
185  CS_PASSWORD = 9101,
186 #define CS_PASSWORD CS_PASSWORD
187  CS_APPNAME = 9102,
188 #define CS_APPNAME CS_APPNAME
189  CS_HOSTNAME = 9103,
190 #define CS_HOSTNAME CS_HOSTNAME
191  CS_LOGIN_STATUS = 9104,
192 #define CS_LOGIN_STATUS CS_LOGIN_STATUS
193  CS_TDS_VERSION = 9105,
194 #define CS_TDS_VERSION CS_TDS_VERSION
195  CS_CHARSETCNV = 9106,
196 #define CS_CHARSETCNV CS_CHARSETCNV
197  CS_PACKETSIZE = 9107,
198 #define CS_PACKETSIZE CS_PACKETSIZE
199  CS_USERDATA = 9108,
200 #define CS_USERDATA CS_USERDATA
201  CS_NETIO = 9110,
202 #define CS_NETIO CS_NETIO
203  CS_TEXTLIMIT = 9112,
204 #define CS_TEXTLIMIT CS_TEXTLIMIT
205  CS_HIDDEN_KEYS = 9113,
206 #define CS_HIDDEN_KEYS CS_HIDDEN_KEYS
207  CS_VERSION = 9114,
208 #define CS_VERSION CS_VERSION
209  CS_IFILE = 9115,
210 #define CS_IFILE CS_IFILE
211  CS_LOGIN_TIMEOUT = 9116,
212 #define CS_LOGIN_TIMEOUT CS_LOGIN_TIMEOUT
213  CS_TIMEOUT = 9117,
214 #define CS_TIMEOUT CS_TIMEOUT
215  CS_MAX_CONNECT = 9118,
216 #define CS_MAX_CONNECT CS_MAX_CONNECT
217  CS_EXPOSE_FMTS = 9120,
218 #define CS_EXPOSE_FMTS CS_EXPOSE_FMTS
219  CS_EXTRA_INF = 9121,
220 #define CS_EXTRA_INF CS_EXTRA_INF
221  CS_ANSI_BINDS = 9123,
222 #define CS_ANSI_BINDS CS_ANSI_BINDS
223  CS_BULK_LOGIN = 9124,
224 #define CS_BULK_LOGIN CS_BULK_LOGIN
225  CS_LOC_PROP = 9125,
226 #define CS_LOC_PROP CS_LOC_PROP
227  CS_PARENT_HANDLE = 9130,
228 #define CS_PARENT_HANDLE CS_PARENT_HANDLE
229  CS_EED_CMD = 9131,
230 #define CS_EED_CMD CS_EED_CMD
231  CS_DIAG_TIMEOUT = 9132,
232 #define CS_DIAG_TIMEOUT CS_DIAG_TIMEOUT
233  CS_DISABLE_POLL = 9133,
234 #define CS_DISABLE_POLL CS_DISABLE_POLL
235  CS_SEC_ENCRYPTION = 9135,
236 #define CS_SEC_ENCRYPTION CS_SEC_ENCRYPTION
237  CS_SEC_CHALLENGE = 9136,
238 #define CS_SEC_CHALLENGE CS_SEC_CHALLENGE
239  CS_SEC_NEGOTIATE = 9137,
240 #define CS_SEC_NEGOTIATE CS_SEC_NEGOTIATE
241  CS_CON_STATUS = 9143,
242 #define CS_CON_STATUS CS_CON_STATUS
243  CS_VER_STRING = 9144,
244 #define CS_VER_STRING CS_VER_STRING
245  CS_SERVERNAME = 9146,
246 #define CS_SERVERNAME CS_SERVERNAME
247  CS_SEC_APPDEFINED = 9149,
248 #define CS_SEC_APPDEFINED CS_SEC_APPDEFINED
249  CS_STICKY_BINDS = 9151,
250 #define CS_STICKY_BINDS CS_STICKY_BINDS
251  CS_SERVERADDR = 9206,
252 #define CS_SERVERADDR CS_SERVERADDR
253  CS_PORT = 9300
254 #define CS_PORT CS_PORT
255 };
256 
257 /* Arbitrary precision math operators */
258 enum
259 {
260  CS_ADD = 1,
261  CS_SUB,
262  CS_MULT,
263  CS_DIV
264 };
265 
266 enum
267 {
268  CS_TDS_40 = 7360,
269  CS_TDS_42,
270  CS_TDS_46,
271  CS_TDS_495,
272  CS_TDS_50,
273  CS_TDS_70,
274  CS_TDS_71,
275  CS_TDS_72,
276  CS_TDS_73,
277  CS_TDS_74,
278 };
279 
280 /* bit mask values used by CS_DATAFMT.status */
281 #define CS_HIDDEN (1 << 0)
282 #define CS_KEY (1 << 1)
283 #define CS_VERSION_KEY (1 << 2)
284 #define CS_NODATA (1 << 3)
285 #define CS_UPDATABLE (1 << 4)
286 #define CS_CANBENULL (1 << 5)
287 #define CS_DESCIN (1 << 6)
288 #define CS_DESCOUT (1 << 7)
289 #define CS_INPUTVALUE (1 << 8)
290 #define CS_UPDATECOL (1 << 9)
291 #define CS_RETURN (1 << 10)
292 #define CS_TIMESTAMP (1 << 13)
293 #define CS_NODEFAULT (1 << 14)
294 #define CS_IDENTITY (1 << 15)
295 
296 /*
297  * DBD::Sybase compares indicator to CS_NULLDATA so this is -1
298  * (the documentation states -1)
299  */
300 #define CS_GOODDATA 0
301 #define CS_NULLDATA (-1)
302 
303 /* CS_CON_STATUS read-only property bit mask values */
304 #define CS_CONSTAT_CONNECTED 0x01
305 #define CS_CONSTAT_DEAD 0x02
306 
307 /*
308  * Code added for CURSOR support
309  * types accepted by ct_cursor
310  */
311 #define CS_CURSOR_DECLARE 700
312 #define CS_CURSOR_OPEN 701
313 #define CS_CURSOR_ROWS 703
314 #define CS_CURSOR_UPDATE 704
315 #define CS_CURSOR_DELETE 705
316 #define CS_CURSOR_CLOSE 706
317 #define CS_CURSOR_DEALLOC 707
318 #define CS_CURSOR_OPTION 725
319 
320 #define CS_FOR_UPDATE TDS_STATIC_CAST(CS_INT, 0x1)
321 #define CS_READ_ONLY TDS_STATIC_CAST(CS_INT, 0x2)
322 #define CS_RESTORE_OPEN TDS_STATIC_CAST(CS_INT, 0x8)
323 #define CS_IMPLICIT_CURSOR TDS_STATIC_CAST(CS_INT, 0x40)
324 
325 
326 #define CS_CURSTAT_NONE TDS_STATIC_CAST(CS_INT, 0x0)
327 #define CS_CURSTAT_DECLARED TDS_STATIC_CAST(CS_INT, 0x1)
328 #define CS_CURSTAT_OPEN TDS_STATIC_CAST(CS_INT, 0x2)
329 #define CS_CURSTAT_CLOSED TDS_STATIC_CAST(CS_INT, 0x4)
330 #define CS_CURSTAT_RDONLY TDS_STATIC_CAST(CS_INT, 0x8)
331 #define CS_CURSTAT_UPDATABLE TDS_STATIC_CAST(CS_INT, 0x10)
332 #define CS_CURSTAT_ROWCOUNT TDS_STATIC_CAST(CS_INT, 0x20)
333 #define CS_CURSTAT_DEALLOC TDS_STATIC_CAST(CS_INT, 0x40)
334 
335 #define CS_CUR_STATUS TDS_STATIC_CAST(CS_INT, 9126)
336 #define CS_CUR_ID TDS_STATIC_CAST(CS_INT, 9127)
337 #define CS_CUR_NAME TDS_STATIC_CAST(CS_INT, 9128)
338 #define CS_CUR_ROWCOUNT TDS_STATIC_CAST(CS_INT, 9129)
339 
340 /* options accepted by ct_options() */
341 #define CS_OPT_DATEFIRST 5001
342 #define CS_OPT_TEXTSIZE 5002
343 #define CS_OPT_STATS_TIME 5003
344 #define CS_OPT_STATS_IO 5004
345 #define CS_OPT_ROWCOUNT 5005
346 #define CS_OPT_DATEFORMAT 5007
347 #define CS_OPT_ISOLATION 5008
348 #define CS_OPT_AUTHON 5009
349 #define CS_OPT_SHOWPLAN 5013
350 #define CS_OPT_NOEXEC 5014
351 #define CS_OPT_ARITHIGNORE 5015
352 #define CS_OPT_TRUNCIGNORE 5016
353 #define CS_OPT_ARITHABORT 5017
354 #define CS_OPT_PARSEONLY 5018
355 #define CS_OPT_GETDATA 5020
356 #define CS_OPT_NOCOUNT 5021
357 #define CS_OPT_FORCEPLAN 5023
358 #define CS_OPT_FORMATONLY 5024
359 #define CS_OPT_CHAINXACTS 5025
360 #define CS_OPT_CURCLOSEONXACT 5026
361 #define CS_OPT_FIPSFLAG 5027
362 #define CS_OPT_RESTREES 5028
363 #define CS_OPT_IDENTITYON 5029
364 #define CS_OPT_CURREAD 5030
365 #define CS_OPT_CURWRITE 5031
366 #define CS_OPT_IDENTITYOFF 5032
367 #define CS_OPT_AUTHOFF 5033
368 #define CS_OPT_ANSINULL 5034
369 #define CS_OPT_QUOTED_IDENT 5035
370 #define CS_OPT_ANSIPERM 5036
371 #define CS_OPT_STR_RTRUNC 5037
372 
373 /* options accepted by ct_command() */
374 enum ct_command_options
375 {
376  CS_MORE = 16,
377  CS_END = 32,
378  CS_RECOMPILE = 188,
379  CS_NO_RECOMPILE,
380  CS_BULK_INIT,
381  CS_BULK_CONT,
382  CS_BULK_DATA,
383  CS_COLUMN_DATA
384 };
385 
386 
387 /*
388  * bind formats, should be mapped to TDS types
389  * can be a combination of bit
390  */
391 enum
392 {
393  CS_FMT_UNUSED = 0,
394 #define CS_FMT_UNUSED CS_FMT_UNUSED
395  CS_FMT_NULLTERM = 1,
396 #define CS_FMT_NULLTERM CS_FMT_NULLTERM
397  CS_FMT_PADNULL = 2,
398 #define CS_FMT_PADBLANK CS_FMT_PADBLANK
399  CS_FMT_PADBLANK = 4,
400 #define CS_FMT_PADNULL CS_FMT_PADNULL
401  CS_FMT_JUSTIFY_RT = 8
402 #define CS_FMT_JUSTIFY_RT CS_FMT_JUSTIFY_RT
403 };
404 
405 /* callbacks */
406 #define CS_COMPLETION_CB 1
407 #define CS_SERVERMSG_CB 2
408 #define CS_CLIENTMSG_CB 3
409 #define CS_NOTIF_CB 4
410 #define CS_ENCRYPT_CB 5
411 #define CS_CHALLENGE_CB 6
412 #define CS_DS_LOOKUP_CB 7
413 #define CS_SECSESSION_CB 8
414 #define CS_SIGNAL_CB 100
415 #define CS_MESSAGE_CB 9119
416 
417 /* string types */
418 #define CS_NULLTERM -9
419 #define CS_WILDCARD -99
420 #define CS_NO_LIMIT -9999
421 #define CS_UNUSED -99999
422 
423 /* other */
424 #define CS_GET 33
425 #define CS_SET 34
426 #define CS_CLEAR 35
427 #define CS_INIT 36
428 #define CS_STATUS 37
429 #define CS_MSGLIMIT 38
430 #define CS_SUPPORTED 40
431 
432 #define CS_CMD_DONE 4046
433 #define CS_CMD_SUCCEED 4047
434 #define CS_CMD_FAIL 4048
435 
436 /* commands */
437 #define CS_LANG_CMD 148
438 #define CS_RPC_CMD 149
439 #define CS_SEND_DATA_CMD 151
440 #define CS_SEND_BULK_CMD 153
441 
442 #define CS_VERSION_100 112
443 #define CS_VERSION_110 1100
444 #define CS_VERSION_120 1100
445 #define CS_VERSION_125 12500
446 #define CS_VERSION_150 15000
447 
448 #define BLK_VERSION_100 CS_VERSION_100
449 #define BLK_VERSION_110 CS_VERSION_110
450 #define BLK_VERSION_120 CS_VERSION_120
451 #define BLK_VERSION_125 CS_VERSION_125
452 #define BLK_VERSION_150 CS_VERSION_150
453 
454 #define CS_FORCE_EXIT 300
455 #define CS_FORCE_CLOSE 301
456 
457 #define CS_SYNC_IO 8111
458 #define CS_ASYNC_IO 8112
459 #define CS_DEFER_IO 8113
460 
461 #define CS_CANCEL_CURRENT 6000
462 #define CS_CANCEL_ALL 6001
463 #define CS_CANCEL_ATTN 6002
464 
465 #define CS_ROW_COUNT 800
466 #define CS_CMD_NUMBER 801
467 #define CS_NUM_COMPUTES 802
468 #define CS_NUMDATA 803
469 #define CS_NUMORDERCOLS 805
470 #define CS_MSGTYPE 806
471 #define CS_BROWSE_INFO 807
472 #define CS_TRANS_STATE 808
473 
474 #define CS_TRAN_UNDEFINED 0
475 #define CS_TRAN_IN_PROGRESS 1
476 #define CS_TRAN_COMPLETED 2
477 #define CS_TRAN_FAIL 3
478 #define CS_TRAN_STMT_FAIL 4
479 
480 #define CS_COMP_OP 5350
481 #define CS_COMP_ID 5351
482 #define CS_COMP_COLID 5352
483 #define CS_COMP_BYLIST 5353
484 #define CS_BYLIST_LEN 5354
485 
486 #define CS_NO_COUNT -1
487 
488 #define CS_OP_SUM 5370
489 #define CS_OP_AVG 5371
490 #define CS_OP_COUNT 5372
491 #define CS_OP_MIN 5373
492 #define CS_OP_MAX 5374
493 
494 #define CS_CAP_REQUEST 1
495 #define CS_CAP_RESPONSE 2
496 
497 #define CS_PREPARE 717
498 #define CS_EXECUTE 718
499 #define CS_DESCRIBE_INPUT 720
500 #define CS_DESCRIBE_OUTPUT 721
501 
502 #define CS_DEALLOC 711
503 
504 #define CS_LC_ALL 7
505 #define CS_SYB_LANG 8
506 #define CS_SYB_CHARSET 9
507 #define CS_SYB_SORTORDER 10
508 #define CS_SYB_COLLATE CS_SYB_SORTORDER
509 #define CS_SYB_LANG_CHARSET 11
510 
511 #define CS_BLK_IN 1
512 #define CS_BLK_OUT 2
513 
514 #define CS_BLK_BATCH 1
515 #define CS_BLK_ALL 2
516 #define CS_BLK_CANCEL 3
517 
518 /* to do support these */
519 
520 #define CS_BLK_ARRAY_MAXLEN 0x1000
521 #define CS_DEF_PREC 18
522 
523 /* Error Severities */
524 #define CS_SV_INFORM TDS_STATIC_CAST(CS_INT, 0)
525 #define CS_SV_API_FAIL TDS_STATIC_CAST(CS_INT, 1)
526 #define CS_SV_RETRY_FAIL TDS_STATIC_CAST(CS_INT, 2)
527 #define CS_SV_RESOURCE_FAIL TDS_STATIC_CAST(CS_INT, 3)
528 #define CS_SV_CONFIG_FAIL TDS_STATIC_CAST(CS_INT, 4)
529 #define CS_SV_COMM_FAIL TDS_STATIC_CAST(CS_INT, 5)
530 #define CS_SV_INTERNAL_FAIL TDS_STATIC_CAST(CS_INT, 6)
531 #define CS_SV_FATAL TDS_STATIC_CAST(CS_INT, 7)
532 
533 /* result_types */
534 #define CS_COMPUTE_RESULT 4045
535 #define CS_CURSOR_RESULT 4041
536 #define CS_PARAM_RESULT 4042
537 #define CS_ROW_RESULT 4040
538 #define CS_STATUS_RESULT 4043
539 #define CS_COMPUTEFMT_RESULT 4050
540 #define CS_ROWFMT_RESULT 4049
541 #define CS_MSG_RESULT 4044
542 #define CS_DESCRIBE_RESULT 4051
543 
544 /* bind types */
545 #define CS_ILLEGAL_TYPE TDS_STATIC_CAST(CS_INT, -1)
546 #define CS_CHAR_TYPE TDS_STATIC_CAST(CS_INT, 0)
547 #define CS_BINARY_TYPE TDS_STATIC_CAST(CS_INT, 1)
548 #define CS_LONGCHAR_TYPE TDS_STATIC_CAST(CS_INT, 2)
549 #define CS_LONGBINARY_TYPE TDS_STATIC_CAST(CS_INT, 3)
550 #define CS_TEXT_TYPE TDS_STATIC_CAST(CS_INT, 4)
551 #define CS_IMAGE_TYPE TDS_STATIC_CAST(CS_INT, 5)
552 #define CS_TINYINT_TYPE TDS_STATIC_CAST(CS_INT, 6)
553 #define CS_SMALLINT_TYPE TDS_STATIC_CAST(CS_INT, 7)
554 #define CS_INT_TYPE TDS_STATIC_CAST(CS_INT, 8)
555 #define CS_REAL_TYPE TDS_STATIC_CAST(CS_INT, 9)
556 #define CS_FLOAT_TYPE TDS_STATIC_CAST(CS_INT, 10)
557 #define CS_BIT_TYPE TDS_STATIC_CAST(CS_INT, 11)
558 #define CS_DATETIME_TYPE TDS_STATIC_CAST(CS_INT, 12)
559 #define CS_DATETIME4_TYPE TDS_STATIC_CAST(CS_INT, 13)
560 #define CS_MONEY_TYPE TDS_STATIC_CAST(CS_INT, 14)
561 #define CS_MONEY4_TYPE TDS_STATIC_CAST(CS_INT, 15)
562 #define CS_NUMERIC_TYPE TDS_STATIC_CAST(CS_INT, 16)
563 #define CS_DECIMAL_TYPE TDS_STATIC_CAST(CS_INT, 17)
564 #define CS_VARCHAR_TYPE TDS_STATIC_CAST(CS_INT, 18)
565 #define CS_VARBINARY_TYPE TDS_STATIC_CAST(CS_INT, 19)
566 #define CS_LONG_TYPE TDS_STATIC_CAST(CS_INT, 20)
567 #define CS_SENSITIVITY_TYPE TDS_STATIC_CAST(CS_INT, 21)
568 #define CS_BOUNDARY_TYPE TDS_STATIC_CAST(CS_INT, 22)
569 #define CS_VOID_TYPE TDS_STATIC_CAST(CS_INT, 23)
570 #define CS_USHORT_TYPE TDS_STATIC_CAST(CS_INT, 24)
571 #define CS_UNICHAR_TYPE TDS_STATIC_CAST(CS_INT, 25)
572 #define CS_BLOB_TYPE TDS_STATIC_CAST(CS_INT, 26)
573 #define CS_DATE_TYPE TDS_STATIC_CAST(CS_INT, 27)
574 #define CS_TIME_TYPE TDS_STATIC_CAST(CS_INT, 28)
575 #define CS_UNITEXT_TYPE TDS_STATIC_CAST(CS_INT, 29)
576 #define CS_BIGINT_TYPE TDS_STATIC_CAST(CS_INT, 30)
577 #define CS_USMALLINT_TYPE TDS_STATIC_CAST(CS_INT, 31)
578 #define CS_UINT_TYPE TDS_STATIC_CAST(CS_INT, 32)
579 #define CS_UBIGINT_TYPE TDS_STATIC_CAST(CS_INT, 33)
580 #define CS_XML_TYPE TDS_STATIC_CAST(CS_INT, 34)
581 #define CS_BIGDATETIME_TYPE TDS_STATIC_CAST(CS_INT, 35)
582 #define CS_BIGTIME_TYPE TDS_STATIC_CAST(CS_INT, 36)
583 #define CS_UNIQUE_TYPE TDS_STATIC_CAST(CS_INT, 40)
584 
585 #define CS_USER_TYPE TDS_STATIC_CAST(CS_INT, 100)
586 /* cs_dt_info type values */
587 enum
588 {
589  CS_MONTH = 7340,
590 #define CS_MONTH CS_MONTH
591  CS_SHORTMONTH,
592 #define CS_SHORTMONTH CS_SHORTMONTH
593  CS_DAYNAME,
594 #define CS_DAYNAME CS_DAYNAME
595  CS_DATEORDER,
596 #define CS_DATEORDER CS_DATEORDER
597  CS_12HOUR,
598 #define CS_12HOUR CS_12HOUR
599  CS_DT_CONVFMT
600 #define CS_DT_CONVFMT CS_DT_CONVFMT
601 };
602 
603 /* DT_CONVFMT types */
604 enum
605 {
606  CS_DATES_SHORT = 0,
607 #define CS_DATES_SHORT CS_DATES_SHORT
608  CS_DATES_MDY1,
609 #define CS_DATES_MDY1 CS_DATES_MDY1
610  CS_DATES_YMD1,
611 #define CS_DATES_YMD1 CS_DATES_YMD1
612  CS_DATES_DMY1,
613 #define CS_DATES_DMY1 CS_DATES_DMY1
614  CS_DATES_DMY2,
615 #define CS_DATES_DMY2 CS_DATES_DMY2
616  CS_DATES_DMY3,
617 #define CS_DATES_DMY3 CS_DATES_DMY3
618  CS_DATES_DMY4,
619 #define CS_DATES_DMY4 CS_DATES_DMY4
620  CS_DATES_MDY2,
621 #define CS_DATES_MDY2 CS_DATES_MDY2
622  CS_DATES_HMS,
623 #define CS_DATES_HMS CS_DATES_HMS
624  CS_DATES_LONG,
625 #define CS_DATES_LONG CS_DATES_LONG
626  CS_DATES_MDY3,
627 #define CS_DATES_MDY3 CS_DATES_MDY3
628  CS_DATES_YMD2,
629 #define CS_DATES_YMD2 CS_DATES_YMD2
630  CS_DATES_YMD3,
631 #define CS_DATES_YMD3 CS_DATES_YMD3
632  CS_DATES_YDM1,
633 #define CS_DATES_YDM1 CS_DATES_YDM1
634  CS_DATES_MYD1,
635 #define CS_DATES_MYD1 CS_DATES_MYD1
636  CS_DATES_DYM1,
637 #define CS_DATES_DYM1 CS_DATES_DYM1
638  CS_DATES_MDY1_YYYY = 101,
639 #define CS_DATES_MDY1_YYYY CS_DATES_MDY1_YYYY
640  CS_DATES_YMD1_YYYY,
641 #define CS_DATES_YMD1_YYYY CS_DATES_YMD1_YYYY
642  CS_DATES_DMY1_YYYY,
643 #define CS_DATES_DMY1_YYYY CS_DATES_DMY1_YYYY
644  CS_DATES_DMY2_YYYY,
645 #define CS_DATES_DMY2_YYYY CS_DATES_DMY2_YYYY
646  CS_DATES_DMY3_YYYY,
647 #define CS_DATES_DMY3_YYYY CS_DATES_DMY3_YYYY
648  CS_DATES_DMY4_YYYY,
649 #define CS_DATES_DMY4_YYYY CS_DATES_DMY4_YYYY
650  CS_DATES_MDY2_YYYY,
651 #define CS_DATES_MDY2_YYYY CS_DATES_MDY2_YYYY
652  CS_DATES_MDY3_YYYY = 110,
653 #define CS_DATES_MDY3_YYYY CS_DATES_MDY3_YYYY
654  CS_DATES_YMD2_YYYY,
655 #define CS_DATES_YMD2_YYYY CS_DATES_YMD2_YYYY
656  CS_DATES_YMD3_YYYY
657 #define CS_DATES_YMD3_YYYY CS_DATES_YMD3_YYYY
658 };
659 
660 typedef CS_RETCODE(*CS_CONV_FUNC) (CS_CONTEXT * context, CS_DATAFMT * srcfmt, CS_VOID * src, CS_DATAFMT * detsfmt, CS_VOID * dest,
661  CS_INT * destlen);
662 
663 typedef struct _cs_objname
664 {
665  CS_BOOL thinkexists;
666  CS_INT object_type;
667  CS_CHAR last_name[CS_MAX_NAME];
668  CS_INT lnlen;
669  CS_CHAR first_name[CS_MAX_NAME];
670  CS_INT fnlen;
671  CS_VOID *scope;
672  CS_INT scopelen;
673  CS_VOID *thread;
674  CS_INT threadlen;
675 } CS_OBJNAME;
676 
677 typedef struct _cs_objdata
678 {
679  CS_BOOL actuallyexists;
680  CS_CONNECTION *connection;
681  CS_COMMAND *command;
682  CS_VOID *buffer;
683  CS_INT buflen;
684 } CS_OBJDATA;
685 
686 /* Eventually, these should be in terms of TDS values */
687 enum
688 {
689  CS_OPT_MONDAY = 1,
690  CS_OPT_TUESDAY,
691  CS_OPT_WEDNESDAY,
692  CS_OPT_THURSDAY,
693  CS_OPT_FRIDAY,
694  CS_OPT_SATURDAY,
695  CS_OPT_SUNDAY
696 };
697 enum
698 {
699  CS_OPT_FMTMDY = 1,
700  CS_OPT_FMTDMY,
701  CS_OPT_FMTYMD,
702  CS_OPT_FMTYDM,
703  CS_OPT_FMTMYD,
704  CS_OPT_FMTDYM
705 };
706 enum
707 {
708  CS_OPT_LEVEL0 = 0,
709  CS_OPT_LEVEL1,
710  CS_OPT_LEVEL2,
711  CS_OPT_LEVEL3
712 };
713 
714 #define CS_FALSE 0
715 #define CS_TRUE 1
716 
717 #define SRV_PROC CS_VOID
718 
719 /* constants required for ct_diag (not jet implemented) */
720 #define CS_CLIENTMSG_TYPE 4700
721 #define CS_SERVERMSG_TYPE 4701
722 #define CS_ALLMSG_TYPE 4702
723 
724 CS_RETCODE cs_convert(CS_CONTEXT * ctx, CS_DATAFMT * srcfmt, CS_VOID * srcdata, CS_DATAFMT * destfmt, CS_VOID * destdata,
725  CS_INT * resultlen);
726 CS_RETCODE cs_ctx_alloc(CS_INT version, CS_CONTEXT ** ctx);
727 CS_RETCODE cs_ctx_global(CS_INT version, CS_CONTEXT ** ctx);
728 CS_RETCODE cs_ctx_drop(CS_CONTEXT * ctx);
729 CS_RETCODE cs_config(CS_CONTEXT * ctx, CS_INT action, CS_INT property, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen);
730 CS_RETCODE cs_strbuild(CS_CONTEXT * ctx, CS_CHAR * buffer, CS_INT buflen, CS_INT * resultlen, CS_CHAR * text, CS_INT textlen,
731  CS_CHAR * formats, CS_INT formatlen, ...);
732 #undef cs_dt_crack
733 CS_RETCODE cs_dt_crack(CS_CONTEXT * ctx, CS_INT datetype, CS_VOID * dateval, CS_DATEREC * daterec);
734 CS_RETCODE cs_dt_crack_v2(CS_CONTEXT * ctx, CS_INT datetype, CS_VOID * dateval, CS_DATEREC * daterec);
735 #define cs_dt_crack cs_dt_crack_v2
736 CS_RETCODE cs_loc_alloc(CS_CONTEXT * ctx, CS_LOCALE ** locptr);
737 CS_RETCODE cs_loc_drop(CS_CONTEXT * ctx, CS_LOCALE * locale);
738 CS_RETCODE cs_locale(CS_CONTEXT * ctx, CS_INT action, CS_LOCALE * locale, CS_INT type, CS_VOID * buffer, CS_INT buflen,
739  CS_INT * outlen);
740 CS_RETCODE cs_dt_info(CS_CONTEXT * ctx, CS_INT action, CS_LOCALE * locale, CS_INT type, CS_INT item, CS_VOID * buffer,
741  CS_INT buflen, CS_INT * outlen);
742 
743 CS_RETCODE cs_calc(CS_CONTEXT * ctx, CS_INT op, CS_INT datatype, CS_VOID * var1, CS_VOID * var2, CS_VOID * dest);
744 CS_RETCODE cs_cmp(CS_CONTEXT * ctx, CS_INT datatype, CS_VOID * var1, CS_VOID * var2, CS_INT * result);
745 CS_RETCODE cs_conv_mult(CS_CONTEXT * ctx, CS_LOCALE * srcloc, CS_LOCALE * destloc, CS_INT * conv_multiplier);
746 CS_RETCODE cs_diag(CS_CONTEXT * ctx, CS_INT operation, CS_INT type, CS_INT idx, CS_VOID * buffer);
747 CS_RETCODE cs_manage_convert(CS_CONTEXT * ctx, CS_INT action, CS_INT srctype, CS_CHAR * srcname, CS_INT srcnamelen, CS_INT desttype,
748  CS_CHAR * destname, CS_INT destnamelen, CS_INT * conv_multiplier, CS_CONV_FUNC * func);
749 CS_RETCODE cs_objects(CS_CONTEXT * ctx, CS_INT action, CS_OBJNAME * objname, CS_OBJDATA * objdata);
750 CS_RETCODE cs_set_convert(CS_CONTEXT * ctx, CS_INT action, CS_INT srctype, CS_INT desttype, CS_CONV_FUNC * func);
751 CS_RETCODE cs_setnull(CS_CONTEXT * ctx, CS_DATAFMT * datafmt, CS_VOID * buffer, CS_INT buflen);
752 CS_RETCODE cs_strcmp(CS_CONTEXT * ctx, CS_LOCALE * locale, CS_INT type, CS_CHAR * str1, CS_INT len1, CS_CHAR * str2, CS_INT len2,
753  CS_INT * result);
754 CS_RETCODE cs_time(CS_CONTEXT * ctx, CS_LOCALE * locale, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen, CS_DATEREC * daterec);
755 CS_RETCODE cs_will_convert(CS_CONTEXT * ctx, CS_INT srctype, CS_INT desttype, CS_BOOL * result);
756 
757 const char * cs_prretcode(int retcode);
758 
759 #ifdef __cplusplus
760 #if 0
761 {
762 #endif
763 }
764 #endif
765 
766 #endif
Definition: ctlib.h:114
Definition: cstypes.h:179
Definition: ctlib.h:235
Definition: cspublic.h:663
Definition: cstypes.h:161
Definition: cstypes.h:193
Definition: ctlib.h:208
Definition: ctlib.h:74
Definition: ctlib.h:244
Definition: cspublic.h:677
Definition: cstypes.h:116
freetds-1.00.82/doc/reference/a00362_source.html100644 025423 025423 00000104561 13242511131 0014612 FreeTDS API: include/cstypes.h Source File
FreeTDS API
cstypes.h
1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2  * Copyright (C) 1998-1999 Brian Bruns
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 
20 #ifndef _cstypes_h_
21 #define _cstypes_h_
22 
23 #include "tds_sysdep_public.h"
24 
25 #ifdef __cplusplus
26 extern "C"
27 {
28 #if 0
29 }
30 #endif
31 #endif
32 
33 static const char rcsid_cstypes_h[] = "$Id: cstypes.h,v 1.7 2008-05-06 00:14:02 jklowden Exp $";
34 static const void *const no_unused_cstypes_h_warn[] = { rcsid_cstypes_h, no_unused_cstypes_h_warn };
35 
36 typedef tds_sysdep_int32_type CS_INT;
37 typedef unsigned tds_sysdep_int32_type CS_UINT;
38 typedef tds_sysdep_int64_type CS_BIGINT;
39 typedef unsigned tds_sysdep_int64_type CS_UBIGINT;
40 typedef tds_sysdep_int16_type CS_SMALLINT;
41 typedef unsigned tds_sysdep_int16_type CS_USMALLINT;
42 typedef unsigned char CS_TINYINT;
43 typedef char CS_CHAR;
44 typedef unsigned char CS_BYTE;
45 typedef tds_sysdep_real32_type CS_REAL;
46 typedef tds_sysdep_real64_type CS_FLOAT;
47 typedef tds_sysdep_int32_type CS_BOOL;
48 typedef void CS_VOID;
49 typedef unsigned char CS_IMAGE;
50 typedef unsigned char CS_TEXT;
51 typedef unsigned char CS_LONGBINARY;
52 typedef unsigned char CS_LONGCHAR;
53 typedef long CS_LONG;
54 typedef unsigned char CS_BINARY;
55 typedef unsigned tds_sysdep_int16_type CS_USHORT;
56 typedef unsigned char CS_BIT;
57 
58 typedef CS_INT CS_RETCODE;
59 
60 #define CS_MAX_NAME 132
61 #define CS_MAX_SCALE 77
62 #define CS_MAX_PREC 77 /* used by php */
63 #define CS_MAX_NUMLEN 33 /* used by roguewave */
64 #define CS_MAX_MSG 1024
65 #define CS_SQLSTATE_SIZE 8
66 #define CS_OBJ_NAME 400
67 #define CS_TP_SIZE 16 /* text pointer */
68 #define CS_TS_SIZE 8 /* length of timestamp */
69 
70 
71 typedef struct _cs_numeric
72 {
73  unsigned char precision;
74  unsigned char scale;
75  unsigned char array[CS_MAX_NUMLEN];
76 } CS_NUMERIC;
77 
78 typedef CS_NUMERIC CS_DECIMAL;
79 
80 typedef struct _cs_varbinary
81 {
82  CS_SMALLINT len;
83  CS_CHAR array[256];
84 } CS_VARBINARY;
85 
86 typedef struct _cs_varchar
87 {
88  CS_SMALLINT len; /* length of the string */
89  CS_CHAR str[256]; /* string, no NULL terminator */
90 } CS_VARCHAR;
91 
92 typedef struct _cs_config CS_CONFIG;
93 typedef struct _cs_context CS_CONTEXT;
94 typedef struct _cs_connection CS_CONNECTION;
95 typedef struct _cs_locale CS_LOCALE;
96 typedef struct _cs_command CS_COMMAND;
97 typedef struct _cs_blk_row CS_BLK_ROW;
98 
99 typedef struct _cs_iodesc
100 {
101  CS_INT iotype;
102  CS_INT datatype;
103  CS_LOCALE *locale;
104  CS_INT usertype;
105  CS_INT total_txtlen;
106  CS_INT offset;
107  CS_BOOL log_on_update;
108  CS_CHAR name[CS_OBJ_NAME];
109  CS_INT namelen;
110  CS_BYTE timestamp[CS_TS_SIZE];
111  CS_INT timestamplen;
112  CS_BYTE textptr[CS_TP_SIZE];
113  CS_INT textptrlen;
114 } CS_IODESC;
115 
116 typedef struct _cs_datafmt
117 {
118  CS_CHAR name[CS_MAX_NAME];
119  CS_INT namelen;
120  CS_INT datatype;
121  CS_INT format;
122  CS_INT maxlength;
123  CS_INT scale;
124  CS_INT precision;
125  CS_INT status;
126  CS_INT count;
127  CS_INT usertype;
128  CS_LOCALE *locale;
129 } CS_DATAFMT;
130 
131 typedef struct _cs_money
132 {
133  CS_INT mnyhigh;
134  CS_UINT mnylow;
135 } CS_MONEY;
136 
137 typedef struct _cs_money4
138 {
139  CS_INT mny4;
140 } CS_MONEY4;
141 
142 typedef CS_INT CS_DATE;
143 
144 typedef CS_INT CS_TIME;
145 
146 typedef CS_UBIGINT CS_BIGDATETIME;
147 typedef CS_UBIGINT CS_BIGTIME;
148 
149 typedef struct _cs_datetime
150 {
151  CS_INT dtdays;
152  CS_INT dttime;
153 } CS_DATETIME;
154 
155 typedef struct _cs_datetime4
156 {
157  CS_USHORT days;
158  CS_USHORT minutes;
159 } CS_DATETIME4;
160 
161 typedef struct _cs_daterec
162 {
163  CS_INT dateyear;
164  CS_INT datemonth;
165  CS_INT datedmonth;
166  CS_INT datedyear;
167  CS_INT datedweek;
168  CS_INT datehour;
169  CS_INT dateminute;
170  CS_INT datesecond;
171  CS_INT datemsecond;
172  CS_INT datetzone;
173  CS_INT datesecfrac;
174  CS_INT datesecprec;
175 } CS_DATEREC;
176 
177 typedef CS_INT CS_MSGNUM;
178 
179 typedef struct _cs_clientmsg
180 {
181  CS_INT severity;
182  CS_MSGNUM msgnumber;
183  CS_CHAR msgstring[CS_MAX_MSG];
184  CS_INT msgstringlen;
185  CS_INT osnumber;
186  CS_CHAR osstring[CS_MAX_MSG];
187  CS_INT osstringlen;
188  CS_INT status;
189  CS_BYTE sqlstate[CS_SQLSTATE_SIZE];
190  CS_INT sqlstatelen;
191 } CS_CLIENTMSG;
192 
193 typedef struct _cs_servermsg
194 {
195  CS_MSGNUM msgnumber;
196  CS_INT state;
197  CS_INT severity;
198  CS_CHAR text[CS_MAX_MSG];
199  CS_INT textlen;
200  CS_CHAR svrname[CS_MAX_NAME];
201  CS_INT svrnlen;
202  CS_CHAR proc[CS_MAX_NAME];
203  CS_INT proclen;
204  CS_INT line;
205  CS_INT status;
206  CS_BYTE sqlstate[CS_SQLSTATE_SIZE];
207  CS_INT sqlstatelen;
208 } CS_SERVERMSG;
209 
210 #ifdef __cplusplus
211 #if 0
212 {
213 #endif
214 }
215 #endif
216 
217 #endif
Definition: cstypes.h:137
Definition: cstypes.h:155
Definition: ctlib.h:114
Definition: cstypes.h:179
Definition: cstypes.h:99
Definition: ctlib.h:44
Definition: cstypes.h:161
Definition: cstypes.h:193
Definition: cstypes.h:71
Definition: ctlib.h:208
Definition: ctlib.h:74
Definition: cstypes.h:131
Definition: cstypes.h:86
Definition: ctlib.h:244
Definition: cstypes.h:149
Definition: cstypes.h:116
Definition: cstypes.h:80
freetds-1.00.82/doc/reference/a00365_source.html100644 025423 025423 00000132246 13242511131 0014616 FreeTDS API: include/ctlib.h Source File
FreeTDS API
ctlib.h
1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2  * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Brian Bruns
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 
20 #ifndef _ctlib_h_
21 #define _ctlib_h_
22 
23 #include <freetds/tds.h>
24 #include <freetds/convert.h>
25 #include <freetds/string.h>
26 
27 /*
28  * Internal (not part of the exposed API) prototypes and such.
29  */
30 
31 #include <freetds/pushvis.h>
32 
33 #ifdef __cplusplus
34 extern "C"
35 {
36 #if 0
37 }
38 #endif
39 #endif
40 
41 /*
42  * internal types
43  */
44 struct _cs_config
45 {
46  short cs_expose_formats;
47 };
48 
49 /* Code changed for error handling */
50 /* Code changes starts here - CT_DIAG - 01 */
51 
52 /* This structure is used in CT_DIAG */
53 
55 {
56  CS_CLIENTMSG *clientmsg;
57  struct cs_diag_msg_client *next;
58 };
59 
61 {
62  CS_SERVERMSG *servermsg;
63  struct cs_diag_msg_svr *next;
64 };
65 
66 /* Code changes ends here - CT_DIAG - 01 */
67 
69 {
70  CS_CLIENTMSG *msg;
71  struct cs_diag_msg *next;
72 };
73 
75 {
76  CS_INT date_convert_fmt;
77  CS_INT cs_errhandletype;
78  CS_INT cs_diag_msglimit;
79 
80  /* added for storing the maximum messages limit CT_DIAG */
81  /* code changes starts here - CT_DIAG - 02 */
82 
83  CS_INT cs_diag_msglimit_client;
84  CS_INT cs_diag_msglimit_server;
85  CS_INT cs_diag_msglimit_total;
86  struct cs_diag_msg_client *clientstore;
87  struct cs_diag_msg_svr *svrstore;
88 
89  /* code changes ends here - CT_DIAG - 02 */
90 
91  struct cs_diag_msg *msgstore;
92  CS_CSLIBMSG_FUNC _cslibmsg_cb;
93  CS_CLIENTMSG_FUNC _clientmsg_cb;
94  CS_SERVERMSG_FUNC _servermsg_cb;
95  /* code changes start here - CS_CONFIG - 01*/
96  void *userdata;
97  int userdata_len;
98  /* code changes end here - CS_CONFIG - 01*/
99  TDSCONTEXT *tds_ctx;
100  CS_CONFIG config;
101 };
102 
103 /*
104  * internal typedefs
105  */
106 typedef struct _ct_colinfo
107 {
108  TDS_SMALLINT *indicator;
109 }
110 CT_COLINFO;
111 
112 typedef struct _cs_dynamic CS_DYNAMIC;
113 
115 {
116  CS_CONTEXT *ctx;
119  CS_CLIENTMSG_FUNC _clientmsg_cb;
120  CS_SERVERMSG_FUNC _servermsg_cb;
121  void *userdata;
122  int userdata_len;
123  CS_LOCALE *locale;
124  CS_COMMAND *cmds;
125  CS_DYNAMIC *dynlist;
126  char *server_addr;
127 };
128 
129 /*
130  * Formerly CSREMOTE_PROC_PARAM, this structure can be used in other
131  * places, too.
132  */
133 
134 typedef struct _cs_param
135 {
136  struct _cs_param *next;
137  char *name;
138  int status;
139  int datatype;
140  CS_INT maxlen;
141  CS_INT scale;
142  CS_INT precision;
143  CS_INT *datalen;
144  CS_SMALLINT *ind;
145  CS_BYTE *value;
146  int param_by_value;
147  CS_INT datalen_value;
148  CS_SMALLINT indicator_value;
149 } CS_PARAM;
150 
151 /*
152  * Code added for RPC functionality - SUHA
153  * RPC Code changes starts here
154  */
155 
157 
158 typedef struct _csremote_proc
159 {
160  char *name;
161  CS_SMALLINT options;
162  CSREMOTE_PROC_PARAM *param_list;
163 } CSREMOTE_PROC;
164 
165 /*
166  * Structure CS_COMMAND changed for RPC functionality -SUHA
167  * Added CSREMOTE_PROC *rpc to CS_COMMAND structure
168  */
169 
170 typedef CS_PARAM CS_DYNAMIC_PARAM;
171 
173 {
174  struct _cs_dynamic *next;
175  char *id;
176  char *stmt;
177  CS_DYNAMIC_PARAM *param_list;
178  TDSDYNAMIC *tdsdyn;
179 };
180 
181 /* specific FreeTDS commands */
182 #define CS_DYNAMIC_CMD 160
183 #define CS_CUR_CMD 161
184 
185 /* values for cs_command.results_state */
186 
187 #define _CS_RES_NONE -1
188 #define _CS_RES_INIT 0
189 #define _CS_RES_RESULTSET_EMPTY 1
190 #define _CS_RES_RESULTSET_ROWS 2
191 #define _CS_RES_STATUS 3
192 #define _CS_RES_CMD_DONE 4
193 #define _CS_RES_CMD_SUCCEED 5
194 #define _CS_RES_END_RESULTS 6
195 #define _CS_RES_DESCRIBE_RESULT 7
196 
197 /* values for cs_command.command_state */
198 
199 #define _CS_COMMAND_IDLE 0
200 #define _CS_COMMAND_BUILDING 1
201 #define _CS_COMMAND_READY 2
202 #define _CS_COMMAND_SENT 3
203 
204 /* values for cs_command.cancel_state */
205 #define _CS_CANCEL_NOCANCEL 0
206 #define _CS_CANCEL_PENDING 1
207 
209 {
210  struct _cs_command *next;
211  CS_INT command_state;
212  CS_INT results_state;
213  CS_INT cancel_state;
214  CS_INT cursor_state;
215  CS_CONNECTION *con;
216  CS_INT command_type;
217  CS_CHAR *query;
218  short dynamic_cmd;
219  CS_DYNAMIC *dyn;
220  int row_prefetched;
221  int curr_result_type;
222  int bind_count;
223  int get_data_item;
224  int get_data_bytes_returned;
225  CS_IODESC *iodesc;
226  CS_INT send_data_started;
227  CSREMOTE_PROC *rpc;
228  CS_PARAM *input_params;
229  CS_INT client_cursor_id;
230  TDSCURSOR *cursor;
231  void *userdata;
232  int userdata_len;
233 };
234 
236 {
237  TDSBCPINFO bcpinfo;
238 };
239 
240 
241 #define _CS_ERRHAND_INLINE 1
242 #define _CS_ERRHAND_CB 2
243 
245 {
246  char *language;
247  char *charset;
248  char *time;
249  char *collate;
250 };
251 
252 /* internal defines for cursor processing */
253 
254 #define _CS_CURS_TYPE_UNACTIONED 0
255 #define _CS_CURS_TYPE_REQUESTED 1
256 #define _CS_CURS_TYPE_SENT 2
257 
258 /*
259  * internal prototypes
260  */
261 TDSRET _ct_handle_server_message(const TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE * msgptr);
262 int _ct_handle_client_message(const TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE * msgptr);
263 TDS_SERVER_TYPE _ct_get_server_type(TDSSOCKET *tds, int datatype);
264 int _ct_bind_data(CS_CONTEXT *ctx, TDSRESULTINFO * resinfo, TDSRESULTINFO *bindinfo, CS_INT offset);
265 int _ct_get_client_type(TDSCOLUMN *col);
266 void _ctclient_msg(CS_CONNECTION * con, const char *funcname, int layer, int origin, int severity, int number,
267  const char *fmt, ...);
268 CS_INT _ct_diag_clearmsg(CS_CONTEXT * context, CS_INT type);
269 void _cs_locale_free(CS_LOCALE *locale);
270 CS_LOCALE *_cs_locale_copy(CS_LOCALE *orig);
271 int _cs_locale_copy_inplace(CS_LOCALE *new_locale, CS_LOCALE *orig);
272 
273 int _cs_convert_not_client(CS_CONTEXT *ctx, TDSCOLUMN *curcol, CONV_RESULT *convert_buffer, unsigned char **p_src);
274 
275 #ifdef __cplusplus
276 #if 0
277 {
278 #endif
279 }
280 #endif
281 
282 #include <freetds/popvis.h>
283 
284 #endif
Definition: tds.h:1605
Definition: tds.h:1063
Information for a server connection.
Definition: tds.h:1174
Definition: ctlib.h:54
Definition: tds.h:549
Definition: ctlib.h:114
Definition: cstypes.h:179
Definition: ctlib.h:235
Hold information for any results.
Definition: tds.h:803
Definition: ctlib.h:68
Definition: cstypes.h:99
Definition: ctlib.h:44
Main include file for libtds.
Definition: ctlib.h:158
Definition: ctlib.h:106
Definition: ctlib.h:60
Definition: cstypes.h:193
Definition: convert.h:33
Definition: ctlib.h:208
Definition: ctlib.h:134
Definition: ctlib.h:74
Definition: ctlib.h:244
Holds informations about a cursor.
Definition: tds.h:971
Definition: ctlib.h:172
Definition: tds.h:910
Metadata about columns in regular and compute rows.
Definition: tds.h:726
Holds information for a dynamic (also called prepared) query.
Definition: tds.h:1011
freetds-1.00.82/doc/reference/a00368_source.html100644 025423 025423 00000065775 13242511131 0014635 FreeTDS API: include/ctpublic.h Source File
FreeTDS API
ctpublic.h
1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2  * Copyright (C) 1998-1999 Brian Bruns
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 
20 #ifndef _ctpublic_h_
21 #define _ctpublic_h_
22 
23 #include <cspublic.h>
24 
25 #undef TDS_STATIC_CAST
26 #ifdef __cplusplus
27 #define TDS_STATIC_CAST(type, a) static_cast<type>(a)
28 extern "C"
29 {
30 #if 0
31 }
32 #endif
33 #else
34 #define TDS_STATIC_CAST(type, a) ((type)(a))
35 #endif
36 
37 /*
38 ** define for each CT-Lib API
39 */
40 #define CT_BIND TDS_STATIC_CAST(CS_INT, 0)
41 #define CT_BR_COLUMN TDS_STATIC_CAST(CS_INT, 1)
42 #define CT_BR_TABLE TDS_STATIC_CAST(CS_INT, 2)
43 #define CT_CALLBACK TDS_STATIC_CAST(CS_INT, 3)
44 #define CT_CANCEL TDS_STATIC_CAST(CS_INT, 4)
45 #define CT_CAPABILITY TDS_STATIC_CAST(CS_INT, 5)
46 #define CT_CLOSE TDS_STATIC_CAST(CS_INT, 6)
47 #define CT_CMD_ALLOC TDS_STATIC_CAST(CS_INT, 7)
48 #define CT_CMD_DROP TDS_STATIC_CAST(CS_INT, 8)
49 #define CT_CMD_PROPS TDS_STATIC_CAST(CS_INT, 9)
50 #define CT_COMMAND TDS_STATIC_CAST(CS_INT, 10)
51 #define CT_COMPUTE_INFO TDS_STATIC_CAST(CS_INT, 11)
52 #define CT_CON_ALLOC TDS_STATIC_CAST(CS_INT, 12)
53 #define CT_CON_DROP TDS_STATIC_CAST(CS_INT, 13)
54 #define CT_CON_PROPS TDS_STATIC_CAST(CS_INT, 14)
55 #define CT_CON_XFER TDS_STATIC_CAST(CS_INT, 15)
56 #define CT_CONFIG TDS_STATIC_CAST(CS_INT, 16)
57 #define CT_CONNECT TDS_STATIC_CAST(CS_INT, 17)
58 #define CT_CURSOR TDS_STATIC_CAST(CS_INT, 18)
59 #define CT_DATA_INFO TDS_STATIC_CAST(CS_INT, 19)
60 #define CT_DEBUG TDS_STATIC_CAST(CS_INT, 20)
61 #define CT_DESCRIBE TDS_STATIC_CAST(CS_INT, 21)
62 #define CT_DIAG TDS_STATIC_CAST(CS_INT, 22)
63 #define CT_DYNAMIC TDS_STATIC_CAST(CS_INT, 23)
64 #define CT_DYNDESC TDS_STATIC_CAST(CS_INT, 24)
65 #define CT_EXIT TDS_STATIC_CAST(CS_INT, 25)
66 #define CT_FETCH TDS_STATIC_CAST(CS_INT, 26)
67 #define CT_GET_DATA TDS_STATIC_CAST(CS_INT, 27)
68 #define CT_GETFORMAT TDS_STATIC_CAST(CS_INT, 28)
69 #define CT_GETLOGINFO TDS_STATIC_CAST(CS_INT, 29)
70 #define CT_INIT TDS_STATIC_CAST(CS_INT, 30)
71 #define CT_KEYDATA TDS_STATIC_CAST(CS_INT, 31)
72 #define CT_OPTIONS TDS_STATIC_CAST(CS_INT, 32)
73 #define CT_PARAM TDS_STATIC_CAST(CS_INT, 33)
74 #define CT_POLL TDS_STATIC_CAST(CS_INT, 34)
75 #define CT_RECVPASSTHRU TDS_STATIC_CAST(CS_INT, 35)
76 #define CT_REMOTE_PWD TDS_STATIC_CAST(CS_INT, 36)
77 #define CT_RES_INFO TDS_STATIC_CAST(CS_INT, 37)
78 #define CT_RESULTS TDS_STATIC_CAST(CS_INT, 38)
79 #define CT_SEND TDS_STATIC_CAST(CS_INT, 39)
80 #define CT_SEND_DATA TDS_STATIC_CAST(CS_INT, 40)
81 #define CT_SENDPASSTHRU TDS_STATIC_CAST(CS_INT, 41)
82 #define CT_SETLOGINFO TDS_STATIC_CAST(CS_INT, 42)
83 #define CT_WAKEUP TDS_STATIC_CAST(CS_INT, 43)
84 #define CT_LABELS TDS_STATIC_CAST(CS_INT, 44)
85 #define CT_DS_LOOKUP TDS_STATIC_CAST(CS_INT, 45)
86 #define CT_DS_DROP TDS_STATIC_CAST(CS_INT, 46)
87 #define CT_DS_OBJINFO TDS_STATIC_CAST(CS_INT, 47)
88 #define CT_SETPARAM TDS_STATIC_CAST(CS_INT, 48)
89 #define CT_DYNSQLDA TDS_STATIC_CAST(CS_INT, 49)
90 #define CT_NOTIFICATION TDS_STATIC_CAST(CS_INT, 1000)
91 
92 static const char rcsid_ctpublic_h[] = "$Id: ctpublic.h,v 1.14 2005-05-28 10:48:26 freddy77 Exp $";
93 static const void *const no_unused_ctpublic_h_warn[] = { rcsid_ctpublic_h, no_unused_ctpublic_h_warn };
94 
95 
96 CS_RETCODE ct_init(CS_CONTEXT * ctx, CS_INT version);
97 CS_RETCODE ct_con_alloc(CS_CONTEXT * ctx, CS_CONNECTION ** con);
98 CS_RETCODE ct_con_props(CS_CONNECTION * con, CS_INT action, CS_INT property, CS_VOID * buffer, CS_INT buflen, CS_INT * out_len);
99 CS_RETCODE ct_connect(CS_CONNECTION * con, CS_CHAR * servername, CS_INT snamelen);
100 CS_RETCODE ct_cmd_alloc(CS_CONNECTION * con, CS_COMMAND ** cmd);
101 CS_RETCODE ct_cancel(CS_CONNECTION * conn, CS_COMMAND * cmd, CS_INT type);
102 CS_RETCODE ct_cmd_drop(CS_COMMAND * cmd);
103 CS_RETCODE ct_close(CS_CONNECTION * con, CS_INT option);
104 CS_RETCODE ct_con_drop(CS_CONNECTION * con);
105 CS_RETCODE ct_exit(CS_CONTEXT * ctx, CS_INT unused);
106 CS_RETCODE ct_command(CS_COMMAND * cmd, CS_INT type, const CS_VOID * buffer, CS_INT buflen, CS_INT option);
107 CS_RETCODE ct_send(CS_COMMAND * cmd);
108 CS_RETCODE ct_results(CS_COMMAND * cmd, CS_INT * result_type);
109 CS_RETCODE ct_bind(CS_COMMAND * cmd, CS_INT item, CS_DATAFMT * datafmt, CS_VOID * buffer, CS_INT * copied, CS_SMALLINT * indicator);
110 CS_RETCODE ct_fetch(CS_COMMAND * cmd, CS_INT type, CS_INT offset, CS_INT option, CS_INT * rows_read);
111 CS_RETCODE ct_res_info_dyn(CS_COMMAND * cmd, CS_INT type, CS_VOID * buffer, CS_INT buflen, CS_INT * out_len);
112 CS_RETCODE ct_res_info(CS_COMMAND * cmd, CS_INT type, CS_VOID * buffer, CS_INT buflen, CS_INT * out_len);
113 CS_RETCODE ct_describe(CS_COMMAND * cmd, CS_INT item, CS_DATAFMT * datafmt);
114 CS_RETCODE ct_callback(CS_CONTEXT * ctx, CS_CONNECTION * con, CS_INT action, CS_INT type, CS_VOID * func);
115 CS_RETCODE ct_send_dyn(CS_COMMAND * cmd);
116 CS_RETCODE ct_results_dyn(CS_COMMAND * cmd, CS_INT * result_type);
117 CS_RETCODE ct_config(CS_CONTEXT * ctx, CS_INT action, CS_INT property, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen);
118 CS_RETCODE ct_cmd_props(CS_COMMAND * cmd, CS_INT action, CS_INT property, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen);
119 CS_RETCODE ct_compute_info(CS_COMMAND * cmd, CS_INT type, CS_INT colnum, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen);
120 CS_RETCODE ct_get_data(CS_COMMAND * cmd, CS_INT item, CS_VOID * buffer, CS_INT buflen, CS_INT * outlen);
121 CS_RETCODE ct_send_data(CS_COMMAND * cmd, CS_VOID * buffer, CS_INT buflen);
122 CS_RETCODE ct_data_info(CS_COMMAND * cmd, CS_INT action, CS_INT colnum, CS_IODESC * iodesc);
123 CS_RETCODE ct_capability(CS_CONNECTION * con, CS_INT action, CS_INT type, CS_INT capability, CS_VOID * value);
124 CS_RETCODE ct_dynamic(CS_COMMAND * cmd, CS_INT type, CS_CHAR * id, CS_INT idlen, CS_CHAR * buffer, CS_INT buflen);
125 CS_RETCODE ct_param(CS_COMMAND * cmd, CS_DATAFMT * datafmt, CS_VOID * data, CS_INT datalen, CS_SMALLINT indicator);
126 CS_RETCODE ct_setparam(CS_COMMAND * cmd, CS_DATAFMT * datafmt, CS_VOID * data, CS_INT * datalen, CS_SMALLINT * indicator);
127 CS_RETCODE ct_options(CS_CONNECTION * con, CS_INT action, CS_INT option, CS_VOID * param, CS_INT paramlen, CS_INT * outlen);
128 CS_RETCODE ct_poll(CS_CONTEXT * ctx, CS_CONNECTION * connection, CS_INT milliseconds, CS_CONNECTION ** compconn,
129  CS_COMMAND ** compcmd, CS_INT * compid, CS_INT * compstatus);
130 CS_RETCODE ct_cursor(CS_COMMAND * cmd, CS_INT type, CS_CHAR * name, CS_INT namelen, CS_CHAR * text, CS_INT tlen, CS_INT option);
131 CS_RETCODE ct_diag(CS_CONNECTION * conn, CS_INT operation, CS_INT type, CS_INT idx, CS_VOID * buffer);
132 
133 #ifdef __cplusplus
134 #if 0
135 {
136 #endif
137 }
138 #endif
139 
140 #endif
Definition: ctlib.h:114
Definition: cstypes.h:99
Definition: ctlib.h:208
Definition: ctlib.h:74
Definition: cstypes.h:116
freetds-1.00.82/doc/reference/a00371_source.html100644 025423 025423 00000107535 13242511131 0014616 FreeTDS API: include/dblib.h Source File
FreeTDS API
dblib.h
1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2  * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 
20 #ifndef _dblib_h_
21 #define _dblib_h_
22 
23 #include <freetds/pushvis.h>
24 
25 #ifdef __cplusplus
26 extern "C"
27 {
28 #if 0
29 }
30 #endif
31 #endif
32 
33 typedef enum tag_DB_RESULT_STATE {
34  _DB_RES_INIT
35  , _DB_RES_RESULTSET_EMPTY
36  , _DB_RES_RESULTSET_ROWS
37  , _DB_RES_NEXT_RESULT
38  , _DB_RES_NO_MORE_RESULTS
39  , _DB_RES_SUCCEED
40 } DB_RESULT_STATE;
41 
43 {
45 };
46 
47 struct dblib_buffer_row;
48 
49 typedef struct tag_DBPROC_ROWBUF
50 {
51  int received; /* how many rows have been received for this result set */
52  int head; /* queue insertion point */
53  int tail; /* oldest item in queue */
54  int current; /* dbnextrow() reads this row */
55  int capacity; /* how many elements the queue can hold */
56  struct dblib_buffer_row *rows; /* pointer to the row storage */
58 
59 typedef struct
60 {
61  int host_column;
62  TDS_SERVER_TYPE datatype;
63  int prefix_len;
64  DBINT column_len;
65  BYTE *terminator;
66  int term_len;
67  int tab_colnum;
68  int column_error;
70 
71 typedef struct
72 {
73  TDS_CHAR *hostfile;
74  TDS_CHAR *errorfile;
75  FILE *bcp_errfileptr;
76  TDS_INT host_colcount;
77  BCP_HOSTCOLINFO **host_columns;
78  TDS_INT firstrow;
79  TDS_INT lastrow;
80  TDS_INT maxerrs;
81  TDS_INT batch;
83 
84 /* linked list of rpc parameters */
85 
86 typedef struct _DBREMOTE_PROC_PARAM
87 {
88  struct _DBREMOTE_PROC_PARAM *next;
89 
90  char *name;
91  BYTE status;
92  TDS_SERVER_TYPE type;
93  DBINT maxlen;
94  DBINT datalen;
95  BYTE *value;
97 
98 typedef struct _DBREMOTE_PROC
99 {
100  struct _DBREMOTE_PROC *next;
101 
102  char *name;
103  DBSMALLINT options;
104  DBREMOTE_PROC_PARAM *param_list;
105 } DBREMOTE_PROC;
106 
107 typedef struct dboption
108 {
109  const char *text;
110  DBSTRING *param;
111  DBBOOL factive;
112 } DBOPTION;
113 
114 typedef struct _null_representation
115 {
116  const BYTE *bindval;
117  size_t len;
118 } NULLREP;
119 
121 {
123 
124  STATUS row_type;
125  DBPROC_ROWBUF row_buf;
126 
127  int noautofree;
128  int more_results; /* boolean. Are we expecting results? */
129  DB_RESULT_STATE dbresults_state;
130  int dbresults_retcode;
131  BYTE *user_data; /* see dbsetuserdata() and dbgetuserdata() */
132  unsigned char *dbbuf; /* is dynamic! */
133  int dbbufsz;
134  int command_state;
135  TDS_INT text_size;
136  TDS_INT text_sent;
137  DBTYPEINFO typeinfo;
138  unsigned char avail_flag;
139  DBOPTION *dbopts;
140  DBSTRING *dboptcmd;
141  BCP_HOSTFILEINFO *hostfileinfo;
142  TDSBCPINFO *bcpinfo;
143  DBREMOTE_PROC *rpc;
144  DBUSMALLINT envchange_rcv;
145  char dbcurdb[DBMAXNAME + 1];
146  char servcharset[DBMAXNAME + 1];
147  FILE *ftos;
148  DB_DBCHKINTR_FUNC chkintr;
149  DB_DBHNDLINTR_FUNC hndlintr;
150 
152  int msdblib;
153 
154  int ntimeouts;
155 
157  NULLREP nullreps[MAXBINDTYPES];
158 };
159 
160 enum {
161 #if MSDBLIB
162  dblib_msdblib = 1
163 #else
164  dblib_msdblib = 0
165 #endif
166 };
167 
168 /*
169  * internal prototypes
170  */
171 RETCODE dbgetnull(DBPROCESS *dbproc, int bindtype, int varlen, BYTE* varaddr);
172 void copy_data_to_host_var(DBPROCESS * dbproc, TDS_SERVER_TYPE srctype, const BYTE * src, DBINT srclen,
173  BYTE * dest, DBINT destlen,
174  int bindtype, DBINT *indicator);
175 
176 int dbperror (DBPROCESS *dbproc, DBINT msgno, long errnum, ...);
177 int _dblib_handle_info_message(const TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE* msgptr);
178 int _dblib_handle_err_message(const TDSCONTEXT * ctxptr, TDSSOCKET * tdsptr, TDSMESSAGE* msgptr);
179 int _dblib_check_and_handle_interrupt(void * vdbproc);
180 
181 void _dblib_setTDS_version(TDSLOGIN * tds_login, DBINT version);
182 void _dblib_convert_err(DBPROCESS * dbproc, TDS_INT len);
183 
184 DBINT _convert_char(int srctype, BYTE * src, int destype, BYTE * dest, DBINT destlen);
185 DBINT _convert_intn(int srctype, BYTE * src, int destype, BYTE * dest, DBINT destlen);
186 
187 RETCODE _bcp_clear_storage(DBPROCESS * dbproc);
188 RETCODE _bcp_get_prog_data(DBPROCESS * dbproc);
189 
190 extern MHANDLEFUNC _dblib_msg_handler;
191 extern EHANDLEFUNC _dblib_err_handler;
192 
193 #define CHECK_PARAMETER(x, msg, ret) if (!(x)) { dbperror(dbproc, (msg), 0); return ret; }
194 #define CHECK_NULP(x, func, param_num, ret) if (!(x)) { dbperror(dbproc, SYBENULP, 0, func, (int) param_num); return ret; }
195 #define CHECK_PARAMETER_NOPROC(x, msg) if (!(x)) { dbperror(NULL, (msg), 0); return FAIL; }
196 #define DBPERROR_RETURN(x, msg) if (x) { dbperror(dbproc, (msg), 0); return FAIL; }
197 #define DBPERROR_RETURN3(x, msg, a, b, c) if (x) { dbperror(dbproc, (msg), 0, a, b, c); return FAIL; }
198 #define CHECK_CONN(ret) do { CHECK_PARAMETER(dbproc, SYBENULL, (ret)); \
199  if (IS_TDSDEAD(dbproc->tds_socket)) { dbperror(dbproc, SYBEDDNE, 0); return (ret); } } while(0)
200 
201 
202 #ifdef __cplusplus
203 #if 0
204 {
205 #endif
206 }
207 #endif
208 
209 #include <freetds/popvis.h>
210 
211 #endif
Definition: tds.h:1605
Definition: dblib.h:107
Definition: sybdb.h:341
Definition: tds.h:1063
Definition: dblib.h:120
Information for a server connection.
Definition: tds.h:1174
int _dblib_check_and_handle_interrupt(void *vdbproc)
check interrupts for libtds.
Definition: dbutil.c:191
Definition: tds.h:549
RETCODE dbgetnull(DBPROCESS *dbproc, int bindtype, int varlen, BYTE *varaddr)
Definition: dblib.c:540
int dbperror(DBPROCESS *dbproc, DBINT msgno, long errnum,...)
Call client-installed error handler.
Definition: dblib.c:7966
Definition: dblib.h:71
Definition: buffering.h:1
Definition: dblib.h:42
int msdblib
boolean use ms behaviour
Definition: dblib.h:152
Definition: dblib.h:98
Definition: dblib.h:59
Definition: sybdb.h:335
Definition: tds.h:910
Definition: dblib.h:114
Definition: dblib.h:86
Definition: dblib.h:49
freetds-1.00.82/doc/reference/a00374_source.html100644 025423 025423 00000022377 13242511131 0014621 FreeTDS API: include/des.h Source File
FreeTDS API
des.h
1 #ifndef DES_H
2 #define DES_H
3 
4 #ifdef HAVE_NETTLE
5 #include <nettle/des.h>
6 
7 typedef struct des_ctx DES_KEY;
8 #endif
9 
10 #include <freetds/pushvis.h>
11 
12 typedef unsigned char des_cblock[8];
13 
14 #ifndef HAVE_NETTLE
15 typedef struct des_key
16 {
17  unsigned char kn[16][8];
18  TDS_UINT sp[8][64];
19  unsigned char iperm[16][16][8];
20  unsigned char fperm[16][16][8];
21 } DES_KEY;
22 
23 int tds_des_set_key(DES_KEY * dkey, const des_cblock user_key, int len);
24 void tds_des_encrypt(DES_KEY * key, des_cblock block);
25 #endif
26 
27 void tds_des_set_odd_parity(des_cblock key);
28 int tds_des_ecb_encrypt(const void *plaintext, int len, DES_KEY * akey, unsigned char *output);
29 
30 #include <freetds/popvis.h>
31 
32 #ifdef HAVE_NETTLE
33 static inline void tds_des_encrypt(DES_KEY * key, des_cblock block)
34 {
35  nettle_des_encrypt(key, sizeof(des_cblock), block, block);
36 }
37 
38 static inline int tds_des_set_key(DES_KEY * dkey, const des_cblock user_key, int len)
39 {
40  return nettle_des_set_key(dkey, user_key);
41 }
42 #endif
43 
44 #endif /* !DES_H */
Definition: des.h:15
freetds-1.00.82/doc/reference/a00377_source.html100644 025423 025423 00000012347 13242511131 0014620 FreeTDS API: include/freetds/alloca.h Source File
FreeTDS API
alloca.h
1 /* Cfr https://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Particular-Functions.html */
2 #if HAVE_ALLOCA_H
3 # include <alloca.h>
4 #elif defined __GNUC__
5 # define alloca __builtin_alloca
6 #elif defined _AIX
7 # define alloca __alloca
8 #elif defined _MSC_VER
9 # include <malloc.h>
10 # define alloca _alloca
11 #else
12 # include <stddef.h>
13 # ifdef __cplusplus
14 extern "C"
15 # endif
16 void *alloca (size_t);
17 #endif
freetds-1.00.82/doc/reference/a00380_source.html100644 025423 025423 00000020550 13242511131 0014605 FreeTDS API: include/freetds/bool.h Source File
FreeTDS API
bool.h
1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2  * Copyright (C) 2015 Frediano Ziglio
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 
20 #ifndef freetds_bool_h_
21 #define freetds_bool_h_
22 
23 #ifndef __cplusplus
24 
25 #ifdef HAVE_STDBOOL_H
26 
27 #include <stdbool.h>
28 
29 #else
30 
31 #undef true
32 #undef false
33 #undef bool
34 #define bool int
35 #define true 1
36 #define false 0
37 
38 #endif
39 
40 #endif
41 
42 #endif /* freetds_bool_h_ */
freetds-1.00.82/doc/reference/a00383_source.html100644 025423 025423 00000114765 13242511131 0014624 FreeTDS API: include/freetds/bytes.h Source File
FreeTDS API
bytes.h
1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2  * Copyright (C) 2005-2008 Frediano Ziglio
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 
20 #ifndef _tdsbytes_h_
21 #define _tdsbytes_h_
22 
23 #ifndef _tds_h_
24 #error tds.h must be included before bytes.h
25 #endif
26 
27 /*
28  * read a word of n bytes aligned, architecture dependent endian
29  * TDS_GET_An
30  * read a word of n bytes aligned, little endian
31  * TDS_GET_AnLE
32  * read a word of n bytes aligned, big endian
33  * TDS_GET_AnBE
34  * read a word of n bytes unaligned, architecture dependent endian
35  * TDS_GET_UAn
36  * read a word of n bytes unaligned, little endian
37  * TDS_GET_UAnLE
38  * read a word of n bytes unaligned, big endian
39  * TDS_GET_UAnBE
40  */
41 
42 /* TODO optimize (use swap, unaligned platforms) */
43 
44 /* one byte, easy... */
45 #define TDS_GET_A1LE(ptr) (((TDS_UCHAR*)(ptr))[0])
46 #define TDS_GET_A1BE(ptr) TDS_GET_A1LE(ptr)
47 #define TDS_GET_UA1LE(ptr) TDS_GET_A1LE(ptr)
48 #define TDS_GET_UA1BE(ptr) TDS_GET_A1LE(ptr)
49 
50 #define TDS_PUT_A1LE(ptr,val) do { ((TDS_UCHAR*)(ptr))[0] = (val); } while(0)
51 #define TDS_PUT_A1BE(ptr,val) TDS_PUT_A1LE(ptr,val)
52 #define TDS_PUT_UA1LE(ptr,val) TDS_PUT_A1LE(ptr,val)
53 #define TDS_PUT_UA1BE(ptr,val) TDS_PUT_A1LE(ptr,val)
54 
55 /* two bytes */
56 #define TDS_GET_UA2LE(ptr) (((TDS_UCHAR*)(ptr))[1] * 0x100u + ((TDS_UCHAR*)(ptr))[0])
57 #define TDS_GET_UA2BE(ptr) (((TDS_UCHAR*)(ptr))[0] * 0x100u + ((TDS_UCHAR*)(ptr))[1])
58 #define TDS_GET_A2LE(ptr) TDS_GET_UA2LE(ptr)
59 #define TDS_GET_A2BE(ptr) TDS_GET_UA2BE(ptr)
60 
61 #define TDS_PUT_UA2LE(ptr,val) do {\
62  ((TDS_UCHAR*)(ptr))[1] = (TDS_UCHAR)((val)>>8); ((TDS_UCHAR*)(ptr))[0] = (TDS_UCHAR)(val); } while(0)
63 #define TDS_PUT_UA2BE(ptr,val) do {\
64  ((TDS_UCHAR*)(ptr))[0] = (TDS_UCHAR)((val)>>8); ((TDS_UCHAR*)(ptr))[1] = (TDS_UCHAR)(val); } while(0)
65 #define TDS_PUT_A2LE(ptr,val) TDS_PUT_UA2LE(ptr,val)
66 #define TDS_PUT_A2BE(ptr,val) TDS_PUT_UA2BE(ptr,val)
67 
68 /* four bytes */
69 #define TDS_GET_UA4LE(ptr) \
70  (((TDS_UCHAR*)(ptr))[3] * 0x1000000u + ((TDS_UCHAR*)(ptr))[2] * 0x10000u +\
71  ((TDS_UCHAR*)(ptr))[1] * 0x100u + ((TDS_UCHAR*)(ptr))[0])
72 #define TDS_GET_UA4BE(ptr) \
73  (((TDS_UCHAR*)(ptr))[0] * 0x1000000u + ((TDS_UCHAR*)(ptr))[1] * 0x10000u +\
74  ((TDS_UCHAR*)(ptr))[2] * 0x100u + ((TDS_UCHAR*)(ptr))[3])
75 #define TDS_GET_A4LE(ptr) TDS_GET_UA4LE(ptr)
76 #define TDS_GET_A4BE(ptr) TDS_GET_UA4BE(ptr)
77 
78 #define TDS_PUT_UA4LE(ptr,val) do {\
79  ((TDS_UCHAR*)(ptr))[3] = (TDS_UCHAR)((val)>>24); ((TDS_UCHAR*)(ptr))[2] = (TDS_UCHAR)((val)>>16);\
80  ((TDS_UCHAR*)(ptr))[1] = (TDS_UCHAR)((val)>>8); ((TDS_UCHAR*)(ptr))[0] = (TDS_UCHAR)(val); } while(0)
81 #define TDS_PUT_UA4BE(ptr,val) do {\
82  ((TDS_UCHAR*)(ptr))[0] = (TDS_UCHAR)((val)>>24); ((TDS_UCHAR*)(ptr))[1] = (TDS_UCHAR)((val)>>16);\
83  ((TDS_UCHAR*)(ptr))[2] = (TDS_UCHAR)((val)>>8); ((TDS_UCHAR*)(ptr))[3] = (TDS_UCHAR)(val); } while(0)
84 #define TDS_PUT_A4LE(ptr,val) TDS_PUT_UA4LE(ptr,val)
85 #define TDS_PUT_A4BE(ptr,val) TDS_PUT_UA4BE(ptr,val)
86 
87 #if defined(__GNUC__)
88 # define TDS_MAY_ALIAS __attribute__((__may_alias__))
89 #else
90 # define TDS_MAY_ALIAS
91 #endif
92 
93 typedef union {
94  TDS_USMALLINT usi;
95  TDS_UCHAR uc[2];
96 } TDS_MAY_ALIAS TDS_BYTE_CONVERT2;
97 
98 typedef union {
99  TDS_UINT ui;
100  TDS_UCHAR uc[4];
101 } TDS_MAY_ALIAS TDS_BYTE_CONVERT4;
102 
103 /* architecture dependent */
104 /* map to generic macros or redefine for aligned and same endianess */
105 #ifdef WORDS_BIGENDIAN
106 # define TDS_GET_A1(ptr) TDS_GET_A1BE(ptr)
107 # define TDS_GET_UA1(ptr) TDS_GET_UA1BE(ptr)
108 # define TDS_GET_A2(ptr) TDS_GET_A2BE(ptr)
109 # define TDS_GET_UA2(ptr) TDS_GET_UA2BE(ptr)
110 # define TDS_GET_A4(ptr) TDS_GET_A4BE(ptr)
111 # define TDS_GET_UA4(ptr) TDS_GET_UA4BE(ptr)
112 # undef TDS_GET_A2BE
113 # undef TDS_GET_A4BE
114 # define TDS_GET_A2BE(ptr) (((TDS_BYTE_CONVERT2*)(ptr))->usi)
115 # define TDS_GET_A4BE(ptr) (((TDS_BYTE_CONVERT4*)(ptr))->ui)
116 
117 # define TDS_PUT_A1(ptr,val) TDS_PUT_A1BE(ptr,val)
118 # define TDS_PUT_UA1(ptr,val) TDS_PUT_UA1BE(ptr,val)
119 # define TDS_PUT_A2(ptr,val) TDS_PUT_A2BE(ptr,val)
120 # define TDS_PUT_UA2(ptr,val) TDS_PUT_UA2BE(ptr,val)
121 # define TDS_PUT_A4(ptr,val) TDS_PUT_A4BE(ptr,val)
122 # define TDS_PUT_UA4(ptr,val) TDS_PUT_UA4BE(ptr,val)
123 # undef TDS_PUT_A2BE
124 # undef TDS_PUT_A4BE
125 # define TDS_PUT_A2BE(ptr,val) (((TDS_BYTE_CONVERT2*)(ptr))->usi = (val))
126 # define TDS_PUT_A4BE(ptr,val) (((TDS_BYTE_CONVERT4*)(ptr))->ui = (val))
127 # define TDS_HOST2LE(val) TDS_BYTE_SWAP16(val)
128 # define TDS_HOST4LE(val) TDS_BYTE_SWAP32(val)
129 # define TDS_HOST2BE(val) (val)
130 # define TDS_HOST4BE(val) (val)
131 #else
132 # define TDS_GET_A1(ptr) TDS_GET_A1LE(ptr)
133 # define TDS_GET_UA1(ptr) TDS_GET_UA1LE(ptr)
134 # define TDS_GET_A2(ptr) TDS_GET_A2LE(ptr)
135 # define TDS_GET_UA2(ptr) TDS_GET_UA2LE(ptr)
136 # define TDS_GET_A4(ptr) TDS_GET_A4LE(ptr)
137 # define TDS_GET_UA4(ptr) TDS_GET_UA4LE(ptr)
138 # undef TDS_GET_A2LE
139 # undef TDS_GET_A4LE
140 # define TDS_GET_A2LE(ptr) (((TDS_BYTE_CONVERT2*)(ptr))->usi)
141 # define TDS_GET_A4LE(ptr) (((TDS_BYTE_CONVERT4*)(ptr))->ui)
142 
143 # define TDS_PUT_A1(ptr,val) TDS_PUT_A1LE(ptr,val)
144 # define TDS_PUT_UA1(ptr,val) TDS_PUT_UA1LE(ptr,val)
145 # define TDS_PUT_A2(ptr,val) TDS_PUT_A2LE(ptr,val)
146 # define TDS_PUT_UA2(ptr,val) TDS_PUT_UA2LE(ptr,val)
147 # define TDS_PUT_A4(ptr,val) TDS_PUT_A4LE(ptr,val)
148 # define TDS_PUT_UA4(ptr,val) TDS_PUT_UA4LE(ptr,val)
149 # undef TDS_PUT_A2LE
150 # undef TDS_PUT_A4LE
151 # define TDS_PUT_A2LE(ptr,val) (((TDS_BYTE_CONVERT2*)(ptr))->usi = (val))
152 # define TDS_PUT_A4LE(ptr,val) (((TDS_BYTE_CONVERT4*)(ptr))->ui = (val))
153 # define TDS_HOST2LE(val) (val)
154 # define TDS_HOST4LE(val) (val)
155 # define TDS_HOST2BE(val) TDS_BYTE_SWAP16(val)
156 # define TDS_HOST4BE(val) TDS_BYTE_SWAP32(val)
157 #endif
158 
159 /* these platform support unaligned fetch/store */
160 /* map unaligned macro to aligned ones */
161 #if defined(__i386__) || defined(__amd64__) || defined(__CRIS__) ||\
162  defined(__powerpc__) || defined(__powerpc64__) || defined(__ppc__) || defined(__ppc64__) ||\
163  defined(__s390__) || defined(__s390x__) || defined(__m68k__) ||\
164  (defined(_MSC_VER) && (defined(_M_AMD64) || defined(_M_IX86) || defined(_M_X64))) ||\
165  defined(__ARM_FEATURE_UNALIGNED) ||\
166  defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_8__) ||\
167  (defined(_M_ARM) && (_M_ARM >= 7))
168 # ifdef WORDS_BIGENDIAN
169 # undef TDS_GET_UA2BE
170 # undef TDS_GET_UA4BE
171 # define TDS_GET_UA2BE(ptr) TDS_GET_A2BE(ptr)
172 # define TDS_GET_UA4BE(ptr) TDS_GET_A4BE(ptr)
173 
174 # undef TDS_PUT_UA2BE
175 # undef TDS_PUT_UA4BE
176 # define TDS_PUT_UA2BE(ptr,val) TDS_PUT_A2BE(ptr,val)
177 # define TDS_PUT_UA4BE(ptr,val) TDS_PUT_A4BE(ptr,val)
178 # else
179 # undef TDS_GET_UA2LE
180 # undef TDS_GET_UA4LE
181 # define TDS_GET_UA2LE(ptr) TDS_GET_A2LE(ptr)
182 # define TDS_GET_UA4LE(ptr) TDS_GET_A4LE(ptr)
183 
184 # undef TDS_PUT_UA2LE
185 # undef TDS_PUT_UA4LE
186 # define TDS_PUT_UA2LE(ptr,val) TDS_PUT_A2LE(ptr,val)
187 # define TDS_PUT_UA4LE(ptr,val) TDS_PUT_A4LE(ptr,val)
188 # endif
189 #endif
190 
191 #if defined(__linux__) && defined(__GNUC__) && (defined(__i386__) || defined(__amd64__))
192 # include <byteswap.h>
193 # undef TDS_GET_UA2BE
194 # undef TDS_GET_UA4BE
195 # define TDS_GET_UA2BE(ptr) ({ TDS_USMALLINT _tds_si = TDS_GET_UA2LE(ptr); bswap_16(_tds_si); })
196 # define TDS_GET_UA4BE(ptr) ({ TDS_UINT _tds_i = TDS_GET_UA4LE(ptr); bswap_32(_tds_i); })
197 
198 # undef TDS_PUT_UA2BE
199 # undef TDS_PUT_UA4BE
200 # define TDS_PUT_UA2BE(ptr,val) do {\
201  TDS_USMALLINT _tds_si = bswap_16(val); TDS_PUT_UA2LE(ptr,_tds_si); } while(0)
202 # define TDS_PUT_UA4BE(ptr,val) do {\
203  TDS_UINT _tds_i = bswap_32(val); TDS_PUT_UA4LE(ptr,_tds_i); } while(0)
204 #endif
205 
206 #if defined(__GNUC__) && defined(__powerpc__)
207 # undef TDS_GET_UA2LE
208 # undef TDS_GET_UA4LE
209 static inline TDS_USMALLINT
210 TDS_GET_UA2LE(void *ptr)
211 {
212  unsigned long res;
213  __asm__ ("lhbrx %0,0,%1\n" : "=r" (res) : "r" (ptr), "m"(*(TDS_USMALLINT*)ptr));
214  return (TDS_USMALLINT) res;
215 }
216 static inline TDS_UINT
217 TDS_GET_UA4LE(void *ptr)
218 {
219  unsigned long res;
220  __asm__ ("lwbrx %0,0,%1\n" : "=r" (res) : "r" (ptr), "m"(*(TDS_UINT*)ptr));
221  return (TDS_UINT) res;
222 }
223 
224 # undef TDS_PUT_UA2LE
225 # undef TDS_PUT_UA4LE
226 static inline void
227 TDS_PUT_UA2LE(void *ptr, unsigned data)
228 {
229  __asm__ ("sthbrx %1,0,%2\n" : "=m" (*(TDS_USMALLINT *)ptr) : "r" (data), "r" (ptr));
230 }
231 static inline void
232 TDS_PUT_UA4LE(void *ptr, unsigned data)
233 {
234  __asm__ ("stwbrx %1,0,%2\n" : "=m" (*(TDS_UINT *)ptr) : "r" (data), "r" (ptr));
235 }
236 #endif
237 
238 #endif
Definition: bytes.h:93
freetds-1.00.82/doc/reference/a00386_source.html100644 025423 025423 00000033440 13242511131 0014615 FreeTDS API: include/freetds/checks.h Source File
FreeTDS API
checks.h
1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2  * Copyright (C) 2004 Frediano Ziglio
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 
20 #ifndef TDS_CHECKS_H
21 #define TDS_CHECKS_H
22 
23 #include <freetds/pushvis.h>
24 
25 #if ENABLE_EXTRA_CHECKS
26 #define CHECK_STRUCT_EXTRA(func,s) func(s)
27 #else
28 #define CHECK_STRUCT_EXTRA(func,s)
29 #endif
30 
31 #define CHECK_TDS_EXTRA(tds) CHECK_STRUCT_EXTRA(tds_check_tds_extra,tds)
32 #define CHECK_CONTEXT_EXTRA(ctx) CHECK_STRUCT_EXTRA(tds_check_context_extra,ctx)
33 #define CHECK_TDSENV_EXTRA(env) CHECK_STRUCT_EXTRA(tds_check_env_extra,env)
34 #define CHECK_COLUMN_EXTRA(column) CHECK_STRUCT_EXTRA(tds_check_column_extra,column)
35 #define CHECK_RESULTINFO_EXTRA(res_info) CHECK_STRUCT_EXTRA(tds_check_resultinfo_extra,res_info)
36 #define CHECK_PARAMINFO_EXTRA(res_info) CHECK_STRUCT_EXTRA(tds_check_resultinfo_extra,res_info)
37 #define CHECK_CURSOR_EXTRA(cursor) CHECK_STRUCT_EXTRA(tds_check_cursor_extra,cursor)
38 #define CHECK_DYNAMIC_EXTRA(dynamic) CHECK_STRUCT_EXTRA(tds_check_dynamic_extra,dynamic)
39 #define CHECK_CONN_EXTRA(conn)
40 
41 #if ENABLE_EXTRA_CHECKS
42 void tds_check_tds_extra(const TDSSOCKET * tds);
43 void tds_check_context_extra(const TDSCONTEXT * ctx);
44 void tds_check_env_extra(const TDSENV * env);
45 void tds_check_column_extra(const TDSCOLUMN * column);
46 void tds_check_resultinfo_extra(const TDSRESULTINFO * res_info);
47 void tds_check_cursor_extra(const TDSCURSOR * cursor);
48 void tds_check_dynamic_extra(const TDSDYNAMIC * dynamic);
49 #endif
50 
51 #if defined(HAVE_VALGRIND_MEMCHECK_H) && ENABLE_EXTRA_CHECKS
52 # include <valgrind/memcheck.h>
53 # define TDS_MARK_UNDEFINED(ptr, len) VALGRIND_MAKE_MEM_UNDEFINED(ptr, len)
54 #else
55 # define TDS_MARK_UNDEFINED(ptr, len) do {} while(0)
56 #endif
57 
58 #include <freetds/popvis.h>
59 
60 #endif /* TDS_CHECKS_H */
Definition: tds.h:1063
Information for a server connection.
Definition: tds.h:1174
Hold information for any results.
Definition: tds.h:803
Current environment as reported by the server.
Definition: tds.h:997
Holds informations about a cursor.
Definition: tds.h:971
Metadata about columns in regular and compute rows.
Definition: tds.h:726
Holds information for a dynamic (also called prepared) query.
Definition: tds.h:1011
freetds-1.00.82/doc/reference/a00389_source.html100644 025423 025423 00000023113 13242511131 0014614 FreeTDS API: include/freetds/configs.h Source File
FreeTDS API
configs.h
1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2  * Copyright (C) 1998-1999 Brian Bruns
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 
20 #ifndef _tds_configs_h_
21 #define _tds_configs_h_
22 
23 /* $Id: tds_configs.h,v 1.21 2005-07-08 08:22:53 freddy77 Exp $ */
24 
25 #include <freetds/sysconfdir.h>
26 
27 #ifndef _tds_h_
28 #error tds.h must be included before tds_configs.h
29 #endif
30 
31 #ifdef __cplusplus
32 extern "C"
33 {
34 #if 0
35 }
36 #endif
37 #endif
38 
39 #define FREETDS_SYSCONFFILE FREETDS_SYSCONFDIR TDS_SDIR_SEPARATOR "freetds.conf"
40 #define FREETDS_POOLCONFFILE FREETDS_SYSCONFDIR TDS_SDIR_SEPARATOR "pool.conf"
41 #define FREETDS_LOCALECONFFILE FREETDS_SYSCONFDIR TDS_SDIR_SEPARATOR "locales.conf"
42 
43 #ifdef __cplusplus
44 #if 0
45 {
46 #endif
47 }
48 #endif
49 
50 #endif /* _tds_configs_h_ */
freetds-1.00.82/doc/reference/a00392_source.html100644 025423 025423 00000051462 13242511131 0014616 FreeTDS API: include/freetds/convert.h Source File
FreeTDS API
convert.h
1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2  * Copyright (C) 1998-1999 Brian Bruns
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 
20 #ifndef _tdsconvert_h_
21 #define _tdsconvert_h_
22 
23 #include <freetds/pushvis.h>
24 
25 #ifdef __cplusplus
26 extern "C"
27 {
28 #if 0
29 }
30 #endif
31 #endif
32 
33 typedef union conv_result
34 {
35  /* fixed */
36  TDS_TINYINT ti;
37  TDS_SMALLINT si;
38  TDS_USMALLINT usi;
39  TDS_INT i;
40  TDS_UINT ui;
41  TDS_INT8 bi;
42  TDS_UINT8 ubi;
43  TDS_FLOAT f;
44  TDS_REAL r;
45  TDS_MONEY m;
46  TDS_MONEY4 m4;
47  TDS_DATETIME dt;
48  TDS_DATETIME4 dt4;
49  TDS_DATETIMEALL dta;
50  TDS_TIME time;
51  TDS_DATE date;
52  TDS_BIGTIME bigtime;
53  TDS_BIGDATETIME bigdatetime;
54  TDS_NUMERIC n;
55  TDS_UNIQUE u;
56 
57  /* variable */
58  TDS_CHAR *c;
59  TDS_CHAR *ib;
60 
61  /* sized buffer types */
62  struct cc_t {
63  TDS_CHAR *c;
64  TDS_UINT len;
65  } cc;
66  struct cb_t {
67  TDS_CHAR *ib;
68  TDS_UINT len;
69  } cb;
70 }
72 
73 /*
74  * Failure return codes for tds_convert()
75  */
76 #define TDS_CONVERT_FAIL -1 /* unspecified failure */
77 #define TDS_CONVERT_NOAVAIL -2 /* conversion does not exist */
78 #define TDS_CONVERT_SYNTAX -3 /* syntax error in source field */
79 #define TDS_CONVERT_NOMEM -4 /* insufficient memory */
80 #define TDS_CONVERT_OVERFLOW -5 /* result too large */
81 
82 /* sized types */
83 #define TDS_CONVERT_CHAR 256
84 #define TDS_CONVERT_BINARY 257
85 
86 unsigned char tds_willconvert(int srctype, int desttype);
87 
88 TDS_SERVER_TYPE tds_get_null_type(TDS_SERVER_TYPE srctype);
89 TDS_INT tds_char2hex(TDS_CHAR *dest, TDS_UINT destlen, const TDS_CHAR * src, TDS_UINT srclen);
90 TDS_INT tds_convert(const TDSCONTEXT * context, int srctype, const TDS_CHAR * src, TDS_UINT srclen, int desttype, CONV_RESULT * cr);
91 
92 size_t tds_strftime(char *buf, size_t maxsize, const char *format, const TDSDATEREC * timeptr, int prec);
93 
94 #ifdef __cplusplus
95 #if 0
96 {
97 #endif
98 }
99 #endif
100 
101 #include <freetds/popvis.h>
102 
103 #endif /* _tdsconvert_h_ */
Definition: tds.h:1063
Definition: convert.h:66
Definition: proto.h:49
TDS_SERVER_TYPE tds_get_null_type(TDS_SERVER_TYPE srctype)
Get same type but nullable.
Definition: convert.c:2912
Definition: convert.h:62
Definition: proto.h:61
Used by tds_datecrack.
Definition: tds.h:157
Definition: proto.h:44
Definition: proto.h:25
TDS_INT tds_convert(const TDSCONTEXT *context, int srctype, const TDS_CHAR *src, TDS_UINT srclen, int desttype, CONV_RESULT *cr)
tds_convert convert a type to another.
Definition: convert.c:1875
Definition: convert.h:33
unsigned char tds_willconvert(int srctype, int desttype)
Test if a conversion is possible.
Definition: convert.c:3055
Definition: proto.h:55
Definition: proto.h:38
size_t tds_strftime(char *buf, size_t maxsize, const char *format, const TDSDATEREC *timeptr, int prec)
format a date string according to an "extended" strftime(3) formatting definition.
Definition: convert.c:2967
this structure is not directed connected to a TDS protocol but keeps any DATE/TIME information...
Definition: tds.h:144
freetds-1.00.82/doc/reference/a00395_source.html100644 025423 025423 00000044400 13242511131 0014613 FreeTDS API: include/freetds/data.h Source File
FreeTDS API
data.h
1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2  * Copyright (C) 2014 Frediano Ziglio
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 
20 #ifndef _freetds_data_h_
21 #define _freetds_data_h_
22 
23 #ifndef _tds_h_
24 # error Include tds.h before data.h
25 #endif
26 
27 #include <freetds/pushvis.h>
28 
29 #define TDS_COMMON_FUNCS(name) \
30 { \
31  tds_ ## name ## _get_info, \
32  tds_ ## name ## _get, \
33  tds_ ## name ## _row_len, \
34  tds_ ## name ## _put_info_len, \
35  tds_ ## name ## _put_info, \
36  tds_ ## name ## _put, \
37  TDS_EXTRA_CHECK(tds_ ## name ## _check) \
38 }
39 
40 tds_func_get_info tds_invalid_get_info;
41 tds_func_row_len tds_invalid_row_len;
42 tds_func_get_data tds_invalid_get;
43 tds_func_put_info_len tds_invalid_put_info_len;
44 tds_func_put_info tds_invalid_put_info;
45 tds_func_put_data tds_invalid_put;
46 tds_func_check tds_invalid_check;
47 
48 tds_func_get_info tds_generic_get_info;
49 tds_func_row_len tds_generic_row_len;
50 tds_func_get_data tds_generic_get;
51 tds_func_put_info_len tds_generic_put_info_len;
52 tds_func_put_info tds_generic_put_info;
53 tds_func_put_data tds_generic_put;
54 tds_func_check tds_generic_check;
55 
56 tds_func_get_info tds_numeric_get_info;
57 tds_func_row_len tds_numeric_row_len;
58 tds_func_get_data tds_numeric_get;
59 tds_func_put_info_len tds_numeric_put_info_len;
60 tds_func_put_info tds_numeric_put_info;
61 tds_func_put_data tds_numeric_put;
62 tds_func_check tds_numeric_check;
63 
64 #define tds_variant_get_info tds_generic_get_info
65 #define tds_variant_row_len tds_generic_row_len
66 tds_func_get_data tds_variant_get;
67 #define tds_variant_put_info_len tds_generic_put_info_len
68 tds_func_put_info tds_variant_put_info;
69 tds_func_put_data tds_variant_put;
70 tds_func_check tds_variant_check;
71 
72 tds_func_get_info tds_msdatetime_get_info;
73 tds_func_row_len tds_msdatetime_row_len;
74 tds_func_get_data tds_msdatetime_get;
75 #define tds_msdatetime_put_info_len tds_generic_put_info_len
76 tds_func_put_info tds_msdatetime_put_info;
77 tds_func_put_data tds_msdatetime_put;
78 tds_func_check tds_msdatetime_check;
79 
80 tds_func_get_info tds_clrudt_get_info;
81 tds_func_row_len tds_clrudt_row_len;
82 #define tds_clrudt_get tds_generic_get
83 #define tds_clrudt_put_info_len tds_generic_put_info_len
84 tds_func_put_info tds_clrudt_put_info;
85 #define tds_clrudt_put tds_generic_put
86 tds_func_check tds_clrudt_check;
87 
88 tds_func_get_info tds_sybbigtime_get_info;
89 tds_func_row_len tds_sybbigtime_row_len;
90 tds_func_get_data tds_sybbigtime_get;
91 tds_func_put_info_len tds_sybbigtime_put_info_len;
92 tds_func_put_info tds_sybbigtime_put_info;
93 tds_func_put_data tds_sybbigtime_put;
94 tds_func_check tds_sybbigtime_check;
95 
100 #ifndef TDS_DONT_DEFINE_DEFAULT_FUNCTIONS
101 # define TDS_DEFINE_DEFAULT_FUNCS(name) \
102  const TDSCOLUMNFUNCS tds_ ## name ## _funcs = TDS_COMMON_FUNCS(name)
103 
104 TDS_DEFINE_DEFAULT_FUNCS(invalid);
105 TDS_DEFINE_DEFAULT_FUNCS(generic);
106 TDS_DEFINE_DEFAULT_FUNCS(numeric);
107 TDS_DEFINE_DEFAULT_FUNCS(variant);
108 TDS_DEFINE_DEFAULT_FUNCS(msdatetime);
109 TDS_DEFINE_DEFAULT_FUNCS(clrudt);
110 TDS_DEFINE_DEFAULT_FUNCS(sybbigtime);
111 #endif
112 
113 #include <freetds/popvis.h>
114 
115 #endif
TDSRET tds_generic_put_info(TDSSOCKET *tds, TDSCOLUMN *col)
Put data information to wire.
Definition: data.c:860
TDSRET tds_generic_get(TDSSOCKET *tds, TDSCOLUMN *curcol)
Read a data from wire.
Definition: data.c:696
TDSRET tds_generic_put(TDSSOCKET *tds, TDSCOLUMN *curcol, int bcp7)
Write data to wire.
Definition: data.c:933
freetds-1.00.82/doc/reference/a00398_source.html100644 025423 025423 00000020701 13242511131 0014614 FreeTDS API: include/freetds/dlist.h Source File
FreeTDS API
dlist.h
1 /* Dlist - dynamic list
2  * Copyright (C) 2016 Frediano Ziglio
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  */
19 
20 #ifndef TDS_DLIST_H
21 #define TDS_DLIST_H
22 
23 typedef struct dlist_ring {
24  struct dlist_ring *next;
25  struct dlist_ring *prev;
26 } dlist_ring;
27 
28 #if ENABLE_EXTRA_CHECKS
29 void dlist_ring_check(dlist_ring *ring);
30 #endif
31 
32 #define DLIST_FIELDS(name) \
33  dlist_ring name
34 
35 #define DLIST_FOREACH(prefix, list, p) \
36  for (p = prefix ## _ ## first(list); p != NULL; p = prefix ## _ ## next(list, p))
37 
38 #endif /* TDS_DLIST_H */
Definition: dlist.h:23
freetds-1.00.82/doc/reference/a00401_source.html100644 025423 025423 00000045255 13242511131 0014610 FreeTDS API: include/freetds/dlist.tmpl.h Source File
FreeTDS API
dlist.tmpl.h
1 /* Dlist - dynamic list
2  * Copyright (C) 2016 Frediano Ziglio
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  */
19 
20 #if !defined(DLIST_NAME) || !defined(DLIST_TYPE) || !defined(DLIST_LIST_TYPE)
21 #error Required defines missing!
22 #endif
23 
24 typedef struct
25 {
26  dlist_ring ring;
28 
29 #undef DLIST_ITEM
30 #define DLIST_ITEM(ring) ((DLIST_TYPE *) (((char *) (ring)) - TDS_OFFSET(DLIST_TYPE, DLIST_NAME(item))))
31 
32 static inline void DLIST_NAME(check)(DLIST_LIST_TYPE *list)
33 {
34 #if ENABLE_EXTRA_CHECKS
35  assert(list != NULL);
36  dlist_ring_check(&list->ring);
37 #endif
38 }
39 
40 static inline void DLIST_NAME(init)(DLIST_LIST_TYPE *list)
41 {
42  list->ring.next = list->ring.prev = &list->ring;
43  DLIST_NAME(check)(list);
44 }
45 
46 static inline DLIST_TYPE *DLIST_NAME(first)(DLIST_LIST_TYPE *list)
47 {
48  return list->ring.next == &list->ring ? NULL : DLIST_ITEM(list->ring.next);
49 }
50 
51 static inline DLIST_TYPE *DLIST_NAME(last)(DLIST_LIST_TYPE *list)
52 {
53  return list->ring.prev == &list->ring ? NULL : DLIST_ITEM(list->ring.prev);
54 }
55 
56 static inline DLIST_TYPE *DLIST_NAME(next)(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
57 {
58  return item->DLIST_NAME(item).next == &list->ring ? NULL : DLIST_ITEM(item->DLIST_NAME(item).next);
59 }
60 
61 static inline DLIST_TYPE *DLIST_NAME(prev)(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
62 {
63  return item->DLIST_NAME(item).prev == &list->ring ? NULL : DLIST_ITEM(item->DLIST_NAME(item).prev);
64 }
65 
66 static inline void DLIST_NAME(prepend)(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
67 {
68  DLIST_NAME(check)(list);
69  assert(item->DLIST_NAME(item).next == NULL && item->DLIST_NAME(item).prev == NULL);
70  list->ring.next->prev = &item->DLIST_NAME(item);
71  item->DLIST_NAME(item).next = list->ring.next;
72  item->DLIST_NAME(item).prev = &list->ring;
73  list->ring.next = &item->DLIST_NAME(item);
74  assert(item->DLIST_NAME(item).next != NULL && item->DLIST_NAME(item).prev != NULL);
75  DLIST_NAME(check)(list);
76 }
77 
78 static inline void DLIST_NAME(append)(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
79 {
80  DLIST_NAME(check)(list);
81  assert(item->DLIST_NAME(item).next == NULL && item->DLIST_NAME(item).prev == NULL);
82  list->ring.prev->next = &item->DLIST_NAME(item);
83  item->DLIST_NAME(item).prev = list->ring.prev;
84  item->DLIST_NAME(item).next = &list->ring;
85  list->ring.prev = &item->DLIST_NAME(item);
86  assert(item->DLIST_NAME(item).next != NULL && item->DLIST_NAME(item).prev != NULL);
87  DLIST_NAME(check)(list);
88 }
89 
90 static inline void DLIST_NAME(remove)(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
91 {
92  dlist_ring *prev = item->DLIST_NAME(item).prev, *next = item->DLIST_NAME(item).next;
93  DLIST_NAME(check)(list);
94  if (prev)
95  prev->next = next;
96  if (next)
97  next->prev = prev;
98  item->DLIST_NAME(item).prev = NULL;
99  item->DLIST_NAME(item).next = NULL;
100  DLIST_NAME(check)(list);
101 }
102 
103 static inline bool DLIST_NAME(in_list)(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
104 {
105  DLIST_NAME(check)(list);
106  return item->DLIST_NAME(item).prev != NULL || item->DLIST_NAME(item).next != NULL;
107 }
108 
109 #undef DLIST_ITEM
110 #undef DLIST_NAME
111 #undef DLIST_TYPE
112 #undef DLIST_LIST_TYPE
113 
Definition: dlist.tmpl.h:24
Definition: dlist.h:23
freetds-1.00.82/doc/reference/a00404_source.html100644 025423 025423 00000054421 13242511131 0014606 FreeTDS API: include/freetds/enum_cap.h Source File
FreeTDS API
enum_cap.h
1 typedef enum tds_request_capability
2  { TDS_REQ_LANG = 1
3  , TDS_REQ_RPC = 2
4  , TDS_REQ_EVT = 3
5  , TDS_REQ_MSTMT = 4
6  , TDS_REQ_BCP = 5
7  , TDS_REQ_CURSOR = 6
8  , TDS_REQ_DYNF = 7
9  , TDS_REQ_MSG = 8
10  , TDS_REQ_PARAM = 9
11  , TDS_REQ_DATA_INT1 = 10
12  , TDS_REQ_DATA_INT2 = 11
13  , TDS_REQ_DATA_INT4 = 12
14  , TDS_REQ_DATA_BIT = 13
15  , TDS_REQ_DATA_CHAR = 14
16  , TDS_REQ_DATA_VCHAR = 15
17  , TDS_REQ_DATA_BIN = 16
18  , TDS_REQ_DATA_VBIN = 17
19  , TDS_REQ_DATA_MNY8 = 18
20  , TDS_REQ_DATA_MNY4 = 19
21  , TDS_REQ_DATA_DATE8 = 20
22  , TDS_REQ_DATA_DATE4 = 21
23  , TDS_REQ_DATA_FLT4 = 22
24  , TDS_REQ_DATA_FLT8 = 23
25  , TDS_REQ_DATA_NUM = 24
26  , TDS_REQ_DATA_TEXT = 25
27  , TDS_REQ_DATA_IMAGE = 26
28  , TDS_REQ_DATA_DEC = 27
29  , TDS_REQ_DATA_LCHAR = 28
30  , TDS_REQ_DATA_LBIN = 29
31  , TDS_REQ_DATA_INTN = 30
32  , TDS_REQ_DATA_DATETIMEN = 31
33  , TDS_REQ_DATA_MONEYN = 32
34  , TDS_REQ_CSR_PREV = 33
35  , TDS_REQ_CSR_FIRST = 34
36  , TDS_REQ_CSR_LAST = 35
37  , TDS_REQ_CSR_ABS = 36
38  , TDS_REQ_CSR_REL = 37
39  , TDS_REQ_CSR_MULTI = 38
40  , TDS_REQ_CON_OOB = 39
41  , TDS_REQ_CON_INBAND = 40
42  , TDS_REQ_CON_LOGICAL = 41
43  , TDS_REQ_PROTO_TEXT = 42
44  , TDS_REQ_PROTO_BULK = 43
45  , TDS_REQ_URGEVT = 44
46  , TDS_REQ_DATA_SENSITIVITY = 45
47  , TDS_REQ_DATA_BOUNDARY = 46
48  , TDS_REQ_PROTO_DYNAMIC = 47
49  , TDS_REQ_PROTO_DYNPROC = 48
50  , TDS_REQ_DATA_FLTN = 49
51  , TDS_REQ_DATA_BITN = 50
52  , TDS_REQ_DATA_INT8 = 51
53  , TDS_REQ_DATA_VOID = 52
54  , TDS_REQ_DOL_BULK = 53
55  , TDS_REQ_OBJECT_JAVA1 = 54
56  , TDS_REQ_OBJECT_CHAR = 55
57  , TDS_REQ_OBJECT_BINARY = 57
58  , TDS_REQ_DATA_COLUMNSTATUS = 58
59  , TDS_REQ_WIDETABLE = 59
60  , TDS_REQ_DATA_UINT2 = 61
61  , TDS_REQ_DATA_UINT4 = 62
62  , TDS_REQ_DATA_UINT8 = 63
63  , TDS_REQ_DATA_UINTN = 64
64  , TDS_REQ_CUR_IMPLICIT = 65
65  , TDS_REQ_DATA_NLBIN = 66
66  , TDS_REQ_IMAGE_NCHAR = 67
67  , TDS_OBS_BLOB_NCHAR_16 = 68 /* obsolete */
68  , TDS_REQ_BLOB_NCHAR_8 = 69
69  , TDS_REQ_BLOB_NCHAR_SCSU = 70
70  , TDS_REQ_DATA_DATE = 71
71  , TDS_REQ_DATA_TIME = 72
72  , TDS_REQ_DATA_INTERVAL = 73
73  , TDS_REQ_CSR_SCROLL = 74
74  , TDS_REQ_CSR_SENSITIVE = 75
75  , TDS_REQ_CSR_INSENSITIVE = 76
76  , TDS_REQ_CSR_SEMISENSITIVE = 77
77  , TDS_REQ_CSR_KEYSETDRIVEN = 78
78  , TDS_REQ_SRVPKTSIZE = 79
79  , TDS_REQ_DATA_UNITEXT = 80
80  , TDS_REQ_CAP_CLUSTERFAILOVER = 81
81  , TDS_REQ_DATA_SINT1 = 82
82  , TDS_REQ_LARGEIDENT = 83
83  , TDS_REQ_BLOB_NCHAR_16 = 84
84  , TDS_REQ_DATA_XML = 85
85  , TDS_REQ_CURINFO3 = 86
86  , TDS_REQ_DBRPC2 = 87
87  , TDS_REQ_MIGRATE = 89
88  , TDS_REQ_DATA_BIGDATETIME = 93
89  , TDS_REQ_DATA_BIGTIME = 94
90  , TDS_REQ_CAP_MAX = 94 /* repeats last enum */
91  } TDS_REQUEST_CAPABILITY;
92 
93 typedef enum tds_response_capability
94  { TDS_RES_NOMSG = 1
95  , TDS_RES_NOEED = 2
96  , TDS_RES_NOPARAM = 3
97  , TDS_RES_DATA_NOINT1 = 4
98  , TDS_RES_DATA_NOINT2 = 5
99  , TDS_RES_DATA_NOINT4 = 6
100  , TDS_RES_DATA_NOBIT = 7
101  , TDS_RES_DATA_NOCHAR = 8
102  , TDS_RES_DATA_NOVCHAR = 9
103  , TDS_RES_DATA_NOBIN = 10
104  , TDS_RES_DATA_NOVBIN = 11
105  , TDS_RES_DATA_NOMNY8 = 12
106  , TDS_RES_DATA_NOMNY4 = 13
107  , TDS_RES_DATA_NODATE8 = 14
108  , TDS_RES_DATA_NODATE4 = 15
109  , TDS_RES_DATA_NOFLT4 = 16
110  , TDS_RES_DATA_NOFLT8 = 17
111  , TDS_RES_DATA_NONUM = 18
112  , TDS_RES_DATA_NOTEXT = 19
113  , TDS_RES_DATA_NOIMAGE = 20
114  , TDS_RES_DATA_NODEC = 21
115  , TDS_RES_DATA_NOLCHAR = 22
116  , TDS_RES_DATA_NOLBIN = 23
117  , TDS_RES_DATA_INTN = 24
118  , TDS_RES_DATA_NODATETIMEN = 25
119  , TDS_RES_DATA_NOMONEYN = 26
120  , TDS_RES_CON_NOOOB = 27
121  , TDS_RES_CON_NOINBAND = 28
122  , TDS_RES_PROTO_NOTEXT = 29
123  , TDS_RES_PROTO_NOBULK = 30
124  , TDS_RES_DATA_NOSENSITIVITY = 31
125  , TDS_RES_DATA_NOBOUNDARY = 32
126  , TDS_RES_NOTDSDEBUG = 33
127  , TDS_RES_NOSTRIPBLANKS = 34
128  , TDS_RES_DATA_NOINT8 = 35
129  , TDS_RES_OBJECT_NOJAVA1 = 36
130  , TDS_RES_OBJECT_NOCHAR = 37
131  , TDS_RES_DATA_NOCOLUMNSTATUS = 38
132  , TDS_RES_OBJECT_NOBINARY = 39
133  , TDS_RES_DATA_NOUINT2 = 41
134  , TDS_RES_DATA_NOUINT4 = 42
135  , TDS_RES_DATA_NOUINT8 = 43
136  , TDS_RES_DATA_NOUINTN = 44
137  , TDS_RES_NO_WIDETABLES = 45
138  , TDS_RES_DATA_NONLBIN = 46
139  , TDS_RES_IMAGE_NONCHAR = 47
140  , TDS_RES_BLOB_NONCHAR_16 = 48
141  , TDS_RES_BLOB_NONCHAR_8 = 49
142  , TDS_RES_BLOB_NONCHAR_SCSU = 50
143  , TDS_RES_DATA_NODATE = 51
144  , TDS_RES_DATA_NOTIME = 52
145  , TDS_RES_DATA_NOINTERVAL = 53
146  , TDS_RES_DATA_NOUNITEXT = 54
147  , TDS_RES_DATA_NOSINT1 = 55
148  , TDS_RES_NO_LARGEIDENT = 56
149  , TDS_RES_NO_BLOB_NCHAR_16 = 57
150  , TDS_RES_NO_SRVPKTSIZE = 58
151  , TDS_RES_DATA_NOXML = 59
152  , TDS_RES_NONINT_RETURN_VALUE = 60
153  , TDS_RES_NOXNLDATA = 61
154  , TDS_RES_SUPPRESS_FMT = 62
155  , TDS_RES_SUPPRESS_DONEINPROC = 63
156  , TDS_RES_FORCE_ROWFMT2 = 64
157  , TDS_RES_CAP_MAX = 64 /* repeats last enum */
158  } TDS_RESPONSE_CAPABILITY;
freetds-1.00.82/doc/reference/a00407_source.html100644 025423 025423 00000057375 13242511131 0014624 FreeTDS API: include/freetds/iconv.h Source File
FreeTDS API
iconv.h
1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2  * Copyright (C) 2002, 2003, 2004 Brian Bruns
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 
20 #ifndef _tds_iconv_h_
21 #define _tds_iconv_h_
22 
23 #if HAVE_ICONV
24 #include <iconv.h>
25 #else
26 /* Define iconv_t for src/replacements/iconv.c. */
27 #undef iconv_t
28 typedef void *iconv_t;
29 #endif /* HAVE_ICONV */
30 
31 #if HAVE_ERRNO_H
32 #include <errno.h>
33 #endif
34 
35 #if HAVE_WCHAR_H
36 #include <wchar.h>
37 #endif
38 
39 /* The following EILSEQ advice is borrowed verbatim from GNU iconv. */
40 /* Some systems, like SunOS 4, don't have EILSEQ. Some systems, like BSD/OS,
41  have EILSEQ in a different header. On these systems, define EILSEQ
42  ourselves. */
43 #ifndef EILSEQ
44 # define EILSEQ ENOENT
45 #endif
46 
47 #if HAVE_STDLIB_H
48 #include <stdlib.h>
49 #endif /* HAVE_STDLIB_H */
50 
51 #include <freetds/pushvis.h>
52 
53 #ifdef __cplusplus
54 extern "C"
55 {
56 #endif
57 
58 #if ! HAVE_ICONV
59 iconv_t tds_sys_iconv_open(const char *tocode, const char *fromcode);
60 size_t tds_sys_iconv(iconv_t cd, const char **inbuf, size_t * inbytesleft, char **outbuf, size_t * outbytesleft);
61 int tds_sys_iconv_close(iconv_t cd);
62 #else
63 #define tds_sys_iconv_open iconv_open
64 #define tds_sys_iconv iconv
65 #define tds_sys_iconv_close iconv_close
66 #endif /* !HAVE_ICONV */
67 
68 
69 typedef enum
70 { to_server, to_client } TDS_ICONV_DIRECTION;
71 
72 typedef struct _character_set_alias
73 {
74  const char *alias;
75  int canonic;
77 
78 typedef struct tds_errno_message_flags {
79  unsigned int e2big:1;
80  unsigned int eilseq:1;
81  unsigned int einval:1;
83 
84 typedef struct tdsiconvdir
85 {
86  TDS_ENCODING charset;
87 
88  iconv_t cd;
89 } TDSICONVDIR;
90 
92 {
93  struct tdsiconvdir to, from;
94 
95 #define TDS_ENCODING_MEMCPY 1
96  unsigned int flags;
97 
98  /*
99  * Suppress error messages that would otherwise be emitted by tds_iconv().
100  * Functions that process large buffers ask tds_iconv to convert it in "chunks".
101  * We don't want to emit spurious EILSEQ errors or multiple errors for one
102  * buffer. tds_iconv() checks this structure before emiting a message, and
103  * adds to it whenever it emits one. Callers that handle a particular situation themselves
104  * can prepopulate it.
105  */
106  TDS_ERRNO_MESSAGE_FLAGS suppress;
107 
108 };
109 
110 /* We use ICONV_CONST for tds_iconv(), even if we don't have iconv() */
111 #ifndef ICONV_CONST
112 # define ICONV_CONST const
113 #endif
114 
115 size_t tds_iconv(TDSSOCKET * tds, TDSICONV * char_conv, TDS_ICONV_DIRECTION io,
116  const char **inbuf, size_t * inbytesleft, char **outbuf, size_t * outbytesleft);
117 const char *tds_canonical_charset_name(const char *charset_name);
118 TDSICONV *tds_iconv_get(TDSCONNECTION * conn, const char *client_charset, const char *server_charset);
119 
120 #ifdef __cplusplus
121 }
122 #endif
123 
124 #include <freetds/popvis.h>
125 
126 #endif /* _tds_iconv_h_ */
iconv_t tds_sys_iconv_open(const char *tocode, const char *fromcode)
Inputs are FreeTDS canonical names, no other.
Definition: iconv.c:337
Information for a server connection.
Definition: tds.h:1174
Definition: iconv.h:84
Information relevant to libiconv.
Definition: tds.h:648
Definition: iconv.h:78
Definition: iconv.h:91
Definition: iconv.h:72
const char * tds_canonical_charset_name(const char *charset_name)
Determine canonical iconv character set name.
Definition: iconv.c:949
Definition: tds.h:1102
size_t tds_iconv(TDSSOCKET *tds, TDSICONV *char_conv, TDS_ICONV_DIRECTION io, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
Wrapper around iconv(3).
Definition: iconv.c:546
freetds-1.00.82/doc/reference/a00410_source.html100644 025423 025423 00000355237 13242511131 0014614 FreeTDS API: include/freetds/odbc.h Source File
FreeTDS API
odbc.h
1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2  * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns
3  * Copyright (C) 2004-2010 Frediano Ziglio
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20 
21 #ifndef _sql_h_
22 #define _sql_h_
23 
24 #define TDS_DONT_DEFINE_DEFAULT_FUNCTIONS
25 #include <freetds/tds.h>
26 #include <freetds/thread.h>
27 #include <freetds/data.h>
28 
29 #if defined(UNIXODBC) || defined(_WIN32) || defined(TDS_NO_DM)
30 #include <sql.h>
31 #include <sqlext.h>
32 #if defined(UNIXODBC) || defined(_WIN32)
33 #include <odbcinst.h>
34 #endif
35 #else /* IODBC */
36 #include <isql.h>
37 #include <isqlext.h>
38 #ifdef HAVE_IODBCINST_H
39 #include <iodbcinst.h>
40 #endif /* HAVE_IODBCINST_H */
41 #endif
42 
43 #ifndef HAVE_SQLLEN
44 #ifndef SQLULEN
45 #define SQLULEN SQLUINTEGER
46 #endif
47 #ifndef SQLLEN
48 #define SQLLEN SQLINTEGER
49 #endif
50 #endif
51 
52 #ifndef HAVE_SQLSETPOSIROW
53 #define SQLSETPOSIROW SQLUSMALLINT
54 #endif
55 
56 #ifndef HAVE_SQLROWOFFSET
57 #define SQLROWOFFSET SQLLEN
58 #endif
59 
60 #ifndef HAVE_SQLROWSETSIZE
61 #define SQLROWSETSIZE SQLULEN
62 #endif
63 
64 #ifdef __cplusplus
65 extern "C"
66 {
67 #if 0
68 }
69 #endif
70 #endif
71 
72 #include <freetds/pushvis.h>
73 #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__)
74 #define ODBC_API SQL_API __attribute__((externally_visible))
75 #else
76 #define ODBC_API SQL_API
77 #endif
78 
79 #if (defined(_WIN32) || defined(__CYGWIN__)) && defined(__GNUC__)
80 # define ODBC_PUBLIC __attribute__((dllexport))
81 #else
82 # define ODBC_PUBLIC
83 #endif
84 
85 #define ODBC_MAX(a,b) ( (a) > (b) ? (a) : (b) )
86 #define ODBC_MIN(a,b) ( (a) < (b) ? (a) : (b) )
87 
88 struct _sql_error
89 {
90  const char *msg;
91  char state2[6];
92  char state3[6];
93  TDS_UINT native;
94  char *server;
95  int linenum;
96  int msgstate;
97  int row;
98 };
99 
101 {
102  struct _sql_error *errs;
103  int num_errors;
104  SQLRETURN lastrc;
105  char ranked;
106 };
107 
108 typedef struct _sql_errors TDS_ERRS;
109 
110 #if ENABLE_EXTRA_CHECKS
111 void odbc_check_struct_extra(void *p);
112 #else
113 static inline void odbc_check_struct_extra(void *p) {}
114 #endif
115 
116 #define ODBC_RETURN(handle, rc) \
117  do { odbc_check_struct_extra(handle); \
118  return handle->errs.lastrc = (rc); } while(0)
119 #define ODBC_RETURN_(handle) \
120  do { odbc_check_struct_extra(handle); \
121  return handle->errs.lastrc; } while(0)
122 
123 #define ODBC_EXIT(handle, rc) \
124  do { SQLRETURN _odbc_rc = handle->errs.lastrc = (rc); \
125  odbc_check_struct_extra(handle); \
126  tds_mutex_unlock(&handle->mtx); \
127  return _odbc_rc; } while(0)
128 #define ODBC_EXIT_(handle) \
129  do { SQLRETURN _odbc_rc = handle->errs.lastrc; \
130  odbc_check_struct_extra(handle); \
131  tds_mutex_unlock(&handle->mtx); \
132  return _odbc_rc; } while(0)
133 
134 
136 void odbc_errs_reset(struct _sql_errors *errs);
137 
139 void odbc_errs_add(struct _sql_errors *errs, const char *sqlstate, const char *msg);
140 
142 void odbc_errs_add_rdbms(struct _sql_errors *errs, TDS_UINT native, const char *sqlstate, const char *msg, int linenum,
143  int msgstate, const char *server, int row);
144 
145 struct _dheader
146 {
147  SQLSMALLINT sql_desc_alloc_type;
148  SQLINTEGER sql_desc_bind_type;
149  SQLULEN sql_desc_array_size;
150  /* TODO SQLLEN ?? see http://support.microsoft.com/default.aspx?scid=kb;en-us;298678 */
151  SQLSMALLINT sql_desc_count;
152  SQLUSMALLINT *sql_desc_array_status_ptr;
153  SQLULEN *sql_desc_rows_processed_ptr;
154  SQLLEN *sql_desc_bind_offset_ptr;
155 };
156 
157 struct _drecord
158 {
159  SQLUINTEGER sql_desc_auto_unique_value;
160  DSTR sql_desc_base_column_name;
161  DSTR sql_desc_base_table_name;
162  SQLINTEGER sql_desc_case_sensitive;
163  DSTR sql_desc_catalog_name;
164  SQLSMALLINT sql_desc_concise_type;
165  SQLPOINTER sql_desc_data_ptr;
166  SQLSMALLINT sql_desc_datetime_interval_code;
167  SQLINTEGER sql_desc_datetime_interval_precision;
168  SQLLEN sql_desc_display_size;
169  SQLSMALLINT sql_desc_fixed_prec_scale;
170  SQLLEN *sql_desc_indicator_ptr;
171  DSTR sql_desc_label;
172  SQLULEN sql_desc_length;
173  /* this point to a constant buffer, do not free or modify */
174  const char *sql_desc_literal_prefix;
175  /* this point to a constant buffer, do not free or modify */
176  const char *sql_desc_literal_suffix;
177  DSTR sql_desc_local_type_name;
178  DSTR sql_desc_name;
179  SQLSMALLINT sql_desc_nullable;
180  SQLINTEGER sql_desc_num_prec_radix;
181  SQLLEN sql_desc_octet_length;
182  SQLLEN *sql_desc_octet_length_ptr;
183  SQLSMALLINT sql_desc_parameter_type;
184  SQLSMALLINT sql_desc_precision;
185  SQLSMALLINT sql_desc_rowver;
186  SQLSMALLINT sql_desc_scale;
187  DSTR sql_desc_schema_name;
188  SQLSMALLINT sql_desc_searchable;
189  DSTR sql_desc_table_name;
190  SQLSMALLINT sql_desc_type;
191  /* this point to a constant buffer, do not free or modify */
192  const char *sql_desc_type_name;
193  SQLSMALLINT sql_desc_unnamed;
194  SQLSMALLINT sql_desc_unsigned;
195  SQLSMALLINT sql_desc_updatable;
196 };
197 
198 struct _hdesc
199 {
200  SQLSMALLINT htype; /* do not reorder this field */
201  struct _sql_errors errs; /* do not reorder this field */
202  tds_mutex mtx;
203  int type;
204  SQLHANDLE parent;
205  struct _dheader header;
206  struct _drecord *records;
207 };
208 
209 typedef struct _hdesc TDS_DESC;
210 
211 #define DESC_IRD 1
212 #define DESC_IPD 2
213 #define DESC_ARD 3
214 #define DESC_APD 4
215 
216 struct _heattr
217 {
218  SQLUINTEGER connection_pooling;
219  SQLUINTEGER cp_match;
220  SQLINTEGER odbc_version;
221  SQLINTEGER output_nts;
222 };
223 
224 struct _hchk
225 {
226  SQLSMALLINT htype; /* do not reorder this field */
227  struct _sql_errors errs; /* do not reorder this field */
228  tds_mutex mtx;
229 };
230 
231 struct _henv
232 {
233  SQLSMALLINT htype; /* do not reorder this field */
234  struct _sql_errors errs; /* do not reorder this field */
235  tds_mutex mtx;
236  TDSCONTEXT *tds_ctx;
237  struct _heattr attr;
238 };
239 
240 struct _hcattr
241 {
242  SQLUINTEGER access_mode;
243  SQLUINTEGER async_enable;
244  SQLUINTEGER auto_ipd;
245  SQLUINTEGER autocommit;
246  SQLUINTEGER connection_dead;
247  SQLUINTEGER connection_timeout;
248  DSTR current_catalog;
249  SQLUINTEGER login_timeout;
250  SQLUINTEGER metadata_id;
251  SQLUINTEGER odbc_cursors;
252  SQLUINTEGER packet_size;
253  SQLHWND quite_mode;
254  DSTR translate_lib;
255  SQLUINTEGER translate_option;
256  SQLUINTEGER txn_isolation;
257  SQLUINTEGER mars_enabled;
258  SQLUINTEGER cursor_type;
259  SQLUINTEGER bulk_enabled;
260 #ifdef TDS_NO_DM
261  SQLUINTEGER trace;
262  DSTR tracefile;
263 #endif
264 };
265 
266 #define TDS_MAX_APP_DESC 100
267 
268 struct _hstmt;
269 struct _hdbc
270 {
271  SQLSMALLINT htype; /* do not reorder this field */
272  struct _sql_errors errs; /* do not reorder this field */
273  tds_mutex mtx;
274  struct _henv *env;
276  DSTR dsn;
277  DSTR oldpwd;
278 #ifdef ENABLE_ODBC_WIDE
279  DSTR original_charset;
280  TDSICONV *mb_conv;
281 #endif
282 
290  struct _hstmt *stmt_list;
291  struct _hcattr attr;
293  TDS_DESC *uad[TDS_MAX_APP_DESC];
295  unsigned int cursor_support:1;
296  unsigned int use_oldpwd:1;
297  TDS_INT default_query_timeout;
298 
299  TDSBCPINFO *bcpinfo;
300  char *bcphint;
301 };
302 
303 struct _hsattr
304 {
305  /* TODO remove IRD, ARD, IPD, APD from statement, do not duplicate */
306 /* TDS_DESC *app_row_desc; */
307 /* TDS_DESC *app_param_desc; */
308  SQLUINTEGER async_enable;
309  SQLUINTEGER concurrency;
310  SQLUINTEGER cursor_scrollable;
311  SQLUINTEGER cursor_sensitivity;
312  SQLUINTEGER cursor_type;
313  SQLUINTEGER enable_auto_ipd;
314  SQLPOINTER fetch_bookmark_ptr;
315  SQLULEN keyset_size;
316  SQLULEN max_length;
317  SQLULEN max_rows;
318  SQLUINTEGER metadata_id;
319  SQLUINTEGER noscan;
320  /* apd->sql_desc_bind_offset_ptr */
321  /* SQLUINTEGER *param_bind_offset_ptr; */
322  /* apd->sql_desc_bind_type */
323  /* SQLUINTEGER param_bind_type; */
324  /* apd->sql_desc_array_status_ptr */
325  /* SQLUSMALLINT *param_operation_ptr; */
326  /* ipd->sql_desc_array_status_ptr */
327  /* SQLUSMALLINT *param_status_ptr; */
328  /* ipd->sql_desc_rows_processed_ptr */
329  /* SQLUSMALLINT *params_processed_ptr; */
330  /* apd->sql_desc_array_size */
331  /* SQLUINTEGER paramset_size; */
332  SQLUINTEGER query_timeout;
333  SQLUINTEGER retrieve_data;
334  /* ard->sql_desc_bind_offset_ptr */
335  /* SQLUINTEGER *row_bind_offset_ptr; */
336  /* ard->sql_desc_array_size */
337  /* SQLUINTEGER row_array_size; */
338  /* ard->sql_desc_bind_type */
339  /* SQLUINTEGER row_bind_type; */
340  SQLULEN row_number;
341  /* ard->sql_desc_array_status_ptr */
342  /* SQLUINTEGER *row_operation_ptr; */
343  /* ird->sql_desc_array_status_ptr */
344  /* SQLUINTEGER *row_status_ptr; */
345  /* ird->sql_desc_rows_processed_ptr */
346  /* SQLUINTEGER *rows_fetched_ptr; */
347  SQLUINTEGER simulate_cursor;
348  SQLUINTEGER use_bookmarks;
349  /* SQLGetStmtAttr only */
350 /* TDS_DESC *imp_row_desc; */
351 /* TDS_DESC *imp_param_desc; */
352  DSTR qn_msgtext;
353  DSTR qn_options;
354  SQLUINTEGER qn_timeout;
355 };
356 
357 typedef enum
358 {
359  NOT_IN_ROW,
360  IN_NORMAL_ROW,
361  IN_COMPUTE_ROW,
362  AFTER_COMPUTE_ROW,
363  PRE_NORMAL_ROW
364 } TDS_ODBC_ROW_STATUS;
365 
366 typedef enum
367 {
368  ODBC_SPECIAL_NONE = 0,
369  ODBC_SPECIAL_GETTYPEINFO = 1,
370  ODBC_SPECIAL_COLUMNS = 2,
371  ODBC_SPECIAL_PROCEDURECOLUMNS = 3,
372  ODBC_SPECIAL_SPECIALCOLUMNS = 4
373 } TDS_ODBC_SPECIAL_ROWS;
374 
375 struct _hstmt
376 {
377  SQLSMALLINT htype; /* do not reorder this field */
378  struct _sql_errors errs; /* do not reorder this field */
379  tds_mutex mtx;
380  struct _hdbc *dbc;
385 
387  struct _hstmt *next;
389  struct _hstmt *prev;
390 
391  /* begin prepared query stuff */
392  unsigned is_prepared_query:1;
393  unsigned prepared_query_is_func:1;
394  unsigned prepared_query_is_rpc:1;
395  unsigned need_reprepare:1;
396  unsigned param_data_called:1;
397  /* end prepared query stuff */
398 
405 
406  unsigned int curr_param_row, num_param_rows;
407 
409  unsigned int param_count;
410  int row;
412  TDS_INT8 row_count;
414  TDS_ODBC_ROW_STATUS row_status;
415  /* do NOT free dynamic, free from socket or attach to connection */
416  TDSDYNAMIC *dyn;
417  TDS_DESC *ard, *ird, *apd, *ipd;
418  TDS_DESC *orig_ard, *orig_apd;
419  SQLULEN sql_rowset_size;
420  struct _hsattr attr;
421  DSTR cursor_name; /* auto generated cursor name */
422  TDS_ODBC_SPECIAL_ROWS special_row;
423  /* do NOT free cursor, free from socket or attach to connection */
424  TDSCURSOR *cursor;
425 };
426 
427 typedef struct _henv TDS_ENV;
428 typedef struct _hdbc TDS_DBC;
429 typedef struct _hstmt TDS_STMT;
430 typedef struct _hchk TDS_CHK;
431 
432 typedef struct {
433  /* this must be the first member */
434  TDSCOLUMNFUNCS common;
435  void (*set_type_info)(TDSCOLUMN *col, struct _drecord *drec, SQLINTEGER odbc_ver);
436 } TDS_FUNCS;
437 
438 #define IS_HENV(x) (((TDS_CHK *)x)->htype == SQL_HANDLE_ENV)
439 #define IS_HDBC(x) (((TDS_CHK *)x)->htype == SQL_HANDLE_DBC)
440 #define IS_HSTMT(x) (((TDS_CHK *)x)->htype == SQL_HANDLE_STMT)
441 #define IS_HDESC(x) (((TDS_CHK *)x)->htype == SQL_HANDLE_DESC)
442 
443 /* fix a bug in MingW headers */
444 #ifdef __MINGW32__
445 #if SQL_INTERVAL_YEAR == (100 + SQL_CODE_SECOND)
446 
447 #undef SQL_INTERVAL_YEAR
448 #undef SQL_INTERVAL_MONTH
449 #undef SQL_INTERVAL_DAY
450 #undef SQL_INTERVAL_HOUR
451 #undef SQL_INTERVAL_MINUTE
452 #undef SQL_INTERVAL_SECOND
453 #undef SQL_INTERVAL_YEAR_TO_MONTH
454 #undef SQL_INTERVAL_DAY_TO_HOUR
455 #undef SQL_INTERVAL_DAY_TO_MINUTE
456 #undef SQL_INTERVAL_DAY_TO_SECOND
457 #undef SQL_INTERVAL_HOUR_TO_MINUTE
458 #undef SQL_INTERVAL_HOUR_TO_SECOND
459 #undef SQL_INTERVAL_MINUTE_TO_SECOND
460 
461 #define SQL_INTERVAL_YEAR (100 + SQL_CODE_YEAR)
462 #define SQL_INTERVAL_MONTH (100 + SQL_CODE_MONTH)
463 #define SQL_INTERVAL_DAY (100 + SQL_CODE_DAY)
464 #define SQL_INTERVAL_HOUR (100 + SQL_CODE_HOUR)
465 #define SQL_INTERVAL_MINUTE (100 + SQL_CODE_MINUTE)
466 #define SQL_INTERVAL_SECOND (100 + SQL_CODE_SECOND)
467 #define SQL_INTERVAL_YEAR_TO_MONTH (100 + SQL_CODE_YEAR_TO_MONTH)
468 #define SQL_INTERVAL_DAY_TO_HOUR (100 + SQL_CODE_DAY_TO_HOUR)
469 #define SQL_INTERVAL_DAY_TO_MINUTE (100 + SQL_CODE_DAY_TO_MINUTE)
470 #define SQL_INTERVAL_DAY_TO_SECOND (100 + SQL_CODE_DAY_TO_SECOND)
471 #define SQL_INTERVAL_HOUR_TO_MINUTE (100 + SQL_CODE_HOUR_TO_MINUTE)
472 #define SQL_INTERVAL_HOUR_TO_SECOND (100 + SQL_CODE_HOUR_TO_SECOND)
473 #define SQL_INTERVAL_MINUTE_TO_SECOND (100 + SQL_CODE_MINUTE_TO_SECOND)
474 
475 #endif
476 #endif
477 
478 #ifdef _WIN32
479 BOOL get_login_info(HWND hwndParent, TDSLOGIN * login);
480 #endif
481 
482 #define ODBC_PARAM_LIST \
483  ODBC_PARAM(Servername) \
484  ODBC_PARAM(Server) \
485  ODBC_PARAM(DSN) \
486  ODBC_PARAM(UID) \
487  ODBC_PARAM(PWD) \
488  ODBC_PARAM(Address) \
489  ODBC_PARAM(Port) \
490  ODBC_PARAM(TDS_Version) \
491  ODBC_PARAM(Language) \
492  ODBC_PARAM(Database) \
493  ODBC_PARAM(TextSize) \
494  ODBC_PARAM(PacketSize) \
495  ODBC_PARAM(ClientCharset) \
496  ODBC_PARAM(DumpFile) \
497  ODBC_PARAM(DumpFileAppend) \
498  ODBC_PARAM(DebugFlags) \
499  ODBC_PARAM(Encryption) \
500  ODBC_PARAM(Trusted_Connection) \
501  ODBC_PARAM(APP) \
502  ODBC_PARAM(WSID) \
503  ODBC_PARAM(UseNTLMv2) \
504  ODBC_PARAM(MARS_Connection) \
505  ODBC_PARAM(REALM) \
506  ODBC_PARAM(ServerSPN) \
507  ODBC_PARAM(AttachDbFilename) \
508  ODBC_PARAM(ApplicationIntent)
509 
510 #define ODBC_PARAM(p) ODBC_PARAM_##p,
511 enum {
512  ODBC_PARAM_LIST
513  ODBC_PARAM_SIZE
514 };
515 #undef ODBC_PARAM
516 
517 
518 /*
519  * connectparams.h
520  */
521 
522 typedef struct {
523  const char *p;
524  size_t len;
526 
534 int odbc_parse_connect_string(TDS_ERRS *errs, const char *connect_string, const char *connect_string_end, TDSLOGIN * login, TDS_PARSED_PARAM *parsed_params);
535 int odbc_get_dsn_info(TDS_ERRS *errs, const char *DSN, TDSLOGIN * login);
536 #ifdef _WIN32
537 int odbc_build_connect_string(TDS_ERRS *errs, TDS_PARSED_PARAM *params, char **out);
538 #endif
539 
540 /*
541  * convert_tds2sql.c
542  */
543 SQLLEN odbc_tds2sql(TDS_STMT * stmt, TDSCOLUMN *curcol, int srctype, TDS_CHAR * src, TDS_UINT srclen, int desttype, TDS_CHAR * dest, SQLULEN destlen, const struct _drecord *drec_ixd);
544 
545 /*
546  * descriptor.c
547  */
548 TDS_DESC *desc_alloc(SQLHANDLE parent, int desc_type, int alloc_type);
549 SQLRETURN desc_free(TDS_DESC * desc);
550 SQLRETURN desc_alloc_records(TDS_DESC * desc, unsigned count);
551 SQLRETURN desc_copy(TDS_DESC * dest, TDS_DESC * src);
552 SQLRETURN desc_free_records(TDS_DESC * desc);
553 TDS_DBC *desc_get_dbc(TDS_DESC *desc);
554 
555 /*
556  * odbc.c
557  */
558 SQLRETURN _SQLRowCount(SQLHSTMT hstmt, SQLLEN FAR * pcrow);
559 
560 /*
561  * odbc_checks.h
562  */
563 #if ENABLE_EXTRA_CHECKS
564 /* macro */
565 #define CHECK_ENV_EXTRA(env) odbc_check_env_extra(env)
566 #define CHECK_DBC_EXTRA(dbc) odbc_check_dbc_extra(dbc)
567 #define CHECK_STMT_EXTRA(stmt) odbc_check_stmt_extra(stmt)
568 #define CHECK_DESC_EXTRA(desc) odbc_check_desc_extra(desc)
569 /* declarations*/
570 void odbc_check_env_extra(TDS_ENV * env);
571 void odbc_check_dbc_extra(TDS_DBC * dbc);
572 void odbc_check_stmt_extra(TDS_STMT * stmt);
573 void odbc_check_desc_extra(TDS_DESC * desc);
574 #else
575 /* macro */
576 #define CHECK_ENV_EXTRA(env)
577 #define CHECK_DBC_EXTRA(dbc)
578 #define CHECK_STMT_EXTRA(stmt)
579 #define CHECK_DESC_EXTRA(desc)
580 #endif
581 
582 /*
583  * odbc_util.h
584  */
585 
586 /* helpers for ODBC wide string support */
587 #undef _wide
588 #undef _WIDE
589 #ifdef ENABLE_ODBC_WIDE
590 typedef union {
591  char mb[1];
592  SQLWCHAR wide[1];
593 } ODBC_CHAR;
594 # define _wide ,wide
595 # define _wide0 ,0
596 # define _WIDE ,int wide
597 #else
598 # define _wide
599 # define _wide0
600 # define _WIDE
601 # define ODBC_CHAR SQLCHAR
602 #endif
603 int odbc_set_stmt_query(struct _hstmt *stmt, const ODBC_CHAR *sql, int sql_len _WIDE);
604 void odbc_set_return_status(struct _hstmt *stmt, unsigned int n_row);
605 void odbc_set_return_params(struct _hstmt *stmt, unsigned int n_row);
606 
607 void odbc_set_sql_type_info(TDSCOLUMN * col, struct _drecord *drec, SQLINTEGER odbc_ver);
608 
609 int odbc_sql_to_c_type_default(int sql_type);
610 TDS_SERVER_TYPE odbc_sql_to_server_type(TDSCONNECTION * conn, int sql_type, int sql_unsigned);
611 TDS_SERVER_TYPE odbc_c_to_server_type(int c_type);
612 
613 unsigned int odbc_get_string_size(int size, const ODBC_CHAR * str _WIDE);
614 void odbc_rdbms_version(TDSSOCKET * tds_socket, char *pversion_string);
615 SQLINTEGER odbc_get_param_len(const struct _drecord *drec_axd, const struct _drecord *drec_ixd, const TDS_DESC* axd, unsigned int n_row);
616 
617 #ifdef ENABLE_ODBC_WIDE
618 DSTR* odbc_dstr_copy_flag(TDS_DBC *dbc, DSTR *s, int size, const ODBC_CHAR * str, int flag);
619 #define odbc_dstr_copy(dbc, s, len, out) \
620  odbc_dstr_copy_flag(dbc, s, len, sizeof((out)->mb) ? (out) : (out), wide)
621 #define odbc_dstr_copy_oct(dbc, s, len, out) \
622  odbc_dstr_copy_flag(dbc, s, len, out, wide|0x20)
623 #else
624 DSTR* odbc_dstr_copy(TDS_DBC *dbc, DSTR *s, int size, const ODBC_CHAR * str);
625 #define odbc_dstr_copy_oct odbc_dstr_copy
626 #endif
627 
628 
629 SQLRETURN odbc_set_string_flag(TDS_DBC *dbc, SQLPOINTER buffer, SQLINTEGER cbBuffer, void FAR * pcbBuffer, const char *s, int len, int flag);
630 #ifdef ENABLE_ODBC_WIDE
631 #define odbc_set_string(dbc, buf, buf_len, out_len, s, s_len) \
632  odbc_set_string_flag(dbc, sizeof((buf)->mb) ? (buf) : (buf), buf_len, out_len, s, s_len, (wide) | (sizeof(*(out_len)) == sizeof(SQLSMALLINT)?0:0x10))
633 #define odbc_set_string_oct(dbc, buf, buf_len, out_len, s, s_len) \
634  odbc_set_string_flag(dbc, buf, buf_len, out_len, s, s_len, (wide) | (sizeof(*(out_len)) == sizeof(SQLSMALLINT)?0x20:0x30))
635 #else
636 #define odbc_set_string(dbc, buf, buf_len, out_len, s, s_len) \
637  odbc_set_string_flag(dbc, buf, buf_len, out_len, s, s_len, (sizeof(*(out_len)) == sizeof(SQLSMALLINT)?0:0x10))
638 #define odbc_set_string_oct(dbc, buf, buf_len, out_len, s, s_len) \
639  odbc_set_string_flag(dbc, buf, buf_len, out_len, s, s_len, (sizeof(*(out_len)) == sizeof(SQLSMALLINT)?0x20:0x30))
640 #endif
641 
642 SQLSMALLINT odbc_get_concise_sql_type(SQLSMALLINT type, SQLSMALLINT interval);
643 SQLRETURN odbc_set_concise_sql_type(SQLSMALLINT concise_type, struct _drecord *drec, int check_only);
644 SQLSMALLINT odbc_get_concise_c_type(SQLSMALLINT type, SQLSMALLINT interval);
645 SQLRETURN odbc_set_concise_c_type(SQLSMALLINT concise_type, struct _drecord *drec, int check_only);
646 
647 SQLLEN odbc_get_octet_len(int c_type, const struct _drecord *drec);
648 void odbc_convert_err_set(struct _sql_errors *errs, TDS_INT err);
649 
650 /*
651  * prepare_query.c
652  */
653 SQLRETURN prepare_call(struct _hstmt *stmt);
654 SQLRETURN native_sql(struct _hdbc *dbc, DSTR *s);
655 int parse_prepared_query(struct _hstmt *stmt, int compute_row);
656 int start_parse_prepared_query(struct _hstmt *stmt, int compute_row);
657 int continue_parse_prepared_query(struct _hstmt *stmt, SQLPOINTER DataPtr, SQLLEN StrLen_or_Ind);
658 const char *parse_const_param(const char * s, TDS_SERVER_TYPE *type);
659 const char *odbc_skip_rpc_name(const char *s);
660 
661 /*
662  * sql2tds.c
663  */
664 SQLRETURN odbc_sql2tds(TDS_STMT * stmt, const struct _drecord *drec_ixd, const struct _drecord *drec_axd, TDSCOLUMN *curcol, int compute_row, const TDS_DESC* axd, unsigned int n_row);
665 TDS_INT convert_datetime2server(int bindtype, const void *src, TDS_DATETIMEALL * dta);
666 
667 /*
668  * bcp.c
669  */
670 void odbc_bcp_free_storage(TDS_DBC *dbc);
671 void odbc_bcp_init(TDS_DBC *dbc, const ODBC_CHAR *tblname, const ODBC_CHAR *hfile, const ODBC_CHAR *errfile, int direction _WIDE);
672 void odbc_bcp_control(TDS_DBC *dbc, int field, void *value);
673 void odbc_bcp_colptr(TDS_DBC *dbc, const void * colptr, int table_column);
674 void odbc_bcp_sendrow(TDS_DBC *dbc);
675 int odbc_bcp_batch(TDS_DBC *dbc);
676 int odbc_bcp_done(TDS_DBC *dbc);
677 void odbc_bcp_bind(TDS_DBC *dbc, const void * varaddr, int prefixlen, int varlen, const void * terminator, int termlen, int vartype, int table_column);
678 
679 /*
680  * sqlwchar.c
681  */
682 #if SIZEOF_SQLWCHAR != SIZEOF_WCHAR_T
683 size_t sqlwcslen(const SQLWCHAR * s);
684 
685 typedef struct sqlwstr_buf {
686  struct sqlwstr_buf *next;
687  wchar_t buf[256];
688 } SQLWSTRBUF;
689 const wchar_t *sqlwstr(const SQLWCHAR * s, SQLWSTRBUF **bufs);
690 void sqlwstr_free(SQLWSTRBUF *bufs);
691 #define SQLWSTR_BUFS(n) SQLWSTRBUF *bufs = NULL
692 #define SQLWSTR(s) sqlwstr(s, &bufs)
693 #define SQLWSTR_FREE() sqlwstr_free(bufs)
694 #else
695 #define sqlwcslen(s) wcslen(s)
696 
697 #define SQLWSTR_BUFS(n) do {} while(0)
698 #define SQLWSTR(s) ((const wchar_t*)(s))
699 #define SQLWSTR_FREE() do {} while(0)
700 #endif
701 
702 #if SIZEOF_SQLWCHAR == 2
703 # if WORDS_BIGENDIAN
704 # define ODBC_WIDE_NAME "UCS-2BE"
705 # define ODBC_WIDE_NAME_UTF "UTF-16BE"
706 # else
707 # define ODBC_WIDE_NAME "UCS-2LE"
708 # define ODBC_WIDE_NAME_UTF "UTF-16LE"
709 # endif
710 const char *odbc_get_wide_name(TDSCONNECTION *conn);
711 #elif SIZEOF_SQLWCHAR == 4
712 # if WORDS_BIGENDIAN
713 # define ODBC_WIDE_NAME "UCS-4BE"
714 # else
715 # define ODBC_WIDE_NAME "UCS-4LE"
716 # endif
717 static inline const char *
718 odbc_get_wide_name(TDSCONNECTION *conn)
719 {
720  return ODBC_WIDE_NAME;
721 }
722 #else
723 #error SIZEOF_SQLWCHAR not supported !!
724 #endif
725 
726 #include <freetds/popvis.h>
727 
728 #ifdef __cplusplus
729 #if 0
730 {
731 #endif
732 }
733 #endif
734 
735 #endif
Definition: tds.h:1605
Definition: odbc.h:375
TDS_ODBC_ROW_STATUS row_status
status of row, it can happen that this flag mark that we are still parsing row, this it&#39;s normal ...
Definition: odbc.h:414
Structure to hold a string.
Definition: tds.h:94
Definition: tds.h:1063
Information for a server connection.
Definition: tds.h:1174
TDSSOCKET * tds
socket (only if active)
Definition: odbc.h:384
Definition: odbc.h:522
Definition: tds.h:549
struct _hstmt * stmt_list
list of all statements allocated from this connection
Definition: odbc.h:290
DSTR query
query to execute
Definition: odbc.h:382
TDSPARAMINFO * params
parameters saved
Definition: odbc.h:400
SQLRETURN odbc_set_concise_sql_type(SQLSMALLINT concise_type, struct _drecord *drec, int check_only)
Set concise type and all cascading field.
Definition: odbc_util.c:971
struct _hstmt * prev
previous in list
Definition: odbc.h:389
SQLINTEGER odbc_get_param_len(const struct _drecord *drec_axd, const struct _drecord *drec_ixd, const TDS_DESC *axd, unsigned int n_row)
Return length of parameter from parameter information.
Definition: odbc_util.c:857
Definition: odbc.h:157
TDS_SERVER_TYPE odbc_c_to_server_type(int c_type)
Pass this an SQL_C_* type and get a SYB* type which most closely corresponds to the SQL_C_* type...
Definition: odbc_util.c:600
Hold information for any results.
Definition: tds.h:803
int param_num
last valid parameter in params, it&#39;s a ODBC index (from 1 relative to descriptor) ...
Definition: odbc.h:402
Definition: odbc.h:240
Main include file for libtds.
unsigned int param_count
number of parameter in current query
Definition: odbc.h:409
Definition: odbc.h:88
Definition: tds.h:674
Definition: odbc.h:216
Definition: odbc.h:145
void odbc_rdbms_version(TDSSOCKET *tds_socket, char *pversion_string)
Returns the version of the RDBMS in the ODBC format.
Definition: odbc_util.c:848
Definition: iconv.h:91
Definition: odbc.h:303
char * prepared_pos
position in prepared query to check parameters, used only in RPC
Definition: odbc.h:404
Definition: odbc.h:231
Holds informations about a cursor.
Definition: tds.h:971
Definition: odbc.h:198
TDS_INT8 row_count
row count to return
Definition: odbc.h:412
Definition: odbc.h:100
SQLRETURN odbc_set_string_flag(TDS_DBC *dbc, SQLPOINTER buffer, SQLINTEGER cbBuffer, void FAR *pcbBuffer, const char *s, int len, int flag)
Copy a string to client setting size according to ODBC convenction.
Definition: odbc_util.c:279
Metadata about columns in regular and compute rows.
Definition: tds.h:726
struct _hstmt * current_statement
Statement executing.
Definition: odbc.h:288
SQLRETURN odbc_set_concise_c_type(SQLSMALLINT concise_type, struct _drecord *drec, int check_only)
Set concise type and all cascading field.
Definition: odbc_util.c:1093
Definition: tds.h:1102
Definition: odbc.h:432
this structure is not directed connected to a TDS protocol but keeps any DATE/TIME information...
Definition: tds.h:144
Definition: odbc.h:269
Holds information for a dynamic (also called prepared) query.
Definition: tds.h:1011
Definition: odbc.h:224
struct _hstmt * next
next in list
Definition: odbc.h:387
freetds-1.00.82/doc/reference/a00413_source.html100644 025423 025423 00000006372 13242511131 0014610 FreeTDS API: include/freetds/popvis.h Source File
FreeTDS API
popvis.h
1 #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__)
2 #pragma GCC visibility pop
3 #endif
freetds-1.00.82/doc/reference/a00416_source.html100644 025423 025423 00000220140 13242511131 0014602 FreeTDS API: include/freetds/proto.h Source File
FreeTDS API
proto.h
1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2  * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns
3  * Copyright (C) 2010, 2011 Frediano Ziglio
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20 
21 /*
22  * This file contains defines and structures strictly related to TDS protocol
23  */
24 
25 typedef struct tdsnumeric
26 {
27  unsigned char precision;
28  unsigned char scale;
29  unsigned char array[33];
30 } TDS_NUMERIC;
31 
32 typedef struct tdsoldmoney
33 {
34  TDS_INT mnyhigh;
35  TDS_UINT mnylow;
37 
38 typedef union tdsmoney
39 {
41  TDS_INT8 mny;
42 } TDS_MONEY;
43 
44 typedef struct tdsmoney4
45 {
46  TDS_INT mny4;
47 } TDS_MONEY4;
48 
49 typedef struct tdsdatetime
50 {
51  TDS_INT dtdays;
52  TDS_INT dttime;
53 } TDS_DATETIME;
54 
55 typedef struct tdsdatetime4
56 {
57  TDS_USMALLINT days;
58  TDS_USMALLINT minutes;
60 
61 typedef struct tdsunique
62 {
63  TDS_UINT Data1;
64  TDS_USMALLINT Data2;
65  TDS_USMALLINT Data3;
66  TDS_UCHAR Data4[8];
67 } TDS_UNIQUE;
68 
69 typedef TDS_INT TDS_DATE;
70 typedef TDS_INT TDS_TIME;
71 
72 typedef TDS_UINT8 TDS_BIGTIME;
73 typedef TDS_UINT8 TDS_BIGDATETIME;
74 
75 #define TDS5_PARAMFMT2_TOKEN 32 /* 0x20 */
76 #define TDS_LANGUAGE_TOKEN 33 /* 0x21 TDS 5.0 only */
77 #define TDS_ORDERBY2_TOKEN 34 /* 0x22 */
78 #define TDS_ROWFMT2_TOKEN 97 /* 0x61 TDS 5.0 only */
79 #define TDS_MSG_TOKEN 101 /* 0x65 TDS 5.0 only */
80 #define TDS_LOGOUT_TOKEN 113 /* 0x71 TDS 5.0 only? ct_close() */
81 #define TDS_RETURNSTATUS_TOKEN 121 /* 0x79 */
82 #define TDS_PROCID_TOKEN 124 /* 0x7C TDS 4.2 only - TDS_PROCID */
83 #define TDS7_RESULT_TOKEN 129 /* 0x81 TDS 7.0 only */
84 #define TDS7_COMPUTE_RESULT_TOKEN 136 /* 0x88 TDS 7.0 only */
85 #define TDS_COLNAME_TOKEN 160 /* 0xA0 TDS 4.2 only */
86 #define TDS_COLFMT_TOKEN 161 /* 0xA1 TDS 4.2 only - TDS_COLFMT */
87 #define TDS_DYNAMIC2_TOKEN 163 /* 0xA3 */
88 #define TDS_TABNAME_TOKEN 164 /* 0xA4 */
89 #define TDS_COLINFO_TOKEN 165 /* 0xA5 */
90 #define TDS_OPTIONCMD_TOKEN 166 /* 0xA6 */
91 #define TDS_COMPUTE_NAMES_TOKEN 167 /* 0xA7 */
92 #define TDS_COMPUTE_RESULT_TOKEN 168 /* 0xA8 */
93 #define TDS_ORDERBY_TOKEN 169 /* 0xA9 TDS_ORDER */
94 #define TDS_ERROR_TOKEN 170 /* 0xAA */
95 #define TDS_INFO_TOKEN 171 /* 0xAB */
96 #define TDS_PARAM_TOKEN 172 /* 0xAC RETURNVALUE? */
97 #define TDS_LOGINACK_TOKEN 173 /* 0xAD */
98 #define TDS_CONTROL_FEATUREEXTACK_TOKEN \
99  174 /* 0xAE TDS_CONTROL/TDS_FEATUREEXTACK */
100 #define TDS_ROW_TOKEN 209 /* 0xD1 */
101 #define TDS_NBC_ROW_TOKEN 210 /* 0xD2 as of TDS 7.3.B */
102 #define TDS_CMP_ROW_TOKEN 211 /* 0xD3 */
103 #define TDS5_PARAMS_TOKEN 215 /* 0xD7 TDS 5.0 only */
104 #define TDS_CAPABILITY_TOKEN 226 /* 0xE2 */
105 #define TDS_ENVCHANGE_TOKEN 227 /* 0xE3 */
106 #define TDS_SESSIONSTATE_TOKEN 228 /* 0xE4 TDS 7.4 */
107 #define TDS_EED_TOKEN 229 /* 0xE5 */
108 #define TDS_DBRPC_TOKEN 230 /* 0xE6 TDS 5.0 only */
109 #define TDS5_DYNAMIC_TOKEN 231 /* 0xE7 TDS 5.0 only */
110 #define TDS5_PARAMFMT_TOKEN 236 /* 0xEC TDS 5.0 only */
111 #define TDS_AUTH_TOKEN 237 /* 0xED TDS 7.0 only */
112 #define TDS_RESULT_TOKEN 238 /* 0xEE */
113 #define TDS_DONE_TOKEN 253 /* 0xFD TDS_DONE */
114 #define TDS_DONEPROC_TOKEN 254 /* 0xFE TDS_DONEPROC */
115 #define TDS_DONEINPROC_TOKEN 255 /* 0xFF TDS_DONEINPROC */
116 
117 /* CURSOR support: TDS 5.0 only*/
118 #define TDS_CURCLOSE_TOKEN 128 /* 0x80 TDS 5.0 only */
119 #define TDS_CURDELETE_TOKEN 129 /* 0x81 TDS 5.0 only */
120 #define TDS_CURFETCH_TOKEN 130 /* 0x82 TDS 5.0 only */
121 #define TDS_CURINFO_TOKEN 131 /* 0x83 TDS 5.0 only */
122 #define TDS_CUROPEN_TOKEN 132 /* 0x84 TDS 5.0 only */
123 #define TDS_CURDECLARE_TOKEN 134 /* 0x86 TDS 5.0 only */
124 
125 
126 /* environment type field */
127 #define TDS_ENV_DATABASE 1
128 #define TDS_ENV_LANG 2
129 #define TDS_ENV_CHARSET 3
130 #define TDS_ENV_PACKSIZE 4
131 #define TDS_ENV_LCID 5
132 #define TDS_ENV_SQLCOLLATION 7
133 #define TDS_ENV_BEGINTRANS 8
134 #define TDS_ENV_COMMITTRANS 9
135 #define TDS_ENV_ROLLBACKTRANS 10
136 #define TDS_ENV_ROUTING 20
137 
138 /* Microsoft internal stored procedure id's */
139 #define TDS_SP_CURSOR 1
140 #define TDS_SP_CURSOROPEN 2
141 #define TDS_SP_CURSORPREPARE 3
142 #define TDS_SP_CURSOREXECUTE 4
143 #define TDS_SP_CURSORPREPEXEC 5
144 #define TDS_SP_CURSORUNPREPARE 6
145 #define TDS_SP_CURSORFETCH 7
146 #define TDS_SP_CURSOROPTION 8
147 #define TDS_SP_CURSORCLOSE 9
148 #define TDS_SP_EXECUTESQL 10
149 #define TDS_SP_PREPARE 11
150 #define TDS_SP_EXECUTE 12
151 #define TDS_SP_PREPEXEC 13
152 #define TDS_SP_PREPEXECRPC 14
153 #define TDS_SP_UNPREPARE 15
154 
155 /*
156  * <rant> Sybase does an awful job of this stuff, non null ints of size 1 2
157  * and 4 have there own codes but nullable ints are lumped into INTN
158  * sheesh! </rant>
159  */
160 typedef enum
161 {
162  SYBCHAR = 47, /* 0x2F */
163  SYBVARCHAR = 39, /* 0x27 */
164  SYBINTN = 38, /* 0x26 */
165  SYBINT1 = 48, /* 0x30 */
166  SYBINT2 = 52, /* 0x34 */
167  SYBINT4 = 56, /* 0x38 */
168  SYBFLT8 = 62, /* 0x3E */
169  SYBDATETIME = 61, /* 0x3D */
170  SYBBIT = 50, /* 0x32 */
171  SYBTEXT = 35, /* 0x23 */
172  SYBNTEXT = 99, /* 0x63 */
173  SYBIMAGE = 34, /* 0x22 */
174  SYBMONEY4 = 122, /* 0x7A */
175  SYBMONEY = 60, /* 0x3C */
176  SYBDATETIME4 = 58, /* 0x3A */
177  SYBREAL = 59, /* 0x3B */
178  SYBBINARY = 45, /* 0x2D */
179  SYBVOID = 31, /* 0x1F */
180  SYBVARBINARY = 37, /* 0x25 */
181  SYBBITN = 104, /* 0x68 */
182  SYBNUMERIC = 108, /* 0x6C */
183  SYBDECIMAL = 106, /* 0x6A */
184  SYBFLTN = 109, /* 0x6D */
185  SYBMONEYN = 110, /* 0x6E */
186  SYBDATETIMN = 111, /* 0x6F */
187 
188 /*
189  * MS only types
190  */
191  SYBNVARCHAR = 103, /* 0x67 */
192  SYBINT8 = 127, /* 0x7F */
193  XSYBCHAR = 175, /* 0xAF */
194  XSYBVARCHAR = 167, /* 0xA7 */
195  XSYBNVARCHAR = 231, /* 0xE7 */
196  XSYBNCHAR = 239, /* 0xEF */
197  XSYBVARBINARY = 165, /* 0xA5 */
198  XSYBBINARY = 173, /* 0xAD */
199  SYBUNIQUE = 36, /* 0x24 */
200  SYBVARIANT = 98, /* 0x62 */
201  SYBMSUDT = 240, /* 0xF0 */
202  SYBMSXML = 241, /* 0xF1 */
203  SYBMSDATE = 40, /* 0x28 */
204  SYBMSTIME = 41, /* 0x29 */
205  SYBMSDATETIME2 = 42, /* 0x2a */
206  SYBMSDATETIMEOFFSET = 43,/* 0x2b */
207 
208 /*
209  * Sybase only types
210  */
211  SYBLONGBINARY = 225, /* 0xE1 */
212  SYBUINT1 = 64, /* 0x40 */
213  SYBUINT2 = 65, /* 0x41 */
214  SYBUINT4 = 66, /* 0x42 */
215  SYBUINT8 = 67, /* 0x43 */
216  SYBBLOB = 36, /* 0x24 */
217  SYBBOUNDARY = 104, /* 0x68 */
218  SYBDATE = 49, /* 0x31 */
219  SYBDATEN = 123, /* 0x7B */
220  SYB5INT8 = 191, /* 0xBF */
221  SYBINTERVAL = 46, /* 0x2E */
222  SYBLONGCHAR = 175, /* 0xAF */
223  SYBSENSITIVITY = 103, /* 0x67 */
224  SYBSINT1 = 176, /* 0xB0 */
225  SYBTIME = 51, /* 0x33 */
226  SYBTIMEN = 147, /* 0x93 */
227  SYBUINTN = 68, /* 0x44 */
228  SYBUNITEXT = 174, /* 0xAE */
229  SYBXML = 163, /* 0xA3 */
230  SYB5BIGDATETIME = 187, /* 0xBB */
231  SYB5BIGTIME = 188, /* 0xBC */
232 
233 } TDS_SERVER_TYPE;
234 
235 typedef enum
236 {
237  USER_UNICHAR_TYPE = 34, /* 0x22 */
238  USER_UNIVARCHAR_TYPE = 35 /* 0x23 */
239 } TDS_USER_TYPE;
240 
241 /* compute operator */
242 #define SYBAOPCNT 75 /* 0x4B */
243 #define SYBAOPCNTU 76 /* 0x4C, obsolete */
244 #define SYBAOPSUM 77 /* 0x4D */
245 #define SYBAOPSUMU 78 /* 0x4E, obsolete */
246 #define SYBAOPAVG 79 /* 0x4F */
247 #define SYBAOPAVGU 80 /* 0x50, obsolete */
248 #define SYBAOPMIN 81 /* 0x51 */
249 #define SYBAOPMAX 82 /* 0x52 */
250 
251 /* mssql2k compute operator */
252 #define SYBAOPCNT_BIG 9 /* 0x09 */
253 #define SYBAOPSTDEV 48 /* 0x30 */
254 #define SYBAOPSTDEVP 49 /* 0x31 */
255 #define SYBAOPVAR 50 /* 0x32 */
256 #define SYBAOPVARP 51 /* 0x33 */
257 #define SYBAOPCHECKSUM_AGG 114 /* 0x72 */
258 
262 typedef enum
263 {
264  TDS_OPT_SET = 1
265  , TDS_OPT_DEFAULT = 2
266  , TDS_OPT_LIST = 3
267  , TDS_OPT_INFO = 4
268 } TDS_OPTION_CMD;
269 
270 typedef enum
271 {
272  TDS_OPT_DATEFIRST = 1 /* 0x01 */
273  , TDS_OPT_TEXTSIZE = 2 /* 0x02 */
274  , TDS_OPT_STAT_TIME = 3 /* 0x03 */
275  , TDS_OPT_STAT_IO = 4 /* 0x04 */
276  , TDS_OPT_ROWCOUNT = 5 /* 0x05 */
277  , TDS_OPT_NATLANG = 6 /* 0x06 */
278  , TDS_OPT_DATEFORMAT = 7 /* 0x07 */
279  , TDS_OPT_ISOLATION = 8 /* 0x08 */
280  , TDS_OPT_AUTHON = 9 /* 0x09 */
281  , TDS_OPT_CHARSET = 10 /* 0x0a */
282  , TDS_OPT_SHOWPLAN = 13 /* 0x0d */
283  , TDS_OPT_NOEXEC = 14 /* 0x0e */
284  , TDS_OPT_ARITHIGNOREON = 15 /* 0x0f */
285  , TDS_OPT_ARITHABORTON = 17 /* 0x11 */
286  , TDS_OPT_PARSEONLY = 18 /* 0x12 */
287  , TDS_OPT_GETDATA = 20 /* 0x14 */
288  , TDS_OPT_NOCOUNT = 21 /* 0x15 */
289  , TDS_OPT_FORCEPLAN = 23 /* 0x17 */
290  , TDS_OPT_FORMATONLY = 24 /* 0x18 */
291  , TDS_OPT_CHAINXACTS = 25 /* 0x19 */
292  , TDS_OPT_CURCLOSEONXACT = 26 /* 0x1a */
293  , TDS_OPT_FIPSFLAG = 27 /* 0x1b */
294  , TDS_OPT_RESTREES = 28 /* 0x1c */
295  , TDS_OPT_IDENTITYON = 29 /* 0x1d */
296  , TDS_OPT_CURREAD = 30 /* 0x1e */
297  , TDS_OPT_CURWRITE = 31 /* 0x1f */
298  , TDS_OPT_IDENTITYOFF = 32 /* 0x20 */
299  , TDS_OPT_AUTHOFF = 33 /* 0x21 */
300  , TDS_OPT_ANSINULL = 34 /* 0x22 */
301  , TDS_OPT_QUOTED_IDENT = 35 /* 0x23 */
302  , TDS_OPT_ARITHIGNOREOFF = 36 /* 0x24 */
303  , TDS_OPT_ARITHABORTOFF = 37 /* 0x25 */
304  , TDS_OPT_TRUNCABORT = 38 /* 0x26 */
305 } TDS_OPTION;
306 
307 enum {
308  TDS_OPT_ARITHOVERFLOW = 0x01,
309  TDS_OPT_NUMERICTRUNC = 0x02
310 };
311 
312 enum TDS_OPT_DATEFIRST_CHOICE
313 {
314  TDS_OPT_MONDAY = 1, TDS_OPT_TUESDAY = 2, TDS_OPT_WEDNESDAY = 3, TDS_OPT_THURSDAY = 4, TDS_OPT_FRIDAY = 5, TDS_OPT_SATURDAY =
315  6, TDS_OPT_SUNDAY = 7
316 };
317 
318 enum TDS_OPT_DATEFORMAT_CHOICE
319 {
320  TDS_OPT_FMTMDY = 1, TDS_OPT_FMTDMY = 2, TDS_OPT_FMTYMD = 3, TDS_OPT_FMTYDM = 4, TDS_OPT_FMTMYD = 5, TDS_OPT_FMTDYM = 6
321 };
322 enum TDS_OPT_ISOLATION_CHOICE
323 {
324  TDS_OPT_LEVEL0 = 0,
325  TDS_OPT_LEVEL1 = 1,
326  TDS_OPT_LEVEL2 = 2,
327  TDS_OPT_LEVEL3 = 3
328 };
329 
330 
331 typedef enum tds_packet_type
332 {
333  TDS_QUERY = 1,
334  TDS_LOGIN = 2,
335  TDS_RPC = 3,
336  TDS_REPLY = 4,
337  TDS_CANCEL = 6,
338  TDS_BULK = 7,
339  TDS7_TRANS = 14, /* transaction management */
340  TDS_NORMAL = 15,
341  TDS7_LOGIN = 16,
342  TDS7_AUTH = 17,
343  TDS71_PRELOGIN = 18,
344  TDS72_SMP = 0x53
345 } TDS_PACKET_TYPE;
346 
350 typedef struct
351 {
352  TDS_USMALLINT locale_id; /* master..syslanguages.lcid */
353  TDS_USMALLINT flags;
354  TDS_UCHAR charset_id; /* or zero */
356 
360 typedef struct
361 {
362  TDS_UCHAR signature; /* TDS72_SMP */
363  TDS_UCHAR type;
364  TDS_USMALLINT sid;
365  TDS_UINT size;
366  TDS_UINT seq;
367  TDS_UINT wnd;
369 
370 enum {
371  TDS_SMP_SYN = 1,
372  TDS_SMP_ACK = 2,
373  TDS_SMP_FIN = 4,
374  TDS_SMP_DATA = 8,
375 };
376 
377 /* SF stands for "sort flag" */
378 #define TDS_SF_BIN (TDS_USMALLINT) 0x100
379 #define TDS_SF_WIDTH_INSENSITIVE (TDS_USMALLINT) 0x080
380 #define TDS_SF_KATATYPE_INSENSITIVE (TDS_USMALLINT) 0x040
381 #define TDS_SF_ACCENT_SENSITIVE (TDS_USMALLINT) 0x020
382 #define TDS_SF_CASE_INSENSITIVE (TDS_USMALLINT) 0x010
383 
384 /* UT stands for user type */
385 #define TDS_UT_TIMESTAMP 80
386 
387 
388 /* mssql login options flags */
389 enum option_flag1_values {
390  TDS_BYTE_ORDER_X86 = 0,
391  TDS_CHARSET_ASCII = 0,
392  TDS_DUMPLOAD_ON = 0,
393  TDS_FLOAT_IEEE_754 = 0,
394  TDS_INIT_DB_WARN = 0,
395  TDS_SET_LANG_OFF = 0,
396  TDS_USE_DB_SILENT = 0,
397  TDS_BYTE_ORDER_68000 = 0x01,
398  TDS_CHARSET_EBDDIC = 0x02,
399  TDS_FLOAT_VAX = 0x04,
400  TDS_FLOAT_ND5000 = 0x08,
401  TDS_DUMPLOAD_OFF = 0x10, /* prevent BCP */
402  TDS_USE_DB_NOTIFY = 0x20,
403  TDS_INIT_DB_FATAL = 0x40,
404  TDS_SET_LANG_ON = 0x80
405 };
406 
407 enum option_flag2_values {
408  TDS_INIT_LANG_WARN = 0,
409  TDS_INTEGRATED_SECURTY_OFF = 0,
410  TDS_ODBC_OFF = 0,
411  TDS_USER_NORMAL = 0, /* SQL Server login */
412  TDS_INIT_LANG_REQUIRED = 0x01,
413  TDS_ODBC_ON = 0x02,
414  TDS_TRANSACTION_BOUNDARY71 = 0x04, /* removed in TDS 7.2 */
415  TDS_CACHE_CONNECT71 = 0x08, /* removed in TDS 7.2 */
416  TDS_USER_SERVER = 0x10, /* reserved */
417  TDS_USER_REMUSER = 0x20, /* DQ login */
418  TDS_USER_SQLREPL = 0x40, /* replication login */
419  TDS_INTEGRATED_SECURITY_ON = 0x80
420 };
421 
422 enum option_flag3_values {
423  TDS_RESTRICTED_COLLATION = 0,
424  TDS_CHANGE_PASSWORD = 0x01, /* TDS 7.2 */
425  TDS_SEND_YUKON_BINARY_XML = 0x02, /* TDS 7.2 */
426  TDS_REQUEST_USER_INSTANCE = 0x04, /* TDS 7.2 */
427  TDS_UNKNOWN_COLLATION_HANDLING = 0x08, /* TDS 7.3 */
428  TDS_EXTENSION = 0x10, /* TDS 7.4 */
429 };
430 
431 enum type_flags {
432  TDS_OLEDB_ON = 0x10,
433  TDS_READONLY_INTENT = 0x20,
434 };
435 
436 /* Sybase dynamic types */
437 enum dynamic_types {
438  TDS_DYN_PREPARE = 0x01,
439  TDS_DYN_EXEC = 0x02,
440  TDS_DYN_DEALLOC = 0x04,
441  TDS_DYN_EXEC_IMMED = 0x08,
442  TDS_DYN_PROCNAME = 0x10,
443  TDS_DYN_ACK = 0x20,
444  TDS_DYN_DESCIN = 0x40,
445  TDS_DYN_DESCOUT = 0x80,
446 };
447 
448 /* http://jtds.sourceforge.net/apiCursors.html */
449 /* Cursor scroll option, must be one of 0x01 - 0x10, OR'd with other bits */
450 enum {
451  TDS_CUR_TYPE_KEYSET = 0x0001, /* default */
452  TDS_CUR_TYPE_DYNAMIC = 0x0002,
453  TDS_CUR_TYPE_FORWARD = 0x0004,
454  TDS_CUR_TYPE_STATIC = 0x0008,
455  TDS_CUR_TYPE_FASTFORWARDONLY = 0x0010,
456  TDS_CUR_TYPE_PARAMETERIZED = 0x1000,
457  TDS_CUR_TYPE_AUTO_FETCH = 0x2000
458 };
459 
460 enum {
461  TDS_CUR_CONCUR_READ_ONLY = 1,
462  TDS_CUR_CONCUR_SCROLL_LOCKS = 2,
463  TDS_CUR_CONCUR_OPTIMISTIC = 4, /* default */
464  TDS_CUR_CONCUR_OPTIMISTIC_VALUES = 8
465 };
466 
467 /* TDS 4/5 login*/
468 #define TDS_MAXNAME 30 /* maximum login name lenghts */
469 #define TDS_PROGNLEN 10 /* maximum program lenght */
470 #define TDS_PKTLEN 6 /* maximum packet lenght in login */
471 
472 /* TDS 5 login security flags */
473 enum {
474  TDS5_SEC_LOG_ENCRYPT = 1,
475  TDS5_SEC_LOG_CHALLENGE = 2,
476  TDS5_SEC_LOG_LABELS = 4,
477  TDS5_SEC_LOG_APPDEFINED = 8,
478  TDS5_SEC_LOG_SECSESS = 16,
479  TDS5_SEC_LOG_ENCRYPT2 = 32,
480  TDS5_SEC_LOG_NONCE = 128
481 };
Definition: proto.h:49
Definition: proto.h:32
Definition: proto.h:61
Definition: proto.h:44
Definition: proto.h:25
TDS 7.2 SMP packet header.
Definition: proto.h:360
Definition: proto.h:55
Definition: proto.h:38
TDS 7.1 collation informations.
Definition: proto.h:350
freetds-1.00.82/doc/reference/a00419_source.html100644 025423 025423 00000006405 13242511131 0014613 FreeTDS API: include/freetds/pushvis.h Source File
FreeTDS API
pushvis.h
1 #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__)
2 #pragma GCC visibility push(hidden)
3 #endif
freetds-1.00.82/doc/reference/a00422_source.html100644 025423 025423 00000037615 13242511131 0014614 FreeTDS API: include/freetds/server.h Source File
FreeTDS API
server.h
1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2  * Copyright (C) 1998-1999 Brian Bruns
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 
20 #ifndef _tdsserver_h_
21 #define _tdsserver_h_
22 #endif
23 
24 #ifdef __cplusplus
25 extern "C"
26 {
27 #endif
28 #if 0
29 }
30 #endif
31 
32 /* login.c */
33 unsigned char *tds7_decrypt_pass(const unsigned char *crypt_pass, int len, unsigned char *clear_pass);
34 TDSSOCKET *tds_listen(TDSCONTEXT * ctx, int ip_port);
35 int tds_read_login(TDSSOCKET * tds, TDSLOGIN * login);
36 int tds7_read_login(TDSSOCKET * tds, TDSLOGIN * login);
37 TDSLOGIN *tds_alloc_read_login(TDSSOCKET * tds);
38 
39 /* query.c */
40 char *tds_get_query(TDSSOCKET * tds);
41 char *tds_get_generic_query(TDSSOCKET * tds);
42 
43 /* server.c */
44 void tds_env_change(TDSSOCKET * tds, int type, const char *oldvalue, const char *newvalue);
45 void tds_send_msg(TDSSOCKET * tds, int msgno, int msgstate, int severity, const char *msgtext, const char *srvname,
46  const char *procname, int line);
47 void tds_send_login_ack(TDSSOCKET * tds, const char *progname);
48 void tds_send_eed(TDSSOCKET * tds, int msgno, int msgstate, int severity, char *msgtext, char *srvname, char *procname, int line);
49 void tds_send_err(TDSSOCKET * tds, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr);
50 void tds_send_capabilities_token(TDSSOCKET * tds);
51 /* TODO remove, use tds_send_done */
52 void tds_send_done_token(TDSSOCKET * tds, TDS_SMALLINT flags, TDS_INT numrows);
53 void tds_send_done(TDSSOCKET * tds, int token, TDS_SMALLINT flags, TDS_INT numrows);
54 void tds_send_control_token(TDSSOCKET * tds, TDS_SMALLINT numcols);
55 void tds_send_col_name(TDSSOCKET * tds, TDSRESULTINFO * resinfo);
56 void tds_send_col_info(TDSSOCKET * tds, TDSRESULTINFO * resinfo);
57 void tds_send_result(TDSSOCKET * tds, TDSRESULTINFO * resinfo);
58 void tds7_send_result(TDSSOCKET * tds, TDSRESULTINFO * resinfo);
59 void tds_send_table_header(TDSSOCKET * tds, TDSRESULTINFO * resinfo);
60 void tds_send_row(TDSSOCKET * tds, TDSRESULTINFO * resinfo);
61 void tds71_send_prelogin(TDSSOCKET * tds);
62 
63 #if 0
64 {
65 #endif
66 #ifdef __cplusplus
67 }
68 #endif
Definition: tds.h:1063
Information for a server connection.
Definition: tds.h:1174
Definition: tds.h:549
Hold information for any results.
Definition: tds.h:803
freetds-1.00.82/doc/reference/a00425_source.html100644 025423 025423 00000060765 13242511131 0014621 FreeTDS API: include/freetds/stream.h Source File
FreeTDS API
stream.h
1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2  * Copyright (C) 2013 Frediano Ziglio
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 
20 #ifndef _freetds_stream_h_
21 #define _freetds_stream_h_
22 
23 #ifndef _tds_h_
24 #error Include tds.h first
25 #endif
26 
27 #include <freetds/pushvis.h>
28 
30 typedef struct tds_input_stream {
35  int (*read)(struct tds_input_stream *stream, void *ptr, size_t len);
36 } TDSINSTREAM;
37 
39 typedef struct tds_output_stream {
41  int (*write)(struct tds_output_stream *stream, size_t len);
50  char *buffer;
51  size_t buf_len;
52 } TDSOUTSTREAM;
53 
55 TDSRET tds_convert_stream(TDSSOCKET * tds, TDSICONV * char_conv, TDS_ICONV_DIRECTION direction,
56  TDSINSTREAM * istream, TDSOUTSTREAM *ostream);
58 TDSRET tds_copy_stream(TDSSOCKET * tds, TDSINSTREAM * istream, TDSOUTSTREAM * ostream);
59 
60 /* Additional streams */
61 
63 typedef struct tds_datain_stream {
64  TDSINSTREAM stream;
65  size_t wire_size;
66  TDSSOCKET *tds;
68 
69 void tds_datain_stream_init(TDSDATAINSTREAM * stream, TDSSOCKET * tds, size_t wire_size);
70 
72 typedef struct tds_dataout_stream {
73  TDSOUTSTREAM stream;
74  TDSSOCKET *tds;
75  size_t written;
77 
79 
81 typedef struct tds_staticin_stream {
82  TDSINSTREAM stream;
83  const char *buffer;
84  size_t buf_left;
86 
87 void tds_staticin_stream_init(TDSSTATICINSTREAM * stream, const void *ptr, size_t len);
88 
92 typedef struct tds_staticout_stream {
93  TDSOUTSTREAM stream;
95 
96 void tds_staticout_stream_init(TDSSTATICOUTSTREAM * stream, void *ptr, size_t len);
97 
99 typedef struct tds_dynamic_stream {
100  TDSOUTSTREAM stream;
102  void **buf;
104  size_t allocated;
106  size_t size;
108 
109 TDSRET tds_dynamic_stream_init(TDSDYNAMICSTREAM * stream, void **ptr, size_t allocated);
110 
111 #include <freetds/popvis.h>
112 
113 #endif
114 
TDSRET tds_dynamic_stream_init(TDSDYNAMICSTREAM *stream, void **ptr, size_t allocated)
Initialize a dynamic output stream.
Definition: stream.c:353
Information for a server connection.
Definition: tds.h:1174
void tds_dataout_stream_init(TDSDATAOUTSTREAM *stream, TDSSOCKET *tds)
Initialize a data output stream.
Definition: stream.c:243
void tds_staticin_stream_init(TDSSTATICINSTREAM *stream, const void *ptr, size_t len)
Initialize an input stream for read from a static allocated buffer.
Definition: stream.c:285
int(* read)(struct tds_input_stream *stream, void *ptr, size_t len)
read some data Return 0 if end of stream Return <0 if error (actually not defined) ...
Definition: stream.h:35
define a stream of data used for input
Definition: stream.h:30
size_t wire_size
bytes still to read
Definition: stream.h:65
char * buffer
write buffer.
Definition: stream.h:50
output stream to write data to a static buffer.
Definition: stream.h:92
void tds_datain_stream_init(TDSDATAINSTREAM *stream, TDSSOCKET *tds, size_t wire_size)
Initialize a data input stream.
Definition: stream.c:203
void tds_staticout_stream_init(TDSSTATICOUTSTREAM *stream, void *ptr, size_t len)
Initialize an output stream for write into a static allocated buffer.
Definition: stream.c:312
size_t size
size of data inside buffer
Definition: stream.h:106
TDSRET tds_copy_stream(TDSSOCKET *tds, TDSINSTREAM *istream, TDSOUTSTREAM *ostream)
Reads and writes from a stream to another.
Definition: stream.c:163
input stream to read data from tds protocol
Definition: stream.h:63
Definition: iconv.h:91
size_t allocated
currently allocated buffer
Definition: stream.h:104
input stream to read data from a static buffer
Definition: stream.h:81
define a stream of data used for output
Definition: stream.h:39
void ** buf
where is stored the pointer
Definition: stream.h:102
TDSRET tds_convert_stream(TDSSOCKET *tds, TDSICONV *char_conv, TDS_ICONV_DIRECTION direction, TDSINSTREAM *istream, TDSOUTSTREAM *ostream)
Reads and writes from a stream converting characters.
Definition: stream.c:71
output stream to write data to a dynamic buffer
Definition: stream.h:99
output stream to write data to tds protocol
Definition: stream.h:72
freetds-1.00.82/doc/reference/a00428_source.html100644 025423 025423 00000051154 13242511131 0014614 FreeTDS API: include/freetds/string.h Source File
FreeTDS API
string.h
1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2  * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Brian Bruns
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 
20 #ifndef _tdsstring_h_
21 #define _tdsstring_h_
22 
23 #include <freetds/pushvis.h>
24 
30 extern const struct tds_dstr tds_str_empty;
31 
37 #define DSTR_INITIALIZER ((struct tds_dstr*) &tds_str_empty)
38 
40 static inline void
42 {
43  *(s) = DSTR_INITIALIZER;
44 }
45 
47 static inline int
49 {
50  return (*s)->dstr_size == 0;
51 }
52 
58 static inline char *
60 {
61  return (*s)->dstr_s;
62 }
63 
65 static inline const char *
67 {
68  return (*s)->dstr_s;
69 }
70 
72 static inline size_t
74 {
75  return (*s)->dstr_size;
76 }
77 
79 #define tds_dstr_empty(s) \
80  tds_dstr_free(s)
81 
82 void tds_dstr_zero(DSTR * s);
83 void tds_dstr_free(DSTR * s);
84 
85 DSTR* tds_dstr_dup(DSTR * s, const DSTR * src) TDS_WUR;
86 DSTR* tds_dstr_copy(DSTR * s, const char *src) TDS_WUR;
87 DSTR* tds_dstr_copyn(DSTR * s, const char *src, size_t length) TDS_WUR;
88 DSTR* tds_dstr_set(DSTR * s, char *src) TDS_WUR;
89 
90 DSTR* tds_dstr_setlen(DSTR *s, size_t length);
91 DSTR* tds_dstr_alloc(DSTR *s, size_t length) TDS_WUR;
92 
95 #include <freetds/popvis.h>
96 
97 #endif /* _tdsstring_h_ */
DSTR * tds_dstr_set(DSTR *s, char *src)
set a string from another buffer.
Definition: tdsstring.c:108
Structure to hold a string.
Definition: tds.h:94
static int tds_dstr_isempty(DSTR *s)
test if string is empty
Definition: string.h:48
static const char * tds_dstr_cstr(DSTR *s)
Returns a C version (NUL terminated string) of dstr.
Definition: string.h:66
DSTR * tds_dstr_dup(DSTR *s, const DSTR *src)
Duplicate a string from another dynamic string.
Definition: tdsstring.c:135
DSTR * tds_dstr_copy(DSTR *s, const char *src)
copy a string from another
Definition: tdsstring.c:123
#define DSTR_INITIALIZER
Initializer, used to initialize string like in the following example.
Definition: string.h:37
static void tds_dstr_init(DSTR *s)
init a string with empty
Definition: string.h:41
const struct tds_dstr tds_str_empty
Internal representation for an empty string.
Definition: tdsstring.c:46
void tds_dstr_free(DSTR *s)
free string
Definition: tdsstring.c:63
static char * tds_dstr_buf(DSTR *s)
Returns a buffer to edit the string.
Definition: string.h:59
void tds_dstr_zero(DSTR *s)
clear all string filling with zeroes (mainly for security reason)
Definition: tdsstring.c:56
DSTR * tds_dstr_copyn(DSTR *s, const char *src, size_t length)
Set string to a given buffer of characters.
Definition: tdsstring.c:78
static size_t tds_dstr_len(DSTR *s)
Returns the length of the string in bytes.
Definition: string.h:73
DSTR * tds_dstr_setlen(DSTR *s, size_t length)
limit length of string, MUST be <= current length
Definition: tdsstring.c:146
DSTR * tds_dstr_alloc(DSTR *s, size_t length)
allocate space for length char
Definition: tdsstring.c:166
freetds-1.00.82/doc/reference/a00431_source.html100644 025423 025423 00000120156 13242511131 0014605 FreeTDS API: include/freetds/sysdep_private.h Source File
FreeTDS API
sysdep_private.h
1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2  * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Brian Bruns
3  * Copyright (C) 2010 Frediano Ziglio
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20 
21 #ifndef _tds_sysdep_private_h_
22 #define _tds_sysdep_private_h_
23 
24 #define TDS_ADDITIONAL_SPACE 16
25 
26 #ifdef MSG_NOSIGNAL
27 # define TDS_NOSIGNAL MSG_NOSIGNAL
28 #else
29 # define TDS_NOSIGNAL 0L
30 #endif
31 
32 #ifdef __cplusplus
33 extern "C"
34 {
35 #if 0
36 }
37 #endif
38 #endif
39 
40 #ifdef __INCvxWorksh
41 #include <ioLib.h> /* for FIONBIO */
42 #endif /* __INCvxWorksh */
43 
44 #if defined(DOS32X)
45 #define READSOCKET(a,b,c) recv((a), (b), (c), TDS_NOSIGNAL)
46 #define WRITESOCKET(a,b,c) send((a), (b), (c), TDS_NOSIGNAL)
47 #define CLOSESOCKET(a) closesocket((a))
48 #define IOCTLSOCKET(a,b,c) ioctlsocket((a), (b), (char*)(c))
49 #define SOCKLEN_T int
50 #define select select_s
51 typedef int pid_t;
52 #define strcasecmp stricmp
53 #define strncasecmp strnicmp
54 /* TODO this has nothing to do with ip ... */
55 #define getpid() _gethostid()
56 #endif /* defined(DOS32X) */
57 
58 #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(_WIN64)
59 #include <winsock2.h>
60 #include <ws2tcpip.h>
61 #include <windows.h>
62 #define READSOCKET(a,b,c) recv((a), (char *) (b), (c), TDS_NOSIGNAL)
63 #define WRITESOCKET(a,b,c) send((a), (const char *) (b), (c), TDS_NOSIGNAL)
64 #define CLOSESOCKET(a) closesocket((a))
65 #define IOCTLSOCKET(a,b,c) ioctlsocket((a), (b), (c))
66 #define SOCKLEN_T int
67 int tds_socket_init(void);
68 #define INITSOCKET() tds_socket_init()
69 void tds_socket_done(void);
70 #define DONESOCKET() tds_socket_done()
71 #define NETDB_REENTRANT 1 /* BSD-style netdb interface is reentrant */
72 
73 #define TDSSOCK_EINTR WSAEINTR
74 #define TDSSOCK_EINPROGRESS WSAEWOULDBLOCK
75 #define TDSSOCK_ETIMEDOUT WSAETIMEDOUT
76 #define TDSSOCK_WOULDBLOCK(e) ((e)==WSAEWOULDBLOCK)
77 #define TDSSOCK_ECONNRESET WSAECONNRESET
78 #define sock_errno WSAGetLastError()
79 #define set_sock_errno(err) WSASetLastError(err)
80 #define sock_strerror(n) tds_prwsaerror(n)
81 #define sock_strerror_free(s) tds_prwsaerror_free(s)
82 #ifndef __MINGW32__
83 typedef DWORD pid_t;
84 #endif
85 #undef strcasecmp
86 #define strcasecmp stricmp
87 #undef strncasecmp
88 #define strncasecmp strnicmp
89 #if defined(HAVE__SNPRINTF) && !defined(HAVE_SNPRINTF)
90 #define snprintf _snprintf
91 #endif
92 
93 #ifndef WIN32
94 #define WIN32 1
95 #endif
96 
97 #if defined(_WIN64) && !defined(WIN64)
98 #define WIN64 1
99 #endif
100 
101 #define TDS_SDIR_SEPARATOR "\\"
102 
103 /* use macros to use new style names */
104 #if defined(__MSVCRT__) || defined(_MSC_VER)
105 /* Use API as always present and not causing problems */
106 #undef getpid
107 #define getpid() GetCurrentProcessId()
108 #define strdup(s) _strdup(s)
109 #define unlink(f) _unlink(f)
110 #define putenv(s) _putenv(s)
111 #undef fileno
112 #define fileno(f) _fileno(f)
113 #define stricmp(s1,s2) _stricmp(s1,s2)
114 #define strnicmp(s1,s2,n) _strnicmp(s1,s2,n)
115 #endif
116 
117 #endif /* defined(WIN32) || defined(_WIN32) || defined(__WIN32__) */
118 
119 #ifndef sock_errno
120 #define sock_errno errno
121 #endif
122 
123 #ifndef set_sock_errno
124 #define set_sock_errno(err) do { errno = (err); } while(0)
125 #endif
126 
127 #ifndef sock_strerror
128 #define sock_strerror(n) strerror(n)
129 #define sock_strerror_free(s) do {} while(0)
130 #endif
131 
132 #ifndef TDSSOCK_EINTR
133 #define TDSSOCK_EINTR EINTR
134 #endif
135 
136 #ifndef TDSSOCK_EINPROGRESS
137 #define TDSSOCK_EINPROGRESS EINPROGRESS
138 #endif
139 
140 #ifndef TDSSOCK_ETIMEDOUT
141 #define TDSSOCK_ETIMEDOUT ETIMEDOUT
142 #endif
143 
144 #ifndef TDSSOCK_WOULDBLOCK
145 # if defined(EWOULDBLOCK) && EAGAIN != EWOULDBLOCK
146 # define TDSSOCK_WOULDBLOCK(e) ((e)==EAGAIN||(e)==EWOULDBLOCK)
147 # else
148 # define TDSSOCK_WOULDBLOCK(e) ((e)==EAGAIN)
149 # endif
150 #endif
151 
152 #ifndef TDSSOCK_ECONNRESET
153 #define TDSSOCK_ECONNRESET ECONNRESET
154 #endif
155 
156 #ifndef INITSOCKET
157 #define INITSOCKET() 0
158 #endif /* !INITSOCKET */
159 
160 #ifndef DONESOCKET
161 #define DONESOCKET() do { } while(0)
162 #endif /* !DONESOCKET */
163 
164 #ifndef READSOCKET
165 # ifdef MSG_NOSIGNAL
166 # define READSOCKET(s,b,l) recv((s), (b), (l), MSG_NOSIGNAL)
167 # else
168 # define READSOCKET(s,b,l) read((s), (b), (l))
169 # endif
170 #endif /* !READSOCKET */
171 
172 #ifndef WRITESOCKET
173 # ifdef MSG_NOSIGNAL
174 # define WRITESOCKET(s,b,l) send((s), (b), (l), MSG_NOSIGNAL)
175 # else
176 # define WRITESOCKET(s,b,l) write((s), (b), (l))
177 # endif
178 #endif /* !WRITESOCKET */
179 
180 #ifndef CLOSESOCKET
181 #define CLOSESOCKET(s) close((s))
182 #endif /* !CLOSESOCKET */
183 
184 #ifndef IOCTLSOCKET
185 #define IOCTLSOCKET(s,b,l) ioctl((s), (b), (l))
186 #endif /* !IOCTLSOCKET */
187 
188 #ifndef SOCKLEN_T
189 # define SOCKLEN_T socklen_t
190 #endif
191 
192 #if !defined(__WIN32__) && !defined(_WIN32) && !defined(WIN32)
193 typedef int TDS_SYS_SOCKET;
194 #define INVALID_SOCKET -1
195 #define TDS_IS_SOCKET_INVALID(s) ((s) < 0)
196 #else
197 typedef SOCKET TDS_SYS_SOCKET;
198 #define TDS_IS_SOCKET_INVALID(s) ((s) == INVALID_SOCKET)
199 #endif
200 
201 #define tds_accept accept
202 #define tds_getpeername getpeername
203 #define tds_getsockopt getsockopt
204 #define tds_getsockname getsockname
205 #define tds_recvfrom recvfrom
206 
207 #if defined(__hpux__) && SIZEOF_VOID_P == 8 && SIZEOF_INT == 4
208 # if HAVE__XPG_ACCEPT
209 # undef tds_accept
210 # define tds_accept _xpg_accept
211 # elif HAVE___ACCEPT
212 # undef tds_accept
213 # define tds_accept __accept
214 # endif
215 # if HAVE__XPG_GETPEERNAME
216 # undef tds_getpeername
217 # define tds_getpeername _xpg_getpeername
218 # elif HAVE___GETPEERNAME
219 # undef tds_getpeername
220 # define tds_getpeername __getpeername
221 # endif
222 # if HAVE__XPG_GETSOCKOPT
223 # undef tds_getsockopt
224 # define tds_getsockopt _xpg_getsockopt
225 # elif HAVE___GETSOCKOPT
226 # undef tds_getsockopt
227 # define tds_getsockopt __getsockopt
228 # endif
229 # if HAVE__XPG_GETSOCKNAME
230 # undef tds_getsockname
231 # define tds_getsockname _xpg_getsockname
232 # elif HAVE___GETSOCKNAME
233 # undef tds_getsockname
234 # define tds_getsockname __getsockname
235 # endif
236 # if HAVE__XPG_RECVFROM
237 # undef tds_recvfrom
238 # define tds_recvfrom _xpg_recvfrom
239 # elif HAVE___RECVFROM
240 # undef tds_recvfrom
241 # define tds_recvfrom __recvfrom
242 # endif
243 #endif
244 
245 #ifndef TDS_SDIR_SEPARATOR
246 #define TDS_SDIR_SEPARATOR "/"
247 #endif /* !TDS_SDIR_SEPARATOR */
248 
249 #ifdef HAVE_INTTYPES_H
250 #include <inttypes.h>
251 #endif
252 
253 #ifndef PRId64
254 #define PRId64 TDS_I64_PREFIX "d"
255 #endif
256 #ifndef PRIu64
257 #define PRIu64 TDS_I64_PREFIX "u"
258 #endif
259 #ifndef PRIx64
260 #define PRIx64 TDS_I64_PREFIX "x"
261 #endif
262 
263 #ifdef __cplusplus
264 #if 0
265 {
266 #endif
267 }
268 #endif
269 
270 #endif /* _tds_sysdep_private_h_ */
freetds-1.00.82/doc/reference/a00434.html100644 025423 025423 00001126302 13242511136 0013235 FreeTDS API: include/freetds/tds.h File Reference
FreeTDS API
tds.h File Reference

Main include file for libtds. More...

#include <stdarg.h>
#include <stdio.h>
#include <time.h>
#include <freetds/version.h>
#include "tds_sysdep_public.h"
#include <freetds/sysdep_private.h>
#include <freetds/thread.h>
#include <freetds/bool.h>
#include "replacements.h"
#include <freetds/pushvis.h>
#include <freetds/proto.h>
#include <freetds/popvis.h>
Include dependency graph for tds.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

union  tds_align_struct
 
struct  tds_authentication
 
struct  tds_bcpcoldata
 
struct  tds_bcpinfo
 
struct  tds_blob
 Information about blobs (e.g. More...
 
struct  tds_capabilities
 
struct  tds_capability_type
 
struct  tds_column
 Metadata about columns in regular and compute rows. More...
 
struct  tds_column_funcs
 
struct  tds_compiletime_settings
 A structure to hold all the compile-time settings. More...
 
struct  tds_connection
 
struct  tds_context
 
struct  tds_cursor
 Holds informations about a cursor. More...
 
struct  tds_cursor_status
 
struct  TDS_DATETIMEALL
 this structure is not directed connected to a TDS protocol but keeps any DATE/TIME information. More...
 
struct  tds_dstr
 Structure to hold a string. More...
 
struct  tds_dynamic
 Holds information for a dynamic (also called prepared) query. More...
 
struct  tds_encoding
 Information relevant to libiconv. More...
 
struct  tds_env
 Current environment as reported by the server. More...
 
struct  tds_headers
 
struct  tds_locale
 
struct  tds_login
 
struct  tds_message
 
struct  tds_multiple
 
union  tds_option_arg
 
struct  tds_packet
 
struct  tds_poll_wakeup
 
struct  tds_result_info
 Hold information for any results. More...
 
struct  tds_socket
 Information for a server connection. More...
 
struct  tds_upd_col
 
struct  tds_variant
 Store variant informations. More...
 
struct  tdsdaterec
 Used by tds_datecrack. More...
 

Macros

#define is_ascii_type(x)   ((tds_type_flags_ms[x] & TDS_TYPEFLAG_ASCII) != 0)
 
#define is_blob_col(x)   ((x)->column_varint_size > 2)
 
#define is_blob_type(x)   ((x)==SYBTEXT || (x)==SYBIMAGE || (x)==SYBNTEXT)
 
#define is_char_type(x)   ((tds_type_flags_ms[x] & (TDS_TYPEFLAG_ASCII|TDS_TYPEFLAG_UNICODE)) != 0)
 
#define is_collate_type(x)   ((tds_type_flags_ms[x] & TDS_TYPEFLAG_COLLATE) != 0)
 
#define is_datetime_type(x)   ((tds_type_flags_ms[x] & TDS_TYPEFLAG_DATETIME) != 0)
 return true if type is a datetime (but not date or time)
 
#define is_end_token(x)
 
#define is_fixed_type(x)   ((tds_type_flags_ms[x] & TDS_TYPEFLAG_FIXED) != 0)
 
#define is_nullable_type(x)   ((tds_type_flags_ms[x] & TDS_TYPEFLAG_NULLABLE) != 0)
 
#define is_numeric_type(x)   ((x)==SYBNUMERIC || (x)==SYBDECIMAL)
 
#define is_similar_type(x, y)   (is_char_type(x) && is_char_type(y))
 
#define IS_TDS42(x)   (x->tds_version==0x402)
 
#define IS_TDS46(x)   (x->tds_version==0x406)
 
#define IS_TDS50(x)   (x->tds_version==0x500)
 
#define IS_TDS50_PLUS(x)   ((x)->tds_version>=0x500)
 
#define IS_TDS70(x)   (x->tds_version==0x700)
 
#define IS_TDS71(x)   (x->tds_version==0x701)
 
#define IS_TDS71_PLUS(x)   ((x)->tds_version>=0x701)
 
#define IS_TDS72(x)   (x->tds_version==0x702)
 
#define IS_TDS72_PLUS(x)   ((x)->tds_version>=0x702)
 
#define IS_TDS73(x)   (x->tds_version==0x703)
 
#define IS_TDS73_PLUS(x)   ((x)->tds_version>=0x703)
 
#define IS_TDS74_PLUS(x)   ((x)->tds_version>=0x704)
 
#define IS_TDS7_PLUS(x)   ((x)->tds_version>=0x700)
 
#define IS_TDSDEAD(x)   (((x) == NULL) || (x)->state == TDS_DEAD)
 
#define is_unicode_type(x)   ((tds_type_flags_ms[x] & TDS_TYPEFLAG_UNICODE) != 0)
 
#define is_variable_type(x)   ((tds_type_flags_ms[x] & TDS_TYPEFLAG_VARIABLE) != 0)
 
#define MAXPRECISION   77
 
#define TDS_ALIGN_SIZE   sizeof(tds_align_struct)
 
#define TDS_BYTE_SWAP16(value)
 
#define TDS_BYTE_SWAP32(value)
 
#define TDS_CANCELLED   ((TDSRET)-2)
 
#define tds_capability_has_req(conn, cap)   tds_capability_enabled(&conn->capabilities.types[0], cap)
 
#define TDS_CMD_DONE   4046
 
#define TDS_CMD_FAIL   4048
 
#define TDS_CMD_SUCCEED   4047
 
#define TDS_COMPILE_CHECK(name, check)   extern int disabled_check_##name
 
#define TDS_COMPUTE_RESULT   4045
 
#define TDS_COMPUTEFMT_RESULT   4050
 
#define tds_convert_string_free(original, converted)   do { if (original != converted) free((char*) converted); } while(0)
 
#define TDS_DBG_ERROR   __FILE__, ((__LINE__ << 4) | 2)
 
#define TDS_DBG_FUNC   __FILE__, ((__LINE__ << 4) | 7)
 
#define TDS_DBG_HEADER   __FILE__, ((__LINE__ << 4) | 10)
 
#define TDS_DBG_INFO1   __FILE__, ((__LINE__ << 4) | 5)
 
#define TDS_DBG_INFO2   __FILE__, ((__LINE__ << 4) | 6)
 
#define TDS_DBG_LOGIN   __FILE__, ((__LINE__ << 4) | 11)
 
#define TDS_DBG_NETWORK   __FILE__, ((__LINE__ << 4) | 4)
 
#define TDS_DBG_SEVERE   __FILE__, ((__LINE__ << 4) | 1)
 
#define TDS_DBG_WARN   __FILE__, ((__LINE__ << 4) | 3)
 
#define TDS_DBGFLAG_ALL   0xfff
 
#define TDS_DBGFLAG_ERROR   0x04
 
#define TDS_DBGFLAG_FUNC   0x80
 
#define TDS_DBGFLAG_HEADER   0x0400
 
#define TDS_DBGFLAG_INFO1   0x20
 
#define TDS_DBGFLAG_INFO2   0x40
 
#define TDS_DBGFLAG_LOGIN   0x0800
 
#define TDS_DBGFLAG_NETWORK   0x10
 
#define TDS_DBGFLAG_PID   0x1000
 
#define TDS_DBGFLAG_SEVERE   0x02
 
#define TDS_DBGFLAG_SOURCE   0x4000
 
#define TDS_DBGFLAG_THREAD   0x8000
 
#define TDS_DBGFLAG_TIME   0x2000
 
#define TDS_DBGFLAG_WARN   0x08
 
#define TDS_DEF_BLKSZ   512
 
#define TDS_DEF_CHARSET   "iso_1"
 
#define TDS_DEF_LANG   "us_english"
 
#define TDS_DEF_PORT   1433
 
#define TDS_DEF_SERVER   "SYBASE"
 
#define TDS_DEFAULT_VERSION   0x000
 
#define TDS_DESCRIBE_RESULT   4051
 
#define TDS_DONE_RESULT   4052
 
#define TDS_DONEINPROC_RESULT   4054
 
#define TDS_DONEPROC_RESULT   4053
 
#define TDS_EXTRA_CHECK(stmt)
 
#define TDS_FAIL   ((TDSRET)-1)
 
#define TDS_FAILED(rc)   ((rc)<0)
 
#define tds_get_ctx(tds)   ((tds)->conn->tds_ctx)
 
#define tds_get_int(tds)   ((TDS_INT) tds_get_uint(tds))
 
#define tds_get_int8(tds)   ((TDS_INT8) tds_get_uint8(tds))
 
#define tds_get_parent(tds)   ((tds)->parent)
 
#define tds_get_s(tds)   ((tds)->conn->s)
 
#define tds_get_smallint(tds)   ((TDS_SMALLINT) tds_get_usmallint(tds))
 
#define TDS_GSSAPI_DELEGATION   "enable gssapi delegation"
 
#define TDS_INT_CANCEL   2
 
#define TDS_INT_CONTINUE   1
 
#define TDS_INT_TIMEOUT   3
 
#define TDS_INVALID_TYPE   ((TDS_SERVER_TYPE) 0)
 
#define TDS_IS_MSSQL(x)   (((x)->conn->product_version & 0x80000000u)!=0)
 Check if product is Microsft SQL Server. More...
 
#define TDS_IS_SYBASE(x)   (!((x)->conn->product_version & 0x80000000u))
 Check if product is Sybase (such as Adaptive Server Enterrprice). More...
 
#define TDS_LIKELY(x)   (x)
 
#define TDS_MAJOR(x)   ((x)->tds_version >> 8)
 
#define TDS_MAX_CAPABILITY   32
 
#define TDS_MAX_CONN   4096
 
#define TDS_MAX_DYNID_LEN   30
 
#define TDS_MAX_LOGIN_STR_SZ   128
 
#define TDS_MINOR(x)   ((x)->tds_version & 0xff)
 
#define TDS_MS_VER(maj, min, x)   (0x80000000u|((maj)<<24)|((min)<<16)|(x))
 Calc a version number for mssql. More...
 
#define TDS_MSG_RESULT   4044
 
#define tds_new(type, n)   ((type *) malloc(sizeof(type) * (n)))
 
#define tds_new0(type, n)   ((type *) calloc(n, sizeof(type)))
 
#define TDS_NO_COUNT   -1
 
#define TDS_NO_MORE_RESULTS   ((TDSRET)1)
 
#define TDS_NULLTERM   -9
 
#define TDS_OFFSET(str, field)   (((char*)&((str*)0)->field)-((char*)0))
 
#define TDS_OTHERS_RESULT   4055
 
#define TDS_PARAM_RESULT   4042
 
#define TDS_PUT_BYTE(tds, v)   tds_put_byte((tds), ((unsigned char)(v)))
 
#define TDS_PUT_INT(tds, v)   tds_put_int((tds), ((TDS_INT)(v)))
 
#define TDS_PUT_SMALLINT(tds, v)   tds_put_smallint((tds), ((TDS_SMALLINT)(v)))
 
#define tds_put_tinyint(tds, ti)   tds_put_byte(tds,ti)
 Output a tinyint value.
 
#define TDS_RESIZE(p, n_elem)   tds_realloc((void **) &(p), sizeof(*(p)) * (size_t) (n_elem))
 
#define TDS_ROW_RESULT   4040
 
#define TDS_ROWFMT_RESULT   4049
 
#define tds_set_ctx(tds, val)   do { ((tds)->conn->tds_ctx) = (val); } while(0)
 
#define tds_set_parent(tds, val)   do { ((tds)->parent) = (val); } while(0)
 
#define tds_set_s(tds, val)   do { ((tds)->conn->s) = (val); } while(0)
 
#define TDS_STATUS_RESULT   4043
 
#define TDS_STR_APPENDMODE   "dump file append"
 
#define TDS_STR_ASA_DATABASE   "asa database"
 
#define TDS_STR_BLKSZ   "initial block size"
 
#define TDS_STR_CAFILE   "ca file"
 
#define TDS_STR_CHARSET   "charset"
 
#define TDS_STR_CHECKSSLHOSTNAME   "check certificate hostname"
 
#define TDS_STR_CLCHARSET   "client charset"
 
#define TDS_STR_CONNTIMEOUT   "connect timeout"
 
#define TDS_STR_CRLFILE   "crl file"
 
#define TDS_STR_DATABASE   "database"
 
#define TDS_STR_DATEFMT   "date format"
 
#define TDS_STR_DBFILENAME   "database filename"
 
#define TDS_STR_DEBUGFLAGS   "debug flags"
 
#define TDS_STR_DEBUGLVL   "debug level"
 
#define TDS_STR_DUMPFILE   "dump file"
 
#define TDS_STR_EMUL_LE   "emulate little endian"
 
#define TDS_STR_ENCRYPTION   "encryption"
 
#define TDS_STR_ENCRYPTION_OFF   "off"
 
#define TDS_STR_ENCRYPTION_REQUEST   "request"
 
#define TDS_STR_ENCRYPTION_REQUIRE   "require"
 
#define TDS_STR_HOST   "host"
 
#define TDS_STR_HOSTNAME   "hostname"
 
#define TDS_STR_INSTANCE   "instance"
 
#define TDS_STR_LANGUAGE   "language"
 
#define TDS_STR_PORT   "port"
 
#define TDS_STR_QUERY_TIMEOUT   "query timeout"
 
#define TDS_STR_READONLY_INTENT   "read-only intent"
 
#define TDS_STR_REALM   "realm"
 
#define TDS_STR_SPN   "spn"
 
#define TDS_STR_SWAPDT   "swap broken dates"
 
#define TDS_STR_TEXTSZ   "text size"
 
#define TDS_STR_TIMEOUT   "timeout"
 
#define TDS_STR_USE_UTF_16   "use utf-16"
 
#define TDS_STR_USELANMAN   "use lanman"
 
#define TDS_STR_USENTLMV2   "use ntlmv2"
 
#define TDS_STR_VERSION   "tds version"
 
#define TDS_SUCCEED(rc)   ((rc)>=0)
 
#define TDS_SUCCESS   ((TDSRET)0)
 
#define TDS_SYB_VER(maj, min, x)   (((maj)<<24)|((min)<<16)|(x)<<8)
 Calc a version number for Sybase. More...
 
#define TDS_TOKEN_FLAG(flag)   TDS_RETURN_##flag = (1 << (TDS_TOKEN_RES_##flag*2)), TDS_STOPAT_##flag = (2 << (TDS_TOKEN_RES_##flag*2))
 
#define TDS_UNLIKELY(x)   (x)
 
#define TDS_VECTOR_SIZE(x)   (sizeof(x)/sizeof(x[0]))
 
#define TDS_WUR
 
#define TDS_ZERO_FREE(x)   do {free((x)); (x) = NULL;} while(0)
 
#define TDSDUMP_BUF_FAST   if (TDS_UNLIKELY(tds_write_dump)) tdsdump_dump_buf
 
#define tdsdump_dump_buf   TDSDUMP_BUF_FAST
 
#define tdsdump_log   TDSDUMP_LOG_FAST
 
#define TDSDUMP_LOG_FAST   if (TDS_UNLIKELY(tds_write_dump)) tdsdump_log
 
#define TDSSELREAD   POLLIN
 
#define TDSSELWRITE   POLLOUT
 
#define TLS_STR_OPENSSL_CIPHERS   "openssl ciphers"
 

Typedefs

typedef struct tds_bcpcoldata BCPCOLDATA
 
typedef struct tds_dstrDSTR
 Structure to hold a string. More...
 
typedef int(* err_handler_t) (const TDSCONTEXT *, TDSSOCKET *, TDSMESSAGE *)
 
typedef TDSRET(* tds_bcp_get_col_data) (TDSBCPINFO *bulk, TDSCOLUMN *bcpcol, int offset)
 
typedef void(* tds_bcp_null_error) (TDSBCPINFO *bulk, int index, int offset)
 
typedef struct tds_capabilities TDS_CAPABILITIES
 
typedef struct tds_capability_type TDS_CAPABILITY_TYPE
 
typedef char TDS_CHAR
 
typedef struct tds_compiletime_settings TDS_COMPILETIME_SETTINGS
 A structure to hold all the compile-time settings. More...
 
typedef enum tds_cursor_fetch TDS_CURSOR_FETCH
 
typedef enum tds_cursor_operation TDS_CURSOR_OPERATION
 
typedef struct tds_cursor_status TDS_CURSOR_STATUS
 
typedef struct tds_encoding TDS_ENCODING
 Information relevant to libiconv. More...
 
typedef enum tds_encryption_level TDS_ENCRYPTION_LEVEL
 
typedef tds_sysdep_real64_type TDS_FLOAT
 
typedef int tds_func_check(const TDSCOLUMN *col)
 
typedef TDSRET tds_func_get_data(TDSSOCKET *tds, TDSCOLUMN *col)
 
typedef TDSRET tds_func_get_info(TDSSOCKET *tds, TDSCOLUMN *col)
 
typedef TDSRET tds_func_put_data(TDSSOCKET *tds, TDSCOLUMN *col, int bcp7)
 
typedef TDSRET tds_func_put_info(TDSSOCKET *tds, TDSCOLUMN *col)
 
typedef unsigned tds_func_put_info_len(TDSSOCKET *tds, TDSCOLUMN *col)
 
typedef TDS_INT tds_func_row_len(TDSCOLUMN *col)
 
typedef tds_sysdep_int32_type TDS_INT
 
typedef tds_sysdep_int64_type TDS_INT8
 
typedef tds_sysdep_intptr_type TDS_INTPTR
 
typedef enum tds_operations TDS_OPERATION
 
typedef union tds_option_arg TDS_OPTION_ARG
 
typedef tds_sysdep_real32_type TDS_REAL
 
typedef tds_sysdep_int16_type TDS_SMALLINT
 
typedef enum tds_states TDS_STATE
 values for tds->state
 
typedef unsigned char TDS_TINYINT
 
typedef unsigned char TDS_UCHAR
 
typedef unsigned tds_sysdep_int32_type TDS_UINT
 
typedef unsigned tds_sysdep_int64_type TDS_UINT8
 
typedef unsigned tds_sysdep_intptr_type TDS_UINTPTR
 
typedef unsigned tds_sysdep_int16_type TDS_USMALLINT
 
typedef struct tds_authentication TDSAUTHENTICATION
 
typedef struct tds_bcpinfo TDSBCPINFO
 
typedef struct tds_blob TDSBLOB
 Information about blobs (e.g. More...
 
typedef struct tds_column TDSCOLUMN
 
typedef struct tds_column_funcs TDSCOLUMNFUNCS
 
typedef struct tds_result_info TDSCOMPUTEINFO
 
typedef void(* TDSCONFPARSE) (const char *option, const char *value, void *param)
 
typedef struct tds_connection TDSCONNECTION
 
typedef struct tds_context TDSCONTEXT
 
typedef struct tds_cursor TDSCURSOR
 Holds informations about a cursor.
 
typedef struct tdsdaterec TDSDATEREC
 Used by tds_datecrack.
 
typedef struct tds_dynamic TDSDYNAMIC
 Holds information for a dynamic (also called prepared) query.
 
typedef struct tds_env TDSENV
 Current environment as reported by the server.
 
typedef struct tds_headers TDSHEADERS
 
typedef struct tdsiconvinfo TDSICONV
 
typedef struct tds_locale TDSLOCALE
 
typedef struct tds_login TDSLOGIN
 
typedef struct tds_message TDSMESSAGE
 
typedef struct tds_multiple TDSMULTIPLE
 
typedef struct tds_packet TDSPACKET
 
typedef TDSRESULTINFO TDSPARAMINFO
 
typedef struct tds_poll_wakeup TDSPOLLWAKEUP
 
typedef struct tds_result_info TDSRESULTINFO
 Hold information for any results.
 
typedef int TDSRET
 
typedef struct tds_socket TDSSOCKET
 
typedef struct tds_upd_col TDSUPDCOL
 
typedef struct tds_variant TDSVARIANT
 Store variant informations.
 

Enumerations

enum  {
  TDS_CUR_ISTAT_UNUSED = 0x00, TDS_CUR_ISTAT_DECLARED = 0x01, TDS_CUR_ISTAT_OPEN = 0x02, TDS_CUR_ISTAT_CLOSED = 0x04,
  TDS_CUR_ISTAT_RDONLY = 0x08, TDS_CUR_ISTAT_UPDATABLE = 0x10, TDS_CUR_ISTAT_ROWCNT = 0x20, TDS_CUR_ISTAT_DEALLOC = 0x40
}
 
enum  {
  TDS_TYPEFLAG_INVALID = 0, TDS_TYPEFLAG_NULLABLE = 1, TDS_TYPEFLAG_FIXED = 2, TDS_TYPEFLAG_VARIABLE = 4,
  TDS_TYPEFLAG_COLLATE = 8, TDS_TYPEFLAG_ASCII = 16, TDS_TYPEFLAG_UNICODE = 32, TDS_TYPEFLAG_NUMERIC = 64,
  TDS_TYPEFLAG_DATETIME = 128
}
 
enum  tds_bcp_directions { TDS_BCP_IN = 1, TDS_BCP_OUT = 2, TDS_BCP_QUERYOUT = 3 }
 bcp direction
 
enum  tds_cursor_fetch {
  TDS_CURSOR_FETCH_NEXT = 1, TDS_CURSOR_FETCH_PREV, TDS_CURSOR_FETCH_FIRST, TDS_CURSOR_FETCH_LAST,
  TDS_CURSOR_FETCH_ABSOLUTE, TDS_CURSOR_FETCH_RELATIVE
}
 
enum  tds_cursor_operation { TDS_CURSOR_POSITION = 0, TDS_CURSOR_UPDATE = 1, TDS_CURSOR_DELETE = 2, TDS_CURSOR_INSERT = 4 }
 
enum  TDS_CURSOR_STATE { TDS_CURSOR_STATE_UNACTIONED = 0, TDS_CURSOR_STATE_REQUESTED = 1, TDS_CURSOR_STATE_SENT = 2, TDS_CURSOR_STATE_ACTIONED = 3 }
 
enum  tds_encryption_level { TDS_ENCRYPTION_OFF, TDS_ENCRYPTION_REQUEST, TDS_ENCRYPTION_REQUIRE }
 
enum  tds_end {
  TDS_DONE_FINAL = 0x00, TDS_DONE_MORE_RESULTS = 0x01, TDS_DONE_ERROR = 0x02, TDS_DONE_INXACT = 0x04,
  TDS_DONE_PROC = 0x08, TDS_DONE_COUNT = 0x10, TDS_DONE_CANCELLED = 0x20, TDS_DONE_EVENT = 0x40,
  TDS_DONE_SRVERROR = 0x100, TDS_DONE_NO_TRAN = 0, TDS_DONE_TRAN_SUCCEED = 1, TDS_DONE_TRAN_PROGRESS = 2,
  TDS_DONE_STMT_ABORT = 3, TDS_DONE_TRAN_ABORT = 4
}
 Flags returned in TDS_DONE token. More...
 
enum  TDS_ICONV_ENTRY { client2ucs2, client2server_chardata, initial_char_conv_count }
 
enum  TDS_MULTIPLE_TYPE { TDS_MULTIPLE_QUERY, TDS_MULTIPLE_EXECUTE, TDS_MULTIPLE_RPC }
 
enum  tds_operations {
  TDS_OP_NONE = 0, TDS_OP_CURSOR = TDS_SP_CURSOR, TDS_OP_CURSOROPEN = TDS_SP_CURSOROPEN, TDS_OP_CURSORPREPARE = TDS_SP_CURSORPREPARE,
  TDS_OP_CURSOREXECUTE = TDS_SP_CURSOREXECUTE, TDS_OP_CURSORPREPEXEC = TDS_SP_CURSORPREPEXEC, TDS_OP_CURSORUNPREPARE = TDS_SP_CURSORUNPREPARE, TDS_OP_CURSORFETCH = TDS_SP_CURSORFETCH,
  TDS_OP_CURSOROPTION = TDS_SP_CURSOROPTION, TDS_OP_CURSORCLOSE = TDS_SP_CURSORCLOSE, TDS_OP_EXECUTESQL = TDS_SP_EXECUTESQL, TDS_OP_PREPARE = TDS_SP_PREPARE,
  TDS_OP_EXECUTE = TDS_SP_EXECUTE, TDS_OP_PREPEXEC = TDS_SP_PREPEXEC, TDS_OP_PREPEXECRPC = TDS_SP_PREPEXECRPC, TDS_OP_UNPREPARE = TDS_SP_UNPREPARE,
  TDS_OP_DYN_DEALLOC = 100
}
 
enum  tds_states {
  TDS_IDLE, TDS_WRITING, TDS_SENDING, TDS_PENDING,
  TDS_READING, TDS_DEAD
}
 values for tds->state More...
 
enum  tds_token_flags {
  TDS_HANDLE_ALL = 0, TDS_TOKEN_FLAG =(OTHERS), TDS_TOKEN_FLAG =(OTHERS), TDS_TOKEN_FLAG =(OTHERS),
  TDS_TOKEN_FLAG =(OTHERS), TDS_TOKEN_FLAG =(OTHERS), TDS_TOKEN_FLAG =(OTHERS), TDS_TOKEN_FLAG =(OTHERS),
  TDS_TOKEN_FLAG =(OTHERS), TDS_TOKEN_FLAG =(OTHERS), TDS_TOKEN_FLAG =(OTHERS), TDS_TOKEN_RESULTS = TDS_RETURN_ROWFMT|TDS_RETURN_COMPUTEFMT|TDS_RETURN_DONE|TDS_STOPAT_ROW|TDS_STOPAT_COMPUTE|TDS_RETURN_PROC,
  TDS_TOKEN_TRAILING = TDS_STOPAT_ROWFMT|TDS_STOPAT_COMPUTEFMT|TDS_STOPAT_ROW|TDS_STOPAT_COMPUTE|TDS_STOPAT_MSG|TDS_STOPAT_OTHERS
}
 
enum  tds_token_results {
  TDS_TOKEN_RES_OTHERS, TDS_TOKEN_RES_ROWFMT, TDS_TOKEN_RES_COMPUTEFMT, TDS_TOKEN_RES_PARAMFMT,
  TDS_TOKEN_RES_DONE, TDS_TOKEN_RES_ROW, TDS_TOKEN_RES_COMPUTE, TDS_TOKEN_RES_PROC,
  TDS_TOKEN_RES_MSG, TDS_TOKEN_RES_ENV
}
 
enum  TDSERRNO {
  TDSEOK = TDS_SUCCESS, TDSEVERDOWN = 100, TDSEICONVIU = 2400, TDSEICONVAVAIL = 2401,
  TDSEICONVO = 2402, TDSEICONVI = 2403, TDSEICONV2BIG = 2404, TDSEPORTINSTANCE = 2500,
  TDSESYNC = 20001, TDSEFCON = 20002, TDSETIME = 20003, TDSEREAD = 20004,
  TDSEWRIT = 20006, TDSESOCK = 20008, TDSECONN = 20009, TDSEMEM = 20010,
  TDSEINTF = 20012, TDSEUHST = 20013, TDSEPWD = 20014, TDSESEOF = 20017,
  TDSERPND = 20019, TDSEBTOK = 20020, TDSEOOB = 20022, TDSECLOS = 20056,
  TDSEUSCT = 20058, TDSEUTDS = 20146, TDSEEUNR = 20185, TDSECAP = 20203,
  TDSENEG = 20210, TDSEUMSG = 20212, TDSECAPTYP = 20213, TDSECONF = 20214,
  TDSEBPROBADTYP = 20250, TDSECLOSEIN = 20292
}
 

Functions

int determine_adjusted_size (const TDSICONV *char_conv, int size)
 Allow for maximum possible size of converted data, while being careful about integer division truncation. More...
 
static bool is_tds_type_valid (int type)
 
TDSAUTHENTICATIONtds5_negotiate_get_auth (TDSSOCKET *tds)
 
void tds5_negotiate_set_msg_type (TDSSOCKET *tds, TDSAUTHENTICATION *auth, unsigned msg_type)
 
int tds5_send_optioncmd (TDSSOCKET *tds, TDS_OPTION_CMD tds_command, TDS_OPTION tds_option, TDS_OPTION_ARG *tds_argument, TDS_INT *tds_argsize)
 
TDSRET tds71_submit_prepexec (TDSSOCKET *tds, const char *query, const char *id, TDSDYNAMIC **dyn_out, TDSPARAMINFO *params)
 tds71_submit_prepexec() creates a temporary stored procedure in the server. More...
 
int tds7_get_instance_port (struct addrinfo *addr, const char *instance)
 Get port of given instance. More...
 
int tds7_get_instance_ports (FILE *output, struct addrinfo *addr)
 Get port of all instances. More...
 
void tds7_srv_charset_changed (TDSCONNECTION *conn, int sql_collate, int lcid)
 
const char * tds_addrinfo2str (struct addrinfo *addr, char *name, int namemax)
 
TDSSOCKETtds_alloc_additional_socket (TDSCONNECTION *conn)
 
BCPCOLDATAtds_alloc_bcp_column_data (unsigned int column_size)
 
TDSBCPINFOtds_alloc_bcpinfo (void)
 
char * tds_alloc_client_sqlstate (int msgno)
 
TDSCOMPUTEINFO ** tds_alloc_compute_results (TDSSOCKET *tds, TDS_USMALLINT num_cols, TDS_USMALLINT by_cols)
 
TDSRET tds_alloc_compute_row (TDSCOMPUTEINFO *res_info)
 
TDSCONTEXTtds_alloc_context (void *parent)
 
TDSCURSORtds_alloc_cursor (TDSSOCKET *tds, const char *name, TDS_INT namelen, const char *query, TDS_INT querylen)
 
TDSDYNAMICtds_alloc_dynamic (TDSCONNECTION *conn, const char *id)
 Allocate a dynamic statement. More...
 
TDSLOCALEtds_alloc_locale (void)
 
TDSLOGINtds_alloc_login (int use_environment)
 
char * tds_alloc_lookup_sqlstate (TDSSOCKET *tds, int msgno)
 
TDSPACKETtds_alloc_packet (void *buf, unsigned len)
 
void * tds_alloc_param_data (TDSCOLUMN *curparam)
 Allocate data for a parameter. More...
 
TDSPARAMINFOtds_alloc_param_result (TDSPARAMINFO *old_param)
 Adds a output parameter to TDSPARAMINFO. More...
 
TDSRESULTINFOtds_alloc_results (TDS_USMALLINT num_cols)
 
TDSRET tds_alloc_row (TDSRESULTINFO *res_info)
 Allocate space for row store return NULL on out of memory.
 
TDSSOCKETtds_alloc_socket (TDSCONTEXT *context, unsigned int bufsize)
 
TDSRET tds_bcp_done (TDSSOCKET *tds, int *rows_copied)
 Tell we finished sending BCP data to server. More...
 
TDSRET tds_bcp_fread (TDSSOCKET *tds, TDSICONV *conv, FILE *stream, const char *terminator, size_t term_len, char **outbuf, size_t *outbytes)
 Read a data file, passing the data through iconv(). More...
 
TDSRET tds_bcp_init (TDSSOCKET *tds, TDSBCPINFO *bcpinfo)
 Initialize BCP information. More...
 
TDSRET tds_bcp_send_record (TDSSOCKET *tds, TDSBCPINFO *bcpinfo, tds_bcp_get_col_data get_col_data, tds_bcp_null_error null_error, int offset)
 Send one row of data to server. More...
 
TDSRET tds_bcp_start (TDSSOCKET *tds, TDSBCPINFO *bcpinfo)
 Start sending BCP data to server. More...
 
TDSRET tds_bcp_start_copy_in (TDSSOCKET *tds, TDSBCPINFO *bcpinfo)
 Start bulk copy to server. More...
 
static bool tds_capability_enabled (const TDS_CAPABILITY_TYPE *cap, unsigned cap_num)
 
void tds_close_socket (TDSSOCKET *tds)
 Close current socket. More...
 
int tds_config_boolean (const char *option, const char *value, TDSLOGIN *login)
 
TDS_USMALLINT * tds_config_verstr (const char *tdsver, TDSLOGIN *login)
 Set TDS version from given string. More...
 
int tds_connect_and_login (TDSSOCKET *tds, TDSLOGIN *login)
 
void tds_connection_close (TDSCONNECTION *conn)
 
int tds_connection_read (TDSSOCKET *tds, unsigned char *buf, int buflen)
 
int tds_connection_write (TDSSOCKET *tds, const unsigned char *buf, int buflen, int final)
 
const char * tds_convert_string (TDSSOCKET *tds, TDSICONV *char_conv, const char *s, int len, size_t *out_len)
 Convert a string in an allocated buffer. More...
 
void tds_convert_string_free (const char *original, const char *converted)
 
int tds_count_placeholders (const char *query)
 Count the number of placeholders in query. More...
 
TDSRET tds_cursor_close (TDSSOCKET *tds, TDSCURSOR *cursor)
 
TDSRET tds_cursor_dealloc (TDSSOCKET *tds, TDSCURSOR *cursor)
 Send a deallocation request to server.
 
void tds_cursor_deallocated (TDSCONNECTION *conn, TDSCURSOR *cursor)
 
TDSRET tds_cursor_declare (TDSSOCKET *tds, TDSCURSOR *cursor, TDSPARAMINFO *params, int *send)
 
TDSRET tds_cursor_fetch (TDSSOCKET *tds, TDSCURSOR *cursor, TDS_CURSOR_FETCH fetch_type, TDS_INT i_row)
 
TDSRET tds_cursor_get_cursor_info (TDSSOCKET *tds, TDSCURSOR *cursor, TDS_UINT *row_number, TDS_UINT *row_count)
 
TDSRET tds_cursor_open (TDSSOCKET *tds, TDSCURSOR *cursor, TDSPARAMINFO *params, int *send)
 
TDSRET tds_cursor_setname (TDSSOCKET *tds, TDSCURSOR *cursor)
 
TDSRET tds_cursor_setrows (TDSSOCKET *tds, TDSCURSOR *cursor, int *send)
 
TDSRET tds_cursor_update (TDSSOCKET *tds, TDSCURSOR *cursor, TDS_CURSOR_OPERATION op, TDS_INT i_row, TDSPARAMINFO *params)
 
TDSRET tds_datecrack (TDS_INT datetype, const void *di, TDSDATEREC *dr)
 Convert from db date format to a structured date format. More...
 
TDSRET tds_deferred_cursor_dealloc (TDSCONNECTION *conn, TDSCURSOR *cursor)
 Deallocate cursor on idle. More...
 
TDSRET tds_deferred_unprepare (TDSCONNECTION *conn, TDSDYNAMIC *dyn)
 Unprepare dynamic on idle. More...
 
void tds_deinit_bcpinfo (TDSBCPINFO *bcpinfo)
 
void tds_detach_results (TDSRESULTINFO *info)
 Detach result info from it current socket.
 
TDSRET tds_disconnect (TDSSOCKET *tds)
 
DSTRtds_dstr_get (TDSSOCKET *tds, DSTR *s, size_t len)
 Reads a string from wire and put in a DSTR. More...
 
void tds_dynamic_deallocated (TDSCONNECTION *conn, TDSDYNAMIC *dyn)
 
size_t tds_fix_column_size (TDSSOCKET *tds, TDSCOLUMN *curcol)
 Get column size for wire.
 
void tds_fix_login (TDSLOGIN *login)
 Fix configuration after reading it. More...
 
TDSRET tds_flush_packet (TDSSOCKET *tds)
 Flush packet to server. More...
 
void tds_free_all_results (TDSSOCKET *tds)
 
void tds_free_bcp_column_data (BCPCOLDATA *coldata)
 
void tds_free_bcpinfo (TDSBCPINFO *bcpinfo)
 
void tds_free_context (TDSCONTEXT *locale)
 
void tds_free_input_params (TDSDYNAMIC *dyn)
 Frees all allocated input parameters of a dynamic statement. More...
 
void tds_free_locale (TDSLOCALE *locale)
 
void tds_free_login (TDSLOGIN *login)
 
void tds_free_msg (TDSMESSAGE *message)
 
void tds_free_packets (TDSPACKET *packet)
 
void tds_free_param_result (TDSPARAMINFO *param_info)
 Delete latest parameter.
 
void tds_free_param_results (TDSPARAMINFO *param_info)
 
void tds_free_results (TDSRESULTINFO *res_info)
 
void tds_free_row (TDSRESULTINFO *res_info, unsigned char *row)
 
void tds_free_socket (TDSSOCKET *tds)
 
unsigned char tds_get_byte (TDSSOCKET *tds)
 Return a single byte from the input buffer. More...
 
TDS_SERVER_TYPE tds_get_cardinal_type (TDS_SERVER_TYPE datatype, int usertype)
 
TDSRET tds_get_char_data (TDSSOCKET *tds, char *dest, size_t wire_size, TDSCOLUMN *curcol)
 Fetch character data the wire. More...
 
TDSRET tds_get_column_declaration (TDSSOCKET *tds, TDSCOLUMN *curcol, char *out)
 Return declaration for column (like "varchar(20)") More...
 
const TDS_COMPILETIME_SETTINGStds_get_compiletime_settings (void)
 Return a structure capturing the compile-time settings provided to the configure script.
 
TDS_SERVER_TYPE tds_get_conversion_type (TDS_SERVER_TYPE srctype, int colsize)
 Return type suitable for conversions (convert all nullable types to fixed type) More...
 
char * tds_get_homedir (void)
 Get user home directory. More...
 
TDSLOCALEtds_get_locale (void)
 Get locale information. More...
 
void * tds_get_n (TDSSOCKET *tds, void *dest, size_t n)
 Get N bytes from the buffer and return them in the already allocated space given to us. More...
 
int tds_get_size_by_type (TDS_SERVER_TYPE servertype)
 Return the number of bytes needed by specified type.
 
size_t tds_get_string (TDSSOCKET *tds, size_t string_len, char *dest, size_t dest_size)
 Fetch a string from the wire. More...
 
int tds_get_token_size (int marker)
 tds_get_token_size() returns the size of a fixed length token used by tds_process_cancel() to determine how to read past a token More...
 
TDS_UINT tds_get_uint (TDSSOCKET *tds)
 Get an int32 from the server. More...
 
TDS_UINT8 tds_get_uint8 (TDSSOCKET *tds)
 Get an uint64 from the server. More...
 
TDS_USMALLINT tds_get_usmallint (TDSSOCKET *tds)
 Get an int16 from the server.
 
int tds_get_varint_size (TDSCONNECTION *conn, int datatype)
 tds_get_varint_size() returns the size of a variable length integer returned in a TDS 7.0 result string
 
struct hostent * tds_gethostbyname_r (const char *servername, struct hostent *result, char *buffer, int buflen, int *h_errnop)
 
void tds_getmac (TDS_SYS_SOCKET s, unsigned char mac[6])
 
int tds_getservice (const char *name)
 Return service port given the name.
 
int tds_goodread (TDSSOCKET *tds, unsigned char *buf, int buflen)
 Loops until we have received some characters return -1 on failure.
 
int tds_goodwrite (TDSSOCKET *tds, const unsigned char *buffer, size_t buflen)
 
TDSAUTHENTICATIONtds_gss_get_auth (TDSSOCKET *tds)
 
int tds_iconv_alloc (TDSCONNECTION *conn)
 Allocate iconv stuff. More...
 
void tds_iconv_close (TDSCONNECTION *conn)
 
void tds_iconv_free (TDSCONNECTION *conn)
 
TDSICONVtds_iconv_from_collate (TDSCONNECTION *conn, TDS_UCHAR collate[5])
 Get iconv information from a LCID (to support different column encoding under MSSQL2K)
 
TDSRET tds_iconv_open (TDSCONNECTION *conn, const char *charset, int use_utf16)
 
TDSLOGINtds_init_login (TDSLOGIN *login, TDSLOCALE *locale)
 Initialize login structure with locale information and other stuff for connection. More...
 
int tds_init_write_buf (TDSSOCKET *tds)
 
struct tm * tds_localtime_r (const time_t *timep, struct tm *result)
 
TDSDYNAMICtds_lookup_dynamic (TDSCONNECTION *conn, const char *id)
 Finds a dynamic given string id. More...
 
struct addrinfo * tds_lookup_host (const char *servername)
 Get the IP address for a hostname. More...
 
TDSRET tds_lookup_host_set (const char *servername, struct addrinfo **addr)
 
char * tds_money_to_string (const TDS_MONEY *money, char *s)
 
TDSRET tds_multiple_done (TDSSOCKET *tds, TDSMULTIPLE *multiple)
 
TDSRET tds_multiple_execute (TDSSOCKET *tds, TDSMULTIPLE *multiple, TDSDYNAMIC *dyn)
 
TDSRET tds_multiple_init (TDSSOCKET *tds, TDSMULTIPLE *multiple, TDS_MULTIPLE_TYPE type, TDSHEADERS *head)
 
TDSRET tds_multiple_query (TDSSOCKET *tds, TDSMULTIPLE *multiple, const char *query, TDSPARAMINFO *params)
 
int tds_needs_unprepare (TDSCONNECTION *conn, TDSDYNAMIC *dyn)
 Check if dynamic request must be unprepared. More...
 
const char * tds_next_placeholder (const char *start)
 Get position of next placeholder. More...
 
TDSAUTHENTICATIONtds_ntlm_get_auth (TDSSOCKET *tds)
 Build a NTLMSPP packet to send to server. More...
 
TDS_INT tds_numeric_change_prec_scale (TDS_NUMERIC *numeric, unsigned char new_prec, unsigned char new_scale)
 
TDS_INT tds_numeric_to_string (const TDS_NUMERIC *numeric, char *s)
 
TDSERRNO tds_open_socket (TDSSOCKET *tds, struct addrinfo *ipaddr, unsigned int port, int timeout, int *p_oserr)
 
int tds_parse_boolean (const char *value, int default_value)
 
void tds_parse_conf_section (const char *option, const char *value, void *param)
 
unsigned char tds_peek (TDSSOCKET *tds)
 Reads a byte from the TDS stream without removing it. More...
 
TDSRET tds_process_cancel (TDSSOCKET *tds)
 
TDSRET tds_process_login_tokens (TDSSOCKET *tds)
 tds_process_login_tokens() is called after sending the login packet to the server. More...
 
TDSRET tds_process_simple_query (TDSSOCKET *tds)
 Process results for simple query as "SET TEXTSIZE" or "USE dbname" If the statement returns results, beware they are discarded. More...
 
TDSRET tds_process_tokens (TDSSOCKET *tds, TDS_INT *result_type, int *done_flags, unsigned flag)
 process all streams. More...
 
const char * tds_prtype (int token)
 Returns string representation of the given type. More...
 
char * tds_prwsaerror (int erc)
 
void tds_prwsaerror_free (char *s)
 
int tds_put_buf (TDSSOCKET *tds, const unsigned char *buf, int dsize, int ssize)
 
int tds_put_byte (TDSSOCKET *tds, unsigned char c)
 
int tds_put_cancel (TDSSOCKET *tds)
 
int tds_put_int (TDSSOCKET *tds, TDS_INT i)
 
int tds_put_int8 (TDSSOCKET *tds, TDS_INT8 i)
 
int tds_put_n (TDSSOCKET *tds, const void *buf, size_t n)
 
int tds_put_smallint (TDSSOCKET *tds, TDS_SMALLINT si)
 
int tds_put_string (TDSSOCKET *tds, const char *buf, int len)
 Output a string to wire automatic translate string to unicode if needed. More...
 
size_t tds_quote_id (TDSSOCKET *tds, char *buffer, const char *id, int idlen)
 Quote an id. More...
 
size_t tds_quote_string (TDSSOCKET *tds, char *buffer, const char *str, int len)
 Quote a string. More...
 
void tds_random_buffer (unsigned char *out, int len)
 
int tds_read_conf_file (TDSLOGIN *login, const char *server)
 Read configuration info for given server return 0 on error. More...
 
int tds_read_conf_section (FILE *in, const char *section, TDSCONFPARSE tds_conf_parse, void *parse_param)
 Read a section of configuration file (INI style file) More...
 
TDSLOGINtds_read_config_info (TDSSOCKET *tds, TDSLOGIN *login, TDSLOCALE *locale)
 tds_read_config_info() will fill the tds connection structure based on configuration information gathered in the following order: 1) Program specified in TDSLOGIN structure 2) The environment variables TDSVER, TDSDUMP, TDSPORT, TDSQUERY, TDSHOST 3) A config file with the following search order: a) a readable file specified by environment variable FREETDSCONF b) a readable file in ~/.freetds.conf c) a readable file in $prefix/etc/freetds.conf 3) ~/.interfaces if exists 4) $SYBASE/interfaces if exists 5) TDS_DEF_* default values More...
 
int tds_read_packet (TDSSOCKET *tds)
 Read in one 'packet' from the server. More...
 
void * tds_realloc (void **pp, size_t new_size)
 Reallocate a pointer and update it if success. More...
 
TDSPACKETtds_realloc_packet (TDSPACKET *packet, unsigned len)
 
TDSSOCKETtds_realloc_socket (TDSSOCKET *tds, size_t bufsize)
 
static void tds_release_cur_dyn (TDSSOCKET *tds)
 
void tds_release_cursor (TDSCURSOR **pcursor)
 
void tds_release_dynamic (TDSDYNAMIC **dyn)
 Frees dynamic statement. More...
 
int tds_select (TDSSOCKET *tds, unsigned tds_sel, int timeout_seconds)
 Select on a socket until it's available or the timeout expires. More...
 
TDSRET tds_send_cancel (TDSSOCKET *tds)
 tds_send_cancel() sends an empty packet (8 byte header only) tds_process_cancel should be called directly after this. More...
 
bool tds_set_app (TDSLOGIN *tds_login, const char *application) TDS_WUR
 
void tds_set_bulk (TDSLOGIN *tds_login, TDS_TINYINT enabled)
 
bool tds_set_client_charset (TDSLOGIN *tds_login, const char *charset) TDS_WUR
 
void tds_set_column_type (TDSCONNECTION *conn, TDSCOLUMN *curcol, TDS_SERVER_TYPE type)
 Set type of column initializing all dependency. More...
 
void tds_set_cur_dyn (TDSSOCKET *tds, TDSDYNAMIC *dyn)
 Set current dynamic. More...
 
void tds_set_current_results (TDSSOCKET *tds, TDSRESULTINFO *info)
 
bool tds_set_host (TDSLOGIN *tds_login, const char *hostname) TDS_WUR
 
TDSRET tds_set_interfaces_file_loc (const char *interfloc)
 Set the full name of interface file. More...
 
bool tds_set_language (TDSLOGIN *tds_login, const char *language) TDS_WUR
 
bool tds_set_library (TDSLOGIN *tds_login, const char *library) TDS_WUR
 
void tds_set_packet (TDSLOGIN *tds_login, int packet_size)
 
void tds_set_param_type (TDSCONNECTION *conn, TDSCOLUMN *curcol, TDS_SERVER_TYPE type)
 Set type of column initializing all dependency. More...
 
bool tds_set_passwd (TDSLOGIN *tds_login, const char *password) TDS_WUR
 
void tds_set_port (TDSLOGIN *tds_login, int port)
 
bool tds_set_server (TDSLOGIN *tds_login, const char *server) TDS_WUR
 Set the servername in a TDSLOGIN structure. More...
 
TDS_STATE tds_set_state (TDSSOCKET *tds, TDS_STATE state)
 Set state of TDS connection, with logging and checking. More...
 
bool tds_set_user (TDSLOGIN *tds_login, const char *username) TDS_WUR
 
void tds_set_version (TDSLOGIN *tds_login, TDS_TINYINT major_ver, TDS_TINYINT minor_ver)
 
const char * tds_skip_comment (const char *s)
 Skip a comment in a query. More...
 
const char * tds_skip_quoted (const char *s)
 Skip quoting string (like 'sfsf', "dflkdj" or [dfkjd]) More...
 
void tds_socket_flush (TDS_SYS_SOCKET sock)
 
int tds_socket_set_nonblocking (TDS_SYS_SOCKET sock)
 Set socket to non-blocking. More...
 
void tds_srv_charset_changed (TDSCONNECTION *conn, const char *charset)
 
void tds_start_query (TDSSOCKET *tds, unsigned char packet_type)
 Start query packet of a given type. More...
 
char * tds_strndup (const void *s, TDS_INTPTR len)
 Copy a string of length len to a new allocated buffer This function does not read more than len bytes Please note that some system implementation of strndup do not assure they don't read past len bytes as they use still strlen to check length to copy limiting after strlen to size passed Also this function is different from strndup as it assume that len bytes are valid String returned is NUL terminated. More...
 
TDSRET tds_submit_begin_tran (TDSSOCKET *tds)
 Send a rollback request. More...
 
TDSRET tds_submit_commit (TDSSOCKET *tds, int cont)
 Send a commit request. More...
 
TDSRET tds_submit_execdirect (TDSSOCKET *tds, const char *query, TDSPARAMINFO *params, TDSHEADERS *head)
 Submit a prepared query with parameters. More...
 
TDSRET tds_submit_execute (TDSSOCKET *tds, TDSDYNAMIC *dyn)
 tds_submit_execute() sends a previously prepared dynamic statement to the server. More...
 
TDSRET tds_submit_optioncmd (TDSSOCKET *tds, TDS_OPTION_CMD command, TDS_OPTION option, TDS_OPTION_ARG *param, TDS_INT param_size)
 Send option commands to server. More...
 
TDSRET tds_submit_prepare (TDSSOCKET *tds, const char *query, const char *id, TDSDYNAMIC **dyn_out, TDSPARAMINFO *params)
 tds_submit_prepare() creates a temporary stored procedure in the server. More...
 
TDSRET tds_submit_query (TDSSOCKET *tds, const char *query)
 tds_submit_query() sends a language string to the database server for processing. More...
 
TDSRET tds_submit_query_params (TDSSOCKET *tds, const char *query, TDSPARAMINFO *params, TDSHEADERS *head)
 tds_submit_query_params() sends a language string to the database server for processing. More...
 
TDSRET tds_submit_queryf (TDSSOCKET *tds, const char *queryf,...)
 Format and submit a query. More...
 
TDSRET tds_submit_rollback (TDSSOCKET *tds, int cont)
 Send a rollback request. More...
 
TDSRET tds_submit_rpc (TDSSOCKET *tds, const char *rpc_name, TDSPARAMINFO *params, TDSHEADERS *head)
 tds_submit_rpc() call a RPC from server. More...
 
TDSRET tds_submit_unprepare (TDSSOCKET *tds, TDSDYNAMIC *dyn)
 Send a unprepare request for a prepared query. More...
 
void tds_swap_bytes (void *buf, int bytes)
 
char * tds_timestamp_str (char *str, int maxlen)
 
void tds_unget_byte (TDSSOCKET *tds)
 Unget will always work as long as you don't call it twice in a row. More...
 
TDSRET tds_vstrbuild (char *buffer, int buflen, int *resultlen, const char *text, int textlen, const char *formats, int formatlen, va_list ap)
 
void tds_wakeup_close (TDSPOLLWAKEUP *wakeup)
 
static TDS_SYS_SOCKET tds_wakeup_get_fd (const TDSPOLLWAKEUP *wakeup)
 
int tds_wakeup_init (TDSPOLLWAKEUP *wakeup)
 
void tds_wakeup_send (TDSPOLLWAKEUP *wakeup, char cancel)
 
TDSRET tds_write_packet (TDSSOCKET *tds, unsigned char final)
 
TDSRET tds_writetext_continue (TDSSOCKET *tds, const TDS_UCHAR *text, TDS_UINT size)
 Send some data in the writetext request started by tds_writetext_start. More...
 
TDSRET tds_writetext_end (TDSSOCKET *tds)
 Finish sending writetext data. More...
 
TDSRET tds_writetext_start (TDSSOCKET *tds, const char *objname, const char *textptr, const char *timestamp, int with_log, TDS_UINT size)
 Start writing writetext request. More...
 
void tdsdump_close (void)
 Close the TDS dump log file.
 
void tdsdump_col (const TDSCOLUMN *col)
 Write a column value to the debug log. More...
 
void tdsdump_dump_buf (const char *file, unsigned int level_line, const char *msg, const void *buf, size_t length)
 Dump the contents of data into the log file in a human readable format. More...
 
int tdsdump_isopen (void)
 
void tdsdump_log (const char *file, unsigned int level_line, const char *fmt,...)
 Write a message to the debug log. More...
 
void tdsdump_off (void)
 Temporarily turn off logging.
 
void tdsdump_on (void)
 Turn logging back on. More...
 
int tdsdump_open (const char *filename)
 Create and truncate a human readable dump file for the TDS traffic. More...
 
int tdserror (const TDSCONTEXT *tds_ctx, TDSSOCKET *tds, int msgno, int errnum)
 Call the client library's error handler (for library-generated errors only) More...
 

Variables

const char STD_DATETIME_FMT []
 
int tds_debug_flags
 
int tds_g_append_mode
 
const char tds_hex_digits []
 
const int tds_numeric_bytes_per_prec []
 The following little table is indexed by precision and will tell us the number of bytes required to store the specified precision. More...
 
const unsigned char tds_type_flags_ms [256]
 
int tds_write_dump
 Tell if TDS debug logging is turned on or off.
 

Detailed Description

Main include file for libtds.

Macro Definition Documentation

§ is_end_token

#define is_end_token (   x)
Value:
(x==TDS_DONE_TOKEN || \
x==TDS_DONEPROC_TOKEN || \
x==TDS_DONEINPROC_TOKEN)

§ TDS_BYTE_SWAP16

#define TDS_BYTE_SWAP16 (   value)
Value:
(((((unsigned short)value)<<8) & 0xFF00) | \
((((unsigned short)value)>>8) & 0x00FF))

§ TDS_BYTE_SWAP32

#define TDS_BYTE_SWAP32 (   value)
Value:
(((((unsigned long)value)<<24) & 0xFF000000) | \
((((unsigned long)value)<< 8) & 0x00FF0000) | \
((((unsigned long)value)>> 8) & 0x0000FF00) | \
((((unsigned long)value)>>24) & 0x000000FF))

§ TDS_IS_MSSQL

#define TDS_IS_MSSQL (   x)    (((x)->conn->product_version & 0x80000000u)!=0)

Check if product is Microsft SQL Server.

x should be a TDSSOCKET*.

§ TDS_IS_SYBASE

#define TDS_IS_SYBASE (   x)    (!((x)->conn->product_version & 0x80000000u))

Check if product is Sybase (such as Adaptive Server Enterrprice).

x should be a TDSSOCKET*.

§ TDS_MS_VER

#define TDS_MS_VER (   maj,
  min,
 
)    (0x80000000u|((maj)<<24)|((min)<<16)|(x))

Calc a version number for mssql.

Use with TDS_MS_VER(7,0,842). For test for a range of version you can use check like if (tds->product_version >= TDS_MS_VER(7,0,0) && tds->product_version < TDS_MS_VER(8,0,0))

§ TDS_SYB_VER

#define TDS_SYB_VER (   maj,
  min,
 
)    (((maj)<<24)|((min)<<16)|(x)<<8)

Calc a version number for Sybase.

Typedef Documentation

§ DSTR

typedef struct tds_dstr * DSTR

Structure to hold a string.

Use tds_dstr_* functions/macros, do not access members directly. There should be always a buffer.

§ TDS_COMPILETIME_SETTINGS

A structure to hold all the compile-time settings.

This structure is returned by tds_get_compiletime_settings

§ TDS_ENCODING

typedef struct tds_encoding TDS_ENCODING

Information relevant to libiconv.

The name is an iconv name, not the same as found in master..syslanguages.

§ TDSBLOB

typedef struct tds_blob TDSBLOB

Information about blobs (e.g.

text or image). current_row contains this structure.

Enumeration Type Documentation

§ tds_end

enum tds_end

Flags returned in TDS_DONE token.

Enumerator
TDS_DONE_FINAL 

final result set, command completed successfully.

TDS_DONE_MORE_RESULTS 

more results follow

TDS_DONE_ERROR 

error occurred

TDS_DONE_INXACT 

transaction in progress

TDS_DONE_PROC 

results are from a stored procedure

TDS_DONE_COUNT 

count field in packet is valid

TDS_DONE_CANCELLED 

acknowledging an attention command (usually a cancel)

TDS_DONE_SRVERROR 

SQL server server error.

§ tds_states

enum tds_states

values for tds->state

Enumerator
TDS_IDLE 

no data expected

TDS_WRITING 

client is writing data

TDS_SENDING 

client would send data

TDS_PENDING 

cilent is waiting for data

TDS_READING 

client is reading data

TDS_DEAD 

no connection

Function Documentation

§ tds_bcp_done()

TDSRET tds_bcp_done ( TDSSOCKET tds,
int *  rows_copied 
)

Tell we finished sending BCP data to server.

Parameters
tdsA pointer to the TDSSOCKET structure managing a client/server operation.
[out]rows_copiednumber of rows copied to server
Here is the call graph for this function:

§ tds_bcp_fread()

TDSRET tds_bcp_fread ( TDSSOCKET tds,
TDSICONV char_conv,
FILE *  stream,
const char *  terminator,
size_t  term_len,
char **  outbuf,
size_t *  outbytes 
)

Read a data file, passing the data through iconv().

Return values
TDS_SUCCESSsuccess
TDS_FAILerror reading the column
TDS_NO_MORE_RESULTSend of file detected
Here is the call graph for this function:

§ tds_bcp_init()

TDSRET tds_bcp_init ( TDSSOCKET tds,
TDSBCPINFO bcpinfo 
)

Initialize BCP information.

Query structure of the table to server.

Parameters
tdsA pointer to the TDSSOCKET structure managing a client/server operation.
bcpinfoBCP information to initialize. Structure should be allocate and table name and direction should be already set.

§ tds_bcp_send_record()

TDSRET tds_bcp_send_record ( TDSSOCKET tds,
TDSBCPINFO bcpinfo,
tds_bcp_get_col_data  get_col_data,
tds_bcp_null_error  ignored,
int  offset 
)

Send one row of data to server.

Parameters
tdsA pointer to the TDSSOCKET structure managing a client/server operation.
bcpinfoBCP information
get_col_datafunction to call to retrieve data to be sent
ignoredfunction to call if we try to send NULL if not allowed (not used)
offsetpassed to get_col_data and null_error to specify the row to get
Returns
TDS_SUCCESS or TDS_FAIL.

§ tds_bcp_start()

TDSRET tds_bcp_start ( TDSSOCKET tds,
TDSBCPINFO bcpinfo 
)

Start sending BCP data to server.

Initialize stream to accept data.

Parameters
tdsA pointer to the TDSSOCKET structure managing a client/server operation.
bcpinfoBCP information already prepared
Here is the call graph for this function:

§ tds_bcp_start_copy_in()

TDSRET tds_bcp_start_copy_in ( TDSSOCKET tds,
TDSBCPINFO bcpinfo 
)

Start bulk copy to server.

Parameters
tdsA pointer to the TDSSOCKET structure managing a client/server operation.
bcpinfoBCP information already prepared
Here is the call graph for this function:

§ tds_get_conversion_type()

TDS_SERVER_TYPE tds_get_conversion_type ( TDS_SERVER_TYPE  srctype,
int  colsize 
)

Return type suitable for conversions (convert all nullable types to fixed type)

Parameters
srctypetype to convert
colsizesize of type
Returns
type for conversion
Here is the caller graph for this function:

§ tds_get_homedir()

char* tds_get_homedir ( void  )

Get user home directory.

Returns
home directory or NULL if error. Should be freed with free
Here is the caller graph for this function:

§ tds_get_locale()

TDSLOCALE* tds_get_locale ( void  )

Get locale information.

Returns
allocated structure with all information or NULL if error

§ tds_iconv_alloc()

int tds_iconv_alloc ( TDSCONNECTION conn)

Allocate iconv stuff.

Returns
0 for success

§ tds_numeric_to_string()

TDS_INT tds_numeric_to_string ( const TDS_NUMERIC numeric,
char *  s 
)
Returns
<0 if error

§ tds_set_column_type()

void tds_set_column_type ( TDSCONNECTION conn,
TDSCOLUMN curcol,
TDS_SERVER_TYPE  type 
)

Set type of column initializing all dependency.

Parameters
curcolcolumn to set
typetype to set

§ tds_set_param_type()

void tds_set_param_type ( TDSCONNECTION conn,
TDSCOLUMN curcol,
TDS_SERVER_TYPE  type 
)

Set type of column initializing all dependency.

Parameters
tdsstate information for the socket and the TDS protocol
curcolcolumn to set
typetype to set

§ tds_set_server()

bool tds_set_server ( TDSLOGIN tds_login,
const char *  server 
)

Set the servername in a TDSLOGIN structure.

Normally copies server into tds_login. If server does not point to a plausible name, the environment variables TDSQUERY and DSQUERY are used, in that order. If they don't exist, the "default default" servername is "SYBASE" (although the utility of that choice is a bit murky).

Parameters
tds_loginpoints to a TDSLOGIN structure
serverthe servername, or NULL, or a zero-length string
Todo:
open the log file earlier, so these messages can be seen.

§ tds_set_state()

TDS_STATE tds_set_state ( TDSSOCKET tds,
TDS_STATE  state 
)

Set state of TDS connection, with logging and checking.

Parameters
tdsstate information for the socket and the TDS protocol
statethe new state of the connection, cf. TDS_STATE.
Returns
the new state, which might not be state.
Here is the caller graph for this function:

§ tds_strndup()

char* tds_strndup ( const void *  s,
TDS_INTPTR  len 
)

Copy a string of length len to a new allocated buffer This function does not read more than len bytes Please note that some system implementation of strndup do not assure they don't read past len bytes as they use still strlen to check length to copy limiting after strlen to size passed Also this function is different from strndup as it assume that len bytes are valid String returned is NUL terminated.

Parameters
sstring to copy from
lenlength to copy
Returns
string copied or NULL if errors

§ tds_timestamp_str()

char* tds_timestamp_str ( char *  str,
int  maxlen 
)

strftime(str, maxlen - 6, "%Y-%m-%d %H:%M:%S", tm);

§ tds_writetext_continue()

TDSRET tds_writetext_continue ( TDSSOCKET tds,
const TDS_UCHAR *  text,
TDS_UINT  size 
)

Send some data in the writetext request started by tds_writetext_start.

You should write in total (with multiple calls to this function) all bytes declared calling tds_writetext_start.

Parameters
tdsA pointer to the TDSSOCKET structure managing a client/server operation.
textdata to write
sizedata size in bytes
Here is the call graph for this function:

§ tds_writetext_end()

TDSRET tds_writetext_end ( TDSSOCKET tds)

Finish sending writetext data.

Parameters
tdsA pointer to the TDSSOCKET structure managing a client/server operation.
Here is the call graph for this function:

§ tds_writetext_start()

TDSRET tds_writetext_start ( TDSSOCKET tds,
const char *  objname,
const char *  textptr,
const char *  timestamp,
int  with_log,
TDS_UINT  size 
)

Start writing writetext request.

This request start a bulk session.

Parameters
tdsA pointer to the TDSSOCKET structure managing a client/server operation.
objnametable name
textptrTEXTPTR (see sql documentation)
timestampdata timestamp
with_logis log is enabled during insert
sizebytes to be inserted
Here is the call graph for this function:

§ tdsdump_col()

void tdsdump_col ( const TDSCOLUMN col)

Write a column value to the debug log.

Parameters
colcolumn to dump
Here is the call graph for this function:

§ tdsdump_dump_buf()

void tdsdump_dump_buf ( const char *  file,
unsigned int  level_line,
const char *  msg,
const void *  buf,
size_t  length 
)

Dump the contents of data into the log file in a human readable format.

Parameters
filesource file name
level_lineline and level combined. This and file are automatically computed by TDS_DBG_* macros.
msgmessage to print before dump
bufbuffer to dump
lengthnumber of bytes in the buffer

§ tdsdump_log()

void tdsdump_log ( const char *  file,
unsigned int  level_line,
const char *  fmt,
  ... 
)

Write a message to the debug log.

Parameters
filename of the log file
level_linekind of detail to be included
fmtprintf-like format string

§ tdsdump_on()

void tdsdump_on ( void  )

Turn logging back on.

You must call tdsdump_open() before calling this routine.

§ tdsdump_open()

int tdsdump_open ( const char *  filename)

Create and truncate a human readable dump file for the TDS traffic.

The name of the file is specified by the filename parameter. If that is given as NULL or an empty string, any existing log file will be closed.

Returns
true if the file was opened, false if it couldn't be opened.
Here is the caller graph for this function:

§ tdserror()

int tdserror ( const TDSCONTEXT tds_ctx,
TDSSOCKET tds,
int  msgno,
int  errnum 
)

Call the client library's error handler (for library-generated errors only)

The client library error handler may return: TDS_INT_CANCEL – Return TDS_FAIL to the calling function. For TDSETIME, closes the connection first. TDS_INT_CONTINUE – For TDSETIME only, retry the network read/write operation. Else invalid. TDS_INT_TIMEOUT – For TDSETIME only, send a TDSCANCEL packet. Else invalid.

These are Sybase semantics, but they serve all purposes. The application tells the library to quit, fail, retry, or attempt to cancel. In the event of a network timeout, a failed operation necessarily means the connection becomes unusable, because no cancellation dialog was concluded with the server.

It is the client library's duty to call the error handler installed by the application, if any, and to interpret the installed handler's return code. It may return to this function one of the above codes only. This function will not check the return code because there's nothing that can be done here except abort. It is merely passed to the calling function, which will (we hope) DTRT.

Parameters
tds_ctxpoints to a TDSCONTEXT structure
tdsthe connection structure, may be NULL if not connected
msgnoan enumerated libtds msgno, cf. tds.h
errnumthe OS errno, if it matters, else zero
Returns
client library function's return code

Variable Documentation

§ tds_numeric_bytes_per_prec

const int tds_numeric_bytes_per_prec[]

The following little table is indexed by precision and will tell us the number of bytes required to store the specified precision.

The following little table is indexed by precision and will tell us the number of bytes required to store the specified precision.

Support precision up to 77 digits

freetds-1.00.82/doc/reference/a00434_source.html100644 025423 025423 00001246420 13242511131 0014614 FreeTDS API: include/freetds/tds.h Source File
FreeTDS API
tds.h
Go to the documentation of this file.
1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2  * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Brian Bruns
3  * Copyright (C) 2010, 2011 Frediano Ziglio
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20 
21 #ifndef _tds_h_
22 #define _tds_h_
23 
24 #include <stdarg.h>
25 #include <stdio.h>
26 #include <time.h>
27 
28 #ifdef HAVE_STDDEF_H
29 #include <stddef.h>
30 #endif
31 
32 #if HAVE_NETDB_H
33 #include <netdb.h>
34 #endif /* HAVE_NETDB_H */
35 
36 #if HAVE_NETINET_IN_H
37 #include <netinet/in.h>
38 #endif /* HAVE_NET_INET_IN_H */
39 #if HAVE_ARPA_INET_H
40 #include <arpa/inet.h>
41 #endif /* HAVE_ARPA_INET_H */
42 
43 /* forward declaration */
44 typedef struct tdsiconvinfo TDSICONV;
45 typedef struct tds_connection TDSCONNECTION;
46 typedef struct tds_socket TDSSOCKET;
47 typedef struct tds_column TDSCOLUMN;
48 typedef struct tds_bcpinfo TDSBCPINFO;
49 
50 #include <freetds/version.h>
51 #include "tds_sysdep_public.h"
52 #include <freetds/sysdep_private.h>
53 #include <freetds/thread.h>
54 #include <freetds/bool.h>
55 #include "replacements.h"
56 
57 #include <freetds/pushvis.h>
58 
59 #ifdef __cplusplus
60 extern "C"
61 {
62 #if 0
63 }
64 #endif
65 #endif
66 
73 {
74  const char *freetds_version; /* release version of FreeTDS */
75  const char *sysconfdir; /* location of freetds.conf */
76  const char *last_update; /* latest software_version date among the modules */
77  int msdblib; /* for MS style dblib */
78  int sybase_compat; /* enable increased Open Client binary compatibility */
79  int threadsafe; /* compile for thread safety default=no */
80  int libiconv; /* search for libiconv in DIR/include and DIR/lib */
81  const char *tdsver; /* TDS protocol version (4.2/4.6/5.0/7.0/7.1) 5.0 */
82  int iodbc; /* build odbc driver against iODBC in DIR */
83  int unixodbc; /* build odbc driver against unixODBC in DIR */
84  int openssl; /* build against OpenSSL */
85  int gnutls; /* build against GnuTLS */
86  int mars; /* MARS enabled */
88 
94 typedef struct tds_dstr {
95  size_t dstr_size;
96  char dstr_s[1];
97 } *DSTR;
98 
114 /*
115  * All references to data that touch the wire should use the following typedefs.
116  *
117  * If you have problems on 64-bit machines and the code is
118  * using a native datatype, please change it to use
119  * these. (In the TDS layer only, the API layers have their
120  * own typedefs which equate to these).
121  */
122 typedef char TDS_CHAR; /* 8-bit char */
123 typedef unsigned char TDS_UCHAR; /* 8-bit uchar */
124 typedef unsigned char TDS_TINYINT; /* 8-bit unsigned */
125 typedef tds_sysdep_int16_type TDS_SMALLINT; /* 16-bit int */
126 typedef unsigned tds_sysdep_int16_type TDS_USMALLINT; /* 16-bit unsigned */
127 typedef tds_sysdep_int32_type TDS_INT; /* 32-bit int */
128 typedef unsigned tds_sysdep_int32_type TDS_UINT; /* 32-bit unsigned */
129 typedef tds_sysdep_real32_type TDS_REAL; /* 32-bit real */
130 typedef tds_sysdep_real64_type TDS_FLOAT; /* 64-bit real */
131 typedef tds_sysdep_int64_type TDS_INT8; /* 64-bit integer */
132 typedef unsigned tds_sysdep_int64_type TDS_UINT8; /* 64-bit unsigned */
133 typedef tds_sysdep_intptr_type TDS_INTPTR;
134 typedef unsigned tds_sysdep_intptr_type TDS_UINTPTR;
135 
136 #include <freetds/proto.h>
137 
138 #define TDS_INVALID_TYPE ((TDS_SERVER_TYPE) 0)
139 
144 typedef struct
145 {
146  TDS_UINT8 time;
147  TDS_INT date;
148  TDS_SMALLINT offset;
149  TDS_USMALLINT time_prec:3;
150  TDS_USMALLINT _tds_reserved:10;
151  TDS_USMALLINT has_time:1;
152  TDS_USMALLINT has_date:1;
153  TDS_USMALLINT has_offset:1;
155 
157 typedef struct tdsdaterec
158 {
159  TDS_INT year;
160  TDS_INT quarter;
161  TDS_INT month;
162  TDS_INT day;
163  TDS_INT dayofyear;
164  TDS_INT weekday;
165  TDS_INT hour;
166  TDS_INT minute;
167  TDS_INT second;
168  TDS_INT decimicrosecond;
169  TDS_INT timezone;
170 } TDSDATEREC;
171 
177 extern const int tds_numeric_bytes_per_prec[];
178 
179 typedef int TDSRET;
180 #define TDS_NO_MORE_RESULTS ((TDSRET)1)
181 #define TDS_SUCCESS ((TDSRET)0)
182 #define TDS_FAIL ((TDSRET)-1)
183 #define TDS_CANCELLED ((TDSRET)-2)
184 #define TDS_FAILED(rc) ((rc)<0)
185 #define TDS_SUCCEED(rc) ((rc)>=0)
186 
187 #define TDS_INT_CONTINUE 1
188 #define TDS_INT_CANCEL 2
189 #define TDS_INT_TIMEOUT 3
190 
191 
192 #define TDS_NO_COUNT -1
193 
194 #define TDS_ROW_RESULT 4040
195 #define TDS_PARAM_RESULT 4042
196 #define TDS_STATUS_RESULT 4043
197 #define TDS_MSG_RESULT 4044
198 #define TDS_COMPUTE_RESULT 4045
199 #define TDS_CMD_DONE 4046
200 #define TDS_CMD_SUCCEED 4047
201 #define TDS_CMD_FAIL 4048
202 #define TDS_ROWFMT_RESULT 4049
203 #define TDS_COMPUTEFMT_RESULT 4050
204 #define TDS_DESCRIBE_RESULT 4051
205 #define TDS_DONE_RESULT 4052
206 #define TDS_DONEPROC_RESULT 4053
207 #define TDS_DONEINPROC_RESULT 4054
208 #define TDS_OTHERS_RESULT 4055
209 
210 enum tds_token_results
211 {
212  TDS_TOKEN_RES_OTHERS,
213  TDS_TOKEN_RES_ROWFMT,
214  TDS_TOKEN_RES_COMPUTEFMT,
215  TDS_TOKEN_RES_PARAMFMT,
216  TDS_TOKEN_RES_DONE,
217  TDS_TOKEN_RES_ROW,
218  TDS_TOKEN_RES_COMPUTE,
219  TDS_TOKEN_RES_PROC,
220  TDS_TOKEN_RES_MSG,
221  TDS_TOKEN_RES_ENV,
222 };
223 
224 #define TDS_TOKEN_FLAG(flag) TDS_RETURN_##flag = (1 << (TDS_TOKEN_RES_##flag*2)), TDS_STOPAT_##flag = (2 << (TDS_TOKEN_RES_##flag*2))
225 
226 enum tds_token_flags
227 {
228  TDS_HANDLE_ALL = 0,
229  TDS_TOKEN_FLAG(OTHERS),
230  TDS_TOKEN_FLAG(ROWFMT),
231  TDS_TOKEN_FLAG(COMPUTEFMT),
232  TDS_TOKEN_FLAG(PARAMFMT),
233  TDS_TOKEN_FLAG(DONE),
234  TDS_TOKEN_FLAG(ROW),
235  TDS_TOKEN_FLAG(COMPUTE),
236  TDS_TOKEN_FLAG(PROC),
237  TDS_TOKEN_FLAG(MSG),
238  TDS_TOKEN_FLAG(ENV),
239  TDS_TOKEN_RESULTS = TDS_RETURN_ROWFMT|TDS_RETURN_COMPUTEFMT|TDS_RETURN_DONE|TDS_STOPAT_ROW|TDS_STOPAT_COMPUTE|TDS_RETURN_PROC,
240  TDS_TOKEN_TRAILING = TDS_STOPAT_ROWFMT|TDS_STOPAT_COMPUTEFMT|TDS_STOPAT_ROW|TDS_STOPAT_COMPUTE|TDS_STOPAT_MSG|TDS_STOPAT_OTHERS
241 };
242 
247 {
250  , TDS_DONE_ERROR = 0x02
251  , TDS_DONE_INXACT = 0x04
252  , TDS_DONE_PROC = 0x08
253  , TDS_DONE_COUNT = 0x10
255  , TDS_DONE_EVENT = 0x40 /* part of an event notification. */
256  , TDS_DONE_SRVERROR = 0x100
258  /* after the above flags, a TDS_DONE packet has a field describing the state of the transaction */
259  , TDS_DONE_NO_TRAN = 0 /* No transaction in effect */
260  , TDS_DONE_TRAN_SUCCEED = 1 /* Transaction completed successfully */
261  , TDS_DONE_TRAN_PROGRESS= 2 /* Transaction in progress */
262  , TDS_DONE_STMT_ABORT = 3 /* A statement aborted */
263  , TDS_DONE_TRAN_ABORT = 4 /* Transaction aborted */
264 };
265 
266 
267 /*
268  * TDSERRNO is emitted by libtds to the client library's error handler
269  * (which may in turn call the client's error handler).
270  * These match the db-lib msgno, because the same values have the same meaning
271  * in db-lib and ODBC. ct-lib maps them to ct-lib numbers (todo).
272  */
273 typedef enum { TDSEOK = TDS_SUCCESS,
274  TDSEVERDOWN = 100,
275  TDSEICONVIU = 2400,
276  TDSEICONVAVAIL = 2401,
277  TDSEICONVO = 2402,
278  TDSEICONVI = 2403,
279  TDSEICONV2BIG = 2404,
280  TDSEPORTINSTANCE = 2500,
281  TDSESYNC = 20001,
282  TDSEFCON = 20002,
283  TDSETIME = 20003,
284  TDSEREAD = 20004,
285  TDSEWRIT = 20006,
286  TDSESOCK = 20008,
287  TDSECONN = 20009,
288  TDSEMEM = 20010,
289  TDSEINTF = 20012, /* Server name not found in interface file */
290  TDSEUHST = 20013, /* Unknown host machine name. */
291  TDSEPWD = 20014,
292  TDSESEOF = 20017,
293  TDSERPND = 20019,
294  TDSEBTOK = 20020,
295  TDSEOOB = 20022,
296  TDSECLOS = 20056,
297  TDSEUSCT = 20058,
298  TDSEUTDS = 20146,
299  TDSEEUNR = 20185,
300  TDSECAP = 20203,
301  TDSENEG = 20210,
302  TDSEUMSG = 20212,
303  TDSECAPTYP = 20213,
304  TDSECONF = 20214,
305  TDSEBPROBADTYP = 20250,
306  TDSECLOSEIN = 20292
307 } TDSERRNO;
308 
309 
310 enum {
311  TDS_CUR_ISTAT_UNUSED = 0x00,
312  TDS_CUR_ISTAT_DECLARED = 0x01,
313  TDS_CUR_ISTAT_OPEN = 0x02,
314  TDS_CUR_ISTAT_CLOSED = 0x04,
315  TDS_CUR_ISTAT_RDONLY = 0x08,
316  TDS_CUR_ISTAT_UPDATABLE = 0x10,
317  TDS_CUR_ISTAT_ROWCNT = 0x20,
318  TDS_CUR_ISTAT_DEALLOC = 0x40
319 };
320 
321 /* string types */
322 #define TDS_NULLTERM -9
323 
324 
325 typedef union tds_option_arg
326 {
327  TDS_TINYINT ti;
328  TDS_INT i;
329  TDS_CHAR *c;
331 
332 
333 typedef enum tds_encryption_level {
334  TDS_ENCRYPTION_OFF, TDS_ENCRYPTION_REQUEST, TDS_ENCRYPTION_REQUIRE
335 } TDS_ENCRYPTION_LEVEL;
336 
337 #define TDS_ZERO_FREE(x) do {free((x)); (x) = NULL;} while(0)
338 #define TDS_VECTOR_SIZE(x) (sizeof(x)/sizeof(x[0]))
339 #ifdef offsetof
340 #define TDS_OFFSET(str, field) offsetof(str, field)
341 #else
342 #define TDS_OFFSET(str, field) (((char*)&((str*)0)->field)-((char*)0))
343 #endif
344 
345 #if defined(__GNUC__) && __GNUC__ >= 3
346 # define TDS_LIKELY(x) __builtin_expect(!!(x), 1)
347 # define TDS_UNLIKELY(x) __builtin_expect(!!(x), 0)
348 #else
349 # define TDS_LIKELY(x) (x)
350 # define TDS_UNLIKELY(x) (x)
351 #endif
352 
353 #if ENABLE_EXTRA_CHECKS
354 # if defined(__GNUC__) && __GNUC__ >= 2
355 # define TDS_COMPILE_CHECK(name,check) \
356  extern int name[(check)?1:-1] __attribute__ ((unused))
357 # else
358 # define TDS_COMPILE_CHECK(name,check) \
359  extern int name[(check)?1:-1]
360 # endif
361 # define TDS_EXTRA_CHECK(stmt) stmt
362 #else
363 # define TDS_COMPILE_CHECK(name,check) \
364  extern int disabled_check_##name
365 # define TDS_EXTRA_CHECK(stmt)
366 #endif
367 
368 #if ENABLE_EXTRA_CHECKS && defined(__GNUC__) && __GNUC__ >= 4
369 #define TDS_WUR __attribute__ ((__warn_unused_result__))
370 #else
371 #define TDS_WUR
372 #endif
373 
374 /*
375  * TODO use system macros for optimization
376  * See mcrypt for reference and linux kernel source for optimization
377  * check if unaligned access and use fast write/read when implemented
378  */
379 #define TDS_BYTE_SWAP16(value) \
380  (((((unsigned short)value)<<8) & 0xFF00) | \
381  ((((unsigned short)value)>>8) & 0x00FF))
382 
383 #define TDS_BYTE_SWAP32(value) \
384  (((((unsigned long)value)<<24) & 0xFF000000) | \
385  ((((unsigned long)value)<< 8) & 0x00FF0000) | \
386  ((((unsigned long)value)>> 8) & 0x0000FF00) | \
387  ((((unsigned long)value)>>24) & 0x000000FF))
388 
389 #define is_end_token(x) (x==TDS_DONE_TOKEN || \
390  x==TDS_DONEPROC_TOKEN || \
391  x==TDS_DONEINPROC_TOKEN)
392 
393 enum {
394  TDS_TYPEFLAG_INVALID = 0,
395  TDS_TYPEFLAG_NULLABLE = 1,
396  TDS_TYPEFLAG_FIXED = 2,
397  TDS_TYPEFLAG_VARIABLE = 4,
398  TDS_TYPEFLAG_COLLATE = 8,
399  TDS_TYPEFLAG_ASCII = 16,
400  TDS_TYPEFLAG_UNICODE = 32,
401  TDS_TYPEFLAG_NUMERIC = 64,
402  TDS_TYPEFLAG_DATETIME = 128,
403 };
404 
405 extern const unsigned char tds_type_flags_ms[256];
406 #if 0
407 extern const unsigned char tds_type_flags_syb[256];
408 extern const char *const tds_type_names[256];
409 #endif
410 
411 #define is_fixed_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_FIXED) != 0)
412 #define is_nullable_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_NULLABLE) != 0)
413 #define is_variable_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_VARIABLE) != 0)
414 
415 
416 #define is_blob_type(x) ((x)==SYBTEXT || (x)==SYBIMAGE || (x)==SYBNTEXT)
417 #define is_blob_col(x) ((x)->column_varint_size > 2)
418 /* large type means it has a two byte size field */
419 /* define is_large_type(x) (x>128) */
420 #define is_numeric_type(x) ((x)==SYBNUMERIC || (x)==SYBDECIMAL)
421 
422 #define is_datetime_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_DATETIME) != 0)
423 #define is_unicode_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_UNICODE) != 0)
424 #define is_collate_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_COLLATE) != 0)
425 #define is_ascii_type(x) ((tds_type_flags_ms[x] & TDS_TYPEFLAG_ASCII) != 0)
426 #define is_char_type(x) ((tds_type_flags_ms[x] & (TDS_TYPEFLAG_ASCII|TDS_TYPEFLAG_UNICODE)) != 0)
427 #define is_similar_type(x, y) (is_char_type(x) && is_char_type(y))
428 static inline
429 bool is_tds_type_valid(int type)
430 {
431  return (unsigned) type < 256u && tds_type_flags_ms[type] != 0;
432 }
433 
434 
435 #define TDS_MAX_CAPABILITY 32
436 #define MAXPRECISION 77
437 #define TDS_MAX_CONN 4096
438 #define TDS_MAX_DYNID_LEN 30
439 
440 /* defaults to use if no others are found */
441 #define TDS_DEF_SERVER "SYBASE"
442 #define TDS_DEF_BLKSZ 512
443 #define TDS_DEF_CHARSET "iso_1"
444 #define TDS_DEF_LANG "us_english"
445 #if TDS42
446 #define TDS_DEFAULT_VERSION 0x402
447 #define TDS_DEF_PORT 1433
448 #elif TDS46
449 #define TDS_DEFAULT_VERSION 0x406
450 #define TDS_DEF_PORT 4000
451 #elif TDS50
452 #define TDS_DEFAULT_VERSION 0x500
453 #define TDS_DEF_PORT 4000
454 #elif TDS70
455 #define TDS_DEFAULT_VERSION 0x700
456 #define TDS_DEF_PORT 1433
457 #elif TDS71
458 #define TDS_DEFAULT_VERSION 0x701
459 #define TDS_DEF_PORT 1433
460 #elif TDS72
461 #define TDS_DEFAULT_VERSION 0x702
462 #define TDS_DEF_PORT 1433
463 #elif TDS73
464 #define TDS_DEFAULT_VERSION 0x703
465 #define TDS_DEF_PORT 1433
466 #elif TDS74
467 #define TDS_DEFAULT_VERSION 0x704
468 #define TDS_DEF_PORT 1433
469 #else
470 #define TDS_DEFAULT_VERSION 0x000
471 #define TDS_DEF_PORT 1433
472 #endif
473 
474 /* normalized strings from freetds.conf file */
475 #define TDS_STR_VERSION "tds version"
476 #define TDS_STR_BLKSZ "initial block size"
477 #define TDS_STR_SWAPDT "swap broken dates"
478 #define TDS_STR_DUMPFILE "dump file"
479 #define TDS_STR_DEBUGLVL "debug level"
480 #define TDS_STR_DEBUGFLAGS "debug flags"
481 #define TDS_STR_TIMEOUT "timeout"
482 #define TDS_STR_QUERY_TIMEOUT "query timeout"
483 #define TDS_STR_CONNTIMEOUT "connect timeout"
484 #define TDS_STR_HOSTNAME "hostname"
485 #define TDS_STR_HOST "host"
486 #define TDS_STR_PORT "port"
487 #define TDS_STR_TEXTSZ "text size"
488 /* for big endian hosts */
489 #define TDS_STR_EMUL_LE "emulate little endian"
490 #define TDS_STR_CHARSET "charset"
491 #define TDS_STR_CLCHARSET "client charset"
492 #define TDS_STR_USE_UTF_16 "use utf-16"
493 #define TDS_STR_LANGUAGE "language"
494 #define TDS_STR_APPENDMODE "dump file append"
495 #define TDS_STR_DATEFMT "date format"
496 #define TDS_STR_INSTANCE "instance"
497 #define TDS_STR_ASA_DATABASE "asa database"
498 #define TDS_STR_DATABASE "database"
499 #define TDS_STR_ENCRYPTION "encryption"
500 #define TDS_STR_USENTLMV2 "use ntlmv2"
501 #define TDS_STR_USELANMAN "use lanman"
502 /* conf values */
503 #define TDS_STR_ENCRYPTION_OFF "off"
504 #define TDS_STR_ENCRYPTION_REQUEST "request"
505 #define TDS_STR_ENCRYPTION_REQUIRE "require"
506 /* Defines to enable optional GSSAPI delegation */
507 #define TDS_GSSAPI_DELEGATION "enable gssapi delegation"
508 /* Kerberos realm name */
509 #define TDS_STR_REALM "realm"
510 /* Kerberos SPN */
511 #define TDS_STR_SPN "spn"
512 /* CA file */
513 #define TDS_STR_CAFILE "ca file"
514 /* CRL file */
515 #define TDS_STR_CRLFILE "crl file"
516 /* check SSL hostname */
517 #define TDS_STR_CHECKSSLHOSTNAME "check certificate hostname"
518 /* database filename to attach on login (MSSQL) */
519 #define TDS_STR_DBFILENAME "database filename"
520 /* Application Intent MSSQL 2012 support */
521 #define TDS_STR_READONLY_INTENT "read-only intent"
522 /* configurable cipher suite to send to openssl's SSL_set_cipher_list() function */
523 #define TLS_STR_OPENSSL_CIPHERS "openssl ciphers"
524 
525 
526 /* TODO do a better check for alignment than this */
527 typedef union
528 {
529  void *p;
530  int i;
531  TDS_INT8 ui;
533 
534 #define TDS_ALIGN_SIZE sizeof(tds_align_struct)
535 
536 typedef struct tds_capability_type
537 {
538  unsigned char type;
539  unsigned char len; /* always sizeof(values) */
540  unsigned char values[TDS_MAX_CAPABILITY/2-2];
542 
543 typedef struct tds_capabilities
544 {
545  TDS_CAPABILITY_TYPE types[2];
547 
548 #define TDS_MAX_LOGIN_STR_SZ 128
549 typedef struct tds_login
550 {
552  int port;
553  TDS_USMALLINT tds_version;
554  int block_size;
555  DSTR language; /* e.g. us-english */
557  TDS_INT connect_timeout;
558  DSTR client_host_name;
559  DSTR server_host_name;
565  DSTR openssl_ciphers;
566  DSTR app_name;
571  DSTR library; /* Ct-Library, DB-Library, TDS-Library or ODBC */
572  TDS_TINYINT encryption_level;
573 
574  TDS_INT query_timeout;
575  TDS_CAPABILITIES capabilities;
576  DSTR client_charset;
577  DSTR database;
578 
579  struct addrinfo *ip_addrs;
580  struct addrinfo *connected_addr; /* ip of connected server */
581  DSTR instance_name;
582  DSTR dump_file;
583  int debug_flags;
584  int text_size;
585  DSTR routing_address;
586  TDS_USMALLINT routing_port;
587 
588  unsigned char option_flag2;
589 
590  unsigned int bulk_copy:1;
591  unsigned int suppress_language:1;
592  unsigned int emul_little_endian:1;
593  unsigned int gssapi_use_delegation:1;
594  unsigned int use_ntlmv2:1;
595  unsigned int use_lanman:1;
596  unsigned int mars:1;
597  unsigned int use_utf16:1;
598  unsigned int use_new_password:1;
599  unsigned int valid_configuration:1;
600  unsigned int check_ssl_hostname:1;
601  unsigned int readonly_intent:1;
602 } TDSLOGIN;
603 
604 typedef struct tds_headers
605 {
606  const char *qn_options;
607  const char *qn_msgtext;
608  TDS_INT qn_timeout;
609  /* TDS 7.4+: trace activity ID char[20] */
610 } TDSHEADERS;
611 
612 typedef struct tds_locale
613 {
614  char *language;
615  char *server_charset;
616  char *date_fmt;
617 } TDSLOCALE;
618 
623 typedef struct tds_blob
624 {
625  TDS_CHAR *textvalue;
626  TDS_CHAR textptr[16];
627  TDS_CHAR timestamp[8];
628  unsigned char valid_ptr;
629 } TDSBLOB;
630 
634 typedef struct tds_variant
635 {
636  /* this MUST have same position and place of textvalue in tds_blob */
637  TDS_CHAR *data;
638  TDS_INT size;
639  TDS_INT data_len;
640  TDS_SERVER_TYPE type;
641  TDS_UCHAR collation[5];
642 } TDSVARIANT;
643 
648 typedef struct tds_encoding
649 {
651  const char *name;
652  unsigned char min_bytes_per_char;
653  unsigned char max_bytes_per_char;
655  unsigned char canonic;
656 } TDS_ENCODING;
657 
658 typedef struct tds_bcpcoldata
659 {
660  TDS_UCHAR *data;
661  TDS_INT datalen;
662  TDS_INT is_null;
663 } BCPCOLDATA;
664 
665 
666 typedef TDSRET tds_func_get_info(TDSSOCKET *tds, TDSCOLUMN *col);
667 typedef TDSRET tds_func_get_data(TDSSOCKET *tds, TDSCOLUMN *col);
668 typedef TDS_INT tds_func_row_len(TDSCOLUMN *col);
669 typedef unsigned tds_func_put_info_len(TDSSOCKET *tds, TDSCOLUMN *col);
670 typedef TDSRET tds_func_put_info(TDSSOCKET *tds, TDSCOLUMN *col);
671 typedef TDSRET tds_func_put_data(TDSSOCKET *tds, TDSCOLUMN *col, int bcp7);
672 typedef int tds_func_check(const TDSCOLUMN *col);
673 
674 typedef struct tds_column_funcs
675 {
676  tds_func_get_info *get_info;
677  tds_func_get_data *get_data;
678  tds_func_row_len *row_len;
684  tds_func_put_info_len *put_info_len;
690  tds_func_put_info *put_info;
700  tds_func_put_data *put_data;
701 #if ENABLE_EXTRA_CHECKS
702 
716  tds_func_check *check;
717 #endif
718 #if 0
719  TDSRET (*convert)(TDSSOCKET *tds, TDSCOLUMN *col);
720 #endif
722 
727 {
728  const TDSCOLUMNFUNCS *funcs;
729  TDS_INT column_usertype;
730  TDS_INT column_flags;
731 
732  TDS_INT column_size;
734  TDS_SERVER_TYPE column_type;
739  TDS_TINYINT column_varint_size;
741  TDS_TINYINT column_prec;
742  TDS_TINYINT column_scale;
744  struct
745  {
746  TDS_SERVER_TYPE column_type;
747  TDS_INT column_size;
748  } on_server;
749 
752  DSTR table_name;
753  DSTR column_name;
754  DSTR table_column_name;
755 
756  unsigned char *column_data;
757  void (*column_data_free)(struct tds_column *column);
758  unsigned int column_nullable:1;
759  unsigned int column_writeable:1;
760  unsigned int column_identity:1;
761  unsigned int column_key:1;
762  unsigned int column_hidden:1;
763  unsigned int column_output:1;
764  unsigned int column_timestamp:1;
765  TDS_UCHAR column_collation[5];
766 
767  /* additional fields flags for compute results */
768  TDS_TINYINT column_operator;
769  TDS_SMALLINT column_operand;
770 
771  /* FIXME this is data related, not column */
774 
775  /* related to binding or info stored by client libraries */
776  /* FIXME find a best place to store these data, some are unused */
777  TDS_SMALLINT column_bindtype;
778  TDS_SMALLINT column_bindfmt;
779  TDS_UINT column_bindlen;
780  TDS_SMALLINT *column_nullbind;
781  TDS_CHAR *column_varaddr;
782  TDS_INT *column_lenbind;
783  TDS_INT column_textpos;
784  TDS_INT column_text_sqlgetdatapos;
785  TDS_CHAR column_text_sqlputdatainfo;
786 
787  BCPCOLDATA *bcp_column_data;
796  TDS_INT bcp_prefix_len;
797  TDS_INT bcp_term_len;
798  TDS_CHAR *bcp_terminator;
799 };
800 
801 
803 typedef struct tds_result_info
804 {
805  /* TODO those fields can became a struct */
806  TDSCOLUMN **columns;
807  TDS_USMALLINT num_cols;
808  TDS_USMALLINT computeid;
809  TDS_INT ref_count;
810  TDSSOCKET *attached_to;
811  unsigned char *current_row;
812  void (*row_free)(struct tds_result_info* result, unsigned char *row);
813  TDS_INT row_size;
814 
815  TDS_SMALLINT *bycolumns;
816  TDS_USMALLINT by_cols;
817  TDS_TINYINT rows_exist;
818  /* TODO remove ?? used only in dblib */
819  TDS_TINYINT more_results;
820 } TDSRESULTINFO;
821 
823 typedef enum tds_states
824 {
831 } TDS_STATE;
832 
833 typedef enum tds_operations
834 {
835  TDS_OP_NONE = 0,
836 
837  /* mssql operations */
838  TDS_OP_CURSOR = TDS_SP_CURSOR,
839  TDS_OP_CURSOROPEN = TDS_SP_CURSOROPEN,
840  TDS_OP_CURSORPREPARE = TDS_SP_CURSORPREPARE,
841  TDS_OP_CURSOREXECUTE = TDS_SP_CURSOREXECUTE,
842  TDS_OP_CURSORPREPEXEC = TDS_SP_CURSORPREPEXEC,
843  TDS_OP_CURSORUNPREPARE = TDS_SP_CURSORUNPREPARE,
844  TDS_OP_CURSORFETCH = TDS_SP_CURSORFETCH,
845  TDS_OP_CURSOROPTION = TDS_SP_CURSOROPTION,
846  TDS_OP_CURSORCLOSE = TDS_SP_CURSORCLOSE,
847  TDS_OP_EXECUTESQL = TDS_SP_EXECUTESQL,
848  TDS_OP_PREPARE = TDS_SP_PREPARE,
849  TDS_OP_EXECUTE = TDS_SP_EXECUTE,
850  TDS_OP_PREPEXEC = TDS_SP_PREPEXEC,
851  TDS_OP_PREPEXECRPC = TDS_SP_PREPEXECRPC,
852  TDS_OP_UNPREPARE = TDS_SP_UNPREPARE,
853 
854  /* sybase operations */
855  TDS_OP_DYN_DEALLOC = 100,
856 } TDS_OPERATION;
857 
858 #define TDS_DBG_LOGIN __FILE__, ((__LINE__ << 4) | 11)
859 #define TDS_DBG_HEADER __FILE__, ((__LINE__ << 4) | 10)
860 #define TDS_DBG_FUNC __FILE__, ((__LINE__ << 4) | 7)
861 #define TDS_DBG_INFO2 __FILE__, ((__LINE__ << 4) | 6)
862 #define TDS_DBG_INFO1 __FILE__, ((__LINE__ << 4) | 5)
863 #define TDS_DBG_NETWORK __FILE__, ((__LINE__ << 4) | 4)
864 #define TDS_DBG_WARN __FILE__, ((__LINE__ << 4) | 3)
865 #define TDS_DBG_ERROR __FILE__, ((__LINE__ << 4) | 2)
866 #define TDS_DBG_SEVERE __FILE__, ((__LINE__ << 4) | 1)
867 
868 #define TDS_DBGFLAG_FUNC 0x80
869 #define TDS_DBGFLAG_INFO2 0x40
870 #define TDS_DBGFLAG_INFO1 0x20
871 #define TDS_DBGFLAG_NETWORK 0x10
872 #define TDS_DBGFLAG_WARN 0x08
873 #define TDS_DBGFLAG_ERROR 0x04
874 #define TDS_DBGFLAG_SEVERE 0x02
875 #define TDS_DBGFLAG_ALL 0xfff
876 #define TDS_DBGFLAG_LOGIN 0x0800
877 #define TDS_DBGFLAG_HEADER 0x0400
878 #define TDS_DBGFLAG_PID 0x1000
879 #define TDS_DBGFLAG_TIME 0x2000
880 #define TDS_DBGFLAG_SOURCE 0x4000
881 #define TDS_DBGFLAG_THREAD 0x8000
882 
883 #if 0
884 
889 enum TDS_DBG_LOG_STATE
890 {
891  TDS_DBG_LOGIN = (1 << 0)
893  , TDS_DBG_API = (1 << 1)
894  , TDS_DBG_ASYNC = (1 << 2)
895  , TDS_DBG_DIAG = (1 << 3)
896  , TDS_DBG_error = (1 << 4)
897  /* TODO: ^^^^^ make upper case when old #defines (above) are removed */
898  /* Log FreeTDS runtime/logic error occurs. */
899  , TDS_DBG_PACKET = (1 << 5)
900  , TDS_DBG_LIBTDS = (1 << 6)
901  , TDS_DBG_CONFIG = (1 << 7)
902  , TDS_DBG_DEFAULT = 0xFE
903 };
904 #endif
905 
906 typedef struct tds_result_info TDSCOMPUTEINFO;
907 
909 
910 typedef struct tds_message
911 {
912  TDS_CHAR *server;
913  TDS_CHAR *message;
914  TDS_CHAR *proc_name;
915  TDS_CHAR *sql_state;
916  TDS_INT msgno;
917  TDS_INT line_number;
918  /* -1 .. 255 */
919  TDS_SMALLINT state;
920  TDS_TINYINT priv_msg_type;
921  TDS_TINYINT severity;
922  /* for library-generated errors */
923  int oserr;
924 } TDSMESSAGE;
925 
926 typedef struct tds_upd_col
927 {
928  struct tds_upd_col *next;
929  TDS_INT colnamelength;
930  char * columnname;
931 } TDSUPDCOL;
932 
933 typedef enum {
934  TDS_CURSOR_STATE_UNACTIONED = 0 /* initial value */
935  , TDS_CURSOR_STATE_REQUESTED = 1 /* called by ct_cursor */
936  , TDS_CURSOR_STATE_SENT = 2 /* sent to server */
937  , TDS_CURSOR_STATE_ACTIONED = 3 /* acknowledged by server */
938 } TDS_CURSOR_STATE;
939 
940 typedef struct tds_cursor_status
941 {
942  TDS_CURSOR_STATE declare;
943  TDS_CURSOR_STATE cursor_row;
944  TDS_CURSOR_STATE open;
945  TDS_CURSOR_STATE fetch;
946  TDS_CURSOR_STATE close;
947  TDS_CURSOR_STATE dealloc;
949 
950 typedef enum tds_cursor_operation
951 {
952  TDS_CURSOR_POSITION = 0,
953  TDS_CURSOR_UPDATE = 1,
954  TDS_CURSOR_DELETE = 2,
955  TDS_CURSOR_INSERT = 4
956 } TDS_CURSOR_OPERATION;
957 
958 typedef enum tds_cursor_fetch
959 {
960  TDS_CURSOR_FETCH_NEXT = 1,
961  TDS_CURSOR_FETCH_PREV,
962  TDS_CURSOR_FETCH_FIRST,
963  TDS_CURSOR_FETCH_LAST,
964  TDS_CURSOR_FETCH_ABSOLUTE,
965  TDS_CURSOR_FETCH_RELATIVE
966 } TDS_CURSOR_FETCH;
967 
971 typedef struct tds_cursor
972 {
973  struct tds_cursor *next;
974  TDS_INT ref_count;
975  char *cursor_name;
976  TDS_INT cursor_id;
977  TDS_TINYINT options;
981  TDS_TINYINT defer_close;
982  char *query;
983  /* TODO for updatable columns */
984  /* TDS_TINYINT number_upd_cols; */
985  /* TDSUPDCOL *cur_col_list; */
986  TDS_INT cursor_rows;
987  /* TDSPARAMINFO *params; */
989  TDS_USMALLINT srv_status;
990  TDSRESULTINFO *res_info;
991  TDS_INT type, concurrency;
992 } TDSCURSOR;
993 
997 typedef struct tds_env
998 {
1001  char *language;
1003  char *charset;
1005  char *database;
1006 } TDSENV;
1007 
1011 typedef struct tds_dynamic
1012 {
1013  struct tds_dynamic *next;
1014  TDS_INT ref_count;
1016  TDS_INT num_id;
1022  char id[30];
1028  TDS_TINYINT emulated;
1032  TDS_TINYINT defer_close;
1033  /* int dyn_state; */ /* TODO use it */
1044  char *query;
1045 } TDSDYNAMIC;
1046 
1047 typedef enum {
1048  TDS_MULTIPLE_QUERY,
1049  TDS_MULTIPLE_EXECUTE,
1050  TDS_MULTIPLE_RPC
1051 } TDS_MULTIPLE_TYPE;
1052 
1053 typedef struct tds_multiple
1054 {
1055  TDS_MULTIPLE_TYPE type;
1056  unsigned int flags;
1057 } TDSMULTIPLE;
1058 
1059 /* forward declaration */
1060 typedef struct tds_context TDSCONTEXT;
1061 typedef int (*err_handler_t) (const TDSCONTEXT *, TDSSOCKET *, TDSMESSAGE *);
1062 
1064 {
1065  TDSLOCALE *locale;
1066  void *parent;
1067  /* handlers */
1068  int (*msg_handler) (const TDSCONTEXT *, TDSSOCKET *, TDSMESSAGE *);
1069  int (*err_handler) (const TDSCONTEXT *, TDSSOCKET *, TDSMESSAGE *);
1070  int (*int_handler) (void *);
1071 };
1072 
1073 enum TDS_ICONV_ENTRY
1074 {
1075  client2ucs2
1076  , client2server_chardata
1077  , initial_char_conv_count /* keep last */
1078 };
1079 
1080 typedef struct tds_authentication
1081 {
1082  TDS_UCHAR *packet;
1083  int packet_len;
1084  TDSRET (*free)(TDSCONNECTION* conn, struct tds_authentication * auth);
1085  TDSRET (*handle_next)(TDSSOCKET * tds, struct tds_authentication * auth, size_t len);
1087 
1088 typedef struct tds_packet
1089 {
1090  struct tds_packet *next;
1091  short sid;
1092  unsigned len, capacity;
1093  unsigned char buf[1];
1094 } TDSPACKET;
1095 
1096 typedef struct tds_poll_wakeup
1097 {
1098  TDS_SYS_SOCKET s_signal, s_signaled;
1099 } TDSPOLLWAKEUP;
1100 
1101 /* field related to connection */
1103 {
1104  TDS_USMALLINT tds_version;
1105  TDS_UINT product_version;
1106  char *product_name;
1107 
1108  TDS_SYS_SOCKET s;
1109  TDSPOLLWAKEUP wakeup;
1110  const TDSCONTEXT *tds_ctx;
1111 
1114 
1125 
1126  int char_conv_count;
1127  TDSICONV **char_convs;
1128 
1129  TDS_UCHAR collation[5];
1130  TDS_UCHAR tds72_transaction[8];
1131 
1132  TDS_CAPABILITIES capabilities;
1133  unsigned int emul_little_endian:1;
1134  unsigned int use_iconv:1;
1135  unsigned int tds71rev1:1;
1136  unsigned int pending_close:1;
1137  unsigned int encrypt_single_packet:1;
1138 #if ENABLE_ODBC_MARS
1139  unsigned int mars:1;
1140 
1141  TDSSOCKET *in_net_tds;
1142  TDSPACKET *packets;
1143  TDSPACKET *recv_packet;
1144  TDSPACKET *send_packets;
1145  unsigned send_pos, recv_pos;
1146 
1147  tds_mutex list_mtx;
1148 #define BUSY_SOCKET ((TDSSOCKET*)(TDS_UINTPTR)1)
1149 #define TDSSOCKET_VALID(tds) (((TDS_UINTPTR)(tds)) > 1)
1150  struct tds_socket **sessions;
1151  unsigned num_sessions;
1152  unsigned num_cached_packets;
1153  TDSPACKET *packet_cache;
1154 #endif
1155 
1156  int spid;
1157  int client_spid;
1158 
1159  void *tls_session;
1160 #if defined(HAVE_GNUTLS)
1161  void *tls_credentials;
1162 #elif defined(HAVE_OPENSSL)
1163  void *tls_ctx;
1164 #else
1165  void *tls_dummy;
1166 #endif
1167  TDSAUTHENTICATION *authentication;
1168  char *server;
1169 };
1170 
1175 {
1176 #if ENABLE_ODBC_MARS
1177  TDSCONNECTION *conn;
1178 #else
1179  TDSCONNECTION conn[1];
1180 #endif
1181 
1187  unsigned char *in_buf;
1188 
1194  unsigned char *out_buf;
1195 
1200  unsigned int out_buf_max;
1201  unsigned in_pos;
1202  unsigned out_pos;
1203  unsigned in_len;
1204  unsigned char in_flag;
1205  unsigned char out_flag;
1207  void *parent;
1208 
1209 #if ENABLE_ODBC_MARS
1210  short sid;
1211  tds_condition packet_cond;
1212  TDS_UINT recv_seq;
1213  TDS_UINT send_seq;
1214  TDS_UINT recv_wnd;
1215  TDS_UINT send_wnd;
1216 #endif
1217  /* packet we received */
1218  TDSPACKET *recv_packet;
1221 
1228  TDSRESULTINFO *res_info;
1229  TDS_UINT num_comp_info;
1230  TDSCOMPUTEINFO **comp_info;
1231  TDSPARAMINFO *param_info;
1233  TDS_TINYINT bulk_query;
1234  TDS_TINYINT has_status;
1235  bool in_row;
1236  TDS_INT ret_status;
1237  TDS_STATE state;
1238  volatile
1239  unsigned char in_cancel;
1242  TDS_INT8 rows_affected;
1243  TDS_INT query_timeout;
1244 
1249  void (*env_chg_func) (TDSSOCKET * tds, int type, char *oldval, char *newval);
1250  TDS_OPERATION current_op;
1251 
1252  int option_value;
1253  tds_mutex wire_mtx;
1254 };
1255 
1256 #define tds_get_ctx(tds) ((tds)->conn->tds_ctx)
1257 #define tds_set_ctx(tds, val) do { ((tds)->conn->tds_ctx) = (val); } while(0)
1258 #define tds_get_parent(tds) ((tds)->parent)
1259 #define tds_set_parent(tds, val) do { ((tds)->parent) = (val); } while(0)
1260 #define tds_get_s(tds) ((tds)->conn->s)
1261 #define tds_set_s(tds, val) do { ((tds)->conn->s) = (val); } while(0)
1262 
1263 
1264 /* config.c */
1266 typedef void (*TDSCONFPARSE) (const char *option, const char *value, void *param);
1267 int tds_read_conf_section(FILE * in, const char *section, TDSCONFPARSE tds_conf_parse, void *parse_param);
1268 int tds_read_conf_file(TDSLOGIN * login, const char *server);
1269 void tds_parse_conf_section(const char *option, const char *value, void *param);
1270 TDSLOGIN *tds_read_config_info(TDSSOCKET * tds, TDSLOGIN * login, TDSLOCALE * locale);
1271 void tds_fix_login(TDSLOGIN* login);
1272 TDS_USMALLINT * tds_config_verstr(const char *tdsver, TDSLOGIN* login);
1273 struct addrinfo *tds_lookup_host(const char *servername);
1274 TDSRET tds_lookup_host_set(const char *servername, struct addrinfo **addr);
1275 const char *tds_addrinfo2str(struct addrinfo *addr, char *name, int namemax);
1276 
1277 TDSRET tds_set_interfaces_file_loc(const char *interfloc);
1278 extern const char STD_DATETIME_FMT[];
1279 int tds_parse_boolean(const char *value, int default_value);
1280 int tds_config_boolean(const char *option, const char *value, TDSLOGIN * login);
1281 
1282 TDSLOCALE *tds_get_locale(void);
1283 TDSRET tds_alloc_row(TDSRESULTINFO * res_info);
1284 TDSRET tds_alloc_compute_row(TDSCOMPUTEINFO * res_info);
1285 BCPCOLDATA * tds_alloc_bcp_column_data(unsigned int column_size);
1286 TDSDYNAMIC *tds_lookup_dynamic(TDSCONNECTION * conn, const char *id);
1287 /*@observer@*/ const char *tds_prtype(int token);
1288 int tds_get_varint_size(TDSCONNECTION * conn, int datatype);
1289 TDS_SERVER_TYPE tds_get_cardinal_type(TDS_SERVER_TYPE datatype, int usertype);
1290 
1291 
1292 /* iconv.c */
1293 TDSRET tds_iconv_open(TDSCONNECTION * conn, const char *charset, int use_utf16);
1294 void tds_iconv_close(TDSCONNECTION * conn);
1295 void tds_srv_charset_changed(TDSCONNECTION * conn, const char *charset);
1296 void tds7_srv_charset_changed(TDSCONNECTION * conn, int sql_collate, int lcid);
1297 int tds_iconv_alloc(TDSCONNECTION * conn);
1298 void tds_iconv_free(TDSCONNECTION * conn);
1299 TDSICONV *tds_iconv_from_collate(TDSCONNECTION * conn, TDS_UCHAR collate[5]);
1300 
1301 
1302 /* threadsafe.c */
1303 char *tds_timestamp_str(char *str, int maxlen);
1304 struct tm *tds_localtime_r(const time_t *timep, struct tm *result);
1305 struct hostent *tds_gethostbyname_r(const char *servername, struct hostent *result, char *buffer, int buflen, int *h_errnop);
1306 int tds_getservice(const char *name);
1307 char *tds_get_homedir(void);
1308 
1309 
1310 /* mem.c */
1311 void tds_free_socket(TDSSOCKET * tds);
1312 void tds_free_all_results(TDSSOCKET * tds);
1313 void tds_free_results(TDSRESULTINFO * res_info);
1314 void tds_free_param_results(TDSPARAMINFO * param_info);
1315 void tds_free_param_result(TDSPARAMINFO * param_info);
1316 void tds_free_msg(TDSMESSAGE * message);
1317 void tds_cursor_deallocated(TDSCONNECTION *conn, TDSCURSOR *cursor);
1318 void tds_release_cursor(TDSCURSOR **pcursor);
1319 void tds_free_bcp_column_data(BCPCOLDATA * coldata);
1320 TDSRESULTINFO *tds_alloc_results(TDS_USMALLINT num_cols);
1321 TDSCOMPUTEINFO **tds_alloc_compute_results(TDSSOCKET * tds, TDS_USMALLINT num_cols, TDS_USMALLINT by_cols);
1322 TDSCONTEXT *tds_alloc_context(void * parent);
1323 void tds_free_context(TDSCONTEXT * locale);
1325 void tds_free_input_params(TDSDYNAMIC * dyn);
1326 void tds_release_dynamic(TDSDYNAMIC ** dyn);
1327 static inline
1328 void tds_release_cur_dyn(TDSSOCKET * tds)
1329 {
1331 }
1332 void tds_dynamic_deallocated(TDSCONNECTION *conn, TDSDYNAMIC *dyn);
1333 void tds_set_cur_dyn(TDSSOCKET *tds, TDSDYNAMIC *dyn);
1334 TDSSOCKET *tds_realloc_socket(TDSSOCKET * tds, size_t bufsize);
1335 char *tds_alloc_client_sqlstate(int msgno);
1336 char *tds_alloc_lookup_sqlstate(TDSSOCKET * tds, int msgno);
1337 TDSLOGIN *tds_alloc_login(int use_environment);
1338 TDSDYNAMIC *tds_alloc_dynamic(TDSCONNECTION * conn, const char *id);
1339 void tds_free_login(TDSLOGIN * login);
1340 TDSLOGIN *tds_init_login(TDSLOGIN * login, TDSLOCALE * locale);
1341 TDSLOCALE *tds_alloc_locale(void);
1342 void *tds_alloc_param_data(TDSCOLUMN * curparam);
1343 void tds_free_locale(TDSLOCALE * locale);
1344 TDSCURSOR * tds_alloc_cursor(TDSSOCKET * tds, const char *name, TDS_INT namelen, const char *query, TDS_INT querylen);
1345 void tds_free_row(TDSRESULTINFO * res_info, unsigned char *row);
1346 TDSSOCKET *tds_alloc_socket(TDSCONTEXT * context, unsigned int bufsize);
1347 TDSSOCKET *tds_alloc_additional_socket(TDSCONNECTION *conn);
1348 void tds_set_current_results(TDSSOCKET *tds, TDSRESULTINFO *info);
1349 void tds_detach_results(TDSRESULTINFO *info);
1350 void * tds_realloc(void **pp, size_t new_size);
1351 #define TDS_RESIZE(p, n_elem) \
1352  tds_realloc((void **) &(p), sizeof(*(p)) * (size_t) (n_elem))
1353 #define tds_new(type, n) ((type *) malloc(sizeof(type) * (n)))
1354 #define tds_new0(type, n) ((type *) calloc(n, sizeof(type)))
1355 
1356 TDSPACKET *tds_alloc_packet(void *buf, unsigned len);
1357 TDSPACKET *tds_realloc_packet(TDSPACKET *packet, unsigned len);
1358 void tds_free_packets(TDSPACKET *packet);
1359 TDSBCPINFO *tds_alloc_bcpinfo(void);
1360 void tds_free_bcpinfo(TDSBCPINFO *bcpinfo);
1361 void tds_deinit_bcpinfo(TDSBCPINFO *bcpinfo);
1362 
1363 
1364 /* login.c */
1365 void tds_set_packet(TDSLOGIN * tds_login, int packet_size);
1366 void tds_set_port(TDSLOGIN * tds_login, int port);
1367 bool tds_set_passwd(TDSLOGIN * tds_login, const char *password) TDS_WUR;
1368 void tds_set_bulk(TDSLOGIN * tds_login, TDS_TINYINT enabled);
1369 bool tds_set_user(TDSLOGIN * tds_login, const char *username) TDS_WUR;
1370 bool tds_set_app(TDSLOGIN * tds_login, const char *application) TDS_WUR;
1371 bool tds_set_host(TDSLOGIN * tds_login, const char *hostname) TDS_WUR;
1372 bool tds_set_library(TDSLOGIN * tds_login, const char *library) TDS_WUR;
1373 bool tds_set_server(TDSLOGIN * tds_login, const char *server) TDS_WUR;
1374 bool tds_set_client_charset(TDSLOGIN * tds_login, const char *charset) TDS_WUR;
1375 bool tds_set_language(TDSLOGIN * tds_login, const char *language) TDS_WUR;
1376 void tds_set_version(TDSLOGIN * tds_login, TDS_TINYINT major_ver, TDS_TINYINT minor_ver);
1377 int tds_connect_and_login(TDSSOCKET * tds, TDSLOGIN * login);
1378 
1379 
1380 /* query.c */
1381 void tds_start_query(TDSSOCKET *tds, unsigned char packet_type);
1382 
1383 TDSRET tds_submit_query(TDSSOCKET * tds, const char *query);
1384 TDSRET tds_submit_query_params(TDSSOCKET * tds, const char *query, TDSPARAMINFO * params, TDSHEADERS * head);
1385 TDSRET tds_submit_queryf(TDSSOCKET * tds, const char *queryf, ...);
1386 TDSRET tds_submit_prepare(TDSSOCKET * tds, const char *query, const char *id, TDSDYNAMIC ** dyn_out, TDSPARAMINFO * params);
1387 TDSRET tds_submit_execdirect(TDSSOCKET * tds, const char *query, TDSPARAMINFO * params, TDSHEADERS * head);
1388 TDSRET tds71_submit_prepexec(TDSSOCKET * tds, const char *query, const char *id, TDSDYNAMIC ** dyn_out, TDSPARAMINFO * params);
1389 TDSRET tds_submit_execute(TDSSOCKET * tds, TDSDYNAMIC * dyn);
1390 TDSRET tds_send_cancel(TDSSOCKET * tds);
1391 const char *tds_next_placeholder(const char *start);
1392 int tds_count_placeholders(const char *query);
1393 int tds_needs_unprepare(TDSCONNECTION * conn, TDSDYNAMIC * dyn);
1394 TDSRET tds_deferred_unprepare(TDSCONNECTION * conn, TDSDYNAMIC * dyn);
1395 TDSRET tds_submit_unprepare(TDSSOCKET * tds, TDSDYNAMIC * dyn);
1396 TDSRET tds_submit_rpc(TDSSOCKET * tds, const char *rpc_name, TDSPARAMINFO * params, TDSHEADERS * head);
1397 TDSRET tds_submit_optioncmd(TDSSOCKET * tds, TDS_OPTION_CMD command, TDS_OPTION option, TDS_OPTION_ARG *param, TDS_INT param_size);
1398 TDSRET tds_submit_begin_tran(TDSSOCKET *tds);
1399 TDSRET tds_submit_rollback(TDSSOCKET *tds, int cont);
1400 TDSRET tds_submit_commit(TDSSOCKET *tds, int cont);
1401 TDSRET tds_disconnect(TDSSOCKET * tds);
1402 size_t tds_quote_id(TDSSOCKET * tds, char *buffer, const char *id, int idlen);
1403 size_t tds_quote_string(TDSSOCKET * tds, char *buffer, const char *str, int len);
1404 const char *tds_skip_comment(const char *s);
1405 const char *tds_skip_quoted(const char *s);
1406 size_t tds_fix_column_size(TDSSOCKET * tds, TDSCOLUMN * curcol);
1407 const char *tds_convert_string(TDSSOCKET * tds, TDSICONV * char_conv, const char *s, int len, size_t *out_len);
1408 void tds_convert_string_free(const char *original, const char *converted);
1409 #if !ENABLE_EXTRA_CHECKS
1410 #define tds_convert_string_free(original, converted) \
1411  do { if (original != converted) free((char*) converted); } while(0)
1412 #endif
1413 TDSRET tds_get_column_declaration(TDSSOCKET * tds, TDSCOLUMN * curcol, char *out);
1414 
1415 TDSRET tds_cursor_declare(TDSSOCKET * tds, TDSCURSOR * cursor, TDSPARAMINFO *params, int *send);
1416 TDSRET tds_cursor_setrows(TDSSOCKET * tds, TDSCURSOR * cursor, int *send);
1417 TDSRET tds_cursor_open(TDSSOCKET * tds, TDSCURSOR * cursor, TDSPARAMINFO *params, int *send);
1418 TDSRET tds_cursor_fetch(TDSSOCKET * tds, TDSCURSOR * cursor, TDS_CURSOR_FETCH fetch_type, TDS_INT i_row);
1419 TDSRET tds_cursor_get_cursor_info(TDSSOCKET * tds, TDSCURSOR * cursor, TDS_UINT * row_number, TDS_UINT * row_count);
1420 TDSRET tds_cursor_close(TDSSOCKET * tds, TDSCURSOR * cursor);
1421 TDSRET tds_cursor_dealloc(TDSSOCKET * tds, TDSCURSOR * cursor);
1422 TDSRET tds_deferred_cursor_dealloc(TDSCONNECTION *conn, TDSCURSOR * cursor);
1423 TDSRET tds_cursor_update(TDSSOCKET * tds, TDSCURSOR * cursor, TDS_CURSOR_OPERATION op, TDS_INT i_row, TDSPARAMINFO * params);
1424 TDSRET tds_cursor_setname(TDSSOCKET * tds, TDSCURSOR * cursor);
1425 
1426 TDSRET tds_multiple_init(TDSSOCKET *tds, TDSMULTIPLE *multiple, TDS_MULTIPLE_TYPE type, TDSHEADERS * head);
1427 TDSRET tds_multiple_done(TDSSOCKET *tds, TDSMULTIPLE *multiple);
1428 TDSRET tds_multiple_query(TDSSOCKET *tds, TDSMULTIPLE *multiple, const char *query, TDSPARAMINFO * params);
1429 TDSRET tds_multiple_execute(TDSSOCKET *tds, TDSMULTIPLE *multiple, TDSDYNAMIC * dyn);
1430 
1431 
1432 /* token.c */
1433 TDSRET tds_process_cancel(TDSSOCKET * tds);
1434 int tds_get_token_size(int marker);
1435 TDSRET tds_process_login_tokens(TDSSOCKET * tds);
1436 TDSRET tds_process_simple_query(TDSSOCKET * tds);
1437 int tds5_send_optioncmd(TDSSOCKET * tds, TDS_OPTION_CMD tds_command, TDS_OPTION tds_option, TDS_OPTION_ARG * tds_argument,
1438  TDS_INT * tds_argsize);
1439 TDSRET tds_process_tokens(TDSSOCKET * tds, /*@out@*/ TDS_INT * result_type, /*@out@*/ int *done_flags, unsigned flag);
1440 int determine_adjusted_size(const TDSICONV * char_conv, int size);
1441 
1442 
1443 /* data.c */
1444 void tds_set_param_type(TDSCONNECTION * conn, TDSCOLUMN * curcol, TDS_SERVER_TYPE type);
1445 void tds_set_column_type(TDSCONNECTION * conn, TDSCOLUMN * curcol, TDS_SERVER_TYPE type);
1446 
1447 
1448 /* tds_convert.c */
1449 TDSRET tds_datecrack(TDS_INT datetype, const void *di, TDSDATEREC * dr);
1450 TDS_SERVER_TYPE tds_get_conversion_type(TDS_SERVER_TYPE srctype, int colsize);
1451 extern const char tds_hex_digits[];
1452 
1453 
1454 /* write.c */
1455 int tds_init_write_buf(TDSSOCKET * tds);
1456 int tds_put_n(TDSSOCKET * tds, const void *buf, size_t n);
1457 int tds_put_string(TDSSOCKET * tds, const char *buf, int len);
1458 int tds_put_int(TDSSOCKET * tds, TDS_INT i);
1459 int tds_put_int8(TDSSOCKET * tds, TDS_INT8 i);
1460 int tds_put_smallint(TDSSOCKET * tds, TDS_SMALLINT si);
1462 #define tds_put_tinyint(tds, ti) tds_put_byte(tds,ti)
1463 int tds_put_byte(TDSSOCKET * tds, unsigned char c);
1464 TDSRET tds_flush_packet(TDSSOCKET * tds);
1465 int tds_put_buf(TDSSOCKET * tds, const unsigned char *buf, int dsize, int ssize);
1466 
1467 
1468 /* read.c */
1469 unsigned char tds_get_byte(TDSSOCKET * tds);
1470 void tds_unget_byte(TDSSOCKET * tds);
1471 unsigned char tds_peek(TDSSOCKET * tds);
1472 TDS_USMALLINT tds_get_usmallint(TDSSOCKET * tds);
1473 #define tds_get_smallint(tds) ((TDS_SMALLINT) tds_get_usmallint(tds))
1474 TDS_UINT tds_get_uint(TDSSOCKET * tds);
1475 #define tds_get_int(tds) ((TDS_INT) tds_get_uint(tds))
1476 TDS_UINT8 tds_get_uint8(TDSSOCKET * tds);
1477 #define tds_get_int8(tds) ((TDS_INT8) tds_get_uint8(tds))
1478 size_t tds_get_string(TDSSOCKET * tds, size_t string_len, char *dest, size_t dest_size);
1479 TDSRET tds_get_char_data(TDSSOCKET * tds, char *dest, size_t wire_size, TDSCOLUMN * curcol);
1480 void *tds_get_n(TDSSOCKET * tds, /*@out@*/ /*@null@*/ void *dest, size_t n);
1481 int tds_get_size_by_type(TDS_SERVER_TYPE servertype);
1482 DSTR* tds_dstr_get(TDSSOCKET * tds, DSTR * s, size_t len);
1483 
1484 
1485 /* util.c */
1486 int tdserror (const TDSCONTEXT * tds_ctx, TDSSOCKET * tds, int msgno, int errnum);
1488 void tds_swap_bytes(void *buf, int bytes);
1489 #ifdef ENABLE_DEVELOPING
1490 unsigned int tds_gettime_ms(void);
1491 #endif
1492 char *tds_strndup(const void *s, TDS_INTPTR len);
1493 
1494 
1495 /* log.c */
1496 void tdsdump_off(void);
1497 void tdsdump_on(void);
1498 int tdsdump_isopen(void);
1499 #include <freetds/popvis.h>
1500 int tdsdump_open(const char *filename);
1501 #include <freetds/pushvis.h>
1502 void tdsdump_close(void);
1503 void tdsdump_dump_buf(const char* file, unsigned int level_line, const char *msg, const void *buf, size_t length);
1504 void tdsdump_col(const TDSCOLUMN *col);
1505 #undef tdsdump_log
1506 void tdsdump_log(const char* file, unsigned int level_line, const char *fmt, ...)
1507 #if defined(__GNUC__) && __GNUC__ >= 2
1508 #if defined(__MINGW32__)
1509  __attribute__ ((__format__ (ms_printf, 3, 4)))
1510 #else
1511  __attribute__ ((__format__ (__printf__, 3, 4)))
1512 #endif
1513 #endif
1514 ;
1515 #define TDSDUMP_LOG_FAST if (TDS_UNLIKELY(tds_write_dump)) tdsdump_log
1516 #define tdsdump_log TDSDUMP_LOG_FAST
1517 #define TDSDUMP_BUF_FAST if (TDS_UNLIKELY(tds_write_dump)) tdsdump_dump_buf
1518 #define tdsdump_dump_buf TDSDUMP_BUF_FAST
1519 
1520 extern int tds_write_dump;
1521 extern int tds_debug_flags;
1522 extern int tds_g_append_mode;
1523 
1524 
1525 /* net.c */
1526 TDSERRNO tds_open_socket(TDSSOCKET * tds, struct addrinfo *ipaddr, unsigned int port, int timeout, int *p_oserr);
1527 void tds_close_socket(TDSSOCKET * tds);
1528 int tds7_get_instance_ports(FILE *output, struct addrinfo *addr);
1529 int tds7_get_instance_port(struct addrinfo *addr, const char *instance);
1530 char *tds_prwsaerror(int erc);
1531 void tds_prwsaerror_free(char *s);
1532 int tds_connection_read(TDSSOCKET * tds, unsigned char *buf, int buflen);
1533 int tds_connection_write(TDSSOCKET *tds, const unsigned char *buf, int buflen, int final);
1534 #define TDSSELREAD POLLIN
1535 #define TDSSELWRITE POLLOUT
1536 int tds_select(TDSSOCKET * tds, unsigned tds_sel, int timeout_seconds);
1537 void tds_connection_close(TDSCONNECTION *conn);
1538 int tds_goodread(TDSSOCKET * tds, unsigned char *buf, int buflen);
1539 int tds_goodwrite(TDSSOCKET * tds, const unsigned char *buffer, size_t buflen);
1540 void tds_socket_flush(TDS_SYS_SOCKET sock);
1541 int tds_socket_set_nonblocking(TDS_SYS_SOCKET sock);
1542 int tds_wakeup_init(TDSPOLLWAKEUP *wakeup);
1543 void tds_wakeup_close(TDSPOLLWAKEUP *wakeup);
1544 void tds_wakeup_send(TDSPOLLWAKEUP *wakeup, char cancel);
1545 static inline TDS_SYS_SOCKET tds_wakeup_get_fd(const TDSPOLLWAKEUP *wakeup)
1546 {
1547  return wakeup->s_signaled;
1548 }
1549 
1550 
1551 /* packet.c */
1552 int tds_read_packet(TDSSOCKET * tds);
1553 TDSRET tds_write_packet(TDSSOCKET * tds, unsigned char final);
1554 #if ENABLE_ODBC_MARS
1555 int tds_append_cancel(TDSSOCKET *tds);
1556 TDSRET tds_append_fin(TDSSOCKET *tds);
1557 #else
1558 int tds_put_cancel(TDSSOCKET * tds);
1559 #endif
1560 
1561 
1562 /* vstrbuild.c */
1563 TDSRET tds_vstrbuild(char *buffer, int buflen, int *resultlen, const char *text, int textlen, const char *formats, int formatlen,
1564  va_list ap);
1565 
1566 
1567 /* numeric.c */
1568 char *tds_money_to_string(const TDS_MONEY * money, char *s);
1569 TDS_INT tds_numeric_to_string(const TDS_NUMERIC * numeric, char *s);
1570 TDS_INT tds_numeric_change_prec_scale(TDS_NUMERIC * numeric, unsigned char new_prec, unsigned char new_scale);
1571 
1572 
1573 /* getmac.c */
1574 void tds_getmac(TDS_SYS_SOCKET s, unsigned char mac[6]);
1575 
1576 
1577 /* challenge.c */
1578 #ifndef HAVE_SSPI
1580 TDSAUTHENTICATION * tds_gss_get_auth(TDSSOCKET * tds);
1581 #else
1582 TDSAUTHENTICATION * tds_sspi_get_auth(TDSSOCKET * tds);
1583 #endif
1584 
1585 
1586 /* random.c */
1587 void tds_random_buffer(unsigned char *out, int len);
1588 
1589 
1590 /* sec_negotiate.c */
1591 TDSAUTHENTICATION * tds5_negotiate_get_auth(TDSSOCKET * tds);
1592 void tds5_negotiate_set_msg_type(TDSSOCKET * tds, TDSAUTHENTICATION * auth, unsigned msg_type);
1593 
1594 
1595 /* bulk.c */
1596 
1599 {
1600  TDS_BCP_IN = 1,
1601  TDS_BCP_OUT = 2,
1602  TDS_BCP_QUERYOUT = 3
1603 };
1604 
1606 {
1607  const char *hint;
1608  void *parent;
1609  DSTR tablename;
1610  TDS_CHAR *insert_stmt;
1611  TDS_INT direction;
1612  TDS_INT identity_insert_on;
1613  TDS_INT xfer_init;
1614  TDS_INT bind_count;
1615  TDSRESULTINFO *bindinfo;
1616 };
1617 
1618 TDSRET tds_bcp_init(TDSSOCKET *tds, TDSBCPINFO *bcpinfo);
1619 typedef TDSRET (*tds_bcp_get_col_data) (TDSBCPINFO *bulk, TDSCOLUMN *bcpcol, int offset);
1620 typedef void (*tds_bcp_null_error) (TDSBCPINFO *bulk, int index, int offset);
1621 TDSRET tds_bcp_send_record(TDSSOCKET *tds, TDSBCPINFO *bcpinfo, tds_bcp_get_col_data get_col_data, tds_bcp_null_error null_error, int offset);
1622 TDSRET tds_bcp_done(TDSSOCKET *tds, int *rows_copied);
1623 TDSRET tds_bcp_start(TDSSOCKET *tds, TDSBCPINFO *bcpinfo);
1624 TDSRET tds_bcp_start_copy_in(TDSSOCKET *tds, TDSBCPINFO *bcpinfo);
1625 
1626 TDSRET tds_bcp_fread(TDSSOCKET * tds, TDSICONV * conv, FILE * stream,
1627  const char *terminator, size_t term_len, char **outbuf, size_t * outbytes);
1628 
1629 TDSRET tds_writetext_start(TDSSOCKET *tds, const char *objname, const char *textptr, const char *timestamp, int with_log, TDS_UINT size);
1630 TDSRET tds_writetext_continue(TDSSOCKET *tds, const TDS_UCHAR *text, TDS_UINT size);
1631 TDSRET tds_writetext_end(TDSSOCKET *tds);
1632 
1633 
1634 static inline
1635 bool tds_capability_enabled(const TDS_CAPABILITY_TYPE *cap, unsigned cap_num)
1636 {
1637  return (cap->values[sizeof(cap->values)-1-(cap_num>>3)] >> (cap_num&7)) & 1;
1638 }
1639 #define tds_capability_has_req(conn, cap) \
1640  tds_capability_enabled(&conn->capabilities.types[0], cap)
1641 
1642 #define IS_TDS42(x) (x->tds_version==0x402)
1643 #define IS_TDS46(x) (x->tds_version==0x406)
1644 #define IS_TDS50(x) (x->tds_version==0x500)
1645 #define IS_TDS70(x) (x->tds_version==0x700)
1646 #define IS_TDS71(x) (x->tds_version==0x701)
1647 #define IS_TDS72(x) (x->tds_version==0x702)
1648 #define IS_TDS73(x) (x->tds_version==0x703)
1649 
1650 #define IS_TDS50_PLUS(x) ((x)->tds_version>=0x500)
1651 #define IS_TDS7_PLUS(x) ((x)->tds_version>=0x700)
1652 #define IS_TDS71_PLUS(x) ((x)->tds_version>=0x701)
1653 #define IS_TDS72_PLUS(x) ((x)->tds_version>=0x702)
1654 #define IS_TDS73_PLUS(x) ((x)->tds_version>=0x703)
1655 #define IS_TDS74_PLUS(x) ((x)->tds_version>=0x704)
1656 
1657 #define TDS_MAJOR(x) ((x)->tds_version >> 8)
1658 #define TDS_MINOR(x) ((x)->tds_version & 0xff)
1659 
1660 #define IS_TDSDEAD(x) (((x) == NULL) || (x)->state == TDS_DEAD)
1661 
1663 #define TDS_IS_SYBASE(x) (!((x)->conn->product_version & 0x80000000u))
1664 
1665 #define TDS_IS_MSSQL(x) (((x)->conn->product_version & 0x80000000u)!=0)
1666 
1670 #define TDS_MS_VER(maj,min,x) (0x80000000u|((maj)<<24)|((min)<<16)|(x))
1671 
1672 /* TODO test if not similar to ms one*/
1674 #define TDS_SYB_VER(maj,min,x) (((maj)<<24)|((min)<<16)|(x)<<8)
1675 
1676 #ifdef __cplusplus
1677 #if 0
1678 {
1679 #endif
1680 }
1681 #endif
1682 
1683 #include <freetds/popvis.h>
1684 
1685 #define TDS_PUT_INT(tds,v) tds_put_int((tds), ((TDS_INT)(v)))
1686 #define TDS_PUT_SMALLINT(tds,v) tds_put_smallint((tds), ((TDS_SMALLINT)(v)))
1687 #define TDS_PUT_BYTE(tds,v) tds_put_byte((tds), ((unsigned char)(v)))
1688 
1689 #endif /* _tds_h_ */
Definition: tds.h:940
TDSICONV * tds_iconv_from_collate(TDSCONNECTION *conn, TDS_UCHAR collate[5])
Get iconv information from a LCID (to support different column encoding under MSSQL2K) ...
Definition: iconv.c:1202
int tds_goodwrite(TDSSOCKET *tds, const unsigned char *buffer, size_t buflen)
Definition: net.c:821
TDSRET tds_datecrack(TDS_INT datetype, const void *di, TDSDATEREC *dr)
Convert from db date format to a structured date format.
Definition: convert.c:3121
const int tds_numeric_bytes_per_prec[]
The following little table is indexed by precision and will tell us the number of bytes required to s...
Definition: numeric.c:41
char * tds_timestamp_str(char *str, int maxlen)
Definition: threadsafe.c:101
TDSRET tds_send_cancel(TDSSOCKET *tds)
tds_send_cancel() sends an empty packet (8 byte header only) tds_process_cancel should be called dire...
Definition: query.c:2129
TDSRET tds_bcp_start(TDSSOCKET *tds, TDSBCPINFO *bcpinfo)
Start sending BCP data to server.
Definition: bulk.c:815
int tds_read_conf_file(TDSLOGIN *login, const char *server)
Read configuration info for given server return 0 on error.
Definition: config.c:342
int tds_read_conf_section(FILE *in, const char *section, TDSCONFPARSE tds_conf_parse, void *parse_param)
Read a section of configuration file (INI style file)
Definition: config.c:499
unsigned char * out_buf
Output buffer.
Definition: tds.h:1194
TDSRET tds_flush_packet(TDSSOCKET *tds)
Flush packet to server.
Definition: write.c:285
TDSRET tds_submit_unprepare(TDSSOCKET *tds, TDSDYNAMIC *dyn)
Send a unprepare request for a prepared query.
Definition: query.c:1891
int tds_goodread(TDSSOCKET *tds, unsigned char *buf, int buflen)
Loops until we have received some characters return -1 on failure.
Definition: net.c:750
void tds_fix_login(TDSLOGIN *login)
Fix configuration after reading it.
Definition: config.c:281
volatile unsigned char in_cancel
indicate we are waiting a cancel reply; discard tokens till acknowledge; 1 mean we have to send cance...
Definition: tds.h:1239
Definition: tds.h:543
TDSRET tds_writetext_continue(TDSSOCKET *tds, const TDS_UCHAR *text, TDS_UINT size)
Send some data in the writetext request started by tds_writetext_start.
Definition: bulk.c:1131
TDSRET tds_deferred_cursor_dealloc(TDSCONNECTION *conn, TDSCURSOR *cursor)
Deallocate cursor on idle.
Definition: query.c:3136
TDSRET tds_get_column_declaration(TDSSOCKET *tds, TDSCOLUMN *curcol, char *out)
Return declaration for column (like "varchar(20)")
Definition: query.c:729
Definition: tds.h:1605
Definition: tds.h:325
char * query
saved query, we need to know original query if prepare is impossible
Definition: tds.h:1044
TDS_INT type
row fetched from this cursor
Definition: tds.h:991
TDSRET tds_submit_prepare(TDSSOCKET *tds, const char *query, const char *id, TDSDYNAMIC **dyn_out, TDSPARAMINFO *params)
tds_submit_prepare() creates a temporary stored procedure in the server.
Definition: query.c:1173
void tds_set_column_type(TDSCONNECTION *conn, TDSCOLUMN *curcol, TDS_SERVER_TYPE type)
Set type of column initializing all dependency.
Definition: data.c:225
Definition: tds.h:1096
Structure to hold a string.
Definition: tds.h:94
unsigned in_len
input buffer length
Definition: tds.h:1203
void tds_set_param_type(TDSCONNECTION *conn, TDSCOLUMN *curcol, TDS_SERVER_TYPE type)
Set type of column initializing all dependency.
Definition: data.c:247
int tds_count_placeholders(const char *query)
Count the number of placeholders in query.
Definition: query.c:590
TDSRET tds_bcp_start_copy_in(TDSSOCKET *tds, TDSBCPINFO *bcpinfo)
Start bulk copy to server.
Definition: bulk.c:862
Definition: tds.h:1063
char * charset
character set encoding
Definition: tds.h:1003
struct tds_cursor * next
next in linked list, keep first
Definition: tds.h:973
const char * tds_convert_string(TDSSOCKET *tds, TDSICONV *char_conv, const char *s, int len, size_t *out_len)
Convert a string in an allocated buffer.
Definition: query.c:123
tds_states
values for tds->state
Definition: tds.h:823
TDS_INT column_size
maximun size of data.
Definition: tds.h:732
void tds_close_socket(TDSSOCKET *tds)
Close current socket.
Definition: net.c:384
TDSRET tds_submit_execdirect(TDSSOCKET *tds, const char *query, TDSPARAMINFO *params, TDSHEADERS *head)
Submit a prepared query with parameters.
Definition: query.c:1312
int tdserror(const TDSCONTEXT *tds_ctx, TDSSOCKET *tds, int msgno, int errnum)
Call the client library&#39;s error handler (for library-generated errors only)
Definition: util.c:310
TDS_INT tds_numeric_to_string(const TDS_NUMERIC *numeric, char *s)
Definition: numeric.c:94
TDS_INT minute
0-59
Definition: tds.h:166
int block_size
packet size (512-65535)
Definition: tds.h:1000
error occurred
Definition: tds.h:250
size_t tds_get_string(TDSSOCKET *tds, size_t string_len, char *dest, size_t dest_size)
Fetch a string from the wire.
Definition: read.c:184
struct addrinfo * tds_lookup_host(const char *servername)
Get the IP address for a hostname.
Definition: config.c:960
int tds7_get_instance_port(struct addrinfo *addr, const char *instance)
Get port of given instance.
Definition: net.c:1063
const char * tds_skip_comment(const char *s)
Skip a comment in a query.
Definition: query.c:509
Definition: tds.h:536
Information for a server connection.
Definition: tds.h:1174
struct tds_result_info TDSRESULTINFO
Hold information for any results.
TDS_INT8 rows_affected
rows updated/deleted/inserted/selected, TDS_NO_COUNT if not valid
Definition: tds.h:1242
size_t tds_quote_string(TDSSOCKET *tds, char *buffer, const char *str, int len)
Quote a string.
Definition: query.c:2316
unsigned char out_flag
output buffer type
Definition: tds.h:1205
struct tds_variant TDSVARIANT
Store variant informations.
TDSRET tds_bcp_fread(TDSSOCKET *tds, TDSICONV *conv, FILE *stream, const char *terminator, size_t term_len, char **outbuf, size_t *outbytes)
Read a data file, passing the data through iconv().
Definition: bulk.c:1023
TDSRET tds_process_cancel(TDSSOCKET *tds)
Definition: token.c:2513
TDSRET tds71_submit_prepexec(TDSSOCKET *tds, const char *query, const char *id, TDSDYNAMIC **dyn_out, TDSPARAMINFO *params)
tds71_submit_prepexec() creates a temporary stored procedure in the server.
Definition: query.c:1463
unsigned char in_flag
input buffer type
Definition: tds.h:1204
void tdsdump_off(void)
Temporarily turn off logging.
Definition: log.c:75
int tds_get_token_size(int marker)
tds_get_token_size() returns the size of a fixed length token used by tds_process_cancel() to determi...
Definition: token.c:2716
void tds_detach_results(TDSRESULTINFO *info)
Detach result info from it current socket.
Definition: mem.c:485
TDS_STATE tds_set_state(TDSSOCKET *tds, TDS_STATE state)
Set state of TDS connection, with logging and checking.
Definition: util.c:58
void tds_free_param_result(TDSPARAMINFO *param_info)
Delete latest parameter.
Definition: mem.c:317
TDSRET tds_cursor_dealloc(TDSSOCKET *tds, TDSCURSOR *cursor)
Send a deallocation request to server.
Definition: query.c:3085
no connection
Definition: tds.h:830
int tds_iconv_alloc(TDSCONNECTION *conn)
Allocate iconv stuff.
Definition: iconv.c:265
Definition: tds.h:549
TDSRET tds_submit_execute(TDSSOCKET *tds, TDSDYNAMIC *dyn)
tds_submit_execute() sends a previously prepared dynamic statement to the server. ...
Definition: query.c:1733
char * query
SQL query.
Definition: tds.h:982
final result set, command completed successfully.
Definition: tds.h:248
TDSPARAMINFO * params
query parameters.
Definition: tds.h:1042
TDS_INT num_id
numeric id for mssql7+
Definition: tds.h:1016
TDS_UINT8 time
time, 7 digit precision
Definition: tds.h:146
TDSLOGIN * login
config for login stuff.
Definition: tds.h:1247
int tdsdump_open(const char *filename)
Create and truncate a human readable dump file for the TDS traffic.
Definition: log.c:111
int tds_getservice(const char *name)
Return service port given the name.
Definition: threadsafe.c:343
TDSPARAMINFO * res_info
query results
Definition: tds.h:1034
DSTR password
password of account login
Definition: tds.h:568
unsigned char canonic
internal numeric index into array of all encodings
Definition: tds.h:655
TDSRET tds_deferred_unprepare(TDSCONNECTION *conn, TDSDYNAMIC *dyn)
Unprepare dynamic on idle.
Definition: query.c:1868
const char * tds_skip_quoted(const char *s)
Skip quoting string (like &#39;sfsf&#39;, "dflkdj" or [dfkjd])
Definition: query.c:534
TDSRESULTINFO * current_results
Current query information.
Definition: tds.h:1227
struct tds_dstr * DSTR
Structure to hold a string.
size_t tds_quote_id(TDSSOCKET *tds, char *buffer, const char *id, int idlen)
Quote an id.
Definition: query.c:2272
int tds_get_varint_size(TDSCONNECTION *conn, int datatype)
tds_get_varint_size() returns the size of a variable length integer returned in a TDS 7...
Definition: tds_types.h:57
unsigned char * in_buf
Input buffer.
Definition: tds.h:1187
TDS_INT year
year
Definition: tds.h:159
TDS_INT dayofyear
day of year (1-366)
Definition: tds.h:163
count field in packet is valid
Definition: tds.h:253
Information relevant to libiconv.
Definition: tds.h:648
unsigned char tds_peek(TDSSOCKET *tds)
Reads a byte from the TDS stream without removing it.
Definition: read.c:100
void tds_release_dynamic(TDSDYNAMIC **dyn)
Frees dynamic statement.
Definition: mem.c:250
cilent is waiting for data
Definition: tds.h:828
TDS_UINT product_version
version of product (Sybase/MS and full version)
Definition: tds.h:1105
acknowledging an attention command (usually a cancel)
Definition: tds.h:254
TDSRET tds_process_simple_query(TDSSOCKET *tds)
Process results for simple query as "SET TEXTSIZE" or "USE dbname" If the statement returns results...
Definition: token.c:855
DSTR user_name
account for login
Definition: tds.h:567
TDSRET tds_submit_query(TDSSOCKET *tds, const char *query)
tds_submit_query() sends a language string to the database server for processing. ...
Definition: query.c:205
TDSRET tds_writetext_end(TDSSOCKET *tds)
Finish sending writetext data.
Definition: bulk.c:1148
TDSRET tds_set_interfaces_file_loc(const char *interfloc)
Set the full name of interface file.
Definition: config.c:934
DSTR server_realm_name
server realm name (in freetds.conf)
Definition: tds.h:560
char * database
database name
Definition: tds.h:1005
TDS_SERVER_TYPE column_type
This type can be different from wire type because conversion (e.g.
Definition: tds.h:734
TDS_TINYINT column_scale
scale for decimal/numeric
Definition: tds.h:742
TDS_USMALLINT * tds_config_verstr(const char *tdsver, TDSLOGIN *login)
Set TDS version from given string.
Definition: config.c:891
void tds_set_cur_dyn(TDSSOCKET *tds, TDSDYNAMIC *dyn)
Set current dynamic.
Definition: query.c:187
void tdsdump_col(const TDSCOLUMN *col)
Write a column value to the debug log.
Definition: log.c:407
TDSLOCALE * tds_get_locale(void)
Get locale information.
Definition: locale.c:50
TDSRET tds_submit_begin_tran(TDSSOCKET *tds)
Send a rollback request.
Definition: query.c:3705
void tds_start_query(TDSSOCKET *tds, unsigned char packet_type)
Start query packet of a given type.
Definition: query.c:343
void tds_free_input_params(TDSDYNAMIC *dyn)
Frees all allocated input parameters of a dynamic statement.
Definition: mem.c:203
void tdsdump_on(void)
Turn logging back on.
Definition: log.c:87
TDS_USMALLINT tds_version
TDS version.
Definition: tds.h:553
Hold information for any results.
Definition: tds.h:803
size_t tds_fix_column_size(TDSSOCKET *tds, TDSCOLUMN *curcol)
Get column size for wire.
Definition: query.c:1558
TDSPARAMINFO * tds_alloc_param_result(TDSPARAMINFO *old_param)
Adds a output parameter to TDSPARAMINFO.
Definition: mem.c:281
more results follow
Definition: tds.h:249
TDS_INT ref_count
reference counter so client can retain safely a pointer
Definition: tds.h:1014
struct tds_dynamic * next
next in linked list, keep first
Definition: tds.h:1013
TDS_SMALLINT offset
time offset
Definition: tds.h:148
struct tds_compiletime_settings TDS_COMPILETIME_SETTINGS
A structure to hold all the compile-time settings.
TDSRET tds_bcp_done(TDSSOCKET *tds, int *rows_copied)
Tell we finished sending BCP data to server.
Definition: bulk.c:785
bool tds_set_server(TDSLOGIN *tds_login, const char *server) TDS_WUR
Set the servername in a TDSLOGIN structure.
Definition: login.c:122
TDS_INT day
day of month (1-31)
Definition: tds.h:162
struct tds_env TDSENV
Current environment as reported by the server.
DSTR cafile
certificate authorities file
Definition: tds.h:563
TDSRET tds_submit_optioncmd(TDSSOCKET *tds, TDS_OPTION_CMD command, TDS_OPTION option, TDS_OPTION_ARG *param, TDS_INT param_size)
Send option commands to server.
Definition: query.c:3422
no data expected
Definition: tds.h:825
TDS_TINYINT has_status
true is ret_status is valid
Definition: tds.h:1234
TDSDYNAMIC * tds_alloc_dynamic(TDSCONNECTION *conn, const char *id)
Allocate a dynamic statement.
Definition: mem.c:157
DSTR server_name
server name (in freetds.conf)
Definition: tds.h:551
TDSDYNAMIC * dyns
list of dynamic allocated for this connection contains only dynamic allocated on the server ...
Definition: tds.h:1124
client is reading data
Definition: tds.h:829
TDSICONV * char_conv
refers to previously allocated iconv information
Definition: tds.h:750
int determine_adjusted_size(const TDSICONV *char_conv, int size)
Allow for maximum possible size of converted data, while being careful about integer division truncat...
Definition: token.c:3249
TDSRET tds_submit_rpc(TDSSOCKET *tds, const char *rpc_name, TDSPARAMINFO *params, TDSHEADERS *head)
tds_submit_rpc() call a RPC from server.
Definition: query.c:2025
TDSAUTHENTICATION * tds_ntlm_get_auth(TDSSOCKET *tds)
Build a NTLMSPP packet to send to server.
Definition: challenge.c:690
void * tds_get_n(TDSSOCKET *tds, void *dest, size_t n)
Get N bytes from the buffer and return them in the already allocated space given to us...
Definition: read.c:248
Definition: tds.h:612
TDS_INT month
month number (0-11)
Definition: tds.h:161
struct tds_dynamic TDSDYNAMIC
Holds information for a dynamic (also called prepared) query.
DSTR new_password
new password to set (TDS 7.2+)
Definition: tds.h:569
Current environment as reported by the server.
Definition: tds.h:997
TDS_INT decimicrosecond
0-9999999
Definition: tds.h:168
const char * tds_next_placeholder(const char *start)
Get position of next placeholder.
Definition: query.c:554
TDS_CURSOR_STATUS status
cursor parameter
Definition: tds.h:988
unsigned char tds_get_byte(TDSSOCKET *tds)
Return a single byte from the input buffer.
Definition: read.c:72
void tdsdump_close(void)
Close the TDS dump log file.
Definition: log.c:192
struct tds_blob TDSBLOB
Information about blobs (e.g.
TDSPACKET * send_packet
packet we are preparing to send
Definition: tds.h:1220
TDS_TINYINT defer_close
true if cursor was marker to be closed when connection is idle
Definition: tds.h:981
const char * tds_prtype(int token)
Returns string representation of the given type.
Definition: token.c:3021
struct addrinfo * ip_addrs
ip(s) of server
Definition: tds.h:579
const char * name
name of the encoding (ie UTF-8)
Definition: tds.h:651
TDS_USMALLINT tds_get_usmallint(TDSSOCKET *tds)
Get an int16 from the server.
Definition: read.c:113
TDSENV env
environment is shared between all sessions
Definition: tds.h:1113
TDS_INT date
date, 0 = 1900-01-01
Definition: tds.h:147
void * tds_alloc_param_data(TDSCOLUMN *curparam)
Allocate data for a parameter.
Definition: mem.c:361
int tds_needs_unprepare(TDSCONNECTION *conn, TDSDYNAMIC *dyn)
Check if dynamic request must be unprepared.
Definition: query.c:1846
TDSRET tds_writetext_start(TDSSOCKET *tds, const char *objname, const char *textptr, const char *timestamp, int with_log, TDS_UINT size)
Start writing writetext request.
Definition: bulk.c:1093
Definition: tds.h:674
TDSRET tds_bcp_send_record(TDSSOCKET *tds, TDSBCPINFO *bcpinfo, tds_bcp_get_col_data get_col_data, tds_bcp_null_error null_error, int offset)
Send one row of data to server.
Definition: bulk.c:334
Used by tds_datecrack.
Definition: tds.h:157
Definition: tds.h:1088
char * cursor_name
name of the cursor
Definition: tds.h:975
Store variant informations.
Definition: tds.h:634
TDSRET tds_submit_commit(TDSSOCKET *tds, int cont)
Send a commit request.
Definition: query.c:3764
Definition: proto.h:25
TDSRET tds_process_tokens(TDSSOCKET *tds, TDS_INT *result_type, int *done_flags, unsigned flag)
process all streams.
Definition: token.c:508
Definition: thread.h:255
Definition: tds.h:604
TDS_INT cursor_id
cursor id returned by the server after cursor declare
Definition: tds.h:976
SQL server server error.
Definition: tds.h:256
tds_bcp_directions
bcp direction
Definition: tds.h:1598
TDS_TINYINT options
read only|updatable TODO use it
Definition: tds.h:977
struct tds_encoding TDS_ENCODING
Information relevant to libiconv.
TDS_TINYINT emulated
this dynamic query cannot be prepared so libTDS have to construct a simple query. ...
Definition: tds.h:1028
int tds_write_dump
Tell if TDS debug logging is turned on or off.
Definition: log.c:57
tds_end
Flags returned in TDS_DONE token.
Definition: tds.h:246
TDSDYNAMIC * cur_dyn
dynamic structure in use
Definition: tds.h:1245
TDS_UINT8 tds_get_uint8(TDSSOCKET *tds)
Get an uint64 from the server.
Definition: read.c:148
TDS_SYS_SOCKET s
tcp socket, INVALID_SOCKET if not connected
Definition: tds.h:1108
int tds_get_size_by_type(TDS_SERVER_TYPE servertype)
Return the number of bytes needed by specified type.
Definition: tds_types.h:9
void tdsdump_log(const char *file, unsigned int level_line, const char *fmt,...)
Write a message to the debug log.
Definition: log.c:353
TDS_INT hour
0-23
Definition: tds.h:165
Definition: tds.h:926
TDS_TINYINT column_prec
precision for decimal/numeric
Definition: tds.h:741
TDS_INT timezone
-840 - 840 minutes from UTC
Definition: tds.h:169
char * tds_strndup(const void *s, TDS_INTPTR len)
Copy a string of length len to a new allocated buffer This function does not read more than len bytes...
Definition: util.c:397
TDS_TINYINT defer_close
true if dynamic was marker to be closed when connection is idle
Definition: tds.h:1032
TDSRET tds_submit_rollback(TDSSOCKET *tds, int cont)
Send a rollback request.
Definition: query.c:3733
Definition: iconv.h:91
int tds_select(TDSSOCKET *tds, unsigned tds_sel, int timeout_seconds)
Select on a socket until it&#39;s available or the timeout expires.
Definition: net.c:446
Definition: tds.h:658
TDSRET tds_submit_queryf(TDSSOCKET *tds, const char *queryf,...)
Format and submit a query.
Definition: query.c:486
int tds_read_packet(TDSSOCKET *tds)
Read in one &#39;packet&#39; from the server.
Definition: packet.c:530
client would send data
Definition: tds.h:827
TDSCURSOR * cur_cursor
cursor in use
Definition: tds.h:1232
Definition: proto.h:38
const TDS_COMPILETIME_SETTINGS * tds_get_compiletime_settings(void)
Return a structure capturing the compile-time settings provided to the configure script.
Definition: config.c:1310
unsigned out_pos
current position in out_buf
Definition: tds.h:1202
Information about blobs (e.g.
Definition: tds.h:623
DSTR crlfile
certificate revocation file
Definition: tds.h:564
int tds_put_string(TDSSOCKET *tds, const char *buf, int len)
Output a string to wire automatic translate string to unicode if needed.
Definition: write.c:93
TDSRET tds_submit_query_params(TDSSOCKET *tds, const char *query, TDSPARAMINFO *params, TDSHEADERS *head)
tds_submit_query_params() sends a language string to the database server for processing.
Definition: query.c:361
TDS_INT ret_status
return status from store procedure
Definition: tds.h:1236
DSTR db_filename
database filename to attach (MSSQL)
Definition: tds.h:562
bool in_row
true if we are getting rows
Definition: tds.h:1235
TDSRET tds_alloc_row(TDSRESULTINFO *res_info)
Allocate space for row store return NULL on out of memory.
Definition: mem.c:521
TDSCURSOR * cursors
linked list of cursors allocated for this connection contains only cursors allocated on the server ...
Definition: tds.h:1119
A structure to hold all the compile-time settings.
Definition: tds.h:72
client is writing data
Definition: tds.h:826
Definition: tds.h:1053
int port
port of database service
Definition: tds.h:552
unsigned int out_buf_max
Maximum size of packet pointed by out_buf.
Definition: tds.h:1200
void tds_unget_byte(TDSSOCKET *tds)
Unget will always work as long as you don&#39;t call it twice in a row.
Definition: read.c:89
void * tds_realloc(void **pp, size_t new_size)
Reallocate a pointer and update it if success.
Definition: mem.c:1815
transaction in progress
Definition: tds.h:251
TDSRET tds_get_char_data(TDSSOCKET *tds, char *dest, size_t wire_size, TDSCOLUMN *curcol)
Fetch character data the wire.
Definition: read.c:213
TDSDYNAMIC * tds_lookup_dynamic(TDSCONNECTION *conn, const char *id)
Finds a dynamic given string id.
Definition: token.c:2546
TDS_INT quarter
quarter (0-3)
Definition: tds.h:160
Holds informations about a cursor.
Definition: tds.h:971
int tds_socket_set_nonblocking(TDS_SYS_SOCKET sock)
Set socket to non-blocking.
Definition: net.c:164
DSTR * tds_dstr_get(TDSSOCKET *tds, DSTR *s, size_t len)
Reads a string from wire and put in a DSTR.
Definition: read.c:311
char * tds_get_homedir(void)
Get user home directory.
Definition: threadsafe.c:411
struct tdsdaterec TDSDATEREC
Used by tds_datecrack.
TDSLOGIN * tds_init_login(TDSLOGIN *login, TDSLOCALE *locale)
Initialize login structure with locale information and other stuff for connection.
Definition: mem.c:796
Definition: tds.h:910
DSTR server_spn
server SPN (in freetds.conf)
Definition: tds.h:561
unsigned in_pos
current position in in_buf
Definition: tds.h:1201
TDS_INT second
0-59
Definition: tds.h:167
Metadata about columns in regular and compute rows.
Definition: tds.h:726
void tdsdump_dump_buf(const char *file, unsigned int level_line, const char *msg, const void *buf, size_t length)
Dump the contents of data into the log file in a human readable format.
Definition: log.c:255
TDS_UINT tds_get_uint(TDSSOCKET *tds)
Get an int32 from the server.
Definition: read.c:131
TDSLOGIN * tds_read_config_info(TDSSOCKET *tds, TDSLOGIN *login, TDSLOCALE *locale)
tds_read_config_info() will fill the tds connection structure based on configuration information gath...
Definition: config.c:137
TDS_INT weekday
day of week (0-6, 0 = sunday)
Definition: tds.h:164
TDS_TINYINT bulk_query
true is query sent was a bulk query so we need to switch state to QUERYING
Definition: tds.h:1233
Definition: tds.h:527
TDSRET tds_bcp_init(TDSSOCKET *tds, TDSBCPINFO *bcpinfo)
Initialize BCP information.
Definition: bulk.c:82
TDS_INT ref_count
reference counter so client can retain safely a pointer
Definition: tds.h:974
Definition: tds.h:1102
TDS_INT cursor_rows
< number of updatable columns
Definition: tds.h:986
TDS_INT column_cur_size
size written in variable (ie: char, text, binary).
Definition: tds.h:773
this structure is not directed connected to a TDS protocol but keeps any DATE/TIME information...
Definition: tds.h:144
enum tds_states TDS_STATE
values for tds->state
results are from a stored procedure
Definition: tds.h:252
struct tds_cursor TDSCURSOR
Holds informations about a cursor.
TDS_TINYINT column_varint_size
size of length when reading from wire (0, 1, 2 or 4)
Definition: tds.h:739
TDS_INT bcp_prefix_len
The length, in bytes, of any length prefix this column may have.
Definition: tds.h:796
Definition: tds.h:1080
DSTR server_charset
charset of server e.g.
Definition: tds.h:556
int tds7_get_instance_ports(FILE *output, struct addrinfo *addr)
Get port of all instances.
Definition: net.c:927
Holds information for a dynamic (also called prepared) query.
Definition: tds.h:1011
TDS_SERVER_TYPE tds_get_conversion_type(TDS_SERVER_TYPE srctype, int colsize)
Return type suitable for conversions (convert all nullable types to fixed type)
Definition: tds_types.h:125
TDSRET tds_process_login_tokens(TDSSOCKET *tds)
tds_process_login_tokens() is called after sending the login packet to the server.
Definition: token.c:294
freetds-1.00.82/doc/reference/menu.js100644 025423 025423 00000003554 13242511131 0013033function initMenu(relPath,searchEnabled,serverSide,searchPage,search) { function makeTree(data,relPath) { var result=''; if ('children' in data) { result+=''; } return result; } $('#main-nav').append(makeTree(menudata,relPath)); $('#main-nav').children(':first').addClass('sm sm-dox').attr('id','main-menu'); if (searchEnabled) { if (serverSide) { $('#main-menu').append('
  • '); } else { $('#main-menu').append('
  • '); } } $('#main-menu').smartmenus(); } freetds-1.00.82/doc/reference/search/search_l.png100644 025423 025423 00000001134 13242511131 0015254‰PNG  IHDRŒ-µ pHYs  šœ cHRMm˜sŽà8‚ÕzÊ´3Dv„6*½âIDATxÚ¬T=«ÚP~ÎÉ91Mü@0FìPD/ºÚÑ¡.Ý;J¡¦t½Cÿ„ý‚Ú¥ƒÜŠˆ DƒÆ(­IÞ.xo¯4hŸí¼pž÷FD8E¯×c¶mçmÛnº®ûn³ÙÜl·ÛçŒ1ü ,"ìv»Ìó¼Ìh4zíºî‡l6{“ËåD:†¦iP%>a§ÓaóùüÉx<¾Õuýy¥R¦i"•JAÓ4!À‹E(`µZ¥'“ɧb±ø²Z­"ŸÏÃ0 H)Á9G\» Úí6ŸN§¯LÓ|Q¯×aYt]‡”—@, “ˆÞÖj5ݲ,†!.÷<¯Y.—ŸEÊ8ç¸<‚F¡Pxt­²#¡”òi&“áQf÷÷Ò÷ý/ž›sUU³‘UÆÂ0¼òÕçæ\J9p\‹¸ëqÖ2uöûýÑêեѷõz„a"ºžPQ”¯ŽãüÜívøà‰DâÇr¹üî8|ß?Z¿ßvlÂF£ñ+‚Ûápè, A"º¸þg¾xž÷y0Œg³E%SID88-óÎo`)„øèyžÛï÷ß—J¥ÇÑSTURÊ¿ !Œ‡Z­–P'¢7ªª6 Ã(&“I¡išÂ9•Áï5åÕ^Ðí ýIEND®B`‚freetds-1.00.82/doc/reference/search/search_m.png100644 025423 025423 00000000236 13242511131 0015257‰PNG  IHDR5^KMgAMAÖØÔOX2tEXtSoftwareAdobe ImageReadyqÉe<0IDATxÚb,//g```<~ü8ˆúøñ#ˆúÿÿ?bbZP,Xnݺ¤ ¥<~áE§IEND®B`‚freetds-1.00.82/doc/reference/search/search_r.png100644 025423 025423 00000001144 13242511131 0015263‰PNG  IHDR’]ò pHYs  šœ cHRMm˜sŽà8‚ÕzÊ´3Dv„6*½êIDATxÚ¤Ô¿ªAðoöŸ² k¥V‹¤’Ôi|±YIRß¼CÌ+¤L—g¤,R\B$`Š4)BPA! —ÕU³»î²ÎîÌI‘( 檧Ãs˜ù†u:‰B$ù|~Z,?–J¥^µZýR.—ýF£!ŽûØ`08 eY†$Iðíòz½–Ãáù|þ¥)ÓétÐu]ŒF£üô
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/all_0.js100644 025423 025423 00000010253 13242511131 0014315var searchData= [ ['_5fbcp_5fexec_5fin',['_bcp_exec_in',['../a00521.html#ga7370f1223f13510d6b33e98f2de09fb5',1,'bcp.c']]], ['_5fbcp_5fexec_5fout',['_bcp_exec_out',['../a00521.html#gae67546338cb9542a4902aa914f57f314',1,'bcp.c']]], ['_5fbcp_5ffgets',['_bcp_fgets',['../a00521.html#gaf4e2c59203f2af21bb2803ef4a69bfa8',1,'bcp.c']]], ['_5fbcp_5ffree_5fcolumns',['_bcp_free_columns',['../a00521.html#gacf69ac4cbe8e3c3e6ea665e31e5e85b8',1,'bcp.c']]], ['_5fbcp_5ffree_5fstorage',['_bcp_free_storage',['../a00521.html#gaa134c1c3ccc4326e693adb8357272f1d',1,'bcp.c']]], ['_5fbcp_5fget_5fcol_5fdata',['_bcp_get_col_data',['../a00521.html#ga0f8def4cad04c5c1e27c2b653d482dd8',1,'bcp.c']]], ['_5fbcp_5fget_5fterm_5fvar',['_bcp_get_term_var',['../a00521.html#gac82ffc5c1f71cbf453d81d1057004f1e',1,'bcp.c']]], ['_5fbcp_5fread_5fhostfile',['_bcp_read_hostfile',['../a00521.html#ga065757a7d0dce354660900de4aa79e2f',1,'bcp.c']]], ['_5fbcp_5freadfmt_5fcolinfo',['_bcp_readfmt_colinfo',['../a00521.html#gafc23d62bc86b38fb757e3ac4aadca0a4',1,'bcp.c']]], ['_5fcharacter_5fset_5falias',['_character_set_alias',['../a00933.html',1,'']]], ['_5fcs_5fblkdesc',['_cs_blkdesc',['../a00861.html',1,'']]], ['_5fcs_5fclientmsg',['_cs_clientmsg',['../a00809.html',1,'']]], ['_5fcs_5fcommand',['_cs_command',['../a00857.html',1,'']]], ['_5fcs_5fconfig',['_cs_config',['../a00817.html',1,'']]], ['_5fcs_5fconnection',['_cs_connection',['../a00841.html',1,'']]], ['_5fcs_5fcontext',['_cs_context',['../a00833.html',1,'']]], ['_5fcs_5fdatafmt',['_cs_datafmt',['../a00785.html',1,'']]], ['_5fcs_5fdaterec',['_cs_daterec',['../a00805.html',1,'']]], ['_5fcs_5fdatetime',['_cs_datetime',['../a00797.html',1,'']]], ['_5fcs_5fdatetime4',['_cs_datetime4',['../a00801.html',1,'']]], ['_5fcs_5fdynamic',['_cs_dynamic',['../a00853.html',1,'']]], ['_5fcs_5fiodesc',['_cs_iodesc',['../a00781.html',1,'']]], ['_5fcs_5flocale',['_cs_locale',['../a00865.html',1,'']]], ['_5fcs_5fmoney',['_cs_money',['../a00789.html',1,'']]], ['_5fcs_5fmoney4',['_cs_money4',['../a00793.html',1,'']]], ['_5fcs_5fnumeric',['_cs_numeric',['../a00769.html',1,'']]], ['_5fcs_5fobjdata',['_cs_objdata',['../a00765.html',1,'']]], ['_5fcs_5fobjname',['_cs_objname',['../a00761.html',1,'']]], ['_5fcs_5fparam',['_cs_param',['../a00845.html',1,'']]], ['_5fcs_5fservermsg',['_cs_servermsg',['../a00813.html',1,'']]], ['_5fcs_5fvarbinary',['_cs_varbinary',['../a00773.html',1,'']]], ['_5fcs_5fvarchar',['_cs_varchar',['../a00777.html',1,'']]], ['_5fcsremote_5fproc',['_csremote_proc',['../a00849.html',1,'']]], ['_5fct_5fcolinfo',['_ct_colinfo',['../a00837.html',1,'']]], ['_5fdbcoldata',['_dbcoldata',['../a00524.html#ga3c6f474c0662158f3100fe464bf077d9',1,'dblib.c']]], ['_5fdblib_5fcheck_5fand_5fhandle_5finterrupt',['_dblib_check_and_handle_interrupt',['../a00524.html#gadf15185b0d417edc0bb8a6a4f0bae727',1,'_dblib_check_and_handle_interrupt(void *vdbproc): dbutil.c'],['../a00524.html#gadf15185b0d417edc0bb8a6a4f0bae727',1,'_dblib_check_and_handle_interrupt(void *vdbproc): dbutil.c']]], ['_5fdblib_5ferror_5fmessage',['_dblib_error_message',['../a00589.html',1,'']]], ['_5fdbremote_5fproc',['_DBREMOTE_PROC',['../a00889.html',1,'']]], ['_5fdbremote_5fproc_5fparam',['_DBREMOTE_PROC_PARAM',['../a00885.html',1,'']]], ['_5fdbresults',['_dbresults',['../a00518.html#gaf1879b85e8238c015b9648d077665285',1,'dblib.c']]], ['_5fdheader',['_dheader',['../a00957.html',1,'']]], ['_5fdrecord',['_drecord',['../a00961.html',1,'']]], ['_5fhcattr',['_hcattr',['../a00981.html',1,'']]], ['_5fhchk',['_hchk',['../a00973.html',1,'']]], ['_5fhdbc',['_hdbc',['../a00985.html',1,'']]], ['_5fhdesc',['_hdesc',['../a00965.html',1,'']]], ['_5fheattr',['_heattr',['../a00969.html',1,'']]], ['_5fhenv',['_henv',['../a00977.html',1,'']]], ['_5fhsattr',['_hsattr',['../a00989.html',1,'']]], ['_5fhstmt',['_hstmt',['../a00993.html',1,'']]], ['_5fnull_5frepresentation',['_null_representation',['../a00897.html',1,'']]], ['_5foptions',['_options',['../a00557.html',1,'']]], ['_5fprocedure',['_procedure',['../a00577.html',1,'']]], ['_5fsql_5ferror',['_sql_error',['../a00949.html',1,'']]], ['_5fsql_5ferrors',['_sql_errors',['../a00953.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/all_1.html100644 025423 025423 00000001765 13242511131 0014656
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/all_1.js100644 025423 025423 00000000711 13242511131 0014314var searchData= [ ['adjust_5fcharacter_5fcolumn_5fsize',['adjust_character_column_size',['../a00536.html#ga91770634ce8c0d6f1fe007b45da186fd',1,'token.c']]], ['agg_5ft',['agg_t',['../a00601.html',1,'']]], ['allocated',['allocated',['../a01065.html#a9f32de09fe01879aeed23e858f3cef79',1,'tds_dynamic_stream']]], ['asn1_5fder_5fiterator',['asn1_der_iterator',['../a00741.html',1,'']]], ['authentication',['Authentication',['../a00528.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/all_2.html100644 025423 025423 00000001765 13242511131 0014657
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/all_2.js100644 025423 025423 00000013513 13242511131 0014321var searchData= [ ['bcp_5fbatch',['bcp_batch',['../a00520.html#gaa23f8e5c7f437a94746c90292dd1cb01',1,'bcp_batch(DBPROCESS *dbproc): bcp.c'],['../a00520.html#gaa23f8e5c7f437a94746c90292dd1cb01',1,'bcp_batch(DBPROCESS *dbproc): bcp.c']]], ['bcp_5fbind',['bcp_bind',['../a00520.html#ga6cf03708baaf02eb016b9ee77160d879',1,'bcp_bind(DBPROCESS *dbproc, BYTE *varaddr, int prefixlen, DBINT varlen, BYTE *terminator, int termlen, int db_vartype, int table_column): bcp.c'],['../a00520.html#ga6cf03708baaf02eb016b9ee77160d879',1,'bcp_bind(DBPROCESS *dbproc, BYTE *varaddr, int prefixlen, DBINT varlen, BYTE *terminator, int termlen, int type, int table_column): bcp.c']]], ['bcp_5fcolfmt',['bcp_colfmt',['../a00520.html#ga0ed03c69e698336d015bb315ad755fd5',1,'bcp_colfmt(DBPROCESS *dbproc, int host_colnum, int host_type, int host_prefixlen, DBINT host_collen, const BYTE *host_term, int host_termlen, int table_colnum): bcp.c'],['../a00520.html#ga0ed03c69e698336d015bb315ad755fd5',1,'bcp_colfmt(DBPROCESS *dbproc, int host_column, int host_type, int host_prefixlen, DBINT host_collen, const BYTE *host_term, int host_termlen, int colnum): bcp.c']]], ['bcp_5fcolfmt_5fps',['bcp_colfmt_ps',['../a00520.html#gaf13b2bb12b4200752718f3a3face3870',1,'bcp_colfmt_ps(DBPROCESS *dbproc, int host_colnum, int host_type, int host_prefixlen, DBINT host_collen, BYTE *host_term, int host_termlen, int table_colnum, DBTYPEINFO *typeinfo): bcp.c'],['../a00520.html#gaf13b2bb12b4200752718f3a3face3870',1,'bcp_colfmt_ps(DBPROCESS *dbproc, int host_column, int host_type, int host_prefixlen, DBINT host_collen, BYTE *host_term, int host_termlen, int colnum, DBTYPEINFO *typeinfo): bcp.c']]], ['bcp_5fcollen',['bcp_collen',['../a00520.html#gae41d196a22c544d66212dacc5b555791',1,'bcp_collen(DBPROCESS *dbproc, DBINT varlen, int table_column): bcp.c'],['../a00520.html#gae41d196a22c544d66212dacc5b555791',1,'bcp_collen(DBPROCESS *dbproc, DBINT varlen, int table_column): bcp.c']]], ['bcp_5fcolptr',['bcp_colptr',['../a00520.html#ga6498235e4ef8e41ea43b01494b28998d',1,'bcp_colptr(DBPROCESS *dbproc, BYTE *colptr, int table_column): bcp.c'],['../a00520.html#ga6498235e4ef8e41ea43b01494b28998d',1,'bcp_colptr(DBPROCESS *dbproc, BYTE *colptr, int table_column): bcp.c']]], ['bcp_5fcolumns',['bcp_columns',['../a00520.html#ga330b9f1028f856a9eec5115550bcb4f7',1,'bcp_columns(DBPROCESS *dbproc, int host_colcount): bcp.c'],['../a00520.html#ga330b9f1028f856a9eec5115550bcb4f7',1,'bcp_columns(DBPROCESS *dbproc, int host_colcount): bcp.c']]], ['bcp_5fcontrol',['bcp_control',['../a00520.html#ga244547855b41788fa3a67756956fbc81',1,'bcp_control(DBPROCESS *dbproc, int field, DBINT value): bcp.c'],['../a00520.html#ga244547855b41788fa3a67756956fbc81',1,'bcp_control(DBPROCESS *dbproc, int field, DBINT value): bcp.c']]], ['bcp_5fdone',['bcp_done',['../a00520.html#ga8b85f79f53a62ac7a728fe626d609b65',1,'bcp_done(DBPROCESS *dbproc): bcp.c'],['../a00520.html#ga8b85f79f53a62ac7a728fe626d609b65',1,'bcp_done(DBPROCESS *dbproc): bcp.c']]], ['bcp_5fexec',['bcp_exec',['../a00520.html#ga7a184158b27a50f713e9cfae3b746209',1,'bcp_exec(DBPROCESS *dbproc, DBINT *rows_copied): bcp.c'],['../a00520.html#ga7a184158b27a50f713e9cfae3b746209',1,'bcp_exec(DBPROCESS *dbproc, DBINT *rows_copied): bcp.c']]], ['bcp_5fgetl',['bcp_getl',['../a00520.html#ga220f6b043602da1028f98dacb2fd00c0',1,'bcp_getl(LOGINREC *login): bcp.c'],['../a00520.html#ga220f6b043602da1028f98dacb2fd00c0',1,'bcp_getl(LOGINREC *login): bcp.c']]], ['bcp_5fhostcolinfo',['BCP_HOSTCOLINFO',['../a00877.html',1,'']]], ['bcp_5fhostfileinfo',['BCP_HOSTFILEINFO',['../a00881.html',1,'']]], ['bcp_5finit',['bcp_init',['../a00520.html#gada8e987c4a6225b9276c05ba3a4f47a0',1,'bcp_init(DBPROCESS *dbproc, const char *tblname, const char *hfile, const char *errfile, int direction): bcp.c'],['../a00520.html#gada8e987c4a6225b9276c05ba3a4f47a0',1,'bcp_init(DBPROCESS *dbproc, const char *tblname, const char *hfile, const char *errfile, int direction): bcp.c']]], ['bcp_5foptions',['bcp_options',['../a00520.html#gafec3feb5bac1cb33545ba01efb0a67b8',1,'bcp_options(DBPROCESS *dbproc, int option, BYTE *value, int valuelen): bcp.c'],['../a00520.html#gafec3feb5bac1cb33545ba01efb0a67b8',1,'bcp_options(DBPROCESS *dbproc, int option, BYTE *value, int valuelen): bcp.c']]], ['bcp_5fprefix_5flen',['bcp_prefix_len',['../a01133.html#a07d747c0592ff37eb467ba14c4dcaeb2',1,'tds_column']]], ['bcp_5freadfmt',['bcp_readfmt',['../a00520.html#ga963c5e38bca7668afc57f5cc123d10fb',1,'bcp_readfmt(DBPROCESS *dbproc, const char filename[]): bcp.c'],['../a00520.html#ga963c5e38bca7668afc57f5cc123d10fb',1,'bcp_readfmt(DBPROCESS *dbproc, const char filename[]): bcp.c']]], ['bcp_5fsendrow',['bcp_sendrow',['../a00520.html#gaf1130ac97f6af55e86ec70b0aa4f5b40',1,'bcp_sendrow(DBPROCESS *dbproc): bcp.c'],['../a00520.html#gaf1130ac97f6af55e86ec70b0aa4f5b40',1,'bcp_sendrow(DBPROCESS *dbproc): bcp.c']]], ['bcp_5fsetl',['BCP_SETL',['../a00517.html#ga5a626d228e82be0af8449d2b8c278241',1,'sybdb.h']]], ['binary_5fto_5fresult',['binary_to_result',['../a00530.html#gab09f8279ad6da8a0a6a935e5810d753a',1,'convert.c']]], ['block_5fsize',['block_size',['../a01161.html#aaad54522a6e04122eba4c37a200d3f20',1,'tds_env']]], ['buf',['buf',['../a01065.html#a1b4967f395da537910ded1b392dd5d9b',1,'tds_dynamic_stream']]], ['buffer',['buffer',['../a01045.html#a5ba4ad38fdcb68e7d0c7252be65a4ecc',1,'tds_output_stream']]], ['bug_20list',['Bug List',['../a00516.html',1,'']]], ['bulk_2ec',['bulk.c',['../a00248.html',1,'']]], ['bulk_5fcopy',['bulk_copy',['../a01101.html#ad0d5f6fc4c5a5d64f11efd2e11ecaaa4',1,'tds_login']]], ['bulk_5fquery',['bulk_query',['../a01193.html#a8c44578d269fafd7249f43593958b0be',1,'tds_socket']]], ['bulk_20copy_20functions',['Bulk copy functions',['../a00520.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/all_3.html100644 025423 025423 00000001765 13242511131 0014660
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/all_3.js100644 025423 025423 00000005574 13242511131 0014332var searchData= [ ['cafile',['cafile',['../a01101.html#ad12291abe6678aa30b8c43ab8e75429c',1,'tds_login']]], ['canonic',['canonic',['../a01121.html#aa9d3f1d6d994fcd5871ca41d7797ae95',1,'tds_encoding']]], ['cb',['cb',['../a00689.html#afc81c17990646fe0ed1c9cce5a917487',1,'tds_pbcb']]], ['cb_5ft',['cb_t',['../a00921.html',1,'conv_result']]], ['cc_5ft',['cc_t',['../a00917.html',1,'conv_result']]], ['char_5fconv',['char_conv',['../a01133.html#ab3afb8272401bdb51064cdf910334159',1,'tds_column']]], ['charset',['charset',['../a01161.html#a09756f0c4e0d588152c4dc3a8d019bcd',1,'tds_env']]], ['col_5ft',['col_t',['../a00593.html',1,'']]], ['column_5fcur_5fsize',['column_cur_size',['../a01133.html#ada14ba479a67762fc1bef78910ef4beb',1,'tds_column']]], ['column_5fprec',['column_prec',['../a01133.html#a7ae346f8b1fdd364749825ca0863d166',1,'tds_column']]], ['column_5fscale',['column_scale',['../a01133.html#ab73b012b3a9f08da8661dc230ec17d7f',1,'tds_column']]], ['column_5fsize',['column_size',['../a01133.html#a2c2756c00a1099c82d4cfa4da2894672',1,'tds_column']]], ['column_5ftype',['column_type',['../a01133.html#a7f08ecedc5835a4e81129c6b2b493947',1,'tds_column']]], ['column_5fvarint_5fsize',['column_varint_size',['../a01133.html#a12914f03ee2f24fa3fe577060410770d',1,'tds_column']]], ['conf_5fparams',['conf_params',['../a00641.html',1,'']]], ['configuration',['Configuration',['../a00529.html',1,'']]], ['connect_5fevent',['CONNECT_EVENT',['../a00649.html',1,'']]], ['charset_20conversion',['Charset conversion',['../a00531.html',1,'']]], ['conv_5fresult',['conv_result',['../a00913.html',1,'']]], ['conversion',['Conversion',['../a00530.html',1,'']]], ['crlfile',['crlfile',['../a01101.html#a15808ea4c259a779c63732f8c1067c54',1,'tds_login']]], ['cs_5fdiag_5fmsg',['cs_diag_msg',['../a00829.html',1,'']]], ['cs_5fdiag_5fmsg_5fclient',['cs_diag_msg_client',['../a00821.html',1,'']]], ['cs_5fdiag_5fmsg_5fsvr',['cs_diag_msg_svr',['../a00825.html',1,'']]], ['cur_5fcursor',['cur_cursor',['../a01193.html#aa708effeb88270302ab5524f0c0366ac',1,'tds_socket']]], ['cur_5fdyn',['cur_dyn',['../a01193.html#afb404985164205ebdc9b0c18fabb47e2',1,'tds_socket']]], ['current_5fresults',['current_results',['../a01193.html#a4b77fb56b92b93e413fcbb8ba5633ce4',1,'tds_socket']]], ['current_5fstatement',['current_statement',['../a00985.html#acaf05aab946ae9dec9e06dd230839675',1,'_hdbc']]], ['cursor_5fid',['cursor_id',['../a01157.html#a7b7d4cedf0cc7f890133f021d18af58c',1,'tds_cursor']]], ['cursor_5fname',['cursor_name',['../a01157.html#afd459125b5c4d4ccbf77a7d6ca8a4aaa',1,'tds_cursor']]], ['cursor_5frows',['cursor_rows',['../a01157.html#a7ec745adff5b2391e609e836c9f010cd',1,'tds_cursor']]], ['cursor_5fsupport',['cursor_support',['../a00985.html#ae45d3601984f4773024a81394764d28d',1,'_hdbc']]], ['cursors',['cursors',['../a01189.html#a42b972a1cd99c8f2f83b2cf5c635435a',1,'tds_connection']]] ]; freetds-1.00.82/doc/reference/search/all_4.html100644 025423 025423 00000001765 13242511131 0014661
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/all_4.js100644 025423 025423 00000123551 13242511131 0014327var searchData= [ ['data',['DATA',['../a00545.html',1,'']]], ['data_2ec',['data.c',['../a00260.html',1,'']]], ['database',['database',['../a01161.html#ad05b5a83816aee8ff9858ddb1eb172b8',1,'tds_env']]], ['date',['date',['../a01077.html#a4697c11cf7da815856eb96bae4d57bac',1,'TDS_DATETIMEALL::date()'],['../a01265.html#afa93266cde7ab536615bca3d904aabed',1,'DBDATETIMEALL::date()']]], ['day',['day',['../a01081.html#a82d0cf263d8d4a3abcf84b9a146ddf83',1,'tdsdaterec']]], ['dayofyear',['dayofyear',['../a01081.html#a3f7925156708744d28016aacb90b6093',1,'tdsdaterec']]], ['db_5ffilename',['db_filename',['../a01101.html#a425f8ddd194f897f185d9f4d5e0618c2',1,'tds_login']]], ['dbadata',['dbadata',['../a00518.html#gabcc14a1ca58b65bc46cce6c81c45218c',1,'dbadata(DBPROCESS *dbproc, int computeid, int column): dblib.c'],['../a00518.html#gabcc14a1ca58b65bc46cce6c81c45218c',1,'dbadata(DBPROCESS *dbproc, int computeid, int column): dblib.c']]], ['dbadlen',['dbadlen',['../a00518.html#ga3340e21db274b272ec11c037cb147222',1,'dbadlen(DBPROCESS *dbproc, int computeid, int column): dblib.c'],['../a00518.html#ga3340e21db274b272ec11c037cb147222',1,'dbadlen(DBPROCESS *dbproc, int computeid, int column): dblib.c']]], ['dbaltbind',['dbaltbind',['../a00518.html#gafefd17e15b22adda84366c817178dd7d',1,'dbaltbind(DBPROCESS *dbproc, int computeid, int column, int vartype, DBINT varlen, BYTE *varaddr): dblib.c'],['../a00518.html#gafefd17e15b22adda84366c817178dd7d',1,'dbaltbind(DBPROCESS *dbprocess, int computeid, int column, int vartype, DBINT varlen, BYTE *varaddr): dblib.c']]], ['dbaltcolid',['dbaltcolid',['../a00518.html#gad10c9fd75a86c7a0ac375937df0e90a6',1,'dbaltcolid(DBPROCESS *dbproc, int computeid, int column): dblib.c'],['../a00518.html#gad10c9fd75a86c7a0ac375937df0e90a6',1,'dbaltcolid(DBPROCESS *dbproc, int computeid, int column): dblib.c']]], ['dbaltlen',['dbaltlen',['../a00518.html#ga9a35c8d3cd0e35c10555baf8f6a01e93',1,'dbaltlen(DBPROCESS *dbproc, int computeid, int column): dblib.c'],['../a00518.html#ga9a35c8d3cd0e35c10555baf8f6a01e93',1,'dbaltlen(DBPROCESS *dbproc, int computeid, int column): dblib.c']]], ['dbaltop',['dbaltop',['../a00518.html#ga947837a5c8fd99898c043435945b668c',1,'dbaltop(DBPROCESS *dbproc, int computeid, int column): dblib.c'],['../a00518.html#ga947837a5c8fd99898c043435945b668c',1,'dbaltop(DBPROCESS *dbproc, int computeid, int column): dblib.c']]], ['dbalttype',['dbalttype',['../a00518.html#gaa85171e020dc606f2bd3395ad1d3ab4f',1,'dbalttype(DBPROCESS *dbproc, int computeid, int column): dblib.c'],['../a00518.html#gaa85171e020dc606f2bd3395ad1d3ab4f',1,'dbalttype(DBPROCESS *dbproc, int computeid, int column): dblib.c']]], ['dbaltutype',['dbaltutype',['../a00518.html#gaf1c00d83dfa88dc99a3fb449c49660ea',1,'dbaltutype(DBPROCESS *dbproc, int computeid, int column): dblib.c'],['../a00518.html#gaf1c00d83dfa88dc99a3fb449c49660ea',1,'dbaltutype(DBPROCESS *dbproc, int computeid, int column): dblib.c']]], ['dbanullbind',['dbanullbind',['../a00518.html#ga939c2a2e67b9992c787e2cec5b6cc1a7',1,'dbanullbind(DBPROCESS *dbproc, int computeid, int column, DBINT *indicator): dblib.c'],['../a00518.html#ga939c2a2e67b9992c787e2cec5b6cc1a7',1,'dbanullbind(DBPROCESS *dbprocess, int computeid, int column, DBINT *indicator): dblib.c']]], ['dbanydatecrack',['dbanydatecrack',['../a00518.html#gad57aa777300cf7f62077478ec6000d00',1,'dbanydatecrack(DBPROCESS *dbproc, DBDATEREC2 *di, int type, const void *data): dblib.c'],['../a00518.html#gad57aa777300cf7f62077478ec6000d00',1,'dbanydatecrack(DBPROCESS *dbproc, DBDATEREC2 *di, int type, const void *data): dblib.c']]], ['dbbind',['dbbind',['../a00518.html#ga873bc0f4663165e711655ade1dfae795',1,'dbbind(DBPROCESS *dbproc, int column, int vartype, DBINT varlen, BYTE *varaddr): dblib.c'],['../a00518.html#ga873bc0f4663165e711655ade1dfae795',1,'dbbind(DBPROCESS *dbproc, int column, int vartype, DBINT varlen, BYTE *varaddr): dblib.c']]], ['dbbylist',['dbbylist',['../a00518.html#gae658a0cd5270f3bd6f22de17b2cb2e64',1,'dbbylist(DBPROCESS *dbproc, int computeid, int *size): dblib.c'],['../a00518.html#gae658a0cd5270f3bd6f22de17b2cb2e64',1,'dbbylist(DBPROCESS *dbproc, int computeid, int *size): dblib.c']]], ['dbcancel',['dbcancel',['../a00518.html#ga5ea23272124fff03b8d87538c1ec3ee5',1,'dbcancel(DBPROCESS *dbproc): dblib.c'],['../a00518.html#ga5ea23272124fff03b8d87538c1ec3ee5',1,'dbcancel(DBPROCESS *dbproc): dblib.c']]], ['dbcanquery',['dbcanquery',['../a00518.html#ga559e24ba70d0d96c3469eb6ab8f74e05',1,'dbcanquery(DBPROCESS *dbproc): dblib.c'],['../a00518.html#ga559e24ba70d0d96c3469eb6ab8f74e05',1,'dbcanquery(DBPROCESS *dbproc): dblib.c']]], ['dbchange',['dbchange',['../a00518.html#ga8cbc761b1266bd947783d843aeeec264',1,'dbchange(DBPROCESS *dbproc): dblib.c'],['../a00518.html#ga8cbc761b1266bd947783d843aeeec264',1,'dbchange(DBPROCESS *dbprocess): dblib.c']]], ['dbclose',['dbclose',['../a00518.html#gaef740b394b44eb33925c2718f7b30d69',1,'dbclose(DBPROCESS *dbproc): dblib.c'],['../a00518.html#gaef740b394b44eb33925c2718f7b30d69',1,'dbclose(DBPROCESS *dbproc): dblib.c']]], ['dbclrbuf',['dbclrbuf',['../a00518.html#ga01404b179a251c249aecfdae72ec6ca4',1,'dbclrbuf(DBPROCESS *dbproc, DBINT n): dblib.c'],['../a00518.html#ga01404b179a251c249aecfdae72ec6ca4',1,'dbclrbuf(DBPROCESS *dbproc, DBINT n): dblib.c']]], ['dbclropt',['dbclropt',['../a00518.html#ga93ee3c8ca34a08588f88784898fd69e0',1,'dbclropt(DBPROCESS *dbproc, int option, const char param[]): dblib.c'],['../a00518.html#ga93ee3c8ca34a08588f88784898fd69e0',1,'dbclropt(DBPROCESS *dbproc, int option, const char param[]): dblib.c']]], ['dbcmd',['dbcmd',['../a00518.html#ga87b39d9863316b4ba85654b0885d53a0',1,'dbcmd(DBPROCESS *dbproc, const char cmdstring[]): dblib.c'],['../a00518.html#ga87b39d9863316b4ba85654b0885d53a0',1,'dbcmd(DBPROCESS *dbproc, const char cmdstring[]): dblib.c']]], ['dbcmdrow',['DBCMDROW',['../a00518.html#ga8b263669ce0312e52b5ea42a57a56838',1,'DBCMDROW(): sybdb.h'],['../a00524.html#ga196f6d67de47f34a32fcc2103ab0f416',1,'dbcmdrow(DBPROCESS *dbproc): dblib.c'],['../a00524.html#ga196f6d67de47f34a32fcc2103ab0f416',1,'dbcmdrow(DBPROCESS *dbproc): dblib.c']]], ['dbcol',['DBCOL',['../a01277.html',1,'']]], ['dbcol2',['DBCOL2',['../a01281.html',1,'']]], ['dbcolinfo',['dbcolinfo',['../a00077.html#a9b73fd1afa2c3ccfca481635212d2e43',1,'dbcolinfo(DBPROCESS *dbproc, CI_TYPE type, DBINT column, DBINT computeid, DBCOL *pdbcol): dblib.c'],['../a00479.html#a9b73fd1afa2c3ccfca481635212d2e43',1,'dbcolinfo(DBPROCESS *dbproc, CI_TYPE type, DBINT column, DBINT computeid, DBCOL *pdbcol): dblib.c']]], ['dbcollen',['dbcollen',['../a00518.html#ga89fc5589b4bf41932324d2cfc6ad6433',1,'dbcollen(DBPROCESS *dbproc, int column): dblib.c'],['../a00518.html#ga89fc5589b4bf41932324d2cfc6ad6433',1,'dbcollen(DBPROCESS *dbproc, int column): dblib.c']]], ['dbcolname',['dbcolname',['../a00518.html#gad06f5deddac18604dfa858b2580e232f',1,'dbcolname(DBPROCESS *dbproc, int column): dblib.c'],['../a00518.html#gad06f5deddac18604dfa858b2580e232f',1,'dbcolname(DBPROCESS *dbproc, int column): dblib.c']]], ['dbcolptr',['dbcolptr',['../a00524.html#ga0fc84c7073ed4876d9596c3eccac3609',1,'dblib.c']]], ['dbcolsource',['dbcolsource',['../a00518.html#ga3a96d0188e5e0eb9eea661b3685fdcc3',1,'dbcolsource(DBPROCESS *dbproc, int column): dblib.c'],['../a00518.html#ga3a96d0188e5e0eb9eea661b3685fdcc3',1,'dbcolsource(DBPROCESS *dbproc, int colnum): dblib.c']]], ['dbcoltype',['dbcoltype',['../a00518.html#ga636e6f1b64743f3cf22158a56eef371f',1,'dbcoltype(DBPROCESS *dbproc, int column): dblib.c'],['../a00518.html#ga636e6f1b64743f3cf22158a56eef371f',1,'dbcoltype(DBPROCESS *dbproc, int column): dblib.c']]], ['dbcoltypeinfo',['dbcoltypeinfo',['../a00518.html#ga3c33e72c41b40e08dbcfdfa0d16bc399',1,'dbcoltypeinfo(DBPROCESS *dbproc, int column): dblib.c'],['../a00518.html#ga3c33e72c41b40e08dbcfdfa0d16bc399',1,'dbcoltypeinfo(DBPROCESS *dbproc, int column): dblib.c']]], ['dbcolutype',['dbcolutype',['../a00518.html#gab33d2f4fd44f50e55b6c71902db4fdae',1,'dbcolutype(DBPROCESS *dbproc, int column): dblib.c'],['../a00518.html#gab33d2f4fd44f50e55b6c71902db4fdae',1,'dbcolutype(DBPROCESS *dbprocess, int column): dblib.c']]], ['dbconvert',['dbconvert',['../a00518.html#ga32eb72f6fb3edb130e59fb3dd0766e7e',1,'dbconvert(DBPROCESS *dbproc, int srctype, const BYTE *src, DBINT srclen, int desttype, BYTE *dest, DBINT destlen): dblib.c'],['../a00518.html#ga32eb72f6fb3edb130e59fb3dd0766e7e',1,'dbconvert(DBPROCESS *dbproc, int srctype, const BYTE *src, DBINT srclen, int desttype, BYTE *dest, DBINT destlen): dblib.c']]], ['dbconvert_5fps',['dbconvert_ps',['../a00518.html#ga8b00d5cdcaa20cba13fa2e03d52a443e',1,'dbconvert_ps(DBPROCESS *dbproc, int db_srctype, const BYTE *src, DBINT srclen, int db_desttype, BYTE *dest, DBINT destlen, DBTYPEINFO *typeinfo): dblib.c'],['../a00518.html#ga8b00d5cdcaa20cba13fa2e03d52a443e',1,'dbconvert_ps(DBPROCESS *dbprocess, int srctype, const BYTE *src, DBINT srclen, int desttype, BYTE *dest, DBINT destlen, DBTYPEINFO *typeinfo): dblib.c']]], ['dbcount',['DBCOUNT',['../a00518.html#ga0ac1828f731a21c591c8d6330cbba3a9',1,'DBCOUNT(): sybdb.h'],['../a00518.html#ga9433bc200c0978569964354451d9b64e',1,'dbcount(DBPROCESS *dbproc): dblib.c'],['../a00518.html#ga9433bc200c0978569964354451d9b64e',1,'dbcount(DBPROCESS *dbproc): dblib.c']]], ['dbcurcmd',['DBCURCMD',['../a00518.html#gae375344b1ec50c1f756e3b69f3cef715',1,'DBCURCMD(): sybdb.h'],['../a00524.html#ga01e7fb38bece3bb07526532fa6be50e5',1,'dbcurcmd(DBPROCESS *dbproc): dblib.c'],['../a00524.html#ga01e7fb38bece3bb07526532fa6be50e5',1,'dbcurcmd(DBPROCESS *dbproc): dblib.c']]], ['dbcurrow',['DBCURROW',['../a00518.html#gaf49e4b58918bfa4d4adaa14ee5bb375c',1,'DBCURROW(): sybdb.h'],['../a00524.html#ga9e23a95d84192b4fc83db7544d772d16',1,'dbcurrow(DBPROCESS *dbproc): dblib.c'],['../a00524.html#ga9e23a95d84192b4fc83db7544d772d16',1,'dbcurrow(DBPROCESS *dbproc): dblib.c']]], ['dbdata',['dbdata',['../a00518.html#gaee60c306a22383805a4b9caa647a1e16',1,'dbdata(DBPROCESS *dbproc, int column): dblib.c'],['../a00518.html#gaee60c306a22383805a4b9caa647a1e16',1,'dbdata(DBPROCESS *dbproc, int column): dblib.c']]], ['dbdatecmp',['dbdatecmp',['../a00523.html#ga129d2922d347121a6b312dd8e75ed6d2',1,'dbdatecmp(DBPROCESS *dbproc, DBDATETIME *d1, DBDATETIME *d2): dblib.c'],['../a00523.html#ga129d2922d347121a6b312dd8e75ed6d2',1,'dbdatecmp(DBPROCESS *dbproc, DBDATETIME *d1, DBDATETIME *d2): dblib.c']]], ['dbdatecrack',['dbdatecrack',['../a00518.html#ga46f3641b79a2e90371a66950b6db2c4d',1,'dbdatecrack(DBPROCESS *dbproc, DBDATEREC *di, DBDATETIME *datetime): dblib.c'],['../a00518.html#ga46f3641b79a2e90371a66950b6db2c4d',1,'dbdatecrack(DBPROCESS *dbproc, DBDATEREC *di, DBDATETIME *dt): dblib.c']]], ['dbdatetime',['DBDATETIME',['../a01257.html',1,'']]], ['dbdatetime4',['DBDATETIME4',['../a01261.html',1,'']]], ['dbdatetimeall',['DBDATETIMEALL',['../a01265.html',1,'']]], ['dbdatlen',['dbdatlen',['../a00518.html#gae666d141533126babb0235af21bdca0f',1,'dbdatlen(DBPROCESS *dbproc, int column): dblib.c'],['../a00518.html#gae666d141533126babb0235af21bdca0f',1,'dbdatlen(DBPROCESS *dbproc, int column): dblib.c']]], ['dbdead',['DBDEAD',['../a00518.html#ga2c7b5eec4843ea326b21f2db2ded2754',1,'DBDEAD(): sybdb.h'],['../a00524.html#gaed43cb21ed54dc1a6340075d6290e4b0',1,'dbdead(DBPROCESS *dbproc): dblib.c'],['../a00524.html#gaed43cb21ed54dc1a6340075d6290e4b0',1,'dbdead(DBPROCESS *dbproc): dblib.c']]], ['dberrhandle',['dberrhandle',['../a00518.html#gab8209543de865f359bdb32829fa8b757',1,'dberrhandle(EHANDLEFUNC handler): dblib.c'],['../a00518.html#gab8209543de865f359bdb32829fa8b757',1,'dberrhandle(EHANDLEFUNC handler): dblib.c']]], ['dbexit',['dbexit',['../a00518.html#gad0044401c8c83205583f93a4764f2d8b',1,'dbexit(): dblib.c'],['../a00518.html#gad0044401c8c83205583f93a4764f2d8b',1,'dbexit(void): dblib.c']]], ['dbfcmd',['dbfcmd',['../a00518.html#ga43727b10d4cbb7708b374811abe6eadb',1,'dbfcmd(DBPROCESS *dbproc, const char *fmt,...): dblib.c'],['../a00518.html#ga43727b10d4cbb7708b374811abe6eadb',1,'dbfcmd(DBPROCESS *dbproc, const char *fmt,...): dblib.c']]], ['dbfirstrow',['DBFIRSTROW',['../a00518.html#ga97a6493786124215ec9fe4b4bd2d7cbb',1,'DBFIRSTROW(): sybdb.h'],['../a00524.html#gaf40b925f3b3ba43804720dd4ae584935',1,'dbfirstrow(DBPROCESS *dbproc): dblib.c'],['../a00524.html#gaf40b925f3b3ba43804720dd4ae584935',1,'dbfirstrow(DBPROCESS *dbproc): dblib.c']]], ['dbfreebuf',['dbfreebuf',['../a00518.html#ga0fcfcf6846442dac9dd5584d270ec72a',1,'dbfreebuf(DBPROCESS *dbproc): dblib.c'],['../a00518.html#ga0fcfcf6846442dac9dd5584d270ec72a',1,'dbfreebuf(DBPROCESS *dbproc): dblib.c']]], ['dbgetchar',['dbgetchar',['../a00518.html#gaf917cf746c954a5d1b718afe3c4d1940',1,'dbgetchar(DBPROCESS *dbproc, int pos): dblib.c'],['../a00518.html#gaf917cf746c954a5d1b718afe3c4d1940',1,'dbgetchar(DBPROCESS *dbprocess, int n): dblib.c']]], ['dbgetmaxprocs',['dbgetmaxprocs',['../a00518.html#gadb34c5c2aae50ac9f2a26d8984136997',1,'dbgetmaxprocs(void): dblib.c'],['../a00518.html#gadb34c5c2aae50ac9f2a26d8984136997',1,'dbgetmaxprocs(void): dblib.c']]], ['dbgetnull',['dbgetnull',['../a00077.html#aea6a865806d454280126de940478c214',1,'dblib.c']]], ['dbgetpacket',['dbgetpacket',['../a00518.html#gabaf9aa756f7cb8bbec80d1c7201c6238',1,'dbgetpacket(DBPROCESS *dbproc): dblib.c'],['../a00518.html#gabaf9aa756f7cb8bbec80d1c7201c6238',1,'dbgetpacket(DBPROCESS *dbproc): dblib.c']]], ['dbgetrow',['dbgetrow',['../a00518.html#ga60fe544491c760f8bc6c37bc7f777d70',1,'dbgetrow(DBPROCESS *dbproc, DBINT row): dblib.c'],['../a00518.html#ga60fe544491c760f8bc6c37bc7f777d70',1,'dbgetrow(DBPROCESS *dbproc, DBINT row): dblib.c']]], ['dbgettime',['dbgettime',['../a00518.html#ga6ccffbb3f0cfb10883ad349f1e47c50e',1,'dbgettime(void): dblib.c'],['../a00518.html#ga6ccffbb3f0cfb10883ad349f1e47c50e',1,'dbgettime(void): dblib.c']]], ['dbgetuserdata',['dbgetuserdata',['../a00518.html#gaa5714a91d7c14365fa1e5b164bb2b0b6',1,'dbgetuserdata(DBPROCESS *dbproc): dblib.c'],['../a00518.html#gaa5714a91d7c14365fa1e5b164bb2b0b6',1,'dbgetuserdata(DBPROCESS *dbproc): dblib.c']]], ['dbhasretstat',['dbhasretstat',['../a00519.html#ga7a5062dac92ccedc8459f6d4a530ffb7',1,'dbhasretstat(DBPROCESS *dbproc): dblib.c'],['../a00519.html#ga7a5062dac92ccedc8459f6d4a530ffb7',1,'dbhasretstat(DBPROCESS *dbproc): dblib.c']]], ['dbinit',['dbinit',['../a00518.html#ga564dd3a1bb0425a8957f1714d8b2a7c0',1,'dbinit(void): dblib.c'],['../a00518.html#ga564dd3a1bb0425a8957f1714d8b2a7c0',1,'dbinit(void): dblib.c']]], ['dbiordesc',['DBIORDESC',['../a00518.html#ga74ac942f9b7baa49e1d7d18628321297',1,'DBIORDESC(): sybdb.h'],['../a00524.html#gab842baac0ec420b265d8c199cc45059d',1,'dbiordesc(DBPROCESS *dbproc): dblib.c'],['../a00524.html#gab842baac0ec420b265d8c199cc45059d',1,'dbiordesc(DBPROCESS *dbproc): dblib.c']]], ['dbiowdesc',['DBIOWDESC',['../a00518.html#ga5afb13924cda059d30be36a70dcf2cd9',1,'DBIOWDESC(): sybdb.h'],['../a00524.html#ga666a4d0609ee7f241deb0a62893d2cfa',1,'dbiowdesc(DBPROCESS *dbproc): dblib.c'],['../a00524.html#ga666a4d0609ee7f241deb0a62893d2cfa',1,'dbiowdesc(DBPROCESS *dbproc): dblib.c']]], ['dbisavail',['DBISAVAIL',['../a00518.html#ga40f6c951a851744e58ee715c652a8ac8',1,'sybdb.h']]], ['dbiscount',['dbiscount',['../a00518.html#ga6ba2a7f18cb76d24776e45fd71141494',1,'dbiscount(DBPROCESS *dbproc): dblib.c'],['../a00518.html#ga6ba2a7f18cb76d24776e45fd71141494',1,'dbiscount(DBPROCESS *dbproc): dblib.c']]], ['dbisopt',['dbisopt',['../a00518.html#gac3eb8cb53f50998403ea9aebc6263df9',1,'dbisopt(DBPROCESS *dbproc, int option, const char param[]): dblib.c'],['../a00518.html#gac3eb8cb53f50998403ea9aebc6263df9',1,'dbisopt(DBPROCESS *dbproc, int option, const char param[]): dblib.c']]], ['dblastrow',['DBLASTROW',['../a00518.html#ga10b9b26cf9a901146e9675a9e678632b',1,'DBLASTROW(): sybdb.h'],['../a00524.html#ga13ead146339b43b3a4d9049eb124ef4b',1,'dblastrow(DBPROCESS *dbproc): dblib.c'],['../a00524.html#ga13ead146339b43b3a4d9049eb124ef4b',1,'dblastrow(DBPROCESS *dbproc): dblib.c']]], ['dblib_2ec',['dblib.c',['../a00077.html',1,'']]], ['dblib_5fbuffer_5frow',['dblib_buffer_row',['../a00581.html',1,'']]], ['dblib_5fcontext',['dblib_context',['../a00585.html',1,'']]], ['datetime_20functions',['Datetime functions',['../a00523.html',1,'']]], ['dblib_5ferror_5fmessage',['DBLIB_ERROR_MESSAGE',['../a00524.html#ga73ccf3a130f836159e43074544f338e3',1,'dblib.c']]], ['dblibcontext',['DBLIBCONTEXT',['../a00077.html#ac34310fe36604ce96b30f66427b093ef',1,'dblib.c']]], ['dblogin',['dblogin',['../a00518.html#ga0984798bb806f7451a53bffa7e2c430f',1,'dblogin(void): dblib.c'],['../a00518.html#ga0984798bb806f7451a53bffa7e2c430f',1,'dblogin(void): dblib.c']]], ['dbloginfree',['dbloginfree',['../a00518.html#gac1bdb1766b791153f37dceae8ff64ad6',1,'dbloginfree(LOGINREC *login): dblib.c'],['../a00518.html#gac1bdb1766b791153f37dceae8ff64ad6',1,'dbloginfree(LOGINREC *login): dblib.c']]], ['dbmny4add',['dbmny4add',['../a00522.html#ga0a384938a6586b7411fc42420ffad6ed',1,'dbmny4add(DBPROCESS *dbproc, DBMONEY4 *m1, DBMONEY4 *m2, DBMONEY4 *sum): dblib.c'],['../a00522.html#ga0a384938a6586b7411fc42420ffad6ed',1,'dbmny4add(DBPROCESS *dbproc, DBMONEY4 *m1, DBMONEY4 *m2, DBMONEY4 *sum): dblib.c']]], ['dbmny4cmp',['dbmny4cmp',['../a00522.html#ga109d4868baccb08fad3b26b6f031dc78',1,'dbmny4cmp(DBPROCESS *dbproc, DBMONEY4 *m1, DBMONEY4 *m2): dblib.c'],['../a00522.html#ga109d4868baccb08fad3b26b6f031dc78',1,'dbmny4cmp(DBPROCESS *dbproc, DBMONEY4 *m1, DBMONEY4 *m2): dblib.c']]], ['dbmny4copy',['dbmny4copy',['../a00522.html#gaa6d4c700b628f6a18a9d1ed9f8e2ba62',1,'dbmny4copy(DBPROCESS *dbproc, DBMONEY4 *src, DBMONEY4 *dest): dblib.c'],['../a00522.html#gaa6d4c700b628f6a18a9d1ed9f8e2ba62',1,'dbmny4copy(DBPROCESS *dbprocess, DBMONEY4 *m1, DBMONEY4 *m2): dblib.c']]], ['dbmny4minus',['dbmny4minus',['../a00522.html#ga76177eb61a67dd52424236aba1b16bc9',1,'dbmny4minus(DBPROCESS *dbproc, DBMONEY4 *src, DBMONEY4 *dest): dblib.c'],['../a00522.html#ga76177eb61a67dd52424236aba1b16bc9',1,'dbmny4minus(DBPROCESS *dbproc, DBMONEY4 *src, DBMONEY4 *dest): dblib.c']]], ['dbmny4sub',['dbmny4sub',['../a00522.html#ga856143f4f9c7a5c15fb15633af81487d',1,'dbmny4sub(DBPROCESS *dbproc, DBMONEY4 *m1, DBMONEY4 *m2, DBMONEY4 *diff): dblib.c'],['../a00522.html#ga856143f4f9c7a5c15fb15633af81487d',1,'dbmny4sub(DBPROCESS *dbproc, DBMONEY4 *m1, DBMONEY4 *m2, DBMONEY4 *diff): dblib.c']]], ['dbmny4zero',['dbmny4zero',['../a00522.html#ga070e94f72f12c138a16a7bcdf732fa8b',1,'dbmny4zero(DBPROCESS *dbproc, DBMONEY4 *dest): dblib.c'],['../a00522.html#ga070e94f72f12c138a16a7bcdf732fa8b',1,'dbmny4zero(DBPROCESS *dbproc, DBMONEY4 *dest): dblib.c']]], ['dbmnycmp',['dbmnycmp',['../a00522.html#gadddacad5c3028aa8d3726246c3825651',1,'dbmnycmp(DBPROCESS *dbproc, DBMONEY *m1, DBMONEY *m2): dblib.c'],['../a00522.html#gadddacad5c3028aa8d3726246c3825651',1,'dbmnycmp(DBPROCESS *dbproc, DBMONEY *m1, DBMONEY *m2): dblib.c']]], ['dbmnycopy',['dbmnycopy',['../a00522.html#ga8f1e9aa0280c1cb46c10e5c90b8faced',1,'dbmnycopy(DBPROCESS *dbproc, DBMONEY *src, DBMONEY *dest): dblib.c'],['../a00522.html#ga8f1e9aa0280c1cb46c10e5c90b8faced',1,'dbmnycopy(DBPROCESS *dbproc, DBMONEY *src, DBMONEY *dest): dblib.c']]], ['dbmnydec',['dbmnydec',['../a00522.html#gabedce74748a31ea8a6e4068a5d44d8e4',1,'dbmnydec(DBPROCESS *dbproc, DBMONEY *amount): dblib.c'],['../a00522.html#gabedce74748a31ea8a6e4068a5d44d8e4',1,'dbmnydec(DBPROCESS *dbproc, DBMONEY *mnyptr): dblib.c']]], ['dbmnyinc',['dbmnyinc',['../a00522.html#gabf5216aaaa59ea7e7f07899f82a27faf',1,'dbmnyinc(DBPROCESS *dbproc, DBMONEY *amount): dblib.c'],['../a00522.html#gabf5216aaaa59ea7e7f07899f82a27faf',1,'dbmnyinc(DBPROCESS *dbproc, DBMONEY *mnyptr): dblib.c']]], ['dbmnymaxneg',['dbmnymaxneg',['../a00522.html#gabc3cb44d33bf1b9b18fd59f23e4da722',1,'dbmnymaxneg(DBPROCESS *dbproc, DBMONEY *amount): dblib.c'],['../a00522.html#gabc3cb44d33bf1b9b18fd59f23e4da722',1,'dbmnymaxneg(DBPROCESS *dbproc, DBMONEY *dest): dblib.c']]], ['dbmnymaxpos',['dbmnymaxpos',['../a00522.html#ga70ca2474f6c93acd6e3b842330b712c7',1,'dbmnymaxpos(DBPROCESS *dbproc, DBMONEY *amount): dblib.c'],['../a00522.html#ga70ca2474f6c93acd6e3b842330b712c7',1,'dbmnymaxpos(DBPROCESS *dbproc, DBMONEY *dest): dblib.c']]], ['dbmnyminus',['dbmnyminus',['../a00522.html#ga826bca98da4fd1c3188da45c383c3a68',1,'dbmnyminus(DBPROCESS *dbproc, DBMONEY *src, DBMONEY *dest): dblib.c'],['../a00522.html#ga826bca98da4fd1c3188da45c383c3a68',1,'dbmnyminus(DBPROCESS *dbproc, DBMONEY *src, DBMONEY *dest): dblib.c']]], ['dbmnyzero',['dbmnyzero',['../a00522.html#ga8eab0959d5a3cd534487b350258c939e',1,'dbmnyzero(DBPROCESS *dbproc, DBMONEY *dest): dblib.c'],['../a00522.html#ga8eab0959d5a3cd534487b350258c939e',1,'dbmnyzero(DBPROCESS *dbproc, DBMONEY *dest): dblib.c']]], ['dbmoney',['DBMONEY',['../a01249.html',1,'']]], ['dbmoney4',['DBMONEY4',['../a01253.html',1,'']]], ['dbmonthname',['dbmonthname',['../a00523.html#ga38ecd55ae5827bfa0fd12e2baf0950dd',1,'dbmonthname(DBPROCESS *dbproc, char *language, int monthnum, DBBOOL shortform): dblib.c'],['../a00523.html#ga38ecd55ae5827bfa0fd12e2baf0950dd',1,'dbmonthname(DBPROCESS *dbproc, char *language, int monthnum, DBBOOL shortform): dblib.c']]], ['dbmorecmds',['DBMORECMDS',['../a00518.html#gad887bdce8cb0d3b8c6aaf659eb477b48',1,'DBMORECMDS(): sybdb.h'],['../a00518.html#gac3ba9f53cc77e4dde8f48335ed94ac19',1,'dbmorecmds(DBPROCESS *dbproc): dblib.c'],['../a00518.html#gac3ba9f53cc77e4dde8f48335ed94ac19',1,'dbmorecmds(DBPROCESS *dbproc): dblib.c']]], ['dbmoretext',['dbmoretext',['../a00518.html#ga6f13381522a1fa0b6ce2c15378088cdd',1,'dbmoretext(DBPROCESS *dbproc, DBINT size, const BYTE text[]): dblib.c'],['../a00518.html#ga6f13381522a1fa0b6ce2c15378088cdd',1,'dbmoretext(DBPROCESS *dbproc, DBINT size, const BYTE text[]): dblib.c']]], ['dbmsghandle',['dbmsghandle',['../a00518.html#gadc8af9a65f3719804c2537fd737298ca',1,'dbmsghandle(MHANDLEFUNC handler): dblib.c'],['../a00518.html#gadc8af9a65f3719804c2537fd737298ca',1,'dbmsghandle(MHANDLEFUNC handler): dblib.c']]], ['dbname',['dbname',['../a00518.html#gab185982ffe0b85b8fd19747bd1f433fe',1,'dbname(DBPROCESS *dbproc): dblib.c'],['../a00518.html#gab185982ffe0b85b8fd19747bd1f433fe',1,'dbname(DBPROCESS *dbproc): dblib.c']]], ['dbnullbind',['dbnullbind',['../a00518.html#ga85dcc40c3615f94be96b09b2ec043533',1,'dbnullbind(DBPROCESS *dbproc, int column, DBINT *indicator): dblib.c'],['../a00518.html#ga85dcc40c3615f94be96b09b2ec043533',1,'dbnullbind(DBPROCESS *dbproc, int column, DBINT *indicator): dblib.c']]], ['dbnumalts',['dbnumalts',['../a00518.html#ga67934deac3bebbf8238eff8c0559389a',1,'dbnumalts(DBPROCESS *dbproc, int computeid): dblib.c'],['../a00518.html#ga67934deac3bebbf8238eff8c0559389a',1,'dbnumalts(DBPROCESS *dbproc, int computeid): dblib.c']]], ['dbnumcols',['dbnumcols',['../a00518.html#gadaa9482a082aa3fe52231e17749c2993',1,'dbnumcols(DBPROCESS *dbproc): dblib.c'],['../a00518.html#gadaa9482a082aa3fe52231e17749c2993',1,'dbnumcols(DBPROCESS *dbproc): dblib.c']]], ['dbnumcompute',['dbnumcompute',['../a00518.html#gac554d2cb2da0c9f9fd3d4867998edcc4',1,'dbnumcompute(DBPROCESS *dbproc): dblib.c'],['../a00518.html#gac554d2cb2da0c9f9fd3d4867998edcc4',1,'dbnumcompute(DBPROCESS *dbprocess): dblib.c']]], ['dbnumeric',['DBNUMERIC',['../a01245.html',1,'']]], ['dbnumrets',['dbnumrets',['../a00519.html#gaff09873008411a0573f6d1a9e6c7cf4b',1,'dbnumrets(DBPROCESS *dbproc): dblib.c'],['../a00519.html#gaff09873008411a0573f6d1a9e6c7cf4b',1,'dbnumrets(DBPROCESS *dbproc): dblib.c']]], ['dbopen',['dbopen',['../a00479.html#ae408d8e1c2ab0767d8bfd26d00d1ff6a',1,'dbopen.c']]], ['dboption',['dboption',['../a00893.html',1,'']]], ['dbperror',['dbperror',['../a00524.html#ga302a4ce6559b81808e3be51615cd1b67',1,'dbperror(DBPROCESS *dbproc, DBINT msgno, long errnum,...): dblib.c'],['../a00524.html#ga302a4ce6559b81808e3be51615cd1b67',1,'dbperror(DBPROCESS *dbproc, DBINT msgno, long errnum,...): dblib.c']]], ['dbpivot',['dbpivot',['../a00479.html#af8ada101cd189eff87b3533cbeaaa23b',1,'dbpivot.c']]], ['dbprcollen',['dbprcollen',['../a00518.html#gac0cb0584f6500d61a2ac95a891da73eb',1,'dbprcollen(DBPROCESS *dbproc, int column): dblib.c'],['../a00518.html#gac0cb0584f6500d61a2ac95a891da73eb',1,'dbprcollen(DBPROCESS *dbproc, int column): dblib.c']]], ['dbprhead',['dbprhead',['../a00518.html#ga9dfc2ee533e5e48a7aa8ca22f8d9ed79',1,'dbprhead(DBPROCESS *dbproc): dblib.c'],['../a00518.html#ga9dfc2ee533e5e48a7aa8ca22f8d9ed79',1,'dbprhead(DBPROCESS *dbproc): dblib.c']]], ['dbprrow',['dbprrow',['../a00518.html#gaa30be3414a97aac6139af2e928db91ca',1,'dbprrow(DBPROCESS *dbproc): dblib.c'],['../a00518.html#gaa30be3414a97aac6139af2e928db91ca',1,'dbprrow(DBPROCESS *dbproc): dblib.c']]], ['dbprtype',['dbprtype',['../a00518.html#gac25ae21ca19777ffab1c013bd6049ebf',1,'dbprtype(int token): dblib.c'],['../a00518.html#gac25ae21ca19777ffab1c013bd6049ebf',1,'dbprtype(int token): dblib.c']]], ['dbreadtext',['dbreadtext',['../a00518.html#gadd5685565c8c6c86079e17b8a73b324c',1,'dbreadtext(DBPROCESS *dbproc, void *buf, DBINT bufsize): dblib.c'],['../a00518.html#gadd5685565c8c6c86079e17b8a73b324c',1,'dbreadtext(DBPROCESS *dbproc, void *buf, DBINT bufsize): dblib.c']]], ['dbrecftos',['dbrecftos',['../a00518.html#gabb14ad9f268b92a8d63fa506098b24dd',1,'dbrecftos(const char filename[]): dblib.c'],['../a00518.html#gabb14ad9f268b92a8d63fa506098b24dd',1,'dbrecftos(const char filename[]): dblib.c']]], ['dbresults',['dbresults',['../a00518.html#ga4e26d949be2c3bf71b1a33c75b11d931',1,'dbresults(DBPROCESS *dbproc): dblib.c'],['../a00518.html#ga4e26d949be2c3bf71b1a33c75b11d931',1,'dbresults(DBPROCESS *dbproc): dblib.c']]], ['dbretdata',['dbretdata',['../a00519.html#ga42e187003b74fec6e9ca92d410bfb9c0',1,'dbretdata(DBPROCESS *dbproc, int retnum): dblib.c'],['../a00519.html#ga42e187003b74fec6e9ca92d410bfb9c0',1,'dbretdata(DBPROCESS *dbproc, int retnum): dblib.c']]], ['dbretlen',['dbretlen',['../a00519.html#gab705bf94be535e9d8fc4edc0f48c98b0',1,'dbretlen(DBPROCESS *dbproc, int retnum): dblib.c'],['../a00519.html#gab705bf94be535e9d8fc4edc0f48c98b0',1,'dbretlen(DBPROCESS *dbproc, int retnum): dblib.c']]], ['dbretname',['dbretname',['../a00519.html#ga0311328d63bae5d9bd5aea5ea4914223',1,'dbretname(DBPROCESS *dbproc, int retnum): dblib.c'],['../a00519.html#ga0311328d63bae5d9bd5aea5ea4914223',1,'dbretname(DBPROCESS *dbproc, int retnum): dblib.c']]], ['dbretstatus',['dbretstatus',['../a00519.html#ga2306039d73fbc7045f257b0e750c37b4',1,'dbretstatus(DBPROCESS *dbproc): dblib.c'],['../a00519.html#ga2306039d73fbc7045f257b0e750c37b4',1,'dbretstatus(DBPROCESS *dbproc): dblib.c']]], ['dbrettype',['dbrettype',['../a00519.html#gaa478c8b96923bca02d158d966172ec1b',1,'dbrettype(DBPROCESS *dbproc, int retnum): dblib.c'],['../a00519.html#gaa478c8b96923bca02d158d966172ec1b',1,'dbrettype(DBPROCESS *dbproc, int retnum): dblib.c']]], ['dbrows',['DBROWS',['../a00518.html#ga48d71b32c26703c810191ef916c5448c',1,'DBROWS(): sybdb.h'],['../a00524.html#ga4be2ab59dc7161d6b93c17202e7ae9b1',1,'dbrows(DBPROCESS *dbproc): dblib.c'],['../a00524.html#ga4be2ab59dc7161d6b93c17202e7ae9b1',1,'dbrows(DBPROCESS *dbproc): dblib.c']]], ['dbrowtype',['DBROWTYPE',['../a00518.html#ga6fda3f4982dda5825d13fee392e89fd9',1,'DBROWTYPE(): sybdb.h'],['../a00524.html#gaa2dc8c062342f76adffe53ee280b7fb4',1,'dbrowtype(DBPROCESS *dbproc): dblib.c'],['../a00524.html#gaa2dc8c062342f76adffe53ee280b7fb4',1,'dbrowtype(DBPROCESS *dbprocess): dblib.c']]], ['dbrpcinit',['dbrpcinit',['../a00519.html#ga5b4374c13c7a83cd4345b0bfa3e787bd',1,'dbrpcinit(DBPROCESS *dbproc, const char rpcname[], DBSMALLINT options): rpc.c'],['../a00519.html#ga5b4374c13c7a83cd4345b0bfa3e787bd',1,'dbrpcinit(DBPROCESS *dbproc, const char rpcname[], DBSMALLINT options): rpc.c']]], ['dbrpcparam',['dbrpcparam',['../a00519.html#gaf6b6b0a641180a5c28382df39cd7d346',1,'dbrpcparam(DBPROCESS *dbproc, const char paramname[], BYTE status, int db_type, DBINT maxlen, DBINT datalen, BYTE *value): rpc.c'],['../a00519.html#gaf6b6b0a641180a5c28382df39cd7d346',1,'dbrpcparam(DBPROCESS *dbproc, const char paramname[], BYTE status, int type, DBINT maxlen, DBINT datalen, BYTE *value): rpc.c']]], ['dbrpcsend',['dbrpcsend',['../a00519.html#gafa4dfd181be21e49c397f7daaa9cf96c',1,'dbrpcsend(DBPROCESS *dbproc): rpc.c'],['../a00519.html#gafa4dfd181be21e49c397f7daaa9cf96c',1,'dbrpcsend(DBPROCESS *dbproc): rpc.c']]], ['dbsafestr',['dbsafestr',['../a00518.html#gad0ccc03b94ba2515fd1f5d35559fcb41',1,'dbsafestr(DBPROCESS *dbproc, const char *src, DBINT srclen, char *dest, DBINT destlen, int quotetype): dblib.c'],['../a00518.html#gad0ccc03b94ba2515fd1f5d35559fcb41',1,'dbsafestr(DBPROCESS *dbproc, const char *src, DBINT srclen, char *dest, DBINT destlen, int quotetype): dblib.c']]], ['dbservcharset',['dbservcharset',['../a00518.html#ga39302e8efbb476ba01cff109ffb3661e',1,'dbservcharset(DBPROCESS *dbproc): dblib.c'],['../a00518.html#ga39302e8efbb476ba01cff109ffb3661e',1,'dbservcharset(DBPROCESS *dbprocess): dblib.c']]], ['dbsetavail',['dbsetavail',['../a00524.html#ga5ce245ff327a3d333280fe7b43d69ded',1,'dbsetavail(DBPROCESS *dbproc): dblib.c'],['../a00524.html#ga5ce245ff327a3d333280fe7b43d69ded',1,'dbsetavail(DBPROCESS *dbprocess): dblib.c']]], ['dbsetifile',['dbsetifile',['../a00518.html#ga663350909fec3a1d152316c45a65e708',1,'dbsetifile(char *filename): dblib.c'],['../a00518.html#ga663350909fec3a1d152316c45a65e708',1,'dbsetifile(char *filename): dblib.c']]], ['dbsetinterrupt',['dbsetinterrupt',['../a00518.html#ga335fcbe476ad0f897e4e2ce377f0a8cc',1,'dbsetinterrupt(DBPROCESS *dbproc, DB_DBCHKINTR_FUNC chkintr, DB_DBHNDLINTR_FUNC hndlintr): dblib.c'],['../a00518.html#ga335fcbe476ad0f897e4e2ce377f0a8cc',1,'dbsetinterrupt(DBPROCESS *dbproc, DB_DBCHKINTR_FUNC chkintr, DB_DBHNDLINTR_FUNC hndlintr): dblib.c']]], ['dbsetlapp',['DBSETLAPP',['../a00517.html#gab6c2da7fd615cf7462d555e5387a5580',1,'sybdb.h']]], ['dbsetlbool',['dbsetlbool',['../a00524.html#ga03e850369aca6fba074da5e9da4effd7',1,'dbsetlbool(LOGINREC *login, int value, int which): dblib.c'],['../a00524.html#ga03e850369aca6fba074da5e9da4effd7',1,'dbsetlbool(LOGINREC *login, int value, int which): dblib.c']]], ['dbsetlcharset',['DBSETLCHARSET',['../a00518.html#ga316c0fd24b8dc1259ce9eb4d25016400',1,'sybdb.h']]], ['dbsetlencrypt',['DBSETLENCRYPT',['../a00518.html#gac51e3075197963557a8d2a37d82df921',1,'sybdb.h']]], ['dbsetlhost',['DBSETLHOST',['../a00517.html#gaef0e7a5fcf2d8c8f795b2b06ce4de8b1',1,'sybdb.h']]], ['dbsetllabeled',['DBSETLLABELED',['../a00524.html#gae52fc525116a3491c7e1092ad8257767',1,'sybdb.h']]], ['dbsetllong',['dbsetllong',['../a00524.html#gabdcccf4e0d093ff48c0e7048a4bfaf84',1,'dbsetllong(LOGINREC *login, long value, int which): dblib.c'],['../a00524.html#gabdcccf4e0d093ff48c0e7048a4bfaf84',1,'dbsetllong(LOGINREC *login, long value, int which): dblib.c']]], ['dbsetlname',['dbsetlname',['../a00524.html#gae1fc46447c4f8a9ff7f66607b8cd23b6',1,'dbsetlname(LOGINREC *login, const char *value, int which): dblib.c'],['../a00524.html#gae1fc46447c4f8a9ff7f66607b8cd23b6',1,'dbsetlname(LOGINREC *login, const char *value, int which): dblib.c']]], ['dbsetlnatlang',['dbsetlnatlang',['../a00518.html#ga30e0028e6208414c2245e5fcd6740d9d',1,'dbsetlnatlang(): sybdb.h'],['../a00518.html#gadada0e76c811a6fb84ce6759bcf116b5',1,'DBSETLNATLANG(): sybdb.h']]], ['dbsetlogintime',['dbsetlogintime',['../a00518.html#ga5f1281c07dde5a6d28e60ef62c501d1d',1,'dbsetlogintime(int seconds): dblib.c'],['../a00518.html#ga5f1281c07dde5a6d28e60ef62c501d1d',1,'dbsetlogintime(int seconds): dblib.c']]], ['dbsetlpacket',['DBSETLPACKET',['../a00518.html#gae7e59f9c3cc0ec5916c06977ff7d8565',1,'DBSETLPACKET(): sybdb.h'],['../a00518.html#ga0d0acc4ce2243e48023e022b50e2ac45',1,'dbsetlpacket(): sybdb.h']]], ['dbsetlpwd',['DBSETLPWD',['../a00517.html#ga61e04e8e2f0d7f1740d40634041f98eb',1,'sybdb.h']]], ['dbsetluser',['DBSETLUSER',['../a00517.html#gafbe7e48171d2f9b1d4f99e0bfdd98f5e',1,'sybdb.h']]], ['dbsetlversion',['dbsetlversion',['../a00518.html#gaa22dce1ee0eb83059699c34c47d07c14',1,'dbsetlversion(LOGINREC *login, BYTE version): dblib.c'],['../a00518.html#gaa22dce1ee0eb83059699c34c47d07c14',1,'dbsetlversion(LOGINREC *login, BYTE version): dblib.c'],['../a00524.html#ga7306859300823c120d807108a061c45a',1,'DBSETLVERSION(): sybdb.h']]], ['dbsetmaxprocs',['dbsetmaxprocs',['../a00518.html#gaf2ca0e63f800b3839684c894ff651dd4',1,'dbsetmaxprocs(int maxprocs): dblib.c'],['../a00518.html#gaf2ca0e63f800b3839684c894ff651dd4',1,'dbsetmaxprocs(int maxprocs): dblib.c']]], ['dbsetnull',['dbsetnull',['../a00518.html#ga399512ec78c15ce3db79ea88ef3b1293',1,'dbsetnull(DBPROCESS *dbproc, int bindtype, int bindlen, BYTE *bindval): dblib.c'],['../a00518.html#ga399512ec78c15ce3db79ea88ef3b1293',1,'dbsetnull(DBPROCESS *dbprocess, int bindtype, int bindlen, BYTE *bindval): dblib.c']]], ['dbsetopt',['dbsetopt',['../a00518.html#ga9d660d278f3f58871b4086c0e175f4c6',1,'dbsetopt(DBPROCESS *dbproc, int option, const char *char_param, int int_param): dblib.c'],['../a00518.html#ga9d660d278f3f58871b4086c0e175f4c6',1,'dbsetopt(DBPROCESS *dbproc, int option, const char *char_param, int int_param): dblib.c']]], ['dbsetrow',['dbsetrow',['../a00518.html#gaeb3d621e4f6846bb228b0a596d8758c0',1,'dbsetrow(DBPROCESS *dbproc, DBINT row): dblib.c'],['../a00518.html#gaeb3d621e4f6846bb228b0a596d8758c0',1,'dbsetrow(DBPROCESS *dbprocess, DBINT row): dblib.c']]], ['dbsettime',['dbsettime',['../a00518.html#gada4b41f34542a87f0cd87e78e56d18bb',1,'dbsettime(int seconds): dblib.c'],['../a00518.html#gada4b41f34542a87f0cd87e78e56d18bb',1,'dbsettime(int seconds): dblib.c']]], ['dbsetuserdata',['dbsetuserdata',['../a00518.html#gabea9c70d02bf3e46bbb1d759915cb91e',1,'dbsetuserdata(DBPROCESS *dbproc, BYTE *ptr): dblib.c'],['../a00518.html#gabea9c70d02bf3e46bbb1d759915cb91e',1,'dbsetuserdata(DBPROCESS *dbproc, BYTE *ptr): dblib.c']]], ['dbsetversion',['dbsetversion',['../a00518.html#gab9aa181fb3081ffb314340cbd71e434d',1,'dbsetversion(DBINT version): dblib.c'],['../a00518.html#gab9aa181fb3081ffb314340cbd71e434d',1,'dbsetversion(DBINT version): dblib.c']]], ['dbspid',['dbspid',['../a00518.html#ga223a6d333f95e726b0b42ec19a076731',1,'dbspid(DBPROCESS *dbproc): dblib.c'],['../a00518.html#ga223a6d333f95e726b0b42ec19a076731',1,'dbspid(DBPROCESS *dbproc): dblib.c']]], ['dbspr1row',['dbspr1row',['../a00518.html#gaf641c8e3d34607ca8b7ac2afed3e6d67',1,'dbspr1row(DBPROCESS *dbproc, char *buffer, DBINT buf_len): dblib.c'],['../a00518.html#gaf641c8e3d34607ca8b7ac2afed3e6d67',1,'dbspr1row(DBPROCESS *dbproc, char *buffer, DBINT buf_len): dblib.c']]], ['dbspr1rowlen',['dbspr1rowlen',['../a00518.html#ga308918c13a5b1644269c1654fbea96ac',1,'dbspr1rowlen(DBPROCESS *dbproc): dblib.c'],['../a00518.html#ga308918c13a5b1644269c1654fbea96ac',1,'dbspr1rowlen(DBPROCESS *dbproc): dblib.c']]], ['dbsprhead',['dbsprhead',['../a00518.html#gaaa4839a9c88e5b90f33bd2407fcbc43e',1,'dbsprhead(DBPROCESS *dbproc, char *buffer, DBINT buf_len): dblib.c'],['../a00518.html#gaaa4839a9c88e5b90f33bd2407fcbc43e',1,'dbsprhead(DBPROCESS *dbproc, char *buffer, DBINT buf_len): dblib.c']]], ['dbsprline',['dbsprline',['../a00518.html#gacfaf9feb29c87cfb660886162f643152',1,'dbsprline(DBPROCESS *dbproc, char *buffer, DBINT buf_len, DBCHAR line_char): dblib.c'],['../a00518.html#gacfaf9feb29c87cfb660886162f643152',1,'dbsprline(DBPROCESS *dbproc, char *buffer, DBINT buf_len, DBCHAR line_char): dblib.c']]], ['dbsqlexec',['dbsqlexec',['../a00518.html#gaae889abeb145ec41f7361aa8f597fe46',1,'dbsqlexec(DBPROCESS *dbproc): dblib.c'],['../a00518.html#gaae889abeb145ec41f7361aa8f597fe46',1,'dbsqlexec(DBPROCESS *dbproc): dblib.c']]], ['dbsqlok',['dbsqlok',['../a00518.html#gae1f50a6a2c31fda57cb481922b06841e',1,'dbsqlok(DBPROCESS *dbproc): dblib.c'],['../a00518.html#gae1f50a6a2c31fda57cb481922b06841e',1,'dbsqlok(DBPROCESS *dbproc): dblib.c']]], ['dbsqlsend',['dbsqlsend',['../a00518.html#gac980139b9cea03cf93e373d425991481',1,'dbsqlsend(DBPROCESS *dbproc): dblib.c'],['../a00518.html#gac980139b9cea03cf93e373d425991481',1,'dbsqlsend(DBPROCESS *dbproc): dblib.c']]], ['dbstrbuild',['dbstrbuild',['../a00518.html#gab5fe0cd5f24d4fd33670111035a4fbed',1,'dbstrbuild(DBPROCESS *dbproc, char *charbuf, int bufsize, char *text, char *formats,...): dblib.c'],['../a00518.html#gab5fe0cd5f24d4fd33670111035a4fbed',1,'dbstrbuild(DBPROCESS *dbproc, char *charbuf, int bufsize, char *text, char *formats,...): dblib.c']]], ['dbstrcpy',['dbstrcpy',['../a00518.html#gaf130b12e9e58b1bfd4a6685e33f5b3cd',1,'dbstrcpy(DBPROCESS *dbproc, int start, int numbytes, char *dest): dblib.c'],['../a00518.html#gaf130b12e9e58b1bfd4a6685e33f5b3cd',1,'dbstrcpy(DBPROCESS *dbproc, int start, int numbytes, char *dest): dblib.c']]], ['dbstring',['dbstring',['../a01273.html',1,'']]], ['dbstrlen',['dbstrlen',['../a00518.html#ga13caa07ec45cd6f64e9197d29e3cfe5e',1,'dbstrlen(DBPROCESS *dbproc): dblib.c'],['../a00518.html#ga13caa07ec45cd6f64e9197d29e3cfe5e',1,'dbstrlen(DBPROCESS *dbproc): dblib.c']]], ['dbtablecolinfo',['dbtablecolinfo',['../a00518.html#ga9804fc70ae6ed35c92cd75d410dad570',1,'dbtablecolinfo(DBPROCESS *dbproc, DBINT column, DBCOL *pdbcol): dblib.c'],['../a00518.html#ga9804fc70ae6ed35c92cd75d410dad570',1,'dbtablecolinfo(DBPROCESS *dbproc, DBINT column, DBCOL *pdbcol): dblib.c']]], ['dbtds',['dbtds',['../a00524.html#ga8d765d810a40dfa01b39995a8e7406f0',1,'dbtds(DBPROCESS *dbproc): dblib.c'],['../a00524.html#ga8d765d810a40dfa01b39995a8e7406f0',1,'dbtds(DBPROCESS *dbprocess): dblib.c'],['../a00518.html#ga1644cf55d37435711df65c12a3f7b785',1,'DBTDS(): sybdb.h']]], ['dbtds_5funknown',['DBTDS_UNKNOWN',['../a00479.html#a4e19c79341755a7c6666197d381e1ac6',1,'sybdb.h']]], ['dbtxptr',['dbtxptr',['../a00518.html#ga57e4098b153a030f0be02bcd98e08ba2',1,'dbtxptr(DBPROCESS *dbproc, int column): dblib.c'],['../a00518.html#ga57e4098b153a030f0be02bcd98e08ba2',1,'dbtxptr(DBPROCESS *dbproc, int column): dblib.c']]], ['dbtxtimestamp',['dbtxtimestamp',['../a00518.html#gac3f11142ec7ff25b1f8972af10fe9454',1,'dbtxtimestamp(DBPROCESS *dbproc, int column): dblib.c'],['../a00518.html#gac3f11142ec7ff25b1f8972af10fe9454',1,'dbtxtimestamp(DBPROCESS *dbproc, int column): dblib.c']]], ['dbtypeinfo',['dbtypeinfo',['../a01269.html',1,'']]], ['dbuse',['dbuse',['../a00518.html#ga66ea891910f0a357cc78107d6ab7d962',1,'dbuse(DBPROCESS *dbproc, const char *name): dblib.c'],['../a00518.html#ga66ea891910f0a357cc78107d6ab7d962',1,'dbuse(DBPROCESS *dbproc, const char *name): dblib.c']]], ['dbvarybin',['DBVARYBIN',['../a01241.html',1,'']]], ['dbvarychar',['DBVARYCHAR',['../a01237.html',1,'']]], ['dbvarylen',['dbvarylen',['../a00518.html#ga57c856964a9a0b4cc43f5192647c51e7',1,'dbvarylen(DBPROCESS *dbproc, int column): dblib.c'],['../a00518.html#ga57c856964a9a0b4cc43f5192647c51e7',1,'dbvarylen(DBPROCESS *dbproc, int column): dblib.c']]], ['dbversion',['dbversion',['../a00518.html#ga666726c86108342b1c1f27eecf68e13c',1,'dbversion(): dblib.c'],['../a00518.html#ga666726c86108342b1c1f27eecf68e13c',1,'dbversion(void): dblib.c']]], ['dbversion_5funknown',['DBVERSION_UNKNOWN',['../a00479.html#adbc038c5d57c0ab4c1c9e081a664dc0f',1,'sybdb.h']]], ['dbwillconvert',['dbwillconvert',['../a00518.html#gaaf8349999c16b3c36caf5947747a2915',1,'dbwillconvert(int srctype, int desttype): dblib.c'],['../a00518.html#gaaf8349999c16b3c36caf5947747a2915',1,'dbwillconvert(int srctype, int desttype): dblib.c']]], ['dbwritetext',['dbwritetext',['../a00518.html#ga548153eb2eae76c48aa9d4b72258dc1c',1,'dbwritetext(DBPROCESS *dbproc, char *objname, DBBINARY *textptr, DBTINYINT textptrlen, DBBINARY *timestamp, DBBOOL log, DBINT size, BYTE *text): dblib.c'],['../a00518.html#ga548153eb2eae76c48aa9d4b72258dc1c',1,'dbwritetext(DBPROCESS *dbproc, char *objname, DBBINARY *textptr, DBTINYINT textptrlen, DBBINARY *timestamp, DBBOOL log, DBINT size, BYTE *text): dblib.c']]], ['decimicrosecond',['decimicrosecond',['../a01081.html#a838e73fd12eec9e3b5368316198f4762',1,'tdsdaterec']]], ['default_5ferr_5fhandler',['default_err_handler',['../a00524.html#gaccbc6d98d9528c48cf0254d809ca73ff',1,'dblib.c']]], ['defer_5fclose',['defer_close',['../a01157.html#a7a9dd4b827046f94f3d6a53035928d9c',1,'tds_cursor::defer_close()'],['../a01165.html#a0c0907ff62841056a9c1e023d68eb0f0',1,'tds_dynamic::defer_close()']]], ['des_5fkey',['des_key',['../a00905.html',1,'']]], ['determine_5fadjusted_5fsize',['determine_adjusted_size',['../a00536.html#ga87209537d51f069fee02bc224da492cb',1,'determine_adjusted_size(const TDSICONV *char_conv, int size): token.c'],['../a00536.html#ga87209537d51f069fee02bc224da492cb',1,'determine_adjusted_size(const TDSICONV *char_conv, int size): token.c']]], ['dlist_5flist_5ftype',['DLIST_LIST_TYPE',['../a00929.html',1,'']]], ['dlist_5fring',['dlist_ring',['../a00925.html',1,'']]], ['dsn',['dsn',['../a00637.html#acd76726add649629f26f1f1754fe48cf',1,'DSNINFO']]], ['dsninfo',['DSNINFO',['../a00637.html',1,'']]], ['dstr',['DSTR',['../a00434.html#afddddf5bd7ad223cadee3d3bdc899954',1,'tds.h']]], ['dstr_5finitializer',['DSTR_INITIALIZER',['../a00535.html#ga581a03a4de6c926c57b4a75a11214df4',1,'string.h']]], ['dynamic_20string_20functions',['Dynamic string functions',['../a00535.html',1,'']]], ['dyns',['dyns',['../a01189.html#a7dc98cfe507c626073b6e76985a06a8a',1,'tds_connection']]] ]; freetds-1.00.82/doc/reference/search/all_5.html100644 025423 025423 00000001765 13242511131 0014662
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/all_5.js100644 025423 025423 00000000430 13242511131 0014316var searchData= [ ['emulated',['emulated',['../a01165.html#ad3fedfbec2ba0db4a64b82779d95a0c5',1,'tds_dynamic']]], ['end_5flogin_5fevent',['END_LOGIN_EVENT',['../a00681.html',1,'']]], ['env',['env',['../a01189.html#a17b3352a5f14239b2eecc4fc272bfe2a',1,'tds_connection']]] ]; freetds-1.00.82/doc/reference/search/all_6.html100644 025423 025423 00000001765 13242511131 0014663
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/all_6.js100644 025423 025423 00000000544 13242511131 0014325var searchData= [ ['f',['f',['../a00693.html#a460a14dac0d298ff184e3cc67aafe91b',1,'tds_file_stream']]], ['from_5fmalloc',['from_malloc',['../a00689.html#ad483e0559eaa78104c4978667a0b739c',1,'tds_pbcb']]], ['func_5finfo',['func_info',['../a00629.html',1,'']]], ['freetds_20reference_20manual',['FreeTDS Reference Manual',['../index.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/all_7.html100644 025423 025423 00000001765 13242511131 0014664
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/all_7.js100644 025423 025423 00000000455 13242511131 0014327var searchData= [ ['has_5fstatus',['has_status',['../a01193.html#a75ab58b901d242ae27e36bd39b23a54f',1,'tds_socket']]], ['hour',['hour',['../a01081.html#ae9f0348efe607ac7333eac841be46333',1,'tdsdaterec']]], ['how_20to_20add_20a_20new_20type',['How to add a new type',['../a01298.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/all_8.html100644 025423 025423 00000001765 13242511131 0014665
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/all_8.js100644 025423 025423 00000002164 13242511131 0014327var searchData= [ ['internal_20bcp_20functions',['Internal bcp functions',['../a00521.html',1,'']]], ['internals',['Internals',['../a00524.html',1,'']]], ['iconv_2ec',['iconv.c',['../a01342.html',1,'']]], ['iconv_2ec',['iconv.c',['../a01339.html',1,'']]], ['id',['id',['../a01165.html#a72332750aee80a0a94c92b35d7263d76',1,'tds_dynamic']]], ['in_5fbuf',['in_buf',['../a01193.html#a24c1995f6e8d0f9a5990998524b00b6b',1,'tds_socket']]], ['in_5fcancel',['in_cancel',['../a01193.html#ae67d850cfbedf6b1e6b02111d4388d42',1,'tds_socket']]], ['in_5fflag',['in_flag',['../a01193.html#a765e007b69a2e188c989f05a689f6a11',1,'tds_socket']]], ['in_5flen',['in_len',['../a01193.html#a0b6e65b9d00b3a4efbf78b2d866cca20',1,'tds_socket']]], ['in_5fpos',['in_pos',['../a01193.html#a9d1b4fc8e1e801fdc703ee7bb68d9838',1,'tds_socket']]], ['in_5frow',['in_row',['../a01193.html#ab6a91be7f3b9966216e621c60e8151f2',1,'tds_socket']]], ['ip_5faddrs',['ip_addrs',['../a01101.html#a6e04f60eb1fae0e632ab6cddbb804a55',1,'tds_login']]], ['is_5fdatetime_5ftype',['is_datetime_type',['../a00434.html#a4a70a4d36139165f8be99ea6fffb57ce',1,'tds.h']]] ]; freetds-1.00.82/doc/reference/search/all_9.html100644 025423 025423 00000001765 13242511131 0014666
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/all_9.js100644 025423 025423 00000000105 13242511131 0014321var searchData= [ ['key_5ft',['KEY_T',['../a00553.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/all_a.html100644 025423 025423 00000001765 13242511131 0014736
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/all_a.js100644 025423 025423 00000001075 13242511131 0014400var searchData= [ ['left',['left',['../a00693.html#a3a7b329811d3ba3154aefa3b60ae1770',1,'tds_file_stream']]], ['libtds_20api',['LibTDS API',['../a00537.html',1,'']]], ['login',['login',['../a00637.html#ad7ff73ac9d36bdb6dc6d6c8f8c6847bb',1,'DSNINFO::login()'],['../a01193.html#a00c22eeebbdb781ab7b9d5e8403e451e',1,'tds_socket::login()']]], ['login_5fevent',['LOGIN_EVENT',['../a00677.html',1,'']]], ['login_5ftimeout',['login_timeout',['../a00585.html#a2da93c0f3681f87f94ad169deb09dc64',1,'dblib_context']]], ['loginrec',['LOGINREC',['../a00565.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/all_b.html100644 025423 025423 00000001765 13242511131 0014737
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/all_b.js100644 025423 025423 00000001412 13242511131 0014374var searchData= [ ['money_20functions',['Money functions',['../a00522.html',1,'']]], ['md4context',['MD4Context',['../a01213.html',1,'']]], ['md5context',['MD5Context',['../a01217.html',1,'']]], ['memory_20allocation',['Memory allocation',['../a00532.html',1,'']]], ['metacomp',['METACOMP',['../a00549.html',1,'']]], ['metadata',['METADATA',['../a00541.html',1,'']]], ['metadata_5ft',['metadata_t',['../a00605.html',1,'']]], ['minute',['minute',['../a01081.html#a81d1931139497023deb1bb75dc0aae7a',1,'tdsdaterec']]], ['month',['month',['../a01081.html#af1542b5698f668f7df650b20fa27c177',1,'tdsdaterec']]], ['mpz_5ft',['mpz_t',['../a00737.html',1,'']]], ['msdblib',['msdblib',['../a00901.html#af3aab1ff30d324143f440bcd9f60d1c3',1,'tds_dblib_dbprocess']]] ]; freetds-1.00.82/doc/reference/search/all_c.html100644 025423 025423 00000001765 13242511131 0014740
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/all_c.js100644 025423 025423 00000002164 13242511131 0014402var searchData= [ ['name',['name',['../a00749.html#aabc5f36785b65913edd51be1fd8ea1e3',1,'namelist::name()'],['../a01121.html#aa7152f00b01261e88db974cac1348c74',1,'tds_encoding::name()']]], ['name_5ft',['name_t',['../a00613.html',1,'']]], ['namelist',['namelist',['../a00749.html',1,'']]], ['names_5fblob_5fprefix_5ft',['names_blob_prefix_t',['../a00701.html',1,'']]], ['native_5finfo',['native_info',['../a00633.html',1,'']]], ['network_20functions',['Network functions',['../a00534.html',1,'']]], ['new_5fpassword',['new_password',['../a01101.html#a90cffdbb528cddb0cf30d1f9de7c3e9c',1,'tds_login']]], ['next',['next',['../a00749.html#a3aaf5848cba17d39d5ea5bd180590bb3',1,'namelist::next()'],['../a00993.html#ad2152f527dcdd108165e7e03fe476b8f',1,'_hstmt::next()'],['../a01157.html#a8743877d9147d83ef0ae64e04c8a46fb',1,'tds_cursor::next()'],['../a01165.html#adc93b94b6b4caf15dcf45297d928a8da',1,'tds_dynamic::next()']]], ['nullreps',['nullreps',['../a00901.html#a2baeb464798b61d8da14887eb35d63e7',1,'tds_dblib_dbprocess']]], ['num_5fid',['num_id',['../a01165.html#af6fd2355838cce1689fb0e04724b7b6a',1,'tds_dynamic']]] ]; freetds-1.00.82/doc/reference/search/all_d.html100644 025423 025423 00000001765 13242511131 0014741
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/all_d.js100644 025423 025423 00000006362 13242511131 0014407var searchData= [ ['objectinfo',['OBJECTINFO',['../a00569.html',1,'']]], ['odbc_20api',['ODBC API',['../a00526.html',1,'']]], ['odbc_5fc_5fto_5fserver_5ftype',['odbc_c_to_server_type',['../a00527.html#ga3f0a413cea480a38d3d9b90c95515f6b',1,'odbc_c_to_server_type(int c_type): odbc_util.c'],['../a00527.html#ga3f0a413cea480a38d3d9b90c95515f6b',1,'odbc_c_to_server_type(int c_type): odbc_util.c']]], ['odbc_5fget_5fparam_5flen',['odbc_get_param_len',['../a00527.html#ga35028e8de1d50dc51ccef1d645c55e2a',1,'odbc_get_param_len(const struct _drecord *drec_axd, const struct _drecord *drec_ixd, const TDS_DESC *axd, unsigned int n_row): odbc_util.c'],['../a00527.html#ga35028e8de1d50dc51ccef1d645c55e2a',1,'odbc_get_param_len(const struct _drecord *drec_axd, const struct _drecord *drec_ixd, const TDS_DESC *axd, unsigned int n_row): odbc_util.c']]], ['odbc_5frdbms_5fversion',['odbc_rdbms_version',['../a00527.html#gae85ff7fb2002b5a7abc04fbee79e5525',1,'odbc_rdbms_version(TDSSOCKET *tds, char *pversion_string): odbc_util.c'],['../a00527.html#gae85ff7fb2002b5a7abc04fbee79e5525',1,'odbc_rdbms_version(TDSSOCKET *tds_socket, char *pversion_string): odbc_util.c']]], ['odbc_5fset_5fconcise_5fc_5ftype',['odbc_set_concise_c_type',['../a00527.html#ga128f6b09cde0af252370ba89cfa1fb78',1,'odbc_set_concise_c_type(SQLSMALLINT concise_type, struct _drecord *drec, int check_only): odbc_util.c'],['../a00527.html#ga128f6b09cde0af252370ba89cfa1fb78',1,'odbc_set_concise_c_type(SQLSMALLINT concise_type, struct _drecord *drec, int check_only): odbc_util.c']]], ['odbc_5fset_5fconcise_5fsql_5ftype',['odbc_set_concise_sql_type',['../a00527.html#ga125574bd2de677438909612db80041ea',1,'odbc_set_concise_sql_type(SQLSMALLINT concise_type, struct _drecord *drec, int check_only): odbc_util.c'],['../a00527.html#ga125574bd2de677438909612db80041ea',1,'odbc_set_concise_sql_type(SQLSMALLINT concise_type, struct _drecord *drec, int check_only): odbc_util.c']]], ['odbc_5fset_5fstring_5fflag',['odbc_set_string_flag',['../a00527.html#gadba4490bf3183799a70c9e2f44fab331',1,'odbc_set_string_flag(TDS_DBC *dbc, SQLPOINTER buffer, SQLINTEGER cbBuffer, void FAR *pcbBuffer, const char *s, int len, int flag): odbc_util.c'],['../a00527.html#gadba4490bf3183799a70c9e2f44fab331',1,'odbc_set_string_flag(TDS_DBC *dbc, SQLPOINTER buffer, SQLINTEGER cbBuffer, void FAR *pcbBuffer, const char *s, int len, int flag): odbc_util.c']]], ['odbc_20utility',['ODBC utility',['../a00527.html',1,'']]], ['offset',['offset',['../a01077.html#a76f4cbcb3bc7c10b3616579ec7861f58',1,'TDS_DATETIMEALL::offset()'],['../a01265.html#a13159d738e1d0b582a3a731123feb5f3',1,'DBDATETIMEALL::offset()']]], ['options',['options',['../a01157.html#a1be9f69f84a6d83ce86380c33a2bf9f8',1,'tds_cursor']]], ['origdsn',['origdsn',['../a00637.html#a8127a82b8c4130820a4c44f88eda8bcf',1,'DSNINFO']]], ['out_5fbuf',['out_buf',['../a01193.html#ad6b5121e435d22d640a645b98833cb9d',1,'tds_socket']]], ['out_5fbuf_5fmax',['out_buf_max',['../a01193.html#ae6fc66be718f3211fac3b835557e330e',1,'tds_socket']]], ['out_5fflag',['out_flag',['../a01193.html#a9bb663ee7c71f56f1602cbfcd993018c',1,'tds_socket']]], ['out_5fpos',['out_pos',['../a01193.html#a426adbd80f29f477377e42e8f78d3ff0',1,'tds_socket']]] ]; freetds-1.00.82/doc/reference/search/all_e.html100644 025423 025423 00000001765 13242511131 0014742
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/all_e.js100644 025423 025423 00000004262 13242511131 0014405var searchData= [ ['primary_20functions',['Primary functions',['../a00518.html',1,'']]], ['param_5fcount',['param_count',['../a00993.html#a36e6cb901103834b074bf5a00fe7afbe',1,'_hstmt']]], ['param_5fnum',['param_num',['../a00993.html#a9b8cb8cb0826323811192adbed126348',1,'_hstmt']]], ['params',['params',['../a00993.html#aebe221315ae3dfd4850c399ad204ca4f',1,'_hstmt::params()'],['../a01165.html#adba427a655336d0b128cdec36544464b',1,'tds_dynamic::params()']]], ['parse_5fint8',['parse_int8',['../a00530.html#gace939c1fa676d172cb0cae94848b7fac',1,'convert.c']]], ['parse_5fnumeric',['parse_numeric',['../a00530.html#ga53a19b5da172ff364d01e8f04b97015a',1,'convert.c']]], ['parse_5fserver_5fname_5ffor_5fport',['parse_server_name_for_port',['../a00529.html#gaa9670914093b354e7a123b10ba877813',1,'config.c']]], ['password',['password',['../a01101.html#a411a965cbfdb05e69b6da62a30531bb2',1,'tds_login']]], ['pb',['pb',['../a00689.html#a616193286e91acc0a5dbe8942550e11e',1,'tds_pbcb']]], ['pd',['pd',['../a00573.html',1,'']]], ['pending_5fclose',['pending_close',['../a01189.html#a824fd854618d7d2005f2bec452247be7',1,'tds_connection']]], ['pivot_5ft',['pivot_t',['../a00609.html',1,'']]], ['pivot_5ft',['pivot_t',['../a00561.html',1,'_options']]], ['poll_2eh',['poll.h',['../a00461.html',1,'']]], ['pollfd',['pollfd',['../a01229.html',1,'']]], ['port',['port',['../a01101.html#aec3fe0f3f17448018ae5c92cff3abb6d',1,'tds_login']]], ['prepared_5fpos',['prepared_pos',['../a00993.html#a937cc5e2c56a56cee0d57b8bb3c2f549',1,'_hstmt']]], ['prev',['prev',['../a00993.html#ad36ac281bcfcc5a6b6af0c1428b41d5f',1,'_hstmt']]], ['product_5fversion',['product_version',['../a01189.html#a7473cd879ba62019eb9d3bbb153832a1',1,'tds_connection']]], ['profileparam',['ProfileParam',['../a00617.html',1,'']]], ['ptw32_5fmcs_5fnode_5ft_5f',['ptw32_mcs_node_t_',['../a00685.html',1,'']]], ['put_5fdata',['put_data',['../a01129.html#a09912b32c805bec7ab47080b42bf93a1',1,'tds_column_funcs']]], ['put_5finfo',['put_info',['../a01129.html#afed4993bb75cb37dfc7a6bcdb74820e2',1,'tds_column_funcs']]], ['put_5finfo_5flen',['put_info_len',['../a01129.html#a8da57c1e795fc9fb5d268b5fe690d9c3',1,'tds_column_funcs']]] ]; freetds-1.00.82/doc/reference/search/all_f.html100644 025423 025423 00000001765 13242511131 0014743
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/all_f.js100644 025423 025423 00000001010 13242511131 0014372var searchData= [ ['quarter',['quarter',['../a01081.html#aa0efc92bb0079287e043bb2c46c4603d',1,'tdsdaterec']]], ['query',['query',['../a00993.html#aaf4c8eb3163d2261ce6ce90118a70aec',1,'_hstmt::query()'],['../a01157.html#aeec2a01af48693b8b22449f15725d502',1,'tds_cursor::query()'],['../a01165.html#a1cee141e5f7045e691eec830cec1c158',1,'tds_dynamic::query()'],['../a00533.html',1,'(Global Namespace)']]], ['query_5ftimeout',['query_timeout',['../a00585.html#abf71abb24c7afea7dd7ef440048ea4c9',1,'dblib_context']]] ]; freetds-1.00.82/doc/reference/search/all_10.html100644 025423 025423 00000001766 13242511131 0014737
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/all_10.js100644 025423 025423 00000003233 13242511131 0014376var searchData= [ ['remote_20procedure_20functions',['Remote Procedure functions',['../a00519.html',1,'']]], ['read',['read',['../a01041.html#a2f0be7677a1bf9c730e3c697bfba21c9',1,'tds_input_stream']]], ['read_2ec',['read.c',['../a00311.html',1,'']]], ['read_5fand_5fconvert',['read_and_convert',['../a00534.html#ga676c4dee6522815b16fdc8e448e43590',1,'read.c']]], ['ref_5fcount',['ref_count',['../a00585.html#a812580afdfca53b6d54a7d09938c65c2',1,'dblib_context::ref_count()'],['../a01157.html#a692ccceff71d836df0d084ec26123c2d',1,'tds_cursor::ref_count()'],['../a01165.html#a2798c66fb3c8637c7fb29c6d1efebfa4',1,'tds_dynamic::ref_count()']]], ['res_5finfo',['res_info',['../a01165.html#ac736e163c0d4cdbca980a861214d99e7',1,'tds_dynamic']]], ['resinfo',['resinfo',['../a00581.html#ad49b82677ae277e5d5b0038f522da293',1,'dblib_buffer_row']]], ['ret_5fstatus',['ret_status',['../a01193.html#a355e0b8c6219908747f82cd7482c6efb',1,'tds_socket']]], ['row',['row',['../a00581.html#a015599345b266045d8bd3fac731e4675',1,'dblib_buffer_row']]], ['row_5fcount',['row_count',['../a00993.html#a8fd44f3c44ae4c83a1bdda0b73776ecd',1,'_hstmt']]], ['row_5fdata',['row_data',['../a00581.html#a5a057d6bbecfac1a85a9fbcd09eaf3a0',1,'dblib_buffer_row']]], ['row_5fstatus',['row_status',['../a00993.html#a41dd89b2dc41fe0e747580f6ea807063',1,'_hstmt']]], ['rows_5faffected',['rows_affected',['../a01193.html#a803e29dabc76d35227f5de2488f29877',1,'tds_socket']]], ['rsa_5fpublic_5fkey',['rsa_public_key',['../a00745.html',1,'']]], ['rtrim',['rtrim',['../a00521.html#ga4d5be57b25a0654e2170fd656dc35489',1,'bcp.c']]], ['results_20processing',['Results processing',['../a00536.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/all_11.html100644 025423 025423 00000001766 13242511131 0014740
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/all_11.js100644 025423 025423 00000005134 13242511131 0014401var searchData= [ ['s',['s',['../a01189.html#a4853be2466fd81c9463ac88f8da8b9c2',1,'tds_connection']]], ['s_5fsqlmsgmap',['s_SqlMsgMap',['../a00621.html',1,'']]], ['s_5fv3to2map',['s_v3to2map',['../a00625.html',1,'']]], ['search_5finterface_5ffile',['search_interface_file',['../a00529.html#gaca20b6e5f5a5ac1727126712dd39564b',1,'config.c']]], ['second',['second',['../a01081.html#a8560717700de586f279af702bac86ad6',1,'tdsdaterec']]], ['select_5finfo',['select_info',['../a00645.html',1,'']]], ['send_5fpacket',['send_packet',['../a01193.html#a1c7c38af79f5845b90f19aaf5f63ce18',1,'tds_socket']]], ['server_5fcharset',['server_charset',['../a01101.html#a80dae8a766655c5c7365ba42d4d4d62c',1,'tds_login']]], ['server_5fname',['server_name',['../a01101.html#a69ed4cfded269727901bed2f95f1652e',1,'tds_login']]], ['server_5frealm_5fname',['server_realm_name',['../a01101.html#a1e5a5a13fa3cb0c5168d44187b52c814',1,'tds_login']]], ['server_5fspn',['server_spn',['../a01101.html#ad8d335a04cf09453a87a8e0b9118eaeb',1,'tds_login']]], ['size',['size',['../a01065.html#a9d221dd860f67d97daa71e107dce3470',1,'tds_dynamic_stream']]], ['sizes',['sizes',['../a00581.html#abe1aa9f8ea96dda1400654813e68130a',1,'dblib_buffer_row']]], ['skip_5fone_5finput_5fsequence',['skip_one_input_sequence',['../a00531.html#ga3380140fc6eb9f2090c430f40e846876',1,'iconv.c']]], ['status',['status',['../a01157.html#ab5d6a587ac5780f001d383d4b874852f',1,'tds_cursor']]], ['stmt_5flist',['stmt_list',['../a00985.html#a4a9f3e8f1eba573df79a1ed300d8fc91',1,'_hdbc']]], ['store_5fmonthname',['store_monthname',['../a00530.html#ga17a0597ec3522c7f1ddb54956226dbfc',1,'convert.c']]], ['stream',['stream',['../a00693.html#abb6db59e849d11de92f4c55c61d51744',1,'tds_file_stream']]], ['stream_2ec',['stream.c',['../a01330.html',1,'']]], ['string_5flinked_5flist',['string_linked_list',['../a00757.html',1,'']]], ['string_5fto_5fint',['string_to_int',['../a00530.html#ga0176fafd412b5b8005bf1202fbc13b00',1,'convert.c']]], ['string_5fto_5fint8',['string_to_int8',['../a00530.html#ga933f87cca76156648e91f472650b98f3',1,'convert.c']]], ['string_5fto_5fnumeric',['string_to_numeric',['../a00530.html#ga28c75aff2615032005257af7455ed70d',1,'convert.c']]], ['string_5fto_5fresult',['string_to_result',['../a00530.html#ga46a5a00dfa70cad4a02d7cc73b314c31',1,'convert.c']]], ['string_5fto_5fuint8',['string_to_uint8',['../a00530.html#gae8e173a9f8d2e3f152ada9f48d3d5f28',1,'convert.c']]], ['stringz_5fto_5fnumeric',['stringz_to_numeric',['../a00530.html#ga467401163bf05ed167f7b2b7e8bd875a',1,'convert.c']]], ['sybdb_2eh',['sybdb.h',['../a00479.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/all_12.html100644 025423 025423 00000001766 13242511131 0014741
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/all_12.js100644 025423 025423 00000161563 13242511131 0014413var searchData= [ ['the_20db_2dlib_20api',['The db-lib API',['../a00517.html',1,'']]], ['tag_5fdbproc_5frowbuf',['tag_DBPROC_ROWBUF',['../a00873.html',1,'']]], ['tagss_5ftime2_5fstruct',['tagSS_TIME2_STRUCT',['../a01221.html',1,'']]], ['tagss_5ftimestampoffset_5fstruct',['tagSS_TIMESTAMPOFFSET_STRUCT',['../a01225.html',1,'']]], ['tds',['tds',['../a00993.html#ad357e33164f46fce2bc70267d71a1959',1,'_hstmt']]], ['tds_2eh',['tds.h',['../a00434.html',1,'']]], ['tds5_5ffix_5fdot_5fquery',['tds5_fix_dot_query',['../a00533.html#ga3a5d1771cacc947521c4077551f0d3a4',1,'query.c']]], ['tds5_5fprocess_5fdyn_5fresult2',['tds5_process_dyn_result2',['../a00536.html#gae688b515631141acfbc41bbb91c8b921',1,'token.c']]], ['tds5_5fprocess_5foptioncmd',['tds5_process_optioncmd',['../a00536.html#gaa6a7e5aeb10a1322911c47be9c43e2d2',1,'token.c']]], ['tds5_5fprocess_5fresult',['tds5_process_result',['../a00536.html#ga547b2f48659f77a69aa802d861ac827d',1,'token.c']]], ['tds5_5fprocess_5fresult2',['tds5_process_result2',['../a00536.html#gabe2bdd5a41ce067cb31aef18ff81cb1c',1,'token.c']]], ['tds71_5fcollation',['TDS71_COLLATION',['../a01033.html',1,'']]], ['tds71_5fread_5ftable_5fnames',['tds71_read_table_names',['../a00536.html#ga7482b5730d880fcedbe9fcd609a550ce',1,'token.c']]], ['tds71_5fsubmit_5fprepexec',['tds71_submit_prepexec',['../a00533.html#ga08877c101704bebe4fa57e0849dc272d',1,'tds71_submit_prepexec(TDSSOCKET *tds, const char *query, const char *id, TDSDYNAMIC **dyn_out, TDSPARAMINFO *params): query.c'],['../a00533.html#ga08877c101704bebe4fa57e0849dc272d',1,'tds71_submit_prepexec(TDSSOCKET *tds, const char *query, const char *id, TDSDYNAMIC **dyn_out, TDSPARAMINFO *params): query.c']]], ['tds72_5fsmp_5fheader',['TDS72_SMP_HEADER',['../a01037.html',1,'']]], ['tds7_5fbcp_5fsend_5fcolmetadata',['tds7_bcp_send_colmetadata',['../a00248.html#a4daaa551e54dbd978650e2eef89e09ff',1,'bulk.c']]], ['tds7_5fbuild_5fbulk_5finsert_5fstmt',['tds7_build_bulk_insert_stmt',['../a00248.html#a3118c7232bc9c3e47f8ba872bb39e967',1,'bulk.c']]], ['tds7_5fbuild_5fparam_5fdef_5ffrom_5fparams',['tds7_build_param_def_from_params',['../a00533.html#gac8d5497c2d1b9fadb724111660bd03bd',1,'query.c']]], ['tds7_5fbuild_5fparam_5fdef_5ffrom_5fquery',['tds7_build_param_def_from_query',['../a00533.html#gab775332d378c7fe083750d624441b303',1,'query.c']]], ['tds7_5fget_5fdata_5finfo',['tds7_get_data_info',['../a00536.html#ga07cee55fd522cca16fb59b7a8f0b1376',1,'token.c']]], ['tds7_5fget_5finstance_5fport',['tds7_get_instance_port',['../a00534.html#gac23c12ccb3e8599f10f305e993e216f6',1,'tds7_get_instance_port(struct addrinfo *addr, const char *instance): net.c'],['../a00534.html#gac23c12ccb3e8599f10f305e993e216f6',1,'tds7_get_instance_port(struct addrinfo *addr, const char *instance): net.c']]], ['tds7_5fget_5finstance_5fports',['tds7_get_instance_ports',['../a00534.html#ga954dcc3b0332fa9448d9edf59c0fe439',1,'tds7_get_instance_ports(FILE *output, struct addrinfo *addr): net.c'],['../a00534.html#ga954dcc3b0332fa9448d9edf59c0fe439',1,'tds7_get_instance_ports(FILE *output, struct addrinfo *addr): net.c']]], ['tds7_5fprocess_5fcompute_5fresult',['tds7_process_compute_result',['../a00536.html#ga6728e344caa20aea1def85f58dea138b',1,'token.c']]], ['tds7_5fprocess_5fresult',['tds7_process_result',['../a00536.html#gaca56fc22d65a24a96d1bef310ade73aa',1,'token.c']]], ['tds7_5fput_5fparams_5fdefinition',['tds7_put_params_definition',['../a00533.html#ga0f0b6bf447e9672e3b1ea8453ddeb113',1,'query.c']]], ['tds7_5fput_5fquery_5fparams',['tds7_put_query_params',['../a00533.html#ga6e42b4a1d1d3898229ea2fe4afc2ecec',1,'query.c']]], ['tds7_5fsend_5fexecute',['tds7_send_execute',['../a00533.html#gab71e2dc686eafe926dbebbce00d27dc4',1,'query.c']]], ['tds_5faddrinfo',['tds_addrinfo',['../a01233.html',1,'']]], ['tds_5falign_5fstruct',['tds_align_struct',['../a01089.html',1,'']]], ['tds_5falloc_5fcompute_5fresult',['tds_alloc_compute_result',['../a00532.html#gae042c280bdf5ecdd530a6e5cc2cf83f5',1,'mem.c']]], ['tds_5falloc_5fdynamic',['tds_alloc_dynamic',['../a00532.html#ga69559de43b47f4a9e2eecc7a56527444',1,'tds_alloc_dynamic(TDSCONNECTION *conn, const char *id): mem.c'],['../a00532.html#ga69559de43b47f4a9e2eecc7a56527444',1,'tds_alloc_dynamic(TDSCONNECTION *conn, const char *id): mem.c']]], ['tds_5falloc_5fget_5fstring',['tds_alloc_get_string',['../a00536.html#gafb26aba5d935e40b87b95e21a5185848',1,'token.c']]], ['tds_5falloc_5fparam_5fdata',['tds_alloc_param_data',['../a00532.html#ga282d67682d293810625d87d566443c2d',1,'tds_alloc_param_data(TDSCOLUMN *curparam): mem.c'],['../a00532.html#ga282d67682d293810625d87d566443c2d',1,'tds_alloc_param_data(TDSCOLUMN *curparam): mem.c']]], ['tds_5falloc_5fparam_5fresult',['tds_alloc_param_result',['../a00532.html#ga314c65c067570dc1ef3e58bbfc4eb763',1,'tds_alloc_param_result(TDSPARAMINFO *old_param): mem.c'],['../a00532.html#ga314c65c067570dc1ef3e58bbfc4eb763',1,'tds_alloc_param_result(TDSPARAMINFO *old_param): mem.c']]], ['tds_5falloc_5frow',['tds_alloc_row',['../a00532.html#ga1224fb9277112dc2ce12531d2b73b145',1,'tds_alloc_row(TDSRESULTINFO *res_info): mem.c'],['../a00532.html#ga1224fb9277112dc2ce12531d2b73b145',1,'tds_alloc_row(TDSRESULTINFO *res_info): mem.c']]], ['tds_5fanswer',['tds_answer',['../a00697.html',1,'']]], ['tds_5fanswer_5fchallenge',['tds_answer_challenge',['../a00528.html#ga4c76be38f4758db45be58f9de8ccdef0',1,'challenge.c']]], ['tds_5fascii_5fto_5fucs2',['tds_ascii_to_ucs2',['../a00533.html#gad05fc65e1d505c68d14c82b99a00e4eb',1,'query.c']]], ['tds_5fauthentication',['tds_authentication',['../a01177.html',1,'']]], ['tds_5fbcp_5fadd_5ffixed_5fcolumns',['tds_bcp_add_fixed_columns',['../a00248.html#a6d1e3ee3ba4ddeac7d5c9b5e30b185f1',1,'bulk.c']]], ['tds_5fbcp_5fadd_5fvariable_5fcolumns',['tds_bcp_add_variable_columns',['../a00248.html#a0184a0b53bd92aeca39b136542238dd4',1,'bulk.c']]], ['tds_5fbcp_5fdirections',['tds_bcp_directions',['../a00434.html#ad5c5c8cb776334af4b0ebf7a0d740cb2',1,'tds.h']]], ['tds_5fbcp_5fdone',['tds_bcp_done',['../a00248.html#ade7df2db455b61edc83819ad60edb339',1,'tds_bcp_done(TDSSOCKET *tds, int *rows_copied): bulk.c'],['../a00434.html#ade7df2db455b61edc83819ad60edb339',1,'tds_bcp_done(TDSSOCKET *tds, int *rows_copied): bulk.c']]], ['tds_5fbcp_5ffread',['tds_bcp_fread',['../a00248.html#a86ac92bd8a3c61a413d27150ec9bc202',1,'tds_bcp_fread(TDSSOCKET *tds, TDSICONV *char_conv, FILE *stream, const char *terminator, size_t term_len, char **outbuf, size_t *outbytes): bulk.c'],['../a00434.html#a8184311543c685f2ee0bcccfb725ca02',1,'tds_bcp_fread(TDSSOCKET *tds, TDSICONV *conv, FILE *stream, const char *terminator, size_t term_len, char **outbuf, size_t *outbytes): bulk.c']]], ['tds_5fbcp_5finit',['tds_bcp_init',['../a00248.html#ac6610c72bd31bad5378f760fa9b12d66',1,'tds_bcp_init(TDSSOCKET *tds, TDSBCPINFO *bcpinfo): bulk.c'],['../a00434.html#ac6610c72bd31bad5378f760fa9b12d66',1,'tds_bcp_init(TDSSOCKET *tds, TDSBCPINFO *bcpinfo): bulk.c']]], ['tds_5fbcp_5frow_5ffree',['tds_bcp_row_free',['../a00248.html#a7c4f2b050cd1a747604aa305d6877de7',1,'bulk.c']]], ['tds_5fbcp_5fsend_5frecord',['tds_bcp_send_record',['../a00248.html#adbc0876f3d1eae0c26e7a1abe37419fe',1,'tds_bcp_send_record(TDSSOCKET *tds, TDSBCPINFO *bcpinfo, tds_bcp_get_col_data get_col_data, tds_bcp_null_error ignored, int offset): bulk.c'],['../a00434.html#ad9e44450025cbcee1ad81d7e5a2cc099',1,'tds_bcp_send_record(TDSSOCKET *tds, TDSBCPINFO *bcpinfo, tds_bcp_get_col_data get_col_data, tds_bcp_null_error null_error, int offset): bulk.c']]], ['tds_5fbcp_5fstart',['tds_bcp_start',['../a00248.html#a8208eef2a3974ae1f0cf3c8c8ab011ce',1,'tds_bcp_start(TDSSOCKET *tds, TDSBCPINFO *bcpinfo): bulk.c'],['../a00434.html#a8208eef2a3974ae1f0cf3c8c8ab011ce',1,'tds_bcp_start(TDSSOCKET *tds, TDSBCPINFO *bcpinfo): bulk.c']]], ['tds_5fbcp_5fstart_5fcopy_5fin',['tds_bcp_start_copy_in',['../a00248.html#a5eec23828b0610c58de248c4edb53879',1,'tds_bcp_start_copy_in(TDSSOCKET *tds, TDSBCPINFO *bcpinfo): bulk.c'],['../a00434.html#a5eec23828b0610c58de248c4edb53879',1,'tds_bcp_start_copy_in(TDSSOCKET *tds, TDSBCPINFO *bcpinfo): bulk.c']]], ['tds_5fbcp_5fstart_5finsert_5fstmt',['tds_bcp_start_insert_stmt',['../a00248.html#ab4d7e5309152f54613d52c8469a07fd8',1,'bulk.c']]], ['tds_5fbcpcoldata',['tds_bcpcoldata',['../a01125.html',1,'']]], ['tds_5fbcpinfo',['tds_bcpinfo',['../a01197.html',1,'']]], ['tds_5fblob',['tds_blob',['../a01113.html',1,'']]], ['tds_5fcanonical_5fcharset',['tds_canonical_charset',['../a00531.html#ga38c0ac641a8c6e25e91ee9205c3c50c5',1,'iconv.c']]], ['tds_5fcanonical_5fcharset_5fname',['tds_canonical_charset_name',['../a00531.html#ga6561d1dba1a04c168431b16ec17d7e4c',1,'tds_canonical_charset_name(const char *charset_name): iconv.c'],['../a00531.html#ga6561d1dba1a04c168431b16ec17d7e4c',1,'tds_canonical_charset_name(const char *charset_name): iconv.c']]], ['tds_5fcapabilities',['tds_capabilities',['../a01097.html',1,'']]], ['tds_5fcapability_5ftype',['tds_capability_type',['../a01093.html',1,'']]], ['tds_5fclose_5fsocket',['tds_close_socket',['../a00534.html#ga3e3f76009fce5ceedb2f42bb2c9aed2e',1,'tds_close_socket(TDSSOCKET *tds): net.c'],['../a00534.html#ga3e3f76009fce5ceedb2f42bb2c9aed2e',1,'tds_close_socket(TDSSOCKET *tds): net.c']]], ['tds_5fcolumn',['tds_column',['../a01133.html',1,'']]], ['tds_5fcolumn_5ffuncs',['tds_column_funcs',['../a01129.html',1,'']]], ['tds_5fcompiletime_5fsettings',['tds_compiletime_settings',['../a01069.html',1,'tds_compiletime_settings'],['../a00434.html#ab30e42bf2bf063932ecd1a8212f617f0',1,'TDS_COMPILETIME_SETTINGS(): tds.h']]], ['tds_5fcondition',['tds_condition',['../a01205.html',1,'']]], ['tds_5fconfig_5fverstr',['tds_config_verstr',['../a00529.html#gade94d7e89ba1f668c82be0b00a7f5cd7',1,'tds_config_verstr(const char *tdsver, TDSLOGIN *login): config.c'],['../a00529.html#gade94d7e89ba1f668c82be0b00a7f5cd7',1,'tds_config_verstr(const char *tdsver, TDSLOGIN *login): config.c']]], ['tds_5fconnection',['tds_connection',['../a01189.html',1,'']]], ['tds_5fcontext',['tds_context',['../a01173.html',1,'']]], ['tds_5fconvert',['tds_convert',['../a00530.html#gaa865e08f7ad70ef92b111c2ea3657457',1,'tds_convert(const TDSCONTEXT *tds_ctx, int srctype, const TDS_CHAR *src, TDS_UINT srclen, int desttype, CONV_RESULT *cr): convert.c'],['../a00530.html#gaa865e08f7ad70ef92b111c2ea3657457',1,'tds_convert(const TDSCONTEXT *context, int srctype, const TDS_CHAR *src, TDS_UINT srclen, int desttype, CONV_RESULT *cr): convert.c']]], ['tds_5fconvert_5fstream',['tds_convert_stream',['../a01330.html#a9d8eb43a81ff58ab423dce0ce95b9564',1,'stream.c']]], ['tds_5fconvert_5fstring',['tds_convert_string',['../a00533.html#ga024bc5482366735070befd6f4af59f71',1,'tds_convert_string(TDSSOCKET *tds, TDSICONV *char_conv, const char *s, int len, size_t *out_len): query.c'],['../a00533.html#ga024bc5482366735070befd6f4af59f71',1,'tds_convert_string(TDSSOCKET *tds, TDSICONV *char_conv, const char *s, int len, size_t *out_len): query.c']]], ['tds_5fcopy_5fstream',['tds_copy_stream',['../a01330.html#a2b8e3379c38cd2bce28b90cb199c2aa9',1,'stream.c']]], ['tds_5fcount_5fplaceholders',['tds_count_placeholders',['../a00533.html#gaaa7b4d37bf796019e72f25c6e7fe7bea',1,'tds_count_placeholders(const char *query): query.c'],['../a00533.html#gaaa7b4d37bf796019e72f25c6e7fe7bea',1,'tds_count_placeholders(const char *query): query.c']]], ['tds_5fcount_5fplaceholders_5fucs2le',['tds_count_placeholders_ucs2le',['../a00533.html#ga0cd19215e9169ea299a6c9cbf5b2fb60',1,'query.c']]], ['tds_5fctx',['tds_ctx',['../a00585.html#afb3fb2d591c0f75b9412f8ca77e2629d',1,'dblib_context']]], ['tds_5fctx_5fref_5fcount',['tds_ctx_ref_count',['../a00585.html#ad01d901acbc92e8c369e6a6c784d7446',1,'dblib_context']]], ['tds_5fcursor',['tds_cursor',['../a01157.html',1,'']]], ['tds_5fcursor_5fcheck_5fallocated',['tds_cursor_check_allocated',['../a00533.html#ga2c6da4886cc30af02546a3bc2ebcae5d',1,'query.c']]], ['tds_5fcursor_5fdealloc',['tds_cursor_dealloc',['../a00533.html#gab25de0567ac096e8f8e88490eeddf562',1,'tds_cursor_dealloc(TDSSOCKET *tds, TDSCURSOR *cursor): query.c'],['../a00533.html#gab25de0567ac096e8f8e88490eeddf562',1,'tds_cursor_dealloc(TDSSOCKET *tds, TDSCURSOR *cursor): query.c']]], ['tds_5fcursor_5fstatus',['tds_cursor_status',['../a01153.html',1,'']]], ['tds_5fdatain_5fstream',['tds_datain_stream',['../a01049.html',1,'']]], ['tds_5fdatain_5fstream_5finit',['tds_datain_stream_init',['../a01330.html#abc3a77c8aa28842e7f28583cbabc1415',1,'stream.c']]], ['tds_5fdatain_5fstream_5fread',['tds_datain_stream_read',['../a01330.html#a04b537d889f7d4c9b9701eb81baf7efd',1,'stream.c']]], ['tds_5fdataout_5fstream',['tds_dataout_stream',['../a01053.html',1,'']]], ['tds_5fdataout_5fstream_5finit',['tds_dataout_stream_init',['../a01330.html#aa038a9125979f8f0915dbd53cbf27e5a',1,'stream.c']]], ['tds_5fdataout_5fstream_5fwrite',['tds_dataout_stream_write',['../a01330.html#ae38a590ee08cf398e7adef536ac94538',1,'stream.c']]], ['tds_5fdatecrack',['tds_datecrack',['../a00530.html#ga883855e6e3793de6684b21db39c756c4',1,'tds_datecrack(TDS_INT datetype, const void *di, TDSDATEREC *dr): convert.c'],['../a00530.html#ga883855e6e3793de6684b21db39c756c4',1,'tds_datecrack(TDS_INT datetype, const void *di, TDSDATEREC *dr): convert.c']]], ['tds_5fdatetimeall',['TDS_DATETIMEALL',['../a01077.html',1,'']]], ['tds_5fdblib_5fdbprocess',['tds_dblib_dbprocess',['../a00901.html',1,'']]], ['tds_5fdblib_5floginrec',['tds_dblib_loginrec',['../a00869.html',1,'']]], ['tds_5fdead',['TDS_DEAD',['../a00434.html#a87cdae58f91ebe9229206bf0628f8e33af087b64970a1fb35bbcf1bc6ea7a643d',1,'tds.h']]], ['tds_5fdeferred_5fcursor_5fdealloc',['tds_deferred_cursor_dealloc',['../a00533.html#ga57bd0fabe5bcdeb3ef091259b3a7c1fc',1,'tds_deferred_cursor_dealloc(TDSCONNECTION *conn, TDSCURSOR *cursor): query.c'],['../a00533.html#ga57bd0fabe5bcdeb3ef091259b3a7c1fc',1,'tds_deferred_cursor_dealloc(TDSCONNECTION *conn, TDSCURSOR *cursor): query.c']]], ['tds_5fdeferred_5funprepare',['tds_deferred_unprepare',['../a00533.html#ga9f80fdf732b084aef7de7a323261aa61',1,'tds_deferred_unprepare(TDSCONNECTION *conn, TDSDYNAMIC *dyn): query.c'],['../a00533.html#ga9f80fdf732b084aef7de7a323261aa61',1,'tds_deferred_unprepare(TDSCONNECTION *conn, TDSDYNAMIC *dyn): query.c']]], ['tds_5fdetach_5fresults',['tds_detach_results',['../a00532.html#ga1d60bf443e274797b1d1a9e7418ab962',1,'tds_detach_results(TDSRESULTINFO *info): mem.c'],['../a00532.html#ga1d60bf443e274797b1d1a9e7418ab962',1,'tds_detach_results(TDSRESULTINFO *info): mem.c']]], ['tds_5fdone_5fcancelled',['TDS_DONE_CANCELLED',['../a00434.html#aa8d8044be84bcde003f28ec25a77519ca202254cfd6784404cf1aa22bc7147c86',1,'tds.h']]], ['tds_5fdone_5fcount',['TDS_DONE_COUNT',['../a00434.html#aa8d8044be84bcde003f28ec25a77519caf17d0c6591e318014c806a10c2f0270b',1,'tds.h']]], ['tds_5fdone_5ferror',['TDS_DONE_ERROR',['../a00434.html#aa8d8044be84bcde003f28ec25a77519caa9d79a3b62e3321332223ac3d1a5b18d',1,'tds.h']]], ['tds_5fdone_5ffinal',['TDS_DONE_FINAL',['../a00434.html#aa8d8044be84bcde003f28ec25a77519ca7ed9046db24ad78bb94c2b12d6e11f46',1,'tds.h']]], ['tds_5fdone_5finxact',['TDS_DONE_INXACT',['../a00434.html#aa8d8044be84bcde003f28ec25a77519cac79a30d1a0bac125e77d87f5d87bc2b2',1,'tds.h']]], ['tds_5fdone_5fmore_5fresults',['TDS_DONE_MORE_RESULTS',['../a00434.html#aa8d8044be84bcde003f28ec25a77519ca688b8bf555ce6ae72f3e047177bfc966',1,'tds.h']]], ['tds_5fdone_5fproc',['TDS_DONE_PROC',['../a00434.html#aa8d8044be84bcde003f28ec25a77519cae170f368306f421d507c6f08e4d48d9a',1,'tds.h']]], ['tds_5fdone_5fsrverror',['TDS_DONE_SRVERROR',['../a00434.html#aa8d8044be84bcde003f28ec25a77519ca7bfe89d6f8fc309eae412ad0a503e34c',1,'tds.h']]], ['tds_5fdstr',['tds_dstr',['../a01073.html',1,'']]], ['tds_5fdstr_5falloc',['tds_dstr_alloc',['../a00535.html#ga6aa14b8b717b51afcfb65bd55143689d',1,'tdsstring.c']]], ['tds_5fdstr_5fbuf',['tds_dstr_buf',['../a00535.html#ga8fa35e3ff06ef0b7d0d642cf50282ab8',1,'string.h']]], ['tds_5fdstr_5fcopy',['tds_dstr_copy',['../a00535.html#gad96366d9fa93bfc283cef1299fbe97ab',1,'tdsstring.c']]], ['tds_5fdstr_5fcopyn',['tds_dstr_copyn',['../a00535.html#ga656718f240d7403f986ae887d84a6ca1',1,'tdsstring.c']]], ['tds_5fdstr_5fcstr',['tds_dstr_cstr',['../a00535.html#ga3340b488ed37845018e34572450e64c6',1,'string.h']]], ['tds_5fdstr_5fdup',['tds_dstr_dup',['../a00535.html#ga4e6d9fa6f9b9551a5a3390e10a5322e6',1,'tdsstring.c']]], ['tds_5fdstr_5fempty',['tds_dstr_empty',['../a00535.html#ga42d67780bd4fd442915780d4815fc743',1,'string.h']]], ['tds_5fdstr_5ffree',['tds_dstr_free',['../a00535.html#gaccd1c1c8ff938813578123963212388c',1,'tdsstring.c']]], ['tds_5fdstr_5fget',['tds_dstr_get',['../a00534.html#gafae08056186b143f3ef1399307dc9be7',1,'tds_dstr_get(TDSSOCKET *tds, DSTR *s, size_t len): read.c'],['../a00534.html#gafae08056186b143f3ef1399307dc9be7',1,'tds_dstr_get(TDSSOCKET *tds, DSTR *s, size_t len): read.c']]], ['tds_5fdstr_5finit',['tds_dstr_init',['../a00535.html#ga6c0aba5c6da921898768e7f6cf177ca7',1,'string.h']]], ['tds_5fdstr_5fisempty',['tds_dstr_isempty',['../a00535.html#gae6d3d12bd1f5f0c56df934a377c245d3',1,'string.h']]], ['tds_5fdstr_5flen',['tds_dstr_len',['../a00535.html#gaf0e232f3c35f2d8b43486e8708f7a8fc',1,'string.h']]], ['tds_5fdstr_5fset',['tds_dstr_set',['../a00535.html#gab78cc59b110df2817b00f9bed74c6ff1',1,'tdsstring.c']]], ['tds_5fdstr_5fsetlen',['tds_dstr_setlen',['../a00535.html#ga0cd7863ba7c2d2da4a193234472a3d14',1,'tdsstring.c']]], ['tds_5fdstr_5fzero',['tds_dstr_zero',['../a00535.html#ga339ba30216e2bd5bd076aa9dcd26f3c4',1,'tdsstring.c']]], ['tds_5fdynamic',['tds_dynamic',['../a01165.html',1,'']]], ['tds_5fdynamic_5fstream',['tds_dynamic_stream',['../a01065.html',1,'']]], ['tds_5fdynamic_5fstream_5finit',['tds_dynamic_stream_init',['../a01330.html#a4f9e40da6941cb9407d0da5bc3030517',1,'stream.c']]], ['tds_5fdynamic_5fstream_5fwrite',['tds_dynamic_stream_write',['../a01330.html#abaf688c85ea04a2392103d519a55d04e',1,'stream.c']]], ['tds_5fencoding',['tds_encoding',['../a01121.html',1,'tds_encoding'],['../a00434.html#a6a0febfe3d78cb085172d18282a8cfaf',1,'TDS_ENCODING(): tds.h']]], ['tds_5fend',['tds_end',['../a00434.html#aa8d8044be84bcde003f28ec25a77519c',1,'tds.h']]], ['tds_5fenv',['tds_env',['../a01161.html',1,'']]], ['tds_5ferrno_5fmessage_5fflags',['tds_errno_message_flags',['../a00937.html',1,'']]], ['tds_5ferror_5fmessage',['tds_error_message',['../a00753.html',1,'']]], ['tds_5ffile_5fstream',['tds_file_stream',['../a00693.html',1,'']]], ['tds_5ffile_5fstream_5fread',['tds_file_stream_read',['../a00248.html#a1b83c9db016b481aa1fa0352f976d50d',1,'bulk.c']]], ['tds_5ffix_5fcolumn_5fsize',['tds_fix_column_size',['../a00533.html#ga440f0f469afad1eac4c008979873ccdd',1,'tds_fix_column_size(TDSSOCKET *tds, TDSCOLUMN *curcol): query.c'],['../a00533.html#ga440f0f469afad1eac4c008979873ccdd',1,'tds_fix_column_size(TDSSOCKET *tds, TDSCOLUMN *curcol): query.c']]], ['tds_5ffix_5flogin',['tds_fix_login',['../a00529.html#gacee4f06ba749b10ee9f2e5bb1c4a8910',1,'tds_fix_login(TDSLOGIN *login): config.c'],['../a00529.html#gacee4f06ba749b10ee9f2e5bb1c4a8910',1,'tds_fix_login(TDSLOGIN *login): config.c']]], ['tds_5fflush_5fpacket',['tds_flush_packet',['../a00534.html#ga5feb53554e8917a81bbbc332163a61fb',1,'tds_flush_packet(TDSSOCKET *tds): write.c'],['../a00534.html#ga5feb53554e8917a81bbbc332163a61fb',1,'tds_flush_packet(TDSSOCKET *tds): write.c']]], ['tds_5ffree_5finput_5fparams',['tds_free_input_params',['../a00532.html#gabdc5fee73b22345c02ab894e49ad7f95',1,'tds_free_input_params(TDSDYNAMIC *dyn): mem.c'],['../a00532.html#gabdc5fee73b22345c02ab894e49ad7f95',1,'tds_free_input_params(TDSDYNAMIC *dyn): mem.c']]], ['tds_5ffree_5fnamelist',['tds_free_namelist',['../a00536.html#ga21e9de33de9c8c492aa2f96c823596bb',1,'token.c']]], ['tds_5ffree_5fparam_5fresult',['tds_free_param_result',['../a00532.html#ga66cd6e3c5089ced9415a8a0e258d205a',1,'tds_free_param_result(TDSPARAMINFO *param_info): mem.c'],['../a00532.html#ga66cd6e3c5089ced9415a8a0e258d205a',1,'tds_free_param_result(TDSPARAMINFO *param_info): mem.c']]], ['tds_5ffuncs',['TDS_FUNCS',['../a00997.html',1,'']]], ['tds_5fgeneric_5fget',['tds_generic_get',['../a00260.html#abac4d689e0e31e80587f89247c6395a4',1,'data.c']]], ['tds_5fgeneric_5fput',['tds_generic_put',['../a00260.html#a84e17808683ba2dd956e811a42e23176',1,'data.c']]], ['tds_5fgeneric_5fput_5finfo',['tds_generic_put_info',['../a00260.html#aabd0e5f15615b5c141c525b76e746520',1,'data.c']]], ['tds_5fget_5fbyte',['tds_get_byte',['../a00534.html#ga0cb72d3f6943795c39db1fa692be0a58',1,'tds_get_byte(TDSSOCKET *tds): read.c'],['../a00534.html#ga0cb72d3f6943795c39db1fa692be0a58',1,'tds_get_byte(TDSSOCKET *tds): read.c']]], ['tds_5fget_5fchar_5fdata',['tds_get_char_data',['../a00534.html#ga8d214089b6e97fc0da5e0be09f216d73',1,'tds_get_char_data(TDSSOCKET *tds, char *row_buffer, size_t wire_size, TDSCOLUMN *curcol): read.c'],['../a00534.html#ga8d214089b6e97fc0da5e0be09f216d73',1,'tds_get_char_data(TDSSOCKET *tds, char *dest, size_t wire_size, TDSCOLUMN *curcol): read.c']]], ['tds_5fget_5fcolumn_5fdeclaration',['tds_get_column_declaration',['../a00533.html#ga50d62edeb2a432e2dc668263f3f958ff',1,'tds_get_column_declaration(TDSSOCKET *tds, TDSCOLUMN *curcol, char *out): query.c'],['../a00533.html#ga50d62edeb2a432e2dc668263f3f958ff',1,'tds_get_column_declaration(TDSSOCKET *tds, TDSCOLUMN *curcol, char *out): query.c']]], ['tds_5fget_5fcompiletime_5fsettings',['tds_get_compiletime_settings',['../a00529.html#ga860690ac47a80f74c83b25cbd8d7703d',1,'tds_get_compiletime_settings(void): config.c'],['../a00529.html#ga860690ac47a80f74c83b25cbd8d7703d',1,'tds_get_compiletime_settings(void): config.c']]], ['tds_5fget_5fconversion_5ftype',['tds_get_conversion_type',['../a00434.html#a0383d5dcb629582266a442f0f0dbd13a',1,'tds_types.h']]], ['tds_5fget_5fdata_5finfo',['tds_get_data_info',['../a00536.html#gad9b6b86f48be077fb44ac603845a0c27',1,'token.c']]], ['tds_5fget_5fdynid',['tds_get_dynid',['../a00532.html#ga501af7e6186e59c257729599a044a30b',1,'mem.c']]], ['tds_5fget_5fhome_5ffile',['tds_get_home_file',['../a00529.html#gaf49eca946d1b2457e189de7207e3670c',1,'config.c']]], ['tds_5fget_5fhomedir',['tds_get_homedir',['../a00434.html#a6fb8c78f678c0016c12096765ab2f5c1',1,'threadsafe.c']]], ['tds_5fget_5flocale',['tds_get_locale',['../a00434.html#af43163dc067b230b2236a619a067c675',1,'locale.c']]], ['tds_5fget_5fn',['tds_get_n',['../a00534.html#gae7d9c4e1a079e1d0aa0252732631e8c4',1,'tds_get_n(TDSSOCKET *tds, void *dest, size_t need): read.c'],['../a00534.html#gae7d9c4e1a079e1d0aa0252732631e8c4',1,'tds_get_n(TDSSOCKET *tds, void *dest, size_t n): read.c']]], ['tds_5fget_5fnull_5ftype',['tds_get_null_type',['../a00530.html#ga68e3a76fd7b0a77614765826a8ab5be8',1,'tds_get_null_type(TDS_SERVER_TYPE srctype): convert.c'],['../a00530.html#ga68e3a76fd7b0a77614765826a8ab5be8',1,'tds_get_null_type(TDS_SERVER_TYPE srctype): convert.c']]], ['tds_5fget_5fsize_5fby_5ftype',['tds_get_size_by_type',['../a00434.html#a4c070147d189dede5e08a2dc66852678',1,'tds_types.h']]], ['tds_5fget_5fstring',['tds_get_string',['../a00534.html#ga90f080e6e9448feac15dee1370d66802',1,'tds_get_string(TDSSOCKET *tds, size_t string_len, char *dest, size_t dest_size): read.c'],['../a00534.html#ga90f080e6e9448feac15dee1370d66802',1,'tds_get_string(TDSSOCKET *tds, size_t string_len, char *dest, size_t dest_size): read.c']]], ['tds_5fget_5ftoken_5fsize',['tds_get_token_size',['../a00536.html#ga995b82e53aeac5bede01ef16e9aeaa65',1,'tds_get_token_size(int marker): token.c'],['../a00536.html#ga995b82e53aeac5bede01ef16e9aeaa65',1,'tds_get_token_size(int marker): token.c']]], ['tds_5fget_5fuint',['tds_get_uint',['../a00534.html#ga9ac121c269e203337a48c5bf8afc48c3',1,'tds_get_uint(TDSSOCKET *tds): read.c'],['../a00534.html#ga9ac121c269e203337a48c5bf8afc48c3',1,'tds_get_uint(TDSSOCKET *tds): read.c']]], ['tds_5fget_5fuint8',['tds_get_uint8',['../a00534.html#ga8ab6c87318eaf15ea17a9575763f7809',1,'tds_get_uint8(TDSSOCKET *tds): read.c'],['../a00534.html#ga8ab6c87318eaf15ea17a9575763f7809',1,'tds_get_uint8(TDSSOCKET *tds): read.c']]], ['tds_5fget_5fusmallint',['tds_get_usmallint',['../a00534.html#gad38aa5b9547817854ccba1fcc7855861',1,'tds_get_usmallint(TDSSOCKET *tds): read.c'],['../a00534.html#gad38aa5b9547817854ccba1fcc7855861',1,'tds_get_usmallint(TDSSOCKET *tds): read.c']]], ['tds_5fget_5fvarint_5fsize',['tds_get_varint_size',['../a00434.html#a68855f1251759a6b7338635306ab0041',1,'tds_types.h']]], ['tds_5fgetservice',['tds_getservice',['../a00434.html#a3a2add5890ed468e36d780d29263ae22',1,'threadsafe.c']]], ['tds_5fgoodread',['tds_goodread',['../a00534.html#ga6f2ae00407f59fb1ab280fa44a56295e',1,'tds_goodread(TDSSOCKET *tds, unsigned char *buf, int buflen): net.c'],['../a00534.html#ga6f2ae00407f59fb1ab280fa44a56295e',1,'tds_goodread(TDSSOCKET *tds, unsigned char *buf, int buflen): net.c']]], ['tds_5fgoodwrite',['tds_goodwrite',['../a00534.html#ga2734407109c834c5dda7ff8a45c71230',1,'tds_goodwrite(TDSSOCKET *tds, const unsigned char *buffer, size_t buflen): net.c'],['../a00534.html#ga2734407109c834c5dda7ff8a45c71230',1,'tds_goodwrite(TDSSOCKET *tds, const unsigned char *buffer, size_t buflen): net.c']]], ['tds_5fheaders',['tds_headers',['../a01105.html',1,'']]], ['tds_5ficonv',['tds_iconv',['../a00531.html#ga87db49044919f1bc84c0ff5e9ab00304',1,'tds_iconv(TDSSOCKET *tds, TDSICONV *conv, TDS_ICONV_DIRECTION io, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft): iconv.c'],['../a00531.html#ga87db49044919f1bc84c0ff5e9ab00304',1,'tds_iconv(TDSSOCKET *tds, TDSICONV *char_conv, TDS_ICONV_DIRECTION io, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft): iconv.c']]], ['tds_5ficonv_5falloc',['tds_iconv_alloc',['../a01342.html#a026957dbbd994b48b571a63405f427cd',1,'tds_iconv_alloc(TDSCONNECTION *conn): iconv.c'],['../a00434.html#a026957dbbd994b48b571a63405f427cd',1,'tds_iconv_alloc(TDSCONNECTION *conn): iconv.c']]], ['tds_5ficonv_5ffrom_5fcollate',['tds_iconv_from_collate',['../a00531.html#gaed775f7fcca42b5c2a53f9508c140259',1,'tds_iconv_from_collate(TDSCONNECTION *conn, TDS_UCHAR collate[5]): iconv.c'],['../a00531.html#gaed775f7fcca42b5c2a53f9508c140259',1,'tds_iconv_from_collate(TDSCONNECTION *conn, TDS_UCHAR collate[5]): iconv.c']]], ['tds_5ficonv_5fget_5finfo',['tds_iconv_get_info',['../a00531.html#gac85bc9c101048a124707c7050035e30f',1,'iconv.c']]], ['tds_5ficonv_5finfo_5finit',['tds_iconv_info_init',['../a00531.html#ga3a7a7b4d6ed344127e164dd0b443d790',1,'iconv.c']]], ['tds_5ficonv_5finit',['tds_iconv_init',['../a01342.html#a89de4d12be43b135ad355236717e9cbb',1,'iconv.c']]], ['tds_5fidle',['TDS_IDLE',['../a00434.html#a87cdae58f91ebe9229206bf0628f8e33ad1586abc1f75b7f3d640b994afe310e9',1,'tds.h']]], ['tds_5finit_5flogin',['tds_init_login',['../a00532.html#ga2ef389ac3b0cddec76bf8f1c0951bc9c',1,'tds_init_login(TDSLOGIN *login, TDSLOCALE *locale): mem.c'],['../a00532.html#ga2ef389ac3b0cddec76bf8f1c0951bc9c',1,'tds_init_login(TDSLOGIN *login, TDSLOCALE *locale): mem.c']]], ['tds_5finput_5fstream',['tds_input_stream',['../a01041.html',1,'']]], ['tds_5fis_5fmssql',['TDS_IS_MSSQL',['../a00434.html#a07e9371c3e72b9e319f4c14e6fc2c20f',1,'tds.h']]], ['tds_5fis_5fsybase',['TDS_IS_SYBASE',['../a00434.html#a4840433488d0c66601ff4002a54b41d7',1,'tds.h']]], ['tds_5flocale',['tds_locale',['../a01109.html',1,'']]], ['tds_5flogin',['tds_login',['../a01101.html',1,'']]], ['tds_5flookup_5fdynamic',['tds_lookup_dynamic',['../a00536.html#ga595fe391e60a71bd98ffd53b4c015e44',1,'tds_lookup_dynamic(TDSCONNECTION *conn, const char *id): token.c'],['../a00536.html#ga595fe391e60a71bd98ffd53b4c015e44',1,'tds_lookup_dynamic(TDSCONNECTION *conn, const char *id): token.c']]], ['tds_5flookup_5fhost',['tds_lookup_host',['../a00529.html#gaa17936ef93e1c68833c4aab769bd90d9',1,'tds_lookup_host(const char *servername): config.c'],['../a00529.html#gaa17936ef93e1c68833c4aab769bd90d9',1,'tds_lookup_host(const char *servername): config.c']]], ['tds_5flookup_5fport',['tds_lookup_port',['../a00529.html#ga45281d1cb2ac649db65d80bb3ff06b66',1,'config.c']]], ['tds_5fmay_5falias',['TDS_MAY_ALIAS',['../a00909.html',1,'']]], ['tds_5fmessage',['tds_message',['../a01145.html',1,'']]], ['tds_5fmicrosoft_5fdbdaterec',['tds_microsoft_dbdaterec',['../a01285.html',1,'']]], ['tds_5fmicrosoft_5fdbdaterec2',['tds_microsoft_dbdaterec2',['../a01293.html',1,'']]], ['tds_5fms_5fver',['TDS_MS_VER',['../a00434.html#a1f5fb9d2184949ed566c8ce308a4e91e',1,'tds.h']]], ['tds_5fmultiple',['tds_multiple',['../a01169.html',1,'']]], ['tds_5fneeds_5funprepare',['tds_needs_unprepare',['../a00533.html#ga05ac7bab753d19b6ba1ffc7505d8fcd0',1,'tds_needs_unprepare(TDSCONNECTION *conn, TDSDYNAMIC *dyn): query.c'],['../a00533.html#ga05ac7bab753d19b6ba1ffc7505d8fcd0',1,'tds_needs_unprepare(TDSCONNECTION *conn, TDSDYNAMIC *dyn): query.c']]], ['tds_5fnext_5fplaceholder',['tds_next_placeholder',['../a00533.html#ga6455b2991afbf7da90270787f2059d31',1,'tds_next_placeholder(const char *start): query.c'],['../a00533.html#ga6455b2991afbf7da90270787f2059d31',1,'tds_next_placeholder(const char *start): query.c']]], ['tds_5fnext_5fplaceholder_5fucs2le',['tds_next_placeholder_ucs2le',['../a00533.html#gaa823973b74efdf1ff00f340496bff614',1,'query.c']]], ['tds_5fntlm_5fauth',['tds_ntlm_auth',['../a00705.html',1,'']]], ['tds_5fntlm_5fget_5fauth',['tds_ntlm_get_auth',['../a00528.html#ga679f2d22b4a4bdefe0fa475d63503778',1,'tds_ntlm_get_auth(TDSSOCKET *tds): challenge.c'],['../a00528.html#ga679f2d22b4a4bdefe0fa475d63503778',1,'tds_ntlm_get_auth(TDSSOCKET *tds): challenge.c']]], ['tds_5fnumeric_5fbytes_5fper_5fprec',['tds_numeric_bytes_per_prec',['../a00434.html#a4da9eedb6322f7dfca89d5d89be7b374',1,'numeric.c']]], ['tds_5fnumeric_5fto_5fstring',['tds_numeric_to_string',['../a00434.html#a622da936832b0337742da956be123719',1,'numeric.c']]], ['tds_5foption_5farg',['tds_option_arg',['../a01085.html',1,'']]], ['tds_5foutput_5fstream',['tds_output_stream',['../a01045.html',1,'']]], ['tds_5fpacket',['tds_packet',['../a01181.html',1,'']]], ['tds_5fparsed_5fparam',['TDS_PARSED_PARAM',['../a01001.html',1,'']]], ['tds_5fpbcb',['tds_pbcb',['../a00689.html',1,'']]], ['tds_5fpeek',['tds_peek',['../a00534.html#ga221e98a9c8be96ec6c8547891e1b53af',1,'tds_peek(TDSSOCKET *tds): read.c'],['../a00534.html#ga221e98a9c8be96ec6c8547891e1b53af',1,'tds_peek(TDSSOCKET *tds): read.c']]], ['tds_5fpending',['TDS_PENDING',['../a00434.html#a87cdae58f91ebe9229206bf0628f8e33a00f6d5ac5560f2f44661e599241849a8',1,'tds.h']]], ['tds_5fpoll_5fwakeup',['tds_poll_wakeup',['../a01185.html',1,'']]], ['tds_5fpool',['tds_pool',['../a00669.html',1,'']]], ['tds_5fpool_5fevent',['tds_pool_event',['../a00653.html',1,'']]], ['tds_5fpool_5fmember',['tds_pool_member',['../a00665.html',1,'']]], ['tds_5fpool_5fsocket',['tds_pool_socket',['../a00657.html',1,'']]], ['tds_5fpool_5fuser',['tds_pool_user',['../a00661.html',1,'']]], ['tds_5fpr_5fop',['tds_pr_op',['../a00536.html#ga62dc14d21453e88e24880ee0acaca73a',1,'token.c']]], ['tds_5fprdatatype',['tds_prdatatype',['../a00077.html#ac7a199aaeb82935f6d1dda2be551a089',1,'dblib.c']]], ['tds_5fprocess_5fauth',['tds_process_auth',['../a00536.html#ga4e1e52e09b0c27a9b9f53eb6b539afce',1,'token.c']]], ['tds_5fprocess_5fcancel',['tds_process_cancel',['../a00536.html#gaf233e79967f82f4e0dd4d11524917a34',1,'tds_process_cancel(TDSSOCKET *tds): token.c'],['../a00536.html#gaf233e79967f82f4e0dd4d11524917a34',1,'tds_process_cancel(TDSSOCKET *tds): token.c']]], ['tds_5fprocess_5fcol_5ffmt',['tds_process_col_fmt',['../a00536.html#ga4e3dd9d3614f5f0433b78b761dd68741',1,'token.c']]], ['tds_5fprocess_5fcol_5fname',['tds_process_col_name',['../a00536.html#ga905d2fa5e1b602817bd16bb0fcf9eadb',1,'token.c']]], ['tds_5fprocess_5fcolinfo',['tds_process_colinfo',['../a00536.html#ga22c7f413d43fc0d511e122a3de389166',1,'token.c']]], ['tds_5fprocess_5fcompute',['tds_process_compute',['../a00536.html#ga6fcb37d5addebdc1af9f34ebc59fd7a8',1,'token.c']]], ['tds_5fprocess_5fcompute_5fnames',['tds_process_compute_names',['../a00536.html#gae5b3e01f3d665f9e377de091f46f1ab9',1,'token.c']]], ['tds_5fprocess_5fcompute_5fresult',['tds_process_compute_result',['../a00536.html#gae3368ea80d0d8b13791ceb13ee5f19c9',1,'token.c']]], ['tds_5fprocess_5fcursor_5ftokens',['tds_process_cursor_tokens',['../a00536.html#ga315d875d90c64d12d61fc9e33b4dee96',1,'token.c']]], ['tds_5fprocess_5fdefault_5ftokens',['tds_process_default_tokens',['../a00536.html#ga39453d084f3f780ac4602d4abf2839f7',1,'token.c']]], ['tds_5fprocess_5fdyn_5fresult',['tds_process_dyn_result',['../a00536.html#ga416cf119c1d4a0fca27dc5b50c261358',1,'token.c']]], ['tds_5fprocess_5fdynamic',['tds_process_dynamic',['../a00536.html#ga5cfc0340d8d717e67f60037e029b2142',1,'token.c']]], ['tds_5fprocess_5fend',['tds_process_end',['../a00536.html#ga7a081cf9bb8f04ead12f0299fb7c4cd9',1,'token.c']]], ['tds_5fprocess_5fenv_5fchg',['tds_process_env_chg',['../a00536.html#ga3e1b4df4410a86a563a8c155e7799720',1,'token.c']]], ['tds_5fprocess_5finfo',['tds_process_info',['../a00536.html#ga65a2316369529731732f200c190d05d6',1,'token.c']]], ['tds_5fprocess_5flogin_5ftokens',['tds_process_login_tokens',['../a00536.html#ga93945b42d45ee28ae1296b35a1c1e9bb',1,'tds_process_login_tokens(TDSSOCKET *tds): token.c'],['../a00536.html#ga93945b42d45ee28ae1296b35a1c1e9bb',1,'tds_process_login_tokens(TDSSOCKET *tds): token.c']]], ['tds_5fprocess_5fnbcrow',['tds_process_nbcrow',['../a00536.html#gaf7264c9eb3aa7a73358a4c65f02d3d3c',1,'token.c']]], ['tds_5fprocess_5fparam_5fresult',['tds_process_param_result',['../a00536.html#gacb3354443bcefe7a500a500a4904cc05',1,'token.c']]], ['tds_5fprocess_5fparam_5fresult_5ftokens',['tds_process_param_result_tokens',['../a00536.html#ga9fdef8228d29cab7fa9098f07fa73fba',1,'token.c']]], ['tds_5fprocess_5fparams_5fresult_5ftoken',['tds_process_params_result_token',['../a00536.html#ga7b18c0911a9dc69939577b39eb64725d',1,'token.c']]], ['tds_5fprocess_5fpending_5fcloses',['tds_process_pending_closes',['../a00536.html#ga69902dffb299d62a799888e0fa3ccd68',1,'token.c']]], ['tds_5fprocess_5frow',['tds_process_row',['../a00536.html#gaad814dd6e35aee8332035d06dc8b5d65',1,'token.c']]], ['tds_5fprocess_5fsimple_5fquery',['tds_process_simple_query',['../a00536.html#gaeeb1562044786ea17bea361ed83e6946',1,'tds_process_simple_query(TDSSOCKET *tds): token.c'],['../a00536.html#gaeeb1562044786ea17bea361ed83e6946',1,'tds_process_simple_query(TDSSOCKET *tds): token.c']]], ['tds_5fprocess_5ftabname',['tds_process_tabname',['../a00536.html#gaeec59bca9bd0c5388e245f0d19d9c81a',1,'token.c']]], ['tds_5fprocess_5ftokens',['tds_process_tokens',['../a00536.html#gabfc9de1d1fe718818caf63a4be4035a6',1,'tds_process_tokens(TDSSOCKET *tds, TDS_INT *result_type, int *done_flags, unsigned flag): token.c'],['../a00536.html#gabfc9de1d1fe718818caf63a4be4035a6',1,'tds_process_tokens(TDSSOCKET *tds, TDS_INT *result_type, int *done_flags, unsigned flag): token.c']]], ['tds_5fprtype',['tds_prtype',['../a00536.html#ga0cf7e719115b0ae476753442d10505ab',1,'tds_prtype(int type): token.c'],['../a00536.html#ga0cf7e719115b0ae476753442d10505ab',1,'tds_prtype(int token): token.c']]], ['tds_5fput_5fdata',['tds_put_data',['../a00533.html#ga9fcc0a3932dcad530511395ef8a767fb',1,'query.c']]], ['tds_5fput_5fdata_5finfo',['tds_put_data_info',['../a00533.html#gafd74652c4722ddce4d642cc4209449d4',1,'query.c']]], ['tds_5fput_5fdata_5finfo_5flength',['tds_put_data_info_length',['../a00533.html#ga319d610d59b2cc669b7fe20c793122af',1,'query.c']]], ['tds_5fput_5fn_5fas_5fucs2',['TDS_PUT_N_AS_UCS2',['../a00533.html#ga62c3dc9946acb3ffd1b7ae43424f5b47',1,'query.c']]], ['tds_5fput_5fparam_5fas_5fstring',['tds_put_param_as_string',['../a00533.html#ga0e2e7230c425e925402d7856ff5b4b18',1,'query.c']]], ['tds_5fput_5fparams',['tds_put_params',['../a00533.html#ga28264995cf9616661f1fa788ac0d246d',1,'query.c']]], ['tds_5fput_5fstring',['tds_put_string',['../a00534.html#ga1fcaf8d488cc1390f106ce3ad0bf37b4',1,'tds_put_string(TDSSOCKET *tds, const char *s, int len): write.c'],['../a00534.html#ga1fcaf8d488cc1390f106ce3ad0bf37b4',1,'tds_put_string(TDSSOCKET *tds, const char *buf, int len): write.c']]], ['tds_5fput_5ftinyint',['tds_put_tinyint',['../a00434.html#adfc186758f4c1856c01746b5436aff74',1,'tds.h']]], ['tds_5fquery_5fflush_5fpacket',['tds_query_flush_packet',['../a00533.html#gada27f4cfce925240ad33b71b63ca692d',1,'query.c']]], ['tds_5fquote',['tds_quote',['../a00533.html#ga7efaa23c3b21158ffc963f85fbc3fdf4',1,'query.c']]], ['tds_5fquote_5fand_5fput',['tds_quote_and_put',['../a00533.html#ga26b26296d060dca75f6a43e9ac41e58d',1,'query.c']]], ['tds_5fquote_5fid',['tds_quote_id',['../a00533.html#ga8d8f2f1c91635ee95f30722208ae3043',1,'tds_quote_id(TDSSOCKET *tds, char *buffer, const char *id, int idlen): query.c'],['../a00533.html#ga8d8f2f1c91635ee95f30722208ae3043',1,'tds_quote_id(TDSSOCKET *tds, char *buffer, const char *id, int idlen): query.c']]], ['tds_5fquote_5fstring',['tds_quote_string',['../a00533.html#ga737b9fb9971fb425af5c722415ef0eac',1,'tds_quote_string(TDSSOCKET *tds, char *buffer, const char *str, int len): query.c'],['../a00533.html#ga737b9fb9971fb425af5c722415ef0eac',1,'tds_quote_string(TDSSOCKET *tds, char *buffer, const char *str, int len): query.c']]], ['tds_5fraw_5fmutex',['tds_raw_mutex',['../a01201.html',1,'']]], ['tds_5fread_5fconf_5ffile',['tds_read_conf_file',['../a00529.html#ga0a63cb612f245fd85e56cfea98ff8f3b',1,'tds_read_conf_file(TDSLOGIN *login, const char *server): config.c'],['../a00529.html#ga0a63cb612f245fd85e56cfea98ff8f3b',1,'tds_read_conf_file(TDSLOGIN *login, const char *server): config.c']]], ['tds_5fread_5fconf_5fsection',['tds_read_conf_section',['../a00529.html#ga6580a3a0a6063c8095a3c4405061e068',1,'tds_read_conf_section(FILE *in, const char *section, TDSCONFPARSE tds_conf_parse, void *param): config.c'],['../a00529.html#ga6580a3a0a6063c8095a3c4405061e068',1,'tds_read_conf_section(FILE *in, const char *section, TDSCONFPARSE tds_conf_parse, void *parse_param): config.c']]], ['tds_5fread_5fconfig_5finfo',['tds_read_config_info',['../a00529.html#ga9af192306186ddf39e09be0fd4ad8aaf',1,'tds_read_config_info(TDSSOCKET *tds, TDSLOGIN *login, TDSLOCALE *locale): config.c'],['../a00529.html#ga9af192306186ddf39e09be0fd4ad8aaf',1,'tds_read_config_info(TDSSOCKET *tds, TDSLOGIN *login, TDSLOCALE *locale): config.c']]], ['tds_5fread_5finterfaces',['tds_read_interfaces',['../a00529.html#ga6631af35ee817f93827c62bbda41674a',1,'config.c']]], ['tds_5fread_5fnamelist',['tds_read_namelist',['../a00536.html#gaeaaed2ea1d8c827da1a0f5b419524ae1',1,'token.c']]], ['tds_5fread_5fpacket',['tds_read_packet',['../a00534.html#ga410619783bdf2bb60b0f27a5578e0e07',1,'tds_read_packet(TDSSOCKET *tds): packet.c'],['../a00534.html#ga410619783bdf2bb60b0f27a5578e0e07',1,'tds_read_packet(TDSSOCKET *tds): packet.c']]], ['tds_5freading',['TDS_READING',['../a00434.html#a87cdae58f91ebe9229206bf0628f8e33a36ddbc8f326d6b297009a8fafd958529',1,'tds.h']]], ['tds_5frealloc',['tds_realloc',['../a00532.html#ga924cb9fb5d19dbd308ba0ce8c1a8a1d5',1,'tds_realloc(void **pp, size_t new_size): mem.c'],['../a00532.html#ga924cb9fb5d19dbd308ba0ce8c1a8a1d5',1,'tds_realloc(void **pp, size_t new_size): mem.c']]], ['tds_5frelease_5fdynamic',['tds_release_dynamic',['../a00532.html#gabf2fdb0def5388508602ee7dd2f49506',1,'tds_release_dynamic(TDSDYNAMIC **pdyn): mem.c'],['../a00532.html#gabf2fdb0def5388508602ee7dd2f49506',1,'tds_release_dynamic(TDSDYNAMIC **dyn): mem.c']]], ['tds_5fresult_5finfo',['tds_result_info',['../a01141.html',1,'']]], ['tds_5fsave_5fcontext',['tds_save_context',['../a00733.html',1,'']]], ['tds_5fsave_5fenv',['tds_save_env',['../a00729.html',1,'']]], ['tds_5fsave_5fmsg',['tds_save_msg',['../a00725.html',1,'']]], ['tds_5fselect',['tds_select',['../a00534.html#gad7aae89e32444ab30852fee056231403',1,'tds_select(TDSSOCKET *tds, unsigned tds_sel, int timeout_seconds): net.c'],['../a00534.html#gad7aae89e32444ab30852fee056231403',1,'tds_select(TDSSOCKET *tds, unsigned tds_sel, int timeout_seconds): net.c']]], ['tds_5fsend_5fcancel',['tds_send_cancel',['../a00533.html#ga11338742dc30fd0c2711f58eb830316f',1,'tds_send_cancel(TDSSOCKET *tds): query.c'],['../a00533.html#ga11338742dc30fd0c2711f58eb830316f',1,'tds_send_cancel(TDSSOCKET *tds): query.c']]], ['tds_5fsend_5femulated_5fexecute',['tds_send_emulated_execute',['../a00533.html#ga02c6ce3ff96369603a6ee4efee64caae',1,'query.c']]], ['tds_5fsend_5femulated_5frpc',['tds_send_emulated_rpc',['../a00533.html#gaf614c75ea8f7ad411e53dac0e2f91be4',1,'query.c']]], ['tds_5fsending',['TDS_SENDING',['../a00434.html#a87cdae58f91ebe9229206bf0628f8e33a2bad5be30bd85edc9495dae3d199d2c1',1,'tds.h']]], ['tds_5fset_5fcolumn_5ftype',['tds_set_column_type',['../a00260.html#a31604382d8b77257aad203f409155a29',1,'tds_set_column_type(TDSCONNECTION *conn, TDSCOLUMN *curcol, TDS_SERVER_TYPE type): data.c'],['../a00434.html#a31604382d8b77257aad203f409155a29',1,'tds_set_column_type(TDSCONNECTION *conn, TDSCOLUMN *curcol, TDS_SERVER_TYPE type): data.c']]], ['tds_5fset_5fcur_5fcursor',['tds_set_cur_cursor',['../a00533.html#ga34fb1084682cc31fe02a4a7946955a5a',1,'query.c']]], ['tds_5fset_5fcur_5fdyn',['tds_set_cur_dyn',['../a00533.html#gae8b7db85af16701fc0604eb117cbd4e4',1,'tds_set_cur_dyn(TDSSOCKET *tds, TDSDYNAMIC *dyn): query.c'],['../a00533.html#gae8b7db85af16701fc0604eb117cbd4e4',1,'tds_set_cur_dyn(TDSSOCKET *tds, TDSDYNAMIC *dyn): query.c']]], ['tds_5fset_5ficonv_5fname',['tds_set_iconv_name',['../a01342.html#a010ab1d181c8996f6a5984c9900eca6b',1,'iconv.c']]], ['tds_5fset_5finterfaces_5ffile_5floc',['tds_set_interfaces_file_loc',['../a00529.html#ga57cea6e376d7c2d28b811a5b0053210c',1,'tds_set_interfaces_file_loc(const char *interf): config.c'],['../a00529.html#ga57cea6e376d7c2d28b811a5b0053210c',1,'tds_set_interfaces_file_loc(const char *interfloc): config.c']]], ['tds_5fset_5fparam_5ftype',['tds_set_param_type',['../a00260.html#a86768d86059c5addf9a3f89edb1ef44e',1,'tds_set_param_type(TDSCONNECTION *conn, TDSCOLUMN *curcol, TDS_SERVER_TYPE type): data.c'],['../a00434.html#a86768d86059c5addf9a3f89edb1ef44e',1,'tds_set_param_type(TDSCONNECTION *conn, TDSCOLUMN *curcol, TDS_SERVER_TYPE type): data.c']]], ['tds_5fset_5fserver',['tds_set_server',['../a00434.html#a3ab8874994a0776acdaff797afdb710a',1,'login.c']]], ['tds_5fset_5fstate',['tds_set_state',['../a00434.html#a16db200d2281f76fe46fc1cbe37ca9df',1,'util.c']]], ['tds_5fskip_5fcomment',['tds_skip_comment',['../a00533.html#gaac7347ba9380d77d726648b85e9fab8f',1,'tds_skip_comment(const char *s): query.c'],['../a00533.html#gaac7347ba9380d77d726648b85e9fab8f',1,'tds_skip_comment(const char *s): query.c']]], ['tds_5fskip_5fcomment_5fucs2le',['tds_skip_comment_ucs2le',['../a00533.html#gab304fda9f325e852ba5c5252079d22e3',1,'query.c']]], ['tds_5fskip_5fquoted',['tds_skip_quoted',['../a00533.html#ga5dbe51ce9533218f2da23f69ff63dda4',1,'tds_skip_quoted(const char *s): query.c'],['../a00533.html#ga5dbe51ce9533218f2da23f69ff63dda4',1,'tds_skip_quoted(const char *s): query.c']]], ['tds_5fskip_5fquoted_5fucs2le',['tds_skip_quoted_ucs2le',['../a00533.html#ga2361ec4629aa0eac38f1702b03ed8185',1,'query.c']]], ['tds_5fsocket',['tds_socket',['../a01193.html',1,'']]], ['tds_5fsocket_5fread',['tds_socket_read',['../a00534.html#ga8560e2536fdcf8f1514d4fa14f90876c',1,'net.c']]], ['tds_5fsocket_5fset_5fnonblocking',['tds_socket_set_nonblocking',['../a00534.html#ga2a7429ff031f77023d1bf31339a266db',1,'tds_socket_set_nonblocking(TDS_SYS_SOCKET sock): net.c'],['../a00534.html#ga2a7429ff031f77023d1bf31339a266db',1,'tds_socket_set_nonblocking(TDS_SYS_SOCKET sock): net.c']]], ['tds_5fsocket_5fwrite',['tds_socket_write',['../a00534.html#gad6f81b48fbcfc18ce0b213dbbea47e30',1,'net.c']]], ['tds_5fstart_5fquery',['tds_start_query',['../a00533.html#ga0da385231bfa3dc49377e1fb2bea2c07',1,'tds_start_query(TDSSOCKET *tds, unsigned char packet_type): query.c'],['../a00533.html#ga0da385231bfa3dc49377e1fb2bea2c07',1,'tds_start_query(TDSSOCKET *tds, unsigned char packet_type): query.c']]], ['tds_5fstart_5fquery_5fhead',['tds_start_query_head',['../a00533.html#ga9ad2e6defce530a8778791cce0166ccd',1,'query.c']]], ['tds_5fstate',['TDS_STATE',['../a00434.html#a58f34a3a686a968357537c7486521b51',1,'tds.h']]], ['tds_5fstates',['tds_states',['../a00434.html#a87cdae58f91ebe9229206bf0628f8e33',1,'tds.h']]], ['tds_5fstaticin_5fstream',['tds_staticin_stream',['../a01057.html',1,'']]], ['tds_5fstaticin_5fstream_5finit',['tds_staticin_stream_init',['../a01330.html#aa9e1e45f0305622dd6aed9f8fe158581',1,'stream.c']]], ['tds_5fstaticin_5fstream_5fread',['tds_staticin_stream_read',['../a01330.html#a76b02f1fa5b79dc7e1ef2651a9afe3f7',1,'stream.c']]], ['tds_5fstaticout_5fstream',['tds_staticout_stream',['../a01061.html',1,'']]], ['tds_5fstaticout_5fstream_5finit',['tds_staticout_stream_init',['../a01330.html#a9fe0d3799d2e3bde49b614c9d0c3785d',1,'stream.c']]], ['tds_5fstaticout_5fstream_5fwrite',['tds_staticout_stream_write',['../a01330.html#a1d92ebe06f18378ac17ccfd20db05126',1,'stream.c']]], ['tds_5fstr_5fempty',['tds_str_empty',['../a00535.html#ga676fd3c5c489584d09c89d66c7a0af2d',1,'tds_str_empty(): tdsstring.c'],['../a00535.html#ga676fd3c5c489584d09c89d66c7a0af2d',1,'tds_str_empty(): tdsstring.c']]], ['tds_5fstrftime',['tds_strftime',['../a00530.html#ga8c9652e8b1f3e56a3289fd71b12cee1d',1,'tds_strftime(char *buf, size_t maxsize, const char *format, const TDSDATEREC *dr, int prec): convert.c'],['../a00530.html#ga8c9652e8b1f3e56a3289fd71b12cee1d',1,'tds_strftime(char *buf, size_t maxsize, const char *format, const TDSDATEREC *timeptr, int prec): convert.c']]], ['tds_5fstrndup',['tds_strndup',['../a00434.html#a1275e23db464803292b4c759c46621a6',1,'util.c']]], ['tds_5fsubmit_5fbegin_5ftran',['tds_submit_begin_tran',['../a00533.html#ga7bf3670d3d6dabed469b9eb117298079',1,'tds_submit_begin_tran(TDSSOCKET *tds): query.c'],['../a00533.html#ga7bf3670d3d6dabed469b9eb117298079',1,'tds_submit_begin_tran(TDSSOCKET *tds): query.c']]], ['tds_5fsubmit_5fcommit',['tds_submit_commit',['../a00533.html#ga530538c4c975524cf0b771a550fc94a3',1,'tds_submit_commit(TDSSOCKET *tds, int cont): query.c'],['../a00533.html#ga530538c4c975524cf0b771a550fc94a3',1,'tds_submit_commit(TDSSOCKET *tds, int cont): query.c']]], ['tds_5fsubmit_5fexecdirect',['tds_submit_execdirect',['../a00533.html#gae603aed795a4c5bb26ab159a11256996',1,'tds_submit_execdirect(TDSSOCKET *tds, const char *query, TDSPARAMINFO *params, TDSHEADERS *head): query.c'],['../a00533.html#gae603aed795a4c5bb26ab159a11256996',1,'tds_submit_execdirect(TDSSOCKET *tds, const char *query, TDSPARAMINFO *params, TDSHEADERS *head): query.c']]], ['tds_5fsubmit_5fexecute',['tds_submit_execute',['../a00533.html#ga3e7b4793c6f799fbc6c174f673bb5b32',1,'tds_submit_execute(TDSSOCKET *tds, TDSDYNAMIC *dyn): query.c'],['../a00533.html#ga3e7b4793c6f799fbc6c174f673bb5b32',1,'tds_submit_execute(TDSSOCKET *tds, TDSDYNAMIC *dyn): query.c']]], ['tds_5fsubmit_5foptioncmd',['tds_submit_optioncmd',['../a00533.html#gaf0da49585d39e99780a004ee2ca23479',1,'tds_submit_optioncmd(TDSSOCKET *tds, TDS_OPTION_CMD command, TDS_OPTION option, TDS_OPTION_ARG *param, TDS_INT param_size): query.c'],['../a00533.html#gaf0da49585d39e99780a004ee2ca23479',1,'tds_submit_optioncmd(TDSSOCKET *tds, TDS_OPTION_CMD command, TDS_OPTION option, TDS_OPTION_ARG *param, TDS_INT param_size): query.c']]], ['tds_5fsubmit_5fprepare',['tds_submit_prepare',['../a00533.html#ga74eb08c3a1c85be8ac9db428842c8b9d',1,'tds_submit_prepare(TDSSOCKET *tds, const char *query, const char *id, TDSDYNAMIC **dyn_out, TDSPARAMINFO *params): query.c'],['../a00533.html#ga74eb08c3a1c85be8ac9db428842c8b9d',1,'tds_submit_prepare(TDSSOCKET *tds, const char *query, const char *id, TDSDYNAMIC **dyn_out, TDSPARAMINFO *params): query.c']]], ['tds_5fsubmit_5fquery',['tds_submit_query',['../a00533.html#ga5a29ae7f99d089dc3cea85ec6ee5f3ab',1,'tds_submit_query(TDSSOCKET *tds, const char *query): query.c'],['../a00533.html#ga5a29ae7f99d089dc3cea85ec6ee5f3ab',1,'tds_submit_query(TDSSOCKET *tds, const char *query): query.c']]], ['tds_5fsubmit_5fquery_5fparams',['tds_submit_query_params',['../a00533.html#ga95e0fccedc459a4404f496eec74a369a',1,'tds_submit_query_params(TDSSOCKET *tds, const char *query, TDSPARAMINFO *params, TDSHEADERS *head): query.c'],['../a00533.html#ga95e0fccedc459a4404f496eec74a369a',1,'tds_submit_query_params(TDSSOCKET *tds, const char *query, TDSPARAMINFO *params, TDSHEADERS *head): query.c']]], ['tds_5fsubmit_5fqueryf',['tds_submit_queryf',['../a00533.html#gad695defcbf663b0023851a198206a772',1,'tds_submit_queryf(TDSSOCKET *tds, const char *queryf,...): query.c'],['../a00533.html#gad695defcbf663b0023851a198206a772',1,'tds_submit_queryf(TDSSOCKET *tds, const char *queryf,...): query.c']]], ['tds_5fsubmit_5frollback',['tds_submit_rollback',['../a00533.html#ga9c1cdcc388506a2ca3c0aaee8c461ba6',1,'tds_submit_rollback(TDSSOCKET *tds, int cont): query.c'],['../a00533.html#ga9c1cdcc388506a2ca3c0aaee8c461ba6',1,'tds_submit_rollback(TDSSOCKET *tds, int cont): query.c']]], ['tds_5fsubmit_5frpc',['tds_submit_rpc',['../a00533.html#ga5f071b94ad7889690762dc85646c74ab',1,'tds_submit_rpc(TDSSOCKET *tds, const char *rpc_name, TDSPARAMINFO *params, TDSHEADERS *head): query.c'],['../a00533.html#ga5f071b94ad7889690762dc85646c74ab',1,'tds_submit_rpc(TDSSOCKET *tds, const char *rpc_name, TDSPARAMINFO *params, TDSHEADERS *head): query.c']]], ['tds_5fsubmit_5funprepare',['tds_submit_unprepare',['../a00533.html#gaf573d8d4d2660c8c27770573fca05ff5',1,'tds_submit_unprepare(TDSSOCKET *tds, TDSDYNAMIC *dyn): query.c'],['../a00533.html#gaf573d8d4d2660c8c27770573fca05ff5',1,'tds_submit_unprepare(TDSSOCKET *tds, TDSDYNAMIC *dyn): query.c']]], ['tds_5fswap_5fnumeric',['tds_swap_numeric',['../a00260.html#aa818c1cbf4d16e609b7e4895cc7ed74f',1,'data.c']]], ['tds_5fsyb_5fver',['TDS_SYB_VER',['../a00434.html#aca53a637849948c4b7a07f69e40c685c',1,'tds.h']]], ['tds_5fsybase_5fdbdaterec',['tds_sybase_dbdaterec',['../a01289.html',1,'']]], ['tds_5fsybase_5fdbdaterec2',['tds_sybase_dbdaterec2',['../a01297.html',1,'']]], ['tds_5fsys_5ficonv_5fopen',['tds_sys_iconv_open',['../a00531.html#ga900b0bce08c6bfc2e7c988f4b5970516',1,'tds_sys_iconv_open(const char *tocode, const char *fromcode): iconv.c'],['../a00531.html#ga900b0bce08c6bfc2e7c988f4b5970516',1,'tds_sys_iconv_open(const char *tocode, const char *fromcode): iconv.c']]], ['tds_5fthread',['tds_thread',['../a01209.html',1,'']]], ['tds_5ftime',['tds_time',['../a00717.html',1,'']]], ['tds_5ftimestamp_5fstr',['tds_timestamp_str',['../a00434.html#a9222a29979fcf3a660f9f4ca3cc494ee',1,'threadsafe.c']]], ['tds_5ftoken_5fname',['tds_token_name',['../a00536.html#ga7f24a7af985cd320788122e98072b7af',1,'token.c']]], ['tds_5funget_5fbyte',['tds_unget_byte',['../a00534.html#gad70d59fb317d098b0c9fd29dd77131a8',1,'tds_unget_byte(TDSSOCKET *tds): read.c'],['../a00534.html#gad70d59fb317d098b0c9fd29dd77131a8',1,'tds_unget_byte(TDSSOCKET *tds): read.c']]], ['tds_5fupd_5fcol',['tds_upd_col',['../a01149.html',1,'']]], ['tds_5fvariant',['tds_variant',['../a01117.html',1,'']]], ['tds_5fvarmax_5fstream',['tds_varmax_stream',['../a00721.html',1,'']]], ['tds_5fversion',['tds_version',['../a01101.html#a8f9f756b25fd18916a6080f9c22f835d',1,'tds_login']]], ['tds_5fwillconvert',['tds_willconvert',['../a00530.html#ga80487b313213f60d8be71a50a002bb2c',1,'tds_willconvert(int srctype, int desttype): convert.c'],['../a00530.html#ga80487b313213f60d8be71a50a002bb2c',1,'tds_willconvert(int srctype, int desttype): convert.c']]], ['tds_5fwrite_5fdump',['tds_write_dump',['../a00434.html#a4766b1a553077cb3257d36b9ac28f5b5',1,'log.c']]], ['tds_5fwritetext_5fcontinue',['tds_writetext_continue',['../a00248.html#ab68dead99a2ebec55895a10cd3db5202',1,'tds_writetext_continue(TDSSOCKET *tds, const TDS_UCHAR *text, TDS_UINT size): bulk.c'],['../a00434.html#ab68dead99a2ebec55895a10cd3db5202',1,'tds_writetext_continue(TDSSOCKET *tds, const TDS_UCHAR *text, TDS_UINT size): bulk.c']]], ['tds_5fwritetext_5fend',['tds_writetext_end',['../a00248.html#ac1e460551f1188620ea478238864ac4b',1,'tds_writetext_end(TDSSOCKET *tds): bulk.c'],['../a00434.html#ac1e460551f1188620ea478238864ac4b',1,'tds_writetext_end(TDSSOCKET *tds): bulk.c']]], ['tds_5fwritetext_5fstart',['tds_writetext_start',['../a00248.html#a7711612cc544a7da2c7aa212b870acb2',1,'tds_writetext_start(TDSSOCKET *tds, const char *objname, const char *textptr, const char *timestamp, int with_log, TDS_UINT size): bulk.c'],['../a00434.html#a7711612cc544a7da2c7aa212b870acb2',1,'tds_writetext_start(TDSSOCKET *tds, const char *objname, const char *textptr, const char *timestamp, int with_log, TDS_UINT size): bulk.c']]], ['tds_5fwriting',['TDS_WRITING',['../a00434.html#a87cdae58f91ebe9229206bf0628f8e33a4a4fcc1840bee1e09521f08a0184d025',1,'tds.h']]], ['tdsblob',['TDSBLOB',['../a00434.html#a479425fecfdcd8e617b2b2e38d54b664',1,'tds.h']]], ['tdscursor',['TDSCURSOR',['../a00434.html#aad3739704ca49d8ebe445ca9b5e3b8b2',1,'tds.h']]], ['tdsdaterec',['tdsdaterec',['../a01081.html',1,'tdsdaterec'],['../a00434.html#a2ab81f7a472558595c985c9c3f8c528e',1,'TDSDATEREC(): tds.h']]], ['tdsdatetime',['tdsdatetime',['../a01021.html',1,'']]], ['tdsdatetime4',['tdsdatetime4',['../a01025.html',1,'']]], ['tdsdbopen',['tdsdbopen',['../a00524.html#ga2c99ec565452279e9a382451d89642eb',1,'tdsdbopen(LOGINREC *login, const char *server, int msdblib): dblib.c'],['../a00524.html#ga2c99ec565452279e9a382451d89642eb',1,'tdsdbopen(LOGINREC *login, const char *server, int msdblib): dblib.c']]], ['tdsdump_5fclose',['tdsdump_close',['../a00434.html#a2f00fc0907d3bb04ce0eeb9738e08d0c',1,'log.c']]], ['tdsdump_5fcol',['tdsdump_col',['../a00434.html#aaee3fe5c514ce5570c9548de9b16e0d9',1,'log.c']]], ['tdsdump_5fdump_5fbuf',['tdsdump_dump_buf',['../a00434.html#a79449d2f35a8acc8ed0585044f75524d',1,'log.c']]], ['tdsdump_5flog',['tdsdump_log',['../a00434.html#ab45c291105027e69836002e1dd586141',1,'log.c']]], ['tdsdump_5foff',['tdsdump_off',['../a00434.html#ac4dfaa4426d8a98bb1c74e46293eb4d1',1,'log.c']]], ['tdsdump_5fon',['tdsdump_on',['../a00434.html#a0bff83b40604dcc2e5d4f6f26256a96d',1,'log.c']]], ['tdsdump_5fopen',['tdsdump_open',['../a00434.html#a24471508ddfde7cc0f8577801e70c42f',1,'log.c']]], ['tdsdynamic',['TDSDYNAMIC',['../a00434.html#a4a7511ca7305098f5bb111aa9214810b',1,'tds.h']]], ['tdsenv',['TDSENV',['../a00434.html#ab2c3d86ac695df335c70b088729853ae',1,'tds.h']]], ['tdserror',['tdserror',['../a00434.html#abf18b98efef6ce2dc0b97d658a3a1918',1,'util.c']]], ['tdsfilestream',['TDSFILESTREAM',['../a00248.html#a017b2e89d0641a6af2a84e3953574fb0',1,'bulk.c']]], ['tdsiconvdir',['tdsiconvdir',['../a00941.html',1,'']]], ['tdsiconvinfo',['tdsiconvinfo',['../a00945.html',1,'']]], ['tdsmoney',['tdsmoney',['../a01013.html',1,'']]], ['tdsmoney4',['tdsmoney4',['../a01017.html',1,'']]], ['tdsnumeric',['tdsnumeric',['../a01005.html',1,'']]], ['tdsoldmoney',['tdsoldmoney',['../a01009.html',1,'']]], ['tdspbcb',['TDSPBCB',['../a00248.html#a786e761d5de7ac54bff4a948e1dab4b6',1,'bulk.c']]], ['tdsresultinfo',['TDSRESULTINFO',['../a00434.html#a22c989e4b40c76c0bfb64c6610f4a8b6',1,'tds.h']]], ['tdsunique',['tdsunique',['../a01029.html',1,'']]], ['tdsvariant',['TDSVARIANT',['../a00434.html#a7ef9511424cb9015043fa7e7da4efb74',1,'tds.h']]], ['tdsvername_5ft',['tdsvername_t',['../a00713.html',1,'']]], ['term_5flen',['term_len',['../a00693.html#aae893302d33ee1e9d83c3d85d7390dca',1,'tds_file_stream']]], ['terminator',['terminator',['../a00693.html#a463c28a7d862c0a6d7bf3170dd614dc0',1,'tds_file_stream']]], ['time',['time',['../a01077.html#afd6a58ec251f2c08a040917ba5a8cd3f',1,'TDS_DATETIMEALL::time()'],['../a01265.html#a6bb5dcd5b47813b71934546e0c60e035',1,'DBDATETIMEALL::time()']]], ['timezone',['timezone',['../a01081.html#a624e21e65d0ae89797b3a7eadc48829f',1,'tdsdaterec']]], ['tm_5fhour',['tm_hour',['../a00717.html#a6ece03e77f69035da83d5739e16ef905',1,'tds_time']]], ['tm_5fmday',['tm_mday',['../a00717.html#a8dfc26d484c247040f521f20288651f1',1,'tds_time']]], ['tm_5fmin',['tm_min',['../a00717.html#ab50f30e05dc6b493d347918ab7ded1e9',1,'tds_time']]], ['tm_5fmon',['tm_mon',['../a00717.html#adce28126e9bbd4ef005e3bf181d59745',1,'tds_time']]], ['tm_5fns',['tm_ns',['../a00717.html#a386f1cfcabbe3ed86afe72bed75778cf',1,'tds_time']]], ['tm_5fsec',['tm_sec',['../a00717.html#adeb5e3f535662c0341d28f8d669cb59b',1,'tds_time']]], ['tm_5fyear',['tm_year',['../a00717.html#a3e27d50ebb5196356a6a8a9b495c8758',1,'tds_time']]], ['tmp_5fcol_5fstruct',['tmp_col_struct',['../a00673.html',1,'']]], ['todo_20list',['Todo List',['../a00515.html',1,'']]], ['token_2ec',['token.c',['../a00344.html',1,'']]], ['type',['type',['../a01157.html#a889aafdde1d57c9be0585326022831f0',1,'tds_cursor']]] ]; freetds-1.00.82/doc/reference/search/all_13.html100644 025423 025423 00000001766 13242511131 0014742
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/all_13.js100644 025423 025423 00000000600 13242511131 0014374var searchData= [ ['unimplemented',['Unimplemented',['../a00525.html',1,'']]], ['uad',['uad',['../a00985.html#a93c0c73d7161aa0c8fd59016e66def9e',1,'_hdbc']]], ['unix_5fto_5fnt_5ftime',['unix_to_nt_time',['../a00528.html#ga73c98114ee9846fe7606de3862519e9d',1,'challenge.c']]], ['user_5fname',['user_name',['../a01101.html#a2b2de13270472df39952848eb3970d9a',1,'tds_login']]] ]; freetds-1.00.82/doc/reference/search/all_14.html100644 025423 025423 00000001766 13242511131 0014743
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/all_14.js100644 025423 025423 00000000636 13242511131 0014406var searchData= [ ['waiters',['waiters',['../a00669.html#a009d30222683a3540fcddbc3e9033828',1,'tds_pool']]], ['weekday',['weekday',['../a01081.html#a40de0c7d78e9c1edae4c07435c10192b',1,'tdsdaterec']]], ['wire_5fsize',['wire_size',['../a01049.html#a8101abd3e9e8d6f90b2ba2717bf7f926',1,'tds_datain_stream']]], ['write',['write',['../a01045.html#a8513fb41c8ba79f22e54266b87278415',1,'tds_output_stream']]] ]; freetds-1.00.82/doc/reference/search/all_15.html100644 025423 025423 00000001766 13242511131 0014744
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/all_15.js100644 025423 025423 00000000155 13242511131 0014403var searchData= [ ['year',['year',['../a01081.html#a5a6a5b0180c3db53acbda61dd570d70f',1,'tdsdaterec']]] ]; freetds-1.00.82/doc/reference/search/classes_0.html100644 025423 025423 00000001771 13242511131 0015537
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/classes_0.js100644 025423 025423 00000005215 13242511131 0015204var searchData= [ ['_5fcharacter_5fset_5falias',['_character_set_alias',['../a00933.html',1,'']]], ['_5fcs_5fblkdesc',['_cs_blkdesc',['../a00861.html',1,'']]], ['_5fcs_5fclientmsg',['_cs_clientmsg',['../a00809.html',1,'']]], ['_5fcs_5fcommand',['_cs_command',['../a00857.html',1,'']]], ['_5fcs_5fconfig',['_cs_config',['../a00817.html',1,'']]], ['_5fcs_5fconnection',['_cs_connection',['../a00841.html',1,'']]], ['_5fcs_5fcontext',['_cs_context',['../a00833.html',1,'']]], ['_5fcs_5fdatafmt',['_cs_datafmt',['../a00785.html',1,'']]], ['_5fcs_5fdaterec',['_cs_daterec',['../a00805.html',1,'']]], ['_5fcs_5fdatetime',['_cs_datetime',['../a00797.html',1,'']]], ['_5fcs_5fdatetime4',['_cs_datetime4',['../a00801.html',1,'']]], ['_5fcs_5fdynamic',['_cs_dynamic',['../a00853.html',1,'']]], ['_5fcs_5fiodesc',['_cs_iodesc',['../a00781.html',1,'']]], ['_5fcs_5flocale',['_cs_locale',['../a00865.html',1,'']]], ['_5fcs_5fmoney',['_cs_money',['../a00789.html',1,'']]], ['_5fcs_5fmoney4',['_cs_money4',['../a00793.html',1,'']]], ['_5fcs_5fnumeric',['_cs_numeric',['../a00769.html',1,'']]], ['_5fcs_5fobjdata',['_cs_objdata',['../a00765.html',1,'']]], ['_5fcs_5fobjname',['_cs_objname',['../a00761.html',1,'']]], ['_5fcs_5fparam',['_cs_param',['../a00845.html',1,'']]], ['_5fcs_5fservermsg',['_cs_servermsg',['../a00813.html',1,'']]], ['_5fcs_5fvarbinary',['_cs_varbinary',['../a00773.html',1,'']]], ['_5fcs_5fvarchar',['_cs_varchar',['../a00777.html',1,'']]], ['_5fcsremote_5fproc',['_csremote_proc',['../a00849.html',1,'']]], ['_5fct_5fcolinfo',['_ct_colinfo',['../a00837.html',1,'']]], ['_5fdblib_5ferror_5fmessage',['_dblib_error_message',['../a00589.html',1,'']]], ['_5fdbremote_5fproc',['_DBREMOTE_PROC',['../a00889.html',1,'']]], ['_5fdbremote_5fproc_5fparam',['_DBREMOTE_PROC_PARAM',['../a00885.html',1,'']]], ['_5fdheader',['_dheader',['../a00957.html',1,'']]], ['_5fdrecord',['_drecord',['../a00961.html',1,'']]], ['_5fhcattr',['_hcattr',['../a00981.html',1,'']]], ['_5fhchk',['_hchk',['../a00973.html',1,'']]], ['_5fhdbc',['_hdbc',['../a00985.html',1,'']]], ['_5fhdesc',['_hdesc',['../a00965.html',1,'']]], ['_5fheattr',['_heattr',['../a00969.html',1,'']]], ['_5fhenv',['_henv',['../a00977.html',1,'']]], ['_5fhsattr',['_hsattr',['../a00989.html',1,'']]], ['_5fhstmt',['_hstmt',['../a00993.html',1,'']]], ['_5fnull_5frepresentation',['_null_representation',['../a00897.html',1,'']]], ['_5foptions',['_options',['../a00557.html',1,'']]], ['_5fprocedure',['_procedure',['../a00577.html',1,'']]], ['_5fsql_5ferror',['_sql_error',['../a00949.html',1,'']]], ['_5fsql_5ferrors',['_sql_errors',['../a00953.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/classes_1.html100644 025423 025423 00000001771 13242511131 0015540
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/classes_1.js100644 025423 025423 00000000220 13242511131 0015174var searchData= [ ['agg_5ft',['agg_t',['../a00601.html',1,'']]], ['asn1_5fder_5fiterator',['asn1_der_iterator',['../a00741.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/classes_2.html100644 025423 025423 00000001771 13242511131 0015541
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/classes_2.js100644 025423 025423 00000000240 13242511131 0015177var searchData= [ ['bcp_5fhostcolinfo',['BCP_HOSTCOLINFO',['../a00877.html',1,'']]], ['bcp_5fhostfileinfo',['BCP_HOSTFILEINFO',['../a00881.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/classes_3.html100644 025423 025423 00000001771 13242511131 0015542
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/classes_3.js100644 025423 025423 00000001113 13242511131 0015200var searchData= [ ['cb_5ft',['cb_t',['../a00921.html',1,'conv_result']]], ['cc_5ft',['cc_t',['../a00917.html',1,'conv_result']]], ['col_5ft',['col_t',['../a00593.html',1,'']]], ['conf_5fparams',['conf_params',['../a00641.html',1,'']]], ['connect_5fevent',['CONNECT_EVENT',['../a00649.html',1,'']]], ['conv_5fresult',['conv_result',['../a00913.html',1,'']]], ['cs_5fdiag_5fmsg',['cs_diag_msg',['../a00829.html',1,'']]], ['cs_5fdiag_5fmsg_5fclient',['cs_diag_msg_client',['../a00821.html',1,'']]], ['cs_5fdiag_5fmsg_5fsvr',['cs_diag_msg_svr',['../a00825.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/classes_4.html100644 025423 025423 00000001771 13242511131 0015543
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/classes_4.js100644 025423 025423 00000002172 13242511131 0015207var searchData= [ ['data',['DATA',['../a00545.html',1,'']]], ['dbcol',['DBCOL',['../a01277.html',1,'']]], ['dbcol2',['DBCOL2',['../a01281.html',1,'']]], ['dbdatetime',['DBDATETIME',['../a01257.html',1,'']]], ['dbdatetime4',['DBDATETIME4',['../a01261.html',1,'']]], ['dbdatetimeall',['DBDATETIMEALL',['../a01265.html',1,'']]], ['dblib_5fbuffer_5frow',['dblib_buffer_row',['../a00581.html',1,'']]], ['dblib_5fcontext',['dblib_context',['../a00585.html',1,'']]], ['dbmoney',['DBMONEY',['../a01249.html',1,'']]], ['dbmoney4',['DBMONEY4',['../a01253.html',1,'']]], ['dbnumeric',['DBNUMERIC',['../a01245.html',1,'']]], ['dboption',['dboption',['../a00893.html',1,'']]], ['dbstring',['dbstring',['../a01273.html',1,'']]], ['dbtypeinfo',['dbtypeinfo',['../a01269.html',1,'']]], ['dbvarybin',['DBVARYBIN',['../a01241.html',1,'']]], ['dbvarychar',['DBVARYCHAR',['../a01237.html',1,'']]], ['des_5fkey',['des_key',['../a00905.html',1,'']]], ['dlist_5flist_5ftype',['DLIST_LIST_TYPE',['../a00929.html',1,'']]], ['dlist_5fring',['dlist_ring',['../a00925.html',1,'']]], ['dsninfo',['DSNINFO',['../a00637.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/classes_5.html100644 025423 025423 00000001771 13242511131 0015544
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/classes_5.js100644 025423 025423 00000000133 13242511131 0015203var searchData= [ ['end_5flogin_5fevent',['END_LOGIN_EVENT',['../a00681.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/classes_6.html100644 025423 025423 00000001771 13242511131 0015545
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/classes_6.js100644 025423 025423 00000000115 13242511131 0015204var searchData= [ ['func_5finfo',['func_info',['../a00629.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/classes_7.html100644 025423 025423 00000001771 13242511131 0015546
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/classes_7.js100644 025423 025423 00000000105 13242511131 0015204var searchData= [ ['key_5ft',['KEY_T',['../a00553.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/classes_8.html100644 025423 025423 00000001771 13242511131 0015547
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/classes_8.js100644 025423 025423 00000000206 13242511131 0015207var searchData= [ ['login_5fevent',['LOGIN_EVENT',['../a00677.html',1,'']]], ['loginrec',['LOGINREC',['../a00565.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/classes_9.html100644 025423 025423 00000001771 13242511131 0015550
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/classes_9.js100644 025423 025423 00000000534 13242511131 0015214var searchData= [ ['md4context',['MD4Context',['../a01213.html',1,'']]], ['md5context',['MD5Context',['../a01217.html',1,'']]], ['metacomp',['METACOMP',['../a00549.html',1,'']]], ['metadata',['METADATA',['../a00541.html',1,'']]], ['metadata_5ft',['metadata_t',['../a00605.html',1,'']]], ['mpz_5ft',['mpz_t',['../a00737.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/classes_a.html100644 025423 025423 00000001771 13242511131 0015620
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/classes_a.js100644 025423 025423 00000000412 13242511131 0015257var searchData= [ ['name_5ft',['name_t',['../a00613.html',1,'']]], ['namelist',['namelist',['../a00749.html',1,'']]], ['names_5fblob_5fprefix_5ft',['names_blob_prefix_t',['../a00701.html',1,'']]], ['native_5finfo',['native_info',['../a00633.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/classes_b.html100644 025423 025423 00000001771 13242511131 0015621
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/classes_b.js100644 025423 025423 00000000115 13242511131 0015260var searchData= [ ['objectinfo',['OBJECTINFO',['../a00569.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/classes_c.html100644 025423 025423 00000001771 13242511131 0015622
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/classes_c.js100644 025423 025423 00000000554 13242511131 0015270var searchData= [ ['pd',['pd',['../a00573.html',1,'']]], ['pivot_5ft',['pivot_t',['../a00609.html',1,'']]], ['pivot_5ft',['pivot_t',['../a00561.html',1,'_options']]], ['pollfd',['pollfd',['../a01229.html',1,'']]], ['profileparam',['ProfileParam',['../a00617.html',1,'']]], ['ptw32_5fmcs_5fnode_5ft_5f',['ptw32_mcs_node_t_',['../a00685.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/classes_d.html100644 025423 025423 00000001771 13242511131 0015623
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/classes_d.js100644 025423 025423 00000000131 13242511131 0015260var searchData= [ ['rsa_5fpublic_5fkey',['rsa_public_key',['../a00745.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/classes_e.html100644 025423 025423 00000001771 13242511131 0015624
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/classes_e.js100644 025423 025423 00000000426 13242511131 0015270var searchData= [ ['s_5fsqlmsgmap',['s_SqlMsgMap',['../a00621.html',1,'']]], ['s_5fv3to2map',['s_v3to2map',['../a00625.html',1,'']]], ['select_5finfo',['select_info',['../a00645.html',1,'']]], ['string_5flinked_5flist',['string_linked_list',['../a00757.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/classes_f.html100644 025423 025423 00000001771 13242511131 0015625
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/classes_f.js100644 025423 025423 00000013110 13242511131 0015263var searchData= [ ['tag_5fdbproc_5frowbuf',['tag_DBPROC_ROWBUF',['../a00873.html',1,'']]], ['tagss_5ftime2_5fstruct',['tagSS_TIME2_STRUCT',['../a01221.html',1,'']]], ['tagss_5ftimestampoffset_5fstruct',['tagSS_TIMESTAMPOFFSET_STRUCT',['../a01225.html',1,'']]], ['tds71_5fcollation',['TDS71_COLLATION',['../a01033.html',1,'']]], ['tds72_5fsmp_5fheader',['TDS72_SMP_HEADER',['../a01037.html',1,'']]], ['tds_5faddrinfo',['tds_addrinfo',['../a01233.html',1,'']]], ['tds_5falign_5fstruct',['tds_align_struct',['../a01089.html',1,'']]], ['tds_5fanswer',['tds_answer',['../a00697.html',1,'']]], ['tds_5fauthentication',['tds_authentication',['../a01177.html',1,'']]], ['tds_5fbcpcoldata',['tds_bcpcoldata',['../a01125.html',1,'']]], ['tds_5fbcpinfo',['tds_bcpinfo',['../a01197.html',1,'']]], ['tds_5fblob',['tds_blob',['../a01113.html',1,'']]], ['tds_5fcapabilities',['tds_capabilities',['../a01097.html',1,'']]], ['tds_5fcapability_5ftype',['tds_capability_type',['../a01093.html',1,'']]], ['tds_5fcolumn',['tds_column',['../a01133.html',1,'']]], ['tds_5fcolumn_5ffuncs',['tds_column_funcs',['../a01129.html',1,'']]], ['tds_5fcompiletime_5fsettings',['tds_compiletime_settings',['../a01069.html',1,'']]], ['tds_5fcondition',['tds_condition',['../a01205.html',1,'']]], ['tds_5fconnection',['tds_connection',['../a01189.html',1,'']]], ['tds_5fcontext',['tds_context',['../a01173.html',1,'']]], ['tds_5fcursor',['tds_cursor',['../a01157.html',1,'']]], ['tds_5fcursor_5fstatus',['tds_cursor_status',['../a01153.html',1,'']]], ['tds_5fdatain_5fstream',['tds_datain_stream',['../a01049.html',1,'']]], ['tds_5fdataout_5fstream',['tds_dataout_stream',['../a01053.html',1,'']]], ['tds_5fdatetimeall',['TDS_DATETIMEALL',['../a01077.html',1,'']]], ['tds_5fdblib_5fdbprocess',['tds_dblib_dbprocess',['../a00901.html',1,'']]], ['tds_5fdblib_5floginrec',['tds_dblib_loginrec',['../a00869.html',1,'']]], ['tds_5fdstr',['tds_dstr',['../a01073.html',1,'']]], ['tds_5fdynamic',['tds_dynamic',['../a01165.html',1,'']]], ['tds_5fdynamic_5fstream',['tds_dynamic_stream',['../a01065.html',1,'']]], ['tds_5fencoding',['tds_encoding',['../a01121.html',1,'']]], ['tds_5fenv',['tds_env',['../a01161.html',1,'']]], ['tds_5ferrno_5fmessage_5fflags',['tds_errno_message_flags',['../a00937.html',1,'']]], ['tds_5ferror_5fmessage',['tds_error_message',['../a00753.html',1,'']]], ['tds_5ffile_5fstream',['tds_file_stream',['../a00693.html',1,'']]], ['tds_5ffuncs',['TDS_FUNCS',['../a00997.html',1,'']]], ['tds_5fheaders',['tds_headers',['../a01105.html',1,'']]], ['tds_5finput_5fstream',['tds_input_stream',['../a01041.html',1,'']]], ['tds_5flocale',['tds_locale',['../a01109.html',1,'']]], ['tds_5flogin',['tds_login',['../a01101.html',1,'']]], ['tds_5fmay_5falias',['TDS_MAY_ALIAS',['../a00909.html',1,'']]], ['tds_5fmessage',['tds_message',['../a01145.html',1,'']]], ['tds_5fmicrosoft_5fdbdaterec',['tds_microsoft_dbdaterec',['../a01285.html',1,'']]], ['tds_5fmicrosoft_5fdbdaterec2',['tds_microsoft_dbdaterec2',['../a01293.html',1,'']]], ['tds_5fmultiple',['tds_multiple',['../a01169.html',1,'']]], ['tds_5fntlm_5fauth',['tds_ntlm_auth',['../a00705.html',1,'']]], ['tds_5foption_5farg',['tds_option_arg',['../a01085.html',1,'']]], ['tds_5foutput_5fstream',['tds_output_stream',['../a01045.html',1,'']]], ['tds_5fpacket',['tds_packet',['../a01181.html',1,'']]], ['tds_5fparsed_5fparam',['TDS_PARSED_PARAM',['../a01001.html',1,'']]], ['tds_5fpbcb',['tds_pbcb',['../a00689.html',1,'']]], ['tds_5fpoll_5fwakeup',['tds_poll_wakeup',['../a01185.html',1,'']]], ['tds_5fpool',['tds_pool',['../a00669.html',1,'']]], ['tds_5fpool_5fevent',['tds_pool_event',['../a00653.html',1,'']]], ['tds_5fpool_5fmember',['tds_pool_member',['../a00665.html',1,'']]], ['tds_5fpool_5fsocket',['tds_pool_socket',['../a00657.html',1,'']]], ['tds_5fpool_5fuser',['tds_pool_user',['../a00661.html',1,'']]], ['tds_5fraw_5fmutex',['tds_raw_mutex',['../a01201.html',1,'']]], ['tds_5fresult_5finfo',['tds_result_info',['../a01141.html',1,'']]], ['tds_5fsave_5fcontext',['tds_save_context',['../a00733.html',1,'']]], ['tds_5fsave_5fenv',['tds_save_env',['../a00729.html',1,'']]], ['tds_5fsave_5fmsg',['tds_save_msg',['../a00725.html',1,'']]], ['tds_5fsocket',['tds_socket',['../a01193.html',1,'']]], ['tds_5fstaticin_5fstream',['tds_staticin_stream',['../a01057.html',1,'']]], ['tds_5fstaticout_5fstream',['tds_staticout_stream',['../a01061.html',1,'']]], ['tds_5fsybase_5fdbdaterec',['tds_sybase_dbdaterec',['../a01289.html',1,'']]], ['tds_5fsybase_5fdbdaterec2',['tds_sybase_dbdaterec2',['../a01297.html',1,'']]], ['tds_5fthread',['tds_thread',['../a01209.html',1,'']]], ['tds_5ftime',['tds_time',['../a00717.html',1,'']]], ['tds_5fupd_5fcol',['tds_upd_col',['../a01149.html',1,'']]], ['tds_5fvariant',['tds_variant',['../a01117.html',1,'']]], ['tds_5fvarmax_5fstream',['tds_varmax_stream',['../a00721.html',1,'']]], ['tdsdaterec',['tdsdaterec',['../a01081.html',1,'']]], ['tdsdatetime',['tdsdatetime',['../a01021.html',1,'']]], ['tdsdatetime4',['tdsdatetime4',['../a01025.html',1,'']]], ['tdsiconvdir',['tdsiconvdir',['../a00941.html',1,'']]], ['tdsiconvinfo',['tdsiconvinfo',['../a00945.html',1,'']]], ['tdsmoney',['tdsmoney',['../a01013.html',1,'']]], ['tdsmoney4',['tdsmoney4',['../a01017.html',1,'']]], ['tdsnumeric',['tdsnumeric',['../a01005.html',1,'']]], ['tdsoldmoney',['tdsoldmoney',['../a01009.html',1,'']]], ['tdsunique',['tdsunique',['../a01029.html',1,'']]], ['tdsvername_5ft',['tdsvername_t',['../a00713.html',1,'']]], ['tmp_5fcol_5fstruct',['tmp_col_struct',['../a00673.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/files_0.html100644 025423 025423 00000001767 13242511131 0015211
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/files_0.js100644 025423 025423 00000000107 13242511131 0014644var searchData= [ ['bulk_2ec',['bulk.c',['../a00248.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/files_1.html100644 025423 025423 00000001767 13242511131 0015212
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/files_1.js100644 025423 025423 00000000174 13242511131 0014651var searchData= [ ['data_2ec',['data.c',['../a00260.html',1,'']]], ['dblib_2ec',['dblib.c',['../a00077.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/files_2.html100644 025423 025423 00000001767 13242511131 0015213
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/files_2.js100644 025423 025423 00000000176 13242511131 0014654var searchData= [ ['iconv_2ec',['iconv.c',['../a01339.html',1,'']]], ['iconv_2ec',['iconv.c',['../a01342.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/files_3.html100644 025423 025423 00000001767 13242511131 0015214
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/files_3.js100644 025423 025423 00000000107 13242511131 0014647var searchData= [ ['poll_2eh',['poll.h',['../a00461.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/files_4.html100644 025423 025423 00000001767 13242511131 0015215
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/files_4.js100644 025423 025423 00000000107 13242511131 0014650var searchData= [ ['read_2ec',['read.c',['../a00311.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/files_5.html100644 025423 025423 00000001767 13242511131 0015216
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/files_5.js100644 025423 025423 00000000200 13242511131 0014643var searchData= [ ['stream_2ec',['stream.c',['../a01330.html',1,'']]], ['sybdb_2eh',['sybdb.h',['../a00479.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/files_6.html100644 025423 025423 00000001767 13242511131 0015217
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/files_6.js100644 025423 025423 00000000172 13242511131 0014654var searchData= [ ['tds_2eh',['tds.h',['../a00434.html',1,'']]], ['token_2ec',['token.c',['../a00344.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/functions_0.html100644 025423 025423 00000001773 13242511131 0016114
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/functions_0.js100644 025423 025423 00000003062 13242511131 0015555var searchData= [ ['_5fbcp_5fexec_5fin',['_bcp_exec_in',['../a00521.html#ga7370f1223f13510d6b33e98f2de09fb5',1,'bcp.c']]], ['_5fbcp_5fexec_5fout',['_bcp_exec_out',['../a00521.html#gae67546338cb9542a4902aa914f57f314',1,'bcp.c']]], ['_5fbcp_5ffgets',['_bcp_fgets',['../a00521.html#gaf4e2c59203f2af21bb2803ef4a69bfa8',1,'bcp.c']]], ['_5fbcp_5ffree_5fcolumns',['_bcp_free_columns',['../a00521.html#gacf69ac4cbe8e3c3e6ea665e31e5e85b8',1,'bcp.c']]], ['_5fbcp_5ffree_5fstorage',['_bcp_free_storage',['../a00521.html#gaa134c1c3ccc4326e693adb8357272f1d',1,'bcp.c']]], ['_5fbcp_5fget_5fcol_5fdata',['_bcp_get_col_data',['../a00521.html#ga0f8def4cad04c5c1e27c2b653d482dd8',1,'bcp.c']]], ['_5fbcp_5fget_5fterm_5fvar',['_bcp_get_term_var',['../a00521.html#gac82ffc5c1f71cbf453d81d1057004f1e',1,'bcp.c']]], ['_5fbcp_5fread_5fhostfile',['_bcp_read_hostfile',['../a00521.html#ga065757a7d0dce354660900de4aa79e2f',1,'bcp.c']]], ['_5fbcp_5freadfmt_5fcolinfo',['_bcp_readfmt_colinfo',['../a00521.html#gafc23d62bc86b38fb757e3ac4aadca0a4',1,'bcp.c']]], ['_5fdbcoldata',['_dbcoldata',['../a00524.html#ga3c6f474c0662158f3100fe464bf077d9',1,'dblib.c']]], ['_5fdblib_5fcheck_5fand_5fhandle_5finterrupt',['_dblib_check_and_handle_interrupt',['../a00524.html#gadf15185b0d417edc0bb8a6a4f0bae727',1,'_dblib_check_and_handle_interrupt(void *vdbproc): dbutil.c'],['../a00524.html#gadf15185b0d417edc0bb8a6a4f0bae727',1,'_dblib_check_and_handle_interrupt(void *vdbproc): dbutil.c']]], ['_5fdbresults',['_dbresults',['../a00518.html#gaf1879b85e8238c015b9648d077665285',1,'dblib.c']]] ]; freetds-1.00.82/doc/reference/search/functions_1.html100644 025423 025423 00000001773 13242511131 0016115
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/functions_1.js100644 025423 025423 00000000241 13242511131 0015552var searchData= [ ['adjust_5fcharacter_5fcolumn_5fsize',['adjust_character_column_size',['../a00536.html#ga91770634ce8c0d6f1fe007b45da186fd',1,'token.c']]] ]; freetds-1.00.82/doc/reference/search/functions_2.html100644 025423 025423 00000001773 13242511131 0016116
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/functions_2.js100644 025423 025423 00000011502 13242511131 0015555var searchData= [ ['bcp_5fbatch',['bcp_batch',['../a00520.html#gaa23f8e5c7f437a94746c90292dd1cb01',1,'bcp_batch(DBPROCESS *dbproc): bcp.c'],['../a00520.html#gaa23f8e5c7f437a94746c90292dd1cb01',1,'bcp_batch(DBPROCESS *dbproc): bcp.c']]], ['bcp_5fbind',['bcp_bind',['../a00520.html#ga6cf03708baaf02eb016b9ee77160d879',1,'bcp_bind(DBPROCESS *dbproc, BYTE *varaddr, int prefixlen, DBINT varlen, BYTE *terminator, int termlen, int db_vartype, int table_column): bcp.c'],['../a00520.html#ga6cf03708baaf02eb016b9ee77160d879',1,'bcp_bind(DBPROCESS *dbproc, BYTE *varaddr, int prefixlen, DBINT varlen, BYTE *terminator, int termlen, int type, int table_column): bcp.c']]], ['bcp_5fcolfmt',['bcp_colfmt',['../a00520.html#ga0ed03c69e698336d015bb315ad755fd5',1,'bcp_colfmt(DBPROCESS *dbproc, int host_colnum, int host_type, int host_prefixlen, DBINT host_collen, const BYTE *host_term, int host_termlen, int table_colnum): bcp.c'],['../a00520.html#ga0ed03c69e698336d015bb315ad755fd5',1,'bcp_colfmt(DBPROCESS *dbproc, int host_column, int host_type, int host_prefixlen, DBINT host_collen, const BYTE *host_term, int host_termlen, int colnum): bcp.c']]], ['bcp_5fcolfmt_5fps',['bcp_colfmt_ps',['../a00520.html#gaf13b2bb12b4200752718f3a3face3870',1,'bcp_colfmt_ps(DBPROCESS *dbproc, int host_colnum, int host_type, int host_prefixlen, DBINT host_collen, BYTE *host_term, int host_termlen, int table_colnum, DBTYPEINFO *typeinfo): bcp.c'],['../a00520.html#gaf13b2bb12b4200752718f3a3face3870',1,'bcp_colfmt_ps(DBPROCESS *dbproc, int host_column, int host_type, int host_prefixlen, DBINT host_collen, BYTE *host_term, int host_termlen, int colnum, DBTYPEINFO *typeinfo): bcp.c']]], ['bcp_5fcollen',['bcp_collen',['../a00520.html#gae41d196a22c544d66212dacc5b555791',1,'bcp_collen(DBPROCESS *dbproc, DBINT varlen, int table_column): bcp.c'],['../a00520.html#gae41d196a22c544d66212dacc5b555791',1,'bcp_collen(DBPROCESS *dbproc, DBINT varlen, int table_column): bcp.c']]], ['bcp_5fcolptr',['bcp_colptr',['../a00520.html#ga6498235e4ef8e41ea43b01494b28998d',1,'bcp_colptr(DBPROCESS *dbproc, BYTE *colptr, int table_column): bcp.c'],['../a00520.html#ga6498235e4ef8e41ea43b01494b28998d',1,'bcp_colptr(DBPROCESS *dbproc, BYTE *colptr, int table_column): bcp.c']]], ['bcp_5fcolumns',['bcp_columns',['../a00520.html#ga330b9f1028f856a9eec5115550bcb4f7',1,'bcp_columns(DBPROCESS *dbproc, int host_colcount): bcp.c'],['../a00520.html#ga330b9f1028f856a9eec5115550bcb4f7',1,'bcp_columns(DBPROCESS *dbproc, int host_colcount): bcp.c']]], ['bcp_5fcontrol',['bcp_control',['../a00520.html#ga244547855b41788fa3a67756956fbc81',1,'bcp_control(DBPROCESS *dbproc, int field, DBINT value): bcp.c'],['../a00520.html#ga244547855b41788fa3a67756956fbc81',1,'bcp_control(DBPROCESS *dbproc, int field, DBINT value): bcp.c']]], ['bcp_5fdone',['bcp_done',['../a00520.html#ga8b85f79f53a62ac7a728fe626d609b65',1,'bcp_done(DBPROCESS *dbproc): bcp.c'],['../a00520.html#ga8b85f79f53a62ac7a728fe626d609b65',1,'bcp_done(DBPROCESS *dbproc): bcp.c']]], ['bcp_5fexec',['bcp_exec',['../a00520.html#ga7a184158b27a50f713e9cfae3b746209',1,'bcp_exec(DBPROCESS *dbproc, DBINT *rows_copied): bcp.c'],['../a00520.html#ga7a184158b27a50f713e9cfae3b746209',1,'bcp_exec(DBPROCESS *dbproc, DBINT *rows_copied): bcp.c']]], ['bcp_5fgetl',['bcp_getl',['../a00520.html#ga220f6b043602da1028f98dacb2fd00c0',1,'bcp_getl(LOGINREC *login): bcp.c'],['../a00520.html#ga220f6b043602da1028f98dacb2fd00c0',1,'bcp_getl(LOGINREC *login): bcp.c']]], ['bcp_5finit',['bcp_init',['../a00520.html#gada8e987c4a6225b9276c05ba3a4f47a0',1,'bcp_init(DBPROCESS *dbproc, const char *tblname, const char *hfile, const char *errfile, int direction): bcp.c'],['../a00520.html#gada8e987c4a6225b9276c05ba3a4f47a0',1,'bcp_init(DBPROCESS *dbproc, const char *tblname, const char *hfile, const char *errfile, int direction): bcp.c']]], ['bcp_5foptions',['bcp_options',['../a00520.html#gafec3feb5bac1cb33545ba01efb0a67b8',1,'bcp_options(DBPROCESS *dbproc, int option, BYTE *value, int valuelen): bcp.c'],['../a00520.html#gafec3feb5bac1cb33545ba01efb0a67b8',1,'bcp_options(DBPROCESS *dbproc, int option, BYTE *value, int valuelen): bcp.c']]], ['bcp_5freadfmt',['bcp_readfmt',['../a00520.html#ga963c5e38bca7668afc57f5cc123d10fb',1,'bcp_readfmt(DBPROCESS *dbproc, const char filename[]): bcp.c'],['../a00520.html#ga963c5e38bca7668afc57f5cc123d10fb',1,'bcp_readfmt(DBPROCESS *dbproc, const char filename[]): bcp.c']]], ['bcp_5fsendrow',['bcp_sendrow',['../a00520.html#gaf1130ac97f6af55e86ec70b0aa4f5b40',1,'bcp_sendrow(DBPROCESS *dbproc): bcp.c'],['../a00520.html#gaf1130ac97f6af55e86ec70b0aa4f5b40',1,'bcp_sendrow(DBPROCESS *dbproc): bcp.c']]], ['binary_5fto_5fresult',['binary_to_result',['../a00530.html#gab09f8279ad6da8a0a6a935e5810d753a',1,'convert.c']]] ]; freetds-1.00.82/doc/reference/search/functions_3.html100644 025423 025423 00000001773 13242511131 0016117
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/functions_3.js100644 025423 025423 00000110770 13242511131 0015565var searchData= [ ['dbadata',['dbadata',['../a00518.html#gabcc14a1ca58b65bc46cce6c81c45218c',1,'dbadata(DBPROCESS *dbproc, int computeid, int column): dblib.c'],['../a00518.html#gabcc14a1ca58b65bc46cce6c81c45218c',1,'dbadata(DBPROCESS *dbproc, int computeid, int column): dblib.c']]], ['dbadlen',['dbadlen',['../a00518.html#ga3340e21db274b272ec11c037cb147222',1,'dbadlen(DBPROCESS *dbproc, int computeid, int column): dblib.c'],['../a00518.html#ga3340e21db274b272ec11c037cb147222',1,'dbadlen(DBPROCESS *dbproc, int computeid, int column): dblib.c']]], ['dbaltbind',['dbaltbind',['../a00518.html#gafefd17e15b22adda84366c817178dd7d',1,'dbaltbind(DBPROCESS *dbproc, int computeid, int column, int vartype, DBINT varlen, BYTE *varaddr): dblib.c'],['../a00518.html#gafefd17e15b22adda84366c817178dd7d',1,'dbaltbind(DBPROCESS *dbprocess, int computeid, int column, int vartype, DBINT varlen, BYTE *varaddr): dblib.c']]], ['dbaltcolid',['dbaltcolid',['../a00518.html#gad10c9fd75a86c7a0ac375937df0e90a6',1,'dbaltcolid(DBPROCESS *dbproc, int computeid, int column): dblib.c'],['../a00518.html#gad10c9fd75a86c7a0ac375937df0e90a6',1,'dbaltcolid(DBPROCESS *dbproc, int computeid, int column): dblib.c']]], ['dbaltlen',['dbaltlen',['../a00518.html#ga9a35c8d3cd0e35c10555baf8f6a01e93',1,'dbaltlen(DBPROCESS *dbproc, int computeid, int column): dblib.c'],['../a00518.html#ga9a35c8d3cd0e35c10555baf8f6a01e93',1,'dbaltlen(DBPROCESS *dbproc, int computeid, int column): dblib.c']]], ['dbaltop',['dbaltop',['../a00518.html#ga947837a5c8fd99898c043435945b668c',1,'dbaltop(DBPROCESS *dbproc, int computeid, int column): dblib.c'],['../a00518.html#ga947837a5c8fd99898c043435945b668c',1,'dbaltop(DBPROCESS *dbproc, int computeid, int column): dblib.c']]], ['dbalttype',['dbalttype',['../a00518.html#gaa85171e020dc606f2bd3395ad1d3ab4f',1,'dbalttype(DBPROCESS *dbproc, int computeid, int column): dblib.c'],['../a00518.html#gaa85171e020dc606f2bd3395ad1d3ab4f',1,'dbalttype(DBPROCESS *dbproc, int computeid, int column): dblib.c']]], ['dbaltutype',['dbaltutype',['../a00518.html#gaf1c00d83dfa88dc99a3fb449c49660ea',1,'dbaltutype(DBPROCESS *dbproc, int computeid, int column): dblib.c'],['../a00518.html#gaf1c00d83dfa88dc99a3fb449c49660ea',1,'dbaltutype(DBPROCESS *dbproc, int computeid, int column): dblib.c']]], ['dbanullbind',['dbanullbind',['../a00518.html#ga939c2a2e67b9992c787e2cec5b6cc1a7',1,'dbanullbind(DBPROCESS *dbproc, int computeid, int column, DBINT *indicator): dblib.c'],['../a00518.html#ga939c2a2e67b9992c787e2cec5b6cc1a7',1,'dbanullbind(DBPROCESS *dbprocess, int computeid, int column, DBINT *indicator): dblib.c']]], ['dbanydatecrack',['dbanydatecrack',['../a00518.html#gad57aa777300cf7f62077478ec6000d00',1,'dbanydatecrack(DBPROCESS *dbproc, DBDATEREC2 *di, int type, const void *data): dblib.c'],['../a00518.html#gad57aa777300cf7f62077478ec6000d00',1,'dbanydatecrack(DBPROCESS *dbproc, DBDATEREC2 *di, int type, const void *data): dblib.c']]], ['dbbind',['dbbind',['../a00518.html#ga873bc0f4663165e711655ade1dfae795',1,'dbbind(DBPROCESS *dbproc, int column, int vartype, DBINT varlen, BYTE *varaddr): dblib.c'],['../a00518.html#ga873bc0f4663165e711655ade1dfae795',1,'dbbind(DBPROCESS *dbproc, int column, int vartype, DBINT varlen, BYTE *varaddr): dblib.c']]], ['dbbylist',['dbbylist',['../a00518.html#gae658a0cd5270f3bd6f22de17b2cb2e64',1,'dbbylist(DBPROCESS *dbproc, int computeid, int *size): dblib.c'],['../a00518.html#gae658a0cd5270f3bd6f22de17b2cb2e64',1,'dbbylist(DBPROCESS *dbproc, int computeid, int *size): dblib.c']]], ['dbcancel',['dbcancel',['../a00518.html#ga5ea23272124fff03b8d87538c1ec3ee5',1,'dbcancel(DBPROCESS *dbproc): dblib.c'],['../a00518.html#ga5ea23272124fff03b8d87538c1ec3ee5',1,'dbcancel(DBPROCESS *dbproc): dblib.c']]], ['dbcanquery',['dbcanquery',['../a00518.html#ga559e24ba70d0d96c3469eb6ab8f74e05',1,'dbcanquery(DBPROCESS *dbproc): dblib.c'],['../a00518.html#ga559e24ba70d0d96c3469eb6ab8f74e05',1,'dbcanquery(DBPROCESS *dbproc): dblib.c']]], ['dbchange',['dbchange',['../a00518.html#ga8cbc761b1266bd947783d843aeeec264',1,'dbchange(DBPROCESS *dbproc): dblib.c'],['../a00518.html#ga8cbc761b1266bd947783d843aeeec264',1,'dbchange(DBPROCESS *dbprocess): dblib.c']]], ['dbclose',['dbclose',['../a00518.html#gaef740b394b44eb33925c2718f7b30d69',1,'dbclose(DBPROCESS *dbproc): dblib.c'],['../a00518.html#gaef740b394b44eb33925c2718f7b30d69',1,'dbclose(DBPROCESS *dbproc): dblib.c']]], ['dbclrbuf',['dbclrbuf',['../a00518.html#ga01404b179a251c249aecfdae72ec6ca4',1,'dbclrbuf(DBPROCESS *dbproc, DBINT n): dblib.c'],['../a00518.html#ga01404b179a251c249aecfdae72ec6ca4',1,'dbclrbuf(DBPROCESS *dbproc, DBINT n): dblib.c']]], ['dbclropt',['dbclropt',['../a00518.html#ga93ee3c8ca34a08588f88784898fd69e0',1,'dbclropt(DBPROCESS *dbproc, int option, const char param[]): dblib.c'],['../a00518.html#ga93ee3c8ca34a08588f88784898fd69e0',1,'dbclropt(DBPROCESS *dbproc, int option, const char param[]): dblib.c']]], ['dbcmd',['dbcmd',['../a00518.html#ga87b39d9863316b4ba85654b0885d53a0',1,'dbcmd(DBPROCESS *dbproc, const char cmdstring[]): dblib.c'],['../a00518.html#ga87b39d9863316b4ba85654b0885d53a0',1,'dbcmd(DBPROCESS *dbproc, const char cmdstring[]): dblib.c']]], ['dbcmdrow',['dbcmdrow',['../a00524.html#ga196f6d67de47f34a32fcc2103ab0f416',1,'dbcmdrow(DBPROCESS *dbproc): dblib.c'],['../a00524.html#ga196f6d67de47f34a32fcc2103ab0f416',1,'dbcmdrow(DBPROCESS *dbproc): dblib.c']]], ['dbcolinfo',['dbcolinfo',['../a00077.html#a9b73fd1afa2c3ccfca481635212d2e43',1,'dbcolinfo(DBPROCESS *dbproc, CI_TYPE type, DBINT column, DBINT computeid, DBCOL *pdbcol): dblib.c'],['../a00479.html#a9b73fd1afa2c3ccfca481635212d2e43',1,'dbcolinfo(DBPROCESS *dbproc, CI_TYPE type, DBINT column, DBINT computeid, DBCOL *pdbcol): dblib.c']]], ['dbcollen',['dbcollen',['../a00518.html#ga89fc5589b4bf41932324d2cfc6ad6433',1,'dbcollen(DBPROCESS *dbproc, int column): dblib.c'],['../a00518.html#ga89fc5589b4bf41932324d2cfc6ad6433',1,'dbcollen(DBPROCESS *dbproc, int column): dblib.c']]], ['dbcolname',['dbcolname',['../a00518.html#gad06f5deddac18604dfa858b2580e232f',1,'dbcolname(DBPROCESS *dbproc, int column): dblib.c'],['../a00518.html#gad06f5deddac18604dfa858b2580e232f',1,'dbcolname(DBPROCESS *dbproc, int column): dblib.c']]], ['dbcolptr',['dbcolptr',['../a00524.html#ga0fc84c7073ed4876d9596c3eccac3609',1,'dblib.c']]], ['dbcolsource',['dbcolsource',['../a00518.html#ga3a96d0188e5e0eb9eea661b3685fdcc3',1,'dbcolsource(DBPROCESS *dbproc, int column): dblib.c'],['../a00518.html#ga3a96d0188e5e0eb9eea661b3685fdcc3',1,'dbcolsource(DBPROCESS *dbproc, int colnum): dblib.c']]], ['dbcoltype',['dbcoltype',['../a00518.html#ga636e6f1b64743f3cf22158a56eef371f',1,'dbcoltype(DBPROCESS *dbproc, int column): dblib.c'],['../a00518.html#ga636e6f1b64743f3cf22158a56eef371f',1,'dbcoltype(DBPROCESS *dbproc, int column): dblib.c']]], ['dbcoltypeinfo',['dbcoltypeinfo',['../a00518.html#ga3c33e72c41b40e08dbcfdfa0d16bc399',1,'dbcoltypeinfo(DBPROCESS *dbproc, int column): dblib.c'],['../a00518.html#ga3c33e72c41b40e08dbcfdfa0d16bc399',1,'dbcoltypeinfo(DBPROCESS *dbproc, int column): dblib.c']]], ['dbcolutype',['dbcolutype',['../a00518.html#gab33d2f4fd44f50e55b6c71902db4fdae',1,'dbcolutype(DBPROCESS *dbproc, int column): dblib.c'],['../a00518.html#gab33d2f4fd44f50e55b6c71902db4fdae',1,'dbcolutype(DBPROCESS *dbprocess, int column): dblib.c']]], ['dbconvert',['dbconvert',['../a00518.html#ga32eb72f6fb3edb130e59fb3dd0766e7e',1,'dbconvert(DBPROCESS *dbproc, int srctype, const BYTE *src, DBINT srclen, int desttype, BYTE *dest, DBINT destlen): dblib.c'],['../a00518.html#ga32eb72f6fb3edb130e59fb3dd0766e7e',1,'dbconvert(DBPROCESS *dbproc, int srctype, const BYTE *src, DBINT srclen, int desttype, BYTE *dest, DBINT destlen): dblib.c']]], ['dbconvert_5fps',['dbconvert_ps',['../a00518.html#ga8b00d5cdcaa20cba13fa2e03d52a443e',1,'dbconvert_ps(DBPROCESS *dbproc, int db_srctype, const BYTE *src, DBINT srclen, int db_desttype, BYTE *dest, DBINT destlen, DBTYPEINFO *typeinfo): dblib.c'],['../a00518.html#ga8b00d5cdcaa20cba13fa2e03d52a443e',1,'dbconvert_ps(DBPROCESS *dbprocess, int srctype, const BYTE *src, DBINT srclen, int desttype, BYTE *dest, DBINT destlen, DBTYPEINFO *typeinfo): dblib.c']]], ['dbcount',['dbcount',['../a00518.html#ga9433bc200c0978569964354451d9b64e',1,'dbcount(DBPROCESS *dbproc): dblib.c'],['../a00518.html#ga9433bc200c0978569964354451d9b64e',1,'dbcount(DBPROCESS *dbproc): dblib.c']]], ['dbcurcmd',['dbcurcmd',['../a00524.html#ga01e7fb38bece3bb07526532fa6be50e5',1,'dbcurcmd(DBPROCESS *dbproc): dblib.c'],['../a00524.html#ga01e7fb38bece3bb07526532fa6be50e5',1,'dbcurcmd(DBPROCESS *dbproc): dblib.c']]], ['dbcurrow',['dbcurrow',['../a00524.html#ga9e23a95d84192b4fc83db7544d772d16',1,'dbcurrow(DBPROCESS *dbproc): dblib.c'],['../a00524.html#ga9e23a95d84192b4fc83db7544d772d16',1,'dbcurrow(DBPROCESS *dbproc): dblib.c']]], ['dbdata',['dbdata',['../a00518.html#gaee60c306a22383805a4b9caa647a1e16',1,'dbdata(DBPROCESS *dbproc, int column): dblib.c'],['../a00518.html#gaee60c306a22383805a4b9caa647a1e16',1,'dbdata(DBPROCESS *dbproc, int column): dblib.c']]], ['dbdatecmp',['dbdatecmp',['../a00523.html#ga129d2922d347121a6b312dd8e75ed6d2',1,'dbdatecmp(DBPROCESS *dbproc, DBDATETIME *d1, DBDATETIME *d2): dblib.c'],['../a00523.html#ga129d2922d347121a6b312dd8e75ed6d2',1,'dbdatecmp(DBPROCESS *dbproc, DBDATETIME *d1, DBDATETIME *d2): dblib.c']]], ['dbdatecrack',['dbdatecrack',['../a00518.html#ga46f3641b79a2e90371a66950b6db2c4d',1,'dbdatecrack(DBPROCESS *dbproc, DBDATEREC *di, DBDATETIME *datetime): dblib.c'],['../a00518.html#ga46f3641b79a2e90371a66950b6db2c4d',1,'dbdatecrack(DBPROCESS *dbproc, DBDATEREC *di, DBDATETIME *dt): dblib.c']]], ['dbdatlen',['dbdatlen',['../a00518.html#gae666d141533126babb0235af21bdca0f',1,'dbdatlen(DBPROCESS *dbproc, int column): dblib.c'],['../a00518.html#gae666d141533126babb0235af21bdca0f',1,'dbdatlen(DBPROCESS *dbproc, int column): dblib.c']]], ['dbdead',['dbdead',['../a00524.html#gaed43cb21ed54dc1a6340075d6290e4b0',1,'dbdead(DBPROCESS *dbproc): dblib.c'],['../a00524.html#gaed43cb21ed54dc1a6340075d6290e4b0',1,'dbdead(DBPROCESS *dbproc): dblib.c']]], ['dberrhandle',['dberrhandle',['../a00518.html#gab8209543de865f359bdb32829fa8b757',1,'dberrhandle(EHANDLEFUNC handler): dblib.c'],['../a00518.html#gab8209543de865f359bdb32829fa8b757',1,'dberrhandle(EHANDLEFUNC handler): dblib.c']]], ['dbexit',['dbexit',['../a00518.html#gad0044401c8c83205583f93a4764f2d8b',1,'dbexit(): dblib.c'],['../a00518.html#gad0044401c8c83205583f93a4764f2d8b',1,'dbexit(void): dblib.c']]], ['dbfcmd',['dbfcmd',['../a00518.html#ga43727b10d4cbb7708b374811abe6eadb',1,'dbfcmd(DBPROCESS *dbproc, const char *fmt,...): dblib.c'],['../a00518.html#ga43727b10d4cbb7708b374811abe6eadb',1,'dbfcmd(DBPROCESS *dbproc, const char *fmt,...): dblib.c']]], ['dbfirstrow',['dbfirstrow',['../a00524.html#gaf40b925f3b3ba43804720dd4ae584935',1,'dbfirstrow(DBPROCESS *dbproc): dblib.c'],['../a00524.html#gaf40b925f3b3ba43804720dd4ae584935',1,'dbfirstrow(DBPROCESS *dbproc): dblib.c']]], ['dbfreebuf',['dbfreebuf',['../a00518.html#ga0fcfcf6846442dac9dd5584d270ec72a',1,'dbfreebuf(DBPROCESS *dbproc): dblib.c'],['../a00518.html#ga0fcfcf6846442dac9dd5584d270ec72a',1,'dbfreebuf(DBPROCESS *dbproc): dblib.c']]], ['dbgetchar',['dbgetchar',['../a00518.html#gaf917cf746c954a5d1b718afe3c4d1940',1,'dbgetchar(DBPROCESS *dbproc, int pos): dblib.c'],['../a00518.html#gaf917cf746c954a5d1b718afe3c4d1940',1,'dbgetchar(DBPROCESS *dbprocess, int n): dblib.c']]], ['dbgetmaxprocs',['dbgetmaxprocs',['../a00518.html#gadb34c5c2aae50ac9f2a26d8984136997',1,'dbgetmaxprocs(void): dblib.c'],['../a00518.html#gadb34c5c2aae50ac9f2a26d8984136997',1,'dbgetmaxprocs(void): dblib.c']]], ['dbgetnull',['dbgetnull',['../a00077.html#aea6a865806d454280126de940478c214',1,'dblib.c']]], ['dbgetpacket',['dbgetpacket',['../a00518.html#gabaf9aa756f7cb8bbec80d1c7201c6238',1,'dbgetpacket(DBPROCESS *dbproc): dblib.c'],['../a00518.html#gabaf9aa756f7cb8bbec80d1c7201c6238',1,'dbgetpacket(DBPROCESS *dbproc): dblib.c']]], ['dbgetrow',['dbgetrow',['../a00518.html#ga60fe544491c760f8bc6c37bc7f777d70',1,'dbgetrow(DBPROCESS *dbproc, DBINT row): dblib.c'],['../a00518.html#ga60fe544491c760f8bc6c37bc7f777d70',1,'dbgetrow(DBPROCESS *dbproc, DBINT row): dblib.c']]], ['dbgettime',['dbgettime',['../a00518.html#ga6ccffbb3f0cfb10883ad349f1e47c50e',1,'dbgettime(void): dblib.c'],['../a00518.html#ga6ccffbb3f0cfb10883ad349f1e47c50e',1,'dbgettime(void): dblib.c']]], ['dbgetuserdata',['dbgetuserdata',['../a00518.html#gaa5714a91d7c14365fa1e5b164bb2b0b6',1,'dbgetuserdata(DBPROCESS *dbproc): dblib.c'],['../a00518.html#gaa5714a91d7c14365fa1e5b164bb2b0b6',1,'dbgetuserdata(DBPROCESS *dbproc): dblib.c']]], ['dbhasretstat',['dbhasretstat',['../a00519.html#ga7a5062dac92ccedc8459f6d4a530ffb7',1,'dbhasretstat(DBPROCESS *dbproc): dblib.c'],['../a00519.html#ga7a5062dac92ccedc8459f6d4a530ffb7',1,'dbhasretstat(DBPROCESS *dbproc): dblib.c']]], ['dbinit',['dbinit',['../a00518.html#ga564dd3a1bb0425a8957f1714d8b2a7c0',1,'dbinit(void): dblib.c'],['../a00518.html#ga564dd3a1bb0425a8957f1714d8b2a7c0',1,'dbinit(void): dblib.c']]], ['dbiordesc',['dbiordesc',['../a00524.html#gab842baac0ec420b265d8c199cc45059d',1,'dbiordesc(DBPROCESS *dbproc): dblib.c'],['../a00524.html#gab842baac0ec420b265d8c199cc45059d',1,'dbiordesc(DBPROCESS *dbproc): dblib.c']]], ['dbiowdesc',['dbiowdesc',['../a00524.html#ga666a4d0609ee7f241deb0a62893d2cfa',1,'dbiowdesc(DBPROCESS *dbproc): dblib.c'],['../a00524.html#ga666a4d0609ee7f241deb0a62893d2cfa',1,'dbiowdesc(DBPROCESS *dbproc): dblib.c']]], ['dbiscount',['dbiscount',['../a00518.html#ga6ba2a7f18cb76d24776e45fd71141494',1,'dbiscount(DBPROCESS *dbproc): dblib.c'],['../a00518.html#ga6ba2a7f18cb76d24776e45fd71141494',1,'dbiscount(DBPROCESS *dbproc): dblib.c']]], ['dbisopt',['dbisopt',['../a00518.html#gac3eb8cb53f50998403ea9aebc6263df9',1,'dbisopt(DBPROCESS *dbproc, int option, const char param[]): dblib.c'],['../a00518.html#gac3eb8cb53f50998403ea9aebc6263df9',1,'dbisopt(DBPROCESS *dbproc, int option, const char param[]): dblib.c']]], ['dblastrow',['dblastrow',['../a00524.html#ga13ead146339b43b3a4d9049eb124ef4b',1,'dblastrow(DBPROCESS *dbproc): dblib.c'],['../a00524.html#ga13ead146339b43b3a4d9049eb124ef4b',1,'dblastrow(DBPROCESS *dbproc): dblib.c']]], ['dblogin',['dblogin',['../a00518.html#ga0984798bb806f7451a53bffa7e2c430f',1,'dblogin(void): dblib.c'],['../a00518.html#ga0984798bb806f7451a53bffa7e2c430f',1,'dblogin(void): dblib.c']]], ['dbloginfree',['dbloginfree',['../a00518.html#gac1bdb1766b791153f37dceae8ff64ad6',1,'dbloginfree(LOGINREC *login): dblib.c'],['../a00518.html#gac1bdb1766b791153f37dceae8ff64ad6',1,'dbloginfree(LOGINREC *login): dblib.c']]], ['dbmny4add',['dbmny4add',['../a00522.html#ga0a384938a6586b7411fc42420ffad6ed',1,'dbmny4add(DBPROCESS *dbproc, DBMONEY4 *m1, DBMONEY4 *m2, DBMONEY4 *sum): dblib.c'],['../a00522.html#ga0a384938a6586b7411fc42420ffad6ed',1,'dbmny4add(DBPROCESS *dbproc, DBMONEY4 *m1, DBMONEY4 *m2, DBMONEY4 *sum): dblib.c']]], ['dbmny4cmp',['dbmny4cmp',['../a00522.html#ga109d4868baccb08fad3b26b6f031dc78',1,'dbmny4cmp(DBPROCESS *dbproc, DBMONEY4 *m1, DBMONEY4 *m2): dblib.c'],['../a00522.html#ga109d4868baccb08fad3b26b6f031dc78',1,'dbmny4cmp(DBPROCESS *dbproc, DBMONEY4 *m1, DBMONEY4 *m2): dblib.c']]], ['dbmny4copy',['dbmny4copy',['../a00522.html#gaa6d4c700b628f6a18a9d1ed9f8e2ba62',1,'dbmny4copy(DBPROCESS *dbproc, DBMONEY4 *src, DBMONEY4 *dest): dblib.c'],['../a00522.html#gaa6d4c700b628f6a18a9d1ed9f8e2ba62',1,'dbmny4copy(DBPROCESS *dbprocess, DBMONEY4 *m1, DBMONEY4 *m2): dblib.c']]], ['dbmny4minus',['dbmny4minus',['../a00522.html#ga76177eb61a67dd52424236aba1b16bc9',1,'dbmny4minus(DBPROCESS *dbproc, DBMONEY4 *src, DBMONEY4 *dest): dblib.c'],['../a00522.html#ga76177eb61a67dd52424236aba1b16bc9',1,'dbmny4minus(DBPROCESS *dbproc, DBMONEY4 *src, DBMONEY4 *dest): dblib.c']]], ['dbmny4sub',['dbmny4sub',['../a00522.html#ga856143f4f9c7a5c15fb15633af81487d',1,'dbmny4sub(DBPROCESS *dbproc, DBMONEY4 *m1, DBMONEY4 *m2, DBMONEY4 *diff): dblib.c'],['../a00522.html#ga856143f4f9c7a5c15fb15633af81487d',1,'dbmny4sub(DBPROCESS *dbproc, DBMONEY4 *m1, DBMONEY4 *m2, DBMONEY4 *diff): dblib.c']]], ['dbmny4zero',['dbmny4zero',['../a00522.html#ga070e94f72f12c138a16a7bcdf732fa8b',1,'dbmny4zero(DBPROCESS *dbproc, DBMONEY4 *dest): dblib.c'],['../a00522.html#ga070e94f72f12c138a16a7bcdf732fa8b',1,'dbmny4zero(DBPROCESS *dbproc, DBMONEY4 *dest): dblib.c']]], ['dbmnycmp',['dbmnycmp',['../a00522.html#gadddacad5c3028aa8d3726246c3825651',1,'dbmnycmp(DBPROCESS *dbproc, DBMONEY *m1, DBMONEY *m2): dblib.c'],['../a00522.html#gadddacad5c3028aa8d3726246c3825651',1,'dbmnycmp(DBPROCESS *dbproc, DBMONEY *m1, DBMONEY *m2): dblib.c']]], ['dbmnycopy',['dbmnycopy',['../a00522.html#ga8f1e9aa0280c1cb46c10e5c90b8faced',1,'dbmnycopy(DBPROCESS *dbproc, DBMONEY *src, DBMONEY *dest): dblib.c'],['../a00522.html#ga8f1e9aa0280c1cb46c10e5c90b8faced',1,'dbmnycopy(DBPROCESS *dbproc, DBMONEY *src, DBMONEY *dest): dblib.c']]], ['dbmnydec',['dbmnydec',['../a00522.html#gabedce74748a31ea8a6e4068a5d44d8e4',1,'dbmnydec(DBPROCESS *dbproc, DBMONEY *amount): dblib.c'],['../a00522.html#gabedce74748a31ea8a6e4068a5d44d8e4',1,'dbmnydec(DBPROCESS *dbproc, DBMONEY *mnyptr): dblib.c']]], ['dbmnyinc',['dbmnyinc',['../a00522.html#gabf5216aaaa59ea7e7f07899f82a27faf',1,'dbmnyinc(DBPROCESS *dbproc, DBMONEY *amount): dblib.c'],['../a00522.html#gabf5216aaaa59ea7e7f07899f82a27faf',1,'dbmnyinc(DBPROCESS *dbproc, DBMONEY *mnyptr): dblib.c']]], ['dbmnymaxneg',['dbmnymaxneg',['../a00522.html#gabc3cb44d33bf1b9b18fd59f23e4da722',1,'dbmnymaxneg(DBPROCESS *dbproc, DBMONEY *amount): dblib.c'],['../a00522.html#gabc3cb44d33bf1b9b18fd59f23e4da722',1,'dbmnymaxneg(DBPROCESS *dbproc, DBMONEY *dest): dblib.c']]], ['dbmnymaxpos',['dbmnymaxpos',['../a00522.html#ga70ca2474f6c93acd6e3b842330b712c7',1,'dbmnymaxpos(DBPROCESS *dbproc, DBMONEY *amount): dblib.c'],['../a00522.html#ga70ca2474f6c93acd6e3b842330b712c7',1,'dbmnymaxpos(DBPROCESS *dbproc, DBMONEY *dest): dblib.c']]], ['dbmnyminus',['dbmnyminus',['../a00522.html#ga826bca98da4fd1c3188da45c383c3a68',1,'dbmnyminus(DBPROCESS *dbproc, DBMONEY *src, DBMONEY *dest): dblib.c'],['../a00522.html#ga826bca98da4fd1c3188da45c383c3a68',1,'dbmnyminus(DBPROCESS *dbproc, DBMONEY *src, DBMONEY *dest): dblib.c']]], ['dbmnyzero',['dbmnyzero',['../a00522.html#ga8eab0959d5a3cd534487b350258c939e',1,'dbmnyzero(DBPROCESS *dbproc, DBMONEY *dest): dblib.c'],['../a00522.html#ga8eab0959d5a3cd534487b350258c939e',1,'dbmnyzero(DBPROCESS *dbproc, DBMONEY *dest): dblib.c']]], ['dbmonthname',['dbmonthname',['../a00523.html#ga38ecd55ae5827bfa0fd12e2baf0950dd',1,'dbmonthname(DBPROCESS *dbproc, char *language, int monthnum, DBBOOL shortform): dblib.c'],['../a00523.html#ga38ecd55ae5827bfa0fd12e2baf0950dd',1,'dbmonthname(DBPROCESS *dbproc, char *language, int monthnum, DBBOOL shortform): dblib.c']]], ['dbmorecmds',['dbmorecmds',['../a00518.html#gac3ba9f53cc77e4dde8f48335ed94ac19',1,'dbmorecmds(DBPROCESS *dbproc): dblib.c'],['../a00518.html#gac3ba9f53cc77e4dde8f48335ed94ac19',1,'dbmorecmds(DBPROCESS *dbproc): dblib.c']]], ['dbmoretext',['dbmoretext',['../a00518.html#ga6f13381522a1fa0b6ce2c15378088cdd',1,'dbmoretext(DBPROCESS *dbproc, DBINT size, const BYTE text[]): dblib.c'],['../a00518.html#ga6f13381522a1fa0b6ce2c15378088cdd',1,'dbmoretext(DBPROCESS *dbproc, DBINT size, const BYTE text[]): dblib.c']]], ['dbmsghandle',['dbmsghandle',['../a00518.html#gadc8af9a65f3719804c2537fd737298ca',1,'dbmsghandle(MHANDLEFUNC handler): dblib.c'],['../a00518.html#gadc8af9a65f3719804c2537fd737298ca',1,'dbmsghandle(MHANDLEFUNC handler): dblib.c']]], ['dbname',['dbname',['../a00518.html#gab185982ffe0b85b8fd19747bd1f433fe',1,'dbname(DBPROCESS *dbproc): dblib.c'],['../a00518.html#gab185982ffe0b85b8fd19747bd1f433fe',1,'dbname(DBPROCESS *dbproc): dblib.c']]], ['dbnullbind',['dbnullbind',['../a00518.html#ga85dcc40c3615f94be96b09b2ec043533',1,'dbnullbind(DBPROCESS *dbproc, int column, DBINT *indicator): dblib.c'],['../a00518.html#ga85dcc40c3615f94be96b09b2ec043533',1,'dbnullbind(DBPROCESS *dbproc, int column, DBINT *indicator): dblib.c']]], ['dbnumalts',['dbnumalts',['../a00518.html#ga67934deac3bebbf8238eff8c0559389a',1,'dbnumalts(DBPROCESS *dbproc, int computeid): dblib.c'],['../a00518.html#ga67934deac3bebbf8238eff8c0559389a',1,'dbnumalts(DBPROCESS *dbproc, int computeid): dblib.c']]], ['dbnumcols',['dbnumcols',['../a00518.html#gadaa9482a082aa3fe52231e17749c2993',1,'dbnumcols(DBPROCESS *dbproc): dblib.c'],['../a00518.html#gadaa9482a082aa3fe52231e17749c2993',1,'dbnumcols(DBPROCESS *dbproc): dblib.c']]], ['dbnumcompute',['dbnumcompute',['../a00518.html#gac554d2cb2da0c9f9fd3d4867998edcc4',1,'dbnumcompute(DBPROCESS *dbproc): dblib.c'],['../a00518.html#gac554d2cb2da0c9f9fd3d4867998edcc4',1,'dbnumcompute(DBPROCESS *dbprocess): dblib.c']]], ['dbnumrets',['dbnumrets',['../a00519.html#gaff09873008411a0573f6d1a9e6c7cf4b',1,'dbnumrets(DBPROCESS *dbproc): dblib.c'],['../a00519.html#gaff09873008411a0573f6d1a9e6c7cf4b',1,'dbnumrets(DBPROCESS *dbproc): dblib.c']]], ['dbopen',['dbopen',['../a00479.html#ae408d8e1c2ab0767d8bfd26d00d1ff6a',1,'dbopen.c']]], ['dbperror',['dbperror',['../a00524.html#ga302a4ce6559b81808e3be51615cd1b67',1,'dbperror(DBPROCESS *dbproc, DBINT msgno, long errnum,...): dblib.c'],['../a00524.html#ga302a4ce6559b81808e3be51615cd1b67',1,'dbperror(DBPROCESS *dbproc, DBINT msgno, long errnum,...): dblib.c']]], ['dbpivot',['dbpivot',['../a00479.html#af8ada101cd189eff87b3533cbeaaa23b',1,'dbpivot.c']]], ['dbprcollen',['dbprcollen',['../a00518.html#gac0cb0584f6500d61a2ac95a891da73eb',1,'dbprcollen(DBPROCESS *dbproc, int column): dblib.c'],['../a00518.html#gac0cb0584f6500d61a2ac95a891da73eb',1,'dbprcollen(DBPROCESS *dbproc, int column): dblib.c']]], ['dbprhead',['dbprhead',['../a00518.html#ga9dfc2ee533e5e48a7aa8ca22f8d9ed79',1,'dbprhead(DBPROCESS *dbproc): dblib.c'],['../a00518.html#ga9dfc2ee533e5e48a7aa8ca22f8d9ed79',1,'dbprhead(DBPROCESS *dbproc): dblib.c']]], ['dbprrow',['dbprrow',['../a00518.html#gaa30be3414a97aac6139af2e928db91ca',1,'dbprrow(DBPROCESS *dbproc): dblib.c'],['../a00518.html#gaa30be3414a97aac6139af2e928db91ca',1,'dbprrow(DBPROCESS *dbproc): dblib.c']]], ['dbprtype',['dbprtype',['../a00518.html#gac25ae21ca19777ffab1c013bd6049ebf',1,'dbprtype(int token): dblib.c'],['../a00518.html#gac25ae21ca19777ffab1c013bd6049ebf',1,'dbprtype(int token): dblib.c']]], ['dbreadtext',['dbreadtext',['../a00518.html#gadd5685565c8c6c86079e17b8a73b324c',1,'dbreadtext(DBPROCESS *dbproc, void *buf, DBINT bufsize): dblib.c'],['../a00518.html#gadd5685565c8c6c86079e17b8a73b324c',1,'dbreadtext(DBPROCESS *dbproc, void *buf, DBINT bufsize): dblib.c']]], ['dbrecftos',['dbrecftos',['../a00518.html#gabb14ad9f268b92a8d63fa506098b24dd',1,'dbrecftos(const char filename[]): dblib.c'],['../a00518.html#gabb14ad9f268b92a8d63fa506098b24dd',1,'dbrecftos(const char filename[]): dblib.c']]], ['dbresults',['dbresults',['../a00518.html#ga4e26d949be2c3bf71b1a33c75b11d931',1,'dbresults(DBPROCESS *dbproc): dblib.c'],['../a00518.html#ga4e26d949be2c3bf71b1a33c75b11d931',1,'dbresults(DBPROCESS *dbproc): dblib.c']]], ['dbretdata',['dbretdata',['../a00519.html#ga42e187003b74fec6e9ca92d410bfb9c0',1,'dbretdata(DBPROCESS *dbproc, int retnum): dblib.c'],['../a00519.html#ga42e187003b74fec6e9ca92d410bfb9c0',1,'dbretdata(DBPROCESS *dbproc, int retnum): dblib.c']]], ['dbretlen',['dbretlen',['../a00519.html#gab705bf94be535e9d8fc4edc0f48c98b0',1,'dbretlen(DBPROCESS *dbproc, int retnum): dblib.c'],['../a00519.html#gab705bf94be535e9d8fc4edc0f48c98b0',1,'dbretlen(DBPROCESS *dbproc, int retnum): dblib.c']]], ['dbretname',['dbretname',['../a00519.html#ga0311328d63bae5d9bd5aea5ea4914223',1,'dbretname(DBPROCESS *dbproc, int retnum): dblib.c'],['../a00519.html#ga0311328d63bae5d9bd5aea5ea4914223',1,'dbretname(DBPROCESS *dbproc, int retnum): dblib.c']]], ['dbretstatus',['dbretstatus',['../a00519.html#ga2306039d73fbc7045f257b0e750c37b4',1,'dbretstatus(DBPROCESS *dbproc): dblib.c'],['../a00519.html#ga2306039d73fbc7045f257b0e750c37b4',1,'dbretstatus(DBPROCESS *dbproc): dblib.c']]], ['dbrettype',['dbrettype',['../a00519.html#gaa478c8b96923bca02d158d966172ec1b',1,'dbrettype(DBPROCESS *dbproc, int retnum): dblib.c'],['../a00519.html#gaa478c8b96923bca02d158d966172ec1b',1,'dbrettype(DBPROCESS *dbproc, int retnum): dblib.c']]], ['dbrows',['dbrows',['../a00524.html#ga4be2ab59dc7161d6b93c17202e7ae9b1',1,'dbrows(DBPROCESS *dbproc): dblib.c'],['../a00524.html#ga4be2ab59dc7161d6b93c17202e7ae9b1',1,'dbrows(DBPROCESS *dbproc): dblib.c']]], ['dbrowtype',['dbrowtype',['../a00524.html#gaa2dc8c062342f76adffe53ee280b7fb4',1,'dbrowtype(DBPROCESS *dbproc): dblib.c'],['../a00524.html#gaa2dc8c062342f76adffe53ee280b7fb4',1,'dbrowtype(DBPROCESS *dbprocess): dblib.c']]], ['dbrpcinit',['dbrpcinit',['../a00519.html#ga5b4374c13c7a83cd4345b0bfa3e787bd',1,'dbrpcinit(DBPROCESS *dbproc, const char rpcname[], DBSMALLINT options): rpc.c'],['../a00519.html#ga5b4374c13c7a83cd4345b0bfa3e787bd',1,'dbrpcinit(DBPROCESS *dbproc, const char rpcname[], DBSMALLINT options): rpc.c']]], ['dbrpcparam',['dbrpcparam',['../a00519.html#gaf6b6b0a641180a5c28382df39cd7d346',1,'dbrpcparam(DBPROCESS *dbproc, const char paramname[], BYTE status, int db_type, DBINT maxlen, DBINT datalen, BYTE *value): rpc.c'],['../a00519.html#gaf6b6b0a641180a5c28382df39cd7d346',1,'dbrpcparam(DBPROCESS *dbproc, const char paramname[], BYTE status, int type, DBINT maxlen, DBINT datalen, BYTE *value): rpc.c']]], ['dbrpcsend',['dbrpcsend',['../a00519.html#gafa4dfd181be21e49c397f7daaa9cf96c',1,'dbrpcsend(DBPROCESS *dbproc): rpc.c'],['../a00519.html#gafa4dfd181be21e49c397f7daaa9cf96c',1,'dbrpcsend(DBPROCESS *dbproc): rpc.c']]], ['dbsafestr',['dbsafestr',['../a00518.html#gad0ccc03b94ba2515fd1f5d35559fcb41',1,'dbsafestr(DBPROCESS *dbproc, const char *src, DBINT srclen, char *dest, DBINT destlen, int quotetype): dblib.c'],['../a00518.html#gad0ccc03b94ba2515fd1f5d35559fcb41',1,'dbsafestr(DBPROCESS *dbproc, const char *src, DBINT srclen, char *dest, DBINT destlen, int quotetype): dblib.c']]], ['dbservcharset',['dbservcharset',['../a00518.html#ga39302e8efbb476ba01cff109ffb3661e',1,'dbservcharset(DBPROCESS *dbproc): dblib.c'],['../a00518.html#ga39302e8efbb476ba01cff109ffb3661e',1,'dbservcharset(DBPROCESS *dbprocess): dblib.c']]], ['dbsetavail',['dbsetavail',['../a00524.html#ga5ce245ff327a3d333280fe7b43d69ded',1,'dbsetavail(DBPROCESS *dbproc): dblib.c'],['../a00524.html#ga5ce245ff327a3d333280fe7b43d69ded',1,'dbsetavail(DBPROCESS *dbprocess): dblib.c']]], ['dbsetifile',['dbsetifile',['../a00518.html#ga663350909fec3a1d152316c45a65e708',1,'dbsetifile(char *filename): dblib.c'],['../a00518.html#ga663350909fec3a1d152316c45a65e708',1,'dbsetifile(char *filename): dblib.c']]], ['dbsetinterrupt',['dbsetinterrupt',['../a00518.html#ga335fcbe476ad0f897e4e2ce377f0a8cc',1,'dbsetinterrupt(DBPROCESS *dbproc, DB_DBCHKINTR_FUNC chkintr, DB_DBHNDLINTR_FUNC hndlintr): dblib.c'],['../a00518.html#ga335fcbe476ad0f897e4e2ce377f0a8cc',1,'dbsetinterrupt(DBPROCESS *dbproc, DB_DBCHKINTR_FUNC chkintr, DB_DBHNDLINTR_FUNC hndlintr): dblib.c']]], ['dbsetlbool',['dbsetlbool',['../a00524.html#ga03e850369aca6fba074da5e9da4effd7',1,'dbsetlbool(LOGINREC *login, int value, int which): dblib.c'],['../a00524.html#ga03e850369aca6fba074da5e9da4effd7',1,'dbsetlbool(LOGINREC *login, int value, int which): dblib.c']]], ['dbsetllong',['dbsetllong',['../a00524.html#gabdcccf4e0d093ff48c0e7048a4bfaf84',1,'dbsetllong(LOGINREC *login, long value, int which): dblib.c'],['../a00524.html#gabdcccf4e0d093ff48c0e7048a4bfaf84',1,'dbsetllong(LOGINREC *login, long value, int which): dblib.c']]], ['dbsetlname',['dbsetlname',['../a00524.html#gae1fc46447c4f8a9ff7f66607b8cd23b6',1,'dbsetlname(LOGINREC *login, const char *value, int which): dblib.c'],['../a00524.html#gae1fc46447c4f8a9ff7f66607b8cd23b6',1,'dbsetlname(LOGINREC *login, const char *value, int which): dblib.c']]], ['dbsetlogintime',['dbsetlogintime',['../a00518.html#ga5f1281c07dde5a6d28e60ef62c501d1d',1,'dbsetlogintime(int seconds): dblib.c'],['../a00518.html#ga5f1281c07dde5a6d28e60ef62c501d1d',1,'dbsetlogintime(int seconds): dblib.c']]], ['dbsetlversion',['dbsetlversion',['../a00518.html#gaa22dce1ee0eb83059699c34c47d07c14',1,'dbsetlversion(LOGINREC *login, BYTE version): dblib.c'],['../a00518.html#gaa22dce1ee0eb83059699c34c47d07c14',1,'dbsetlversion(LOGINREC *login, BYTE version): dblib.c']]], ['dbsetmaxprocs',['dbsetmaxprocs',['../a00518.html#gaf2ca0e63f800b3839684c894ff651dd4',1,'dbsetmaxprocs(int maxprocs): dblib.c'],['../a00518.html#gaf2ca0e63f800b3839684c894ff651dd4',1,'dbsetmaxprocs(int maxprocs): dblib.c']]], ['dbsetnull',['dbsetnull',['../a00518.html#ga399512ec78c15ce3db79ea88ef3b1293',1,'dbsetnull(DBPROCESS *dbproc, int bindtype, int bindlen, BYTE *bindval): dblib.c'],['../a00518.html#ga399512ec78c15ce3db79ea88ef3b1293',1,'dbsetnull(DBPROCESS *dbprocess, int bindtype, int bindlen, BYTE *bindval): dblib.c']]], ['dbsetopt',['dbsetopt',['../a00518.html#ga9d660d278f3f58871b4086c0e175f4c6',1,'dbsetopt(DBPROCESS *dbproc, int option, const char *char_param, int int_param): dblib.c'],['../a00518.html#ga9d660d278f3f58871b4086c0e175f4c6',1,'dbsetopt(DBPROCESS *dbproc, int option, const char *char_param, int int_param): dblib.c']]], ['dbsetrow',['dbsetrow',['../a00518.html#gaeb3d621e4f6846bb228b0a596d8758c0',1,'dbsetrow(DBPROCESS *dbproc, DBINT row): dblib.c'],['../a00518.html#gaeb3d621e4f6846bb228b0a596d8758c0',1,'dbsetrow(DBPROCESS *dbprocess, DBINT row): dblib.c']]], ['dbsettime',['dbsettime',['../a00518.html#gada4b41f34542a87f0cd87e78e56d18bb',1,'dbsettime(int seconds): dblib.c'],['../a00518.html#gada4b41f34542a87f0cd87e78e56d18bb',1,'dbsettime(int seconds): dblib.c']]], ['dbsetuserdata',['dbsetuserdata',['../a00518.html#gabea9c70d02bf3e46bbb1d759915cb91e',1,'dbsetuserdata(DBPROCESS *dbproc, BYTE *ptr): dblib.c'],['../a00518.html#gabea9c70d02bf3e46bbb1d759915cb91e',1,'dbsetuserdata(DBPROCESS *dbproc, BYTE *ptr): dblib.c']]], ['dbsetversion',['dbsetversion',['../a00518.html#gab9aa181fb3081ffb314340cbd71e434d',1,'dbsetversion(DBINT version): dblib.c'],['../a00518.html#gab9aa181fb3081ffb314340cbd71e434d',1,'dbsetversion(DBINT version): dblib.c']]], ['dbspid',['dbspid',['../a00518.html#ga223a6d333f95e726b0b42ec19a076731',1,'dbspid(DBPROCESS *dbproc): dblib.c'],['../a00518.html#ga223a6d333f95e726b0b42ec19a076731',1,'dbspid(DBPROCESS *dbproc): dblib.c']]], ['dbspr1row',['dbspr1row',['../a00518.html#gaf641c8e3d34607ca8b7ac2afed3e6d67',1,'dbspr1row(DBPROCESS *dbproc, char *buffer, DBINT buf_len): dblib.c'],['../a00518.html#gaf641c8e3d34607ca8b7ac2afed3e6d67',1,'dbspr1row(DBPROCESS *dbproc, char *buffer, DBINT buf_len): dblib.c']]], ['dbspr1rowlen',['dbspr1rowlen',['../a00518.html#ga308918c13a5b1644269c1654fbea96ac',1,'dbspr1rowlen(DBPROCESS *dbproc): dblib.c'],['../a00518.html#ga308918c13a5b1644269c1654fbea96ac',1,'dbspr1rowlen(DBPROCESS *dbproc): dblib.c']]], ['dbsprhead',['dbsprhead',['../a00518.html#gaaa4839a9c88e5b90f33bd2407fcbc43e',1,'dbsprhead(DBPROCESS *dbproc, char *buffer, DBINT buf_len): dblib.c'],['../a00518.html#gaaa4839a9c88e5b90f33bd2407fcbc43e',1,'dbsprhead(DBPROCESS *dbproc, char *buffer, DBINT buf_len): dblib.c']]], ['dbsprline',['dbsprline',['../a00518.html#gacfaf9feb29c87cfb660886162f643152',1,'dbsprline(DBPROCESS *dbproc, char *buffer, DBINT buf_len, DBCHAR line_char): dblib.c'],['../a00518.html#gacfaf9feb29c87cfb660886162f643152',1,'dbsprline(DBPROCESS *dbproc, char *buffer, DBINT buf_len, DBCHAR line_char): dblib.c']]], ['dbsqlexec',['dbsqlexec',['../a00518.html#gaae889abeb145ec41f7361aa8f597fe46',1,'dbsqlexec(DBPROCESS *dbproc): dblib.c'],['../a00518.html#gaae889abeb145ec41f7361aa8f597fe46',1,'dbsqlexec(DBPROCESS *dbproc): dblib.c']]], ['dbsqlok',['dbsqlok',['../a00518.html#gae1f50a6a2c31fda57cb481922b06841e',1,'dbsqlok(DBPROCESS *dbproc): dblib.c'],['../a00518.html#gae1f50a6a2c31fda57cb481922b06841e',1,'dbsqlok(DBPROCESS *dbproc): dblib.c']]], ['dbsqlsend',['dbsqlsend',['../a00518.html#gac980139b9cea03cf93e373d425991481',1,'dbsqlsend(DBPROCESS *dbproc): dblib.c'],['../a00518.html#gac980139b9cea03cf93e373d425991481',1,'dbsqlsend(DBPROCESS *dbproc): dblib.c']]], ['dbstrbuild',['dbstrbuild',['../a00518.html#gab5fe0cd5f24d4fd33670111035a4fbed',1,'dbstrbuild(DBPROCESS *dbproc, char *charbuf, int bufsize, char *text, char *formats,...): dblib.c'],['../a00518.html#gab5fe0cd5f24d4fd33670111035a4fbed',1,'dbstrbuild(DBPROCESS *dbproc, char *charbuf, int bufsize, char *text, char *formats,...): dblib.c']]], ['dbstrcpy',['dbstrcpy',['../a00518.html#gaf130b12e9e58b1bfd4a6685e33f5b3cd',1,'dbstrcpy(DBPROCESS *dbproc, int start, int numbytes, char *dest): dblib.c'],['../a00518.html#gaf130b12e9e58b1bfd4a6685e33f5b3cd',1,'dbstrcpy(DBPROCESS *dbproc, int start, int numbytes, char *dest): dblib.c']]], ['dbstrlen',['dbstrlen',['../a00518.html#ga13caa07ec45cd6f64e9197d29e3cfe5e',1,'dbstrlen(DBPROCESS *dbproc): dblib.c'],['../a00518.html#ga13caa07ec45cd6f64e9197d29e3cfe5e',1,'dbstrlen(DBPROCESS *dbproc): dblib.c']]], ['dbtablecolinfo',['dbtablecolinfo',['../a00518.html#ga9804fc70ae6ed35c92cd75d410dad570',1,'dbtablecolinfo(DBPROCESS *dbproc, DBINT column, DBCOL *pdbcol): dblib.c'],['../a00518.html#ga9804fc70ae6ed35c92cd75d410dad570',1,'dbtablecolinfo(DBPROCESS *dbproc, DBINT column, DBCOL *pdbcol): dblib.c']]], ['dbtds',['dbtds',['../a00524.html#ga8d765d810a40dfa01b39995a8e7406f0',1,'dbtds(DBPROCESS *dbproc): dblib.c'],['../a00524.html#ga8d765d810a40dfa01b39995a8e7406f0',1,'dbtds(DBPROCESS *dbprocess): dblib.c']]], ['dbtxptr',['dbtxptr',['../a00518.html#ga57e4098b153a030f0be02bcd98e08ba2',1,'dbtxptr(DBPROCESS *dbproc, int column): dblib.c'],['../a00518.html#ga57e4098b153a030f0be02bcd98e08ba2',1,'dbtxptr(DBPROCESS *dbproc, int column): dblib.c']]], ['dbtxtimestamp',['dbtxtimestamp',['../a00518.html#gac3f11142ec7ff25b1f8972af10fe9454',1,'dbtxtimestamp(DBPROCESS *dbproc, int column): dblib.c'],['../a00518.html#gac3f11142ec7ff25b1f8972af10fe9454',1,'dbtxtimestamp(DBPROCESS *dbproc, int column): dblib.c']]], ['dbuse',['dbuse',['../a00518.html#ga66ea891910f0a357cc78107d6ab7d962',1,'dbuse(DBPROCESS *dbproc, const char *name): dblib.c'],['../a00518.html#ga66ea891910f0a357cc78107d6ab7d962',1,'dbuse(DBPROCESS *dbproc, const char *name): dblib.c']]], ['dbvarylen',['dbvarylen',['../a00518.html#ga57c856964a9a0b4cc43f5192647c51e7',1,'dbvarylen(DBPROCESS *dbproc, int column): dblib.c'],['../a00518.html#ga57c856964a9a0b4cc43f5192647c51e7',1,'dbvarylen(DBPROCESS *dbproc, int column): dblib.c']]], ['dbversion',['dbversion',['../a00518.html#ga666726c86108342b1c1f27eecf68e13c',1,'dbversion(): dblib.c'],['../a00518.html#ga666726c86108342b1c1f27eecf68e13c',1,'dbversion(void): dblib.c']]], ['dbwillconvert',['dbwillconvert',['../a00518.html#gaaf8349999c16b3c36caf5947747a2915',1,'dbwillconvert(int srctype, int desttype): dblib.c'],['../a00518.html#gaaf8349999c16b3c36caf5947747a2915',1,'dbwillconvert(int srctype, int desttype): dblib.c']]], ['dbwritetext',['dbwritetext',['../a00518.html#ga548153eb2eae76c48aa9d4b72258dc1c',1,'dbwritetext(DBPROCESS *dbproc, char *objname, DBBINARY *textptr, DBTINYINT textptrlen, DBBINARY *timestamp, DBBOOL log, DBINT size, BYTE *text): dblib.c'],['../a00518.html#ga548153eb2eae76c48aa9d4b72258dc1c',1,'dbwritetext(DBPROCESS *dbproc, char *objname, DBBINARY *textptr, DBTINYINT textptrlen, DBBINARY *timestamp, DBBOOL log, DBINT size, BYTE *text): dblib.c']]], ['default_5ferr_5fhandler',['default_err_handler',['../a00524.html#gaccbc6d98d9528c48cf0254d809ca73ff',1,'dblib.c']]], ['determine_5fadjusted_5fsize',['determine_adjusted_size',['../a00536.html#ga87209537d51f069fee02bc224da492cb',1,'determine_adjusted_size(const TDSICONV *char_conv, int size): token.c'],['../a00536.html#ga87209537d51f069fee02bc224da492cb',1,'determine_adjusted_size(const TDSICONV *char_conv, int size): token.c']]] ]; freetds-1.00.82/doc/reference/search/functions_4.html100644 025423 025423 00000001773 13242511131 0016120
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/functions_4.js100644 025423 025423 00000004473 13242511131 0015570var searchData= [ ['odbc_5fc_5fto_5fserver_5ftype',['odbc_c_to_server_type',['../a00527.html#ga3f0a413cea480a38d3d9b90c95515f6b',1,'odbc_c_to_server_type(int c_type): odbc_util.c'],['../a00527.html#ga3f0a413cea480a38d3d9b90c95515f6b',1,'odbc_c_to_server_type(int c_type): odbc_util.c']]], ['odbc_5fget_5fparam_5flen',['odbc_get_param_len',['../a00527.html#ga35028e8de1d50dc51ccef1d645c55e2a',1,'odbc_get_param_len(const struct _drecord *drec_axd, const struct _drecord *drec_ixd, const TDS_DESC *axd, unsigned int n_row): odbc_util.c'],['../a00527.html#ga35028e8de1d50dc51ccef1d645c55e2a',1,'odbc_get_param_len(const struct _drecord *drec_axd, const struct _drecord *drec_ixd, const TDS_DESC *axd, unsigned int n_row): odbc_util.c']]], ['odbc_5frdbms_5fversion',['odbc_rdbms_version',['../a00527.html#gae85ff7fb2002b5a7abc04fbee79e5525',1,'odbc_rdbms_version(TDSSOCKET *tds, char *pversion_string): odbc_util.c'],['../a00527.html#gae85ff7fb2002b5a7abc04fbee79e5525',1,'odbc_rdbms_version(TDSSOCKET *tds_socket, char *pversion_string): odbc_util.c']]], ['odbc_5fset_5fconcise_5fc_5ftype',['odbc_set_concise_c_type',['../a00527.html#ga128f6b09cde0af252370ba89cfa1fb78',1,'odbc_set_concise_c_type(SQLSMALLINT concise_type, struct _drecord *drec, int check_only): odbc_util.c'],['../a00527.html#ga128f6b09cde0af252370ba89cfa1fb78',1,'odbc_set_concise_c_type(SQLSMALLINT concise_type, struct _drecord *drec, int check_only): odbc_util.c']]], ['odbc_5fset_5fconcise_5fsql_5ftype',['odbc_set_concise_sql_type',['../a00527.html#ga125574bd2de677438909612db80041ea',1,'odbc_set_concise_sql_type(SQLSMALLINT concise_type, struct _drecord *drec, int check_only): odbc_util.c'],['../a00527.html#ga125574bd2de677438909612db80041ea',1,'odbc_set_concise_sql_type(SQLSMALLINT concise_type, struct _drecord *drec, int check_only): odbc_util.c']]], ['odbc_5fset_5fstring_5fflag',['odbc_set_string_flag',['../a00527.html#gadba4490bf3183799a70c9e2f44fab331',1,'odbc_set_string_flag(TDS_DBC *dbc, SQLPOINTER buffer, SQLINTEGER cbBuffer, void FAR *pcbBuffer, const char *s, int len, int flag): odbc_util.c'],['../a00527.html#gadba4490bf3183799a70c9e2f44fab331',1,'odbc_set_string_flag(TDS_DBC *dbc, SQLPOINTER buffer, SQLINTEGER cbBuffer, void FAR *pcbBuffer, const char *s, int len, int flag): odbc_util.c']]] ]; freetds-1.00.82/doc/reference/search/functions_5.html100644 025423 025423 00000001773 13242511131 0016121
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/functions_5.js100644 025423 025423 00000000564 13242511131 0015566var searchData= [ ['parse_5fint8',['parse_int8',['../a00530.html#gace939c1fa676d172cb0cae94848b7fac',1,'convert.c']]], ['parse_5fnumeric',['parse_numeric',['../a00530.html#ga53a19b5da172ff364d01e8f04b97015a',1,'convert.c']]], ['parse_5fserver_5fname_5ffor_5fport',['parse_server_name_for_port',['../a00529.html#gaa9670914093b354e7a123b10ba877813',1,'config.c']]] ]; freetds-1.00.82/doc/reference/search/functions_6.html100644 025423 025423 00000001773 13242511131 0016122
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/functions_6.js100644 025423 025423 00000000335 13242511131 0015563var searchData= [ ['read_5fand_5fconvert',['read_and_convert',['../a00534.html#ga676c4dee6522815b16fdc8e448e43590',1,'read.c']]], ['rtrim',['rtrim',['../a00521.html#ga4d5be57b25a0654e2170fd656dc35489',1,'bcp.c']]] ]; freetds-1.00.82/doc/reference/search/functions_7.html100644 025423 025423 00000001773 13242511131 0016123
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/functions_7.js100644 025423 025423 00000002076 13242511131 0015570var searchData= [ ['search_5finterface_5ffile',['search_interface_file',['../a00529.html#gaca20b6e5f5a5ac1727126712dd39564b',1,'config.c']]], ['skip_5fone_5finput_5fsequence',['skip_one_input_sequence',['../a00531.html#ga3380140fc6eb9f2090c430f40e846876',1,'iconv.c']]], ['store_5fmonthname',['store_monthname',['../a00530.html#ga17a0597ec3522c7f1ddb54956226dbfc',1,'convert.c']]], ['string_5fto_5fint',['string_to_int',['../a00530.html#ga0176fafd412b5b8005bf1202fbc13b00',1,'convert.c']]], ['string_5fto_5fint8',['string_to_int8',['../a00530.html#ga933f87cca76156648e91f472650b98f3',1,'convert.c']]], ['string_5fto_5fnumeric',['string_to_numeric',['../a00530.html#ga28c75aff2615032005257af7455ed70d',1,'convert.c']]], ['string_5fto_5fresult',['string_to_result',['../a00530.html#ga46a5a00dfa70cad4a02d7cc73b314c31',1,'convert.c']]], ['string_5fto_5fuint8',['string_to_uint8',['../a00530.html#gae8e173a9f8d2e3f152ada9f48d3d5f28',1,'convert.c']]], ['stringz_5fto_5fnumeric',['stringz_to_numeric',['../a00530.html#ga467401163bf05ed167f7b2b7e8bd875a',1,'convert.c']]] ]; freetds-1.00.82/doc/reference/search/functions_8.html100644 025423 025423 00000001773 13242511131 0016124
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/functions_8.js100644 025423 025423 00000131712 13242511131 0015571var searchData= [ ['tds5_5ffix_5fdot_5fquery',['tds5_fix_dot_query',['../a00533.html#ga3a5d1771cacc947521c4077551f0d3a4',1,'query.c']]], ['tds5_5fprocess_5fdyn_5fresult2',['tds5_process_dyn_result2',['../a00536.html#gae688b515631141acfbc41bbb91c8b921',1,'token.c']]], ['tds5_5fprocess_5foptioncmd',['tds5_process_optioncmd',['../a00536.html#gaa6a7e5aeb10a1322911c47be9c43e2d2',1,'token.c']]], ['tds5_5fprocess_5fresult',['tds5_process_result',['../a00536.html#ga547b2f48659f77a69aa802d861ac827d',1,'token.c']]], ['tds5_5fprocess_5fresult2',['tds5_process_result2',['../a00536.html#gabe2bdd5a41ce067cb31aef18ff81cb1c',1,'token.c']]], ['tds71_5fread_5ftable_5fnames',['tds71_read_table_names',['../a00536.html#ga7482b5730d880fcedbe9fcd609a550ce',1,'token.c']]], ['tds71_5fsubmit_5fprepexec',['tds71_submit_prepexec',['../a00533.html#ga08877c101704bebe4fa57e0849dc272d',1,'tds71_submit_prepexec(TDSSOCKET *tds, const char *query, const char *id, TDSDYNAMIC **dyn_out, TDSPARAMINFO *params): query.c'],['../a00533.html#ga08877c101704bebe4fa57e0849dc272d',1,'tds71_submit_prepexec(TDSSOCKET *tds, const char *query, const char *id, TDSDYNAMIC **dyn_out, TDSPARAMINFO *params): query.c']]], ['tds7_5fbcp_5fsend_5fcolmetadata',['tds7_bcp_send_colmetadata',['../a00248.html#a4daaa551e54dbd978650e2eef89e09ff',1,'bulk.c']]], ['tds7_5fbuild_5fbulk_5finsert_5fstmt',['tds7_build_bulk_insert_stmt',['../a00248.html#a3118c7232bc9c3e47f8ba872bb39e967',1,'bulk.c']]], ['tds7_5fbuild_5fparam_5fdef_5ffrom_5fparams',['tds7_build_param_def_from_params',['../a00533.html#gac8d5497c2d1b9fadb724111660bd03bd',1,'query.c']]], ['tds7_5fbuild_5fparam_5fdef_5ffrom_5fquery',['tds7_build_param_def_from_query',['../a00533.html#gab775332d378c7fe083750d624441b303',1,'query.c']]], ['tds7_5fget_5fdata_5finfo',['tds7_get_data_info',['../a00536.html#ga07cee55fd522cca16fb59b7a8f0b1376',1,'token.c']]], ['tds7_5fget_5finstance_5fport',['tds7_get_instance_port',['../a00534.html#gac23c12ccb3e8599f10f305e993e216f6',1,'tds7_get_instance_port(struct addrinfo *addr, const char *instance): net.c'],['../a00534.html#gac23c12ccb3e8599f10f305e993e216f6',1,'tds7_get_instance_port(struct addrinfo *addr, const char *instance): net.c']]], ['tds7_5fget_5finstance_5fports',['tds7_get_instance_ports',['../a00534.html#ga954dcc3b0332fa9448d9edf59c0fe439',1,'tds7_get_instance_ports(FILE *output, struct addrinfo *addr): net.c'],['../a00534.html#ga954dcc3b0332fa9448d9edf59c0fe439',1,'tds7_get_instance_ports(FILE *output, struct addrinfo *addr): net.c']]], ['tds7_5fprocess_5fcompute_5fresult',['tds7_process_compute_result',['../a00536.html#ga6728e344caa20aea1def85f58dea138b',1,'token.c']]], ['tds7_5fprocess_5fresult',['tds7_process_result',['../a00536.html#gaca56fc22d65a24a96d1bef310ade73aa',1,'token.c']]], ['tds7_5fput_5fparams_5fdefinition',['tds7_put_params_definition',['../a00533.html#ga0f0b6bf447e9672e3b1ea8453ddeb113',1,'query.c']]], ['tds7_5fput_5fquery_5fparams',['tds7_put_query_params',['../a00533.html#ga6e42b4a1d1d3898229ea2fe4afc2ecec',1,'query.c']]], ['tds7_5fsend_5fexecute',['tds7_send_execute',['../a00533.html#gab71e2dc686eafe926dbebbce00d27dc4',1,'query.c']]], ['tds_5falloc_5fcompute_5fresult',['tds_alloc_compute_result',['../a00532.html#gae042c280bdf5ecdd530a6e5cc2cf83f5',1,'mem.c']]], ['tds_5falloc_5fdynamic',['tds_alloc_dynamic',['../a00532.html#ga69559de43b47f4a9e2eecc7a56527444',1,'tds_alloc_dynamic(TDSCONNECTION *conn, const char *id): mem.c'],['../a00532.html#ga69559de43b47f4a9e2eecc7a56527444',1,'tds_alloc_dynamic(TDSCONNECTION *conn, const char *id): mem.c']]], ['tds_5falloc_5fget_5fstring',['tds_alloc_get_string',['../a00536.html#gafb26aba5d935e40b87b95e21a5185848',1,'token.c']]], ['tds_5falloc_5fparam_5fdata',['tds_alloc_param_data',['../a00532.html#ga282d67682d293810625d87d566443c2d',1,'tds_alloc_param_data(TDSCOLUMN *curparam): mem.c'],['../a00532.html#ga282d67682d293810625d87d566443c2d',1,'tds_alloc_param_data(TDSCOLUMN *curparam): mem.c']]], ['tds_5falloc_5fparam_5fresult',['tds_alloc_param_result',['../a00532.html#ga314c65c067570dc1ef3e58bbfc4eb763',1,'tds_alloc_param_result(TDSPARAMINFO *old_param): mem.c'],['../a00532.html#ga314c65c067570dc1ef3e58bbfc4eb763',1,'tds_alloc_param_result(TDSPARAMINFO *old_param): mem.c']]], ['tds_5falloc_5frow',['tds_alloc_row',['../a00532.html#ga1224fb9277112dc2ce12531d2b73b145',1,'tds_alloc_row(TDSRESULTINFO *res_info): mem.c'],['../a00532.html#ga1224fb9277112dc2ce12531d2b73b145',1,'tds_alloc_row(TDSRESULTINFO *res_info): mem.c']]], ['tds_5fanswer_5fchallenge',['tds_answer_challenge',['../a00528.html#ga4c76be38f4758db45be58f9de8ccdef0',1,'challenge.c']]], ['tds_5fascii_5fto_5fucs2',['tds_ascii_to_ucs2',['../a00533.html#gad05fc65e1d505c68d14c82b99a00e4eb',1,'query.c']]], ['tds_5fbcp_5fadd_5ffixed_5fcolumns',['tds_bcp_add_fixed_columns',['../a00248.html#a6d1e3ee3ba4ddeac7d5c9b5e30b185f1',1,'bulk.c']]], ['tds_5fbcp_5fadd_5fvariable_5fcolumns',['tds_bcp_add_variable_columns',['../a00248.html#a0184a0b53bd92aeca39b136542238dd4',1,'bulk.c']]], ['tds_5fbcp_5fdone',['tds_bcp_done',['../a00248.html#ade7df2db455b61edc83819ad60edb339',1,'tds_bcp_done(TDSSOCKET *tds, int *rows_copied): bulk.c'],['../a00434.html#ade7df2db455b61edc83819ad60edb339',1,'tds_bcp_done(TDSSOCKET *tds, int *rows_copied): bulk.c']]], ['tds_5fbcp_5ffread',['tds_bcp_fread',['../a00248.html#a86ac92bd8a3c61a413d27150ec9bc202',1,'tds_bcp_fread(TDSSOCKET *tds, TDSICONV *char_conv, FILE *stream, const char *terminator, size_t term_len, char **outbuf, size_t *outbytes): bulk.c'],['../a00434.html#a8184311543c685f2ee0bcccfb725ca02',1,'tds_bcp_fread(TDSSOCKET *tds, TDSICONV *conv, FILE *stream, const char *terminator, size_t term_len, char **outbuf, size_t *outbytes): bulk.c']]], ['tds_5fbcp_5finit',['tds_bcp_init',['../a00248.html#ac6610c72bd31bad5378f760fa9b12d66',1,'tds_bcp_init(TDSSOCKET *tds, TDSBCPINFO *bcpinfo): bulk.c'],['../a00434.html#ac6610c72bd31bad5378f760fa9b12d66',1,'tds_bcp_init(TDSSOCKET *tds, TDSBCPINFO *bcpinfo): bulk.c']]], ['tds_5fbcp_5frow_5ffree',['tds_bcp_row_free',['../a00248.html#a7c4f2b050cd1a747604aa305d6877de7',1,'bulk.c']]], ['tds_5fbcp_5fsend_5frecord',['tds_bcp_send_record',['../a00248.html#adbc0876f3d1eae0c26e7a1abe37419fe',1,'tds_bcp_send_record(TDSSOCKET *tds, TDSBCPINFO *bcpinfo, tds_bcp_get_col_data get_col_data, tds_bcp_null_error ignored, int offset): bulk.c'],['../a00434.html#ad9e44450025cbcee1ad81d7e5a2cc099',1,'tds_bcp_send_record(TDSSOCKET *tds, TDSBCPINFO *bcpinfo, tds_bcp_get_col_data get_col_data, tds_bcp_null_error null_error, int offset): bulk.c']]], ['tds_5fbcp_5fstart',['tds_bcp_start',['../a00248.html#a8208eef2a3974ae1f0cf3c8c8ab011ce',1,'tds_bcp_start(TDSSOCKET *tds, TDSBCPINFO *bcpinfo): bulk.c'],['../a00434.html#a8208eef2a3974ae1f0cf3c8c8ab011ce',1,'tds_bcp_start(TDSSOCKET *tds, TDSBCPINFO *bcpinfo): bulk.c']]], ['tds_5fbcp_5fstart_5fcopy_5fin',['tds_bcp_start_copy_in',['../a00248.html#a5eec23828b0610c58de248c4edb53879',1,'tds_bcp_start_copy_in(TDSSOCKET *tds, TDSBCPINFO *bcpinfo): bulk.c'],['../a00434.html#a5eec23828b0610c58de248c4edb53879',1,'tds_bcp_start_copy_in(TDSSOCKET *tds, TDSBCPINFO *bcpinfo): bulk.c']]], ['tds_5fbcp_5fstart_5finsert_5fstmt',['tds_bcp_start_insert_stmt',['../a00248.html#ab4d7e5309152f54613d52c8469a07fd8',1,'bulk.c']]], ['tds_5fcanonical_5fcharset',['tds_canonical_charset',['../a00531.html#ga38c0ac641a8c6e25e91ee9205c3c50c5',1,'iconv.c']]], ['tds_5fcanonical_5fcharset_5fname',['tds_canonical_charset_name',['../a00531.html#ga6561d1dba1a04c168431b16ec17d7e4c',1,'tds_canonical_charset_name(const char *charset_name): iconv.c'],['../a00531.html#ga6561d1dba1a04c168431b16ec17d7e4c',1,'tds_canonical_charset_name(const char *charset_name): iconv.c']]], ['tds_5fclose_5fsocket',['tds_close_socket',['../a00534.html#ga3e3f76009fce5ceedb2f42bb2c9aed2e',1,'tds_close_socket(TDSSOCKET *tds): net.c'],['../a00534.html#ga3e3f76009fce5ceedb2f42bb2c9aed2e',1,'tds_close_socket(TDSSOCKET *tds): net.c']]], ['tds_5fconfig_5fverstr',['tds_config_verstr',['../a00529.html#gade94d7e89ba1f668c82be0b00a7f5cd7',1,'tds_config_verstr(const char *tdsver, TDSLOGIN *login): config.c'],['../a00529.html#gade94d7e89ba1f668c82be0b00a7f5cd7',1,'tds_config_verstr(const char *tdsver, TDSLOGIN *login): config.c']]], ['tds_5fconvert',['tds_convert',['../a00530.html#gaa865e08f7ad70ef92b111c2ea3657457',1,'tds_convert(const TDSCONTEXT *tds_ctx, int srctype, const TDS_CHAR *src, TDS_UINT srclen, int desttype, CONV_RESULT *cr): convert.c'],['../a00530.html#gaa865e08f7ad70ef92b111c2ea3657457',1,'tds_convert(const TDSCONTEXT *context, int srctype, const TDS_CHAR *src, TDS_UINT srclen, int desttype, CONV_RESULT *cr): convert.c']]], ['tds_5fconvert_5fstream',['tds_convert_stream',['../a01330.html#a9d8eb43a81ff58ab423dce0ce95b9564',1,'stream.c']]], ['tds_5fconvert_5fstring',['tds_convert_string',['../a00533.html#ga024bc5482366735070befd6f4af59f71',1,'tds_convert_string(TDSSOCKET *tds, TDSICONV *char_conv, const char *s, int len, size_t *out_len): query.c'],['../a00533.html#ga024bc5482366735070befd6f4af59f71',1,'tds_convert_string(TDSSOCKET *tds, TDSICONV *char_conv, const char *s, int len, size_t *out_len): query.c']]], ['tds_5fcopy_5fstream',['tds_copy_stream',['../a01330.html#a2b8e3379c38cd2bce28b90cb199c2aa9',1,'stream.c']]], ['tds_5fcount_5fplaceholders',['tds_count_placeholders',['../a00533.html#gaaa7b4d37bf796019e72f25c6e7fe7bea',1,'tds_count_placeholders(const char *query): query.c'],['../a00533.html#gaaa7b4d37bf796019e72f25c6e7fe7bea',1,'tds_count_placeholders(const char *query): query.c']]], ['tds_5fcount_5fplaceholders_5fucs2le',['tds_count_placeholders_ucs2le',['../a00533.html#ga0cd19215e9169ea299a6c9cbf5b2fb60',1,'query.c']]], ['tds_5fcursor_5fcheck_5fallocated',['tds_cursor_check_allocated',['../a00533.html#ga2c6da4886cc30af02546a3bc2ebcae5d',1,'query.c']]], ['tds_5fcursor_5fdealloc',['tds_cursor_dealloc',['../a00533.html#gab25de0567ac096e8f8e88490eeddf562',1,'tds_cursor_dealloc(TDSSOCKET *tds, TDSCURSOR *cursor): query.c'],['../a00533.html#gab25de0567ac096e8f8e88490eeddf562',1,'tds_cursor_dealloc(TDSSOCKET *tds, TDSCURSOR *cursor): query.c']]], ['tds_5fdatain_5fstream_5finit',['tds_datain_stream_init',['../a01330.html#abc3a77c8aa28842e7f28583cbabc1415',1,'stream.c']]], ['tds_5fdatain_5fstream_5fread',['tds_datain_stream_read',['../a01330.html#a04b537d889f7d4c9b9701eb81baf7efd',1,'stream.c']]], ['tds_5fdataout_5fstream_5finit',['tds_dataout_stream_init',['../a01330.html#aa038a9125979f8f0915dbd53cbf27e5a',1,'stream.c']]], ['tds_5fdataout_5fstream_5fwrite',['tds_dataout_stream_write',['../a01330.html#ae38a590ee08cf398e7adef536ac94538',1,'stream.c']]], ['tds_5fdatecrack',['tds_datecrack',['../a00530.html#ga883855e6e3793de6684b21db39c756c4',1,'tds_datecrack(TDS_INT datetype, const void *di, TDSDATEREC *dr): convert.c'],['../a00530.html#ga883855e6e3793de6684b21db39c756c4',1,'tds_datecrack(TDS_INT datetype, const void *di, TDSDATEREC *dr): convert.c']]], ['tds_5fdeferred_5fcursor_5fdealloc',['tds_deferred_cursor_dealloc',['../a00533.html#ga57bd0fabe5bcdeb3ef091259b3a7c1fc',1,'tds_deferred_cursor_dealloc(TDSCONNECTION *conn, TDSCURSOR *cursor): query.c'],['../a00533.html#ga57bd0fabe5bcdeb3ef091259b3a7c1fc',1,'tds_deferred_cursor_dealloc(TDSCONNECTION *conn, TDSCURSOR *cursor): query.c']]], ['tds_5fdeferred_5funprepare',['tds_deferred_unprepare',['../a00533.html#ga9f80fdf732b084aef7de7a323261aa61',1,'tds_deferred_unprepare(TDSCONNECTION *conn, TDSDYNAMIC *dyn): query.c'],['../a00533.html#ga9f80fdf732b084aef7de7a323261aa61',1,'tds_deferred_unprepare(TDSCONNECTION *conn, TDSDYNAMIC *dyn): query.c']]], ['tds_5fdetach_5fresults',['tds_detach_results',['../a00532.html#ga1d60bf443e274797b1d1a9e7418ab962',1,'tds_detach_results(TDSRESULTINFO *info): mem.c'],['../a00532.html#ga1d60bf443e274797b1d1a9e7418ab962',1,'tds_detach_results(TDSRESULTINFO *info): mem.c']]], ['tds_5fdstr_5falloc',['tds_dstr_alloc',['../a00535.html#ga6aa14b8b717b51afcfb65bd55143689d',1,'tdsstring.c']]], ['tds_5fdstr_5fbuf',['tds_dstr_buf',['../a00535.html#ga8fa35e3ff06ef0b7d0d642cf50282ab8',1,'string.h']]], ['tds_5fdstr_5fcopy',['tds_dstr_copy',['../a00535.html#gad96366d9fa93bfc283cef1299fbe97ab',1,'tdsstring.c']]], ['tds_5fdstr_5fcopyn',['tds_dstr_copyn',['../a00535.html#ga656718f240d7403f986ae887d84a6ca1',1,'tdsstring.c']]], ['tds_5fdstr_5fcstr',['tds_dstr_cstr',['../a00535.html#ga3340b488ed37845018e34572450e64c6',1,'string.h']]], ['tds_5fdstr_5fdup',['tds_dstr_dup',['../a00535.html#ga4e6d9fa6f9b9551a5a3390e10a5322e6',1,'tdsstring.c']]], ['tds_5fdstr_5ffree',['tds_dstr_free',['../a00535.html#gaccd1c1c8ff938813578123963212388c',1,'tdsstring.c']]], ['tds_5fdstr_5fget',['tds_dstr_get',['../a00534.html#gafae08056186b143f3ef1399307dc9be7',1,'tds_dstr_get(TDSSOCKET *tds, DSTR *s, size_t len): read.c'],['../a00534.html#gafae08056186b143f3ef1399307dc9be7',1,'tds_dstr_get(TDSSOCKET *tds, DSTR *s, size_t len): read.c']]], ['tds_5fdstr_5finit',['tds_dstr_init',['../a00535.html#ga6c0aba5c6da921898768e7f6cf177ca7',1,'string.h']]], ['tds_5fdstr_5fisempty',['tds_dstr_isempty',['../a00535.html#gae6d3d12bd1f5f0c56df934a377c245d3',1,'string.h']]], ['tds_5fdstr_5flen',['tds_dstr_len',['../a00535.html#gaf0e232f3c35f2d8b43486e8708f7a8fc',1,'string.h']]], ['tds_5fdstr_5fset',['tds_dstr_set',['../a00535.html#gab78cc59b110df2817b00f9bed74c6ff1',1,'tdsstring.c']]], ['tds_5fdstr_5fsetlen',['tds_dstr_setlen',['../a00535.html#ga0cd7863ba7c2d2da4a193234472a3d14',1,'tdsstring.c']]], ['tds_5fdstr_5fzero',['tds_dstr_zero',['../a00535.html#ga339ba30216e2bd5bd076aa9dcd26f3c4',1,'tdsstring.c']]], ['tds_5fdynamic_5fstream_5finit',['tds_dynamic_stream_init',['../a01330.html#a4f9e40da6941cb9407d0da5bc3030517',1,'stream.c']]], ['tds_5fdynamic_5fstream_5fwrite',['tds_dynamic_stream_write',['../a01330.html#abaf688c85ea04a2392103d519a55d04e',1,'stream.c']]], ['tds_5ffile_5fstream_5fread',['tds_file_stream_read',['../a00248.html#a1b83c9db016b481aa1fa0352f976d50d',1,'bulk.c']]], ['tds_5ffix_5fcolumn_5fsize',['tds_fix_column_size',['../a00533.html#ga440f0f469afad1eac4c008979873ccdd',1,'tds_fix_column_size(TDSSOCKET *tds, TDSCOLUMN *curcol): query.c'],['../a00533.html#ga440f0f469afad1eac4c008979873ccdd',1,'tds_fix_column_size(TDSSOCKET *tds, TDSCOLUMN *curcol): query.c']]], ['tds_5ffix_5flogin',['tds_fix_login',['../a00529.html#gacee4f06ba749b10ee9f2e5bb1c4a8910',1,'tds_fix_login(TDSLOGIN *login): config.c'],['../a00529.html#gacee4f06ba749b10ee9f2e5bb1c4a8910',1,'tds_fix_login(TDSLOGIN *login): config.c']]], ['tds_5fflush_5fpacket',['tds_flush_packet',['../a00534.html#ga5feb53554e8917a81bbbc332163a61fb',1,'tds_flush_packet(TDSSOCKET *tds): write.c'],['../a00534.html#ga5feb53554e8917a81bbbc332163a61fb',1,'tds_flush_packet(TDSSOCKET *tds): write.c']]], ['tds_5ffree_5finput_5fparams',['tds_free_input_params',['../a00532.html#gabdc5fee73b22345c02ab894e49ad7f95',1,'tds_free_input_params(TDSDYNAMIC *dyn): mem.c'],['../a00532.html#gabdc5fee73b22345c02ab894e49ad7f95',1,'tds_free_input_params(TDSDYNAMIC *dyn): mem.c']]], ['tds_5ffree_5fnamelist',['tds_free_namelist',['../a00536.html#ga21e9de33de9c8c492aa2f96c823596bb',1,'token.c']]], ['tds_5ffree_5fparam_5fresult',['tds_free_param_result',['../a00532.html#ga66cd6e3c5089ced9415a8a0e258d205a',1,'tds_free_param_result(TDSPARAMINFO *param_info): mem.c'],['../a00532.html#ga66cd6e3c5089ced9415a8a0e258d205a',1,'tds_free_param_result(TDSPARAMINFO *param_info): mem.c']]], ['tds_5fgeneric_5fget',['tds_generic_get',['../a00260.html#abac4d689e0e31e80587f89247c6395a4',1,'data.c']]], ['tds_5fgeneric_5fput',['tds_generic_put',['../a00260.html#a84e17808683ba2dd956e811a42e23176',1,'data.c']]], ['tds_5fgeneric_5fput_5finfo',['tds_generic_put_info',['../a00260.html#aabd0e5f15615b5c141c525b76e746520',1,'data.c']]], ['tds_5fget_5fbyte',['tds_get_byte',['../a00534.html#ga0cb72d3f6943795c39db1fa692be0a58',1,'tds_get_byte(TDSSOCKET *tds): read.c'],['../a00534.html#ga0cb72d3f6943795c39db1fa692be0a58',1,'tds_get_byte(TDSSOCKET *tds): read.c']]], ['tds_5fget_5fchar_5fdata',['tds_get_char_data',['../a00534.html#ga8d214089b6e97fc0da5e0be09f216d73',1,'tds_get_char_data(TDSSOCKET *tds, char *row_buffer, size_t wire_size, TDSCOLUMN *curcol): read.c'],['../a00534.html#ga8d214089b6e97fc0da5e0be09f216d73',1,'tds_get_char_data(TDSSOCKET *tds, char *dest, size_t wire_size, TDSCOLUMN *curcol): read.c']]], ['tds_5fget_5fcolumn_5fdeclaration',['tds_get_column_declaration',['../a00533.html#ga50d62edeb2a432e2dc668263f3f958ff',1,'tds_get_column_declaration(TDSSOCKET *tds, TDSCOLUMN *curcol, char *out): query.c'],['../a00533.html#ga50d62edeb2a432e2dc668263f3f958ff',1,'tds_get_column_declaration(TDSSOCKET *tds, TDSCOLUMN *curcol, char *out): query.c']]], ['tds_5fget_5fcompiletime_5fsettings',['tds_get_compiletime_settings',['../a00529.html#ga860690ac47a80f74c83b25cbd8d7703d',1,'tds_get_compiletime_settings(void): config.c'],['../a00529.html#ga860690ac47a80f74c83b25cbd8d7703d',1,'tds_get_compiletime_settings(void): config.c']]], ['tds_5fget_5fconversion_5ftype',['tds_get_conversion_type',['../a00434.html#a0383d5dcb629582266a442f0f0dbd13a',1,'tds_types.h']]], ['tds_5fget_5fdata_5finfo',['tds_get_data_info',['../a00536.html#gad9b6b86f48be077fb44ac603845a0c27',1,'token.c']]], ['tds_5fget_5fdynid',['tds_get_dynid',['../a00532.html#ga501af7e6186e59c257729599a044a30b',1,'mem.c']]], ['tds_5fget_5fhome_5ffile',['tds_get_home_file',['../a00529.html#gaf49eca946d1b2457e189de7207e3670c',1,'config.c']]], ['tds_5fget_5fhomedir',['tds_get_homedir',['../a00434.html#a6fb8c78f678c0016c12096765ab2f5c1',1,'threadsafe.c']]], ['tds_5fget_5flocale',['tds_get_locale',['../a00434.html#af43163dc067b230b2236a619a067c675',1,'locale.c']]], ['tds_5fget_5fn',['tds_get_n',['../a00534.html#gae7d9c4e1a079e1d0aa0252732631e8c4',1,'tds_get_n(TDSSOCKET *tds, void *dest, size_t need): read.c'],['../a00534.html#gae7d9c4e1a079e1d0aa0252732631e8c4',1,'tds_get_n(TDSSOCKET *tds, void *dest, size_t n): read.c']]], ['tds_5fget_5fnull_5ftype',['tds_get_null_type',['../a00530.html#ga68e3a76fd7b0a77614765826a8ab5be8',1,'tds_get_null_type(TDS_SERVER_TYPE srctype): convert.c'],['../a00530.html#ga68e3a76fd7b0a77614765826a8ab5be8',1,'tds_get_null_type(TDS_SERVER_TYPE srctype): convert.c']]], ['tds_5fget_5fsize_5fby_5ftype',['tds_get_size_by_type',['../a00434.html#a4c070147d189dede5e08a2dc66852678',1,'tds_types.h']]], ['tds_5fget_5fstring',['tds_get_string',['../a00534.html#ga90f080e6e9448feac15dee1370d66802',1,'tds_get_string(TDSSOCKET *tds, size_t string_len, char *dest, size_t dest_size): read.c'],['../a00534.html#ga90f080e6e9448feac15dee1370d66802',1,'tds_get_string(TDSSOCKET *tds, size_t string_len, char *dest, size_t dest_size): read.c']]], ['tds_5fget_5ftoken_5fsize',['tds_get_token_size',['../a00536.html#ga995b82e53aeac5bede01ef16e9aeaa65',1,'tds_get_token_size(int marker): token.c'],['../a00536.html#ga995b82e53aeac5bede01ef16e9aeaa65',1,'tds_get_token_size(int marker): token.c']]], ['tds_5fget_5fuint',['tds_get_uint',['../a00534.html#ga9ac121c269e203337a48c5bf8afc48c3',1,'tds_get_uint(TDSSOCKET *tds): read.c'],['../a00534.html#ga9ac121c269e203337a48c5bf8afc48c3',1,'tds_get_uint(TDSSOCKET *tds): read.c']]], ['tds_5fget_5fuint8',['tds_get_uint8',['../a00534.html#ga8ab6c87318eaf15ea17a9575763f7809',1,'tds_get_uint8(TDSSOCKET *tds): read.c'],['../a00534.html#ga8ab6c87318eaf15ea17a9575763f7809',1,'tds_get_uint8(TDSSOCKET *tds): read.c']]], ['tds_5fget_5fusmallint',['tds_get_usmallint',['../a00534.html#gad38aa5b9547817854ccba1fcc7855861',1,'tds_get_usmallint(TDSSOCKET *tds): read.c'],['../a00534.html#gad38aa5b9547817854ccba1fcc7855861',1,'tds_get_usmallint(TDSSOCKET *tds): read.c']]], ['tds_5fget_5fvarint_5fsize',['tds_get_varint_size',['../a00434.html#a68855f1251759a6b7338635306ab0041',1,'tds_types.h']]], ['tds_5fgetservice',['tds_getservice',['../a00434.html#a3a2add5890ed468e36d780d29263ae22',1,'threadsafe.c']]], ['tds_5fgoodread',['tds_goodread',['../a00534.html#ga6f2ae00407f59fb1ab280fa44a56295e',1,'tds_goodread(TDSSOCKET *tds, unsigned char *buf, int buflen): net.c'],['../a00534.html#ga6f2ae00407f59fb1ab280fa44a56295e',1,'tds_goodread(TDSSOCKET *tds, unsigned char *buf, int buflen): net.c']]], ['tds_5fgoodwrite',['tds_goodwrite',['../a00534.html#ga2734407109c834c5dda7ff8a45c71230',1,'tds_goodwrite(TDSSOCKET *tds, const unsigned char *buffer, size_t buflen): net.c'],['../a00534.html#ga2734407109c834c5dda7ff8a45c71230',1,'tds_goodwrite(TDSSOCKET *tds, const unsigned char *buffer, size_t buflen): net.c']]], ['tds_5ficonv',['tds_iconv',['../a00531.html#ga87db49044919f1bc84c0ff5e9ab00304',1,'tds_iconv(TDSSOCKET *tds, TDSICONV *conv, TDS_ICONV_DIRECTION io, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft): iconv.c'],['../a00531.html#ga87db49044919f1bc84c0ff5e9ab00304',1,'tds_iconv(TDSSOCKET *tds, TDSICONV *char_conv, TDS_ICONV_DIRECTION io, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft): iconv.c']]], ['tds_5ficonv_5falloc',['tds_iconv_alloc',['../a01342.html#a026957dbbd994b48b571a63405f427cd',1,'tds_iconv_alloc(TDSCONNECTION *conn): iconv.c'],['../a00434.html#a026957dbbd994b48b571a63405f427cd',1,'tds_iconv_alloc(TDSCONNECTION *conn): iconv.c']]], ['tds_5ficonv_5ffrom_5fcollate',['tds_iconv_from_collate',['../a00531.html#gaed775f7fcca42b5c2a53f9508c140259',1,'tds_iconv_from_collate(TDSCONNECTION *conn, TDS_UCHAR collate[5]): iconv.c'],['../a00531.html#gaed775f7fcca42b5c2a53f9508c140259',1,'tds_iconv_from_collate(TDSCONNECTION *conn, TDS_UCHAR collate[5]): iconv.c']]], ['tds_5ficonv_5fget_5finfo',['tds_iconv_get_info',['../a00531.html#gac85bc9c101048a124707c7050035e30f',1,'iconv.c']]], ['tds_5ficonv_5finfo_5finit',['tds_iconv_info_init',['../a00531.html#ga3a7a7b4d6ed344127e164dd0b443d790',1,'iconv.c']]], ['tds_5ficonv_5finit',['tds_iconv_init',['../a01342.html#a89de4d12be43b135ad355236717e9cbb',1,'iconv.c']]], ['tds_5finit_5flogin',['tds_init_login',['../a00532.html#ga2ef389ac3b0cddec76bf8f1c0951bc9c',1,'tds_init_login(TDSLOGIN *login, TDSLOCALE *locale): mem.c'],['../a00532.html#ga2ef389ac3b0cddec76bf8f1c0951bc9c',1,'tds_init_login(TDSLOGIN *login, TDSLOCALE *locale): mem.c']]], ['tds_5flookup_5fdynamic',['tds_lookup_dynamic',['../a00536.html#ga595fe391e60a71bd98ffd53b4c015e44',1,'tds_lookup_dynamic(TDSCONNECTION *conn, const char *id): token.c'],['../a00536.html#ga595fe391e60a71bd98ffd53b4c015e44',1,'tds_lookup_dynamic(TDSCONNECTION *conn, const char *id): token.c']]], ['tds_5flookup_5fhost',['tds_lookup_host',['../a00529.html#gaa17936ef93e1c68833c4aab769bd90d9',1,'tds_lookup_host(const char *servername): config.c'],['../a00529.html#gaa17936ef93e1c68833c4aab769bd90d9',1,'tds_lookup_host(const char *servername): config.c']]], ['tds_5flookup_5fport',['tds_lookup_port',['../a00529.html#ga45281d1cb2ac649db65d80bb3ff06b66',1,'config.c']]], ['tds_5fneeds_5funprepare',['tds_needs_unprepare',['../a00533.html#ga05ac7bab753d19b6ba1ffc7505d8fcd0',1,'tds_needs_unprepare(TDSCONNECTION *conn, TDSDYNAMIC *dyn): query.c'],['../a00533.html#ga05ac7bab753d19b6ba1ffc7505d8fcd0',1,'tds_needs_unprepare(TDSCONNECTION *conn, TDSDYNAMIC *dyn): query.c']]], ['tds_5fnext_5fplaceholder',['tds_next_placeholder',['../a00533.html#ga6455b2991afbf7da90270787f2059d31',1,'tds_next_placeholder(const char *start): query.c'],['../a00533.html#ga6455b2991afbf7da90270787f2059d31',1,'tds_next_placeholder(const char *start): query.c']]], ['tds_5fnext_5fplaceholder_5fucs2le',['tds_next_placeholder_ucs2le',['../a00533.html#gaa823973b74efdf1ff00f340496bff614',1,'query.c']]], ['tds_5fntlm_5fget_5fauth',['tds_ntlm_get_auth',['../a00528.html#ga679f2d22b4a4bdefe0fa475d63503778',1,'tds_ntlm_get_auth(TDSSOCKET *tds): challenge.c'],['../a00528.html#ga679f2d22b4a4bdefe0fa475d63503778',1,'tds_ntlm_get_auth(TDSSOCKET *tds): challenge.c']]], ['tds_5fnumeric_5fto_5fstring',['tds_numeric_to_string',['../a00434.html#a622da936832b0337742da956be123719',1,'numeric.c']]], ['tds_5fpeek',['tds_peek',['../a00534.html#ga221e98a9c8be96ec6c8547891e1b53af',1,'tds_peek(TDSSOCKET *tds): read.c'],['../a00534.html#ga221e98a9c8be96ec6c8547891e1b53af',1,'tds_peek(TDSSOCKET *tds): read.c']]], ['tds_5fpr_5fop',['tds_pr_op',['../a00536.html#ga62dc14d21453e88e24880ee0acaca73a',1,'token.c']]], ['tds_5fprdatatype',['tds_prdatatype',['../a00077.html#ac7a199aaeb82935f6d1dda2be551a089',1,'dblib.c']]], ['tds_5fprocess_5fauth',['tds_process_auth',['../a00536.html#ga4e1e52e09b0c27a9b9f53eb6b539afce',1,'token.c']]], ['tds_5fprocess_5fcancel',['tds_process_cancel',['../a00536.html#gaf233e79967f82f4e0dd4d11524917a34',1,'tds_process_cancel(TDSSOCKET *tds): token.c'],['../a00536.html#gaf233e79967f82f4e0dd4d11524917a34',1,'tds_process_cancel(TDSSOCKET *tds): token.c']]], ['tds_5fprocess_5fcol_5ffmt',['tds_process_col_fmt',['../a00536.html#ga4e3dd9d3614f5f0433b78b761dd68741',1,'token.c']]], ['tds_5fprocess_5fcol_5fname',['tds_process_col_name',['../a00536.html#ga905d2fa5e1b602817bd16bb0fcf9eadb',1,'token.c']]], ['tds_5fprocess_5fcolinfo',['tds_process_colinfo',['../a00536.html#ga22c7f413d43fc0d511e122a3de389166',1,'token.c']]], ['tds_5fprocess_5fcompute',['tds_process_compute',['../a00536.html#ga6fcb37d5addebdc1af9f34ebc59fd7a8',1,'token.c']]], ['tds_5fprocess_5fcompute_5fnames',['tds_process_compute_names',['../a00536.html#gae5b3e01f3d665f9e377de091f46f1ab9',1,'token.c']]], ['tds_5fprocess_5fcompute_5fresult',['tds_process_compute_result',['../a00536.html#gae3368ea80d0d8b13791ceb13ee5f19c9',1,'token.c']]], ['tds_5fprocess_5fcursor_5ftokens',['tds_process_cursor_tokens',['../a00536.html#ga315d875d90c64d12d61fc9e33b4dee96',1,'token.c']]], ['tds_5fprocess_5fdefault_5ftokens',['tds_process_default_tokens',['../a00536.html#ga39453d084f3f780ac4602d4abf2839f7',1,'token.c']]], ['tds_5fprocess_5fdyn_5fresult',['tds_process_dyn_result',['../a00536.html#ga416cf119c1d4a0fca27dc5b50c261358',1,'token.c']]], ['tds_5fprocess_5fdynamic',['tds_process_dynamic',['../a00536.html#ga5cfc0340d8d717e67f60037e029b2142',1,'token.c']]], ['tds_5fprocess_5fend',['tds_process_end',['../a00536.html#ga7a081cf9bb8f04ead12f0299fb7c4cd9',1,'token.c']]], ['tds_5fprocess_5fenv_5fchg',['tds_process_env_chg',['../a00536.html#ga3e1b4df4410a86a563a8c155e7799720',1,'token.c']]], ['tds_5fprocess_5finfo',['tds_process_info',['../a00536.html#ga65a2316369529731732f200c190d05d6',1,'token.c']]], ['tds_5fprocess_5flogin_5ftokens',['tds_process_login_tokens',['../a00536.html#ga93945b42d45ee28ae1296b35a1c1e9bb',1,'tds_process_login_tokens(TDSSOCKET *tds): token.c'],['../a00536.html#ga93945b42d45ee28ae1296b35a1c1e9bb',1,'tds_process_login_tokens(TDSSOCKET *tds): token.c']]], ['tds_5fprocess_5fnbcrow',['tds_process_nbcrow',['../a00536.html#gaf7264c9eb3aa7a73358a4c65f02d3d3c',1,'token.c']]], ['tds_5fprocess_5fparam_5fresult',['tds_process_param_result',['../a00536.html#gacb3354443bcefe7a500a500a4904cc05',1,'token.c']]], ['tds_5fprocess_5fparam_5fresult_5ftokens',['tds_process_param_result_tokens',['../a00536.html#ga9fdef8228d29cab7fa9098f07fa73fba',1,'token.c']]], ['tds_5fprocess_5fparams_5fresult_5ftoken',['tds_process_params_result_token',['../a00536.html#ga7b18c0911a9dc69939577b39eb64725d',1,'token.c']]], ['tds_5fprocess_5fpending_5fcloses',['tds_process_pending_closes',['../a00536.html#ga69902dffb299d62a799888e0fa3ccd68',1,'token.c']]], ['tds_5fprocess_5frow',['tds_process_row',['../a00536.html#gaad814dd6e35aee8332035d06dc8b5d65',1,'token.c']]], ['tds_5fprocess_5fsimple_5fquery',['tds_process_simple_query',['../a00536.html#gaeeb1562044786ea17bea361ed83e6946',1,'tds_process_simple_query(TDSSOCKET *tds): token.c'],['../a00536.html#gaeeb1562044786ea17bea361ed83e6946',1,'tds_process_simple_query(TDSSOCKET *tds): token.c']]], ['tds_5fprocess_5ftabname',['tds_process_tabname',['../a00536.html#gaeec59bca9bd0c5388e245f0d19d9c81a',1,'token.c']]], ['tds_5fprocess_5ftokens',['tds_process_tokens',['../a00536.html#gabfc9de1d1fe718818caf63a4be4035a6',1,'tds_process_tokens(TDSSOCKET *tds, TDS_INT *result_type, int *done_flags, unsigned flag): token.c'],['../a00536.html#gabfc9de1d1fe718818caf63a4be4035a6',1,'tds_process_tokens(TDSSOCKET *tds, TDS_INT *result_type, int *done_flags, unsigned flag): token.c']]], ['tds_5fprtype',['tds_prtype',['../a00536.html#ga0cf7e719115b0ae476753442d10505ab',1,'tds_prtype(int type): token.c'],['../a00536.html#ga0cf7e719115b0ae476753442d10505ab',1,'tds_prtype(int token): token.c']]], ['tds_5fput_5fdata',['tds_put_data',['../a00533.html#ga9fcc0a3932dcad530511395ef8a767fb',1,'query.c']]], ['tds_5fput_5fdata_5finfo',['tds_put_data_info',['../a00533.html#gafd74652c4722ddce4d642cc4209449d4',1,'query.c']]], ['tds_5fput_5fdata_5finfo_5flength',['tds_put_data_info_length',['../a00533.html#ga319d610d59b2cc669b7fe20c793122af',1,'query.c']]], ['tds_5fput_5fparam_5fas_5fstring',['tds_put_param_as_string',['../a00533.html#ga0e2e7230c425e925402d7856ff5b4b18',1,'query.c']]], ['tds_5fput_5fparams',['tds_put_params',['../a00533.html#ga28264995cf9616661f1fa788ac0d246d',1,'query.c']]], ['tds_5fput_5fstring',['tds_put_string',['../a00534.html#ga1fcaf8d488cc1390f106ce3ad0bf37b4',1,'tds_put_string(TDSSOCKET *tds, const char *s, int len): write.c'],['../a00534.html#ga1fcaf8d488cc1390f106ce3ad0bf37b4',1,'tds_put_string(TDSSOCKET *tds, const char *buf, int len): write.c']]], ['tds_5fquery_5fflush_5fpacket',['tds_query_flush_packet',['../a00533.html#gada27f4cfce925240ad33b71b63ca692d',1,'query.c']]], ['tds_5fquote',['tds_quote',['../a00533.html#ga7efaa23c3b21158ffc963f85fbc3fdf4',1,'query.c']]], ['tds_5fquote_5fand_5fput',['tds_quote_and_put',['../a00533.html#ga26b26296d060dca75f6a43e9ac41e58d',1,'query.c']]], ['tds_5fquote_5fid',['tds_quote_id',['../a00533.html#ga8d8f2f1c91635ee95f30722208ae3043',1,'tds_quote_id(TDSSOCKET *tds, char *buffer, const char *id, int idlen): query.c'],['../a00533.html#ga8d8f2f1c91635ee95f30722208ae3043',1,'tds_quote_id(TDSSOCKET *tds, char *buffer, const char *id, int idlen): query.c']]], ['tds_5fquote_5fstring',['tds_quote_string',['../a00533.html#ga737b9fb9971fb425af5c722415ef0eac',1,'tds_quote_string(TDSSOCKET *tds, char *buffer, const char *str, int len): query.c'],['../a00533.html#ga737b9fb9971fb425af5c722415ef0eac',1,'tds_quote_string(TDSSOCKET *tds, char *buffer, const char *str, int len): query.c']]], ['tds_5fread_5fconf_5ffile',['tds_read_conf_file',['../a00529.html#ga0a63cb612f245fd85e56cfea98ff8f3b',1,'tds_read_conf_file(TDSLOGIN *login, const char *server): config.c'],['../a00529.html#ga0a63cb612f245fd85e56cfea98ff8f3b',1,'tds_read_conf_file(TDSLOGIN *login, const char *server): config.c']]], ['tds_5fread_5fconf_5fsection',['tds_read_conf_section',['../a00529.html#ga6580a3a0a6063c8095a3c4405061e068',1,'tds_read_conf_section(FILE *in, const char *section, TDSCONFPARSE tds_conf_parse, void *param): config.c'],['../a00529.html#ga6580a3a0a6063c8095a3c4405061e068',1,'tds_read_conf_section(FILE *in, const char *section, TDSCONFPARSE tds_conf_parse, void *parse_param): config.c']]], ['tds_5fread_5fconfig_5finfo',['tds_read_config_info',['../a00529.html#ga9af192306186ddf39e09be0fd4ad8aaf',1,'tds_read_config_info(TDSSOCKET *tds, TDSLOGIN *login, TDSLOCALE *locale): config.c'],['../a00529.html#ga9af192306186ddf39e09be0fd4ad8aaf',1,'tds_read_config_info(TDSSOCKET *tds, TDSLOGIN *login, TDSLOCALE *locale): config.c']]], ['tds_5fread_5finterfaces',['tds_read_interfaces',['../a00529.html#ga6631af35ee817f93827c62bbda41674a',1,'config.c']]], ['tds_5fread_5fnamelist',['tds_read_namelist',['../a00536.html#gaeaaed2ea1d8c827da1a0f5b419524ae1',1,'token.c']]], ['tds_5fread_5fpacket',['tds_read_packet',['../a00534.html#ga410619783bdf2bb60b0f27a5578e0e07',1,'tds_read_packet(TDSSOCKET *tds): packet.c'],['../a00534.html#ga410619783bdf2bb60b0f27a5578e0e07',1,'tds_read_packet(TDSSOCKET *tds): packet.c']]], ['tds_5frealloc',['tds_realloc',['../a00532.html#ga924cb9fb5d19dbd308ba0ce8c1a8a1d5',1,'tds_realloc(void **pp, size_t new_size): mem.c'],['../a00532.html#ga924cb9fb5d19dbd308ba0ce8c1a8a1d5',1,'tds_realloc(void **pp, size_t new_size): mem.c']]], ['tds_5frelease_5fdynamic',['tds_release_dynamic',['../a00532.html#gabf2fdb0def5388508602ee7dd2f49506',1,'tds_release_dynamic(TDSDYNAMIC **pdyn): mem.c'],['../a00532.html#gabf2fdb0def5388508602ee7dd2f49506',1,'tds_release_dynamic(TDSDYNAMIC **dyn): mem.c']]], ['tds_5fselect',['tds_select',['../a00534.html#gad7aae89e32444ab30852fee056231403',1,'tds_select(TDSSOCKET *tds, unsigned tds_sel, int timeout_seconds): net.c'],['../a00534.html#gad7aae89e32444ab30852fee056231403',1,'tds_select(TDSSOCKET *tds, unsigned tds_sel, int timeout_seconds): net.c']]], ['tds_5fsend_5fcancel',['tds_send_cancel',['../a00533.html#ga11338742dc30fd0c2711f58eb830316f',1,'tds_send_cancel(TDSSOCKET *tds): query.c'],['../a00533.html#ga11338742dc30fd0c2711f58eb830316f',1,'tds_send_cancel(TDSSOCKET *tds): query.c']]], ['tds_5fsend_5femulated_5fexecute',['tds_send_emulated_execute',['../a00533.html#ga02c6ce3ff96369603a6ee4efee64caae',1,'query.c']]], ['tds_5fsend_5femulated_5frpc',['tds_send_emulated_rpc',['../a00533.html#gaf614c75ea8f7ad411e53dac0e2f91be4',1,'query.c']]], ['tds_5fset_5fcolumn_5ftype',['tds_set_column_type',['../a00260.html#a31604382d8b77257aad203f409155a29',1,'tds_set_column_type(TDSCONNECTION *conn, TDSCOLUMN *curcol, TDS_SERVER_TYPE type): data.c'],['../a00434.html#a31604382d8b77257aad203f409155a29',1,'tds_set_column_type(TDSCONNECTION *conn, TDSCOLUMN *curcol, TDS_SERVER_TYPE type): data.c']]], ['tds_5fset_5fcur_5fcursor',['tds_set_cur_cursor',['../a00533.html#ga34fb1084682cc31fe02a4a7946955a5a',1,'query.c']]], ['tds_5fset_5fcur_5fdyn',['tds_set_cur_dyn',['../a00533.html#gae8b7db85af16701fc0604eb117cbd4e4',1,'tds_set_cur_dyn(TDSSOCKET *tds, TDSDYNAMIC *dyn): query.c'],['../a00533.html#gae8b7db85af16701fc0604eb117cbd4e4',1,'tds_set_cur_dyn(TDSSOCKET *tds, TDSDYNAMIC *dyn): query.c']]], ['tds_5fset_5ficonv_5fname',['tds_set_iconv_name',['../a01342.html#a010ab1d181c8996f6a5984c9900eca6b',1,'iconv.c']]], ['tds_5fset_5finterfaces_5ffile_5floc',['tds_set_interfaces_file_loc',['../a00529.html#ga57cea6e376d7c2d28b811a5b0053210c',1,'tds_set_interfaces_file_loc(const char *interf): config.c'],['../a00529.html#ga57cea6e376d7c2d28b811a5b0053210c',1,'tds_set_interfaces_file_loc(const char *interfloc): config.c']]], ['tds_5fset_5fparam_5ftype',['tds_set_param_type',['../a00260.html#a86768d86059c5addf9a3f89edb1ef44e',1,'tds_set_param_type(TDSCONNECTION *conn, TDSCOLUMN *curcol, TDS_SERVER_TYPE type): data.c'],['../a00434.html#a86768d86059c5addf9a3f89edb1ef44e',1,'tds_set_param_type(TDSCONNECTION *conn, TDSCOLUMN *curcol, TDS_SERVER_TYPE type): data.c']]], ['tds_5fset_5fserver',['tds_set_server',['../a00434.html#a3ab8874994a0776acdaff797afdb710a',1,'login.c']]], ['tds_5fset_5fstate',['tds_set_state',['../a00434.html#a16db200d2281f76fe46fc1cbe37ca9df',1,'util.c']]], ['tds_5fskip_5fcomment',['tds_skip_comment',['../a00533.html#gaac7347ba9380d77d726648b85e9fab8f',1,'tds_skip_comment(const char *s): query.c'],['../a00533.html#gaac7347ba9380d77d726648b85e9fab8f',1,'tds_skip_comment(const char *s): query.c']]], ['tds_5fskip_5fcomment_5fucs2le',['tds_skip_comment_ucs2le',['../a00533.html#gab304fda9f325e852ba5c5252079d22e3',1,'query.c']]], ['tds_5fskip_5fquoted',['tds_skip_quoted',['../a00533.html#ga5dbe51ce9533218f2da23f69ff63dda4',1,'tds_skip_quoted(const char *s): query.c'],['../a00533.html#ga5dbe51ce9533218f2da23f69ff63dda4',1,'tds_skip_quoted(const char *s): query.c']]], ['tds_5fskip_5fquoted_5fucs2le',['tds_skip_quoted_ucs2le',['../a00533.html#ga2361ec4629aa0eac38f1702b03ed8185',1,'query.c']]], ['tds_5fsocket_5fread',['tds_socket_read',['../a00534.html#ga8560e2536fdcf8f1514d4fa14f90876c',1,'net.c']]], ['tds_5fsocket_5fset_5fnonblocking',['tds_socket_set_nonblocking',['../a00534.html#ga2a7429ff031f77023d1bf31339a266db',1,'tds_socket_set_nonblocking(TDS_SYS_SOCKET sock): net.c'],['../a00534.html#ga2a7429ff031f77023d1bf31339a266db',1,'tds_socket_set_nonblocking(TDS_SYS_SOCKET sock): net.c']]], ['tds_5fsocket_5fwrite',['tds_socket_write',['../a00534.html#gad6f81b48fbcfc18ce0b213dbbea47e30',1,'net.c']]], ['tds_5fstart_5fquery',['tds_start_query',['../a00533.html#ga0da385231bfa3dc49377e1fb2bea2c07',1,'tds_start_query(TDSSOCKET *tds, unsigned char packet_type): query.c'],['../a00533.html#ga0da385231bfa3dc49377e1fb2bea2c07',1,'tds_start_query(TDSSOCKET *tds, unsigned char packet_type): query.c']]], ['tds_5fstart_5fquery_5fhead',['tds_start_query_head',['../a00533.html#ga9ad2e6defce530a8778791cce0166ccd',1,'query.c']]], ['tds_5fstaticin_5fstream_5finit',['tds_staticin_stream_init',['../a01330.html#aa9e1e45f0305622dd6aed9f8fe158581',1,'stream.c']]], ['tds_5fstaticin_5fstream_5fread',['tds_staticin_stream_read',['../a01330.html#a76b02f1fa5b79dc7e1ef2651a9afe3f7',1,'stream.c']]], ['tds_5fstaticout_5fstream_5finit',['tds_staticout_stream_init',['../a01330.html#a9fe0d3799d2e3bde49b614c9d0c3785d',1,'stream.c']]], ['tds_5fstaticout_5fstream_5fwrite',['tds_staticout_stream_write',['../a01330.html#a1d92ebe06f18378ac17ccfd20db05126',1,'stream.c']]], ['tds_5fstrftime',['tds_strftime',['../a00530.html#ga8c9652e8b1f3e56a3289fd71b12cee1d',1,'tds_strftime(char *buf, size_t maxsize, const char *format, const TDSDATEREC *dr, int prec): convert.c'],['../a00530.html#ga8c9652e8b1f3e56a3289fd71b12cee1d',1,'tds_strftime(char *buf, size_t maxsize, const char *format, const TDSDATEREC *timeptr, int prec): convert.c']]], ['tds_5fstrndup',['tds_strndup',['../a00434.html#a1275e23db464803292b4c759c46621a6',1,'util.c']]], ['tds_5fsubmit_5fbegin_5ftran',['tds_submit_begin_tran',['../a00533.html#ga7bf3670d3d6dabed469b9eb117298079',1,'tds_submit_begin_tran(TDSSOCKET *tds): query.c'],['../a00533.html#ga7bf3670d3d6dabed469b9eb117298079',1,'tds_submit_begin_tran(TDSSOCKET *tds): query.c']]], ['tds_5fsubmit_5fcommit',['tds_submit_commit',['../a00533.html#ga530538c4c975524cf0b771a550fc94a3',1,'tds_submit_commit(TDSSOCKET *tds, int cont): query.c'],['../a00533.html#ga530538c4c975524cf0b771a550fc94a3',1,'tds_submit_commit(TDSSOCKET *tds, int cont): query.c']]], ['tds_5fsubmit_5fexecdirect',['tds_submit_execdirect',['../a00533.html#gae603aed795a4c5bb26ab159a11256996',1,'tds_submit_execdirect(TDSSOCKET *tds, const char *query, TDSPARAMINFO *params, TDSHEADERS *head): query.c'],['../a00533.html#gae603aed795a4c5bb26ab159a11256996',1,'tds_submit_execdirect(TDSSOCKET *tds, const char *query, TDSPARAMINFO *params, TDSHEADERS *head): query.c']]], ['tds_5fsubmit_5fexecute',['tds_submit_execute',['../a00533.html#ga3e7b4793c6f799fbc6c174f673bb5b32',1,'tds_submit_execute(TDSSOCKET *tds, TDSDYNAMIC *dyn): query.c'],['../a00533.html#ga3e7b4793c6f799fbc6c174f673bb5b32',1,'tds_submit_execute(TDSSOCKET *tds, TDSDYNAMIC *dyn): query.c']]], ['tds_5fsubmit_5foptioncmd',['tds_submit_optioncmd',['../a00533.html#gaf0da49585d39e99780a004ee2ca23479',1,'tds_submit_optioncmd(TDSSOCKET *tds, TDS_OPTION_CMD command, TDS_OPTION option, TDS_OPTION_ARG *param, TDS_INT param_size): query.c'],['../a00533.html#gaf0da49585d39e99780a004ee2ca23479',1,'tds_submit_optioncmd(TDSSOCKET *tds, TDS_OPTION_CMD command, TDS_OPTION option, TDS_OPTION_ARG *param, TDS_INT param_size): query.c']]], ['tds_5fsubmit_5fprepare',['tds_submit_prepare',['../a00533.html#ga74eb08c3a1c85be8ac9db428842c8b9d',1,'tds_submit_prepare(TDSSOCKET *tds, const char *query, const char *id, TDSDYNAMIC **dyn_out, TDSPARAMINFO *params): query.c'],['../a00533.html#ga74eb08c3a1c85be8ac9db428842c8b9d',1,'tds_submit_prepare(TDSSOCKET *tds, const char *query, const char *id, TDSDYNAMIC **dyn_out, TDSPARAMINFO *params): query.c']]], ['tds_5fsubmit_5fquery',['tds_submit_query',['../a00533.html#ga5a29ae7f99d089dc3cea85ec6ee5f3ab',1,'tds_submit_query(TDSSOCKET *tds, const char *query): query.c'],['../a00533.html#ga5a29ae7f99d089dc3cea85ec6ee5f3ab',1,'tds_submit_query(TDSSOCKET *tds, const char *query): query.c']]], ['tds_5fsubmit_5fquery_5fparams',['tds_submit_query_params',['../a00533.html#ga95e0fccedc459a4404f496eec74a369a',1,'tds_submit_query_params(TDSSOCKET *tds, const char *query, TDSPARAMINFO *params, TDSHEADERS *head): query.c'],['../a00533.html#ga95e0fccedc459a4404f496eec74a369a',1,'tds_submit_query_params(TDSSOCKET *tds, const char *query, TDSPARAMINFO *params, TDSHEADERS *head): query.c']]], ['tds_5fsubmit_5fqueryf',['tds_submit_queryf',['../a00533.html#gad695defcbf663b0023851a198206a772',1,'tds_submit_queryf(TDSSOCKET *tds, const char *queryf,...): query.c'],['../a00533.html#gad695defcbf663b0023851a198206a772',1,'tds_submit_queryf(TDSSOCKET *tds, const char *queryf,...): query.c']]], ['tds_5fsubmit_5frollback',['tds_submit_rollback',['../a00533.html#ga9c1cdcc388506a2ca3c0aaee8c461ba6',1,'tds_submit_rollback(TDSSOCKET *tds, int cont): query.c'],['../a00533.html#ga9c1cdcc388506a2ca3c0aaee8c461ba6',1,'tds_submit_rollback(TDSSOCKET *tds, int cont): query.c']]], ['tds_5fsubmit_5frpc',['tds_submit_rpc',['../a00533.html#ga5f071b94ad7889690762dc85646c74ab',1,'tds_submit_rpc(TDSSOCKET *tds, const char *rpc_name, TDSPARAMINFO *params, TDSHEADERS *head): query.c'],['../a00533.html#ga5f071b94ad7889690762dc85646c74ab',1,'tds_submit_rpc(TDSSOCKET *tds, const char *rpc_name, TDSPARAMINFO *params, TDSHEADERS *head): query.c']]], ['tds_5fsubmit_5funprepare',['tds_submit_unprepare',['../a00533.html#gaf573d8d4d2660c8c27770573fca05ff5',1,'tds_submit_unprepare(TDSSOCKET *tds, TDSDYNAMIC *dyn): query.c'],['../a00533.html#gaf573d8d4d2660c8c27770573fca05ff5',1,'tds_submit_unprepare(TDSSOCKET *tds, TDSDYNAMIC *dyn): query.c']]], ['tds_5fswap_5fnumeric',['tds_swap_numeric',['../a00260.html#aa818c1cbf4d16e609b7e4895cc7ed74f',1,'data.c']]], ['tds_5fsys_5ficonv_5fopen',['tds_sys_iconv_open',['../a00531.html#ga900b0bce08c6bfc2e7c988f4b5970516',1,'tds_sys_iconv_open(const char *tocode, const char *fromcode): iconv.c'],['../a00531.html#ga900b0bce08c6bfc2e7c988f4b5970516',1,'tds_sys_iconv_open(const char *tocode, const char *fromcode): iconv.c']]], ['tds_5ftimestamp_5fstr',['tds_timestamp_str',['../a00434.html#a9222a29979fcf3a660f9f4ca3cc494ee',1,'threadsafe.c']]], ['tds_5ftoken_5fname',['tds_token_name',['../a00536.html#ga7f24a7af985cd320788122e98072b7af',1,'token.c']]], ['tds_5funget_5fbyte',['tds_unget_byte',['../a00534.html#gad70d59fb317d098b0c9fd29dd77131a8',1,'tds_unget_byte(TDSSOCKET *tds): read.c'],['../a00534.html#gad70d59fb317d098b0c9fd29dd77131a8',1,'tds_unget_byte(TDSSOCKET *tds): read.c']]], ['tds_5fwillconvert',['tds_willconvert',['../a00530.html#ga80487b313213f60d8be71a50a002bb2c',1,'tds_willconvert(int srctype, int desttype): convert.c'],['../a00530.html#ga80487b313213f60d8be71a50a002bb2c',1,'tds_willconvert(int srctype, int desttype): convert.c']]], ['tds_5fwritetext_5fcontinue',['tds_writetext_continue',['../a00248.html#ab68dead99a2ebec55895a10cd3db5202',1,'tds_writetext_continue(TDSSOCKET *tds, const TDS_UCHAR *text, TDS_UINT size): bulk.c'],['../a00434.html#ab68dead99a2ebec55895a10cd3db5202',1,'tds_writetext_continue(TDSSOCKET *tds, const TDS_UCHAR *text, TDS_UINT size): bulk.c']]], ['tds_5fwritetext_5fend',['tds_writetext_end',['../a00248.html#ac1e460551f1188620ea478238864ac4b',1,'tds_writetext_end(TDSSOCKET *tds): bulk.c'],['../a00434.html#ac1e460551f1188620ea478238864ac4b',1,'tds_writetext_end(TDSSOCKET *tds): bulk.c']]], ['tds_5fwritetext_5fstart',['tds_writetext_start',['../a00248.html#a7711612cc544a7da2c7aa212b870acb2',1,'tds_writetext_start(TDSSOCKET *tds, const char *objname, const char *textptr, const char *timestamp, int with_log, TDS_UINT size): bulk.c'],['../a00434.html#a7711612cc544a7da2c7aa212b870acb2',1,'tds_writetext_start(TDSSOCKET *tds, const char *objname, const char *textptr, const char *timestamp, int with_log, TDS_UINT size): bulk.c']]], ['tdsdbopen',['tdsdbopen',['../a00524.html#ga2c99ec565452279e9a382451d89642eb',1,'tdsdbopen(LOGINREC *login, const char *server, int msdblib): dblib.c'],['../a00524.html#ga2c99ec565452279e9a382451d89642eb',1,'tdsdbopen(LOGINREC *login, const char *server, int msdblib): dblib.c']]], ['tdsdump_5fclose',['tdsdump_close',['../a00434.html#a2f00fc0907d3bb04ce0eeb9738e08d0c',1,'log.c']]], ['tdsdump_5fcol',['tdsdump_col',['../a00434.html#aaee3fe5c514ce5570c9548de9b16e0d9',1,'log.c']]], ['tdsdump_5fdump_5fbuf',['tdsdump_dump_buf',['../a00434.html#a79449d2f35a8acc8ed0585044f75524d',1,'log.c']]], ['tdsdump_5flog',['tdsdump_log',['../a00434.html#ab45c291105027e69836002e1dd586141',1,'log.c']]], ['tdsdump_5foff',['tdsdump_off',['../a00434.html#ac4dfaa4426d8a98bb1c74e46293eb4d1',1,'log.c']]], ['tdsdump_5fon',['tdsdump_on',['../a00434.html#a0bff83b40604dcc2e5d4f6f26256a96d',1,'log.c']]], ['tdsdump_5fopen',['tdsdump_open',['../a00434.html#a24471508ddfde7cc0f8577801e70c42f',1,'log.c']]], ['tdserror',['tdserror',['../a00434.html#abf18b98efef6ce2dc0b97d658a3a1918',1,'util.c']]] ]; freetds-1.00.82/doc/reference/search/functions_9.html100644 025423 025423 00000001773 13242511131 0016125
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/functions_9.js100644 025423 025423 00000000213 13242511131 0015561var searchData= [ ['unix_5fto_5fnt_5ftime',['unix_to_nt_time',['../a00528.html#ga73c98114ee9846fe7606de3862519e9d',1,'challenge.c']]] ]; freetds-1.00.82/doc/reference/search/variables_0.html100644 025423 025423 00000001773 13242511131 0016054
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/variables_0.js100644 025423 025423 00000000177 13242511131 0015521var searchData= [ ['allocated',['allocated',['../a01065.html#a9f32de09fe01879aeed23e858f3cef79',1,'tds_dynamic_stream']]] ]; freetds-1.00.82/doc/reference/search/variables_1.html100644 025423 025423 00000001773 13242511131 0016055
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/variables_1.js100644 025423 025423 00000001167 13242511131 0015522var searchData= [ ['bcp_5fprefix_5flen',['bcp_prefix_len',['../a01133.html#a07d747c0592ff37eb467ba14c4dcaeb2',1,'tds_column']]], ['block_5fsize',['block_size',['../a01161.html#aaad54522a6e04122eba4c37a200d3f20',1,'tds_env']]], ['buf',['buf',['../a01065.html#a1b4967f395da537910ded1b392dd5d9b',1,'tds_dynamic_stream']]], ['buffer',['buffer',['../a01045.html#a5ba4ad38fdcb68e7d0c7252be65a4ecc',1,'tds_output_stream']]], ['bulk_5fcopy',['bulk_copy',['../a01101.html#ad0d5f6fc4c5a5d64f11efd2e11ecaaa4',1,'tds_login']]], ['bulk_5fquery',['bulk_query',['../a01193.html#a8c44578d269fafd7249f43593958b0be',1,'tds_socket']]] ]; freetds-1.00.82/doc/reference/search/variables_2.html100644 025423 025423 00000001773 13242511131 0016056
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/variables_2.js100644 025423 025423 00000004202 13242511131 0015514var searchData= [ ['cafile',['cafile',['../a01101.html#ad12291abe6678aa30b8c43ab8e75429c',1,'tds_login']]], ['canonic',['canonic',['../a01121.html#aa9d3f1d6d994fcd5871ca41d7797ae95',1,'tds_encoding']]], ['cb',['cb',['../a00689.html#afc81c17990646fe0ed1c9cce5a917487',1,'tds_pbcb']]], ['char_5fconv',['char_conv',['../a01133.html#ab3afb8272401bdb51064cdf910334159',1,'tds_column']]], ['charset',['charset',['../a01161.html#a09756f0c4e0d588152c4dc3a8d019bcd',1,'tds_env']]], ['column_5fcur_5fsize',['column_cur_size',['../a01133.html#ada14ba479a67762fc1bef78910ef4beb',1,'tds_column']]], ['column_5fprec',['column_prec',['../a01133.html#a7ae346f8b1fdd364749825ca0863d166',1,'tds_column']]], ['column_5fscale',['column_scale',['../a01133.html#ab73b012b3a9f08da8661dc230ec17d7f',1,'tds_column']]], ['column_5fsize',['column_size',['../a01133.html#a2c2756c00a1099c82d4cfa4da2894672',1,'tds_column']]], ['column_5ftype',['column_type',['../a01133.html#a7f08ecedc5835a4e81129c6b2b493947',1,'tds_column']]], ['column_5fvarint_5fsize',['column_varint_size',['../a01133.html#a12914f03ee2f24fa3fe577060410770d',1,'tds_column']]], ['crlfile',['crlfile',['../a01101.html#a15808ea4c259a779c63732f8c1067c54',1,'tds_login']]], ['cur_5fcursor',['cur_cursor',['../a01193.html#aa708effeb88270302ab5524f0c0366ac',1,'tds_socket']]], ['cur_5fdyn',['cur_dyn',['../a01193.html#afb404985164205ebdc9b0c18fabb47e2',1,'tds_socket']]], ['current_5fresults',['current_results',['../a01193.html#a4b77fb56b92b93e413fcbb8ba5633ce4',1,'tds_socket']]], ['current_5fstatement',['current_statement',['../a00985.html#acaf05aab946ae9dec9e06dd230839675',1,'_hdbc']]], ['cursor_5fid',['cursor_id',['../a01157.html#a7b7d4cedf0cc7f890133f021d18af58c',1,'tds_cursor']]], ['cursor_5fname',['cursor_name',['../a01157.html#afd459125b5c4d4ccbf77a7d6ca8a4aaa',1,'tds_cursor']]], ['cursor_5frows',['cursor_rows',['../a01157.html#a7ec745adff5b2391e609e836c9f010cd',1,'tds_cursor']]], ['cursor_5fsupport',['cursor_support',['../a00985.html#ae45d3601984f4773024a81394764d28d',1,'_hdbc']]], ['cursors',['cursors',['../a01189.html#a42b972a1cd99c8f2f83b2cf5c635435a',1,'tds_connection']]] ]; freetds-1.00.82/doc/reference/search/variables_3.html100644 025423 025423 00000001773 13242511131 0016057
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/variables_3.js100644 025423 025423 00000002065 13242511131 0015522var searchData= [ ['database',['database',['../a01161.html#ad05b5a83816aee8ff9858ddb1eb172b8',1,'tds_env']]], ['date',['date',['../a01077.html#a4697c11cf7da815856eb96bae4d57bac',1,'TDS_DATETIMEALL::date()'],['../a01265.html#afa93266cde7ab536615bca3d904aabed',1,'DBDATETIMEALL::date()']]], ['day',['day',['../a01081.html#a82d0cf263d8d4a3abcf84b9a146ddf83',1,'tdsdaterec']]], ['dayofyear',['dayofyear',['../a01081.html#a3f7925156708744d28016aacb90b6093',1,'tdsdaterec']]], ['db_5ffilename',['db_filename',['../a01101.html#a425f8ddd194f897f185d9f4d5e0618c2',1,'tds_login']]], ['decimicrosecond',['decimicrosecond',['../a01081.html#a838e73fd12eec9e3b5368316198f4762',1,'tdsdaterec']]], ['defer_5fclose',['defer_close',['../a01157.html#a7a9dd4b827046f94f3d6a53035928d9c',1,'tds_cursor::defer_close()'],['../a01165.html#a0c0907ff62841056a9c1e023d68eb0f0',1,'tds_dynamic::defer_close()']]], ['dsn',['dsn',['../a00637.html#acd76726add649629f26f1f1754fe48cf',1,'DSNINFO']]], ['dyns',['dyns',['../a01189.html#a7dc98cfe507c626073b6e76985a06a8a',1,'tds_connection']]] ]; freetds-1.00.82/doc/reference/search/variables_4.html100644 025423 025423 00000001773 13242511131 0016060
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/variables_4.js100644 025423 025423 00000000321 13242511131 0015514var searchData= [ ['emulated',['emulated',['../a01165.html#ad3fedfbec2ba0db4a64b82779d95a0c5',1,'tds_dynamic']]], ['env',['env',['../a01189.html#a17b3352a5f14239b2eecc4fc272bfe2a',1,'tds_connection']]] ]; freetds-1.00.82/doc/reference/search/variables_5.html100644 025423 025423 00000001773 13242511131 0016061
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/variables_5.js100644 025423 025423 00000000323 13242511131 0015517var searchData= [ ['f',['f',['../a00693.html#a460a14dac0d298ff184e3cc67aafe91b',1,'tds_file_stream']]], ['from_5fmalloc',['from_malloc',['../a00689.html#ad483e0559eaa78104c4978667a0b739c',1,'tds_pbcb']]] ]; freetds-1.00.82/doc/reference/search/variables_6.html100644 025423 025423 00000001773 13242511131 0016062
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/variables_6.js100644 025423 025423 00000000324 13242511131 0015521var searchData= [ ['has_5fstatus',['has_status',['../a01193.html#a75ab58b901d242ae27e36bd39b23a54f',1,'tds_socket']]], ['hour',['hour',['../a01081.html#ae9f0348efe607ac7333eac841be46333',1,'tdsdaterec']]] ]; freetds-1.00.82/doc/reference/search/enums_0.js100644 025423 025423 00000000506 13242511131 0014674var searchData= [ ['tds_5fbcp_5fdirections',['tds_bcp_directions',['../a00434.html#ad5c5c8cb776334af4b0ebf7a0d740cb2',1,'tds.h']]], ['tds_5fend',['tds_end',['../a00434.html#aa8d8044be84bcde003f28ec25a77519c',1,'tds.h']]], ['tds_5fstates',['tds_states',['../a00434.html#a87cdae58f91ebe9229206bf0628f8e33',1,'tds.h']]] ]; freetds-1.00.82/doc/reference/search/variables_7.html100644 025423 025423 00000001773 13242511131 0016063
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/variables_7.js100644 025423 025423 00000001416 13242511131 0015525var searchData= [ ['id',['id',['../a01165.html#a72332750aee80a0a94c92b35d7263d76',1,'tds_dynamic']]], ['in_5fbuf',['in_buf',['../a01193.html#a24c1995f6e8d0f9a5990998524b00b6b',1,'tds_socket']]], ['in_5fcancel',['in_cancel',['../a01193.html#ae67d850cfbedf6b1e6b02111d4388d42',1,'tds_socket']]], ['in_5fflag',['in_flag',['../a01193.html#a765e007b69a2e188c989f05a689f6a11',1,'tds_socket']]], ['in_5flen',['in_len',['../a01193.html#a0b6e65b9d00b3a4efbf78b2d866cca20',1,'tds_socket']]], ['in_5fpos',['in_pos',['../a01193.html#a9d1b4fc8e1e801fdc703ee7bb68d9838',1,'tds_socket']]], ['in_5frow',['in_row',['../a01193.html#ab6a91be7f3b9966216e621c60e8151f2',1,'tds_socket']]], ['ip_5faddrs',['ip_addrs',['../a01101.html#a6e04f60eb1fae0e632ab6cddbb804a55',1,'tds_login']]] ]; freetds-1.00.82/doc/reference/search/variables_8.html100644 025423 025423 00000001773 13242511131 0016064
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/variables_8.js100644 025423 025423 00000000620 13242511131 0015522var searchData= [ ['left',['left',['../a00693.html#a3a7b329811d3ba3154aefa3b60ae1770',1,'tds_file_stream']]], ['login',['login',['../a00637.html#ad7ff73ac9d36bdb6dc6d6c8f8c6847bb',1,'DSNINFO::login()'],['../a01193.html#a00c22eeebbdb781ab7b9d5e8403e451e',1,'tds_socket::login()']]], ['login_5ftimeout',['login_timeout',['../a00585.html#a2da93c0f3681f87f94ad169deb09dc64',1,'dblib_context']]] ]; freetds-1.00.82/doc/reference/search/variables_9.html100644 025423 025423 00000001773 13242511131 0016065
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/variables_9.js100644 025423 025423 00000000464 13242511131 0015531var searchData= [ ['minute',['minute',['../a01081.html#a81d1931139497023deb1bb75dc0aae7a',1,'tdsdaterec']]], ['month',['month',['../a01081.html#af1542b5698f668f7df650b20fa27c177',1,'tdsdaterec']]], ['msdblib',['msdblib',['../a00901.html#af3aab1ff30d324143f440bcd9f60d1c3',1,'tds_dblib_dbprocess']]] ]; freetds-1.00.82/doc/reference/search/variables_a.html100644 025423 025423 00000001773 13242511131 0016135
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/variables_a.js100644 025423 025423 00000001465 13242511131 0015603var searchData= [ ['name',['name',['../a00749.html#aabc5f36785b65913edd51be1fd8ea1e3',1,'namelist::name()'],['../a01121.html#aa7152f00b01261e88db974cac1348c74',1,'tds_encoding::name()']]], ['new_5fpassword',['new_password',['../a01101.html#a90cffdbb528cddb0cf30d1f9de7c3e9c',1,'tds_login']]], ['next',['next',['../a00749.html#a3aaf5848cba17d39d5ea5bd180590bb3',1,'namelist::next()'],['../a00993.html#ad2152f527dcdd108165e7e03fe476b8f',1,'_hstmt::next()'],['../a01157.html#a8743877d9147d83ef0ae64e04c8a46fb',1,'tds_cursor::next()'],['../a01165.html#adc93b94b6b4caf15dcf45297d928a8da',1,'tds_dynamic::next()']]], ['nullreps',['nullreps',['../a00901.html#a2baeb464798b61d8da14887eb35d63e7',1,'tds_dblib_dbprocess']]], ['num_5fid',['num_id',['../a01165.html#af6fd2355838cce1689fb0e04724b7b6a',1,'tds_dynamic']]] ]; freetds-1.00.82/doc/reference/search/variables_b.html100644 025423 025423 00000001773 13242511131 0016136
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/variables_b.js100644 025423 025423 00000001434 13242511131 0015600var searchData= [ ['offset',['offset',['../a01077.html#a76f4cbcb3bc7c10b3616579ec7861f58',1,'TDS_DATETIMEALL::offset()'],['../a01265.html#a13159d738e1d0b582a3a731123feb5f3',1,'DBDATETIMEALL::offset()']]], ['options',['options',['../a01157.html#a1be9f69f84a6d83ce86380c33a2bf9f8',1,'tds_cursor']]], ['origdsn',['origdsn',['../a00637.html#a8127a82b8c4130820a4c44f88eda8bcf',1,'DSNINFO']]], ['out_5fbuf',['out_buf',['../a01193.html#ad6b5121e435d22d640a645b98833cb9d',1,'tds_socket']]], ['out_5fbuf_5fmax',['out_buf_max',['../a01193.html#ae6fc66be718f3211fac3b835557e330e',1,'tds_socket']]], ['out_5fflag',['out_flag',['../a01193.html#a9bb663ee7c71f56f1602cbfcd993018c',1,'tds_socket']]], ['out_5fpos',['out_pos',['../a01193.html#a426adbd80f29f477377e42e8f78d3ff0',1,'tds_socket']]] ]; freetds-1.00.82/doc/reference/search/variables_c.html100644 025423 025423 00000001773 13242511131 0016137
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/variables_c.js100644 025423 025423 00000002576 13242511131 0015611var searchData= [ ['param_5fcount',['param_count',['../a00993.html#a36e6cb901103834b074bf5a00fe7afbe',1,'_hstmt']]], ['param_5fnum',['param_num',['../a00993.html#a9b8cb8cb0826323811192adbed126348',1,'_hstmt']]], ['params',['params',['../a00993.html#aebe221315ae3dfd4850c399ad204ca4f',1,'_hstmt::params()'],['../a01165.html#adba427a655336d0b128cdec36544464b',1,'tds_dynamic::params()']]], ['password',['password',['../a01101.html#a411a965cbfdb05e69b6da62a30531bb2',1,'tds_login']]], ['pb',['pb',['../a00689.html#a616193286e91acc0a5dbe8942550e11e',1,'tds_pbcb']]], ['pending_5fclose',['pending_close',['../a01189.html#a824fd854618d7d2005f2bec452247be7',1,'tds_connection']]], ['port',['port',['../a01101.html#aec3fe0f3f17448018ae5c92cff3abb6d',1,'tds_login']]], ['prepared_5fpos',['prepared_pos',['../a00993.html#a937cc5e2c56a56cee0d57b8bb3c2f549',1,'_hstmt']]], ['prev',['prev',['../a00993.html#ad36ac281bcfcc5a6b6af0c1428b41d5f',1,'_hstmt']]], ['product_5fversion',['product_version',['../a01189.html#a7473cd879ba62019eb9d3bbb153832a1',1,'tds_connection']]], ['put_5fdata',['put_data',['../a01129.html#a09912b32c805bec7ab47080b42bf93a1',1,'tds_column_funcs']]], ['put_5finfo',['put_info',['../a01129.html#afed4993bb75cb37dfc7a6bcdb74820e2',1,'tds_column_funcs']]], ['put_5finfo_5flen',['put_info_len',['../a01129.html#a8da57c1e795fc9fb5d268b5fe690d9c3',1,'tds_column_funcs']]] ]; freetds-1.00.82/doc/reference/search/variables_d.html100644 025423 025423 00000001773 13242511131 0016140
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/variables_d.js100644 025423 025423 00000000736 13242511131 0015606var searchData= [ ['quarter',['quarter',['../a01081.html#aa0efc92bb0079287e043bb2c46c4603d',1,'tdsdaterec']]], ['query',['query',['../a00993.html#aaf4c8eb3163d2261ce6ce90118a70aec',1,'_hstmt::query()'],['../a01157.html#aeec2a01af48693b8b22449f15725d502',1,'tds_cursor::query()'],['../a01165.html#a1cee141e5f7045e691eec830cec1c158',1,'tds_dynamic::query()']]], ['query_5ftimeout',['query_timeout',['../a00585.html#abf71abb24c7afea7dd7ef440048ea4c9',1,'dblib_context']]] ]; freetds-1.00.82/doc/reference/search/variables_e.html100644 025423 025423 00000001773 13242511131 0016141
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/variables_e.js100644 025423 025423 00000002262 13242511131 0015603var searchData= [ ['read',['read',['../a01041.html#a2f0be7677a1bf9c730e3c697bfba21c9',1,'tds_input_stream']]], ['ref_5fcount',['ref_count',['../a00585.html#a812580afdfca53b6d54a7d09938c65c2',1,'dblib_context::ref_count()'],['../a01157.html#a692ccceff71d836df0d084ec26123c2d',1,'tds_cursor::ref_count()'],['../a01165.html#a2798c66fb3c8637c7fb29c6d1efebfa4',1,'tds_dynamic::ref_count()']]], ['res_5finfo',['res_info',['../a01165.html#ac736e163c0d4cdbca980a861214d99e7',1,'tds_dynamic']]], ['resinfo',['resinfo',['../a00581.html#ad49b82677ae277e5d5b0038f522da293',1,'dblib_buffer_row']]], ['ret_5fstatus',['ret_status',['../a01193.html#a355e0b8c6219908747f82cd7482c6efb',1,'tds_socket']]], ['row',['row',['../a00581.html#a015599345b266045d8bd3fac731e4675',1,'dblib_buffer_row']]], ['row_5fcount',['row_count',['../a00993.html#a8fd44f3c44ae4c83a1bdda0b73776ecd',1,'_hstmt']]], ['row_5fdata',['row_data',['../a00581.html#a5a057d6bbecfac1a85a9fbcd09eaf3a0',1,'dblib_buffer_row']]], ['row_5fstatus',['row_status',['../a00993.html#a41dd89b2dc41fe0e747580f6ea807063',1,'_hstmt']]], ['rows_5faffected',['rows_affected',['../a01193.html#a803e29dabc76d35227f5de2488f29877',1,'tds_socket']]] ]; freetds-1.00.82/doc/reference/search/variables_f.html100644 025423 025423 00000001773 13242511131 0016142
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/variables_f.js100644 025423 025423 00000002304 13242511131 0015601var searchData= [ ['s',['s',['../a01189.html#a4853be2466fd81c9463ac88f8da8b9c2',1,'tds_connection']]], ['second',['second',['../a01081.html#a8560717700de586f279af702bac86ad6',1,'tdsdaterec']]], ['send_5fpacket',['send_packet',['../a01193.html#a1c7c38af79f5845b90f19aaf5f63ce18',1,'tds_socket']]], ['server_5fcharset',['server_charset',['../a01101.html#a80dae8a766655c5c7365ba42d4d4d62c',1,'tds_login']]], ['server_5fname',['server_name',['../a01101.html#a69ed4cfded269727901bed2f95f1652e',1,'tds_login']]], ['server_5frealm_5fname',['server_realm_name',['../a01101.html#a1e5a5a13fa3cb0c5168d44187b52c814',1,'tds_login']]], ['server_5fspn',['server_spn',['../a01101.html#ad8d335a04cf09453a87a8e0b9118eaeb',1,'tds_login']]], ['size',['size',['../a01065.html#a9d221dd860f67d97daa71e107dce3470',1,'tds_dynamic_stream']]], ['sizes',['sizes',['../a00581.html#abe1aa9f8ea96dda1400654813e68130a',1,'dblib_buffer_row']]], ['status',['status',['../a01157.html#ab5d6a587ac5780f001d383d4b874852f',1,'tds_cursor']]], ['stmt_5flist',['stmt_list',['../a00985.html#a4a9f3e8f1eba573df79a1ed300d8fc91',1,'_hdbc']]], ['stream',['stream',['../a00693.html#abb6db59e849d11de92f4c55c61d51744',1,'tds_file_stream']]] ]; freetds-1.00.82/doc/reference/search/variables_10.html100644 025423 025423 00000001774 13242511131 0016136
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/variables_10.js100644 025423 025423 00000004132 13242511131 0015575var searchData= [ ['tds',['tds',['../a00993.html#ad357e33164f46fce2bc70267d71a1959',1,'_hstmt']]], ['tds_5fctx',['tds_ctx',['../a00585.html#afb3fb2d591c0f75b9412f8ca77e2629d',1,'dblib_context']]], ['tds_5fctx_5fref_5fcount',['tds_ctx_ref_count',['../a00585.html#ad01d901acbc92e8c369e6a6c784d7446',1,'dblib_context']]], ['tds_5fnumeric_5fbytes_5fper_5fprec',['tds_numeric_bytes_per_prec',['../a00434.html#a4da9eedb6322f7dfca89d5d89be7b374',1,'numeric.c']]], ['tds_5fstr_5fempty',['tds_str_empty',['../a00535.html#ga676fd3c5c489584d09c89d66c7a0af2d',1,'tds_str_empty(): tdsstring.c'],['../a00535.html#ga676fd3c5c489584d09c89d66c7a0af2d',1,'tds_str_empty(): tdsstring.c']]], ['tds_5fversion',['tds_version',['../a01101.html#a8f9f756b25fd18916a6080f9c22f835d',1,'tds_login']]], ['tds_5fwrite_5fdump',['tds_write_dump',['../a00434.html#a4766b1a553077cb3257d36b9ac28f5b5',1,'log.c']]], ['term_5flen',['term_len',['../a00693.html#aae893302d33ee1e9d83c3d85d7390dca',1,'tds_file_stream']]], ['terminator',['terminator',['../a00693.html#a463c28a7d862c0a6d7bf3170dd614dc0',1,'tds_file_stream']]], ['time',['time',['../a01077.html#afd6a58ec251f2c08a040917ba5a8cd3f',1,'TDS_DATETIMEALL::time()'],['../a01265.html#a6bb5dcd5b47813b71934546e0c60e035',1,'DBDATETIMEALL::time()']]], ['timezone',['timezone',['../a01081.html#a624e21e65d0ae89797b3a7eadc48829f',1,'tdsdaterec']]], ['tm_5fhour',['tm_hour',['../a00717.html#a6ece03e77f69035da83d5739e16ef905',1,'tds_time']]], ['tm_5fmday',['tm_mday',['../a00717.html#a8dfc26d484c247040f521f20288651f1',1,'tds_time']]], ['tm_5fmin',['tm_min',['../a00717.html#ab50f30e05dc6b493d347918ab7ded1e9',1,'tds_time']]], ['tm_5fmon',['tm_mon',['../a00717.html#adce28126e9bbd4ef005e3bf181d59745',1,'tds_time']]], ['tm_5fns',['tm_ns',['../a00717.html#a386f1cfcabbe3ed86afe72bed75778cf',1,'tds_time']]], ['tm_5fsec',['tm_sec',['../a00717.html#adeb5e3f535662c0341d28f8d669cb59b',1,'tds_time']]], ['tm_5fyear',['tm_year',['../a00717.html#a3e27d50ebb5196356a6a8a9b495c8758',1,'tds_time']]], ['type',['type',['../a01157.html#a889aafdde1d57c9be0585326022831f0',1,'tds_cursor']]] ]; freetds-1.00.82/doc/reference/search/variables_11.html100644 025423 025423 00000001774 13242511131 0016137
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/variables_11.js100644 025423 025423 00000000312 13242511131 0015572var searchData= [ ['uad',['uad',['../a00985.html#a93c0c73d7161aa0c8fd59016e66def9e',1,'_hdbc']]], ['user_5fname',['user_name',['../a01101.html#a2b2de13270472df39952848eb3970d9a',1,'tds_login']]] ]; freetds-1.00.82/doc/reference/search/variables_12.html100644 025423 025423 00000001774 13242511131 0016140
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/variables_12.js100644 025423 025423 00000000636 13242511131 0015604var searchData= [ ['waiters',['waiters',['../a00669.html#a009d30222683a3540fcddbc3e9033828',1,'tds_pool']]], ['weekday',['weekday',['../a01081.html#a40de0c7d78e9c1edae4c07435c10192b',1,'tdsdaterec']]], ['wire_5fsize',['wire_size',['../a01049.html#a8101abd3e9e8d6f90b2ba2717bf7f926',1,'tds_datain_stream']]], ['write',['write',['../a01045.html#a8513fb41c8ba79f22e54266b87278415',1,'tds_output_stream']]] ]; freetds-1.00.82/doc/reference/search/variables_13.html100644 025423 025423 00000001774 13242511131 0016141
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/variables_13.js100644 025423 025423 00000000155 13242511131 0015601var searchData= [ ['year',['year',['../a01081.html#a5a6a5b0180c3db53acbda61dd570d70f',1,'tdsdaterec']]] ]; freetds-1.00.82/doc/reference/search/typedefs_0.html100644 025423 025423 00000001772 13242511131 0015726
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/typedefs_0.js100644 025423 025423 00000000507 13242511131 0015371var searchData= [ ['dblib_5ferror_5fmessage',['DBLIB_ERROR_MESSAGE',['../a00524.html#ga73ccf3a130f836159e43074544f338e3',1,'dblib.c']]], ['dblibcontext',['DBLIBCONTEXT',['../a00077.html#ac34310fe36604ce96b30f66427b093ef',1,'dblib.c']]], ['dstr',['DSTR',['../a00434.html#afddddf5bd7ad223cadee3d3bdc899954',1,'tds.h']]] ]; freetds-1.00.82/doc/reference/search/typedefs_1.html100644 025423 025423 00000001772 13242511131 0015727
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/typedefs_1.js100644 025423 025423 00000002262 13242511131 0015372var searchData= [ ['tds_5fcompiletime_5fsettings',['TDS_COMPILETIME_SETTINGS',['../a00434.html#ab30e42bf2bf063932ecd1a8212f617f0',1,'tds.h']]], ['tds_5fencoding',['TDS_ENCODING',['../a00434.html#a6a0febfe3d78cb085172d18282a8cfaf',1,'tds.h']]], ['tds_5fstate',['TDS_STATE',['../a00434.html#a58f34a3a686a968357537c7486521b51',1,'tds.h']]], ['tdsblob',['TDSBLOB',['../a00434.html#a479425fecfdcd8e617b2b2e38d54b664',1,'tds.h']]], ['tdscursor',['TDSCURSOR',['../a00434.html#aad3739704ca49d8ebe445ca9b5e3b8b2',1,'tds.h']]], ['tdsdaterec',['TDSDATEREC',['../a00434.html#a2ab81f7a472558595c985c9c3f8c528e',1,'tds.h']]], ['tdsdynamic',['TDSDYNAMIC',['../a00434.html#a4a7511ca7305098f5bb111aa9214810b',1,'tds.h']]], ['tdsenv',['TDSENV',['../a00434.html#ab2c3d86ac695df335c70b088729853ae',1,'tds.h']]], ['tdsfilestream',['TDSFILESTREAM',['../a00248.html#a017b2e89d0641a6af2a84e3953574fb0',1,'bulk.c']]], ['tdspbcb',['TDSPBCB',['../a00248.html#a786e761d5de7ac54bff4a948e1dab4b6',1,'bulk.c']]], ['tdsresultinfo',['TDSRESULTINFO',['../a00434.html#a22c989e4b40c76c0bfb64c6610f4a8b6',1,'tds.h']]], ['tdsvariant',['TDSVARIANT',['../a00434.html#a7ef9511424cb9015043fa7e7da4efb74',1,'tds.h']]] ]; freetds-1.00.82/doc/reference/search/enums_0.html100644 025423 025423 00000001767 13242511131 0015236
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/enumvalues_0.html100644 025423 025423 00000001774 13242511131 0016271
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/enumvalues_0.js100644 025423 025423 00000003654 13242511131 0015740var searchData= [ ['tds_5fdead',['TDS_DEAD',['../a00434.html#a87cdae58f91ebe9229206bf0628f8e33af087b64970a1fb35bbcf1bc6ea7a643d',1,'tds.h']]], ['tds_5fdone_5fcancelled',['TDS_DONE_CANCELLED',['../a00434.html#aa8d8044be84bcde003f28ec25a77519ca202254cfd6784404cf1aa22bc7147c86',1,'tds.h']]], ['tds_5fdone_5fcount',['TDS_DONE_COUNT',['../a00434.html#aa8d8044be84bcde003f28ec25a77519caf17d0c6591e318014c806a10c2f0270b',1,'tds.h']]], ['tds_5fdone_5ferror',['TDS_DONE_ERROR',['../a00434.html#aa8d8044be84bcde003f28ec25a77519caa9d79a3b62e3321332223ac3d1a5b18d',1,'tds.h']]], ['tds_5fdone_5ffinal',['TDS_DONE_FINAL',['../a00434.html#aa8d8044be84bcde003f28ec25a77519ca7ed9046db24ad78bb94c2b12d6e11f46',1,'tds.h']]], ['tds_5fdone_5finxact',['TDS_DONE_INXACT',['../a00434.html#aa8d8044be84bcde003f28ec25a77519cac79a30d1a0bac125e77d87f5d87bc2b2',1,'tds.h']]], ['tds_5fdone_5fmore_5fresults',['TDS_DONE_MORE_RESULTS',['../a00434.html#aa8d8044be84bcde003f28ec25a77519ca688b8bf555ce6ae72f3e047177bfc966',1,'tds.h']]], ['tds_5fdone_5fproc',['TDS_DONE_PROC',['../a00434.html#aa8d8044be84bcde003f28ec25a77519cae170f368306f421d507c6f08e4d48d9a',1,'tds.h']]], ['tds_5fdone_5fsrverror',['TDS_DONE_SRVERROR',['../a00434.html#aa8d8044be84bcde003f28ec25a77519ca7bfe89d6f8fc309eae412ad0a503e34c',1,'tds.h']]], ['tds_5fidle',['TDS_IDLE',['../a00434.html#a87cdae58f91ebe9229206bf0628f8e33ad1586abc1f75b7f3d640b994afe310e9',1,'tds.h']]], ['tds_5fpending',['TDS_PENDING',['../a00434.html#a87cdae58f91ebe9229206bf0628f8e33a00f6d5ac5560f2f44661e599241849a8',1,'tds.h']]], ['tds_5freading',['TDS_READING',['../a00434.html#a87cdae58f91ebe9229206bf0628f8e33a36ddbc8f326d6b297009a8fafd958529',1,'tds.h']]], ['tds_5fsending',['TDS_SENDING',['../a00434.html#a87cdae58f91ebe9229206bf0628f8e33a2bad5be30bd85edc9495dae3d199d2c1',1,'tds.h']]], ['tds_5fwriting',['TDS_WRITING',['../a00434.html#a87cdae58f91ebe9229206bf0628f8e33a4a4fcc1840bee1e09521f08a0184d025',1,'tds.h']]] ]; freetds-1.00.82/doc/reference/search/defines_0.html100644 025423 025423 00000001771 13242511131 0015517
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/defines_0.js100644 025423 025423 00000000360 13242511131 0015160var searchData= [ ['dbtds_5funknown',['DBTDS_UNKNOWN',['../a00479.html#a4e19c79341755a7c6666197d381e1ac6',1,'sybdb.h']]], ['dbversion_5funknown',['DBVERSION_UNKNOWN',['../a00479.html#adbc038c5d57c0ab4c1c9e081a664dc0f',1,'sybdb.h']]] ]; freetds-1.00.82/doc/reference/search/defines_1.html100644 025423 025423 00000001771 13242511131 0015520
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/defines_1.js100644 025423 025423 00000000204 13242511131 0015156var searchData= [ ['is_5fdatetime_5ftype',['is_datetime_type',['../a00434.html#a4a70a4d36139165f8be99ea6fffb57ce',1,'tds.h']]] ]; freetds-1.00.82/doc/reference/search/defines_2.html100644 025423 025423 00000001771 13242511131 0015521
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/defines_2.js100644 025423 025423 00000001036 13242511131 0015163var searchData= [ ['tds_5fis_5fmssql',['TDS_IS_MSSQL',['../a00434.html#a07e9371c3e72b9e319f4c14e6fc2c20f',1,'tds.h']]], ['tds_5fis_5fsybase',['TDS_IS_SYBASE',['../a00434.html#a4840433488d0c66601ff4002a54b41d7',1,'tds.h']]], ['tds_5fms_5fver',['TDS_MS_VER',['../a00434.html#a1f5fb9d2184949ed566c8ce308a4e91e',1,'tds.h']]], ['tds_5fput_5ftinyint',['tds_put_tinyint',['../a00434.html#adfc186758f4c1856c01746b5436aff74',1,'tds.h']]], ['tds_5fsyb_5fver',['TDS_SYB_VER',['../a00434.html#aca53a637849948c4b7a07f69e40c685c',1,'tds.h']]] ]; freetds-1.00.82/doc/reference/search/groups_0.html100644 025423 025423 00000001770 13242511131 0015420
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/groups_0.js100644 025423 025423 00000000125 13242511131 0015061var searchData= [ ['authentication',['Authentication',['../a00528.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/groups_1.html100644 025423 025423 00000001770 13242511131 0015421
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/groups_1.js100644 025423 025423 00000000143 13242511131 0015062var searchData= [ ['bulk_20copy_20functions',['Bulk copy functions',['../a00520.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/groups_2.html100644 025423 025423 00000001770 13242511131 0015422
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/groups_2.js100644 025423 025423 00000000327 13242511131 0015067var searchData= [ ['configuration',['Configuration',['../a00529.html',1,'']]], ['charset_20conversion',['Charset conversion',['../a00531.html',1,'']]], ['conversion',['Conversion',['../a00530.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/groups_3.html100644 025423 025423 00000001770 13242511131 0015423
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/groups_3.js100644 025423 025423 00000000270 13242511131 0015065var searchData= [ ['datetime_20functions',['Datetime functions',['../a00523.html',1,'']]], ['dynamic_20string_20functions',['Dynamic string functions',['../a00535.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/groups_4.html100644 025423 025423 00000001770 13242511131 0015424
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/groups_4.js100644 025423 025423 00000000240 13242511131 0015063var searchData= [ ['internal_20bcp_20functions',['Internal bcp functions',['../a00521.html',1,'']]], ['internals',['Internals',['../a00524.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/groups_5.html100644 025423 025423 00000001770 13242511131 0015425
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/groups_5.js100644 025423 025423 00000000117 13242511131 0015067var searchData= [ ['libtds_20api',['LibTDS API',['../a00537.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/groups_6.html100644 025423 025423 00000001770 13242511131 0015426
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/groups_6.js100644 025423 025423 00000000242 13242511131 0015067var searchData= [ ['money_20functions',['Money functions',['../a00522.html',1,'']]], ['memory_20allocation',['Memory allocation',['../a00532.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/groups_7.html100644 025423 025423 00000001770 13242511131 0015427
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/groups_7.js100644 025423 025423 00000000135 13242511131 0015071var searchData= [ ['network_20functions',['Network functions',['../a00534.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/groups_8.html100644 025423 025423 00000001770 13242511131 0015430
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/groups_8.js100644 025423 025423 00000000212 13242511131 0015066var searchData= [ ['odbc_20api',['ODBC API',['../a00526.html',1,'']]], ['odbc_20utility',['ODBC utility',['../a00527.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/groups_9.html100644 025423 025423 00000001770 13242511131 0015431
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/groups_9.js100644 025423 025423 00000000135 13242511131 0015073var searchData= [ ['primary_20functions',['Primary functions',['../a00518.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/groups_a.html100644 025423 025423 00000001770 13242511131 0015501
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/groups_a.js100644 025423 025423 00000000103 13242511131 0015136var searchData= [ ['query',['Query',['../a00533.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/groups_b.html100644 025423 025423 00000001770 13242511131 0015502
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/groups_b.js100644 025423 025423 00000000274 13242511131 0015150var searchData= [ ['remote_20procedure_20functions',['Remote Procedure functions',['../a00519.html',1,'']]], ['results_20processing',['Results processing',['../a00536.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/groups_c.html100644 025423 025423 00000001770 13242511131 0015503
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/groups_c.js100644 025423 025423 00000000133 13242511131 0015143var searchData= [ ['the_20db_2dlib_20api',['The db-lib API',['../a00517.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/groups_d.html100644 025423 025423 00000001770 13242511131 0015504
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/groups_d.js100644 025423 025423 00000000123 13242511131 0015143var searchData= [ ['unimplemented',['Unimplemented',['../a00525.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/pages_0.html100644 025423 025423 00000001767 13242511131 0015206
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/pages_0.js100644 025423 025423 00000000113 13242511131 0014636var searchData= [ ['bug_20list',['Bug List',['../a00516.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/pages_1.html100644 025423 025423 00000001767 13242511131 0015207
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/pages_1.js100644 025423 025423 00000000154 13242511131 0014644var searchData= [ ['freetds_20reference_20manual',['FreeTDS Reference Manual',['../index.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/pages_2.html100644 025423 025423 00000001767 13242511131 0015210
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/pages_2.js100644 025423 025423 00000000155 13242511131 0014646var searchData= [ ['how_20to_20add_20a_20new_20type',['How to add a new type',['../a01298.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/pages_3.html100644 025423 025423 00000001767 13242511131 0015211
    Loading...
    Searching...
    No Matches
    freetds-1.00.82/doc/reference/search/pages_3.js100644 025423 025423 00000000115 13242511131 0014643var searchData= [ ['todo_20list',['Todo List',['../a00515.html',1,'']]] ]; freetds-1.00.82/doc/reference/search/searchdata.js100644 025423 025423 00000001212 13242511131 0015420var indexSectionsWithContent = { 0: "_abcdefhiklmnopqrstuwy", 1: "_abcdefklmnoprst", 2: "bdiprst", 3: "_abdoprstu", 4: "abcdefhilmnopqrstuwy", 5: "dt", 6: "t", 7: "t", 8: "dit", 9: "abcdilmnopqrtu", 10: "bfht" }; var indexSectionNames = { 0: "all", 1: "classes", 2: "files", 3: "functions", 4: "variables", 5: "typedefs", 6: "enums", 7: "enumvalues", 8: "defines", 9: "groups", 10: "pages" }; var indexSectionLabels = { 0: "All", 1: "Classes", 2: "Files", 3: "Functions", 4: "Variables", 5: "Typedefs", 6: "Enumerations", 7: "Enumerator", 8: "Macros", 9: "Modules", 10: "Pages" }; freetds-1.00.82/doc/reference/search/search.js100644 025423 025423 00000053155 13242511131 0014603function convertToId(search) { var result = ''; for (i=0;i do a search { this.Search(); } } this.OnSearchSelectKey = function(evt) { var e = (evt) ? evt : window.event; // for IE if (e.keyCode==40 && this.searchIndex0) // Up { this.searchIndex--; this.OnSelectItem(this.searchIndex); } else if (e.keyCode==13 || e.keyCode==27) { this.OnSelectItem(this.searchIndex); this.CloseSelectionWindow(); this.DOMSearchField().focus(); } return false; } // --------- Actions // Closes the results window. this.CloseResultsWindow = function() { this.DOMPopupSearchResultsWindow().style.display = 'none'; this.DOMSearchClose().style.display = 'none'; this.Activate(false); } this.CloseSelectionWindow = function() { this.DOMSearchSelectWindow().style.display = 'none'; } // Performs a search. this.Search = function() { this.keyTimeout = 0; // strip leading whitespace var searchValue = this.DOMSearchField().value.replace(/^ +/, ""); var code = searchValue.toLowerCase().charCodeAt(0); var idxChar = searchValue.substr(0, 1).toLowerCase(); if ( 0xD800 <= code && code <= 0xDBFF && searchValue > 1) // surrogate pair { idxChar = searchValue.substr(0, 2); } var resultsPage; var resultsPageWithSearch; var hasResultsPage; var idx = indexSectionsWithContent[this.searchIndex].indexOf(idxChar); if (idx!=-1) { var hexCode=idx.toString(16); resultsPage = this.resultsPath + '/' + indexSectionNames[this.searchIndex] + '_' + hexCode + '.html'; resultsPageWithSearch = resultsPage+'?'+escape(searchValue); hasResultsPage = true; } else // nothing available for this search term { resultsPage = this.resultsPath + '/nomatches.html'; resultsPageWithSearch = resultsPage; hasResultsPage = false; } window.frames.MSearchResults.location = resultsPageWithSearch; var domPopupSearchResultsWindow = this.DOMPopupSearchResultsWindow(); if (domPopupSearchResultsWindow.style.display!='block') { var domSearchBox = this.DOMSearchBox(); this.DOMSearchClose().style.display = 'inline'; if (this.insideFrame) { var domPopupSearchResults = this.DOMPopupSearchResults(); domPopupSearchResultsWindow.style.position = 'relative'; domPopupSearchResultsWindow.style.display = 'block'; var width = document.body.clientWidth - 8; // the -8 is for IE :-( domPopupSearchResultsWindow.style.width = width + 'px'; domPopupSearchResults.style.width = width + 'px'; } else { var domPopupSearchResults = this.DOMPopupSearchResults(); var left = getXPos(domSearchBox) + 150; // domSearchBox.offsetWidth; var top = getYPos(domSearchBox) + 20; // domSearchBox.offsetHeight + 1; domPopupSearchResultsWindow.style.display = 'block'; left -= domPopupSearchResults.offsetWidth; domPopupSearchResultsWindow.style.top = top + 'px'; domPopupSearchResultsWindow.style.left = left + 'px'; } } this.lastSearchValue = searchValue; this.lastResultsPage = resultsPage; } // -------- Activation Functions // Activates or deactivates the search panel, resetting things to // their default values if necessary. this.Activate = function(isActive) { if (isActive || // open it this.DOMPopupSearchResultsWindow().style.display == 'block' ) { this.DOMSearchBox().className = 'MSearchBoxActive'; var searchField = this.DOMSearchField(); if (searchField.value == this.searchLabel) // clear "Search" term upon entry { searchField.value = ''; this.searchActive = true; } } else if (!isActive) // directly remove the panel { this.DOMSearchBox().className = 'MSearchBoxInactive'; this.DOMSearchField().value = this.searchLabel; this.searchActive = false; this.lastSearchValue = '' this.lastResultsPage = ''; } } } // ----------------------------------------------------------------------- // The class that handles everything on the search results page. function SearchResults(name) { // The number of matches from the last run of . this.lastMatchCount = 0; this.lastKey = 0; this.repeatOn = false; // Toggles the visibility of the passed element ID. this.FindChildElement = function(id) { var parentElement = document.getElementById(id); var element = parentElement.firstChild; while (element && element!=parentElement) { if (element.nodeName == 'DIV' && element.className == 'SRChildren') { return element; } if (element.nodeName == 'DIV' && element.hasChildNodes()) { element = element.firstChild; } else if (element.nextSibling) { element = element.nextSibling; } else { do { element = element.parentNode; } while (element && element!=parentElement && !element.nextSibling); if (element && element!=parentElement) { element = element.nextSibling; } } } } this.Toggle = function(id) { var element = this.FindChildElement(id); if (element) { if (element.style.display == 'block') { element.style.display = 'none'; } else { element.style.display = 'block'; } } } // Searches for the passed string. If there is no parameter, // it takes it from the URL query. // // Always returns true, since other documents may try to call it // and that may or may not be possible. this.Search = function(search) { if (!search) // get search word from URL { search = window.location.search; search = search.substring(1); // Remove the leading '?' search = unescape(search); } search = search.replace(/^ +/, ""); // strip leading spaces search = search.replace(/ +$/, ""); // strip trailing spaces search = search.toLowerCase(); search = convertToId(search); var resultRows = document.getElementsByTagName("div"); var matches = 0; var i = 0; while (i < resultRows.length) { var row = resultRows.item(i); if (row.className == "SRResult") { var rowMatchName = row.id.toLowerCase(); rowMatchName = rowMatchName.replace(/^sr\d*_/, ''); // strip 'sr123_' if (search.length<=rowMatchName.length && rowMatchName.substr(0, search.length)==search) { row.style.display = 'block'; matches++; } else { row.style.display = 'none'; } } i++; } document.getElementById("Searching").style.display='none'; if (matches == 0) // no results { document.getElementById("NoMatches").style.display='block'; } else // at least one result { document.getElementById("NoMatches").style.display='none'; } this.lastMatchCount = matches; return true; } // return the first item with index index or higher that is visible this.NavNext = function(index) { var focusItem; while (1) { var focusName = 'Item'+index; focusItem = document.getElementById(focusName); if (focusItem && focusItem.parentNode.parentNode.style.display=='block') { break; } else if (!focusItem) // last element { break; } focusItem=null; index++; } return focusItem; } this.NavPrev = function(index) { var focusItem; while (1) { var focusName = 'Item'+index; focusItem = document.getElementById(focusName); if (focusItem && focusItem.parentNode.parentNode.style.display=='block') { break; } else if (!focusItem) // last element { break; } focusItem=null; index--; } return focusItem; } this.ProcessKeys = function(e) { if (e.type == "keydown") { this.repeatOn = false; this.lastKey = e.keyCode; } else if (e.type == "keypress") { if (!this.repeatOn) { if (this.lastKey) this.repeatOn = true; return false; // ignore first keypress after keydown } } else if (e.type == "keyup") { this.lastKey = 0; this.repeatOn = false; } return this.lastKey!=0; } this.Nav = function(evt,itemIndex) { var e = (evt) ? evt : window.event; // for IE if (e.keyCode==13) return true; if (!this.ProcessKeys(e)) return false; if (this.lastKey==38) // Up { var newIndex = itemIndex-1; var focusItem = this.NavPrev(newIndex); if (focusItem) { var child = this.FindChildElement(focusItem.parentNode.parentNode.id); if (child && child.style.display == 'block') // children visible { var n=0; var tmpElem; while (1) // search for last child { tmpElem = document.getElementById('Item'+newIndex+'_c'+n); if (tmpElem) { focusItem = tmpElem; } else // found it! { break; } n++; } } } if (focusItem) { focusItem.focus(); } else // return focus to search field { parent.document.getElementById("MSearchField").focus(); } } else if (this.lastKey==40) // Down { var newIndex = itemIndex+1; var focusItem; var item = document.getElementById('Item'+itemIndex); var elem = this.FindChildElement(item.parentNode.parentNode.id); if (elem && elem.style.display == 'block') // children visible { focusItem = document.getElementById('Item'+itemIndex+'_c0'); } if (!focusItem) focusItem = this.NavNext(newIndex); if (focusItem) focusItem.focus(); } else if (this.lastKey==39) // Right { var item = document.getElementById('Item'+itemIndex); var elem = this.FindChildElement(item.parentNode.parentNode.id); if (elem) elem.style.display = 'block'; } else if (this.lastKey==37) // Left { var item = document.getElementById('Item'+itemIndex); var elem = this.FindChildElement(item.parentNode.parentNode.id); if (elem) elem.style.display = 'none'; } else if (this.lastKey==27) // Escape { parent.searchBox.CloseResultsWindow(); parent.document.getElementById("MSearchField").focus(); } else if (this.lastKey==13) // Enter { return true; } return false; } this.NavChild = function(evt,itemIndex,childIndex) { var e = (evt) ? evt : window.event; // for IE if (e.keyCode==13) return true; if (!this.ProcessKeys(e)) return false; if (this.lastKey==38) // Up { if (childIndex>0) { var newIndex = childIndex-1; document.getElementById('Item'+itemIndex+'_c'+newIndex).focus(); } else // already at first child, jump to parent { document.getElementById('Item'+itemIndex).focus(); } } else if (this.lastKey==40) // Down { var newIndex = childIndex+1; var elem = document.getElementById('Item'+itemIndex+'_c'+newIndex); if (!elem) // last child, jump to parent next parent { elem = this.NavNext(itemIndex+1); } if (elem) { elem.focus(); } } else if (this.lastKey==27) // Escape { parent.searchBox.CloseResultsWindow(); parent.document.getElementById("MSearchField").focus(); } else if (this.lastKey==13) // Enter { return true; } return false; } } function setKeyActions(elem,action) { elem.setAttribute('onkeydown',action); elem.setAttribute('onkeypress',action); elem.setAttribute('onkeyup',action); } function setClassAttr(elem,attr) { elem.setAttribute('class',attr); elem.setAttribute('className',attr); } function createResults() { var results = document.getElementById("SRResults"); for (var e=0; e
    No Matches
    freetds-1.00.82/doc/reference/a00434_a0383d5dcb629582266a442f0f0dbd13a_icgraph.map100644 025423 025423 00000000354 13242511134 0021242 freetds-1.00.82/doc/reference/a00434_a0383d5dcb629582266a442f0f0dbd13a_icgraph.md5100644 025423 025423 00000000040 13242511133 0021141d822b975f833c12ff57ec27a47752bc5freetds-1.00.82/doc/reference/a00434_a0383d5dcb629582266a442f0f0dbd13a_icgraph.svg100644 025423 025423 00000003175 13242511136 0021272 tds_get_conversion_type Node17 tds_get_conversion_type Node18 tdsdump_col Node17->Node18 freetds-1.00.82/doc/reference/a00434_a16db200d2281f76fe46fc1cbe37ca9df_icgraph.map100644 025423 025423 00000001551 13242511134 0021553 freetds-1.00.82/doc/reference/a00434_a16db200d2281f76fe46fc1cbe37ca9df_icgraph.md5100644 025423 025423 00000000040 13242511133 0021452e17322585d954a5457fa3a1cb4d40d4bfreetds-1.00.82/doc/reference/a00434_a16db200d2281f76fe46fc1cbe37ca9df_icgraph.svg100644 025423 025423 00000011514 13242511136 0021577 tds_set_state Node35 tds_set_state Node36 tds_query_flush_packet Node35->Node36 Node38 tds_submit_rpc Node35->Node38 Node39 tds_writetext_continue Node35->Node39 Node40 tds_writetext_end Node35->Node40 Node37 tds_send_emulated_rpc Node36->Node37 freetds-1.00.82/doc/reference/a00434_a24471508ddfde7cc0f8577801e70c42f_icgraph.map100644 025423 025423 00000000542 13242511134 0021265 freetds-1.00.82/doc/reference/a00434_a24471508ddfde7cc0f8577801e70c42f_icgraph.md5100644 025423 025423 00000000040 13242511133 0021165237690c0638053bdc3c72a0ffa82cd12freetds-1.00.82/doc/reference/a00434_a24471508ddfde7cc0f8577801e70c42f_icgraph.svg100644 025423 025423 00000004501 13242511136 0021310 tdsdump_open Node242 tdsdump_open Node243 tdsdbopen Node242->Node243 Node244 dbopen Node243->Node244 freetds-1.00.82/doc/reference/a00434_a5eec23828b0610c58de248c4edb53879_cgraph.map100644 025423 025423 00000000343 13242511134 0021116 freetds-1.00.82/doc/reference/a00434_a5eec23828b0610c58de248c4edb53879_cgraph.md5100644 025423 025423 00000000040 13242511133 0021017f52ecb617b17f20675bba2c58607c362freetds-1.00.82/doc/reference/a00434_a5eec23828b0610c58de248c4edb53879_cgraph.svg100644 025423 025423 00000003173 13242511136 0021146 tds_bcp_start_copy_in Node13 tds_bcp_start_copy_in Node14 tdsdump_log Node13->Node14 freetds-1.00.82/doc/reference/a00434_a6fb8c78f678c0016c12096765ab2f5c1_icgraph.map100644 025423 025423 00000000333 13242511134 0021203 freetds-1.00.82/doc/reference/a00434_a6fb8c78f678c0016c12096765ab2f5c1_icgraph.md5100644 025423 025423 00000000040 13242511133 0021105657f12e085d9d135fcac32a820bd368efreetds-1.00.82/doc/reference/a00434_a6fb8c78f678c0016c12096765ab2f5c1_icgraph.svg100644 025423 025423 00000003154 13242511136 0021233 tds_get_homedir Node20 tds_get_homedir Node21 tds_get_home_file Node20->Node21 freetds-1.00.82/doc/reference/a00434_a7711612cc544a7da2c7aa212b870acb2_cgraph.map100644 025423 025423 00000000331 13242511134 0021125 freetds-1.00.82/doc/reference/a00434_a7711612cc544a7da2c7aa212b870acb2_cgraph.md5100644 025423 025423 00000000040 13242511133 0021031b9c5f3e419cf4381fc651ce175f96b5afreetds-1.00.82/doc/reference/a00434_a7711612cc544a7da2c7aa212b870acb2_cgraph.svg100644 025423 025423 00000003163 13242511136 0021157 tds_writetext_start Node51 tds_writetext_start Node52 tds_submit_queryf Node51->Node52 freetds-1.00.82/doc/reference/a00434_a8184311543c685f2ee0bcccfb725ca02_cgraph.map100644 025423 025423 00000000361 13242511134 0021150 freetds-1.00.82/doc/reference/a00434_a8184311543c685f2ee0bcccfb725ca02_cgraph.md5100644 025423 025423 00000000040 13242511133 00210512409c2860a8f0d59b0ba44aa9e226c95freetds-1.00.82/doc/reference/a00434_a8184311543c685f2ee0bcccfb725ca02_cgraph.svg100644 025423 025423 00000003174 13242511136 0021201 tds_bcp_fread Node3 tds_bcp_fread Node4 tds_file_stream_read Node3->Node4 freetds-1.00.82/doc/reference/a00434_a8208eef2a3974ae1f0cf3c8c8ab011ce_cgraph.map100644 025423 025423 00000000323 13242511134 0021371 freetds-1.00.82/doc/reference/a00434_a8208eef2a3974ae1f0cf3c8c8ab011ce_cgraph.md5100644 025423 025423 00000000040 13242511133 00212749867e9c2bd2cb49cdef5233d20ed703dfreetds-1.00.82/doc/reference/a00434_a8208eef2a3974ae1f0cf3c8c8ab011ce_cgraph.svg100644 025423 025423 00000003136 13242511136 0021422 tds_bcp_start Node10 tds_bcp_start Node11 tdsdump_log Node10->Node11 freetds-1.00.82/doc/reference/a00435.map100644 025423 025423 00000003101 13242511134 0013033 freetds-1.00.82/doc/reference/a00434_aaee3fe5c514ce5570c9548de9b16e0d9_cgraph.map100644 025423 025423 00000000654 13242511134 0021346 freetds-1.00.82/doc/reference/a00434_aaee3fe5c514ce5570c9548de9b16e0d9_cgraph.md5100644 025423 025423 00000000040 13242511133 0021242599fa8e4fc56b724ad1aae821f6321fcfreetds-1.00.82/doc/reference/a00434_aaee3fe5c514ce5570c9548de9b16e0d9_cgraph.svg100644 025423 025423 00000004722 13242511136 0021372 tdsdump_col Node54 tdsdump_col Node55 tds_prtype Node54->Node55 Node56 tds_get_conversion_type Node54->Node56 freetds-1.00.82/doc/reference/a00434_ab68dead99a2ebec55895a10cd3db5202_cgraph.map100644 025423 025423 00000000373 13242511134 0021403 freetds-1.00.82/doc/reference/a00434_ab68dead99a2ebec55895a10cd3db5202_cgraph.md5100644 025423 025423 00000000040 13242511133 0021301f3252b0f200a05983477cfa7e8088e74freetds-1.00.82/doc/reference/a00434_ab68dead99a2ebec55895a10cd3db5202_cgraph.svg100644 025423 025423 00000003222 13242511136 0021423 tds_writetext_continue Node45 tds_writetext_continue Node46 tds_set_state Node45->Node46 freetds-1.00.82/doc/reference/a00434_ac1e460551f1188620ea478238864ac4b_cgraph.map100644 025423 025423 00000000361 13242511134 0020663 freetds-1.00.82/doc/reference/a00434_ac1e460551f1188620ea478238864ac4b_cgraph.md5100644 025423 025423 00000000040 13242511133 002056486b1ffef98d4284146d1cac9fde8903efreetds-1.00.82/doc/reference/a00435.md5100644 025423 025423 00000000040 13242511133 001274126ab16f0b443cdab0c31f06326c397fcfreetds-1.00.82/doc/reference/a00434_ac1e460551f1188620ea478238864ac4b_cgraph.svg100644 025423 025423 00000003201 13242511136 0020703 tds_writetext_end Node48 tds_writetext_end Node49 tds_set_state Node48->Node49 freetds-1.00.82/doc/reference/a00434_ade7df2db455b61edc83819ad60edb339_cgraph.map100644 025423 025423 00000000321 13242511134 0021406 freetds-1.00.82/doc/reference/a00434_ade7df2db455b61edc83819ad60edb339_cgraph.md5100644 025423 025423 00000000040 13242511133 00213133b05f6145f9aafb5f8c7b5edbeb8c82afreetds-1.00.82/doc/reference/a00434_ade7df2db455b61edc83819ad60edb339_cgraph.svg100644 025423 025423 00000003126 13242511136 0021440 tds_bcp_done Node0 tds_bcp_done Node1 tdsdump_log Node0->Node1 freetds-1.00.82/doc/reference/a00435.svg100644 025423 025423 00000037377 13242511136 0013105 include/freetds/tds.h Node0 include/freetds/tds.h Node1 stdarg.h Node0->Node1 Node2 stdio.h Node0->Node2 Node3 time.h Node0->Node3 Node4 freetds/version.h Node0->Node4 Node5 tds_sysdep_public.h Node0->Node5 Node6 freetds/sysdep_private.h Node0->Node6 Node7 freetds/thread.h Node0->Node7 Node8 freetds/bool.h Node0->Node8 Node9 replacements.h Node0->Node9 Node11 freetds/pushvis.h Node0->Node11 Node12 freetds/popvis.h Node0->Node12 Node15 freetds/proto.h Node0->Node15 Node3->Node3 Node9->Node1 Node9->Node5 Node9->Node6 Node10 replacements/readpassphrase.h Node9->Node10 Node9->Node11 Node9->Node12 Node13 replacements/poll.h Node9->Node13 Node10->Node11 Node10->Node12 Node13->Node11 Node13->Node12 Node14 config.h Node13->Node14 freetds-1.00.82/doc/reference/a00436.map100644 025423 025423 00000002657 13242511134 0013053 freetds-1.00.82/doc/reference/a00436.md5100644 025423 025423 00000000040 13242511133 001274247b751123d1a671a4183511b26e803b3freetds-1.00.82/doc/reference/a00436.svg100644 025423 025423 00000022301 13242511136 0013063 include/freetds/tds.h Node16 include/freetds/tds.h Node17 src/dblib/dblib.c Node16->Node17 Node18 src/pool/pool.h Node16->Node18 Node19 src/replacements/iconv.c Node16->Node19 Node20 src/tds/bulk.c Node16->Node20 Node21 src/tds/data.c Node16->Node21 Node22 src/tds/iconv.c Node16->Node22 Node23 src/tds/read.c Node16->Node23 Node24 src/tds/stream.c Node16->Node24 Node25 src/tds/token.c Node16->Node25 Node26 include/ctlib.h Node16->Node26 Node27 include/freetds/odbc.h Node16->Node27 freetds-1.00.82/doc/reference/a00437_source.html100644 025423 025423 00000161710 13242511131 0014614 FreeTDS API: include/freetds/thread.h Source File
    FreeTDS API
    thread.h
    1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
    2  *
    3  * Copyright (C) 2005 Liam Widdowson
    4  * Copyright (C) 2010-2012 Frediano Ziglio
    5  *
    6  * This library is free software; you can redistribute it and/or
    7  * modify it under the terms of the GNU Library General Public
    8  * License as published by the Free Software Foundation; either
    9  * version 2 of the License, or (at your option) any later version.
    10  *
    11  * This library is distributed in the hope that it will be useful,
    12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    14  * Library General Public License for more details.
    15  *
    16  * You should have received a copy of the GNU Library General Public
    17  * License along with this library; if not, write to the
    18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    19  * Boston, MA 02111-1307, USA.
    20  */
    21 
    22 #ifndef TDSTHREAD_H
    23 #define TDSTHREAD_H 1
    24 
    25 #undef TDS_HAVE_MUTEX
    26 
    27 #if defined(_THREAD_SAFE) && defined(TDS_HAVE_PTHREAD_MUTEX)
    28 
    29 #include <pthread.h>
    30 
    31 #include <freetds/pushvis.h>
    32 
    33 typedef pthread_mutex_t tds_raw_mutex;
    34 #define TDS_RAW_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
    35 
    36 static inline void tds_raw_mutex_lock(tds_raw_mutex *mtx)
    37 {
    38  pthread_mutex_lock(mtx);
    39 }
    40 
    41 static inline int tds_raw_mutex_trylock(tds_raw_mutex *mtx)
    42 {
    43  return pthread_mutex_trylock(mtx);
    44 }
    45 
    46 static inline void tds_raw_mutex_unlock(tds_raw_mutex *mtx)
    47 {
    48  pthread_mutex_unlock(mtx);
    49 }
    50 
    51 static inline int tds_raw_mutex_init(tds_raw_mutex *mtx)
    52 {
    53  return pthread_mutex_init(mtx, NULL);
    54 }
    55 
    56 static inline void tds_raw_mutex_free(tds_raw_mutex *mtx)
    57 {
    58  pthread_mutex_destroy(mtx);
    59 }
    60 
    61 typedef pthread_cond_t tds_condition;
    62 
    63 int tds_raw_cond_init(tds_condition *cond);
    64 static inline int tds_raw_cond_destroy(tds_condition *cond)
    65 {
    66  return pthread_cond_destroy(cond);
    67 }
    68 static inline int tds_raw_cond_signal(tds_condition *cond)
    69 {
    70  return pthread_cond_signal(cond);
    71 }
    72 static inline int tds_raw_cond_wait(tds_condition *cond, tds_raw_mutex *mtx)
    73 {
    74  return pthread_cond_wait(cond, mtx);
    75 }
    76 int tds_raw_cond_timedwait(tds_condition *cond, tds_raw_mutex *mtx, int timeout_sec);
    77 
    78 #define TDS_HAVE_MUTEX 1
    79 
    80 typedef pthread_t tds_thread;
    81 typedef pthread_t tds_thread_id;
    82 typedef void *(*tds_thread_proc)(void *arg);
    83 #define TDS_THREAD_PROC_DECLARE(name, arg) \
    84  void *name(void *arg)
    85 
    86 static inline int tds_thread_create(tds_thread *ret, tds_thread_proc proc, void *arg)
    87 {
    88  return pthread_create(ret, NULL, proc, arg);
    89 }
    90 
    91 static inline int tds_thread_create_detached(tds_thread_proc proc, void *arg)
    92 {
    93  tds_thread th;
    94  int ret = pthread_create(&th, NULL, proc, arg);
    95  if (!ret)
    96  pthread_detach(th);
    97  return ret;
    98 }
    99 
    100 static inline int tds_thread_join(tds_thread th, void **ret)
    101 {
    102  return pthread_join(th, ret);
    103 }
    104 
    105 static inline tds_thread_id tds_thread_get_current_id(void)
    106 {
    107  return pthread_self();
    108 }
    109 
    110 static inline int tds_thread_is_current(tds_thread_id th)
    111 {
    112  return pthread_equal(th, pthread_self());
    113 }
    114 
    115 #include <freetds/popvis.h>
    116 
    117 #elif defined(_WIN32)
    118 
    119 struct ptw32_mcs_node_t_;
    120 
    121 typedef struct {
    122  struct ptw32_mcs_node_t_ *lock;
    123  LONG done;
    124  CRITICAL_SECTION crit;
    125 } tds_raw_mutex;
    126 
    127 #define TDS_RAW_MUTEX_INITIALIZER { NULL, 0 }
    128 
    129 static inline int
    130 tds_raw_mutex_init(tds_raw_mutex *mtx)
    131 {
    132  mtx->lock = NULL;
    133  mtx->done = 0;
    134  return 0;
    135 }
    136 
    137 void tds_win_mutex_lock(tds_raw_mutex *mutex);
    138 
    139 static inline void tds_raw_mutex_lock(tds_raw_mutex *mtx)
    140 {
    141  if ((mtx)->done)
    142  EnterCriticalSection(&(mtx)->crit);
    143  else
    144  tds_win_mutex_lock(mtx);
    145 }
    146 
    147 int tds_raw_mutex_trylock(tds_raw_mutex *mtx);
    148 
    149 static inline void tds_raw_mutex_unlock(tds_raw_mutex *mtx)
    150 {
    151  LeaveCriticalSection(&(mtx)->crit);
    152 }
    153 
    154 static inline void tds_raw_mutex_free(tds_raw_mutex *mtx)
    155 {
    156  if ((mtx)->done) {
    157  DeleteCriticalSection(&(mtx)->crit);
    158  (mtx)->done = 0;
    159  }
    160 }
    161 
    162 #define TDS_HAVE_MUTEX 1
    163 
    164 /* easy way, only single signal supported */
    165 typedef void *TDS_CONDITION_VARIABLE;
    166 typedef union {
    167  HANDLE ev;
    168  TDS_CONDITION_VARIABLE cv;
    169 } tds_condition;
    170 
    171 extern int (*tds_raw_cond_init)(tds_condition *cond);
    172 extern int (*tds_raw_cond_destroy)(tds_condition *cond);
    173 extern int (*tds_raw_cond_signal)(tds_condition *cond);
    174 extern int (*tds_raw_cond_timedwait)(tds_condition *cond, tds_raw_mutex *mtx, int timeout_sec);
    175 static inline int tds_raw_cond_wait(tds_condition *cond, tds_raw_mutex *mtx)
    176 {
    177  return tds_raw_cond_timedwait(cond, mtx, -1);
    178 }
    179 
    180 typedef HANDLE tds_thread;
    181 typedef DWORD tds_thread_id;
    182 typedef void *(WINAPI *tds_thread_proc)(void *arg);
    183 #define TDS_THREAD_PROC_DECLARE(name, arg) \
    184  void *WINAPI name(void *arg)
    185 
    186 static inline int tds_thread_create(tds_thread *ret, tds_thread_proc proc, void *arg)
    187 {
    188  *ret = CreateThread(NULL, 0, (DWORD (WINAPI *)(void*)) proc, arg, 0, NULL);
    189  return *ret != NULL ? 0 : 11 /* EAGAIN */;
    190 }
    191 
    192 static inline int tds_thread_create_detached(tds_thread_proc proc, void *arg)
    193 {
    194  HANDLE h = CreateThread(NULL, 0, (DWORD (WINAPI *)(void*)) proc, arg, 0, NULL);
    195  if (h)
    196  return 0;
    197  CloseHandle(h);
    198  return 11 /* EAGAIN */;
    199 }
    200 
    201 static inline int tds_thread_join(tds_thread th, void **ret)
    202 {
    203  if (WaitForSingleObject(th, INFINITE) == WAIT_OBJECT_0) {
    204  DWORD r;
    205  if (ret && GetExitCodeThread(th, &r))
    206  *ret = (void*) (((char*)0) + r);
    207 
    208  CloseHandle(th);
    209  return 0;
    210  }
    211  CloseHandle(th);
    212  return 22 /* EINVAL */;
    213 }
    214 
    215 static inline tds_thread_id tds_thread_get_current_id(void)
    216 {
    217  return GetCurrentThreadId();
    218 }
    219 
    220 static inline int tds_thread_is_current(tds_thread_id th)
    221 {
    222  return th == GetCurrentThreadId();
    223 }
    224 
    225 #else
    226 
    227 /* define noops as "successful" */
    228 typedef struct {
    229 } tds_raw_mutex;
    230 
    231 #define TDS_RAW_MUTEX_INITIALIZER {}
    232 
    233 static inline void tds_raw_mutex_lock(tds_raw_mutex *mtx)
    234 {
    235 }
    236 
    237 static inline int tds_raw_mutex_trylock(tds_raw_mutex *mtx)
    238 {
    239  return 0;
    240 }
    241 
    242 static inline void tds_raw_mutex_unlock(tds_raw_mutex *mtx)
    243 {
    244 }
    245 
    246 static inline int tds_raw_mutex_init(tds_raw_mutex *mtx)
    247 {
    248  return 0;
    249 }
    250 
    251 static inline void tds_raw_mutex_free(tds_raw_mutex *mtx)
    252 {
    253 }
    254 
    255 typedef struct {
    256 } tds_condition;
    257 
    258 static inline int tds_raw_cond_init(tds_condition *cond)
    259 {
    260  return 0;
    261 }
    262 static inline int tds_raw_cond_destroy(tds_condition *cond)
    263 {
    264  return 0;
    265 }
    266 #define tds_raw_cond_signal(cond) \
    267  FreeTDS_Condition_not_compiled
    268 
    269 #define tds_raw_cond_wait(cond, mtx) \
    270  FreeTDS_Condition_not_compiled
    271 
    272 #define tds_raw_cond_timedwait(cond, mtx, timeout_sec) \
    273  FreeTDS_Condition_not_compiled
    274 
    275 typedef struct {
    276 } tds_thread;
    277 typedef int tds_thread_id;
    278 
    279 typedef void *(*tds_thread_proc)(void *arg);
    280 #define TDS_THREAD_PROC_DECLARE(name, arg) \
    281  void *name(void *arg)
    282 
    283 #define tds_thread_create(ret, proc, arg) \
    284  FreeTDS_Thread_not_compiled
    285 
    286 #define tds_thread_create_detached(proc, arg) \
    287  FreeTDS_Thread_not_compiled
    288 
    289 #define tds_thread_join(th, ret) \
    290  FreeTDS_Thread_not_compiled
    291 
    292 static inline tds_thread_id tds_thread_get_current_id(void)
    293 {
    294  return 0;
    295 }
    296 
    297 static inline int tds_thread_is_current(tds_thread_id th)
    298 {
    299  return 1;
    300 }
    301 
    302 
    303 #endif
    304 
    305 #ifdef TDS_HAVE_MUTEX
    306 # define tds_cond_init tds_raw_cond_init
    307 # define tds_cond_destroy tds_raw_cond_destroy
    308 # define tds_cond_signal tds_raw_cond_signal
    309 # if !ENABLE_EXTRA_CHECKS
    310 # define TDS_MUTEX_INITIALIZER TDS_RAW_MUTEX_INITIALIZER
    311 # define tds_mutex tds_raw_mutex
    312 # define tds_mutex_lock tds_raw_mutex_lock
    313 # define tds_mutex_trylock tds_raw_mutex_trylock
    314 # define tds_mutex_unlock tds_raw_mutex_unlock
    315 # define tds_mutex_check_owned(mtx) do {} while(0)
    316 # define tds_mutex_init tds_raw_mutex_init
    317 # define tds_mutex_free tds_raw_mutex_free
    318 # define tds_cond_wait tds_raw_cond_wait
    319 # define tds_cond_timedwait tds_raw_cond_timedwait
    320 # else
    321 # include <assert.h>
    322 
    323 typedef struct tds_mutex
    324 {
    325  tds_raw_mutex mtx;
    326  volatile int locked;
    327  volatile tds_thread_id locked_by;
    328 } tds_mutex;
    329 
    330 # define TDS_MUTEX_INITIALIZER { TDS_RAW_MUTEX_INITIALIZER, 0 }
    331 
    332 static inline void tds_mutex_lock(tds_mutex *mtx)
    333 {
    334  assert(mtx);
    335  tds_raw_mutex_lock(&mtx->mtx);
    336  assert(!mtx->locked);
    337  mtx->locked = 1;
    338  mtx->locked_by = tds_thread_get_current_id();
    339 }
    340 
    341 static inline int tds_mutex_trylock(tds_mutex *mtx)
    342 {
    343  int ret;
    344  assert(mtx);
    345  ret = tds_raw_mutex_trylock(&mtx->mtx);
    346  if (!ret) {
    347  assert(!mtx->locked);
    348  mtx->locked = 1;
    349  mtx->locked_by = tds_thread_get_current_id();
    350  }
    351  return ret;
    352 }
    353 
    354 static inline void tds_mutex_unlock(tds_mutex *mtx)
    355 {
    356  assert(mtx && mtx->locked);
    357  mtx->locked = 0;
    358  tds_raw_mutex_unlock(&mtx->mtx);
    359 }
    360 
    361 static inline void tds_mutex_check_owned(tds_mutex *mtx)
    362 {
    363  int ret;
    364  assert(mtx);
    365  ret = tds_raw_mutex_trylock(&mtx->mtx);
    366  assert(ret);
    367  assert(mtx->locked);
    368  assert(tds_thread_is_current(mtx->locked_by));
    369 }
    370 
    371 static inline int tds_mutex_init(tds_mutex *mtx)
    372 {
    373  mtx->locked = 0;
    374  return tds_raw_mutex_init(&mtx->mtx);
    375 }
    376 
    377 static inline void tds_mutex_free(tds_mutex *mtx)
    378 {
    379  assert(mtx && !mtx->locked);
    380  tds_raw_mutex_free(&mtx->mtx);
    381 }
    382 
    383 static inline int tds_cond_wait(tds_condition *cond, tds_mutex *mtx)
    384 {
    385  int ret;
    386  assert(mtx && mtx->locked);
    387  mtx->locked = 0;
    388  ret = tds_raw_cond_wait(cond, &mtx->mtx);
    389  mtx->locked = 1;
    390  mtx->locked_by = tds_thread_get_current_id();
    391  return ret;
    392 }
    393 
    394 static inline int tds_cond_timedwait(tds_condition *cond, tds_mutex *mtx, int timeout_sec)
    395 {
    396  int ret;
    397  assert(mtx && mtx->locked);
    398  mtx->locked = 0;
    399  ret = tds_raw_cond_timedwait(cond, &mtx->mtx, timeout_sec);
    400  mtx->locked = 1;
    401  mtx->locked_by = tds_thread_get_current_id();
    402  return ret;
    403 }
    404 
    405 # endif
    406 #endif
    407 
    408 #endif
    Definition: thread.h:228
    Definition: thread.h:275
    Definition: thread.h:255
    Definition: ptw32_MCS_lock.c:97
    freetds-1.00.82/doc/reference/a00440_source.html100644 025423 025423 00000010276 13242511131 0014606 FreeTDS API: include/freetds/time.h Source File
    FreeTDS API
    time.h
    1 #if TIME_WITH_SYS_TIME
    2 # include <sys/time.h>
    3 # include <time.h>
    4 #else
    5 # if HAVE_SYS_TIME_H
    6 # include <sys/time.h>
    7 # else
    8 # include <time.h>
    9 # endif
    10 #endif
    11 
    freetds-1.00.82/doc/reference/a00443_source.html100644 025423 025423 00000047226 13242511131 0014616 FreeTDS API: include/freetds/tls.h Source File
    FreeTDS API
    tls.h
    1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
    2  * Copyright (C) 2015 Frediano Ziglio
    3  *
    4  * This library is free software; you can redistribute it and/or
    5  * modify it under the terms of the GNU Library General Public
    6  * License as published by the Free Software Foundation; either
    7  * version 2 of the License, or (at your option) any later version.
    8  *
    9  * This library is distributed in the hope that it will be useful,
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    12  * Library General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU Library General Public
    15  * License along with this library; if not, write to the
    16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    17  * Boston, MA 02111-1307, USA.
    18  */
    19 
    20 #ifndef _freetds_tls_h_
    21 #define _freetds_tls_h_
    22 
    23 #ifndef _tds_h_
    24 #error tds.h must be included before tls.h
    25 #endif
    26 
    27 #ifdef HAVE_GNUTLS
    28 # if defined(_THREAD_SAFE) && defined(TDS_HAVE_PTHREAD_MUTEX)
    29 # include <freetds/thread.h>
    30 # ifndef GNUTLS_USE_NETTLE
    31 # include <gcrypt.h>
    32 # endif
    33 # endif
    34 # include <gnutls/gnutls.h>
    35 # include <gnutls/x509.h>
    36 #elif defined(HAVE_OPENSSL)
    37 # include <openssl/ssl.h>
    38 # include <openssl/x509v3.h>
    39 #endif
    40 
    41 #include <freetds/pushvis.h>
    42 
    43 #if defined(HAVE_GNUTLS) || defined(HAVE_OPENSSL)
    44 TDSRET tds_ssl_init(TDSSOCKET *tds);
    45 void tds_ssl_deinit(TDSCONNECTION *conn);
    46 
    47 # ifdef HAVE_GNUTLS
    48 
    49 static inline int
    50 tds_ssl_pending(TDSCONNECTION *conn)
    51 {
    52  return gnutls_record_check_pending((gnutls_session_t) conn->tls_session);
    53 }
    54 
    55 static inline int
    56 tds_ssl_read(TDSCONNECTION *conn, unsigned char *buf, int buflen)
    57 {
    58  return gnutls_record_recv((gnutls_session_t) conn->tls_session, buf, buflen);
    59 }
    60 
    61 static inline int
    62 tds_ssl_write(TDSCONNECTION *conn, const unsigned char *buf, int buflen)
    63 {
    64  return gnutls_record_send((gnutls_session_t) conn->tls_session, buf, buflen);
    65 }
    66 # else
    67 
    68 static inline int
    69 tds_ssl_pending(TDSCONNECTION *conn)
    70 {
    71  return SSL_pending((SSL *) conn->tls_session);
    72 }
    73 
    74 static inline int
    75 tds_ssl_read(TDSCONNECTION *conn, unsigned char *buf, int buflen)
    76 {
    77  return SSL_read((SSL *) conn->tls_session, buf, buflen);
    78 }
    79 
    80 static inline int
    81 tds_ssl_write(TDSCONNECTION *conn, const unsigned char *buf, int buflen)
    82 {
    83  return SSL_write((SSL *) conn->tls_session, buf, buflen);
    84 }
    85 # endif
    86 #else
    87 static inline TDSRET
    88 tds_ssl_init(TDSSOCKET *tds)
    89 {
    90  return TDS_FAIL;
    91 }
    92 
    93 static inline void
    94 tds_ssl_deinit(TDSCONNECTION *conn)
    95 {
    96 }
    97 
    98 static inline int
    99 tds_ssl_pending(TDSCONNECTION *conn)
    100 {
    101  return 0;
    102 }
    103 
    104 static inline int
    105 tds_ssl_read(TDSCONNECTION *conn, unsigned char *buf, int buflen)
    106 {
    107  return -1;
    108 }
    109 
    110 static inline int
    111 tds_ssl_write(TDSCONNECTION *conn, const unsigned char *buf, int buflen)
    112 {
    113  return -1;
    114 }
    115 #endif
    116 
    117 #include <freetds/popvis.h>
    118 
    119 #endif /* _freetds_tls_h_ */
    Information for a server connection.
    Definition: tds.h:1174
    Definition: tds.h:1102
    freetds-1.00.82/doc/reference/a00446_source.html100644 025423 025423 00000016502 13242511131 0014612 FreeTDS API: include/freetds/version.h Source File
    FreeTDS API
    version.h
    1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
    2  * Copyright (C) 1998-1999 Brian Bruns
    3  *
    4  * This library is free software; you can redistribute it and/or
    5  * modify it under the terms of the GNU Library General Public
    6  * License as published by the Free Software Foundation; either
    7  * version 2 of the License, or (at your option) any later version.
    8  *
    9  * This library is distributed in the hope that it will be useful,
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    12  * Library General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU Library General Public
    15  * License along with this library; if not, write to the
    16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    17  * Boston, MA 02111-1307, USA.
    18  */
    19 
    20 #ifndef _tdsversion_h_
    21 #define _tdsversion_h_
    22 
    23 /* $Id: 9640daf619734147e3b5ff6a1dad56ad305ffa51 $ */
    24 
    25 #define TDS_VERSION_NO "freetds v1.00.82"
    26 
    27 #define TDS_VERSION_MAJOR 1
    28 #define TDS_VERSION_MINOR 00
    29 #define TDS_VERSION_SUBVERSION 82
    30 #define TDS_VERSION_BUILD_NUMBER 6638
    31 
    32 #endif
    freetds-1.00.82/doc/reference/a00449_source.html100644 025423 025423 00000016226 13242511131 0014620 FreeTDS API: include/hmac_md5.h Source File
    FreeTDS API
    hmac_md5.h
    1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
    2  * Copyright (C) 2008 Frediano Ziglio
    3  *
    4  * This library is free software; you can redistribute it and/or
    5  * modify it under the terms of the GNU Library General Public
    6  * License as published by the Free Software Foundation; either
    7  * version 2 of the License, or (at your option) any later version.
    8  *
    9  * This library is distributed in the hope that it will be useful,
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    12  * Library General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU Library General Public
    15  * License along with this library; if not, write to the
    16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    17  * Boston, MA 02111-1307, USA.
    18  */
    19 
    20 #ifndef _hmac_md5_h_
    21 #define _hmac_md5_h_
    22 
    23 #include <freetds/pushvis.h>
    24 void hmac_md5(const unsigned char key[16],
    25  const unsigned char* data, size_t data_len,
    26  unsigned char* digest);
    27 #include <freetds/popvis.h>
    28 
    29 #endif
    freetds-1.00.82/doc/reference/a00452_source.html100644 025423 025423 00000022161 13242511131 0014605 FreeTDS API: include/md4.h Source File
    FreeTDS API
    md4.h
    1 #ifndef MD4_H
    2 #define MD4_H
    3 
    4 #ifndef HAVE_NETTLE
    5 
    6 #include <freetds/pushvis.h>
    7 
    8 struct MD4Context
    9 {
    10  TDS_UINT buf[4];
    11  TDS_UINT8 bytes;
    12  unsigned char in[64];
    13 };
    14 
    15 void MD4Init(struct MD4Context *context);
    16 void MD4Update(struct MD4Context *context, unsigned char const *buf, size_t len);
    17 void MD4Final(struct MD4Context *context, unsigned char *digest);
    18 
    19 typedef struct MD4Context MD4_CTX;
    20 
    21 #include <freetds/popvis.h>
    22 
    23 #else
    24 
    25 #include <nettle/md4.h>
    26 
    27 typedef struct md4_ctx MD4_CTX;
    28 
    29 static inline void MD4Init(MD4_CTX *ctx)
    30 {
    31  nettle_md4_init(ctx);
    32 }
    33 
    34 static inline void MD4Update(MD4_CTX *ctx, unsigned char const *buf, size_t len)
    35 {
    36  nettle_md4_update(ctx, len, buf);
    37 }
    38 
    39 static inline void MD4Final(MD4_CTX *ctx, unsigned char *digest)
    40 {
    41  nettle_md4_digest(ctx, 16, digest);
    42 }
    43 
    44 
    45 #endif
    46 
    47 #endif /* !MD4_H */
    Definition: md4.h:8
    freetds-1.00.82/doc/reference/a00461.html100644 025423 025423 00000025632 13242511136 0013240 FreeTDS API: include/replacements/poll.h File Reference
    FreeTDS API
    poll.h File Reference

    Provide poll call where missing. More...

    #include <config.h>
    #include <freetds/pushvis.h>
    #include <freetds/popvis.h>
    Include dependency graph for poll.h:
    This graph shows which files directly or indirectly include this file:

    Go to the source code of this file.

    Classes

    struct  pollfd
     

    Macros

    #define _REPLACEMENTS_POLL_H
     
    #define FD_SETSIZE   OPEN_MAX
     
    #define poll(fds, nfds, timeout)   tds_poll(fds, nfds, timeout)
     
    #define POLLERR   0x0008
     
    #define POLLHUP   0x0010
     
    #define POLLIN   0x0001
     
    #define POLLNORM   POLLIN
     
    #define POLLNVAL   0x0020
     
    #define POLLOUT   0x0004
     
    #define POLLPRI   POLLIN
     
    #define POLLRDBAND   POLLIN
     
    #define POLLRDNORM   POLLIN
     
    #define POLLWRBAND   POLLOUT
     
    #define POLLWRNORM   POLLOUT
     

    Typedefs

    typedef struct pollfd pollfd_t
     

    Functions

    int tds_poll (struct pollfd fds[], int nfds, int timeout)
     

    Detailed Description

    Provide poll call where missing.

    freetds-1.00.82/doc/reference/a00455_source.html100644 025423 025423 00000022542 13242511131 0014613 FreeTDS API: include/md5.h Source File
    FreeTDS API
    md5.h
    1 #ifndef MD5_H
    2 #define MD5_H
    3 
    4 #ifndef HAVE_NETTLE
    5 
    6 #include <freetds/pushvis.h>
    7 
    8 struct MD5Context {
    9  TDS_UINT buf[4];
    10  TDS_UINT8 bytes;
    11  unsigned char in[64];
    12 };
    13 
    14 void MD5Init(struct MD5Context *context);
    15 void MD5Update(struct MD5Context *context, unsigned char const *buf, size_t len);
    16 void MD5Final(struct MD5Context *context, unsigned char *digest);
    17 
    18 /*
    19  * This is needed to make RSAREF happy on some MS-DOS compilers.
    20  */
    21 typedef struct MD5Context MD5_CTX;
    22 
    23 #include <freetds/popvis.h>
    24 
    25 #else
    26 
    27 #include <nettle/md5.h>
    28 
    29 typedef struct md5_ctx MD5_CTX;
    30 
    31 static inline void MD5Init(MD5_CTX *ctx)
    32 {
    33  nettle_md5_init(ctx);
    34 }
    35 
    36 static inline void MD5Update(MD5_CTX *ctx, unsigned char const *buf, size_t len)
    37 {
    38  nettle_md5_update(ctx, len, buf);
    39 }
    40 
    41 static inline void MD5Final(MD5_CTX *ctx, unsigned char *digest)
    42 {
    43  nettle_md5_digest(ctx, 16, digest);
    44 }
    45 
    46 #endif
    47 
    48 #endif /* !MD5_H */
    Definition: md5.h:8
    freetds-1.00.82/doc/reference/a00458_source.html100644 025423 025423 00000160717 13242511131 0014625 FreeTDS API: include/odbcss.h Source File
    FreeTDS API
    odbcss.h
    1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
    2  * Copyright (C) 2008 Frediano Ziglio
    3  *
    4  * This library is free software; you can redistribute it and/or
    5  * modify it under the terms of the GNU Library General Public
    6  * License as published by the Free Software Foundation; either
    7  * version 2 of the License, or (at your option) any later version.
    8  *
    9  * This library is distributed in the hope that it will be useful,
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    12  * Library General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU Library General Public
    15  * License along with this library; if not, write to the
    16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    17  * Boston, MA 02111-1307, USA.
    18  */
    19 
    20 #ifndef _odbcss_h_
    21 #define _odbcss_h_
    22 
    23 #ifdef TDSODBC_BCP
    24 #include <sql.h>
    25 #endif
    26 
    27 #ifdef __cplusplus
    28 extern "C" {
    29 #endif
    30 
    31 #define SQL_DIAG_SS_MSGSTATE (-1150)
    32 #define SQL_DIAG_SS_LINE (-1154)
    33 
    34 #define SQL_SOPT_SS_QUERYNOTIFICATION_TIMEOUT 1233
    35 #define SQL_SOPT_SS_QUERYNOTIFICATION_MSGTEXT 1234
    36 #define SQL_SOPT_SS_QUERYNOTIFICATION_OPTIONS 1235
    37 
    38 #ifndef SQL_SS_LENGTH_UNLIMITED
    39 #define SQL_SS_LENGTH_UNLIMITED 0
    40 #endif
    41 
    42 #ifndef SQL_COPT_SS_BASE
    43 #define SQL_COPT_SS_BASE 1200
    44 #endif
    45 
    46 #ifndef SQL_COPT_SS_MARS_ENABLED
    47 #define SQL_COPT_SS_MARS_ENABLED (SQL_COPT_SS_BASE+24)
    48 #endif
    49 
    50 #ifndef SQL_COPT_SS_OLDPWD
    51 #define SQL_COPT_SS_OLDPWD (SQL_COPT_SS_BASE+26)
    52 #endif
    53 
    54 #define SQL_INFO_FREETDS_TDS_VERSION 1300
    55 
    56 #ifndef SQL_MARS_ENABLED_NO
    57 #define SQL_MARS_ENABLED_NO 0
    58 #endif
    59 
    60 #ifndef SQL_MARS_ENABLED_YES
    61 #define SQL_MARS_ENABLED_YES 1
    62 #endif
    63 
    64 #ifndef SQL_SS_VARIANT
    65 #define SQL_SS_VARIANT (-150)
    66 #endif
    67 
    68 #ifndef SQL_SS_UDT
    69 #define SQL_SS_UDT (-151)
    70 #endif
    71 
    72 #ifndef SQL_SS_XML
    73 #define SQL_SS_XML (-152)
    74 #endif
    75 
    76 #ifndef SQL_SS_TABLE
    77 #define SQL_SS_TABLE (-153)
    78 #endif
    79 
    80 #ifndef SQL_SS_TIME2
    81 #define SQL_SS_TIME2 (-154)
    82 #endif
    83 
    84 #ifndef SQL_SS_TIMESTAMPOFFSET
    85 #define SQL_SS_TIMESTAMPOFFSET (-155)
    86 #endif
    87 
    88 /*
    89  * these types are used from conversion from client to server
    90  */
    91 #ifndef SQL_C_SS_TIME2
    92 #define SQL_C_SS_TIME2 (0x4000)
    93 #endif
    94 
    95 #ifndef SQL_C_SS_TIMESTAMPOFFSET
    96 #define SQL_C_SS_TIMESTAMPOFFSET (0x4001)
    97 #endif
    98 
    99 #ifndef SQL_CA_SS_BASE
    100 #define SQL_CA_SS_BASE 1200
    101 #endif
    102 
    103 #ifndef SQL_CA_SS_UDT_CATALOG_NAME
    104 #define SQL_CA_SS_UDT_CATALOG_NAME (SQL_CA_SS_BASE+18)
    105 #endif
    106 
    107 #ifndef SQL_CA_SS_UDT_SCHEMA_NAME
    108 #define SQL_CA_SS_UDT_SCHEMA_NAME (SQL_CA_SS_BASE+19)
    109 #endif
    110 
    111 #ifndef SQL_CA_SS_UDT_TYPE_NAME
    112 #define SQL_CA_SS_UDT_TYPE_NAME (SQL_CA_SS_BASE+20)
    113 #endif
    114 
    115 #ifndef SQL_CA_SS_UDT_ASSEMBLY_TYPE_NAME
    116 #define SQL_CA_SS_UDT_ASSEMBLY_TYPE_NAME (SQL_CA_SS_BASE+21)
    117 #endif
    118 
    119 #ifndef SQL_CA_SS_XML_SCHEMACOLLECTION_CATALOG_NAME
    120 #define SQL_CA_SS_XML_SCHEMACOLLECTION_CATALOG_NAME (SQL_CA_SS_BASE+22)
    121 #endif
    122 
    123 #ifndef SQL_CA_SS_XML_SCHEMACOLLECTION_SCHEMA_NAME
    124 #define SQL_CA_SS_XML_SCHEMACOLLECTION_SCHEMA_NAME (SQL_CA_SS_BASE+23)
    125 #endif
    126 
    127 #ifndef SQL_CA_SS_XML_SCHEMACOLLECTION_NAME
    128 #define SQL_CA_SS_XML_SCHEMACOLLECTION_NAME (SQL_CA_SS_BASE+24)
    129 #endif
    130 
    131 typedef struct tagSS_TIME2_STRUCT {
    132  SQLUSMALLINT hour;
    133  SQLUSMALLINT minute;
    134  SQLUSMALLINT second;
    135  SQLUINTEGER fraction;
    137 
    139  SQLSMALLINT year;
    140  SQLUSMALLINT month;
    141  SQLUSMALLINT day;
    142  SQLUSMALLINT hour;
    143  SQLUSMALLINT minute;
    144  SQLUSMALLINT second;
    145  SQLUINTEGER fraction;
    146  SQLSMALLINT timezone_hour;
    147  SQLSMALLINT timezone_minute;
    149 
    150 
    151 #ifdef TDSODBC_BCP
    152 
    153 #ifndef SUCCEED
    154 #define SUCCEED 1
    155 #endif
    156 #ifndef FAIL
    157 #define FAIL 0
    158 #endif
    159 
    160 #ifndef BCPKEEPIDENTITY
    161 #define BCPKEEPIDENTITY 8
    162 #endif
    163 #ifndef BCPHINTS
    164 #define BCPHINTS 6
    165 #endif
    166 
    167 #define BCP_DIRECTION_IN 1
    168 
    169 #define SQL_COPT_SS_BCP (SQL_COPT_SS_BASE+19)
    170 #define SQL_BCP_OFF 0
    171 #define SQL_BCP_ON 1
    172 
    173 #define SQL_COPT_TDSODBC_IMPL_BASE 1500
    174 #define SQL_COPT_TDSODBC_IMPL_BCP_INITA (SQL_COPT_TDSODBC_IMPL_BASE)
    175 #define SQL_COPT_TDSODBC_IMPL_BCP_CONTROL (SQL_COPT_TDSODBC_IMPL_BASE+1)
    176 #define SQL_COPT_TDSODBC_IMPL_BCP_COLPTR (SQL_COPT_TDSODBC_IMPL_BASE+2)
    177 #define SQL_COPT_TDSODBC_IMPL_BCP_SENDROW (SQL_COPT_TDSODBC_IMPL_BASE+3)
    178 #define SQL_COPT_TDSODBC_IMPL_BCP_BATCH (SQL_COPT_TDSODBC_IMPL_BASE+4)
    179 #define SQL_COPT_TDSODBC_IMPL_BCP_DONE (SQL_COPT_TDSODBC_IMPL_BASE+5)
    180 #define SQL_COPT_TDSODBC_IMPL_BCP_BIND (SQL_COPT_TDSODBC_IMPL_BASE+6)
    181 #define SQL_COPT_TDSODBC_IMPL_BCP_INITW (SQL_COPT_TDSODBC_IMPL_BASE+7)
    182 
    183 #define SQL_VARLEN_DATA -10
    184 
    185 /* copied from sybdb.h which was copied from tds.h */
    186 /* TODO find a much better way... */
    187 enum
    188 {
    189  BCP_TYPE_SQLCHAR = 47, /* 0x2F */
    190 #define BCP_TYPE_SQLCHAR BCP_TYPE_SQLCHAR
    191  BCP_TYPE_SQLVARCHAR = 39, /* 0x27 */
    192 #define BCP_TYPE_SQLVARCHAR BCP_TYPE_SQLVARCHAR
    193  BCP_TYPE_SQLINTN = 38, /* 0x26 */
    194 #define BCP_TYPE_SQLINTN BCP_TYPE_SQLINTN
    195  BCP_TYPE_SQLINT1 = 48, /* 0x30 */
    196 #define BCP_TYPE_SQLINT1 BCP_TYPE_SQLINT1
    197  BCP_TYPE_SQLINT2 = 52, /* 0x34 */
    198 #define BCP_TYPE_SQLINT2 BCP_TYPE_SQLINT2
    199  BCP_TYPE_SQLINT4 = 56, /* 0x38 */
    200 #define BCP_TYPE_SQLINT4 BCP_TYPE_SQLINT4
    201  BCP_TYPE_SQLINT8 = 127, /* 0x7F */
    202 #define BCP_TYPE_SQLINT8 BCP_TYPE_SQLINT8
    203  BCP_TYPE_SQLFLT8 = 62, /* 0x3E */
    204 #define BCP_TYPE_SQLFLT8 BCP_TYPE_SQLFLT8
    205  BCP_TYPE_SQLDATETIME = 61, /* 0x3D */
    206 #define BCP_TYPE_SQLDATETIME BCP_TYPE_SQLDATETIME
    207  BCP_TYPE_SQLBIT = 50, /* 0x32 */
    208 #define BCP_TYPE_SQLBIT BCP_TYPE_SQLBIT
    209  BCP_TYPE_SQLBITN = 104, /* 0x68 */
    210 #define BCP_TYPE_SQLBITN BCP_TYPE_SQLBITN
    211  BCP_TYPE_SQLTEXT = 35, /* 0x23 */
    212 #define BCP_TYPE_SQLTEXT BCP_TYPE_SQLTEXT
    213  BCP_TYPE_SQLNTEXT = 99, /* 0x63 */
    214 #define BCP_TYPE_SQLNTEXT BCP_TYPE_SQLNTEXT
    215  BCP_TYPE_SQLIMAGE = 34, /* 0x22 */
    216 #define BCP_TYPE_SQLIMAGE BCP_TYPE_SQLIMAGE
    217  BCP_TYPE_SQLMONEY4 = 122, /* 0x7A */
    218 #define BCP_TYPE_SQLMONEY4 BCP_TYPE_SQLMONEY4
    219  BCP_TYPE_SQLMONEY = 60, /* 0x3C */
    220 #define BCP_TYPE_SQLMONEY BCP_TYPE_SQLMONEY
    221  BCP_TYPE_SQLDATETIME4 = 58, /* 0x3A */
    222 #define BCP_TYPE_SQLDATETIME4 BCP_TYPE_SQLDATETIME4
    223  BCP_TYPE_SQLREAL = 59, /* 0x3B */
    224  BCP_TYPE_SQLFLT4 = 59, /* 0x3B */
    225 #define BCP_TYPE_SQLREAL BCP_TYPE_SQLREAL
    226 #define BCP_TYPE_SQLFLT4 BCP_TYPE_SQLFLT4
    227  BCP_TYPE_SQLBINARY = 45, /* 0x2D */
    228 #define BCP_TYPE_SQLBINARY BCP_TYPE_SQLBINARY
    229  BCP_TYPE_SQLVOID = 31, /* 0x1F */
    230 #define BCP_TYPE_SQLVOID BCP_TYPE_SQLVOID
    231  BCP_TYPE_SQLVARBINARY = 37, /* 0x25 */
    232 #define BCP_TYPE_SQLVARBINARY BCP_TYPE_SQLVARBINARY
    233  BCP_TYPE_SQLNUMERIC = 108, /* 0x6C */
    234 #define BCP_TYPE_SQLNUMERIC BCP_TYPE_SQLNUMERIC
    235  BCP_TYPE_SQLDECIMAL = 106, /* 0x6A */
    236 #define BCP_TYPE_SQLDECIMAL BCP_TYPE_SQLDECIMAL
    237  BCP_TYPE_SQLFLTN = 109, /* 0x6D */
    238 #define BCP_TYPE_SQLFLTN BCP_TYPE_SQLFLTN
    239  BCP_TYPE_SQLMONEYN = 110, /* 0x6E */
    240 #define BCP_TYPE_SQLMONEYN BCP_TYPE_SQLMONEYN
    241  BCP_TYPE_SQLDATETIMN = 111, /* 0x6F */
    242 #define BCP_TYPE_SQLDATETIMN BCP_TYPE_SQLDATETIMN
    243  BCP_TYPE_SQLNVARCHAR = 103, /* 0x67 */
    244 #define BCP_TYPE_SQLNVARCHAR BCP_TYPE_SQLNVARCHAR
    245  BCP_TYPE_SQLUNIQUEID = 36, /* 0x24 */
    246 #define BCP_TYPE_SQLUNIQUEID BCP_TYPE_SQLUNIQUEID
    247  BCP_TYPE_SQLDATETIME2 = 42, /* 0x2a */
    248 #define BCP_TYPE_SQLDATETIME2 BCP_TYPE_SQLDATETIME2
    249 };
    250 
    251 typedef struct
    252 {
    253  int dtdays;
    254  int dttime;
    255 } DBDATETIME;
    256 
    257 #ifdef _MSC_VER
    258 #define TDSODBC_INLINE __inline
    259 #else
    260 #define TDSODBC_INLINE __inline__
    261 #endif
    262 
    263 struct tdsodbc_impl_bcp_init_params
    264 {
    265  const void *tblname;
    266  const void *hfile;
    267  const void *errfile;
    268  int direction;
    269 };
    270 
    271 static TDSODBC_INLINE RETCODE SQL_API
    272 bcp_initA(HDBC hdbc, const char *tblname, const char *hfile, const char *errfile, int direction)
    273 {
    274  struct tdsodbc_impl_bcp_init_params params = {tblname, hfile, errfile, direction};
    275  return SQL_SUCCEEDED(SQLSetConnectAttr(hdbc, SQL_COPT_TDSODBC_IMPL_BCP_INITA, &params, SQL_IS_POINTER)) ? SUCCEED : FAIL;
    276 }
    277 
    278 static TDSODBC_INLINE RETCODE SQL_API
    279 bcp_initW(HDBC hdbc, const SQLWCHAR *tblname, const SQLWCHAR *hfile, const SQLWCHAR *errfile, int direction)
    280 {
    281  struct tdsodbc_impl_bcp_init_params params = {tblname, hfile, errfile, direction};
    282  return SQL_SUCCEEDED(SQLSetConnectAttr(hdbc, SQL_COPT_TDSODBC_IMPL_BCP_INITW, &params, SQL_IS_POINTER)) ? SUCCEED : FAIL;
    283 }
    284 
    285 struct tdsodbc_impl_bcp_control_params
    286 {
    287  int field;
    288  void *value;
    289 };
    290 
    291 static TDSODBC_INLINE RETCODE SQL_API
    292 bcp_control(HDBC hdbc, int field, void *value)
    293 {
    294  struct tdsodbc_impl_bcp_control_params params = {field, value};
    295  return SQL_SUCCEEDED(SQLSetConnectAttr(hdbc, SQL_COPT_TDSODBC_IMPL_BCP_CONTROL, &params, SQL_IS_POINTER)) ? SUCCEED : FAIL;
    296 }
    297 
    298 struct tdsodbc_impl_bcp_colptr_params
    299 {
    300  const unsigned char * colptr;
    301  int table_column;
    302 };
    303 
    304 static TDSODBC_INLINE RETCODE SQL_API
    305 bcp_colptr(HDBC hdbc, const unsigned char * colptr, int table_column)
    306 {
    307  struct tdsodbc_impl_bcp_colptr_params params = {colptr, table_column};
    308  return SQL_SUCCEEDED(SQLSetConnectAttr(hdbc, SQL_COPT_TDSODBC_IMPL_BCP_COLPTR, &params, SQL_IS_POINTER)) ? SUCCEED : FAIL;
    309 }
    310 
    311 static TDSODBC_INLINE RETCODE SQL_API
    312 bcp_sendrow(HDBC hdbc)
    313 {
    314  return SQL_SUCCEEDED(SQLSetConnectAttr(hdbc, SQL_COPT_TDSODBC_IMPL_BCP_SENDROW, NULL, SQL_IS_POINTER)) ? SUCCEED : FAIL;
    315 }
    316 
    317 struct tdsodbc_impl_bcp_batch_params
    318 {
    319  int rows;
    320 };
    321 
    322 static TDSODBC_INLINE int SQL_API
    323 bcp_batch(HDBC hdbc)
    324 {
    325  struct tdsodbc_impl_bcp_batch_params params = {-1};
    326  return SQL_SUCCEEDED(SQLSetConnectAttr(hdbc, SQL_COPT_TDSODBC_IMPL_BCP_BATCH, &params, SQL_IS_POINTER)) ? params.rows : -1;
    327 }
    328 
    329 struct tdsodbc_impl_bcp_done_params
    330 {
    331  int rows;
    332 };
    333 
    334 static TDSODBC_INLINE int SQL_API
    335 bcp_done(HDBC hdbc)
    336 {
    337  struct tdsodbc_impl_bcp_done_params params = {-1};
    338  return SQL_SUCCEEDED(SQLSetConnectAttr(hdbc, SQL_COPT_TDSODBC_IMPL_BCP_DONE, &params, SQL_IS_POINTER)) ? params.rows : -1;
    339 }
    340 
    341 struct tdsodbc_impl_bcp_bind_params
    342 {
    343  const unsigned char * varaddr;
    344  int prefixlen;
    345  int varlen;
    346  const unsigned char * terminator;
    347  int termlen;
    348  int vartype;
    349  int table_column;
    350 };
    351 
    352 static TDSODBC_INLINE RETCODE SQL_API
    353 bcp_bind(HDBC hdbc, const unsigned char * varaddr, int prefixlen, int varlen,
    354  const unsigned char * terminator, int termlen, int vartype, int table_column)
    355 {
    356  struct tdsodbc_impl_bcp_bind_params params = {varaddr, prefixlen, varlen, terminator, termlen, vartype, table_column};
    357  return SQL_SUCCEEDED(SQLSetConnectAttr(hdbc, SQL_COPT_TDSODBC_IMPL_BCP_BIND, &params, SQL_IS_POINTER)) ? SUCCEED : FAIL;
    358 }
    359 
    360 #ifdef UNICODE
    361 #define bcp_init bcp_initW
    362 #else
    363 #define bcp_init bcp_initA
    364 #endif
    365 
    366 #endif /* TDSODBC_BCP */
    367 
    368 #ifdef __cplusplus
    369 }
    370 #endif
    371 
    372 #endif /* _odbcss_h_ */
    RETCODE bcp_bind(DBPROCESS *dbproc, BYTE *varaddr, int prefixlen, DBINT varlen, BYTE *terminator, int termlen, int db_vartype, int table_column)
    Bind a program host variable to a database column.
    Definition: bcp.c:2028
    DBINT bcp_batch(DBPROCESS *dbproc)
    Commit a set of rows to the table.
    Definition: bcp.c:1959
    RETCODE bcp_control(DBPROCESS *dbproc, int field, DBINT value)
    Set BCP options for uploading a datafile.
    Definition: bcp.c:539
    Definition: odbcss.h:131
    RETCODE bcp_sendrow(DBPROCESS *dbproc)
    Write data in host variables to the table.
    Definition: bcp.c:1339
    DBINT bcp_done(DBPROCESS *dbproc)
    Conclude the transfer of data from program variables.
    Definition: bcp.c:1986
    Definition: odbcss.h:138
    RETCODE bcp_colptr(DBPROCESS *dbproc, BYTE *colptr, int table_column)
    Override bcp_bind() by pointing to a different host variable.
    Definition: bcp.c:661
    Definition: sybdb.h:294
    freetds-1.00.82/doc/reference/a00461_source.html100644 025423 025423 00000034277 13242511131 0014620 FreeTDS API: include/replacements/poll.h Source File
    FreeTDS API
    poll.h
    Go to the documentation of this file.
    1 
    5 #if !defined(_REPLACEMENTS_POLL_H) && !defined(HAVE_POLL)
    6 #define _REPLACEMENTS_POLL_H
    7 
    8 #include <config.h>
    9 
    10 #if HAVE_LIMITS_H
    11 #include <limits.h>
    12 #endif
    13 
    14 #if HAVE_SYS_SELECT_H
    15 #include <sys/select.h>
    16 #endif
    17 
    18 #if defined(_WIN32)
    19 #include <winsock2.h>
    20 #endif
    21 
    22 #if defined(__VMS)
    23 #include <time.h> /* FD_SETSIZE is in here */
    24 #endif
    25 
    26 #if !defined(FD_SETSIZE)
    27 # if !defined(OPEN_MAX)
    28 # error cannot establish FD_SETSIZE
    29 # endif
    30 #define FD_SETSIZE OPEN_MAX
    31 #endif
    32 
    33 #include <freetds/pushvis.h>
    34 
    35 #ifndef _WIN32
    36 /* poll flags */
    37 # define POLLIN 0x0001
    38 # define POLLOUT 0x0004
    39 # define POLLERR 0x0008
    40 
    41 /* synonyms */
    42 # define POLLNORM POLLIN
    43 # define POLLPRI POLLIN
    44 # define POLLRDNORM POLLIN
    45 # define POLLRDBAND POLLIN
    46 # define POLLWRNORM POLLOUT
    47 # define POLLWRBAND POLLOUT
    48 
    49 /* ignored */
    50 # define POLLHUP 0x0010
    51 # define POLLNVAL 0x0020
    52 typedef struct pollfd {
    53  int fd; /* file descriptor to poll */
    54  short events; /* events of interest on fd */
    55  short revents; /* events that occurred on fd */
    56 } pollfd_t;
    57 
    58 #else /* Windows */
    59 /*
    60  * Windows use different constants then Unix
    61  * Newer version have a WSAPoll which is equal to Unix poll
    62  */
    63 # if !defined(POLLRDNORM) && !defined(POLLWRNORM)
    64 # define POLLIN 0x0300
    65 # define POLLOUT 0x0010
    66 # define POLLERR 0x0001
    67 # define POLLRDNORM 0x0100
    68 # define POLLWRNORM 0x0010
    69 typedef struct pollfd {
    70  SOCKET fd; /* file descriptor to poll */
    71  short events; /* events of interest on fd */
    72  short revents; /* events that occurred on fd */
    73 } pollfd_t;
    74 # else
    75 typedef struct pollfd pollfd_t;
    76 # endif
    77 #endif
    78 
    79 #undef poll
    80 int tds_poll(struct pollfd fds[], int nfds, int timeout);
    81 #define poll(fds, nfds, timeout) tds_poll(fds, nfds, timeout)
    82 
    83 #include <freetds/popvis.h>
    84 
    85 #endif
    Definition: poll.h:52
    freetds-1.00.82/doc/reference/a00462.map100644 025423 025423 00000000640 13242511134 0013040 freetds-1.00.82/doc/reference/a00462.md5100644 025423 025423 00000000040 13242511133 0012741086cab9b4041748a0f8cdbaf70df08c9freetds-1.00.82/doc/reference/a00462.svg100644 025423 025423 00000006225 13242511136 0013071 include/replacements/poll.h Node0 include/replacements /poll.h Node1 config.h Node0->Node1 Node2 freetds/pushvis.h Node0->Node2 Node3 freetds/popvis.h Node0->Node3 freetds-1.00.82/doc/reference/a00463.map100644 025423 025423 00000003274 13242511134 0013047 freetds-1.00.82/doc/reference/a00463.md5100644 025423 025423 00000000040 13242511133 001274251eded2f23ef6923311b2265e5931d9ffreetds-1.00.82/doc/reference/a00463.svg100644 025423 025423 00000027410 13242511136 0013071 include/replacements/poll.h Node4 include/replacements /poll.h Node5 include/replacements.h Node4->Node5 Node6 src/dblib/dblib.c Node5->Node6 Node7 src/tds/bulk.c Node5->Node7 Node8 src/tds/token.c Node5->Node8 Node9 include/freetds/tds.h Node5->Node9 Node9->Node6 Node9->Node7 Node9->Node8 Node10 src/pool/pool.h Node9->Node10 Node11 src/replacements/iconv.c Node9->Node11 Node12 src/tds/data.c Node9->Node12 Node13 src/tds/iconv.c Node9->Node13 Node14 src/tds/read.c Node9->Node14 Node15 src/tds/stream.c Node9->Node15 Node16 include/ctlib.h Node9->Node16 Node17 include/freetds/odbc.h Node9->Node17 freetds-1.00.82/doc/reference/a00464_source.html100644 025423 025423 00000030426 13242511131 0014613 FreeTDS API: include/replacements/readpassphrase.h Source File
    FreeTDS API
    readpassphrase.h
    1 /* OPENBSD ORIGINAL: include/readpassphrase.h */
    2 
    3 /* $OpenBSD: readpassphrase.h,v 1.3 2002/06/28 12:32:22 millert Exp $ */
    4 
    5 /*
    6  * Copyright (c) 2000 Todd C. Miller <Todd.Miller@courtesan.com>
    7  * All rights reserved.
    8  *
    9  * Redistribution and use in source and binary forms, with or without
    10  * modification, are permitted provided that the following conditions
    11  * are met:
    12  * 1. Redistributions of source code must retain the above copyright
    13  * notice, this list of conditions and the following disclaimer.
    14  * 2. Redistributions in binary form must reproduce the above copyright
    15  * notice, this list of conditions and the following disclaimer in the
    16  * documentation and/or other materials provided with the distribution.
    17  * 3. The name of the author may not be used to endorse or promote products
    18  * derived from this software without specific prior written permission.
    19  *
    20  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
    21  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
    22  * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
    23  * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    24  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    25  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
    26  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
    27  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    28  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
    29  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    30  */
    31 
    32 #ifndef FREETDS_READPASSPHRASE_H_
    33 #define FREETDS_READPASSPHRASE_H_
    34 
    35 #ifdef HAVE_READPASSPHRASE
    36 
    37 # include <readpassphrase.h>
    38 
    39 #else /* !HAVE_READPASSPHRASE */
    40 
    41 #include <freetds/pushvis.h>
    42 
    43 #define RPP_ECHO_OFF 0x00 /* Turn off echo (default). */
    44 #define RPP_ECHO_ON 0x01 /* Leave echo on. */
    45 #define RPP_REQUIRE_TTY 0x02 /* Fail if there is no tty. */
    46 #define RPP_FORCELOWER 0x04 /* Force input to lower case. */
    47 #define RPP_FORCEUPPER 0x08 /* Force input to upper case. */
    48 #define RPP_SEVENBIT 0x10 /* Strip the high bit from input. */
    49 #define RPP_STDIN 0x20 /* Read from stdin, not /dev/tty */
    50 
    51 #undef readpassphrase
    52 char * tds_readpassphrase(const char *, char *, size_t, int);
    53 #define readpassphrase tds_readpassphrase
    54 
    55 #include <freetds/popvis.h>
    56 
    57 #endif /* !HAVE_READPASSPHRASE */
    58 
    59 #endif /* !FREETDS_READPASSPHRASE_H_ */
    freetds-1.00.82/doc/reference/a00467_source.html100644 025423 025423 00000074302 13242511131 0014617 FreeTDS API: include/replacements.h Source File
    FreeTDS API
    replacements.h
    1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
    2  * Copyright (C) 1998-1999 Brian Bruns
    3  *
    4  * This library is free software; you can redistribute it and/or
    5  * modify it under the terms of the GNU Library General Public
    6  * License as published by the Free Software Foundation; either
    7  * version 2 of the License, or (at your option) any later version.
    8  *
    9  * This library is distributed in the hope that it will be useful,
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    12  * Library General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU Library General Public
    15  * License along with this library; if not, write to the
    16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    17  * Boston, MA 02111-1307, USA.
    18  */
    19 
    20 #ifndef _replacements_h_
    21 #define _replacements_h_
    22 
    23 #include <stdarg.h>
    24 #include "tds_sysdep_public.h"
    25 #include <freetds/sysdep_private.h>
    26 
    27 #include <replacements/readpassphrase.h>
    28 
    29 /* these headers are needed for basename */
    30 #ifdef HAVE_STRING_H
    31 # include <string.h>
    32 #endif
    33 #ifdef HAVE_LIBGEN_H
    34 # include <libgen.h>
    35 #endif
    36 #ifdef HAVE_GETOPT_H
    37 # include <getopt.h>
    38 #endif
    39 
    40 #if !HAVE_POLL
    41 #include <replacements/poll.h>
    42 #endif /* !HAVE_POLL */
    43 
    44 #include <freetds/pushvis.h>
    45 
    46 #ifdef __cplusplus
    47 extern "C"
    48 {
    49 #endif
    50 
    51 #if !HAVE_ASPRINTF
    52 #undef asprintf
    53 int tds_asprintf(char **ret, const char *fmt, ...);
    54 #define asprintf tds_asprintf
    55 #endif /* !HAVE_ASPRINTF */
    56 
    57 #if !HAVE_VASPRINTF
    58 #undef vasprintf
    59 int tds_vasprintf(char **ret, const char *fmt, va_list ap);
    60 #define vasprintf tds_vasprintf
    61 #endif /* !HAVE_VASPRINTF */
    62 
    63 #if !HAVE_STRTOK_R
    64 /* Some MingW define strtok_r macro thread-safe but not reentrant but we
    65  need both so avoid using the macro */
    66 #undef strtok_r
    67 char *tds_strtok_r(char *str, const char *sep, char **lasts);
    68 #define strtok_r tds_strtok_r
    69 #endif /* !HAVE_STRTOK_R */
    70 
    71 #if !HAVE_STRSEP
    72 #undef strsep
    73 char *tds_strsep(char **stringp, const char *delim);
    74 #define strsep tds_strsep
    75 #endif /* !HAVE_STRSEP */
    76 
    77 #if !HAVE_STRLCPY
    78 size_t tds_strlcpy(char *dest, const char *src, size_t len);
    79 #undef strlcpy
    80 #define strlcpy(d,s,l) tds_strlcpy(d,s,l)
    81 #endif
    82 
    83 #if !HAVE_GETADDRINFO
    84 typedef struct tds_addrinfo {
    85  int ai_flags;
    86  int ai_family;
    87  int ai_socktype;
    88  int ai_protocol;
    89  size_t ai_addrlen;
    90  struct sockaddr *ai_addr;
    91  char *ai_canonname;
    92  struct tds_addrinfo *ai_next;
    93 } tds_addrinfo;
    94 
    95 int tds_getaddrinfo(const char *node, const char *service, const struct tds_addrinfo *hints, struct tds_addrinfo **res);
    96 int tds_getnameinfo(const struct sockaddr *sa, size_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags);
    97 void tds_freeaddrinfo(struct tds_addrinfo *addr);
    98 #define addrinfo tds_addrinfo
    99 #define getaddrinfo(n,s,h,r) tds_getaddrinfo(n,s,h,r)
    100 #define getnameinfo(a,b,c,d,e,f,g) tds_getnameinfo(a,b,c,d,e,f,g)
    101 #define freeaddrinfo(a) tds_freeaddrinfo(a)
    102 #endif
    103 
    104 #ifndef AI_FQDN
    105 #define AI_FQDN 0
    106 #endif
    107 
    108 #if !HAVE_STRLCAT
    109 size_t tds_strlcat(char *dest, const char *src, size_t len);
    110 #undef strlcat
    111 #define strlcat(d,s,l) tds_strlcat(d,s,l)
    112 #endif
    113 
    114 #if !HAVE_BASENAME
    115 char *tds_basename(char *path);
    116 #define basename(path) tds_basename(path)
    117 #endif
    118 
    119 /*
    120  * Microsoft's C Runtime library is missing strcasecmp and strncasecmp.
    121  * Other Win32 C runtime libraries, notably minwg, may define it.
    122  * There is no symbol uniquely defined in Microsoft's header files that
    123  * can be used by the preprocessor to know whether we're compiling for
    124  * Microsoft's library or not (or which version). Thus there's no
    125  * way to automatically decide whether or not to define strcasecmp
    126  * in terms of stricmp.
    127  *
    128  * The Microsoft *compiler* defines _MSC_VER. On the assumption that
    129  * anyone using their compiler is also using their library, the below
    130  * tests check _MSC_VER as a proxy.
    131  */
    132 #if defined(_WIN32)
    133 # if !defined(strcasecmp) && defined(_MSC_VER)
    134 # define strcasecmp(A, B) stricmp((A), (B))
    135 # endif
    136 # if !defined(strncasecmp) && defined(_MSC_VER)
    137 # define strncasecmp(x,y,z) strnicmp((x),(y),(z))
    138 # endif
    139 
    140 #undef gettimeofday
    141 int tds_gettimeofday (struct timeval *tv, void *tz);
    142 #define gettimeofday tds_gettimeofday
    143 
    144 /* Older Mingw-w64 versions don't define these flags. */
    145 #if defined(__MINGW32__) && !defined(AI_ADDRCONFIG)
    146 # define AI_ADDRCONFIG 0x00000400
    147 #endif
    148 #if defined(__MINGW32__) && !defined(AI_V4MAPPED)
    149 # define AI_V4MAPPED 0x00000800
    150 #endif
    151 
    152 #endif
    153 
    154 #if !HAVE_GETOPT
    155 #undef getopt
    156 int tds_getopt(int argc, char * const argv[], const char *optstring);
    157 #define getopt tds_getopt
    158 
    159 extern char *optarg;
    160 extern int optind, offset, opterr, optreset;
    161 #endif
    162 
    163 #if !HAVE_SOCKETPAIR
    164 int tds_socketpair(int domain, int type, int protocol, TDS_SYS_SOCKET sv[2]);
    165 #define socketpair(d,t,p,s) tds_socketpair(d,t,p,s)
    166 #endif
    167 
    168 #if !HAVE_DAEMON
    169 int tds_daemon(int no_chdir, int no_close);
    170 #define daemon(d,c) tds_daemon(d,c)
    171 #endif
    172 
    173 char *tds_getpassarg(char *arg);
    174 void tds_sleep_s(unsigned sec);
    175 void tds_sleep_ms(unsigned ms);
    176 
    177 #ifdef __cplusplus
    178 }
    179 #endif
    180 
    181 #include <freetds/popvis.h>
    182 
    183 #endif
    Provide poll call where missing.
    Definition: replacements.h:84
    freetds-1.00.82/doc/reference/a00470_source.html100644 025423 025423 00000070615 13242511131 0014614 FreeTDS API: include/sqldb.h Source File
    FreeTDS API
    sqldb.h
    1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
    2  * Copyright (C) 1998-1999 Brian Bruns
    3  *
    4  * This library is free software; you can redistribute it and/or
    5  * modify it under the terms of the GNU Library General Public
    6  * License as published by the Free Software Foundation; either
    7  * version 2 of the License, or (at your option) any later version.
    8  *
    9  * This library is distributed in the hope that it will be useful,
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    12  * Library General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU Library General Public
    15  * License along with this library; if not, write to the
    16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    17  * Boston, MA 02111-1307, USA.
    18  */
    19 
    20 #ifndef SQLDB_h
    21 #define SQLDB_h
    22 
    23 #include "./sybdb.h"
    24 
    25 #define SQLCHAR SYBCHAR
    26 #define SQLVARCHAR SYBVARCHAR
    27 #define SQLINTN SYBINTN
    28 #define SQLINT1 SYBINT1
    29 #define SQLINT2 SYBINT2
    30 #define SQLINT4 SYBINT4
    31 #define SQLINT8 SYBINT8
    32 #define SQLFLT8 SYBFLT8
    33 #define SQLDATETIME SYBDATETIME
    34 #define SQLBIT SYBBIT
    35 #define SQLTEXT SYBTEXT
    36 #define SQLIMAGE SYBIMAGE
    37 #define SQLMONEY4 SYBMONEY4
    38 #define SQLMONEY SYBMONEY
    39 #define SQLDATETIM4 SYBDATETIME4
    40 #define SQLFLT4 SYBREAL
    41 #define SQLBINARY SYBBINARY
    42 #define SQLVARBINARY SYBVARBINARY
    43 #define SQLNUMERIC SYBNUMERIC
    44 #define SQLDECIMAL SYBDECIMAL
    45 #define SQLFLTN SYBFLTN
    46 #define SQLMONEYN SYBMONEYN
    47 #define SQLDATETIMN SYBDATETIMN
    48 #define SQLVOID SYBVOID
    49 
    50 #define SMALLDATETIBIND SMALLDATETIMEBIND
    51 
    52 #define DBERRHANDLE_PROC EHANDLEFUNC
    53 #define DBMSGHANDLE_PROC MHANDLEFUNC
    54 
    55 /* DB-Library errors as defined by Microsoft */
    56 #define SQLEMEM SYBEMEM
    57 #define SQLENULL SYBENULL
    58 #define SQLENLOG SYBENLOG
    59 #define SQLEPWD SYBEPWD
    60 #define SQLECONN SYBECONN
    61 #define SQLEDDNE SYBEDDNE
    62 #define SQLENULLO SYBENULLO
    63 #define SQLESMSG SYBESMSG
    64 #define SQLEBTOK SYBEBTOK
    65 #define SQLENSPE SYBENSPE
    66 #define SQLEREAD SYBEREAD
    67 #define SQLECNOR SYBECNOR
    68 #define SQLETSIT SYBETSIT
    69 #define SQLEPARM SYBEPARM
    70 #define SQLEAUTN SYBEAUTN
    71 #define SQLECOFL SYBECOFL
    72 #define SQLERDCN SYBERDCN
    73 #define SQLEICN SYBEICN
    74 #define SQLECLOS SYBECLOS
    75 #define SQLENTXT SYBENTXT
    76 #define SQLEDNTI SYBEDNTI
    77 #define SQLETMTD SYBETMTD
    78 #define SQLEASEC SYBEASEC
    79 #define SQLENTLL SYBENTLL
    80 #define SQLETIME SYBETIME
    81 #define SQLEWRIT SYBEWRIT
    82 #define SQLEMODE SYBEMODE
    83 #define SQLEOOB SYBEOOB
    84 #define SQLEITIM SYBEITIM
    85 #define SQLEDBPS SYBEDBPS
    86 #define SQLEIOPT SYBEIOPT
    87 #define SQLEASNL SYBEASNL
    88 #define SQLEASUL SYBEASUL
    89 #define SQLENPRM SYBENPRM
    90 #define SQLEDBOP SYBEDBOP
    91 #define SQLENSIP SYBENSIP
    92 #define SQLECNULL SYBECNULL
    93 #define SQLESEOF SYBESEOF
    94 #define SQLERPND SYBERPND
    95 #define SQLECSYN SYBECSYN
    96 #define SQLENONET SYBENONET
    97 #define SQLEBTYP SYBEBTYP
    98 #define SQLEABNC SYBEABNC
    99 #define SQLEABMT SYBEABMT
    100 #define SQLEABNP SYBEABNP
    101 #define SQLEBNCR SYBEBNCR
    102 #define SQLEAAMT SYBEAAMT
    103 #define SQLENXID SYBENXID
    104 #define SQLEIFNB SYBEIFNB
    105 #define SQLEKBCO SYBEKBCO
    106 #define SQLEBBCI SYBEBBCI
    107 #define SQLEKBCI SYBEKBCI
    108 #define SQLEBCWE SYBEBCWE
    109 #define SQLEBCNN SYBEBCNN
    110 #define SQLEBCOR SYBEBCOR
    111 #define SQLEBCPI SYBEBCPI
    112 #define SQLEBCPN SYBEBCPN
    113 #define SQLEBCPB SYBEBCPB
    114 #define SQLEVDPT SYBEVDPT
    115 #define SQLEBIVI SYBEBIVI
    116 #define SQLEBCBC SYBEBCBC
    117 #define SQLEBCFO SYBEBCFO
    118 #define SQLEBCVH SYBEBCVH
    119 #define SQLEBCUO SYBEBCUO
    120 #define SQLEBUOE SYBEBUOE
    121 #define SQLEBWEF SYBEBWEF
    122 #define SQLEBTMT SYBEBTMT
    123 #define SQLEBEOF SYBEBEOF
    124 #define SQLEBCSI SYBEBCSI
    125 #define SQLEPNUL SYBEPNUL
    126 #define SQLEBSKERR SYBEBSKERR
    127 #define SQLEBDIO SYBEBDIO
    128 #define SQLEBCNT SYBEBCNT
    129 #define SQLEMDBP SYBEMDBP
    130 #define SQLINIT SYBINIT
    131 #define SQLCRSINV SYBCRSINV
    132 #define SQLCRSCMD SYBCRSCMD
    133 #define SQLCRSNOIND SYBCRSNOIND
    134 #define SQLCRSDIS SYBCRSDIS
    135 #define SQLCRSAGR SYBCRSAGR
    136 #define SQLCRSORD SYBCRSORD
    137 #define SQLCRSMEM SYBCRSMEM
    138 #define SQLCRSBSKEY SYBCRSBSKEY
    139 #define SQLCRSNORES SYBCRSNORES
    140 #define SQLCRSVIEW SYBCRSVIEW
    141 #define SQLCRSBUFR SYBCRSBUFR
    142 #define SQLCRSFROWN SYBCRSFROWN
    143 #define SQLCRSBROL SYBCRSBROL
    144 #define SQLCRSFRAND SYBCRSFRAND
    145 #define SQLCRSFLAST SYBCRSFLAST
    146 #define SQLCRSRO SYBCRSRO
    147 #define SQLCRSTAB SYBCRSTAB
    148 #define SQLCRSUPDTAB SYBCRSUPDTAB
    149 #define SQLCRSUPDNB SYBCRSUPDNB
    150 #define SQLCRSVIIND SYBCRSVIIND
    151 #define SQLCRSNOUPD SYBCRSNOUPD
    152 #define SQLCRSOS SYBCRSOS
    153 #define SQLEBCSA SYBEBCSA
    154 #define SQLEBCRO SYBEBCRO
    155 #define SQLEBCNE SYBEBCNE
    156 #define SQLEBCSK SYBEBCSK
    157 #define SQLEUVBF SYBEUVBF
    158 #define SQLEBIHC SYBEBIHC
    159 #define SQLEBWFF SYBEBWFF
    160 #define SQLNUMVAL SYBNUMVAL
    161 #define SQLEOLDVR SYBEOLDVR
    162 #define SQLEBCPS SYBEBCPS
    163 #define SQLEDTC SYBEDTC
    164 #define SQLENOTIMPL SYBENOTIMPL
    165 #define SQLENONFLOAT SYBENONFLOAT
    166 #define SQLECONNFB SYBECONNFB
    167 
    168 
    169 #define dbfreelogin(x) dbloginfree((x))
    170 
    171 #define dbprocerrhandle(p, h) dberrhandle((h))
    172 #define dbprocmsghandle(p, h) dbmsghandle((h))
    173 
    174 #define dbwinexit()
    175 
    176 static const char rcsid_sqldb_h[] = "$Id: sqldb.h,v 1.6 2009-12-02 22:35:18 jklowden Exp $";
    177 static const void *const no_unused_sqldb_h_warn[] = { rcsid_sqldb_h, no_unused_sqldb_h_warn };
    178 
    179 
    180 #endif
    Primary include file for db-lib applications.
    freetds-1.00.82/doc/reference/a00473_source.html100644 025423 025423 00000030554 13242511131 0014615 FreeTDS API: include/sqlfront.h Source File
    FreeTDS API
    sqlfront.h
    1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
    2  * Copyright (C) 1998-1999 Brian Bruns
    3  * Copyright (C) 2011 Frediano Ziglio
    4  *
    5  * This library is free software; you can redistribute it and/or
    6  * modify it under the terms of the GNU Library General Public
    7  * License as published by the Free Software Foundation; either
    8  * version 2 of the License, or (at your option) any later version.
    9  *
    10  * This library is distributed in the hope that it will be useful,
    11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    13  * Library General Public License for more details.
    14  *
    15  * You should have received a copy of the GNU Library General Public
    16  * License along with this library; if not, write to the
    17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    18  * Boston, MA 02111-1307, USA.
    19  */
    20 
    21 #ifndef SQLFRONT_h
    22 #define SQLFRONT_h
    23 
    24 #include "./sybfront.h"
    25 
    26 static const char rcsid_sqlfront_h[] = "$Id: sqlfront.h,v 1.10 2011-07-13 11:06:31 freddy77 Exp $";
    27 static const void *const no_unused_sqlfront_h_warn[] = { rcsid_sqlfront_h, no_unused_sqlfront_h_warn };
    28 
    29 typedef DBPROCESS * PDBPROCESS;
    30 typedef LOGINREC * PLOGINREC;
    31 typedef DBCURSOR * PDBCURSOR;
    32 
    33 typedef int * LPINT;
    34 typedef char * LPSTR;
    35 #if !defined(PHP_MSSQL_H) || !defined(PHP_MSSQL_API)
    36 typedef BYTE * LPBYTE;
    37 #endif
    38 typedef void * LPVOID;
    39 typedef const char * LPCSTR;
    40 
    41 typedef const LPINT LPCINT;
    42 #ifndef _LPCBYTE_DEFINED
    43 #define _LPCBYTE_DEFINED
    44 typedef const BYTE * LPCBYTE;
    45 #endif
    46 typedef USHORT * LPUSHORT;
    47 typedef const LPUSHORT LPCUSHORT;
    48 typedef DBINT * LPDBINT;
    49 typedef const LPDBINT LPCDBINT;
    50 typedef DBBINARY * LPDBBINARY;
    51 typedef const LPDBBINARY LPCDBBINARY;
    52 typedef DBDATEREC * LPDBDATEREC;
    53 typedef const LPDBDATEREC LPCDBDATEREC;
    54 typedef DBDATETIME * LPDBDATETIME;
    55 typedef const LPDBDATETIME LPCDBDATETIME;
    56 
    57 #endif
    Definition: dblib.h:120
    Definition: bsqlodbc.c:97
    Definition: sybdb.h:294
    Definition: sybdb.h:473
    freetds-1.00.82/doc/reference/a00476_source.html100644 025423 025423 00000021405 13242511131 0014613 FreeTDS API: include/sybdb.dox.h Source File
    FreeTDS API
    sybdb.dox.h
    1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
    2  * Copyright (C) 2005 James K. Lowden
    3  *
    4  * This library is free software; you can redistribute it and/or
    5  * modify it under the terms of the GNU Library General Public
    6  * License as published by the Free Software Foundation; either
    7  * version 2 of the License, or (at your option) any later version.
    8  *
    9  * This library is distributed in the hope that it will be useful,
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    12  * Library General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU Library General Public
    15  * License along with this library; if not, write to the
    16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    17  * Boston, MA 02111-1307, USA.
    18  */
    19 
    93  /*------------------------*/
    119  /*------------------------*/
    135 /* \fn DBSETLHID(x,y) (not implemented)
    136  * \ingroup dblib_core
    137  * \brief
    138  * \sa dbsetlhid()
    139  */
    140 /* \fn DBSETLNOSHORT(x,y) (not implemented)
    141  * \ingroup dblib_core
    142  * \brief
    143  * \sa dbsetlnoshort()
    144  */
    145 /* \fn DBSETLHIER(x,y) (not implemented)
    146  * \ingroup dblib_core
    147  * \brief
    148  * \sa dbsetlhier()
    149  */
    171 /* \fn BCP_SETLABELED(x,y) (not implemented)
    172  * \ingroup dblib_internal
    173  * \brief Sybase macro mapping to the Microsoft (lower-case) function.
    174  * \sa bcp_setlabeled()
    175  */
    182  /*------------------------*/
    183 
    freetds-1.00.82/doc/reference/a00479.html100644 025423 025423 00001410567 13242511136 0013257 FreeTDS API: include/sybdb.h File Reference
    FreeTDS API
    sybdb.h File Reference

    Primary include file for db-lib applications. More...

    #include "tds_sysdep_public.h"
    Include dependency graph for sybdb.h:
    This graph shows which files directly or indirectly include this file:

    Go to the source code of this file.

    Classes

    struct  DBCOL
     
    struct  DBCOL2
     
    struct  DBDATETIME
     
    struct  DBDATETIME4
     
    struct  DBDATETIMEALL
     
    struct  DBMONEY
     
    struct  DBMONEY4
     
    struct  DBNUMERIC
     
    struct  dbstring
     
    struct  dbtypeinfo
     
    struct  DBVARYBIN
     
    struct  DBVARYCHAR
     
    struct  tds_microsoft_dbdaterec
     
    struct  tds_microsoft_dbdaterec2
     
    struct  tds_sybase_dbdaterec
     
    struct  tds_sybase_dbdaterec2
     

    Macros

    #define BCP_SETL(x, y)   dbsetlbool((x), (y), DBSETBCP)
     Enable (or prevent) bcp operations for connections made with a login. More...
     
    #define BCP_SETLABELED(x, y)   dbsetlbool((x), (y), DBSETLABELED)
     
    #define BCPBATCH   4
     
    #define BCPFIRST   2
     
    #define BCPHINTS   6
     
    #define BCPKEEPIDENTITY   8
     
    #define BCPLABELED   5
     
    #define BCPLAST   3
     
    #define BCPMAXERRS   1
     
    #define BIGDATETIMEBIND   23
     
    #define BIGINTBIND   30
     
    #define BIGTIMEBIND   24
     
    #define BINARYBIND   15
     
    #define BITBIND   16
     
    #define BUF_FULL   -3
     
    #define CHARBIND   0
     
    #define DATEBIND   21
     
    #define DATETIME2BIND   31
     
    #define DATETIMEBIND   11
     
    #define DB_IN   1
     
    #define DB_OUT   2
     
    #define DB_QUERYOUT   3
     
    #define DBARITHABORT   6
     
    #define DBARITHIGNORE   4
     
    #define DBAUTH   29
     
    #define DBBOTH   2
     
    #define DBBROWSE   8
     
    #define DBBUFFER   14
     
    #define DBCHAINXACTS   26
     
    #define DBCLIENTCURSORS   33
     
    #define DBCMDNONE   0
     
    #define DBCMDPEND   1
     
    #define DBCMDROW(x)   dbcmdrow((x))
     Sybase macro mapping to the Microsoft (lower-case) function. More...
     
    #define DBCMDSENT   2
     
    #define DBCONFIRM   12
     
    #define DBCOUNT(x)   dbcount((x))
     Sybase macro mapping to the Microsoft (lower-case) function. More...
     
    #define DBCURCMD(x)   dbcurcmd((x))
     Sybase macro mapping to the Microsoft (lower-case) function. More...
     
    #define DBCURROW(x)   dbcurrow((x))
     Sybase macro mapping to the Microsoft (lower-case) function. More...
     
    #define DBDATEFIRST   25
     
    #define DBDATEFORMAT   19
     
    #define DBDATESHORT   32
     
    #define DBDEAD(x)   dbdead((x))
     Sybase macro mapping to the Microsoft (lower-case) function. More...
     
    #define DBDOUBLE   1
     
    #define DBERRLVL   11
     
    #define DBESTIMATE   1
     
    #define DBFIPSFLAG   27
     
    #define DBFIRSTROW(x)   dbfirstrow((x))
     Sybase macro mapping to the Microsoft (lower-case) function. More...
     
    #define DBGETTIME   dbgettime
     
    #define DBIDENTITY   30
     
    #define DBINTERRUPT   4
     
    #define DBIORDESC(x)   dbiordesc((x))
     Sybase macro, maps to the internal (lower-case) function. More...
     
    #define DBIOWDESC(x)   dbiowdesc((x))
     Sybase macro, maps to the internal (lower-case) function. More...
     
    #define DBISAVAIL(x)   dbisavail((x))
     Sybase macro mapping to the Microsoft (lower-case) function. More...
     
    #define DBISOLATION   28
     
    #define DBLASTROW(x)   dblastrow((x))
     Sybase macro mapping to the Microsoft (lower-case) function. More...
     
    #define DBLFCONVERT   24
     
    #define DBMAXNAME   128
     
    #define DBMAXNUMLEN   33
     
    #define DBMORECMDS(x)   dbmorecmds((x))
     Sybase macro mapping to the Microsoft (lower-case) function. More...
     
    #define DBNATLANG   18
     
    #define DBNOAUTOFREE   15
     
    #define DBNOCOUNT   5
     
    #define DBNOERR   -1
     
    #define DBNOEXEC   3
     
    #define DBNOIDCOL   31
     
    #define DBNOSAVE   0
     
    #define DBNOTIFICATION   2
     
    #define DBNUMOPTIONS   36
     
    #define DBOFFSET   9
     
    #define dbopen(x, y)   tdsdbopen((x),(y), 0)
     
    #define DBPADOFF   0
     
    #define DBPADON   1
     
    #define DBPARSEONLY   0
     
    #define DBPRCOLSEP   21
     
    #define DBPRCOLSEP   21
     
    #define DBPRLINELEN   22
     
    #define DBPRLINELEN   22
     
    #define DBPRLINESEP   23
     
    #define DBPRPAD   20
     
    #define DBQUOTEDIDENT   35
     
    #define DBRESULT   1
     
    #define DBROWCOUNT   16
     
    #define DBROWS(x)   dbrows((x))
     Sybase macro mapping to the Microsoft (lower-case) function. More...
     
    #define DBROWTYPE(x)   dbrowtype((x))
     Sybase macro mapping to the Microsoft (lower-case) function. More...
     
    #define DBRPCCURSOR   TDS_STATIC_CAST(DBSMALLINT, 0x0008)
     
    #define DBRPCDEFAULT   2
     
    #define DBRPCRECOMPILE   TDS_STATIC_CAST(DBSMALLINT, 0x0001)
     
    #define DBRPCRESET   TDS_STATIC_CAST(DBSMALLINT, 0x0002)
     
    #define DBRPCRETURN   1
     
    #define DBSAVE   1
     
    #define DBSETAPP   5
     
    #define DBSETBCP   6
     
    #define DBSETCHARSET   10
     
    #define DBSETDBNAME   14
     
    #define DBSETENCRYPT   12
     
    #define DBSETHOST   1
     
    #define DBSETLABELED   13
     
    #define DBSETLAPP(x, y)   dbsetlname((x), (y), DBSETAPP)
     Set the (client) application name in the login packet. More...
     
    #define dbsetlapp(x, y)   dbsetlname((x), (y), DBSETAPP)
     
    #define DBSETLCHARSET(x, y)   dbsetlname((x), (y), DBSETCHARSET)
     Set the client character set in the login packet. More...
     
    #define DBSETLDBNAME(x, y)   dbsetlname((x), (y), DBSETDBNAME)
     
    #define DBSETLENCRYPT(x, y)   dbsetlbool((x), (y), DBSETENCRYPT)
     Enable (or not) network password encryption for Sybase servers version 10.0 or above. More...
     
    #define DBSETLHOST(x, y)   dbsetlname((x), (y), DBSETHOST)
     Set the (client) host name in the login packet. More...
     
    #define dbsetlhost(x, y)   dbsetlname((x), (y), DBSETHOST)
     
    #define DBSETLLABELED(x, y)   dbsetlbool((x), (y), DBSETLABELED)
     Alternative way to set login packet fields. More...
     
    #define DBSETLNATLANG(x, y)   dbsetlname((x), (y), DBSETNATLANG)
     Set the language the server should use for messages. More...
     
    #define dbsetlnatlang(x, y)   dbsetlname((x), (y), DBSETNATLANG)
     Set the language the server should use for messages. More...
     
    #define DBSETLNTLMV2(x, y)   dbsetlbool((x), (y), DBSETNTLMV2)
     
    #define DBSETLPACKET(x, y)   dbsetllong((x), (y), DBSETPACKET)
     Set the packet size in the login packet for new connections. More...
     
    #define dbsetlpacket(x, y)   dbsetllong((x), (y), DBSETPACKET)
     Set the packet size in the login packet for new connections. More...
     
    #define DBSETLPWD(x, y)   dbsetlname((x), (y), DBSETPWD)
     Set the password in the login packet. More...
     
    #define dbsetlpwd(x, y)   dbsetlname((x), (y), DBSETPWD)
     
    #define DBSETLREADONLY(x, y)   dbsetlbool((x), (y), DBSETREADONLY)
     
    #define DBSETLSECURE(x)   dbsetlbool((x), (1), DBSETBCP)
     
    #define DBSETLUSER(x, y)   dbsetlname((x), (y), DBSETUSER)
     Set the username in the login packet. More...
     
    #define dbsetluser(x, y)   dbsetlname((x), (y), DBSETUSER)
     
    #define DBSETLUTF16(x, y)   dbsetlbool((x), (y), DBSETUTF16)
     
    #define DBSETLVERSION(login, version)   dbsetlversion((login), (version))
     maps to the Microsoft (lower-case) function. More...
     
    #define DBSETNATLANG   7
     
    #define DBSETNTLMV2   1002
     
    #define DBSETPACKET   11
     
    #define DBSETPWD   3
     
    #define DBSETREADONLY   1003
     
    #define DBSETTIME   34
     
    #define DBSETUSER   2
     
    #define DBSETUTF16   1001
     
    #define DBSHOWPLAN   2
     
    #define DBSINGLE   0
     
    #define DBSTAT   10
     
    #define DBSTORPROCID   13
     
    #define DBTDS(a)   dbtds(a)
     Sybase macro, maps to the internal (lower-case) function. More...
     
    #define DBTDS_2_0   1 /* pre 4.0 SQL Server */
     
    #define DBTDS_3_4   2 /* Microsoft SQL Server (3.0) */
     
    #define DBTDS_4_0   3 /* 4.0 SQL Server */
     
    #define DBTDS_4_2   4 /* 4.2 SQL Server */
     
    #define DBTDS_4_6   5 /* 2.0 OpenServer and 4.6 SQL Server. */
     
    #define DBTDS_4_9_5   6 /* 4.9.5 (NCR) SQL Server */
     
    #define DBTDS_5_0   7 /* 5.0 SQL Server */
     
    #define DBTDS_7_0   8 /* Microsoft SQL Server 7.0 */
     
    #define DBTDS_7_1   9 /* Microsoft SQL Server 2000 */
     
    #define DBTDS_7_2   10 /* Microsoft SQL Server 2005 */
     
    #define DBTDS_7_3   11 /* Microsoft SQL Server 2008 */
     
    #define DBTDS_7_4   12 /* Microsoft SQL Server 2012/2014 */
     
    #define DBTDS_8_0   9 /* Microsoft SQL Server 2000 */
     
    #define DBTDS_9_0   10 /* Microsoft SQL Server 2005 */
     
    #define DBTDS_UNKNOWN   0
     DBTDS_xxx are returned by DBTDS() The integer values of the constants are poorly chosen.
     
    #define DBTEXTLIMIT   7
     
    #define DBTEXTSIZE   17
     
    #define DBTIMEOUT   3
     
    #define DBTXPLEN   16
     
    #define DBTXTSLEN   8
     
    #define DBVER42   DBVERSION_42
     
    #define DBVER60   DBVERSION_70 /* our best approximation */
     
    #define DBVERSION_100   2
     
    #define DBVERSION_42   3
     
    #define DBVERSION_46   1
     
    #define DBVERSION_70   4
     
    #define DBVERSION_71   5
     
    #define DBVERSION_72   6
     
    #define DBVERSION_73   7
     
    #define DBVERSION_74   8
     
    #define DBVERSION_UNKNOWN   0
     DBVERSION_xxx are used with dbsetversion()
     
    #define DECIMALBIND   18
     
    #define FAIL   0
     
    #define FALSE   0
     
    #define FLT8BIND   9
     
    #define INT_CANCEL   2
     
    #define INT_CONTINUE   1
     
    #define INT_EXIT   0
     
    #define INT_TIMEOUT   3
     
    #define INTBIND   8
     
    #define MAXBINDTYPES   32 /* keep last */
     
    #define MAXOPTTEXT   32
     
    #define MONEYBIND   13
     
    #define MORE_ROWS   -1
     
    #define NO_MORE_RESULTS   2
     
    #define NO_MORE_ROWS   -2
     
    #define NOSUCHOPTION   2
     
    #define NTBSTRINGBIND   2
     
    #define NUMERICBIND   17
     
    #define OFF   0
     
    #define ON   1
     
    #define REALBIND   10
     
    #define REG_ROW   -1
     
    #define SMALLBIND   7
     
    #define SMALLDATETIMEBIND   12
     
    #define SMALLMONEYBIND   14
     
    #define SRCDECIMALBIND   20
     
    #define SRCNUMERICBIND   19
     
    #define STRINGBIND   1
     
    #define SUCCEED   1
     
    #define SYBAOPAVG   0x4f
     
    #define SYBAOPAVGU   0x50
     
    #define SYBAOPCHECKSUM_AGG   0x72
     
    #define SYBAOPCNT   0x4b
     
    #define SYBAOPCNT_BIG   0x09
     
    #define SYBAOPCNTU   0x4c
     
    #define SYBAOPMAX   0x52
     
    #define SYBAOPMIN   0x51
     
    #define SYBAOPSTDEV   0x30
     
    #define SYBAOPSTDEVP   0x31
     
    #define SYBAOPSUM   0x4d
     
    #define SYBAOPSUMU   0x4e
     
    #define SYBAOPVAR   0x32
     
    #define SYBAOPVARP   0x33
     
    #define SYBBIGDATETIME   SYBBIGDATETIME
     
    #define SYBBIGTIME   SYBBIGTIME
     
    #define SYBBINARY   SYBBINARY
     
    #define SYBBIT   SYBBIT
     
    #define SYBBITN   SYBBITN
     
    #define SYBCHAR   SYBCHAR
     
    #define SYBDATE   SYBDATE
     
    #define SYBDATETIME   SYBDATETIME
     
    #define SYBDATETIME4   SYBDATETIME4
     
    #define SYBDATETIMN   SYBDATETIMN
     
    #define SYBDECIMAL   SYBDECIMAL
     
    #define SYBEAAMT   20035 /* User attempted a dbaltbind() with mismatched column and variable types. */
     
    #define SYBEABMT   20033 /* User attempted a dbbind() with mismatched column and variable types. */
     
    #define SYBEABNC   20032 /* Attempt to bind to a non-existent column. */
     
    #define SYBEABNP   20034 /* Attempt to bind using NULL pointers. */
     
    #define SYBEABNV   20046 /* Attempt to bind to a NULL program variable. */
     
    #define SYBEACNV   20148 /* Attemp to do conversion with NULL destination variable. */
     
    #define SYBEADST   20128 /* Error in attempting to determine the size of a pair of translation tables. */
     
    #define SYBEAICF   20127 /* Error in attempting to install custom format. */
     
    #define SYBEALTT   20129 /* Error in attempting to load a pair of translation tables. */
     
    #define SYBEAOLF   20133 /* Error in attempting to open a localization file. */
     
    #define SYBEAPCT   20130 /* Error in attempting to perform a character-set translation. */
     
    #define SYBEAPUT   20040 /* Attempt to print unknown token. */
     
    #define SYBEARDI   20134 /* Error in attempting to read datetime information from a localization file. */
     
    #define SYBEARDL   20136 /* Error in attempting to read the dblib.loc localization file. */
     
    #define SYBEASEC   20091 /* Attempt to send an empty command buffer to the SQL Server. */
     
    #define SYBEASNL   20041 /* Attempt to set fields in a null loginrec. */
     
    #define SYBEASTF   20089 /* VMS: Unable to setmode for control_c ast. */
     
    #define SYBEASTL   20197 /* Synchronous I/O attempted at AST level. */
     
    #define SYBEASUL   20043 /* Attempt to set unknown loginrec field. */
     
    #define SYBEATTNACK   20296 /* Timed out waiting for server to acknowledge attention." */
     
    #define SYBEAUTN   20062 /* Attempt to update the timestamp of a table which has no timestamp column. */
     
    #define SYBEBADPK   20201 /* Packet size of %1! not supported. -- size of %2! used instead. */
     
    #define SYBEBADTYPE   20254 /* Illegal value for type parameter given to %1!. */
     
    #define SYBEBBCI   20068 /* Batch successfully bulk-copied to SQL Server. */
     
    #define SYBEBBFL   20297 /* -001- Batch failed in bulk-copy to SQL Server */
     
    #define SYBEBBL   20215 /* Bad bindlen parameter passed to dbsetnull() */
     
    #define SYBEBCBC   20081 /* bcp_columns() must be called before bcp_colfmt() and bcp_colfmt_ps(). */
     
    #define SYBEBCBNPR   20230 /* bcp_bind(): if varaddr is NULL, prefixlen must be 0 and no terminator should be specified. */
     
    #define SYBEBCBNTYP   20231 /* bcp_bind(): if varaddr is NULL and varlen greater than 0, the table column type must be SYBTEXT or SYBIMAGE and the program variable type must be SYBTEXT, SYBCHAR, SYBIMAGE or SYBBINARY. */
     
    #define SYBEBCBPREF   20236 /* Illegal prefix length. Legal values are 0, 1, 2 or 4. */
     
    #define SYBEBCFO   20082 /* Bcp host-files must contain at least one column. */
     
    #define SYBEBCHLEN   20235 /* host_collen should be greater than or equal to -1. */
     
    #define SYBEBCIS   20075 /* Attempt to bulk-copy an illegally-sized column value to the SQL Server. */
     
    #define SYBEBCIT   20107 /* It's illegal to use BCP terminators with program variables other than SYBCHAR, SYBBINARY, SYBTEXT, or SYBIMAGE. */
     
    #define SYBEBCITBLEN   20239 /* bcp_init(): tblname parameter is too long. */
     
    #define SYBEBCITBNM   20238 /* bcp_init(): tblname parameter cannot be NULL. */
     
    #define SYBEBCMTXT   20228 /* bcp_moretext() may be used only when there is at least one text or image column in the server table. */
     
    #define SYBEBCNL   20105 /* Negative length-prefix found in BCP data-file. */
     
    #define SYBEBCNN   20073 /* Attempt to bulk-copy a NULL value into Server column %d, which does not accept NULL values. */
     
    #define SYBEBCNT   20064 /* Attempt to use Bulk Copy with a non-existent Server table. */
     
    #define SYBEBCOR   20074 /* Attempt to bulk-copy an oversized row to the SQL Server. */
     
    #define SYBEBCPB   20078 /* bcp_bind(), bcp_moretext() and bcp_sendrow() may NOT be used after bcp_init() has been passed a non-NULL input file name. */
     
    #define SYBEBCPCTYP   20233 /* bcp_colfmt(): If table_colnum is 0, host_type cannot be 0. */
     
    #define SYBEBCPI   20076 /* bcp_init() must be called before any other bcp routines. */
     
    #define SYBEBCPN   20077 /* bcp_bind(), bcp_collen(), bcp_colptr(), bcp_moretext() and bcp_sendrow() may be used only after bcp_init() has been called with the copy direction set to DB_IN. */
     
    #define SYBEBCPOPT   20294 /* The option cannot be called while a bulk copy operation is progress. */
     
    #define SYBEBCPREC   20229 /* Column %1!: Illegal precision value encountered. */
     
    #define SYBEBCPREF   20237 /* Illegal prefix length. Legal values are -1, 0, 1, 2 or 4. */
     
    #define SYBEBCRE   20070 /* I/O error while reading bcp data-file. */
     
    #define SYBEBCRO   20111 /* The BCP hostfile '%s' contains only %ld rows. It was impossible to read the requested %ld rows. */
     
    #define SYBEBCSA   20108 /* The BCP hostfile '%s' contains only %ld rows. Skipping all of these rows is not allowed. */
     
    #define SYBEBCSET   20221 /* Unknown character-set encountered." */
     
    #define SYBEBCSI   20106 /* Host-file columns may be skipped only when copying INto the Server. */
     
    #define SYBEBCSNDROW   20240 /* bcp_sendrow() may NOT be called unless all text data for the previous row has been sent using bcp_moretext(). */
     
    #define SYBEBCSNTYP   20232 /* column number %1!: if varaddr is NULL and varlen greater than 0, the table column type must be SYBTEXT or SYBIMAGE and the program variable type must be SYBTEXT, SYBCHAR, SYBIMAGE or SYBBINARY. */
     
    #define SYBEBCUC   20085 /* Bcp: Unable to close host data-file. */
     
    #define SYBEBCUO   20084 /* Bcp: Unable to open host data-file. */
     
    #define SYBEBCVH   20083 /* bcp_exec() may be called only after bcp_init() has been passed a valid host file. */
     
    #define SYBEBCVLEN   20234 /* varlen should be greater than or equal to -1. */
     
    #define SYBEBCWE   20072 /* I/O error while writing bcp data-file. */
     
    #define SYBEBDIO   20063 /* Bad bulk-copy direction. Must be either IN or OUT. */
     
    #define SYBEBEOF   20104 /* Unexpected EOF encountered in BCP data-file. */
     
    #define SYBEBIHC   20103 /* Incorrect host-column number found in bcp format-file. */
     
    #define SYBEBIVI   20080 /* bcp_columns(), bcp_colfmt() and bcp_colfmt_ps() may be used only after bcp_init() has been passed a valid input file. */
     
    #define SYBEBNCR   20024 /* Attempt to bind user variable to a non-existent compute row. */
     
    #define SYBEBNUM   20214 /* Bad numbytes parameter passed to dbstrcpy() */
     
    #define SYBEBOOL   20293 /* Boolean parameters must be TRUE or FALSE. */
     
    #define SYBEBPKS   20193 /* In DBSETLPACKET(), the packet size parameter must be between 0 and 999999. */
     
    #define SYBEBPREC   20216 /* Illegal precision specified */
     
    #define SYBEBPROBADDEF   20249 /* bcp protocol error: illegal default column id received. */
     
    #define SYBEBPROBADLEN   20251 /* bcp protocol error: illegal datatype length received. */
     
    #define SYBEBPROBADPREC   20252 /* bcp protocol error: illegal precision value received. */
     
    #define SYBEBPROBADSCL   20253 /* bcp protocol error: illegal scale value received. */
     
    #define SYBEBPROBADTYP   20250 /* bcp protocol error: unknown column datatype. */
     
    #define SYBEBPROCOL   20241 /* bcp protocol error: returned column count differs from the actual number of columns received. */
     
    #define SYBEBPRODEF   20242 /* bcp protocol error: expected default information and got none. */
     
    #define SYBEBPRODEFID   20244 /* bcp protocol error: default column id and actual column id are not same */
     
    #define SYBEBPRODEFTYP   20246 /* bcp protocol error: default value datatype differs from column datatype. */
     
    #define SYBEBPROEXTDEF   20247 /* bcp protocol error: more than one row of default information received. */
     
    #define SYBEBPROEXTRES   20248 /* bcp protocol error: unexpected set of results received. */
     
    #define SYBEBPRONODEF   20245 /* bcp protocol error: default value received for column that does not have default. */
     
    #define SYBEBPRONUMDEF   20243 /* bcp protocol error: expected number of defaults differs from the actual number of defaults received. */
     
    #define SYBEBRFF   20100 /* I/O error while reading bcp format-file. */
     
    #define SYBEBSCALE   20217 /* Illegal scale specified */
     
    #define SYBEBTMT   20095 /* Attempt to send too much TEXT data via the bcp_moretext() call. */
     
    #define SYBEBTOK   20020 /* Bad token from SQL Server: Data-stream processing out of sync. */
     
    #define SYBEBTYP   20023 /* Unknown bind type passed to DB-LIBRARY function. */
     
    #define SYBEBTYPSRV   20220 /* Datatype is not supported by the server. */
     
    #define SYBEBUCE   20087 /* Bcp: Unable to close error-file. */
     
    #define SYBEBUCF   20099 /* Bcp: Unable to close format-file. */
     
    #define SYBEBUDF   20102 /* Bcp: Unrecognized datatype found in format-file. */
     
    #define SYBEBUFF   20147 /* Bcp: Unable to create format-file. */
     
    #define SYBEBUFL   20005 /* DB-LIBRARY internal error - send buffer length corrupted. */
     
    #define SYBEBULKINSERT   20599 /* cannot build bulk insert statement */
     
    #define SYBEBUOE   20086 /* Bcp: Unable to open error-file. */
     
    #define SYBEBUOF   20098 /* Bcp: Unable to open format-file. */
     
    #define SYBEBWEF   20088 /* I/O error while writing bcp error-file. */
     
    #define SYBEBWFF   20101 /* I/O error while writing bcp format-file. */
     
    #define SYBECAP   20203 /* DB-Library capabilities not accepted by the Server. */
     
    #define SYBECAPTYP   20213 /* Unexpected capability type in CAPABILITY datastream. */
     
    #define SYBECDNS   20031 /* Datastream indicates that a compute column is derived from a non-existent select-list member. */
     
    #define SYBECDOMAIN   20218 /* Source field value is not within the domain of legal values. */
     
    #define SYBECINTERNAL   20219 /* Internal Conversion error. */
     
    #define SYBECLOS   20056 /* Error in closing network connection. */
     
    #define SYBECLOSEIN   20292 /* Unable to close interface file. */
     
    #define SYBECLPR   20051 /* Data-conversion resulted in loss of precision. */
     
    #define SYBECNOR   20026 /* Column number out of range. */
     
    #define SYBECNOV   20052 /* Attempt to set variable to NULL resulted in overflow. */
     
    #define SYBECOFL   20049 /* Data-conversion resulted in overflow. */
     
    #define SYBECOLSIZE   22000 /* Invalid column information structure size */
     
    #define SYBECONN   20009 /* Unable to connect socket -- SQL Server is unavailable or does not exist. */
     
    #define SYBECRNC   20116 /* The current row is not a result of compute clause %d, so it is illegal to attempt to extract that data from this row. */
     
    #define SYBECRSAGR   20263 /* Aggregate functions are not allowed in a cursor statement. */
     
    #define SYBECRSBROL   20266 /* Backward scrolling cannot be used in a forward scrolling cursor. */
     
    #define SYBECRSBSKEY   20268 /* Keyset cannot be scrolled backward in mixed cursors with a previous fetch type. */
     
    #define SYBECRSBUFR   20260 /* Row buffering should not be turned on when using cursor APIs. */
     
    #define SYBECRSDIS   20262 /* Cursor statement contains one of the disallowed phrases 'compute', 'union', 'for browse', or 'select into'. */
     
    #define SYBECRSFLAST   20265 /* Fetch type LAST requires fully keyset driven cursors. */
     
    #define SYBECRSFRAND   20264 /* Fetch types RANDOM and RELATIVE can only be used within the keyset of keyset driven cursors. */
     
    #define SYBECRSFROWN   20267 /* Row number to be fetched is outside valid range. */
     
    #define SYBECRSFTYPE   20280 /* Unknown fetch type. */
     
    #define SYBECRSINV   20277 /* Invalid cursor statement. */
     
    #define SYBECRSINVALID   20281 /* The cursor handle is invalid. */
     
    #define SYBECRSMROWS   20282 /* Multiple rows are returned, only one is expected. */
     
    #define SYBECRSNOBIND   20279 /* Cursor bind must be called prior to updating cursor */
     
    #define SYBECRSNOCOUNT   20270 /* The DBNOCOUNT option should not be turned on when doing updates or deletes with dbcursor(). */
     
    #define SYBECRSNOFREE   20261 /* The DBNOAUTOFREE option should not be turned on when using cursor APIs. */
     
    #define SYBECRSNOIND   20256 /* One of the tables involved in the cursor statement does not have a unique index. */
     
    #define SYBECRSNOKEYS   20278 /* The entire keyset must be defined for KEYSET cursors. */
     
    #define SYBECRSNOLEN   20284 /* No unique index found. */
     
    #define SYBECRSNOPTCC   20285 /* No OPTCC was found. */
     
    #define SYBECRSNORDER   20286 /* The order of clauses must be from, where, and order by. */
     
    #define SYBECRSNORES   20255 /* Cursor statement generated no results. */
     
    #define SYBECRSNOTABLE   20287 /* Table name is NULL. */
     
    #define SYBECRSNOUPD   20276 /* Update or delete operation did not affect any rows. */
     
    #define SYBECRSNOWHERE   20273 /* A WHERE clause is not allowed in a cursor update or insert. */
     
    #define SYBECRSNROWS   20283 /* No rows returned, at least one is expected. */
     
    #define SYBECRSNUNIQUE   20288 /* No unique keys associated with this view. */
     
    #define SYBECRSORD   20259 /* Only fully keyset driven cursors can have 'order by', ' group by', or 'having' phrases. */
     
    #define SYBECRSRO   20269 /* Data locking or modifications cannot be made in a READONLY cursor. */
     
    #define SYBECRSSET   20274 /* A SET clause is required for a cursor update or insert. */
     
    #define SYBECRSTAB   20271 /* Table name must be determined in operations involving data locking or modifications. */
     
    #define SYBECRSUPDNB   20272 /* Update or insert operations cannot use bind variables when binding type is NOBIND. */
     
    #define SYBECRSUPDTAB   20275 /* Update or insert operations using bind variables require single table cursors. */
     
    #define SYBECRSVAR   20289 /* There is no valid address associated with this bind. */
     
    #define SYBECRSVIEW   20257 /* A view cannot be joined with another table or a view in a cursor statement. */
     
    #define SYBECRSVIIND   20258 /* The view used in the cursor statement does not include all the unique index columns of the underlying tables. */
     
    #define SYBECS   20299 /* -004- cs context Error */
     
    #define SYBECSYN   20050 /* Attempt to convert data stopped by syntax error in source field. */
     
    #define SYBECUFL   20048 /* Data-conversion resulted in underflow. */
     
    #define SYBECWLL   20123 /* Attempt to set column width less than 1. */
     
    #define SYBEDBPS   20011 /* Maximum number of DBPROCESSes already allocated. */
     
    #define SYBEDCL   20298 /* -004- DCL Error */
     
    #define SYBEDDNE   20047 /* DBPROCESS is dead or not enabled. */
     
    #define SYBEDIVZ   20196 /* Attempt to divide by $0.00 in function %1!. */
     
    #define SYBEDNTI   20094 /* Attempt to use dbtxtsput() to put a new text-timestamp into a column whose datatype is neither SYBTEXT nor SYBIMAGE. */
     
    #define SYBEDPOR   20149 /* Out-of-range datepart constant. */
     
    #define SYBEDVOR   20152 /* Day values must be between 1 and 7. */
     
    #define SYBEECAN   20184 /* Attempted to cancel unrequested event notification. */
     
    #define SYBEECRT   20183 /* Must call dbregdefine() before dbregcreate(). */
     
    #define SYBEEINI   20182 /* Must call dbreginit() before dbregraise(). */
     
    #define SYBEEQVA   20059 /* Error in queueing VMS AST routine. */
     
    #define SYBEERRLABEL   20295 /* An illegal value was returned from the security label handler. */
     
    #define SYBEESSL   20172 /* Login security level entered does not agree with operating system level */
     
    #define SYBEETD   20164 /* Failure to send the expected amount of TEXT or IMAGE data via dbmoretext(). */
     
    #define SYBEEUNR   20185 /* Unsolicited event notification received. */
     
    #define SYBEEVOP   20178 /* Called dbregwatch() with a bad options parameter. */
     
    #define SYBEEVST   20181 /* Must initiate a transaction before calling dbregparam(). */
     
    #define SYBEFCON   20002 /* SQL Server connection failed. */
     
    #define SYBEFENC   20222 /* Password Encryption failed." */
     
    #define SYBEFGTL   20122 /* Bcp: Row number of the first row to be copied cannot be greater than the row number for the last row to be copied. */
     
    #define SYBEFMODE   20167 /* Read/Write/Append mode denied on file. */
     
    #define SYBEFRES   20223 /* Challenge-Response function failed.", */
     
    #define SYBEFSHD   20132 /* Error in attempting to find the Sybase home directory. */
     
    #define SYBEFUNC   20204 /* Functionality not supported at the specified version level. */
     
    #define SYBEGENOS   20161 /* General Operating System Error. */
     
    #define SYBEICN   20038 /* Invalid computeid or compute column number. */
     
    #define SYBEICONV2BIG   2404 /* Buffer overflow converting characters from client into server's character set.*/
     
    #define SYBEICONVAVAIL   2401 /* Character set conversion is not available between client character set '%.*s' and server character set '%.*s'.*/
     
    #define SYBEICONVI   2403 /* Some character(s) could not be converted into client's character set. Unconverted bytes were changed to question marks ('?').*/
     
    #define SYBEICONVIU   2400 /* Some character(s) could not be converted into client's character set. */
     
    #define SYBEICONVO   2402 /* Error converting characters into server's character set. Some character(s) could not be converted.*/
     
    #define SYBEIDCL   20143 /* Illegal datetime column length returned by DataServer. Legal datetime lengths are 4 and 8 bytes. */
     
    #define SYBEIDECCL   20227 /* Invalid decimal column length returned by the server. */
     
    #define SYBEIFCL   20145 /* Illegal floating-point column length returned by DataServer. Legal floating-point lengths are 4 and 8 bytes. */
     
    #define SYBEIFNB   20065 /* Illegal field number passed to bcp_control(). */
     
    #define SYBEIICL   20025 /* Illegal integer column length returned by SQL Server. Legal integer lengths are 1, 2, and 4 bytes. */
     
    #define SYBEIMCL   20144 /* Illegal money column length returned by DataServer. Legal money lengths are 4 and 8 bytes. */
     
    #define SYBEINLN   20016 /* Interface file: unexpected end-of-line. */
     
    #define SYBEINTF   20012 /* Server name not found in interface file */
     
    #define SYBEINUMCL   20226 /* Invalid numeric column length returned by the server. */
     
    #define SYBEIPV   20194 /* %1! is an illegal value for the %2! parameter of %3!. */
     
    #define SYBEISOI   20142 /* Invalid sort-order information found. */
     
    #define SYBEISRVPREC   20224 /* Illegal precision value returned by the server. */
     
    #define SYBEISRVSCL   20225 /* Illegal scale value returned by the server. */
     
    #define SYBEITIM   20021 /* Illegal timeout value specified. */
     
    #define SYBEIVERS   20206 /* Illegal version level specified. */
     
    #define SYBEKBCI   20069 /* Bcp: 1000 rows sent to SQL Server. */
     
    #define SYBEKBCO   20067 /* 1000 rows successfully bulk-copied to host-file. */
     
    #define SYBELBLEN   20211 /* Security labels should be less than 256 characters long. */
     
    #define SYBEMEM   20010 /* Unable to allocate sufficient memory */
     
    #define SYBEMOV   20195 /* Money arithmetic resulted in overflow in function %1!. */
     
    #define SYBEMPLL   20112 /* Attempt to set maximum number of DBPROCESSes lower than 1. */
     
    #define SYBEMVOR   20151 /* Month values must be between 1 and 12. */
     
    #define SYBENBUF   20175 /* called dbsendpassthru() with a NULL buf pointer. */
     
    #define SYBENBVP   20153 /* Cannot pass dbsetnull() a NULL bindval pointer. */
     
    #define SYBENDC   20150 /* Cannot have negative component in date in numeric form. */
     
    #define SYBENDTP   20155 /* Called dbdatecrack() with a NULL datetime parameter. */
     
    #define SYBENEG   20210 /* Negotiated login attempt failed. */
     
    #define SYBENEHA   20179 /* Called dbreghandle() with a NULL handler parameter. */
     
    #define SYBENHAN   20174 /* called dbrecvpassthru() with a NULL handler parameter. */
     
    #define SYBENLNL   20173 /* Program not linked with specified network library. */
     
    #define SYBENMOB   20039 /* No such member of 'order by' clause. */
     
    #define SYBENOEV   20200 /* dbpoll() cannot be called if registered procedure notifications have been disabled. */
     
    #define SYBENOTI   20177 /* No event handler installed. */
     
    #define SYBENOVALUE   20290 /* Security labels require both a name and a value */
     
    #define SYBENPRM   20027 /* NULL parameter not allowed for this dboption. */
     
    #define SYBENSIP   20045 /* Negative starting index passed to dbstrcpy(). */
     
    #define SYBENTLL   20042 /* Name too long for loginrec field. */
     
    #define SYBENTST   20170 /* The file being opened must be a stream_lf. */
     
    #define SYBENTTN   20093 /* Attempt to use dbtxtsput() to put a new text-timestamp into a non-existent data row. */
     
    #define SYBENULL   20109 /* NULL DBPROCESS pointer passed to DB-Library. */
     
    #define SYBENULP   20176 /* Called %s with a NULL %s parameter. */
     
    #define SYBENUM   20159 /* Incorrect number of arguments given to DB-Library. */
     
    #define SYBENXID   20036 /* The Server did not grant us a distributed-transaction ID. */
     
    #define SYBEONCE   20207 /* Function can be called only once. */
     
    #define SYBEOOB   20022 /* Error in sending out-of-band data to SQL Server. */
     
    #define SYBEOPIN   20015 /* Could not open interface file. */
     
    #define SYBEOPNA   20121 /* The text/image facility is available only when using a SQL Server whose version number is 4.0 or greater. */
     
    #define SYBEOPTNO   20163 /* Option is not allowed or is unreconized */
     
    #define SYBEOREN   20141 /* Warning: an out-of-range error-number was encountered in dblib.loc. The maximum permissible error-number is defined as DBERRCOUNT in sybdb.h. */
     
    #define SYBEORPF   20096 /* Attempt to set remote password would overflow the login-record's remote-password field. */
     
    #define SYBEOSSL   20171 /* Operating system login level not in range of Secure SQL Server */
     
    #define SYBEPAGE   20162 /* wrong resource type or length given for dbpage() operation. */
     
    #define SYBEPOLL   20199 /* Only one dbpoll() can be active at a time. */
     
    #define SYBEPORT   2500 /* Both port and instance specified */
     
    #define SYBEPRTF   20191 /* dbtracestring() may only be called from a printfunc(). */
     
    #define SYBEPWD   20014 /* Incorrect password. */
     
    #define SYBERDCN   20053 /* Requested data-conversion does not exist. */
     
    #define SYBERDNR   20044 /* Attempt to retrieve data from a non-existent row. */
     
    #define SYBEREAD   20004 /* Read from SQL Server failed. */
     
    #define SYBERESP   20205 /* Response function address passed to dbresponse() must be non-NULL. */
     
    #define SYBERFILE   20166 /* "Can not open resource file." */
     
    #define SYBERPCS   20186 /* Must call dbrpcinit() before dbrpcparam(). */
     
    #define SYBERPIL   20113 /* It is illegal to pass -1 to dbrpcparam() for the datalen of parameters which are of type SYBCHAR, SYBVARCHAR, SYBBINARY, or SYBVARBINARY. */
     
    #define SYBERPNA   20120 /* The RPC facility is available only when using a SQL Server whose version number is 4.0 or greater. */
     
    #define SYBERPND   20019 /* Attempt to initiate a new SQL Server operation with results pending. */
     
    #define SYBERPNULL   20208 /* value parameter for dbprcparam() can be NULL, only if the datalen parameter is 0 */
     
    #define SYBERPTXTIM   20209 /* RPC parameters cannot be of type Text/Image. */
     
    #define SYBERPUL   20114 /* When passing a SYBINTN, SYBDATETIMN, SYBMONEYN, or SYBFLTN parameter via dbrpcparam(), it's necessary to specify the parameter's maximum or actual length, so that DB-Library can recognize it as a SYBINT1, SYBINT2, SYBINT4, SYBMONEY, or SYBMONEY4, etc. */
     
    #define SYBERTCC   20117 /* dbreadtext() may not be used to receive the results of a query which contains a COMPUTE clause. */
     
    #define SYBERTSC   20118 /* dbreadtext() may only be used to receive the results of a query which contains a single result column. */
     
    #define SYBERTYPE   20165 /* Invalid resource type given to DB-Library. */
     
    #define SYBERXID   20037 /* The Server did not recognize our distributed-transaction ID. */
     
    #define SYBESECURE   20202 /* Secure Server function not supported in this version. */
     
    #define SYBESEFA   20198 /* DBSETNOTIFS cannot be called if connections are present. */
     
    #define SYBESEOF   20017 /* Unexpected EOF from SQL Server. */
     
    #define SYBESFOV   20054 /* dbsafestr() overflowed its destination buffer. */
     
    #define SYBESLCT   20168 /* Could not select or copy field specified */
     
    #define SYBESMSG   20018 /* General SQL Server error: Check messages from the SQL Server. */
     
    #define SYBESOCK   20008 /* Unable to open socket */
     
    #define SYBESPID   20154 /* Called dbspid() with a NULL dbproc. */
     
    #define SYBESYNC   20001 /* Read attempted while out of synchronization with SQL Server. */
     
    #define SYBETDSVER   2410 /* Cannot bcp with TDSVER < 5.0 */
     
    #define SYBETEXS   20188 /* Called dbmoretext() with a bad size parameter. */
     
    #define SYBETIME   20003 /* SQL Server connection timed out. */
     
    #define SYBETMCF   20126 /* Attempt to install too many custom formats via dbfmtinstall(). */
     
    #define SYBETMTD   20092 /* Attempt to send too much TEXT data via the dbmoretext() call. */
     
    #define SYBETPAR   20187 /* No SYBTEXT or SYBIMAGE parameters were defined. */
     
    #define SYBETPTN   20071 /* Syntax error: only two periods are permitted in table names. */
     
    #define SYBETRAC   20189 /* Attempted to turn off a trace flag that was not on. */
     
    #define SYBETRAN   20180 /* DBPROCESS is being used for another transaction. */
     
    #define SYBETRAS   20190 /* DB-Library internal error - trace structure not found. */
     
    #define SYBETRSN   20192 /* Bad numbytes parameter passed to dbtracestring(). */
     
    #define SYBETSIT   20061 /* Attempt to call dbtsput() with an invalid timestamp. */
     
    #define SYBETTS   20066 /* The table which bulk-copy is attempting to copy to a host-file is shorter than the number of rows which bulk-copy was instructed to skip. */
     
    #define SYBETYPE   20160 /* Invalid argument type given to DB-Library. */
     
    #define SYBEUACS   20090 /* VMS: Unable to assign channel to sys$command. */
     
    #define SYBEUAVE   20057 /* Unable to allocate VMS event flag. */
     
    #define SYBEUCPT   20125 /* Unrecognized custom-format parameter-type encountered in dbstrbuild(). */
     
    #define SYBEUCRR   20119 /* Internal software error: Unknown connection result reported by * dbpasswd(). */
     
    #define SYBEUDTY   20060 /* Unknown datatype encountered. */
     
    #define SYBEUFDS   20124 /* Unrecognized format encountered in dbstrbuild(). */
     
    #define SYBEUFDT   20029 /* Unknown fixed-length datatype encountered. */
     
    #define SYBEUHST   20013 /* Unknown host machine name */
     
    #define SYBEUMSG   20212 /* Unknown message-id in MSG datastream. */
     
    #define SYBEUNAM   20110 /* Unable to get current username from operating system. */
     
    #define SYBEUNOP   20115 /* Unknown option passed to dbsetopt(). */
     
    #define SYBEUNT   20055 /* Unknown network type found in interface file. */
     
    #define SYBEURCI   20135 /* Unable to read copyright information from the dblib localization file. */
     
    #define SYBEUREI   20140 /* Unable to read error information from the dblib localization file. */
     
    #define SYBEUREM   20138 /* Unable to read error mnemonic from the dblib localization file. */
     
    #define SYBEURES   20139 /* Unable to read error string from the dblib localization file. */
     
    #define SYBEURMI   20137 /* Unable to read money-format information from the dblib localization file. */
     
    #define SYBEUSCT   20058 /* Unable to set communications timer. */
     
    #define SYBEUTDS   20146 /* Unrecognized TDS version received from SQL Server. */
     
    #define SYBEUVBF   20097 /* Attempt to read an unknown version of BCP format-file. */
     
    #define SYBEUVDT   20028 /* Unknown variable-length datatype encountered. */
     
    #define SYBEVDPT   20079 /* For bulk copy, all variable-length data must have either a length-prefix or a terminator specified. */
     
    #define SYBEVERDOWN   100 /* TDS version downgraded . */
     
    #define SYBEVMS   20007 /* Sendflush: VMS I/O error. */
     
    #define SYBEVOIDRET   20291 /* Parameter of type SYBVOID cannot be a return parameter. */
     
    #define SYBEWAID   20030 /* DB-LIBRARY internal error: ALTFMT following ALTNAME has wrong id. */
     
    #define SYBEWRIT   20006 /* Write to SQL Server failed. */
     
    #define SYBEXOCI   20131 /* A character-set translation overflowed its destination buffer while using bcp to copy data from a host-file to the SQL Server. */
     
    #define SYBEXTDN   20157 /* Warning: the xlt_todisp parameter to dbfree_xlate() was NULL. The space associated with the xlt_tosrv parameter has been freed. */
     
    #define SYBEXTN   20156 /* The xlt_todisp and xlt_tosrv parameters to dbfree_xlate() were NULL. */
     
    #define SYBEXTSN   20158 /* Warning: the xlt_tosrv parameter to dbfree_xlate() was NULL. The space associated with the xlt_todisp parameter has been freed. */
     
    #define SYBEZTXT   20169 /* Attempt to send zero length TEXT or IMAGE to dataserver via dbwritetext(). */
     
    #define SYBFLT8   SYBFLT8
     
    #define SYBFLTN   SYBFLTN
     
    #define SYBIMAGE   SYBIMAGE
     
    #define SYBINT1   SYBINT1
     
    #define SYBINT2   SYBINT2
     
    #define SYBINT4   SYBINT4
     
    #define SYBINT8   SYBINT8
     
    #define SYBINTN   SYBINTN
     
    #define SYBMONEY   SYBMONEY
     
    #define SYBMONEY4   SYBMONEY4
     
    #define SYBMONEYN   SYBMONEYN
     
    #define SYBMSDATE   SYBMSDATE
     
    #define SYBMSDATETIME2   SYBMSDATETIME2
     
    #define SYBMSDATETIMEOFFSET   SYBMSDATETIMEOFFSET
     
    #define SYBMSTIME   SYBMSTIME
     
    #define SYBNTEXT   SYBNTEXT
     
    #define SYBNUMERIC   SYBNUMERIC
     
    #define SYBNVARCHAR   SYBNVARCHAR
     
    #define SYBREAL   SYBREAL
     
    #define SYBTEXT   SYBTEXT
     
    #define SYBTIME   SYBTIME
     
    #define SYBVARBINARY   SYBVARBINARY
     
    #define SYBVARCHAR   SYBVARCHAR
     
    #define SYBVOID   SYBVOID
     
    #define TDS_STATIC_CAST(type, a)   ((type)(a))
     
    #define TIMEBIND   22
     
    #define TINYBIND   6
     
    #define TRUE   1
     
    #define VARYBINBIND   4
     
    #define VARYCHARBIND   3
     

    Typedefs

    typedef int BOOL
     
    typedef unsigned char BYTE
     
    typedef DBWAITFUNC(* DB_DBBUSY_FUNC) (void *dbproc)
     
    typedef int(* DB_DBCHKINTR_FUNC) (void *dbproc)
     
    typedef int(* DB_DBHNDLINTR_FUNC) (void *dbproc)
     
    typedef void(* DB_DBIDLE_FUNC) (DBWAITFUNC dfunc, void *dbproc)
     
    typedef tds_sysdep_int64_type DBBIGINT
     
    typedef unsigned char DBBINARY
     
    typedef unsigned char DBBIT
     
    typedef unsigned char DBBOOL
     
    typedef char DBCHAR
     
    typedef void DBCURSOR
     
    typedef struct tds_sybase_dbdaterec DBDATEREC
     
    typedef struct tds_sybase_dbdaterec2 DBDATEREC2
     
    typedef DBNUMERIC DBDECIMAL
     
    typedef tds_sysdep_real64_type DBFLT8
     
    typedef tds_sysdep_int32_type DBINT
     
    typedef void DBLOGINFO
     
    typedef void(* DBPIVOT_FUNC) (struct col_t *output, const struct col_t *input)
     
    typedef struct tds_dblib_dbprocess DBPROCESS
     
    typedef tds_sysdep_real32_type DBREAL
     
    typedef tds_sysdep_int16_type DBSMALLINT
     
    typedef void DBSORTORDER
     
    typedef struct dbstring DBSTRING
     
    typedef unsigned char DBTINYINT
     
    typedef struct dbtypeinfo DBTYPEINFO
     
    typedef unsigned tds_sysdep_int64_type DBUBIGINT
     
    typedef unsigned tds_sysdep_int32_type DBUINT
     
    typedef unsigned tds_sysdep_int16_type DBUSMALLINT
     
    typedef void * DBVOIDPTR
     
    typedef int(* DBWAITFUNC) (void)
     
    typedef void DBXLATE
     
    typedef int(* EHANDLEFUNC) (DBPROCESS *dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr)
     
    typedef int(* INTFUNCPTR) (void *,...)
     
    typedef struct tds_dblib_loginrec LOGINREC
     
    typedef int(* MHANDLEFUNC) (DBPROCESS *dbproc, DBINT msgno, int msgstate, int severity, char *msgtext, char *srvname, char *proc, int line)
     
    typedef int RETCODE
     
    typedef short SHORT
     
    typedef int STATUS
     
    typedef unsigned short USHORT
     

    Enumerations

    enum  {
      SYBCHAR = 47, SYBCHAR = 47, SYBVARCHAR = 39, SYBVARCHAR = 39,
      SYBINTN = 38, SYBINTN = 38, SYBINT1 = 48, SYBINT1 = 48,
      SYBINT2 = 52, SYBINT2 = 52, SYBINT4 = 56, SYBINT4 = 56,
      SYBINT8 = 127, SYBINT8 = 127, SYBFLT8 = 62, SYBFLT8 = 62,
      SYBDATETIME = 61, SYBDATETIME = 61, SYBBIT = 50, SYBBIT = 50,
      SYBBITN = 104, SYBBITN = 104, SYBTEXT = 35, SYBTEXT = 35,
      SYBNTEXT = 99, SYBNTEXT = 99, SYBIMAGE = 34, SYBIMAGE = 34,
      SYBMONEY4 = 122, SYBMONEY4 = 122, SYBMONEY = 60, SYBMONEY = 60,
      SYBDATETIME4 = 58, SYBDATETIME4 = 58, SYBREAL = 59, SYBREAL = 59,
      SYBBINARY = 45, SYBBINARY = 45, SYBVOID = 31, SYBVOID = 31,
      SYBVARBINARY = 37, SYBVARBINARY = 37, SYBNUMERIC = 108, SYBNUMERIC = 108,
      SYBDECIMAL = 106, SYBDECIMAL = 106, SYBFLTN = 109, SYBFLTN = 109,
      SYBMONEYN = 110, SYBMONEYN = 110, SYBDATETIMN = 111, SYBDATETIMN = 111,
      SYBNVARCHAR = 103, SYBNVARCHAR = 103, SYBDATE = 49, SYBDATE = 49,
      SYBTIME = 51, SYBTIME = 51, SYBBIGDATETIME = 187, SYBBIGDATETIME = 187,
      SYBBIGTIME = 188, SYBBIGTIME = 188, SYBMSDATE = 40, SYBMSDATE = 40,
      SYBMSTIME = 41, SYBMSTIME = 41, SYBMSDATETIME2 = 42, SYBMSDATETIME2 = 42,
      SYBMSDATETIMEOFFSET = 43, SYBMSDATETIMEOFFSET = 43
    }
     
    enum  { MAXCOLNAMELEN = 512 }
     
    enum  CI_TYPE { CI_REGULAR =1, CI_ALTERNATE =2, CI_CURSOR =3 }
     

    Functions

    DBINT bcp_batch (DBPROCESS *dbproc)
     Commit a set of rows to the table. More...
     
    RETCODE bcp_bind (DBPROCESS *dbproc, BYTE *varaddr, int prefixlen, DBINT varlen, BYTE *terminator, int termlen, int type, int table_column)
     Bind a program host variable to a database column. More...
     
    RETCODE bcp_colfmt (DBPROCESS *dbproc, int host_column, int host_type, int host_prefixlen, DBINT host_collen, const BYTE *host_term, int host_termlen, int colnum)
     Specify the format of a datafile prior to writing to a table. More...
     
    RETCODE bcp_colfmt_ps (DBPROCESS *dbproc, int host_column, int host_type, int host_prefixlen, DBINT host_collen, BYTE *host_term, int host_termlen, int colnum, DBTYPEINFO *typeinfo)
     Specify the format of a host file for bulk copy purposes, with precision and scale support for numeric and decimal columns. More...
     
    RETCODE bcp_collen (DBPROCESS *dbproc, DBINT varlen, int table_column)
     Set the length of a host variable to be written to a table. More...
     
    RETCODE bcp_colptr (DBPROCESS *dbproc, BYTE *colptr, int table_column)
     Override bcp_bind() by pointing to a different host variable. More...
     
    RETCODE bcp_columns (DBPROCESS *dbproc, int host_colcount)
     Indicate how many columns are to be found in the datafile. More...
     
    RETCODE bcp_control (DBPROCESS *dbproc, int field, DBINT value)
     Set BCP options for uploading a datafile. More...
     
    DBINT bcp_done (DBPROCESS *dbproc)
     Conclude the transfer of data from program variables. More...
     
    RETCODE bcp_exec (DBPROCESS *dbproc, DBINT *rows_copied)
     Write a datafile to a table. More...
     
    int bcp_getbatchsize (DBPROCESS *dbproc)
     
    DBBOOL bcp_getl (LOGINREC *login)
     See if BCP_SETL() was used to set the LOGINREC for BCP work. More...
     
    RETCODE bcp_init (DBPROCESS *dbproc, const char *tblname, const char *hfile, const char *errfile, int direction)
     Prepare for bulk copy operation on a table. More...
     
    RETCODE bcp_options (DBPROCESS *dbproc, int option, BYTE *value, int valuelen)
     Set "hints" for uploading a file. More...
     
    RETCODE bcp_readfmt (DBPROCESS *dbproc, const char filename[])
     Read a format definition file. More...
     
    RETCODE bcp_sendrow (DBPROCESS *dbproc)
     Write data in host variables to the table. More...
     
    BYTE * dbadata (DBPROCESS *dbproc, int computeid, int column)
     Get address of compute column data. More...
     
    DBINT dbadlen (DBPROCESS *dbproc, int computeid, int column)
     Get size of data in a compute column. More...
     
    RETCODE dbaltbind (DBPROCESS *dbprocess, int computeid, int column, int vartype, DBINT varlen, BYTE *varaddr)
     Bind a compute column to a program variable. More...
     
    RETCODE dbaltbind_ps (DBPROCESS *dbprocess, int computeid, int column, int vartype, DBINT varlen, BYTE *varaddr, DBTYPEINFO *typeinfo)
     
    int dbaltcolid (DBPROCESS *dbproc, int computeid, int column)
     Get column ID of a compute column. More...
     
    DBINT dbaltlen (DBPROCESS *dbproc, int computeid, int column)
     Get size of data in compute column. More...
     
    int dbaltop (DBPROCESS *dbproc, int computeid, int column)
     Get aggregation operator for a compute column. More...
     
    int dbalttype (DBPROCESS *dbproc, int computeid, int column)
     Get datatype for a compute column. More...
     
    DBINT dbaltutype (DBPROCESS *dbproc, int computeid, int column)
     Get user-defined datatype of a compute column. More...
     
    RETCODE dbanullbind (DBPROCESS *dbprocess, int computeid, int column, DBINT *indicator)
     Tie a null-indicator to a compute result column. More...
     
    RETCODE dbanydatecrack (DBPROCESS *dbproc, DBDATEREC2 *di, int type, const void *data)
     Break any kind of date or time value into useful pieces. More...
     
    RETCODE dbbind (DBPROCESS *dbproc, int column, int vartype, DBINT varlen, BYTE *varaddr)
     Tie a host variable to a resultset column. More...
     
    RETCODE dbbind_ps (DBPROCESS *dbprocess, int column, int vartype, DBINT varlen, BYTE *varaddr, DBTYPEINFO *typeinfo)
     
    int dbbufsize (DBPROCESS *dbprocess)
     
    BYTE * dbbylist (DBPROCESS *dbproc, int computeid, int *size)
     Get bylist for a compute row. More...
     
    RETCODE dbcancel (DBPROCESS *dbproc)
     Cancel the current command batch. More...
     
    RETCODE dbcanquery (DBPROCESS *dbproc)
     Cancel the query currently being retrieved, discarding all pending rows. More...
     
    char * dbchange (DBPROCESS *dbprocess)
     See if a command caused the current database to change. More...
     
    DBBOOL dbcharsetconv (DBPROCESS *dbprocess)
     
    void dbclose (DBPROCESS *dbproc)
     Close a connection to the server and free associated resources. More...
     
    void dbclrbuf (DBPROCESS *dbproc, DBINT n)
     Clear n rows from the row buffer. More...
     
    RETCODE dbclropt (DBPROCESS *dbproc, int option, const char param[])
     Reset an option. More...
     
    RETCODE dbcmd (DBPROCESS *dbproc, const char cmdstring[])
     Append SQL to the command buffer. More...
     
    RETCODE dbcmdrow (DBPROCESS *dbproc)
     See if the current command can return rows. More...
     
    RETCODE dbcolinfo (DBPROCESS *dbproc, CI_TYPE type, DBINT column, DBINT computeid, DBCOL *pdbcol)
     Get a bunch of column attributes with a single call (Microsoft-compatibility feature). More...
     
    DBINT dbcollen (DBPROCESS *dbproc, int column)
     Get size of a regular result column. More...
     
    char * dbcolname (DBPROCESS *dbproc, int column)
     Return name of a regular result column. More...
     
    char * dbcolsource (DBPROCESS *dbproc, int colnum)
     Get base database column name for a result set column. More...
     
    int dbcoltype (DBPROCESS *dbproc, int column)
     Get the datatype of a regular result set column. More...
     
    DBTYPEINFOdbcoltypeinfo (DBPROCESS *dbproc, int column)
     Get precision and scale information for a regular result column. More...
     
    DBINT dbcolutype (DBPROCESS *dbprocess, int column)
     Get user-defined datatype of a regular result column. More...
     
    DBINT dbconvert (DBPROCESS *dbproc, int srctype, const BYTE *src, DBINT srclen, int desttype, BYTE *dest, DBINT destlen)
     cf. More...
     
    DBINT dbconvert_ps (DBPROCESS *dbprocess, int srctype, const BYTE *src, DBINT srclen, int desttype, BYTE *dest, DBINT destlen, DBTYPEINFO *typeinfo)
     Convert one datatype to another. More...
     
    DBINT dbcount (DBPROCESS *dbproc)
     Get count of rows processed. More...
     
    int dbcurcmd (DBPROCESS *dbproc)
     Get number of the row just returned. More...
     
    DBINT dbcurrow (DBPROCESS *dbproc)
     Get number of the row currently being read. More...
     
    BYTE * dbdata (DBPROCESS *dbproc, int column)
     Get address of data in a regular result column. More...
     
    int dbdatecmp (DBPROCESS *dbproc, DBDATETIME *d1, DBDATETIME *d2)
     Compare DBDATETIME values, similar to strcmp(3). More...
     
    RETCODE dbdatecrack (DBPROCESS *dbproc, DBDATEREC *di, DBDATETIME *dt)
     Break a DBDATETIME value into useful pieces. More...
     
    DBINT dbdatlen (DBPROCESS *dbproc, int column)
     Get size of current row's data in a regular result column. More...
     
    DBBOOL dbdead (DBPROCESS *dbproc)
     Check if dbproc is an ex-parrot. More...
     
    EHANDLEFUNC dberrhandle (EHANDLEFUNC handler)
     Set an error handler, for messages from db-lib. More...
     
    void dbexit (void)
     Close server connections and free all related structures. More...
     
    RETCODE dbfcmd (DBPROCESS *dbproc, const char *fmt,...)
     printf-like way to form SQL to send to the server. More...
     
    DBINT dbfirstrow (DBPROCESS *dbproc)
     See if a server response has arrived. More...
     
    void dbfreebuf (DBPROCESS *dbproc)
     Erase the command buffer, in case DBNOAUTOFREE was set with dbsetopt(). More...
     
    char * dbgetchar (DBPROCESS *dbprocess, int n)
     Get address of a position in the command buffer. More...
     
    char * dbgetcharset (DBPROCESS *dbprocess)
     
    int dbgetlusername (LOGINREC *login, BYTE *name_buffer, int buffer_len)
     
    int dbgetmaxprocs (void)
     get maximum simultaneous connections db-lib will open to the server. More...
     
    char * dbgetnatlanf (DBPROCESS *dbprocess)
     
    int dbgetpacket (DBPROCESS *dbproc)
     Get TDS packet size for the connection. More...
     
    RETCODE dbgetrow (DBPROCESS *dbproc, DBINT row)
     Read a row from the row buffer. More...
     
    int dbgettime (void)
     Get maximum seconds db-lib waits for a server response to query. More...
     
    BYTE * dbgetuserdata (DBPROCESS *dbproc)
     Get address of user-allocated data from a DBPROCESS. More...
     
    DBBOOL dbhasretstat (DBPROCESS *dbproc)
     Determine if query generated a return status number. More...
     
    RETCODE dbinit (void)
     Initialize db-lib. More...
     
    int dbiordesc (DBPROCESS *dbproc)
     Get file descriptor of the socket used by a DBPROCESS to read data coming from the server. (!) More...
     
    int dbiowdesc (DBPROCESS *dbproc)
     Get file descriptor of the socket used by a DBPROCESS to write data coming to the server. (!) More...
     
    DBBOOL dbisavail (DBPROCESS *dbprocess)
     
    BOOL dbiscount (DBPROCESS *dbproc)
     Indicates whether or not the count returned by dbcount is real (Microsoft-compatibility feature). More...
     
    DBBOOL dbisopt (DBPROCESS *dbproc, int option, const char param[])
     Get value of an option. More...
     
    DBINT dblastrow (DBPROCESS *dbproc)
     Get number of the last row in the row buffer. More...
     
    LOGINRECdblogin (void)
     Allocate a LOGINREC structure. More...
     
    void dbloginfree (LOGINREC *login)
     free the LOGINREC More...
     
    RETCODE dbmny4add (DBPROCESS *dbproc, DBMONEY4 *m1, DBMONEY4 *m2, DBMONEY4 *sum)
     Add two DBMONEY4 values. More...
     
    int dbmny4cmp (DBPROCESS *dbproc, DBMONEY4 *m1, DBMONEY4 *m2)
     Compare two DBMONEY4 values. More...
     
    RETCODE dbmny4copy (DBPROCESS *dbprocess, DBMONEY4 *m1, DBMONEY4 *m2)
     Copy a DBMONEY4 value. More...
     
    RETCODE dbmny4minus (DBPROCESS *dbproc, DBMONEY4 *src, DBMONEY4 *dest)
     Negate a DBMONEY4 value. More...
     
    RETCODE dbmny4sub (DBPROCESS *dbproc, DBMONEY4 *m1, DBMONEY4 *m2, DBMONEY4 *diff)
     Subtract two DBMONEY4 values. More...
     
    RETCODE dbmny4zero (DBPROCESS *dbproc, DBMONEY4 *dest)
     Zero a DBMONEY4 value. More...
     
    int dbmnycmp (DBPROCESS *dbproc, DBMONEY *m1, DBMONEY *m2)
     Compare two DBMONEY values. More...
     
    RETCODE dbmnycopy (DBPROCESS *dbproc, DBMONEY *src, DBMONEY *dest)
     Copy a DBMONEY value. More...
     
    RETCODE dbmnydec (DBPROCESS *dbproc, DBMONEY *mnyptr)
     Subtract $0.0001 from a DBMONEY value. More...
     
    RETCODE dbmnyinc (DBPROCESS *dbproc, DBMONEY *mnyptr)
     Add $0.0001 to a DBMONEY value. More...
     
    RETCODE dbmnymaxneg (DBPROCESS *dbproc, DBMONEY *dest)
     Get maximum negative DBMONEY value supported. More...
     
    RETCODE dbmnymaxpos (DBPROCESS *dbproc, DBMONEY *dest)
     Get maximum positive DBMONEY value supported. More...
     
    RETCODE dbmnyminus (DBPROCESS *dbproc, DBMONEY *src, DBMONEY *dest)
     Negate a DBMONEY value. More...
     
    RETCODE dbmnysub (DBPROCESS *dbproc, DBMONEY *m1, DBMONEY *m2, DBMONEY *diff)
     
    RETCODE dbmnyzero (DBPROCESS *dbproc, DBMONEY *dest)
     Set a DBMONEY value to zero. More...
     
    const char * dbmonthname (DBPROCESS *dbproc, char *language, int monthnum, DBBOOL shortform)
     Get name of a month, in some human language. More...
     
    RETCODE dbmorecmds (DBPROCESS *dbproc)
     See if more commands are to be processed. More...
     
    RETCODE dbmoretext (DBPROCESS *dbproc, DBINT size, const BYTE text[])
     Send chunk of a text/image value to the server. More...
     
    MHANDLEFUNC dbmsghandle (MHANDLEFUNC handler)
     Set a message handler, for messages from the server. More...
     
    char * dbname (DBPROCESS *dbproc)
     Get name of current database. More...
     
    STATUS dbnextrow (DBPROCESS *dbproc)
     
    STATUS dbnextrow_pivoted (DBPROCESS *dbproc, struct pivot_t *pp)
     
    RETCODE dbnullbind (DBPROCESS *dbproc, int column, DBINT *indicator)
     Tie a null-indicator to a regular result column. More...
     
    int dbnumalts (DBPROCESS *dbproc, int computeid)
     Get count of columns in a compute row. More...
     
    int dbnumcols (DBPROCESS *dbproc)
     Return number of regular columns in a result set. More...
     
    int dbnumcompute (DBPROCESS *dbprocess)
     Get count of COMPUTE clauses for a result set. More...
     
    int dbnumrets (DBPROCESS *dbproc)
     Get count of output parameters filled by a stored procedure. More...
     
    DBPROCESSdbopen (LOGINREC *login, const char *server)
     Normally not used. More...
     
    RETCODE dbpivot (DBPROCESS *dbproc, int nkeys, int *keys, int ncols, int *cols, DBPIVOT_FUNC func, int val)
     Pivot the rows, creating a new resultset. More...
     
    void dbpivot_count (struct col_t *output, const struct col_t *input)
     
    DBPIVOT_FUNC dbpivot_lookup_name (const char name[])
     
    void dbpivot_max (struct col_t *output, const struct col_t *input)
     
    void dbpivot_min (struct col_t *output, const struct col_t *input)
     
    void dbpivot_sum (struct col_t *output, const struct col_t *input)
     
    DBINT dbprcollen (DBPROCESS *dbproc, int column)
     Get size of a result column needed to print column. More...
     
    void dbprhead (DBPROCESS *dbproc)
     Print result set headings to stdout. More...
     
    RETCODE dbprrow (DBPROCESS *dbproc)
     Print a result set to stdout. More...
     
    const char * dbprtype (int token)
     Print a token value's name to a buffer. More...
     
    STATUS dbreadtext (DBPROCESS *dbproc, void *buf, DBINT bufsize)
     Fetch part of a text or image value from the server. More...
     
    void dbrecftos (const char filename[])
     Record to a file all SQL commands sent to the server. More...
     
    RETCODE dbresults (DBPROCESS *dbproc)
     Set up query results. More...
     
    RETCODE dbresults_r (DBPROCESS *dbproc, int recursive)
     
    BYTE * dbretdata (DBPROCESS *dbproc, int retnum)
     Get value of an output parameter filled by a stored procedure. More...
     
    int dbretlen (DBPROCESS *dbproc, int retnum)
     Get size of an output parameter filled by a stored procedure. More...
     
    char * dbretname (DBPROCESS *dbproc, int retnum)
     Get name of an output parameter filled by a stored procedure. More...
     
    DBINT dbretstatus (DBPROCESS *dbproc)
     Fetch status value returned by query or remote procedure call. More...
     
    int dbrettype (DBPROCESS *dbproc, int retnum)
     Get datatype of a stored procedure's return parameter. More...
     
    RETCODE dbrows (DBPROCESS *dbproc)
     Indicate whether a query returned rows. More...
     
    struct pivot_tdbrows_pivoted (DBPROCESS *dbproc)
     
    STATUS dbrowtype (DBPROCESS *dbprocess)
     Get returned row's type. More...
     
    RETCODE dbrpcinit (DBPROCESS *dbproc, const char rpcname[], DBSMALLINT options)
     Initialize a remote procedure call. More...
     
    RETCODE dbrpcparam (DBPROCESS *dbproc, const char paramname[], BYTE status, int type, DBINT maxlen, DBINT datalen, BYTE *value)
     Add a parameter to a remote procedure call. More...
     
    RETCODE dbrpcsend (DBPROCESS *dbproc)
     Execute the procedure and free associated memory. More...
     
    RETCODE dbsafestr (DBPROCESS *dbproc, const char *src, DBINT srclen, char *dest, DBINT destlen, int quotetype)
     safely quotes character values in SQL text. More...
     
    RETCODE * dbsechandle (DBINT type, INTFUNCPTR handler)
     
    char * dbservcharset (DBPROCESS *dbprocess)
     Get syscharset name of the server character set. More...
     
    void dbsetavail (DBPROCESS *dbprocess)
     Mark a DBPROCESS as "available". More...
     
    void dbsetbusy (DBPROCESS *dbprocess, DB_DBBUSY_FUNC busyfunc)
     
    RETCODE dbsetdefcharset (char *charset)
     
    void dbsetidle (DBPROCESS *dbprocess, DB_DBIDLE_FUNC idlefunc)
     
    void dbsetifile (char *filename)
     set name and location of the interfaces file FreeTDS should use to look up a servername. More...
     
    void dbsetinterrupt (DBPROCESS *dbproc, DB_DBCHKINTR_FUNC chkintr, DB_DBHNDLINTR_FUNC hndlintr)
     Set interrupt handler for db-lib to use while blocked against a read from the server. More...
     
    RETCODE dbsetlbool (LOGINREC *login, int value, int which)
     Set a boolean value in a LOGINREC structure. More...
     
    RETCODE dbsetllong (LOGINREC *login, long value, int which)
     Set an integer value in a LOGINREC structure. More...
     
    RETCODE dbsetlname (LOGINREC *login, const char *value, int which)
     Set the value of a string in a LOGINREC structure. More...
     
    RETCODE dbsetlogintime (int seconds)
     Set maximum seconds db-lib waits for a server response to a login attempt. More...
     
    RETCODE dbsetlshort (LOGINREC *login, int value, int which)
     
    RETCODE dbsetlversion (LOGINREC *login, BYTE version)
     Set TDS version for future connections. More...
     
    RETCODE dbsetmaxprocs (int maxprocs)
     Set maximum simultaneous connections db-lib will open to the server. More...
     
    RETCODE dbsetnull (DBPROCESS *dbprocess, int bindtype, int bindlen, BYTE *bindval)
     Define substitution values to be used when binding null values. More...
     
    RETCODE dbsetopt (DBPROCESS *dbproc, int option, const char *char_param, int int_param)
     Set db-lib or server option. More...
     
    STATUS dbsetrow (DBPROCESS *dbprocess, DBINT row)
     Make a buffered row "current" without fetching it into bound variables. More...
     
    RETCODE dbsettime (int seconds)
     Set maximum seconds db-lib waits for a server response to query. More...
     
    void dbsetuserdata (DBPROCESS *dbproc, BYTE *ptr)
     Associate client-allocated (and defined) data with a DBPROCESS. More...
     
    RETCODE dbsetversion (DBINT version)
     Specify a db-lib version level. More...
     
    int dbspid (DBPROCESS *dbproc)
     Get server process ID for a DBPROCESS. More...
     
    RETCODE dbspr1row (DBPROCESS *dbproc, char *buffer, DBINT buf_len)
     Print a regular result row to a buffer. More...
     
    DBINT dbspr1rowlen (DBPROCESS *dbproc)
     Determine size buffer required to hold the results returned by dbsprhead(), dbsprline(), and dbspr1row(). More...
     
    RETCODE dbsprhead (DBPROCESS *dbproc, char *buffer, DBINT buf_len)
     Print result set headings to a buffer. More...
     
    RETCODE dbsprline (DBPROCESS *dbproc, char *buffer, DBINT buf_len, DBCHAR line_char)
     Get formatted string for underlining dbsprhead() column names. More...
     
    RETCODE dbsqlexec (DBPROCESS *dbproc)
     send the SQL command to the server and wait for an answer. More...
     
    RETCODE dbsqlok (DBPROCESS *dbproc)
     Wait for results of a query from the server. More...
     
    RETCODE dbsqlsend (DBPROCESS *dbproc)
     Transmit the command buffer to the server. More...
     
    int dbstrbuild (DBPROCESS *dbproc, char *charbuf, int bufsize, char *text, char *formats,...)
     Build a printable string from text containing placeholders for variables. More...
     
    RETCODE dbstrcpy (DBPROCESS *dbproc, int start, int numbytes, char *dest)
     Get a copy of a chunk of the command buffer. More...
     
    int dbstrlen (DBPROCESS *dbproc)
     Get size of the command buffer, in bytes. More...
     
    RETCODE dbtablecolinfo (DBPROCESS *dbproc, DBINT column, DBCOL *pdbcol)
     describe table column attributes with a single call (Freetds-only API function modelled on dbcolinfo) More...
     
    int dbtds (DBPROCESS *dbprocess)
     Get the TDS version in use for dbproc. More...
     
    DBINT dbtextsize (DBPROCESS *dbprocess)
     
    DBBINARY * dbtxptr (DBPROCESS *dbproc, int column)
     Get text pointer for a column in the current row. More...
     
    DBBINARY * dbtxtimestamp (DBPROCESS *dbproc, int column)
     Get text timestamp for a column in the current row. More...
     
    DBBINARY * dbtxtsnewval (DBPROCESS *dbprocess)
     
    RETCODE dbtxtsput (DBPROCESS *dbprocess, DBBINARY newtxts, int colnum)
     
    RETCODE dbuse (DBPROCESS *dbproc, const char *name)
     Change current database. More...
     
    DBINT dbvarylen (DBPROCESS *dbproc, int column)
     Determine whether a column can vary in size. More...
     
    const char * dbversion (void)
     See which version of db-lib is in use. More...
     
    DBBOOL dbwillconvert (int srctype, int desttype)
     Test whether or not a datatype can be converted to another datatype. More...
     
    RETCODE dbwritetext (DBPROCESS *dbproc, char *objname, DBBINARY *textptr, DBTINYINT textptrlen, DBBINARY *timestamp, DBBOOL log, DBINT size, BYTE *text)
     Send text or image data to the server. More...
     
    DBBOOL DRBUF (DBPROCESS *dbprocess)
     
    DBPROCESStdsdbopen (LOGINREC *login, const char *server, int msdblib)
     Form a connection with the server. More...
     

    Detailed Description

    Primary include file for db-lib applications.

    Declares macros, functions, enumerated types, and defined tokens used by the db-lib API.

    Function Documentation

    § dbcolinfo()

    RETCODE dbcolinfo ( DBPROCESS dbproc,
    CI_TYPE  type,
    DBINT  column,
    DBINT  computeid,
    DBCOL pdbcol 
    )

    Get a bunch of column attributes with a single call (Microsoft-compatibility feature).

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    typemust be CI_REGULAR or CI_ALTERNATE (CI_CURSOR is defined by the vendor, but is not yet implemented).
    columnNth in the result set, starting from 1.
    computeid(ignored)
    pdbcoladdress of structure to be populated by this function.
    Returns
    SUCCEED or FAIL.
    See also
    dbcolbrowse(), dbqual(), dbtabbrowse(), dbtabcount(), dbtabname(), dbtabsource(), dbtsnewlen(), dbtsnewval(), dbtsput().
    Todo:
    Support cursor rows.
    Here is the call graph for this function:

    § dbopen()

    DBPROCESS* dbopen ( LOGINREC login,
    const char *  server 
    )

    Normally not used.

    The function is linked in only if the –enable-sybase-compat configure option is used. Cf. sybdb.h dbopen() macros, and dbdatecrack().

    Here is the call graph for this function:

    § dbpivot()

    RETCODE dbpivot ( DBPROCESS dbproc,
    int  nkeys,
    int *  keys,
    int  ncols,
    int *  cols,
    DBPIVOT_FUNC  func,
    int  val 
    )

    Pivot the rows, creating a new resultset.

    Call dbpivot() immediately after dbresults(). It calls dbnextrow() as long as it returns REG_ROW, transforming the results into a cross-tab report. dbpivot() modifies the metadata such that DB-Library can be used tranparently: retrieve the rows as usual with dbnumcols(), dbnextrow(), etc.

    , our old friend the number of left-edge columns to group by an array of left-edge columns to group by the number of top-edge columns to group by an array of top-edge columns to group by the aggregation function to use the number of the column to which is applied

    Returns
    the return code from the final call to dbnextrow(). Success is normally indicated by NO_MORE_ROWS.
    freetds-1.00.82/doc/reference/a00479_a9b73fd1afa2c3ccfca481635212d2e43_cgraph.map100644 025423 025423 00000000313 13242511134 0021313 freetds-1.00.82/doc/reference/a00479_a9b73fd1afa2c3ccfca481635212d2e43_cgraph.md5100644 025423 025423 00000000040 13242511133 0021217214a36c80c247fb3fccfe97d55de1efffreetds-1.00.82/doc/reference/a00479_source.html100644 025423 025423 00001157734 13242511132 0014637 FreeTDS API: include/sybdb.h Source File
    FreeTDS API
    sybdb.h
    Go to the documentation of this file.
    1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
    2  * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Brian Bruns
    3  * Copyright (C) 2010, 2011 Frediano Ziglio
    4  *
    5  * This library is free software; you can redistribute it and/or
    6  * modify it under the terms of the GNU Library General Public
    7  * License as published by the Free Software Foundation; either
    8  * version 2 of the License, or (at your option) any later version.
    9  *
    10  * This library is distributed in the hope that it will be useful,
    11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    13  * Library General Public License for more details.
    14  *
    15  * You should have received a copy of the GNU Library General Public
    16  * License along with this library; if not, write to the
    17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    18  * Boston, MA 02111-1307, USA.
    19  */
    20 
    28 #ifndef _sybdb_h_
    29 #define _sybdb_h_
    30 
    31 #include "tds_sysdep_public.h"
    32 
    33 #undef TDS_STATIC_CAST
    34 #ifdef __cplusplus
    35 #define TDS_STATIC_CAST(type, a) static_cast<type>(a)
    36 extern "C"
    37 {
    38 #if 0
    39 }
    40 #endif
    41 #else
    42 #define TDS_STATIC_CAST(type, a) ((type)(a))
    43 #endif
    44 
    45 #ifdef FALSE
    46 #undef FALSE
    47 #endif
    48 #ifdef TRUE
    49 #undef TRUE
    50 #endif
    51 #define FALSE 0
    52 #define TRUE 1
    53 
    54 #define DBSAVE 1
    55 #define DBNOSAVE 0
    56 #define DBNOERR -1
    57 
    58 #define INT_EXIT 0
    59 #define INT_CONTINUE 1
    60 #define INT_CANCEL 2
    61 #define INT_TIMEOUT 3
    62 
    63 #define DBMAXNUMLEN 33
    64 /* https://msdn.microsoft.com/en-us/library/ms176061.aspx */
    65 #define DBMAXNAME 128
    66 
    70 #define DBVERSION_UNKNOWN 0
    71 #define DBVERSION_46 1
    72 #define DBVERSION_100 2
    73 #define DBVERSION_42 3
    74 #define DBVERSION_70 4
    75 #define DBVERSION_71 5
    76 #define DBVERSION_72 6
    77 #define DBVERSION_73 7
    78 #define DBVERSION_74 8
    79 
    80 /* these two are defined by Microsoft for dbsetlversion() */
    81 #define DBVER42 DBVERSION_42
    82 #define DBVER60 DBVERSION_70 /* our best approximation */
    83 
    88 #define DBTDS_UNKNOWN 0
    89 #define DBTDS_2_0 1 /* pre 4.0 SQL Server */
    90 #define DBTDS_3_4 2 /* Microsoft SQL Server (3.0) */
    91 #define DBTDS_4_0 3 /* 4.0 SQL Server */
    92 #define DBTDS_4_2 4 /* 4.2 SQL Server */
    93 #define DBTDS_4_6 5 /* 2.0 OpenServer and 4.6 SQL Server. */
    94 #define DBTDS_4_9_5 6 /* 4.9.5 (NCR) SQL Server */
    95 #define DBTDS_5_0 7 /* 5.0 SQL Server */
    96 #define DBTDS_7_0 8 /* Microsoft SQL Server 7.0 */
    97 #define DBTDS_8_0 9 /* Microsoft SQL Server 2000 */
    98 #define DBTDS_9_0 10 /* Microsoft SQL Server 2005 */
    99 #define DBTDS_7_1 9 /* Microsoft SQL Server 2000 */
    100 #define DBTDS_7_2 10 /* Microsoft SQL Server 2005 */
    101 #define DBTDS_7_3 11 /* Microsoft SQL Server 2008 */
    102 #define DBTDS_7_4 12 /* Microsoft SQL Server 2012/2014 */
    103 
    104 #define DBTXPLEN 16
    105 
    106 #define BCPMAXERRS 1
    107 #define BCPFIRST 2
    108 #define BCPLAST 3
    109 #define BCPBATCH 4
    110 #define BCPKEEPIDENTITY 8
    111 
    112 #define BCPLABELED 5
    113 #define BCPHINTS 6
    114 
    115 #define DBCMDNONE 0
    116 #define DBCMDPEND 1
    117 #define DBCMDSENT 2
    118 
    119 typedef int RETCODE;
    120 
    121 typedef void DBCURSOR;
    122 typedef void DBXLATE;
    123 typedef void DBSORTORDER;
    124 typedef void DBLOGINFO;
    125 typedef void *DBVOIDPTR;
    126 typedef short SHORT;
    127 typedef unsigned short USHORT;
    128 typedef int (*INTFUNCPTR) (void *, ...);
    129 typedef int (*DBWAITFUNC) (void);
    130 typedef DBWAITFUNC(*DB_DBBUSY_FUNC) (void *dbproc);
    131 typedef void (*DB_DBIDLE_FUNC) (DBWAITFUNC dfunc, void *dbproc);
    132 typedef int (*DB_DBCHKINTR_FUNC) (void *dbproc);
    133 typedef int (*DB_DBHNDLINTR_FUNC) (void *dbproc);
    134 
    135 #ifndef __INCvxWorksh
    136 /* VxWorks already defines STATUS and BOOL. Compiler gets mad if you
    137 ** redefine them. */
    138 /* __INCvxWorksh will get #defined by std. include files included from tds.h
    139 */
    140 #ifdef STATUS
    141 /* On DU4.0d we get a conflicting STATUS definition from arpa/nameser.h
    142  when _REENTRANT is defined.
    143 */
    144 #undef STATUS
    145 #endif
    146 typedef int STATUS;
    147 #if !defined(_WINDEF_) && !defined(_WINDEF_H) && !defined(DOS32X)
    148 typedef int BOOL;
    149 #endif
    150 #endif
    151 
    152 #ifndef _tds_h_
    153 /* copied from tds.h */
    154 /* TODO find a best way... */
    155 enum
    156 {
    157  SYBCHAR = 47, /* 0x2F */
    158 #define SYBCHAR SYBCHAR
    159  SYBVARCHAR = 39, /* 0x27 */
    160 #define SYBVARCHAR SYBVARCHAR
    161  SYBINTN = 38, /* 0x26 */
    162 #define SYBINTN SYBINTN
    163  SYBINT1 = 48, /* 0x30 */
    164 #define SYBINT1 SYBINT1
    165  SYBINT2 = 52, /* 0x34 */
    166 #define SYBINT2 SYBINT2
    167  SYBINT4 = 56, /* 0x38 */
    168 #define SYBINT4 SYBINT4
    169  SYBINT8 = 127, /* 0x7F */
    170 #define SYBINT8 SYBINT8
    171  SYBFLT8 = 62, /* 0x3E */
    172 #define SYBFLT8 SYBFLT8
    173  SYBDATETIME = 61, /* 0x3D */
    174 #define SYBDATETIME SYBDATETIME
    175  SYBBIT = 50, /* 0x32 */
    176 #define SYBBIT SYBBIT
    177  SYBBITN = 104, /* 0x68 */
    178 #define SYBBITN SYBBITN
    179  SYBTEXT = 35, /* 0x23 */
    180 #define SYBTEXT SYBTEXT
    181  SYBNTEXT = 99, /* 0x63 */
    182 #define SYBNTEXT SYBNTEXT
    183  SYBIMAGE = 34, /* 0x22 */
    184 #define SYBIMAGE SYBIMAGE
    185  SYBMONEY4 = 122, /* 0x7A */
    186 #define SYBMONEY4 SYBMONEY4
    187  SYBMONEY = 60, /* 0x3C */
    188 #define SYBMONEY SYBMONEY
    189  SYBDATETIME4 = 58, /* 0x3A */
    190 #define SYBDATETIME4 SYBDATETIME4
    191  SYBREAL = 59, /* 0x3B */
    192 #define SYBREAL SYBREAL
    193  SYBBINARY = 45, /* 0x2D */
    194 #define SYBBINARY SYBBINARY
    195  SYBVOID = 31, /* 0x1F */
    196 #define SYBVOID SYBVOID
    197  SYBVARBINARY = 37, /* 0x25 */
    198 #define SYBVARBINARY SYBVARBINARY
    199  SYBNUMERIC = 108, /* 0x6C */
    200 #define SYBNUMERIC SYBNUMERIC
    201  SYBDECIMAL = 106, /* 0x6A */
    202 #define SYBDECIMAL SYBDECIMAL
    203  SYBFLTN = 109, /* 0x6D */
    204 #define SYBFLTN SYBFLTN
    205  SYBMONEYN = 110, /* 0x6E */
    206 #define SYBMONEYN SYBMONEYN
    207  SYBDATETIMN = 111, /* 0x6F */
    208 #define SYBDATETIMN SYBDATETIMN
    209  SYBNVARCHAR = 103, /* 0x67 */
    210 #define SYBNVARCHAR SYBNVARCHAR
    211  SYBDATE = 49, /* 0x31 */
    212 #define SYBDATE SYBDATE
    213  SYBTIME = 51, /* 0x33 */
    214 #define SYBTIME SYBTIME
    215  SYBBIGDATETIME = 187, /* 0xBB */
    216 #define SYBBIGDATETIME SYBBIGDATETIME
    217  SYBBIGTIME = 188, /* 0xBC */
    218 #define SYBBIGTIME SYBBIGTIME
    219  SYBMSDATE = 40, /* 0x28 */
    220 #define SYBMSDATE SYBMSDATE
    221  SYBMSTIME = 41, /* 0x29 */
    222 #define SYBMSTIME SYBMSTIME
    223  SYBMSDATETIME2 = 42, /* 0x2A */
    224 #define SYBMSDATETIME2 SYBMSDATETIME2
    225  SYBMSDATETIMEOFFSET = 43, /* 0x2B */
    226 #define SYBMSDATETIMEOFFSET SYBMSDATETIMEOFFSET
    227 };
    228 
    229 #define SYBAOPCNT 0x4b
    230 #define SYBAOPCNTU 0x4c
    231 #define SYBAOPSUM 0x4d
    232 #define SYBAOPSUMU 0x4e
    233 #define SYBAOPAVG 0x4f
    234 #define SYBAOPAVGU 0x50
    235 #define SYBAOPMIN 0x51
    236 #define SYBAOPMAX 0x52
    237 
    238 /* mssql2k compute operator */
    239 #define SYBAOPCNT_BIG 0x09
    240 #define SYBAOPSTDEV 0x30
    241 #define SYBAOPSTDEVP 0x31
    242 #define SYBAOPVAR 0x32
    243 #define SYBAOPVARP 0x33
    244 #define SYBAOPCHECKSUM_AGG 0x72
    245 
    246 #endif
    247 
    248 typedef unsigned char DBBOOL;
    249 typedef char DBCHAR;
    250 typedef unsigned char DBBIT;
    251 typedef unsigned char DBTINYINT;
    252 typedef tds_sysdep_int16_type DBSMALLINT;
    253 typedef tds_sysdep_int32_type DBINT;
    254 typedef tds_sysdep_int64_type DBBIGINT;
    255 typedef unsigned char DBBINARY;
    256 typedef tds_sysdep_real32_type DBREAL;
    257 typedef tds_sysdep_real64_type DBFLT8;
    258 typedef unsigned tds_sysdep_int16_type DBUSMALLINT;
    259 typedef unsigned tds_sysdep_int32_type DBUINT;
    260 typedef unsigned tds_sysdep_int64_type DBUBIGINT;
    261 
    262 typedef struct
    263 {
    264  DBSMALLINT len;
    265  char str[256];
    266 } DBVARYCHAR;
    267 
    268 typedef struct
    269 {
    270  DBSMALLINT len;
    271  unsigned char array[256];
    272 } DBVARYBIN;
    273 
    274 typedef struct
    275 {
    276  unsigned char precision;
    277  unsigned char scale;
    278  unsigned char array[33];
    279 } DBNUMERIC;
    280 
    281 typedef DBNUMERIC DBDECIMAL;
    282 
    283 typedef struct
    284 {
    285  DBINT mnyhigh;
    286  unsigned tds_sysdep_int32_type mnylow;
    287 } DBMONEY;
    288 
    289 typedef struct
    290 {
    291  DBINT mny4;
    292 } DBMONEY4;
    293 
    294 typedef struct
    295 {
    296  DBINT dtdays;
    297  DBINT dttime;
    298 } DBDATETIME;
    299 
    300 typedef struct
    301 {
    302  DBUSMALLINT days; /* days since Jan-1-1900 */
    303  DBUSMALLINT minutes; /* minutes since midnight */
    304 } DBDATETIME4;
    305 
    306 typedef struct
    307 {
    308  DBUBIGINT time;
    309  DBINT date;
    310  DBSMALLINT offset;
    311  DBUSMALLINT time_prec:3;
    312 // fix a problem with some public headers defining _res
    313 #undef _res
    314  DBUSMALLINT _res:10;
    315  DBUSMALLINT has_time:1;
    316  DBUSMALLINT has_date:1;
    317  DBUSMALLINT has_offset:1;
    318 } DBDATETIMEALL;
    319 
    320 #ifdef MSDBLIB
    321 # define SQLCHAR SYBCHAR
    322  typedef struct
    323  {
    324  DBUSMALLINT numdays;
    325  DBUSMALLINT nummins;
    326  } DBDATETIM4;
    327 #endif
    328 
    329 typedef struct tds_dblib_loginrec LOGINREC;
    330 
    331 #ifndef DOS32X
    332 typedef unsigned char BYTE;
    333 #endif
    334 
    335 typedef struct dbtypeinfo
    336 {
    337  DBINT precision;
    338  DBINT scale;
    339 } DBTYPEINFO;
    340 
    341 struct dbstring
    342 {
    343  BYTE *strtext;
    344  DBINT strtotlen;
    345  struct dbstring *strnext;
    346 };
    347 typedef struct dbstring DBSTRING;
    348 
    349 /* Used by dbcolinfo */
    350 enum
    351 { MAXCOLNAMELEN = 512 }; /* duplicates TDS_SYSNAME_SIZE */
    352 typedef enum { CI_REGULAR=1, CI_ALTERNATE=2, CI_CURSOR=3 } CI_TYPE;
    353 
    354 typedef struct
    355 {
    356  DBINT SizeOfStruct;
    357  DBCHAR Name[MAXCOLNAMELEN+2];
    358  DBCHAR ActualName[MAXCOLNAMELEN+2];
    359  DBCHAR TableName[MAXCOLNAMELEN+2];
    360  SHORT Type;
    361  DBINT UserType;
    362  DBINT MaxLength;
    363  BYTE Precision;
    364  BYTE Scale;
    365  BOOL VarLength;
    366  BYTE Null;
    367  BYTE CaseSensitive;
    368  BYTE Updatable;
    369  BOOL Identity;
    370 
    371 } DBCOL;
    372 
    373 typedef struct
    374 {
    375  DBINT SizeOfStruct;
    376  DBCHAR Name[MAXCOLNAMELEN+2];
    377  DBCHAR ActualName[MAXCOLNAMELEN+2];
    378  DBCHAR TableName[MAXCOLNAMELEN+2];
    379  SHORT Type;
    380  DBINT UserType;
    381  DBINT MaxLength;
    382  BYTE Precision;
    383  BYTE Scale;
    384  BOOL VarLength;
    385  BYTE Null;
    386  BYTE CaseSensitive;
    387  BYTE Updatable;
    388  BOOL Identity;
    389  SHORT ServerType;
    390  DBINT ServerMaxLength;
    391  DBCHAR ServerTypeDeclaration[256];
    392 } DBCOL2;
    393 /* end dbcolinfo stuff */
    394 
    395 
    396 
    397 /* a large list of options, DBTEXTSIZE is needed by sybtcl */
    398 #define DBPARSEONLY 0
    399 #define DBESTIMATE 1
    400 #define DBSHOWPLAN 2
    401 #define DBNOEXEC 3
    402 #define DBARITHIGNORE 4
    403 #define DBNOCOUNT 5
    404 #define DBARITHABORT 6
    405 #define DBTEXTLIMIT 7
    406 #define DBBROWSE 8
    407 #define DBOFFSET 9
    408 #define DBSTAT 10
    409 #define DBERRLVL 11
    410 #define DBCONFIRM 12
    411 #define DBSTORPROCID 13
    412 #define DBBUFFER 14
    413 #define DBNOAUTOFREE 15
    414 #define DBROWCOUNT 16
    415 #define DBTEXTSIZE 17
    416 #define DBNATLANG 18
    417 #define DBDATEFORMAT 19
    418 #define DBPRPAD 20
    419 #define DBPRCOLSEP 21
    420 #define DBPRLINELEN 22
    421 #define DBPRLINESEP 23
    422 #define DBLFCONVERT 24
    423 #define DBDATEFIRST 25
    424 #define DBCHAINXACTS 26
    425 #define DBFIPSFLAG 27
    426 #define DBISOLATION 28
    427 #define DBAUTH 29
    428 #define DBIDENTITY 30
    429 #define DBNOIDCOL 31
    430 #define DBDATESHORT 32
    431 #define DBCLIENTCURSORS 33
    432 #define DBSETTIME 34
    433 #define DBQUOTEDIDENT 35
    434 
    435 #define DBNUMOPTIONS 36
    436 
    437 #define DBPADOFF 0
    438 #define DBPADON 1
    439 
    440 #define OFF 0
    441 #define ON 1
    442 
    443 #define NOSUCHOPTION 2
    444 
    445 #define MAXOPTTEXT 32
    446 
    447 typedef struct tds_dblib_dbprocess DBPROCESS;
    448 
    449 /*
    450  * Sybase & Microsoft use different names for the dbdaterec members.
    451  * Keep these two structures physically identical in memory.
    452  * dbdatecrack() casts one to the other for ease of implementation.
    453  *
    454  * Giving credit where credit is due, we can acknowledge that
    455  * Microsoft chose the better names here, hands down. ("datedmonth"?!)
    456  */
    458 {
    459  DBINT year; /* 1753 - 9999 */
    460  DBINT quarter; /* 1 - 4 */
    461  DBINT month; /* 1 - 12 */
    462  DBINT day; /* 1 - 31 */
    463  DBINT dayofyear; /* 1 - 366 */
    464  DBINT week; /* 1 - 54 (for leap years) */
    465  DBINT weekday; /* 1 - 7 (Mon. - Sun.) */
    466  DBINT hour; /* 0 - 23 */
    467  DBINT minute; /* 0 - 59 */
    468  DBINT second; /* 0 - 59 */
    469  DBINT millisecond; /* 0 - 999 */
    470  DBINT tzone; /* -840 - 840 */
    471 };
    472 
    474 {
    475  DBINT dateyear; /* 1900 and counting */
    476  DBINT quarter; /* 0 - 3 (Microsoft only) */
    477  DBINT datemonth; /* 0 - 11 */
    478  DBINT datedmonth; /* 1 - 31 */
    479  DBINT datedyear; /* 1 - 366 */
    480  DBINT week; /* 1 - 54 (Microsoft only) */
    481  DBINT datedweek; /* 0 - 6 */
    482  DBINT datehour; /* 0 - 23 */
    483  DBINT dateminute; /* 0 - 59 */
    484  DBINT datesecond; /* 0 - 59 */
    485  DBINT datemsecond; /* 0 - 999 */
    486  DBINT datetzone; /* -840 - 840 */
    487 };
    488 
    490 {
    491  DBINT year; /* 1753 - 9999 */
    492  DBINT quarter; /* 1 - 4 */
    493  DBINT month; /* 1 - 12 */
    494  DBINT day; /* 1 - 31 */
    495  DBINT dayofyear; /* 1 - 366 */
    496  DBINT week; /* 1 - 54 (for leap years) */
    497  DBINT weekday; /* 1 - 7 (Mon. - Sun.) */
    498  DBINT hour; /* 0 - 23 */
    499  DBINT minute; /* 0 - 59 */
    500  DBINT second; /* 0 - 59 */
    501  DBINT nanosecond; /* 0 - 999999999 */
    502  DBINT tzone; /* 0 - 127 (Sybase only) */
    503 };
    504 
    506 {
    507  DBINT dateyear; /* 1900 and counting */
    508  DBINT quarter; /* 0 - 3 (Microsoft only) */
    509  DBINT datemonth; /* 0 - 11 */
    510  DBINT datedmonth; /* 1 - 31 */
    511  DBINT datedyear; /* 1 - 366 */
    512  DBINT week; /* 1 - 54 (Microsoft only) */
    513  DBINT datedweek; /* 0 - 6 */
    514  DBINT datehour; /* 0 - 23 */
    515  DBINT dateminute; /* 0 - 59 */
    516  DBINT datesecond; /* 0 - 59 */
    517  DBINT datensecond; /* 0 - 999999999 */
    518  DBINT datetzone; /* 0 - 127 */
    519 };
    520 
    521 
    522 #ifdef MSDBLIB
    523 typedef struct tds_microsoft_dbdaterec DBDATEREC;
    524 typedef struct tds_microsoft_dbdaterec2 DBDATEREC2;
    525 #else
    526 typedef struct tds_sybase_dbdaterec DBDATEREC;
    527 typedef struct tds_sybase_dbdaterec2 DBDATEREC2;
    528 #endif
    529 
    530 typedef int (*EHANDLEFUNC) (DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr);
    531 
    532 typedef int (*MHANDLEFUNC) (DBPROCESS * dbproc, DBINT msgno, int msgstate, int severity, char *msgtext, char *srvname,
    533  char *proc, int line);
    534 
    535 /* dbpoll() result codes, sybtcl needs DBRESULT */
    536 #define DBRESULT 1
    537 #define DBNOTIFICATION 2
    538 #define DBTIMEOUT 3
    539 #define DBINTERRUPT 4
    540 
    541 /* more sybtcl needs: */
    542 #define DBTXTSLEN 8
    543 
    544 /* bind types */
    545 #define CHARBIND 0
    546 #define STRINGBIND 1
    547 #define NTBSTRINGBIND 2
    548 #define VARYCHARBIND 3
    549 #define VARYBINBIND 4
    550 #define TINYBIND 6
    551 #define SMALLBIND 7
    552 #define INTBIND 8
    553 #define FLT8BIND 9
    554 #define REALBIND 10
    555 #define DATETIMEBIND 11
    556 #define SMALLDATETIMEBIND 12
    557 #define MONEYBIND 13
    558 #define SMALLMONEYBIND 14
    559 #define BINARYBIND 15
    560 #define BITBIND 16
    561 #define NUMERICBIND 17
    562 #define DECIMALBIND 18
    563 #define SRCNUMERICBIND 19
    564 #define SRCDECIMALBIND 20
    565 #define DATEBIND 21
    566 #define TIMEBIND 22
    567 #define BIGDATETIMEBIND 23
    568 #define BIGTIMEBIND 24
    569 #define BIGINTBIND 30
    570 #define DATETIME2BIND 31
    571 #define MAXBINDTYPES 32 /* keep last */
    572 
    573 #define DBPRCOLSEP 21
    574 #define DBPRLINELEN 22
    575 #define DBRPCRETURN 1
    576 #define DBRPCDEFAULT 2
    577 
    578 #define REG_ROW -1
    579 #define MORE_ROWS -1
    580 #define NO_MORE_ROWS -2
    581 #define BUF_FULL -3
    582 #define NO_MORE_RESULTS 2
    583 #define SUCCEED 1
    584 #define FAIL 0
    585 
    586 #define DB_IN 1
    587 #define DB_OUT 2
    588 #define DB_QUERYOUT 3
    589 
    590 #define DBSINGLE 0
    591 #define DBDOUBLE 1
    592 #define DBBOTH 2
    593 
    594 /* remote procedure call (rpc) options */
    595 #define DBRPCRECOMPILE TDS_STATIC_CAST(DBSMALLINT, 0x0001)
    596 #define DBRPCRESET TDS_STATIC_CAST(DBSMALLINT, 0x0002)
    597 #define DBRPCCURSOR TDS_STATIC_CAST(DBSMALLINT, 0x0008)
    598 
    599 #if defined(DBLIB_UNIMPLEMENTED)
    600 DBBOOL db12hour(DBPROCESS * dbprocess, const char language[]);
    601 
    602 DBBOOL dbcolbrowse(DBPROCESS * dbprocess, int colnum);
    603 
    604 RETCODE dbcursor(DBCURSOR * hc, DBINT optype, DBINT bufno, BYTE * table, BYTE * values);
    605 RETCODE dbcursorbind(DBCURSOR * hc, int col, int vartype, DBINT varlen, DBINT * poutlen, BYTE * pvaraddr, DBTYPEINFO * typeinfo);
    606 void dbcursorclose(DBCURSOR * hc);
    607 RETCODE dbcursorcolinfo(DBCURSOR * hc, DBINT column, DBCHAR * colname, DBINT * coltype, DBINT * collen, DBINT * usertype);
    608 RETCODE dbcursorfetch(DBCURSOR * hc, DBINT fetchtype, DBINT rownum);
    609 RETCODE dbcursorinfo(DBCURSOR * hc, DBINT * ncols, DBINT * nrows);
    610 DBCURSOR *dbcursoropen(DBPROCESS * dbprocess, BYTE * stmt, SHORT scollopt, SHORT concuropt, USHORT nrows, DBINT * pstatus);
    611 
    612 int dbdate4cmp(DBPROCESS * dbprocess, DBDATETIME4 * d1, DBDATETIME4 * d2);
    613 RETCODE dbdate4zero(DBPROCESS * dbprocess, DBDATETIME4 * d1);
    614 RETCODE dbdatechar(DBPROCESS * dbprocess, char *buf, int datepart, int value);
    615 int dbdatename(DBPROCESS * dbprocess, char *buf, int date, DBDATETIME * datetime);
    616 char *dateorder(DBPROCESS * dbprocess, char *language);
    617 DBINT dbdatepart(DBPROCESS * dbprocess, int datepart, DBDATETIME * datetime);
    618 RETCODE dbdatezero(DBPROCESS * dbprocess, DBDATETIME * d1);
    619 char *dbdayname(DBPROCESS * dbprocess, char *language, int daynum);
    620 
    621 int dbgetoff(DBPROCESS * dbprocess, DBUSMALLINT offtype, int startfrom);
    622 
    623 char *dbqual(DBPROCESS * dbprocess, int tabnum, char *tabname);
    624 void dbfreequal(char *qualptr);
    625 
    626 DBSORTORDER *dbloadsort(DBPROCESS * dbprocess);
    627 RETCODE dbfreesort(DBPROCESS * dbprocess, DBSORTORDER * sortorder);
    628 
    629 RETCODE dbload_xlate(DBPROCESS * dbprocess, char *srv_charset, char *clt_name, DBXLATE ** xlt_tosrv, DBXLATE ** xlt_todisp);
    630 
    631 RETCODE dbmny4divide(DBPROCESS * dbproc, DBMONEY4 * m1, DBMONEY4 * m2, DBMONEY4 * quotient);
    632 RETCODE dbmny4mul(DBPROCESS * dbproc, DBMONEY4 * m1, DBMONEY4 * m2, DBMONEY4 * prod);
    633 RETCODE dbmnyadd(DBPROCESS * dbproc, DBMONEY * m1, DBMONEY * m2, DBMONEY * sum);
    634 RETCODE dbmnydivide(DBPROCESS * dbproc, DBMONEY * m1, DBMONEY * m2, DBMONEY * quotient);
    635 RETCODE dbmnydown(DBPROCESS * dbproc, DBMONEY * mnyptr, int divisor, int *remainder);
    636 RETCODE dbmnyinit(DBPROCESS * dbproc, DBMONEY * mnyptr, int trim, DBBOOL * negative);
    637 RETCODE dbmnyndigit(DBPROCESS * dbproc, DBMONEY * mnyptr, DBCHAR * value, DBBOOL * zero);
    638 RETCODE dbmnymul(DBPROCESS * dbproc, DBMONEY * m1, DBMONEY * m2, DBMONEY * prod);
    639 RETCODE dbmnydigit(DBPROCESS * dbprocess, DBMONEY * m1, DBCHAR * value, DBBOOL * zero);
    640 RETCODE dbmnyscale(DBPROCESS * dbproc, DBMONEY * dest, int multiplier, int addend);
    641 
    642 
    643 RETCODE dbnpcreate(DBPROCESS * dbprocess);
    644 RETCODE dbnpdefine(DBPROCESS * dbprocess, DBCHAR * procedure_name, DBSMALLINT namelen);
    645 
    646 int DBNUMORDERS(DBPROCESS * dbprocess);
    647 
    648 RETCODE dbpoll(DBPROCESS * dbproc, long milliseconds, DBPROCESS ** ready_dbproc, int *return_reason);
    649 int dbordercol(DBPROCESS * dbprocess, int order);
    650 
    651 RETCODE dbregdrop(DBPROCESS * dbprocess, DBCHAR * procnm, DBSMALLINT namelen);
    652 RETCODE dbregexec(DBPROCESS * dbproc, DBUSMALLINT options);
    653 RETCODE dbreghandle(DBPROCESS * dbprocess, DBCHAR * procnm, DBSMALLINT namelen, INTFUNCPTR handler);
    654 RETCODE dbreginit(DBPROCESS * dbproc, DBCHAR * procedure_name, DBSMALLINT namelen);
    655 RETCODE dbreglist(DBPROCESS * dbproc);
    656 RETCODE dbregnowatch(DBPROCESS * dbprocess, DBCHAR * procnm, DBSMALLINT namelen);
    657 RETCODE dbregparam(DBPROCESS * dbproc, char *param_name, int type, DBINT datalen, BYTE * data);
    658 RETCODE dbregwatch(DBPROCESS * dbprocess, DBCHAR * procnm, DBSMALLINT namelen, DBUSMALLINT options);
    659 RETCODE dbregwatchlist(DBPROCESS * dbprocess);
    660 
    661 void dbrpwclr(LOGINREC * login);
    662 RETCODE dbrpwset(LOGINREC * login, char *srvname, char *password, int pwlen);
    663 
    664 DBINT dbreadpage(DBPROCESS * dbprocess, char *p_dbname, DBINT pageno, BYTE * buf);
    665 RETCODE dbwritepage(DBPROCESS * dbprocess, char *p_dbname, DBINT pageno, DBINT size, BYTE * buf);
    666 
    667 RETCODE dbsetdeflang(char *language);
    668 
    669 int dbstrcmp(DBPROCESS * dbprocess, char *s1, int l1, char *s2, int l2, DBSORTORDER * sort);
    670 int dbstrsort(DBPROCESS * dbprocess, char *s1, int l1, char *s2, int l2, DBSORTORDER * sort);
    671 
    672 DBBOOL dbtabbrowse(DBPROCESS * dbprocess, int tabnum);
    673 int dbtabcount(DBPROCESS * dbprocess);
    674 char *dbtabname(DBPROCESS * dbprocess, int tabnum);
    675 char *dbtabsource(DBPROCESS * dbprocess, int colnum, int *tabnum);
    676 
    677 RETCODE dbsendpassthru(DBPROCESS * dbprocess, DBVOIDPTR bufp);
    678 RETCODE dbrecvpassthru(DBPROCESS * dbprocess, DBVOIDPTR * bufp);
    679 
    680 RETCODE dbgetloginfo(DBPROCESS * dbprocess, DBLOGINFO ** loginfo);
    681 RETCODE dbsetloginfo(LOGINREC * loginrec, DBLOGINFO * loginfo);
    682 
    683 int dbtsnewlen(DBPROCESS * dbprocess);
    684 DBBINARY *dbtsnewval(DBPROCESS * dbprocess);
    685 RETCODE dbtsput(DBPROCESS * dbprocess, DBBINARY * newts, int newtslen, int tabnum, char *tabname);
    686 
    687 RETCODE dbfree_xlate(DBPROCESS * dbprocess, DBXLATE * xlt_tosrv, DBXLATE * clt_todisp);
    688 int dbxlate(DBPROCESS * dbprocess, char *src, int srclen, char *dest, int destlen, DBXLATE * xlt, int *srcbytes_used,
    689  DBBOOL srcend, int status);
    690 
    691 RETCODE bcp_moretext(DBPROCESS * dbproc, DBINT size, BYTE * text);
    692 RETCODE bcp_writefmt(DBPROCESS * dbproc, const char filename[]);
    693 
    694 void build_xact_string(char *xact_name, char *service_name, DBINT commid, char *result);
    695 RETCODE remove_xact(DBPROCESS * connect, DBINT commid, int n);
    696 RETCODE abort_xact(DBPROCESS * connect, DBINT commid);
    697 void close_commit(DBPROCESS * connect);
    698 RETCODE commit_xact(DBPROCESS * connect, DBINT commid);
    699 DBPROCESS *open_commit(LOGINREC * login, char *servername);
    700 RETCODE scan_xact(DBPROCESS * connect, DBINT commid);
    701 DBINT start_xact(DBPROCESS * connect, char *application_name, char *xact_name, int site_count);
    702 DBINT stat_xact(DBPROCESS * connect, DBINT commid);
    703 
    704 #endif /* define unimplemented */
    705 
    706 BYTE *dbadata(DBPROCESS * dbproc, int computeid, int column);
    707 DBINT dbadlen(DBPROCESS * dbproc, int computeid, int column);
    708 RETCODE dbaltbind(DBPROCESS * dbprocess, int computeid, int column, int vartype, DBINT varlen, BYTE * varaddr);
    709 RETCODE dbaltbind_ps(DBPROCESS * dbprocess, int computeid, int column, int vartype, DBINT varlen, BYTE * varaddr,
    710  DBTYPEINFO * typeinfo);
    711 int dbaltcolid(DBPROCESS * dbproc, int computeid, int column);
    712 DBINT dbaltlen(DBPROCESS * dbproc, int computeid, int column);
    713 int dbaltop(DBPROCESS * dbproc, int computeid, int column);
    714 int dbalttype(DBPROCESS * dbproc, int computeid, int column);
    715 DBINT dbaltutype(DBPROCESS * dbproc, int computeid, int column);
    716 RETCODE dbanullbind(DBPROCESS * dbprocess, int computeid, int column, DBINT * indicator);
    717 RETCODE dbbind(DBPROCESS * dbproc, int column, int vartype, DBINT varlen, BYTE * varaddr);
    718 RETCODE dbbind_ps(DBPROCESS * dbprocess, int column, int vartype, DBINT varlen, BYTE * varaddr, DBTYPEINFO * typeinfo);
    719 int dbbufsize(DBPROCESS * dbprocess);
    720 BYTE *dbbylist(DBPROCESS * dbproc, int computeid, int *size);
    721 RETCODE dbcancel(DBPROCESS * dbproc);
    722 RETCODE dbcanquery(DBPROCESS * dbproc);
    723 char *dbchange(DBPROCESS * dbprocess);
    724 DBBOOL dbcharsetconv(DBPROCESS * dbprocess);
    725 void dbclose(DBPROCESS * dbproc);
    726 void dbclrbuf(DBPROCESS * dbproc, DBINT n);
    727 RETCODE dbclropt(DBPROCESS * dbproc, int option, const char param[]);
    728 RETCODE dbcmd(DBPROCESS * dbproc, const char cmdstring[]);
    729 RETCODE dbcmdrow(DBPROCESS * dbproc);
    730 
    731 #define DBCMDROW(x) dbcmdrow((x))
    732 RETCODE dbtablecolinfo (DBPROCESS *dbproc, DBINT column, DBCOL *pdbcol );
    733 RETCODE dbcolinfo (DBPROCESS *dbproc, CI_TYPE type, DBINT column, DBINT computeid, DBCOL *pdbcol);
    734 DBINT dbcollen(DBPROCESS * dbproc, int column);
    735 char *dbcolname(DBPROCESS * dbproc, int column);
    736 char *dbcolsource(DBPROCESS * dbproc, int colnum);
    737 int dbcoltype(DBPROCESS * dbproc, int column);
    738 DBTYPEINFO *dbcoltypeinfo(DBPROCESS * dbproc, int column);
    739 DBINT dbcolutype(DBPROCESS * dbprocess, int column);
    740 DBINT dbconvert(DBPROCESS * dbproc, int srctype, const BYTE * src, DBINT srclen, int desttype, BYTE * dest, DBINT destlen);
    741 DBINT dbconvert_ps(DBPROCESS * dbprocess, int srctype, const BYTE * src, DBINT srclen, int desttype, BYTE * dest, DBINT destlen,
    742  DBTYPEINFO * typeinfo);
    743 BOOL dbiscount(DBPROCESS * dbproc);
    744 DBINT dbcount(DBPROCESS * dbproc);
    745 
    746 #define DBCOUNT(x) dbcount((x))
    747 int dbcurcmd(DBPROCESS * dbproc);
    748 
    749 #define DBCURCMD(x) dbcurcmd((x))
    750 DBINT dbcurrow(DBPROCESS * dbproc);
    751 
    752 #define DBCURROW(x) dbcurrow((x))
    753 BYTE *dbdata(DBPROCESS * dbproc, int column);
    754 int dbdatecmp(DBPROCESS * dbproc, DBDATETIME * d1, DBDATETIME * d2);
    755 RETCODE dbdatecrack(DBPROCESS * dbproc, DBDATEREC * di, DBDATETIME * dt);
    756 RETCODE dbanydatecrack(DBPROCESS * dbproc, DBDATEREC2 * di, int type, const void *data);
    757 DBINT dbdatlen(DBPROCESS * dbproc, int column);
    758 DBBOOL dbdead(DBPROCESS * dbproc);
    759 
    760 #define DBDEAD(x) dbdead((x))
    761 EHANDLEFUNC dberrhandle(EHANDLEFUNC handler);
    762 void dbexit(void);
    763 RETCODE dbfcmd(DBPROCESS * dbproc, const char *fmt, ...);
    764 DBINT dbfirstrow(DBPROCESS * dbproc);
    765 
    766 #define DBFIRSTROW(x) dbfirstrow((x))
    767 void dbfreebuf(DBPROCESS * dbproc);
    768 char *dbgetchar(DBPROCESS * dbprocess, int n);
    769 char *dbgetcharset(DBPROCESS * dbprocess);
    770 int dbgetlusername(LOGINREC * login, BYTE * name_buffer, int buffer_len);
    771 int dbgetmaxprocs(void);
    772 char *dbgetnatlanf(DBPROCESS * dbprocess);
    773 int dbgetpacket(DBPROCESS * dbproc);
    774 RETCODE dbgetrow(DBPROCESS * dbproc, DBINT row);
    775 int dbgettime(void);
    776 #define DBGETTIME dbgettime
    777 BYTE *dbgetuserdata(DBPROCESS * dbproc);
    778 DBBOOL dbhasretstat(DBPROCESS * dbproc);
    779 RETCODE dbinit(void);
    780 int dbiordesc(DBPROCESS * dbproc);
    781 
    782 #define DBIORDESC(x) dbiordesc((x))
    783 int dbiowdesc(DBPROCESS * dbproc);
    784 
    785 #define DBIOWDESC(x) dbiowdesc((x))
    786 DBBOOL dbisavail(DBPROCESS * dbprocess);
    787 
    788 #define DBISAVAIL(x) dbisavail((x))
    789 DBBOOL dbisopt(DBPROCESS * dbproc, int option, const char param[]);
    790 DBINT dblastrow(DBPROCESS * dbproc);
    791 
    792 #define DBLASTROW(x) dblastrow((x))
    793 LOGINREC *dblogin(void);
    794 void dbloginfree(LOGINREC * login);
    795 
    796 int dbmny4cmp(DBPROCESS * dbproc, DBMONEY4 * m1, DBMONEY4 * m2);
    797 int dbmnycmp(DBPROCESS * dbproc, DBMONEY * m1, DBMONEY * m2);
    798 
    799 RETCODE dbmny4add(DBPROCESS * dbproc, DBMONEY4 * m1, DBMONEY4 * m2, DBMONEY4 * sum);
    800 RETCODE dbmnydec(DBPROCESS * dbproc, DBMONEY * mnyptr);
    801 RETCODE dbmnyinc(DBPROCESS * dbproc, DBMONEY * mnyptr);
    802 RETCODE dbmnymaxpos(DBPROCESS * dbproc, DBMONEY * dest);
    803 RETCODE dbmnymaxneg(DBPROCESS * dbproc, DBMONEY * dest);
    804 RETCODE dbmny4minus(DBPROCESS * dbproc, DBMONEY4 * src, DBMONEY4 * dest);
    805 RETCODE dbmnyminus(DBPROCESS * dbproc, DBMONEY * src, DBMONEY * dest);
    806 RETCODE dbmny4sub(DBPROCESS * dbproc, DBMONEY4 * m1, DBMONEY4 * m2, DBMONEY4 * diff);
    807 RETCODE dbmnysub(DBPROCESS * dbproc, DBMONEY * m1, DBMONEY * m2, DBMONEY * diff);
    808 
    809 RETCODE dbmny4copy(DBPROCESS * dbprocess, DBMONEY4 * m1, DBMONEY4 * m2);
    810 RETCODE dbmnycopy(DBPROCESS * dbproc, DBMONEY * src, DBMONEY * dest);
    811 
    812 RETCODE dbmny4zero(DBPROCESS * dbproc, DBMONEY4 * dest);
    813 RETCODE dbmnyzero(DBPROCESS * dbproc, DBMONEY * dest);
    814 
    815 const char *dbmonthname(DBPROCESS * dbproc, char *language, int monthnum, DBBOOL shortform);
    816 RETCODE dbmorecmds(DBPROCESS * dbproc);
    817 
    818 #define DBMORECMDS(x) dbmorecmds((x))
    819 RETCODE dbmoretext(DBPROCESS * dbproc, DBINT size, const BYTE text[]);
    820 MHANDLEFUNC dbmsghandle(MHANDLEFUNC handler);
    821 char *dbname(DBPROCESS * dbproc);
    822 STATUS dbnextrow(DBPROCESS * dbproc);
    823 RETCODE dbnullbind(DBPROCESS * dbproc, int column, DBINT * indicator);
    824 int dbnumalts(DBPROCESS * dbproc, int computeid);
    825 int dbnumcols(DBPROCESS * dbproc);
    826 int dbnumcompute(DBPROCESS * dbprocess);
    827 int dbnumrets(DBPROCESS * dbproc);
    828 DBPROCESS *tdsdbopen(LOGINREC * login, const char *server, int msdblib);
    829 DBPROCESS *dbopen(LOGINREC * login, const char *server);
    830 
    831 /* pivot functions */
    832 struct col_t;
    833 void dbpivot_count (struct col_t *output, const struct col_t *input);
    834 void dbpivot_sum (struct col_t *output, const struct col_t *input);
    835 void dbpivot_min (struct col_t *output, const struct col_t *input);
    836 void dbpivot_max (struct col_t *output, const struct col_t *input);
    837 
    838 struct pivot_t;
    839 typedef void (*DBPIVOT_FUNC)(struct col_t *output, const struct col_t *input);
    840 struct pivot_t * dbrows_pivoted(DBPROCESS *dbproc);
    841 STATUS dbnextrow_pivoted(DBPROCESS *dbproc, struct pivot_t *pp);
    842 RETCODE dbpivot(DBPROCESS *dbproc, int nkeys, int *keys, int ncols, int *cols, DBPIVOT_FUNC func, int val);
    843 
    844 DBPIVOT_FUNC dbpivot_lookup_name( const char name[] );
    845 
    846 #ifdef MSDBLIB
    847 #define dbopen(x,y) tdsdbopen((x),(y), 1)
    848 #else
    849 #define dbopen(x,y) tdsdbopen((x),(y), 0)
    850 #endif
    851 
    852 /* fix PHP problem */
    853 #ifdef PHP_SYBASE_DBOPEN
    854 #undef PHP_SYBASE_DBOPEN
    855 #define PHP_SYBASE_DBOPEN dbopen
    856 #endif
    857 
    858 void dbprhead(DBPROCESS * dbproc);
    859 DBINT dbprcollen(DBPROCESS * dbproc, int column);
    860 RETCODE dbprrow(DBPROCESS * dbproc);
    861 const char *dbprtype(int token);
    862 DBBOOL DRBUF(DBPROCESS * dbprocess);
    863 STATUS dbreadtext(DBPROCESS * dbproc, void *buf, DBINT bufsize);
    864 void dbrecftos(const char filename[]);
    865 RETCODE dbresults(DBPROCESS * dbproc);
    866 RETCODE dbresults_r(DBPROCESS * dbproc, int recursive);
    867 BYTE *dbretdata(DBPROCESS * dbproc, int retnum);
    868 int dbretlen(DBPROCESS * dbproc, int retnum);
    869 char *dbretname(DBPROCESS * dbproc, int retnum);
    870 DBINT dbretstatus(DBPROCESS * dbproc);
    871 int dbrettype(DBPROCESS * dbproc, int retnum);
    872 RETCODE dbrows(DBPROCESS * dbproc);
    873 
    874 #define DBROWS(x) dbrows((x))
    875 STATUS dbrowtype(DBPROCESS * dbprocess);
    876 
    877 #define DBROWTYPE(x) dbrowtype((x))
    878 RETCODE dbrpcinit(DBPROCESS * dbproc, const char rpcname[], DBSMALLINT options);
    879 RETCODE dbrpcparam(DBPROCESS * dbproc, const char paramname[], BYTE status, int type, DBINT maxlen, DBINT datalen, BYTE * value);
    880 RETCODE dbrpcsend(DBPROCESS * dbproc);
    881 RETCODE dbsafestr(DBPROCESS * dbproc, const char *src, DBINT srclen, char *dest, DBINT destlen, int quotetype);
    882 RETCODE *dbsechandle(DBINT type, INTFUNCPTR handler);
    883 char *dbservcharset(DBPROCESS * dbprocess);
    884 void dbsetavail(DBPROCESS * dbprocess);
    885 void dbsetbusy(DBPROCESS * dbprocess, DB_DBBUSY_FUNC busyfunc);
    886 RETCODE dbsetdefcharset(char *charset);
    887 void dbsetidle(DBPROCESS * dbprocess, DB_DBIDLE_FUNC idlefunc);
    888 void dbsetifile(char *filename);
    889 void dbsetinterrupt(DBPROCESS * dbproc, DB_DBCHKINTR_FUNC chkintr, DB_DBHNDLINTR_FUNC hndlintr);
    890 RETCODE dbsetlogintime(int seconds);
    891 RETCODE dbsetmaxprocs(int maxprocs);
    892 RETCODE dbsetnull(DBPROCESS * dbprocess, int bindtype, int bindlen, BYTE * bindval);
    893 RETCODE dbsetopt(DBPROCESS * dbproc, int option, const char *char_param, int int_param);
    894 STATUS dbsetrow(DBPROCESS * dbprocess, DBINT row);
    895 RETCODE dbsettime(int seconds);
    896 void dbsetuserdata(DBPROCESS * dbproc, BYTE * ptr);
    897 RETCODE dbsetversion(DBINT version);
    898 
    899 int dbspid(DBPROCESS * dbproc);
    900 RETCODE dbspr1row(DBPROCESS * dbproc, char *buffer, DBINT buf_len);
    901 DBINT dbspr1rowlen(DBPROCESS * dbproc);
    902 RETCODE dbsprhead(DBPROCESS * dbproc, char *buffer, DBINT buf_len);
    903 RETCODE dbsprline(DBPROCESS * dbproc, char *buffer, DBINT buf_len, DBCHAR line_char);
    904 RETCODE dbsqlexec(DBPROCESS * dbproc);
    905 RETCODE dbsqlok(DBPROCESS * dbproc);
    906 RETCODE dbsqlsend(DBPROCESS * dbproc);
    907 int dbstrbuild(DBPROCESS * dbproc, char *charbuf, int bufsize, char *text, char *formats, ...);
    908 RETCODE dbstrcpy(DBPROCESS * dbproc, int start, int numbytes, char *dest);
    909 int dbstrlen(DBPROCESS * dbproc);
    910 DBINT dbvarylen(DBPROCESS * dbproc, int column);
    911 
    912 #define SYBEVERDOWN 100 /* TDS version downgraded . */
    913 #define SYBEICONVIU 2400 /* Some character(s) could not be converted into client's character set. */
    914 #define SYBEICONVAVAIL 2401 /* Character set conversion is not available between client character set '%.*s' and server character set '%.*s'.*/
    915 #define SYBEICONVO 2402 /* Error converting characters into server's character set. Some character(s) could not be converted.*/
    916 #define SYBEICONVI 2403 /* Some character(s) could not be converted into client's character set. Unconverted bytes were changed to question marks ('?').*/
    917 #define SYBEICONV2BIG 2404 /* Buffer overflow converting characters from client into server's character set.*/
    918  /* cf. doc/dblib_errors.txt for more iconv error values. */
    919  /* Reserve a few slots for other iconv-related issues. */
    920 #define SYBETDSVER 2410 /* Cannot bcp with TDSVER < 5.0 */
    921 #define SYBEPORT 2500 /* Both port and instance specified */
    922 #define SYBESYNC 20001 /* Read attempted while out of synchronization with SQL Server. */
    923 #define SYBEFCON 20002 /* SQL Server connection failed. */
    924 #define SYBETIME 20003 /* SQL Server connection timed out. */
    925 #define SYBEREAD 20004 /* Read from SQL Server failed. */
    926 #define SYBEBUFL 20005 /* DB-LIBRARY internal error - send buffer length corrupted. */
    927 #define SYBEWRIT 20006 /* Write to SQL Server failed. */
    928 #define SYBEVMS 20007 /* Sendflush: VMS I/O error. */
    929 #define SYBESOCK 20008 /* Unable to open socket */
    930 #define SYBECONN 20009 /* Unable to connect socket -- SQL Server is unavailable or does not exist. */
    931 #define SYBEMEM 20010 /* Unable to allocate sufficient memory */
    932 #define SYBEDBPS 20011 /* Maximum number of DBPROCESSes already allocated. */
    933 #define SYBEINTF 20012 /* Server name not found in interface file */
    934 #define SYBEUHST 20013 /* Unknown host machine name */
    935 #define SYBEPWD 20014 /* Incorrect password. */
    936 #define SYBEOPIN 20015 /* Could not open interface file. */
    937 #define SYBEINLN 20016 /* Interface file: unexpected end-of-line. */
    938 #define SYBESEOF 20017 /* Unexpected EOF from SQL Server. */
    939 #define SYBESMSG 20018 /* General SQL Server error: Check messages from the SQL Server. */
    940 #define SYBERPND 20019 /* Attempt to initiate a new SQL Server operation with results pending. */
    941 #define SYBEBTOK 20020 /* Bad token from SQL Server: Data-stream processing out of sync. */
    942 #define SYBEITIM 20021 /* Illegal timeout value specified. */
    943 #define SYBEOOB 20022 /* Error in sending out-of-band data to SQL Server. */
    944 #define SYBEBTYP 20023 /* Unknown bind type passed to DB-LIBRARY function. */
    945 #define SYBEBNCR 20024 /* Attempt to bind user variable to a non-existent compute row. */
    946 #define SYBEIICL 20025 /* Illegal integer column length returned by SQL Server. Legal integer lengths are 1, 2, and 4 bytes. */
    947 #define SYBECNOR 20026 /* Column number out of range. */
    948 #define SYBENPRM 20027 /* NULL parameter not allowed for this dboption. */
    949 #define SYBEUVDT 20028 /* Unknown variable-length datatype encountered. */
    950 #define SYBEUFDT 20029 /* Unknown fixed-length datatype encountered. */
    951 #define SYBEWAID 20030 /* DB-LIBRARY internal error: ALTFMT following ALTNAME has wrong id. */
    952 #define SYBECDNS 20031 /* Datastream indicates that a compute column is derived from a non-existent select-list member. */
    953 #define SYBEABNC 20032 /* Attempt to bind to a non-existent column. */
    954 #define SYBEABMT 20033 /* User attempted a dbbind() with mismatched column and variable types. */
    955 #define SYBEABNP 20034 /* Attempt to bind using NULL pointers. */
    956 #define SYBEAAMT 20035 /* User attempted a dbaltbind() with mismatched column and variable types. */
    957 #define SYBENXID 20036 /* The Server did not grant us a distributed-transaction ID. */
    958 #define SYBERXID 20037 /* The Server did not recognize our distributed-transaction ID. */
    959 #define SYBEICN 20038 /* Invalid computeid or compute column number. */
    960 #define SYBENMOB 20039 /* No such member of 'order by' clause. */
    961 #define SYBEAPUT 20040 /* Attempt to print unknown token. */
    962 #define SYBEASNL 20041 /* Attempt to set fields in a null loginrec. */
    963 #define SYBENTLL 20042 /* Name too long for loginrec field. */
    964 #define SYBEASUL 20043 /* Attempt to set unknown loginrec field. */
    965 #define SYBERDNR 20044 /* Attempt to retrieve data from a non-existent row. */
    966 #define SYBENSIP 20045 /* Negative starting index passed to dbstrcpy(). */
    967 #define SYBEABNV 20046 /* Attempt to bind to a NULL program variable. */
    968 #define SYBEDDNE 20047 /* DBPROCESS is dead or not enabled. */
    969 #define SYBECUFL 20048 /* Data-conversion resulted in underflow. */
    970 #define SYBECOFL 20049 /* Data-conversion resulted in overflow. */
    971 #define SYBECSYN 20050 /* Attempt to convert data stopped by syntax error in source field. */
    972 #define SYBECLPR 20051 /* Data-conversion resulted in loss of precision. */
    973 #define SYBECNOV 20052 /* Attempt to set variable to NULL resulted in overflow. */
    974 #define SYBERDCN 20053 /* Requested data-conversion does not exist. */
    975 #define SYBESFOV 20054 /* dbsafestr() overflowed its destination buffer. */
    976 #define SYBEUNT 20055 /* Unknown network type found in interface file. */
    977 #define SYBECLOS 20056 /* Error in closing network connection. */
    978 #define SYBEUAVE 20057 /* Unable to allocate VMS event flag. */
    979 #define SYBEUSCT 20058 /* Unable to set communications timer. */
    980 #define SYBEEQVA 20059 /* Error in queueing VMS AST routine. */
    981 #define SYBEUDTY 20060 /* Unknown datatype encountered. */
    982 #define SYBETSIT 20061 /* Attempt to call dbtsput() with an invalid timestamp. */
    983 #define SYBEAUTN 20062 /* Attempt to update the timestamp of a table which has no timestamp column. */
    984 #define SYBEBDIO 20063 /* Bad bulk-copy direction. Must be either IN or OUT. */
    985 #define SYBEBCNT 20064 /* Attempt to use Bulk Copy with a non-existent Server table. */
    986 #define SYBEIFNB 20065 /* Illegal field number passed to bcp_control(). */
    987 #define SYBETTS 20066 /* The table which bulk-copy is attempting to copy to a host-file is shorter than the number of rows which bulk-copy was instructed to skip. */
    988 #define SYBEKBCO 20067 /* 1000 rows successfully bulk-copied to host-file. */
    989 #define SYBEBBCI 20068 /* Batch successfully bulk-copied to SQL Server. */
    990 #define SYBEKBCI 20069 /* Bcp: 1000 rows sent to SQL Server. */
    991 #define SYBEBCRE 20070 /* I/O error while reading bcp data-file. */
    992 #define SYBETPTN 20071 /* Syntax error: only two periods are permitted in table names. */
    993 #define SYBEBCWE 20072 /* I/O error while writing bcp data-file. */
    994 #define SYBEBCNN 20073 /* Attempt to bulk-copy a NULL value into Server column %d, which does not accept NULL values. */
    995 #define SYBEBCOR 20074 /* Attempt to bulk-copy an oversized row to the SQL Server. */
    996 #define SYBEBCIS 20075 /* Attempt to bulk-copy an illegally-sized column value to the SQL Server. */
    997 #define SYBEBCPI 20076 /* bcp_init() must be called before any other bcp routines. */
    998 #define SYBEBCPN 20077 /* bcp_bind(), bcp_collen(), bcp_colptr(), bcp_moretext() and bcp_sendrow() may be used only after bcp_init() has been called with the copy direction set to DB_IN. */
    999 #define SYBEBCPB 20078 /* bcp_bind(), bcp_moretext() and bcp_sendrow() may NOT be used after bcp_init() has been passed a non-NULL input file name. */
    1000 #define SYBEVDPT 20079 /* For bulk copy, all variable-length data must have either a length-prefix or a terminator specified. */
    1001 #define SYBEBIVI 20080 /* bcp_columns(), bcp_colfmt() and bcp_colfmt_ps() may be used only after bcp_init() has been passed a valid input file. */
    1002 #define SYBEBCBC 20081 /* bcp_columns() must be called before bcp_colfmt() and bcp_colfmt_ps(). */
    1003 #define SYBEBCFO 20082 /* Bcp host-files must contain at least one column. */
    1004 #define SYBEBCVH 20083 /* bcp_exec() may be called only after bcp_init() has been passed a valid host file. */
    1005 #define SYBEBCUO 20084 /* Bcp: Unable to open host data-file. */
    1006 #define SYBEBCUC 20085 /* Bcp: Unable to close host data-file. */
    1007 #define SYBEBUOE 20086 /* Bcp: Unable to open error-file. */
    1008 #define SYBEBUCE 20087 /* Bcp: Unable to close error-file. */
    1009 #define SYBEBWEF 20088 /* I/O error while writing bcp error-file. */
    1010 #define SYBEASTF 20089 /* VMS: Unable to setmode for control_c ast. */
    1011 #define SYBEUACS 20090 /* VMS: Unable to assign channel to sys$command. */
    1012 #define SYBEASEC 20091 /* Attempt to send an empty command buffer to the SQL Server. */
    1013 #define SYBETMTD 20092 /* Attempt to send too much TEXT data via the dbmoretext() call. */
    1014 #define SYBENTTN 20093 /* Attempt to use dbtxtsput() to put a new text-timestamp into a non-existent data row. */
    1015 #define SYBEDNTI 20094 /* Attempt to use dbtxtsput() to put a new text-timestamp into a column whose datatype is neither SYBTEXT nor SYBIMAGE. */
    1016 #define SYBEBTMT 20095 /* Attempt to send too much TEXT data via the bcp_moretext() call. */
    1017 #define SYBEORPF 20096 /* Attempt to set remote password would overflow the login-record's remote-password field. */
    1018 #define SYBEUVBF 20097 /* Attempt to read an unknown version of BCP format-file. */
    1019 #define SYBEBUOF 20098 /* Bcp: Unable to open format-file. */
    1020 #define SYBEBUCF 20099 /* Bcp: Unable to close format-file. */
    1021 #define SYBEBRFF 20100 /* I/O error while reading bcp format-file. */
    1022 #define SYBEBWFF 20101 /* I/O error while writing bcp format-file. */
    1023 #define SYBEBUDF 20102 /* Bcp: Unrecognized datatype found in format-file. */
    1024 #define SYBEBIHC 20103 /* Incorrect host-column number found in bcp format-file. */
    1025 #define SYBEBEOF 20104 /* Unexpected EOF encountered in BCP data-file. */
    1026 #define SYBEBCNL 20105 /* Negative length-prefix found in BCP data-file. */
    1027 #define SYBEBCSI 20106 /* Host-file columns may be skipped only when copying INto the Server. */
    1028 #define SYBEBCIT 20107 /* It's illegal to use BCP terminators with program variables other than SYBCHAR, SYBBINARY, SYBTEXT, or SYBIMAGE. */
    1029 #define SYBEBCSA 20108 /* The BCP hostfile '%s' contains only %ld rows. Skipping all of these rows is not allowed. */
    1030 #define SYBENULL 20109 /* NULL DBPROCESS pointer passed to DB-Library. */
    1031 #define SYBEUNAM 20110 /* Unable to get current username from operating system. */
    1032 #define SYBEBCRO 20111 /* The BCP hostfile '%s' contains only %ld rows. It was impossible to read the requested %ld rows. */
    1033 #define SYBEMPLL 20112 /* Attempt to set maximum number of DBPROCESSes lower than 1. */
    1034 #define SYBERPIL 20113 /* It is illegal to pass -1 to dbrpcparam() for the datalen of parameters which are of type SYBCHAR, SYBVARCHAR, SYBBINARY, or SYBVARBINARY. */
    1035 #define SYBERPUL 20114 /* When passing a SYBINTN, SYBDATETIMN, SYBMONEYN, or SYBFLTN parameter via dbrpcparam(), it's necessary to specify the parameter's maximum or actual length, so that DB-Library can recognize it as a SYBINT1, SYBINT2, SYBINT4, SYBMONEY, or SYBMONEY4, etc. */
    1036 #define SYBEUNOP 20115 /* Unknown option passed to dbsetopt(). */
    1037 #define SYBECRNC 20116 /* The current row is not a result of compute clause %d, so it is illegal to attempt to extract that data from this row. */
    1038 #define SYBERTCC 20117 /* dbreadtext() may not be used to receive the results of a query which contains a COMPUTE clause. */
    1039 #define SYBERTSC 20118 /* dbreadtext() may only be used to receive the results of a query which contains a single result column. */
    1040 #define SYBEUCRR 20119 /* Internal software error: Unknown connection result reported by * dbpasswd(). */
    1041 #define SYBERPNA 20120 /* The RPC facility is available only when using a SQL Server whose version number is 4.0 or greater. */
    1042 #define SYBEOPNA 20121 /* The text/image facility is available only when using a SQL Server whose version number is 4.0 or greater. */
    1043 #define SYBEFGTL 20122 /* Bcp: Row number of the first row to be copied cannot be greater than the row number for the last row to be copied. */
    1044 #define SYBECWLL 20123 /* Attempt to set column width less than 1. */
    1045 #define SYBEUFDS 20124 /* Unrecognized format encountered in dbstrbuild(). */
    1046 #define SYBEUCPT 20125 /* Unrecognized custom-format parameter-type encountered in dbstrbuild(). */
    1047 #define SYBETMCF 20126 /* Attempt to install too many custom formats via dbfmtinstall(). */
    1048 #define SYBEAICF 20127 /* Error in attempting to install custom format. */
    1049 #define SYBEADST 20128 /* Error in attempting to determine the size of a pair of translation tables. */
    1050 #define SYBEALTT 20129 /* Error in attempting to load a pair of translation tables. */
    1051 #define SYBEAPCT 20130 /* Error in attempting to perform a character-set translation. */
    1052 #define SYBEXOCI 20131 /* A character-set translation overflowed its destination buffer while using bcp to copy data from a host-file to the SQL Server. */
    1053 #define SYBEFSHD 20132 /* Error in attempting to find the Sybase home directory. */
    1054 #define SYBEAOLF 20133 /* Error in attempting to open a localization file. */
    1055 #define SYBEARDI 20134 /* Error in attempting to read datetime information from a localization file. */
    1056 #define SYBEURCI 20135 /* Unable to read copyright information from the dblib localization file. */
    1057 #define SYBEARDL 20136 /* Error in attempting to read the dblib.loc localization file. */
    1058 #define SYBEURMI 20137 /* Unable to read money-format information from the dblib localization file. */
    1059 #define SYBEUREM 20138 /* Unable to read error mnemonic from the dblib localization file. */
    1060 #define SYBEURES 20139 /* Unable to read error string from the dblib localization file. */
    1061 #define SYBEUREI 20140 /* Unable to read error information from the dblib localization file. */
    1062 #define SYBEOREN 20141 /* Warning: an out-of-range error-number was encountered in dblib.loc. The maximum permissible error-number is defined as DBERRCOUNT in sybdb.h. */
    1063 #define SYBEISOI 20142 /* Invalid sort-order information found. */
    1064 #define SYBEIDCL 20143 /* Illegal datetime column length returned by DataServer. Legal datetime lengths are 4 and 8 bytes. */
    1065 #define SYBEIMCL 20144 /* Illegal money column length returned by DataServer. Legal money lengths are 4 and 8 bytes. */
    1066 #define SYBEIFCL 20145 /* Illegal floating-point column length returned by DataServer. Legal floating-point lengths are 4 and 8 bytes. */
    1067 #define SYBEUTDS 20146 /* Unrecognized TDS version received from SQL Server. */
    1068 #define SYBEBUFF 20147 /* Bcp: Unable to create format-file. */
    1069 #define SYBEACNV 20148 /* Attemp to do conversion with NULL destination variable. */
    1070 #define SYBEDPOR 20149 /* Out-of-range datepart constant. */
    1071 #define SYBENDC 20150 /* Cannot have negative component in date in numeric form. */
    1072 #define SYBEMVOR 20151 /* Month values must be between 1 and 12. */
    1073 #define SYBEDVOR 20152 /* Day values must be between 1 and 7. */
    1074 #define SYBENBVP 20153 /* Cannot pass dbsetnull() a NULL bindval pointer. */
    1075 #define SYBESPID 20154 /* Called dbspid() with a NULL dbproc. */
    1076 #define SYBENDTP 20155 /* Called dbdatecrack() with a NULL datetime parameter. */
    1077 #define SYBEXTN 20156 /* The xlt_todisp and xlt_tosrv parameters to dbfree_xlate() were NULL. */
    1078 #define SYBEXTDN 20157 /* Warning: the xlt_todisp parameter to dbfree_xlate() was NULL. The space associated with the xlt_tosrv parameter has been freed. */
    1079 #define SYBEXTSN 20158 /* Warning: the xlt_tosrv parameter to dbfree_xlate() was NULL. The space associated with the xlt_todisp parameter has been freed. */
    1080 #define SYBENUM 20159 /* Incorrect number of arguments given to DB-Library. */
    1081 #define SYBETYPE 20160 /* Invalid argument type given to DB-Library. */
    1082 #define SYBEGENOS 20161 /* General Operating System Error. */
    1083 #define SYBEPAGE 20162 /* wrong resource type or length given for dbpage() operation. */
    1084 #define SYBEOPTNO 20163 /* Option is not allowed or is unreconized */
    1085 #define SYBEETD 20164 /* Failure to send the expected amount of TEXT or IMAGE data via dbmoretext(). */
    1086 #define SYBERTYPE 20165 /* Invalid resource type given to DB-Library. */
    1087 #define SYBERFILE 20166 /* "Can not open resource file." */
    1088 #define SYBEFMODE 20167 /* Read/Write/Append mode denied on file. */
    1089 #define SYBESLCT 20168 /* Could not select or copy field specified */
    1090 #define SYBEZTXT 20169 /* Attempt to send zero length TEXT or IMAGE to dataserver via dbwritetext(). */
    1091 #define SYBENTST 20170 /* The file being opened must be a stream_lf. */
    1092 #define SYBEOSSL 20171 /* Operating system login level not in range of Secure SQL Server */
    1093 #define SYBEESSL 20172 /* Login security level entered does not agree with operating system level */
    1094 #define SYBENLNL 20173 /* Program not linked with specified network library. */
    1095 #define SYBENHAN 20174 /* called dbrecvpassthru() with a NULL handler parameter. */
    1096 #define SYBENBUF 20175 /* called dbsendpassthru() with a NULL buf pointer. */
    1097 #define SYBENULP 20176 /* Called %s with a NULL %s parameter. */
    1098 #define SYBENOTI 20177 /* No event handler installed. */
    1099 #define SYBEEVOP 20178 /* Called dbregwatch() with a bad options parameter. */
    1100 #define SYBENEHA 20179 /* Called dbreghandle() with a NULL handler parameter. */
    1101 #define SYBETRAN 20180 /* DBPROCESS is being used for another transaction. */
    1102 #define SYBEEVST 20181 /* Must initiate a transaction before calling dbregparam(). */
    1103 #define SYBEEINI 20182 /* Must call dbreginit() before dbregraise(). */
    1104 #define SYBEECRT 20183 /* Must call dbregdefine() before dbregcreate(). */
    1105 #define SYBEECAN 20184 /* Attempted to cancel unrequested event notification. */
    1106 #define SYBEEUNR 20185 /* Unsolicited event notification received. */
    1107 #define SYBERPCS 20186 /* Must call dbrpcinit() before dbrpcparam(). */
    1108 #define SYBETPAR 20187 /* No SYBTEXT or SYBIMAGE parameters were defined. */
    1109 #define SYBETEXS 20188 /* Called dbmoretext() with a bad size parameter. */
    1110 #define SYBETRAC 20189 /* Attempted to turn off a trace flag that was not on. */
    1111 #define SYBETRAS 20190 /* DB-Library internal error - trace structure not found. */
    1112 #define SYBEPRTF 20191 /* dbtracestring() may only be called from a printfunc(). */
    1113 #define SYBETRSN 20192 /* Bad numbytes parameter passed to dbtracestring(). */
    1114 #define SYBEBPKS 20193 /* In DBSETLPACKET(), the packet size parameter must be between 0 and 999999. */
    1115 #define SYBEIPV 20194 /* %1! is an illegal value for the %2! parameter of %3!. */
    1116 #define SYBEMOV 20195 /* Money arithmetic resulted in overflow in function %1!. */
    1117 #define SYBEDIVZ 20196 /* Attempt to divide by $0.00 in function %1!. */
    1118 #define SYBEASTL 20197 /* Synchronous I/O attempted at AST level. */
    1119 #define SYBESEFA 20198 /* DBSETNOTIFS cannot be called if connections are present. */
    1120 #define SYBEPOLL 20199 /* Only one dbpoll() can be active at a time. */
    1121 #define SYBENOEV 20200 /* dbpoll() cannot be called if registered procedure notifications have been disabled. */
    1122 #define SYBEBADPK 20201 /* Packet size of %1! not supported. -- size of %2! used instead. */
    1123 #define SYBESECURE 20202 /* Secure Server function not supported in this version. */
    1124 #define SYBECAP 20203 /* DB-Library capabilities not accepted by the Server. */
    1125 #define SYBEFUNC 20204 /* Functionality not supported at the specified version level. */
    1126 #define SYBERESP 20205 /* Response function address passed to dbresponse() must be non-NULL. */
    1127 #define SYBEIVERS 20206 /* Illegal version level specified. */
    1128 #define SYBEONCE 20207 /* Function can be called only once. */
    1129 #define SYBERPNULL 20208 /* value parameter for dbprcparam() can be NULL, only if the datalen parameter is 0 */
    1130 #define SYBERPTXTIM 20209 /* RPC parameters cannot be of type Text/Image. */
    1131 #define SYBENEG 20210 /* Negotiated login attempt failed. */
    1132 #define SYBELBLEN 20211 /* Security labels should be less than 256 characters long. */
    1133 #define SYBEUMSG 20212 /* Unknown message-id in MSG datastream. */
    1134 #define SYBECAPTYP 20213 /* Unexpected capability type in CAPABILITY datastream. */
    1135 #define SYBEBNUM 20214 /* Bad numbytes parameter passed to dbstrcpy() */
    1136 #define SYBEBBL 20215 /* Bad bindlen parameter passed to dbsetnull() */
    1137 #define SYBEBPREC 20216 /* Illegal precision specified */
    1138 #define SYBEBSCALE 20217 /* Illegal scale specified */
    1139 #define SYBECDOMAIN 20218 /* Source field value is not within the domain of legal values. */
    1140 #define SYBECINTERNAL 20219 /* Internal Conversion error. */
    1141 #define SYBEBTYPSRV 20220 /* Datatype is not supported by the server. */
    1142 #define SYBEBCSET 20221 /* Unknown character-set encountered." */
    1143 #define SYBEFENC 20222 /* Password Encryption failed." */
    1144 #define SYBEFRES 20223 /* Challenge-Response function failed.", */
    1145 #define SYBEISRVPREC 20224 /* Illegal precision value returned by the server. */
    1146 #define SYBEISRVSCL 20225 /* Illegal scale value returned by the server. */
    1147 #define SYBEINUMCL 20226 /* Invalid numeric column length returned by the server. */
    1148 #define SYBEIDECCL 20227 /* Invalid decimal column length returned by the server. */
    1149 #define SYBEBCMTXT 20228 /* bcp_moretext() may be used only when there is at least one text or image column in the server table. */
    1150 #define SYBEBCPREC 20229 /* Column %1!: Illegal precision value encountered. */
    1151 #define SYBEBCBNPR 20230 /* bcp_bind(): if varaddr is NULL, prefixlen must be 0 and no terminator should be specified. */
    1152 #define SYBEBCBNTYP 20231 /* bcp_bind(): if varaddr is NULL and varlen greater than 0, the table column type must be SYBTEXT or SYBIMAGE and the program variable type must be SYBTEXT, SYBCHAR, SYBIMAGE or SYBBINARY. */
    1153 #define SYBEBCSNTYP 20232 /* column number %1!: if varaddr is NULL and varlen greater than 0, the table column type must be SYBTEXT or SYBIMAGE and the program variable type must be SYBTEXT, SYBCHAR, SYBIMAGE or SYBBINARY. */
    1154 #define SYBEBCPCTYP 20233 /* bcp_colfmt(): If table_colnum is 0, host_type cannot be 0. */
    1155 #define SYBEBCVLEN 20234 /* varlen should be greater than or equal to -1. */
    1156 #define SYBEBCHLEN 20235 /* host_collen should be greater than or equal to -1. */
    1157 #define SYBEBCBPREF 20236 /* Illegal prefix length. Legal values are 0, 1, 2 or 4. */
    1158 #define SYBEBCPREF 20237 /* Illegal prefix length. Legal values are -1, 0, 1, 2 or 4. */
    1159 #define SYBEBCITBNM 20238 /* bcp_init(): tblname parameter cannot be NULL. */
    1160 #define SYBEBCITBLEN 20239 /* bcp_init(): tblname parameter is too long. */
    1161 #define SYBEBCSNDROW 20240 /* bcp_sendrow() may NOT be called unless all text data for the previous row has been sent using bcp_moretext(). */
    1162 #define SYBEBPROCOL 20241 /* bcp protocol error: returned column count differs from the actual number of columns received. */
    1163 #define SYBEBPRODEF 20242 /* bcp protocol error: expected default information and got none. */
    1164 #define SYBEBPRONUMDEF 20243 /* bcp protocol error: expected number of defaults differs from the actual number of defaults received. */
    1165 #define SYBEBPRODEFID 20244 /* bcp protocol error: default column id and actual column id are not same */
    1166 #define SYBEBPRONODEF 20245 /* bcp protocol error: default value received for column that does not have default. */
    1167 #define SYBEBPRODEFTYP 20246 /* bcp protocol error: default value datatype differs from column datatype. */
    1168 #define SYBEBPROEXTDEF 20247 /* bcp protocol error: more than one row of default information received. */
    1169 #define SYBEBPROEXTRES 20248 /* bcp protocol error: unexpected set of results received. */
    1170 #define SYBEBPROBADDEF 20249 /* bcp protocol error: illegal default column id received. */
    1171 #define SYBEBPROBADTYP 20250 /* bcp protocol error: unknown column datatype. */
    1172 #define SYBEBPROBADLEN 20251 /* bcp protocol error: illegal datatype length received. */
    1173 #define SYBEBPROBADPREC 20252 /* bcp protocol error: illegal precision value received. */
    1174 #define SYBEBPROBADSCL 20253 /* bcp protocol error: illegal scale value received. */
    1175 #define SYBEBADTYPE 20254 /* Illegal value for type parameter given to %1!. */
    1176 #define SYBECRSNORES 20255 /* Cursor statement generated no results. */
    1177 #define SYBECRSNOIND 20256 /* One of the tables involved in the cursor statement does not have a unique index. */
    1178 #define SYBECRSVIEW 20257 /* A view cannot be joined with another table or a view in a cursor statement. */
    1179 #define SYBECRSVIIND 20258 /* The view used in the cursor statement does not include all the unique index columns of the underlying tables. */
    1180 #define SYBECRSORD 20259 /* Only fully keyset driven cursors can have 'order by', ' group by', or 'having' phrases. */
    1181 #define SYBECRSBUFR 20260 /* Row buffering should not be turned on when using cursor APIs. */
    1182 #define SYBECRSNOFREE 20261 /* The DBNOAUTOFREE option should not be turned on when using cursor APIs. */
    1183 #define SYBECRSDIS 20262 /* Cursor statement contains one of the disallowed phrases 'compute', 'union', 'for browse', or 'select into'. */
    1184 #define SYBECRSAGR 20263 /* Aggregate functions are not allowed in a cursor statement. */
    1185 #define SYBECRSFRAND 20264 /* Fetch types RANDOM and RELATIVE can only be used within the keyset of keyset driven cursors. */
    1186 #define SYBECRSFLAST 20265 /* Fetch type LAST requires fully keyset driven cursors. */
    1187 #define SYBECRSBROL 20266 /* Backward scrolling cannot be used in a forward scrolling cursor. */
    1188 #define SYBECRSFROWN 20267 /* Row number to be fetched is outside valid range. */
    1189 #define SYBECRSBSKEY 20268 /* Keyset cannot be scrolled backward in mixed cursors with a previous fetch type. */
    1190 #define SYBECRSRO 20269 /* Data locking or modifications cannot be made in a READONLY cursor. */
    1191 #define SYBECRSNOCOUNT 20270 /* The DBNOCOUNT option should not be turned on when doing updates or deletes with dbcursor(). */
    1192 #define SYBECRSTAB 20271 /* Table name must be determined in operations involving data locking or modifications. */
    1193 #define SYBECRSUPDNB 20272 /* Update or insert operations cannot use bind variables when binding type is NOBIND. */
    1194 #define SYBECRSNOWHERE 20273 /* A WHERE clause is not allowed in a cursor update or insert. */
    1195 #define SYBECRSSET 20274 /* A SET clause is required for a cursor update or insert. */
    1196 #define SYBECRSUPDTAB 20275 /* Update or insert operations using bind variables require single table cursors. */
    1197 #define SYBECRSNOUPD 20276 /* Update or delete operation did not affect any rows. */
    1198 #define SYBECRSINV 20277 /* Invalid cursor statement. */
    1199 #define SYBECRSNOKEYS 20278 /* The entire keyset must be defined for KEYSET cursors. */
    1200 #define SYBECRSNOBIND 20279 /* Cursor bind must be called prior to updating cursor */
    1201 #define SYBECRSFTYPE 20280 /* Unknown fetch type. */
    1202 #define SYBECRSINVALID 20281 /* The cursor handle is invalid. */
    1203 #define SYBECRSMROWS 20282 /* Multiple rows are returned, only one is expected. */
    1204 #define SYBECRSNROWS 20283 /* No rows returned, at least one is expected. */
    1205 #define SYBECRSNOLEN 20284 /* No unique index found. */
    1206 #define SYBECRSNOPTCC 20285 /* No OPTCC was found. */
    1207 #define SYBECRSNORDER 20286 /* The order of clauses must be from, where, and order by. */
    1208 #define SYBECRSNOTABLE 20287 /* Table name is NULL. */
    1209 #define SYBECRSNUNIQUE 20288 /* No unique keys associated with this view. */
    1210 #define SYBECRSVAR 20289 /* There is no valid address associated with this bind. */
    1211 #define SYBENOVALUE 20290 /* Security labels require both a name and a value */
    1212 #define SYBEVOIDRET 20291 /* Parameter of type SYBVOID cannot be a return parameter. */
    1213 #define SYBECLOSEIN 20292 /* Unable to close interface file. */
    1214 #define SYBEBOOL 20293 /* Boolean parameters must be TRUE or FALSE. */
    1215 #define SYBEBCPOPT 20294 /* The option cannot be called while a bulk copy operation is progress. */
    1216 #define SYBEERRLABEL 20295 /* An illegal value was returned from the security label handler. */
    1217 #define SYBEATTNACK 20296 /* Timed out waiting for server to acknowledge attention." */
    1218 #define SYBEBBFL 20297 /* -001- Batch failed in bulk-copy to SQL Server */
    1219 #define SYBEDCL 20298 /* -004- DCL Error */
    1220 #define SYBECS 20299 /* -004- cs context Error */
    1221 #define SYBEBULKINSERT 20599 /* cannot build bulk insert statement */
    1222 #define SYBECOLSIZE 22000 /* Invalid column information structure size */
    1223 
    1224 int dbtds(DBPROCESS * dbprocess);
    1225 
    1226 #define DBTDS(a) dbtds(a)
    1227 DBINT dbtextsize(DBPROCESS * dbprocess);
    1228 DBBINARY *dbtxptr(DBPROCESS * dbproc, int column);
    1229 DBBINARY *dbtxtimestamp(DBPROCESS * dbproc, int column);
    1230 DBBINARY *dbtxtsnewval(DBPROCESS * dbprocess);
    1231 RETCODE dbtxtsput(DBPROCESS * dbprocess, DBBINARY newtxts, int colnum);
    1232 RETCODE dbuse(DBPROCESS * dbproc, const char *name);
    1233 const char *dbversion(void);
    1234 DBBOOL dbwillconvert(int srctype, int desttype);
    1235 RETCODE dbwritetext(DBPROCESS * dbproc, char *objname, DBBINARY * textptr, DBTINYINT textptrlen, DBBINARY * timestamp,
    1236  DBBOOL log, DBINT size, BYTE * text);
    1237 
    1238 /* LOGINREC manipulation */
    1239 RETCODE dbsetlname(LOGINREC * login, const char *value, int which);
    1240 RETCODE dbsetlbool(LOGINREC * login, int value, int which);
    1241 RETCODE dbsetlshort(LOGINREC * login, int value, int which);
    1242 RETCODE dbsetllong(LOGINREC * login, long value, int which);
    1243 RETCODE dbsetlversion (LOGINREC * login, BYTE version);
    1244 
    1245 #define DBSETHOST 1
    1246 #define DBSETLHOST(x,y) dbsetlname((x), (y), DBSETHOST)
    1247 #define dbsetlhost(x,y) dbsetlname((x), (y), DBSETHOST)
    1248 #define DBSETUSER 2
    1249 #define DBSETLUSER(x,y) dbsetlname((x), (y), DBSETUSER)
    1250 #define dbsetluser(x,y) dbsetlname((x), (y), DBSETUSER)
    1251 #define DBSETPWD 3
    1252 #define DBSETLPWD(x,y) dbsetlname((x), (y), DBSETPWD)
    1253 #define dbsetlpwd(x,y) dbsetlname((x), (y), DBSETPWD)
    1254 #if defined(DBLIB_UNIMPLEMENTED)
    1255 # define DBSETHID 4 /* not implemented */
    1256 # define DBSETLHID(x,y) dbsetlname((x), (y), DBSETHID)
    1257 #endif
    1258 #define DBSETAPP 5
    1259 #define DBSETLAPP(x,y) dbsetlname((x), (y), DBSETAPP)
    1260 #define dbsetlapp(x,y) dbsetlname((x), (y), DBSETAPP)
    1261 #define DBSETBCP 6
    1262 #define BCP_SETL(x,y) dbsetlbool((x), (y), DBSETBCP)
    1263 #define DBSETLSECURE(x) dbsetlbool((x), (1), DBSETBCP)
    1264 #define DBSETNATLANG 7
    1265 #define DBSETLNATLANG(x,y) dbsetlname((x), (y), DBSETNATLANG)
    1266 #define dbsetlnatlang(x,y) dbsetlname((x), (y), DBSETNATLANG)
    1267 #if defined(DBLIB_UNIMPLEMENTED)
    1268 # define DBSETNOSHORT 8 /* not implemented */
    1269 # define DBSETLNOSHORT(x,y) dbsetlbool((x), (y), DBSETNOSHORT)
    1270 # define DBSETHIER 9 /* not implemented */
    1271 # define DBSETLHIER(x,y) dbsetlshort((x), (y), DBSETHIER)
    1272 #endif
    1273 #define DBSETCHARSET 10
    1274 #define DBSETLCHARSET(x,y) dbsetlname((x), (y), DBSETCHARSET)
    1275 #define DBSETPACKET 11
    1276 #define DBSETLPACKET(x,y) dbsetllong((x), (y), DBSETPACKET)
    1277 #define dbsetlpacket(x,y) dbsetllong((x), (y), DBSETPACKET)
    1278 #define DBSETENCRYPT 12
    1279 #define DBSETLENCRYPT(x,y) dbsetlbool((x), (y), DBSETENCRYPT)
    1280 #define DBSETLABELED 13
    1281 #define DBSETLLABELED(x,y) dbsetlbool((x), (y), DBSETLABELED)
    1282 #define BCP_SETLABELED(x,y) dbsetlbool((x), (y), DBSETLABELED)
    1283 #define DBSETDBNAME 14
    1284 #define DBSETLDBNAME(x,y) dbsetlname((x), (y), DBSETDBNAME)
    1285 #define DBSETLVERSION(login, version) dbsetlversion((login), (version))
    1286 /* settings from here are purely FreeTDS extensions */
    1287 #define DBSETUTF16 1001
    1288 #define DBSETLUTF16(x,y) dbsetlbool((x), (y), DBSETUTF16)
    1289 #define DBSETNTLMV2 1002
    1290 #define DBSETLNTLMV2(x,y) dbsetlbool((x), (y), DBSETNTLMV2)
    1291 #define DBSETREADONLY 1003
    1292 #define DBSETLREADONLY(x,y) dbsetlbool((x), (y), DBSETREADONLY)
    1293 
    1294 RETCODE bcp_init(DBPROCESS * dbproc, const char *tblname, const char *hfile, const char *errfile, int direction);
    1295 DBINT bcp_done(DBPROCESS * dbproc);
    1296 
    1297 DBINT bcp_batch(DBPROCESS * dbproc);
    1298 RETCODE bcp_bind(DBPROCESS * dbproc, BYTE * varaddr, int prefixlen, DBINT varlen, BYTE * terminator, int termlen, int type,
    1299  int table_column);
    1300 RETCODE bcp_collen(DBPROCESS * dbproc, DBINT varlen, int table_column);
    1301 RETCODE bcp_columns(DBPROCESS * dbproc, int host_colcount);
    1302 RETCODE bcp_colfmt(DBPROCESS * dbproc, int host_column, int host_type, int host_prefixlen, DBINT host_collen,
    1303  const BYTE * host_term, int host_termlen, int colnum);
    1304 RETCODE bcp_colfmt_ps(DBPROCESS * dbproc, int host_column, int host_type, int host_prefixlen, DBINT host_collen,
    1305  BYTE * host_term, int host_termlen, int colnum, DBTYPEINFO * typeinfo);
    1306 RETCODE bcp_colptr(DBPROCESS * dbproc, BYTE * colptr, int table_column);
    1307 RETCODE bcp_control(DBPROCESS * dbproc, int field, DBINT value);
    1308 int bcp_getbatchsize(DBPROCESS * dbproc); /* FreeTDS only */
    1309 RETCODE bcp_exec(DBPROCESS * dbproc, DBINT * rows_copied);
    1310 DBBOOL bcp_getl(LOGINREC * login);
    1311 RETCODE bcp_options(DBPROCESS * dbproc, int option, BYTE * value, int valuelen);
    1312 RETCODE bcp_readfmt(DBPROCESS * dbproc, const char filename[]);
    1313 RETCODE bcp_sendrow(DBPROCESS * dbproc);
    1314 
    1315 #ifdef __cplusplus
    1316 #if 0
    1317 {
    1318 #endif
    1319 }
    1320 #endif
    1321 
    1322 #endif
    Definition: sybdb.h:289
    char * dbname(DBPROCESS *dbproc)
    Get name of current database.
    Definition: dblib.c:6858
    int dbstrbuild(DBPROCESS *dbproc, char *charbuf, int bufsize, char *text, char *formats,...)
    Build a printable string from text containing placeholders for variables.
    Definition: dblib.c:7152
    RETCODE dbcancel(DBPROCESS *dbproc)
    Cancel the current command batch.
    Definition: dblib.c:3231
    RETCODE dbcanquery(DBPROCESS *dbproc)
    Cancel the query currently being retrieved, discarding all pending rows.
    Definition: dblib.c:5877
    RETCODE dbmny4sub(DBPROCESS *dbproc, DBMONEY4 *m1, DBMONEY4 *m2, DBMONEY4 *diff)
    Subtract two DBMONEY4 values.
    Definition: dblib.c:5471
    Definition: sybdb.h:505
    RETCODE dbmnydec(DBPROCESS *dbproc, DBMONEY *mnyptr)
    Subtract $0.0001 from a DBMONEY value.
    Definition: dblib.c:5338
    DBINT dbprcollen(DBPROCESS *dbproc, int column)
    Get size of a result column needed to print column.
    Definition: dblib.c:3086
    void dbsetavail(DBPROCESS *dbprocess)
    Mark a DBPROCESS as "available".
    Definition: dblib.c:7127
    RETCODE bcp_init(DBPROCESS *dbproc, const char *tblname, const char *hfile, const char *errfile, int direction)
    Prepare for bulk copy operation on a table.
    Definition: bcp.c:164
    Definition: dbpivot.c:75
    RETCODE bcp_bind(DBPROCESS *dbproc, BYTE *varaddr, int prefixlen, DBINT varlen, BYTE *terminator, int termlen, int type, int table_column)
    Bind a program host variable to a database column.
    Definition: bcp.c:2028
    BYTE * dbdata(DBPROCESS *dbproc, int column)
    Get address of data in a regular result column.
    Definition: dblib.c:3189
    Definition: sybdb.h:457
    RETCODE dbmnyzero(DBPROCESS *dbproc, DBMONEY *dest)
    Set a DBMONEY value to zero.
    Definition: dblib.c:5171
    int dbmnycmp(DBPROCESS *dbproc, DBMONEY *m1, DBMONEY *m2)
    Compare two DBMONEY values.
    Definition: dblib.c:5113
    Definition: sybdb.h:341
    void dbrecftos(const char filename[])
    Record to a file all SQL commands sent to the server.
    Definition: dblib.c:6618
    int dbaltop(DBPROCESS *dbproc, int computeid, int column)
    Get aggregation operator for a compute column.
    Definition: dblib.c:4293
    RETCODE dbsqlok(DBPROCESS *dbproc)
    Wait for results of a query from the server.
    Definition: dblib.c:4660
    RETCODE dbrpcsend(DBPROCESS *dbproc)
    Execute the procedure and free associated memory.
    Definition: rpc.c:281
    void dbloginfree(LOGINREC *login)
    free the LOGINREC
    Definition: dblib.c:748
    RETCODE dbresults(DBPROCESS *dbproc)
    Set up query results.
    Definition: dblib.c:1688
    int dbalttype(DBPROCESS *dbproc, int computeid, int column)
    Get datatype for a compute column.
    Definition: dblib.c:4180
    RETCODE dbsetlbool(LOGINREC *login, int value, int which)
    Set a boolean value in a LOGINREC structure.
    Definition: dblib.c:904
    DBPROCESS * dbopen(LOGINREC *login, const char *server)
    Normally not used.
    Definition: dbopen.c:36
    char * dbretname(DBPROCESS *dbproc, int retnum)
    Get name of an output parameter filled by a stored procedure.
    Definition: dblib.c:4570
    DBINT dbaltutype(DBPROCESS *dbproc, int computeid, int column)
    Get user-defined datatype of a compute column.
    Definition: dblib.c:6965
    DBINT dbspr1rowlen(DBPROCESS *dbproc)
    Determine size buffer required to hold the results returned by dbsprhead(), dbsprline(), and dbspr1row().
    Definition: dblib.c:3256
    Definition: dblib.h:120
    RETCODE dbcmdrow(DBPROCESS *dbproc)
    See if the current command can return rows.
    Definition: dblib.c:4098
    DBINT bcp_batch(DBPROCESS *dbproc)
    Commit a set of rows to the table.
    Definition: bcp.c:1959
    RETCODE dbcolinfo(DBPROCESS *dbproc, CI_TYPE type, DBINT column, DBINT computeid, DBCOL *pdbcol)
    Get a bunch of column attributes with a single call (Microsoft-compatibility feature).
    Definition: dblib.c:2941
    Definition: sybdb.h:489
    DBBOOL bcp_getl(LOGINREC *login)
    See if BCP_SETL() was used to set the LOGINREC for BCP work.
    Definition: bcp.c:697
    RETCODE bcp_readfmt(DBPROCESS *dbproc, const char filename[])
    Read a format definition file.
    Definition: bcp.c:1627
    void dbexit(void)
    Close server connections and free all related structures.
    Definition: dblib.c:1541
    int dbrettype(DBPROCESS *dbproc, int retnum)
    Get datatype of a stored procedure&#39;s return parameter.
    Definition: dblib.c:6117
    int dbmny4cmp(DBPROCESS *dbproc, DBMONEY4 *m1, DBMONEY4 *m2)
    Compare two DBMONEY4 values.
    Definition: dblib.c:5559
    RETCODE dbcmd(DBPROCESS *dbproc, const char cmdstring[])
    Append SQL to the command buffer.
    Definition: dblib.c:1359
    RETCODE dbdatecrack(DBPROCESS *dbproc, DBDATEREC *di, DBDATETIME *dt)
    Break a DBDATETIME value into useful pieces.
    Definition: dblib.c:5694
    RETCODE dbmny4minus(DBPROCESS *dbproc, DBMONEY4 *src, DBMONEY4 *dest)
    Negate a DBMONEY4 value.
    Definition: dblib.c:5393
    DBINT dbretstatus(DBPROCESS *dbproc)
    Fetch status value returned by query or remote procedure call.
    Definition: dblib.c:4520
    RETCODE dbsetlversion(LOGINREC *login, BYTE version)
    Set TDS version for future connections.
    Definition: dblib.c:942
    RETCODE dbpivot(DBPROCESS *dbproc, int nkeys, int *keys, int ncols, int *cols, DBPIVOT_FUNC func, int val)
    Pivot the rows, creating a new resultset.
    Definition: dbpivot.c:907
    STATUS dbreadtext(DBPROCESS *dbproc, void *buf, DBINT bufsize)
    Fetch part of a text or image value from the server.
    Definition: dblib.c:6514
    int dbdatecmp(DBPROCESS *dbproc, DBDATETIME *d1, DBDATETIME *d2)
    Compare DBDATETIME values, similar to strcmp(3).
    Definition: dblib.c:5612
    int dbspid(DBPROCESS *dbproc)
    Get server process ID for a DBPROCESS.
    Definition: dblib.c:5767
    void dbsetuserdata(DBPROCESS *dbproc, BYTE *ptr)
    Associate client-allocated (and defined) data with a DBPROCESS.
    Definition: dblib.c:5787
    RETCODE bcp_control(DBPROCESS *dbproc, int field, DBINT value)
    Set BCP options for uploading a datafile.
    Definition: bcp.c:539
    LOGINREC * dblogin(void)
    Allocate a LOGINREC structure.
    Definition: dblib.c:716
    int dbnumrets(DBPROCESS *dbproc)
    Get count of output parameters filled by a stored procedure.
    Definition: dblib.c:4538
    DBTYPEINFO * dbcoltypeinfo(DBPROCESS *dbproc, int column)
    Get precision and scale information for a regular result column.
    Definition: dblib.c:2912
    DBINT dbdatlen(DBPROCESS *dbproc, int column)
    Get size of current row&#39;s data in a regular result column.
    Definition: dblib.c:3161
    RETCODE dbmnyminus(DBPROCESS *dbproc, DBMONEY *src, DBMONEY *dest)
    Negate a DBMONEY value.
    Definition: dblib.c:5366
    void dbfreebuf(DBPROCESS *dbproc)
    Erase the command buffer, in case DBNOAUTOFREE was set with dbsetopt().
    Definition: dblib.c:5909
    RETCODE dbaltbind(DBPROCESS *dbprocess, int computeid, int column, int vartype, DBINT varlen, BYTE *varaddr)
    Bind a compute column to a program variable.
    Definition: dblib.c:4216
    int dbnumcols(DBPROCESS *dbproc)
    Return number of regular columns in a result set.
    Definition: dblib.c:1842
    RETCODE bcp_exec(DBPROCESS *dbproc, DBINT *rows_copied)
    Write a datafile to a table.
    Definition: bcp.c:1566
    RETCODE dbsetnull(DBPROCESS *dbprocess, int bindtype, int bindlen, BYTE *bindval)
    Define substitution values to be used when binding null values.
    Definition: dblib.c:1930
    DBINT dbvarylen(DBPROCESS *dbproc, int column)
    Determine whether a column can vary in size.
    Definition: dblib.c:3112
    DBINT dbcurrow(DBPROCESS *dbproc)
    Get number of the row currently being read.
    Definition: dblib.c:6035
    RETCODE bcp_columns(DBPROCESS *dbproc, int host_colcount)
    Indicate how many columns are to be found in the datafile.
    Definition: bcp.c:296
    RETCODE dbuse(DBPROCESS *dbproc, const char *name)
    Change current database.
    Definition: dblib.c:1431
    DBINT dbcollen(DBPROCESS *dbproc, int column)
    Get size of a regular result column.
    Definition: dblib.c:3063
    RETCODE dbwritetext(DBPROCESS *dbproc, char *objname, DBBINARY *textptr, DBTINYINT textptrlen, DBBINARY *timestamp, DBBOOL log, DBINT size, BYTE *text)
    Send text or image data to the server.
    Definition: dblib.c:6445
    void dbprhead(DBPROCESS *dbproc)
    Print result set headings to stdout.
    Definition: dblib.c:3795
    int dbgetmaxprocs(void)
    get maximum simultaneous connections db-lib will open to the server.
    Definition: dblib.c:4009
    Definition: dbpivot.c:764
    RETCODE bcp_sendrow(DBPROCESS *dbproc)
    Write data in host variables to the table.
    Definition: bcp.c:1339
    RETCODE dbsqlsend(DBPROCESS *dbproc)
    Transmit the command buffer to the server.
    Definition: dblib.c:6894
    RETCODE dbmny4copy(DBPROCESS *dbprocess, DBMONEY4 *m1, DBMONEY4 *m2)
    Copy a DBMONEY4 value.
    Definition: dblib.c:5587
    RETCODE dbmoretext(DBPROCESS *dbproc, DBINT size, const BYTE text[])
    Send chunk of a text/image value to the server.
    Definition: dblib.c:6583
    RETCODE dbmny4zero(DBPROCESS *dbproc, DBMONEY4 *dest)
    Zero a DBMONEY4 value.
    Definition: dblib.c:5417
    const char * dbmonthname(DBPROCESS *dbproc, char *language, int monthnum, DBBOOL shortform)
    Get name of a month, in some human language.
    Definition: dblib.c:6809
    RETCODE dbmnycopy(DBPROCESS *dbproc, DBMONEY *src, DBMONEY *dest)
    Copy a DBMONEY value.
    Definition: dblib.c:5856
    DBINT dbadlen(DBPROCESS *dbproc, int computeid, int column)
    Get size of data in a compute column.
    Definition: dblib.c:4149
    DBSMALLINT offset
    time offset
    Definition: sybdb.h:310
    RETCODE dbmnymaxpos(DBPROCESS *dbproc, DBMONEY *dest)
    Get maximum positive DBMONEY value supported.
    Definition: dblib.c:5192
    RETCODE dbspr1row(DBPROCESS *dbproc, char *buffer, DBINT buf_len)
    Print a regular result row to a buffer.
    Definition: dblib.c:3294
    Definition: sybdb.h:268
    int dbiordesc(DBPROCESS *dbproc)
    Get file descriptor of the socket used by a DBPROCESS to read data coming from the server...
    Definition: dblib.c:7083
    DBINT dbcount(DBPROCESS *dbproc)
    Get count of rows processed.
    Definition: dblib.c:2793
    DBINT dblastrow(DBPROCESS *dbproc)
    Get number of the last row in the row buffer.
    Definition: dblib.c:7059
    DBINT dbconvert(DBPROCESS *dbproc, int srctype, const BYTE *src, DBINT srclen, int desttype, BYTE *dest, DBINT destlen)
    cf.
    Definition: dblib.c:2562
    int dbaltcolid(DBPROCESS *dbproc, int computeid, int column)
    Get column ID of a compute column.
    Definition: dblib.c:4122
    const char * dbprtype(int token)
    Print a token value&#39;s name to a buffer.
    Definition: dblib.c:6299
    DBUBIGINT time
    time, 7 digit precision
    Definition: sybdb.h:308
    int dbgetpacket(DBPROCESS *dbproc)
    Get TDS packet size for the connection.
    Definition: dblib.c:3911
    RETCODE dbmny4add(DBPROCESS *dbproc, DBMONEY4 *m1, DBMONEY4 *m2, DBMONEY4 *sum)
    Add two DBMONEY4 values.
    Definition: dblib.c:5440
    RETCODE dbanydatecrack(DBPROCESS *dbproc, DBDATEREC2 *di, int type, const void *data)
    Break any kind of date or time value into useful pieces.
    Definition: dblib.c:5715
    STATUS dbsetrow(DBPROCESS *dbprocess, DBINT row)
    Make a buffered row "current" without fetching it into bound variables.
    Definition: dblib.c:2013
    RETCODE dbmnyinc(DBPROCESS *dbproc, DBMONEY *mnyptr)
    Add $0.0001 to a DBMONEY value.
    Definition: dblib.c:5310
    RETCODE dbsetlname(LOGINREC *login, const char *value, int which)
    Set the value of a string in a LOGINREC structure.
    Definition: dblib.c:770
    RETCODE dbmnymaxneg(DBPROCESS *dbproc, DBMONEY *dest)
    Get maximum negative DBMONEY value supported.
    Definition: dblib.c:5213
    Definition: sybdb.h:300
    RETCODE dbinit(void)
    Initialize db-lib.
    Definition: dblib.c:671
    char * dbcolname(DBPROCESS *dbproc, int column)
    Return name of a regular result column.
    Definition: dblib.c:1866
    RETCODE dbmorecmds(DBPROCESS *dbproc)
    See if more commands are to be processed.
    Definition: dblib.c:6086
    DBINT bcp_done(DBPROCESS *dbproc)
    Conclude the transfer of data from program variables.
    Definition: bcp.c:1986
    RETCODE dbsprhead(DBPROCESS *dbproc, char *buffer, DBINT buf_len)
    Print result set headings to a buffer.
    Definition: dblib.c:3731
    BYTE * dbretdata(DBPROCESS *dbproc, int retnum)
    Get value of an output parameter filled by a stored procedure.
    Definition: dblib.c:4599
    DBINT dbconvert_ps(DBPROCESS *dbprocess, int srctype, const BYTE *src, DBINT srclen, int desttype, BYTE *dest, DBINT destlen, DBTYPEINFO *typeinfo)
    Convert one datatype to another.
    Definition: dblib.c:2269
    char * dbcolsource(DBPROCESS *dbproc, int colnum)
    Get base database column name for a result set column.
    Definition: dblib.c:3038
    DBBOOL dbhasretstat(DBPROCESS *dbproc)
    Determine if query generated a return status number.
    Definition: dblib.c:4496
    BYTE * dbbylist(DBPROCESS *dbproc, int computeid, int *size)
    Get bylist for a compute row.
    Definition: dblib.c:4846
    DBBINARY * dbtxtimestamp(DBPROCESS *dbproc, int column)
    Get text timestamp for a column in the current row.
    Definition: dblib.c:6378
    RETCODE dbrows(DBPROCESS *dbproc)
    Indicate whether a query returned rows.
    Definition: dblib.c:3870
    DBINT dbaltlen(DBPROCESS *dbproc, int computeid, int column)
    Get size of data in compute column.
    Definition: dblib.c:6989
    RETCODE dbsprline(DBPROCESS *dbproc, char *buffer, DBINT buf_len, DBCHAR line_char)
    Get formatted string for underlining dbsprhead() column names.
    Definition: dblib.c:3673
    void dbsetinterrupt(DBPROCESS *dbproc, DB_DBCHKINTR_FUNC chkintr, DB_DBHNDLINTR_FUNC hndlintr)
    Set interrupt handler for db-lib to use while blocked against a read from the server.
    Definition: dblib.c:4477
    char * dbchange(DBPROCESS *dbprocess)
    See if a command caused the current database to change.
    Definition: dblib.c:6838
    RETCODE dbsetmaxprocs(int maxprocs)
    Set maximum simultaneous connections db-lib will open to the server.
    Definition: dblib.c:3935
    RETCODE bcp_colfmt_ps(DBPROCESS *dbproc, int host_column, int host_type, int host_prefixlen, DBINT host_collen, BYTE *host_term, int host_termlen, int colnum, DBTYPEINFO *typeinfo)
    Specify the format of a host file for bulk copy purposes, with precision and scale support for numeri...
    Definition: bcp.c:504
    DBINT dbfirstrow(DBPROCESS *dbproc)
    See if a server response has arrived.
    Definition: dblib.c:7044
    Definition: sybdb.h:373
    int dbgettime(void)
    Get maximum seconds db-lib waits for a server response to query.
    Definition: dblib.c:4061
    int dbcurcmd(DBPROCESS *dbproc)
    Get number of the row just returned.
    Definition: dblib.c:6069
    RETCODE dbsafestr(DBPROCESS *dbproc, const char *src, DBINT srclen, char *dest, DBINT destlen, int quotetype)
    safely quotes character values in SQL text.
    Definition: dblib.c:6238
    RETCODE dbrpcinit(DBPROCESS *dbproc, const char rpcname[], DBSMALLINT options)
    Initialize a remote procedure call.
    Definition: rpc.c:72
    Definition: dblib.h:42
    RETCODE dbsetllong(LOGINREC *login, long value, int which)
    Set an integer value in a LOGINREC structure.
    Definition: dblib.c:833
    BYTE * dbadata(DBPROCESS *dbproc, int computeid, int column)
    Get address of compute column data.
    Definition: dblib.c:4263
    Definition: sybdb.h:283
    char * dbservcharset(DBPROCESS *dbprocess)
    Get syscharset name of the server character set.
    Definition: dblib.c:6874
    RETCODE dbsetversion(DBINT version)
    Specify a db-lib version level.
    Definition: dblib.c:5823
    int dbnumcompute(DBPROCESS *dbprocess)
    Get count of COMPUTE clauses for a result set.
    Definition: dblib.c:4820
    Definition: sybdb.h:262
    DBINT date
    date, 0 = 1900-01-01
    Definition: sybdb.h:309
    RETCODE dbrpcparam(DBPROCESS *dbproc, const char paramname[], BYTE status, int type, DBINT maxlen, DBINT datalen, BYTE *value)
    Add a parameter to a remote procedure call.
    Definition: rpc.c:155
    BYTE * dbgetuserdata(DBPROCESS *dbproc)
    Get address of user-allocated data from a DBPROCESS.
    Definition: dblib.c:5805
    int dbtds(DBPROCESS *dbprocess)
    Get the TDS version in use for dbproc.
    Definition: dblib.c:6652
    int dbiowdesc(DBPROCESS *dbproc)
    Get file descriptor of the socket used by a DBPROCESS to write data coming to the server...
    Definition: dblib.c:7099
    BOOL dbiscount(DBPROCESS *dbproc)
    Indicates whether or not the count returned by dbcount is real (Microsoft-compatibility feature)...
    Definition: dblib.c:2773
    int dbstrlen(DBPROCESS *dbproc)
    Get size of the command buffer, in bytes.
    Definition: dblib.c:6142
    RETCODE bcp_options(DBPROCESS *dbproc, int option, BYTE *value, int valuelen)
    Set "hints" for uploading a file.
    Definition: bcp.c:613
    int dbcoltype(DBPROCESS *dbproc, int column)
    Get the datatype of a regular result set column.
    Definition: dblib.c:2860
    DBINT dbcolutype(DBPROCESS *dbprocess, int column)
    Get user-defined datatype of a regular result column.
    Definition: dblib.c:2889
    char * dbgetchar(DBPROCESS *dbprocess, int n)
    Get address of a position in the command buffer.
    Definition: dblib.c:6161
    STATUS dbrowtype(DBPROCESS *dbprocess)
    Get returned row&#39;s type.
    Definition: dblib.c:6052
    void dbclose(DBPROCESS *dbproc)
    Close a connection to the server and free associated resources.
    Definition: dblib.c:1474
    DBBOOL dbwillconvert(int srctype, int desttype)
    Test whether or not a datatype can be converted to another datatype.
    Definition: dblib.c:2843
    RETCODE dbsetopt(DBPROCESS *dbproc, int option, const char *char_param, int int_param)
    Set db-lib or server option.
    Definition: dblib.c:4321
    void dbsetifile(char *filename)
    set name and location of the interfaces file FreeTDS should use to look up a servername.
    Definition: dblib.c:2680
    RETCODE bcp_colptr(DBPROCESS *dbproc, BYTE *colptr, int table_column)
    Override bcp_bind() by pointing to a different host variable.
    Definition: bcp.c:661
    Definition: sybdb.h:335
    DBBOOL dbisopt(DBPROCESS *dbproc, int option, const char param[])
    Get value of an option.
    Definition: dblib.c:6012
    RETCODE dbsettime(int seconds)
    Set maximum seconds db-lib waits for a server response to query.
    Definition: dblib.c:4030
    void dbclrbuf(DBPROCESS *dbproc, DBINT n)
    Clear n rows from the row buffer.
    Definition: dblib.c:2813
    EHANDLEFUNC dberrhandle(EHANDLEFUNC handler)
    Set an error handler, for messages from db-lib.
    Definition: dblib.c:4968
    Definition: sybdb.h:294
    Definition: sybdb.h:274
    RETCODE dbnullbind(DBPROCESS *dbproc, int column, DBINT *indicator)
    Tie a null-indicator to a regular result column.
    Definition: dblib.c:2709
    DBBOOL dbdead(DBPROCESS *dbproc)
    Check if dbproc is an ex-parrot.
    Definition: dblib.c:4905
    int dbretlen(DBPROCESS *dbproc, int retnum)
    Get size of an output parameter filled by a stored procedure.
    Definition: dblib.c:4625
    DBBINARY * dbtxptr(DBPROCESS *dbproc, int column)
    Get text pointer for a column in the current row.
    Definition: dblib.c:6408
    RETCODE dbsqlexec(DBPROCESS *dbproc)
    send the SQL command to the server and wait for an answer.
    Definition: dblib.c:1405
    RETCODE dbstrcpy(DBPROCESS *dbproc, int start, int numbytes, char *dest)
    Get a copy of a chunk of the command buffer.
    Definition: dblib.c:6194
    RETCODE dbclropt(DBPROCESS *dbproc, int option, const char param[])
    Reset an option.
    Definition: dblib.c:5944
    RETCODE dbsetlogintime(int seconds)
    Set maximum seconds db-lib waits for a server response to a login attempt.
    Definition: dblib.c:4077
    RETCODE bcp_colfmt(DBPROCESS *dbproc, int host_column, int host_type, int host_prefixlen, DBINT host_collen, const BYTE *host_term, int host_termlen, int colnum)
    Specify the format of a datafile prior to writing to a table.
    Definition: bcp.c:372
    int dbnumalts(DBPROCESS *dbproc, int computeid)
    Get count of columns in a compute row.
    Definition: dblib.c:4787
    const char * dbversion(void)
    See which version of db-lib is in use.
    Definition: dblib.c:6691
    RETCODE dbprrow(DBPROCESS *dbproc)
    Print a result set to stdout.
    Definition: dblib.c:3377
    Definition: sybdb.h:473
    RETCODE dbbind(DBPROCESS *dbproc, int column, int vartype, DBINT varlen, BYTE *varaddr)
    Tie a host variable to a resultset column.
    Definition: dblib.c:2603
    DBPROCESS * tdsdbopen(LOGINREC *login, const char *server, int msdblib)
    Form a connection with the server.
    Definition: dblib.c:1171
    Definition: sybdb.h:354
    RETCODE dbanullbind(DBPROCESS *dbprocess, int computeid, int column, DBINT *indicator)
    Tie a null-indicator to a compute result column.
    Definition: dblib.c:2745
    RETCODE dbfcmd(DBPROCESS *dbproc, const char *fmt,...)
    printf-like way to form SQL to send to the server.
    Definition: dblib.c:1320
    RETCODE dbtablecolinfo(DBPROCESS *dbproc, DBINT column, DBCOL *pdbcol)
    describe table column attributes with a single call (Freetds-only API function modelled on dbcolinfo)...
    Definition: dblib.c:6316
    RETCODE bcp_collen(DBPROCESS *dbproc, DBINT varlen, int table_column)
    Set the length of a host variable to be written to a table.
    Definition: bcp.c:261
    RETCODE dbgetrow(DBPROCESS *dbproc, DBINT row)
    Read a row from the row buffer.
    Definition: dblib.c:1898
    Definition: sybdb.h:306
    MHANDLEFUNC dbmsghandle(MHANDLEFUNC handler)
    Set a message handler, for messages from the server.
    Definition: dblib.c:4987
    freetds-1.00.82/doc/reference/a00479_a9b73fd1afa2c3ccfca481635212d2e43_cgraph.svg100644 025423 025423 00000003110 13242511136 0021335 dbcolinfo Node0 dbcolinfo Node1 tdsdump_log Node0->Node1 freetds-1.00.82/doc/reference/a00479_ae408d8e1c2ab0767d8bfd26d00d1ff6a_cgraph.map100644 025423 025423 00000001047 13242511134 0021411 freetds-1.00.82/doc/reference/a00479_ae408d8e1c2ab0767d8bfd26d00d1ff6a_cgraph.md5100644 025423 025423 00000000040 13242511133 00213106048748ff5a1d3cd859c16a266c05e27freetds-1.00.82/doc/reference/a00479_ae408d8e1c2ab0767d8bfd26d00d1ff6a_cgraph.svg100644 025423 025423 00000006175 13242511136 0021444 dbopen Node3 dbopen Node4 tdsdbopen Node3->Node4 Node5 tdsdump_open Node4->Node5 Node6 tdsdump_log Node4->Node6 freetds-1.00.82/doc/reference/a00480.map100644 025423 025423 00000000255 13242511134 0013042 freetds-1.00.82/doc/reference/a00480.md5100644 025423 025423 00000000040 13242511133 0012741bd5525d04aef100542624a5500ffa982freetds-1.00.82/doc/reference/a00480.svg100644 025423 025423 00000003160 13242511136 0013064 include/sybdb.h Node0 include/sybdb.h Node1 tds_sysdep_public.h Node0->Node1 freetds-1.00.82/doc/reference/a00481.map100644 025423 025423 00000001031 13242511134 0013034 freetds-1.00.82/doc/reference/a00481.md5100644 025423 025423 00000000040 13242511133 0012742a8a6aea25413d02ed350bf8284923a73freetds-1.00.82/doc/reference/a00481.svg100644 025423 025423 00000010114 13242511136 0013062 include/sybdb.h Node2 include/sybdb.h Node3 src/dblib/dblib.c Node2->Node3 Node4 include/sqldb.h Node2->Node4 Node5 include/sybfront.h Node2->Node5 Node5->Node3 Node6 include/sqlfront.h Node5->Node6 freetds-1.00.82/doc/reference/a00482_source.html100644 025423 025423 00000024267 13242511132 0014622 FreeTDS API: include/syberror.h Source File
    FreeTDS API
    syberror.h
    1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
    2  * Copyright (C) 1998-1999 Brian Bruns
    3  *
    4  * This library is free software; you can redistribute it and/or
    5  * modify it under the terms of the GNU Library General Public
    6  * License as published by the Free Software Foundation; either
    7  * version 2 of the License, or (at your option) any later version.
    8  *
    9  * This library is distributed in the hope that it will be useful,
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    12  * Library General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU Library General Public
    15  * License along with this library; if not, write to the
    16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    17  * Boston, MA 02111-1307, USA.
    18  */
    19 
    20 #ifndef _syberror_h_
    21 #define _syberror_h_
    22 
    23 #ifdef __cplusplus
    24 extern "C"
    25 {
    26 #if 0
    27 }
    28 #endif
    29 #endif
    30 
    31 static const char rcsid_syberror_h[] = "$Id: syberror.h,v 1.4 2004-10-28 12:42:12 freddy77 Exp $";
    32 static const void *const no_unused_syberror_h_warn[] = { rcsid_syberror_h, no_unused_syberror_h_warn };
    33 
    34 /* severity levels, gleaned from google */
    35 #define EXINFO 1
    36 #define EXUSER 2
    37 #define EXNONFATAL 3
    38 #define EXCONVERSION 4
    39 #define EXSERVER 5
    40 #define EXTIME 6
    41 #define EXPROGRAM 7
    42 #define EXRESOURCE 8
    43 #define EXCOMM 9
    44 #define EXFATAL 10
    45 #define EXCONSISTENCY 11
    46 
    47 #ifdef __cplusplus
    48 #if 0
    49 {
    50 #endif
    51 }
    52 #endif
    53 
    54 #endif
    freetds-1.00.82/doc/reference/a00485_source.html100644 025423 025423 00000022136 13242511132 0014616 FreeTDS API: include/sybfront.h Source File
    FreeTDS API
    sybfront.h
    1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
    2  * Copyright (C) 1998-1999 Brian Bruns
    3  *
    4  * This library is free software; you can redistribute it and/or
    5  * modify it under the terms of the GNU Library General Public
    6  * License as published by the Free Software Foundation; either
    7  * version 2 of the License, or (at your option) any later version.
    8  *
    9  * This library is distributed in the hope that it will be useful,
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    12  * Library General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU Library General Public
    15  * License along with this library; if not, write to the
    16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    17  * Boston, MA 02111-1307, USA.
    18  */
    19 
    20 #ifndef SYBFRONT_h
    21 #define SYBFRONT_h
    22 
    23 #include "sybdb.h"
    24 
    25 #ifdef __cplusplus
    26 extern "C"
    27 {
    28 #if 0
    29 }
    30 #endif
    31 #endif
    32 
    33 static const char rcsid_sybfront_h[] = "$Id: sybfront.h,v 1.3 2004-10-28 12:42:12 freddy77 Exp $";
    34 static const void *const no_unused_sybfront_h_warn[] = { rcsid_sybfront_h, no_unused_sybfront_h_warn };
    35 
    36 
    37 
    38 #ifdef __cplusplus
    39 #if 0
    40 {
    41 #endif
    42 }
    43 #endif
    44 
    45 
    46 #endif
    Primary include file for db-lib applications.
    freetds-1.00.82/doc/reference/a00488_source.html100644 025423 025423 00000035005 13242511132 0014620 FreeTDS API: include/tds_sysdep_public.h Source File
    FreeTDS API
    tds_sysdep_public.h
    1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
    2  * Copyright (C) 1998-2011 Brian Bruns
    3  *
    4  * This library is free software; you can redistribute it and/or
    5  * modify it under the terms of the GNU Library General Public
    6  * License as published by the Free Software Foundation; either
    7  * version 2 of the License, or (at your option) any later version.
    8  *
    9  * This library is distributed in the hope that it will be useful,
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    12  * Library General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU Library General Public
    15  * License along with this library; if not, write to the
    16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    17  * Boston, MA 02111-1307, USA.
    18  */
    19 
    20 #ifndef _tds_sysdep_public_h_
    21 #define _tds_sysdep_public_h_
    22 
    23 /*
    24 ** This is where platform-specific changes need to be made.
    25 */
    26 #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
    27 #include <winsock2.h>
    28 #include <ws2tcpip.h>
    29 #include <windows.h>
    30 #define tds_sysdep_int16_type short /* 16-bit int */
    31 #define tds_sysdep_int32_type int /* 32-bit int */
    32 #define tds_sysdep_int64_type __int64 /* 64-bit int */
    33 #define tds_sysdep_real32_type float /* 32-bit real */
    34 #define tds_sysdep_real64_type double /* 64-bit real */
    35 #if !defined(WIN64) && !defined(_WIN64)
    36 #define tds_sysdep_intptr_type int /* 32-bit int */
    37 #else
    38 #define tds_sysdep_intptr_type __int64 /* 64-bit int */
    39 #endif
    40 #endif /* defined(WIN32) || defined(_WIN32) || defined(__WIN32__) */
    41 
    42 #ifndef tds_sysdep_int16_type
    43 #define tds_sysdep_int16_type short /* 16-bit int */
    44 #endif /* !tds_sysdep_int16_type */
    45 
    46 #ifndef tds_sysdep_int32_type
    47 #define tds_sysdep_int32_type int /* 32-bit int */
    48 #endif /* !tds_sysdep_int32_type */
    49 
    50 #ifndef tds_sysdep_int64_type
    51 #define tds_sysdep_int64_type long /* 64-bit int */
    52 #endif /* !tds_sysdep_int64_type */
    53 
    54 #ifndef tds_sysdep_real32_type
    55 #define tds_sysdep_real32_type float /* 32-bit real */
    56 #endif /* !tds_sysdep_real32_type */
    57 
    58 #ifndef tds_sysdep_real64_type
    59 #define tds_sysdep_real64_type double /* 64-bit real */
    60 #endif /* !tds_sysdep_real64_type */
    61 
    62 #ifndef tds_sysdep_intptr_type
    63 #define tds_sysdep_intptr_type long
    64 #endif /* !tds_sysdep_intptr_type */
    65 
    66 #if !defined(MSDBLIB) && !defined(SYBDBLIB)
    67 #define SYBDBLIB 1
    68 #endif
    69 #if defined(MSDBLIB) && defined(SYBDBLIB)
    70 #error MSDBLIB and SYBDBLIB cannot both be defined
    71 #endif
    72 
    73 #endif /* _tds_sysdep_public_h_ */
    freetds-1.00.82/doc/reference/a00491_source.html100644 025423 025423 00000005711 13242511133 0014614 FreeTDS API: win32/freetds/sysconfdir.h Source File
    FreeTDS API
    sysconfdir.h
    1 #define FREETDS_SYSCONFDIR "c:"
    freetds-1.00.82/doc/reference/a00500_source.html100644 025423 025423 00000031021 13242511133 0014574 FreeTDS API: vms/vargdefs.h Source File
    FreeTDS API
    vargdefs.h
    1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
    2  * Copyright (C) 2010 Craig A. Berry craigberry@mac.com
    3  *
    4  * This library is free software; you can redistribute it and/or
    5  * modify it under the terms of the GNU Library General Public
    6  * License as published by the Free Software Foundation; either
    7  * version 2 of the License, or (at your option) any later version.
    8  *
    9  * This library is distributed in the hope that it will be useful,
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    12  * Library General Public License for more details.
    13  *
    14  * You should have received a copy of the GNU Library General Public
    15  * License along with this library; if not, write to the
    16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    17  * Boston, MA 02111-1307, USA.
    18 
    19 /*
    20  * Definitions used by the VMSARG parsing and mapping routines.
    21  *
    22  * Based on VMSARG Version 2.0 by Tom Wade <t.wade@vms.eurokom.ei>
    23  *
    24  * Extensively revised for inclusion in FreeTDS by Craig A. Berry.
    25  *
    26  * From the VMSARG 2.0 documentation:
    27  *
    28  * The product is aimed at . . . people who are porting a package from
    29  * Unix to VMS. This software is made freely available for inclusion in
    30  * such products, whether they are freeware, public domain or commercial.
    31  * No licensing is required.
    32  */
    33 
    34 #if __CRTL_VER >= 70302000 && !defined(__VAX)
    35 #define QUAL_LENGTH (4000+1)
    36 #define S_LENGTH (4096+1)
    37 #else
    38 #define QUAL_LENGTH (255+1)
    39 #define S_LENGTH (1024+1)
    40 #endif
    41 
    42 #define MAX_ARGS 255
    43 
    44 /* bit fields for arg flags.
    45 */
    46 
    47 #define VARG_M_AFFIRM 1
    48 #define VARG_M_NEGATIVE 2
    49 #define VARG_M_KEYWORDS 4
    50 #define VARG_M_SEPARATOR 8
    51 #define VARG_M_DATE 16
    52 #define VARG_M_APPEND 32
    53 #define VARG_M_HELP 64
    54 
    55 /* bit fields for action flags.
    56 */
    57 
    58 #define VARGACT_M_UPPER 1
    59 #define VARGACT_M_LOWER 2
    60 #define VARGACT_M_SPECIAL 4
    61 #define VARGACT_M_ESCAPE 8
    62 #define VARGACT_M_DOUBLE 16
    63 #define VARGACT_M_IMAGE 32
    64 #define VARGACT_M_SYMBOL 64
    65 #define VARGACT_M_COMMAND 128
    66 #define VARGACT_M_RETURN 256
    67 #define VARGACT_M_PROTECT 512
    68 #define VARGACT_M_UNIXARG 1024
    69 
    70 #define VARGACT_M_PROTMASK 1+2+4+8+16
    freetds-1.00.82/doc/reference/a00515.html100644 025423 025423 00000017377 13242511133 0013244 FreeTDS API: Todo List
    FreeTDS API
    Todo List
    Member bcp_colfmt_ps (DBPROCESS *dbproc, int host_colnum, int host_type, int host_prefixlen, DBINT host_collen, BYTE *host_term, int host_termlen, int table_colnum, DBTYPEINFO *typeinfo)
    Not implemented.
    Member bcp_options (DBPROCESS *dbproc, int option, BYTE *value, int valuelen)
    Simplify. Remove valuelen, and dbproc->bcpinfo->hint = strdup(hints[i])
    Member dbanullbind (DBPROCESS *dbproc, int computeid, int column, DBINT *indicator)
    Never fails, but only because failure conditions aren't checked.
    Member dbcancel (DBPROCESS *dbproc)
    Check for failure and return accordingly.
    Member dbcolinfo (DBPROCESS *dbproc, CI_TYPE type, DBINT column, DBINT computeid, DBCOL *pdbcol)
    Support cursor rows.
    Member dbconvert_ps (DBPROCESS *dbproc, int db_srctype, const BYTE *src, DBINT srclen, int db_desttype, BYTE *dest, DBINT destlen, DBTYPEINFO *typeinfo)

    What happens if client does not reset values?

    Microsoft and Sybase define this function differently.

    Member dbcurcmd (DBPROCESS *dbproc)
    Unimplemented.
    Member dbcurrow (DBPROCESS *dbproc)
    Unimplemented.
    Member dbexit ()
    breaks if ctlib/dblib used in same process.
    Member dbfirstrow (DBPROCESS *dbproc)
    Unimplemented.
    Member dbmoretext (DBPROCESS *dbproc, DBINT size, const BYTE text[])
    Check return value of called functions and return FAIL if appropriate.
    Member dbretdata (DBPROCESS *dbproc, int retnum)
    Handle blobs.
    Member dbsetlbool (LOGINREC *login, int value, int which)
    DBSETNOSHORT, DBSETENCRYPT, DBSETLABELED
    Member DBSETLENCRYPT (x, y)
    Unimplemented.
    Member dbsetopt (DBPROCESS *dbproc, int option, const char *char_param, int int_param)
    Implement more options.
    Member tds_iconv (TDSSOCKET *tds, TDSICONV *conv, TDS_ICONV_DIRECTION io, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)

    Check for variable multibyte non-UTF-8 input character set.

    Use more robust error message generation.

    For reads, cope with outbuf encodings that don't have the equivalent of an ASCII '?'.

    Support alternative to '?' for the replacement character.

    Member tds_process_tokens (TDSSOCKET *tds, TDS_INT *result_type, int *done_flags, unsigned flag)
    Complete TDS_DESCRIBE_RESULT description
    Member tds_set_server (TDSLOGIN *tds_login, const char *server) TDS_WUR
    open the log file earlier, so these messages can be seen.
    Member tdsdbopen (LOGINREC *login, const char *server, int msdblib)

    use asprintf() to avoid buffer overflow.

    separate error messages for no-such-server and no-such-user.

    freetds-1.00.82/doc/reference/a00516.html100644 025423 025423 00000005601 13242511133 0013230 FreeTDS API: Bug List
    FreeTDS API
    Bug List
    Member dbcolname (DBPROCESS *dbproc, int column)
    Relies on ASCII column names, post iconv conversion. Will not work as described for UTF-8 or UCS-2 clients. But maybe it shouldn't.
    freetds-1.00.82/doc/reference/a00517.html100644 025423 025423 00000036277 13242511136 0013251 FreeTDS API: The db-lib API
    FreeTDS API
    The db-lib API

    Functions callable by db-lib client programs. More...

    Collaboration diagram for The db-lib API:

    Modules

     Primary functions
     Core functions needed by most db-lib programs.
     
     Remote Procedure functions
     Functions used with stored procedures.
     
     Bulk copy functions
     Functions to bulk-copy (a/k/a bcp) data to/from the database.
     
     Money functions
     Functions to manipulate the MONEY datatype.
     
     Datetime functions
     Functions to manipulate DBDATETIME structures.
     
     Internals
     Functions called within db-lib for self-help.
     
     Unimplemented
     Functions thus far not implemented in the FreeTDS db-lib implementation.
     

    Macros

    #define BCP_SETL(x, y)   dbsetlbool((x), (y), DBSETBCP)
     Enable (or prevent) bcp operations for connections made with a login. More...
     
    #define DBSETLAPP(x, y)   dbsetlname((x), (y), DBSETAPP)
     Set the (client) application name in the login packet. More...
     
    #define DBSETLHOST(x, y)   dbsetlname((x), (y), DBSETHOST)
     Set the (client) host name in the login packet. More...
     
    #define DBSETLPWD(x, y)   dbsetlname((x), (y), DBSETPWD)
     Set the password in the login packet. More...
     
    #define DBSETLUSER(x, y)   dbsetlname((x), (y), DBSETUSER)
     Set the username in the login packet. More...
     

    Detailed Description

    Functions callable by db-lib client programs.

    The db_lib interface is implemented by both Sybase and Microsoft. FreeTDS seeks to implement first the intersection of the functions defined by the vendors.

    Macro Definition Documentation

    § BCP_SETL

    BCP_SETL (   x,
     
    )    dbsetlbool((x), (y), DBSETBCP)

    Enable (or prevent) bcp operations for connections made with a login.

    See also
    bcp_setl()

    § DBSETLAPP

    DBSETLAPP (   x,
     
    )    dbsetlname((x), (y), DBSETAPP)

    Set the (client) application name in the login packet.

    See also
    dbsetlapp()

    § DBSETLHOST

    DBSETLHOST (   x,
     
    )    dbsetlname((x), (y), DBSETHOST)

    Set the (client) host name in the login packet.

    See also
    dbsetlhost()

    § DBSETLPWD

    DBSETLPWD (   x,
     
    )    dbsetlname((x), (y), DBSETPWD)

    Set the password in the login packet.

    See also
    dbsetlpwd()

    § DBSETLUSER

    DBSETLUSER (   x,
     
    )    dbsetlname((x), (y), DBSETUSER)

    Set the username in the login packet.

    See also
    dbsetluser()
    freetds-1.00.82/doc/reference/a00517.map100644 025423 025423 00000002077 13242511134 0013047 freetds-1.00.82/doc/reference/a00517.md5100644 025423 025423 00000000040 13242511133 00127423c062f1521ae5c8572bf62260a7b8bd4freetds-1.00.82/doc/reference/a00517.svg100644 025423 025423 00000014226 13242511136 0013072 The db-lib API Node0 The db-lib API Node2 Remote Procedure functions Node0->Node2 Node4 Money functions Node0->Node4 Node6 Internals Node0->Node6 Node1 Primary functions Node0->Node1 Node5 Datetime functions Node0->Node5 Node7 Unimplemented Node0->Node7 Node3 Bulk copy functions Node0->Node3 freetds-1.00.82/doc/reference/a00518.html100644 025423 025423 00001217024 13242511136 0013242 FreeTDS API: Primary functions
    FreeTDS API
    Primary functions

    Core functions needed by most db-lib programs. More...

    Collaboration diagram for Primary functions:

    Macros

    #define DBCMDROW(x)   dbcmdrow((x))
     Sybase macro mapping to the Microsoft (lower-case) function. More...
     
    #define DBCOUNT(x)   dbcount((x))
     Sybase macro mapping to the Microsoft (lower-case) function. More...
     
    #define DBCURCMD(x)   dbcurcmd((x))
     Sybase macro mapping to the Microsoft (lower-case) function. More...
     
    #define DBCURROW(x)   dbcurrow((x))
     Sybase macro mapping to the Microsoft (lower-case) function. More...
     
    #define DBDEAD(x)   dbdead((x))
     Sybase macro mapping to the Microsoft (lower-case) function. More...
     
    #define DBFIRSTROW(x)   dbfirstrow((x))
     Sybase macro mapping to the Microsoft (lower-case) function. More...
     
    #define DBIORDESC(x)   dbiordesc((x))
     Sybase macro, maps to the internal (lower-case) function. More...
     
    #define DBIOWDESC(x)   dbiowdesc((x))
     Sybase macro, maps to the internal (lower-case) function. More...
     
    #define DBISAVAIL(x)   dbisavail((x))
     Sybase macro mapping to the Microsoft (lower-case) function. More...
     
    #define DBLASTROW(x)   dblastrow((x))
     Sybase macro mapping to the Microsoft (lower-case) function. More...
     
    #define DBMORECMDS(x)   dbmorecmds((x))
     Sybase macro mapping to the Microsoft (lower-case) function. More...
     
    #define DBROWS(x)   dbrows((x))
     Sybase macro mapping to the Microsoft (lower-case) function. More...
     
    #define DBROWTYPE(x)   dbrowtype((x))
     Sybase macro mapping to the Microsoft (lower-case) function. More...
     
    #define DBSETLCHARSET(x, y)   dbsetlname((x), (y), DBSETCHARSET)
     Set the client character set in the login packet. More...
     
    #define DBSETLENCRYPT(x, y)   dbsetlbool((x), (y), DBSETENCRYPT)
     Enable (or not) network password encryption for Sybase servers version 10.0 or above. More...
     
    #define DBSETLNATLANG(x, y)   dbsetlname((x), (y), DBSETNATLANG)
     Set the language the server should use for messages. More...
     
    #define dbsetlnatlang(x, y)   dbsetlname((x), (y), DBSETNATLANG)
     Set the language the server should use for messages. More...
     
    #define DBSETLPACKET(x, y)   dbsetllong((x), (y), DBSETPACKET)
     Set the packet size in the login packet for new connections. More...
     
    #define dbsetlpacket(x, y)   dbsetllong((x), (y), DBSETPACKET)
     Set the packet size in the login packet for new connections. More...
     
    #define DBTDS(a)   dbtds(a)
     Sybase macro, maps to the internal (lower-case) function. More...
     

    Functions

    static RETCODE _dbresults (DBPROCESS *dbproc)
     
    BYTE * dbadata (DBPROCESS *dbproc, int computeid, int column)
     Get address of compute column data. More...
     
    DBINT dbadlen (DBPROCESS *dbproc, int computeid, int column)
     Get size of data in a compute column. More...
     
    RETCODE dbaltbind (DBPROCESS *dbproc, int computeid, int column, int vartype, DBINT varlen, BYTE *varaddr)
     Bind a compute column to a program variable. More...
     
    int dbaltcolid (DBPROCESS *dbproc, int computeid, int column)
     Get column ID of a compute column. More...
     
    DBINT dbaltlen (DBPROCESS *dbproc, int computeid, int column)
     Get size of data in compute column. More...
     
    int dbaltop (DBPROCESS *dbproc, int computeid, int column)
     Get aggregation operator for a compute column. More...
     
    int dbalttype (DBPROCESS *dbproc, int computeid, int column)
     Get datatype for a compute column. More...
     
    DBINT dbaltutype (DBPROCESS *dbproc, int computeid, int column)
     Get user-defined datatype of a compute column. More...
     
    RETCODE dbanullbind (DBPROCESS *dbproc, int computeid, int column, DBINT *indicator)
     Tie a null-indicator to a compute result column. More...
     
    RETCODE dbanydatecrack (DBPROCESS *dbproc, DBDATEREC2 *di, int type, const void *data)
     Break any kind of date or time value into useful pieces. More...
     
    RETCODE dbbind (DBPROCESS *dbproc, int column, int vartype, DBINT varlen, BYTE *varaddr)
     Tie a host variable to a resultset column. More...
     
    BYTE * dbbylist (DBPROCESS *dbproc, int computeid, int *size)
     Get bylist for a compute row. More...
     
    RETCODE dbcancel (DBPROCESS *dbproc)
     Cancel the current command batch. More...
     
    RETCODE dbcanquery (DBPROCESS *dbproc)
     Cancel the query currently being retrieved, discarding all pending rows. More...
     
    char * dbchange (DBPROCESS *dbproc)
     See if a command caused the current database to change. More...
     
    void dbclose (DBPROCESS *dbproc)
     Close a connection to the server and free associated resources. More...
     
    void dbclrbuf (DBPROCESS *dbproc, DBINT n)
     Clear n rows from the row buffer. More...
     
    RETCODE dbclropt (DBPROCESS *dbproc, int option, const char param[])
     Reset an option. More...
     
    RETCODE dbcmd (DBPROCESS *dbproc, const char cmdstring[])
     Append SQL to the command buffer. More...
     
    DBINT dbcollen (DBPROCESS *dbproc, int column)
     Get size of a regular result column. More...
     
    char * dbcolname (DBPROCESS *dbproc, int column)
     Return name of a regular result column. More...
     
    char * dbcolsource (DBPROCESS *dbproc, int column)
     Get base database column name for a result set column. More...
     
    int dbcoltype (DBPROCESS *dbproc, int column)
     Get the datatype of a regular result set column. More...
     
    DBTYPEINFOdbcoltypeinfo (DBPROCESS *dbproc, int column)
     Get precision and scale information for a regular result column. More...
     
    int dbcolutype (DBPROCESS *dbproc, int column)
     Get user-defined datatype of a regular result column. More...
     
    DBINT dbconvert (DBPROCESS *dbproc, int srctype, const BYTE *src, DBINT srclen, int desttype, BYTE *dest, DBINT destlen)
     cf. More...
     
    DBINT dbconvert_ps (DBPROCESS *dbproc, int db_srctype, const BYTE *src, DBINT srclen, int db_desttype, BYTE *dest, DBINT destlen, DBTYPEINFO *typeinfo)
     Convert one datatype to another. More...
     
    DBINT dbcount (DBPROCESS *dbproc)
     Get count of rows processed. More...
     
    BYTE * dbdata (DBPROCESS *dbproc, int column)
     Get address of data in a regular result column. More...
     
    RETCODE dbdatecrack (DBPROCESS *dbproc, DBDATEREC *di, DBDATETIME *datetime)
     Break a DBDATETIME value into useful pieces. More...
     
    DBINT dbdatlen (DBPROCESS *dbproc, int column)
     Get size of current row's data in a regular result column. More...
     
    EHANDLEFUNC dberrhandle (EHANDLEFUNC handler)
     Set an error handler, for messages from db-lib. More...
     
    void dbexit ()
     Close server connections and free all related structures. More...
     
    RETCODE dbfcmd (DBPROCESS *dbproc, const char *fmt,...)
     printf-like way to form SQL to send to the server. More...
     
    void dbfreebuf (DBPROCESS *dbproc)
     Erase the command buffer, in case DBNOAUTOFREE was set with dbsetopt(). More...
     
    char * dbgetchar (DBPROCESS *dbproc, int pos)
     Get address of a position in the command buffer. More...
     
    int dbgetmaxprocs (void)
     get maximum simultaneous connections db-lib will open to the server. More...
     
    int dbgetpacket (DBPROCESS *dbproc)
     Get TDS packet size for the connection. More...
     
    RETCODE dbgetrow (DBPROCESS *dbproc, DBINT row)
     Read a row from the row buffer. More...
     
    int dbgettime (void)
     Get maximum seconds db-lib waits for a server response to query. More...
     
    BYTE * dbgetuserdata (DBPROCESS *dbproc)
     Get address of user-allocated data from a DBPROCESS. More...
     
    RETCODE dbinit (void)
     Initialize db-lib. More...
     
    BOOL dbiscount (DBPROCESS *dbproc)
     Indicates whether or not the count returned by dbcount is real (Microsoft-compatibility feature). More...
     
    DBBOOL dbisopt (DBPROCESS *dbproc, int option, const char param[])
     Get value of an option. More...
     
    LOGINRECdblogin (void)
     Allocate a LOGINREC structure. More...
     
    void dbloginfree (LOGINREC *login)
     free the LOGINREC More...
     
    RETCODE dbmorecmds (DBPROCESS *dbproc)
     See if more commands are to be processed. More...
     
    RETCODE dbmoretext (DBPROCESS *dbproc, DBINT size, const BYTE text[])
     Send chunk of a text/image value to the server. More...
     
    MHANDLEFUNC dbmsghandle (MHANDLEFUNC handler)
     Set a message handler, for messages from the server. More...
     
    char * dbname (DBPROCESS *dbproc)
     Get name of current database. More...
     
    RETCODE dbnullbind (DBPROCESS *dbproc, int column, DBINT *indicator)
     Tie a null-indicator to a regular result column. More...
     
    int dbnumalts (DBPROCESS *dbproc, int computeid)
     Get count of columns in a compute row. More...
     
    int dbnumcols (DBPROCESS *dbproc)
     Return number of regular columns in a result set. More...
     
    int dbnumcompute (DBPROCESS *dbproc)
     Get count of COMPUTE clauses for a result set. More...
     
    DBINT dbprcollen (DBPROCESS *dbproc, int column)
     Get size of a result column needed to print column. More...
     
    void dbprhead (DBPROCESS *dbproc)
     Print result set headings to stdout. More...
     
    RETCODE dbprrow (DBPROCESS *dbproc)
     Print a result set to stdout. More...
     
    const char * dbprtype (int token)
     Print a token value's name to a buffer. More...
     
    STATUS dbreadtext (DBPROCESS *dbproc, void *buf, DBINT bufsize)
     Fetch part of a text or image value from the server. More...
     
    void dbrecftos (const char filename[])
     Record to a file all SQL commands sent to the server. More...
     
    RETCODE dbresults (DBPROCESS *dbproc)
     Set up query results. More...
     
    RETCODE dbsafestr (DBPROCESS *dbproc, const char *src, DBINT srclen, char *dest, DBINT destlen, int quotetype)
     safely quotes character values in SQL text. More...
     
    char * dbservcharset (DBPROCESS *dbproc)
     Get syscharset name of the server character set. More...
     
    void dbsetifile (char *filename)
     set name and location of the interfaces file FreeTDS should use to look up a servername. More...
     
    void dbsetinterrupt (DBPROCESS *dbproc, DB_DBCHKINTR_FUNC chkintr, DB_DBHNDLINTR_FUNC hndlintr)
     Set interrupt handler for db-lib to use while blocked against a read from the server. More...
     
    RETCODE dbsetlogintime (int seconds)
     Set maximum seconds db-lib waits for a server response to a login attempt. More...
     
    RETCODE dbsetlversion (LOGINREC *login, BYTE version)
     Set TDS version for future connections. More...
     
    RETCODE dbsetmaxprocs (int maxprocs)
     Set maximum simultaneous connections db-lib will open to the server. More...
     
    RETCODE dbsetnull (DBPROCESS *dbproc, int bindtype, int bindlen, BYTE *bindval)
     Define substitution values to be used when binding null values. More...
     
    RETCODE dbsetopt (DBPROCESS *dbproc, int option, const char *char_param, int int_param)
     Set db-lib or server option. More...
     
    STATUS dbsetrow (DBPROCESS *dbproc, DBINT row)
     Make a buffered row "current" without fetching it into bound variables. More...
     
    RETCODE dbsettime (int seconds)
     Set maximum seconds db-lib waits for a server response to query. More...
     
    void dbsetuserdata (DBPROCESS *dbproc, BYTE *ptr)
     Associate client-allocated (and defined) data with a DBPROCESS. More...
     
    RETCODE dbsetversion (DBINT version)
     Specify a db-lib version level. More...
     
    int dbspid (DBPROCESS *dbproc)
     Get server process ID for a DBPROCESS. More...
     
    RETCODE dbspr1row (DBPROCESS *dbproc, char *buffer, DBINT buf_len)
     Print a regular result row to a buffer. More...
     
    DBINT dbspr1rowlen (DBPROCESS *dbproc)
     Determine size buffer required to hold the results returned by dbsprhead(), dbsprline(), and dbspr1row(). More...
     
    RETCODE dbsprhead (DBPROCESS *dbproc, char *buffer, DBINT buf_len)
     Print result set headings to a buffer. More...
     
    RETCODE dbsprline (DBPROCESS *dbproc, char *buffer, DBINT buf_len, DBCHAR line_char)
     Get formatted string for underlining dbsprhead() column names. More...
     
    RETCODE dbsqlexec (DBPROCESS *dbproc)
     send the SQL command to the server and wait for an answer. More...
     
    RETCODE dbsqlok (DBPROCESS *dbproc)
     Wait for results of a query from the server. More...
     
    RETCODE dbsqlsend (DBPROCESS *dbproc)
     Transmit the command buffer to the server. More...
     
    RETCODE dbstrbuild (DBPROCESS *dbproc, char *charbuf, int bufsize, char *text, char *formats,...)
     Build a printable string from text containing placeholders for variables. More...
     
    RETCODE dbstrcpy (DBPROCESS *dbproc, int start, int numbytes, char *dest)
     Get a copy of a chunk of the command buffer. More...
     
    int dbstrlen (DBPROCESS *dbproc)
     Get size of the command buffer, in bytes. More...
     
    RETCODE dbtablecolinfo (DBPROCESS *dbproc, DBINT column, DBCOL *pdbcol)
     describe table column attributes with a single call (Freetds-only API function modelled on dbcolinfo) More...
     
    DBBINARY * dbtxptr (DBPROCESS *dbproc, int column)
     Get text pointer for a column in the current row. More...
     
    DBBINARY * dbtxtimestamp (DBPROCESS *dbproc, int column)
     Get text timestamp for a column in the current row. More...
     
    RETCODE dbuse (DBPROCESS *dbproc, const char *name)
     Change current database. More...
     
    DBINT dbvarylen (DBPROCESS *dbproc, int column)
     Determine whether a column can vary in size. More...
     
    const char * dbversion ()
     See which version of db-lib is in use. More...
     
    DBBOOL dbwillconvert (int srctype, int desttype)
     Test whether or not a datatype can be converted to another datatype. More...
     
    RETCODE dbwritetext (DBPROCESS *dbproc, char *objname, DBBINARY *textptr, DBTINYINT textptrlen, DBBINARY *timestamp, DBBOOL log, DBINT size, BYTE *text)
     Send text or image data to the server. More...
     

    Detailed Description

    Core functions needed by most db-lib programs.

    Macro Definition Documentation

    § DBCMDROW

    DBCMDROW (   x)    dbcmdrow((x))

    Sybase macro mapping to the Microsoft (lower-case) function.

    See also
    dbcmdrow()

    § DBCOUNT

    DBCOUNT (   x)    dbcount((x))

    Sybase macro mapping to the Microsoft (lower-case) function.

    See also
    dbcount()

    § DBCURCMD

    DBCURCMD (   x)    dbcurcmd((x))

    Sybase macro mapping to the Microsoft (lower-case) function.

    See also
    dbcurcmd()

    § DBCURROW

    DBCURROW (   x)    dbcurrow((x))

    Sybase macro mapping to the Microsoft (lower-case) function.

    See also
    dbcurrow()

    § DBDEAD

    DBDEAD (   x)    dbdead((x))

    Sybase macro mapping to the Microsoft (lower-case) function.

    See also
    dbdead()

    § DBFIRSTROW

    DBFIRSTROW (   x)    dbfirstrow((x))

    Sybase macro mapping to the Microsoft (lower-case) function.

    See also
    dbfirstrow()

    § DBIORDESC

    DBIORDESC (   x)    dbiordesc((x))

    Sybase macro, maps to the internal (lower-case) function.

    See also
    dbiordesc()

    § DBIOWDESC

    DBIOWDESC (   x)    dbiowdesc((x))

    Sybase macro, maps to the internal (lower-case) function.

    See also
    dbiowdesc()

    § DBISAVAIL

    DBISAVAIL (   x)    dbisavail((x))

    Sybase macro mapping to the Microsoft (lower-case) function.

    See also
    dbisavail()

    § DBLASTROW

    DBLASTROW (   x)    dblastrow((x))

    Sybase macro mapping to the Microsoft (lower-case) function.

    See also
    dblastrow(), DBFIRSTROW()

    § DBMORECMDS

    DBMORECMDS (   x)    dbmorecmds((x))

    Sybase macro mapping to the Microsoft (lower-case) function.

    See also
    dbmorecmds()

    § DBROWS

    DBROWS (   x)    dbrows((x))

    Sybase macro mapping to the Microsoft (lower-case) function.

    See also
    dbrows()

    § DBROWTYPE

    DBROWTYPE (   x)    dbrowtype((x))

    Sybase macro mapping to the Microsoft (lower-case) function.

    See also
    dbrowtype()

    § DBSETLCHARSET

    DBSETLCHARSET (   x,
     
    )    dbsetlname((x), (y), DBSETCHARSET)

    Set the client character set in the login packet.

    Remarks
    Has no effect on TDS 7.0+ connections.

    § DBSETLENCRYPT

    DBSETLENCRYPT (   x,
     
    )    dbsetlbool((x), (y), DBSETENCRYPT)

    Enable (or not) network password encryption for Sybase servers version 10.0 or above.

    Todo:
    Unimplemented.
    See also
    dbsetlencrypt()

    § DBSETLNATLANG

    DBSETLNATLANG (   x,
     
    )    dbsetlname((x), (y), DBSETNATLANG)

    Set the language the server should use for messages.

    See also
    dbsetlnatlang(), dbsetlname()

    § dbsetlnatlang

    dbsetlnatlang (   x,
     
    )    dbsetlname((x), (y), DBSETNATLANG)

    Set the language the server should use for messages.

    See also
    DBSETLNATLANG(), dbsetlname()

    § DBSETLPACKET

    DBSETLPACKET (   x,
     
    )    dbsetllong((x), (y), DBSETPACKET)

    Set the packet size in the login packet for new connections.

    See also
    dbsetlpacket(), dbsetllong()

    § dbsetlpacket

    dbsetlpacket (   x,
     
    )    dbsetllong((x), (y), DBSETPACKET)

    Set the packet size in the login packet for new connections.

    See also
    DBSETLPACKET(), dbsetllong()

    § DBTDS

    DBTDS (   a)    dbtds(a)

    Sybase macro, maps to the internal (lower-case) function.

    See also
    dbtds()

    Function Documentation

    § _dbresults()

    static RETCODE _dbresults ( DBPROCESS dbproc)
    static
    Remarks
    Either SYBDBLIB or MSDBLIB (not both) must be defined. This affects how certain application-addressable strucures are defined.
    Here is the caller graph for this function:

    § dbadata()

    BYTE* dbadata ( DBPROCESS dbproc,
    int  computeid,
    int  column 
    )

    Get address of compute column data.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    computeidof COMPUTE clause to which we're referring.
    columnNth column in computeid, starting from 1.
    Returns
    pointer to columns's data buffer.
    Return values
    NULLno such computeid or column.
    See also
    dbadlen(), dbaltbind(), dbaltlen(), dbalttype(), dbgetrow(), dbnextrow(), dbnumalts().
    Here is the call graph for this function:

    § dbadlen()

    DBINT dbadlen ( DBPROCESS dbproc,
    int  computeid,
    int  column 
    )

    Get size of data in a compute column.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    computeidof COMPUTE clause to which we're referring.
    columnNth column in computeid, starting from 1.
    Returns
    size of the data, in bytes.
    Return values
    -1no such column or computeid.
    0data are NULL.
    See also
    dbadata(), dbaltlen(), dbalttype(), dbgetrow(), dbnextrow(), dbnumalts().
    Here is the call graph for this function:

    § dbaltbind()

    RETCODE dbaltbind ( DBPROCESS dbproc,
    int  computeid,
    int  column,
    int  vartype,
    DBINT  varlen,
    BYTE *  varaddr 
    )

    Bind a compute column to a program variable.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    computeidof COMPUTE clause to which we're referring.
    columnNth column in computeid, starting from 1.
    vartypedatatype of the host variable that will receive the data
    varlensize of host variable pointed to varaddr
    varaddraddress of host variable
    Return values
    SUCCEEDeverything worked.
    FAILno such computeid or column, or no such conversion possible, or target buffer too small.
    See also
    dbadata(), dbaltbind_ps(), dbanullbind(), dbbind(), dbbind_ps(), dbconvert(), dbconvert_ps(), dbnullbind(), dbsetnull(), dbsetversion(), dbwillconvert().
    Here is the call graph for this function:

    § dbaltcolid()

    int dbaltcolid ( DBPROCESS dbproc,
    int  computeid,
    int  column 
    )

    Get column ID of a compute column.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    computeidof COMPUTE clause to which we're referring.
    columnNth column in computeid, starting from 1.
    Returns
    Nth column in the base result set, on which column was computed.
    See also
    dbadata(), dbadlen(), dbaltlen(), dbgetrow(), dbnextrow(), dbnumalts(), dbprtype().
    Here is the call graph for this function:

    § dbaltlen()

    DBINT dbaltlen ( DBPROCESS dbproc,
    int  computeid,
    int  column 
    )

    Get size of data in compute column.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    computeidof COMPUTE clause to which we're referring.
    columnNth column in computeid, starting from 1.
    See also
    dbadata(), dbadlen(), dbalttype(), dbgetrow(), dbnextrow(), dbnumalts().
    Here is the call graph for this function:

    § dbaltop()

    int dbaltop ( DBPROCESS dbproc,
    int  computeid,
    int  column 
    )

    Get aggregation operator for a compute column.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    computeidof COMPUTE clause to which we're referring.
    columnNth column in computeid, starting from 1.
    Returns
    token value for the type of the compute column's aggregation operator.
    Return values
    -1no such computeid or column.
    See also
    dbadata(), dbadlen(), dbaltlen(), dbnextrow(), dbnumalts(), dbprtype().
    Here is the call graph for this function:

    § dbalttype()

    int dbalttype ( DBPROCESS dbproc,
    int  computeid,
    int  column 
    )

    Get datatype for a compute column.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    computeidof COMPUTE clause to which we're referring.
    columnNth column in computeid, starting from 1.
    Returns
    SYB* dataype token.
    Return values
    -1no such column or computeid.
    See also
    dbadata(), dbadlen(), dbaltlen(), dbnextrow(), dbnumalts(), dbprtype().
    Here is the call graph for this function:

    § dbaltutype()

    DBINT dbaltutype ( DBPROCESS dbproc,
    int  computeid,
    int  column 
    )

    Get user-defined datatype of a compute column.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    computeidof COMPUTE clause to which we're referring.
    columnNth column in computeid, starting from 1.
    Returns
    user-defined datatype of compute column, else -1.
    See also
    dbalttype(), dbcolutype().
    Here is the call graph for this function:

    § dbanullbind()

    RETCODE dbanullbind ( DBPROCESS dbproc,
    int  computeid,
    int  column,
    DBINT *  indicator 
    )

    Tie a null-indicator to a compute result column.

    When a row is fetched, the indicator variable tells the state of the column's data.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    computeididentifies which one of potientially many compute rows is meant. The first compute clause has computeid == 1.
    columnNth column in the result set, starting with 1.
    indicatoraddress of host variable.
    Return values
    SUCCEEDvariable accepted.
    FAILindicator is NULL or column is out of range.
    Remarks
    Contents of indicator are set with dbnextrow(). Possible values are:
    • 0 column bound successfully
    • -1 column is NULL.
    • >0 true length of data, had column not been truncated due to insufficient space in the columns bound host variable .
    See also
    dbadata(), dbadlen(), dbaltbind(), dbnextrow(), dbnullbind().
    Todo:
    Never fails, but only because failure conditions aren't checked.
    Here is the call graph for this function:

    § dbanydatecrack()

    RETCODE dbanydatecrack ( DBPROCESS dbproc,
    DBDATEREC2 di,
    int  type,
    const void *  data 
    )

    Break any kind of date or time value into useful pieces.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    dioutput: structure to contain the exploded parts of datetime.
    typeinput: type of date/time value returned by dbcoltype().
    datainput: date/time value to be converted.
    Return values
    SUCCEEDalways.
    Remarks
    The members of di have different names, depending on whether –with-msdblib was configured.

    This is an extension to dbdatecrack(), see it for more information.

    See also
    dbdatecrack(), dbconvert(), dbdata(), dbdatechar(), dbdatename(), dbdatepart(), tdsdbopen().

    § dbbind()

    RETCODE dbbind ( DBPROCESS dbproc,
    int  column,
    int  vartype,
    DBINT  varlen,
    BYTE *  varaddr 
    )

    Tie a host variable to a resultset column.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    columnNth column, starting at 1.
    vartypedatatype of the host variable that will receive the data
    varlensize of host variable pointed to varaddr
    varaddraddress of host variable
    Return values
    SUCCEEDeverything worked.
    FAILno such column or no such conversion possible, or target buffer too small.
    See also
    Here is the call graph for this function:

    § dbbylist()

    BYTE* dbbylist ( DBPROCESS dbproc,
    int  computeid,
    int *  size 
    )

    Get bylist for a compute row.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    computeidof COMPUTE clause to which we're referring.
    sizeoutput: size of bylist buffer whose address is returned, possibly zero.
    Returns
    address of bylist for computeid.
    Return values
    NULLno such computeid.
    Remarks
    Do not free returned pointer.
    See also
    dbadata(), dbadlen(), dbaltlen(), dbalttype(), dbcolname(), dbgetrow(), dbnextrow().
    Here is the call graph for this function:

    § dbcancel()

    RETCODE dbcancel ( DBPROCESS dbproc)

    Cancel the current command batch.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    Return values
    SUCCEEDalways.
    See also
    dbcanquery(), dbnextrow(), dbresults(), dbsetinterrupt(), dbsqlexec(), dbsqlok(), dbsqlsend().
    Todo:
    Check for failure and return accordingly.
    Here is the call graph for this function:

    § dbcanquery()

    RETCODE dbcanquery ( DBPROCESS dbproc)

    Cancel the query currently being retrieved, discarding all pending rows.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    See also
    Here is the call graph for this function:

    § dbchange()

    char* dbchange ( DBPROCESS dbproc)

    See if a command caused the current database to change.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    Returns
    name of new database, if changed, as a null-terminated ASCII string, else NULL.
    See also
    dbname(), dbresults(), dbsqlexec(), dbsqlsend(), dbuse().
    Here is the call graph for this function:

    § dbclose()

    void dbclose ( DBPROCESS dbproc)

    Close a connection to the server and free associated resources.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    See also
    dbexit(), dbopen().
    Here is the call graph for this function:

    § dbclrbuf()

    void dbclrbuf ( DBPROCESS dbproc,
    DBINT  n 
    )

    Clear n rows from the row buffer.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    nnumber of rows to remove, >= 0.
    See also
    dbgetrow(), dbnextrow(), dbsetopt().
    Here is the call graph for this function:

    § dbclropt()

    RETCODE dbclropt ( DBPROCESS dbproc,
    int  option,
    const char  param[] 
    )

    Reset an option.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    optionto be turned off.
    paramclearing some options requires a parameter, believe it or not.
    Return values
    SUCCEEDoption and parameter seem sane.
    FAILno such option.
    Remarks
    Only the following options are recognized:
    • DBARITHABORT
    • DBARITHIGNORE
    • DBCHAINXACTS
    • DBFIPSFLAG
    • DBISOLATION
    • DBNOCOUNT
    • DBNOEXEC
    • DBPARSEONLY
    • DBSHOWPLAN
    • DBSTORPROCID
    • DBQUOTEDIDENT
    • DBSETTIME
    See also
    dbisopt(), dbsetopt().
    Here is the call graph for this function:

    § dbcmd()

    RETCODE dbcmd ( DBPROCESS dbproc,
    const char  cmdstring[] 
    )

    Append SQL to the command buffer.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    cmdstringSQL to append to the command buffer.
    Return values
    SUCCEEDsuccess.
    FAILinsufficient memory.
    Remarks
    set command state to DBCMDPEND unless the command state is DBCMDSENT, in which case it frees the command buffer. This latter may or may not be the Right Thing to do.
    See also
    dbfcmd(), dbfreebuf(), dbgetchar(), dbopen(), dbstrcpy(), dbstrlen().
    Here is the call graph for this function:

    § dbcollen()

    DBINT dbcollen ( DBPROCESS dbproc,
    int  column 
    )

    Get size of a regular result column.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    columnNth in the result set, starting from 1.
    Returns
    size of the column (not of data in any particular row). On error, -1.
    See also
    dbcolname(), dbcoltype(), dbdata(), dbdatlen(), dbnumcols().
    Here is the call graph for this function:

    § dbcolname()

    char* dbcolname ( DBPROCESS dbproc,
    int  column 
    )

    Return name of a regular result column.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    columnNth in the result set, starting with 1.
    Returns
    pointer to ASCII null-terminated string, the name of the column.
    Return values
    NULLcolumn is not in range.
    See also
    dbcollen(), dbcoltype(), dbdata(), dbdatlen(), dbnumcols().
    Bug:
    Relies on ASCII column names, post iconv conversion. Will not work as described for UTF-8 or UCS-2 clients. But maybe it shouldn't.
    Here is the call graph for this function:

    § dbcolsource()

    char* dbcolsource ( DBPROCESS dbproc,
    int  column 
    )

    Get base database column name for a result set column.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    columnNth in the result set, starting from 1.
    Returns
    pointer to ASCII null-terminated string, the name of the column. On error, NULL.
    See also
    dbcolbrowse(), dbqual(), dbtabbrowse(), dbtabcount(), dbtabname(), dbtabsource(), dbtsnewlen(), dbtsnewval(), dbtsput().
    Here is the call graph for this function:

    § dbcoltype()

    int dbcoltype ( DBPROCESS dbproc,
    int  column 
    )

    Get the datatype of a regular result set column.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    columnNth in the result set, starting from 1.
    Returns
    SYB* datetype token value, or zero if column out of range
    See also
    dbcollen(), dbcolname(), dbdata(), dbdatlen(), dbnumcols(), dbprtype(), dbvarylen().
    Here is the call graph for this function:

    § dbcoltypeinfo()

    DBTYPEINFO* dbcoltypeinfo ( DBPROCESS dbproc,
    int  column 
    )

    Get precision and scale information for a regular result column.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    columnNth in the result set, starting from 1.
    Returns
    Pointer to a DBTYPEINFO structure . NULL column is out of range.
    See also
    dbcollen(), dbcolname(), dbcoltype(), dbdata(), dbdatlen(), dbnumcols(), dbprtype(), dbvarylen().
    Here is the call graph for this function:

    § dbcolutype()

    int dbcolutype ( DBPROCESS dbproc,
    int  column 
    )

    Get user-defined datatype of a regular result column.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    columnNth in the result set, starting from 1.
    Returns
    SYB* datetype token value, or -1 if column out of range
    See also
    dbaltutype(), dbcoltype().
    Here is the call graph for this function:

    § dbconvert()

    DBINT dbconvert ( DBPROCESS dbproc,
    int  srctype,
    const BYTE *  src,
    DBINT  srclen,
    int  desttype,
    BYTE *  dest,
    DBINT  destlen 
    )

    cf.

    dbconvert_ps(), above

    Sybase: Convert numeric types.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    srctypedatatype of the data to convert.
    srcbuffer to convert
    srclenlength of src
    desttypetarget datatype
    destoutput buffer
    destlensize of dest
    typeinfoaddress of a DBTYPEINFO structure that governs the precision & scale of the output, may be NULL.
    See also
    dbaltbind(), dbaltbind_ps(), dbbind(), dbbind_ps(), dbconvert_ps(), dberrhandle(), dbsetnull(), dbsetversion(), dbwillconvert().
    Here is the call graph for this function:

    § dbconvert_ps()

    DBINT dbconvert_ps ( DBPROCESS dbproc,
    int  db_srctype,
    const BYTE *  src,
    DBINT  srclen,
    int  db_desttype,
    BYTE *  dest,
    DBINT  destlen,
    DBTYPEINFO typeinfo 
    )

    Convert one datatype to another.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    srctypedatatype of the data to convert.
    srcbuffer to convert
    srclenlength of src
    desttypetarget datatype
    destoutput buffer
    destlensize of dest
    Returns
    On success, the count of output bytes in dest, else -1. On failure, it will call any user-supplied error handler.
    Remarks
    Causes of failure:
    • No such conversion unavailable.
    • Character data output was truncated, or numerical data overflowed or lost precision.
    • In converting character data to one of the numeric types, the string could not be interpreted as a number.

    Conversion functions are handled in the TDS layer.

    The main reason for this is that ct-lib and ODBC (and presumably DBI) need to be able to do conversions between datatypes. This is possible because the format of complex data (dates, money, numeric, decimal) is defined by its representation on the wire; thus what we call DBMONEY is exactly its format on the wire. CLIs that need a different representation (ODBC?) need to convert from this format anyway, so the code would already be in place.

    Each datatype is also defined by its Server-type so all CLIs should be able to map native types to server types as well.

    tds_convert() copies from src to dest and returns the output data length, period. All padding and termination is the responsibility of the API library and is done post-conversion. The peculiar rule in dbconvert() is that a destlen of -1 and a desttype of SYBCHAR means the output buffer should be null-terminated.

    See also
    dbaltbind(), dbaltbind_ps(), dbbind(), dbbind_ps(), dbconvert_ps(), dberrhandle(), dbsetnull(), dbsetversion(), dbwillconvert().
    Todo:

    What happens if client does not reset values?

    Microsoft and Sybase define this function differently.

    Here is the call graph for this function:

    § dbcount()

    DBINT dbcount ( DBPROCESS dbproc)

    Get count of rows processed.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    Returns
    • for insert/update/delete, count of rows affected.
    • for select, count of rows returned, after all rows have been fetched.
    See also
    DBCOUNT(), dbnextrow(), dbresults().
    Here is the call graph for this function:

    § dbdata()

    BYTE* dbdata ( DBPROCESS dbproc,
    int  column 
    )

    Get address of data in a regular result column.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    columnNth in the result set, starting from 1.
    Returns
    pointer the data, or NULL if data are NULL, or if column is out of range.
    See also
    dbbind(), dbcollen(), dbcolname(), dbcoltype(), dbdatlen(), dbnumcols().
    Here is the call graph for this function:

    § dbdatecrack()

    RETCODE dbdatecrack ( DBPROCESS dbproc,
    DBDATEREC di,
    DBDATETIME datetime 
    )

    Break a DBDATETIME value into useful pieces.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    dioutput: structure to contain the exploded parts of datetime.
    datetimeinput: DBDATETIME to be converted.
    Return values
    SUCCEEDalways.
    Remarks
    The members of di have different names, depending on whether –with-msdblib was configured.

    If DBPROCESS is NULL, dbdatecrack() uses the compiled in default value of MSDBLIB as of when libsybdb was compiled, irrespective of its value when the application is compiled. This can lead to incorrect results because Sybase and Microsoft use different ranges – [0,11] vs. [1,12] – for the month.

    See also
    dbconvert(), dbdata(), dbdatechar(), dbdatename(), dbdatepart(), tdsdbopen().

    § dbdatlen()

    DBINT dbdatlen ( DBPROCESS dbproc,
    int  column 
    )

    Get size of current row's data in a regular result column.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    columnNth in the result set, starting from 1.
    Returns
    size of the data, in bytes.
    See also
    dbcollen(), dbcolname(), dbcoltype(), dbdata(), dbnumcols().
    Here is the call graph for this function:

    § dberrhandle()

    EHANDLEFUNC dberrhandle ( EHANDLEFUNC  handler)

    Set an error handler, for messages from db-lib.

    Parameters
    handlerpointer to callback function that will handle errors. Pass NULL to restore the default handler.
    Returns
    address of prior handler, or NULL if none was previously installed.
    See also
    DBDEAD(), dbmsghandle().

    § dbexit()

    void dbexit ( void  )

    Close server connections and free all related structures.

    See also
    dbclose(), dbinit(), dbopen().
    Todo:
    breaks if ctlib/dblib used in same process.
    Here is the call graph for this function:

    § dbfcmd()

    RETCODE dbfcmd ( DBPROCESS dbproc,
    const char *  fmt,
      ... 
    )

    printf-like way to form SQL to send to the server.

    Forms a command string and writes to the command buffer with dbcmd().

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    fmt man vasprintf for details.
    Return values
    SUCCEEDsuccess.
    FAILinsufficient memory, or dbcmd() failed.
    See also
    dbcmd(), dbfreebuf(), dbgetchar(), dbopen(), dbstrcpy(), dbstrlen().
    Here is the call graph for this function:

    § dbfreebuf()

    void dbfreebuf ( DBPROCESS dbproc)

    Erase the command buffer, in case DBNOAUTOFREE was set with dbsetopt().

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    See also
    dbcmd(), dbfcmd(), dbgetchar(), dbsqlexec(), dbsqlsend(), dbsetopt(), dbstrcpy(), dbstrlen().
    Here is the call graph for this function:

    § dbgetchar()

    char* dbgetchar ( DBPROCESS dbproc,
    int  pos 
    )

    Get address of a position in the command buffer.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    posoffset within the command buffer, starting at 0.
    Remarks
    A bit overspecialized, this one.
    See also
    dbcmd(), dbfcmd(), dbfreebuf(), dbstrcpy(), dbstrlen(),
    Here is the call graph for this function:

    § dbgetmaxprocs()

    int dbgetmaxprocs ( void  )

    get maximum simultaneous connections db-lib will open to the server.

    Returns
    Current maximum.
    See also
    dbsetmaxprocs(), dbopen()
    Here is the call graph for this function:

    § dbgetpacket()

    int dbgetpacket ( DBPROCESS dbproc)

    Get TDS packet size for the connection.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    Returns
    TDS packet size, in bytes.
    See also
    DBSETLPACKET()
    Here is the call graph for this function:

    § dbgetrow()

    RETCODE dbgetrow ( DBPROCESS dbproc,
    DBINT  row 
    )

    Read a row from the row buffer.

    When row buffering is enabled (DBBUFFER option is on), the client can use dbgetrow() to re-read a row previously fetched with dbnextrow(). The effect is to move the row pointer – analogous to fseek() – back to row. Calls to dbnextrow() read from row + 1 until the buffer is exhausted, at which point it resumes its normal behavior, except that as each row is fetched from the server, it is added to the row buffer (in addition to being returned to the client). When the buffer is filled, dbnextrow() returns FAIL until the buffer is at least partially emptied with dbclrbuf().

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    rowNth row to read, starting with 1.
    Return values
    REG_ROWreturned row is a regular row.
    Returns
    computeid when returned row is a compute row.
    Return values
    NO_MORE_ROWSno such row in the row buffer. Current row is unchanged.
    FAILunsuccessful; row buffer may be full.
    See also
    dbaltbind(), dbbind(), dbclrbuf(), DBCURROW(), DBFIRSTROW(), DBLASTROW(), dbnextrow(), dbsetrow().

    § dbgettime()

    int dbgettime ( void  )

    Get maximum seconds db-lib waits for a server response to query.

    Return values
    querytimeout limit, in seconds
    See also
    dberrhandle(), DBSETTIME(), dbsetlogintime(), dbsqlexec(), dbsqlok(), dbsqlsend().
    Here is the call graph for this function:

    § dbgetuserdata()

    BYTE* dbgetuserdata ( DBPROCESS dbproc)

    Get address of user-allocated data from a DBPROCESS.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    Returns
    address of user-defined data that db-lib associated with dbproc when the client called dbsetuserdata().
    Return values
    undefined(probably NULL) dbsetuserdata() was not previously called.
    See also
    dbsetuserdata().
    Here is the call graph for this function:

    § dbinit()

    RETCODE dbinit ( void  )

    Initialize db-lib.

    Remarks
    Call this function before trying to use db-lib in any way. Allocates various internal structures and reads locales.conf (if any) to determine the default date format.
    Return values
    SUCCEEDnormal.
    FAILcannot allocate an array of TDS_MAX_CONN TDSSOCKET pointers.

    § dbiscount()

    BOOL dbiscount ( DBPROCESS dbproc)

    Indicates whether or not the count returned by dbcount is real (Microsoft-compatibility feature).

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    Returns
    TRUE if the count returned by dbcount is real or FALSE if the count returned by dbcount is not real.
    See also
    DBCOUNT(), dbcount().
    Here is the call graph for this function:

    § dbisopt()

    DBBOOL dbisopt ( DBPROCESS dbproc,
    int  option,
    const char  param[] 
    )

    Get value of an option.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    optionthe option
    parama parameter to option.
    See also
    dbclropt(), dbsetopt().
    Here is the call graph for this function:

    § dblogin()

    LOGINREC* dblogin ( void  )

    Allocate a LOGINREC structure.

    Remarks
    A LOGINREC structure is passed to dbopen() to create a connection to the database. Does not communicate to the server; interacts strictly with library.
    Return values
    NULLthe LOGINREC cannot be allocated.
    LOGINREC*to valid memory, otherwise.
    Here is the call graph for this function:

    § dbloginfree()

    void dbloginfree ( LOGINREC login)

    free the LOGINREC

    Here is the call graph for this function:

    § dbmorecmds()

    RETCODE dbmorecmds ( DBPROCESS dbproc)

    See if more commands are to be processed.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    See also
    DBMORECMDS(). DBCMDROW(), dbresults(), DBROWS(), DBROWTYPE().
    Here is the call graph for this function:

    § dbmoretext()

    RETCODE dbmoretext ( DBPROCESS dbproc,
    DBINT  size,
    const BYTE  text[] 
    )

    Send chunk of a text/image value to the server.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    sizecount of bytes to send.
    texttextpointer, obtained from dbtxptr.
    Return values
    SUCCEEDalways.
    See also
    dbtxptr(), dbtxtimestamp(), dbwritetext().
    Todo:
    Check return value of called functions and return FAIL if appropriate.
    Here is the call graph for this function:

    § dbmsghandle()

    MHANDLEFUNC dbmsghandle ( MHANDLEFUNC  handler)

    Set a message handler, for messages from the server.

    Parameters
    handleraddress of the function that will process the messages.
    See also
    DBDEAD(), dberrhandle().

    § dbname()

    char* dbname ( DBPROCESS dbproc)

    Get name of current database.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    Returns
    current database name, as null-terminated ASCII string.
    See also
    dbchange(), dbuse().
    Here is the call graph for this function:

    § dbnullbind()

    RETCODE dbnullbind ( DBPROCESS dbproc,
    int  column,
    DBINT *  indicator 
    )

    Tie a null-indicator to a regular result column.

    When a row is fetched, the indicator variable tells the state of the column's data.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    columnNth column in the result set, starting with 1.
    indicatoraddress of host variable.
    Return values
    SUCCEEDvariable accepted.
    FAILindicator is NULL or column is out of range.
    Remarks
    Contents of indicator are set with dbnextrow(). Possible values are:
    • 0 column bound successfully
    • -1 column is NULL.
    • >0 true length of data, had column not been truncated due to insufficient space in the columns bound host variable .
    See also
    dbanullbind(), dbbind(), dbdata(), dbdatlen(), dbnextrow().
    Here is the call graph for this function:

    § dbnumalts()

    int dbnumalts ( DBPROCESS dbproc,
    int  computeid 
    )

    Get count of columns in a compute row.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    computeidof COMPUTE clause to which we're referring.
    Returns
    number of columns, else -1 if no such computeid.
    See also
    dbadata(), dbadlen(), dbaltlen(), dbalttype(), dbgetrow(), dbnextrow(), dbnumcols().
    Here is the call graph for this function:

    § dbnumcols()

    int dbnumcols ( DBPROCESS dbproc)

    Return number of regular columns in a result set.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    See also
    dbcollen(), dbcolname(), dbnumalts().
    Here is the call graph for this function:

    § dbnumcompute()

    int dbnumcompute ( DBPROCESS dbproc)

    Get count of COMPUTE clauses for a result set.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    Returns
    number of compute clauses for the current query, possibly zero.
    See also
    dbnumalts(), dbresults().
    Here is the call graph for this function:

    § dbprcollen()

    DBINT dbprcollen ( DBPROCESS dbproc,
    int  column 
    )

    Get size of a result column needed to print column.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    columnNth in the result set, starting from 1.
    Returns
    size of the column in characters (not of data in any particular row). On error, -1.
    See also
    dbcolname(), dbcoltype(), dbdata(), dbdatlen(), dbnumcols().
    Here is the call graph for this function:

    § dbprhead()

    void dbprhead ( DBPROCESS dbproc)

    Print result set headings to stdout.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    See also
    Here is the call graph for this function:

    § dbprrow()

    RETCODE dbprrow ( DBPROCESS dbproc)

    Print a result set to stdout.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    See also
    dbbind(), dbnextrow(), dbprhead(), dbresults(), dbspr1row(), dbsprhead(), dbsprline().
    Here is the call graph for this function:

    § dbprtype()

    const char* dbprtype ( int  token)

    Print a token value's name to a buffer.

    Parameters
    tokenserver SYB* value, e.g. SYBINT.
    Returns
    ASCII null-terminated string.
    See also
    dbaltop(), dbalttype(), dbcoltype(), dbrettype().
    Here is the call graph for this function:

    § dbreadtext()

    STATUS dbreadtext ( DBPROCESS dbproc,
    void *  buf,
    DBINT  bufsize 
    )

    Fetch part of a text or image value from the server.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    bufoutput: buffer into which text will be placed.
    bufsizesize of buf, in bytes.
    Returns
    • >0 count of bytes placed in buf.
    • 0 end of row.
    • -1 error, no result set ready for dbproc.
    • NO_MORE_ROWS all rows read, no further data.
    See also
    dbmoretext(), dbnextrow(), dbwritetext().
    Here is the call graph for this function:

    § dbrecftos()

    void dbrecftos ( const char  filename[])

    Record to a file all SQL commands sent to the server.

    Parameters
    filenamename of file to write to.
    Remarks
    Files are named filename.n, where n is an integer, starting with 0, and incremented with each callto dbopen().
    See also
    dbopen(), TDSDUMP environment variable().
    Here is the call graph for this function:

    § dbresults()

    RETCODE dbresults ( DBPROCESS dbproc)

    Set up query results.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    Return values
    SUCCEEDSome results are available.
    FAILquery was not processed successfully by the server
    NO_MORE_RESULTSquery produced no results.
    Remarks
    Call dbresults() after calling dbsqlexec() or dbsqlok(), or dbrpcsend() returns SUCCEED. Unless one of them fails, dbresults will return either SUCCEED or NO_MORE_RESULTS.

    The meaning of results is very specific and not very intuitive. Results are created by either

    • a SELECT statement

      • a stored procedure

      When dbresults returns SUCCEED, therefore, it indicates the server processed the query successfully and that one or more of these is present:

    • metadata – dbnumcols() returns 1 or more
    • data – dbnextrow() returns SUCCEED
    • return status – dbhasretstat() returns TRUE
    • output parameters – dbnumrets() returns 1 or more

    If none of the above are present, dbresults() returns NO_MORE_RESULTS.

    SUCCEED does not imply that DBROWS() will return TRUE or even that dbnumcols() will return nonzero. A general algorithm for reading results will call dbresults() until it return NO_MORE_RESULTS (or FAIL). An application should check for all the above kinds of results within the dbresults() loop.

    See also
    dbsqlexec(), dbsqlok(), dbrpcsend(), dbcancel(), DBROWS(), dbnextrow(), dbnumcols(), dbhasretstat(), dbretstatus(), dbnumrets()
    Here is the call graph for this function:

    § dbsafestr()

    RETCODE dbsafestr ( DBPROCESS dbproc,
    const char *  src,
    DBINT  srclen,
    char *  dest,
    DBINT  destlen,
    int  quotetype 
    )

    safely quotes character values in SQL text.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    srcinput string.
    srclenlength of src in bytes, or -1 to indicate it's null-terminated.
    destoutput: client-provided output buffer.
    destlensize of dest in bytes, or -1 to indicate it's "big enough" and the data should be null-terminated.
    quotetype
    • DBSINGLE Doubles all single quotes (').
    • DBDOUBLE Doubles all double quotes (").
    • DBBOTH Doubles all single and double quotes.
    Return values
    SUCCEEDeverything worked.
    FAILno such quotetype, or insufficient room in dest.
    See also
    dbcmd(), dbfcmd().

    § dbservcharset()

    char* dbservcharset ( DBPROCESS dbproc)

    Get syscharset name of the server character set.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    Returns
    name of server's charset, as null-terminated ASCII string.
    See also
    dbcharsetconv(), dbgetcharset(), DBSETLCHARSET().
    Here is the call graph for this function:

    § dbsetifile()

    void dbsetifile ( char *  filename)

    set name and location of the interfaces file FreeTDS should use to look up a servername.

    Does not affect lookups or location of freetds.conf.

    Parameters
    filenamename of interfaces
    See also
    dbopen()
    Here is the call graph for this function:

    § dbsetinterrupt()

    void dbsetinterrupt ( DBPROCESS dbproc,
    DB_DBCHKINTR_FUNC  chkintr,
    DB_DBHNDLINTR_FUNC  hndlintr 
    )

    Set interrupt handler for db-lib to use while blocked against a read from the server.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    chkintr
    hndlintr
    See also
    dbcancel(), dbgetuserdata(), dbsetuserdata(), dbsetbusy(), dbsetidle().

    § dbsetlogintime()

    RETCODE dbsetlogintime ( int  seconds)

    Set maximum seconds db-lib waits for a server response to a login attempt.

    Parameters
    secondsNew limit for application.
    Return values
    SUCCEEDAlways.
    See also
    dberrhandle(), dbsettime()
    Here is the call graph for this function:

    § dbsetlversion()

    RETCODE dbsetlversion ( LOGINREC login,
    BYTE  version 
    )

    Set TDS version for future connections.

    Here is the call graph for this function:

    § dbsetmaxprocs()

    RETCODE dbsetmaxprocs ( int  maxprocs)

    Set maximum simultaneous connections db-lib will open to the server.

    Parameters
    maxprocsLimit for process.
    Return values
    SUCCEEDAlways.
    See also
    dbgetmaxprocs(), dbopen()
    Here is the call graph for this function:

    § dbsetnull()

    RETCODE dbsetnull ( DBPROCESS dbproc,
    int  bindtype,
    int  bindlen,
    BYTE *  bindval 
    )

    Define substitution values to be used when binding null values.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    bindtypetype of binding to which the substitute value will apply.
    bindlensize of the substitute value you are supplying, in bytes. Ignored except for CHARBIND and BINARYBIND.
    bindvalpointer to a buffer containing the substitute value.
    Return values
    SUCCEEDquery was processed without errors.
    FAILquery was not processed
    See also
    dbaltbind(), dbbind(), dbconvert(), dbnullbind().
    Here is the call graph for this function:

    § dbsetopt()

    RETCODE dbsetopt ( DBPROCESS dbproc,
    int  option,
    const char *  char_param,
    int  int_param 
    )

    Set db-lib or server option.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    optionoption to set.
    char_paramvalue to set option to, if it wants a null-teminated ASCII string.
    int_paramvalue to set option to, if it wants an integer value.
    Return values
    SUCCEEDeverything worked.
    FAILno such option, or insufficient memory, or unimplemented.
    Remarks
    Many are unimplemented.
    See also
    dbclropt(), dbisopt().
    Todo:
    Implement more options.
    Here is the call graph for this function:

    § dbsetrow()

    STATUS dbsetrow ( DBPROCESS dbproc,
    DBINT  row 
    )

    Make a buffered row "current" without fetching it into bound variables.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    Return values
    MORE_ROWSrow found
    NO_MORE_ROWSrow not found
    FAILdbproc is dead or not enabled
    See also
    dbaltbind(), dbbind(), dbcanquery(), dbclrbuf(), dbgetrow(), dbnextrow(), dbprrow().
    Here is the call graph for this function:

    § dbsettime()

    RETCODE dbsettime ( int  seconds)

    Set maximum seconds db-lib waits for a server response to query.

    Parameters
    secondsNew limit for application.
    Return values
    SUCCEEDAlways.
    See also
    dberrhandle(), DBGETTIME(), dbsetlogintime(), dbsqlexec(), dbsqlok(), dbsqlsend().
    Here is the call graph for this function:

    § dbsetuserdata()

    void dbsetuserdata ( DBPROCESS dbproc,
    BYTE *  ptr 
    )

    Associate client-allocated (and defined) data with a DBPROCESS.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    ptraddress of client-defined data.
    Remarks
    ptr is the location of user data that db-lib will associate with dbproc. The client allocates the buffer addressed by ptr. db-lib never examines or uses the information; it just stashes the pointer for later retrieval by the application with dbgetuserdata().
    See also
    dbgetuserdata().
    Here is the call graph for this function:

    § dbsetversion()

    RETCODE dbsetversion ( DBINT  version)

    Specify a db-lib version level.

    Parameters
    versionanything, really.
    Return values
    SUCCEEDAlways.
    Remarks
    No effect on behavior of db-lib in FreeTDS.
    See also
    Here is the call graph for this function:

    § dbspid()

    int dbspid ( DBPROCESS dbproc)

    Get server process ID for a DBPROCESS.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    Returns
    "spid", the server's process ID.
    See also
    dbopen().
    Here is the call graph for this function:

    § dbspr1row()

    RETCODE dbspr1row ( DBPROCESS dbproc,
    char *  buffer,
    DBINT  buf_len 
    )

    Print a regular result row to a buffer.

    Fills a buffer with one data row, represented as a null-terminated ASCII string. Helpful for debugging.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    bufferoutput: Address of a buffer to hold ASCII null-terminated string.
    buf_lensize of buffer, in bytes.
    Return values
    SUCCEEDon success.
    FAILtrouble encountered.
    See also
    dbclropt(), dbisopt(), dbprhead(), dbprrow(), dbspr1rowlen(), dbsprhead(), dbsprline().
    Here is the call graph for this function:

    § dbspr1rowlen()

    DBINT dbspr1rowlen ( DBPROCESS dbproc)

    Determine size buffer required to hold the results returned by dbsprhead(), dbsprline(), and dbspr1row().

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    Returns
    size of buffer requirement, in bytes.
    Remarks
    An esoteric function.
    See also
    dbprhead(), dbprrow(), dbspr1row(), dbsprhead(), dbsprline().
    Here is the call graph for this function:

    § dbsprhead()

    RETCODE dbsprhead ( DBPROCESS dbproc,
    char *  buffer,
    DBINT  buf_len 
    )

    Print result set headings to a buffer.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    bufferoutput buffer
    buf_lensize of buffer
    Return values
    SUCCEEDbuffer filled.
    FAILinsufficient spaace in buffer, usually.
    See also
    dbprhead(), dbprrow(), dbsetopt(), dbspr1row(), dbspr1rowlen(), dbsprline().
    Here is the call graph for this function:

    § dbsprline()

    RETCODE dbsprline ( DBPROCESS dbproc,
    char *  buffer,
    DBINT  buf_len,
    DBCHAR  line_char 
    )

    Get formatted string for underlining dbsprhead() column names.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    bufferoutput buffer
    buf_lensize of buffer
    line_charcharacter to use to represent underlining.
    Return values
    SUCCEEDbuffer filled.
    FAILinsufficient space in buffer, usually.
    See also
    dbprhead(), dbprrow(), dbspr1row(), dbspr1rowlen(), dbsprhead().
    Here is the call graph for this function:

    § dbsqlexec()

    RETCODE dbsqlexec ( DBPROCESS dbproc)

    send the SQL command to the server and wait for an answer.

    Please be patient. This function waits for the server to respond. dbsqlexec is equivalent to dbsqlsend() followed by dbsqlok().

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    Return values
    SUCCEEDquery was processed without errors.
    FAILwas returned by dbsqlsend() or dbsqlok().
    See also
    dbcmd(), dbfcmd(), dbnextrow(), dbresults(), dbretstatus(), dbsettime(), dbsqlok(), dbsqlsend()

    § dbsqlok()

    RETCODE dbsqlok ( DBPROCESS dbproc)

    Wait for results of a query from the server.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    Return values
    SUCCEEDeverything worked, fetch results with dbnextresults().
    FAILSQL syntax error, typically.
    See also
    dbcmd(), dbfcmd(), DBIORDESC(), DBIOWDESC(), dbmoretext(), dbnextrow(), dbpoll(), DBRBUF(), dbresults(), dbretstatus(), dbrpcsend(), dbsettime(), dbsqlexec(), dbsqlsend(), dbwritetext().

    § dbsqlsend()

    RETCODE dbsqlsend ( DBPROCESS dbproc)

    Transmit the command buffer to the server.

    Non-blocking, does not wait for a response.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    Return values
    SUCCEEDSQL sent.
    FAILprotocol problem, unless dbsqlsend() when it's not supposed to be (in which case a db-lib error message will be emitted).
    See also
    dbcmd(), dbfcmd(), DBIORDESC(), DBIOWDESC(), dbnextrow(), dbpoll(), dbresults(), dbsettime(), dbsqlexec(), dbsqlok().
    Here is the call graph for this function:

    § dbstrbuild()

    RETCODE dbstrbuild ( DBPROCESS dbproc,
    char *  charbuf,
    int  bufsize,
    char *  text,
    char *  formats,
      ... 
    )

    Build a printable string from text containing placeholders for variables.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    charbufoutput: buffer that will contain the ASCII null-terminated string built by dbstrbuild().
    bufsizesize of charbuf, in bytes.
    textnull-terminated ASCII string, with placeholders for variables. A Placeholder is a three-byte string, made up of:
    • '' a percent sign
    • 0-9 an integer (designates the argument number to use, starting with 1.)
    • '!' an exclamation point
    formatsnull-terminated ASCII sprintf-style string. Has one format specifier for each placeholder in text.
    Remarks
    Following formats are the arguments, the values to substitute for the placeholders.
    See also
    dbconvert(), dbdatename(), dbdatepart().
    Here is the call graph for this function:

    § dbstrcpy()

    RETCODE dbstrcpy ( DBPROCESS dbproc,
    int  start,
    int  numbytes,
    char *  dest 
    )

    Get a copy of a chunk of the command buffer.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    startposition in the command buffer to start copying from, starting from 0. If start is past the end of the command buffer, dbstrcpy() inserts a null terminator at dest[0].
    numbytesnumber of bytes to copy.
    • If -1, dbstrcpy() copies the whole command buffer.
    • If 0 dbstrcpy() writes a NULL to dest[0].
    • If the command buffer contains fewer than numbytes (taking start into account) dbstrcpy() copies the rest of it.
    destoutput: the buffer to write to. Make sure it's big enough.
    Return values
    SUCCEEDthe inputs were valid and dest was affected.
    FAILstart < 0 or numbytes < -1.
    See also
    dbcmd(), dbfcmd(), dbfreebuf(), dbgetchar(), dbstrlen().
    Here is the call graph for this function:

    § dbstrlen()

    int dbstrlen ( DBPROCESS dbproc)

    Get size of the command buffer, in bytes.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    See also
    dbcmd(), dbfcmd(), dbfreebuf(), dbgetchar(), dbstrcpy().
    Here is the call graph for this function:

    § dbtablecolinfo()

    RETCODE dbtablecolinfo ( DBPROCESS dbproc,
    DBINT  column,
    DBCOL pdbcol 
    )

    describe table column attributes with a single call (Freetds-only API function modelled on dbcolinfo)

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    columnNth in the result set, starting from 1.
    pdbcoladdress of structure to be populated by this function.
    Returns
    SUCCEED or FAIL.
    See also
    dbcolinfo().
    Here is the call graph for this function:

    § dbtxptr()

    DBBINARY* dbtxptr ( DBPROCESS dbproc,
    int  column 
    )

    Get text pointer for a column in the current row.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    columnnumber of the column in the SELECT statement, starting at 1.
    Returns
    text pointer for column, may be NULL.
    See also
    dbtxtimestamp(), dbwritetext().
    Here is the call graph for this function:

    § dbtxtimestamp()

    DBBINARY* dbtxtimestamp ( DBPROCESS dbproc,
    int  column 
    )

    Get text timestamp for a column in the current row.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    columnnumber of the column in the SELECT statement, starting at 1.
    Returns
    timestamp for column, may be NULL.
    See also
    dbtxptr(), dbwritetext().
    Here is the call graph for this function:

    § dbuse()

    RETCODE dbuse ( DBPROCESS dbproc,
    const char *  name 
    )

    Change current database.

    Analagous to the unix command cd, dbuse() makes name the default database. Waits for an answer from the server.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    namedatabase to use.
    Return values
    SUCCEEDquery was processed without errors.
    FAILquery was not processed
    See also
    dbchange(), dbname().
    Here is the call graph for this function:

    § dbvarylen()

    DBINT dbvarylen ( DBPROCESS dbproc,
    int  column 
    )

    Determine whether a column can vary in size.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    columnNth in the result set, starting from 1.
    Return values
    TRUEdatatype of column can vary in size, or is nullable.
    FALSEdatatype of column is fixed and is not nullable.
    See also
    dbcollen(), dbcolname(), dbcoltype(), dbdata(), dbdatlen(), dbnumcols(), dbprtype().
    Here is the call graph for this function:

    § dbversion()

    const char* dbversion ( void  )

    See which version of db-lib is in use.

    Returns
    null-terminated ASCII string representing the version of db-lib.
    Remarks
    FreeTDS returns the CVS version string of dblib.c.
    See also
    Here is the call graph for this function:

    § dbwillconvert()

    DBBOOL dbwillconvert ( int  srctype,
    int  desttype 
    )

    Test whether or not a datatype can be converted to another datatype.

    Parameters
    srctypetype converting from
    desttypetype converting to
    Remarks
    dbwillconvert() lies sometimes. Some datatypes should be convertible but aren't yet in our implementation. Legal unimplemented conversions return TRUE.
    Return values
    TRUEconvertible, or should be.
    FAILnot convertible.
    See also
    dbaltbind(), dbbind(), dbconvert(), dbconvert_ps(), src/dblib/unittests/convert().c().
    Here is the call graph for this function:

    § dbwritetext()

    RETCODE dbwritetext ( DBPROCESS dbproc,
    char *  objname,
    DBBINARY *  textptr,
    DBTINYINT  textptrlen,
    DBBINARY *  timestamp,
    DBBOOL  log,
    DBINT  size,
    BYTE *  text 
    )

    Send text or image data to the server.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    objnametable name
    textptrtext pointer to be modified, obtained from dbtxptr().
    textptrlenIgnored. Supposed to be DBTXPLEN.
    timestamptext timestamp to be modified, obtained from dbtxtimestamp() or dbtxtsnewval(), may be NULL.
    logTRUE if the operation is to be recorded in the transaction log.
    sizeoverall size of the data (in total, not just for this call), in bytes. A guideline, must not overstate the case.
    textthe chunk of data to write.
    Return values
    SUCCEEDeverything worked.
    FAILnot sent, possibly because timestamp is invalid or was changed in the database since it was fetched.
    See also
    dbmoretext(), dbtxptr(), dbtxtimestamp(), dbwritetext(), dbtxtsput().
    Here is the call graph for this function:
    freetds-1.00.82/doc/reference/a00518.map100644 025423 025423 00000000307 13242511134 0013042 freetds-1.00.82/doc/reference/a00518.md5100644 025423 025423 00000000040 13242511133 00127434ce9c8b0eb185fc3c74b4eb4a1a0fb16freetds-1.00.82/doc/reference/a00518.svg100644 025423 025423 00000003100 13242511136 0013060 Primary functions Node1 The db-lib API Node0 Primary functions Node1->Node0 freetds-1.00.82/doc/reference/a00518_ga01404b179a251c249aecfdae72ec6ca4_cgraph.map100644 025423 025423 00000000311 13242511134 0021447 freetds-1.00.82/doc/reference/a00518_ga01404b179a251c249aecfdae72ec6ca4_cgraph.md5100644 025423 025423 00000000040 13242511133 0021355945710e83957979bc8d8e30fac5e0636freetds-1.00.82/doc/reference/a00518_ga01404b179a251c249aecfdae72ec6ca4_cgraph.svg100644 025423 025423 00000003117 13242511136 0021502 dbclrbuf Node50 dbclrbuf Node51 tdsdump_log Node50->Node51 freetds-1.00.82/doc/reference/a00518_ga0984798bb806f7451a53bffa7e2c430f_cgraph.map100644 025423 025423 00000000307 13242511134 0021271 freetds-1.00.82/doc/reference/a00519.html100644 025423 025423 00000112310 13242511136 0013232 FreeTDS API: Remote Procedure functions
    FreeTDS API
    Remote Procedure functions

    Functions used with stored procedures. More...

    Collaboration diagram for Remote Procedure functions:

    Functions

    DBBOOL dbhasretstat (DBPROCESS *dbproc)
     Determine if query generated a return status number. More...
     
    int dbnumrets (DBPROCESS *dbproc)
     Get count of output parameters filled by a stored procedure. More...
     
    BYTE * dbretdata (DBPROCESS *dbproc, int retnum)
     Get value of an output parameter filled by a stored procedure. More...
     
    int dbretlen (DBPROCESS *dbproc, int retnum)
     Get size of an output parameter filled by a stored procedure. More...
     
    char * dbretname (DBPROCESS *dbproc, int retnum)
     Get name of an output parameter filled by a stored procedure. More...
     
    DBINT dbretstatus (DBPROCESS *dbproc)
     Fetch status value returned by query or remote procedure call. More...
     
    int dbrettype (DBPROCESS *dbproc, int retnum)
     Get datatype of a stored procedure's return parameter. More...
     
    RETCODE dbrpcinit (DBPROCESS *dbproc, const char rpcname[], DBSMALLINT options)
     Initialize a remote procedure call. More...
     
    RETCODE dbrpcparam (DBPROCESS *dbproc, const char paramname[], BYTE status, int db_type, DBINT maxlen, DBINT datalen, BYTE *value)
     Add a parameter to a remote procedure call. More...
     
    RETCODE dbrpcsend (DBPROCESS *dbproc)
     Execute the procedure and free associated memory. More...
     

    Detailed Description

    Functions used with stored procedures.

    Especially useful for OUTPUT parameters, because modern Microsoft servers do not return output parameter data to the client unless the procedure was invoked with dbrpcsend().

    Function Documentation

    § dbhasretstat()

    DBBOOL dbhasretstat ( DBPROCESS dbproc)

    Determine if query generated a return status number.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    Return values
    TRUEfetch return status with dbretstatus().
    FALSEno return status.
    See also
    dbnextrow(), dbresults(), dbretdata(), dbretstatus(), dbrpcinit(), dbrpcparam(), dbrpcsend().
    Here is the call graph for this function:

    § dbnumrets()

    int dbnumrets ( DBPROCESS dbproc)

    Get count of output parameters filled by a stored procedure.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    Returns
    How many, possibly zero.
    Remarks
    This name sounds funny.
    See also
    Here is the call graph for this function:

    § dbretdata()

    BYTE* dbretdata ( DBPROCESS dbproc,
    int  retnum 
    )

    Get value of an output parameter filled by a stored procedure.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    retnumNth parameter between 1 and the return value from dbnumrets().
    Returns
    Address of a return parameter value, or NULL if no such retnum.
    See also
    dbnextrow(), dbnumrets(), dbresults(), dbretlen(), dbretname(), dbrettype(), dbrpcinit(), dbrpcparam().
    Todo:
    Handle blobs.
    Here is the call graph for this function:

    § dbretlen()

    int dbretlen ( DBPROCESS dbproc,
    int  retnum 
    )

    Get size of an output parameter filled by a stored procedure.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    retnumNth parameter between 1 and the return value from dbnumrets().
    Returns
    Size of a return parameter value, or NULL if no such retnum.
    See also
    dbnextrow(), dbnumrets(), dbresults(), dbretdata(), dbretname(), dbrettype(), dbrpcinit(), dbrpcparam().
    Here is the call graph for this function:

    § dbretname()

    char* dbretname ( DBPROCESS dbproc,
    int  retnum 
    )

    Get name of an output parameter filled by a stored procedure.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    retnumNth parameter between 1 and the return value from dbnumrets().
    Returns
    ASCII null-terminated string, NULL if no such retnum.
    See also
    dbnextrow(), dbnumrets(), dbresults(), dbretdata(), dbretlen(), dbrettype(), dbrpcinit(), dbrpcparam().
    Here is the call graph for this function:

    § dbretstatus()

    DBINT dbretstatus ( DBPROCESS dbproc)

    Fetch status value returned by query or remote procedure call.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    Returns
    return value
    See also
    dbhasretstat(), dbnextrow(), dbresults(), dbretdata(), dbrpcinit(), dbrpcparam(), dbrpcsend().
    Here is the call graph for this function:

    § dbrettype()

    int dbrettype ( DBPROCESS dbproc,
    int  retnum 
    )

    Get datatype of a stored procedure's return parameter.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    retnumNth return parameter, between 1 and dbnumrets().
    Returns
    SYB* datatype token, or -1 if retnum is out of range.
    See also
    dbnextrow(), dbnumrets(), dbprtype(), dbresults(), dbretdata(), dbretlen(), dbretname(), dbrpcinit(), dbrpcparam().
    Here is the call graph for this function:

    § dbrpcinit()

    RETCODE dbrpcinit ( DBPROCESS dbproc,
    const char  rpcname[],
    DBSMALLINT  options 
    )

    Initialize a remote procedure call.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    rpcnamename of the stored procedure to be run.
    optionsOnly supported option would be DBRPCRECOMPILE, which causes the stored procedure to be recompiled before executing.
    Remarks
    The RPC functions are the only way to get back OUTPUT parameter data with db-lib from modern Microsoft servers.
    Return values
    SUCCEEDnormal.
    FAILon error
    See also
    dbrpcparam(), dbrpcsend()
    Here is the call graph for this function:

    § dbrpcparam()

    RETCODE dbrpcparam ( DBPROCESS dbproc,
    const char  paramname[],
    BYTE  status,
    int  db_type,
    DBINT  maxlen,
    DBINT  datalen,
    BYTE *  value 
    )

    Add a parameter to a remote procedure call.

    Call between dbrpcinit() and dbrpcsend()

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    paramnameliteral name of the parameter, according to the stored procedure (starts with '@'). Optional. If not used, parameters will be passed in order instead of by name.
    statusmust be DBRPCRETURN, if this parameter is a return parameter, else 0.
    typedatatype of the value parameter e.g., SYBINT4, SYBCHAR.
    maxlenMaximum output size of the parameter's value to be returned by the stored procedure, usually the size of your host variable. Fixed-length datatypes take -1 (NULL or not). Non-OUTPUT parameters also use -1. Use 0 to send a NULL value for a variable length datatype.
    datalenFor variable-length datatypes, the byte size of the data to be sent, exclusive of any null terminator. For fixed-length datatypes use -1. To send a NULL value, use 0.
    valueAddress of your host variable.
    Return values
    SUCCEEDnormal.
    FAILon error
    See also
    dbrpcinit(), dbrpcsend()
    Here is the call graph for this function:

    § dbrpcsend()

    RETCODE dbrpcsend ( DBPROCESS dbproc)

    Execute the procedure and free associated memory.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    Return values
    SUCCEEDnormal.
    FAILon error
    See also
    dbrpcinit(), dbrpcparam()
    Here is the call graph for this function:
    freetds-1.00.82/doc/reference/a00519.map100644 025423 025423 00000000331 13242511134 0013040 freetds-1.00.82/doc/reference/a00518_ga0984798bb806f7451a53bffa7e2c430f_cgraph.md5100644 025423 025423 00000000040 13242511133 0021172b03c722d150c1421fbe4483661278742freetds-1.00.82/doc/reference/a00518_ga0984798bb806f7451a53bffa7e2c430f_cgraph.svg100644 025423 025423 00000003120 13242511136 0021311 dblogin Node130 dblogin Node131 tdsdump_log Node130->Node131 freetds-1.00.82/doc/reference/a00518_ga0fcfcf6846442dac9dd5584d270ec72a_cgraph.map100644 025423 025423 00000000313 13242511134 0021502 freetds-1.00.82/doc/reference/a00518_ga0fcfcf6846442dac9dd5584d270ec72a_cgraph.md5100644 025423 025423 00000000040 13242511133 00214063cce8529545cd3c674122bd25f899cc4freetds-1.00.82/doc/reference/a00518_ga0fcfcf6846442dac9dd5584d270ec72a_cgraph.svg100644 025423 025423 00000003127 13242511136 0021534 dbfreebuf Node102 dbfreebuf Node103 tdsdump_log Node102->Node103 freetds-1.00.82/doc/reference/a00518_ga13caa07ec45cd6f64e9197d29e3cfe5e_cgraph.map100644 025423 025423 00000000311 13242511134 0021564 freetds-1.00.82/doc/reference/a00518_ga13caa07ec45cd6f64e9197d29e3cfe5e_cgraph.md5100644 025423 025423 00000000040 13242511133 0021472144547c78cd0082b97da45e21d4db51bfreetds-1.00.82/doc/reference/a00518_ga13caa07ec45cd6f64e9197d29e3cfe5e_cgraph.svg100644 025423 025423 00000003124 13242511136 0021615 dbstrlen Node245 dbstrlen Node246 tdsdump_log Node245->Node246 freetds-1.00.82/doc/reference/a00518_ga223a6d333f95e726b0b42ec19a076731_cgraph.map100644 025423 025423 00000000305 13242511134 0021103 freetds-1.00.82/doc/reference/a00518_ga223a6d333f95e726b0b42ec19a076731_cgraph.md5100644 025423 025423 00000000040 13242511133 0021006b379edeef74123bd9463afa56ac1944cfreetds-1.00.82/doc/reference/a00518_ga223a6d333f95e726b0b42ec19a076731_cgraph.svg100644 025423 025423 00000003120 13242511136 0021125 dbspid Node217 dbspid Node218 tdsdump_log Node217->Node218 freetds-1.00.82/doc/reference/a00518_ga308918c13a5b1644269c1654fbea96ac_cgraph.map100644 025423 025423 00000000321 13242511134 0021171 freetds-1.00.82/doc/reference/a00518_ga308918c13a5b1644269c1654fbea96ac_cgraph.md5100644 025423 025423 00000000040 13242511133 0021076588e5eded5817fd4eb1b4e83d0280aaefreetds-1.00.82/doc/reference/a00518_ga308918c13a5b1644269c1654fbea96ac_cgraph.svg100644 025423 025423 00000003143 13242511136 0021222 dbspr1rowlen Node223 dbspr1rowlen Node224 tdsdump_log Node223->Node224 freetds-1.00.82/doc/reference/a00518_ga32eb72f6fb3edb130e59fb3dd0766e7e_cgraph.map100644 025423 025423 00000000313 13242511134 0021557 freetds-1.00.82/doc/reference/a00518_ga32eb72f6fb3edb130e59fb3dd0766e7e_cgraph.md5100644 025423 025423 00000000040 13242511133 00214639544e732ab07b796c40ed81230abbd93freetds-1.00.82/doc/reference/a00518_ga32eb72f6fb3edb130e59fb3dd0766e7e_cgraph.svg100644 025423 025423 00000003122 13242511136 0021604 dbconvert Node77 dbconvert Node78 tdsdump_log Node77->Node78 freetds-1.00.82/doc/reference/a00518_ga3340e21db274b272ec11c037cb147222_cgraph.map100644 025423 025423 00000000307 13242511134 0021055 freetds-1.00.82/doc/reference/a00518_ga3340e21db274b272ec11c037cb147222_cgraph.md5100644 025423 025423 00000000040 13242511133 002075603a95ca88499c0ab3e304d4159d76a0cfreetds-1.00.82/doc/reference/a00518_ga3340e21db274b272ec11c037cb147222_cgraph.svg100644 025423 025423 00000003101 13242511136 0021074 dbadlen Node6 dbadlen Node7 tdsdump_log Node6->Node7 freetds-1.00.82/doc/reference/a00518_ga39302e8efbb476ba01cff109ffb3661e_cgraph.map100644 025423 025423 00000000323 13242511134 0021471 freetds-1.00.82/doc/reference/a00518_ga39302e8efbb476ba01cff109ffb3661e_cgraph.md5100644 025423 025423 00000000040 13242511133 00213745aebb39b54cbec2db163f80690b3a88dfreetds-1.00.82/doc/reference/a00518_ga39302e8efbb476ba01cff109ffb3661e_cgraph.svg100644 025423 025423 00000003151 13242511136 0021517 dbservcharset Node182 dbservcharset Node183 tdsdump_log Node182->Node183 freetds-1.00.82/doc/reference/a00518_ga399512ec78c15ce3db79ea88ef3b1293_cgraph.map100644 025423 025423 00000000313 13242511134 0021355 freetds-1.00.82/doc/reference/a00518_ga399512ec78c15ce3db79ea88ef3b1293_cgraph.md5100644 025423 025423 00000000040 13242511133 00212617700e445a19eb5d50d507bb63404aecbfreetds-1.00.82/doc/reference/a00518_ga399512ec78c15ce3db79ea88ef3b1293_cgraph.svg100644 025423 025423 00000003127 13242511136 0021407 dbsetnull Node199 dbsetnull Node200 tdsdump_log Node199->Node200 freetds-1.00.82/doc/reference/a00518_ga3a96d0188e5e0eb9eea661b3685fdcc3_cgraph.map100644 025423 025423 00000000317 13242511134 0021510 freetds-1.00.82/doc/reference/a00518_ga3a96d0188e5e0eb9eea661b3685fdcc3_cgraph.md5100644 025423 025423 00000000040 13242511133 0021410d6a6af3820022b7971a0282cbcf1cba7freetds-1.00.82/doc/reference/a00518_ga3a96d0188e5e0eb9eea661b3685fdcc3_cgraph.svg100644 025423 025423 00000003133 13242511136 0021533 dbcolsource Node65 dbcolsource Node66 tdsdump_log Node65->Node66 freetds-1.00.82/doc/reference/a00518_ga3c33e72c41b40e08dbcfdfa0d16bc399_cgraph.map100644 025423 025423 00000000323 13242511134 0021537 freetds-1.00.82/doc/reference/a00518_ga3c33e72c41b40e08dbcfdfa0d16bc399_cgraph.md5100644 025423 025423 00000000040 13242511133 002144273f6f77de598222c753e35005fcfd665freetds-1.00.82/doc/reference/a00518_ga3c33e72c41b40e08dbcfdfa0d16bc399_cgraph.svg100644 025423 025423 00000003137 13242511136 0021571 dbcoltypeinfo Node71 dbcoltypeinfo Node72 tdsdump_log Node71->Node72 freetds-1.00.82/doc/reference/a00518_ga43727b10d4cbb7708b374811abe6eadb_cgraph.map100644 025423 025423 00000000305 13242511134 0021376 freetds-1.00.82/doc/reference/a00518_ga43727b10d4cbb7708b374811abe6eadb_cgraph.md5100644 025423 025423 00000000040 13242511133 00213016977db482851611c76086668ac637ba6freetds-1.00.82/doc/reference/a00518_ga43727b10d4cbb7708b374811abe6eadb_cgraph.svg100644 025423 025423 00000003111 13242511136 0021420 dbfcmd Node99 dbfcmd Node100 tdsdump_log Node99->Node100 freetds-1.00.82/doc/reference/a00518_ga4e26d949be2c3bf71b1a33c75b11d931_cgraph.map100644 025423 025423 00000000264 13242511134 0021327 freetds-1.00.82/doc/reference/a00518_ga4e26d949be2c3bf71b1a33c75b11d931_cgraph.md5100644 025423 025423 00000000040 13242511133 00212269870bfe4f70e9eb41e9082665b149e5ffreetds-1.00.82/doc/reference/a00518_ga4e26d949be2c3bf71b1a33c75b11d931_cgraph.svg100644 025423 025423 00000003102 13242511136 0021345 dbresults Node177 dbresults Node178 _dbresults Node177->Node178 freetds-1.00.82/doc/reference/a00518_ga548153eb2eae76c48aa9d4b72258dc1c_cgraph.map100644 025423 025423 00000000317 13242511134 0021420 freetds-1.00.82/doc/reference/a00518_ga548153eb2eae76c48aa9d4b72258dc1c_cgraph.md5100644 025423 025423 00000000040 13242511133 0021320b48863aef8e252bfa57287a852219863freetds-1.00.82/doc/reference/a00518_ga548153eb2eae76c48aa9d4b72258dc1c_cgraph.svg100644 025423 025423 00000003140 13242511136 0021441 dbwritetext Node269 dbwritetext Node270 tdsdump_log Node269->Node270 freetds-1.00.82/doc/reference/a00518_ga559e24ba70d0d96c3469eb6ab8f74e05_cgraph.map100644 025423 025423 00000000315 13242511134 0021347 freetds-1.00.82/doc/reference/a00518_ga559e24ba70d0d96c3469eb6ab8f74e05_cgraph.md5100644 025423 025423 00000000040 13242511133 00212511f950cb804b32bfdb69b2938fa0625d6freetds-1.00.82/doc/reference/a00518_ga559e24ba70d0d96c3469eb6ab8f74e05_cgraph.svg100644 025423 025423 00000003130 13242511136 0021371 dbcanquery Node41 dbcanquery Node42 tdsdump_log Node41->Node42 freetds-1.00.82/doc/reference/a00518_ga57c856964a9a0b4cc43f5192647c51e7_cgraph.map100644 025423 025423 00000000313 13242511134 0021132 freetds-1.00.82/doc/reference/a00518_ga57c856964a9a0b4cc43f5192647c51e7_cgraph.md5100644 025423 025423 00000000040 13242511133 002103662ef459643fbfb91c0694f3e6e87f101freetds-1.00.82/doc/reference/a00518_ga57c856964a9a0b4cc43f5192647c51e7_cgraph.svg100644 025423 025423 00000003127 13242511136 0021164 dbvarylen Node260 dbvarylen Node261 tdsdump_log Node260->Node261 freetds-1.00.82/doc/reference/a00518_ga57e4098b153a030f0be02bcd98e08ba2_cgraph.map100644 025423 025423 00000000307 13242511134 0021315 freetds-1.00.82/doc/reference/a00518_ga57e4098b153a030f0be02bcd98e08ba2_cgraph.md5100644 025423 025423 00000000040 13242511133 00212160ab4444818075fa3fe0ec7c070681c92freetds-1.00.82/doc/reference/a00518_ga57e4098b153a030f0be02bcd98e08ba2_cgraph.svg100644 025423 025423 00000003123 13242511136 0021340 dbtxptr Node251 dbtxptr Node252 tdsdump_log Node251->Node252 freetds-1.00.82/doc/reference/a00518_ga5ea23272124fff03b8d87538c1ec3ee5_cgraph.map100644 025423 025423 00000000311 13242511134 0021332 freetds-1.00.82/doc/reference/a00518_ga5ea23272124fff03b8d87538c1ec3ee5_cgraph.md5100644 025423 025423 00000000040 13242511133 0021240509547f97294405c163d3f086da92091freetds-1.00.82/doc/reference/a00518_ga5ea23272124fff03b8d87538c1ec3ee5_cgraph.svg100644 025423 025423 00000003115 13242511136 0021363 dbcancel Node38 dbcancel Node39 tdsdump_log Node38->Node39 freetds-1.00.82/doc/reference/a00518_ga5f1281c07dde5a6d28e60ef62c501d1d_cgraph.map100644 025423 025423 00000000325 13242511134 0021405 freetds-1.00.82/doc/reference/a00518_ga5f1281c07dde5a6d28e60ef62c501d1d_cgraph.md5100644 025423 025423 00000000040 13242511133 00213060aa4c6385d04f5f36378d3df08f43785freetds-1.00.82/doc/reference/a00518_ga5f1281c07dde5a6d28e60ef62c501d1d_cgraph.svg100644 025423 025423 00000003152 13242511136 0021432 dbsetlogintime Node190 dbsetlogintime Node191 tdsdump_log Node190->Node191 freetds-1.00.82/doc/reference/a00518_ga636e6f1b64743f3cf22158a56eef371f_cgraph.map100644 025423 025423 00000000313 13242511134 0021266 freetds-1.00.82/doc/reference/a00518_ga636e6f1b64743f3cf22158a56eef371f_cgraph.md5100644 025423 025423 00000000040 13242511133 00211721b241212ce6209bc4bbbea7432dbc030freetds-1.00.82/doc/reference/a00518_ga636e6f1b64743f3cf22158a56eef371f_cgraph.svg100644 025423 025423 00000003117 13242511136 0021317 dbcoltype Node68 dbcoltype Node69 tdsdump_log Node68->Node69 freetds-1.00.82/doc/reference/a00518_ga663350909fec3a1d152316c45a65e708_cgraph.map100644 025423 025423 00000000315 13242511134 0021032 freetds-1.00.82/doc/reference/a00518_ga663350909fec3a1d152316c45a65e708_cgraph.md5100644 025423 025423 00000000040 13242511133 002073453089b3a2ddcc8051679926f07597b28freetds-1.00.82/doc/reference/a00518_ga663350909fec3a1d152316c45a65e708_cgraph.svg100644 025423 025423 00000003132 13242511136 0021056 dbsetifile Node185 dbsetifile Node186 tdsdump_log Node185->Node186 freetds-1.00.82/doc/reference/a00518_ga666726c86108342b1c1f27eecf68e13c_cgraph.map100644 025423 025423 00000000313 13242511134 0021201 freetds-1.00.82/doc/reference/a00518_ga666726c86108342b1c1f27eecf68e13c_cgraph.md5100644 025423 025423 00000000040 13242511133 002110511db83f006e2d3ab4af7dc700d7f7516freetds-1.00.82/doc/reference/a00518_ga666726c86108342b1c1f27eecf68e13c_cgraph.svg100644 025423 025423 00000003127 13242511136 0021233 dbversion Node263 dbversion Node264 tdsdump_log Node263->Node264 freetds-1.00.82/doc/reference/a00518_ga66ea891910f0a357cc78107d6ab7d962_cgraph.map100644 025423 025423 00000000303 13242511134 0021203 freetds-1.00.82/doc/reference/a00518_ga66ea891910f0a357cc78107d6ab7d962_cgraph.md5100644 025423 025423 00000000040 13242511133 00211105ee7902d7e56de42e58a40377b9e3a36freetds-1.00.82/doc/reference/a00518_ga66ea891910f0a357cc78107d6ab7d962_cgraph.svg100644 025423 025423 00000003114 13242511136 0021232 dbuse Node257 dbuse Node258 tdsdump_log Node257->Node258 freetds-1.00.82/doc/reference/a00518_ga67934deac3bebbf8238eff8c0559389a_cgraph.map100644 025423 025423 00000000313 13242511134 0021521 freetds-1.00.82/doc/reference/a00518_ga67934deac3bebbf8238eff8c0559389a_cgraph.md5100644 025423 025423 00000000040 13242511133 00214250396380fee1e52e06afe1e0237be04aefreetds-1.00.82/doc/reference/a00518_ga67934deac3bebbf8238eff8c0559389a_cgraph.svg100644 025423 025423 00000003131 13242511136 0021546 dbnumalts Node150 dbnumalts Node151 tdsdump_log Node150->Node151 freetds-1.00.82/doc/reference/a00518_ga6ba2a7f18cb76d24776e45fd71141494_cgraph.map100644 025423 025423 00000000313 13242511134 0021203 freetds-1.00.82/doc/reference/a00518_ga6ba2a7f18cb76d24776e45fd71141494_cgraph.md5100644 025423 025423 00000000040 13242511133 0021107d52269a257e1774c29843e440b32f4a1freetds-1.00.82/doc/reference/a00518_ga6ba2a7f18cb76d24776e45fd71141494_cgraph.svg100644 025423 025423 00000003132 13242511136 0021231 dbiscount Node124 dbiscount Node125 tdsdump_log Node124->Node125 freetds-1.00.82/doc/reference/a00518_ga6ccffbb3f0cfb10883ad349f1e47c50e_cgraph.map100644 025423 025423 00000000313 13242511134 0021627 freetds-1.00.82/doc/reference/a00518_ga6ccffbb3f0cfb10883ad349f1e47c50e_cgraph.md5100644 025423 025423 00000000040 13242511133 0021533bceb13524235169e12b5e170d9ba00d0freetds-1.00.82/doc/reference/a00518_ga6ccffbb3f0cfb10883ad349f1e47c50e_cgraph.svg100644 025423 025423 00000003127 13242511136 0021661 dbgettime Node116 dbgettime Node117 tdsdump_log Node116->Node117 freetds-1.00.82/doc/reference/a00518_ga6f13381522a1fa0b6ce2c15378088cdd_cgraph.map100644 025423 025423 00000000315 13242511134 0021242 freetds-1.00.82/doc/reference/a00518_ga6f13381522a1fa0b6ce2c15378088cdd_cgraph.md5100644 025423 025423 00000000040 13242511133 0021144d988526609766c3df21738f8a90e0444freetds-1.00.82/doc/reference/a00518_ga6f13381522a1fa0b6ce2c15378088cdd_cgraph.svg100644 025423 025423 00000003137 13242511136 0021273 dbmoretext Node139 dbmoretext Node140 tdsdump_log Node139->Node140 freetds-1.00.82/doc/reference/a00518_ga85dcc40c3615f94be96b09b2ec043533_cgraph.map100644 025423 025423 00000000315 13242511134 0021253 freetds-1.00.82/doc/reference/a00518_ga85dcc40c3615f94be96b09b2ec043533_cgraph.md5100644 025423 025423 00000000040 13242511133 00211553706a53f39c9545338df7086a941a129freetds-1.00.82/doc/reference/a00518_ga85dcc40c3615f94be96b09b2ec043533_cgraph.svg100644 025423 025423 00000003135 13242511136 0021302 dbnullbind Node147 dbnullbind Node148 tdsdump_log Node147->Node148 freetds-1.00.82/doc/reference/a00518_ga873bc0f4663165e711655ade1dfae795_cgraph.map100644 025423 025423 00000000305 13242511134 0021265 freetds-1.00.82/doc/reference/a00518_ga873bc0f4663165e711655ade1dfae795_cgraph.md5100644 025423 025423 00000000040 13242511133 00211700aef30985e0cc72347fa6f979b455da7freetds-1.00.82/doc/reference/a00518_ga873bc0f4663165e711655ade1dfae795_cgraph.svg100644 025423 025423 00000003110 13242511136 0021306 dbbind Node32 dbbind Node33 tdsdump_log Node32->Node33 freetds-1.00.82/doc/reference/a00518_ga87b39d9863316b4ba85654b0885d53a0_cgraph.map100644 025423 025423 00000000303 13242511134 0021047 freetds-1.00.82/doc/reference/a00518_ga87b39d9863316b4ba85654b0885d53a0_cgraph.md5100644 025423 025423 00000000040 13242511133 002075495a20d9a56eb327c5f92b1dfd8b5cc2cfreetds-1.00.82/doc/reference/a00518_ga87b39d9863316b4ba85654b0885d53a0_cgraph.svg100644 025423 025423 00000003105 13242511136 0021076 dbcmd Node56 dbcmd Node57 tdsdump_log Node56->Node57 freetds-1.00.82/doc/reference/a00518_ga89fc5589b4bf41932324d2cfc6ad6433_cgraph.map100644 025423 025423 00000000311 13242511134 0021264 freetds-1.00.82/doc/reference/a00518_ga89fc5589b4bf41932324d2cfc6ad6433_cgraph.md5100644 025423 025423 00000000040 13242511133 00211722dfc7239d7766e1d42f64855560b866cfreetds-1.00.82/doc/reference/a00518_ga89fc5589b4bf41932324d2cfc6ad6433_cgraph.svg100644 025423 025423 00000003114 13242511136 0021314 dbcollen Node59 dbcollen Node60 tdsdump_log Node59->Node60 freetds-1.00.82/doc/reference/a00518_ga8b00d5cdcaa20cba13fa2e03d52a443e_cgraph.map100644 025423 025423 00000000321 13242511134 0021561 freetds-1.00.82/doc/reference/a00518_ga8b00d5cdcaa20cba13fa2e03d52a443e_cgraph.md5100644 025423 025423 00000000040 13242511133 0021466e1ffabc239fd748501b8cb7253261c65freetds-1.00.82/doc/reference/a00518_ga8b00d5cdcaa20cba13fa2e03d52a443e_cgraph.svg100644 025423 025423 00000003133 13242511136 0021611 dbconvert_ps Node80 dbconvert_ps Node81 tdsdump_log Node80->Node81 freetds-1.00.82/doc/reference/a00518_ga8cbc761b1266bd947783d843aeeec264_cgraph.map100644 025423 025423 00000000311 13242511134 0021345 freetds-1.00.82/doc/reference/a00518_ga8cbc761b1266bd947783d843aeeec264_cgraph.md5100644 025423 025423 00000000040 13242511133 0021253f2644be37b599b5ee0db8fc4f29b6ad1freetds-1.00.82/doc/reference/a00518_ga8cbc761b1266bd947783d843aeeec264_cgraph.svg100644 025423 025423 00000003117 13242511136 0021400 dbchange Node44 dbchange Node45 tdsdump_log Node44->Node45 freetds-1.00.82/doc/reference/a00518_ga939c2a2e67b9992c787e2cec5b6cc1a7_cgraph.map100644 025423 025423 00000000317 13242511134 0021443 freetds-1.00.82/doc/reference/a00518_ga939c2a2e67b9992c787e2cec5b6cc1a7_cgraph.md5100644 025423 025423 00000000040 13242511133 0021343832a808aa50d1db6c02edb7248670f82freetds-1.00.82/doc/reference/a00518_ga939c2a2e67b9992c787e2cec5b6cc1a7_cgraph.svg100644 025423 025423 00000003132 13242511136 0021465 dbanullbind Node27 dbanullbind Node28 tdsdump_log Node27->Node28 freetds-1.00.82/doc/reference/a00518_ga93ee3c8ca34a08588f88784898fd69e0_cgraph.map100644 025423 025423 00000000311 13242511134 0021245 freetds-1.00.82/doc/reference/a00518_ga93ee3c8ca34a08588f88784898fd69e0_cgraph.md5100644 025423 025423 00000000040 13242511133 002115307b65dbeea1ebf8ee1f6ae5e762114d2freetds-1.00.82/doc/reference/a00518_ga93ee3c8ca34a08588f88784898fd69e0_cgraph.svg100644 025423 025423 00000003114 13242511136 0021275 dbclropt Node53 dbclropt Node54 tdsdump_log Node53->Node54 freetds-1.00.82/doc/reference/a00518_ga9433bc200c0978569964354451d9b64e_cgraph.map100644 025423 025423 00000000307 13242511134 0020715 freetds-1.00.82/doc/reference/a00518_ga9433bc200c0978569964354451d9b64e_cgraph.md5100644 025423 025423 00000000040 13242511133 0020616b0ebe84a9fa0aeb604ef44ef2f8c7df4freetds-1.00.82/doc/reference/a00518_ga9433bc200c0978569964354451d9b64e_cgraph.svg100644 025423 025423 00000003114 13242511136 0020740 dbcount Node83 dbcount Node84 tdsdump_log Node83->Node84 freetds-1.00.82/doc/reference/a00518_ga947837a5c8fd99898c043435945b668c_cgraph.map100644 025423 025423 00000000307 13242511134 0021032 freetds-1.00.82/doc/reference/a00518_ga947837a5c8fd99898c043435945b668c_cgraph.md5100644 025423 025423 00000000040 13242511133 0020733be2154f38097ba3c60d16e7a772e5089freetds-1.00.82/doc/reference/a00518_ga947837a5c8fd99898c043435945b668c_cgraph.svg100644 025423 025423 00000003113 13242511136 0021054 dbaltop Node18 dbaltop Node19 tdsdump_log Node18->Node19 freetds-1.00.82/doc/reference/a00518_ga9804fc70ae6ed35c92cd75d410dad570_cgraph.map100644 025423 025423 00000000325 13242511134 0021416 freetds-1.00.82/doc/reference/a00518_ga9804fc70ae6ed35c92cd75d410dad570_cgraph.md5100644 025423 025423 00000000040 13242511133 0021317b63ffb011c40e376d9d5879db5412bfbfreetds-1.00.82/doc/reference/a00518_ga9804fc70ae6ed35c92cd75d410dad570_cgraph.svg100644 025423 025423 00000003154 13242511136 0021445 dbtablecolinfo Node248 dbtablecolinfo Node249 tdsdump_log Node248->Node249 freetds-1.00.82/doc/reference/a00518_ga9a35c8d3cd0e35c10555baf8f6a01e93_cgraph.map100644 025423 025423 00000000311 13242511134 0021403 freetds-1.00.82/doc/reference/a00518_ga9a35c8d3cd0e35c10555baf8f6a01e93_cgraph.md5100644 025423 025423 00000000040 13242511133 00213115987a4d3ec1318a24d161355f6d43fb2freetds-1.00.82/doc/reference/a00518_ga9a35c8d3cd0e35c10555baf8f6a01e93_cgraph.svg100644 025423 025423 00000003117 13242511136 0021436 dbaltlen Node15 dbaltlen Node16 tdsdump_log Node15->Node16 freetds-1.00.82/doc/reference/a00518_ga9d660d278f3f58871b4086c0e175f4c6_cgraph.map100644 025423 025423 00000000311 13242511134 0021136 freetds-1.00.82/doc/reference/a00518_ga9d660d278f3f58871b4086c0e175f4c6_cgraph.md5100644 025423 025423 00000000040 13242511133 00210446674c0b64956b38cab6f43da9f053e03freetds-1.00.82/doc/reference/a00518_ga9d660d278f3f58871b4086c0e175f4c6_cgraph.svg100644 025423 025423 00000003127 13242511136 0021172 dbsetopt Node202 dbsetopt Node203 tdsdump_log Node202->Node203 freetds-1.00.82/doc/reference/a00518_ga9dfc2ee533e5e48a7aa8ca22f8d9ed79_cgraph.map100644 025423 025423 00000000311 13242511134 0021656 freetds-1.00.82/doc/reference/a00518_ga9dfc2ee533e5e48a7aa8ca22f8d9ed79_cgraph.md5100644 025423 025423 00000000040 13242511133 0021564f610a664e4ab462de241eee8e6fd8b37freetds-1.00.82/doc/reference/a00518_ga9dfc2ee533e5e48a7aa8ca22f8d9ed79_cgraph.svg100644 025423 025423 00000003124 13242511136 0021707 dbprhead Node162 dbprhead Node163 tdsdump_log Node162->Node163 freetds-1.00.82/doc/reference/a00518_gaa22dce1ee0eb83059699c34c47d07c14_cgraph.map100644 025423 025423 00000000323 13242511134 0021332 freetds-1.00.82/doc/reference/a00518_gaa22dce1ee0eb83059699c34c47d07c14_cgraph.md5100644 025423 025423 00000000040 13242511133 0021235d9ee1158dc16fc5f02448332a6f8d19bfreetds-1.00.82/doc/reference/a00518_gaa22dce1ee0eb83059699c34c47d07c14_cgraph.svg100644 025423 025423 00000003147 13242511136 0021365 dbsetlversion Node193 dbsetlversion Node194 tdsdump_log Node193->Node194 freetds-1.00.82/doc/reference/a00518_gaa30be3414a97aac6139af2e928db91ca_cgraph.map100644 025423 025423 00000000307 13242511134 0021462 freetds-1.00.82/doc/reference/a00518_gaa30be3414a97aac6139af2e928db91ca_cgraph.md5100644 025423 025423 00000000040 13242511133 00213635e47135bd622918d9d1c2f580cb66f6ffreetds-1.00.82/doc/reference/a00518_gaa30be3414a97aac6139af2e928db91ca_cgraph.svg100644 025423 025423 00000003123 13242511136 0021505 dbprrow Node165 dbprrow Node166 tdsdump_log Node165->Node166 freetds-1.00.82/doc/reference/a00518_gaa5714a91d7c14365fa1e5b164bb2b0b6_cgraph.map100644 025423 025423 00000000323 13242511134 0021310 freetds-1.00.82/doc/reference/a00518_gaa5714a91d7c14365fa1e5b164bb2b0b6_cgraph.md5100644 025423 025423 00000000040 13242511133 0021213e73984d1b93c8478b6d108cca2ef043dfreetds-1.00.82/doc/reference/a00518_gaa5714a91d7c14365fa1e5b164bb2b0b6_cgraph.svg100644 025423 025423 00000003147 13242511136 0021343 dbgetuserdata Node119 dbgetuserdata Node120 tdsdump_log Node119->Node120 freetds-1.00.82/doc/reference/a00518_gaa85171e020dc606f2bd3395ad1d3ab4f_cgraph.map100644 025423 025423 00000000313 13242511134 0021367 freetds-1.00.82/doc/reference/a00518_gaa85171e020dc606f2bd3395ad1d3ab4f_cgraph.md5100644 025423 025423 00000000040 13242511133 0021273b5d6d3ed16d365f5037156fd41d9db0dfreetds-1.00.82/doc/reference/a00518_gaa85171e020dc606f2bd3395ad1d3ab4f_cgraph.svg100644 025423 025423 00000003120 13242511136 0021412 dbalttype Node21 dbalttype Node22 tdsdump_log Node21->Node22 freetds-1.00.82/doc/reference/a00518_gaaa4839a9c88e5b90f33bd2407fcbc43e_cgraph.map100644 025423 025423 00000000313 13242511134 0021477 freetds-1.00.82/doc/reference/a00518_gaaa4839a9c88e5b90f33bd2407fcbc43e_cgraph.md5100644 025423 025423 00000000040 13242511133 00214030ab3f1a4da1120c79d73b6e29d28bc61freetds-1.00.82/doc/reference/a00518_gaaa4839a9c88e5b90f33bd2407fcbc43e_cgraph.svg100644 025423 025423 00000003134 13242511136 0021527 dbsprhead Node226 dbsprhead Node227 tdsdump_log Node226->Node227 freetds-1.00.82/doc/reference/a00518_gaaf8349999c16b3c36caf5947747a2915_cgraph.map100644 025423 025423 00000000323 13242511134 0021147 freetds-1.00.82/doc/reference/a00518_gaaf8349999c16b3c36caf5947747a2915_cgraph.md5100644 025423 025423 00000000040 13242511133 0021052e707f4eba73d56efe554b1131cd3b5ccfreetds-1.00.82/doc/reference/a00518_gaaf8349999c16b3c36caf5947747a2915_cgraph.svg100644 025423 025423 00000003150 13242511136 0021174 dbwillconvert Node266 dbwillconvert Node267 tdsdump_log Node266->Node267 freetds-1.00.82/doc/reference/a00518_gab185982ffe0b85b8fd19747bd1f433fe_cgraph.map100644 025423 025423 00000000305 13242511134 0021440 freetds-1.00.82/doc/reference/a00518_gab185982ffe0b85b8fd19747bd1f433fe_cgraph.md5100644 025423 025423 00000000040 13242511133 0021343efd7e7317a059f79db22af9341308f23freetds-1.00.82/doc/reference/a00518_gab185982ffe0b85b8fd19747bd1f433fe_cgraph.svg100644 025423 025423 00000003116 13242511136 0021467 dbname Node144 dbname Node145 tdsdump_log Node144->Node145 freetds-1.00.82/doc/reference/a00518_gab33d2f4fd44f50e55b6c71902db4fdae_cgraph.map100644 025423 025423 00000000315 13242511134 0021550 freetds-1.00.82/doc/reference/a00518_gab33d2f4fd44f50e55b6c71902db4fdae_cgraph.md5100644 025423 025423 00000000040 13242511133 00214522e4c943d5455665eb8a32a3babf198f4freetds-1.00.82/doc/reference/a00518_gab33d2f4fd44f50e55b6c71902db4fdae_cgraph.svg100644 025423 025423 00000003127 13242511136 0021600 dbcolutype Node74 dbcolutype Node75 tdsdump_log Node74->Node75 freetds-1.00.82/doc/reference/a00518_gab5fe0cd5f24d4fd33670111035a4fbed_cgraph.map100644 025423 025423 00000000315 13242511134 0021454 freetds-1.00.82/doc/reference/a00518_gab5fe0cd5f24d4fd33670111035a4fbed_cgraph.md5100644 025423 025423 00000000040 13242511133 0021356d7d285a44b26ac7662db17c1f360166afreetds-1.00.82/doc/reference/a00518_gab5fe0cd5f24d4fd33670111035a4fbed_cgraph.svg100644 025423 025423 00000003135 13242511136 0021503 dbstrbuild Node239 dbstrbuild Node240 tdsdump_log Node239->Node240 freetds-1.00.82/doc/reference/a00518_gab9aa181fb3081ffb314340cbd71e434d_cgraph.map100644 025423 025423 00000000321 13242511134 0021366 freetds-1.00.82/doc/reference/a00518_gab9aa181fb3081ffb314340cbd71e434d_cgraph.md5100644 025423 025423 00000000040 13242511133 0021273541849d9c84547a92eff6a64d08a5dc3freetds-1.00.82/doc/reference/a00518_gab9aa181fb3081ffb314340cbd71e434d_cgraph.svg100644 025423 025423 00000003145 13242511136 0021421 dbsetversion Node214 dbsetversion Node215 tdsdump_log Node214->Node215 freetds-1.00.82/doc/reference/a00518_gabaf9aa756f7cb8bbec80d1c7201c6238_cgraph.map100644 025423 025423 00000000317 13242511134 0021552 freetds-1.00.82/doc/reference/a00518_gabaf9aa756f7cb8bbec80d1c7201c6238_cgraph.md5100644 025423 025423 00000000040 13242511133 0021452103c5b59f0a7d3c0be850a20ac5ab18cfreetds-1.00.82/doc/reference/a00518_gabaf9aa756f7cb8bbec80d1c7201c6238_cgraph.svg100644 025423 025423 00000003141 13242511136 0021574 dbgetpacket Node111 dbgetpacket Node112 tdsdump_log Node111->Node112 freetds-1.00.82/doc/reference/a00518_gabb14ad9f268b92a8d63fa506098b24dd_cgraph.map100644 025423 025423 00000000313 13242511134 0021415 freetds-1.00.82/doc/reference/a00518_gabb14ad9f268b92a8d63fa506098b24dd_cgraph.md5100644 025423 025423 00000000040 13242511133 00213216b964c674eccfeeea4edeba1bffb60e6freetds-1.00.82/doc/reference/a00518_gabb14ad9f268b92a8d63fa506098b24dd_cgraph.svg100644 025423 025423 00000003127 13242511136 0021447 dbrecftos Node174 dbrecftos Node175 tdsdump_log Node174->Node175 freetds-1.00.82/doc/reference/a00518_gabcc14a1ca58b65bc46cce6c81c45218c_cgraph.map100644 025423 025423 00000000307 13242511134 0021540 freetds-1.00.82/doc/reference/a00518_gabcc14a1ca58b65bc46cce6c81c45218c_cgraph.md5100644 025423 025423 00000000040 13242511133 0021441d74a77248d417acd16715c09b613b050freetds-1.00.82/doc/reference/a00518_gabcc14a1ca58b65bc46cce6c81c45218c_cgraph.svg100644 025423 025423 00000003103 13242511136 0021561 dbadata Node3 dbadata Node4 tdsdump_log Node3->Node4 freetds-1.00.82/doc/reference/a00518_gabea9c70d02bf3e46bbb1d759915cb91e_cgraph.map100644 025423 025423 00000000323 13242511134 0021551 freetds-1.00.82/doc/reference/a00518_gabea9c70d02bf3e46bbb1d759915cb91e_cgraph.md5100644 025423 025423 00000000040 13242511133 002145494a80c39788da8a01070cc480ab170f8freetds-1.00.82/doc/reference/a00518_gabea9c70d02bf3e46bbb1d759915cb91e_cgraph.svg100644 025423 025423 00000003151 13242511136 0021577 dbsetuserdata Node211 dbsetuserdata Node212 tdsdump_log Node211->Node212 freetds-1.00.82/doc/reference/a00518_gac0cb0584f6500d61a2ac95a891da73eb_cgraph.map100644 025423 025423 00000000315 13242511134 0021377 freetds-1.00.82/doc/reference/a00518_gac0cb0584f6500d61a2ac95a891da73eb_cgraph.md5100644 025423 025423 00000000040 13242511133 0021301822d7753fcddd1f3baed949eaab3c466freetds-1.00.82/doc/reference/a00518_gac0cb0584f6500d61a2ac95a891da73eb_cgraph.svg100644 025423 025423 00000003135 13242511136 0021426 dbprcollen Node159 dbprcollen Node160 tdsdump_log Node159->Node160 freetds-1.00.82/doc/reference/a00518_gac1bdb1766b791153f37dceae8ff64ad6_cgraph.map100644 025423 025423 00000000317 13242511134 0021565 freetds-1.00.82/doc/reference/a00518_gac1bdb1766b791153f37dceae8ff64ad6_cgraph.md5100644 025423 025423 00000000040 13242511133 0021465f338345e5e5c73652f7953e10f6b91dbfreetds-1.00.82/doc/reference/a00518_gac1bdb1766b791153f37dceae8ff64ad6_cgraph.svg100644 025423 025423 00000003142 13242511136 0021610 dbloginfree Node133 dbloginfree Node134 tdsdump_log Node133->Node134 freetds-1.00.82/doc/reference/a00518_gac25ae21ca19777ffab1c013bd6049ebf_cgraph.map100644 025423 025423 00000000311 13242511134 0021533 freetds-1.00.82/doc/reference/a00518_gac25ae21ca19777ffab1c013bd6049ebf_cgraph.md5100644 025423 025423 00000000040 13242511133 002144116d732b580fd9a6bfebf73ba0c402dc0freetds-1.00.82/doc/reference/a00518_gac25ae21ca19777ffab1c013bd6049ebf_cgraph.svg100644 025423 025423 00000003124 13242511136 0021564 dbprtype Node168 dbprtype Node169 tdsdump_log Node168->Node169 freetds-1.00.82/doc/reference/a00518_gac3ba9f53cc77e4dde8f48335ed94ac19_cgraph.map100644 025423 025423 00000000315 13242511134 0021577 freetds-1.00.82/doc/reference/a00518_gac3ba9f53cc77e4dde8f48335ed94ac19_cgraph.md5100644 025423 025423 00000000040 13242511133 0021501368a01eda2e7f528679d0dbd3f81c907freetds-1.00.82/doc/reference/a00518_gac3ba9f53cc77e4dde8f48335ed94ac19_cgraph.svg100644 025423 025423 00000003137 13242511136 0021630 dbmorecmds Node136 dbmorecmds Node137 tdsdump_log Node136->Node137 freetds-1.00.82/doc/reference/a00518_gac3eb8cb53f50998403ea9aebc6263df9_cgraph.map100644 025423 025423 00000000307 13242511134 0021511 freetds-1.00.82/doc/reference/a00518_gac3eb8cb53f50998403ea9aebc6263df9_cgraph.md5100644 025423 025423 00000000040 13242511133 0021412925cb44b16c34c189427af07e380b407freetds-1.00.82/doc/reference/a00518_gac3eb8cb53f50998403ea9aebc6263df9_cgraph.svg100644 025423 025423 00000003120 13242511136 0021531 dbisopt Node127 dbisopt Node128 tdsdump_log Node127->Node128 freetds-1.00.82/doc/reference/a00518_gac3f11142ec7ff25b1f8972af10fe9454_cgraph.map100644 025423 025423 00000000323 13242511134 0021336 freetds-1.00.82/doc/reference/a00518_gac3f11142ec7ff25b1f8972af10fe9454_cgraph.md5100644 025423 025423 00000000040 13242511133 00212412484bfd623b63d7227286df1bfd8cd53freetds-1.00.82/doc/reference/a00518_gac3f11142ec7ff25b1f8972af10fe9454_cgraph.svg100644 025423 025423 00000003147 13242511136 0021371 dbtxtimestamp Node254 dbtxtimestamp Node255 tdsdump_log Node254->Node255 freetds-1.00.82/doc/reference/a00518_gac554d2cb2da0c9f9fd3d4867998edcc4_cgraph.map100644 025423 025423 00000000321 13242511134 0021576 freetds-1.00.82/doc/reference/a00518_gac554d2cb2da0c9f9fd3d4867998edcc4_cgraph.md5100644 025423 025423 00000000040 13242511133 0021503b197f05bdd2b700bedf7efde5da7c83ffreetds-1.00.82/doc/reference/a00518_gac554d2cb2da0c9f9fd3d4867998edcc4_cgraph.svg100644 025423 025423 00000003146 13242511136 0021632 dbnumcompute Node156 dbnumcompute Node157 tdsdump_log Node156->Node157 freetds-1.00.82/doc/reference/a00518_gac980139b9cea03cf93e373d425991481_cgraph.map100644 025423 025423 00000000313 13242511134 0021130 freetds-1.00.82/doc/reference/a00518_gac980139b9cea03cf93e373d425991481_cgraph.md5100644 025423 025423 00000000040 13242511133 002103441c7e5ba158b55d53043c302d39ec46cfreetds-1.00.82/doc/reference/a00518_gac980139b9cea03cf93e373d425991481_cgraph.svg100644 025423 025423 00000003132 13242511136 0021156 dbsqlsend Node236 dbsqlsend Node237 tdsdump_log Node236->Node237 freetds-1.00.82/doc/reference/a00518_gacfaf9feb29c87cfb660886162f643152_cgraph.map100644 025423 025423 00000000313 13242511134 0021356 freetds-1.00.82/doc/reference/a00518_gacfaf9feb29c87cfb660886162f643152_cgraph.md5100644 025423 025423 00000000040 13242511133 0021262eb9780161ac01bd674feab0d98c536f5freetds-1.00.82/doc/reference/a00518_gacfaf9feb29c87cfb660886162f643152_cgraph.svg100644 025423 025423 00000003130 13242511136 0021402 dbsprline Node229 dbsprline Node230 tdsdump_log Node229->Node230 freetds-1.00.82/doc/reference/a00518_gad0044401c8c83205583f93a4764f2d8b_cgraph.map100644 025423 025423 00000000305 13242511134 0021032 freetds-1.00.82/doc/reference/a00518_gad0044401c8c83205583f93a4764f2d8b_cgraph.md5100644 025423 025423 00000000040 13242511133 00207356cc2b5885d9bbe27c3f1c06a70b198ebfreetds-1.00.82/doc/reference/a00518_gad0044401c8c83205583f93a4764f2d8b_cgraph.svg100644 025423 025423 00000003107 13242511136 0021061 dbexit Node96 dbexit Node97 tdsdump_log Node96->Node97 freetds-1.00.82/doc/reference/a00518_gad06f5deddac18604dfa858b2580e232f_cgraph.map100644 025423 025423 00000000313 13242511134 0021472 freetds-1.00.82/doc/reference/a00518_gad06f5deddac18604dfa858b2580e232f_cgraph.md5100644 025423 025423 00000000040 13242511133 0021376bfd0f6c95c889b313e9fbe1b36d32eebfreetds-1.00.82/doc/reference/a00518_gad06f5deddac18604dfa858b2580e232f_cgraph.svg100644 025423 025423 00000003122 13242511136 0021517 dbcolname Node62 dbcolname Node63 tdsdump_log Node62->Node63 freetds-1.00.82/doc/reference/a00518_gad10c9fd75a86c7a0ac375937df0e90a6_cgraph.map100644 025423 025423 00000000315 13242511134 0021422 freetds-1.00.82/doc/reference/a00518_gad10c9fd75a86c7a0ac375937df0e90a6_cgraph.md5100644 025423 025423 00000000040 13242511133 00213246ec19367bd677653cf04b347bb3c3c05freetds-1.00.82/doc/reference/a00518_gad10c9fd75a86c7a0ac375937df0e90a6_cgraph.svg100644 025423 025423 00000003125 13242511136 0021450 dbaltcolid Node12 dbaltcolid Node13 tdsdump_log Node12->Node13 freetds-1.00.82/doc/reference/a00518_gada4b41f34542a87f0cd87e78e56d18bb_cgraph.map100644 025423 025423 00000000313 13242511134 0021423 freetds-1.00.82/doc/reference/a00518_gada4b41f34542a87f0cd87e78e56d18bb_cgraph.md5100644 025423 025423 00000000040 13242511133 00213274bd30001ae4f6ae9c3db78101999fc14freetds-1.00.82/doc/reference/a00518_gada4b41f34542a87f0cd87e78e56d18bb_cgraph.svg100644 025423 025423 00000003127 13242511136 0021455 dbsettime Node208 dbsettime Node209 tdsdump_log Node208->Node209 freetds-1.00.82/doc/reference/a00518_gadaa9482a082aa3fe52231e17749c2993_cgraph.map100644 025423 025423 00000000313 13242511134 0021172 freetds-1.00.82/doc/reference/a00518_gadaa9482a082aa3fe52231e17749c2993_cgraph.md5100644 025423 025423 00000000040 13242511133 00210760e29b831bf26c0d3177baab5b4658c7afreetds-1.00.82/doc/reference/a00518_gadaa9482a082aa3fe52231e17749c2993_cgraph.svg100644 025423 025423 00000003133 13242511136 0021221 dbnumcols Node153 dbnumcols Node154 tdsdump_log Node153->Node154 freetds-1.00.82/doc/reference/a00518_gadb34c5c2aae50ac9f2a26d8984136997_cgraph.map100644 025423 025423 00000000323 13242511134 0021343 freetds-1.00.82/doc/reference/a00518_gadb34c5c2aae50ac9f2a26d8984136997_cgraph.md5100644 025423 025423 00000000040 13242511133 002124655ec74bce4a2335e564cfc7cf515e05dfreetds-1.00.82/doc/reference/a00518_gadb34c5c2aae50ac9f2a26d8984136997_cgraph.svg100644 025423 025423 00000003151 13242511136 0021371 dbgetmaxprocs Node108 dbgetmaxprocs Node109 tdsdump_log Node108->Node109 freetds-1.00.82/doc/reference/a00518_gadd5685565c8c6c86079e17b8a73b324c_cgraph.map100644 025423 025423 00000000315 13242511134 0021221 freetds-1.00.82/doc/reference/a00518_gadd5685565c8c6c86079e17b8a73b324c_cgraph.md5100644 025423 025423 00000000040 13242511133 002112398fc1baac4a790ca3cbd3a88e0df0ab6freetds-1.00.82/doc/reference/a00518_gadd5685565c8c6c86079e17b8a73b324c_cgraph.svg100644 025423 025423 00000003137 13242511136 0021252 dbreadtext Node171 dbreadtext Node172 tdsdump_log Node171->Node172 freetds-1.00.82/doc/reference/a00518_gae658a0cd5270f3bd6f22de17b2cb2e64_cgraph.map100644 025423 025423 00000000311 13242511134 0021460 freetds-1.00.82/doc/reference/a00518_gae658a0cd5270f3bd6f22de17b2cb2e64_cgraph.md5100644 025423 025423 00000000040 13242511133 0021366ad75d716129d54f89b698e9f1192ff75freetds-1.00.82/doc/reference/a00518_gae658a0cd5270f3bd6f22de17b2cb2e64_cgraph.svg100644 025423 025423 00000003116 13242511136 0021512 dbbylist Node35 dbbylist Node36 tdsdump_log Node35->Node36 freetds-1.00.82/doc/reference/a00518_gae666d141533126babb0235af21bdca0f_cgraph.map100644 025423 025423 00000000311 13242511134 0021350 freetds-1.00.82/doc/reference/a00518_gae666d141533126babb0235af21bdca0f_cgraph.md5100644 025423 025423 00000000040 13242511133 0021256d05a5d73d36a4c8c9db8c93691b05542freetds-1.00.82/doc/reference/a00518_gae666d141533126babb0235af21bdca0f_cgraph.svg100644 025423 025423 00000003117 13242511136 0021403 dbdatlen Node91 dbdatlen Node92 tdsdump_log Node91->Node92 freetds-1.00.82/doc/reference/a00518_gaeb3d621e4f6846bb228b0a596d8758c0_cgraph.map100644 025423 025423 00000000311 13242511134 0021260 freetds-1.00.82/doc/reference/a00518_gaeb3d621e4f6846bb228b0a596d8758c0_cgraph.md5100644 025423 025423 00000000040 13242511133 0021166e706010bb907bf5d312b1ceb2dd5b718freetds-1.00.82/doc/reference/a00518_gaeb3d621e4f6846bb228b0a596d8758c0_cgraph.svg100644 025423 025423 00000003125 13242511136 0021312 dbsetrow Node205 dbsetrow Node206 tdsdump_log Node205->Node206 freetds-1.00.82/doc/reference/a00518_gaee60c306a22383805a4b9caa647a1e16_cgraph.map100644 025423 025423 00000000305 13242511134 0021233 freetds-1.00.82/doc/reference/a00518_gaee60c306a22383805a4b9caa647a1e16_cgraph.md5100644 025423 025423 00000000040 13242511133 00211362979a7e29f802d302dc567b539bbb2d0freetds-1.00.82/doc/reference/a00518_gaee60c306a22383805a4b9caa647a1e16_cgraph.svg100644 025423 025423 00000003110 13242511136 0021254 dbdata Node86 dbdata Node87 tdsdump_log Node86->Node87 freetds-1.00.82/doc/reference/a00518_gaef740b394b44eb33925c2718f7b30d69_cgraph.map100644 025423 025423 00000000307 13242511134 0021206 freetds-1.00.82/doc/reference/a00518_gaef740b394b44eb33925c2718f7b30d69_cgraph.md5100644 025423 025423 00000000040 13242511133 0021107c9370165dc9fe496e056b87f75fb1dcffreetds-1.00.82/doc/reference/a00518_gaef740b394b44eb33925c2718f7b30d69_cgraph.svg100644 025423 025423 00000003114 13242511136 0021231 dbclose Node47 dbclose Node48 tdsdump_log Node47->Node48 freetds-1.00.82/doc/reference/a00518_gaf130b12e9e58b1bfd4a6685e33f5b3cd_cgraph.map100644 025423 025423 00000000311 13242511134 0021466 freetds-1.00.82/doc/reference/a00518_gaf130b12e9e58b1bfd4a6685e33f5b3cd_cgraph.md5100644 025423 025423 00000000040 13242511133 0021374b885d36fca03e7a1177c582220ccc9bbfreetds-1.00.82/doc/reference/a00518_gaf130b12e9e58b1bfd4a6685e33f5b3cd_cgraph.svg100644 025423 025423 00000003124 13242511136 0021517 dbstrcpy Node242 dbstrcpy Node243 tdsdump_log Node242->Node243 freetds-1.00.82/doc/reference/a00518_gaf1879b85e8238c015b9648d077665285_icgraph.map100644 025423 025423 00000000302 13242511134 0021101 freetds-1.00.82/doc/reference/a00518_gaf1879b85e8238c015b9648d077665285_icgraph.md5100644 025423 025423 00000000040 13242511133 0021007358561b3669aa89d8a5681cc93f8901ffreetds-1.00.82/doc/reference/a00518_gaf1879b85e8238c015b9648d077665285_icgraph.svg100644 025423 025423 00000003073 13242511136 0021135 _dbresults Node1 _dbresults Node2 dbresults Node1->Node2 freetds-1.00.82/doc/reference/a00518_gaf1c00d83dfa88dc99a3fb449c49660ea_cgraph.map100644 025423 025423 00000000315 13242511134 0021510 freetds-1.00.82/doc/reference/a00518_gaf1c00d83dfa88dc99a3fb449c49660ea_cgraph.md5100644 025423 025423 00000000040 13242511133 002141220bc8eef0b674320abc8434497658da6freetds-1.00.82/doc/reference/a00518_gaf1c00d83dfa88dc99a3fb449c49660ea_cgraph.svg100644 025423 025423 00000003125 13242511136 0021536 dbaltutype Node24 dbaltutype Node25 tdsdump_log Node24->Node25 freetds-1.00.82/doc/reference/a00518_gaf2ca0e63f800b3839684c894ff651dd4_cgraph.map100644 025423 025423 00000000323 13242511134 0021272 freetds-1.00.82/doc/reference/a00518_gaf2ca0e63f800b3839684c894ff651dd4_cgraph.md5100644 025423 025423 00000000040 13242511133 00211756cb76f9eb7c289f4fbba184dd8dac44efreetds-1.00.82/doc/reference/a00518_gaf2ca0e63f800b3839684c894ff651dd4_cgraph.svg100644 025423 025423 00000003147 13242511136 0021325 dbsetmaxprocs Node196 dbsetmaxprocs Node197 tdsdump_log Node196->Node197 freetds-1.00.82/doc/reference/a00518_gaf641c8e3d34607ca8b7ac2afed3e6d67_cgraph.map100644 025423 025423 00000000313 13242511134 0021560 freetds-1.00.82/doc/reference/a00518_gaf641c8e3d34607ca8b7ac2afed3e6d67_cgraph.md5100644 025423 025423 00000000040 13242511133 00214645dcb1cc0bd294eca703fa6188bf3504bfreetds-1.00.82/doc/reference/a00518_gaf641c8e3d34607ca8b7ac2afed3e6d67_cgraph.svg100644 025423 025423 00000003133 13242511136 0021607 dbspr1row Node220 dbspr1row Node221 tdsdump_log Node220->Node221 freetds-1.00.82/doc/reference/a00518_gaf917cf746c954a5d1b718afe3c4d1940_cgraph.map100644 025423 025423 00000000313 13242511134 0021345 freetds-1.00.82/doc/reference/a00518_gaf917cf746c954a5d1b718afe3c4d1940_cgraph.md5100644 025423 025423 00000000040 13242511133 00212516095c2bf9129333dda1c21f9cd80c8d6freetds-1.00.82/doc/reference/a00518_gaf917cf746c954a5d1b718afe3c4d1940_cgraph.svg100644 025423 025423 00000003131 13242511136 0021372 dbgetchar Node105 dbgetchar Node106 tdsdump_log Node105->Node106 freetds-1.00.82/doc/reference/a00518_gafefd17e15b22adda84366c817178dd7d_cgraph.map100644 025423 025423 00000000313 13242511134 0021503 freetds-1.00.82/doc/reference/a00518_gafefd17e15b22adda84366c817178dd7d_cgraph.md5100644 025423 025423 00000000040 13242511133 0021407b490ec92f1372e911f426fcb523b770dfreetds-1.00.82/doc/reference/a00518_gafefd17e15b22adda84366c817178dd7d_cgraph.svg100644 025423 025423 00000003114 13242511136 0021531 dbaltbind Node9 dbaltbind Node10 tdsdump_log Node9->Node10 freetds-1.00.82/doc/reference/a00519.md5100644 025423 025423 00000000040 13242511133 0012744782008f39fe09946e88276793ca954f0freetds-1.00.82/doc/reference/a00519.svg100644 025423 025423 00000003133 13242511136 0013067 Remote Procedure functions Node1 The db-lib API Node0 Remote Procedure functions Node1->Node0 freetds-1.00.82/doc/reference/a00519_ga0311328d63bae5d9bd5aea5ea4914223_cgraph.map100644 025423 025423 00000000313 13242511134 0021312 freetds-1.00.82/doc/reference/a00519_ga0311328d63bae5d9bd5aea5ea4914223_cgraph.md5100644 025423 025423 00000000040 13242511133 0021216d174cfd10d1de49810eef3157d4584d3freetds-1.00.82/doc/reference/a00519_ga0311328d63bae5d9bd5aea5ea4914223_cgraph.svg100644 025423 025423 00000003124 13242511136 0021341 dbretname Node12 dbretname Node13 tdsdump_log Node12->Node13 freetds-1.00.82/doc/reference/a00519_ga2306039d73fbc7045f257b0e750c37b4_cgraph.map100644 025423 025423 00000000317 13242511134 0021111 freetds-1.00.82/doc/reference/a00519_ga2306039d73fbc7045f257b0e750c37b4_cgraph.md5100644 025423 025423 00000000040 13242511133 0021011ef00415cc505f8137234437875c822cffreetds-1.00.82/doc/reference/a00519_ga2306039d73fbc7045f257b0e750c37b4_cgraph.svg100644 025423 025423 00000003130 13242511136 0021131 dbretstatus Node15 dbretstatus Node16 tdsdump_log Node15->Node16 freetds-1.00.82/doc/reference/a00519_ga42e187003b74fec6e9ca92d410bfb9c0_cgraph.map100644 025423 025423 00000000313 13242511134 0021406 freetds-1.00.82/doc/reference/a00520.html100644 025423 025423 00000210266 13242511136 0013233 FreeTDS API: Bulk copy functions
    FreeTDS API
    Bulk copy functions

    Functions to bulk-copy (a/k/a bcp) data to/from the database. More...

    Collaboration diagram for Bulk copy functions:

    Modules

     Internal bcp functions
     Static functions internal to the bcp library.
     

    Functions

    DBINT bcp_batch (DBPROCESS *dbproc)
     Commit a set of rows to the table. More...
     
    RETCODE bcp_bind (DBPROCESS *dbproc, BYTE *varaddr, int prefixlen, DBINT varlen, BYTE *terminator, int termlen, int db_vartype, int table_column)
     Bind a program host variable to a database column. More...
     
    RETCODE bcp_colfmt (DBPROCESS *dbproc, int host_colnum, int host_type, int host_prefixlen, DBINT host_collen, const BYTE *host_term, int host_termlen, int table_colnum)
     Specify the format of a datafile prior to writing to a table. More...
     
    RETCODE bcp_colfmt_ps (DBPROCESS *dbproc, int host_colnum, int host_type, int host_prefixlen, DBINT host_collen, BYTE *host_term, int host_termlen, int table_colnum, DBTYPEINFO *typeinfo)
     Specify the format of a host file for bulk copy purposes, with precision and scale support for numeric and decimal columns. More...
     
    RETCODE bcp_collen (DBPROCESS *dbproc, DBINT varlen, int table_column)
     Set the length of a host variable to be written to a table. More...
     
    RETCODE bcp_colptr (DBPROCESS *dbproc, BYTE *colptr, int table_column)
     Override bcp_bind() by pointing to a different host variable. More...
     
    RETCODE bcp_columns (DBPROCESS *dbproc, int host_colcount)
     Indicate how many columns are to be found in the datafile. More...
     
    RETCODE bcp_control (DBPROCESS *dbproc, int field, DBINT value)
     Set BCP options for uploading a datafile. More...
     
    DBINT bcp_done (DBPROCESS *dbproc)
     Conclude the transfer of data from program variables. More...
     
    RETCODE bcp_exec (DBPROCESS *dbproc, DBINT *rows_copied)
     Write a datafile to a table. More...
     
    DBBOOL bcp_getl (LOGINREC *login)
     See if BCP_SETL() was used to set the LOGINREC for BCP work. More...
     
    RETCODE bcp_init (DBPROCESS *dbproc, const char *tblname, const char *hfile, const char *errfile, int direction)
     Prepare for bulk copy operation on a table. More...
     
    RETCODE bcp_options (DBPROCESS *dbproc, int option, BYTE *value, int valuelen)
     Set "hints" for uploading a file. More...
     
    RETCODE bcp_readfmt (DBPROCESS *dbproc, const char filename[])
     Read a format definition file. More...
     
    RETCODE bcp_sendrow (DBPROCESS *dbproc)
     Write data in host variables to the table. More...
     

    Detailed Description

    Functions to bulk-copy (a/k/a bcp) data to/from the database.

    Function Documentation

    § bcp_batch()

    DBINT bcp_batch ( DBPROCESS dbproc)

    Commit a set of rows to the table.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    Remarks
    If not called, bcp_done() will cause the rows to be saved.
    Returns
    Count of rows saved, or -1 on error.
    See also
    bcp_bind(), bcp_done(), bcp_sendrow()
    Here is the call graph for this function:

    § bcp_bind()

    RETCODE bcp_bind ( DBPROCESS dbproc,
    BYTE *  varaddr,
    int  prefixlen,
    DBINT  varlen,
    BYTE *  terminator,
    int  termlen,
    int  db_vartype,
    int  table_column 
    )

    Bind a program host variable to a database column.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    varaddraddress of host variable
    prefixlenlength of any prefix found at the beginning of varaddr, in bytes. Use zero for fixed-length datatypes.
    varlenbytes of data in varaddr. Zero for NULL, -1 for fixed-length datatypes.
    terminatorbyte sequence that marks the end of the data in varaddr
    termlenlength of terminator
    vartypedatatype of the host variable
    table_columnNth column, starting at 1, in the table.
    Remarks
    The order of operation is:
    Returns
    SUCCEED or FAIL.
    See also
    bcp_batch(), bcp_colfmt(), bcp_collen(), bcp_colptr(), bcp_columns(), bcp_control(), bcp_done(), bcp_exec(), bcp_moretext(), bcp_sendrow()
    Here is the call graph for this function:

    § bcp_colfmt()

    RETCODE bcp_colfmt ( DBPROCESS dbproc,
    int  host_colnum,
    int  host_type,
    int  host_prefixlen,
    DBINT  host_collen,
    const BYTE *  host_term,
    int  host_termlen,
    int  table_colnum 
    )

    Specify the format of a datafile prior to writing to a table.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    host_colnumdatafile column number (starting with 1, not zero).
    host_typedataype token describing the data type in host_colnum. E.g. SYBCHAR for character data.
    host_prefixlensize of the prefix in the datafile column, if any. For delimited files: zero. May be 0, 1, 2, or 4 bytes. The prefix will be read as an integer (not a character string) from the data file, and will be interpreted the data size of that column, in bytes.
    host_collenmaximum size of datafile column, exclusive of any prefix/terminator. Just the data, ma'am. Special values:
    • 0 indicates NULL.
    • -1 for fixed-length non-null datatypes
    • -1 for variable-length datatypes (e.g. SYBCHAR) where the length is established by a prefix/terminator.
    host_termthe sequence of characters that will serve as a column terminator (delimiter) in the datafile. Often a tab character, but can be any string of any length. Zero indicates no terminator. Special characters:
    • '\0' terminator is an ASCII NUL.
    • '\t' terminator is an ASCII TAB.
    • '\n' terminator is an ASCII NL.
    host_termlenthe length of host_term, in bytes.
    table_colnumNth column, starting at 1, in the table that maps to host_colnum. If there is a column in the datafile that does not map to a table column, set table_colnum to zero.
    Remarks
    bcp_colfmt() is called once for each column in the datafile, as specified with bcp_columns(). In so doing, you describe to FreeTDS how to parse each line of your datafile, and where to send each field.

    When a prefix or terminator is used with variable-length data, host_collen may have one of three values:

    • positive indicating the maximum number of bytes to be used
    • 0 indicating NULL
    • -1 indicating no maximum; all data, as described by the prefix/terminator will be used.
    Returns
    SUCCEED or FAIL.
    See also
    bcp_batch(), bcp_bind(), bcp_colfmt_ps(), bcp_collen(), bcp_colptr(), bcp_columns(), bcp_control(), bcp_done(), bcp_exec(), bcp_init(), bcp_sendrow
    Here is the call graph for this function:

    § bcp_colfmt_ps()

    RETCODE bcp_colfmt_ps ( DBPROCESS dbproc,
    int  host_colnum,
    int  host_type,
    int  host_prefixlen,
    DBINT  host_collen,
    BYTE *  host_term,
    int  host_termlen,
    int  table_colnum,
    DBTYPEINFO typeinfo 
    )

    Specify the format of a host file for bulk copy purposes, with precision and scale support for numeric and decimal columns.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    host_colnumdatafile column number (starting with 1, not zero).
    host_typedataype token describing the data type in host_colnum. E.g. SYBCHAR for character data.
    host_prefixlensize of the prefix in the datafile column, if any. For delimited files: zero. May be 0, 1, 2, or 4 bytes. The prefix will be read as an integer (not a character string) from the data file, and will be interpreted the data size of that column, in bytes.
    host_collenmaximum size of datafile column, exclusive of any prefix/terminator. Just the data, ma'am. Special values:
    • 0 indicates NULL.
    • -1 for fixed-length non-null datatypes
    • -1 for variable-length datatypes (e.g. SYBCHAR) where the length is established by a prefix/terminator.
    host_termthe sequence of characters that will serve as a column terminator (delimiter) in the datafile. Often a tab character, but can be any string of any length. Zero indicates no terminator. Special characters:
    • '\0' terminator is an ASCII NUL.
    • '\t' terminator is an ASCII TAB.
    • '\n' terminator is an ASCII NL.
    host_termlenthe length of host_term, in bytes.
    table_colnumNth column, starting at 1, in the table that maps to host_colnum. If there is a column in the datafile that does not map to a table column, set table_colnum to zero.
    typeinfosomething
    Todo:
    Not implemented.
    Returns
    SUCCEED or FAIL.
    See also
    bcp_batch(), bcp_bind(), bcp_colfmt(), bcp_collen(), bcp_colptr(), bcp_columns(), bcp_control(), bcp_done(), bcp_exec(), bcp_init(), bcp_sendrow
    Here is the call graph for this function:

    § bcp_collen()

    RETCODE bcp_collen ( DBPROCESS dbproc,
    DBINT  varlen,
    int  table_column 
    )

    Set the length of a host variable to be written to a table.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    varlensize of the variable, in bytes, or
    • 0 indicating NULL
    • -1 indicating size is determined by the prefix or terminator. (If both a prefix and a terminator are present, bcp is supposed to use the smaller of the two. This feature might or might not actually work.)
      Parameters
      table_columnthe number of the column in the table (starting with 1, not zero).
      Returns
      SUCCEED or FAIL.
      See also
      bcp_bind(), bcp_colptr(), bcp_sendrow()
    Here is the call graph for this function:

    § bcp_colptr()

    RETCODE bcp_colptr ( DBPROCESS dbproc,
    BYTE *  colptr,
    int  table_column 
    )

    Override bcp_bind() by pointing to a different host variable.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    colptrThe pointer, the address of your variable.
    table_columnThe 1-based column ordinal in the table.
    Remarks
    Use between calls to bcp_sendrow(). After calling bcp_colptr(), subsequent calls to bcp_sendrow() will bind to the new address.
    Returns
    SUCCEED or FAIL.
    See also
    bcp_bind(), bcp_collen(), bcp_sendrow()
    Here is the call graph for this function:

    § bcp_columns()

    RETCODE bcp_columns ( DBPROCESS dbproc,
    int  host_colcount 
    )

    Indicate how many columns are to be found in the datafile.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    host_colcountcount of columns in the datafile, irrespective of how many you intend to use.
    Remarks
    This function describes the file as it is, not how it will be used.
    Returns
    SUCCEED or FAIL. It's hard to see how it could fail.
    See also
    bcp_colfmt()
    Here is the call graph for this function:

    § bcp_control()

    RETCODE bcp_control ( DBPROCESS dbproc,
    int  field,
    DBINT  value 
    )

    Set BCP options for uploading a datafile.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    fieldsymbolic constant indicating the option to be set, one of:
    • BCPMAXERRS Maximum errors tolerated before quitting. The default is 10.
    • BCPFIRST The first row to read in the datafile. The default is 1.
    • BCPLAST The last row to read in the datafile. The default is to copy all rows. A value of -1 resets this field to its default?
    • BCPBATCH The number of rows per batch. Default is 0, meaning a single batch.
    valueThe value for field.
    Remarks
    These options control the behavior of bcp_exec(). When writing to a table from application host memory variables, program logic controls error tolerance and batch size.
    Returns
    SUCCEED or FAIL.
    See also
    bcp_batch(), bcp_bind(), bcp_colfmt(), bcp_collen(), bcp_colptr(), bcp_columns(), bcp_done(), bcp_exec(), bcp_options()
    Here is the call graph for this function:

    § bcp_done()

    DBINT bcp_done ( DBPROCESS dbproc)

    Conclude the transfer of data from program variables.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    Remarks
    Do not overlook this function. According to Sybase, failure to call bcp_done() "will result in unpredictable errors".
    Returns
    As with bcp_batch(), the count of rows saved, or -1 on error.
    See also
    bcp_batch(), bcp_bind(), bcp_moretext(), bcp_sendrow()
    Here is the call graph for this function:

    § bcp_exec()

    RETCODE bcp_exec ( DBPROCESS dbproc,
    DBINT *  rows_copied 
    )

    Write a datafile to a table.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    rows_copiedbcp_exec will write the count of rows successfully written to this address. If rows_copied is NULL, it will be ignored by db-lib.
    Returns
    SUCCEED or FAIL.
    See also
    bcp_batch(), bcp_bind(), bcp_colfmt(), bcp_collen(), bcp_colptr(), bcp_columns(), bcp_control(), bcp_done(), bcp_init(), bcp_sendrow()

    § bcp_getl()

    DBBOOL bcp_getl ( LOGINREC login)

    See if BCP_SETL() was used to set the LOGINREC for BCP work.

    Parameters
    loginAddress of the LOGINREC variable to be passed to dbopen().
    Returns
    TRUE or FALSE.
    See also
    BCP_SETL(), bcp_init(), dblogin(), dbopen()
    Here is the call graph for this function:

    § bcp_init()

    RETCODE bcp_init ( DBPROCESS dbproc,
    const char *  tblname,
    const char *  hfile,
    const char *  errfile,
    int  direction 
    )

    Prepare for bulk copy operation on a table.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    tblnamethe name of the table receiving or providing the data.
    hfilethe data file opposite the table, if any.
    errfilethe "error file" captures messages and, if errors are encountered, copies of any rows that could not be written to the table.
    directionone of
    • DB_IN writing to the table
    • DB_OUT writing to the host file
    Remarks
    bcp_init() sets the host file data format and acquires the table metadata. It is called before the other bulk copy functions.

    When writing to a table, bcp can use as its data source a data file (hfile), or program data in an application's variables. In the latter case, call bcp_bind() to associate your data with the appropriate table column.

    Returns
    SUCCEED or FAIL.
    See also
    BCP_SETL(), bcp_bind(), bcp_done(), bcp_exec()
    Here is the call graph for this function:

    § bcp_options()

    RETCODE bcp_options ( DBPROCESS dbproc,
    int  option,
    BYTE *  value,
    int  valuelen 
    )

    Set "hints" for uploading a file.

    A FreeTDS-only function.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    optionsymbolic constant indicating the option to be set, one of:
    • BCPLABELED Not implemented.
    • BCPHINTS The hint to be passed when the bulk-copy begins.
    valueThe string constant for option a/k/a the hint. One of:
    • ORDER The data are ordered in accordance with the table's clustered index.
    • ROWS_PER_BATCH The batch size
    • KILOBYTES_PER_BATCH The approximate number of kilobytes to use for a batch size
    • TABLOCK Lock the table
    • CHECK_CONSTRAINTS Apply constraints
    • FIRE_TRIGGERS Fire any INSERT triggers on the target table
    valuelenThe strlen of value.
    Returns
    SUCCEED or FAIL.
    See also
    bcp_control(), bcp_exec(),
    Todo:
    Simplify. Remove valuelen, and dbproc->bcpinfo->hint = strdup(hints[i])
    Here is the call graph for this function:

    § bcp_readfmt()

    RETCODE bcp_readfmt ( DBPROCESS dbproc,
    const char  filename[] 
    )

    Read a format definition file.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    filenameName that will be passed to fopen(3).
    Remarks
    Reads a format file and calls bcp_columns() and bcp_colfmt() as needed.
    Returns
    SUCCEED or FAIL.
    See also
    bcp_colfmt(), bcp_colfmt_ps(), bcp_columns(), bcp_writefmt()
    Here is the call graph for this function:

    § bcp_sendrow()

    RETCODE bcp_sendrow ( DBPROCESS dbproc)

    Write data in host variables to the table.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    Remarks
    Call bcp_bind() first to describe the variables to be used. Use bcp_batch() to commit sets of rows. After sending the last row call bcp_done().
    Returns
    SUCCEED or FAIL.
    See also
    bcp_batch(), bcp_bind(), bcp_colfmt(), bcp_collen(), bcp_colptr(), bcp_columns(), bcp_control(), bcp_done(), bcp_exec(), bcp_init(), bcp_moretext(), bcp_options()
    Here is the call graph for this function:
    freetds-1.00.82/doc/reference/a00519_ga42e187003b74fec6e9ca92d410bfb9c0_cgraph.md5100644 025423 025423 00000000040 13242511133 00213122e4d7ae31b4edc68cec9cc705ecd66c8freetds-1.00.82/doc/reference/a00519_ga42e187003b74fec6e9ca92d410bfb9c0_cgraph.svg100644 025423 025423 00000003107 13242511136 0021436 dbretdata Node6 dbretdata Node7 tdsdump_log Node6->Node7 freetds-1.00.82/doc/reference/a00519_ga5b4374c13c7a83cd4345b0bfa3e787bd_cgraph.map100644 025423 025423 00000000313 13242511134 0021407 freetds-1.00.82/doc/reference/a00519_ga5b4374c13c7a83cd4345b0bfa3e787bd_cgraph.md5100644 025423 025423 00000000040 13242511133 00213138b696fd7b157154c40b0837dfea0100dfreetds-1.00.82/doc/reference/a00519_ga5b4374c13c7a83cd4345b0bfa3e787bd_cgraph.svg100644 025423 025423 00000003117 13242511136 0021440 dbrpcinit Node21 dbrpcinit Node22 tdsdump_log Node21->Node22 freetds-1.00.82/doc/reference/a00519_ga7a5062dac92ccedc8459f6d4a530ffb7_cgraph.map100644 025423 025423 00000000321 13242511134 0021560 freetds-1.00.82/doc/reference/a00519_ga7a5062dac92ccedc8459f6d4a530ffb7_cgraph.md5100644 025423 025423 00000000040 13242511133 00214652a4fd83dcc953c3b465c9fcd38c8495afreetds-1.00.82/doc/reference/a00519_ga7a5062dac92ccedc8459f6d4a530ffb7_cgraph.svg100644 025423 025423 00000003126 13242511136 0021612 dbhasretstat Node0 dbhasretstat Node1 tdsdump_log Node0->Node1 freetds-1.00.82/doc/reference/a00519_gaa478c8b96923bca02d158d966172ec1b_cgraph.map100644 025423 025423 00000000313 13242511134 0021261 freetds-1.00.82/doc/reference/a00519_gaa478c8b96923bca02d158d966172ec1b_cgraph.md5100644 025423 025423 00000000040 13242511133 002116537130aaf42eb351c4b0b76615a2fbcf7freetds-1.00.82/doc/reference/a00519_gaa478c8b96923bca02d158d966172ec1b_cgraph.svg100644 025423 025423 00000003122 13242511136 0021306 dbrettype Node18 dbrettype Node19 tdsdump_log Node18->Node19 freetds-1.00.82/doc/reference/a00519_gab705bf94be535e9d8fc4edc0f48c98b0_cgraph.map100644 025423 025423 00000000311 13242511134 0021573 freetds-1.00.82/doc/reference/a00519_gab705bf94be535e9d8fc4edc0f48c98b0_cgraph.md5100644 025423 025423 00000000040 13242511133 002150100cabdcc7ab190dcf643a64d1e7f12a4freetds-1.00.82/doc/reference/a00519_gab705bf94be535e9d8fc4edc0f48c98b0_cgraph.svg100644 025423 025423 00000003112 13242511136 0021621 dbretlen Node9 dbretlen Node10 tdsdump_log Node9->Node10 freetds-1.00.82/doc/reference/a00519_gaf6b6b0a641180a5c28382df39cd7d346_cgraph.map100644 025423 025423 00000000315 13242511134 0021255 freetds-1.00.82/doc/reference/a00519_gaf6b6b0a641180a5c28382df39cd7d346_cgraph.md5100644 025423 025423 00000000040 13242511133 0021157439d78142772db05743c9d39672cc285freetds-1.00.82/doc/reference/a00519_gaf6b6b0a641180a5c28382df39cd7d346_cgraph.svg100644 025423 025423 00000003130 13242511136 0021277 dbrpcparam Node24 dbrpcparam Node25 tdsdump_log Node24->Node25 freetds-1.00.82/doc/reference/a00519_gafa4dfd181be21e49c397f7daaa9cf96c_cgraph.map100644 025423 025423 00000000313 13242511134 0021730 freetds-1.00.82/doc/reference/a00519_gafa4dfd181be21e49c397f7daaa9cf96c_cgraph.md5100644 025423 025423 00000000040 13242511133 00216340fba39f480732e817619c26058837ce9freetds-1.00.82/doc/reference/a00519_gafa4dfd181be21e49c397f7daaa9cf96c_cgraph.svg100644 025423 025423 00000003123 13242511136 0021756 dbrpcsend Node27 dbrpcsend Node28 tdsdump_log Node27->Node28 freetds-1.00.82/doc/reference/a00519_gaff09873008411a0573f6d1a9e6c7cf4b_cgraph.map100644 025423 025423 00000000313 13242511134 0021257 freetds-1.00.82/doc/reference/a00519_gaff09873008411a0573f6d1a9e6c7cf4b_cgraph.md5100644 025423 025423 00000000040 13242511133 00211632a58722e9990ad08d9b18bfeb550a2d5freetds-1.00.82/doc/reference/a00519_gaff09873008411a0573f6d1a9e6c7cf4b_cgraph.svg100644 025423 025423 00000003112 13242511136 0021303 dbnumrets Node3 dbnumrets Node4 tdsdump_log Node3->Node4 freetds-1.00.82/doc/reference/a00520.map100644 025423 025423 00000000523 13242511134 0013033 freetds-1.00.82/doc/reference/a00520.md5100644 025423 025423 00000000040 13242511133 00127345bca12fd64bab79a4ed19912adee32c6freetds-1.00.82/doc/reference/a00520.svg100644 025423 025423 00000004423 13242511136 0013062 Bulk copy functions Node1 The db-lib API Node0 Bulk copy functions Node1->Node0 Node2 Internal bcp functions Node0->Node2 freetds-1.00.82/doc/reference/a00520_ga0ed03c69e698336d015bb315ad755fd5_cgraph.map100644 025423 025423 00000000315 13242511134 0021247 freetds-1.00.82/doc/reference/a00520_ga0ed03c69e698336d015bb315ad755fd5_cgraph.md5100644 025423 025423 00000000040 13242511133 00211516c0dd035603b432be46092e9ac8c7ceafreetds-1.00.82/doc/reference/a00520_ga0ed03c69e698336d015bb315ad755fd5_cgraph.svg100644 025423 025423 00000003117 13242511136 0021276 bcp_colfmt Node6 bcp_colfmt Node7 tdsdump_log Node6->Node7 freetds-1.00.82/doc/reference/a00520_ga220f6b043602da1028f98dacb2fd00c0_cgraph.map100644 025423 025423 00000000311 13242511134 0021262 freetds-1.00.82/doc/reference/a00520_ga220f6b043602da1028f98dacb2fd00c0_cgraph.md5100644 025423 025423 00000000040 13242511133 002117072587901043afa8307c2c15afcad8b43freetds-1.00.82/doc/reference/a00520_ga220f6b043602da1028f98dacb2fd00c0_cgraph.svg100644 025423 025423 00000003114 13242511136 0021312 bcp_getl Node29 bcp_getl Node30 tdsdump_log Node29->Node30 freetds-1.00.82/doc/reference/a00520_ga244547855b41788fa3a67756956fbc81_cgraph.map100644 025423 025423 00000000317 13242511134 0021003 freetds-1.00.82/doc/reference/a00520_ga244547855b41788fa3a67756956fbc81_cgraph.md5100644 025423 025423 00000000040 13242511133 0020703b721a3c91ca67a4bc05e4b623ffc7b61freetds-1.00.82/doc/reference/a00520_ga244547855b41788fa3a67756956fbc81_cgraph.svg100644 025423 025423 00000003133 13242511136 0021026 bcp_control Node21 bcp_control Node22 tdsdump_log Node21->Node22 freetds-1.00.82/doc/reference/a00520_ga330b9f1028f856a9eec5115550bcb4f7_cgraph.map100644 025423 025423 00000000317 13242511134 0021247 freetds-1.00.82/doc/reference/a00520_ga330b9f1028f856a9eec5115550bcb4f7_cgraph.md5100644 025423 025423 00000000040 13242511133 0021147da566b28ceadd9c0fd0b805153239803freetds-1.00.82/doc/reference/a00520_ga330b9f1028f856a9eec5115550bcb4f7_cgraph.svg100644 025423 025423 00000003132 13242511136 0021271 bcp_columns Node18 bcp_columns Node19 tdsdump_log Node18->Node19 freetds-1.00.82/doc/reference/a00520_ga6498235e4ef8e41ea43b01494b28998d_cgraph.map100644 025423 025423 00000000315 13242511134 0021133 freetds-1.00.82/doc/reference/a00520_ga6498235e4ef8e41ea43b01494b28998d_cgraph.md5100644 025423 025423 00000000040 13242511133 00210359931ac0d4bbea48b21d839ee62e0080dfreetds-1.00.82/doc/reference/a00520_ga6498235e4ef8e41ea43b01494b28998d_cgraph.svg100644 025423 025423 00000003125 13242511136 0021161 bcp_colptr Node15 bcp_colptr Node16 tdsdump_log Node15->Node16 freetds-1.00.82/doc/reference/a00520_ga6cf03708baaf02eb016b9ee77160d879_cgraph.map100644 025423 025423 00000000311 13242511134 0021322 freetds-1.00.82/doc/reference/a00520_ga6cf03708baaf02eb016b9ee77160d879_cgraph.md5100644 025423 025423 00000000040 13242511133 0021230c62013e8f704067d6fcb57920b1fdbc7freetds-1.00.82/doc/reference/a00520_ga6cf03708baaf02eb016b9ee77160d879_cgraph.svg100644 025423 025423 00000003105 13242511136 0021352 bcp_bind Node3 bcp_bind Node4 tdsdump_log Node3->Node4 freetds-1.00.82/doc/reference/a00520_ga8b85f79f53a62ac7a728fe626d609b65_cgraph.map100644 025423 025423 00000000311 13242511134 0021273 freetds-1.00.82/doc/reference/a00520_ga8b85f79f53a62ac7a728fe626d609b65_cgraph.md5100644 025423 025423 00000000040 13242511133 0021201ba81bfaccf563180800562ff12c8cfdffreetds-1.00.82/doc/reference/a00520_ga8b85f79f53a62ac7a728fe626d609b65_cgraph.svg100644 025423 025423 00000003117 13242511136 0021326 bcp_done Node24 bcp_done Node25 tdsdump_log Node24->Node25 freetds-1.00.82/doc/reference/a00520_ga963c5e38bca7668afc57f5cc123d10fb_cgraph.map100644 025423 025423 00000000317 13242511134 0021474 freetds-1.00.82/doc/reference/a00520_ga963c5e38bca7668afc57f5cc123d10fb_cgraph.md5100644 025423 025423 00000000040 13242511133 0021374292022359678dc293fe02be5c1a57786freetds-1.00.82/doc/reference/a00520_ga963c5e38bca7668afc57f5cc123d10fb_cgraph.svg100644 025423 025423 00000003133 13242511136 0021517 bcp_readfmt Node38 bcp_readfmt Node39 tdsdump_log Node38->Node39 freetds-1.00.82/doc/reference/a00520_gaa23f8e5c7f437a94746c90292dd1cb01_cgraph.map100644 025423 025423 00000000313 13242511134 0021246 freetds-1.00.82/doc/reference/a00520_gaa23f8e5c7f437a94746c90292dd1cb01_cgraph.md5100644 025423 025423 00000000040 13242511133 0021152f5317fd6dda5996557ab049a7c069cb4freetds-1.00.82/doc/reference/a00520_gaa23f8e5c7f437a94746c90292dd1cb01_cgraph.svg100644 025423 025423 00000003112 13242511136 0021272 bcp_batch Node0 bcp_batch Node1 tdsdump_log Node0->Node1 freetds-1.00.82/doc/reference/a00520_gada8e987c4a6225b9276c05ba3a4f47a0_cgraph.map100644 025423 025423 00000000311 13242511134 0021321 freetds-1.00.82/doc/reference/a00520_gada8e987c4a6225b9276c05ba3a4f47a0_cgraph.md5100644 025423 025423 00000000040 13242511133 0021227810070ee1f916a142451c2542ebc552efreetds-1.00.82/doc/reference/a00520_gada8e987c4a6225b9276c05ba3a4f47a0_cgraph.svg100644 025423 025423 00000003117 13242511136 0021354 bcp_init Node32 bcp_init Node33 tdsdump_log Node32->Node33 freetds-1.00.82/doc/reference/a00520_gae41d196a22c544d66212dacc5b555791_cgraph.map100644 025423 025423 00000000315 13242511134 0021157 freetds-1.00.82/doc/reference/a00520_gae41d196a22c544d66212dacc5b555791_cgraph.md5100644 025423 025423 00000000040 13242511133 002106154a35b0e93063941ae4dc903506de94bfreetds-1.00.82/doc/reference/a00520_gae41d196a22c544d66212dacc5b555791_cgraph.svg100644 025423 025423 00000003127 13242511136 0021207 bcp_collen Node12 bcp_collen Node13 tdsdump_log Node12->Node13 freetds-1.00.82/doc/reference/a00520_gaf1130ac97f6af55e86ec70b0aa4f5b40_cgraph.map100644 025423 025423 00000000317 13242511134 0021456 freetds-1.00.82/doc/reference/a00520_gaf1130ac97f6af55e86ec70b0aa4f5b40_cgraph.md5100644 025423 025423 00000000040 13242511133 00213565f65d57dc297a1dc0427b65b0139b635freetds-1.00.82/doc/reference/a00520_gaf1130ac97f6af55e86ec70b0aa4f5b40_cgraph.svg100644 025423 025423 00000003130 13242511136 0021476 bcp_sendrow Node41 bcp_sendrow Node42 tdsdump_log Node41->Node42 freetds-1.00.82/doc/reference/a00520_gaf13b2bb12b4200752718f3a3face3870_cgraph.map100644 025423 025423 00000000323 13242511134 0021215 freetds-1.00.82/doc/reference/a00520_gaf13b2bb12b4200752718f3a3face3870_cgraph.md5100644 025423 025423 00000000040 13242511133 0021120af80619cd012b675fe60c0840644677cfreetds-1.00.82/doc/reference/a00520_gaf13b2bb12b4200752718f3a3face3870_cgraph.svg100644 025423 025423 00000003133 13242511136 0021243 bcp_colfmt_ps Node9 bcp_colfmt_ps Node10 tdsdump_log Node9->Node10 freetds-1.00.82/doc/reference/a00520_gafec3feb5bac1cb33545ba01efb0a67b8_cgraph.map100644 025423 025423 00000000317 13242511134 0021743 freetds-1.00.82/doc/reference/a00520_gafec3feb5bac1cb33545ba01efb0a67b8_cgraph.md5100644 025423 025423 00000000040 13242511133 00216438ac418225fdd5e186f1dad5ba670503cfreetds-1.00.82/doc/reference/a00520_gafec3feb5bac1cb33545ba01efb0a67b8_cgraph.svg100644 025423 025423 00000003131 13242511136 0021764 bcp_options Node35 bcp_options Node36 tdsdump_log Node35->Node36 freetds-1.00.82/doc/reference/a00521.html100644 025423 025423 00000114036 13242511136 0013232 FreeTDS API: Internal bcp functions
    FreeTDS API
    Internal bcp functions

    Static functions internal to the bcp library. More...

    Collaboration diagram for Internal bcp functions:

    Functions

    static RETCODE _bcp_exec_in (DBPROCESS *dbproc, DBINT *rows_copied)
     
    static RETCODE _bcp_exec_out (DBPROCESS *dbproc, DBINT *rows_copied)
     
    static char * _bcp_fgets (char *buffer, int size, FILE *f)
     
    static void _bcp_free_columns (DBPROCESS *dbproc)
     
    static void _bcp_free_storage (DBPROCESS *dbproc)
     
    static TDSRET _bcp_get_col_data (TDSBCPINFO *bcpinfo, TDSCOLUMN *bindcol, int offset)
     For a bcp in from program variables, get the data from the host variable. More...
     
    static int _bcp_get_term_var (BYTE *pdata, BYTE *term, int term_len)
     Get the data for bcp-in from program variables, where the program data have been identified as character terminated, This is a low-level, internal function. More...
     
    static STATUS _bcp_read_hostfile (DBPROCESS *dbproc, FILE *hostfile, int *row_error)
     
    static int _bcp_readfmt_colinfo (DBPROCESS *dbproc, char *buf, BCP_HOSTCOLINFO *ci)
     
    static int rtrim (char *str, int len)
     trim a string of trailing blanks More...
     

    Detailed Description

    Static functions internal to the bcp library.

    Function Documentation

    § _bcp_exec_in()

    static RETCODE _bcp_exec_in ( DBPROCESS dbproc,
    DBINT *  rows_copied 
    )
    static
    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    rows_copied
    Returns
    SUCCEED or FAIL.
    See also
    BCP_SETL(), bcp_batch(), bcp_bind(), bcp_colfmt(), bcp_colfmt_ps(), bcp_collen(), bcp_colptr(), bcp_columns(), bcp_control(), bcp_done(), bcp_exec(), bcp_getl(), bcp_init(), bcp_moretext(), bcp_options(), bcp_readfmt(), bcp_sendrow()
    Here is the call graph for this function:

    § _bcp_exec_out()

    static RETCODE _bcp_exec_out ( DBPROCESS dbproc,
    DBINT *  rows_copied 
    )
    static
    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    rows_copied
    Returns
    SUCCEED or FAIL.
    See also
    BCP_SETL(), bcp_batch(), bcp_bind(), bcp_colfmt(), bcp_colfmt_ps(), bcp_collen(), bcp_colptr(), bcp_columns(), bcp_control(), bcp_done(), bcp_exec(), bcp_getl(), bcp_init(), bcp_moretext(), bcp_options(), bcp_readfmt(), bcp_sendrow()
    Here is the call graph for this function:

    § _bcp_fgets()

    static char* _bcp_fgets ( char *  buffer,
    int  size,
    FILE *  f 
    )
    static

    § _bcp_free_columns()

    static void _bcp_free_columns ( DBPROCESS dbproc)
    static
    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    Here is the call graph for this function:

    § _bcp_free_storage()

    static void _bcp_free_storage ( DBPROCESS dbproc)
    static
    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    See also
    bcp_done(), bcp_exec(), bcp_init()
    Here is the call graph for this function:

    § _bcp_get_col_data()

    static TDSRET _bcp_get_col_data ( TDSBCPINFO bcpinfo,
    TDSCOLUMN bindcol,
    int  offset 
    )
    static

    For a bcp in from program variables, get the data from the host variable.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    bindcol
    Returns
    TDS_SUCCESS or TDS_FAIL.
    See also
    _bcp_add_fixed_columns, _bcp_add_variable_columns, _bcp_send_bcp_record
    Here is the call graph for this function:

    § _bcp_get_term_var()

    static int _bcp_get_term_var ( BYTE *  pdata,
    BYTE *  term,
    int  term_len 
    )
    static

    Get the data for bcp-in from program variables, where the program data have been identified as character terminated, This is a low-level, internal function.

    Call it correctly.

    Parameters
    pdata
    term
    term_len
    Returns
    data length.

    § _bcp_read_hostfile()

    static STATUS _bcp_read_hostfile ( DBPROCESS dbproc,
    FILE *  hostfile,
    int *  row_error 
    )
    static
    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    hostfile
    row_error
    Returns
    MORE_ROWS, NO_MORE_ROWS, or FAIL.
    See also
    BCP_SETL(), bcp_batch(), bcp_bind(), bcp_colfmt(), bcp_colfmt_ps(), bcp_collen(), bcp_colptr(), bcp_columns(), bcp_control(), bcp_done(), bcp_exec(), bcp_getl(), bcp_init(), bcp_moretext(), bcp_options(), bcp_readfmt(), bcp_sendrow()
    Here is the call graph for this function:

    § _bcp_readfmt_colinfo()

    static int _bcp_readfmt_colinfo ( DBPROCESS dbproc,
    char *  buf,
    BCP_HOSTCOLINFO ci 
    )
    static
    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    buf
    ci
    Returns
    SUCCEED or FAIL.
    See also
    BCP_SETL(), bcp_batch(), bcp_bind(), bcp_colfmt(), bcp_colfmt_ps(), bcp_collen(), bcp_colptr(), bcp_columns(), bcp_control(), bcp_done(), bcp_exec(), bcp_getl(), bcp_init(), bcp_moretext(), bcp_options(), bcp_readfmt(), bcp_sendrow()
    Here is the call graph for this function:

    § rtrim()

    static int rtrim ( char *  str,
    int  len 
    )
    static

    trim a string of trailing blanks

    Replaces spaces at the end of a string with NULs

    Parameters
    strpointer to a character buffer (not null-terminated)
    lensize of the str in bytes
    Returns
    modified length
    freetds-1.00.82/doc/reference/a00521.map100644 025423 025423 00000000341 13242511134 0013032 freetds-1.00.82/doc/reference/a00521.md5100644 025423 025423 00000000040 13242511133 0012735815eab488d0bc9de80741be62ce270ddfreetds-1.00.82/doc/reference/a00521.svg100644 025423 025423 00000003146 13242511136 0013064 Internal bcp functions Node0 Internal bcp functions Node1 Bulk copy functions Node1->Node0 freetds-1.00.82/doc/reference/a00521_ga065757a7d0dce354660900de4aa79e2f_cgraph.map100644 025423 025423 00000000335 13242511134 0021253 freetds-1.00.82/doc/reference/a00521_ga065757a7d0dce354660900de4aa79e2f_cgraph.md5100644 025423 025423 00000000040 13242511133 0021153c282a4a1bdccfe8dbec1b05c96e00da7freetds-1.00.82/doc/reference/a00521_ga065757a7d0dce354660900de4aa79e2f_cgraph.svg100644 025423 025423 00000003162 13242511136 0021300 _bcp_read_hostfile Node19 _bcp_read_hostfile Node20 tdsdump_log Node19->Node20 freetds-1.00.82/doc/reference/a00521_ga0f8def4cad04c5c1e27c2b653d482dd8_cgraph.map100644 025423 025423 00000000333 13242511134 0021544 freetds-1.00.82/doc/reference/a00522.html100644 025423 025423 00000144566 13242511136 0013246 FreeTDS API: Money functions
    FreeTDS API
    Money functions

    Functions to manipulate the MONEY datatype. More...

    Collaboration diagram for Money functions:

    Functions

    RETCODE dbmny4add (DBPROCESS *dbproc, DBMONEY4 *m1, DBMONEY4 *m2, DBMONEY4 *sum)
     Add two DBMONEY4 values. More...
     
    int dbmny4cmp (DBPROCESS *dbproc, DBMONEY4 *m1, DBMONEY4 *m2)
     Compare two DBMONEY4 values. More...
     
    RETCODE dbmny4copy (DBPROCESS *dbproc, DBMONEY4 *src, DBMONEY4 *dest)
     Copy a DBMONEY4 value. More...
     
    RETCODE dbmny4minus (DBPROCESS *dbproc, DBMONEY4 *src, DBMONEY4 *dest)
     Negate a DBMONEY4 value. More...
     
    RETCODE dbmny4sub (DBPROCESS *dbproc, DBMONEY4 *m1, DBMONEY4 *m2, DBMONEY4 *diff)
     Subtract two DBMONEY4 values. More...
     
    RETCODE dbmny4zero (DBPROCESS *dbproc, DBMONEY4 *dest)
     Zero a DBMONEY4 value. More...
     
    int dbmnycmp (DBPROCESS *dbproc, DBMONEY *m1, DBMONEY *m2)
     Compare two DBMONEY values. More...
     
    RETCODE dbmnycopy (DBPROCESS *dbproc, DBMONEY *src, DBMONEY *dest)
     Copy a DBMONEY value. More...
     
    RETCODE dbmnydec (DBPROCESS *dbproc, DBMONEY *amount)
     Subtract $0.0001 from a DBMONEY value. More...
     
    RETCODE dbmnyinc (DBPROCESS *dbproc, DBMONEY *amount)
     Add $0.0001 to a DBMONEY value. More...
     
    RETCODE dbmnymaxneg (DBPROCESS *dbproc, DBMONEY *amount)
     Get maximum negative DBMONEY value supported. More...
     
    RETCODE dbmnymaxpos (DBPROCESS *dbproc, DBMONEY *amount)
     Get maximum positive DBMONEY value supported. More...
     
    RETCODE dbmnyminus (DBPROCESS *dbproc, DBMONEY *src, DBMONEY *dest)
     Negate a DBMONEY value. More...
     
    RETCODE dbmnyzero (DBPROCESS *dbproc, DBMONEY *dest)
     Set a DBMONEY value to zero. More...
     

    Detailed Description

    Functions to manipulate the MONEY datatype.

    Function Documentation

    § dbmny4add()

    RETCODE dbmny4add ( DBPROCESS dbproc,
    DBMONEY4 m1,
    DBMONEY4 m2,
    DBMONEY4 sum 
    )

    Add two DBMONEY4 values.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    m1first operand.
    m2other operand.
    sumoutput: result of computation.
    Return values
    SUCCEEDusually.
    FAILon overflow.
    See also
    dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus().
    Here is the call graph for this function:

    § dbmny4cmp()

    int dbmny4cmp ( DBPROCESS dbproc,
    DBMONEY4 m1,
    DBMONEY4 m2 
    )

    Compare two DBMONEY4 values.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    m1some money.
    m2some other money.
    Return values
    0m1 == m2.
    -1m1 < m2.
    1m1 > m2.
    See also
    dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus().
    Here is the call graph for this function:

    § dbmny4copy()

    RETCODE dbmny4copy ( DBPROCESS dbproc,
    DBMONEY4 src,
    DBMONEY4 dest 
    )

    Copy a DBMONEY4 value.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    srcaddress of a DBMONEY4 structure.
    destoutput: new money.
    Return values
    SUCCEEDor FAIL if src/dest NULL.
    See also
    dbmnycopy(), dbmnyminus(), dbmny4minus().
    Here is the call graph for this function:

    § dbmny4minus()

    RETCODE dbmny4minus ( DBPROCESS dbproc,
    DBMONEY4 src,
    DBMONEY4 dest 
    )

    Negate a DBMONEY4 value.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    srcaddress of a DBMONEY4 structure.
    destoutput: result of negation.
    Return values
    SUCCEEDusually.
    FAILon overflow.
    See also
    dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus().
    Here is the call graph for this function:

    § dbmny4sub()

    RETCODE dbmny4sub ( DBPROCESS dbproc,
    DBMONEY4 m1,
    DBMONEY4 m2,
    DBMONEY4 diff 
    )

    Subtract two DBMONEY4 values.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    m1first operand.
    m2other operand, subtracted from m1.
    diffoutput: result of computation.
    Return values
    SUCCEEDusually.
    FAILon overflow.
    See also
    dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus().
    Here is the call graph for this function:

    § dbmny4zero()

    RETCODE dbmny4zero ( DBPROCESS dbproc,
    DBMONEY4 dest 
    )

    Zero a DBMONEY4 value.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    destaddress of a DBMONEY structure.
    Return values
    SUCCEEDusually.
    FAILdest is NULL.
    See also
    dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus().
    Here is the call graph for this function:

    § dbmnycmp()

    int dbmnycmp ( DBPROCESS dbproc,
    DBMONEY m1,
    DBMONEY m2 
    )

    Compare two DBMONEY values.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    m1some money.
    m2some other money.
    Return values
    0m1 == m2.
    -1m1 < m2.
    1m1 > m2.
    See also
    dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus().
    Here is the call graph for this function:

    § dbmnycopy()

    RETCODE dbmnycopy ( DBPROCESS dbproc,
    DBMONEY src,
    DBMONEY dest 
    )

    Copy a DBMONEY value.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    srcaddress of a DBMONEY structure.
    destoutput: new money.
    Return values
    SUCCEEDalways, unless src or dest is NULL.
    See also
    Here is the call graph for this function:

    § dbmnydec()

    RETCODE dbmnydec ( DBPROCESS dbproc,
    DBMONEY amount 
    )

    Subtract $0.0001 from a DBMONEY value.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    amountaddress of a DBMONEY structure.
    Return values
    SUCCEEDor FAIL if overflow or amount NULL.
    See also
    dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus().
    Here is the call graph for this function:

    § dbmnyinc()

    RETCODE dbmnyinc ( DBPROCESS dbproc,
    DBMONEY amount 
    )

    Add $0.0001 to a DBMONEY value.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    amountaddress of a DBMONEY structure.
    Return values
    SUCCEEDor FAIL if overflow or amount NULL.
    See also
    dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus().
    Here is the call graph for this function:

    § dbmnymaxneg()

    RETCODE dbmnymaxneg ( DBPROCESS dbproc,
    DBMONEY amount 
    )

    Get maximum negative DBMONEY value supported.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    amountaddress of a DBMONEY structure.
    Return values
    SUCCEEDAlways.
    See also
    dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus().
    Here is the call graph for this function:

    § dbmnymaxpos()

    RETCODE dbmnymaxpos ( DBPROCESS dbproc,
    DBMONEY amount 
    )

    Get maximum positive DBMONEY value supported.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    amountaddress of a DBMONEY structure.
    Return values
    SUCCEEDAlways.
    See also
    dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus().
    Here is the call graph for this function:

    § dbmnyminus()

    RETCODE dbmnyminus ( DBPROCESS dbproc,
    DBMONEY src,
    DBMONEY dest 
    )

    Negate a DBMONEY value.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    srcaddress of a DBMONEY structure.
    destoutput: result of negation.
    Return values
    SUCCEEDor FAIL if overflow or src/dest NULL.
    See also
    dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus().
    Here is the call graph for this function:

    § dbmnyzero()

    RETCODE dbmnyzero ( DBPROCESS dbproc,
    DBMONEY dest 
    )

    Set a DBMONEY value to zero.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    destaddress of a DBMONEY structure.
    Return values
    SUCCEEDunless amount is NULL.
    See also
    dbmnyadd(), dbmnysub(), dbmnymul(), dbmnydivide(), dbmnyminus(), dbmny4add(), dbmny4sub(), dbmny4mul(), dbmny4divide(), dbmny4minus().
    Here is the call graph for this function:
    freetds-1.00.82/doc/reference/a00522.map100644 025423 025423 00000000303 13242511134 0013031 freetds-1.00.82/doc/reference/a00521_ga0f8def4cad04c5c1e27c2b653d482dd8_cgraph.md5100644 025423 025423 00000000040 13242511133 0021446c2b709dc2cfcb52e2c81da6dac5126fffreetds-1.00.82/doc/reference/a00521_ga0f8def4cad04c5c1e27c2b653d482dd8_cgraph.svg100644 025423 025423 00000003157 13242511136 0021577 _bcp_get_col_data Node14 _bcp_get_col_data Node15 tdsdump_log Node14->Node15 freetds-1.00.82/doc/reference/a00521_ga7370f1223f13510d6b33e98f2de09fb5_cgraph.map100644 025423 025423 00000000321 13242511134 0021161 freetds-1.00.82/doc/reference/a00521_ga7370f1223f13510d6b33e98f2de09fb5_cgraph.md5100644 025423 025423 00000000040 13242511133 0021066d2be1b147a50e38992c44f8b7491d2bafreetds-1.00.82/doc/reference/a00521_ga7370f1223f13510d6b33e98f2de09fb5_cgraph.svg100644 025423 025423 00000003124 13242511136 0021211 _bcp_exec_in Node0 _bcp_exec_in Node1 tdsdump_log Node0->Node1 freetds-1.00.82/doc/reference/a00521_gaa134c1c3ccc4326e693adb8357272f1d_cgraph.map100644 025423 025423 00000000333 13242511134 0021314 freetds-1.00.82/doc/reference/a00521_gaa134c1c3ccc4326e693adb8357272f1d_cgraph.md5100644 025423 025423 00000000040 13242511133 0021216c704f899cfe8bd9e22af326c0b197a68freetds-1.00.82/doc/reference/a00521_gaa134c1c3ccc4326e693adb8357272f1d_cgraph.svg100644 025423 025423 00000003155 13242511136 0021345 _bcp_free_storage Node11 _bcp_free_storage Node12 tdsdump_log Node11->Node12 freetds-1.00.82/doc/reference/a00521_gacf69ac4cbe8e3c3e6ea665e31e5e85b8_cgraph.map100644 025423 025423 00000000333 13242511134 0021647 freetds-1.00.82/doc/reference/a00521_gacf69ac4cbe8e3c3e6ea665e31e5e85b8_cgraph.md5100644 025423 025423 00000000040 13242511133 0021551377c968b7aabf6db19fc1d14bfe1af99freetds-1.00.82/doc/reference/a00521_gacf69ac4cbe8e3c3e6ea665e31e5e85b8_cgraph.svg100644 025423 025423 00000003144 13242511136 0021676 _bcp_free_columns Node8 _bcp_free_columns Node9 tdsdump_log Node8->Node9 freetds-1.00.82/doc/reference/a00521_gae67546338cb9542a4902aa914f57f314_cgraph.map100644 025423 025423 00000000323 13242511134 0021035 freetds-1.00.82/doc/reference/a00521_gae67546338cb9542a4902aa914f57f314_cgraph.md5100644 025423 025423 00000000040 13242511133 00207403ca1b695effef334c2b1f39dda223c5dfreetds-1.00.82/doc/reference/a00521_gae67546338cb9542a4902aa914f57f314_cgraph.svg100644 025423 025423 00000003127 13242511136 0021066 _bcp_exec_out Node3 _bcp_exec_out Node4 tdsdump_log Node3->Node4 freetds-1.00.82/doc/reference/a00521_gafc23d62bc86b38fb757e3ac4aadca0a4_cgraph.map100644 025423 025423 00000000341 13242511134 0021671 freetds-1.00.82/doc/reference/a00521_gafc23d62bc86b38fb757e3ac4aadca0a4_cgraph.md5100644 025423 025423 00000000040 13242511133 00215741bb25c7e7ebaa7f0756bb5b88a075b5dfreetds-1.00.82/doc/reference/a00521_gafc23d62bc86b38fb757e3ac4aadca0a4_cgraph.svg100644 025423 025423 00000003166 13242511136 0021725 _bcp_readfmt_colinfo Node22 _bcp_readfmt_colinfo Node23 tdsdump_log Node22->Node23 freetds-1.00.82/doc/reference/a00522.md5100644 025423 025423 00000000040 13242511133 0012736a3e1a1c0ce43cf58d9cd0ed4374956c2freetds-1.00.82/doc/reference/a00522.svg100644 025423 025423 00000003072 13242511136 0013063 Money functions Node1 The db-lib API Node0 Money functions Node1->Node0 freetds-1.00.82/doc/reference/a00522_ga070e94f72f12c138a16a7bcdf732fa8b_cgraph.map100644 025423 025423 00000000315 13242511134 0021403 freetds-1.00.82/doc/reference/a00522_ga070e94f72f12c138a16a7bcdf732fa8b_cgraph.md5100644 025423 025423 00000000040 13242511133 0021305186b36b92aaf7f094286540301e49dc5freetds-1.00.82/doc/reference/a00522_ga070e94f72f12c138a16a7bcdf732fa8b_cgraph.svg100644 025423 025423 00000003126 13242511136 0021432 dbmny4zero Node15 dbmny4zero Node16 tdsdump_log Node15->Node16 freetds-1.00.82/doc/reference/a00522_ga0a384938a6586b7411fc42420ffad6ed_cgraph.map100644 025423 025423 00000000313 13242511134 0021247 freetds-1.00.82/doc/reference/a00522_ga0a384938a6586b7411fc42420ffad6ed_cgraph.md5100644 025423 025423 00000000040 13242511133 0021153af4787e8c9ea18732bd16d1241aade5bfreetds-1.00.82/doc/reference/a00522_ga0a384938a6586b7411fc42420ffad6ed_cgraph.svg100644 025423 025423 00000003115 13242511136 0021276 dbmny4add Node0 dbmny4add Node1 tdsdump_log Node0->Node1 freetds-1.00.82/doc/reference/a00523.html100644 025423 025423 00000024776 13242511136 0013247 FreeTDS API: Datetime functions
    FreeTDS API
    Datetime functions

    Functions to manipulate DBDATETIME structures. More...

    Collaboration diagram for Datetime functions:

    Functions

    int dbdatecmp (DBPROCESS *dbproc, DBDATETIME *d1, DBDATETIME *d2)
     Compare DBDATETIME values, similar to strcmp(3). More...
     
    const char * dbmonthname (DBPROCESS *dbproc, char *language, int monthnum, DBBOOL shortform)
     Get name of a month, in some human language. More...
     

    Detailed Description

    Functions to manipulate DBDATETIME structures.

    Defined by Sybase only. These are not implemented:

    • dbdate4cmp()
    • dbdate4zero()
    • dbdatechar()
    • dbdatename()
    • dbdateorder()
    • dbdatepart()
    • dbdatezero()
    • dbdayname()

    Function Documentation

    § dbdatecmp()

    int dbdatecmp ( DBPROCESS dbproc,
    DBDATETIME d1,
    DBDATETIME d2 
    )

    Compare DBDATETIME values, similar to strcmp(3).

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    d1a DBDATETIME structure address
    d2another DBDATETIME structure address
    Return values
    0d1 = d2.
    -1d1 < d2.
    1d1 > d2.
    See also
    dbdate4cmp(), dbmnycmp(), dbmny4cmp().
    Here is the call graph for this function:

    § dbmonthname()

    const char* dbmonthname ( DBPROCESS dbproc,
    char *  language,
    int  monthnum,
    DBBOOL  shortform 
    )

    Get name of a month, in some human language.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    languageignored.
    monthnumnumber of the month, starting with 1.
    shortformset to TRUE for a three letter output ("Jan" - "Dec"), else zero.
    Returns
    address of null-terminated ASCII string, or NULL on error.
    See also
    db12hour(), dbdateorder(), dbdayname(), DBSETLNATLANG(), dbsetopt().
    Here is the call graph for this function:
    freetds-1.00.82/doc/reference/a00522_ga109d4868baccb08fad3b26b6f031dc78_cgraph.map100644 025423 025423 00000000313 13242511134 0021460 freetds-1.00.82/doc/reference/a00522_ga109d4868baccb08fad3b26b6f031dc78_cgraph.md5100644 025423 025423 00000000040 13242511133 002136456c3f83d6179e991e8fd03c475ace478freetds-1.00.82/doc/reference/a00522_ga109d4868baccb08fad3b26b6f031dc78_cgraph.svg100644 025423 025423 00000003115 13242511136 0021507 dbmny4cmp Node3 dbmny4cmp Node4 tdsdump_log Node3->Node4 freetds-1.00.82/doc/reference/a00522_ga70ca2474f6c93acd6e3b842330b712c7_cgraph.map100644 025423 025423 00000000317 13242511134 0021242 freetds-1.00.82/doc/reference/a00522_ga70ca2474f6c93acd6e3b842330b712c7_cgraph.md5100644 025423 025423 00000000040 13242511133 00211426422bcb81f0417946a76543c1ce291fffreetds-1.00.82/doc/reference/a00522_ga70ca2474f6c93acd6e3b842330b712c7_cgraph.svg100644 025423 025423 00000003131 13242511136 0021263 dbmnymaxpos Node33 dbmnymaxpos Node34 tdsdump_log Node33->Node34 freetds-1.00.82/doc/reference/a00522_ga76177eb61a67dd52424236aba1b16bc9_cgraph.map100644 025423 025423 00000000317 13242511134 0021241 freetds-1.00.82/doc/reference/a00522_ga76177eb61a67dd52424236aba1b16bc9_cgraph.md5100644 025423 025423 00000000040 13242511133 00211413fe6131ddc87149b4ba1cfb47f61deaffreetds-1.00.82/doc/reference/a00522_ga76177eb61a67dd52424236aba1b16bc9_cgraph.svg100644 025423 025423 00000003124 13242511136 0021264 dbmny4minus Node9 dbmny4minus Node10 tdsdump_log Node9->Node10 freetds-1.00.82/doc/reference/a00522_ga826bca98da4fd1c3188da45c383c3a68_cgraph.map100644 025423 025423 00000000315 13242511134 0021415 freetds-1.00.82/doc/reference/a00522_ga826bca98da4fd1c3188da45c383c3a68_cgraph.md5100644 025423 025423 00000000040 13242511133 00213174ae7c86700429cd4bac2b343f3e3a2d8freetds-1.00.82/doc/reference/a00522_ga826bca98da4fd1c3188da45c383c3a68_cgraph.svg100644 025423 025423 00000003126 13242511136 0021444 dbmnyminus Node36 dbmnyminus Node37 tdsdump_log Node36->Node37 freetds-1.00.82/doc/reference/a00522_ga856143f4f9c7a5c15fb15633af81487d_cgraph.map100644 025423 025423 00000000313 13242511134 0021203 freetds-1.00.82/doc/reference/a00522_ga856143f4f9c7a5c15fb15633af81487d_cgraph.md5100644 025423 025423 00000000040 13242511133 002110775240972ad1c02a209ab35256fcaac26freetds-1.00.82/doc/reference/a00522_ga856143f4f9c7a5c15fb15633af81487d_cgraph.svg100644 025423 025423 00000003124 13242511136 0021232 dbmny4sub Node12 dbmny4sub Node13 tdsdump_log Node12->Node13 freetds-1.00.82/doc/reference/a00522_ga8eab0959d5a3cd534487b350258c939e_cgraph.map100644 025423 025423 00000000313 13242511134 0021205 freetds-1.00.82/doc/reference/a00522_ga8eab0959d5a3cd534487b350258c939e_cgraph.md5100644 025423 025423 00000000040 13242511133 00211119a1d634d0b6a6106529c2697b7fab87cfreetds-1.00.82/doc/reference/a00522_ga8eab0959d5a3cd534487b350258c939e_cgraph.svg100644 025423 025423 00000003122 13242511136 0021232 dbmnyzero Node39 dbmnyzero Node40 tdsdump_log Node39->Node40 freetds-1.00.82/doc/reference/a00522_ga8f1e9aa0280c1cb46c10e5c90b8faced_cgraph.map100644 025423 025423 00000000313 13242511134 0021610 freetds-1.00.82/doc/reference/a00522_ga8f1e9aa0280c1cb46c10e5c90b8faced_cgraph.md5100644 025423 025423 00000000040 13242511133 0021514001d9a3775f5c678a9aa882242ccd9e1freetds-1.00.82/doc/reference/a00522_ga8f1e9aa0280c1cb46c10e5c90b8faced_cgraph.svg100644 025423 025423 00000003123 13242511136 0021636 dbmnycopy Node21 dbmnycopy Node22 tdsdump_log Node21->Node22 freetds-1.00.82/doc/reference/a00522_gaa6d4c700b628f6a18a9d1ed9f8e2ba62_cgraph.map100644 025423 025423 00000000315 13242511134 0021471 freetds-1.00.82/doc/reference/a00522_gaa6d4c700b628f6a18a9d1ed9f8e2ba62_cgraph.md5100644 025423 025423 00000000040 13242511133 00213731b43c81109a34f3a59bb23df866034cafreetds-1.00.82/doc/reference/a00522_gaa6d4c700b628f6a18a9d1ed9f8e2ba62_cgraph.svg100644 025423 025423 00000003115 13242511136 0021516 dbmny4copy Node6 dbmny4copy Node7 tdsdump_log Node6->Node7 freetds-1.00.82/doc/reference/a00522_gabc3cb44d33bf1b9b18fd59f23e4da722_cgraph.map100644 025423 025423 00000000317 13242511134 0021543 freetds-1.00.82/doc/reference/a00522_gabc3cb44d33bf1b9b18fd59f23e4da722_cgraph.md5100644 025423 025423 00000000040 13242511133 002144397d0ad976aebcf65116358d45e58fff9freetds-1.00.82/doc/reference/a00522_gabc3cb44d33bf1b9b18fd59f23e4da722_cgraph.svg100644 025423 025423 00000003133 13242511136 0021566 dbmnymaxneg Node30 dbmnymaxneg Node31 tdsdump_log Node30->Node31 freetds-1.00.82/doc/reference/a00522_gabedce74748a31ea8a6e4068a5d44d8e4_cgraph.map100644 025423 025423 00000000311 13242511134 0021474 freetds-1.00.82/doc/reference/a00522_gabedce74748a31ea8a6e4068a5d44d8e4_cgraph.md5100644 025423 025423 00000000040 13242511133 00214020a564de62f6b31f308cb35f3a4f9b443freetds-1.00.82/doc/reference/a00522_gabedce74748a31ea8a6e4068a5d44d8e4_cgraph.svg100644 025423 025423 00000003117 13242511136 0021527 dbmnydec Node24 dbmnydec Node25 tdsdump_log Node24->Node25 freetds-1.00.82/doc/reference/a00522_gabf5216aaaa59ea7e7f07899f82a27faf_cgraph.map100644 025423 025423 00000000311 13242511134 0021562 freetds-1.00.82/doc/reference/a00522_gabf5216aaaa59ea7e7f07899f82a27faf_cgraph.md5100644 025423 025423 00000000040 13242511133 00214708e534583f8caf13907cb28b3688a0ee9freetds-1.00.82/doc/reference/a00522_gabf5216aaaa59ea7e7f07899f82a27faf_cgraph.svg100644 025423 025423 00000003117 13242511136 0021615 dbmnyinc Node27 dbmnyinc Node28 tdsdump_log Node27->Node28 freetds-1.00.82/doc/reference/a00522_gadddacad5c3028aa8d3726246c3825651_cgraph.map100644 025423 025423 00000000311 13242511134 0021312 freetds-1.00.82/doc/reference/a00522_gadddacad5c3028aa8d3726246c3825651_cgraph.md5100644 025423 025423 00000000040 13242511133 00212200e455bf35fd71deb6463227fe675e6ddfreetds-1.00.82/doc/reference/a00522_gadddacad5c3028aa8d3726246c3825651_cgraph.svg100644 025423 025423 00000003121 13242511136 0021340 dbmnycmp Node18 dbmnycmp Node19 tdsdump_log Node18->Node19 freetds-1.00.82/doc/reference/a00523.map100644 025423 025423 00000000311 13242511134 0013031 freetds-1.00.82/doc/reference/a00523.md5100644 025423 025423 00000000040 13242511133 0012737069372f21348347d14f264672b3bb891freetds-1.00.82/doc/reference/a00523.svg100644 025423 025423 00000003103 13242511136 0013057 Datetime functions Node1 The db-lib API Node0 Datetime functions Node1->Node0 freetds-1.00.82/doc/reference/a00523_ga129d2922d347121a6b312dd8e75ed6d2_cgraph.map100644 025423 025423 00000000313 13242511134 0021160 freetds-1.00.82/doc/reference/a00523_ga129d2922d347121a6b312dd8e75ed6d2_cgraph.md5100644 025423 025423 00000000040 13242511133 00210640fb71efe7d49089c9dc181ab1b530675freetds-1.00.82/doc/reference/a00523_ga129d2922d347121a6b312dd8e75ed6d2_cgraph.svg100644 025423 025423 00000003112 13242511136 0021204 dbdatecmp Node0 dbdatecmp Node1 tdsdump_log Node0->Node1 freetds-1.00.82/doc/reference/a00523_ga38ecd55ae5827bfa0fd12e2baf0950dd_cgraph.map100644 025423 025423 00000000317 13242511135 0021624 freetds-1.00.82/doc/reference/a00523_ga38ecd55ae5827bfa0fd12e2baf0950dd_cgraph.md5100644 025423 025423 00000000040 13242511133 002152341110a1efbdff3c948bab85c9e3ff7eafreetds-1.00.82/doc/reference/a00523_ga38ecd55ae5827bfa0fd12e2baf0950dd_cgraph.svg100644 025423 025423 00000003123 13242511136 0021645 dbmonthname Node3 dbmonthname Node4 tdsdump_log Node3->Node4 freetds-1.00.82/doc/reference/a00524.html100644 025423 025423 00000215523 13242511136 0013240 FreeTDS API: Internals
    FreeTDS API

    Functions called within db-lib for self-help. More...

    Collaboration diagram for Internals:

    Classes

    struct  _dblib_error_message
     

    Macros

    #define DBSETLLABELED(x, y)   dbsetlbool((x), (y), DBSETLABELED)
     Alternative way to set login packet fields. More...
     
    #define DBSETLVERSION(login, version)   dbsetlversion((login), (version))
     maps to the Microsoft (lower-case) function. More...
     

    Typedefs

    typedef struct _dblib_error_message DBLIB_ERROR_MESSAGE
     

    Functions

    static BYTE * _dbcoldata (TDSCOLUMN *colinfo)
     Return data from a column. More...
     
    int _dblib_check_and_handle_interrupt (void *vdbproc)
     check interrupts for libtds. More...
     
    RETCODE dbcmdrow (DBPROCESS *dbproc)
     See if the current command can return rows. More...
     
    static TDSCOLUMNdbcolptr (DBPROCESS *dbproc, int column)
     Sanity checks for column-oriented functions. More...
     
    int dbcurcmd (DBPROCESS *dbproc)
     Get number of the row just returned. More...
     
    DBINT dbcurrow (DBPROCESS *dbproc)
     Get number of the row currently being read. More...
     
    DBBOOL dbdead (DBPROCESS *dbproc)
     Check if dbproc is an ex-parrot. More...
     
    DBINT dbfirstrow (DBPROCESS *dbproc)
     See if a server response has arrived. More...
     
    int dbiordesc (DBPROCESS *dbproc)
     Get file descriptor of the socket used by a DBPROCESS to read data coming from the server. (!) More...
     
    int dbiowdesc (DBPROCESS *dbproc)
     Get file descriptor of the socket used by a DBPROCESS to write data coming to the server. (!) More...
     
    DBINT dblastrow (DBPROCESS *dbproc)
     Get number of the last row in the row buffer. More...
     
    int dbperror (DBPROCESS *dbproc, DBINT msgno, long errnum,...)
     Call client-installed error handler. More...
     
    RETCODE dbrows (DBPROCESS *dbproc)
     Indicate whether a query returned rows. More...
     
    STATUS dbrowtype (DBPROCESS *dbproc)
     Get returned row's type. More...
     
    void dbsetavail (DBPROCESS *dbproc)
     Mark a DBPROCESS as "available". More...
     
    RETCODE dbsetlbool (LOGINREC *login, int value, int which)
     Set a boolean value in a LOGINREC structure. More...
     
    RETCODE dbsetllong (LOGINREC *login, long value, int which)
     Set an integer value in a LOGINREC structure. More...
     
    RETCODE dbsetlname (LOGINREC *login, const char *value, int which)
     Set the value of a string in a LOGINREC structure. More...
     
    int dbtds (DBPROCESS *dbproc)
     Get the TDS version in use for dbproc. More...
     
    static int default_err_handler (DBPROCESS *dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr)
     default error handler for db-lib (handles library-generated errors) More...
     
    DBPROCESStdsdbopen (LOGINREC *login, const char *server, int msdblib)
     Form a connection with the server. More...
     

    Detailed Description

    Functions called within db-lib for self-help.

    These functions are of interest only to people hacking on the FreeTDS db-lib implementation.

    Macro Definition Documentation

    § DBSETLLABELED

    DBSETLLABELED (   x,
     
    )    dbsetlbool((x), (y), DBSETLABELED)

    Alternative way to set login packet fields.

    See also
    dbsetllabeled()

    § DBSETLVERSION

    DBSETLVERSION (   login,
      version 
    )    dbsetlversion((login), (version))

    maps to the Microsoft (lower-case) function.

    See also
    dbsetlversion()

    Typedef Documentation

    § DBLIB_ERROR_MESSAGE

    Remarks
    member msgno Vendor-defined message number
    member severity Is passed to the error handler
    member msgtext Text of message

    Function Documentation

    § _dbcoldata()

    static BYTE * _dbcoldata ( TDSCOLUMN colinfo)
    static

    Return data from a column.

    Parameters
    colinfocontains information on a result column.
    Returns
    pointer to the data, or NULL if data are NULL
    See also
    dbdata(), dbretdata()

    § _dblib_check_and_handle_interrupt()

    int _dblib_check_and_handle_interrupt ( void *  vdbproc)

    check interrupts for libtds.

    Parameters
    vdbproca DBPROCESS pointer, contains all information needed by db-lib to manage communications with the server.
    See also
    DBDEAD(), dbsetinterrupt().

    § dbcmdrow()

    RETCODE dbcmdrow ( DBPROCESS dbproc)

    See if the current command can return rows.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    Return values
    SUCCEEDYes, it can.
    FAILNo, it can't.
    Remarks
    Use DBCMDROW() macro instead.
    See also
    DBCMDROW(), dbnextrow(), dbresults(), DBROWS(), DBROWTYPE().
    Here is the call graph for this function:

    § dbcolptr()

    static TDSCOLUMN* dbcolptr ( DBPROCESS dbproc,
    int  column 
    )
    static

    Sanity checks for column-oriented functions.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    pcolinfoaddress of pointer to a TDSCOLUMN structure.
    Remarks
    Makes sure dbproc and the requested column are valid. Calls dbperror() if not.
    Returns
    appropriate error or SUCCEED
    Here is the call graph for this function:

    § dbcurcmd()

    int dbcurcmd ( DBPROCESS dbproc)

    Get number of the row just returned.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    See also
    DBCURROW().
    Todo:
    Unimplemented.
    Here is the call graph for this function:

    § dbcurrow()

    DBINT dbcurrow ( DBPROCESS dbproc)

    Get number of the row currently being read.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    Returns
    ostensibly the row number, or 0 if no rows have been read yet.
    Return values
    0Always.
    See also
    DBCURROW(), dbclrbuf(), DBFIRSTROW(), dbgetrow(), DBLASTROW(), dbnextrow(), dbsetopt(),.
    Todo:
    Unimplemented.
    Here is the call graph for this function:

    § dbdead()

    DBBOOL dbdead ( DBPROCESS dbproc)

    Check if dbproc is an ex-parrot.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    Return values
    TRUEprocess has been marked dead.
    FALSEprocess is OK.
    Remarks
    dbdead() does not communicate with the server. Unless a previously db-lib marked dbproc dead, dbdead() returns FALSE.
    See also
    dberrhandle().
    Here is the call graph for this function:

    § dbfirstrow()

    DBINT dbfirstrow ( DBPROCESS dbproc)

    See if a server response has arrived.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    millisecondshow long to wait for the server before returning:
    • 0 return immediately.
    • -1 do not return until the server responds or a system interrupt occurs.
    ready_dbprocoutput: DBPROCESS for which a response arrived, of NULL.
    return_reasonoutput:
    • DBRESULT server responded.
    • DBNOTIFICATION registered procedure notification has arrived. dbpoll() the registered handler, if any, before it returns.
    • DBTIMEOUT milliseconds elapsed before the server responded.
    • DBINTERRUPT operating-system interrupt occurred before the server responded.
    Return values
    SUCCEEDeverything worked.
    FAILa server connection died.
    See also
    DBIORDESC(), DBRBUF(), dbresults(), dbreghandle(), dbsqlok().
    Todo:
    Unimplemented.

    Get number of the first row in the row buffer.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    See also
    DBFIRSTROW(), dbclrbuf(), DBCURROW(), dbgetrow(), DBLASTROW(), dbnextrow(), dbsetopt().
    Here is the call graph for this function:

    § dbiordesc()

    int dbiordesc ( DBPROCESS dbproc)

    Get file descriptor of the socket used by a DBPROCESS to read data coming from the server. (!)

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    See also
    dbcmd(), DBIORDESC(), DBIOWDESC(), dbnextrow(), dbpoll(), DBRBUF(), dbresults(), dbsqlok(), dbsqlsend().
    Here is the call graph for this function:

    § dbiowdesc()

    int dbiowdesc ( DBPROCESS dbproc)

    Get file descriptor of the socket used by a DBPROCESS to write data coming to the server. (!)

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    See also
    dbcmd(), DBIORDESC(), DBIOWDESC(), dbnextrow(), dbpoll(), DBRBUF(), dbresults(), dbsqlok(), dbsqlsend().
    Here is the call graph for this function:

    § dblastrow()

    DBINT dblastrow ( DBPROCESS dbproc)

    Get number of the last row in the row buffer.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    See also
    DBLASTROW(), dbclrbuf(), DBCURROW(), DBFIRSTROW(), dbgetrow(), dbnextrow(), dbsetopt().
    Here is the call graph for this function:

    § dbperror()

    int dbperror ( DBPROCESS dbproc,
    DBINT  msgno,
    long  errnum,
      ... 
    )

    Call client-installed error handler.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    msgnoidentifies the error message to be passed to the client's handler.
    errnumidentifies the OS error (errno), if any. Use 0 if not applicable.
    Returns
    the handler's return code, subject to correction and adjustment for vendor style:
    • INT_CANCEL The db-lib function that encountered the error will return FAIL.
    • INT_TIMEOUT The db-lib function will cancel the operation and return FAIL. dbproc remains useable.
    • INT_CONTINUE The db-lib function will retry the operation.
    Remarks
    The client-installed handler may also return INT_EXIT. If Sybase semantics are used, this function notifies the user and calls exit(3). If Microsoft semantics are used, this function returns INT_CANCEL.

    If the client-installed handler returns something other than these four INT_* values, or returns timeout-related value for anything but SYBETIME, it's treated here as INT_EXIT (see above).

    Instead of sprinkling error text all over db-lib, we consolidate it here, where it can be translated (one day), and where it can be mapped to the TDS error number. The libraries don't use consistent error numbers or messages, so when libtds has to emit an error message, it can't include the text. It can pass its error number to a client-library function, which will interpret it, add the text, call the application's installed handler (if any) and return the handler's return code back to the caller.

    The call stack may look something like this:

    1. application
    2. db-lib function (encounters error)
    3. dbperror
    4. error handler (installed by application)

    The error handling in this case is unambiguous: the caller invokes this function, the client's handler returns its instruction, which the caller receives. Quite often the caller will get INT_CANCEL, in which case it should put its house in order and return FAIL.

    The call stack may otherwise look something like this:

    1. application
    2. db-lib function
    3. libtds function (encounters error)
    4. _dblib_handle_err_message
    5. dbperror
    6. error handler (installed by application)

    Because different client libraries specify their handler semantics differently, and because libtds doesn't know which client library is in charge of any given connection, it cannot interpret the raw return code from a db-lib error handler. For these reasons, libtds calls _dblib_handle_err_message, which translates between libtds and db-lib semantics.

    See also
    dberrhandle(), _dblib_handle_err_message().
    Here is the caller graph for this function:

    § dbrows()

    RETCODE dbrows ( DBPROCESS dbproc)

    Indicate whether a query returned rows.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    See also
    DBROWS(), DBCMDROW(), dbnextrow(), dbresults(), DBROWTYPE().
    Here is the call graph for this function:

    § dbrowtype()

    STATUS dbrowtype ( DBPROCESS dbproc)

    Get returned row's type.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    See also
    DBROWTYPE().
    Here is the call graph for this function:

    § dbsetavail()

    void dbsetavail ( DBPROCESS dbproc)

    Mark a DBPROCESS as "available".

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    Remarks
    Basically bogus. FreeTDS behaves the way Sybase's implementation does, but so what? Many db-lib functions set the DBPROCESS to "not available", but only dbsetavail() resets it to "available".
    See also
    DBISAVAIL(). DBSETAVAIL().
    Here is the call graph for this function:

    § dbsetlbool()

    RETCODE dbsetlbool ( LOGINREC login,
    int  value,
    int  which 
    )

    Set a boolean value in a LOGINREC structure.

    Called by various macros to populate login.

    Parameters
    loginthe LOGINREC* to modify.
    valuethe value to set it to.
    whichthe field to set.
    Remarks
    Only DBSETBCP is implemented.
    Return values
    SUCCEEDthe value was set.
    FAILinvalid value passed for which.
    Todo:
    DBSETNOSHORT, DBSETENCRYPT, DBSETLABELED
    Here is the call graph for this function:

    § dbsetllong()

    RETCODE dbsetllong ( LOGINREC login,
    long  value,
    int  which 
    )

    Set an integer value in a LOGINREC structure.

    Called by various macros to populate login.

    Parameters
    loginthe LOGINREC* to modify.
    valuethe value to set it to.
    whichthe field to set.
    Return values
    SUCCEEDthe value was set.
    FAILanything other than DBSETPACKET was passed for which.
    Here is the call graph for this function:

    § dbsetlname()

    RETCODE dbsetlname ( LOGINREC login,
    const char *  value,
    int  which 
    )

    Set the value of a string in a LOGINREC structure.

    Called by various macros to populate login.

    Parameters
    loginthe LOGINREC* to modify.
    valuethe value to set it to.
    whichthe field to set.
    Return values
    SUCCEEDthe value was set.
    FAILDBSETHID or other invalid which was tried.
    Here is the call graph for this function:

    § dbtds()

    int dbtds ( DBPROCESS dbproc)

    Get the TDS version in use for dbproc.

    Parameters
    dbproccontains all information needed by db-lib to manage communications with the server.
    Returns
    a DBTDS* token.
    Remarks
    The integer values of the constants are counterintuitive.
    See also
    DBTDS().
    Here is the call graph for this function:

    § default_err_handler()

    static int default_err_handler ( DBPROCESS dbproc,
    int  severity,
    int  dberr,
    int  oserr,
    char *  dberrstr,
    char *  oserrstr 
    )
    static

    default error handler for db-lib (handles library-generated errors)

    The default error handler doesn't print anything. If you want to see your messages printed, install an error handler. If you think that should be an optional compile- or run-time default, submit a patch. It could be done.

    See also
    DBDEAD(), dberrhandle().
    Here is the call graph for this function:

    § tdsdbopen()

    DBPROCESS* tdsdbopen ( LOGINREC login,
    const char *  server,
    int  msdblib 
    )

    Form a connection with the server.

    Called by the dbopen() macro, normally. If FreeTDS was configured with –enable-msdblib, this function is called by (exported) dbopen() function. tdsdbopen is so-named to avoid namespace conflicts with other database libraries that use the same function name.

    Parameters
    loginLOGINREC* carrying the account information.
    servername of the dataserver to connect to.
    Returns
    valid pointer on successful login.
    Return values
    NULLinsufficient memory, unable to connect for any reason.
    See also
    dbopen()
    Todo:

    use asprintf() to avoid buffer overflow.

    separate error messages for no-such-server and no-such-user.

    Here is the call graph for this function:
    Here is the caller graph for this function:
    freetds-1.00.82/doc/reference/a00524.map100644 025423 025423 00000000267 13242511135 0013045 freetds-1.00.82/doc/reference/a00524.md5100644 025423 025423 00000000040 13242511133 00127407cd02d54183b06e10cff14654eb80b8ffreetds-1.00.82/doc/reference/a00524.svg100644 025423 025423 00000003050 13242511136 0013061 Internals Node1 The db-lib API Node0 Internals Node1->Node0 freetds-1.00.82/doc/reference/a00524_ga01e7fb38bece3bb07526532fa6be50e5_cgraph.map100644 025423 025423 00000000311 13242511135 0021455 freetds-1.00.82/doc/reference/a00524_ga01e7fb38bece3bb07526532fa6be50e5_cgraph.md5100644 025423 025423 00000000040 13242511133 0021362c12924cfb680a59ae9eb4929a0e54375freetds-1.00.82/doc/reference/a00524_ga01e7fb38bece3bb07526532fa6be50e5_cgraph.svg100644 025423 025423 00000003114 13242511136 0021504 dbcurcmd Node10 dbcurcmd Node11 tdsdump_log Node10->Node11 freetds-1.00.82/doc/reference/a00525.html100644 025423 025423 00000007674 13242511136 0013247 FreeTDS API: Unimplemented
    FreeTDS API
    Unimplemented

    Functions thus far not implemented in the FreeTDS db-lib implementation. More...

    Collaboration diagram for Unimplemented:

    Functions thus far not implemented in the FreeTDS db-lib implementation.

    While some of these are simply awaiting someone with time and skill (and inclination) it might be noted here that the old browse functions (e.g. dbcolbrowse()) are on the never-to-do list. They were defined by Sybase and were superseded long ago, although they're still present in Microsoft's implementation. They were never popular and today better alternatives are available. For completeness, they are:

    • dbcolbrowse()
    • dbcolsource()
    • dbfreequal()
    • dbqual()
    • dbtabbrowse()
    • dbtabcount()
    • dbtabname()
    • dbtabsource()
    • dbtsnewlen()
    • dbtsnewval()
    • dbtsput()
    freetds-1.00.82/doc/reference/a00525.map100644 025423 025423 00000000277 13242511135 0013047 freetds-1.00.82/doc/reference/a00524_ga03e850369aca6fba074da5e9da4effd7_cgraph.map100644 025423 025423 00000000315 13242511135 0021635 freetds-1.00.82/doc/reference/a00524_ga03e850369aca6fba074da5e9da4effd7_cgraph.md5100644 025423 025423 00000000040 13242511133 0021536b32ce8eaf875e4be38098ad1f756496dfreetds-1.00.82/doc/reference/a00524_ga03e850369aca6fba074da5e9da4effd7_cgraph.svg100644 025423 025423 00000003124 13242511136 0021661 dbsetlbool Node43 dbsetlbool Node44 tdsdump_log Node43->Node44 freetds-1.00.82/doc/reference/a00524_ga0fc84c7073ed4876d9596c3eccac3609_cgraph.map100644 025423 025423 00000000321 13242511135 0021352 freetds-1.00.82/doc/reference/a00524_ga0fc84c7073ed4876d9596c3eccac3609_cgraph.md5100644 025423 025423 00000000040 13242511133 0021256778f1daab3b33fb642edc229ba25c50dfreetds-1.00.82/doc/reference/a00524_ga0fc84c7073ed4876d9596c3eccac3609_cgraph.svg100644 025423 025423 00000003105 13242511136 0021400 dbcolptr Node7 dbcolptr Node8 dbperror Node7->Node8 freetds-1.00.82/doc/reference/a00524_ga13ead146339b43b3a4d9049eb124ef4b_cgraph.map100644 025423 025423 00000000313 13242511135 0021314 freetds-1.00.82/doc/reference/a00524_ga13ead146339b43b3a4d9049eb124ef4b_cgraph.md5100644 025423 025423 00000000040 13242511133 0021217805f271c1b3059a01fb3812faf878a1bfreetds-1.00.82/doc/reference/a00524_ga13ead146339b43b3a4d9049eb124ef4b_cgraph.svg100644 025423 025423 00000003117 13242511136 0021344 dblastrow Node28 dblastrow Node29 tdsdump_log Node28->Node29 freetds-1.00.82/doc/reference/a00524_ga196f6d67de47f34a32fcc2103ab0f416_cgraph.map100644 025423 025423 00000000311 13242511135 0021320 freetds-1.00.82/doc/reference/a00524_ga196f6d67de47f34a32fcc2103ab0f416_cgraph.md5100644 025423 025423 00000000040 13242511133 00212255d8c82ea207eecddda91fb2e874594f6freetds-1.00.82/doc/reference/a00524_ga196f6d67de47f34a32fcc2103ab0f416_cgraph.svg100644 025423 025423 00000003107 13242511136 0021351 dbcmdrow Node4 dbcmdrow Node5 tdsdump_log Node4->Node5 freetds-1.00.82/doc/reference/a00524_ga2c99ec565452279e9a382451d89642eb_cgraph.map100644 025423 025423 00000000614 13242511135 0021066 freetds-1.00.82/doc/reference/a00524_ga2c99ec565452279e9a382451d89642eb_cgraph.md5100644 025423 025423 00000000040 13242511133 0020765e012866a89178d2884a7a6a61770117dfreetds-1.00.82/doc/reference/a00524_ga2c99ec565452279e9a382451d89642eb_cgraph.svg100644 025423 025423 00000004650 13242511136 0021115 tdsdbopen Node58 tdsdbopen Node59 tdsdump_open Node58->Node59 Node60 tdsdump_log Node58->Node60 freetds-1.00.82/doc/reference/a00524_ga2c99ec565452279e9a382451d89642eb_icgraph.map100644 025423 025423 00000000274 13242511135 0021241 freetds-1.00.82/doc/reference/a00524_ga2c99ec565452279e9a382451d89642eb_icgraph.md5100644 025423 025423 00000000040 13242511133 00211368eed2a8205efcc87259a6c858b4cf4e1freetds-1.00.82/doc/reference/a00524_ga2c99ec565452279e9a382451d89642eb_icgraph.svg100644 025423 025423 00000003074 13242511136 0021265 tdsdbopen Node61 tdsdbopen Node62 dbopen Node61->Node62 freetds-1.00.82/doc/reference/a00524_ga302a4ce6559b81808e3be51615cd1b67_icgraph.map100644 025423 025423 00000000331 13242511135 0021337 freetds-1.00.82/doc/reference/a00524_ga302a4ce6559b81808e3be51615cd1b67_icgraph.md5100644 025423 025423 00000000040 13242511133 00212426e4d7360f1293b9b55a6518277452df3freetds-1.00.82/doc/reference/a00524_ga302a4ce6559b81808e3be51615cd1b67_icgraph.svg100644 025423 025423 00000003131 13242511136 0021363 dbperror Node32 dbperror Node33 dbcolptr Node32->Node33 freetds-1.00.82/doc/reference/a00524_ga4be2ab59dc7161d6b93c17202e7ae9b1_cgraph.map100644 025423 025423 00000000305 13242511135 0021402 freetds-1.00.82/doc/reference/a00524_ga4be2ab59dc7161d6b93c17202e7ae9b1_cgraph.md5100644 025423 025423 00000000040 13242511133 0021304216ed75368dc98b18b93b3e220ab67b8freetds-1.00.82/doc/reference/a00524_ga4be2ab59dc7161d6b93c17202e7ae9b1_cgraph.svg100644 025423 025423 00000003105 13242511136 0021426 dbrows Node34 dbrows Node35 tdsdump_log Node34->Node35 freetds-1.00.82/doc/reference/a00524_ga5ce245ff327a3d333280fe7b43d69ded_cgraph.map100644 025423 025423 00000000315 13242511135 0021420 freetds-1.00.82/doc/reference/a00524_ga5ce245ff327a3d333280fe7b43d69ded_cgraph.md5100644 025423 025423 00000000040 13242511133 00213219159c3f17d20bf8e4a3aad54b34c5325freetds-1.00.82/doc/reference/a00524_ga5ce245ff327a3d333280fe7b43d69ded_cgraph.svg100644 025423 025423 00000003124 13242511136 0021444 dbsetavail Node40 dbsetavail Node41 tdsdump_log Node40->Node41 freetds-1.00.82/doc/reference/a00524_ga666a4d0609ee7f241deb0a62893d2cfa_cgraph.map100644 025423 025423 00000000313 13242511135 0021410 freetds-1.00.82/doc/reference/a00524_ga666a4d0609ee7f241deb0a62893d2cfa_cgraph.md5100644 025423 025423 00000000040 13242511133 0021313a610cd430bf74d7fa09a2dc64542dcdffreetds-1.00.82/doc/reference/a00524_ga666a4d0609ee7f241deb0a62893d2cfa_cgraph.svg100644 025423 025423 00000003123 13242511136 0021435 dbiowdesc Node25 dbiowdesc Node26 tdsdump_log Node25->Node26 freetds-1.00.82/doc/reference/a00524_ga8d765d810a40dfa01b39995a8e7406f0_cgraph.map100644 025423 025423 00000000303 13242511135 0021175 freetds-1.00.82/doc/reference/a00524_ga8d765d810a40dfa01b39995a8e7406f0_cgraph.md5100644 025423 025423 00000000040 13242511133 0021101cde5bf72f0ba10fb657dca5e5a7f1e0dfreetds-1.00.82/doc/reference/a00524_ga8d765d810a40dfa01b39995a8e7406f0_cgraph.svg100644 025423 025423 00000003104 13242511136 0021222 dbtds Node52 dbtds Node53 tdsdump_log Node52->Node53 freetds-1.00.82/doc/reference/a00524_ga9e23a95d84192b4fc83db7544d772d16_cgraph.map100644 025423 025423 00000000311 13242511135 0021207 freetds-1.00.82/doc/reference/a00524_ga9e23a95d84192b4fc83db7544d772d16_cgraph.md5100644 025423 025423 00000000040 13242511133 002111438a0c942e1e880669b286e93176d6540freetds-1.00.82/doc/reference/a00524_ga9e23a95d84192b4fc83db7544d772d16_cgraph.svg100644 025423 025423 00000003115 13242511136 0021237 dbcurrow Node13 dbcurrow Node14 tdsdump_log Node13->Node14 freetds-1.00.82/doc/reference/a00524_gaa2dc8c062342f76adffe53ee280b7fb4_cgraph.map100644 025423 025423 00000000313 13242511135 0021550 freetds-1.00.82/doc/reference/a00524_gaa2dc8c062342f76adffe53ee280b7fb4_cgraph.md5100644 025423 025423 00000000040 13242511133 00214531068999bd94ddcb5119b6ece90bf4dbefreetds-1.00.82/doc/reference/a00524_gaa2dc8c062342f76adffe53ee280b7fb4_cgraph.svg100644 025423 025423 00000003122 13242511136 0021574 dbrowtype Node37 dbrowtype Node38 tdsdump_log Node37->Node38 freetds-1.00.82/doc/reference/a00524_gab842baac0ec420b265d8c199cc45059d_cgraph.map100644 025423 025423 00000000313 13242511135 0021377 freetds-1.00.82/doc/reference/a00524_gab842baac0ec420b265d8c199cc45059d_cgraph.md5100644 025423 025423 00000000040 13242511133 0021302dd31656283221212d713db72bcd02717freetds-1.00.82/doc/reference/a00524_gab842baac0ec420b265d8c199cc45059d_cgraph.svg100644 025423 025423 00000003117 13242511136 0021427 dbiordesc Node22 dbiordesc Node23 tdsdump_log Node22->Node23 freetds-1.00.82/doc/reference/a00524_gabdcccf4e0d093ff48c0e7048a4bfaf84_cgraph.map100644 025423 025423 00000000315 13242511135 0021713 freetds-1.00.82/doc/reference/a00524_gabdcccf4e0d093ff48c0e7048a4bfaf84_cgraph.md5100644 025423 025423 00000000040 13242511133 0021614271f4c0d8044b0abb5f9e72d3bed41d8freetds-1.00.82/doc/reference/a00524_gabdcccf4e0d093ff48c0e7048a4bfaf84_cgraph.svg100644 025423 025423 00000003125 13242511136 0021740 dbsetllong Node46 dbsetllong Node47 tdsdump_log Node46->Node47 freetds-1.00.82/doc/reference/a00524_gaccbc6d98d9528c48cf0254d809ca73ff_cgraph.map100644 025423 025423 00000000337 13242511135 0021522 freetds-1.00.82/doc/reference/a00524_gaccbc6d98d9528c48cf0254d809ca73ff_cgraph.md5100644 025423 025423 00000000040 13242511133 00214173417d4295588e2df76f72365cae0539efreetds-1.00.82/doc/reference/a00524_gaccbc6d98d9528c48cf0254d809ca73ff_cgraph.svg100644 025423 025423 00000003162 13242511136 0021544 default_err_handler Node55 default_err_handler Node56 tdsdump_log Node55->Node56 freetds-1.00.82/doc/reference/a00524_gae1fc46447c4f8a9ff7f66607b8cd23b6_cgraph.map100644 025423 025423 00000000315 13242511135 0021441 freetds-1.00.82/doc/reference/a00524_gae1fc46447c4f8a9ff7f66607b8cd23b6_cgraph.md5100644 025423 025423 00000000040 13242511133 0021342b8d6517e199f024c0fb9cb1adc6e8d12freetds-1.00.82/doc/reference/a00524_gae1fc46447c4f8a9ff7f66607b8cd23b6_cgraph.svg100644 025423 025423 00000003130 13242511136 0021462 dbsetlname Node49 dbsetlname Node50 tdsdump_log Node49->Node50 freetds-1.00.82/doc/reference/a00524_gaed43cb21ed54dc1a6340075d6290e4b0_cgraph.map100644 025423 025423 00000000305 13242511135 0021305 freetds-1.00.82/doc/reference/a00524_gaed43cb21ed54dc1a6340075d6290e4b0_cgraph.md5100644 025423 025423 00000000040 13242511133 00212074dc406173db20a211d10b306102d31a7freetds-1.00.82/doc/reference/a00524_gaed43cb21ed54dc1a6340075d6290e4b0_cgraph.svg100644 025423 025423 00000003106 13242511136 0021332 dbdead Node16 dbdead Node17 tdsdump_log Node16->Node17 freetds-1.00.82/doc/reference/a00524_gaf40b925f3b3ba43804720dd4ae584935_cgraph.map100644 025423 025423 00000000315 13242511135 0021167 freetds-1.00.82/doc/reference/a00524_gaf40b925f3b3ba43804720dd4ae584935_cgraph.md5100644 025423 025423 00000000040 13242511133 00210707193babadc16fec71b2a7ff97460664afreetds-1.00.82/doc/reference/a00524_gaf40b925f3b3ba43804720dd4ae584935_cgraph.svg100644 025423 025423 00000003122 13242511136 0021211 dbfirstrow Node19 dbfirstrow Node20 tdsdump_log Node19->Node20 freetds-1.00.82/doc/reference/a00525.md5100644 025423 025423 00000000040 13242511133 0012741e713513544192c0ac3d8b91f7f941f97freetds-1.00.82/doc/reference/a00525.svg100644 025423 025423 00000003064 13242511136 0013067 Unimplemented Node1 The db-lib API Node0 Unimplemented Node1->Node0 freetds-1.00.82/doc/reference/a00526.html100644 025423 025423 00000007342 13242511136 0013240 FreeTDS API: ODBC API
    FreeTDS API
    ODBC API

    Functions callable by ODBC client programs. More...

    Collaboration diagram for ODBC API:

    Modules

     ODBC utility
     Functions called within ODBC driver.
     

    Detailed Description

    Functions callable by ODBC client programs.

    freetds-1.00.82/doc/reference/a00526.map100644 025423 025423 00000000252 13242511135 0013041 freetds-1.00.82/doc/reference/a00526.md5100644 025423 025423 00000000040 13242511133 001274258dba41384ca93b1c729b75b60db61f7freetds-1.00.82/doc/reference/a00526.svg100644 025423 025423 00000003024 13242511136 0013064 ODBC API Node0 ODBC API Node1 ODBC utility Node0->Node1 freetds-1.00.82/doc/reference/a00527.html100644 025423 025423 00000051315 13242511136 0013240 FreeTDS API: ODBC utility
    FreeTDS API
    ODBC utility

    Functions called within ODBC driver. More...

    Collaboration diagram for ODBC utility:

    Macros

    #define C_TYPES
     
    #define SQL_TYPES
     
    #define TYPE_NORMAL_SQL_C_GUID
     
    #define TYPE_NORMAL_SQL_GUID
     

    Functions

    TDS_SERVER_TYPE odbc_c_to_server_type (int c_type)
     Pass this an SQL_C_* type and get a SYB* type which most closely corresponds to the SQL_C_* type. More...
     
    void odbc_convert_err_set (struct _sql_errors *errs, TDS_INT err)
     
    DSTRodbc_dstr_copy (TDS_DBC *dbc, DSTR *s, int size, const ODBC_CHAR *str)
     
    SQLSMALLINT odbc_get_concise_c_type (SQLSMALLINT type, SQLSMALLINT interval)
     
    SQLSMALLINT odbc_get_concise_sql_type (SQLSMALLINT type, SQLSMALLINT interval)
     
    SQLLEN odbc_get_octet_len (int c_type, const struct _drecord *drec)
     
    SQLINTEGER odbc_get_param_len (const struct _drecord *drec_axd, const struct _drecord *drec_ixd, const TDS_DESC *axd, unsigned int n_row)
     Return length of parameter from parameter information.
     
    unsigned int odbc_get_string_size (int size, const ODBC_CHAR *str _WIDE)
     
    void odbc_rdbms_version (TDSSOCKET *tds, char *pversion_string)
     Returns the version of the RDBMS in the ODBC format.
     
    SQLRETURN odbc_set_concise_c_type (SQLSMALLINT concise_type, struct _drecord *drec, int check_only)
     Set concise type and all cascading field. More...
     
    SQLRETURN odbc_set_concise_sql_type (SQLSMALLINT concise_type, struct _drecord *drec, int check_only)
     Set concise type and all cascading field. More...
     
    void odbc_set_return_params (struct _hstmt *stmt, unsigned int n_row)
     
    void odbc_set_return_status (struct _hstmt *stmt, unsigned int n_row)
     
    int odbc_set_stmt_query (TDS_STMT *stmt, const ODBC_CHAR *sql, int sql_len _WIDE)
     
    SQLRETURN odbc_set_string_flag (TDS_DBC *dbc, SQLPOINTER buffer, SQLINTEGER cbBuffer, void FAR *pcbBuffer, const char *s, int len, int flag)
     Copy a string to client setting size according to ODBC convenction. More...
     
    int odbc_sql_to_c_type_default (int sql_type)
     
    TDS_SERVER_TYPE odbc_sql_to_server_type (TDSCONNECTION *conn, int sql_type, int sql_unsigned)
     

    Detailed Description

    Functions called within ODBC driver.

    Function Documentation

    § odbc_c_to_server_type()

    TDS_SERVER_TYPE odbc_c_to_server_type ( int  c_type)

    Pass this an SQL_C_* type and get a SYB* type which most closely corresponds to the SQL_C_* type.

    This function can return XSYBNVARCHAR or SYBUINTx even if server do not support it

    § odbc_set_concise_c_type()

    SQLRETURN odbc_set_concise_c_type ( SQLSMALLINT  concise_type,
    struct _drecord drec,
    int  check_only 
    )

    Set concise type and all cascading field.

    Parameters
    concise_typeconcise type to set
    drecrecord to set. NULL to test error without setting
    check_onlyit <>0 (true) check only, do not set type

    § odbc_set_concise_sql_type()

    SQLRETURN odbc_set_concise_sql_type ( SQLSMALLINT  concise_type,
    struct _drecord drec,
    int  check_only 
    )

    Set concise type and all cascading field.

    Parameters
    concise_typeconcise type to set
    drecrecord to set. NULL to test error without setting
    check_onlyit <>0 (true) check only, do not set type

    § odbc_set_string_flag()

    SQLRETURN odbc_set_string_flag ( TDS_DBC dbc,
    SQLPOINTER  buffer,
    SQLINTEGER  cbBuffer,
    void FAR *  pcbBuffer,
    const char *  s,
    int  len,
    int  flag 
    )

    Copy a string to client setting size according to ODBC convenction.

    Parameters
    dbcdatabase connection. Can be NULL
    bufferclient buffer
    cbBufferclient buffer size (in bytes)
    pcbBufferpointer to SQLSMALLINT to hold string size
    sstring to copy
    lenlen of string to copy. <0 null terminated
    flagset of flag 0x10 SQLINTEGER
    Here is the call graph for this function:
    freetds-1.00.82/doc/reference/a00527.map100644 025423 025423 00000000266 13242511135 0013047 freetds-1.00.82/doc/reference/a00527.md5100644 025423 025423 00000000040 13242511133 00127434d3c8da6d180e2df673487d813634269freetds-1.00.82/doc/reference/a00527.svg100644 025423 025423 00000003043 13242511136 0013066 ODBC utility Node1 ODBC API Node0 ODBC utility Node1->Node0 freetds-1.00.82/doc/reference/a00527_gadba4490bf3183799a70c9e2f44fab331_cgraph.map100644 025423 025423 00000000567 13242511135 0021347 freetds-1.00.82/doc/reference/a00527_gadba4490bf3183799a70c9e2f44fab331_cgraph.md5100644 025423 025423 00000000040 13242511133 002123790478d39a8507ea11f2bee2a43680d0afreetds-1.00.82/doc/reference/a00527_gadba4490bf3183799a70c9e2f44fab331_cgraph.svg100644 025423 025423 00000004515 13242511136 0021367 odbc_set_string_flag Node6 odbc_set_string_flag Node7 tds_iconv Node6->Node7 Node8 tdsdump_log Node7->Node8 freetds-1.00.82/doc/reference/a00528.html100644 025423 025423 00000101163 13242511136 0013236 FreeTDS API: Authentication
    FreeTDS API

    Functions for handling authentication. More...

    Collaboration diagram for Authentication:

    Classes

    struct  asn1_der_iterator
     
    struct  mpz_t
     
    struct  names_blob_prefix_t
     
    struct  rsa_public_key
     
    struct  tds_answer
     
    struct  tds_ntlm_auth
     

    Macros

    #define dump(b)   dumpl(b, sizeof(b))
     
    #define dumpl(b, l)   tdsdump_dump_buf(TDS_DBG_INFO1, #b, b, l)
     
    #define hash_func   sha1
     
    #define HAVE_GMP   1
     
    #define HAVE_NETTLE   1
     
    #define mpz_clear(n)   gcry_mpi_release((n)->num)
     
    #define mpz_init(n)   do { (n)->num = NULL; } while(0)
     
    #define mpz_powm(w, n, e, m)   gcry_mpi_powm((w)->num, (n)->num, (e)->num, (m)->num);
     

    Typedefs

    typedef void nettle_random_func(void *ctx, size_t len, uint8_t *out)
     
    typedef struct tds_answer TDSANSWER
     
    typedef struct tds_ntlm_auth TDSNTLMAUTH
     

    Enumerations

    enum  { ASN1_SEQUENCE = ASN1_TAG_SEQUENCE }
     
    enum  { hash_len = 20 }
     
    enum  { key_size_max = 1024 }
     
    enum  asn1_iterator_result { ASN1_ITERATOR_ERROR, ASN1_ITERATOR_PRIMITIVE, ASN1_ITERATOR_CONSTRUCTED, ASN1_ITERATOR_END }
     

    Functions

    static enum asn1_iterator_result asn1_der_iterator_first (struct asn1_der_iterator *der, int size, const void *der_buf)
     
    static enum asn1_iterator_result asn1_der_iterator_next (struct asn1_der_iterator *der)
     
    static void convert_to_upper (char *buf, size_t len)
     
    static size_t convert_to_usc2le_string (TDSSOCKET *tds, const char *s, size_t len, char *out)
     
    static void fill_names_blob_prefix (names_blob_prefix_t *prefix)
     
    static unsigned char * make_lm_v2_response (const unsigned char ntlm_v2_hash[16], const unsigned char *client_data, TDS_INT client_data_len, const unsigned char challenge[8])
     
    static TDSRET make_ntlm_hash (TDSSOCKET *tds, const char *passwd, unsigned char ntlm_hash[16])
     
    static TDSRET make_ntlm_v2_hash (TDSSOCKET *tds, const char *passwd, unsigned char ntlm_v2_hash[16])
     
    static void memxor (uint8_t *dest, const uint8_t *src, size_t len)
     
    static void mgf_mask (uint8_t *dest, size_t dest_len, const uint8_t *mask, size_t mask_len)
     
    static void nettle_mpz_get_str_256 (unsigned length, uint8_t *s, const mpz_t x)
     
    static void nettle_mpz_set_str_256_u (mpz_t x, unsigned length, const uint8_t *s)
     
    static int oaep_encrypt (size_t key_size, void *random_ctx, nettle_random_func *random, size_t length, const uint8_t *message, mpz_t m)
     
    static void rnd_func (void *ctx, size_t len, uint8_t *out)
     
    static int rsa_encrypt_oaep (const struct rsa_public_key *key, void *random_ctx, nettle_random_func *random, size_t length, const uint8_t *message, mpz_t gibberish)
     
    static const BIGNUM * rsa_get_n (const RSA *rsa)
     
    static void rsa_public_key_clear (struct rsa_public_key *key)
     
    static int rsa_public_key_from_der_iterator (struct rsa_public_key *key, unsigned key_bits, struct asn1_der_iterator *der)
     
    static void rsa_public_key_init (struct rsa_public_key *key)
     
    static void sha1 (uint8_t *hash, const void *data, size_t len)
     
    TDSAUTHENTICATIONtds5_negotiate_get_auth (TDSSOCKET *tds)
     
    void tds5_negotiate_set_msg_type (TDSSOCKET *tds, TDSAUTHENTICATION *tds_auth, unsigned msg_type)
     
    static void * tds5_rsa_encrypt (const void *key, size_t key_len, const void *nonce, size_t nonce_len, const char *pwd, size_t *em_size)
     
    static TDSRET tds7_send_auth (TDSSOCKET *tds, const unsigned char *challenge, TDS_UINT flags, const unsigned char *names_blob, TDS_INT names_blob_len)
     
    static TDSRET tds_answer_challenge (TDSSOCKET *tds, TDSLOGIN *login, const unsigned char *challenge, TDS_UINT *flags, const unsigned char *names_blob, TDS_INT names_blob_len, TDSANSWER *answer, unsigned char **ntlm_v2_response)
     Crypt a given password using schema required for NTLMv1 or NTLM2 authentication. More...
     
    static TDSRET tds_answer_challenge_ntlmv2 (TDSSOCKET *tds, TDSLOGIN *login, const unsigned char *challenge, TDS_UINT *flags, const unsigned char *names_blob, TDS_INT names_blob_len, TDSANSWER *answer, unsigned char **ntlm_v2_response)
     
    static void tds_convert_key (const unsigned char *key_56, DES_KEY *ks)
     
    static void tds_encrypt_answer (const unsigned char *hash, const unsigned char *challenge, unsigned char *answer)
     
    static TDSRET tds_ntlm_free (TDSCONNECTION *conn, TDSAUTHENTICATION *tds_auth)
     
    TDSAUTHENTICATIONtds_ntlm_get_auth (TDSSOCKET *tds)
     Build a NTLMSPP packet to send to server. More...
     
    static TDSRET tds_ntlm_handle_next (TDSSOCKET *tds, struct tds_authentication *auth, size_t len)
     
    static void unix_to_nt_time (TDS_UINT8 *nt, struct timeval *tv)
     put a 8 byte filetime from a time_t This takes GMT as input
     

    Variables

    static const char label [] = ""
     
    static const unsigned char ntlm_id [] = "NTLMSSP"
     

    Detailed Description

    Functions for handling authentication.

    Function Documentation

    § tds_answer_challenge()

    static TDSRET tds_answer_challenge ( TDSSOCKET tds,
    TDSLOGIN login,
    const unsigned char *  challenge,
    TDS_UINT *  flags,
    const unsigned char *  names_blob,
    TDS_INT  names_blob_len,
    TDSANSWER answer,
    unsigned char **  ntlm_v2_response 
    )
    static

    Crypt a given password using schema required for NTLMv1 or NTLM2 authentication.

    Parameters
    passwdclear text domain password
    challengechallenge data given by server
    flagsNTLM flags from server side
    answerbuffer where to store crypted password
    Here is the call graph for this function:

    § tds_ntlm_get_auth()

    TDSAUTHENTICATION* tds_ntlm_get_auth ( TDSSOCKET tds)

    Build a NTLMSPP packet to send to server.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    Returns
    authentication info
    Here is the call graph for this function:
    freetds-1.00.82/doc/reference/a00528.map100644 025423 025423 00000000255 13242511135 0013046 freetds-1.00.82/doc/reference/a00528.md5100644 025423 025423 00000000040 13242511133 00127443b8529aab9a387d927f969ebb289c7e6freetds-1.00.82/doc/reference/a00528.svg100644 025423 025423 00000003037 13242511136 0013072 Authentication Node0 Authentication Node1 LibTDS API Node1->Node0 freetds-1.00.82/doc/reference/a00528_ga4c76be38f4758db45be58f9de8ccdef0_cgraph.map100644 025423 025423 00000000365 13242511135 0021677 freetds-1.00.82/doc/reference/a00528_ga4c76be38f4758db45be58f9de8ccdef0_cgraph.md5100644 025423 025423 00000000040 13242511133 0021573e4b3c021530fed46999c5a5491e6fc5ffreetds-1.00.82/doc/reference/a00528_ga4c76be38f4758db45be58f9de8ccdef0_cgraph.svg100644 025423 025423 00000003204 13242511136 0021715 tds_answer_challenge Node0 tds_answer_challenge Node1 tds_dstr_cstr Node0->Node1 freetds-1.00.82/doc/reference/a00528_ga679f2d22b4a4bdefe0fa475d63503778_cgraph.map100644 025423 025423 00000000630 13242511135 0021347 freetds-1.00.82/doc/reference/a00528_ga679f2d22b4a4bdefe0fa475d63503778_cgraph.md5100644 025423 025423 00000000040 13242511133 0021250d21df7e3b40b632f8df479d88a54c853freetds-1.00.82/doc/reference/a00528_ga679f2d22b4a4bdefe0fa475d63503778_cgraph.svg100644 025423 025423 00000004660 13242511136 0021401 tds_ntlm_get_auth Node3 tds_ntlm_get_auth Node4 tds_dstr_cstr Node3->Node4 Node5 tds_dstr_len Node3->Node5 freetds-1.00.82/doc/reference/a00529.html100644 025423 025423 00000116372 13242511136 0013247 FreeTDS API: Configuration
    FreeTDS API

    Handle reading of configuration. More...

    Collaboration diagram for Configuration:

    Classes

    struct  tdsvername_t
     

    Macros

    #define TDS_FIND(k, b, c)   tds_find(k, b, sizeof(b)/sizeof(b[0]), sizeof(b[0]), c)
     

    Functions

    static int hex2num (char *hex)
     
    static int hexdigit (int c)
     
    static int parse_server_name_for_port (TDSLOGIN *connection, TDSLOGIN *login)
     Check the server name to find port info first Warning: connection-> & login-> are all modified when needed. More...
     
    static int search_interface_file (TDSLOGIN *login, const char *dir, const char *file, const char *host)
     Open and read the file 'file' searching for a logical server by the name of 'host'. More...
     
    int tds_config_boolean (const char *option, const char *value, TDSLOGIN *login)
     
    static void tds_config_encryption (const char *value, TDSLOGIN *login)
     
    static int tds_config_env_tdsdump (TDSLOGIN *login)
     
    static int tds_config_env_tdshost (TDSLOGIN *login)
     
    static void tds_config_env_tdsport (TDSLOGIN *login)
     
    static void tds_config_env_tdsver (TDSLOGIN *login)
     
    static int tds_config_login (TDSLOGIN *connection, TDSLOGIN *login)
     
    TDS_USMALLINT * tds_config_verstr (const char *tdsver, TDSLOGIN *login)
     Set TDS version from given string. More...
     
    static void * tds_find (const void *key, const void *base, size_t nelem, size_t width, int(*compar)(const void *, const void *))
     
    void tds_fix_login (TDSLOGIN *login)
     Fix configuration after reading it. More...
     
    const TDS_COMPILETIME_SETTINGStds_get_compiletime_settings (void)
     Return a structure capturing the compile-time settings provided to the configure script.
     
    static char * tds_get_home_file (const char *file)
     Return filename from HOME directory. More...
     
    struct addrinfo * tds_lookup_host (const char *servername)
     Get the IP address for a hostname. More...
     
    TDSRET tds_lookup_host_set (const char *servername, struct addrinfo **addr)
     
    static int tds_lookup_port (const char *portname)
     Given a portname lookup the port. More...
     
    int tds_parse_boolean (const char *value, int default_value)
     
    void tds_parse_conf_section (const char *option, const char *value, void *param)
     
    int tds_read_conf_file (TDSLOGIN *login, const char *server)
     Read configuration info for given server return 0 on error. More...
     
    int tds_read_conf_section (FILE *in, const char *section, TDSCONFPARSE tds_conf_parse, void *param)
     Read a section of configuration file (INI style file) More...
     
    static int tds_read_conf_sections (FILE *in, const char *server, TDSLOGIN *login)
     
    TDSLOGINtds_read_config_info (TDSSOCKET *tds, TDSLOGIN *login, TDSLOCALE *locale)
     tds_read_config_info() will fill the tds connection structure based on configuration information gathered in the following order: 1) Program specified in TDSLOGIN structure 2) The environment variables TDSVER, TDSDUMP, TDSPORT, TDSQUERY, TDSHOST 3) A config file with the following search order: a) a readable file specified by environment variable FREETDSCONF b) a readable file in ~/.freetds.conf c) a readable file in $prefix/etc/freetds.conf 3) ~/.interfaces if exists 4) $SYBASE/interfaces if exists 5) TDS_DEF_* default values More...
     
    static int tds_read_interfaces (const char *server, TDSLOGIN *login)
     Try to find the IP number and port for a (possibly) logical server name. More...
     
    TDSRET tds_set_interfaces_file_loc (const char *interf)
     Set the full name of interface file. More...
     
    static int tds_try_conf_file (const char *path, const char *how, const char *server, TDSLOGIN *login)
     
    static int tds_vernanme_cmp (const void *key, const void *pelem)
     

    Variables

    struct {
       unsigned char   to_return
     
       char   value [7]
     
    boolean_values []
     

    Detailed Description

    Handle reading of configuration.

    Function Documentation

    § parse_server_name_for_port()

    static int parse_server_name_for_port ( TDSLOGIN connection,
    TDSLOGIN login 
    )
    static

    Check the server name to find port info first Warning: connection-> & login-> are all modified when needed.

    Returns
    1 when found, else 0
    Here is the call graph for this function:

    § search_interface_file()

    static int search_interface_file ( TDSLOGIN login,
    const char *  dir,
    const char *  file,
    const char *  host 
    )
    static

    Open and read the file 'file' searching for a logical server by the name of 'host'.

    If one is found then lookup the IP address and port number and store them in 'login'

    Parameters
    dirname of base directory for interface file
    filename of the interface file
    hostlogical host to search for
    Returns
    0 if not fount 1 if found
    Here is the call graph for this function:

    § tds_config_verstr()

    TDS_USMALLINT* tds_config_verstr ( const char *  tdsver,
    TDSLOGIN login 
    )

    Set TDS version from given string.

    Parameters
    tdsvertds string version
    loginwhere to store information
    Returns
    as encoded hex value: high nybble major, low nybble minor.

    § tds_fix_login()

    void tds_fix_login ( TDSLOGIN login)

    Fix configuration after reading it.

    Currently this read some environment variables and replace some options.

    § tds_get_home_file()

    static char* tds_get_home_file ( const char *  file)
    static

    Return filename from HOME directory.

    Returns
    allocated string or NULL if error
    Here is the call graph for this function:

    § tds_lookup_host()

    struct addrinfo* tds_lookup_host ( const char *  servername)

    Get the IP address for a hostname.

    Store server's IP address in the string 'ip' in dotted-decimal notation. (The "hostname" might itself be a dotted-decimal address.

    If we can't determine the IP address then 'ip' will be set to empty string.

    § tds_lookup_port()

    static int tds_lookup_port ( const char *  portname)
    static

    Given a portname lookup the port.

    If we can't determine the port number then return 0.

    Here is the call graph for this function:

    § tds_read_conf_file()

    int tds_read_conf_file ( TDSLOGIN login,
    const char *  server 
    )

    Read configuration info for given server return 0 on error.

    Parameters
    loginwhere to store configuration
    serversection of file configuration that hold configuration for a server

    § tds_read_conf_section()

    int tds_read_conf_section ( FILE *  in,
    const char *  section,
    TDSCONFPARSE  tds_conf_parse,
    void *  param 
    )

    Read a section of configuration file (INI style file)

    Parameters
    inconfiguration file
    sectionsection to read
    tds_conf_parsecallback that receive every entry in section
    paramparameter to pass to callback function

    § tds_read_config_info()

    TDSLOGIN* tds_read_config_info ( TDSSOCKET tds,
    TDSLOGIN login,
    TDSLOCALE locale 
    )

    tds_read_config_info() will fill the tds connection structure based on configuration information gathered in the following order: 1) Program specified in TDSLOGIN structure 2) The environment variables TDSVER, TDSDUMP, TDSPORT, TDSQUERY, TDSHOST 3) A config file with the following search order: a) a readable file specified by environment variable FREETDSCONF b) a readable file in ~/.freetds.conf c) a readable file in $prefix/etc/freetds.conf 3) ~/.interfaces if exists 4) $SYBASE/interfaces if exists 5) TDS_DEF_* default values

    .tdsrc and freetds.conf have been added to make the package easier to integration with various Linux and *BSD distributions.

    § tds_read_interfaces()

    static int tds_read_interfaces ( const char *  server,
    TDSLOGIN login 
    )
    static

    Try to find the IP number and port for a (possibly) logical server name.

    Note
    This function uses only the interfaces file and is deprecated.
    Here is the call graph for this function:

    § tds_set_interfaces_file_loc()

    TDSRET tds_set_interfaces_file_loc ( const char *  interf)

    Set the full name of interface file.

    Parameters
    interffile name

    Variable Documentation

    § boolean_values

    const { ... } boolean_values[]
    Initial value:
    = {
    { "yes", 1 },
    { "no", 0 },
    { "on", 1 },
    { "off", 0 },
    { "true", 1 },
    { "false", 0 }
    }
    freetds-1.00.82/doc/reference/a00529.map100644 025423 025423 00000000253 13242511135 0013045 freetds-1.00.82/doc/reference/a00529.md5100644 025423 025423 00000000040 13242511133 0012745fc2d7c5f2ece929f37411550365c6d61freetds-1.00.82/doc/reference/a00529.svg100644 025423 025423 00000003032 13242511136 0013066 Configuration Node0 Configuration Node1 LibTDS API Node1->Node0 freetds-1.00.82/doc/reference/a00529_ga45281d1cb2ac649db65d80bb3ff06b66_cgraph.map100644 025423 025423 00000000331 13242511135 0021410 freetds-1.00.82/doc/reference/a00529_ga45281d1cb2ac649db65d80bb3ff06b66_cgraph.md5100644 025423 025423 00000000040 13242511133 0021313f71d20f9c64ac1f8bcefc879fa0e3f4efreetds-1.00.82/doc/reference/a00529_ga45281d1cb2ac649db65d80bb3ff06b66_cgraph.svg100644 025423 025423 00000003150 13242511136 0021435 tds_lookup_port Node17 tds_lookup_port Node18 tds_getservice Node17->Node18 freetds-1.00.82/doc/reference/a00529_ga6631af35ee817f93827c62bbda41674a_cgraph.map100644 025423 025423 00000000337 13242511135 0021272 freetds-1.00.82/doc/reference/a00529_ga6631af35ee817f93827c62bbda41674a_cgraph.md5100644 025423 025423 00000000040 13242511133 00211671cbfb297c815edd43567812f1b534bfefreetds-1.00.82/doc/reference/a00529_ga6631af35ee817f93827c62bbda41674a_cgraph.svg100644 025423 025423 00000003165 13242511136 0021317 tds_read_interfaces Node26 tds_read_interfaces Node27 tdsdump_log Node26->Node27 freetds-1.00.82/doc/reference/a00529_gaa9670914093b354e7a123b10ba877813_cgraph.map100644 025423 025423 00000001105 13242511135 0020747 freetds-1.00.82/doc/reference/a00529_gaa9670914093b354e7a123b10ba877813_cgraph.md5100644 025423 025423 00000000040 13242511133 0020652b3af4b0b9fb8bc8cdea125e3e1119e9afreetds-1.00.82/doc/reference/a00529_gaa9670914093b354e7a123b10ba877813_cgraph.svg100644 025423 025423 00000007101 13242511136 0020774 parse_server_name_for_port Node0 parse_server_name_for_port Node1 tds_dstr_cstr Node0->Node1 Node2 tds_dstr_copy Node0->Node2 Node3 tds_dstr_copyn Node0->Node3 Node2->Node3 freetds-1.00.82/doc/reference/a00529_gaca20b6e5f5a5ac1727126712dd39564b_cgraph.map100644 025423 025423 00000000343 13242511135 0021246 freetds-1.00.82/doc/reference/a00529_gaca20b6e5f5a5ac1727126712dd39564b_cgraph.md5100644 025423 025423 00000000040 13242511133 00211467a2e12c5780d16ba039a37352221b4f4freetds-1.00.82/doc/reference/a00529_gaca20b6e5f5a5ac1727126712dd39564b_cgraph.svg100644 025423 025423 00000003161 13242511136 0021272 search_interface_file Node5 search_interface_file Node6 tdsdump_log Node5->Node6 freetds-1.00.82/doc/reference/a00529_gaf49eca946d1b2457e189de7207e3670c_cgraph.map100644 025423 025423 00000000322 13242511135 0021275 freetds-1.00.82/doc/reference/a00529_gaf49eca946d1b2457e189de7207e3670c_cgraph.md5100644 025423 025423 00000000040 13242511133 00212008c478487b1d0011f01378745d141373ffreetds-1.00.82/doc/reference/a00529_gaf49eca946d1b2457e189de7207e3670c_cgraph.svg100644 025423 025423 00000003145 13242511136 0021326 tds_get_home_file Node12 tds_get_home_file Node13 tds_get_homedir Node12->Node13 freetds-1.00.82/doc/reference/a00530.html100644 025423 025423 00000171643 13242511136 0013241 FreeTDS API: Conversion
    FreeTDS API

    Conversions between datatypes. More...

    Collaboration diagram for Conversion:

    Macros

    #define CASE_ALL_BINARY
     
    #define CASE_ALL_CHAR   SYBCHAR: case SYBVARCHAR: case SYBTEXT: case XSYBCHAR: case XSYBVARCHAR
     
    #define is_monthname(s)   (store_monthname(s, NULL) >= 0)
     
    #define string_to_result(s, cr)   string_to_result(desttype, s, cr)
     

    Functions

    static TDS_INT binary_to_result (int desttype, const void *data, size_t len, CONV_RESULT *cr)
     Copy binary data to to result and return len or TDS_CONVERT_NOMEM.
     
    static bool is_alphabetic (const char *)
     
    static bool is_ampm (const char *)
     
    static bool is_dd_mon_yyyy (char *t)
     
    static bool is_numeric (const char *)
     
    static bool is_numeric_dateformat (const char *)
     
    static bool is_timeformat (const char *)
     
    static TDS_INT parse_int8 (const char *buf, const char *pend, TDS_UINT8 *res, bool *p_negative)
     convert a number in string to TDS_INT8 More...
     
    static const char * parse_numeric (const char *buf, const char *pend, bool *p_negative, size_t *p_digits, size_t *p_decimals)
     Parse a string for numbers. More...
     
    static int store_dd_mon_yyy_date (char *datestr, struct tds_time *t)
     
    static int store_hour (const char *, const char *, struct tds_time *)
     
    static int store_mday (const char *, struct tds_time *)
     
    static int store_monthname (const char *datestr, struct tds_time *t)
     Test if a string is a month name and store correct month number. More...
     
    static int store_numeric_date (const char *, struct tds_time *)
     
    static int store_time (const char *, struct tds_time *)
     
    static int store_year (int, struct tds_time *)
     
    static int store_yymmdd_date (const char *, struct tds_time *)
     
    static int string_to_datetime (const char *datestr, TDS_UINT len, int desttype, CONV_RESULT *cr)
     
    static TDS_INT string_to_float (const TDS_CHAR *src, TDS_UINT srclen, int desttype, CONV_RESULT *cr)
     
    static TDS_INT string_to_int (const char *buf, const char *pend, TDS_INT *res)
     convert a number in string to TDS_INT More...
     
    static TDS_INT string_to_int8 (const char *buf, const char *pend, TDS_INT8 *res)
     convert a number in string to TDS_INT8 More...
     
    static int string_to_numeric (const char *instr, const char *pend, CONV_RESULT *cr)
     convert a number in string to a TDSNUMERIC More...
     
    static TDS_INT string_to_result (int desttype, const char *s, CONV_RESULT *cr)
     Copy a terminated string to result and return len or TDS_CONVERT_NOMEM.
     
    static TDS_INT string_to_uint8 (const char *buf, const char *pend, TDS_UINT8 *res)
     convert a number in string to TDS_UINT8 More...
     
    static int stringz_to_numeric (const char *instr, CONV_RESULT *cr)
     convert a zero terminated string to NUMERIC More...
     
    TDS_INT tds_char2hex (TDS_CHAR *dest, TDS_UINT destlen, const TDS_CHAR *src, TDS_UINT srclen)
     
    TDS_INT tds_convert (const TDSCONTEXT *tds_ctx, int srctype, const TDS_CHAR *src, TDS_UINT srclen, int desttype, CONV_RESULT *cr)
     tds_convert convert a type to another. More...
     
    static TDS_INT tds_convert_bigdatetime (const TDSCONTEXT *tds_ctx, const TDS_BIGDATETIME *bigdatetime, int desttype, CONV_RESULT *cr)
     
    static TDS_INT tds_convert_bigtime (const TDSCONTEXT *tds_ctx, const TDS_BIGTIME *bigtime, int desttype, CONV_RESULT *cr)
     
    static TDS_INT tds_convert_binary (const TDS_UCHAR *src, TDS_INT srclen, int desttype, CONV_RESULT *cr)
     
    static TDS_INT tds_convert_bit (const TDS_CHAR *src, int desttype, CONV_RESULT *cr)
     
    static TDS_INT tds_convert_char (const TDS_CHAR *src, TDS_UINT srclen, int desttype, CONV_RESULT *cr)
     
    static TDS_INT tds_convert_date (const TDSCONTEXT *tds_ctx, const TDS_DATE *date, int desttype, CONV_RESULT *cr)
     
    static TDS_INT tds_convert_datetime (const TDSCONTEXT *tds_ctx, const TDS_DATETIME *dt, int desttype, unsigned precision, CONV_RESULT *cr)
     
    static TDS_INT tds_convert_datetime4 (const TDSCONTEXT *tds_ctx, const TDS_DATETIME4 *dt4, int desttype, CONV_RESULT *cr)
     
    static TDS_INT tds_convert_datetimeall (const TDSCONTEXT *tds_ctx, int srctype, const TDS_DATETIMEALL *dta, int desttype, CONV_RESULT *cr)
     
    static TDS_INT tds_convert_flt8 (const TDS_FLOAT *src, int desttype, CONV_RESULT *cr)
     
    static TDS_INT tds_convert_int (TDS_INT num, int desttype, CONV_RESULT *cr)
     
    static TDS_INT tds_convert_int1 (const TDS_TINYINT *src, int desttype, CONV_RESULT *cr)
     
    static TDS_INT tds_convert_int2 (const TDS_SMALLINT *src, int desttype, CONV_RESULT *cr)
     
    static TDS_INT tds_convert_int4 (const TDS_INT *src, int desttype, CONV_RESULT *cr)
     
    static TDS_INT tds_convert_int8 (const TDS_INT8 *src, int desttype, CONV_RESULT *cr)
     
    static TDS_INT tds_convert_int8_numeric (unsigned char scale, unsigned char sign, TDS_UINT8 num, CONV_RESULT *cr)
     
    static TDS_INT tds_convert_int_numeric (unsigned char scale, unsigned char sign, TDS_UINT num, CONV_RESULT *cr)
     
    static TDS_INT tds_convert_money (const TDS_MONEY *src, int desttype, CONV_RESULT *cr)
     
    static TDS_INT tds_convert_money4 (const TDS_MONEY4 *src, int desttype, CONV_RESULT *cr)
     
    static TDS_INT tds_convert_numeric (const TDS_NUMERIC *src, int desttype, CONV_RESULT *cr)
     
    static TDS_INT tds_convert_real (const TDS_REAL *src, int desttype, CONV_RESULT *cr)
     
    static TDS_INT tds_convert_time (const TDSCONTEXT *tds_ctx, const TDS_TIME *time, int desttype, CONV_RESULT *cr)
     
    static TDS_INT tds_convert_to_binary (int srctype, const TDS_CHAR *src, TDS_UINT srclen, int desttype, CONV_RESULT *cr)
     
    static TDS_INT tds_convert_uint2 (const TDS_USMALLINT *src, int desttype, CONV_RESULT *cr)
     
    static TDS_INT tds_convert_uint4 (const TDS_UINT *src, int desttype, CONV_RESULT *cr)
     
    static TDS_INT tds_convert_uint8 (const TDS_UINT8 *src, int desttype, CONV_RESULT *cr)
     
    static TDS_INT tds_convert_unique (const TDS_CHAR *src, int desttype, CONV_RESULT *cr)
     
    TDSRET tds_datecrack (TDS_INT datetype, const void *di, TDSDATEREC *dr)
     Convert from db date format to a structured date format. More...
     
    TDS_SERVER_TYPE tds_get_null_type (TDS_SERVER_TYPE srctype)
     Get same type but nullable. More...
     
    size_t tds_strftime (char *buf, size_t maxsize, const char *format, const TDSDATEREC *dr, int prec)
     format a date string according to an "extended" strftime(3) formatting definition. More...
     
    unsigned char tds_willconvert (int srctype, int desttype)
     Test if a conversion is possible. More...
     

    Variables

    const char tds_hex_digits [] = "0123456789abcdef"
     

    Detailed Description

    Conversions between datatypes.

    Supports, for example, dbconvert().

    Macro Definition Documentation

    § CASE_ALL_BINARY

    #define CASE_ALL_BINARY
    Value:
    SYBBINARY: case SYBVARBINARY: case SYBIMAGE: case XSYBBINARY: case XSYBVARBINARY: \
    case SYBLONGBINARY: case TDS_CONVERT_BINARY

    Function Documentation

    § parse_int8()

    static TDS_INT parse_int8 ( const char *  buf,
    const char *  pend,
    TDS_UINT8 *  res,
    bool *  p_negative 
    )
    static

    convert a number in string to TDS_INT8

    Returns
    TDS_CONVERT_* or failure code on error
    Here is the call graph for this function:
    Here is the caller graph for this function:

    § parse_numeric()

    static const char * parse_numeric ( const char *  buf,
    const char *  pend,
    bool *  p_negative,
    size_t *  p_digits,
    size_t *  p_decimals 
    )
    static

    Parse a string for numbers.

    Syntax can be something like " *[+-] *[0-9]*\.[0-9]* *".

    The function ignore all spaces. It strips leading zeroes which could possibly lead to overflow. The function returns a pointer to the integer part followed by *p_digits digits followed by a dot followed by *p_decimals digits (dot and fractional digits are optional, in this case *p_decimals is 0).

    Parameters
    bufstart of string
    pendpointer to string end
    p_negativestore if number is negative
    p_digitsstore number of integer digits
    p_decimalsstore number of fractional digits
    Returns
    pointer to first not zero digit. If NULL this indicate a syntax error.
    Here is the caller graph for this function:

    § store_monthname()

    static int store_monthname ( const char *  datestr,
    struct tds_time t 
    )
    static

    Test if a string is a month name and store correct month number.

    Returns
    month number (0-11) or -1 if not match
    Parameters
    datestrstring to check
    twhere to store month (if NULL no store is done)
    Here is the call graph for this function:

    § string_to_int()

    static TDS_INT string_to_int ( const char *  buf,
    const char *  pend,
    TDS_INT *  res 
    )
    static

    convert a number in string to TDS_INT

    Returns
    TDS_CONVERT_* or failure code on error
    Remarks
    Sybase's char->int conversion tolerates embedded blanks, such that "convert( int, ' - 13 ' )" works. If we find blanks, we copy the string to a temporary buffer, skipping the blanks. We return the results of atoi() with a clean string.

    n.b. it is possible to embed all sorts of non-printable characters, but we only check for spaces. at this time, no one on the project has tested anything else.

    Here is the call graph for this function:

    § string_to_int8()

    static TDS_INT string_to_int8 ( const char *  buf,
    const char *  pend,
    TDS_INT8 *  res 
    )
    static

    convert a number in string to TDS_INT8

    Returns
    TDS_CONVERT_* or failure code on error
    Here is the call graph for this function:

    § string_to_numeric()

    static int string_to_numeric ( const char *  instr,
    const char *  pend,
    CONV_RESULT cr 
    )
    static

    convert a number in string to a TDSNUMERIC

    Returns
    sizeof(TDS_NUMERIC) on success, TDS_CONVERT_* failure code on failure
    Here is the caller graph for this function:

    § string_to_uint8()

    static TDS_INT string_to_uint8 ( const char *  buf,
    const char *  pend,
    TDS_UINT8 *  res 
    )
    static

    convert a number in string to TDS_UINT8

    Returns
    TDS_CONVERT_* or failure code on error
    Here is the call graph for this function:

    § stringz_to_numeric()

    static int stringz_to_numeric ( const char *  instr,
    CONV_RESULT cr 
    )
    static

    convert a zero terminated string to NUMERIC

    Returns
    sizeof(TDS_NUMERIC) on success, TDS_CONVERT_* failure code on failure
    Here is the call graph for this function:

    § tds_convert()

    TDS_INT tds_convert ( const TDSCONTEXT tds_ctx,
    int  srctype,
    const TDS_CHAR *  src,
    TDS_UINT  srclen,
    int  desttype,
    CONV_RESULT cr 
    )

    tds_convert convert a type to another.

    If you convert to SYBDECIMAL/SYBNUMERIC you MUST initialize precision and scale of cr. Do not expect strings to be zero terminated. Databases support zero inside string. Using strlen may result on data loss or even a segmentation fault. Instead, use memcpy to copy destination using length returned. This function does not handle NULL, srclen should be >0. Client libraries handle NULLs each in their own way.

    Parameters
    tds_ctxcontext (used in conversion to data and to return messages)
    srctypetype of source
    srcpointer to source data to convert
    srclenlength in bytes of source (not counting terminator or strings)
    desttypetype of destination
    crstructure to hold result
    Returns
    length of result or TDS_CONVERT_* failure code on failure. All TDS_CONVERT_* constants are <0.

    § tds_datecrack()

    TDSRET tds_datecrack ( TDS_INT  datetype,
    const void *  di,
    TDSDATEREC dr 
    )

    Convert from db date format to a structured date format.

    Parameters
    datetypesource date type. SYBDATETIME or SYBDATETIME4
    disource date
    drdestination date
    Returns
    TDS_FAIL or TDS_SUCCESS

    § tds_get_null_type()

    TDS_SERVER_TYPE tds_get_null_type ( TDS_SERVER_TYPE  srctype)

    Get same type but nullable.

    Parameters
    srctypetype requires
    Returns
    nullable type

    § tds_strftime()

    size_t tds_strftime ( char *  buf,
    size_t  maxsize,
    const char *  format,
    const TDSDATEREC dr,
    int  prec 
    )

    format a date string according to an "extended" strftime(3) formatting definition.

    Parameters
    bufoutput buffer
    maxsizesize of buffer in bytes (space include terminator)
    formatformat string passed to strftime(3), except that z represents fraction of seconds.
    drdate to convert
    precsecond fraction precision (0-7).
    Returns
    length of string returned, 0 for error

    § tds_willconvert()

    unsigned char tds_willconvert ( int  srctype,
    int  desttype 
    )

    Test if a conversion is possible.

    Parameters
    srctypesource type
    desttypedestination type
    Returns
    0 if not convertible
    Here is the call graph for this function:
    freetds-1.00.82/doc/reference/a00530.map100644 025423 025423 00000000245 13242511135 0013036 freetds-1.00.82/doc/reference/a00530.md5100644 025423 025423 00000000040 13242511133 001273586e7b7aa97ce146d22dbe5451f847aeafreetds-1.00.82/doc/reference/a00530.svg100644 025423 025423 00000003021 13242511136 0013054 Conversion Node0 Conversion Node1 LibTDS API Node1->Node0 freetds-1.00.82/doc/reference/a00530_ga0176fafd412b5b8005bf1202fbc13b00_cgraph.map100644 025423 025423 00000000316 13242511135 0021262 freetds-1.00.82/doc/reference/a00530_ga0176fafd412b5b8005bf1202fbc13b00_cgraph.md5100644 025423 025423 00000000040 13242511133 0021162ce2871165b69467c3232626ccbc3f391freetds-1.00.82/doc/reference/a00530_ga0176fafd412b5b8005bf1202fbc13b00_cgraph.svg100644 025423 025423 00000003134 13242511136 0021306 string_to_int Node14 string_to_int Node15 parse_numeric Node14->Node15 freetds-1.00.82/doc/reference/a00530_ga17a0597ec3522c7f1ddb54956226dbfc_cgraph.map100644 025423 025423 00000000327 13242511135 0021335 freetds-1.00.82/doc/reference/a00530_ga17a0597ec3522c7f1ddb54956226dbfc_cgraph.md5100644 025423 025423 00000000040 13242511133 002123349c46c6a038046978b4de7b14eb5d154freetds-1.00.82/doc/reference/a00530_ga17a0597ec3522c7f1ddb54956226dbfc_cgraph.svg100644 025423 025423 00000003147 13242511136 0021363 store_monthname Node11 store_monthname Node12 tdsdump_log Node11->Node12 freetds-1.00.82/doc/reference/a00530_ga28c75aff2615032005257af7455ed70d_icgraph.map100644 025423 025423 00000000346 13242511135 0021260 freetds-1.00.82/doc/reference/a00531.html100644 025423 025423 00000126044 13242511136 0013235 FreeTDS API: Charset conversion
    FreeTDS API

    Convert between different charsets. More...

    Collaboration diagram for Charset conversion:

    Macros

    #define CHUNK_ALLOC   4
     

    Typedefs

    typedef TDS_UINT ICONV_CHAR
     
    typedef int(* iconv_get_t) (const unsigned char *p, size_t len, ICONV_CHAR *out)
     
    typedef int(* iconv_put_t) (unsigned char *buf, size_t buf_len, ICONV_CHAR c)
     

    Enumerations

    enum  ICONV_CD_VALUE { Like_to_Like = 0x100 }
     

    Functions

    static void _iconv_close (iconv_t *cd)
     
    static int collate2charset (int sql_collate, int lcid)
     
    static int get_ascii (const unsigned char *p, size_t len, ICONV_CHAR *out)
     
    static int get_err (const unsigned char *p, size_t len, ICONV_CHAR *out)
     
    static int get_iso1 (const unsigned char *p, size_t len, ICONV_CHAR *out)
     
    static int get_ucs4be (const unsigned char *p, size_t len, ICONV_CHAR *out)
     
    static int get_ucs4le (const unsigned char *p, size_t len, ICONV_CHAR *out)
     
    static int get_utf16be (const unsigned char *p, size_t len, ICONV_CHAR *out)
     
    static int get_utf16le (const unsigned char *p, size_t len, ICONV_CHAR *out)
     
    static int get_utf8 (const unsigned char *p, size_t len, ICONV_CHAR *out)
     
    static int lookup_canonic (const CHARACTER_SET_ALIAS aliases[], const char *charset_name)
     
    static int put_ascii (unsigned char *buf, size_t buf_len, ICONV_CHAR c)
     
    static int put_err (unsigned char *buf, size_t buf_len, ICONV_CHAR c)
     
    static int put_iso1 (unsigned char *buf, size_t buf_len, ICONV_CHAR c)
     
    static int put_ucs4be (unsigned char *buf, size_t buf_len, ICONV_CHAR c)
     
    static int put_ucs4le (unsigned char *buf, size_t buf_len, ICONV_CHAR c)
     
    static int put_utf16be (unsigned char *buf, size_t buf_len, ICONV_CHAR c)
     
    static int put_utf16le (unsigned char *buf, size_t buf_len, ICONV_CHAR c)
     
    static int put_utf8 (unsigned char *buf, size_t buf_len, ICONV_CHAR c)
     
    static size_t skip_one_input_sequence (iconv_t cd, const TDS_ENCODING *charset, const char **input, size_t *input_size)
     Move the input sequence pointer to the next valid position. More...
     
    void tds7_srv_charset_changed (TDSCONNECTION *conn, int sql_collate, int lcid)
     
    static int tds_canonical_charset (const char *charset_name)
     Determine canonical iconv character set. More...
     
    const char * tds_canonical_charset_name (const char *charset_name)
     Determine canonical iconv character set name. More...
     
    size_t tds_iconv (TDSSOCKET *tds, TDSICONV *conv, TDS_ICONV_DIRECTION io, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
     Wrapper around iconv(3). More...
     
    void tds_iconv_close (TDSCONNECTION *conn)
     
    static void tds_iconv_err (TDSSOCKET *tds, int err)
     
    void tds_iconv_free (TDSCONNECTION *conn)
     
    TDSICONVtds_iconv_from_collate (TDSCONNECTION *conn, TDS_UCHAR collate[5])
     Get iconv information from a LCID (to support different column encoding under MSSQL2K)
     
    TDSICONVtds_iconv_get (TDSCONNECTION *conn, const char *client_charset, const char *server_charset)
     
    static TDSICONVtds_iconv_get_info (TDSCONNECTION *conn, int canonic_client, int canonic_server)
     Get a iconv info structure, allocate and initialize if needed.
     
    static void tds_iconv_info_close (TDSICONV *char_conv)
     
    static int tds_iconv_info_init (TDSICONV *char_conv, int client_canonical, int server_canonical)
     Open iconv descriptors to convert between character sets (both directions). More...
     
    TDSRET tds_iconv_open (TDSCONNECTION *conn, const char *charset, int use_utf16)
     
    void tds_srv_charset_changed (TDSCONNECTION *conn, const char *charset)
     
    static void tds_srv_charset_changed_num (TDSCONNECTION *conn, int canonic_charset_num)
     
    size_t tds_sys_iconv (iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
     
    int tds_sys_iconv_close (iconv_t cd)
     
    iconv_t tds_sys_iconv_open (const char *tocode, const char *fromcode)
     Inputs are FreeTDS canonical names, no other. More...
     

    Variables

    static const iconv_get_t iconv_gets [8]
     
    static const iconv_put_t iconv_puts [8]
     
    static const unsigned char utf8_lengths [256]
     
    static const unsigned char utf8_masks [7]
     

    Detailed Description

    Convert between different charsets.

    Set up the initial iconv conversion descriptors.

    When the socket is allocated, three TDSICONV structures are attached to iconv. They have fixed meanings:

    • 0. Client <-> UCS-2 (client2ucs2)
    • 1. Client <-> server single-byte charset (client2server_chardata)

    Other designs that use less data are possible, but these three conversion needs are very often needed. By reserving them, we avoid searching the array for our most common purposes.

    To solve different iconv names and portability problems FreeTDS maintains a list of aliases each charset.

    First we discover the names of our minimum required charsets (UTF-8, ISO8859-1 and UCS2). Later, as and when it's needed, we try to discover others.

    There is one list of canonic names (GNU iconv names) and two sets of aliases (one for other iconv implementations and another for Sybase). For every canonic charset name we cache the iconv name found during discovery.

    Function Documentation

    § skip_one_input_sequence()

    static size_t skip_one_input_sequence ( iconv_t  cd,
    const TDS_ENCODING charset,
    const char **  input,
    size_t *  input_size 
    )
    static

    Move the input sequence pointer to the next valid position.

    Used when an input character cannot be converted.

    Returns
    number of bytes to skip.

    § tds_canonical_charset()

    static int tds_canonical_charset ( const char *  charset_name)
    static

    Determine canonical iconv character set.

    Returns
    canonical position, or -1 if lookup failed.
    Remarks
    Returned name can be used in bytes_per_char(), above.
    Here is the caller graph for this function:

    § tds_canonical_charset_name()

    const char* tds_canonical_charset_name ( const char *  charset_name)

    Determine canonical iconv character set name.

    Returns
    canonical name, or NULL if lookup failed.
    Remarks
    Returned name can be used in bytes_per_char(), above.
    Here is the call graph for this function:

    § tds_iconv()

    size_t tds_iconv ( TDSSOCKET tds,
    TDSICONV conv,
    TDS_ICONV_DIRECTION  io,
    const char **  inbuf,
    size_t *  inbytesleft,
    char **  outbuf,
    size_t *  outbytesleft 
    )

    Wrapper around iconv(3).

    Same parameters, with slightly different behavior.

    Parameters
    tdsstate information for the socket and the TDS protocol
    ioEnumerated value indicating whether the data are being sent to or received from the server.
    convinformation about the encodings involved, including the iconv(3) conversion descriptors.
    inbufaddress of pointer to the input buffer of data to be converted.
    inbytesleftaddress of count of bytes in inbuf.
    outbufaddress of pointer to the output buffer.
    outbytesleftaddress of count of bytes in outbuf.
    Return values
    numberof irreversible conversions performed. -1 on error, see iconv(3) documentation for a description of the possible values of errno.
    Remarks
    Unlike iconv(3), none of the arguments can be nor point to NULL. Like iconv(3), all pointers will be updated. Success is signified by a nonnegative return code and *inbytesleft == 0. If the conversion descriptor in iconv is -1 or NULL, inbuf is copied to outbuf, and all parameters updated accordingly.

    If a character in inbuf cannot be converted because no such cbaracter exists in the outbuf character set, we emit messages similar to the ones Sybase emits when it fails such a conversion. The message varies depending on the direction of the data. On a read error, we emit Msg 2403, Severity 16 (EX_INFO): "WARNING! Some character(s) could not be converted into client's character set. Unconverted bytes were changed to question marks ('?')." On a write error we emit Msg 2402, Severity 16 (EX_USER): "Error converting client characters into server's character set. Some character(s) could not be converted." and return an error code. Client libraries relying on this routine should reflect an error back to the application.

    Todo:

    Check for variable multibyte non-UTF-8 input character set.

    Use more robust error message generation.

    For reads, cope with outbuf encodings that don't have the equivalent of an ASCII '?'.

    Support alternative to '?' for the replacement character.

    Here is the call graph for this function:
    Here is the caller graph for this function:

    § tds_iconv_info_init()

    static int tds_iconv_info_init ( TDSICONV char_conv,
    int  client_canonical,
    int  server_canonical 
    )
    static

    Open iconv descriptors to convert between character sets (both directions).

    1. Look up the canonical names of the character sets.
    2. Look up their widths.
    3. Ask iconv to open a conversion descriptor.
    4. Fail if any of the above offer any resistance.
      Remarks
      The charset names written to iconv will be the canonical names, not necessarily the names passed in.
    Here is the call graph for this function:

    § tds_sys_iconv_open()

    iconv_t tds_sys_iconv_open ( const char *  tocode,
    const char *  fromcode 
    )

    Inputs are FreeTDS canonical names, no other.

    No alias list is consulted.

    Variable Documentation

    § iconv_gets

    const iconv_get_t iconv_gets[8]
    static
    Initial value:
    = {
    get_iso1, get_ascii, get_utf16le, get_utf16be, get_ucs4le, get_ucs4be, get_utf8, get_err
    }

    § iconv_puts

    const iconv_put_t iconv_puts[8]
    static
    Initial value:
    = {
    put_iso1, put_ascii, put_utf16le, put_utf16be, put_ucs4le, put_ucs4be, put_utf8, put_err
    }

    § utf8_lengths

    const unsigned char utf8_lengths[256]
    static
    Initial value:
    = {
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
    2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
    3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
    4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 0, 0,
    }

    § utf8_masks

    const unsigned char utf8_masks[7]
    static
    Initial value:
    = {
    0, 0x7f, 0x1f, 0x0f, 0x07, 0x03, 0x01
    }
    freetds-1.00.82/doc/reference/a00531.map100644 025423 025423 00000000265 13242511135 0013041 freetds-1.00.82/doc/reference/a00530_ga28c75aff2615032005257af7455ed70d_icgraph.md5100644 025423 025423 00000000040 13242511133 0021155e3b51144b034f433839f247c47843fe0freetds-1.00.82/doc/reference/a00530_ga28c75aff2615032005257af7455ed70d_icgraph.svg100644 025423 025423 00000003176 13242511136 0021307 string_to_numeric Node22 string_to_numeric Node23 stringz_to_numeric Node22->Node23 freetds-1.00.82/doc/reference/a00530_ga467401163bf05ed167f7b2b7e8bd875a_cgraph.map100644 025423 025423 00000000347 13242511135 0021262 freetds-1.00.82/doc/reference/a00530_ga467401163bf05ed167f7b2b7e8bd875a_cgraph.md5100644 025423 025423 00000000040 13242511133 0021156b81f37ff89c586ec6c008cd6aac23354freetds-1.00.82/doc/reference/a00530_ga467401163bf05ed167f7b2b7e8bd875a_cgraph.svg100644 025423 025423 00000003200 13242511136 0021274 stringz_to_numeric Node28 stringz_to_numeric Node29 string_to_numeric Node28->Node29 freetds-1.00.82/doc/reference/a00530_ga53a19b5da172ff364d01e8f04b97015a_icgraph.map100644 025423 025423 00000001311 13242511135 0021404 freetds-1.00.82/doc/reference/a00530_ga53a19b5da172ff364d01e8f04b97015a_icgraph.md5100644 025423 025423 00000000040 13242511133 00213100db0c9160d711fb08e0be7cd2e38d81bfreetds-1.00.82/doc/reference/a00530_ga53a19b5da172ff364d01e8f04b97015a_icgraph.svg100644 025423 025423 00000007665 13242511136 0021451 parse_numeric Node6 parse_numeric Node7 string_to_int Node6->Node7 Node8 parse_int8 Node6->Node8 Node9 string_to_int8 Node8->Node9 Node10 string_to_uint8 Node8->Node10 freetds-1.00.82/doc/reference/a00530_ga80487b313213f60d8be71a50a002bb2c_cgraph.map100644 025423 025423 00000000327 13242511135 0021135 freetds-1.00.82/doc/reference/a00530_ga80487b313213f60d8be71a50a002bb2c_cgraph.md5100644 025423 025423 00000000040 13242511133 00210338e1fd30feb5c08e2c9597e2a0251aef3freetds-1.00.82/doc/reference/a00530_ga80487b313213f60d8be71a50a002bb2c_cgraph.svg100644 025423 025423 00000003145 13242511136 0021161 tds_willconvert Node39 tds_willconvert Node40 tdsdump_log Node39->Node40 freetds-1.00.82/doc/reference/a00530_ga933f87cca76156648e91f472650b98f3_cgraph.map100644 025423 025423 00000000564 13242511135 0021074 freetds-1.00.82/doc/reference/a00530_ga933f87cca76156648e91f472650b98f3_cgraph.md5100644 025423 025423 00000000040 13242511133 0020767ae4dab15d80e1a83e3e3e4a3163e798ffreetds-1.00.82/doc/reference/a00530_ga933f87cca76156648e91f472650b98f3_cgraph.svg100644 025423 025423 00000004525 13242511136 0021120 string_to_int8 Node17 string_to_int8 Node18 parse_int8 Node17->Node18 Node19 parse_numeric Node18->Node19 freetds-1.00.82/doc/reference/a00530_gace939c1fa676d172cb0cae94848b7fac_cgraph.map100644 025423 025423 00000000310 13242511135 0021555 freetds-1.00.82/doc/reference/a00530_gace939c1fa676d172cb0cae94848b7fac_cgraph.md5100644 025423 025423 00000000040 13242511133 0021463e1952ffd9c792e460ae748f1bbc923a0freetds-1.00.82/doc/reference/a00530_gace939c1fa676d172cb0cae94848b7fac_cgraph.svg100644 025423 025423 00000003110 13242511136 0021601 parse_int8 Node0 parse_int8 Node1 parse_numeric Node0->Node1 freetds-1.00.82/doc/reference/a00530_gace939c1fa676d172cb0cae94848b7fac_icgraph.map100644 025423 025423 00000000571 13242511135 0021737 freetds-1.00.82/doc/reference/a00530_gace939c1fa676d172cb0cae94848b7fac_icgraph.md5100644 025423 025423 00000000040 13242511133 002163478d57be8bbfb3dce12b31279af74d8b6freetds-1.00.82/doc/reference/a00530_gace939c1fa676d172cb0cae94848b7fac_icgraph.svg100644 025423 025423 00000004616 13242511136 0021766 parse_int8 Node2 parse_int8 Node3 string_to_int8 Node2->Node3 Node4 string_to_uint8 Node2->Node4 freetds-1.00.82/doc/reference/a00530_gae8e173a9f8d2e3f152ada9f48d3d5f28_cgraph.map100644 025423 025423 00000000566 13242511135 0021521 freetds-1.00.82/doc/reference/a00530_gae8e173a9f8d2e3f152ada9f48d3d5f28_cgraph.md5100644 025423 025423 00000000040 13242511133 0021412b896665ccc5b10f7ab4f82cc72adbf22freetds-1.00.82/doc/reference/a00530_gae8e173a9f8d2e3f152ada9f48d3d5f28_cgraph.svg100644 025423 025423 00000004526 13242511136 0021544 string_to_uint8 Node24 string_to_uint8 Node25 parse_int8 Node24->Node25 Node26 parse_numeric Node25->Node26 freetds-1.00.82/doc/reference/a00531.md5100644 025423 025423 00000000040 13242511133 001273654da1cab23c0dfa1ec9c70a921b03882freetds-1.00.82/doc/reference/a00531.svg100644 025423 025423 00000003052 13242511136 0013061 Charset conversion Node0 Charset conversion Node1 LibTDS API Node1->Node0 freetds-1.00.82/doc/reference/a00532.html100644 025423 025423 00000144036 13242511136 0013237 FreeTDS API: Memory allocation
    FreeTDS API
    Memory allocation

    Allocate or free resources. More...

    Collaboration diagram for Memory allocation:

    Macros

    #define REQ(i, n)   |(((TDS_REQ_ ## n / 8) == i)?(1<<(TDS_REQ_ ## n & 7)):0)
     
    #define REQB(i)   0 SUPPORTED_REQ_CAP(i)
     
    #define RES(i, n)   |(((TDS_RES_ ## n / 8) == i)?(1<<(TDS_RES_ ## n & 7)):0)
     
    #define RESB(i)   0 SUPPORTED_RES_CAP(i)
     
    #define SQLS_ENTRY(number, state)   case number: p = state; break
     
    #define SUPPORTED_REQ_CAP(i)
     
    #define SUPPORTED_RES_CAP(i)   RES(i,CON_NOOOB) RES(i,PROTO_NOTEXT) RES(i,PROTO_NOBULK) RES(i,NOTDSDEBUG)
     

    Functions

    BCPCOLDATAtds_alloc_bcp_column_data (unsigned int column_size)
     
    TDSBCPINFOtds_alloc_bcpinfo (void)
     
    char * tds_alloc_client_sqlstate (int msgno)
     
    static TDSCOLUMNtds_alloc_column (void)
     
    static TDSCOMPUTEINFOtds_alloc_compute_result (TDS_USMALLINT num_cols, TDS_USMALLINT by_cols)
     Allocate memory for storing compute info return NULL on out of memory.
     
    TDSCOMPUTEINFO ** tds_alloc_compute_results (TDSSOCKET *tds, TDS_USMALLINT num_cols, TDS_USMALLINT by_cols)
     
    TDSRET tds_alloc_compute_row (TDSCOMPUTEINFO *res_info)
     
    TDSCONTEXTtds_alloc_context (void *parent)
     
    TDSCURSORtds_alloc_cursor (TDSSOCKET *tds, const char *name, TDS_INT namelen, const char *query, TDS_INT querylen)
     
    TDSDYNAMICtds_alloc_dynamic (TDSCONNECTION *conn, const char *id)
     Allocate a dynamic statement. More...
     
    TDSLOCALEtds_alloc_locale (void)
     
    TDSLOGINtds_alloc_login (int use_environment)
     
    char * tds_alloc_lookup_sqlstate (TDSSOCKET *tds, int msgno)
     
    TDSPACKETtds_alloc_packet (void *buf, unsigned len)
     
    void * tds_alloc_param_data (TDSCOLUMN *curparam)
     Allocate data for a parameter. More...
     
    TDSPARAMINFOtds_alloc_param_result (TDSPARAMINFO *old_param)
     Adds a output parameter to TDSPARAMINFO. More...
     
    TDSRESULTINFOtds_alloc_results (TDS_USMALLINT num_cols)
     
    TDSRET tds_alloc_row (TDSRESULTINFO *res_info)
     Allocate space for row store return NULL on out of memory.
     
    TDSSOCKETtds_alloc_socket (TDSCONTEXT *context, unsigned int bufsize)
     
     TDS_COMPILE_CHECK (tds_values_len, sizeof(defaultcaps.types[0].values)==14)
     
     TDS_COMPILE_CHECK (tds_cap_len, sizeof(defaultcaps)==TDS_MAX_CAPABILITY)
     
    static void tds_connection_remove_socket (TDSCONNECTION *conn, TDSSOCKET *tds)
     
    void tds_cursor_deallocated (TDSCONNECTION *conn, TDSCURSOR *cursor)
     
    void tds_deinit_bcpinfo (TDSBCPINFO *bcpinfo)
     
    static void tds_deinit_connection (TDSCONNECTION *conn)
     
    void tds_detach_results (TDSRESULTINFO *info)
     Detach result info from it current socket.
     
    void tds_dynamic_deallocated (TDSCONNECTION *conn, TDSDYNAMIC *dyn)
     
    void tds_free_all_results (TDSSOCKET *tds)
     
    void tds_free_bcp_column_data (BCPCOLDATA *coldata)
     
    void tds_free_bcpinfo (TDSBCPINFO *bcpinfo)
     
    static void tds_free_column (TDSCOLUMN *col)
     
    static void tds_free_compute_result (TDSCOMPUTEINFO *comp_info)
     
    static void tds_free_compute_results (TDSSOCKET *tds)
     
    void tds_free_context (TDSCONTEXT *context)
     
    static void tds_free_env (TDSCONNECTION *conn)
     
    void tds_free_input_params (TDSDYNAMIC *dyn)
     Frees all allocated input parameters of a dynamic statement. More...
     
    void tds_free_locale (TDSLOCALE *locale)
     
    void tds_free_login (TDSLOGIN *login)
     
    void tds_free_msg (TDSMESSAGE *message)
     
    void tds_free_packets (TDSPACKET *packet)
     
    void tds_free_param_result (TDSPARAMINFO *param_info)
     Delete latest parameter.
     
    void tds_free_param_results (TDSPARAMINFO *param_info)
     
    void tds_free_results (TDSRESULTINFO *res_info)
     
    void tds_free_row (TDSRESULTINFO *res_info, unsigned char *row)
     
    void tds_free_socket (TDSSOCKET *tds)
     
    static char * tds_get_dynid (TDSCONNECTION *conn, char *id)
     Get an id for dynamic query based on TDS information. More...
     
    static TDSCONNECTIONtds_init_connection (TDSCONNECTION *conn, TDSCONTEXT *context, unsigned int bufsize)
     
    TDSLOGINtds_init_login (TDSLOGIN *login, TDSLOCALE *locale)
     Initialize login structure with locale information and other stuff for connection. More...
     
    static TDSSOCKETtds_init_socket (TDSSOCKET *tds_socket, unsigned int bufsize)
     
    static void tds_param_free (TDSCOLUMN *col)
     
    void * tds_realloc (void **pp, size_t new_size)
     Reallocate a pointer and update it if success. More...
     
    TDSPACKETtds_realloc_packet (TDSPACKET *packet, unsigned len)
     
    TDSSOCKETtds_realloc_socket (TDSSOCKET *tds, size_t bufsize)
     
    void tds_release_cursor (TDSCURSOR **pcursor)
     
    void tds_release_dynamic (TDSDYNAMIC **pdyn)
     Frees dynamic statement. More...
     
    static void tds_row_free (TDSRESULTINFO *res_info, unsigned char *row)
     
    void tds_set_current_results (TDSSOCKET *tds, TDSRESULTINFO *info)
     
    static int winsock_initialized (void)
     

    Variables

    static const TDS_CAPABILITIES defaultcaps
     
    static volatile unsigned int inc_num = 1
     
    const TDSCOLUMNFUNCS tds_invalid_funcs
     

    Detailed Description

    Allocate or free resources.

    Allocation can fail only on out of memory. In such case they return NULL and leave the state as before call. Mainly function names are in the form tds_alloc_XX or tds_free_XXX. tds_alloc_XXX functions allocate structures and return pointer to allocated data while tds_free_XXX take structure pointers and free them. Some functions require additional parameters to initialize structure correctly. The main exception are structures that use reference counting. These structures have tds_alloc_XXX functions but instead of tds_free_XXX use tds_release_XXX.

    Macro Definition Documentation

    § SUPPORTED_REQ_CAP

    #define SUPPORTED_REQ_CAP (   i)
    Value:
    REQ(i,LANG) REQ(i,RPC) REQ(i,EVT) REQ(i,MSTMT) REQ(i,BCP) REQ(i,CURSOR) REQ(i,DYNF) \
    REQ(i,MSG) REQ(i,PARAM) REQ(i,DATA_INT1) REQ(i,DATA_INT2) REQ(i,DATA_INT4) REQ(i,DATA_BIT) \
    REQ(i,DATA_CHAR) REQ(i,DATA_VCHAR) REQ(i,DATA_BIN) REQ(i,DATA_VBIN) REQ(i,DATA_MNY8) \
    REQ(i,DATA_MNY4) REQ(i,DATA_DATE8) REQ(i,DATA_DATE4) REQ(i,DATA_FLT4) REQ(i,DATA_FLT8) \
    REQ(i,DATA_NUM) REQ(i,DATA_TEXT) REQ(i,DATA_IMAGE) REQ(i,DATA_DEC) REQ(i,DATA_LCHAR) \
    REQ(i,DATA_LBIN) REQ(i,DATA_INTN) REQ(i,DATA_DATETIMEN) REQ(i,DATA_MONEYN) \
    REQ(i,CSR_PREV) REQ(i,CSR_FIRST) REQ(i,CSR_LAST) REQ(i,CSR_ABS) REQ(i,CSR_REL) \
    REQ(i,CSR_MULTI) REQ(i,CON_INBAND) REQ(i,PROTO_TEXT) REQ(i,PROTO_BULK) \
    REQ(i,DATA_SENSITIVITY) REQ(i,DATA_BOUNDARY) REQ(i,PROTO_DYNPROC) REQ(i,DATA_FLTN) \
    REQ(i,DATA_BITN) REQ(i,DATA_INT8) REQ(i,WIDETABLE) \
    REQ(i,DATA_UINT2) REQ(i,DATA_UINT4) REQ(i,DATA_UINT8) REQ(i,DATA_UINTN) REQ(i,LARGEIDENT) \
    REQ(i,SRVPKTSIZE) REQ(i,DATA_DATE) REQ(i,DATA_TIME) REQ(i,DATA_BIGTIME) REQ(i,DATA_BIGDATETIME)

    Function Documentation

    § tds_alloc_dynamic()

    TDSDYNAMIC * tds_alloc_dynamic ( TDSCONNECTION conn,
    const char *  id 
    )

    Allocate a dynamic statement.

    Parameters
    connthe connection within which to allocate the statement.
    ida character label identifying the statement.
    Returns
    a pointer to the allocated structure (NULL on failure).

    tds_alloc_dynamic is used to implement placeholder code under TDS 5.0

    Here is the call graph for this function:

    § tds_alloc_param_data()

    void* tds_alloc_param_data ( TDSCOLUMN curparam)

    Allocate data for a parameter.

    Parameters
    curparamparameter to retrieve size information
    Returns
    NULL on failure or new data

    § tds_alloc_param_result()

    TDSPARAMINFO * tds_alloc_param_result ( TDSPARAMINFO old_param)

    Adds a output parameter to TDSPARAMINFO.

    Parameters
    old_parama pointer to the TDSPARAMINFO structure containing the current set of output parameter, or NULL if none exists.
    Returns
    a pointer to the new TDSPARAMINFO structure.

    tds_alloc_param_result() works a bit differently than the other alloc result functions. Output parameters come in individually with no total number given in advance, so we simply call this func every time with get a TDS_PARAM_TOKEN and let it realloc the columns struct one bigger. tds_free_all_results() usually cleans up after us.

    § tds_free_input_params()

    void tds_free_input_params ( TDSDYNAMIC dyn)

    Frees all allocated input parameters of a dynamic statement.

    Parameters
    dynthe dynamic statement whose input parameter are to be freed

    tds_free_input_params frees all parameters for the give dynamic statement

    § tds_get_dynid()

    static char* tds_get_dynid ( TDSCONNECTION conn,
    char *  id 
    )
    static

    Get an id for dynamic query based on TDS information.

    Parameters
    connstate information for the connection and the TDS protocol
    Returns
    TDS_FAIL or TDS_SUCCESS
    Here is the caller graph for this function:

    § tds_init_login()

    TDSLOGIN* tds_init_login ( TDSLOGIN login,
    TDSLOCALE locale 
    )

    Initialize login structure with locale information and other stuff for connection.

    Parameters
    localelocale information (copied to configuration information)
    Returns
    login structure or NULL if initialization error

    § tds_realloc()

    void* tds_realloc ( void **  pp,
    size_t  new_size 
    )

    Reallocate a pointer and update it if success.

    Parameters
    pppointer to pointer to be reallocated
    new_sizenew size to be allocated
    Returns
    new pointer allocated, NULL on failure

    § tds_release_dynamic()

    void tds_release_dynamic ( TDSDYNAMIC **  pdyn)

    Frees dynamic statement.

    Parameters
    pdynpointer to dynamic statement to be freed.
    Here is the call graph for this function:

    Variable Documentation

    § defaultcaps

    const TDS_CAPABILITIES defaultcaps
    static
    Initial value:
    = { {
    { 1, 14, { REQB(13), REQB(12), REQB(11), REQB(10), REQB(9), REQB(8), REQB(7),
    REQB(6), REQB(5), REQB(4), REQB(3), REQB(2), REQB(1), REQB(0) } },
    { 2, 14, { RESB(13), RESB(12), RESB(11), RESB(10), RESB(9), RESB(8), RESB(7),
    RESB(6), RESB(5), RESB(4), RESB(3), RESB(2), RESB(1), RESB(0) } }
    } }
    freetds-1.00.82/doc/reference/a00531_ga38c0ac641a8c6e25e91ee9205c3c50c5_icgraph.map100644 025423 025423 00000000360 13242511135 0021473 freetds-1.00.82/doc/reference/a00531_ga38c0ac641a8c6e25e91ee9205c3c50c5_icgraph.md5100644 025423 025423 00000000040 13242511133 00213742227b16ab6238295a0b1219407547c1afreetds-1.00.82/doc/reference/a00531_ga38c0ac641a8c6e25e91ee9205c3c50c5_icgraph.svg100644 025423 025423 00000003215 13242511136 0021520 tds_canonical_charset Node3 tds_canonical_charset Node4 tds_canonical_charset_name Node3->Node4 freetds-1.00.82/doc/reference/a00531_ga3a7a7b4d6ed344127e164dd0b443d790_cgraph.map100644 025423 025423 00000000337 13242511135 0021246 freetds-1.00.82/doc/reference/a00531_ga3a7a7b4d6ed344127e164dd0b443d790_cgraph.md5100644 025423 025423 00000000040 13242511133 00211436c6d89f24b9a9633d7d6a7d3f1ec4ccbfreetds-1.00.82/doc/reference/a00531_ga3a7a7b4d6ed344127e164dd0b443d790_cgraph.svg100644 025423 025423 00000003162 13242511136 0021270 tds_iconv_info_init Node12 tds_iconv_info_init Node13 tdsdump_log Node12->Node13 freetds-1.00.82/doc/reference/a00531_ga6561d1dba1a04c168431b16ec17d7e4c_cgraph.map100644 025423 025423 00000000365 13242511135 0021313 freetds-1.00.82/doc/reference/a00531_ga6561d1dba1a04c168431b16ec17d7e4c_cgraph.md5100644 025423 025423 00000000040 13242511133 00212076e0a5d75efc468672f81c5b0e6356d43freetds-1.00.82/doc/reference/a00531_ga6561d1dba1a04c168431b16ec17d7e4c_cgraph.svg100644 025423 025423 00000003224 13242511136 0021333 tds_canonical_charset_name Node5 tds_canonical_charset_name Node6 tds_canonical_charset Node5->Node6 freetds-1.00.82/doc/reference/a00531_ga87db49044919f1bc84c0ff5e9ab00304_cgraph.map100644 025423 025423 00000000313 13242511135 0021247 freetds-1.00.82/doc/reference/a00531_ga87db49044919f1bc84c0ff5e9ab00304_cgraph.md5100644 025423 025423 00000000040 13242511133 00211527750e721514c4fc47d0a851075afca1afreetds-1.00.82/doc/reference/a00531_ga87db49044919f1bc84c0ff5e9ab00304_cgraph.svg100644 025423 025423 00000003107 13242511136 0021276 tds_iconv Node8 tds_iconv Node9 tdsdump_log Node8->Node9 freetds-1.00.82/doc/reference/a00531_ga87db49044919f1bc84c0ff5e9ab00304_icgraph.map100644 025423 025423 00000000356 13242511135 0021427 freetds-1.00.82/doc/reference/a00531_ga87db49044919f1bc84c0ff5e9ab00304_icgraph.md5100644 025423 025423 00000000040 13242511133 0021323c12bf81236ed8909d78c9028d7cf2bbffreetds-1.00.82/doc/reference/a00531_ga87db49044919f1bc84c0ff5e9ab00304_icgraph.svg100644 025423 025423 00000003173 13242511136 0021452 tds_iconv Node10 tds_iconv Node11 odbc_set_string_flag Node10->Node11 freetds-1.00.82/doc/reference/a00532.map100644 025423 025423 00000000263 13242511135 0013040 freetds-1.00.82/doc/reference/a00532.md5100644 025423 025423 00000000040 13242511133 00127379744e3428f91fabf42d1c2cd26e01b53freetds-1.00.82/doc/reference/a00532.svg100644 025423 025423 00000003050 13242511136 0013060 Memory allocation Node0 Memory allocation Node1 LibTDS API Node1->Node0 freetds-1.00.82/doc/reference/a00532_ga501af7e6186e59c257729599a044a30b_icgraph.map100644 025423 025423 00000000320 13242511135 0021210 freetds-1.00.82/doc/reference/a00532_ga501af7e6186e59c257729599a044a30b_icgraph.md5100644 025423 025423 00000000040 13242511133 00211155d5edf82a86d719768e1f32cf1ba5026freetds-1.00.82/doc/reference/a00532_ga501af7e6186e59c257729599a044a30b_icgraph.svg100644 025423 025423 00000003141 13242511136 0021237 tds_get_dynid Node11 tds_get_dynid Node12 tds_alloc_dynamic Node11->Node12 freetds-1.00.82/doc/reference/a00532_ga69559de43b47f4a9e2eecc7a56527444_cgraph.map100644 025423 025423 00000000617 13242511135 0021305 freetds-1.00.82/doc/reference/a00532_ga69559de43b47f4a9e2eecc7a56527444_cgraph.md5100644 025423 025423 00000000040 13242511133 0021201b2b105219304073a2d37b52132127a04freetds-1.00.82/doc/reference/a00532_ga69559de43b47f4a9e2eecc7a56527444_cgraph.svg100644 025423 025423 00000004650 13242511136 0021331 tds_alloc_dynamic Node0 tds_alloc_dynamic Node1 tds_lookup_dynamic Node0->Node1 Node2 tds_get_dynid Node0->Node2 freetds-1.00.82/doc/reference/a00532_gabf2fdb0def5388508602ee7dd2f49506_cgraph.map100644 025423 025423 00000000351 13242511135 0021424 freetds-1.00.82/doc/reference/a00532_gabf2fdb0def5388508602ee7dd2f49506_cgraph.md5100644 025423 025423 00000000040 13242511133 0021325dd3235efbd60ffa0fd2901687e7f96fafreetds-1.00.82/doc/reference/a00532_gabf2fdb0def5388508602ee7dd2f49506_cgraph.svg100644 025423 025423 00000003204 13242511136 0021447 tds_release_dynamic Node17 tds_release_dynamic Node18 tds_detach_results Node17->Node18 freetds-1.00.82/doc/reference/a00533.html100644 025423 025423 00000445403 13242511136 0013242 FreeTDS API: Query
    FreeTDS API

    Function to handle query. More...

    Collaboration diagram for Query:

    Macros

    #define TDS_PUT_N_AS_UCS2(tds, s)
     Utility to convert a constant ascii string to ucs2 and send to server. More...
     

    Enumerations

    enum  { MUL_STARTED = 1 }
     

    Functions

    static char * tds5_fix_dot_query (const char *query, size_t *query_len, TDSPARAMINFO *params)
     Substitute ?-style placeholders with named (@param) ones. More...
     
    TDSRET tds71_submit_prepexec (TDSSOCKET *tds, const char *query, const char *id, TDSDYNAMIC **dyn_out, TDSPARAMINFO *params)
     tds71_submit_prepexec() creates a temporary stored procedure in the server. More...
     
    static char * tds7_build_param_def_from_params (TDSSOCKET *tds, const char *query, size_t query_len, TDSPARAMINFO *params, size_t *out_len)
     Return string with parameters definition, useful for TDS7+. More...
     
    static char * tds7_build_param_def_from_query (TDSSOCKET *tds, const char *converted_query, size_t converted_query_len, TDSPARAMINFO *params, size_t *out_len)
     Return string with parameters definition, useful for TDS7+ Looks like "@P1 INT, @P2 VARCHAR(100)". More...
     
    static void tds7_put_cursor_fetch (TDSSOCKET *tds, TDS_INT cursor_id, TDS_TINYINT fetch_type, TDS_INT i_row, TDS_INT num_rows)
     
    static void tds7_put_params_definition (TDSSOCKET *tds, const char *param_definition, size_t param_length)
     Send parameter definition to server. More...
     
    static void tds7_put_query_params (TDSSOCKET *tds, const char *query, size_t query_len)
     Output params types and query (required by sp_prepare/sp_executesql/sp_prepexec) More...
     
    static void tds7_send_execute (TDSSOCKET *tds, TDSDYNAMIC *dyn)
     Send dynamic request on TDS 7+ to be executed. More...
     
    static size_t tds_ascii_to_ucs2 (char *buffer, const char *buf)
     Accept an ASCII string, convert it to UCS2-LE The input is null-terminated, but the output excludes the null. More...
     
    const char * tds_convert_string (TDSSOCKET *tds, TDSICONV *char_conv, const char *s, int len, size_t *out_len)
     Convert a string in an allocated buffer. More...
     
    int tds_count_placeholders (const char *query)
     Count the number of placeholders in query. More...
     
    static int tds_count_placeholders_ucs2le (const char *query, const char *query_end)
     Count number of placeholders (?) in a query. More...
     
    static int tds_cursor_check_allocated (TDSCONNECTION *conn, TDSCURSOR *cursor)
     Check if a cursor is allocated into the server. More...
     
    TDSRET tds_cursor_close (TDSSOCKET *tds, TDSCURSOR *cursor)
     
    TDSRET tds_cursor_dealloc (TDSSOCKET *tds, TDSCURSOR *cursor)
     Send a deallocation request to server.
     
    TDSRET tds_cursor_declare (TDSSOCKET *tds, TDSCURSOR *cursor, TDSPARAMINFO *params, int *something_to_send)
     
    TDSRET tds_cursor_fetch (TDSSOCKET *tds, TDSCURSOR *cursor, TDS_CURSOR_FETCH fetch_type, TDS_INT i_row)
     
    TDSRET tds_cursor_get_cursor_info (TDSSOCKET *tds, TDSCURSOR *cursor, TDS_UINT *prow_number, TDS_UINT *prow_count)
     
    TDSRET tds_cursor_open (TDSSOCKET *tds, TDSCURSOR *cursor, TDSPARAMINFO *params, int *something_to_send)
     
    TDSRET tds_cursor_setname (TDSSOCKET *tds, TDSCURSOR *cursor)
     
    TDSRET tds_cursor_setrows (TDSSOCKET *tds, TDSCURSOR *cursor, int *something_to_send)
     
    TDSRET tds_cursor_update (TDSSOCKET *tds, TDSCURSOR *cursor, TDS_CURSOR_OPERATION op, TDS_INT i_row, TDSPARAMINFO *params)
     
    TDSRET tds_deferred_cursor_dealloc (TDSCONNECTION *conn, TDSCURSOR *cursor)
     Deallocate cursor on idle. More...
     
    TDSRET tds_deferred_unprepare (TDSCONNECTION *conn, TDSDYNAMIC *dyn)
     Unprepare dynamic on idle. More...
     
    TDSRET tds_disconnect (TDSSOCKET *tds)
     
    size_t tds_fix_column_size (TDSSOCKET *tds, TDSCOLUMN *curcol)
     Get column size for wire.
     
    TDSRET tds_get_column_declaration (TDSSOCKET *tds, TDSCOLUMN *curcol, char *out)
     Return declaration for column (like "varchar(20)") More...
     
    TDSRET tds_multiple_done (TDSSOCKET *tds, TDSMULTIPLE *multiple)
     
    TDSRET tds_multiple_execute (TDSSOCKET *tds, TDSMULTIPLE *multiple, TDSDYNAMIC *dyn)
     
    TDSRET tds_multiple_init (TDSSOCKET *tds, TDSMULTIPLE *multiple, TDS_MULTIPLE_TYPE type, TDSHEADERS *head)
     
    TDSRET tds_multiple_query (TDSSOCKET *tds, TDSMULTIPLE *multiple, const char *query, TDSPARAMINFO *params)
     
    int tds_needs_unprepare (TDSCONNECTION *conn, TDSDYNAMIC *dyn)
     Check if dynamic request must be unprepared. More...
     
    const char * tds_next_placeholder (const char *start)
     Get position of next placeholder. More...
     
    static const char * tds_next_placeholder_ucs2le (const char *start, const char *end, int named)
     Found the next placeholder (? or @param) in a string. More...
     
    static TDSRET tds_put_data (TDSSOCKET *tds, TDSCOLUMN *curcol)
     Write data to wire. More...
     
    static TDSRET tds_put_data_info (TDSSOCKET *tds, TDSCOLUMN *curcol, int flags)
     Put data information to wire. More...
     
    static int tds_put_data_info_length (TDSSOCKET *tds, TDSCOLUMN *curcol, int flags)
     Calc information length in bytes (useful for calculating full packet length) More...
     
    static TDSRET tds_put_param_as_string (TDSSOCKET *tds, TDSPARAMINFO *params, int n)
     Send a parameter to server. More...
     
    static void tds_put_params (TDSSOCKET *tds, TDSPARAMINFO *info, int flags)
     Send parameters to server. More...
     
    static TDSRET tds_query_flush_packet (TDSSOCKET *tds)
     Flush query packet. More...
     
    static size_t tds_quote (TDSSOCKET *tds, char *buffer, char quoting, const char *id, size_t len)
     Quote a string properly. More...
     
    static void tds_quote_and_put (TDSSOCKET *tds, const char *s, const char *end)
     Send a string to server while quoting it. More...
     
    size_t tds_quote_id (TDSSOCKET *tds, char *buffer, const char *id, int idlen)
     Quote an id. More...
     
    size_t tds_quote_string (TDSSOCKET *tds, char *buffer, const char *str, int len)
     Quote a string. More...
     
    TDSRET tds_send_cancel (TDSSOCKET *tds)
     tds_send_cancel() sends an empty packet (8 byte header only) tds_process_cancel should be called directly after this. More...
     
    static TDSRET tds_send_emulated_execute (TDSSOCKET *tds, const char *query, TDSPARAMINFO *params)
     Emulate prepared execute traslating to a normal language.
     
    static TDSRET tds_send_emulated_rpc (TDSSOCKET *tds, const char *rpc_name, TDSPARAMINFO *params)
     Send RPC as string query. More...
     
    static void tds_set_cur_cursor (TDSSOCKET *tds, TDSCURSOR *cursor)
     Set current cursor. More...
     
    void tds_set_cur_dyn (TDSSOCKET *tds, TDSDYNAMIC *dyn)
     Set current dynamic. More...
     
    const char * tds_skip_comment (const char *s)
     Skip a comment in a query. More...
     
    static const char * tds_skip_comment_ucs2le (const char *s, const char *end)
     Skip a comment in a query. More...
     
    const char * tds_skip_quoted (const char *s)
     Skip quoting string (like 'sfsf', "dflkdj" or [dfkjd]) More...
     
    static const char * tds_skip_quoted_ucs2le (const char *s, const char *end)
     Return pointer to end of a quoted string. More...
     
    void tds_start_query (TDSSOCKET *tds, unsigned char packet_type)
     Start query packet of a given type. More...
     
    static TDSRET tds_start_query_head (TDSSOCKET *tds, unsigned char packet_type, TDSHEADERS *head)
     Start query packet of a given type. More...
     
    TDSRET tds_submit_begin_tran (TDSSOCKET *tds)
     Send a rollback request. More...
     
    TDSRET tds_submit_commit (TDSSOCKET *tds, int cont)
     Send a commit request. More...
     
    TDSRET tds_submit_execdirect (TDSSOCKET *tds, const char *query, TDSPARAMINFO *params, TDSHEADERS *head)
     Submit a prepared query with parameters. More...
     
    TDSRET tds_submit_execute (TDSSOCKET *tds, TDSDYNAMIC *dyn)
     tds_submit_execute() sends a previously prepared dynamic statement to the server. More...
     
    TDSRET tds_submit_optioncmd (TDSSOCKET *tds, TDS_OPTION_CMD command, TDS_OPTION option, TDS_OPTION_ARG *param, TDS_INT param_size)
     Send option commands to server. More...
     
    TDSRET tds_submit_prepare (TDSSOCKET *tds, const char *query, const char *id, TDSDYNAMIC **dyn_out, TDSPARAMINFO *params)
     tds_submit_prepare() creates a temporary stored procedure in the server. More...
     
    TDSRET tds_submit_query (TDSSOCKET *tds, const char *query)
     tds_submit_query() sends a language string to the database server for processing. More...
     
    TDSRET tds_submit_query_params (TDSSOCKET *tds, const char *query, TDSPARAMINFO *params, TDSHEADERS *head)
     tds_submit_query_params() sends a language string to the database server for processing. More...
     
    TDSRET tds_submit_queryf (TDSSOCKET *tds, const char *queryf,...)
     Format and submit a query. More...
     
    TDSRET tds_submit_rollback (TDSSOCKET *tds, int cont)
     Send a rollback request. More...
     
    TDSRET tds_submit_rpc (TDSSOCKET *tds, const char *rpc_name, TDSPARAMINFO *params, TDSHEADERS *head)
     tds_submit_rpc() call a RPC from server. More...
     
    TDSRET tds_submit_unprepare (TDSSOCKET *tds, TDSDYNAMIC *dyn)
     Send a unprepare request for a prepared query. More...
     

    Variables

    static const TDSCONTEXT empty_ctx = {0}
     

    Detailed Description

    Function to handle query.

    Macro Definition Documentation

    § TDS_PUT_N_AS_UCS2

    #define TDS_PUT_N_AS_UCS2 (   tds,
     
    )
    Value:
    do { \
    char buffer[sizeof(s)*2-2]; \
    tds_put_smallint(tds, sizeof(buffer)/2); \
    tds_put_n(tds, buffer, tds_ascii_to_ucs2(buffer, s)); \
    } while(0)
    static size_t tds_ascii_to_ucs2(char *buffer, const char *buf)
    Accept an ASCII string, convert it to UCS2-LE The input is null-terminated, but the output excludes t...
    Definition: query.c:88

    Utility to convert a constant ascii string to ucs2 and send to server.

    Used to send internal store procedure names to server.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    sconstanst string to send

    Function Documentation

    § tds5_fix_dot_query()

    static char* tds5_fix_dot_query ( const char *  query,
    size_t *  query_len,
    TDSPARAMINFO params 
    )
    static

    Substitute ?-style placeholders with named (@param) ones.

    Sybase does not support ?-style placeholders so convert them. Also the function replace parameters names.

    Parameters
    queryquery string
    [in,out]query_lenpointer to query length. On input length of input query, on output length of output query
    paramsparameters to send to server
    Returns
    new query or NULL on error

    § tds71_submit_prepexec()

    TDSRET tds71_submit_prepexec ( TDSSOCKET tds,
    const char *  query,
    const char *  id,
    TDSDYNAMIC **  dyn_out,
    TDSPARAMINFO params 
    )

    tds71_submit_prepexec() creates a temporary stored procedure in the server.

    Parameters
    tdsstate information for the socket and the TDS protocol
    querylanguage query with given placeholders (?)
    idstring to identify the dynamic query. Pass NULL for automatic generation.
    dyn_outwill receive allocated TDSDYNAMIC*. Any older allocated dynamic won't be freed, Can be NULL.
    paramsparameters to use. It can be NULL even if parameters are present. Used only for TDS7+
    Returns
    TDS_FAIL or TDS_SUCCESS

    § tds7_build_param_def_from_params()

    static char * tds7_build_param_def_from_params ( TDSSOCKET tds,
    const char *  query,
    size_t  query_len,
    TDSPARAMINFO params,
    size_t *  out_len 
    )
    static

    Return string with parameters definition, useful for TDS7+.

    Parameters
    tdsstate information for the socket and the TDS protocol
    queryquery to send to server encoded as ucs2
    query_lenquery length in bytes
    paramsparameters to build declaration
    out_lenlength output buffer in bytes
    Returns
    allocated and filled string or NULL on failure (coded in ucs2le charset )

    § tds7_build_param_def_from_query()

    static char * tds7_build_param_def_from_query ( TDSSOCKET tds,
    const char *  converted_query,
    size_t  converted_query_len,
    TDSPARAMINFO params,
    size_t *  out_len 
    )
    static

    Return string with parameters definition, useful for TDS7+ Looks like "@P1 INT, @P2 VARCHAR(100)".

    Parameters
    tdsstate information for the socket and the TDS protocol
    converted_queryquery to send to server in ucs2 encoding
    converted_query_lenquery length in bytes
    paramsparameters to build declaration
    out_lenlength output buffer in bytes
    Returns
    allocated and filled string or NULL on failure (coded in ucs2le charset )

    § tds7_put_params_definition()

    static void tds7_put_params_definition ( TDSSOCKET tds,
    const char *  param_definition,
    size_t  param_length 
    )
    static

    Send parameter definition to server.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    param_definitionparameter definition string. Encoded in ucs2
    param_lengthparameter definition string length in bytes

    § tds7_put_query_params()

    static void tds7_put_query_params ( TDSSOCKET tds,
    const char *  query,
    size_t  query_len 
    )
    static

    Output params types and query (required by sp_prepare/sp_executesql/sp_prepexec)

    Parameters
    tdsstate information for the socket and the TDS protocol
    queryquery (in ucs2le codings)
    query_lenquery length in bytes

    § tds7_send_execute()

    static void tds7_send_execute ( TDSSOCKET tds,
    TDSDYNAMIC dyn 
    )
    static

    Send dynamic request on TDS 7+ to be executed.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    dyndynamic query to execute

    § tds_ascii_to_ucs2()

    static size_t tds_ascii_to_ucs2 ( char *  buffer,
    const char *  buf 
    )
    static

    Accept an ASCII string, convert it to UCS2-LE The input is null-terminated, but the output excludes the null.

    Parameters
    bufferbuffer where to store output
    bufstring to write
    Returns
    bytes written

    § tds_convert_string()

    const char* tds_convert_string ( TDSSOCKET tds,
    TDSICONV char_conv,
    const char *  s,
    int  len,
    size_t *  out_len 
    )

    Convert a string in an allocated buffer.

    Parameters
    tdsstate information for the socket and the TDS protocol
    char_convinformation about the encodings involved
    sinput string
    leninput string length (in bytes), -1 for null terminated
    out_lenreturned output length (in bytes)
    Returns
    string allocated (or input pointer if no conversion required) or NULL if error

    § tds_count_placeholders()

    int tds_count_placeholders ( const char *  query)

    Count the number of placeholders in query.

    Parameters
    queryquery string
    Here is the call graph for this function:
    Here is the caller graph for this function:

    § tds_count_placeholders_ucs2le()

    static int tds_count_placeholders_ucs2le ( const char *  query,
    const char *  query_end 
    )
    static

    Count number of placeholders (?) in a query.

    Parameters
    queryquery encoded in ucs2
    query_endend of query
    Returns
    number of placeholders found
    Here is the call graph for this function:

    § tds_cursor_check_allocated()

    static int tds_cursor_check_allocated ( TDSCONNECTION conn,
    TDSCURSOR cursor 
    )
    static

    Check if a cursor is allocated into the server.

    If not is allocated it assure is removed from the connection list

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    Returns
    0 if not allocated <>0 otherwise
    Here is the caller graph for this function:

    § tds_deferred_cursor_dealloc()

    TDSRET tds_deferred_cursor_dealloc ( TDSCONNECTION conn,
    TDSCURSOR cursor 
    )

    Deallocate cursor on idle.

    This let libTDS close the cursor when possible.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    cursorcursor to close
    Here is the call graph for this function:

    § tds_deferred_unprepare()

    TDSRET tds_deferred_unprepare ( TDSCONNECTION conn,
    TDSDYNAMIC dyn 
    )

    Unprepare dynamic on idle.

    This let libTDS close the prepared statement when possible.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    dyndynamic request to close
    Here is the call graph for this function:

    § tds_get_column_declaration()

    TDSRET tds_get_column_declaration ( TDSSOCKET tds,
    TDSCOLUMN curcol,
    char *  out 
    )

    Return declaration for column (like "varchar(20)")

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    curcolcolumn
    outbuffer to hold declaration
    Returns
    TDS_FAIL or TDS_SUCCESS
    Here is the caller graph for this function:

    § tds_needs_unprepare()

    int tds_needs_unprepare ( TDSCONNECTION conn,
    TDSDYNAMIC dyn 
    )

    Check if dynamic request must be unprepared.

    Depending on status and protocol version request should be unprepared or not.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    dyndynamic request to check
    Here is the caller graph for this function:

    § tds_next_placeholder()

    const char* tds_next_placeholder ( const char *  start)

    Get position of next placeholder.

    Parameters
    startpointer to part of query to search
    Returns
    next placeholder or NULL if not found
    Here is the call graph for this function:
    Here is the caller graph for this function:

    § tds_next_placeholder_ucs2le()

    static const char* tds_next_placeholder_ucs2le ( const char *  start,
    const char *  end,
    int  named 
    )
    static

    Found the next placeholder (? or @param) in a string.

    String must be encoded in ucs2.

    Parameters
    startstart of the string (or part of it)
    endend of string
    namedtrue if named parameters should be returned
    Returns
    either start of next placeholder or end if not found
    Here is the call graph for this function:
    Here is the caller graph for this function:

    § tds_put_data()

    static TDSRET tds_put_data ( TDSSOCKET tds,
    TDSCOLUMN curcol 
    )
    inlinestatic

    Write data to wire.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    curcolcolumn where store column information
    Returns
    TDS_FAIL on error or TDS_SUCCESS

    § tds_put_data_info()

    static TDSRET tds_put_data_info ( TDSSOCKET tds,
    TDSCOLUMN curcol,
    int  flags 
    )
    static

    Put data information to wire.

    Parameters
    tdsstate information for the socket and the TDS protocol
    curcolcolumn where to store information
    flagsbit flags on how to send data (use TDS_PUT_DATA_USE_NAME for use name information)
    Returns
    TDS_SUCCESS or TDS_FAIL
    Here is the call graph for this function:

    § tds_put_data_info_length()

    static int tds_put_data_info_length ( TDSSOCKET tds,
    TDSCOLUMN curcol,
    int  flags 
    )
    static

    Calc information length in bytes (useful for calculating full packet length)

    Parameters
    tdsstate information for the socket and the TDS protocol
    curcolcolumn where to store information
    flagsbit flags on how to send data (use TDS_PUT_DATA_USE_NAME for use name information)
    Returns
    data info length

    § tds_put_param_as_string()

    static TDSRET tds_put_param_as_string ( TDSSOCKET tds,
    TDSPARAMINFO params,
    int  n 
    )
    static

    Send a parameter to server.

    Parameters are converted to string and sent to server.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    paramsparameters structure
    nnumber of parameter to send
    Returns
    TDS_FAIL or TDS_SUCCESS
    Here is the caller graph for this function:

    § tds_put_params()

    static void tds_put_params ( TDSSOCKET tds,
    TDSPARAMINFO info,
    int  flags 
    )
    static

    Send parameters to server.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    infoparameters to send
    flags0 or TDS_PUT_DATA_USE_NAME

    § tds_query_flush_packet()

    static TDSRET tds_query_flush_packet ( TDSSOCKET tds)
    static

    Flush query packet.

    Used at the end of packet write to really send packet to server.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    Here is the call graph for this function:
    Here is the caller graph for this function:

    § tds_quote()

    static size_t tds_quote ( TDSSOCKET tds,
    char *  buffer,
    char  quoting,
    const char *  id,
    size_t  len 
    )
    static

    Quote a string properly.

    Output string is always NUL-terminated

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    bufferoutput buffer. If NULL function will just return required bytes
    quotingquote character
    idstring to quote
    lenlength of string to quote
    Returns
    size of output string
    Here is the caller graph for this function:

    § tds_quote_and_put()

    static void tds_quote_and_put ( TDSSOCKET tds,
    const char *  s,
    const char *  end 
    )
    static

    Send a string to server while quoting it.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    sstring start
    endstring end
    Here is the call graph for this function:

    § tds_quote_id()

    size_t tds_quote_id ( TDSSOCKET tds,
    char *  buffer,
    const char *  id,
    int  idlen 
    )

    Quote an id.

    Parameters
    tdsstate information for the socket and the TDS protocol
    bufferbuffer to store quoted id. If NULL do not write anything (useful to compute quote length)
    idid to quote
    idlenid length (< 0 for NUL terminated)
    Returns
    written chars (not including needed terminator)
    Here is the call graph for this function:

    § tds_quote_string()

    size_t tds_quote_string ( TDSSOCKET tds,
    char *  buffer,
    const char *  str,
    int  len 
    )

    Quote a string.

    Parameters
    tdsstate information for the socket and the TDS protocol
    bufferbuffer to store quoted id. If NULL do not write anything (useful to compute quote length)
    strstring to quote (not necessary null-terminated)
    lenlength of string (-1 for null terminated)
    Returns
    written chars (not including needed terminator)
    Here is the call graph for this function:

    § tds_send_cancel()

    TDSRET tds_send_cancel ( TDSSOCKET tds)

    tds_send_cancel() sends an empty packet (8 byte header only) tds_process_cancel should be called directly after this.

    Parameters
    tdsstate information for the socket and the TDS protocol
    Remarks
    tcp will either deliver the packet or time out. (TIME_WAIT determines how long it waits between retries.)

    On sending the cancel, we may get EAGAIN. We then select(2) until we know either 1) it succeeded or 2) it didn't. On failure, close the socket, tell the app, and fail the function.

    On success, we read(2) and wait for a reply with select(2). If we get one, great. If the client's timeout expires, we tell him, but all we can do is wait some more or give up and close the connection. If he tells us to cancel again, we wait some more.

    Here is the call graph for this function:

    § tds_send_emulated_rpc()

    static TDSRET tds_send_emulated_rpc ( TDSSOCKET tds,
    const char *  rpc_name,
    TDSPARAMINFO params 
    )
    static

    Send RPC as string query.

    This function is used on old protocol which does not support RPC queries.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    rpc_namename of RPC to invoke
    paramsparameters to send to server
    Returns
    TDS_FAIL or TDS_SUCCESS
    Here is the call graph for this function:

    § tds_set_cur_cursor()

    static void tds_set_cur_cursor ( TDSSOCKET tds,
    TDSCURSOR cursor 
    )
    inlinestatic

    Set current cursor.

    Current cursor is the one will receive output from server.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    cursorcursor to set as current

    § tds_set_cur_dyn()

    void tds_set_cur_dyn ( TDSSOCKET tds,
    TDSDYNAMIC dyn 
    )

    Set current dynamic.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    dyndynamic to set

    § tds_skip_comment()

    const char* tds_skip_comment ( const char *  s)

    Skip a comment in a query.

    Parameters
    sstart of the string (or part of it)
    Returns
    pointer to end of comment
    Here is the caller graph for this function:

    § tds_skip_comment_ucs2le()

    static const char* tds_skip_comment_ucs2le ( const char *  s,
    const char *  end 
    )
    static

    Skip a comment in a query.

    Parameters
    sstart of the string (or part of it). Encoded in ucs2
    endend of string
    Returns
    pointer to end of comment
    Here is the caller graph for this function:

    § tds_skip_quoted()

    const char* tds_skip_quoted ( const char *  s)

    Skip quoting string (like 'sfsf', "dflkdj" or [dfkjd])

    Parameters
    spointer to first quoting character.
    Should be ', " or [. 
    Returns
    character after quoting
    Here is the caller graph for this function:

    § tds_skip_quoted_ucs2le()

    static const char* tds_skip_quoted_ucs2le ( const char *  s,
    const char *  end 
    )
    static

    Return pointer to end of a quoted string.

    At the beginning pointer should point to delimiter.

    Parameters
    sstart of string to skip encoded in ucs2
    endpointer to end of string
    Here is the caller graph for this function:

    § tds_start_query()

    void tds_start_query ( TDSSOCKET tds,
    unsigned char  packet_type 
    )

    Start query packet of a given type.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    packet_typepacket type
    Here is the call graph for this function:

    § tds_start_query_head()

    static TDSRET tds_start_query_head ( TDSSOCKET tds,
    unsigned char  packet_type,
    TDSHEADERS head 
    )
    static

    Start query packet of a given type.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    packet_typepacket type
    headextra information to put in a TDS7 header
    Here is the caller graph for this function:

    § tds_submit_begin_tran()

    TDSRET tds_submit_begin_tran ( TDSSOCKET tds)

    Send a rollback request.

    TDS 7.2+ need this in order to handle transactions correctly if MARS is used.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    See also
    tds_submit_commit, tds_submit_rollback

    § tds_submit_commit()

    TDSRET tds_submit_commit ( TDSSOCKET tds,
    int  cont 
    )

    Send a commit request.

    TDS 7.2+ need this in order to handle transactions correctly if MARS is used.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    conttrue to start a new transaction
    See also
    tds_submit_rollback, tds_submit_begin_tran

    § tds_submit_execdirect()

    TDSRET tds_submit_execdirect ( TDSSOCKET tds,
    const char *  query,
    TDSPARAMINFO params,
    TDSHEADERS head 
    )

    Submit a prepared query with parameters.

    Parameters
    tdsstate information for the socket and the TDS protocol
    querylanguage query with given placeholders (?)
    paramsparameters to send
    Returns
    TDS_FAIL or TDS_SUCCESS

    § tds_submit_execute()

    TDSRET tds_submit_execute ( TDSSOCKET tds,
    TDSDYNAMIC dyn 
    )

    tds_submit_execute() sends a previously prepared dynamic statement to the server.

    Parameters
    tdsstate information for the socket and the TDS protocol
    dyndynamic proc to execute. Must build from same tds.
    Here is the call graph for this function:

    § tds_submit_optioncmd()

    TDSRET tds_submit_optioncmd ( TDSSOCKET tds,
    TDS_OPTION_CMD  command,
    TDS_OPTION  option,
    TDS_OPTION_ARG param,
    TDS_INT  param_size 
    )

    Send option commands to server.

    Option commands are used to change server options.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    commandcommand type.
    optionoption to set/get.
    paramparameter value
    param_sizelength of parameter value in bytes
    Here is the call graph for this function:

    § tds_submit_prepare()

    TDSRET tds_submit_prepare ( TDSSOCKET tds,
    const char *  query,
    const char *  id,
    TDSDYNAMIC **  dyn_out,
    TDSPARAMINFO params 
    )

    tds_submit_prepare() creates a temporary stored procedure in the server.

    Under TDS 4.2 dynamic statements are emulated building sql command

    Parameters
    tdsstate information for the socket and the TDS protocol
    querylanguage query with given placeholders (?)
    idstring to identify the dynamic query. Pass NULL for automatic generation.
    dyn_outwill receive allocated TDSDYNAMIC*. Any older allocated dynamic won't be freed, Can be NULL.
    paramsparameters to use. It can be NULL even if parameters are present. Used only for TDS7+
    Returns
    TDS_FAIL or TDS_SUCCESS

    § tds_submit_query()

    TDSRET tds_submit_query ( TDSSOCKET tds,
    const char *  query 
    )

    tds_submit_query() sends a language string to the database server for processing.

    TDS 4.2 is a plain text message with a packet type of 0x01, TDS 7.0 is a unicode string with packet type 0x01, and TDS 5.0 uses a TDS_LANGUAGE_TOKEN to encapsulate the query and a packet type of 0x0f.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    querylanguage query to submit
    Returns
    TDS_FAIL or TDS_SUCCESS
    Here is the call graph for this function:

    § tds_submit_query_params()

    TDSRET tds_submit_query_params ( TDSSOCKET tds,
    const char *  query,
    TDSPARAMINFO params,
    TDSHEADERS head 
    )

    tds_submit_query_params() sends a language string to the database server for processing.

    TDS 4.2 is a plain text message with a packet type of 0x01, TDS 7.0 is a unicode string with packet type 0x01, and TDS 5.0 uses a TDS_LANGUAGE_TOKEN to encapsulate the query and a packet type of 0x0f.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    querylanguage query to submit
    paramsparameters of query
    Returns
    TDS_FAIL or TDS_SUCCESS
    Here is the caller graph for this function:

    § tds_submit_queryf()

    TDSRET tds_submit_queryf ( TDSSOCKET tds,
    const char *  queryf,
      ... 
    )

    Format and submit a query.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    queryfquery format. printf like expansion is performed on this query.
    Here is the caller graph for this function:

    § tds_submit_rollback()

    TDSRET tds_submit_rollback ( TDSSOCKET tds,
    int  cont 
    )

    Send a rollback request.

    TDS 7.2+ need this in order to handle transactions correctly if MARS is used.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    conttrue to start a new transaction
    See also
    tds_submit_begin_tran, tds_submit_commit

    § tds_submit_rpc()

    TDSRET tds_submit_rpc ( TDSSOCKET tds,
    const char *  rpc_name,
    TDSPARAMINFO params,
    TDSHEADERS head 
    )

    tds_submit_rpc() call a RPC from server.

    Output parameters will be stored in tds->param_info

    Parameters
    tdsstate information for the socket and the TDS protocol
    rpc_namename of RPC
    paramsparameters informations. NULL for no parameters
    Here is the call graph for this function:

    § tds_submit_unprepare()

    TDSRET tds_submit_unprepare ( TDSSOCKET tds,
    TDSDYNAMIC dyn 
    )

    Send a unprepare request for a prepared query.

    Parameters
    tdsstate information for the socket and the TDS protocol
    dyndynamic query
    Returns
    TDS_SUCCESS or TDS_FAIL
    freetds-1.00.82/doc/reference/a00533.map100644 025423 025423 00000000233 13242511135 0013036 freetds-1.00.82/doc/reference/a00533.md5100644 025423 025423 00000000040 13242511133 00127408b2deb4d45d9ba36072b8b0a067d3cb8freetds-1.00.82/doc/reference/a00533.svg100644 025423 025423 00000003003 13242511136 0013057 Query Node0 Query Node1 LibTDS API Node1->Node0 freetds-1.00.82/doc/reference/a00533_ga05ac7bab753d19b6ba1ffc7505d8fcd0_icgraph.map100644 025423 025423 00000000331 13242511135 0021770 freetds-1.00.82/doc/reference/a00533_ga05ac7bab753d19b6ba1ffc7505d8fcd0_icgraph.md5100644 025423 025423 00000000040 13242511133 00216739b4aec7f2e282b19d26ef3aa2d615c1efreetds-1.00.82/doc/reference/a00533_ga05ac7bab753d19b6ba1ffc7505d8fcd0_icgraph.svg100644 025423 025423 00000003167 13242511136 0022025 tds_needs_unprepare Node42 tds_needs_unprepare Node43 tds_deferred_unprepare Node42->Node43 freetds-1.00.82/doc/reference/a00533_ga0cd19215e9169ea299a6c9cbf5b2fb60_cgraph.map100644 025423 025423 00000001111 13242511135 0021413 freetds-1.00.82/doc/reference/a00533_ga0cd19215e9169ea299a6c9cbf5b2fb60_cgraph.md5100644 025423 025423 00000000040 13242511133 0021321cb08d67fad271bf2706dfe2350adcee8freetds-1.00.82/doc/reference/a00534.html100644 025423 025423 00000170173 13242511136 0013242 FreeTDS API: Network functions
    FreeTDS API
    Network functions

    Functions for reading or writing from network. More...

    Collaboration diagram for Network functions:

    Functions

    static size_t read_and_convert (TDSSOCKET *tds, TDSICONV *char_conv, size_t *wire_size, char *outbuf, size_t outbytesleft)
     For UTF-8 and similar, tds_iconv() may encounter a partial sequence when the chunk boundary is not aligned with the character boundary. More...
     
    int tds7_get_instance_port (struct addrinfo *addr, const char *instance)
     Get port of given instance. More...
     
    int tds7_get_instance_ports (FILE *output, struct addrinfo *addr)
     Get port of all instances. More...
     
    const char * tds_addrinfo2str (struct addrinfo *addr, char *name, int namemax)
     
    static void tds_addrinfo_set_port (struct addrinfo *addr, unsigned int port)
     
    void tds_close_socket (TDSSOCKET *tds)
     Close current socket. More...
     
    static TDSERRNO tds_connect_socket (TDSSOCKET *tds, struct addrinfo *addr, unsigned int port, int timeout, int *p_oserr)
     
    void tds_connection_close (TDSCONNECTION *conn)
     
    int tds_connection_read (TDSSOCKET *tds, unsigned char *buf, int buflen)
     
    static int tds_connection_signaled (TDSCONNECTION *conn)
     
    int tds_connection_write (TDSSOCKET *tds, const unsigned char *buf, int buflen, int final)
     
    DSTRtds_dstr_get (TDSSOCKET *tds, DSTR *s, size_t len)
     Reads a string from wire and put in a DSTR. More...
     
    TDSRET tds_flush_packet (TDSSOCKET *tds)
     Flush packet to server. More...
     
    unsigned char tds_get_byte (TDSSOCKET *tds)
     Return a single byte from the input buffer. More...
     
    TDSRET tds_get_char_data (TDSSOCKET *tds, char *row_buffer, size_t wire_size, TDSCOLUMN *curcol)
     Fetch character data the wire. More...
     
    void * tds_get_n (TDSSOCKET *tds, void *dest, size_t need)
     Get N bytes from the buffer and return them in the already allocated space given to us. More...
     
    size_t tds_get_string (TDSSOCKET *tds, size_t string_len, char *dest, size_t dest_size)
     Fetch a string from the wire. More...
     
    TDS_UINT tds_get_uint (TDSSOCKET *tds)
     Get an int32 from the server. More...
     
    TDS_UINT8 tds_get_uint8 (TDSSOCKET *tds)
     Get an uint64 from the server. More...
     
    TDS_USMALLINT tds_get_usmallint (TDSSOCKET *tds)
     Get an int16 from the server.
     
    int tds_goodread (TDSSOCKET *tds, unsigned char *buf, int buflen)
     Loops until we have received some characters return -1 on failure.
     
    int tds_goodwrite (TDSSOCKET *tds, const unsigned char *buffer, size_t buflen)
     
    int tds_init_write_buf (TDSSOCKET *tds)
     
    TDSERRNO tds_open_socket (TDSSOCKET *tds, struct addrinfo *addr, unsigned int port, int timeout, int *p_oserr)
     
    unsigned char tds_peek (TDSSOCKET *tds)
     Reads a byte from the TDS stream without removing it. More...
     
    int tds_put_buf (TDSSOCKET *tds, const unsigned char *buf, int dsize, int ssize)
     
    int tds_put_byte (TDSSOCKET *tds, unsigned char c)
     
    int tds_put_cancel (TDSSOCKET *tds)
     
    int tds_put_int (TDSSOCKET *tds, TDS_INT i)
     
    int tds_put_int8 (TDSSOCKET *tds, TDS_INT8 i)
     
    int tds_put_n (TDSSOCKET *tds, const void *buf, size_t n)
     
    int tds_put_smallint (TDSSOCKET *tds, TDS_SMALLINT si)
     
    int tds_put_string (TDSSOCKET *tds, const char *s, int len)
     Output a string to wire automatic translate string to unicode if needed. More...
     
    int tds_read_packet (TDSSOCKET *tds)
     Read in one 'packet' from the server. More...
     
    int tds_select (TDSSOCKET *tds, unsigned tds_sel, int timeout_seconds)
     Select on a socket until it's available or the timeout expires. More...
     
    void tds_socket_flush (TDS_SYS_SOCKET sock)
     
    static int tds_socket_read (TDSCONNECTION *conn, TDSSOCKET *tds, unsigned char *buf, int buflen)
     Read from an OS socket remove tds, save error somewhere, report error in another way. More...
     
    int tds_socket_set_nonblocking (TDS_SYS_SOCKET sock)
     Set socket to non-blocking. More...
     
    static int tds_socket_write (TDSCONNECTION *conn, TDSSOCKET *tds, const unsigned char *buf, int buflen)
     Write to an OS socket. More...
     
    void tds_unget_byte (TDSSOCKET *tds)
     Unget will always work as long as you don't call it twice in a row. More...
     
    void tds_wakeup_close (TDSPOLLWAKEUP *wakeup)
     
    int tds_wakeup_init (TDSPOLLWAKEUP *wakeup)
     
    void tds_wakeup_send (TDSPOLLWAKEUP *wakeup, char cancel)
     
    TDSRET tds_write_packet (TDSSOCKET *tds, unsigned char final)
     

    Detailed Description

    Functions for reading or writing from network.

    Function Documentation

    § read_and_convert()

    static size_t read_and_convert ( TDSSOCKET tds,
    TDSICONV char_conv,
    size_t *  wire_size,
    char *  outbuf,
    size_t  outbytesleft 
    )
    static

    For UTF-8 and similar, tds_iconv() may encounter a partial sequence when the chunk boundary is not aligned with the character boundary.

    In that event, it will return an error, and some number of bytes (less than a character) will remain in the tail end of temp[]. They are moved to the beginning, ptemp is adjusted to point just behind them, and the next chunk is read.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    char_convconversion structure
    [out]wire_sizesize readed from wire
    outbufbuffer to write to
    outbytesleftbuffer length
    Returns
    bytes readed
    Here is the call graph for this function:

    § tds7_get_instance_port()

    int tds7_get_instance_port ( struct addrinfo *  addr,
    const char *  instance 
    )

    Get port of given instance.

    Returns
    port number or 0 if error

    § tds7_get_instance_ports()

    int tds7_get_instance_ports ( FILE *  output,
    struct addrinfo *  addr 
    )

    Get port of all instances.

    Returns
    default port number or 0 if error
    Remarks
    experimental, cf. MC-SQLR.pdf.

    § tds_close_socket()

    void tds_close_socket ( TDSSOCKET tds)

    Close current socket.

    For last socket close entire connection. For MARS send FIN request. This attempts a graceful disconnection, for ungraceful call tds_connection_close.

    § tds_dstr_get()

    DSTR* tds_dstr_get ( TDSSOCKET tds,
    DSTR s,
    size_t  len 
    )

    Reads a string from wire and put in a DSTR.

    On error we read the bytes from the wire anyway.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    [out]soutput string
    [in]lenstring length (in characters)
    Returns
    string or NULL on error

    § tds_flush_packet()

    TDSRET tds_flush_packet ( TDSSOCKET tds)

    Flush packet to server.

    Returns
    TDS_FAIL or TDS_SUCCESS
    Here is the caller graph for this function:

    § tds_get_byte()

    unsigned char tds_get_byte ( TDSSOCKET tds)

    Return a single byte from the input buffer.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    Here is the call graph for this function:
    Here is the caller graph for this function:

    § tds_get_char_data()

    TDSRET tds_get_char_data ( TDSSOCKET tds,
    char *  row_buffer,
    size_t  wire_size,
    TDSCOLUMN curcol 
    )

    Fetch character data the wire.

    Output is NOT null terminated. If char_conv is not NULL, convert data accordingly.

    Parameters
    tdsstate information for the socket and the TDS protocol
    row_bufferdestination buffer in current_row. Can't be NULL
    wire_sizesize to read from wire (in bytes)
    curcolcolumn information
    Returns
    TDS_SUCCESS or TDS_FAIL (probably memory error on text data)

    § tds_get_n()

    void* tds_get_n ( TDSSOCKET tds,
    void *  dest,
    size_t  need 
    )

    Get N bytes from the buffer and return them in the already allocated space given to us.

    We ASSUME that the person calling this function has done the bounds checking for us since they know how many bytes they want here. dest of NULL means we just want to eat the bytes. (tethe.nosp@m.row@.nosp@m.nol.o.nosp@m.rg)

    Here is the caller graph for this function:

    § tds_get_string()

    size_t tds_get_string ( TDSSOCKET tds,
    size_t  string_len,
    char *  dest,
    size_t  dest_size 
    )

    Fetch a string from the wire.

    Output string is NOT null terminated. If TDS version is 7 or 8 read unicode string and convert it. This function should be use to read server default encoding strings like columns name, table names, etc, not for data (use tds_get_char_data instead)

    Returns
    bytes written to dest
    Parameters
    tdsconnection information
    string_lenlength of string to read from wire (in server characters, bytes for tds4-tds5, ucs2 for tds7+)
    destdestination buffer, if NULL string is read and discarded
    dest_sizedestination buffer size, in bytes

    § tds_get_uint()

    TDS_UINT tds_get_uint ( TDSSOCKET tds)

    Get an int32 from the server.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    Here is the call graph for this function:
    Here is the caller graph for this function:

    § tds_get_uint8()

    TDS_UINT8 tds_get_uint8 ( TDSSOCKET tds)

    Get an uint64 from the server.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    Here is the call graph for this function:

    § tds_goodwrite()

    int tds_goodwrite ( TDSSOCKET tds,
    const unsigned char *  buffer,
    size_t  buflen 
    )
    Parameters
    tdsthe famous socket
    bufferdata to send
    buflenbytes in buffer
    last1 if this is the last packet, else 0
    Returns
    length written (>0), <0 on failure
    Here is the call graph for this function:

    § tds_peek()

    unsigned char tds_peek ( TDSSOCKET tds)

    Reads a byte from the TDS stream without removing it.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    Here is the call graph for this function:

    § tds_put_string()

    int tds_put_string ( TDSSOCKET tds,
    const char *  s,
    int  len 
    )

    Output a string to wire automatic translate string to unicode if needed.

    Returns
    bytes written to wire
    Parameters
    tdsstate information for the socket and the TDS protocol
    sstring to write
    lenlength of string in characters, or -1 for null terminated
    Here is the caller graph for this function:

    § tds_read_packet()

    int tds_read_packet ( TDSSOCKET tds)

    Read in one 'packet' from the server.

    This is a wrapped outer packet of the protocol (they bundle result packets into chunks and wrap them at what appears to be 512 bytes regardless of how that breaks internal packet up. (tetherow@nol.org)

    Returns
    bytes read or -1 on failure
    Here is the caller graph for this function:

    § tds_select()

    int tds_select ( TDSSOCKET tds,
    unsigned  tds_sel,
    int  timeout_seconds 
    )

    Select on a socket until it's available or the timeout expires.

    Meanwhile, call the interrupt function.

    Returns
    >0 ready descriptors 0 timeout <0 error (cf. errno). Caller should close socket and return failure. This function does not call tdserror or close the socket because it can't know the context in which it's being called.
    Here is the caller graph for this function:

    § tds_socket_read()

    static int tds_socket_read ( TDSCONNECTION conn,
    TDSSOCKET tds,
    unsigned char *  buf,
    int  buflen 
    )
    static

    Read from an OS socket remove tds, save error somewhere, report error in another way.

    Returns
    0 if blocking, <0 error >0 bytes read

    § tds_socket_set_nonblocking()

    int tds_socket_set_nonblocking ( TDS_SYS_SOCKET  sock)

    Set socket to non-blocking.

    Parameters
    socksocket to set
    Returns
    0 on success or error code

    § tds_socket_write()

    static int tds_socket_write ( TDSCONNECTION conn,
    TDSSOCKET tds,
    const unsigned char *  buf,
    int  buflen 
    )
    static

    Write to an OS socket.

    Returns
    0 if blocking, <0 error >0 bytes readed
    Here is the call graph for this function:

    § tds_unget_byte()

    void tds_unget_byte ( TDSSOCKET tds)

    Unget will always work as long as you don't call it twice in a row.

    It it may work if you call it multiple times as long as you don't backup over the beginning of network packet boundary which can occur anywhere in the token stream.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    freetds-1.00.82/doc/reference/a00534.map100644 025423 025423 00000000263 13242511135 0013042 freetds-1.00.82/doc/reference/a00533_ga0cd19215e9169ea299a6c9cbf5b2fb60_cgraph.svg100644 025423 025423 00000006644 13242511136 0021456 tds_count_placeholders_ucs2le Node24 tds_count_placeholders _ucs2le Node25 tds_next_placeholder _ucs2le Node24->Node25 Node26 tds_skip_quoted_ucs2le Node25->Node26 Node27 tds_skip_comment_ucs2le Node25->Node27 freetds-1.00.82/doc/reference/a00533_ga0da385231bfa3dc49377e1fb2bea2c07_cgraph.map100644 025423 025423 00000000332 13242511135 0021451 freetds-1.00.82/doc/reference/a00533_ga0da385231bfa3dc49377e1fb2bea2c07_cgraph.md5100644 025423 025423 00000000040 13242511133 00213534742925b00b888b74262e9637d9d5988freetds-1.00.82/doc/reference/a00533_ga0da385231bfa3dc49377e1fb2bea2c07_cgraph.svg100644 025423 025423 00000003166 13242511136 0021504 tds_start_query Node122 tds_start_query Node123 tds_start_query_head Node122->Node123 freetds-1.00.82/doc/reference/a00533_ga0e2e7230c425e925402d7856ff5b4b18_icgraph.map100644 025423 025423 00000000340 13242511135 0021262 freetds-1.00.82/doc/reference/a00533_ga0e2e7230c425e925402d7856ff5b4b18_icgraph.md5100644 025423 025423 00000000040 13242511133 002116559fe045c34b440bd80386130934bd4adfreetds-1.00.82/doc/reference/a00533_ga0e2e7230c425e925402d7856ff5b4b18_icgraph.svg100644 025423 025423 00000003201 13242511136 0021304 tds_put_param_as_string Node64 tds_put_param_as_string Node65 tds_send_emulated_rpc Node64->Node65 freetds-1.00.82/doc/reference/a00533_ga11338742dc30fd0c2711f58eb830316f_cgraph.map100644 025423 025423 00000000327 13242511135 0021101 freetds-1.00.82/doc/reference/a00533_ga11338742dc30fd0c2711f58eb830316f_cgraph.md5100644 025423 025423 00000000040 13242511133 002077769e64004e43abc154ab5277e4e16864bfreetds-1.00.82/doc/reference/a00533_ga11338742dc30fd0c2711f58eb830316f_cgraph.svg100644 025423 025423 00000003146 13242511136 0021126 tds_send_cancel Node86 tds_send_cancel Node87 tdsdump_log Node86->Node87 freetds-1.00.82/doc/reference/a00533_ga2361ec4629aa0eac38f1702b03ed8185_icgraph.map100644 025423 025423 00000000644 13242511135 0021413 freetds-1.00.82/doc/reference/a00533_ga2361ec4629aa0eac38f1702b03ed8185_icgraph.md5100644 025423 025423 00000000040 13242511133 002130702f48fd386c0bca96e703b1196fef55dfreetds-1.00.82/doc/reference/a00533_ga2361ec4629aa0eac38f1702b03ed8185_icgraph.svg100644 025423 025423 00000005234 13242511136 0021436 tds_skip_quoted_ucs2le Node119 tds_skip_quoted_ucs2le Node120 tds_next_placeholder _ucs2le Node119->Node120 Node121 tds_count_placeholders _ucs2le Node120->Node121 freetds-1.00.82/doc/reference/a00533_ga26b26296d060dca75f6a43e9ac41e58d_cgraph.map100644 025423 025423 00000000403 13242511135 0021332 freetds-1.00.82/doc/reference/a00533_ga26b26296d060dca75f6a43e9ac41e58d_cgraph.md5100644 025423 025423 00000000040 13242511133 0021235308f6c4dbfe7e98f4539e555fe86c517freetds-1.00.82/doc/reference/a00533_ga26b26296d060dca75f6a43e9ac41e58d_cgraph.svg100644 025423 025423 00000003232 13242511136 0021360 tds_quote_and_put Node77 tds_quote_and_put Node78 tds_put_string Node77->Node78 freetds-1.00.82/doc/reference/a00533_ga2c6da4886cc30af02546a3bc2ebcae5d_icgraph.map100644 025423 025423 00000000347 13242511135 0021767 freetds-1.00.82/doc/reference/a00533_ga2c6da4886cc30af02546a3bc2ebcae5d_icgraph.md5100644 025423 025423 00000000040 13242511133 002166334dd1b6dfcee640ef51f6b7e77119b6dfreetds-1.00.82/doc/reference/a00533_ga2c6da4886cc30af02546a3bc2ebcae5d_icgraph.svg100644 025423 025423 00000003374 13242511136 0022015 tds_cursor_check_allocated Node30 tds_cursor_check_allocated Node31 tds_deferred_cursor _dealloc Node30->Node31 freetds-1.00.82/doc/reference/a00533_ga3e7b4793c6f799fbc6c174f673bb5b32_cgraph.map100644 025423 025423 00000000335 13242511135 0021362 freetds-1.00.82/doc/reference/a00533_ga3e7b4793c6f799fbc6c174f673bb5b32_cgraph.md5100644 025423 025423 00000000040 13242511133 00212616c30cd438e1fff655f22932710b12934freetds-1.00.82/doc/reference/a00533_ga3e7b4793c6f799fbc6c174f673bb5b32_cgraph.svg100644 025423 025423 00000003171 13242511136 0021406 tds_submit_execute Node134 tds_submit_execute Node135 tdsdump_log Node134->Node135 freetds-1.00.82/doc/reference/a00533_ga50d62edeb2a432e2dc668263f3f958ff_icgraph.map100644 025423 025423 00000000346 13242511135 0021602 freetds-1.00.82/doc/reference/a00533_ga50d62edeb2a432e2dc668263f3f958ff_icgraph.md5100644 025423 025423 00000000040 13242511133 00214777bfac81e60da26c69acbb470c33cbd67freetds-1.00.82/doc/reference/a00533_ga50d62edeb2a432e2dc668263f3f958ff_icgraph.svg100644 025423 025423 00000003205 13242511136 0021622 tds_get_column_declaration Node39 tds_get_column_declaration Node40 tds_send_emulated_rpc Node39->Node40 freetds-1.00.82/doc/reference/a00533_ga57bd0fabe5bcdeb3ef091259b3a7c1fc_cgraph.map100644 025423 025423 00000000377 13242511135 0021771 freetds-1.00.82/doc/reference/a00533_ga57bd0fabe5bcdeb3ef091259b3a7c1fc_cgraph.md5100644 025423 025423 00000000040 13242511133 002166247110c502e39cd645c0f04a04f9481d2freetds-1.00.82/doc/reference/a00533_ga57bd0fabe5bcdeb3ef091259b3a7c1fc_cgraph.svg100644 025423 025423 00000003420 13242511136 0022004 tds_deferred_cursor_dealloc Node32 tds_deferred_cursor _dealloc Node33 tds_cursor_check_allocated Node32->Node33 freetds-1.00.82/doc/reference/a00533_ga5a29ae7f99d089dc3cea85ec6ee5f3ab_cgraph.map100644 025423 025423 00000000421 13242511135 0021734 freetds-1.00.82/doc/reference/a00533_ga5a29ae7f99d089dc3cea85ec6ee5f3ab_cgraph.md5100644 025423 025423 00000000040 13242511133 00216375278dcdb93ca9fcbeeeef21981240af1freetds-1.00.82/doc/reference/a00533_ga5a29ae7f99d089dc3cea85ec6ee5f3ab_cgraph.svg100644 025423 025423 00000003262 13242511136 0021765 tds_submit_query Node142 tds_submit_query Node143 tds_submit_query_params Node142->Node143 freetds-1.00.82/doc/reference/a00533_ga5dbe51ce9533218f2da23f69ff63dda4_icgraph.map100644 025423 025423 00000001067 13242511135 0021656 freetds-1.00.82/doc/reference/a00533_ga5dbe51ce9533218f2da23f69ff63dda4_icgraph.md5100644 025423 025423 00000000040 13242511133 0021552d087621e45f299b63d5b4ce0d5fa23b0freetds-1.00.82/doc/reference/a00533_ga5dbe51ce9533218f2da23f69ff63dda4_icgraph.svg100644 025423 025423 00000006232 13242511136 0021700 tds_skip_quoted Node114 tds_skip_quoted Node115 tds_next_placeholder Node114->Node115 Node116 tds_count_placeholders Node115->Node116 Node117 tds_send_emulated_execute Node116->Node117 freetds-1.00.82/doc/reference/a00533_ga5f071b94ad7889690762dc85646c74ab_cgraph.map100644 025423 025423 00000000353 13242511135 0021146 freetds-1.00.82/doc/reference/a00533_ga5f071b94ad7889690762dc85646c74ab_cgraph.md5100644 025423 025423 00000000040 13242511133 0021045dfa6bc3d9bb75b2ae9ac59a266cceaebfreetds-1.00.82/doc/reference/a00533_ga5f071b94ad7889690762dc85646c74ab_cgraph.svg100644 025423 025423 00000003202 13242511136 0021165 tds_submit_rpc Node153 tds_submit_rpc Node154 tds_set_state Node153->Node154 freetds-1.00.82/doc/reference/a00533_ga6455b2991afbf7da90270787f2059d31_cgraph.map100644 025423 025423 00000000642 13242511135 0021131 freetds-1.00.82/doc/reference/a00533_ga6455b2991afbf7da90270787f2059d31_cgraph.md5100644 025423 025423 00000000040 13242511133 00210271b302b2b084ab7b6859c9b3df0bf24dbfreetds-1.00.82/doc/reference/a00533_ga6455b2991afbf7da90270787f2059d31_cgraph.svg100644 025423 025423 00000004712 13242511136 0021156 tds_next_placeholder Node44 tds_next_placeholder Node45 tds_skip_quoted Node44->Node45 Node46 tds_skip_comment Node44->Node46 freetds-1.00.82/doc/reference/a00533_ga6455b2991afbf7da90270787f2059d31_icgraph.map100644 025423 025423 00000000642 13242511135 0021302 freetds-1.00.82/doc/reference/a00533_ga6455b2991afbf7da90270787f2059d31_icgraph.md5100644 025423 025423 00000000040 13242511133 002120030ae53ed28a72b54649135faea8c4dc4freetds-1.00.82/doc/reference/a00533_ga6455b2991afbf7da90270787f2059d31_icgraph.svg100644 025423 025423 00000004641 13242511136 0021330 tds_next_placeholder Node47 tds_next_placeholder Node48 tds_count_placeholders Node47->Node48 Node49 tds_send_emulated_execute Node48->Node49 freetds-1.00.82/doc/reference/a00533_ga737b9fb9971fb425af5c722415ef0eac_cgraph.map100644 025423 025423 00000000321 13242511135 0021420 freetds-1.00.82/doc/reference/a00533_ga737b9fb9971fb425af5c722415ef0eac_cgraph.md5100644 025423 025423 00000000040 13242511133 00213241d02ed12431c19e7f65d687fcf557366freetds-1.00.82/doc/reference/a00533_ga737b9fb9971fb425af5c722415ef0eac_cgraph.svg100644 025423 025423 00000003137 13242511136 0021453 tds_quote_string Node83 tds_quote_string Node84 tds_quote Node83->Node84 freetds-1.00.82/doc/reference/a00533_ga7efaa23c3b21158ffc963f85fbc3fdf4_icgraph.map100644 025423 025423 00000000505 13242511135 0022014 freetds-1.00.82/doc/reference/a00533_ga7efaa23c3b21158ffc963f85fbc3fdf4_icgraph.md5100644 025423 025423 00000000040 13242511133 00217141553a6a6c88b5f2abebe775cba8011aefreetds-1.00.82/doc/reference/a00533_ga7efaa23c3b21158ffc963f85fbc3fdf4_icgraph.svg100644 025423 025423 00000004536 13242511136 0022047 tds_quote Node74 tds_quote Node75 tds_quote_id Node74->Node75 Node76 tds_quote_string Node74->Node76 freetds-1.00.82/doc/reference/a00533_ga8d8f2f1c91635ee95f30722208ae3043_cgraph.map100644 025423 025423 00000000311 13242511135 0021112 freetds-1.00.82/doc/reference/a00533_ga8d8f2f1c91635ee95f30722208ae3043_cgraph.md5100644 025423 025423 00000000040 13242511133 002101762e84814977797b04fc97c682c295195freetds-1.00.82/doc/reference/a00533_ga8d8f2f1c91635ee95f30722208ae3043_cgraph.svg100644 025423 025423 00000003123 13242511136 0021141 tds_quote_id Node80 tds_quote_id Node81 tds_quote Node80->Node81 freetds-1.00.82/doc/reference/a00533_ga95e0fccedc459a4404f496eec74a369a_icgraph.map100644 025423 025423 00000000433 13242511135 0021663 freetds-1.00.82/doc/reference/a00533_ga95e0fccedc459a4404f496eec74a369a_icgraph.md5100644 025423 025423 00000000040 13242511133 00215639485609a8dad545478fc2921361283d3freetds-1.00.82/doc/reference/a00533_ga95e0fccedc459a4404f496eec74a369a_icgraph.svg100644 025423 025423 00000003275 13242511136 0021715 tds_submit_query_params Node146 tds_submit_query_params Node147 tds_submit_query Node146->Node147 freetds-1.00.82/doc/reference/a00533_ga9ad2e6defce530a8778791cce0166ccd_icgraph.map100644 025423 025423 00000000344 13242511135 0021741 freetds-1.00.82/doc/reference/a00533_ga9ad2e6defce530a8778791cce0166ccd_icgraph.md5100644 025423 025423 00000000040 13242511133 00216409b3d5aaa41b574b88b49337ce0eaafa4freetds-1.00.82/doc/reference/a00533_ga9ad2e6defce530a8778791cce0166ccd_icgraph.svg100644 025423 025423 00000003202 13242511136 0021760 tds_start_query_head Node126 tds_start_query_head Node127 tds_start_query Node126->Node127 freetds-1.00.82/doc/reference/a00533_ga9f80fdf732b084aef7de7a323261aa61_cgraph.map100644 025423 025423 00000000361 13242511135 0021412 freetds-1.00.82/doc/reference/a00533_ga9f80fdf732b084aef7de7a323261aa61_cgraph.md5100644 025423 025423 00000000040 13242511133 00213123e0463208cbc435a509cc5e53b28a0a2freetds-1.00.82/doc/reference/a00533_ga9f80fdf732b084aef7de7a323261aa61_cgraph.svg100644 025423 025423 00000003216 13242511136 0021437 tds_deferred_unprepare Node35 tds_deferred_unprepare Node36 tds_needs_unprepare Node35->Node36 freetds-1.00.82/doc/reference/a00533_gaa823973b74efdf1ff00f340496bff614_cgraph.map100644 025423 025423 00000000621 13242511135 0021343 freetds-1.00.82/doc/reference/a00533_gaa823973b74efdf1ff00f340496bff614_cgraph.md5100644 025423 025423 00000000040 13242511133 0021244c9d426acedf79db4f69ec1c9002dbbaffreetds-1.00.82/doc/reference/a00533_gaa823973b74efdf1ff00f340496bff614_cgraph.svg100644 025423 025423 00000005047 13242511136 0021375 tds_next_placeholder_ucs2le Node50 tds_next_placeholder _ucs2le Node51 tds_skip_quoted_ucs2le Node50->Node51 Node52 tds_skip_comment_ucs2le Node50->Node52 freetds-1.00.82/doc/reference/a00533_gaa823973b74efdf1ff00f340496bff614_icgraph.map100644 025423 025423 00000000373 13242511135 0021520 freetds-1.00.82/doc/reference/a00533_gaa823973b74efdf1ff00f340496bff614_icgraph.md5100644 025423 025423 00000000040 13242511133 0021415a920fce4c457ad00195e56e7f398fa41freetds-1.00.82/doc/reference/a00533_gaa823973b74efdf1ff00f340496bff614_icgraph.svg100644 025423 025423 00000003606 13242511136 0021545 tds_next_placeholder_ucs2le Node53 tds_next_placeholder _ucs2le Node54 tds_count_placeholders _ucs2le Node53->Node54 freetds-1.00.82/doc/reference/a00533_gaaa7b4d37bf796019e72f25c6e7fe7bea_cgraph.map100644 025423 025423 00000001106 13242511135 0021570 freetds-1.00.82/doc/reference/a00533_gaaa7b4d37bf796019e72f25c6e7fe7bea_cgraph.md5100644 025423 025423 00000000040 13242511133 00214726fdcab0ac60ffe6859e42bc56199a6d5freetds-1.00.82/doc/reference/a00533_gaaa7b4d37bf796019e72f25c6e7fe7bea_cgraph.svg100644 025423 025423 00000006321 13242511136 0021617 tds_count_placeholders Node18 tds_count_placeholders Node19 tds_next_placeholder Node18->Node19 Node20 tds_skip_quoted Node19->Node20 Node21 tds_skip_comment Node19->Node21 freetds-1.00.82/doc/reference/a00533_gaaa7b4d37bf796019e72f25c6e7fe7bea_icgraph.map100644 025423 025423 00000000376 13242511135 0021751 freetds-1.00.82/doc/reference/a00533_gaaa7b4d37bf796019e72f25c6e7fe7bea_icgraph.md5100644 025423 025423 00000000040 13242511133 0021643d65c614b6a319e39d61ff0d832bcd8a3freetds-1.00.82/doc/reference/a00533_gaaa7b4d37bf796019e72f25c6e7fe7bea_icgraph.svg100644 025423 025423 00000003241 13242511136 0021766 tds_count_placeholders Node22 tds_count_placeholders Node23 tds_send_emulated_execute Node22->Node23 freetds-1.00.82/doc/reference/a00533_gaac7347ba9380d77d726648b85e9fab8f_icgraph.map100644 025423 025423 00000001071 13242511135 0021536 freetds-1.00.82/doc/reference/a00533_gaac7347ba9380d77d726648b85e9fab8f_icgraph.md5100644 025423 025423 00000000040 13242511133 0021437d27f01bd63a60207efbde3aa71863c5ffreetds-1.00.82/doc/reference/a00533_gaac7347ba9380d77d726648b85e9fab8f_icgraph.svg100644 025423 025423 00000006242 13242511136 0021566 tds_skip_comment Node105 tds_skip_comment Node106 tds_next_placeholder Node105->Node106 Node107 tds_count_placeholders Node106->Node107 Node108 tds_send_emulated_execute Node107->Node108 freetds-1.00.82/doc/reference/a00533_gab304fda9f325e852ba5c5252079d22e3_icgraph.map100644 025423 025423 00000000646 13242511135 0021424 freetds-1.00.82/doc/reference/a00533_gab304fda9f325e852ba5c5252079d22e3_icgraph.md5100644 025423 025423 00000000040 13242511133 0021316fce5e0635f2143d63b47ac33f22bb50cfreetds-1.00.82/doc/reference/a00533_gab304fda9f325e852ba5c5252079d22e3_icgraph.svg100644 025423 025423 00000005237 13242511136 0021450 tds_skip_comment_ucs2le Node110 tds_skip_comment_ucs2le Node111 tds_next_placeholder _ucs2le Node110->Node111 Node112 tds_count_placeholders _ucs2le Node111->Node112 freetds-1.00.82/doc/reference/a00533_gad695defcbf663b0023851a198206a772_icgraph.map100644 025423 025423 00000000332 13242511135 0021344 freetds-1.00.82/doc/reference/a00533_gad695defcbf663b0023851a198206a772_icgraph.md5100644 025423 025423 00000000040 13242511133 0021246913c30f16dc03c3e03f5a7d55e425d14freetds-1.00.82/doc/reference/a00533_gad695defcbf663b0023851a198206a772_icgraph.svg100644 025423 025423 00000003173 13242511136 0021375 tds_submit_queryf Node149 tds_submit_queryf Node150 tds_writetext_start Node149->Node150 freetds-1.00.82/doc/reference/a00533_gada27f4cfce925240ad33b71b63ca692d_cgraph.map100644 025423 025423 00000000621 13242511135 0021462 freetds-1.00.82/doc/reference/a00533_gada27f4cfce925240ad33b71b63ca692d_cgraph.md5100644 025423 025423 00000000040 13242511133 0021363cbdb1330c4b2a28845794a914529ed4ffreetds-1.00.82/doc/reference/a00533_gada27f4cfce925240ad33b71b63ca692d_cgraph.svg100644 025423 025423 00000004665 13242511136 0021521 tds_query_flush_packet Node68 tds_query_flush_packet Node69 tds_set_state Node68->Node69 Node70 tds_flush_packet Node68->Node70 freetds-1.00.82/doc/reference/a00533_gada27f4cfce925240ad33b71b63ca692d_icgraph.map100644 025423 025423 00000000336 13242511135 0021636 freetds-1.00.82/doc/reference/a00533_gada27f4cfce925240ad33b71b63ca692d_icgraph.md5100644 025423 025423 00000000040 13242511133 0021534a3841ca3db857d0650ab095ff87ca618freetds-1.00.82/doc/reference/a00533_gada27f4cfce925240ad33b71b63ca692d_icgraph.svg100644 025423 025423 00000003170 13242511136 0021660 tds_query_flush_packet Node71 tds_query_flush_packet Node72 tds_send_emulated_rpc Node71->Node72 freetds-1.00.82/doc/reference/a00533_gaf0da49585d39e99780a004ee2ca23479_cgraph.map100644 025423 025423 00000000341 13242511135 0021207 freetds-1.00.82/doc/reference/a00533_gaf0da49585d39e99780a004ee2ca23479_cgraph.md5100644 025423 025423 00000000040 13242511133 002111141cfd410ab00a56e1a1654196356dca0freetds-1.00.82/doc/reference/a00533_gaf0da49585d39e99780a004ee2ca23479_cgraph.svg100644 025423 025423 00000003176 13242511136 0021243 tds_submit_optioncmd Node137 tds_submit_optioncmd Node138 tdsdump_log Node137->Node138 freetds-1.00.82/doc/reference/a00533_gaf614c75ea8f7ad411e53dac0e2f91be4_cgraph.map100644 025423 025423 00000003076 13242511135 0021556 freetds-1.00.82/doc/reference/a00533_gaf614c75ea8f7ad411e53dac0e2f91be4_cgraph.md5100644 025423 025423 00000000040 13242511133 0021450fdef51923f94066e868749fbb63fbb8dfreetds-1.00.82/doc/reference/a00533_gaf614c75ea8f7ad411e53dac0e2f91be4_cgraph.svg100644 025423 025423 00000020137 13242511136 0021576 tds_send_emulated_rpc Node89 tds_send_emulated_rpc Node90 tds_get_column_declaration Node89->Node90 Node91 tds_put_string Node89->Node91 Node92 tds_put_param_as_string Node89->Node92 Node93 tds_dstr_isempty Node89->Node93 Node94 tds_dstr_cstr Node89->Node94 Node95 tds_dstr_len Node89->Node95 Node96 tds_query_flush_packet Node89->Node96 Node97 tds_set_state Node96->Node97 Node98 tds_flush_packet Node96->Node98 freetds-1.00.82/doc/reference/a00533_gafd74652c4722ddce4d642cc4209449d4_cgraph.map100644 025423 025423 00000000604 13242511135 0021261 freetds-1.00.82/doc/reference/a00533_gafd74652c4722ddce4d642cc4209449d4_cgraph.md5100644 025423 025423 00000000040 13242511133 0021161bd4ae2359a9657efe35b2ecf912fb109freetds-1.00.82/doc/reference/a00533_gafd74652c4722ddce4d642cc4209449d4_cgraph.svg100644 025423 025423 00000004650 13242511136 0021311 tds_put_data_info Node57 tds_put_data_info Node58 tds_dstr_len Node57->Node58 Node59 tdsdump_log Node57->Node59 freetds-1.00.82/doc/reference/a00534.md5100644 025423 025423 00000000040 13242511133 001274161bc69e3d0966adf8eba294ded7853bdfreetds-1.00.82/doc/reference/a00534.svg100644 025423 025423 00000003045 13242511136 0013066 Network functions Node0 Network functions Node1 LibTDS API Node1->Node0 freetds-1.00.82/doc/reference/a00534_ga0cb72d3f6943795c39db1fa692be0a58_cgraph.map100644 025423 025423 00000000336 13242511135 0021347 freetds-1.00.82/doc/reference/a00534_ga0cb72d3f6943795c39db1fa692be0a58_cgraph.md5100644 025423 025423 00000000040 13242511133 00212456cd0d839f96f66af1d293f9bffac606afreetds-1.00.82/doc/reference/a00534_ga0cb72d3f6943795c39db1fa692be0a58_cgraph.svg100644 025423 025423 00000003155 13242511136 0021374 tds_get_byte Node20 tds_get_byte Node21 tds_read_packet Node20->Node21 freetds-1.00.82/doc/reference/a00534_ga0cb72d3f6943795c39db1fa692be0a58_icgraph.map100644 025423 025423 00000000606 13242511135 0021520 freetds-1.00.82/doc/reference/a00534_ga0cb72d3f6943795c39db1fa692be0a58_icgraph.md5100644 025423 025423 00000000040 13242511133 0021416820fda12796608263acb15fefb44ac5cfreetds-1.00.82/doc/reference/a00534_ga0cb72d3f6943795c39db1fa692be0a58_icgraph.svg100644 025423 025423 00000005003 13242511136 0021537 tds_get_byte Node22 tds_get_byte Node23 tds_peek Node22->Node23 Node24 tds_process_param_result _tokens Node22->Node24 freetds-1.00.82/doc/reference/a00535.html100644 025423 025423 00000065631 13242511136 0013245 FreeTDS API: Dynamic string functions
    FreeTDS API
    Dynamic string functions

    Handle dynamic string. More...

    Collaboration diagram for Dynamic string functions:

    Macros

    #define DSTR_INITIALIZER   ((struct tds_dstr*) &tds_str_empty)
     Initializer, used to initialize string like in the following example. More...
     
    #define tds_dstr_empty(s)   tds_dstr_free(s)
     Make a string empty.
     

    Functions

    DSTRtds_dstr_alloc (DSTR *s, size_t length)
     allocate space for length char More...
     
    static char * tds_dstr_buf (DSTR *s)
     Returns a buffer to edit the string. More...
     
    DSTRtds_dstr_copy (DSTR *s, const char *src)
     copy a string from another More...
     
    DSTRtds_dstr_copyn (DSTR *s, const char *src, size_t length)
     Set string to a given buffer of characters. More...
     
    static const char * tds_dstr_cstr (DSTR *s)
     Returns a C version (NUL terminated string) of dstr.
     
    DSTRtds_dstr_dup (DSTR *s, const DSTR *src)
     Duplicate a string from another dynamic string. More...
     
    void tds_dstr_free (DSTR *s)
     free string
     
    static void tds_dstr_init (DSTR *s)
     init a string with empty
     
    static int tds_dstr_isempty (DSTR *s)
     test if string is empty
     
    static size_t tds_dstr_len (DSTR *s)
     Returns the length of the string in bytes.
     
    DSTRtds_dstr_set (DSTR *s, char *src)
     set a string from another buffer. More...
     
    DSTRtds_dstr_setlen (DSTR *s, size_t length)
     limit length of string, MUST be <= current length More...
     
    void tds_dstr_zero (DSTR *s)
     clear all string filling with zeroes (mainly for security reason)
     

    Variables

    const struct tds_dstr tds_str_empty
     Internal representation for an empty string.
     

    Detailed Description

    Handle dynamic string.

    In this string are always valid (you don't have NULL pointer, only empty strings)

    Macro Definition Documentation

    § DSTR_INITIALIZER

    #define DSTR_INITIALIZER   ((struct tds_dstr*) &tds_str_empty)

    Initializer, used to initialize string like in the following example.

    Function Documentation

    § tds_dstr_alloc()

    DSTR * tds_dstr_alloc ( DSTR s,
    size_t  length 
    )

    allocate space for length char

    Parameters
    sdynamic string
    lengthnew length
    Returns
    string allocated or NULL on memory error

    § tds_dstr_buf()

    static char* tds_dstr_buf ( DSTR s)
    inlinestatic

    Returns a buffer to edit the string.

    Be careful to avoid buffer overflows and remember to set the correct length at the end of the editing if changed.

    § tds_dstr_copy()

    DSTR * tds_dstr_copy ( DSTR s,
    const char *  src 
    )

    copy a string from another

    Parameters
    sdynamic string
    srcsource buffer
    Returns
    string copied or NULL on memory error
    Here is the call graph for this function:
    Here is the caller graph for this function:

    § tds_dstr_copyn()

    DSTR * tds_dstr_copyn ( DSTR s,
    const char *  src,
    size_t  length 
    )

    Set string to a given buffer of characters.

    Parameters
    sdynamic string
    srcsource buffer
    lengthlength of source buffer
    Returns
    string copied or NULL on memory error
    Here is the caller graph for this function:

    § tds_dstr_dup()

    DSTR * tds_dstr_dup ( DSTR s,
    const DSTR src 
    )

    Duplicate a string from another dynamic string.

    Parameters
    soutput string
    srcsource string to copy
    Returns
    string copied or NULL on memory error
    Here is the call graph for this function:

    § tds_dstr_set()

    DSTR * tds_dstr_set ( DSTR s,
    char *  src 
    )

    set a string from another buffer.

    The string will use the supplied buffer (it not copy the string), so it should be a pointer returned by malloc.

    Parameters
    sdynamic string
    srcsource buffer
    Returns
    string copied or NULL on memory error
    Here is the call graph for this function:

    § tds_dstr_setlen()

    DSTR * tds_dstr_setlen ( DSTR s,
    size_t  length 
    )

    limit length of string, MUST be <= current length

    Parameters
    sdynamic string
    lengthnew length
    freetds-1.00.82/doc/reference/a00534_ga1fcaf8d488cc1390f106ce3ad0bf37b4_icgraph.map100644 025423 025423 00000000566 13242511135 0021725 freetds-1.00.82/doc/reference/a00534_ga1fcaf8d488cc1390f106ce3ad0bf37b4_icgraph.md5100644 025423 025423 00000000040 13242511133 0021616dbe84e8d0a9f4b236783719d353bc633freetds-1.00.82/doc/reference/a00534_ga1fcaf8d488cc1390f106ce3ad0bf37b4_icgraph.svg100644 025423 025423 00000004650 13242511136 0021746 tds_put_string Node62 tds_put_string Node63 tds_send_emulated_rpc Node62->Node63 Node64 tds_quote_and_put Node62->Node64 freetds-1.00.82/doc/reference/a00534_ga221e98a9c8be96ec6c8547891e1b53af_cgraph.map100644 025423 025423 00000000577 13242511135 0021375 freetds-1.00.82/doc/reference/a00534_ga221e98a9c8be96ec6c8547891e1b53af_cgraph.md5100644 025423 025423 00000000040 13242511133 00212643aaaf68cdb292261bc0e8cc83c9859d9freetds-1.00.82/doc/reference/a00534_ga221e98a9c8be96ec6c8547891e1b53af_cgraph.svg100644 025423 025423 00000004531 13242511136 0021412 tds_peek Node57 tds_peek Node58 tds_get_byte Node57->Node58 Node59 tds_read_packet Node58->Node59 freetds-1.00.82/doc/reference/a00534_ga2734407109c834c5dda7ff8a45c71230_cgraph.map100644 025423 025423 00000000366 13242511135 0021116 freetds-1.00.82/doc/reference/a00534_ga2734407109c834c5dda7ff8a45c71230_cgraph.md5100644 025423 025423 00000000040 13242511133 0021011f2e4b92159dc449f2ea31de0ce7f4f82freetds-1.00.82/doc/reference/a00534_ga2734407109c834c5dda7ff8a45c71230_cgraph.svg100644 025423 025423 00000003203 13242511136 0021132 tds_goodwrite Node54 tds_goodwrite Node55 tds_select Node54->Node55 freetds-1.00.82/doc/reference/a00534_ga410619783bdf2bb60b0f27a5578e0e07_icgraph.map100644 025423 025423 00000001066 13242511135 0021343 freetds-1.00.82/doc/reference/a00534_ga410619783bdf2bb60b0f27a5578e0e07_icgraph.md5100644 025423 025423 00000000040 13242511133 0021240c00b254b72f27a944fa2795deac2204efreetds-1.00.82/doc/reference/a00534_ga410619783bdf2bb60b0f27a5578e0e07_icgraph.svg100644 025423 025423 00000006416 13242511136 0021372 tds_read_packet Node66 tds_read_packet Node67 tds_get_byte Node66->Node67 Node68 tds_peek Node67->Node68 Node69 tds_process_param_result _tokens Node67->Node69 freetds-1.00.82/doc/reference/a00534_ga5feb53554e8917a81bbbc332163a61fb_icgraph.map100644 025423 025423 00000000543 13242511135 0021502 freetds-1.00.82/doc/reference/a00534_ga5feb53554e8917a81bbbc332163a61fb_icgraph.md5100644 025423 025423 00000000040 13242511133 00214003f8680b04d310d5891bc2d84bc07bd99freetds-1.00.82/doc/reference/a00534_ga5feb53554e8917a81bbbc332163a61fb_icgraph.svg100644 025423 025423 00000004520 13242511136 0021524 tds_flush_packet Node17 tds_flush_packet Node18 tds_query_flush_packet Node17->Node18 Node19 tds_send_emulated_rpc Node18->Node19 freetds-1.00.82/doc/reference/a00534_ga676c4dee6522815b16fdc8e448e43590_cgraph.map100644 025423 025423 00000002162 13242511135 0021217 freetds-1.00.82/doc/reference/a00534_ga676c4dee6522815b16fdc8e448e43590_cgraph.md5100644 025423 025423 00000000040 13242511133 002111608358cb52d2321d10e7a8ac05e9fedcafreetds-1.00.82/doc/reference/a00534_ga676c4dee6522815b16fdc8e448e43590_cgraph.svg100644 025423 025423 00000013177 13242511136 0021252 read_and_convert Node0 read_and_convert Node1 tds_datain_stream_init Node0->Node1 Node4 tds_staticout_stream_init Node0->Node4 Node6 tds_convert_stream Node0->Node6 Node2 tds_datain_stream_read Node1->Node2 Node3 tds_get_n Node2->Node3 Node5 tds_staticout_stream _write Node4->Node5 freetds-1.00.82/doc/reference/a00534_ga8ab6c87318eaf15ea17a9575763f7809_cgraph.map100644 025423 025423 00000000413 13242511135 0021222 freetds-1.00.82/doc/reference/a00534_ga8ab6c87318eaf15ea17a9575763f7809_cgraph.md5100644 025423 025423 00000000040 13242511133 002112449104c11f2b287c96928d141788e9c10freetds-1.00.82/doc/reference/a00534_ga8ab6c87318eaf15ea17a9575763f7809_cgraph.svg100644 025423 025423 00000003223 13242511136 0021247 tds_get_uint8 Node51 tds_get_uint8 Node52 tds_get_n Node51->Node52 freetds-1.00.82/doc/reference/a00534_ga9ac121c269e203337a48c5bf8afc48c3_cgraph.map100644 025423 025423 00000000411 13242511135 0021325 freetds-1.00.82/doc/reference/a00534_ga9ac121c269e203337a48c5bf8afc48c3_cgraph.md5100644 025423 025423 00000000040 13242511133 0021231581538b2f73fc9edb1acb9735d10476afreetds-1.00.82/doc/reference/a00534_ga9ac121c269e203337a48c5bf8afc48c3_cgraph.svg100644 025423 025423 00000003217 13242511136 0021357 tds_get_uint Node47 tds_get_uint Node48 tds_get_n Node47->Node48 freetds-1.00.82/doc/reference/a00534_ga9ac121c269e203337a48c5bf8afc48c3_icgraph.map100644 025423 025423 00000000354 13242511135 0021504 freetds-1.00.82/doc/reference/a00534_ga9ac121c269e203337a48c5bf8afc48c3_icgraph.md5100644 025423 025423 00000000040 13242511133 00214028acf546ae1b4065b9bbb648fdfbbb4aafreetds-1.00.82/doc/reference/a00534_ga9ac121c269e203337a48c5bf8afc48c3_icgraph.svg100644 025423 025423 00000003203 13242511136 0021523 tds_get_uint Node49 tds_get_uint Node50 tds5_process_dyn_result2 Node49->Node50 freetds-1.00.82/doc/reference/a00534_gad6f81b48fbcfc18ce0b213dbbea47e30_cgraph.map100644 025423 025423 00000000331 13242511135 0021676 freetds-1.00.82/doc/reference/a00534_gad6f81b48fbcfc18ce0b213dbbea47e30_cgraph.md5100644 025423 025423 00000000040 13242511133 0021601e5779e9021e4ae9628215de966f8afd3freetds-1.00.82/doc/reference/a00534_gad6f81b48fbcfc18ce0b213dbbea47e30_cgraph.svg100644 025423 025423 00000003150 13242511136 0021723 tds_socket_write Node78 tds_socket_write Node79 tdsdump_log Node78->Node79 freetds-1.00.82/doc/reference/a00534_gad7aae89e32444ab30852fee056231403_icgraph.map100644 025423 025423 00000000576 13242511135 0021343 freetds-1.00.82/doc/reference/a00534_gad7aae89e32444ab30852fee056231403_icgraph.md5100644 025423 025423 00000000040 13242511133 00212336224885880822d6e62386b016ce6489ffreetds-1.00.82/doc/reference/a00534_gad7aae89e32444ab30852fee056231403_icgraph.svg100644 025423 025423 00000004633 13242511136 0021364 tds_select Node71 tds_select Node72 tds_goodread Node71->Node72 Node73 tds_goodwrite Node71->Node73 freetds-1.00.82/doc/reference/a00534_gae7d9c4e1a079e1d0aa0252732631e8c4_icgraph.map100644 025423 025423 00000005655 13242511135 0021426 freetds-1.00.82/doc/reference/a00534_gae7d9c4e1a079e1d0aa0252732631e8c4_icgraph.md5100644 025423 025423 00000000040 13242511133 00213136427257d545ed691efbd4fc48804995ffreetds-1.00.82/doc/reference/a00534_gae7d9c4e1a079e1d0aa0252732631e8c4_icgraph.svg100644 025423 025423 00000036327 13242511136 0021451 tds_get_n Node28 tds_get_n Node29 tds_datain_stream_read Node28->Node29 Node32 tds_get_usmallint Node28->Node32 Node36 tds_process_colinfo Node28->Node36 Node43 tds_get_uint Node28->Node43 Node44 tds_get_uint8 Node28->Node44 Node30 tds_datain_stream_init Node29->Node30 Node31 read_and_convert Node30->Node31 Node33 tds_process_col_name Node32->Node33 Node34 tds_process_col_fmt Node32->Node34 Node35 tds_process_tabname Node32->Node35 Node32->Node36 Node37 tds_process_end Node32->Node37 Node38 tds_process_env_chg Node32->Node38 Node39 tds_process_dyn_result Node32->Node39 Node40 tds5_process_dyn_result2 Node32->Node40 Node41 tds_process_compute _names Node32->Node41 Node42 tds_process_cursor _tokens Node32->Node42 Node43->Node40 freetds-1.00.82/doc/reference/a00535.map100644 025423 025423 00000000301 13242511135 0013034 freetds-1.00.82/doc/reference/a00535.md5100644 025423 025423 00000000040 13242511133 00127425bc0ca9d6cfd588d87c5a7b6e2650809freetds-1.00.82/doc/reference/a00535.svg100644 025423 025423 00000003075 13242511136 0013072 Dynamic string functions Node0 Dynamic string functions Node1 LibTDS API Node1->Node0 freetds-1.00.82/doc/reference/a00535_ga4e6d9fa6f9b9551a5a3390e10a5322e6_cgraph.map100644 025423 025423 00000000334 13242511135 0021257 freetds-1.00.82/doc/reference/a00535_ga4e6d9fa6f9b9551a5a3390e10a5322e6_cgraph.md5100644 025423 025423 00000000040 13242511133 0021157de7022070361b66b0dad7bd60fbf1357freetds-1.00.82/doc/reference/a00535_ga4e6d9fa6f9b9551a5a3390e10a5322e6_cgraph.svg100644 025423 025423 00000003152 13242511136 0021303 tds_dstr_dup Node17 tds_dstr_dup Node18 tds_dstr_copyn Node17->Node18 freetds-1.00.82/doc/reference/a00535_ga656718f240d7403f986ae887d84a6ca1_icgraph.map100644 025423 025423 00000001661 13242511135 0021317 freetds-1.00.82/doc/reference/a00535_ga656718f240d7403f986ae887d84a6ca1_icgraph.md5100644 025423 025423 00000000040 13242511133 002121310e7b442e57e762cd8b0bfa1e0cc5aedfreetds-1.00.82/doc/reference/a00535_ga656718f240d7403f986ae887d84a6ca1_icgraph.svg100644 025423 025423 00000012174 13242511136 0021343 tds_dstr_copyn Node11 tds_dstr_copyn Node12 parse_server_name_for_port Node11->Node12 Node13 tds_dstr_copy Node11->Node13 Node16 tds_dstr_dup Node11->Node16 Node13->Node12 Node14 tds_dstr_set Node13->Node14 Node15 tds_process_colinfo Node13->Node15 freetds-1.00.82/doc/reference/a00535_gab78cc59b110df2817b00f9bed74c6ff1_cgraph.map100644 025423 025423 00000000564 13242511135 0021504 freetds-1.00.82/doc/reference/a00535_gab78cc59b110df2817b00f9bed74c6ff1_cgraph.md5100644 025423 025423 00000000040 13242511133 002137715747795f38c6592e0d484fb660c171ffreetds-1.00.82/doc/reference/a00535_gab78cc59b110df2817b00f9bed74c6ff1_cgraph.svg100644 025423 025423 00000004532 13242511136 0021526 tds_dstr_set Node20 tds_dstr_set Node21 tds_dstr_copy Node20->Node21 Node22 tds_dstr_copyn Node21->Node22 freetds-1.00.82/doc/reference/a00535_gad96366d9fa93bfc283cef1299fbe97ab_cgraph.map100644 025423 025423 00000000336 13242511135 0021614 freetds-1.00.82/doc/reference/a00535_gad96366d9fa93bfc283cef1299fbe97ab_cgraph.md5100644 025423 025423 00000000040 13242511133 00215120c54946a06dea365a4a8b2533608f480freetds-1.00.82/doc/reference/a00535_gad96366d9fa93bfc283cef1299fbe97ab_cgraph.svg100644 025423 025423 00000003146 13242511136 0021641 tds_dstr_copy Node4 tds_dstr_copy Node5 tds_dstr_copyn Node4->Node5 freetds-1.00.82/doc/reference/a00535_gad96366d9fa93bfc283cef1299fbe97ab_icgraph.map100644 025423 025423 00000001146 13242511135 0021765 freetds-1.00.82/doc/reference/a00535_gad96366d9fa93bfc283cef1299fbe97ab_icgraph.md5100644 025423 025423 00000000040 13242511133 00216630c42465eff5ead3339f727fc32143a86freetds-1.00.82/doc/reference/a00535_gad96366d9fa93bfc283cef1299fbe97ab_icgraph.svg100644 025423 025423 00000006332 13242511136 0022012 tds_dstr_copy Node6 tds_dstr_copy Node7 parse_server_name_for_port Node6->Node7 Node8 tds_dstr_set Node6->Node8 Node9 tds_process_colinfo Node6->Node9 freetds-1.00.82/doc/reference/a00536.html100644 025423 025423 00000324076 13242511136 0013247 FreeTDS API: Results processing
    FreeTDS API
    Results processing

    Handle tokens in packets. More...

    Collaboration diagram for Results processing:

    Classes

    struct  namelist
     Holds list of names. More...
     

    Functions

    static void adjust_character_column_size (TDSSOCKET *tds, TDSCOLUMN *curcol)
     Adjust column size according to client's encoding. More...
     
    int determine_adjusted_size (const TDSICONV *char_conv, int size)
     Allow for maximum possible size of converted data, while being careful about integer division truncation. More...
     
    static TDSRET tds5_process_dyn_result2 (TDSSOCKET *tds)
     Process new TDS 5.0 token for describing output parameters. More...
     
    static TDSRET tds5_process_optioncmd (TDSSOCKET *tds)
     Process option cmd results. More...
     
    static TDSRET tds5_process_result (TDSSOCKET *tds)
     tds5_process_result() is the TDS 5.0 result set processing routine. More...
     
    static TDSRET tds5_process_result2 (TDSSOCKET *tds)
     tds5_process_result2() is the new TDS 5.0 result set processing routine. More...
     
    static int tds71_read_table_names (TDSSOCKET *tds, int remainder, struct namelist **p_head)
     Reads table names for TDS 7.1+. More...
     
    static TDSRET tds7_get_data_info (TDSSOCKET *tds, TDSCOLUMN *curcol)
     Reads data information from wire. More...
     
    static TDSRET tds7_process_compute_result (TDSSOCKET *tds)
     tds7_process_compute_result() processes compute result sets for TDS 7/8. More...
     
    static TDSRET tds7_process_result (TDSSOCKET *tds)
     tds7_process_result() is the TDS 7.0 result set processing routine. More...
     
    static int tds_alloc_get_string (TDSSOCKET *tds, char **string, size_t len)
     Reads a string from wire in a new allocated buffer. More...
     
    static void tds_free_namelist (struct namelist *head)
     Frees list of names. More...
     
    static TDSRET tds_get_data_info (TDSSOCKET *tds, TDSCOLUMN *curcol, int is_param)
     Reads data metadata from wire. More...
     
    int tds_get_token_size (int marker)
     tds_get_token_size() returns the size of a fixed length token used by tds_process_cancel() to determine how to read past a token More...
     
    TDSDYNAMICtds_lookup_dynamic (TDSCONNECTION *conn, const char *id)
     Finds a dynamic given string id. More...
     
    static const char * tds_pr_op (int op)
     Returns string representation for a given operation. More...
     
    static TDSRET tds_process_auth (TDSSOCKET *tds)
     Process authentication token. More...
     
    TDSRET tds_process_cancel (TDSSOCKET *tds)
     
    static TDSRET tds_process_col_fmt (TDSSOCKET *tds)
     tds_process_col_fmt() is the other half of result set processing under TDS 4.2. More...
     
    static TDSRET tds_process_col_name (TDSSOCKET *tds)
     tds_process_col_name() is one half of the result set under TDS 4.2 it contains all the column names, a TDS_COLFMT_TOKEN should immediately follow this token with the datatype/size information This is a 4.2 only function More...
     
    static TDSRET tds_process_colinfo (TDSSOCKET *tds, char **names, int num_names)
     Reads column information. More...
     
    static TDSRET tds_process_compute (TDSSOCKET *tds)
     tds_process_compute() processes compute rows and places them in the row buffer. More...
     
    static TDSRET tds_process_compute_names (TDSSOCKET *tds)
     tds_process_compute_names() processes compute result sets. More...
     
    static TDSRET tds_process_compute_result (TDSSOCKET *tds)
     tds_process_compute_result() processes compute result sets. More...
     
    static TDSRET tds_process_cursor_tokens (TDSSOCKET *tds)
     Reads cursor command results. More...
     
    static TDSRET tds_process_default_tokens (TDSSOCKET *tds, int marker)
     tds_process_default_tokens() is a catch all function that is called to process tokens not known to other tds_process_* routines More...
     
    static TDSRET tds_process_dyn_result (TDSSOCKET *tds)
     Process results from dynamic. More...
     
    static TDSDYNAMICtds_process_dynamic (TDSSOCKET *tds)
     tds_process_dynamic() finds the element of the dyns array for the id More...
     
    static TDSRET tds_process_end (TDSSOCKET *tds, int marker, int *flags_parm)
     tds_process_end() processes any of the DONE, DONEPROC, or DONEINPROC tokens. More...
     
    static TDSRET tds_process_env_chg (TDSSOCKET *tds)
     tds_process_env_chg() when ever certain things change on the server, such as database, character set, language, or block size. More...
     
    static TDSRET tds_process_env_routing (TDSSOCKET *tds)
     
    static TDSRET tds_process_featureextack (TDSSOCKET *tds)
     
    static TDSRET tds_process_info (TDSSOCKET *tds, int marker)
     tds_process_info() is called for INFO, ERR, or EED tokens and is responsible for calling the CLI's message handling routine More...
     
    TDSRET tds_process_login_tokens (TDSSOCKET *tds)
     tds_process_login_tokens() is called after sending the login packet to the server. More...
     
    static TDSRET tds_process_nbcrow (TDSSOCKET *tds)
     tds_process_nbcrow() processes rows and places them in the row buffer.
     
    static TDSRET tds_process_param_result (TDSSOCKET *tds, TDSPARAMINFO **pinfo)
     process output parameters of a stored procedure. More...
     
    static TDSRET tds_process_param_result_tokens (TDSSOCKET *tds)
     Process parameters from networks. More...
     
    static TDSRET tds_process_params_result_token (TDSSOCKET *tds)
     tds_process_params_result_token() processes params on TDS5. More...
     
    static void tds_process_pending_closes (TDSSOCKET *tds)
     Attempt to close all deferred closes (dynamics and cursors). More...
     
    static TDSRET tds_process_row (TDSSOCKET *tds)
     tds_process_row() processes rows and places them in the row buffer. More...
     
    TDSRET tds_process_simple_query (TDSSOCKET *tds)
     Process results for simple query as "SET TEXTSIZE" or "USE dbname" If the statement returns results, beware they are discarded. More...
     
    static TDSRET tds_process_tabname (TDSSOCKET *tds)
     Process list of table from network. More...
     
    TDSRET tds_process_tokens (TDSSOCKET *tds, TDS_INT *result_type, int *done_flags, unsigned flag)
     process all streams. More...
     
    const char * tds_prtype (int type)
     Returns string representation of the given type. More...
     
    static int tds_read_namelist (TDSSOCKET *tds, int remainder, struct namelist **p_head, int large)
     Reads list of names (usually table names) More...
     
    static const char * tds_token_name (unsigned char marker)
     Returns string representation for a given token type. More...
     

    Detailed Description

    Handle tokens in packets.

    Many PDU (packets data unit) contain tokens. (like result description, rows, data, errors and many other).

    Function Documentation

    § adjust_character_column_size()

    static void adjust_character_column_size ( TDSSOCKET tds,
    TDSCOLUMN curcol 
    )
    static

    Adjust column size according to client's encoding.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    curcolcolumn to adjust

    § determine_adjusted_size()

    int determine_adjusted_size ( const TDSICONV char_conv,
    int  size 
    )

    Allow for maximum possible size of converted data, while being careful about integer division truncation.

    All character data pass through iconv. It doesn't matter if the server side is Unicode or not; even Latin1 text need conversion if, for example, the client is UTF-8.

    Parameters
    char_convconversion structure
    sizeunconverted byte size
    Returns
    maximum size for converted string

    § tds5_process_dyn_result2()

    static TDSRET tds5_process_dyn_result2 ( TDSSOCKET tds)
    static

    Process new TDS 5.0 token for describing output parameters.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    Here is the call graph for this function:

    § tds5_process_optioncmd()

    static TDSRET tds5_process_optioncmd ( TDSSOCKET tds)
    static

    Process option cmd results.

    This token is available only on TDS 5.0 (Sybase).

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    Here is the call graph for this function:

    § tds5_process_result()

    static TDSRET tds5_process_result ( TDSSOCKET tds)
    static

    tds5_process_result() is the TDS 5.0 result set processing routine.

    It is responsible for populating the tds->res_info structure. This is a TDS 5.0 only function

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.

    § tds5_process_result2()

    static TDSRET tds5_process_result2 ( TDSSOCKET tds)
    static

    tds5_process_result2() is the new TDS 5.0 result set processing routine.

    It is responsible for populating the tds->res_info structure. This is a TDS 5.0 only function

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    Here is the call graph for this function:

    § tds71_read_table_names()

    static int tds71_read_table_names ( TDSSOCKET tds,
    int  remainder,
    struct namelist **  p_head 
    )
    static

    Reads table names for TDS 7.1+.

    TDS 7.1+ return table names as an array of names (so database.schema.owner.name as separate names)

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    remainderbytes left to read
    p_headpointer to list head to return
    Returns
    number of element returned or -1 on error

    § tds7_get_data_info()

    static TDSRET tds7_get_data_info ( TDSSOCKET tds,
    TDSCOLUMN curcol 
    )
    static

    Reads data information from wire.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    curcolcolumn where to store information

    § tds7_process_compute_result()

    static TDSRET tds7_process_compute_result ( TDSSOCKET tds)
    static

    tds7_process_compute_result() processes compute result sets for TDS 7/8.

    They is are very similar to normal result sets.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.

    § tds7_process_result()

    static TDSRET tds7_process_result ( TDSSOCKET tds)
    static

    tds7_process_result() is the TDS 7.0 result set processing routine.

    It is responsible for populating the tds->res_info structure. This is a TDS 7.0 only function

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    Here is the call graph for this function:

    § tds_alloc_get_string()

    static int tds_alloc_get_string ( TDSSOCKET tds,
    char **  string,
    size_t  len 
    )
    static

    Reads a string from wire in a new allocated buffer.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    stringoutput string
    lenlength of string to read
    Returns
    0 for success, -1 on error.

    § tds_free_namelist()

    static void tds_free_namelist ( struct namelist head)
    static

    Frees list of names.

    Parameters
    headlist head to free

    § tds_get_data_info()

    static TDSRET tds_get_data_info ( TDSSOCKET tds,
    TDSCOLUMN curcol,
    int  is_param 
    )
    static

    Reads data metadata from wire.

    Parameters
    tdsstate information for the socket and the TDS protocol
    curcolcolumn where to store information
    is_paramtrue if metadata are for a parameter (false for normal column)
    Here is the call graph for this function:

    § tds_get_token_size()

    int tds_get_token_size ( int  marker)

    tds_get_token_size() returns the size of a fixed length token used by tds_process_cancel() to determine how to read past a token

    Parameters
    markertoken type.

    § tds_lookup_dynamic()

    TDSDYNAMIC* tds_lookup_dynamic ( TDSCONNECTION conn,
    const char *  id 
    )

    Finds a dynamic given string id.

    Returns
    dynamic or NULL is not found
    Parameters
    connstate information for the socket and the TDS protocol
    iddynamic id to search
    Here is the caller graph for this function:

    § tds_pr_op()

    static const char * tds_pr_op ( int  op)
    static

    Returns string representation for a given operation.

    Parameters
    opoperation code
    Returns
    string representation. Empty if not found.

    § tds_process_auth()

    static TDSRET tds_process_auth ( TDSSOCKET tds)
    static

    Process authentication token.

    This token is only TDS 7.0+.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.

    § tds_process_cancel()

    TDSRET tds_process_cancel ( TDSSOCKET tds)
    Remarks
    Process the incoming token stream until it finds an end token (DONE, DONEPROC, DONEINPROC) with the cancel flag set. At that point the connection should be ready to handle a new query.
    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.

    § tds_process_col_fmt()

    static TDSRET tds_process_col_fmt ( TDSSOCKET tds)
    static

    tds_process_col_fmt() is the other half of result set processing under TDS 4.2.

    It follows tds_process_col_name(). It contains all the column type and size information. This is a 4.2 only function

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    Here is the call graph for this function:

    § tds_process_col_name()

    static TDSRET tds_process_col_name ( TDSSOCKET tds)
    static

    tds_process_col_name() is one half of the result set under TDS 4.2 it contains all the column names, a TDS_COLFMT_TOKEN should immediately follow this token with the datatype/size information This is a 4.2 only function

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    Here is the call graph for this function:

    § tds_process_colinfo()

    static TDSRET tds_process_colinfo ( TDSSOCKET tds,
    char **  names,
    int  num_names 
    )
    static

    Reads column information.

    This token is only TDS 4.2

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    [in]namestable names
    [in]num_namesnumber of table names
    Here is the call graph for this function:

    § tds_process_compute()

    static TDSRET tds_process_compute ( TDSSOCKET tds)
    static

    tds_process_compute() processes compute rows and places them in the row buffer.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.

    § tds_process_compute_names()

    static TDSRET tds_process_compute_names ( TDSSOCKET tds)
    static

    tds_process_compute_names() processes compute result sets.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    Here is the call graph for this function:

    § tds_process_compute_result()

    static TDSRET tds_process_compute_result ( TDSSOCKET tds)
    static

    tds_process_compute_result() processes compute result sets.

    These functions need work but since they get little use, nobody has complained! It is very similar to normal result sets.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.

    § tds_process_cursor_tokens()

    static TDSRET tds_process_cursor_tokens ( TDSSOCKET tds)
    static

    Reads cursor command results.

    This contains status of cursors.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    Here is the call graph for this function:

    § tds_process_default_tokens()

    static TDSRET tds_process_default_tokens ( TDSSOCKET tds,
    int  marker 
    )
    static

    tds_process_default_tokens() is a catch all function that is called to process tokens not known to other tds_process_* routines

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    markerToken type
    Here is the call graph for this function:

    § tds_process_dyn_result()

    static TDSRET tds_process_dyn_result ( TDSSOCKET tds)
    static

    Process results from dynamic.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    Here is the call graph for this function:

    § tds_process_dynamic()

    static TDSDYNAMIC * tds_process_dynamic ( TDSSOCKET tds)
    static

    tds_process_dynamic() finds the element of the dyns array for the id

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    Returns
    allocated dynamic or NULL on failure.

    § tds_process_end()

    static TDSRET tds_process_end ( TDSSOCKET tds,
    int  marker,
    int *  flags_parm 
    )
    static

    tds_process_end() processes any of the DONE, DONEPROC, or DONEINPROC tokens.

    Parameters
    tdsstate information for the socket and the TDS protocol
    markerTDS token number
    flags_parmfilled with bit flags (see TDS_DONE_ constants). Is NULL nothing is returned
    Here is the call graph for this function:

    § tds_process_env_chg()

    static TDSRET tds_process_env_chg ( TDSSOCKET tds)
    static

    tds_process_env_chg() when ever certain things change on the server, such as database, character set, language, or block size.

    A environment change message is generated There is no action taken currently, but certain functions at the CLI level that return the name of the current database will need to use this.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    Here is the call graph for this function:

    § tds_process_info()

    static TDSRET tds_process_info ( TDSSOCKET tds,
    int  marker 
    )
    static

    tds_process_info() is called for INFO, ERR, or EED tokens and is responsible for calling the CLI's message handling routine

    Returns
    TDS_SUCCESS if informational, TDS_FAIL if error.

    § tds_process_login_tokens()

    TDSRET tds_process_login_tokens ( TDSSOCKET tds)

    tds_process_login_tokens() is called after sending the login packet to the server.

    It returns the success or failure of the login dependent on the protocol version. 4.2 sends an ACK token only when successful, TDS 5.0 sends it always with a success byte within

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.

    § tds_process_param_result()

    static TDSRET tds_process_param_result ( TDSSOCKET tds,
    TDSPARAMINFO **  pinfo 
    )
    static

    process output parameters of a stored procedure.

    This differs from regular row/compute results in that there is no total number of parameters given, they just show up singly.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    [out]pinfooutput parameter. Should point to a not allocated structure
    Here is the call graph for this function:
    Here is the caller graph for this function:

    § tds_process_param_result_tokens()

    static TDSRET tds_process_param_result_tokens ( TDSSOCKET tds)
    static

    Process parameters from networks.

    Read all consecutives paramaters, not a single one. Parameters are then stored in tds->param_info or tds->cur_dyn->res_info depending if we are reading cursor results or normal parameters.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    Here is the call graph for this function:

    § tds_process_params_result_token()

    static TDSRET tds_process_params_result_token ( TDSSOCKET tds)
    static

    tds_process_params_result_token() processes params on TDS5.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.

    § tds_process_pending_closes()

    static void tds_process_pending_closes ( TDSSOCKET tds)
    static

    Attempt to close all deferred closes (dynamics and cursors).

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.

    § tds_process_row()

    static TDSRET tds_process_row ( TDSSOCKET tds)
    static

    tds_process_row() processes rows and places them in the row buffer.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.

    § tds_process_simple_query()

    TDSRET tds_process_simple_query ( TDSSOCKET tds)

    Process results for simple query as "SET TEXTSIZE" or "USE dbname" If the statement returns results, beware they are discarded.

    This function was written to avoid direct calls to tds_process_default_tokens (which caused problems such as ignoring query errors). Results are read until idle state or severe failure (do not stop for statement failure).

    Returns
    see tds_process_tokens for results (TDS_NO_MORE_RESULTS is never returned)

    § tds_process_tabname()

    static TDSRET tds_process_tabname ( TDSSOCKET tds)
    static

    Process list of table from network.

    This token is only TDS 4.2

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    Here is the call graph for this function:

    § tds_process_tokens()

    TDSRET tds_process_tokens ( TDSSOCKET tds,
    TDS_INT *  result_type,
    int *  done_flags,
    unsigned  flag 
    )

    process all streams.

    tds_process_tokens() is called after submitting a query with tds_submit_query() and is responsible for calling the routines to populate tds->res_info if appropriate (some query have no result sets)

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    result_typeA pointer to an integer variable which tds_process_tokens sets to indicate the current type of result.
    Values that indicate command status
    TDS_DONE_RESULTThe results of a command have been completely processed. This command returned no rows.
    TDS_DONEPROC_RESULTThe results of a command have been completely processed. This command returned rows.
    TDS_DONEINPROC_RESULTThe results of a command have been completely processed. This command returned rows.
    Values that indicate results information is available
    TDS_ROWFMT_RESULTRegular Data format information tds->res_info now contains the result details ; tds->current_results now points to that data
    TDS_COMPUTEFMT_ RESULTCompute data format information tds->comp_info now contains the result data; tds->current_results now points to that data
    TDS_DESCRIBE_RESULT
    Values that indicate data is available
    ValueMeaningInformation returned
    TDS_ROW_RESULTRegular row results 1 or more rows of regular data can now be retrieved
    TDS_COMPUTE_RESULTCompute row results A single row of compute data can now be retrieved
    TDS_PARAM_RESULTReturn parameter results param_info or cur_dyn->params contain returned parameters
    TDS_STATUS_RESULTStored procedure status results tds->ret_status contain the returned code
    Parameters
    done_flagsFlags contained in the TDS_DONE*_TOKEN readed
    flagFlags to select token type to stop/return
    Todo:
    Complete TDS_DESCRIBE_RESULT description
    Return values
    TDS_SUCCESSif a result set is available for processing.
    TDS_FAILon error.
    TDS_NO_MORE_RESULTSif all results have been completely processed.
    anythingreturned by one of the many functions it calls. :-(
    Here is the call graph for this function:

    § tds_prtype()

    const char* tds_prtype ( int  type)

    Returns string representation of the given type.

    Parameters
    typedata type
    Returns
    type as string. Empty if not found.
    Here is the caller graph for this function:

    § tds_read_namelist()

    static int tds_read_namelist ( TDSSOCKET tds,
    int  remainder,
    struct namelist **  p_head,
    int  large 
    )
    static

    Reads list of names (usually table names)

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    remainderbytes left to read
    p_headlist head to return
    largetrue if name length from network are 2 byte (usually 1)
    Here is the caller graph for this function:

    § tds_token_name()

    static const char * tds_token_name ( unsigned char  marker)
    static

    Returns string representation for a given token type.

    Parameters
    markertoken type
    Returns
    string representation. Empty if not token not valid.
    freetds-1.00.82/doc/reference/a00536.map100644 025423 025423 00000000265 13242511135 0013046 freetds-1.00.82/doc/reference/a00536.md5100644 025423 025423 00000000040 13242511133 0012743d3708f620ce26cb77b1335606bf17c68freetds-1.00.82/doc/reference/a00536.svg100644 025423 025423 00000003051 13242511136 0013065 Results processing Node0 Results processing Node1 LibTDS API Node1->Node0 freetds-1.00.82/doc/reference/a00536_ga0cf7e719115b0ae476753442d10505ab_icgraph.map100644 025423 025423 00000000322 13242511135 0021245 freetds-1.00.82/doc/reference/a00536_ga0cf7e719115b0ae476753442d10505ab_icgraph.md5100644 025423 025423 00000000040 13242511133 0021150c282d3add1b2e2a18e6c60648da94197freetds-1.00.82/doc/reference/a00537.html100644 025423 025423 00000016175 13242511136 0013246 FreeTDS API: LibTDS API
    FreeTDS API
    LibTDS API

    Callable functions in libtds. More...

    Collaboration diagram for LibTDS API:

    Modules

     Authentication
     Functions for handling authentication.
     
     Configuration
     Handle reading of configuration.
     
     Conversion
     Conversions between datatypes.
     
     Charset conversion
     Convert between different charsets.
     
     Memory allocation
     Allocate or free resources.
     
     Query
     Function to handle query.
     
     Network functions
     Functions for reading or writing from network.
     
     Dynamic string functions
     Handle dynamic string.
     
     Results processing
     Handle tokens in packets.
     

    Detailed Description

    Callable functions in libtds.

    The libtds library is for use internal to FreeTDS. It is not intended for use by applications. Although any use is permitted, you're encouraged to use one of the established public APIs instead, because their interfaces are stable and documented by the vendors.

    freetds-1.00.82/doc/reference/a00537.map100644 025423 025423 00000002220 13242511135 0013040 freetds-1.00.82/doc/reference/a00536_ga0cf7e719115b0ae476753442d10505ab_icgraph.svg100644 025423 025423 00000003141 13242511136 0021272 tds_prtype Node119 tds_prtype Node120 tdsdump_col Node119->Node120 freetds-1.00.82/doc/reference/a00536_ga22c7f413d43fc0d511e122a3de389166_cgraph.map100644 025423 025423 00000001372 13242511135 0021164 freetds-1.00.82/doc/reference/a00536_ga22c7f413d43fc0d511e122a3de389166_cgraph.md5100644 025423 025423 00000000040 13242511133 00210618fb9c23096ffba319520aadc150242c4freetds-1.00.82/doc/reference/a00536_ga22c7f413d43fc0d511e122a3de389166_cgraph.svg100644 025423 025423 00000010521 13242511136 0021203 tds_process_colinfo Node53 tds_process_colinfo Node54 tds_get_usmallint Node53->Node54 Node55 tds_get_n Node53->Node55 Node56 tds_dstr_copy Node53->Node56 Node54->Node55 Node57 tds_dstr_copyn Node56->Node57 freetds-1.00.82/doc/reference/a00536_ga315d875d90c64d12d61fc9e33b4dee96_cgraph.map100644 025423 025423 00000000700 13242511135 0021350 freetds-1.00.82/doc/reference/a00536_ga315d875d90c64d12d61fc9e33b4dee96_cgraph.md5100644 025423 025423 00000000040 13242511133 00212533a21c181d9e9e11b6ec4a7abe0e97c2cfreetds-1.00.82/doc/reference/a00536_ga315d875d90c64d12d61fc9e33b4dee96_cgraph.svg100644 025423 025423 00000005016 13242511136 0021400 tds_process_cursor_tokens Node68 tds_process_cursor _tokens Node69 tds_get_usmallint Node68->Node69 Node70 tds_get_n Node69->Node70 freetds-1.00.82/doc/reference/a00536_ga39453d084f3f780ac4602d4abf2839f7_cgraph.map100644 025423 025423 00000000356 13242511135 0021214 freetds-1.00.82/doc/reference/a00536_ga39453d084f3f780ac4602d4abf2839f7_cgraph.md5100644 025423 025423 00000000040 13242511133 00211105da35f2f5273e74ed288f104f3a3eb0bfreetds-1.00.82/doc/reference/a00536_ga39453d084f3f780ac4602d4abf2839f7_cgraph.svg100644 025423 025423 00000003357 13242511136 0021243 tds_process_default_tokens Node72 tds_process_default _tokens Node73 tdsdump_log Node72->Node73 freetds-1.00.82/doc/reference/a00536_ga3e1b4df4410a86a563a8c155e7799720_cgraph.map100644 025423 025423 00000000662 13242511135 0021127 freetds-1.00.82/doc/reference/a00536_ga3e1b4df4410a86a563a8c155e7799720_cgraph.md5100644 025423 025423 00000000040 13242511133 00210233b432914f404079ab9904caed1e9d5cffreetds-1.00.82/doc/reference/a00536_ga3e1b4df4410a86a563a8c155e7799720_cgraph.svg100644 025423 025423 00000004632 13242511136 0021153 tds_process_env_chg Node85 tds_process_env_chg Node86 tds_get_usmallint Node85->Node86 Node87 tds_get_n Node86->Node87 freetds-1.00.82/doc/reference/a00536_ga416cf119c1d4a0fca27dc5b50c261358_cgraph.map100644 025423 025423 00000000670 13242511135 0021317 freetds-1.00.82/doc/reference/a00536_ga416cf119c1d4a0fca27dc5b50c261358_cgraph.md5100644 025423 025423 00000000040 13242511133 00212147f301d871e84d71f82c9f1eba715aff7freetds-1.00.82/doc/reference/a00536_ga416cf119c1d4a0fca27dc5b50c261358_cgraph.svg100644 025423 025423 00000004645 13242511136 0021350 tds_process_dyn_result Node75 tds_process_dyn_result Node76 tds_get_usmallint Node75->Node76 Node77 tds_get_n Node76->Node77 freetds-1.00.82/doc/reference/a00536_ga4e3dd9d3614f5f0433b78b761dd68741_cgraph.map100644 025423 025423 00000000662 13242511135 0021217 freetds-1.00.82/doc/reference/a00536_ga4e3dd9d3614f5f0433b78b761dd68741_cgraph.md5100644 025423 025423 00000000040 13242511133 0021113313fad9b7a0a611ce5af61263c60c545freetds-1.00.82/doc/reference/a00536_ga4e3dd9d3614f5f0433b78b761dd68741_cgraph.svg100644 025423 025423 00000004630 13242511136 0021241 tds_process_col_fmt Node44 tds_process_col_fmt Node45 tds_get_usmallint Node44->Node45 Node46 tds_get_n Node45->Node46 freetds-1.00.82/doc/reference/a00536_ga595fe391e60a71bd98ffd53b4c015e44_icgraph.map100644 025423 025423 00000000332 13242511135 0021517 freetds-1.00.82/doc/reference/a00536_ga595fe391e60a71bd98ffd53b4c015e44_icgraph.md5100644 025423 025423 00000000040 13242511133 0021421aca469c3746eedc3e3666355d16dd4d7freetds-1.00.82/doc/reference/a00536_ga595fe391e60a71bd98ffd53b4c015e44_icgraph.svg100644 025423 025423 00000003162 13242511136 0021546 tds_lookup_dynamic Node36 tds_lookup_dynamic Node37 tds_alloc_dynamic Node36->Node37 freetds-1.00.82/doc/reference/a00536_ga7a081cf9bb8f04ead12f0299fb7c4cd9_cgraph.map100644 025423 025423 00000000652 13242511135 0021567 freetds-1.00.82/doc/reference/a00536_ga7a081cf9bb8f04ead12f0299fb7c4cd9_cgraph.md5100644 025423 025423 00000000040 13242511133 002146440178b3162b3c92331d7e98f6c68bf94freetds-1.00.82/doc/reference/a00536_ga7a081cf9bb8f04ead12f0299fb7c4cd9_cgraph.svg100644 025423 025423 00000004614 13242511136 0021614 tds_process_end Node81 tds_process_end Node82 tds_get_usmallint Node81->Node82 Node83 tds_get_n Node82->Node83 freetds-1.00.82/doc/reference/a00536_ga905d2fa5e1b602817bd16bb0fcf9eadb_cgraph.map100644 025423 025423 00000001134 13242511135 0021622 freetds-1.00.82/doc/reference/a00536_ga905d2fa5e1b602817bd16bb0fcf9eadb_cgraph.md5100644 025423 025423 00000000040 13242511133 00215234d2830f4a019e6c5c9cce83bd8198978freetds-1.00.82/doc/reference/a00536_ga905d2fa5e1b602817bd16bb0fcf9eadb_cgraph.svg100644 025423 025423 00000006335 13242511136 0021655 tds_process_col_name Node48 tds_process_col_name Node49 tds_get_usmallint Node48->Node49 Node51 tds_read_namelist Node48->Node51 Node50 tds_get_n Node49->Node50 freetds-1.00.82/doc/reference/a00536_ga9fdef8228d29cab7fa9098f07fa73fba_cgraph.map100644 025423 025423 00000001373 13242511135 0021670 freetds-1.00.82/doc/reference/a00536_ga9fdef8228d29cab7fa9098f07fa73fba_cgraph.md5100644 025423 025423 00000000040 13242511133 0021564158690350fd4eb3551175af4956ce373freetds-1.00.82/doc/reference/a00536_ga9fdef8228d29cab7fa9098f07fa73fba_cgraph.svg100644 025423 025423 00000010123 13242511136 0021704 tds_process_param_result_tokens Node97 tds_process_param_result _tokens Node98 tds_get_byte Node97->Node98 Node100 tds_process_param_result Node97->Node100 Node99 tds_read_packet Node98->Node99 Node101 tdsdump_log Node100->Node101 freetds-1.00.82/doc/reference/a00536_gaa6a7e5aeb10a1322911c47be9c43e2d2_cgraph.map100644 025423 025423 00000000345 13242511135 0021373 freetds-1.00.82/doc/reference/a00536_gaa6a7e5aeb10a1322911c47be9c43e2d2_cgraph.md5100644 025423 025423 00000000040 13242511133 0021271940770c2ce6de8ee1ef4ccfe37f70aa3freetds-1.00.82/doc/reference/a00536_gaa6a7e5aeb10a1322911c47be9c43e2d2_cgraph.svg100644 025423 025423 00000003171 13242511136 0021416 tds5_process_optioncmd Node9 tds5_process_optioncmd Node10 tdsdump_log Node9->Node10 freetds-1.00.82/doc/reference/a00536_gabe2bdd5a41ce067cb31aef18ff81cb1c_cgraph.map100644 025423 025423 00000000341 13242511135 0021753 freetds-1.00.82/doc/reference/a00536_gabe2bdd5a41ce067cb31aef18ff81cb1c_cgraph.md5100644 025423 025423 00000000040 13242511133 00216557e37ce9b043c4d734f0bd995bb8c7b3cfreetds-1.00.82/doc/reference/a00536_gabe2bdd5a41ce067cb31aef18ff81cb1c_cgraph.svg100644 025423 025423 00000003166 13242511136 0022006 tds5_process_result2 Node14 tds5_process_result2 Node15 tdsdump_log Node14->Node15 freetds-1.00.82/doc/reference/a00536_gabfc9de1d1fe718818caf63a4be4035a6_cgraph.map100644 025423 025423 00000000335 13242511135 0021560 freetds-1.00.82/doc/reference/a00536_gabfc9de1d1fe718818caf63a4be4035a6_cgraph.md5100644 025423 025423 00000000040 13242511133 0021457fcf26729f55fa2c00f3948a8c766bbc9freetds-1.00.82/doc/reference/a00536_gabfc9de1d1fe718818caf63a4be4035a6_cgraph.svg100644 025423 025423 00000003170 13242511136 0021603 tds_process_tokens Node115 tds_process_tokens Node116 tdsdump_log Node115->Node116 freetds-1.00.82/doc/reference/a00536_gaca56fc22d65a24a96d1bef310ade73aa_cgraph.map100644 025423 025423 00000000337 13242511135 0021617 freetds-1.00.82/doc/reference/a00536_gaca56fc22d65a24a96d1bef310ade73aa_cgraph.md5100644 025423 025423 00000000040 13242511133 0021514cfec42da176a91394aa017ba198ae109freetds-1.00.82/doc/reference/a00536_gaca56fc22d65a24a96d1bef310ade73aa_cgraph.svg100644 025423 025423 00000003163 13242511136 0021642 tds7_process_result Node23 tds7_process_result Node24 tdsdump_log Node23->Node24 freetds-1.00.82/doc/reference/a00536_gacb3354443bcefe7a500a500a4904cc05_cgraph.map100644 025423 025423 00000000351 13242511135 0021301 freetds-1.00.82/doc/reference/a00536_gacb3354443bcefe7a500a500a4904cc05_cgraph.md5100644 025423 025423 00000000040 13242511133 0021202d6adbd3ba65950e351639ad650f00abffreetds-1.00.82/doc/reference/a00536_gacb3354443bcefe7a500a500a4904cc05_cgraph.svg100644 025423 025423 00000003201 13242511136 0021321 tds_process_param_result Node93 tds_process_param_result Node94 tdsdump_log Node93->Node94 freetds-1.00.82/doc/reference/a00536_gacb3354443bcefe7a500a500a4904cc05_icgraph.map100644 025423 025423 00000000352 13242511135 0021453 freetds-1.00.82/doc/reference/a00536_gacb3354443bcefe7a500a500a4904cc05_icgraph.md5100644 025423 025423 00000000040 13242511133 0021353f8f5f926108a9113737f28f9095c7e22freetds-1.00.82/doc/reference/a00536_gacb3354443bcefe7a500a500a4904cc05_icgraph.svg100644 025423 025423 00000003376 13242511136 0021507 tds_process_param_result Node95 tds_process_param_result Node96 tds_process_param_result _tokens Node95->Node96 freetds-1.00.82/doc/reference/a00536_gad9b6b86f48be077fb44ac603845a0c27_cgraph.map100644 025423 025423 00000000333 13242511135 0021344 freetds-1.00.82/doc/reference/a00536_gad9b6b86f48be077fb44ac603845a0c27_cgraph.md5100644 025423 025423 00000000040 13242511133 002124584b299c34fe6256b346264cee7e2c388freetds-1.00.82/doc/reference/a00536_gad9b6b86f48be077fb44ac603845a0c27_cgraph.svg100644 025423 025423 00000003155 13242511136 0021374 tds_get_data_info Node30 tds_get_data_info Node31 tdsdump_log Node30->Node31 freetds-1.00.82/doc/reference/a00536_gae5b3e01f3d665f9e377de091f46f1ab9_cgraph.map100644 025423 025423 00000001135 13242511135 0021434 freetds-1.00.82/doc/reference/a00536_gae5b3e01f3d665f9e377de091f46f1ab9_cgraph.md5100644 025423 025423 00000000040 13242511133 0021334178a2f01e5bde7fa6d916d1ead1d6ad5freetds-1.00.82/doc/reference/a00536_gae5b3e01f3d665f9e377de091f46f1ab9_cgraph.svg100644 025423 025423 00000006476 13242511136 0021474 tds_process_compute_names Node61 tds_process_compute _names Node62 tds_get_usmallint Node61->Node62 Node64 tdsdump_log Node61->Node64 Node63 tds_get_n Node62->Node63 freetds-1.00.82/doc/reference/a00536_gae688b515631141acfbc41bbb91c8b921_cgraph.map100644 025423 025423 00000001131 13242511135 0021317 freetds-1.00.82/doc/reference/a00536_gae688b515631141acfbc41bbb91c8b921_cgraph.md5100644 025423 025423 00000000040 13242511133 0021223d2dcbce447d2a24363cbd21718964d4bfreetds-1.00.82/doc/reference/a00536_gae688b515631141acfbc41bbb91c8b921_cgraph.svg100644 025423 025423 00000007062 13242511136 0021353 tds5_process_dyn_result2 Node4 tds5_process_dyn_result2 Node5 tds_get_uint Node4->Node5 Node7 tds_get_usmallint Node4->Node7 Node6 tds_get_n Node5->Node6 Node7->Node6 freetds-1.00.82/doc/reference/a00536_gaeaaed2ea1d8c827da1a0f5b419524ae1_icgraph.map100644 025423 025423 00000000440 13242511135 0021762 freetds-1.00.82/doc/reference/a00536_gaeaaed2ea1d8c827da1a0f5b419524ae1_icgraph.md5100644 025423 025423 00000000040 13242511133 0021664e28f02ad134a269d6ad09e471b5237b3freetds-1.00.82/doc/reference/a00536_gaeaaed2ea1d8c827da1a0f5b419524ae1_icgraph.svg100644 025423 025423 00000003300 13242511136 0022003 tds_read_namelist Node122 tds_read_namelist Node123 tds_process_col_name Node122->Node123 freetds-1.00.82/doc/reference/a00536_gaeec59bca9bd0c5388e245f0d19d9c81a_cgraph.map100644 025423 025423 00000000662 13242511135 0021573 freetds-1.00.82/doc/reference/a00536_gaeec59bca9bd0c5388e245f0d19d9c81a_cgraph.md5100644 025423 025423 00000000040 13242511133 0021467d330b6cc0754cd5588e3dda925341fc7freetds-1.00.82/doc/reference/a00536_gaeec59bca9bd0c5388e245f0d19d9c81a_cgraph.svg100644 025423 025423 00000004650 13242511136 0021617 tds_process_tabname Node111 tds_process_tabname Node112 tds_get_usmallint Node111->Node112 Node113 tds_get_n Node112->Node113 freetds-1.00.82/doc/reference/a00537.md5100644 025423 025423 00000000040 13242511133 00127447eae09aa0c08134f16722a58d3a70468freetds-1.00.82/doc/reference/a00537.svg100644 025423 025423 00000016776 13242511136 0013110 LibTDS API Node7 Network functions Node6 Query Node5 Memory allocation Node1 Authentication Node8 Dynamic string functions Node3 Conversion Node9 Results processing Node2 Configuration Node4 Charset conversion Node0 LibTDS API Node0->Node7 Node0->Node6 Node0->Node5 Node0->Node1 Node0->Node8 Node0->Node3 Node0->Node9 Node0->Node2 Node0->Node4 freetds-1.00.82/doc/reference/a00538.html100644 025423 025423 00000011557 13242511133 0013243 FreeTDS API: Member List
    FreeTDS API
    METADATA Member List

    This is the complete list of members for METADATA, including all inherited members.

    format_string (defined in METADATA)METADATA
    name (defined in METADATA)METADATA
    nchars (defined in METADATA)METADATA
    size (defined in METADATA)METADATA
    size (defined in METADATA)METADATA
    source (defined in METADATA)METADATA
    type (defined in METADATA)METADATA
    type (defined in METADATA)METADATA
    width (defined in METADATA)METADATA
    width (defined in METADATA)METADATA
    freetds-1.00.82/doc/reference/a00541.html100644 025423 025423 00000014526 13242511133 0013234 FreeTDS API: METADATA Struct Reference
    FreeTDS API
    METADATA Struct Reference

    Public Attributes

    char * format_string
     
    char * name
     
    SQLINTEGER nchars
     
    int size
     
    SQLULEN size
     
    const char * source
     
    SQLSMALLINT type
     
    int type
     
    int width
     
    SQLULEN width
     

    The documentation for this struct was generated from the following files:
    • src/apps/bsqldb.c
    • src/apps/bsqlodbc.c
    freetds-1.00.82/doc/reference/a00542.html100644 025423 025423 00000006502 13242511133 0013230 FreeTDS API: Member List
    FreeTDS API
    DATA Member List

    This is the complete list of members for DATA, including all inherited members.

    buffer (defined in DATA)DATA
    len (defined in DATA)DATA
    status (defined in DATA)DATA
    freetds-1.00.82/doc/reference/a00545.html100644 025423 025423 00000007735 13242511133 0013244 FreeTDS API: DATA Struct Reference
    FreeTDS API
    DATA Struct Reference

    Public Attributes

    char * buffer
     
    SQLLEN len
     
    int status
     

    The documentation for this struct was generated from the following files:
    • src/apps/bsqldb.c
    • src/apps/bsqlodbc.c
    freetds-1.00.82/doc/reference/a00546.html100644 025423 025423 00000006542 13242511133 0013240 FreeTDS API: Member List
    FreeTDS API
    METACOMP Member List

    This is the complete list of members for METACOMP, including all inherited members.

    data (defined in METACOMP)METACOMP
    meta (defined in METACOMP)METACOMP
    numalts (defined in METACOMP)METACOMP
    freetds-1.00.82/doc/reference/a00547.map100644 025423 025423 00000000351 13242511136 0013045 freetds-1.00.82/doc/reference/a00547.md5100644 025423 025423 00000000040 13242511133 0012745ac813389754c3a204fb5ebbcdf0f8cfbfreetds-1.00.82/doc/reference/a00547.svg100644 025423 025423 00000004725 13242511136 0013100 METACOMP Node1 METACOMP Node2 METADATA Node2->Node1 meta Node3 DATA Node3->Node1 data freetds-1.00.82/doc/reference/a00549.html100644 025423 025423 00000010662 13242511136 0013244 FreeTDS API: METACOMP Struct Reference
    FreeTDS API
    METACOMP Struct Reference
    Collaboration diagram for METACOMP:
    [legend]

    Public Attributes

    struct DATAdata
     
    struct METADATAmeta
     
    int numalts
     

    The documentation for this struct was generated from the following file:
    • src/apps/bsqldb.c
    freetds-1.00.82/doc/reference/a00550.html100644 025423 025423 00000007031 13242511133 0013225 FreeTDS API: Member List
    FreeTDS API
    KEY_T Member List

    This is the complete list of members for KEY_T, including all inherited members.

    keys (defined in KEY_T)KEY_T
    keys (defined in KEY_T)KEY_T
    nkeys (defined in KEY_T)KEY_T
    nkeys (defined in KEY_T)KEY_T
    freetds-1.00.82/doc/reference/a00551.map100644 025423 025423 00000000202 13242511135 0013032 freetds-1.00.82/doc/reference/a00551.md5100644 025423 025423 00000000040 13242511133 001274079429b1eb66eae6f43ef5c85740924c1freetds-1.00.82/doc/reference/a00551.svg100644 025423 025423 00000003157 13242511136 0013071 KEY_T Node1 KEY_T Node2 col_t Node2->Node1 keys freetds-1.00.82/doc/reference/a00553.html100644 025423 025423 00000011353 13242511136 0013235 FreeTDS API: KEY_T Struct Reference
    FreeTDS API
    KEY_T Struct Reference
    Collaboration diagram for KEY_T:
    [legend]

    Public Attributes

    int * keys
     
    struct col_tkeys
     
    size_t nkeys
     
    int nkeys
     

    The documentation for this struct was generated from the following files:
    • src/apps/bsqldb.c
    • src/dblib/dbpivot.c
    freetds-1.00.82/doc/reference/a00554.html100644 025423 025423 00000013776 13242511133 0013246 FreeTDS API: Member List
    FreeTDS API
    _options Member List

    This is the complete list of members for _options, including all inherited members.

    appname (defined in _options)_options
    colsep (defined in _options)_options
    database (defined in _options)_options
    error_filename (defined in _options)_options
    fquiet (defined in _options)_options
    fverbose (defined in _options)_options
    headers (defined in _options)_options
    hostname (defined in _options)_options
    input_filename (defined in _options)_options
    odbc_version (defined in _options)_options
    optind (defined in _options)_options
    output_filename (defined in _options)_options
    pivot (defined in _options)_options
    servername (defined in _options)_options
    verbose (defined in _options)_options
    freetds-1.00.82/doc/reference/a00555.map100644 025423 025423 00000000526 13242511135 0013047 freetds-1.00.82/doc/reference/a00555.md5100644 025423 025423 00000000040 13242511133 0012744477225a5781c3e9e3d0ed32ba33f6c4dfreetds-1.00.82/doc/reference/a00555.svg100644 025423 025423 00000007657 13242511136 0013106 _options Node1 _options Node2 _options::pivot_t Node2->Node1 pivot Node3 col_t Node3->Node2 func Node4 KEY_T Node3->Node4 keys Node4->Node2 col_key row_key freetds-1.00.82/doc/reference/a00557.html100644 025423 025423 00000021743 13242511136 0013245 FreeTDS API: _options Struct Reference
    FreeTDS API
    _options Struct Reference
    Collaboration diagram for _options:
    [legend]

    Classes

    struct  pivot_t
     

    Public Attributes

    char * appname
     
    const char * colsep
     
    char * database
     
    char * error_filename
     
    int fquiet
     
    int fverbose
     
    FILE * headers
     
    char hostname [128]
     
    char * input_filename
     
    size_t odbc_version
     
    int optind
     
    char * output_filename
     
    struct _options::pivot_t pivot
     
    char * servername
     
    FILE * verbose
     

    The documentation for this struct was generated from the following files:
    • src/apps/bsqldb.c
    • src/apps/bsqlodbc.c
    • src/apps/defncopy.c
    freetds-1.00.82/doc/reference/a00558.html100644 025423 025423 00000007535 13242511133 0013246 FreeTDS API: Member List
    FreeTDS API
    _options::pivot_t Member List

    This is the complete list of members for _options::pivot_t, including all inherited members.

    col_key (defined in _options::pivot_t)_options::pivot_t
    func (defined in _options::pivot_t)_options::pivot_t
    row_key (defined in _options::pivot_t)_options::pivot_t
    val_col (defined in _options::pivot_t)_options::pivot_t
    freetds-1.00.82/doc/reference/a00559.map100644 025423 025423 00000000374 13242511135 0013054 freetds-1.00.82/doc/reference/a00559.md5100644 025423 025423 00000000040 13242511133 0012750f1ef2b7caab34cdcb76d71adb766dc98freetds-1.00.82/doc/reference/a00559.svg100644 025423 025423 00000006201 13242511136 0013072 _options::pivot_t Node1 _options::pivot_t Node2 col_t Node2->Node1 func Node3 KEY_T Node2->Node3 keys Node3->Node1 col_key row_key freetds-1.00.82/doc/reference/a00561.html100644 025423 025423 00000011740 13242511136 0013234 FreeTDS API: _options::pivot_t Struct Reference
    FreeTDS API
    _options::pivot_t Struct Reference
    Collaboration diagram for _options::pivot_t:
    [legend]

    Public Attributes

    KEY_T col_key
     
    DBPIVOT_FUNC func
     
    KEY_T row_key
     
    int val_col
     

    The documentation for this struct was generated from the following file:
    • src/apps/bsqldb.c
    freetds-1.00.82/doc/reference/a00562.html100644 025423 025423 00000010037 13242511133 0013230 FreeTDS API: Member List
    FreeTDS API
    LOGINREC Member List

    This is the complete list of members for LOGINREC, including all inherited members.

    client_charset (defined in LOGINREC)LOGINREC
    client_hostname (defined in LOGINREC)LOGINREC
    connect_timeout (defined in LOGINREC)LOGINREC
    password (defined in LOGINREC)LOGINREC
    query_timeout (defined in LOGINREC)LOGINREC
    username (defined in LOGINREC)LOGINREC
    freetds-1.00.82/doc/reference/a00565.html100644 025423 025423 00000011766 13242511133 0013245 FreeTDS API: LOGINREC Struct Reference
    FreeTDS API
    LOGINREC Struct Reference

    Public Attributes

    char * client_charset
     
    char * client_hostname
     
    int connect_timeout
     
    char * password
     
    int query_timeout
     
    char * username
     

    The documentation for this struct was generated from the following file:
    • src/apps/bsqlodbc.c
    freetds-1.00.82/doc/reference/a00566.html100644 025423 025423 00000007464 13242511133 0013246 FreeTDS API: Member List
    FreeTDS API
    OBJECTINFO Member List

    This is the complete list of members for OBJECTINFO, including all inherited members.

    db (defined in OBJECTINFO)OBJECTINFO
    dbobject (defined in OBJECTINFO)OBJECTINFO
    pass (defined in OBJECTINFO)OBJECTINFO
    server (defined in OBJECTINFO)OBJECTINFO
    user (defined in OBJECTINFO)OBJECTINFO
    freetds-1.00.82/doc/reference/a00569.html100644 025423 025423 00000011175 13242511133 0013243 FreeTDS API: OBJECTINFO Struct Reference
    FreeTDS API
    OBJECTINFO Struct Reference

    Public Attributes

    char * db
     
    char * dbobject
     
    char * pass
     
    char * server
     
    char * user
     

    The documentation for this struct was generated from the following file:
    • src/apps/datacopy.c
    freetds-1.00.82/doc/reference/a00570.html100644 025423 025423 00000031770 13242511133 0013236 FreeTDS API: Member List
    FreeTDS API
    pd Member List

    This is the complete list of members for pd, including all inherited members.

    aflag (defined in pd)pd
    Aflag (defined in pd)pd
    batchsize (defined in pd)pd
    bflag (defined in pd)pd
    cflag (defined in pd)pd
    charset (defined in pd)pd
    dbdirection (defined in pd)pd
    dbname (defined in pd)pd
    dbobject (defined in pd)pd
    dest (defined in pd)pd
    Dflag (defined in pd)pd
    direction (defined in pd)pd
    eflag (defined in pd)pd
    Eflag (defined in pd)pd
    errorfile (defined in pd)pd
    fflag (defined in pd)pd
    Fflag (defined in pd)pd
    fieldterm (defined in pd)pd
    fieldtermlen (defined in pd)pd
    firstrow (defined in pd)pd
    formatfile (defined in pd)pd
    hint (defined in pd)pd
    hostfilename (defined in pd)pd
    Iflag (defined in pd)pd
    inputfile (defined in pd)pd
    interfacesfile (defined in pd)pd
    lastrow (defined in pd)pd
    Lflag (defined in pd)pd
    maxerrors (defined in pd)pd
    mflag (defined in pd)pd
    nflag (defined in pd)pd
    options (defined in pd)pd
    outputfile (defined in pd)pd
    owner (defined in pd)pd
    packetsize (defined in pd)pd
    pass (defined in pd)pd
    pflag (defined in pd)pd
    Pflag (defined in pd)pd
    rflag (defined in pd)pd
    rowterm (defined in pd)pd
    rowtermlen (defined in pd)pd
    server (defined in pd)pd
    Sflag (defined in pd)pd
    src (defined in pd)pd
    textsize (defined in pd)pd
    Tflag (defined in pd)pd
    tflag (defined in pd)pd
    Uflag (defined in pd)pd
    user (defined in pd)pd
    vflag (defined in pd)pd
    freetds-1.00.82/doc/reference/a00571.map100644 025423 025423 00000000201 13242511136 0013034 freetds-1.00.82/doc/reference/a00571.md5100644 025423 025423 00000000040 13242511133 0012742114091c1a2bf3969be06222fdb9f01adfreetds-1.00.82/doc/reference/a00571.svg100644 025423 025423 00000003351 13242511136 0013067 pd Node1 pd Node2 OBJECTINFO Node2->Node1 dest src freetds-1.00.82/doc/reference/a00573.html100644 025423 025423 00000050336 13242511136 0013243 FreeTDS API: pd Struct Reference
    FreeTDS API
    pd Struct Reference
    Collaboration diagram for pd:
    [legend]

    Public Attributes

    int aflag
     
    int Aflag
     
    int batchsize
     
    int bflag
     
    int cflag
     
    char * charset
     
    char dbdirection [10]
     
    char * dbname
     
    char * dbobject
     
    OBJECTINFO dest
     
    int Dflag
     
    DBINT direction
     
    int eflag
     
    int Eflag
     
    char * errorfile
     
    int fflag
     
    int Fflag
     
    char * fieldterm
     
    int fieldtermlen
     
    int firstrow
     
    char * formatfile
     
    char * hint
     
    char * hostfilename
     
    int Iflag
     
    char * inputfile
     
    char * interfacesfile
     
    int lastrow
     
    int Lflag
     
    int maxerrors
     
    int mflag
     
    int nflag
     
    char * options
     
    char * outputfile
     
    char * owner
     
    int packetsize
     
    char * pass
     
    int Pflag
     
    int pflag
     
    int rflag
     
    char * rowterm
     
    int rowtermlen
     
    char * server
     
    int Sflag
     
    OBJECTINFO src
     
    int textsize
     
    int tflag
     
    int Tflag
     
    int Uflag
     
    char * user
     
    int vflag
     

    The documentation for this struct was generated from the following files:
    freetds-1.00.82/doc/reference/a00574.html100644 025423 025423 00000006211 13242511133 0013232 FreeTDS API: Member List
    FreeTDS API
    _procedure Member List

    This is the complete list of members for _procedure, including all inherited members.

    name (defined in _procedure)_procedure
    owner (defined in _procedure)_procedure
    freetds-1.00.82/doc/reference/a00577.html100644 025423 025423 00000007200 13242511133 0013234 FreeTDS API: _procedure Struct Reference
    FreeTDS API
    _procedure Struct Reference

    Public Attributes

    char name [512]
     
    char owner [512]
     

    The documentation for this struct was generated from the following file:
    • src/apps/defncopy.c
    freetds-1.00.82/doc/reference/a00578.html100644 025423 025423 00000007070 13242511133 0013242 FreeTDS API: Member List
    FreeTDS API
    dblib_buffer_row Member List

    This is the complete list of members for dblib_buffer_row, including all inherited members.

    resinfodblib_buffer_row
    rowdblib_buffer_row
    row_datadblib_buffer_row
    sizesdblib_buffer_row
    freetds-1.00.82/doc/reference/a00579.map100644 025423 025423 00000002737 13242511135 0013063 freetds-1.00.82/doc/reference/a00579.md5100644 025423 025423 00000000040 13242511133 0012752b7e3a9e2e107de697f6da8d924b58785freetds-1.00.82/doc/reference/a00579.svg100644 025423 025423 00000045273 13242511136 0013110 dblib_buffer_row Node1 dblib_buffer_row Node2 tds_result_info Node2->Node1 resinfo Node3 tds_socket Node2->Node3 param_info current_results res_info comp_info Node9 tds_dynamic Node2->Node9 res_info params Node10 tds_cursor Node2->Node10 res_info Node3->Node2 attached_to Node4 tds_login Node4->Node3 login Node7 tds_dstr Node7->Node4 server_realm_name password server_name dump_file library crlfile server_spn client_host _name client_charset openssl_ciphers ... Node22 tds_column Node7->Node22 column_name table_name table_column_name Node8 tds_packet Node8->Node3 recv_packet send_packet Node8->Node8 next Node9->Node3 cur_dyn Node9->Node9 next Node12 tds_connection Node9->Node12 dyns Node10->Node3 cur_cursor Node10->Node10 next Node10->Node12 cursors Node12->Node3 conn Node18 tdsiconvinfo Node18->Node12 char_convs Node18->Node22 char_conv Node22->Node2 columns Node23 tds_column_funcs Node23->Node22 funcs Node24 tds_bcpcoldata Node24->Node22 bcp_column_data freetds-1.00.82/doc/reference/a00581.html100644 025423 025423 00000013267 13242511136 0013244 FreeTDS API: dblib_buffer_row Struct Reference
    FreeTDS API
    dblib_buffer_row Struct Reference
    Collaboration diagram for dblib_buffer_row:
    [legend]

    Public Attributes

    TDSRESULTINFOresinfo
     pointer to result informations
     
    DBINT row
     row number
     
    unsigned char * row_data
     row data, NULL for resinfo->current_row
     
    TDS_INT * sizes
     save old sizes
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00582.html100644 025423 025423 00000011751 13242511133 0013236 FreeTDS API: Member List
    FreeTDS API
    dblib_context Member List

    This is the complete list of members for dblib_context, including all inherited members.

    connection_list (defined in dblib_context)dblib_context
    connection_list_size (defined in dblib_context)dblib_context
    connection_list_size_represented (defined in dblib_context)dblib_context
    login_timeoutdblib_context
    query_timeoutdblib_context
    recftos_filename (defined in dblib_context)dblib_context
    recftos_filenum (defined in dblib_context)dblib_context
    ref_countdblib_context
    tds_ctxdblib_context
    tds_ctx_ref_countdblib_context
    freetds-1.00.82/doc/reference/a00583.map100644 025423 025423 00000003444 13242511135 0013052 freetds-1.00.82/doc/reference/a00583.md5100644 025423 025423 00000000040 13242511133 0012745450196dfdedf3643006c3c2bb79a14befreetds-1.00.82/doc/reference/a00583.svg100644 025423 025423 00000051637 13242511136 0013104 dblib_context Node1 dblib_context Node2 tds_socket Node2->Node1 connection_list Node9 tds_result_info Node2->Node9 attached_to Node3 tds_login Node3->Node2 login Node4 tds_capabilities Node4->Node3 capabilities Node19 tds_connection Node4->Node19 capabilities Node6 tds_dstr Node6->Node3 server_realm_name password server_name dump_file library crlfile server_spn client_host _name client_charset openssl_ciphers ... Node7 tds_packet Node7->Node2 recv_packet send_packet Node7->Node7 next Node8 tds_dynamic Node8->Node2 cur_dyn Node8->Node8 next Node8->Node19 dyns Node9->Node2 param_info current_results res_info comp_info Node9->Node8 res_info params Node17 tds_cursor Node9->Node17 res_info Node17->Node2 cur_cursor Node17->Node17 next Node17->Node19 cursors Node18 tds_cursor_status Node18->Node17 status Node19->Node2 conn Node20 tds_poll_wakeup Node20->Node19 wakeup Node21 tds_env Node21->Node19 env Node22 tds_context Node22->Node1 tds_ctx Node22->Node19 tds_ctx Node24 tds_authentication Node24->Node19 authentication Node11 tdsiconvinfo Node11->Node19 char_convs freetds-1.00.82/doc/reference/a00585.html100644 025423 025423 00000020271 13242511136 0013241 FreeTDS API: dblib_context Struct Reference
    FreeTDS API
    dblib_context Struct Reference
    Collaboration diagram for dblib_context:
    [legend]

    Public Attributes

    TDSSOCKET ** connection_list
     
    int connection_list_size
     
    int connection_list_size_represented
     
    int login_timeout
     not used unless positive
     
    int query_timeout
     not used unless positive
     
    char * recftos_filename
     
    int recftos_filenum
     
    int ref_count
     reference count, time dbinit called
     
    TDSCONTEXTtds_ctx
     libTDS context
     
    int tds_ctx_ref_count
     libTDS context reference counter
     

    Detailed Description

    Remarks
    A db-lib connection has an implicit TDS context.

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00586.html100644 025423 025423 00000006707 13242511133 0013247 FreeTDS API: Member List
    FreeTDS API
    _dblib_error_message Member List

    This is the complete list of members for _dblib_error_message, including all inherited members.

    msgno (defined in _dblib_error_message)_dblib_error_message
    msgtext (defined in _dblib_error_message)_dblib_error_message
    severity (defined in _dblib_error_message)_dblib_error_message
    freetds-1.00.82/doc/reference/a00589.html100644 025423 025423 00000010717 13242511133 0013246 FreeTDS API: _dblib_error_message Struct Reference
    FreeTDS API
    _dblib_error_message Struct Reference

    Public Attributes

    DBINT msgno
     
    const char * msgtext
     
    int severity
     

    Detailed Description

    Remarks
    member msgno Vendor-defined message number
    member severity Is passed to the error handler
    member msgtext Text of message

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00590.html100644 025423 025423 00000011427 13242511133 0013235 FreeTDS API: Member List
    FreeTDS API
    col_t Member List

    This is the complete list of members for col_t, including all inherited members.

    data (defined in col_t)col_t
    f (defined in col_t)col_t
    i (defined in col_t)col_t
    len (defined in col_t)col_t
    null_indicator (defined in col_t)col_t
    r (defined in col_t)col_t
    s (defined in col_t)col_t
    si (defined in col_t)col_t
    ti (defined in col_t)col_t
    type (defined in col_t)col_t
    freetds-1.00.82/doc/reference/a00593.html100644 025423 025423 00000013670 13242511133 0013242 FreeTDS API: col_t Struct Reference
    FreeTDS API
    col_t Struct Reference

    Public Attributes

    union {
       DBFLT8   f
     
       DBINT   i
     
       DBREAL   r
     
       DBSMALLINT   si
     
       DBTINYINT   ti
     
    data
     
    size_t len
     
    int null_indicator
     
    char * s
     
    TDS_SERVER_TYPE type
     

    The documentation for this struct was generated from the following file:
    • src/dblib/dbpivot.c
    freetds-1.00.82/doc/reference/a00598.html100644 025423 025423 00000006516 13242511133 0013250 FreeTDS API: Member List
    FreeTDS API
    agg_t Member List

    This is the complete list of members for agg_t, including all inherited members.

    col_key (defined in agg_t)agg_t
    row_key (defined in agg_t)agg_t
    value (defined in agg_t)agg_t
    freetds-1.00.82/doc/reference/a00599.map100644 025423 025423 00000000342 13242511136 0013054 freetds-1.00.82/doc/reference/a00599.md5100644 025423 025423 00000000040 13242511133 0012754b2429197191b84e5ec6b2fc648e13bcefreetds-1.00.82/doc/reference/a00599.svg100644 025423 025423 00000006121 13242511136 0013077 agg_t Node1 agg_t Node2 col_t Node2->Node1 value Node3 KEY_T Node2->Node3 keys Node3->Node1 col_key row_key freetds-1.00.82/doc/reference/a00601.html100644 025423 025423 00000010711 13242511136 0013224 FreeTDS API: agg_t Struct Reference
    FreeTDS API
    agg_t Struct Reference
    Collaboration diagram for agg_t:
    [legend]

    Public Attributes

    KEY_T col_key
     
    KEY_T row_key
     
    struct col_t value
     

    The documentation for this struct was generated from the following file:
    • src/dblib/dbpivot.c
    freetds-1.00.82/doc/reference/a00602.html100644 025423 025423 00000006561 13242511133 0013232 FreeTDS API: Member List
    FreeTDS API
    metadata_t Member List

    This is the complete list of members for metadata_t, including all inherited members.

    col (defined in metadata_t)metadata_t
    name (defined in metadata_t)metadata_t
    pacross (defined in metadata_t)metadata_t
    freetds-1.00.82/doc/reference/a00603.map100644 025423 025423 00000000354 13242511135 0013040 freetds-1.00.82/doc/reference/a00603.md5100644 025423 025423 00000000040 13242511133 001273658eb3fff7cab08dcda4413ca2fb0104ffreetds-1.00.82/doc/reference/a00603.svg100644 025423 025423 00000005716 13242511136 0013072 metadata_t Node1 metadata_t Node2 col_t Node2->Node1 col Node3 KEY_T Node2->Node3 keys Node3->Node1 pacross freetds-1.00.82/doc/reference/a00605.html100644 025423 025423 00000010661 13242511136 0013234 FreeTDS API: metadata_t Struct Reference
    FreeTDS API
    metadata_t Struct Reference
    Collaboration diagram for metadata_t:
    [legend]

    Public Attributes

    struct col_t col
     
    char * name
     
    KEY_Tpacross
     

    The documentation for this struct was generated from the following file:
    • src/dblib/dbpivot.c
    freetds-1.00.82/doc/reference/a00606.html100644 025423 025423 00000010327 13242511133 0013231 FreeTDS API: Member List
    FreeTDS API
    pivot_t Member List

    This is the complete list of members for pivot_t, including all inherited members.

    across (defined in pivot_t)pivot_t
    dbproc (defined in pivot_t)pivot_t
    dbresults_state (defined in pivot_t)pivot_t
    nacross (defined in pivot_t)pivot_t
    nout (defined in pivot_t)pivot_t
    output (defined in pivot_t)pivot_t
    status (defined in pivot_t)pivot_t
    freetds-1.00.82/doc/reference/a00607.map100644 025423 025423 00000003724 13242511136 0013051 freetds-1.00.82/doc/reference/a00607.md5100644 025423 025423 00000000040 13242511133 001274287ac54f4467ebbfc94be5fdf61fabdacfreetds-1.00.82/doc/reference/a00607.svg100644 025423 025423 00000052443 13242511136 0013075 pivot_t Node1 pivot_t Node2 KEY_T Node2->Node1 across Node4 agg_t Node2->Node4 col_key row_key Node3 col_t Node3->Node2 keys Node3->Node4 value Node4->Node1 output Node5 tds_dblib_dbprocess Node5->Node1 dbproc Node6 tag_DBPROC_ROWBUF Node6->Node5 row_buf Node7 dblib_buffer_row Node7->Node6 rows Node8 tds_result_info Node8->Node7 resinfo Node9 tds_socket Node8->Node9 param_info current_results res_info comp_info Node35 tds_bcpinfo Node8->Node35 bindinfo Node9->Node5 tds_socket Node9->Node8 attached_to Node31 BCP_HOSTFILEINFO Node31->Node5 hostfileinfo Node32 BCP_HOSTCOLINFO Node32->Node31 host_columns Node33 _DBREMOTE_PROC Node33->Node5 rpc Node33->Node33 next Node34 _DBREMOTE_PROC_PARAM Node34->Node33 param_list Node34->Node34 next Node35->Node5 bcpinfo Node13 tds_dstr Node13->Node35 tablename Node36 dbstring Node36->Node5 dboptcmd Node36->Node36 strnext Node37 dboption Node36->Node37 param Node37->Node5 dbopts Node38 _null_representation Node38->Node5 nullreps Node39 dbtypeinfo Node39->Node5 typeinfo freetds-1.00.82/doc/reference/a00609.html100644 025423 025423 00000013503 13242511136 0013236 FreeTDS API: pivot_t Struct Reference
    FreeTDS API
    pivot_t Struct Reference
    Collaboration diagram for pivot_t:
    [legend]

    Public Attributes

    KEY_Tacross
     
    DBPROCESSdbproc
     
    DB_RESULT_STATE dbresults_state
     
    size_t nacross
     
    size_t nout
     
    AGG_Toutput
     
    STATUS status
     

    The documentation for this struct was generated from the following file:
    • src/dblib/dbpivot.c
    freetds-1.00.82/doc/reference/a00610.html100644 025423 025423 00000006160 13242511133 0013224 FreeTDS API: Member List
    FreeTDS API
    name_t Member List

    This is the complete list of members for name_t, including all inherited members.

    func (defined in name_t)name_t
    name (defined in name_t)name_t
    freetds-1.00.82/doc/reference/a00611.map100644 025423 025423 00000000204 13242511135 0013031 freetds-1.00.82/doc/reference/a00611.md5100644 025423 025423 00000000040 13242511133 00127355ccde75796eb5538ab1e292d158730fefreetds-1.00.82/doc/reference/a00611.svg100644 025423 025423 00000003162 13242511136 0013062 name_t Node1 name_t Node2 col_t Node2->Node1 func freetds-1.00.82/doc/reference/a00613.html100644 025423 025423 00000010004 13242511136 0013222 FreeTDS API: name_t Struct Reference
    FreeTDS API
    name_t Struct Reference
    Collaboration diagram for name_t:
    [legend]

    Public Attributes

    DBPIVOT_FUNC func
     
    char name [14]
     

    The documentation for this struct was generated from the following file:
    • src/dblib/dbpivot.c
    freetds-1.00.82/doc/reference/a00614.html100644 025423 025423 00000007525 13242511133 0013236 FreeTDS API: Member List
    FreeTDS API
    ProfileParam Member List

    This is the complete list of members for ProfileParam, including all inherited members.

    buffer (defined in ProfileParam)ProfileParam
    buffer_len (defined in ProfileParam)ProfileParam
    entry (defined in ProfileParam)ProfileParam
    found (defined in ProfileParam)ProfileParam
    ret_val (defined in ProfileParam)ProfileParam
    freetds-1.00.82/doc/reference/a00617.html100644 025423 025423 00000011205 13242511133 0013227 FreeTDS API: ProfileParam Struct Reference
    FreeTDS API
    ProfileParam Struct Reference

    Public Attributes

    LPSTR buffer
     
    int buffer_len
     
    LPCSTR entry
     
    int found
     
    int ret_val
     

    The documentation for this struct was generated from the following file:
    • src/odbc/connectparams.c
    freetds-1.00.82/doc/reference/a00618.html100644 025423 025423 00000006221 13242511133 0013232 FreeTDS API: Member List
    FreeTDS API
    s_SqlMsgMap Member List

    This is the complete list of members for s_SqlMsgMap, including all inherited members.

    msg (defined in s_SqlMsgMap)s_SqlMsgMap
    sqlstate (defined in s_SqlMsgMap)s_SqlMsgMap
    freetds-1.00.82/doc/reference/a00621.html100644 025423 025423 00000007201 13242511133 0013223 FreeTDS API: s_SqlMsgMap Struct Reference
    FreeTDS API
    s_SqlMsgMap Struct Reference

    Public Attributes

    const char * msg
     
    char sqlstate [6]
     

    The documentation for this struct was generated from the following file:
    • src/odbc/error.c
    freetds-1.00.82/doc/reference/a00622.html100644 025423 025423 00000006204 13242511133 0013226 FreeTDS API: Member List
    FreeTDS API
    s_v3to2map Member List

    This is the complete list of members for s_v3to2map, including all inherited members.

    v2 (defined in s_v3to2map)s_v3to2map
    v3 (defined in s_v3to2map)s_v3to2map
    freetds-1.00.82/doc/reference/a00625.html100644 025423 025423 00000007164 13242511133 0013237 FreeTDS API: s_v3to2map Struct Reference
    FreeTDS API
    s_v3to2map Struct Reference

    Public Attributes

    char v2 [6]
     
    char v3 [6]
     

    The documentation for this struct was generated from the following file:
    • src/odbc/error.c
    freetds-1.00.82/doc/reference/a00626.html100644 025423 025423 00000007113 13242511133 0013232 FreeTDS API: Member List
    FreeTDS API
    func_info Member List

    This is the complete list of members for func_info, including all inherited members.

    name (defined in func_info)func_info
    num_param (defined in func_info)func_info
    special (defined in func_info)func_info
    sql_name (defined in func_info)func_info
    freetds-1.00.82/doc/reference/a00627.map100644 025423 025423 00000000217 13242511135 0013044 freetds-1.00.82/doc/reference/a00627.md5100644 025423 025423 00000000040 13242511133 0012744d379e2d22e7a31cccac89cea331a7ba9freetds-1.00.82/doc/reference/a00627.svg100644 025423 025423 00000003212 13242511136 0013065 func_info Node1 func_info Node2 native_info Node2->Node1 special freetds-1.00.82/doc/reference/a00629.html100644 025423 025423 00000011310 13242511136 0013232 FreeTDS API: func_info Struct Reference
    FreeTDS API
    func_info Struct Reference
    Collaboration diagram for func_info:
    [legend]

    Public Attributes

    const char * name
     
    int num_param
     
    special_fn special
     
    const char * sql_name
     

    The documentation for this struct was generated from the following file:
    • src/odbc/native.c
    freetds-1.00.82/doc/reference/a00630.html100644 025423 025423 00000006215 13242511133 0013227 FreeTDS API: Member List
    FreeTDS API
    native_info Member List

    This is the complete list of members for native_info, including all inherited members.

    d (defined in native_info)native_info
    length (defined in native_info)native_info
    freetds-1.00.82/doc/reference/a00633.html100644 025423 025423 00000007163 13242511133 0013235 FreeTDS API: native_info Struct Reference
    FreeTDS API
    native_info Struct Reference

    Public Attributes

    char * d
     
    int length
     

    The documentation for this struct was generated from the following file:
    • src/odbc/native.c
    freetds-1.00.82/doc/reference/a00634.html100644 025423 025423 00000006466 13242511133 0013243 FreeTDS API: Member List
    FreeTDS API
    DSNINFO Member List

    This is the complete list of members for DSNINFO, including all inherited members.

    dsnDSNINFO
    loginDSNINFO
    origdsnDSNINFO
    freetds-1.00.82/doc/reference/a00635.map100644 025423 025423 00000000735 13242511135 0013050 freetds-1.00.82/doc/reference/a00635.md5100644 025423 025423 00000000040 13242511133 0012743338f42fc7a77205ac26e25cf71ade964freetds-1.00.82/doc/reference/a00635.svg100644 025423 025423 00000014155 13242511136 0013074 DSNINFO Node1 DSNINFO Node2 tds_login Node2->Node1 login Node3 tds_capabilities Node3->Node2 capabilities Node4 tds_capability_type Node4->Node3 types Node5 tds_dstr Node5->Node1 dsn origdsn Node5->Node2 server_realm_name password server_name dump_file library crlfile server_spn client_host _name client_charset openssl_ciphers ... freetds-1.00.82/doc/reference/a00637.html100644 025423 025423 00000012230 13242511136 0013233 FreeTDS API: DSNINFO Struct Reference
    FreeTDS API
    DSNINFO Struct Reference
    Collaboration diagram for DSNINFO:
    [legend]

    Public Attributes

    DSTR dsn
     edited name of the data source
     
    TDSLOGINlogin
     everything else
     
    DSTR origdsn
     original name of the data source
     

    The documentation for this struct was generated from the following file:
    • src/odbc/winsetup.c
    freetds-1.00.82/doc/reference/a00638.html100644 025423 025423 00000006215 13242511133 0013237 FreeTDS API: Member List
    FreeTDS API
    conf_params Member List

    This is the complete list of members for conf_params, including all inherited members.

    err (defined in conf_params)conf_params
    pool (defined in conf_params)conf_params
    freetds-1.00.82/doc/reference/a00639.map100644 025423 025423 00000000705 13242511135 0013051 freetds-1.00.82/doc/reference/a00639.md5100644 025423 025423 00000000040 13242511133 00127476821acae9e99c0b7880cf5886e83ea2bfreetds-1.00.82/doc/reference/a00639.svg100644 025423 025423 00000011314 13242511136 0013072 conf_params Node1 conf_params Node2 tds_pool Node2->Node1 pool Node3 tds_context Node3->Node2 ctx Node4 tds_locale Node4->Node3 locale Node5 tds_pool_event Node5->Node2 events Node5->Node5 execute next freetds-1.00.82/doc/reference/a00641.html100644 025423 025423 00000010062 13242511136 0013227 FreeTDS API: conf_params Struct Reference
    FreeTDS API
    conf_params Struct Reference
    Collaboration diagram for conf_params:
    [legend]

    Public Attributes

    char ** err
     
    TDS_POOLpool
     

    The documentation for this struct was generated from the following file:
    • src/pool/config.c
    freetds-1.00.82/doc/reference/a00642.html100644 025423 025423 00000006570 13242511133 0013236 FreeTDS API: Member List
    FreeTDS API
    select_info Member List

    This is the complete list of members for select_info, including all inherited members.

    maxfd (defined in select_info)select_info
    rfds (defined in select_info)select_info
    wfds (defined in select_info)select_info
    freetds-1.00.82/doc/reference/a00645.html100644 025423 025423 00000007724 13242511133 0013243 FreeTDS API: select_info Struct Reference
    FreeTDS API
    select_info Struct Reference

    Public Attributes

    TDS_SYS_SOCKET maxfd
     
    fd_set rfds
     
    fd_set wfds
     

    The documentation for this struct was generated from the following file:
    • src/pool/main.c
    freetds-1.00.82/doc/reference/a00646.html100644 025423 025423 00000007160 13242511133 0013236 FreeTDS API: Member List
    FreeTDS API
    CONNECT_EVENT Member List

    This is the complete list of members for CONNECT_EVENT, including all inherited members.

    common (defined in CONNECT_EVENT)CONNECT_EVENT
    pmbr (defined in CONNECT_EVENT)CONNECT_EVENT
    pool (defined in CONNECT_EVENT)CONNECT_EVENT
    tds_version (defined in CONNECT_EVENT)CONNECT_EVENT
    freetds-1.00.82/doc/reference/a00647.map100644 025423 025423 00000001405 13242511135 0013046 freetds-1.00.82/doc/reference/a00647.md5100644 025423 025423 00000000040 13242511133 0012746d41571c02e7a1aa4c2a996f2a8226dc2freetds-1.00.82/doc/reference/a00647.svg100644 025423 025423 00000021434 13242511136 0013075 CONNECT_EVENT Node1 CONNECT_EVENT Node2 tds_pool_member Node2->Node1 pmbr Node3 tds_pool_user Node2->Node3 assigned_member Node3->Node2 current_user Node4 tds_login Node4->Node3 login Node8 tds_pool_socket Node8->Node2 sock Node8->Node3 sock Node28 tds_pool Node28->Node1 pool Node25 tds_context Node25->Node28 ctx Node29 tds_pool_event Node29->Node1 common Node29->Node28 events Node29->Node29 execute next freetds-1.00.82/doc/reference/a00649.html100644 025423 025423 00000011507 13242511136 0013244 FreeTDS API: CONNECT_EVENT Struct Reference
    FreeTDS API
    CONNECT_EVENT Struct Reference
    Collaboration diagram for CONNECT_EVENT:
    [legend]

    Public Attributes

    TDS_POOL_EVENT common
     
    TDS_POOL_MEMBERpmbr
     
    TDS_POOLpool
     
    int tds_version
     

    The documentation for this struct was generated from the following file:
    • src/pool/member.c
    freetds-1.00.82/doc/reference/a00650.html100644 025423 025423 00000006243 13242511133 0013232 FreeTDS API: Member List
    FreeTDS API
    tds_pool_event Member List

    This is the complete list of members for tds_pool_event, including all inherited members.

    execute (defined in tds_pool_event)tds_pool_event
    next (defined in tds_pool_event)tds_pool_event
    freetds-1.00.82/doc/reference/a00651.map100644 025423 025423 00000000067 13242511136 0013045 freetds-1.00.82/doc/reference/a00651.md5100644 025423 025423 00000000040 13242511133 001274162af346a41509c7c93f1b36dc89cc87efreetds-1.00.82/doc/reference/a00651.svg100644 025423 025423 00000002753 13242511136 0013073 tds_pool_event Node1 tds_pool_event Node1->Node1 execute next freetds-1.00.82/doc/reference/a00653.html100644 025423 025423 00000010167 13242511136 0013240 FreeTDS API: tds_pool_event Struct Reference
    FreeTDS API
    tds_pool_event Struct Reference
    Collaboration diagram for tds_pool_event:
    [legend]

    Public Attributes

    TDS_POOL_EXECUTE execute
     
    TDS_POOL_EVENTnext
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00654.html100644 025423 025423 00000006640 13242511133 0013237 FreeTDS API: Member List
    FreeTDS API
    tds_pool_socket Member List

    This is the complete list of members for tds_pool_socket, including all inherited members.

    poll_recv (defined in tds_pool_socket)tds_pool_socket
    poll_send (defined in tds_pool_socket)tds_pool_socket
    tds (defined in tds_pool_socket)tds_pool_socket
    freetds-1.00.82/doc/reference/a00655.map100644 025423 025423 00000003451 13242511136 0013051 freetds-1.00.82/doc/reference/a00655.md5100644 025423 025423 00000000040 13242511133 0012745caec9ec0cd16b1ac2d937408d298a758freetds-1.00.82/doc/reference/a00655.svg100644 025423 025423 00000050635 13242511136 0013101 tds_pool_socket Node1 tds_pool_socket Node2 tds_socket Node2->Node1 tds Node9 tds_result_info Node2->Node9 attached_to Node3 tds_login Node3->Node2 login Node4 tds_capabilities Node4->Node3 capabilities Node19 tds_connection Node4->Node19 capabilities Node6 tds_dstr Node6->Node3 server_realm_name password server_name dump_file library crlfile server_spn client_host _name client_charset openssl_ciphers ... Node7 tds_packet Node7->Node2 recv_packet send_packet Node7->Node7 next Node8 tds_dynamic Node8->Node2 cur_dyn Node8->Node8 next Node8->Node19 dyns Node9->Node2 param_info current_results res_info comp_info Node9->Node8 res_info params Node17 tds_cursor Node9->Node17 res_info Node17->Node2 cur_cursor Node17->Node17 next Node17->Node19 cursors Node18 tds_cursor_status Node18->Node17 status Node19->Node2 conn Node20 tds_poll_wakeup Node20->Node19 wakeup Node21 tds_env Node21->Node19 env Node22 tds_context Node22->Node19 tds_ctx Node24 tds_authentication Node24->Node19 authentication Node11 tdsiconvinfo Node11->Node19 char_convs freetds-1.00.82/doc/reference/a00657.html100644 025423 025423 00000010705 13242511136 0013242 FreeTDS API: tds_pool_socket Struct Reference
    FreeTDS API
    tds_pool_socket Struct Reference
    Collaboration diagram for tds_pool_socket:
    [legend]

    Public Attributes

    bool poll_recv
     
    bool poll_send
     
    TDSSOCKETtds
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00658.html100644 025423 025423 00000007577 13242511133 0013255 FreeTDS API: Member List
    FreeTDS API
    tds_pool_user Member List

    This is the complete list of members for tds_pool_user, including all inherited members.

    assigned_member (defined in tds_pool_user)tds_pool_user
    DLIST_FIELDS(dlist_user_item) (defined in tds_pool_user)tds_pool_user
    login (defined in tds_pool_user)tds_pool_user
    sock (defined in tds_pool_user)tds_pool_user
    user_state (defined in tds_pool_user)tds_pool_user
    freetds-1.00.82/doc/reference/a00659.map100644 025423 025423 00000000757 13242511136 0013063 freetds-1.00.82/doc/reference/a00659.md5100644 025423 025423 00000000040 13242511133 0012751c33e6c4a1815f2b1c5fc2aa90a5b61ecfreetds-1.00.82/doc/reference/a00659.svg100644 025423 025423 00000013410 13242511136 0013073 tds_pool_user Node1 tds_pool_user Node2 tds_pool_member Node1->Node2 current_user Node2->Node1 assigned_member Node3 tds_pool_socket Node3->Node1 sock Node3->Node2 sock Node4 tds_socket Node4->Node3 tds Node5 tds_login Node5->Node1 login Node5->Node4 login freetds-1.00.82/doc/reference/a00661.html100644 025423 025423 00000012714 13242511136 0013237 FreeTDS API: tds_pool_user Struct Reference
    FreeTDS API
    Collaboration diagram for tds_pool_user:
    [legend]

    Public Member Functions

     DLIST_FIELDS (dlist_user_item)
     

    Public Attributes

    TDS_POOL_MEMBERassigned_member
     
    TDSLOGINlogin
     
    TDS_POOL_SOCKET sock
     
    TDS_USER_STATE user_state
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00662.html100644 025423 025423 00000007636 13242511133 0013244 FreeTDS API: Member List
    FreeTDS API
    tds_pool_member Member List

    This is the complete list of members for tds_pool_member, including all inherited members.

    current_user (defined in tds_pool_member)tds_pool_member
    DLIST_FIELDS(dlist_member_item) (defined in tds_pool_member)tds_pool_member
    doing_async (defined in tds_pool_member)tds_pool_member
    last_used_tm (defined in tds_pool_member)tds_pool_member
    sock (defined in tds_pool_member)tds_pool_member
    freetds-1.00.82/doc/reference/a00663.map100644 025423 025423 00000001324 13242511136 0013045 freetds-1.00.82/doc/reference/a00663.md5100644 025423 025423 00000000040 13242511133 00127447cb1ecc4d575a26805a25d9c1423fd23freetds-1.00.82/doc/reference/a00663.svg100644 025423 025423 00000021430 13242511136 0013067 tds_pool_member Node1 tds_pool_member Node2 tds_pool_user Node1->Node2 assigned_member Node2->Node1 current_user Node3 tds_login Node3->Node2 login Node8 tds_socket Node3->Node8 login Node4 tds_capabilities Node4->Node3 capabilities Node6 tds_dstr Node6->Node3 server_realm_name password server_name dump_file library crlfile server_spn client_host _name client_charset openssl_ciphers ... Node7 tds_pool_socket Node7->Node1 sock Node7->Node2 sock Node8->Node7 tds freetds-1.00.82/doc/reference/a00665.html100644 025423 025423 00000012644 13242511136 0013245 FreeTDS API: tds_pool_member Struct Reference
    FreeTDS API
    tds_pool_member Struct Reference
    Collaboration diagram for tds_pool_member:
    [legend]

    Public Member Functions

     DLIST_FIELDS (dlist_member_item)
     

    Public Attributes

    TDS_POOL_USERcurrent_user
     
    bool doing_async
     
    time_t last_used_tm
     
    TDS_POOL_SOCKET sock
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00666.html100644 025423 025423 00000017400 13242511133 0013236 FreeTDS API: Member List
    FreeTDS API
    tds_pool Member List

    This is the complete list of members for tds_pool, including all inherited members.

    active_members (defined in tds_pool)tds_pool
    ctx (defined in tds_pool)tds_pool
    database (defined in tds_pool)tds_pool
    event_fd (defined in tds_pool)tds_pool
    events (defined in tds_pool)tds_pool
    events_mtx (defined in tds_pool)tds_pool
    idle_members (defined in tds_pool)tds_pool
    listen_fd (defined in tds_pool)tds_pool
    max_member_age (defined in tds_pool)tds_pool
    max_open_conn (defined in tds_pool)tds_pool
    member_logins (defined in tds_pool)tds_pool
    min_open_conn (defined in tds_pool)tds_pool
    name (defined in tds_pool)tds_pool
    num_active_members (defined in tds_pool)tds_pool
    num_users (defined in tds_pool)tds_pool
    password (defined in tds_pool)tds_pool
    port (defined in tds_pool)tds_pool
    server (defined in tds_pool)tds_pool
    user (defined in tds_pool)tds_pool
    user_logins (defined in tds_pool)tds_pool
    users (defined in tds_pool)tds_pool
    waiterstds_pool
    wakeup_fd (defined in tds_pool)tds_pool
    freetds-1.00.82/doc/reference/a00667.map100644 025423 025423 00000000533 13242511136 0013052 freetds-1.00.82/doc/reference/a00667.md5100644 025423 025423 00000000040 13242511133 0012750deb8f67089b7da4741752bbce4f2af20freetds-1.00.82/doc/reference/a00667.svg100644 025423 025423 00000007571 13242511136 0013105 tds_pool Node1 tds_pool Node2 tds_context Node2->Node1 ctx Node3 tds_locale Node3->Node2 locale Node4 tds_pool_event Node4->Node1 events Node4->Node4 execute next freetds-1.00.82/doc/reference/a00669.html100644 025423 025423 00000027010 13242511136 0013242 FreeTDS API: tds_pool Struct Reference
    FreeTDS API
    tds_pool Struct Reference
    Collaboration diagram for tds_pool:
    [legend]

    Public Attributes

    dlist_members active_members
     
    TDSCONTEXTctx
     
    char * database
     
    TDS_SYS_SOCKET event_fd
     
    TDS_POOL_EVENTevents
     
    tds_mutex events_mtx
     
    dlist_members idle_members
     
    TDS_SYS_SOCKET listen_fd
     
    int max_member_age
     
    int max_open_conn
     
    unsigned long member_logins
     
    int min_open_conn
     
    char * name
     
    int num_active_members
     
    int num_users
     
    char * password
     
    int port
     
    char * server
     
    char * user
     
    unsigned long user_logins
     
    dlist_users users
     
    dlist_users waiters
     users in wait state
     
    TDS_SYS_SOCKET wakeup_fd
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00670.html100644 025423 025423 00000006247 13242511133 0013240 FreeTDS API: Member List
    FreeTDS API
    tmp_col_struct Member List

    This is the complete list of members for tmp_col_struct, including all inherited members.

    column_name (defined in tmp_col_struct)tmp_col_struct
    next (defined in tmp_col_struct)tmp_col_struct
    freetds-1.00.82/doc/reference/a00671.map100644 025423 025423 00000000067 13242511136 0013047 freetds-1.00.82/doc/reference/a00671.md5100644 025423 025423 00000000040 13242511133 001274348e42e22b0b04d874e943712cf97a5fffreetds-1.00.82/doc/reference/a00671.svg100644 025423 025423 00000002530 13242511136 0013066 tmp_col_struct Node1 tmp_col_struct Node1->Node1 next freetds-1.00.82/doc/reference/a00673.html100644 025423 025423 00000010116 13242511136 0013234 FreeTDS API: tmp_col_struct Struct Reference
    FreeTDS API
    tmp_col_struct Struct Reference
    Collaboration diagram for tmp_col_struct:
    [legend]

    Public Attributes

    char * column_name
     
    struct tmp_col_structnext
     

    The documentation for this struct was generated from the following file:
    • src/pool/stream.c
    freetds-1.00.82/doc/reference/a00674.html100644 025423 025423 00000007131 13242511133 0013235 FreeTDS API: Member List
    FreeTDS API
    LOGIN_EVENT Member List

    This is the complete list of members for LOGIN_EVENT, including all inherited members.

    common (defined in LOGIN_EVENT)LOGIN_EVENT
    pool (defined in LOGIN_EVENT)LOGIN_EVENT
    puser (defined in LOGIN_EVENT)LOGIN_EVENT
    success (defined in LOGIN_EVENT)LOGIN_EVENT
    freetds-1.00.82/doc/reference/a00675.map100644 025423 025423 00000001553 13242511135 0013053 freetds-1.00.82/doc/reference/a00675.md5100644 025423 025423 00000000040 13242511133 0012747462cc873bac91f520f8f55c7e4a455adfreetds-1.00.82/doc/reference/a00675.svg100644 025423 025423 00000023152 13242511136 0013075 LOGIN_EVENT Node1 LOGIN_EVENT Node2 tds_pool Node2->Node1 pool Node3 tds_context Node3->Node2 ctx Node4 tds_locale Node4->Node3 locale Node5 tds_pool_event Node5->Node1 common Node5->Node2 events Node5->Node5 execute next Node6 tds_pool_user Node6->Node1 puser Node7 tds_pool_member Node6->Node7 current_user Node7->Node6 assigned_member Node8 tds_pool_socket Node8->Node6 sock Node8->Node7 sock Node10 tds_login Node10->Node6 login freetds-1.00.82/doc/reference/a00677.html100644 025423 025423 00000011473 13242511136 0013247 FreeTDS API: LOGIN_EVENT Struct Reference
    FreeTDS API
    LOGIN_EVENT Struct Reference
    Collaboration diagram for LOGIN_EVENT:
    [legend]

    Public Attributes

    TDS_POOL_EVENT common
     
    TDS_POOLpool
     
    TDS_POOL_USERpuser
     
    bool success
     

    The documentation for this struct was generated from the following file:
    • src/pool/user.c
    freetds-1.00.82/doc/reference/a00678.html100644 025423 025423 00000007201 13242511133 0013237 FreeTDS API: Member List
    FreeTDS API
    END_LOGIN_EVENT Member List

    This is the complete list of members for END_LOGIN_EVENT, including all inherited members.

    common (defined in END_LOGIN_EVENT)END_LOGIN_EVENT
    pool (defined in END_LOGIN_EVENT)END_LOGIN_EVENT
    puser (defined in END_LOGIN_EVENT)END_LOGIN_EVENT
    success (defined in END_LOGIN_EVENT)END_LOGIN_EVENT
    freetds-1.00.82/doc/reference/a00679.map100644 025423 025423 00000001563 13242511135 0013060 freetds-1.00.82/doc/reference/a00679.md5100644 025423 025423 00000000040 13242511133 001275358824d535a4a294a1c0cc137cb05aa55freetds-1.00.82/doc/reference/a00679.svg100644 025423 025423 00000023166 13242511136 0013106 END_LOGIN_EVENT Node1 END_LOGIN_EVENT Node2 tds_pool Node2->Node1 pool Node3 tds_context Node3->Node2 ctx Node4 tds_locale Node4->Node3 locale Node5 tds_pool_event Node5->Node1 common Node5->Node2 events Node5->Node5 execute next Node6 tds_pool_user Node6->Node1 puser Node7 tds_pool_member Node6->Node7 current_user Node7->Node6 assigned_member Node8 tds_pool_socket Node8->Node6 sock Node8->Node7 sock Node10 tds_login Node10->Node6 login freetds-1.00.82/doc/reference/a00681.html100644 025423 025423 00000011507 13242511136 0013240 FreeTDS API: END_LOGIN_EVENT Struct Reference
    FreeTDS API
    END_LOGIN_EVENT Struct Reference
    Collaboration diagram for END_LOGIN_EVENT:
    [legend]

    Public Attributes

    TDS_POOL_EVENT common
     
    TDS_POOLpool
     
    TDS_POOL_USERpuser
     
    bool success
     

    The documentation for this struct was generated from the following file:
    • src/pool/user.c
    freetds-1.00.82/doc/reference/a00682.html100644 025423 025423 00000007230 13242511133 0013234 FreeTDS API: Member List
    FreeTDS API
    ptw32_mcs_node_t_ Member List

    This is the complete list of members for ptw32_mcs_node_t_, including all inherited members.

    lock (defined in ptw32_mcs_node_t_)ptw32_mcs_node_t_
    next (defined in ptw32_mcs_node_t_)ptw32_mcs_node_t_
    nextFlag (defined in ptw32_mcs_node_t_)ptw32_mcs_node_t_
    readyFlag (defined in ptw32_mcs_node_t_)ptw32_mcs_node_t_
    freetds-1.00.82/doc/reference/a00683.map100644 025423 025423 00000000075 13242511136 0013051 freetds-1.00.82/doc/reference/a00683.md5100644 025423 025423 00000000040 13242511133 0012746f9720156ca3a3e4b2e4c318370bfd2a2freetds-1.00.82/doc/reference/a00683.svg100644 025423 025423 00000002754 13242511136 0013101 ptw32_mcs_node_t_ Node1 ptw32_mcs_node_t_ Node1->Node1 next lock freetds-1.00.82/doc/reference/a00685.html100644 025423 025423 00000011522 13242511136 0013241 FreeTDS API: ptw32_mcs_node_t_ Struct Reference
    FreeTDS API
    ptw32_mcs_node_t_ Struct Reference
    Collaboration diagram for ptw32_mcs_node_t_:
    [legend]

    Public Attributes

    struct ptw32_mcs_node_t_ ** lock
     
    struct ptw32_mcs_node_t_next
     
    void * nextFlag
     
    void * readyFlag
     

    The documentation for this struct was generated from the following file:
    • src/replacements/ptw32_MCS_lock.c
    freetds-1.00.82/doc/reference/a00686.html100644 025423 025423 00000006473 13242511133 0013250 FreeTDS API: Member List
    FreeTDS API
    tds_pbcb Member List

    This is the complete list of members for tds_pbcb, including all inherited members.

    cbtds_pbcb
    from_malloctds_pbcb
    pbtds_pbcb
    freetds-1.00.82/doc/reference/a00689.html100644 025423 025423 00000011503 13242511133 0013241 FreeTDS API: tds_pbcb Struct Reference
    FreeTDS API
    tds_pbcb Struct Reference

    Holds clause buffer. More...

    Public Attributes

    unsigned int cb
     buffer length
     
    unsigned int from_malloc
     true is buffer came from malloc
     
    char * pb
     buffer
     

    Detailed Description

    Holds clause buffer.


    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00690.html100644 025423 025423 00000007771 13242511133 0013245 FreeTDS API: Member List
    FreeTDS API
    tds_file_stream Member List

    This is the complete list of members for tds_file_stream, including all inherited members.

    ftds_file_stream
    lefttds_file_stream
    left_pos (defined in tds_file_stream)tds_file_stream
    streamtds_file_stream
    term_lentds_file_stream
    terminatortds_file_stream
    freetds-1.00.82/doc/reference/a00691.map100644 025423 025423 00000000270 13242511136 0013045 freetds-1.00.82/doc/reference/a00691.md5100644 025423 025423 00000000040 13242511133 0012745b846886695c22298b02df10ea0b0f97ffreetds-1.00.82/doc/reference/a00691.svg100644 025423 025423 00000003337 13242511136 0013076 tds_file_stream Node1 tds_file_stream Node2 tds_input_stream Node2->Node1 stream freetds-1.00.82/doc/reference/a00693.html100644 025423 025423 00000015410 13242511136 0013240 FreeTDS API: tds_file_stream Struct Reference
    FreeTDS API
    tds_file_stream Struct Reference

    input stream to read a file More...

    Collaboration diagram for tds_file_stream:
    [legend]

    Public Attributes

    FILE * f
     file to read from
     
    char * left
     buffer for store bytes readed that could be the terminator
     
    size_t left_pos
     
    TDSINSTREAM stream
     common fields, must be the first field
     
    size_t term_len
     terminator length in bytes
     
    const char * terminator
     terminator
     

    Detailed Description

    input stream to read a file


    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00694.html100644 025423 025423 00000006216 13242511133 0013242 FreeTDS API: Member List
    FreeTDS API
    tds_answer Member List

    This is the complete list of members for tds_answer, including all inherited members.

    lm_resp (defined in tds_answer)tds_answer
    nt_resp (defined in tds_answer)tds_answer
    freetds-1.00.82/doc/reference/a00697.html100644 025423 025423 00000007434 13242511133 0013250 FreeTDS API: tds_answer Struct Reference
    FreeTDS API

    Public Attributes

    unsigned char lm_resp [24]
     
    unsigned char nt_resp [24]
     

    The documentation for this struct was generated from the following file:
    • src/tds/challenge.c
    freetds-1.00.82/doc/reference/a00698.html100644 025423 025423 00000011241 13242511133 0013240 FreeTDS API: Member List
    FreeTDS API
    names_blob_prefix_t Member List

    This is the complete list of members for names_blob_prefix_t, including all inherited members.

    challenge (defined in names_blob_prefix_t)names_blob_prefix_t
    max_response_type (defined in names_blob_prefix_t)names_blob_prefix_t
    reserved1 (defined in names_blob_prefix_t)names_blob_prefix_t
    reserved2 (defined in names_blob_prefix_t)names_blob_prefix_t
    response_type (defined in names_blob_prefix_t)names_blob_prefix_t
    target_info (defined in names_blob_prefix_t)names_blob_prefix_t
    timestamp (defined in names_blob_prefix_t)names_blob_prefix_t
    unknown (defined in names_blob_prefix_t)names_blob_prefix_t
    freetds-1.00.82/doc/reference/a00701.html100644 025423 025423 00000013555 13242511133 0013233 FreeTDS API: names_blob_prefix_t Struct Reference
    FreeTDS API
    names_blob_prefix_t Struct Reference

    Public Attributes

    TDS_UCHAR challenge [8]
     
    TDS_TINYINT max_response_type
     
    TDS_SMALLINT reserved1
     
    TDS_UINT reserved2
     
    TDS_TINYINT response_type
     
    TDS_UCHAR target_info [4]
     
    TDS_UINT8 timestamp
     
    TDS_UINT unknown
     

    The documentation for this struct was generated from the following file:
    • src/tds/challenge.c
    freetds-1.00.82/doc/reference/a00702.html100644 025423 025423 00000005676 13242511133 0013241 FreeTDS API: Member List
    FreeTDS API
    tds_ntlm_auth Member List

    This is the complete list of members for tds_ntlm_auth, including all inherited members.

    tds_auth (defined in tds_ntlm_auth)tds_ntlm_auth
    freetds-1.00.82/doc/reference/a00703.map100644 025423 025423 00000000237 13242511136 0013042 freetds-1.00.82/doc/reference/a00703.md5100644 025423 025423 00000000040 13242511133 00127376f5173f7cd75f4bc50e6ff56f83e425bfreetds-1.00.82/doc/reference/a00703.svg100644 025423 025423 00000003262 13242511136 0013065 tds_ntlm_auth Node1 tds_ntlm_auth Node2 tds_authentication Node2->Node1 tds_auth freetds-1.00.82/doc/reference/a00705.html100644 025423 025423 00000007566 13242511136 0013247 FreeTDS API: tds_ntlm_auth Struct Reference
    FreeTDS API
    tds_ntlm_auth Struct Reference
    Collaboration diagram for tds_ntlm_auth:
    [legend]

    Public Attributes

    TDSAUTHENTICATION tds_auth
     

    The documentation for this struct was generated from the following file:
    • src/tds/challenge.c
    freetds-1.00.82/doc/reference/a00710.html100644 025423 025423 00000006227 13242511133 0013231 FreeTDS API: Member List
    FreeTDS API
    tdsvername_t Member List

    This is the complete list of members for tdsvername_t, including all inherited members.

    name (defined in tdsvername_t)tdsvername_t
    version (defined in tdsvername_t)tdsvername_t
    freetds-1.00.82/doc/reference/a00713.html100644 025423 025423 00000007420 13242511133 0013230 FreeTDS API: tdsvername_t Struct Reference
    FreeTDS API

    Public Attributes

    const char name [6]
     
    TDS_USMALLINT version
     

    The documentation for this struct was generated from the following file:
    • src/tds/config.c
    freetds-1.00.82/doc/reference/a00714.html100644 025423 025423 00000010206 13242511133 0013225 FreeTDS API: Member List
    FreeTDS API
    tds_time Member List

    This is the complete list of members for tds_time, including all inherited members.

    tm_hourtds_time
    tm_mdaytds_time
    tm_mintds_time
    tm_montds_time
    tm_nstds_time
    tm_sectds_time
    tm_yeartds_time
    freetds-1.00.82/doc/reference/a00717.html100644 025423 025423 00000015304 13242511133 0013234 FreeTDS API: tds_time Struct Reference
    FreeTDS API
    tds_time Struct Reference

    Public Attributes

    int tm_hour
     hours (0-23)
     
    int tm_mday
     month day (1-31)
     
    int tm_min
     minutes (0-59)
     
    int tm_mon
     month (0-11)
     
    int tm_ns
     nanoseconds (0-999999999)
     
    int tm_sec
     seconds (0-59)
     
    int tm_year
     year (0=1900)
     

    The documentation for this struct was generated from the following file:
    • src/tds/convert.c
    freetds-1.00.82/doc/reference/a00718.html100644 025423 025423 00000006656 13242511133 0013247 FreeTDS API: Member List
    FreeTDS API
    tds_varmax_stream Member List

    This is the complete list of members for tds_varmax_stream, including all inherited members.

    chunk_left (defined in tds_varmax_stream)tds_varmax_stream
    stream (defined in tds_varmax_stream)tds_varmax_stream
    tds (defined in tds_varmax_stream)tds_varmax_stream
    freetds-1.00.82/doc/reference/a00719.map100644 025423 025423 00000003662 13242511136 0013056 freetds-1.00.82/doc/reference/a00719.md5100644 025423 025423 00000000040 13242511133 00127465aef209ee141f4f9a91672ea1e91208bfreetds-1.00.82/doc/reference/a00719.svg100644 025423 025423 00000052611 13242511136 0013076 tds_varmax_stream Node1 tds_varmax_stream Node2 tds_socket Node2->Node1 tds Node9 tds_result_info Node2->Node9 attached_to Node3 tds_login Node3->Node2 login Node4 tds_capabilities Node4->Node3 capabilities Node19 tds_connection Node4->Node19 capabilities Node6 tds_dstr Node6->Node3 server_realm_name password server_name dump_file library crlfile server_spn client_host _name client_charset openssl_ciphers ... Node7 tds_packet Node7->Node2 recv_packet send_packet Node7->Node7 next Node8 tds_dynamic Node8->Node2 cur_dyn Node8->Node8 next Node8->Node19 dyns Node9->Node2 param_info current_results res_info comp_info Node9->Node8 res_info params Node17 tds_cursor Node9->Node17 res_info Node17->Node2 cur_cursor Node17->Node17 next Node17->Node19 cursors Node18 tds_cursor_status Node18->Node17 status Node19->Node2 conn Node20 tds_poll_wakeup Node20->Node19 wakeup Node21 tds_env Node21->Node19 env Node22 tds_context Node22->Node19 tds_ctx Node24 tds_authentication Node24->Node19 authentication Node11 tdsiconvinfo Node11->Node19 char_convs Node25 tds_input_stream Node25->Node1 stream freetds-1.00.82/doc/reference/a00721.html100644 025423 025423 00000010760 13242511136 0013233 FreeTDS API: tds_varmax_stream Struct Reference
    FreeTDS API
    tds_varmax_stream Struct Reference
    Collaboration diagram for tds_varmax_stream:
    [legend]

    Public Attributes

    TDS_INT chunk_left
     
    TDSINSTREAM stream
     
    TDSSOCKETtds
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00722.html100644 025423 025423 00000006223 13242511133 0013230 FreeTDS API: Member List
    FreeTDS API
    tds_save_msg Member List

    This is the complete list of members for tds_save_msg, including all inherited members.

    msg (defined in tds_save_msg)tds_save_msg
    type (defined in tds_save_msg)tds_save_msg
    freetds-1.00.82/doc/reference/a00723.map100644 025423 025423 00000000226 13242511136 0013042 freetds-1.00.82/doc/reference/a00723.md5100644 025423 025423 00000000040 13242511133 0012741a0154dc0c3edbc34c83fb7e7d984dedafreetds-1.00.82/doc/reference/a00723.svg100644 025423 025423 00000003233 13242511136 0013065 tds_save_msg Node1 tds_save_msg Node2 tds_message Node2->Node1 msg freetds-1.00.82/doc/reference/a00725.html100644 025423 025423 00000010060 13242511136 0013230 FreeTDS API: tds_save_msg Struct Reference
    FreeTDS API
    tds_save_msg Struct Reference
    Collaboration diagram for tds_save_msg:
    [legend]

    Public Attributes

    TDSMESSAGE msg
     
    char type
     

    The documentation for this struct was generated from the following file:
    • src/tds/login.c
    freetds-1.00.82/doc/reference/a00726.html100644 025423 025423 00000006603 13242511133 0013236 FreeTDS API: Member List
    FreeTDS API
    tds_save_env Member List

    This is the complete list of members for tds_save_env, including all inherited members.

    newval (defined in tds_save_env)tds_save_env
    oldval (defined in tds_save_env)tds_save_env
    type (defined in tds_save_env)tds_save_env
    freetds-1.00.82/doc/reference/a00729.html100644 025423 025423 00000007716 13242511133 0013247 FreeTDS API: tds_save_env Struct Reference
    FreeTDS API
    tds_save_env Struct Reference

    Public Attributes

    char * newval
     
    char * oldval
     
    int type
     

    The documentation for this struct was generated from the following file:
    • src/tds/login.c
    freetds-1.00.82/doc/reference/a00730.html100644 025423 025423 00000007575 13242511133 0013242 FreeTDS API: Member List
    FreeTDS API
    tds_save_context Member List

    This is the complete list of members for tds_save_context, including all inherited members.

    ctx (defined in tds_save_context)tds_save_context
    envs (defined in tds_save_context)tds_save_context
    msgs (defined in tds_save_context)tds_save_context
    num_env (defined in tds_save_context)tds_save_context
    num_msg (defined in tds_save_context)tds_save_context
    freetds-1.00.82/doc/reference/a00731.map100644 025423 025423 00000001066 13242511136 0013044 freetds-1.00.82/doc/reference/a00731.md5100644 025423 025423 00000000040 13242511133 0012740afa0733315b2ed87a8e8fb02ca0d24d4freetds-1.00.82/doc/reference/a00731.svg100644 025423 025423 00000011655 13242511136 0013073 tds_save_context Node1 tds_save_context Node2 tds_context Node2->Node1 ctx Node3 tds_locale Node3->Node2 locale Node4 tds_save_env Node4->Node1 envs Node5 tds_save_msg Node5->Node1 msgs Node6 tds_message Node6->Node5 msg freetds-1.00.82/doc/reference/a00733.html100644 025423 025423 00000012270 13242511136 0013234 FreeTDS API: tds_save_context Struct Reference
    FreeTDS API
    tds_save_context Struct Reference
    Collaboration diagram for tds_save_context:
    [legend]

    Public Attributes

    TDSCONTEXT ctx
     
    struct tds_save_env envs [10]
     
    struct tds_save_msg msgs [10]
     
    unsigned num_env
     
    unsigned num_msg
     

    The documentation for this struct was generated from the following file:
    • src/tds/login.c
    freetds-1.00.82/doc/reference/a00734.html100644 025423 025423 00000005631 13242511133 0013235 FreeTDS API: Member List
    FreeTDS API
    mpz_t Member List

    This is the complete list of members for mpz_t, including all inherited members.

    num (defined in mpz_t)mpz_t
    freetds-1.00.82/doc/reference/a00737.html100644 025423 025423 00000006730 13242511133 0013241 FreeTDS API: mpz_t Struct Reference
    FreeTDS API

    Public Attributes

    gcry_mpi_t num
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00738.html100644 025423 025423 00000007225 13242511133 0013242 FreeTDS API: Member List
    FreeTDS API
    asn1_der_iterator Member List

    This is the complete list of members for asn1_der_iterator, including all inherited members.

    data (defined in asn1_der_iterator)asn1_der_iterator
    data_end (defined in asn1_der_iterator)asn1_der_iterator
    length (defined in asn1_der_iterator)asn1_der_iterator
    type (defined in asn1_der_iterator)asn1_der_iterator
    freetds-1.00.82/doc/reference/a00741.html100644 025423 025423 00000011041 13242511133 0013223 FreeTDS API: asn1_der_iterator Struct Reference
    FreeTDS API
    asn1_der_iterator Struct Reference

    Public Attributes

    const unsigned char * data
     
    const unsigned char * data_end
     
    unsigned long length
     
    unsigned long type
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00742.html100644 025423 025423 00000006611 13242511133 0013233 FreeTDS API: Member List
    FreeTDS API
    rsa_public_key Member List

    This is the complete list of members for rsa_public_key, including all inherited members.

    e (defined in rsa_public_key)rsa_public_key
    n (defined in rsa_public_key)rsa_public_key
    size (defined in rsa_public_key)rsa_public_key
    freetds-1.00.82/doc/reference/a00743.map100644 025423 025423 00000000224 13242511136 0013042 freetds-1.00.82/doc/reference/a00743.md5100644 025423 025423 00000000040 13242511133 0012743e2a567ec652ea8de69d19decf3aca1c3freetds-1.00.82/doc/reference/a00743.svg100644 025423 025423 00000003366 13242511136 0013076 rsa_public_key Node1 rsa_public_key Node2 mpz_t Node2->Node1 n e freetds-1.00.82/doc/reference/a00745.html100644 025423 025423 00000011154 13242511136 0013237 FreeTDS API: rsa_public_key Struct Reference
    FreeTDS API
    rsa_public_key Struct Reference
    Collaboration diagram for rsa_public_key:
    [legend]

    Public Attributes

    mpz_t e
     
    mpz_t n
     
    unsigned size
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00746.html100644 025423 025423 00000006142 13242511133 0013236 FreeTDS API: Member List
    FreeTDS API
    namelist Member List

    This is the complete list of members for namelist, including all inherited members.

    namenamelist
    nextnamelist
    freetds-1.00.82/doc/reference/a00747.map100644 025423 025423 00000000053 13242511136 0013046 freetds-1.00.82/doc/reference/a00747.md5100644 025423 025423 00000000040 13242511133 0012747c1765a7a64c6b49cdfe2a364c6a25a02freetds-1.00.82/doc/reference/a00747.svg100644 025423 025423 00000002540 13242511136 0013073 namelist Node1 namelist Node1->Node1 next freetds-1.00.82/doc/reference/a00749.html100644 025423 025423 00000011531 13242511136 0013242 FreeTDS API: namelist Struct Reference
    FreeTDS API

    Holds list of names. More...

    Collaboration diagram for namelist:
    [legend]

    Public Attributes

    char * name
     string name
     
    struct namelistnext
     next element in the list
     

    Detailed Description

    Holds list of names.


    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00750.html100644 025423 025423 00000006657 13242511133 0013244 FreeTDS API: Member List
    FreeTDS API
    tds_error_message Member List

    This is the complete list of members for tds_error_message, including all inherited members.

    msgno (defined in tds_error_message)tds_error_message
    msgtext (defined in tds_error_message)tds_error_message
    severity (defined in tds_error_message)tds_error_message
    freetds-1.00.82/doc/reference/a00753.html100644 025423 025423 00000007743 13242511133 0013244 FreeTDS API: tds_error_message Struct Reference
    FreeTDS API
    tds_error_message Struct Reference

    Public Attributes

    TDSERRNO msgno
     
    const char * msgtext
     
    int severity
     

    The documentation for this struct was generated from the following file:
    • src/tds/util.c
    freetds-1.00.82/doc/reference/a00754.html100644 025423 025423 00000006267 13242511133 0013245 FreeTDS API: Member List
    FreeTDS API
    string_linked_list Member List

    This is the complete list of members for string_linked_list, including all inherited members.

    next (defined in string_linked_list)string_linked_list
    str (defined in string_linked_list)string_linked_list
    freetds-1.00.82/doc/reference/a00755.map100644 025423 025423 00000000077 13242511136 0013053 freetds-1.00.82/doc/reference/a00755.md5100644 025423 025423 00000000040 13242511133 0012746beb0510133082ca0f07edde073c548e5freetds-1.00.82/doc/reference/a00755.svg100644 025423 025423 00000002546 13242511136 0013100 string_linked_list Node1 string_linked_list Node1->Node1 next freetds-1.00.82/doc/reference/a00757.html100644 025423 025423 00000010130 13242511136 0013233 FreeTDS API: string_linked_list Struct Reference
    FreeTDS API
    string_linked_list Struct Reference
    Collaboration diagram for string_linked_list:
    [legend]

    Public Attributes

    struct string_linked_listnext
     
    char * str
     

    The documentation for this struct was generated from the following file:
    • src/tds/vstrbuild.c
    freetds-1.00.82/doc/reference/a00758.html100644 025423 025423 00000011711 13242511133 0013237 FreeTDS API: Member List
    FreeTDS API
    _cs_objname Member List

    This is the complete list of members for _cs_objname, including all inherited members.

    first_name (defined in _cs_objname)_cs_objname
    fnlen (defined in _cs_objname)_cs_objname
    last_name (defined in _cs_objname)_cs_objname
    lnlen (defined in _cs_objname)_cs_objname
    object_type (defined in _cs_objname)_cs_objname
    scope (defined in _cs_objname)_cs_objname
    scopelen (defined in _cs_objname)_cs_objname
    thinkexists (defined in _cs_objname)_cs_objname
    thread (defined in _cs_objname)_cs_objname
    threadlen (defined in _cs_objname)_cs_objname
    freetds-1.00.82/doc/reference/a00761.html100644 025423 025423 00000014640 13242511133 0013235 FreeTDS API: _cs_objname Struct Reference
    FreeTDS API
    _cs_objname Struct Reference

    Public Attributes

    CS_CHAR first_name [CS_MAX_NAME]
     
    CS_INT fnlen
     
    CS_CHAR last_name [CS_MAX_NAME]
     
    CS_INT lnlen
     
    CS_INT object_type
     
    CS_VOID * scope
     
    CS_INT scopelen
     
    CS_BOOL thinkexists
     
    CS_VOID * thread
     
    CS_INT threadlen
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00762.html100644 025423 025423 00000007523 13242511133 0013240 FreeTDS API: Member List
    FreeTDS API
    _cs_objdata Member List

    This is the complete list of members for _cs_objdata, including all inherited members.

    actuallyexists (defined in _cs_objdata)_cs_objdata
    buffer (defined in _cs_objdata)_cs_objdata
    buflen (defined in _cs_objdata)_cs_objdata
    command (defined in _cs_objdata)_cs_objdata
    connection (defined in _cs_objdata)_cs_objdata
    freetds-1.00.82/doc/reference/a00763.map100644 025423 025423 00000002550 13242511135 0013047 freetds-1.00.82/doc/reference/a00763.md5100644 025423 025423 00000000040 13242511133 0012745d740a00d793d6e95568fabd543aadf76freetds-1.00.82/doc/reference/a00763.svg100644 025423 025423 00000046072 13242511136 0013101 _cs_objdata Node1 _cs_objdata Node2 _cs_command Node2->Node1 command Node2->Node2 next Node30 _cs_connection Node2->Node30 cmds Node3 _cs_iodesc Node3->Node2 iodesc Node4 _cs_locale Node4->Node3 locale Node4->Node30 locale Node5 _cs_param Node5->Node2 input_params Node5->Node5 next Node6 _cs_dynamic Node5->Node6 param_list Node38 _csremote_proc Node5->Node38 param_list Node6->Node2 dyn Node6->Node6 next Node6->Node30 dynlist Node7 tds_dynamic Node7->Node6 tdsdyn Node7->Node7 next Node9 tds_socket Node7->Node9 cur_dyn Node15 tds_cursor Node15->Node2 cursor Node15->Node15 next Node15->Node9 cur_cursor Node30->Node1 connection Node30->Node2 con Node9->Node30 tds_socket Node10 tds_login Node10->Node30 tds_login Node10->Node9 login Node31 _cs_context Node31->Node30 ctx _clientmsg_cb _servermsg_cb Node31->Node31 _clientmsg_cb _servermsg_cb _cslibmsg_cb Node38->Node2 rpc freetds-1.00.82/doc/reference/a00765.html100644 025423 025423 00000012255 13242511136 0013244 FreeTDS API: _cs_objdata Struct Reference
    FreeTDS API
    _cs_objdata Struct Reference
    Collaboration diagram for _cs_objdata:
    [legend]

    Public Attributes

    CS_BOOL actuallyexists
     
    CS_VOID * buffer
     
    CS_INT buflen
     
    CS_COMMANDcommand
     
    CS_CONNECTIONconnection
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00766.html100644 025423 025423 00000006576 13242511133 0013253 FreeTDS API: Member List
    FreeTDS API
    _cs_numeric Member List

    This is the complete list of members for _cs_numeric, including all inherited members.

    array (defined in _cs_numeric)_cs_numeric
    precision (defined in _cs_numeric)_cs_numeric
    scale (defined in _cs_numeric)_cs_numeric
    freetds-1.00.82/doc/reference/a00769.html100644 025423 025423 00000010045 13242511133 0013240 FreeTDS API: _cs_numeric Struct Reference
    FreeTDS API
    _cs_numeric Struct Reference

    Public Attributes

    unsigned char array [CS_MAX_NUMLEN]
     
    unsigned char precision
     
    unsigned char scale
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00770.html100644 025423 025423 00000006232 13242511133 0013233 FreeTDS API: Member List
    FreeTDS API
    _cs_varbinary Member List

    This is the complete list of members for _cs_varbinary, including all inherited members.

    array (defined in _cs_varbinary)_cs_varbinary
    len (defined in _cs_varbinary)_cs_varbinary
    freetds-1.00.82/doc/reference/a00773.html100644 025423 025423 00000007263 13242511133 0013243 FreeTDS API: _cs_varbinary Struct Reference
    FreeTDS API
    _cs_varbinary Struct Reference

    Public Attributes

    CS_CHAR array [256]
     
    CS_SMALLINT len
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00774.html100644 025423 025423 00000006214 13242511133 0013237 FreeTDS API: Member List
    FreeTDS API
    _cs_varchar Member List

    This is the complete list of members for _cs_varchar, including all inherited members.

    len (defined in _cs_varchar)_cs_varchar
    str (defined in _cs_varchar)_cs_varchar
    freetds-1.00.82/doc/reference/a00777.html100644 025423 025423 00000007255 13242511133 0013250 FreeTDS API: _cs_varchar Struct Reference
    FreeTDS API
    _cs_varchar Struct Reference

    Public Attributes

    CS_SMALLINT len
     
    CS_CHAR str [256]
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00778.html100644 025423 025423 00000013154 13242511133 0013244 FreeTDS API: Member List
    FreeTDS API
    _cs_iodesc Member List

    This is the complete list of members for _cs_iodesc, including all inherited members.

    datatype (defined in _cs_iodesc)_cs_iodesc
    iotype (defined in _cs_iodesc)_cs_iodesc
    locale (defined in _cs_iodesc)_cs_iodesc
    log_on_update (defined in _cs_iodesc)_cs_iodesc
    name (defined in _cs_iodesc)_cs_iodesc
    namelen (defined in _cs_iodesc)_cs_iodesc
    offset (defined in _cs_iodesc)_cs_iodesc
    textptr (defined in _cs_iodesc)_cs_iodesc
    textptrlen (defined in _cs_iodesc)_cs_iodesc
    timestamp (defined in _cs_iodesc)_cs_iodesc
    timestamplen (defined in _cs_iodesc)_cs_iodesc
    total_txtlen (defined in _cs_iodesc)_cs_iodesc
    usertype (defined in _cs_iodesc)_cs_iodesc
    freetds-1.00.82/doc/reference/a00779.map100644 025423 025423 00000000220 13242511135 0013046 freetds-1.00.82/doc/reference/a00779.md5100644 025423 025423 00000000040 13242511133 00127540312cf95bccca93df0a5d33577ea3f1afreetds-1.00.82/doc/reference/a00779.svg100644 025423 025423 00000003212 13242511136 0013075 _cs_iodesc Node1 _cs_iodesc Node2 _cs_locale Node2->Node1 locale freetds-1.00.82/doc/reference/a00781.html100644 025423 025423 00000017562 13242511136 0013250 FreeTDS API: _cs_iodesc Struct Reference
    FreeTDS API
    _cs_iodesc Struct Reference
    Collaboration diagram for _cs_iodesc:
    [legend]

    Public Attributes

    CS_INT datatype
     
    CS_INT iotype
     
    CS_LOCALElocale
     
    CS_BOOL log_on_update
     
    CS_CHAR name [CS_OBJ_NAME]
     
    CS_INT namelen
     
    CS_INT offset
     
    CS_BYTE textptr [CS_TP_SIZE]
     
    CS_INT textptrlen
     
    CS_BYTE timestamp [CS_TS_SIZE]
     
    CS_INT timestamplen
     
    CS_INT total_txtlen
     
    CS_INT usertype
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00782.html100644 025423 025423 00000012250 13242511133 0013233 FreeTDS API: Member List
    FreeTDS API
    _cs_datafmt Member List

    This is the complete list of members for _cs_datafmt, including all inherited members.

    count (defined in _cs_datafmt)_cs_datafmt
    datatype (defined in _cs_datafmt)_cs_datafmt
    format (defined in _cs_datafmt)_cs_datafmt
    locale (defined in _cs_datafmt)_cs_datafmt
    maxlength (defined in _cs_datafmt)_cs_datafmt
    name (defined in _cs_datafmt)_cs_datafmt
    namelen (defined in _cs_datafmt)_cs_datafmt
    precision (defined in _cs_datafmt)_cs_datafmt
    scale (defined in _cs_datafmt)_cs_datafmt
    status (defined in _cs_datafmt)_cs_datafmt
    usertype (defined in _cs_datafmt)_cs_datafmt
    freetds-1.00.82/doc/reference/a00783.map100644 025423 025423 00000000223 13242511135 0013044 freetds-1.00.82/doc/reference/a00783.md5100644 025423 025423 00000000040 13242511133 0012747df3ba2c393a5ded5afb1ae367ababcbffreetds-1.00.82/doc/reference/a00783.svg100644 025423 025423 00000003215 13242511136 0013073 _cs_datafmt Node1 _cs_datafmt Node2 _cs_locale Node2->Node1 locale freetds-1.00.82/doc/reference/a00785.html100644 025423 025423 00000016221 13242511136 0013243 FreeTDS API: _cs_datafmt Struct Reference
    FreeTDS API
    _cs_datafmt Struct Reference
    Collaboration diagram for _cs_datafmt:
    [legend]

    Public Attributes

    CS_INT count
     
    CS_INT datatype
     
    CS_INT format
     
    CS_LOCALElocale
     
    CS_INT maxlength
     
    CS_CHAR name [CS_MAX_NAME]
     
    CS_INT namelen
     
    CS_INT precision
     
    CS_INT scale
     
    CS_INT status
     
    CS_INT usertype
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00786.html100644 025423 025423 00000006207 13242511133 0013244 FreeTDS API: Member List
    FreeTDS API
    _cs_money Member List

    This is the complete list of members for _cs_money, including all inherited members.

    mnyhigh (defined in _cs_money)_cs_money
    mnylow (defined in _cs_money)_cs_money
    freetds-1.00.82/doc/reference/a00789.html100644 025423 025423 00000007245 13242511133 0013252 FreeTDS API: _cs_money Struct Reference
    FreeTDS API
    _cs_money Struct Reference

    Public Attributes

    CS_INT mnyhigh
     
    CS_UINT mnylow
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00790.html100644 025423 025423 00000005656 13242511133 0013246 FreeTDS API: Member List
    FreeTDS API
    _cs_money4 Member List

    This is the complete list of members for _cs_money4, including all inherited members.

    mny4 (defined in _cs_money4)_cs_money4
    freetds-1.00.82/doc/reference/a00793.html100644 025423 025423 00000006513 13242511133 0013242 FreeTDS API: _cs_money4 Struct Reference
    FreeTDS API
    _cs_money4 Struct Reference

    Public Attributes

    CS_INT mny4
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00794.html100644 025423 025423 00000006230 13242511133 0013237 FreeTDS API: Member List
    FreeTDS API
    _cs_datetime Member List

    This is the complete list of members for _cs_datetime, including all inherited members.

    dtdays (defined in _cs_datetime)_cs_datetime
    dttime (defined in _cs_datetime)_cs_datetime
    freetds-1.00.82/doc/reference/a00797.html100644 025423 025423 00000007251 13242511133 0013246 FreeTDS API: _cs_datetime Struct Reference
    FreeTDS API
    _cs_datetime Struct Reference

    Public Attributes

    CS_INT dtdays
     
    CS_INT dttime
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00798.html100644 025423 025423 00000006235 13242511133 0013250 FreeTDS API: Member List
    FreeTDS API
    _cs_datetime4 Member List

    This is the complete list of members for _cs_datetime4, including all inherited members.

    days (defined in _cs_datetime4)_cs_datetime4
    minutes (defined in _cs_datetime4)_cs_datetime4
    freetds-1.00.82/doc/reference/a00801.html100644 025423 025423 00000007260 13242511133 0013230 FreeTDS API: _cs_datetime4 Struct Reference
    FreeTDS API
    _cs_datetime4 Struct Reference

    Public Attributes

    CS_USHORT days
     
    CS_USHORT minutes
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00802.html100644 025423 025423 00000012652 13242511133 0013232 FreeTDS API: Member List
    FreeTDS API
    _cs_daterec Member List

    This is the complete list of members for _cs_daterec, including all inherited members.

    datedmonth (defined in _cs_daterec)_cs_daterec
    datedweek (defined in _cs_daterec)_cs_daterec
    datedyear (defined in _cs_daterec)_cs_daterec
    datehour (defined in _cs_daterec)_cs_daterec
    dateminute (defined in _cs_daterec)_cs_daterec
    datemonth (defined in _cs_daterec)_cs_daterec
    datemsecond (defined in _cs_daterec)_cs_daterec
    datesecfrac (defined in _cs_daterec)_cs_daterec
    datesecond (defined in _cs_daterec)_cs_daterec
    datesecprec (defined in _cs_daterec)_cs_daterec
    datetzone (defined in _cs_daterec)_cs_daterec
    dateyear (defined in _cs_daterec)_cs_daterec
    freetds-1.00.82/doc/reference/a00805.html100644 025423 025423 00000016102 13242511133 0013227 FreeTDS API: _cs_daterec Struct Reference
    FreeTDS API
    _cs_daterec Struct Reference

    Public Attributes

    CS_INT datedmonth
     
    CS_INT datedweek
     
    CS_INT datedyear
     
    CS_INT datehour
     
    CS_INT dateminute
     
    CS_INT datemonth
     
    CS_INT datemsecond
     
    CS_INT datesecfrac
     
    CS_INT datesecond
     
    CS_INT datesecprec
     
    CS_INT datetzone
     
    CS_INT dateyear
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00806.html100644 025423 025423 00000012000 13242511133 0013221 FreeTDS API: Member List
    FreeTDS API
    _cs_clientmsg Member List

    This is the complete list of members for _cs_clientmsg, including all inherited members.

    msgnumber (defined in _cs_clientmsg)_cs_clientmsg
    msgstring (defined in _cs_clientmsg)_cs_clientmsg
    msgstringlen (defined in _cs_clientmsg)_cs_clientmsg
    osnumber (defined in _cs_clientmsg)_cs_clientmsg
    osstring (defined in _cs_clientmsg)_cs_clientmsg
    osstringlen (defined in _cs_clientmsg)_cs_clientmsg
    severity (defined in _cs_clientmsg)_cs_clientmsg
    sqlstate (defined in _cs_clientmsg)_cs_clientmsg
    sqlstatelen (defined in _cs_clientmsg)_cs_clientmsg
    status (defined in _cs_clientmsg)_cs_clientmsg
    freetds-1.00.82/doc/reference/a00809.html100644 025423 025423 00000014674 13242511133 0013247 FreeTDS API: _cs_clientmsg Struct Reference
    FreeTDS API
    _cs_clientmsg Struct Reference

    Public Attributes

    CS_MSGNUM msgnumber
     
    CS_CHAR msgstring [CS_MAX_MSG]
     
    CS_INT msgstringlen
     
    CS_INT osnumber
     
    CS_CHAR osstring [CS_MAX_MSG]
     
    CS_INT osstringlen
     
    CS_INT severity
     
    CS_BYTE sqlstate [CS_SQLSTATE_SIZE]
     
    CS_INT sqlstatelen
     
    CS_INT status
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00810.html100644 025423 025423 00000013253 13242511133 0013227 FreeTDS API: Member List
    FreeTDS API
    _cs_servermsg Member List

    This is the complete list of members for _cs_servermsg, including all inherited members.

    line (defined in _cs_servermsg)_cs_servermsg
    msgnumber (defined in _cs_servermsg)_cs_servermsg
    proc (defined in _cs_servermsg)_cs_servermsg
    proclen (defined in _cs_servermsg)_cs_servermsg
    severity (defined in _cs_servermsg)_cs_servermsg
    sqlstate (defined in _cs_servermsg)_cs_servermsg
    sqlstatelen (defined in _cs_servermsg)_cs_servermsg
    state (defined in _cs_servermsg)_cs_servermsg
    status (defined in _cs_servermsg)_cs_servermsg
    svrname (defined in _cs_servermsg)_cs_servermsg
    svrnlen (defined in _cs_servermsg)_cs_servermsg
    text (defined in _cs_servermsg)_cs_servermsg
    textlen (defined in _cs_servermsg)_cs_servermsg
    freetds-1.00.82/doc/reference/a00813.html100644 025423 025423 00000016677 13242511133 0013247 FreeTDS API: _cs_servermsg Struct Reference
    FreeTDS API
    _cs_servermsg Struct Reference

    Public Attributes

    CS_INT line
     
    CS_MSGNUM msgnumber
     
    CS_CHAR proc [CS_MAX_NAME]
     
    CS_INT proclen
     
    CS_INT severity
     
    CS_BYTE sqlstate [CS_SQLSTATE_SIZE]
     
    CS_INT sqlstatelen
     
    CS_INT state
     
    CS_INT status
     
    CS_CHAR svrname [CS_MAX_NAME]
     
    CS_INT svrnlen
     
    CS_CHAR text [CS_MAX_MSG]
     
    CS_INT textlen
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00814.html100644 025423 025423 00000005673 13242511133 0013242 FreeTDS API: Member List
    FreeTDS API
    _cs_config Member List

    This is the complete list of members for _cs_config, including all inherited members.

    cs_expose_formats (defined in _cs_config)_cs_config
    freetds-1.00.82/doc/reference/a00817.html100644 025423 025423 00000006525 13242511133 0013242 FreeTDS API: _cs_config Struct Reference
    FreeTDS API
    _cs_config Struct Reference

    Public Attributes

    short cs_expose_formats
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00818.html100644 025423 025423 00000006275 13242511133 0013245 FreeTDS API: Member List
    FreeTDS API
    cs_diag_msg_client Member List

    This is the complete list of members for cs_diag_msg_client, including all inherited members.

    clientmsg (defined in cs_diag_msg_client)cs_diag_msg_client
    next (defined in cs_diag_msg_client)cs_diag_msg_client
    freetds-1.00.82/doc/reference/a00819.map100644 025423 025423 00000000245 13242511135 0013050 freetds-1.00.82/doc/reference/a00819.md5100644 025423 025423 00000000040 13242511133 001274745da08c0246ae0661badb07dfb83c0c1freetds-1.00.82/doc/reference/a00819.svg100644 025423 025423 00000004233 13242511136 0013074 cs_diag_msg_client Node1 cs_diag_msg_client Node1->Node1 next Node2 _cs_clientmsg Node2->Node1 clientmsg freetds-1.00.82/doc/reference/a00821.html100644 025423 025423 00000010264 13242511136 0013233 FreeTDS API: cs_diag_msg_client Struct Reference
    FreeTDS API
    cs_diag_msg_client Struct Reference
    Collaboration diagram for cs_diag_msg_client:
    [legend]

    Public Attributes

    CS_CLIENTMSGclientmsg
     
    struct cs_diag_msg_clientnext
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00822.html100644 025423 025423 00000006253 13242511133 0013234 FreeTDS API: Member List
    FreeTDS API
    cs_diag_msg_svr Member List

    This is the complete list of members for cs_diag_msg_svr, including all inherited members.

    next (defined in cs_diag_msg_svr)cs_diag_msg_svr
    servermsg (defined in cs_diag_msg_svr)cs_diag_msg_svr
    freetds-1.00.82/doc/reference/a00823.map100644 025423 025423 00000000237 13242511135 0013044 freetds-1.00.82/doc/reference/a00823.md5100644 025423 025423 00000000040 13242511133 0012742e825f711af093cd7cb9ee01e923f61bafreetds-1.00.82/doc/reference/a00823.svg100644 025423 025423 00000004222 13242511136 0013065 cs_diag_msg_svr Node1 cs_diag_msg_svr Node1->Node1 next Node2 _cs_servermsg Node2->Node1 servermsg freetds-1.00.82/doc/reference/a00825.html100644 025423 025423 00000010250 13242511136 0013232 FreeTDS API: cs_diag_msg_svr Struct Reference
    FreeTDS API
    cs_diag_msg_svr Struct Reference
    Collaboration diagram for cs_diag_msg_svr:
    [legend]

    Public Attributes

    struct cs_diag_msg_svrnext
     
    CS_SERVERMSGservermsg
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00826.html100644 025423 025423 00000006215 13242511133 0013236 FreeTDS API: Member List
    FreeTDS API
    cs_diag_msg Member List

    This is the complete list of members for cs_diag_msg, including all inherited members.

    msg (defined in cs_diag_msg)cs_diag_msg
    next (defined in cs_diag_msg)cs_diag_msg
    freetds-1.00.82/doc/reference/a00827.map100644 025423 025423 00000000226 13242511135 0013046 freetds-1.00.82/doc/reference/a00827.md5100644 025423 025423 00000000040 13242511133 0012746a407c3b32cd48fff049aca0887f76eacfreetds-1.00.82/doc/reference/a00827.svg100644 025423 025423 00000004200 13242511136 0013065 cs_diag_msg Node1 cs_diag_msg Node1->Node1 next Node2 _cs_clientmsg Node2->Node1 msg freetds-1.00.82/doc/reference/a00829.html100644 025423 025423 00000010222 13242511136 0013235 FreeTDS API: cs_diag_msg Struct Reference
    FreeTDS API
    cs_diag_msg Struct Reference
    Collaboration diagram for cs_diag_msg:
    [legend]

    Public Attributes

    CS_CLIENTMSGmsg
     
    struct cs_diag_msgnext
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00830.html100644 025423 025423 00000014607 13242511133 0013235 FreeTDS API: Member List
    FreeTDS API
    _cs_context Member List

    This is the complete list of members for _cs_context, including all inherited members.

    _clientmsg_cb (defined in _cs_context)_cs_context
    _cslibmsg_cb (defined in _cs_context)_cs_context
    _servermsg_cb (defined in _cs_context)_cs_context
    clientstore (defined in _cs_context)_cs_context
    config (defined in _cs_context)_cs_context
    cs_diag_msglimit (defined in _cs_context)_cs_context
    cs_diag_msglimit_client (defined in _cs_context)_cs_context
    cs_diag_msglimit_server (defined in _cs_context)_cs_context
    cs_diag_msglimit_total (defined in _cs_context)_cs_context
    cs_errhandletype (defined in _cs_context)_cs_context
    date_convert_fmt (defined in _cs_context)_cs_context
    msgstore (defined in _cs_context)_cs_context
    svrstore (defined in _cs_context)_cs_context
    tds_ctx (defined in _cs_context)_cs_context
    userdata (defined in _cs_context)_cs_context
    userdata_len (defined in _cs_context)_cs_context
    freetds-1.00.82/doc/reference/a00831.map100644 025423 025423 00000001555 13242511135 0013047 freetds-1.00.82/doc/reference/a00831.md5100644 025423 025423 00000000040 13242511133 00127412a7982640324af7f17fdfaacc5b6c00cfreetds-1.00.82/doc/reference/a00831.svg100644 025423 025423 00000024217 13242511136 0013072 _cs_context Node1 _cs_context Node1->Node1 _clientmsg_cb _servermsg_cb _cslibmsg_cb Node2 cs_diag_msg_client Node2->Node1 clientstore Node2->Node2 next Node3 _cs_clientmsg Node3->Node2 clientmsg Node9 cs_diag_msg Node3->Node9 msg Node4 tds_context Node4->Node1 tds_ctx Node5 tds_locale Node5->Node4 locale Node6 _cs_config Node6->Node1 config Node7 cs_diag_msg_svr Node7->Node1 svrstore Node7->Node7 next Node8 _cs_servermsg Node8->Node7 servermsg Node9->Node1 msgstore Node9->Node9 next freetds-1.00.82/doc/reference/a00833.html100644 025423 025423 00000022221 13242511136 0013232 FreeTDS API: _cs_context Struct Reference
    FreeTDS API
    _cs_context Struct Reference
    Collaboration diagram for _cs_context:
    [legend]

    Public Attributes

    CS_CLIENTMSG_FUNC _clientmsg_cb
     
    CS_CSLIBMSG_FUNC _cslibmsg_cb
     
    CS_SERVERMSG_FUNC _servermsg_cb
     
    struct cs_diag_msg_clientclientstore
     
    CS_CONFIG config
     
    CS_INT cs_diag_msglimit
     
    CS_INT cs_diag_msglimit_client
     
    CS_INT cs_diag_msglimit_server
     
    CS_INT cs_diag_msglimit_total
     
    CS_INT cs_errhandletype
     
    CS_INT date_convert_fmt
     
    struct cs_diag_msgmsgstore
     
    struct cs_diag_msg_svrsvrstore
     
    TDSCONTEXTtds_ctx
     
    void * userdata
     
    int userdata_len
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00834.html100644 025423 025423 00000005667 13242511133 0013247 FreeTDS API: Member List
    FreeTDS API
    _ct_colinfo Member List

    This is the complete list of members for _ct_colinfo, including all inherited members.

    indicator (defined in _ct_colinfo)_ct_colinfo
    freetds-1.00.82/doc/reference/a00837.html100644 025423 025423 00000006530 13242511133 0013240 FreeTDS API: _ct_colinfo Struct Reference
    FreeTDS API
    _ct_colinfo Struct Reference

    Public Attributes

    TDS_SMALLINT * indicator
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00838.html100644 025423 025423 00000012407 13242511133 0013241 FreeTDS API: Member List
    FreeTDS API
    _cs_connection Member List

    This is the complete list of members for _cs_connection, including all inherited members.

    _clientmsg_cb (defined in _cs_connection)_cs_connection
    _servermsg_cb (defined in _cs_connection)_cs_connection
    cmds (defined in _cs_connection)_cs_connection
    ctx (defined in _cs_connection)_cs_connection
    dynlist (defined in _cs_connection)_cs_connection
    locale (defined in _cs_connection)_cs_connection
    server_addr (defined in _cs_connection)_cs_connection
    tds_login (defined in _cs_connection)_cs_connection
    tds_socket (defined in _cs_connection)_cs_connection
    userdata (defined in _cs_connection)_cs_connection
    userdata_len (defined in _cs_connection)_cs_connection
    freetds-1.00.82/doc/reference/a00839.map100644 025423 025423 00000006240 13242511135 0013053 freetds-1.00.82/doc/reference/a00839.md5100644 025423 025423 00000000040 13242511133 0012751f30e80d8a7d4818a4c9a9f23c421618ffreetds-1.00.82/doc/reference/a00839.svg100644 025423 025423 00000121553 13242511136 0013103 _cs_connection Node1 _cs_connection Node26 _cs_command Node1->Node26 con Node2 _cs_locale Node2->Node1 locale Node27 _cs_iodesc Node2->Node27 locale Node3 tds_socket Node3->Node1 tds_socket Node10 tds_result_info Node3->Node10 attached_to Node4 tds_login Node4->Node1 tds_login Node4->Node3 login Node5 tds_capabilities Node5->Node4 capabilities Node20 tds_connection Node5->Node20 capabilities Node7 tds_dstr Node7->Node4 server_realm_name password server_name dump_file library crlfile server_spn client_host _name client_charset openssl_ciphers ... Node8 tds_packet Node8->Node3 recv_packet send_packet Node8->Node8 next Node9 tds_dynamic Node9->Node3 cur_dyn Node9->Node9 next Node9->Node20 dyns Node29 _cs_dynamic Node9->Node29 tdsdyn Node10->Node3 param_info current_results res_info comp_info Node10->Node9 res_info params Node18 tds_cursor Node10->Node18 res_info Node18->Node3 cur_cursor Node18->Node18 next Node18->Node20 cursors Node18->Node26 cursor Node19 tds_cursor_status Node19->Node18 status Node20->Node3 conn Node21 tds_poll_wakeup Node21->Node20 wakeup Node22 tds_env Node22->Node20 env Node23 tds_context Node23->Node20 tds_ctx Node31 _cs_context Node23->Node31 tds_ctx Node25 tds_authentication Node25->Node20 authentication Node12 tdsiconvinfo Node12->Node20 char_convs Node26->Node1 cmds Node26->Node26 next Node27->Node26 iodesc Node28 _cs_param Node28->Node26 input_params Node28->Node28 next Node28->Node29 param_list Node30 _csremote_proc Node28->Node30 param_list Node29->Node1 dynlist Node29->Node26 dyn Node29->Node29 next Node30->Node26 rpc Node31->Node1 ctx _clientmsg_cb _servermsg_cb Node31->Node31 _clientmsg_cb _servermsg_cb _cslibmsg_cb Node32 cs_diag_msg_client Node32->Node31 clientstore Node32->Node32 next Node33 _cs_clientmsg Node33->Node32 clientmsg Node37 cs_diag_msg Node33->Node37 msg Node34 _cs_config Node34->Node31 config Node35 cs_diag_msg_svr Node35->Node31 svrstore Node35->Node35 next Node36 _cs_servermsg Node36->Node35 servermsg Node37->Node31 msgstore Node37->Node37 next freetds-1.00.82/doc/reference/a00841.html100644 025423 025423 00000016611 13242511136 0013237 FreeTDS API: _cs_connection Struct Reference
    FreeTDS API
    _cs_connection Struct Reference
    Collaboration diagram for _cs_connection:
    [legend]

    Public Attributes

    CS_CLIENTMSG_FUNC _clientmsg_cb
     
    CS_SERVERMSG_FUNC _servermsg_cb
     
    CS_COMMANDcmds
     
    CS_CONTEXTctx
     
    CS_DYNAMICdynlist
     
    CS_LOCALElocale
     
    char * server_addr
     
    TDSLOGINtds_login
     
    TDSSOCKETtds_socket
     
    void * userdata
     
    int userdata_len
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00842.html100644 025423 025423 00000013107 13242511133 0013232 FreeTDS API: Member List
    FreeTDS API
    _cs_param Member List

    This is the complete list of members for _cs_param, including all inherited members.

    datalen (defined in _cs_param)_cs_param
    datalen_value (defined in _cs_param)_cs_param
    datatype (defined in _cs_param)_cs_param
    ind (defined in _cs_param)_cs_param
    indicator_value (defined in _cs_param)_cs_param
    maxlen (defined in _cs_param)_cs_param
    name (defined in _cs_param)_cs_param
    next (defined in _cs_param)_cs_param
    param_by_value (defined in _cs_param)_cs_param
    precision (defined in _cs_param)_cs_param
    scale (defined in _cs_param)_cs_param
    status (defined in _cs_param)_cs_param
    value (defined in _cs_param)_cs_param
    freetds-1.00.82/doc/reference/a00843.map100644 025423 025423 00000000055 13242511135 0013044 freetds-1.00.82/doc/reference/a00843.md5100644 025423 025423 00000000040 13242511133 0012744ba4bc67f10abdfacdac45ca329461304freetds-1.00.82/doc/reference/a00843.svg100644 025423 025423 00000002511 13242511136 0013066 _cs_param Node1 _cs_param Node1->Node1 next freetds-1.00.82/doc/reference/a00845.html100644 025423 025423 00000017506 13242511136 0013247 FreeTDS API: _cs_param Struct Reference
    FreeTDS API
    _cs_param Struct Reference
    Collaboration diagram for _cs_param:
    [legend]

    Public Attributes

    CS_INT * datalen
     
    CS_INT datalen_value
     
    int datatype
     
    CS_SMALLINT * ind
     
    CS_SMALLINT indicator_value
     
    CS_INT maxlen
     
    char * name
     
    struct _cs_paramnext
     
    int param_by_value
     
    CS_INT precision
     
    CS_INT scale
     
    int status
     
    CS_BYTE * value
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00846.html100644 025423 025423 00000006630 13242511133 0013241 FreeTDS API: Member List
    FreeTDS API
    _csremote_proc Member List

    This is the complete list of members for _csremote_proc, including all inherited members.

    name (defined in _csremote_proc)_csremote_proc
    options (defined in _csremote_proc)_csremote_proc
    param_list (defined in _csremote_proc)_csremote_proc
    freetds-1.00.82/doc/reference/a00847.map100644 025423 025423 00000000231 13242511135 0013044 freetds-1.00.82/doc/reference/a00847.md5100644 025423 025423 00000000040 13242511133 00127501f2267127b1be555593754ffe81016f5freetds-1.00.82/doc/reference/a00847.svg100644 025423 025423 00000004257 13242511136 0013103 _csremote_proc Node1 _csremote_proc Node2 _cs_param Node2->Node1 param_list Node2->Node2 next freetds-1.00.82/doc/reference/a00849.html100644 025423 025423 00000010724 13242511136 0013246 FreeTDS API: _csremote_proc Struct Reference
    FreeTDS API
    _csremote_proc Struct Reference
    Collaboration diagram for _csremote_proc:
    [legend]

    Public Attributes

    char * name
     
    CS_SMALLINT options
     
    CSREMOTE_PROC_PARAMparam_list
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00850.html100644 025423 025423 00000007502 13242511133 0013233 FreeTDS API: Member List
    FreeTDS API
    _cs_dynamic Member List

    This is the complete list of members for _cs_dynamic, including all inherited members.

    id (defined in _cs_dynamic)_cs_dynamic
    next (defined in _cs_dynamic)_cs_dynamic
    param_list (defined in _cs_dynamic)_cs_dynamic
    stmt (defined in _cs_dynamic)_cs_dynamic
    tdsdyn (defined in _cs_dynamic)_cs_dynamic
    freetds-1.00.82/doc/reference/a00851.map100644 025423 025423 00000001273 13242511135 0013046 freetds-1.00.82/doc/reference/a00851.md5100644 025423 025423 00000000040 13242511133 00127431a8809c21e43eee1074242955e2ea033freetds-1.00.82/doc/reference/a00851.svg100644 025423 025423 00000020622 13242511136 0013070 _cs_dynamic Node1 _cs_dynamic Node1->Node1 next Node2 tds_dynamic Node2->Node1 tdsdyn Node2->Node2 next Node4 tds_socket Node2->Node4 cur_dyn Node3 tds_result_info Node3->Node2 res_info params Node3->Node4 param_info current_results res_info comp_info Node4->Node3 attached_to Node22 tds_column Node22->Node3 columns Node25 _cs_param Node25->Node1 param_list Node25->Node25 next freetds-1.00.82/doc/reference/a00853.html100644 025423 025423 00000012354 13242511136 0013242 FreeTDS API: _cs_dynamic Struct Reference
    FreeTDS API
    _cs_dynamic Struct Reference
    Collaboration diagram for _cs_dynamic:
    [legend]

    Public Attributes

    char * id
     
    struct _cs_dynamicnext
     
    CS_DYNAMIC_PARAMparam_list
     
    char * stmt
     
    TDSDYNAMICtdsdyn
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00854.html100644 025423 025423 00000017701 13242511133 0013241 FreeTDS API: Member List
    FreeTDS API
    _cs_command Member List

    This is the complete list of members for _cs_command, including all inherited members.

    bind_count (defined in _cs_command)_cs_command
    cancel_state (defined in _cs_command)_cs_command
    client_cursor_id (defined in _cs_command)_cs_command
    command_state (defined in _cs_command)_cs_command
    command_type (defined in _cs_command)_cs_command
    con (defined in _cs_command)_cs_command
    curr_result_type (defined in _cs_command)_cs_command
    cursor (defined in _cs_command)_cs_command
    cursor_state (defined in _cs_command)_cs_command
    dyn (defined in _cs_command)_cs_command
    dynamic_cmd (defined in _cs_command)_cs_command
    get_data_bytes_returned (defined in _cs_command)_cs_command
    get_data_item (defined in _cs_command)_cs_command
    input_params (defined in _cs_command)_cs_command
    iodesc (defined in _cs_command)_cs_command
    next (defined in _cs_command)_cs_command
    query (defined in _cs_command)_cs_command
    results_state (defined in _cs_command)_cs_command
    row_prefetched (defined in _cs_command)_cs_command
    rpc (defined in _cs_command)_cs_command
    send_data_started (defined in _cs_command)_cs_command
    userdata (defined in _cs_command)_cs_command
    userdata_len (defined in _cs_command)_cs_command
    freetds-1.00.82/doc/reference/a00855.map100644 025423 025423 00000003651 13242511135 0013054 freetds-1.00.82/doc/reference/a00855.md5100644 025423 025423 00000000040 13242511133 00127474dd8d0d6c01d60618e37f6163a866145freetds-1.00.82/doc/reference/a00855.svg100644 025423 025423 00000064555 13242511136 0013111 _cs_command Node1 _cs_command Node1->Node1 next Node29 _cs_connection Node1->Node29 cmds Node2 _cs_iodesc Node2->Node1 iodesc Node3 _cs_locale Node3->Node2 locale Node3->Node29 locale Node4 _cs_param Node4->Node1 input_params Node4->Node4 next Node5 _cs_dynamic Node4->Node5 param_list Node37 _csremote_proc Node4->Node37 param_list Node5->Node1 dyn Node5->Node5 next Node5->Node29 dynlist Node6 tds_dynamic Node6->Node5 tdsdyn Node6->Node6 next Node8 tds_socket Node6->Node8 cur_dyn Node7 tds_result_info Node7->Node6 res_info params Node7->Node8 param_info current_results res_info comp_info Node14 tds_cursor Node7->Node14 res_info Node8->Node7 attached_to Node8->Node29 tds_socket Node9 tds_login Node9->Node8 login Node9->Node29 tds_login Node14->Node1 cursor Node14->Node8 cur_cursor Node14->Node14 next Node29->Node1 con Node30 _cs_context Node30->Node29 ctx _clientmsg_cb _servermsg_cb Node30->Node30 _clientmsg_cb _servermsg_cb _cslibmsg_cb Node31 cs_diag_msg_client Node31->Node30 clientstore Node31->Node31 next Node19 tds_context Node19->Node30 tds_ctx Node33 _cs_config Node33->Node30 config Node34 cs_diag_msg_svr Node34->Node30 svrstore Node34->Node34 next Node36 cs_diag_msg Node36->Node30 msgstore Node36->Node36 next Node37->Node1 rpc freetds-1.00.82/doc/reference/a00857.html100644 025423 025423 00000027043 13242511136 0013247 FreeTDS API: _cs_command Struct Reference
    FreeTDS API
    _cs_command Struct Reference
    Collaboration diagram for _cs_command:
    [legend]

    Public Attributes

    int bind_count
     
    CS_INT cancel_state
     
    CS_INT client_cursor_id
     
    CS_INT command_state
     
    CS_INT command_type
     
    CS_CONNECTIONcon
     
    int curr_result_type
     
    TDSCURSORcursor
     
    CS_INT cursor_state
     
    CS_DYNAMICdyn
     
    short dynamic_cmd
     
    int get_data_bytes_returned
     
    int get_data_item
     
    CS_PARAMinput_params
     
    CS_IODESCiodesc
     
    struct _cs_commandnext
     
    CS_CHAR * query
     
    CS_INT results_state
     
    int row_prefetched
     
    CSREMOTE_PROCrpc
     
    CS_INT send_data_started
     
    void * userdata
     
    int userdata_len
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00858.html100644 025423 025423 00000005665 13242511133 0013253 FreeTDS API: Member List
    FreeTDS API
    _cs_blkdesc Member List

    This is the complete list of members for _cs_blkdesc, including all inherited members.

    bcpinfo (defined in _cs_blkdesc)_cs_blkdesc
    freetds-1.00.82/doc/reference/a00859.map100644 025423 025423 00000001234 13242511135 0013053 freetds-1.00.82/doc/reference/a00859.md5100644 025423 025423 00000000040 13242511133 0012753fcff38383ae12b0d506759ae7a6dcb76freetds-1.00.82/doc/reference/a00859.svg100644 025423 025423 00000015360 13242511136 0013103 _cs_blkdesc Node1 _cs_blkdesc Node2 tds_bcpinfo Node2->Node1 bcpinfo Node3 tds_result_info Node3->Node2 bindinfo Node4 tds_socket Node3->Node4 param_info current_results res_info comp_info Node4->Node3 attached_to Node23 tds_column Node23->Node3 columns Node8 tds_dstr Node8->Node2 tablename Node8->Node23 column_name table_name table_column_name freetds-1.00.82/doc/reference/a00861.html100644 025423 025423 00000007411 13242511136 0013237 FreeTDS API: _cs_blkdesc Struct Reference
    FreeTDS API
    _cs_blkdesc Struct Reference
    Collaboration diagram for _cs_blkdesc:
    [legend]

    Public Attributes

    TDSBCPINFO bcpinfo
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00862.html100644 025423 025423 00000007123 13242511133 0013235 FreeTDS API: Member List
    FreeTDS API
    _cs_locale Member List

    This is the complete list of members for _cs_locale, including all inherited members.

    charset (defined in _cs_locale)_cs_locale
    collate (defined in _cs_locale)_cs_locale
    language (defined in _cs_locale)_cs_locale
    time (defined in _cs_locale)_cs_locale
    freetds-1.00.82/doc/reference/a00865.html100644 025423 025423 00000010525 13242511133 0013240 FreeTDS API: _cs_locale Struct Reference
    FreeTDS API
    _cs_locale Struct Reference

    Public Attributes

    char * charset
     
    char * collate
     
    char * language
     
    char * time
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00866.html100644 025423 025423 00000005723 13242511133 0013245 FreeTDS API: Member List
    FreeTDS API
    tds_dblib_loginrec Member List

    This is the complete list of members for tds_dblib_loginrec, including all inherited members.

    tds_login (defined in tds_dblib_loginrec)tds_dblib_loginrec
    freetds-1.00.82/doc/reference/a00867.map100644 025423 025423 00000000763 13242511136 0013061 freetds-1.00.82/doc/reference/a00867.md5100644 025423 025423 00000000040 13242511133 0012752475a8876a44c4a13f5686f60390a6b5dfreetds-1.00.82/doc/reference/a00867.svg100644 025423 025423 00000013021 13242511136 0013072 tds_dblib_loginrec Node1 tds_dblib_loginrec Node2 tds_login Node2->Node1 tds_login Node3 tds_capabilities Node3->Node2 capabilities Node4 tds_capability_type Node4->Node3 types Node5 tds_dstr Node5->Node2 server_realm_name password server_name dump_file library crlfile server_spn client_host _name client_charset openssl_ciphers ... freetds-1.00.82/doc/reference/a00869.html100644 025423 025423 00000007440 13242511136 0013251 FreeTDS API: tds_dblib_loginrec Struct Reference
    FreeTDS API
    tds_dblib_loginrec Struct Reference
    Collaboration diagram for tds_dblib_loginrec:
    [legend]

    Public Attributes

    TDSLOGINtds_login
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00870.html100644 025423 025423 00000010167 13242511133 0013236 FreeTDS API: Member List
    FreeTDS API
    tag_DBPROC_ROWBUF Member List

    This is the complete list of members for tag_DBPROC_ROWBUF, including all inherited members.

    capacity (defined in tag_DBPROC_ROWBUF)tag_DBPROC_ROWBUF
    current (defined in tag_DBPROC_ROWBUF)tag_DBPROC_ROWBUF
    head (defined in tag_DBPROC_ROWBUF)tag_DBPROC_ROWBUF
    received (defined in tag_DBPROC_ROWBUF)tag_DBPROC_ROWBUF
    rows (defined in tag_DBPROC_ROWBUF)tag_DBPROC_ROWBUF
    tail (defined in tag_DBPROC_ROWBUF)tag_DBPROC_ROWBUF
    freetds-1.00.82/doc/reference/a00871.map100644 025423 025423 00000001067 13242511136 0013052 freetds-1.00.82/doc/reference/a00871.md5100644 025423 025423 00000000040 13242511133 00127458b34027ae8a7752c82feb37e32a8d522freetds-1.00.82/doc/reference/a00871.svg100644 025423 025423 00000012200 13242511136 0013063 tag_DBPROC_ROWBUF Node1 tag_DBPROC_ROWBUF Node2 dblib_buffer_row Node2->Node1 rows Node3 tds_result_info Node3->Node2 resinfo Node4 tds_socket Node3->Node4 param_info current_results res_info comp_info Node4->Node3 attached_to Node23 tds_column Node23->Node3 columns freetds-1.00.82/doc/reference/a00873.html100644 025423 025423 00000012721 13242511136 0013242 FreeTDS API: tag_DBPROC_ROWBUF Struct Reference
    FreeTDS API
    tag_DBPROC_ROWBUF Struct Reference
    Collaboration diagram for tag_DBPROC_ROWBUF:
    [legend]

    Public Attributes

    int capacity
     
    int current
     
    int head
     
    int received
     
    struct dblib_buffer_rowrows
     
    int tail
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00874.html100644 025423 025423 00000011124 13242511133 0013234 FreeTDS API: Member List
    FreeTDS API
    BCP_HOSTCOLINFO Member List

    This is the complete list of members for BCP_HOSTCOLINFO, including all inherited members.

    column_error (defined in BCP_HOSTCOLINFO)BCP_HOSTCOLINFO
    column_len (defined in BCP_HOSTCOLINFO)BCP_HOSTCOLINFO
    datatype (defined in BCP_HOSTCOLINFO)BCP_HOSTCOLINFO
    host_column (defined in BCP_HOSTCOLINFO)BCP_HOSTCOLINFO
    prefix_len (defined in BCP_HOSTCOLINFO)BCP_HOSTCOLINFO
    tab_colnum (defined in BCP_HOSTCOLINFO)BCP_HOSTCOLINFO
    term_len (defined in BCP_HOSTCOLINFO)BCP_HOSTCOLINFO
    terminator (defined in BCP_HOSTCOLINFO)BCP_HOSTCOLINFO
    freetds-1.00.82/doc/reference/a00877.html100644 025423 025423 00000013325 13242511133 0013244 FreeTDS API: BCP_HOSTCOLINFO Struct Reference
    FreeTDS API
    BCP_HOSTCOLINFO Struct Reference

    Public Attributes

    int column_error
     
    DBINT column_len
     
    TDS_SERVER_TYPE datatype
     
    int host_column
     
    int prefix_len
     
    int tab_colnum
     
    int term_len
     
    BYTE * terminator
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00878.html100644 025423 025423 00000011531 13242511133 0013242 FreeTDS API: Member List
    FreeTDS API
    BCP_HOSTFILEINFO Member List

    This is the complete list of members for BCP_HOSTFILEINFO, including all inherited members.

    batch (defined in BCP_HOSTFILEINFO)BCP_HOSTFILEINFO
    bcp_errfileptr (defined in BCP_HOSTFILEINFO)BCP_HOSTFILEINFO
    errorfile (defined in BCP_HOSTFILEINFO)BCP_HOSTFILEINFO
    firstrow (defined in BCP_HOSTFILEINFO)BCP_HOSTFILEINFO
    host_colcount (defined in BCP_HOSTFILEINFO)BCP_HOSTFILEINFO
    host_columns (defined in BCP_HOSTFILEINFO)BCP_HOSTFILEINFO
    hostfile (defined in BCP_HOSTFILEINFO)BCP_HOSTFILEINFO
    lastrow (defined in BCP_HOSTFILEINFO)BCP_HOSTFILEINFO
    maxerrs (defined in BCP_HOSTFILEINFO)BCP_HOSTFILEINFO
    freetds-1.00.82/doc/reference/a00879.map100644 025423 025423 00000000242 13242511135 0013053 freetds-1.00.82/doc/reference/a00879.md5100644 025423 025423 00000000040 13242511133 00127554e24a0765c8344ac44853e5025c37894freetds-1.00.82/doc/reference/a00879.svg100644 025423 025423 00000003274 13242511136 0013106 BCP_HOSTFILEINFO Node1 BCP_HOSTFILEINFO Node2 BCP_HOSTCOLINFO Node2->Node1 host_columns freetds-1.00.82/doc/reference/a00881.html100644 025423 025423 00000015011 13242511136 0013234 FreeTDS API: BCP_HOSTFILEINFO Struct Reference
    FreeTDS API
    BCP_HOSTFILEINFO Struct Reference
    Collaboration diagram for BCP_HOSTFILEINFO:
    [legend]

    Public Attributes

    TDS_INT batch
     
    FILE * bcp_errfileptr
     
    TDS_CHAR * errorfile
     
    TDS_INT firstrow
     
    TDS_INT host_colcount
     
    BCP_HOSTCOLINFO ** host_columns
     
    TDS_CHAR * hostfile
     
    TDS_INT lastrow
     
    TDS_INT maxerrs
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00882.html100644 025423 025423 00000010631 13242511133 0013235 FreeTDS API: Member List
    FreeTDS API
    _DBREMOTE_PROC_PARAM Member List

    This is the complete list of members for _DBREMOTE_PROC_PARAM, including all inherited members.

    datalen (defined in _DBREMOTE_PROC_PARAM)_DBREMOTE_PROC_PARAM
    maxlen (defined in _DBREMOTE_PROC_PARAM)_DBREMOTE_PROC_PARAM
    name (defined in _DBREMOTE_PROC_PARAM)_DBREMOTE_PROC_PARAM
    next (defined in _DBREMOTE_PROC_PARAM)_DBREMOTE_PROC_PARAM
    status (defined in _DBREMOTE_PROC_PARAM)_DBREMOTE_PROC_PARAM
    type (defined in _DBREMOTE_PROC_PARAM)_DBREMOTE_PROC_PARAM
    value (defined in _DBREMOTE_PROC_PARAM)_DBREMOTE_PROC_PARAM
    freetds-1.00.82/doc/reference/a00883.map100644 025423 025423 00000000103 13242511135 0013042 freetds-1.00.82/doc/reference/a00883.md5100644 025423 025423 00000000040 13242511133 00127503715267871a6d98b91cc7afe25bb70c6freetds-1.00.82/doc/reference/a00883.svg100644 025423 025423 00000002552 13242511136 0013077 _DBREMOTE_PROC_PARAM Node1 _DBREMOTE_PROC_PARAM Node1->Node1 next freetds-1.00.82/doc/reference/a00885.html100644 025423 025423 00000013504 13242511136 0013245 FreeTDS API: _DBREMOTE_PROC_PARAM Struct Reference
    FreeTDS API
    _DBREMOTE_PROC_PARAM Struct Reference
    Collaboration diagram for _DBREMOTE_PROC_PARAM:
    [legend]

    Public Attributes

    DBINT datalen
     
    DBINT maxlen
     
    char * name
     
    struct _DBREMOTE_PROC_PARAMnext
     
    BYTE status
     
    TDS_SERVER_TYPE type
     
    BYTE * value
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00886.html100644 025423 025423 00000007172 13242511133 0013247 FreeTDS API: Member List
    FreeTDS API
    _DBREMOTE_PROC Member List

    This is the complete list of members for _DBREMOTE_PROC, including all inherited members.

    name (defined in _DBREMOTE_PROC)_DBREMOTE_PROC
    next (defined in _DBREMOTE_PROC)_DBREMOTE_PROC
    options (defined in _DBREMOTE_PROC)_DBREMOTE_PROC
    param_list (defined in _DBREMOTE_PROC)_DBREMOTE_PROC
    freetds-1.00.82/doc/reference/a00887.map100644 025423 025423 00000000243 13242511135 0013053 freetds-1.00.82/doc/reference/a00887.md5100644 025423 025423 00000000040 13242511133 00127545a867dd77d068326d753990eca8abbc2freetds-1.00.82/doc/reference/a00887.svg100644 025423 025423 00000005242 13242511136 0013102 _DBREMOTE_PROC Node1 _DBREMOTE_PROC Node1->Node1 next Node2 _DBREMOTE_PROC_PARAM Node2->Node1 param_list Node2->Node2 next freetds-1.00.82/doc/reference/a00889.html100644 025423 025423 00000011537 13242511136 0013255 FreeTDS API: _DBREMOTE_PROC Struct Reference
    FreeTDS API
    _DBREMOTE_PROC Struct Reference
    Collaboration diagram for _DBREMOTE_PROC:
    [legend]

    Public Attributes

    char * name
     
    struct _DBREMOTE_PROCnext
     
    DBSMALLINT options
     
    DBREMOTE_PROC_PARAMparam_list
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00890.html100644 025423 025423 00000006543 13242511133 0013243 FreeTDS API: Member List
    FreeTDS API
    dboption Member List

    This is the complete list of members for dboption, including all inherited members.

    factive (defined in dboption)dboption
    param (defined in dboption)dboption
    text (defined in dboption)dboption
    freetds-1.00.82/doc/reference/a00891.map100644 025423 025423 00000000212 13242511135 0013042 freetds-1.00.82/doc/reference/a00891.md5100644 025423 025423 00000000040 13242511133 0012747c54176ca820ea6b55591168b4619136dfreetds-1.00.82/doc/reference/a00891.svg100644 025423 025423 00000004210 13242511136 0013067 dboption Node1 dboption Node2 dbstring Node2->Node1 param Node2->Node2 strnext freetds-1.00.82/doc/reference/a00893.html100644 025423 025423 00000010663 13242511136 0013247 FreeTDS API: dboption Struct Reference
    FreeTDS API
    dboption Struct Reference
    Collaboration diagram for dboption:
    [legend]

    Public Attributes

    DBBOOL factive
     
    DBSTRINGparam
     
    const char * text
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00894.html100644 025423 025423 00000006306 13242511133 0013244 FreeTDS API: Member List
    FreeTDS API
    _null_representation Member List

    This is the complete list of members for _null_representation, including all inherited members.

    bindval (defined in _null_representation)_null_representation
    len (defined in _null_representation)_null_representation
    freetds-1.00.82/doc/reference/a00897.html100644 025423 025423 00000007273 13242511133 0013253 FreeTDS API: _null_representation Struct Reference
    FreeTDS API
    _null_representation Struct Reference

    Public Attributes

    const BYTE * bindval
     
    size_t len
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00898.html100644 025423 025423 00000023267 13242511133 0013255 FreeTDS API: Member List
    FreeTDS API
    tds_dblib_dbprocess Member List

    This is the complete list of members for tds_dblib_dbprocess, including all inherited members.

    avail_flag (defined in tds_dblib_dbprocess)tds_dblib_dbprocess
    bcpinfo (defined in tds_dblib_dbprocess)tds_dblib_dbprocess
    chkintr (defined in tds_dblib_dbprocess)tds_dblib_dbprocess
    command_state (defined in tds_dblib_dbprocess)tds_dblib_dbprocess
    dbbuf (defined in tds_dblib_dbprocess)tds_dblib_dbprocess
    dbbufsz (defined in tds_dblib_dbprocess)tds_dblib_dbprocess
    dbcurdb (defined in tds_dblib_dbprocess)tds_dblib_dbprocess
    dboptcmd (defined in tds_dblib_dbprocess)tds_dblib_dbprocess
    dbopts (defined in tds_dblib_dbprocess)tds_dblib_dbprocess
    dbresults_retcode (defined in tds_dblib_dbprocess)tds_dblib_dbprocess
    dbresults_state (defined in tds_dblib_dbprocess)tds_dblib_dbprocess
    envchange_rcv (defined in tds_dblib_dbprocess)tds_dblib_dbprocess
    ftos (defined in tds_dblib_dbprocess)tds_dblib_dbprocess
    hndlintr (defined in tds_dblib_dbprocess)tds_dblib_dbprocess
    hostfileinfo (defined in tds_dblib_dbprocess)tds_dblib_dbprocess
    more_results (defined in tds_dblib_dbprocess)tds_dblib_dbprocess
    msdblibtds_dblib_dbprocess
    noautofree (defined in tds_dblib_dbprocess)tds_dblib_dbprocess
    ntimeouts (defined in tds_dblib_dbprocess)tds_dblib_dbprocess
    nullrepstds_dblib_dbprocess
    row_buf (defined in tds_dblib_dbprocess)tds_dblib_dbprocess
    row_type (defined in tds_dblib_dbprocess)tds_dblib_dbprocess
    rpc (defined in tds_dblib_dbprocess)tds_dblib_dbprocess
    servcharset (defined in tds_dblib_dbprocess)tds_dblib_dbprocess
    tds_socket (defined in tds_dblib_dbprocess)tds_dblib_dbprocess
    text_sent (defined in tds_dblib_dbprocess)tds_dblib_dbprocess
    text_size (defined in tds_dblib_dbprocess)tds_dblib_dbprocess
    typeinfo (defined in tds_dblib_dbprocess)tds_dblib_dbprocess
    user_data (defined in tds_dblib_dbprocess)tds_dblib_dbprocess
    freetds-1.00.82/doc/reference/a00899.map100644 025423 025423 00000003122 13242511136 0013056 freetds-1.00.82/doc/reference/a00899.md5100644 025423 025423 00000000040 13242511133 0012757c023ebf1f81da899c6652507621e4f58freetds-1.00.82/doc/reference/a00899.svg100644 025423 025423 00000041517 13242511136 0013112 tds_dblib_dbprocess Node1 tds_dblib_dbprocess Node2 tag_DBPROC_ROWBUF Node2->Node1 row_buf Node3 dblib_buffer_row Node3->Node2 rows Node4 tds_result_info Node4->Node3 resinfo Node5 tds_socket Node4->Node5 param_info current_results res_info comp_info Node31 tds_bcpinfo Node4->Node31 bindinfo Node5->Node1 tds_socket Node5->Node4 attached_to Node27 BCP_HOSTFILEINFO Node27->Node1 hostfileinfo Node28 BCP_HOSTCOLINFO Node28->Node27 host_columns Node29 _DBREMOTE_PROC Node29->Node1 rpc Node29->Node29 next Node30 _DBREMOTE_PROC_PARAM Node30->Node29 param_list Node30->Node30 next Node31->Node1 bcpinfo Node9 tds_dstr Node9->Node31 tablename Node32 dbstring Node32->Node1 dboptcmd Node32->Node32 strnext Node33 dboption Node32->Node33 param Node33->Node1 dbopts Node34 _null_representation Node34->Node1 nullreps Node35 dbtypeinfo Node35->Node1 typeinfo freetds-1.00.82/doc/reference/a00901.html100644 025423 025423 00000034142 13242511136 0013233 FreeTDS API: tds_dblib_dbprocess Struct Reference
    FreeTDS API
    tds_dblib_dbprocess Struct Reference
    Collaboration diagram for tds_dblib_dbprocess:
    [legend]

    Public Attributes

    unsigned char avail_flag
     
    TDSBCPINFObcpinfo
     
    DB_DBCHKINTR_FUNC chkintr
     
    int command_state
     
    unsigned char * dbbuf
     
    int dbbufsz
     
    char dbcurdb [DBMAXNAME+1]
     
    DBSTRINGdboptcmd
     
    DBOPTIONdbopts
     
    int dbresults_retcode
     
    DB_RESULT_STATE dbresults_state
     
    DBUSMALLINT envchange_rcv
     
    FILE * ftos
     
    DB_DBHNDLINTR_FUNC hndlintr
     
    BCP_HOSTFILEINFOhostfileinfo
     
    int more_results
     
    int msdblib
     boolean use ms behaviour
     
    int noautofree
     
    int ntimeouts
     
    NULLREP nullreps [MAXBINDTYPES]
     default null values
     
    DBPROC_ROWBUF row_buf
     
    STATUS row_type
     
    DBREMOTE_PROCrpc
     
    char servcharset [DBMAXNAME+1]
     
    TDSSOCKETtds_socket
     
    TDS_INT text_sent
     
    TDS_INT text_size
     
    DBTYPEINFO typeinfo
     
    BYTE * user_data
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00902.html100644 025423 025423 00000007051 13242511133 0013230 FreeTDS API: Member List
    FreeTDS API
    des_key Member List

    This is the complete list of members for des_key, including all inherited members.

    fperm (defined in des_key)des_key
    iperm (defined in des_key)des_key
    kn (defined in des_key)des_key
    sp (defined in des_key)des_key
    freetds-1.00.82/doc/reference/a00905.html100644 025423 025423 00000010600 13242511133 0013225 FreeTDS API: des_key Struct Reference
    FreeTDS API
    des_key Struct Reference

    Public Attributes

    unsigned char fperm [16][16][8]
     
    unsigned char iperm [16][16][8]
     
    unsigned char kn [16][8]
     
    TDS_UINT sp [8][64]
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00906.html100644 025423 025423 00000006602 13242511133 0013235 FreeTDS API: Member List
    FreeTDS API
    TDS_MAY_ALIAS Member List

    This is the complete list of members for TDS_MAY_ALIAS, including all inherited members.

    uc (defined in TDS_MAY_ALIAS)TDS_MAY_ALIAS
    ui (defined in TDS_MAY_ALIAS)TDS_MAY_ALIAS
    usi (defined in TDS_MAY_ALIAS)TDS_MAY_ALIAS
    freetds-1.00.82/doc/reference/a00909.html100644 025423 025423 00000010013 13242511133 0013227 FreeTDS API: TDS_MAY_ALIAS Union Reference
    FreeTDS API
    TDS_MAY_ALIAS Union Reference

    Public Attributes

    TDS_UCHAR uc [2]
     
    TDS_UINT ui
     
    TDS_USMALLINT usi
     

    The documentation for this union was generated from the following file:
    freetds-1.00.82/doc/reference/a00910.html100644 025423 025423 00000017744 13242511133 0013241 FreeTDS API: Member List
    FreeTDS API
    conv_result Member List

    This is the complete list of members for conv_result, including all inherited members.

    bi (defined in conv_result)conv_result
    bigdatetime (defined in conv_result)conv_result
    bigtime (defined in conv_result)conv_result
    c (defined in conv_result)conv_result
    cb (defined in conv_result)conv_result
    cc (defined in conv_result)conv_result
    date (defined in conv_result)conv_result
    dt (defined in conv_result)conv_result
    dt4 (defined in conv_result)conv_result
    dta (defined in conv_result)conv_result
    f (defined in conv_result)conv_result
    i (defined in conv_result)conv_result
    ib (defined in conv_result)conv_result
    m (defined in conv_result)conv_result
    m4 (defined in conv_result)conv_result
    n (defined in conv_result)conv_result
    r (defined in conv_result)conv_result
    si (defined in conv_result)conv_result
    ti (defined in conv_result)conv_result
    time (defined in conv_result)conv_result
    u (defined in conv_result)conv_result
    ubi (defined in conv_result)conv_result
    ui (defined in conv_result)conv_result
    usi (defined in conv_result)conv_result
    freetds-1.00.82/doc/reference/a00911.map100644 025423 025423 00000002227 13242511135 0013043 freetds-1.00.82/doc/reference/a00911.md5100644 025423 025423 00000000040 13242511133 00127405b6a8f928a230310051f5a52e368c059freetds-1.00.82/doc/reference/a00911.svg100644 025423 025423 00000022777 13242511136 0013102 conv_result Node1 conv_result Node2 TDS_DATETIMEALL Node2->Node1 dta Node3 conv_result::cc_t Node3->Node1 cc Node4 conv_result::cb_t Node4->Node1 cb Node5 tdsunique Node5->Node1 u Node6 tdsdatetime Node6->Node1 dt Node7 tdsmoney Node7->Node1 m Node8 tdsoldmoney Node8->Node7 tdsoldmoney Node9 tdsnumeric Node9->Node1 n Node10 tdsmoney4 Node10->Node1 m4 Node11 tdsdatetime4 Node11->Node1 dt4 freetds-1.00.82/doc/reference/a00913.html100644 025423 025423 00000031027 13242511136 0013235 FreeTDS API: conv_result Union Reference
    FreeTDS API
    conv_result Union Reference
    Collaboration diagram for conv_result:
    [legend]

    Classes

    struct  cb_t
     
    struct  cc_t
     

    Public Attributes

    TDS_INT8 bi
     
    TDS_BIGDATETIME bigdatetime
     
    TDS_BIGTIME bigtime
     
    TDS_CHAR * c
     
    struct conv_result::cb_t cb
     
    struct conv_result::cc_t cc
     
    TDS_DATE date
     
    TDS_DATETIME dt
     
    TDS_DATETIME4 dt4
     
    TDS_DATETIMEALL dta
     
    TDS_FLOAT f
     
    TDS_INT i
     
    TDS_CHAR * ib
     
    TDS_MONEY m
     
    TDS_MONEY4 m4
     
    TDS_NUMERIC n
     
    TDS_REAL r
     
    TDS_SMALLINT si
     
    TDS_TINYINT ti
     
    TDS_TIME time
     
    TDS_UNIQUE u
     
    TDS_UINT8 ubi
     
    TDS_UINT ui
     
    TDS_USMALLINT usi
     

    The documentation for this union was generated from the following file:
    freetds-1.00.82/doc/reference/a00914.html100644 025423 025423 00000006563 13242511133 0013242 FreeTDS API: Member List
    FreeTDS API
    conv_result::cc_t Member List

    This is the complete list of members for conv_result::cc_t, including all inherited members.

    c (defined in conv_result::cc_t)conv_result::cc_t
    len (defined in conv_result::cc_t)conv_result::cc_t
    freetds-1.00.82/doc/reference/a00917.html100644 025423 025423 00000007576 13242511133 0013252 FreeTDS API: conv_result::cc_t Struct Reference
    FreeTDS API
    conv_result::cc_t Struct Reference

    Public Attributes

    TDS_CHAR * c
     
    TDS_UINT len
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00918.html100644 025423 025423 00000006564 13242511133 0013247 FreeTDS API: Member List
    FreeTDS API
    conv_result::cb_t Member List

    This is the complete list of members for conv_result::cb_t, including all inherited members.

    ib (defined in conv_result::cb_t)conv_result::cb_t
    len (defined in conv_result::cb_t)conv_result::cb_t
    freetds-1.00.82/doc/reference/a00921.html100644 025423 025423 00000007577 13242511133 0013246 FreeTDS API: conv_result::cb_t Struct Reference
    FreeTDS API
    conv_result::cb_t Struct Reference

    Public Attributes

    TDS_CHAR * ib
     
    TDS_UINT len
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00922.html100644 025423 025423 00000006210 13242511133 0013226 FreeTDS API: Member List
    FreeTDS API
    dlist_ring Member List

    This is the complete list of members for dlist_ring, including all inherited members.

    next (defined in dlist_ring)dlist_ring
    prev (defined in dlist_ring)dlist_ring
    freetds-1.00.82/doc/reference/a00923.map100644 025423 025423 00000000057 13242511135 0013045 freetds-1.00.82/doc/reference/a00923.md5100644 025423 025423 00000000040 13242511133 0012743259a95f313e0f8334f323b33d1fe04f4freetds-1.00.82/doc/reference/a00923.svg100644 025423 025423 00000002656 13242511136 0013077 dlist_ring Node1 dlist_ring Node1->Node1 prev next freetds-1.00.82/doc/reference/a00925.html100644 025423 025423 00000010233 13242511136 0013234 FreeTDS API: dlist_ring Struct Reference
    FreeTDS API
    dlist_ring Struct Reference
    Collaboration diagram for dlist_ring:
    [legend]

    Public Attributes

    struct dlist_ringnext
     
    struct dlist_ringprev
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00926.html100644 025423 025423 00000005702 13242511133 0013237 FreeTDS API: Member List
    FreeTDS API
    DLIST_LIST_TYPE Member List

    This is the complete list of members for DLIST_LIST_TYPE, including all inherited members.

    ring (defined in DLIST_LIST_TYPE)DLIST_LIST_TYPE
    freetds-1.00.82/doc/reference/a00927.map100644 025423 025423 00000000234 13242511135 0013046 freetds-1.00.82/doc/reference/a00927.md5100644 025423 025423 00000000040 13242511133 0012747a3c6b02b7eb7045984d27d7b43f1a177freetds-1.00.82/doc/reference/a00927.svg100644 025423 025423 00000004374 13242511136 0013102 DLIST_LIST_TYPE Node1 DLIST_LIST_TYPE Node2 dlist_ring Node2->Node1 ring Node2->Node2 prev next freetds-1.00.82/doc/reference/a00929.html100644 025423 025423 00000007437 13242511136 0013254 FreeTDS API: DLIST_LIST_TYPE Struct Reference
    FreeTDS API
    DLIST_LIST_TYPE Struct Reference
    Collaboration diagram for DLIST_LIST_TYPE:
    [legend]

    Public Attributes

    dlist_ring ring
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00930.html100644 025423 025423 00000006310 13242511133 0013226 FreeTDS API: Member List
    FreeTDS API
    _character_set_alias Member List

    This is the complete list of members for _character_set_alias, including all inherited members.

    alias (defined in _character_set_alias)_character_set_alias
    canonic (defined in _character_set_alias)_character_set_alias
    freetds-1.00.82/doc/reference/a00933.html100644 025423 025423 00000007302 13242511133 0013233 FreeTDS API: _character_set_alias Struct Reference
    FreeTDS API
    _character_set_alias Struct Reference

    Public Attributes

    const char * alias
     
    int canonic
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00934.html100644 025423 025423 00000006734 13242511133 0013244 FreeTDS API: Member List
    FreeTDS API
    tds_errno_message_flags Member List

    This is the complete list of members for tds_errno_message_flags, including all inherited members.

    e2big (defined in tds_errno_message_flags)tds_errno_message_flags
    eilseq (defined in tds_errno_message_flags)tds_errno_message_flags
    einval (defined in tds_errno_message_flags)tds_errno_message_flags
    freetds-1.00.82/doc/reference/a00937.html100644 025423 025423 00000010064 13242511133 0013236 FreeTDS API: tds_errno_message_flags Struct Reference
    FreeTDS API
    tds_errno_message_flags Struct Reference

    Public Attributes

    unsigned int e2big:1
     
    unsigned int eilseq:1
     
    unsigned int einval:1
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00938.html100644 025423 025423 00000006217 13242511133 0013244 FreeTDS API: Member List
    FreeTDS API
    tdsiconvdir Member List

    This is the complete list of members for tdsiconvdir, including all inherited members.

    cd (defined in tdsiconvdir)tdsiconvdir
    charset (defined in tdsiconvdir)tdsiconvdir
    freetds-1.00.82/doc/reference/a00939.map100644 025423 025423 00000000253 13242511136 0013053 freetds-1.00.82/doc/reference/a00939.md5100644 025423 025423 00000000040 13242511133 0012752f1646520cd5311ce1ee5097d12acdfc4freetds-1.00.82/doc/reference/a00939.svg100644 025423 025423 00000003236 13242511136 0013101 tdsiconvdir Node1 tdsiconvdir Node2 tds_encoding Node2->Node1 charset freetds-1.00.82/doc/reference/a00941.html100644 025423 025423 00000010212 13242511136 0013227 FreeTDS API: tdsiconvdir Struct Reference
    FreeTDS API
    tdsiconvdir Struct Reference
    Collaboration diagram for tdsiconvdir:
    [legend]

    Public Attributes

    iconv_t cd
     
    TDS_ENCODING charset
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00942.html100644 025423 025423 00000006604 13242511133 0013237 FreeTDS API: Member List
    FreeTDS API
    tdsiconvinfo Member List

    This is the complete list of members for tdsiconvinfo, including all inherited members.

    flags (defined in tdsiconvinfo)tdsiconvinfo
    from (defined in tdsiconvinfo)tdsiconvinfo
    suppress (defined in tdsiconvinfo)tdsiconvinfo
    freetds-1.00.82/doc/reference/a00943.map100644 025423 025423 00000000607 13242511136 0013051 freetds-1.00.82/doc/reference/a00943.md5100644 025423 025423 00000000040 13242511133 001274571e750239d776b7a3cda26c7e86ade56freetds-1.00.82/doc/reference/a00943.svg100644 025423 025423 00000006620 13242511136 0013074 tdsiconvinfo Node1 tdsiconvinfo Node2 tds_errno_message_flags Node2->Node1 suppress Node3 tdsiconvdir Node3->Node1 from Node4 tds_encoding Node4->Node3 charset freetds-1.00.82/doc/reference/a00945.html100644 025423 025423 00000011011 13242511136 0013231 FreeTDS API: tdsiconvinfo Struct Reference
    FreeTDS API
    tdsiconvinfo Struct Reference
    Collaboration diagram for tdsiconvinfo:
    [legend]

    Public Attributes

    unsigned int flags
     
    struct tdsiconvdir to from
     
    TDS_ERRNO_MESSAGE_FLAGS suppress
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00946.html100644 025423 025423 00000010730 13242511133 0013236 FreeTDS API: Member List
    FreeTDS API
    _sql_error Member List

    This is the complete list of members for _sql_error, including all inherited members.

    linenum (defined in _sql_error)_sql_error
    msg (defined in _sql_error)_sql_error
    msgstate (defined in _sql_error)_sql_error
    native (defined in _sql_error)_sql_error
    row (defined in _sql_error)_sql_error
    server (defined in _sql_error)_sql_error
    state2 (defined in _sql_error)_sql_error
    state3 (defined in _sql_error)_sql_error
    freetds-1.00.82/doc/reference/a00949.html100644 025423 025423 00000013272 13242511133 0013245 FreeTDS API: _sql_error Struct Reference
    FreeTDS API
    _sql_error Struct Reference

    Public Attributes

    int linenum
     
    const char * msg
     
    int msgstate
     
    TDS_UINT native
     
    int row
     
    char * server
     
    char state2 [6]
     
    char state3 [6]
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00950.html100644 025423 025423 00000007135 13242511133 0013236 FreeTDS API: Member List
    FreeTDS API
    _sql_errors Member List

    This is the complete list of members for _sql_errors, including all inherited members.

    errs (defined in _sql_errors)_sql_errors
    lastrc (defined in _sql_errors)_sql_errors
    num_errors (defined in _sql_errors)_sql_errors
    ranked (defined in _sql_errors)_sql_errors
    freetds-1.00.82/doc/reference/a00951.map100644 025423 025423 00000000222 13242511135 0013040 freetds-1.00.82/doc/reference/a00951.md5100644 025423 025423 00000000040 13242511133 001274414a6ef116a6503da7e06f13d7da59ba1freetds-1.00.82/doc/reference/a00951.svg100644 025423 025423 00000003217 13242511136 0013072 _sql_errors Node1 _sql_errors Node2 _sql_error Node2->Node1 errs freetds-1.00.82/doc/reference/a00953.html100644 025423 025423 00000011440 13242511136 0013236 FreeTDS API: _sql_errors Struct Reference
    FreeTDS API
    _sql_errors Struct Reference
    Collaboration diagram for _sql_errors:
    [legend]

    Public Attributes

    struct _sql_errorerrs
     
    SQLRETURN lastrc
     
    int num_errors
     
    char ranked
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00954.html100644 025423 025423 00000010507 13242511133 0013237 FreeTDS API: Member List
    FreeTDS API
    _dheader Member List

    This is the complete list of members for _dheader, including all inherited members.

    sql_desc_alloc_type (defined in _dheader)_dheader
    sql_desc_array_size (defined in _dheader)_dheader
    sql_desc_array_status_ptr (defined in _dheader)_dheader
    sql_desc_bind_offset_ptr (defined in _dheader)_dheader
    sql_desc_bind_type (defined in _dheader)_dheader
    sql_desc_count (defined in _dheader)_dheader
    sql_desc_rows_processed_ptr (defined in _dheader)_dheader
    freetds-1.00.82/doc/reference/a00957.html100644 025423 025423 00000012742 13242511133 0013245 FreeTDS API: _dheader Struct Reference
    FreeTDS API
    _dheader Struct Reference

    Public Attributes

    SQLSMALLINT sql_desc_alloc_type
     
    SQLULEN sql_desc_array_size
     
    SQLUSMALLINT * sql_desc_array_status_ptr
     
    SQLLEN * sql_desc_bind_offset_ptr
     
    SQLINTEGER sql_desc_bind_type
     
    SQLSMALLINT sql_desc_count
     
    SQLULEN * sql_desc_rows_processed_ptr
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00958.html100644 025423 025423 00000025100 13242511133 0013236 FreeTDS API: Member List
    FreeTDS API
    _drecord Member List

    This is the complete list of members for _drecord, including all inherited members.

    sql_desc_auto_unique_value (defined in _drecord)_drecord
    sql_desc_base_column_name (defined in _drecord)_drecord
    sql_desc_base_table_name (defined in _drecord)_drecord
    sql_desc_case_sensitive (defined in _drecord)_drecord
    sql_desc_catalog_name (defined in _drecord)_drecord
    sql_desc_concise_type (defined in _drecord)_drecord
    sql_desc_data_ptr (defined in _drecord)_drecord
    sql_desc_datetime_interval_code (defined in _drecord)_drecord
    sql_desc_datetime_interval_precision (defined in _drecord)_drecord
    sql_desc_display_size (defined in _drecord)_drecord
    sql_desc_fixed_prec_scale (defined in _drecord)_drecord
    sql_desc_indicator_ptr (defined in _drecord)_drecord
    sql_desc_label (defined in _drecord)_drecord
    sql_desc_length (defined in _drecord)_drecord
    sql_desc_literal_prefix (defined in _drecord)_drecord
    sql_desc_literal_suffix (defined in _drecord)_drecord
    sql_desc_local_type_name (defined in _drecord)_drecord
    sql_desc_name (defined in _drecord)_drecord
    sql_desc_nullable (defined in _drecord)_drecord
    sql_desc_num_prec_radix (defined in _drecord)_drecord
    sql_desc_octet_length (defined in _drecord)_drecord
    sql_desc_octet_length_ptr (defined in _drecord)_drecord
    sql_desc_parameter_type (defined in _drecord)_drecord
    sql_desc_precision (defined in _drecord)_drecord
    sql_desc_rowver (defined in _drecord)_drecord
    sql_desc_scale (defined in _drecord)_drecord
    sql_desc_schema_name (defined in _drecord)_drecord
    sql_desc_searchable (defined in _drecord)_drecord
    sql_desc_table_name (defined in _drecord)_drecord
    sql_desc_type (defined in _drecord)_drecord
    sql_desc_type_name (defined in _drecord)_drecord
    sql_desc_unnamed (defined in _drecord)_drecord
    sql_desc_unsigned (defined in _drecord)_drecord
    sql_desc_updatable (defined in _drecord)_drecord
    freetds-1.00.82/doc/reference/a00959.map100644 025423 025423 00000000236 13242511135 0013055 freetds-1.00.82/doc/reference/a00959.md5100644 025423 025423 00000000040 13242511133 0012754afde9b8362b31655492e5a69dea9cae8freetds-1.00.82/doc/reference/a00959.svg100644 025423 025423 00000006043 13242511136 0013102 _drecord Node1 _drecord Node2 tds_dstr Node2->Node1 sql_desc_schema_name sql_desc_name sql_desc_base_column _name sql_desc_base_table _name sql_desc_catalog _name sql_desc_table _name sql_desc_label sql_desc_local _type_name freetds-1.00.82/doc/reference/a00961.html100644 025423 025423 00000037672 13242511136 0013254 FreeTDS API: _drecord Struct Reference
    FreeTDS API
    _drecord Struct Reference
    Collaboration diagram for _drecord:
    [legend]

    Public Attributes

    SQLUINTEGER sql_desc_auto_unique_value
     
    DSTR sql_desc_base_column_name
     
    DSTR sql_desc_base_table_name
     
    SQLINTEGER sql_desc_case_sensitive
     
    DSTR sql_desc_catalog_name
     
    SQLSMALLINT sql_desc_concise_type
     
    SQLPOINTER sql_desc_data_ptr
     
    SQLSMALLINT sql_desc_datetime_interval_code
     
    SQLINTEGER sql_desc_datetime_interval_precision
     
    SQLLEN sql_desc_display_size
     
    SQLSMALLINT sql_desc_fixed_prec_scale
     
    SQLLEN * sql_desc_indicator_ptr
     
    DSTR sql_desc_label
     
    SQLULEN sql_desc_length
     
    const char * sql_desc_literal_prefix
     
    const char * sql_desc_literal_suffix
     
    DSTR sql_desc_local_type_name
     
    DSTR sql_desc_name
     
    SQLSMALLINT sql_desc_nullable
     
    SQLINTEGER sql_desc_num_prec_radix
     
    SQLLEN sql_desc_octet_length
     
    SQLLEN * sql_desc_octet_length_ptr
     
    SQLSMALLINT sql_desc_parameter_type
     
    SQLSMALLINT sql_desc_precision
     
    SQLSMALLINT sql_desc_rowver
     
    SQLSMALLINT sql_desc_scale
     
    DSTR sql_desc_schema_name
     
    SQLSMALLINT sql_desc_searchable
     
    DSTR sql_desc_table_name
     
    SQLSMALLINT sql_desc_type
     
    const char * sql_desc_type_name
     
    SQLSMALLINT sql_desc_unnamed
     
    SQLSMALLINT sql_desc_unsigned
     
    SQLSMALLINT sql_desc_updatable
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00962.html100644 025423 025423 00000010270 13242511133 0013233 FreeTDS API: Member List
    FreeTDS API
    _hdesc Member List

    This is the complete list of members for _hdesc, including all inherited members.

    errs (defined in _hdesc)_hdesc
    header (defined in _hdesc)_hdesc
    htype (defined in _hdesc)_hdesc
    mtx (defined in _hdesc)_hdesc
    parent (defined in _hdesc)_hdesc
    records (defined in _hdesc)_hdesc
    type (defined in _hdesc)_hdesc
    freetds-1.00.82/doc/reference/a00963.map100644 025423 025423 00000001057 13242511135 0013052 freetds-1.00.82/doc/reference/a00963.md5100644 025423 025423 00000000040 13242511133 0012747741f20e610420569ee587d437b2a0521freetds-1.00.82/doc/reference/a00963.svg100644 025423 025423 00000014716 13242511136 0013103 _hdesc Node1 _hdesc Node2 _dheader Node2->Node1 header Node3 _drecord Node3->Node1 records Node4 tds_dstr Node4->Node3 sql_desc_schema_name sql_desc_name sql_desc_base_column _name sql_desc_base_table _name sql_desc_catalog _name sql_desc_table _name sql_desc_label sql_desc_local _type_name Node5 _sql_errors Node5->Node1 errs Node6 _sql_error Node6->Node5 errs freetds-1.00.82/doc/reference/a00965.html100644 025423 025423 00000013567 13242511136 0013255 FreeTDS API: _hdesc Struct Reference
    FreeTDS API
    _hdesc Struct Reference
    Collaboration diagram for _hdesc:
    [legend]

    Public Attributes

    struct _sql_errors errs
     
    struct _dheader header
     
    SQLSMALLINT htype
     
    tds_mutex mtx
     
    SQLHANDLE parent
     
    struct _drecordrecords
     
    int type
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00966.html100644 025423 025423 00000007113 13242511133 0013241 FreeTDS API: Member List
    FreeTDS API
    _heattr Member List

    This is the complete list of members for _heattr, including all inherited members.

    connection_pooling (defined in _heattr)_heattr
    cp_match (defined in _heattr)_heattr
    odbc_version (defined in _heattr)_heattr
    output_nts (defined in _heattr)_heattr
    freetds-1.00.82/doc/reference/a00969.html100644 025423 025423 00000010576 13242511133 0013253 FreeTDS API: _heattr Struct Reference
    FreeTDS API
    _heattr Struct Reference

    Public Attributes

    SQLUINTEGER connection_pooling
     
    SQLUINTEGER cp_match
     
    SQLINTEGER odbc_version
     
    SQLINTEGER output_nts
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00970.html100644 025423 025423 00000006507 13242511133 0013242 FreeTDS API: Member List
    FreeTDS API
    _hchk Member List

    This is the complete list of members for _hchk, including all inherited members.

    errs (defined in _hchk)_hchk
    htype (defined in _hchk)_hchk
    mtx (defined in _hchk)_hchk
    freetds-1.00.82/doc/reference/a00971.map100644 025423 025423 00000000353 13242511135 0013047 freetds-1.00.82/doc/reference/a00971.md5100644 025423 025423 00000000040 13242511133 00127463dba63a98aec5bb182291ba529ca00b1freetds-1.00.82/doc/reference/a00971.svg100644 025423 025423 00000004672 13242511136 0013102 _hchk Node1 _hchk Node2 _sql_errors Node2->Node1 errs Node3 _sql_error Node3->Node2 errs freetds-1.00.82/doc/reference/a00973.html100644 025423 025423 00000010667 13242511136 0013252 FreeTDS API: _hchk Struct Reference
    FreeTDS API
    _hchk Struct Reference
    Collaboration diagram for _hchk:
    [legend]

    Public Attributes

    struct _sql_errors errs
     
    SQLSMALLINT htype
     
    tds_mutex mtx
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00974.html100644 025423 025423 00000007367 13242511133 0013253 FreeTDS API: Member List
    FreeTDS API
    _henv Member List

    This is the complete list of members for _henv, including all inherited members.

    attr (defined in _henv)_henv
    errs (defined in _henv)_henv
    htype (defined in _henv)_henv
    mtx (defined in _henv)_henv
    tds_ctx (defined in _henv)_henv
    freetds-1.00.82/doc/reference/a00975.map100644 025423 025423 00000001031 13242511135 0013045 freetds-1.00.82/doc/reference/a00975.md5100644 025423 025423 00000000040 13242511133 0012752a610896ae330fe346bbf72d2b11fc61cfreetds-1.00.82/doc/reference/a00975.svg100644 025423 025423 00000011653 13242511136 0013103 _henv Node1 _henv Node2 tds_context Node2->Node1 tds_ctx Node3 tds_locale Node3->Node2 locale Node4 _heattr Node4->Node1 attr Node5 _sql_errors Node5->Node1 errs Node6 _sql_error Node6->Node5 errs freetds-1.00.82/doc/reference/a00977.html100644 025423 025423 00000012276 13242511136 0013254 FreeTDS API: _henv Struct Reference
    FreeTDS API
    _henv Struct Reference
    Collaboration diagram for _henv:
    [legend]

    Public Attributes

    struct _heattr attr
     
    struct _sql_errors errs
     
    SQLSMALLINT htype
     
    tds_mutex mtx
     
    TDSCONTEXTtds_ctx
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00978.html100644 025423 025423 00000015265 13242511133 0013253 FreeTDS API: Member List
    FreeTDS API
    _hcattr Member List

    This is the complete list of members for _hcattr, including all inherited members.

    access_mode (defined in _hcattr)_hcattr
    async_enable (defined in _hcattr)_hcattr
    auto_ipd (defined in _hcattr)_hcattr
    autocommit (defined in _hcattr)_hcattr
    bulk_enabled (defined in _hcattr)_hcattr
    connection_dead (defined in _hcattr)_hcattr
    connection_timeout (defined in _hcattr)_hcattr
    current_catalog (defined in _hcattr)_hcattr
    cursor_type (defined in _hcattr)_hcattr
    login_timeout (defined in _hcattr)_hcattr
    mars_enabled (defined in _hcattr)_hcattr
    metadata_id (defined in _hcattr)_hcattr
    odbc_cursors (defined in _hcattr)_hcattr
    packet_size (defined in _hcattr)_hcattr
    quite_mode (defined in _hcattr)_hcattr
    translate_lib (defined in _hcattr)_hcattr
    translate_option (defined in _hcattr)_hcattr
    txn_isolation (defined in _hcattr)_hcattr
    freetds-1.00.82/doc/reference/a00979.map100644 025423 025423 00000000234 13242511135 0013055 freetds-1.00.82/doc/reference/a00979.md5100644 025423 025423 00000000040 13242511133 0012756718c998966cef78a98862a662e68c8d7freetds-1.00.82/doc/reference/a00979.svg100644 025423 025423 00000003454 13242511136 0013107 _hcattr Node1 _hcattr Node2 tds_dstr Node2->Node1 translate_lib current_catalog freetds-1.00.82/doc/reference/a00981.html100644 025423 025423 00000023373 13242511136 0013247 FreeTDS API: _hcattr Struct Reference
    FreeTDS API
    _hcattr Struct Reference
    Collaboration diagram for _hcattr:
    [legend]

    Public Attributes

    SQLUINTEGER access_mode
     
    SQLUINTEGER async_enable
     
    SQLUINTEGER auto_ipd
     
    SQLUINTEGER autocommit
     
    SQLUINTEGER bulk_enabled
     
    SQLUINTEGER connection_dead
     
    SQLUINTEGER connection_timeout
     
    DSTR current_catalog
     
    SQLUINTEGER cursor_type
     
    SQLUINTEGER login_timeout
     
    SQLUINTEGER mars_enabled
     
    SQLUINTEGER metadata_id
     
    SQLUINTEGER odbc_cursors
     
    SQLUINTEGER packet_size
     
    SQLHWND quite_mode
     
    DSTR translate_lib
     
    SQLUINTEGER translate_option
     
    SQLUINTEGER txn_isolation
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00982.html100644 025423 025423 00000014073 13242511133 0013242 FreeTDS API: Member List
    FreeTDS API
    _hdbc Member List

    This is the complete list of members for _hdbc, including all inherited members.

    attr (defined in _hdbc)_hdbc
    bcphint (defined in _hdbc)_hdbc
    bcpinfo (defined in _hdbc)_hdbc
    current_statement_hdbc
    cursor_support_hdbc
    default_query_timeout (defined in _hdbc)_hdbc
    dsn (defined in _hdbc)_hdbc
    env (defined in _hdbc)_hdbc
    errs (defined in _hdbc)_hdbc
    htype (defined in _hdbc)_hdbc
    mtx (defined in _hdbc)_hdbc
    oldpwd (defined in _hdbc)_hdbc
    stmt_list_hdbc
    tds_socket (defined in _hdbc)_hdbc
    uad_hdbc
    use_oldpwd (defined in _hdbc)_hdbc
    freetds-1.00.82/doc/reference/a00983.map100644 025423 025423 00000004134 13242511135 0013053 freetds-1.00.82/doc/reference/a00983.md5100644 025423 025423 00000000040 13242511133 0012751a8110be134b566e104c104043e0c0a15freetds-1.00.82/doc/reference/a00983.svg100644 025423 025423 00000106510 13242511136 0013077 _hdbc Node1 _hdbc Node2 _hstmt Node1->Node2 dbc Node2->Node1 stmt_list current_statement Node2->Node2 prev next Node3 tds_socket Node3->Node1 tds_socket Node3->Node2 tds Node10 tds_result_info Node3->Node10 attached_to Node4 tds_login Node4->Node3 login Node7 tds_dstr Node7->Node1 oldpwd dsn Node7->Node2 query cursor_name Node7->Node4 server_realm_name password server_name dump_file library crlfile server_spn client_host _name client_charset openssl_ciphers ... Node26 _hsattr Node7->Node26 qn_msgtext qn_options Node29 _drecord Node7->Node29 sql_desc_schema_name sql_desc_name sql_desc_base_column _name sql_desc_base_table _name sql_desc_catalog _name sql_desc_table _name sql_desc_label sql_desc_local _type_name Node32 tds_bcpinfo Node7->Node32 tablename Node33 _hcattr Node7->Node33 translate_lib current_catalog Node8 tds_packet Node8->Node3 recv_packet send_packet Node8->Node8 next Node9 tds_dynamic Node9->Node2 dyn Node9->Node3 cur_dyn Node9->Node9 next Node20 tds_connection Node9->Node20 dyns Node10->Node2 params Node10->Node3 param_info current_results res_info comp_info Node10->Node9 res_info params Node18 tds_cursor Node10->Node18 res_info Node10->Node32 bindinfo Node18->Node2 cursor Node18->Node3 cur_cursor Node18->Node18 next Node18->Node20 cursors Node20->Node3 conn Node23 tds_context Node23->Node20 tds_ctx Node34 _henv Node23->Node34 tds_ctx Node26->Node2 attr Node27 _hdesc Node27->Node1 uad Node27->Node2 apd orig_apd orig_ard ird ipd ard Node28 _dheader Node28->Node27 header Node29->Node27 records Node30 _sql_errors Node30->Node1 errs Node30->Node2 errs Node30->Node27 errs Node30->Node34 errs Node32->Node1 bcpinfo Node33->Node1 attr Node34->Node1 env Node35 _heattr Node35->Node34 attr freetds-1.00.82/doc/reference/a00985.html100644 025423 025423 00000025574 13242511136 0013260 FreeTDS API: _hdbc Struct Reference
    FreeTDS API
    _hdbc Struct Reference
    Collaboration diagram for _hdbc:
    [legend]

    Public Attributes

    struct _hcattr attr
     
    char * bcphint
     
    TDSBCPINFObcpinfo
     
    struct _hstmtcurrent_statement
     Statement executing. More...
     
    unsigned int cursor_support:1
     <>0 if server handle cursors
     
    TDS_INT default_query_timeout
     
    DSTR dsn
     
    struct _henvenv
     
    struct _sql_errors errs
     
    SQLSMALLINT htype
     
    tds_mutex mtx
     
    DSTR oldpwd
     
    struct _hstmtstmt_list
     list of all statements allocated from this connection
     
    TDSSOCKETtds_socket
     
    TDS_DESCuad [TDS_MAX_APP_DESC]
     descriptors associated to connection
     
    unsigned int use_oldpwd:1
     

    Member Data Documentation

    § current_statement

    struct _hstmt* _hdbc::current_statement

    Statement executing.

    This should be set AFTER sending query to avoid race condition and assure to not overwrite it if another statement is executing a query.


    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00986.html100644 025423 025423 00000016165 13242511133 0013252 FreeTDS API: Member List
    FreeTDS API
    _hsattr Member List

    This is the complete list of members for _hsattr, including all inherited members.

    async_enable (defined in _hsattr)_hsattr
    concurrency (defined in _hsattr)_hsattr
    cursor_scrollable (defined in _hsattr)_hsattr
    cursor_sensitivity (defined in _hsattr)_hsattr
    cursor_type (defined in _hsattr)_hsattr
    enable_auto_ipd (defined in _hsattr)_hsattr
    fetch_bookmark_ptr (defined in _hsattr)_hsattr
    keyset_size (defined in _hsattr)_hsattr
    max_length (defined in _hsattr)_hsattr
    max_rows (defined in _hsattr)_hsattr
    metadata_id (defined in _hsattr)_hsattr
    noscan (defined in _hsattr)_hsattr
    qn_msgtext (defined in _hsattr)_hsattr
    qn_options (defined in _hsattr)_hsattr
    qn_timeout (defined in _hsattr)_hsattr
    query_timeout (defined in _hsattr)_hsattr
    retrieve_data (defined in _hsattr)_hsattr
    row_number (defined in _hsattr)_hsattr
    simulate_cursor (defined in _hsattr)_hsattr
    use_bookmarks (defined in _hsattr)_hsattr
    freetds-1.00.82/doc/reference/a00987.map100644 025423 025423 00000000234 13242511135 0013054 freetds-1.00.82/doc/reference/a00987.md5100644 025423 025423 00000000040 13242511133 0012755b6db09d2af49aba0eb942c1ed562c41afreetds-1.00.82/doc/reference/a00987.svg100644 025423 025423 00000003440 13242511136 0013101 _hsattr Node1 _hsattr Node2 tds_dstr Node2->Node1 qn_msgtext qn_options freetds-1.00.82/doc/reference/a00989.html100644 025423 025423 00000024657 13242511136 0013265 FreeTDS API: _hsattr Struct Reference
    FreeTDS API
    _hsattr Struct Reference
    Collaboration diagram for _hsattr:
    [legend]

    Public Attributes

    SQLUINTEGER async_enable
     
    SQLUINTEGER concurrency
     
    SQLUINTEGER cursor_scrollable
     
    SQLUINTEGER cursor_sensitivity
     
    SQLUINTEGER cursor_type
     
    SQLUINTEGER enable_auto_ipd
     
    SQLPOINTER fetch_bookmark_ptr
     
    SQLULEN keyset_size
     
    SQLULEN max_length
     
    SQLULEN max_rows
     
    SQLUINTEGER metadata_id
     
    SQLUINTEGER noscan
     
    DSTR qn_msgtext
     
    DSTR qn_options
     
    SQLUINTEGER qn_timeout
     
    SQLUINTEGER query_timeout
     
    SQLUINTEGER retrieve_data
     
    SQLULEN row_number
     
    SQLUINTEGER simulate_cursor
     
    SQLUINTEGER use_bookmarks
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00990.html100644 025423 025423 00000023652 13242511133 0013244 FreeTDS API: Member List
    FreeTDS API
    _hstmt Member List

    This is the complete list of members for _hstmt, including all inherited members.

    apd (defined in _hstmt)_hstmt
    ard (defined in _hstmt)_hstmt
    attr (defined in _hstmt)_hstmt
    curr_param_row (defined in _hstmt)_hstmt
    cursor (defined in _hstmt)_hstmt
    cursor_name (defined in _hstmt)_hstmt
    dbc (defined in _hstmt)_hstmt
    dyn (defined in _hstmt)_hstmt
    errs (defined in _hstmt)_hstmt
    htype (defined in _hstmt)_hstmt
    ipd (defined in _hstmt)_hstmt
    ird (defined in _hstmt)_hstmt
    is_prepared_query (defined in _hstmt)_hstmt
    mtx (defined in _hstmt)_hstmt
    need_reprepare (defined in _hstmt)_hstmt
    next_hstmt
    num_param_rows (defined in _hstmt)_hstmt
    orig_apd (defined in _hstmt)_hstmt
    orig_ard (defined in _hstmt)_hstmt
    param_count_hstmt
    param_data_called (defined in _hstmt)_hstmt
    param_num_hstmt
    params_hstmt
    prepared_pos_hstmt
    prepared_query_is_func (defined in _hstmt)_hstmt
    prepared_query_is_rpc (defined in _hstmt)_hstmt
    prev_hstmt
    query_hstmt
    row (defined in _hstmt)_hstmt
    row_count_hstmt
    row_status_hstmt
    special_row (defined in _hstmt)_hstmt
    sql_rowset_size (defined in _hstmt)_hstmt
    tds_hstmt
    freetds-1.00.82/doc/reference/a00991.map100644 025423 025423 00000005445 13242511135 0013060 freetds-1.00.82/doc/reference/a00991.md5100644 025423 025423 00000000040 13242511133 0012750093a8a042e69996f9f9293c1a11b2b4bfreetds-1.00.82/doc/reference/a00991.svg100644 025423 025423 00000124532 13242511136 0013102 _hstmt Node1 _hstmt Node1->Node1 prev next Node25 _hdbc Node1->Node25 stmt_list current_statement Node2 tds_socket Node2->Node1 tds Node9 tds_result_info Node2->Node9 attached_to Node2->Node25 tds_socket Node3 tds_login Node3->Node2 login Node4 tds_capabilities Node4->Node3 capabilities Node19 tds_connection Node4->Node19 capabilities Node6 tds_dstr Node6->Node1 query cursor_name Node6->Node3 server_realm_name password server_name dump_file library crlfile server_spn client_host _name client_charset openssl_ciphers ... Node6->Node25 oldpwd dsn Node26 tds_bcpinfo Node6->Node26 tablename Node27 _hcattr Node6->Node27 translate_lib current_catalog Node30 _drecord Node6->Node30 sql_desc_schema_name sql_desc_name sql_desc_base_column _name sql_desc_base_table _name sql_desc_catalog _name sql_desc_table _name sql_desc_label sql_desc_local _type_name Node35 _hsattr Node6->Node35 qn_msgtext qn_options Node7 tds_packet Node7->Node2 recv_packet send_packet Node7->Node7 next Node8 tds_dynamic Node8->Node1 dyn Node8->Node2 cur_dyn Node8->Node8 next Node8->Node19 dyns Node9->Node1 params Node9->Node2 param_info current_results res_info comp_info Node9->Node8 res_info params Node17 tds_cursor Node9->Node17 res_info Node9->Node26 bindinfo Node17->Node1 cursor Node17->Node2 cur_cursor Node17->Node17 next Node17->Node19 cursors Node18 tds_cursor_status Node18->Node17 status Node19->Node2 conn Node20 tds_poll_wakeup Node20->Node19 wakeup Node21 tds_env Node21->Node19 env Node22 tds_context Node22->Node19 tds_ctx Node33 _henv Node22->Node33 tds_ctx Node24 tds_authentication Node24->Node19 authentication Node11 tdsiconvinfo Node11->Node19 char_convs Node25->Node1 dbc Node26->Node25 bcpinfo Node27->Node25 attr Node28 _hdesc Node28->Node1 apd orig_apd orig_ard ird ipd ard Node28->Node25 uad Node29 _dheader Node29->Node28 header Node30->Node28 records Node31 _sql_errors Node31->Node1 errs Node31->Node25 errs Node31->Node28 errs Node31->Node33 errs Node33->Node25 env Node34 _heattr Node34->Node33 attr Node35->Node1 attr freetds-1.00.82/doc/reference/a00993.html100644 025423 025423 00000044036 13242511136 0013251 FreeTDS API: _hstmt Struct Reference
    FreeTDS API
    _hstmt Struct Reference
    Collaboration diagram for _hstmt:
    [legend]

    Public Attributes

    TDS_DESCapd
     
    TDS_DESCard
     
    struct _hsattr attr
     
    unsigned int curr_param_row
     
    TDSCURSORcursor
     
    DSTR cursor_name
     
    struct _hdbcdbc
     
    TDSDYNAMICdyn
     
    struct _sql_errors errs
     
    SQLSMALLINT htype
     
    TDS_DESCipd
     
    TDS_DESCird
     
    unsigned is_prepared_query:1
     
    tds_mutex mtx
     
    unsigned need_reprepare:1
     
    struct _hstmtnext
     next in list
     
    unsigned int num_param_rows
     
    TDS_DESCorig_apd
     
    TDS_DESCorig_ard
     
    unsigned int param_count
     number of parameter in current query
     
    unsigned param_data_called:1
     
    int param_num
     last valid parameter in params, it's a ODBC index (from 1 relative to descriptor)
     
    TDSPARAMINFOparams
     parameters saved
     
    char * prepared_pos
     position in prepared query to check parameters, used only in RPC
     
    unsigned prepared_query_is_func:1
     
    unsigned prepared_query_is_rpc:1
     
    struct _hstmtprev
     previous in list
     
    DSTR query
     query to execute
     
    int row
     
    TDS_INT8 row_count
     row count to return
     
    TDS_ODBC_ROW_STATUS row_status
     status of row, it can happen that this flag mark that we are still parsing row, this it's normal
     
    TDS_ODBC_SPECIAL_ROWS special_row
     
    SQLULEN sql_rowset_size
     
    TDSSOCKETtds
     socket (only if active)
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00994.html100644 025423 025423 00000006215 13242511133 0013244 FreeTDS API: Member List
    FreeTDS API
    TDS_FUNCS Member List

    This is the complete list of members for TDS_FUNCS, including all inherited members.

    common (defined in TDS_FUNCS)TDS_FUNCS
    set_type_info (defined in TDS_FUNCS)TDS_FUNCS
    freetds-1.00.82/doc/reference/a00995.map100644 025423 025423 00000000225 13242511136 0013054 freetds-1.00.82/doc/reference/a00995.md5100644 025423 025423 00000000040 13242511133 0012754ada65ee94f72caca42f686f4ffa71045freetds-1.00.82/doc/reference/a00995.svg100644 025423 025423 00000003236 13242511136 0013103 TDS_FUNCS Node1 TDS_FUNCS Node2 tds_column_funcs Node2->Node1 common freetds-1.00.82/doc/reference/a00997.html100644 025423 025423 00000010364 13242511136 0013252 FreeTDS API: TDS_FUNCS Struct Reference
    FreeTDS API
    TDS_FUNCS Struct Reference
    Collaboration diagram for TDS_FUNCS:
    [legend]

    Public Attributes

    TDSCOLUMNFUNCS common
     
    void(* set_type_info )(TDSCOLUMN *col, struct _drecord *drec, SQLINTEGER odbc_ver)
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a00998.html100644 025423 025423 00000006250 13242511133 0013247 FreeTDS API: Member List
    FreeTDS API
    TDS_PARSED_PARAM Member List

    This is the complete list of members for TDS_PARSED_PARAM, including all inherited members.

    len (defined in TDS_PARSED_PARAM)TDS_PARSED_PARAM
    p (defined in TDS_PARSED_PARAM)TDS_PARSED_PARAM
    freetds-1.00.82/doc/reference/a01001.html100644 025423 025423 00000007264 13242511133 0013225 FreeTDS API: TDS_PARSED_PARAM Struct Reference
    FreeTDS API
    TDS_PARSED_PARAM Struct Reference

    Public Attributes

    size_t len
     
    const char * p
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01002.html100644 025423 025423 00000006566 13242511133 0013232 FreeTDS API: Member List
    FreeTDS API
    tdsnumeric Member List

    This is the complete list of members for tdsnumeric, including all inherited members.

    array (defined in tdsnumeric)tdsnumeric
    precision (defined in tdsnumeric)tdsnumeric
    scale (defined in tdsnumeric)tdsnumeric
    freetds-1.00.82/doc/reference/a01005.html100644 025423 025423 00000010036 13242511133 0013220 FreeTDS API: tdsnumeric Struct Reference
    FreeTDS API
    tdsnumeric Struct Reference

    Public Attributes

    unsigned char array [33]
     
    unsigned char precision
     
    unsigned char scale
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01006.html100644 025423 025423 00000006223 13242511133 0013224 FreeTDS API: Member List
    FreeTDS API
    tdsoldmoney Member List

    This is the complete list of members for tdsoldmoney, including all inherited members.

    mnyhigh (defined in tdsoldmoney)tdsoldmoney
    mnylow (defined in tdsoldmoney)tdsoldmoney
    freetds-1.00.82/doc/reference/a01009.html100644 025423 025423 00000007261 13242511133 0013232 FreeTDS API: tdsoldmoney Struct Reference
    FreeTDS API
    tdsoldmoney Struct Reference

    Public Attributes

    TDS_INT mnyhigh
     
    TDS_UINT mnylow
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01010.html100644 025423 025423 00000006202 13242511133 0013214 FreeTDS API: Member List
    FreeTDS API
    tdsmoney Member List

    This is the complete list of members for tdsmoney, including all inherited members.

    mny (defined in tdsmoney)tdsmoney
    tdsoldmoney (defined in tdsmoney)tdsmoney
    freetds-1.00.82/doc/reference/a01011.map100644 025423 025423 00000000216 13242511136 0013030 freetds-1.00.82/doc/reference/a01011.md5100644 025423 025423 00000000040 13242511133 00127308038da3ad1b18a0f0924167a3a52131ffreetds-1.00.82/doc/reference/a01011.svg100644 025423 025423 00000003241 13242511136 0013053 tdsmoney Node1 tdsmoney Node2 tdsoldmoney Node2->Node1 tdsoldmoney freetds-1.00.82/doc/reference/a01013.html100644 025423 025423 00000010143 13242511136 0013221 FreeTDS API: tdsmoney Union Reference
    FreeTDS API
    tdsmoney Union Reference
    Collaboration diagram for tdsmoney:
    [legend]

    Public Attributes

    TDS_INT8 mny
     
    TDS_OLD_MONEY tdsoldmoney
     

    The documentation for this union was generated from the following file:
    freetds-1.00.82/doc/reference/a01014.html100644 025423 025423 00000005652 13242511133 0013230 FreeTDS API: Member List
    FreeTDS API
    tdsmoney4 Member List

    This is the complete list of members for tdsmoney4, including all inherited members.

    mny4 (defined in tdsmoney4)tdsmoney4
    freetds-1.00.82/doc/reference/a01017.html100644 025423 025423 00000006520 13242511133 0013226 FreeTDS API: tdsmoney4 Struct Reference
    FreeTDS API
    tdsmoney4 Struct Reference

    Public Attributes

    TDS_INT mny4
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01018.html100644 025423 025423 00000006222 13242511133 0013226 FreeTDS API: Member List
    FreeTDS API
    tdsdatetime Member List

    This is the complete list of members for tdsdatetime, including all inherited members.

    dtdays (defined in tdsdatetime)tdsdatetime
    dttime (defined in tdsdatetime)tdsdatetime
    freetds-1.00.82/doc/reference/a01021.html100644 025423 025423 00000007257 13242511133 0013231 FreeTDS API: tdsdatetime Struct Reference
    FreeTDS API
    tdsdatetime Struct Reference

    Public Attributes

    TDS_INT dtdays
     
    TDS_INT dttime
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01022.html100644 025423 025423 00000006227 13242511133 0013226 FreeTDS API: Member List
    FreeTDS API
    tdsdatetime4 Member List

    This is the complete list of members for tdsdatetime4, including all inherited members.

    days (defined in tdsdatetime4)tdsdatetime4
    minutes (defined in tdsdatetime4)tdsdatetime4
    freetds-1.00.82/doc/reference/a01025.html100644 025423 025423 00000007274 13242511133 0013234 FreeTDS API: tdsdatetime4 Struct Reference
    FreeTDS API
    tdsdatetime4 Struct Reference

    Public Attributes

    TDS_USMALLINT days
     
    TDS_USMALLINT minutes
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01026.html100644 025423 025423 00000007103 13242511133 0013224 FreeTDS API: Member List
    FreeTDS API
    tdsunique Member List

    This is the complete list of members for tdsunique, including all inherited members.

    Data1 (defined in tdsunique)tdsunique
    Data2 (defined in tdsunique)tdsunique
    Data3 (defined in tdsunique)tdsunique
    Data4 (defined in tdsunique)tdsunique
    freetds-1.00.82/doc/reference/a01029.html100644 025423 025423 00000010554 13242511133 0013233 FreeTDS API: tdsunique Struct Reference
    FreeTDS API
    tdsunique Struct Reference

    Public Attributes

    TDS_UINT Data1
     
    TDS_USMALLINT Data2
     
    TDS_USMALLINT Data3
     
    TDS_UCHAR Data4 [8]
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01030.html100644 025423 025423 00000006643 13242511133 0013227 FreeTDS API: Member List
    FreeTDS API
    TDS71_COLLATION Member List

    This is the complete list of members for TDS71_COLLATION, including all inherited members.

    charset_id (defined in TDS71_COLLATION)TDS71_COLLATION
    flags (defined in TDS71_COLLATION)TDS71_COLLATION
    locale_id (defined in TDS71_COLLATION)TDS71_COLLATION
    freetds-1.00.82/doc/reference/a01033.html100644 025423 025423 00000010555 13242511133 0013227 FreeTDS API: TDS71_COLLATION Struct Reference
    FreeTDS API
    TDS71_COLLATION Struct Reference

    TDS 7.1 collation informations. More...

    #include <proto.h>

    Public Attributes

    TDS_UCHAR charset_id
     
    TDS_USMALLINT flags
     
    TDS_USMALLINT locale_id
     

    Detailed Description

    TDS 7.1 collation informations.


    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01034.html100644 025423 025423 00000010140 13242511133 0013216 FreeTDS API: Member List
    FreeTDS API
    TDS72_SMP_HEADER Member List

    This is the complete list of members for TDS72_SMP_HEADER, including all inherited members.

    seq (defined in TDS72_SMP_HEADER)TDS72_SMP_HEADER
    sid (defined in TDS72_SMP_HEADER)TDS72_SMP_HEADER
    signature (defined in TDS72_SMP_HEADER)TDS72_SMP_HEADER
    size (defined in TDS72_SMP_HEADER)TDS72_SMP_HEADER
    type (defined in TDS72_SMP_HEADER)TDS72_SMP_HEADER
    wnd (defined in TDS72_SMP_HEADER)TDS72_SMP_HEADER
    freetds-1.00.82/doc/reference/a01037.html100644 025423 025423 00000012537 13242511133 0013235 FreeTDS API: TDS72_SMP_HEADER Struct Reference
    FreeTDS API
    TDS72_SMP_HEADER Struct Reference

    TDS 7.2 SMP packet header. More...

    #include <proto.h>

    Public Attributes

    TDS_UINT seq
     
    TDS_USMALLINT sid
     
    TDS_UCHAR signature
     
    TDS_UINT size
     
    TDS_UCHAR type
     
    TDS_UINT wnd
     

    Detailed Description

    TDS 7.2 SMP packet header.


    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01038.html100644 025423 025423 00000005661 13242511133 0013236 FreeTDS API: Member List
    FreeTDS API
    tds_input_stream Member List

    This is the complete list of members for tds_input_stream, including all inherited members.

    readtds_input_stream
    freetds-1.00.82/doc/reference/a01041.html100644 025423 025423 00000010051 13242511133 0013215 FreeTDS API: tds_input_stream Struct Reference
    FreeTDS API
    tds_input_stream Struct Reference

    define a stream of data used for input More...

    #include <stream.h>

    Public Attributes

    int(* read )(struct tds_input_stream *stream, void *ptr, size_t len)
     read some data Return 0 if end of stream Return <0 if error (actually not defined)
     

    Detailed Description

    define a stream of data used for input


    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01042.html100644 025423 025423 00000006601 13242511133 0013224 FreeTDS API: Member List
    FreeTDS API
    tds_output_stream Member List

    This is the complete list of members for tds_output_stream, including all inherited members.

    buf_len (defined in tds_output_stream)tds_output_stream
    buffertds_output_stream
    writetds_output_stream
    freetds-1.00.82/doc/reference/a01045.html100644 025423 025423 00000013235 13242511133 0013230 FreeTDS API: tds_output_stream Struct Reference
    FreeTDS API
    tds_output_stream Struct Reference

    define a stream of data used for output More...

    #include <stream.h>

    Public Attributes

    size_t buf_len
     
    char * buffer
     write buffer. More...
     
    int(* write )(struct tds_output_stream *stream, size_t len)
     write len bytes from buffer, return <0 if error or len
     

    Detailed Description

    define a stream of data used for output

    Member Data Documentation

    § buffer

    char* tds_output_stream::buffer

    write buffer.

    client will write data into this buffer. not required that buffer is the result of any alloc function so buffer pointer can point in the middle of another buffer. client will write up to buf_len. client should not cache buffer and buf_len before a call to write as write can change these values.


    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01046.html100644 025423 025423 00000006627 13242511133 0013240 FreeTDS API: Member List
    FreeTDS API
    tds_datain_stream Member List

    This is the complete list of members for tds_datain_stream, including all inherited members.

    stream (defined in tds_datain_stream)tds_datain_stream
    tds (defined in tds_datain_stream)tds_datain_stream
    wire_sizetds_datain_stream
    freetds-1.00.82/doc/reference/a01047.map100644 025423 025423 00000003662 13242511136 0013051 freetds-1.00.82/doc/reference/a01047.md5100644 025423 025423 00000000040 13242511133 001274123d5220107cb74ef86f12e1a603ba1acfreetds-1.00.82/doc/reference/a01047.svg100644 025423 025423 00000052616 13242511136 0013076 tds_datain_stream Node1 tds_datain_stream Node2 tds_socket Node2->Node1 tds Node9 tds_result_info Node2->Node9 attached_to Node3 tds_login Node3->Node2 login Node4 tds_capabilities Node4->Node3 capabilities Node19 tds_connection Node4->Node19 capabilities Node6 tds_dstr Node6->Node3 server_realm_name password server_name dump_file library crlfile server_spn client_host _name client_charset openssl_ciphers ... Node7 tds_packet Node7->Node2 recv_packet send_packet Node7->Node7 next Node8 tds_dynamic Node8->Node2 cur_dyn Node8->Node8 next Node8->Node19 dyns Node9->Node2 param_info current_results res_info comp_info Node9->Node8 res_info params Node17 tds_cursor Node9->Node17 res_info Node17->Node2 cur_cursor Node17->Node17 next Node17->Node19 cursors Node18 tds_cursor_status Node18->Node17 status Node19->Node2 conn Node20 tds_poll_wakeup Node20->Node19 wakeup Node21 tds_env Node21->Node19 env Node22 tds_context Node22->Node19 tds_ctx Node24 tds_authentication Node24->Node19 authentication Node11 tdsiconvinfo Node11->Node19 char_convs Node25 tds_input_stream Node25->Node1 stream freetds-1.00.82/doc/reference/a01049.html100644 025423 025423 00000012064 13242511136 0013236 FreeTDS API: tds_datain_stream Struct Reference
    FreeTDS API
    tds_datain_stream Struct Reference

    input stream to read data from tds protocol More...

    #include <stream.h>

    Collaboration diagram for tds_datain_stream:
    [legend]

    Public Attributes

    TDSINSTREAM stream
     
    TDSSOCKETtds
     
    size_t wire_size
     bytes still to read
     

    Detailed Description

    input stream to read data from tds protocol


    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01050.html100644 025423 025423 00000006663 13242511133 0013233 FreeTDS API: Member List
    FreeTDS API
    tds_dataout_stream Member List

    This is the complete list of members for tds_dataout_stream, including all inherited members.

    stream (defined in tds_dataout_stream)tds_dataout_stream
    tds (defined in tds_dataout_stream)tds_dataout_stream
    written (defined in tds_dataout_stream)tds_dataout_stream
    freetds-1.00.82/doc/reference/a01051.map100644 025423 025423 00000003665 13242511136 0013047 freetds-1.00.82/doc/reference/a01051.md5100644 025423 025423 00000000040 13242511133 0012734aecf8d6dd113e04010b178c8a70b79f3freetds-1.00.82/doc/reference/a01051.svg100644 025423 025423 00000052622 13242511136 0013066 tds_dataout_stream Node1 tds_dataout_stream Node2 tds_socket Node2->Node1 tds Node9 tds_result_info Node2->Node9 attached_to Node3 tds_login Node3->Node2 login Node4 tds_capabilities Node4->Node3 capabilities Node19 tds_connection Node4->Node19 capabilities Node6 tds_dstr Node6->Node3 server_realm_name password server_name dump_file library crlfile server_spn client_host _name client_charset openssl_ciphers ... Node7 tds_packet Node7->Node2 recv_packet send_packet Node7->Node7 next Node8 tds_dynamic Node8->Node2 cur_dyn Node8->Node8 next Node8->Node19 dyns Node9->Node2 param_info current_results res_info comp_info Node9->Node8 res_info params Node17 tds_cursor Node9->Node17 res_info Node17->Node2 cur_cursor Node17->Node17 next Node17->Node19 cursors Node18 tds_cursor_status Node18->Node17 status Node19->Node2 conn Node20 tds_poll_wakeup Node20->Node19 wakeup Node21 tds_env Node21->Node19 env Node22 tds_context Node22->Node19 tds_ctx Node24 tds_authentication Node24->Node19 authentication Node11 tdsiconvinfo Node11->Node19 char_convs Node25 tds_output_stream Node25->Node1 stream freetds-1.00.82/doc/reference/a01053.html100644 025423 025423 00000011543 13242511136 0013232 FreeTDS API: tds_dataout_stream Struct Reference
    FreeTDS API
    tds_dataout_stream Struct Reference

    output stream to write data to tds protocol More...

    #include <stream.h>

    Collaboration diagram for tds_dataout_stream:
    [legend]

    Public Attributes

    TDSOUTSTREAM stream
     
    TDSSOCKETtds
     
    size_t written
     

    Detailed Description

    output stream to write data to tds protocol


    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01054.html100644 025423 025423 00000006677 13242511133 0013244 FreeTDS API: Member List
    FreeTDS API
    tds_staticin_stream Member List

    This is the complete list of members for tds_staticin_stream, including all inherited members.

    buf_left (defined in tds_staticin_stream)tds_staticin_stream
    buffer (defined in tds_staticin_stream)tds_staticin_stream
    stream (defined in tds_staticin_stream)tds_staticin_stream
    freetds-1.00.82/doc/reference/a01055.map100644 025423 025423 00000000301 13242511136 0013033 freetds-1.00.82/doc/reference/a01055.md5100644 025423 025423 00000000040 13242511133 0012740d0263aab240d27371bc9ba750aa14c38freetds-1.00.82/doc/reference/a01055.svg100644 025423 025423 00000003304 13242511136 0013063 tds_staticin_stream Node1 tds_staticin_stream Node2 tds_input_stream Node2->Node1 stream freetds-1.00.82/doc/reference/a01057.html100644 025423 025423 00000011512 13242511136 0013232 FreeTDS API: tds_staticin_stream Struct Reference
    FreeTDS API
    tds_staticin_stream Struct Reference

    input stream to read data from a static buffer More...

    #include <stream.h>

    Collaboration diagram for tds_staticin_stream:
    [legend]

    Public Attributes

    size_t buf_left
     
    const char * buffer
     
    TDSINSTREAM stream
     

    Detailed Description

    input stream to read data from a static buffer


    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01058.html100644 025423 025423 00000005730 13242511133 0013235 FreeTDS API: Member List
    FreeTDS API
    tds_staticout_stream Member List

    This is the complete list of members for tds_staticout_stream, including all inherited members.

    stream (defined in tds_staticout_stream)tds_staticout_stream
    freetds-1.00.82/doc/reference/a01059.map100644 025423 025423 00000000304 13242511136 0013042 freetds-1.00.82/doc/reference/a01059.md5100644 025423 025423 00000000040 13242511133 001274409d7ae1911d5b12cdad260559b6825d0freetds-1.00.82/doc/reference/a01059.svg100644 025423 025423 00000003311 13242511136 0013065 tds_staticout_stream Node1 tds_staticout_stream Node2 tds_output_stream Node2->Node1 stream freetds-1.00.82/doc/reference/a01061.html100644 025423 025423 00000010337 13242511136 0013231 FreeTDS API: tds_staticout_stream Struct Reference
    FreeTDS API
    tds_staticout_stream Struct Reference

    output stream to write data to a static buffer. More...

    #include <stream.h>

    Collaboration diagram for tds_staticout_stream:
    [legend]

    Public Attributes

    TDSOUTSTREAM stream
     

    Detailed Description

    output stream to write data to a static buffer.

    stream.buffer contains the pointer where stream will write to.


    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01062.html100644 025423 025423 00000007132 13242511133 0013226 FreeTDS API: Member List
    FreeTDS API
    tds_dynamic_stream Member List

    This is the complete list of members for tds_dynamic_stream, including all inherited members.

    allocatedtds_dynamic_stream
    buftds_dynamic_stream
    sizetds_dynamic_stream
    stream (defined in tds_dynamic_stream)tds_dynamic_stream
    freetds-1.00.82/doc/reference/a01063.map100644 025423 025423 00000000300 13242511136 0013031 freetds-1.00.82/doc/reference/a01063.md5100644 025423 025423 00000000040 13242511133 0012737e970afbad89c7ef4a004b2d25732d64efreetds-1.00.82/doc/reference/a01063.svg100644 025423 025423 00000003303 13242511136 0013061 tds_dynamic_stream Node1 tds_dynamic_stream Node2 tds_output_stream Node2->Node1 stream freetds-1.00.82/doc/reference/a01065.html100644 025423 025423 00000013450 13242511136 0013234 FreeTDS API: tds_dynamic_stream Struct Reference
    FreeTDS API
    tds_dynamic_stream Struct Reference

    output stream to write data to a dynamic buffer More...

    #include <stream.h>

    Collaboration diagram for tds_dynamic_stream:
    [legend]

    Public Attributes

    size_t allocated
     currently allocated buffer
     
    void ** buf
     where is stored the pointer
     
    size_t size
     size of data inside buffer
     
    TDSOUTSTREAM stream
     

    Detailed Description

    output stream to write data to a dynamic buffer


    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01066.html100644 025423 025423 00000013766 13242511133 0013244 FreeTDS API: Member List
    FreeTDS API
    tds_compiletime_settings Member List
    freetds-1.00.82/doc/reference/a01069.html100644 025423 025423 00000017532 13242511133 0013242 FreeTDS API: tds_compiletime_settings Struct Reference
    FreeTDS API
    tds_compiletime_settings Struct Reference

    A structure to hold all the compile-time settings. More...

    #include <tds.h>

    Public Attributes

    const char * freetds_version
     
    int gnutls
     
    int iodbc
     
    const char * last_update
     
    int libiconv
     
    int mars
     
    int msdblib
     
    int openssl
     
    int sybase_compat
     
    const char * sysconfdir
     
    const char * tdsver
     
    int threadsafe
     
    int unixodbc
     

    Detailed Description

    A structure to hold all the compile-time settings.

    This structure is returned by tds_get_compiletime_settings


    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01070.html100644 025423 025423 00000006203 13242511133 0013223 FreeTDS API: Member List
    FreeTDS API
    tds_dstr Member List

    This is the complete list of members for tds_dstr, including all inherited members.

    dstr_s (defined in tds_dstr)tds_dstr
    dstr_size (defined in tds_dstr)tds_dstr
    freetds-1.00.82/doc/reference/a01073.html100644 025423 025423 00000010123 13242511133 0013222 FreeTDS API: tds_dstr Struct Reference
    FreeTDS API
    tds_dstr Struct Reference

    Structure to hold a string. More...

    #include <tds.h>

    Public Attributes

    char dstr_s [1]
     
    size_t dstr_size
     

    Detailed Description

    Structure to hold a string.

    Use tds_dstr_* functions/macros, do not access members directly. There should be always a buffer.


    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01074.html100644 025423 025423 00000011007 13242511133 0013225 FreeTDS API: Member List
    FreeTDS API
    TDS_DATETIMEALL Member List

    This is the complete list of members for TDS_DATETIMEALL, including all inherited members.

    _tds_reserved (defined in TDS_DATETIMEALL)TDS_DATETIMEALL
    dateTDS_DATETIMEALL
    has_date (defined in TDS_DATETIMEALL)TDS_DATETIMEALL
    has_offset (defined in TDS_DATETIMEALL)TDS_DATETIMEALL
    has_time (defined in TDS_DATETIMEALL)TDS_DATETIMEALL
    offsetTDS_DATETIMEALL
    timeTDS_DATETIMEALL
    time_prec (defined in TDS_DATETIMEALL)TDS_DATETIMEALL
    freetds-1.00.82/doc/reference/a01077.html100644 025423 025423 00000015506 13242511133 0013240 FreeTDS API: TDS_DATETIMEALL Struct Reference
    FreeTDS API
    TDS_DATETIMEALL Struct Reference

    this structure is not directed connected to a TDS protocol but keeps any DATE/TIME information. More...

    #include <tds.h>

    Public Attributes

    TDS_USMALLINT _tds_reserved:10
     
    TDS_INT date
     date, 0 = 1900-01-01
     
    TDS_USMALLINT has_date:1
     
    TDS_USMALLINT has_offset:1
     
    TDS_USMALLINT has_time:1
     
    TDS_SMALLINT offset
     time offset
     
    TDS_UINT8 time
     time, 7 digit precision
     
    TDS_USMALLINT time_prec:3
     

    Detailed Description

    this structure is not directed connected to a TDS protocol but keeps any DATE/TIME information.


    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01078.html100644 025423 025423 00000011754 13242511133 0013242 FreeTDS API: Member List
    FreeTDS API
    tdsdaterec Member List
    freetds-1.00.82/doc/reference/a01081.html100644 025423 025423 00000022340 13242511133 0013225 FreeTDS API: tdsdaterec Struct Reference
    FreeTDS API
    tdsdaterec Struct Reference

    Used by tds_datecrack. More...

    #include <tds.h>

    Public Attributes

    TDS_INT day
     day of month (1-31)
     
    TDS_INT dayofyear
     day of year (1-366)
     
    TDS_INT decimicrosecond
     0-9999999
     
    TDS_INT hour
     0-23
     
    TDS_INT minute
     0-59
     
    TDS_INT month
     month number (0-11)
     
    TDS_INT quarter
     quarter (0-3)
     
    TDS_INT second
     0-59
     
    TDS_INT timezone
     -840 - 840 minutes from UTC
     
    TDS_INT weekday
     day of week (0-6, 0 = sunday)
     
    TDS_INT year
     year
     

    Detailed Description

    Used by tds_datecrack.


    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01082.html100644 025423 025423 00000006607 13242511133 0013236 FreeTDS API: Member List
    FreeTDS API
    tds_option_arg Member List

    This is the complete list of members for tds_option_arg, including all inherited members.

    c (defined in tds_option_arg)tds_option_arg
    i (defined in tds_option_arg)tds_option_arg
    ti (defined in tds_option_arg)tds_option_arg
    freetds-1.00.82/doc/reference/a01085.html100644 025423 025423 00000010002 13242511133 0013221 FreeTDS API: tds_option_arg Union Reference
    FreeTDS API
    tds_option_arg Union Reference

    Public Attributes

    TDS_CHAR * c
     
    TDS_INT i
     
    TDS_TINYINT ti
     

    The documentation for this union was generated from the following file:
    freetds-1.00.82/doc/reference/a01086.html100644 025423 025423 00000006627 13242511133 0013244 FreeTDS API: Member List
    FreeTDS API
    tds_align_struct Member List

    This is the complete list of members for tds_align_struct, including all inherited members.

    i (defined in tds_align_struct)tds_align_struct
    p (defined in tds_align_struct)tds_align_struct
    ui (defined in tds_align_struct)tds_align_struct
    freetds-1.00.82/doc/reference/a01089.html100644 025423 025423 00000007773 13242511133 0013252 FreeTDS API: tds_align_struct Union Reference
    FreeTDS API
    tds_align_struct Union Reference

    Public Attributes

    int i
     
    void * p
     
    TDS_INT8 ui
     

    The documentation for this union was generated from the following file:
    freetds-1.00.82/doc/reference/a01090.html100644 025423 025423 00000006670 13242511133 0013235 FreeTDS API: Member List
    FreeTDS API
    tds_capability_type Member List

    This is the complete list of members for tds_capability_type, including all inherited members.

    len (defined in tds_capability_type)tds_capability_type
    type (defined in tds_capability_type)tds_capability_type
    values (defined in tds_capability_type)tds_capability_type
    freetds-1.00.82/doc/reference/a01093.html100644 025423 025423 00000010074 13242511133 0013231 FreeTDS API: tds_capability_type Struct Reference
    FreeTDS API
    tds_capability_type Struct Reference

    Public Attributes

    unsigned char len
     
    unsigned char type
     
    unsigned char values [TDS_MAX_CAPABILITY/2-2]
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01094.html100644 025423 025423 00000005707 13242511133 0013241 FreeTDS API: Member List
    FreeTDS API
    tds_capabilities Member List

    This is the complete list of members for tds_capabilities, including all inherited members.

    types (defined in tds_capabilities)tds_capabilities
    freetds-1.00.82/doc/reference/a01095.map100644 025423 025423 00000000246 13242511136 0013047 freetds-1.00.82/doc/reference/a01095.md5100644 025423 025423 00000000040 13242511133 00127440f3a5872633229d1bf505c979e0d2a94freetds-1.00.82/doc/reference/a01095.svg100644 025423 025423 00000003326 13242511136 0013073 tds_capabilities Node1 tds_capabilities Node2 tds_capability_type Node2->Node1 types freetds-1.00.82/doc/reference/a01097.html100644 025423 025423 00000007451 13242511136 0013245 FreeTDS API: tds_capabilities Struct Reference
    FreeTDS API
    tds_capabilities Struct Reference
    Collaboration diagram for tds_capabilities:
    [legend]

    Public Attributes

    TDS_CAPABILITY_TYPE types [2]
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01098.html100644 025423 025423 00000031547 13242511133 0013246 FreeTDS API: Member List
    FreeTDS API
    tds_login Member List

    This is the complete list of members for tds_login, including all inherited members.

    app_name (defined in tds_login)tds_login
    block_size (defined in tds_login)tds_login
    bulk_copytds_login
    cafiletds_login
    capabilities (defined in tds_login)tds_login
    check_ssl_hostname (defined in tds_login)tds_login
    client_charset (defined in tds_login)tds_login
    client_host_name (defined in tds_login)tds_login
    connect_timeout (defined in tds_login)tds_login
    connected_addr (defined in tds_login)tds_login
    crlfiletds_login
    database (defined in tds_login)tds_login
    db_filenametds_login
    debug_flags (defined in tds_login)tds_login
    dump_file (defined in tds_login)tds_login
    emul_little_endian (defined in tds_login)tds_login
    encryption_level (defined in tds_login)tds_login
    gssapi_use_delegation (defined in tds_login)tds_login
    instance_name (defined in tds_login)tds_login
    ip_addrstds_login
    language (defined in tds_login)tds_login
    library (defined in tds_login)tds_login
    mars (defined in tds_login)tds_login
    new_passwordtds_login
    openssl_ciphers (defined in tds_login)tds_login
    option_flag2 (defined in tds_login)tds_login
    passwordtds_login
    porttds_login
    query_timeout (defined in tds_login)tds_login
    readonly_intent (defined in tds_login)tds_login
    routing_address (defined in tds_login)tds_login
    routing_port (defined in tds_login)tds_login
    server_charsettds_login
    server_host_name (defined in tds_login)tds_login
    server_nametds_login
    server_realm_nametds_login
    server_spntds_login
    suppress_language (defined in tds_login)tds_login
    tds_versiontds_login
    text_size (defined in tds_login)tds_login
    use_lanman (defined in tds_login)tds_login
    use_new_password (defined in tds_login)tds_login
    use_ntlmv2 (defined in tds_login)tds_login
    use_utf16 (defined in tds_login)tds_login
    user_nametds_login
    valid_configuration (defined in tds_login)tds_login
    freetds-1.00.82/doc/reference/a01099.map100644 025423 025423 00000000573 13242511136 0013056 freetds-1.00.82/doc/reference/a01099.md5100644 025423 025423 00000000040 13242511133 00127504f1e01eee437f0b496eb830a7cbf22fafreetds-1.00.82/doc/reference/a01099.svg100644 025423 025423 00000011276 13242511136 0013102 tds_login Node1 tds_login Node2 tds_capabilities Node2->Node1 capabilities Node3 tds_capability_type Node3->Node2 types Node4 tds_dstr Node4->Node1 server_realm_name password server_name dump_file library crlfile server_spn client_host _name client_charset openssl_ciphers ... freetds-1.00.82/doc/reference/a01101.html100644 025423 025423 00000060365 13242511136 0013232 FreeTDS API: tds_login Struct Reference
    FreeTDS API
    tds_login Struct Reference
    Collaboration diagram for tds_login:
    [legend]

    Public Attributes

    DSTR app_name
     
    int block_size
     
    unsigned int bulk_copy:1
     if bulk copy should be enabled
     
    DSTR cafile
     certificate authorities file
     
    TDS_CAPABILITIES capabilities
     
    unsigned int check_ssl_hostname:1
     
    DSTR client_charset
     
    DSTR client_host_name
     
    TDS_INT connect_timeout
     
    struct addrinfo * connected_addr
     
    DSTR crlfile
     certificate revocation file
     
    DSTR database
     
    DSTR db_filename
     database filename to attach (MSSQL)
     
    int debug_flags
     
    DSTR dump_file
     
    unsigned int emul_little_endian:1
     
    TDS_TINYINT encryption_level
     
    unsigned int gssapi_use_delegation:1
     
    DSTR instance_name
     
    struct addrinfo * ip_addrs
     ip(s) of server
     
    DSTR language
     
    DSTR library
     
    unsigned int mars:1
     
    DSTR new_password
     new password to set (TDS 7.2+)
     
    DSTR openssl_ciphers
     
    unsigned char option_flag2
     
    DSTR password
     password of account login
     
    int port
     port of database service
     
    TDS_INT query_timeout
     
    unsigned int readonly_intent:1
     
    DSTR routing_address
     
    TDS_USMALLINT routing_port
     
    DSTR server_charset
     charset of server e.g. More...
     
    DSTR server_host_name
     
    DSTR server_name
     server name (in freetds.conf)
     
    DSTR server_realm_name
     server realm name (in freetds.conf)
     
    DSTR server_spn
     server SPN (in freetds.conf)
     
    unsigned int suppress_language:1
     
    TDS_USMALLINT tds_version
     TDS version.
     
    int text_size
     
    unsigned int use_lanman:1
     
    unsigned int use_new_password:1
     
    unsigned int use_ntlmv2:1
     
    unsigned int use_utf16:1
     
    DSTR user_name
     account for login
     
    unsigned int valid_configuration:1
     

    Member Data Documentation

    § server_charset

    DSTR tds_login::server_charset

    charset of server e.g.

    iso_1


    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01102.html100644 025423 025423 00000006611 13242511133 0013222 FreeTDS API: Member List
    FreeTDS API
    tds_headers Member List

    This is the complete list of members for tds_headers, including all inherited members.

    qn_msgtext (defined in tds_headers)tds_headers
    qn_options (defined in tds_headers)tds_headers
    qn_timeout (defined in tds_headers)tds_headers
    freetds-1.00.82/doc/reference/a01105.html100644 025423 025423 00000010034 13242511133 0013217 FreeTDS API: tds_headers Struct Reference
    FreeTDS API
    tds_headers Struct Reference

    Public Attributes

    const char * qn_msgtext
     
    const char * qn_options
     
    TDS_INT qn_timeout
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01106.html100644 025423 025423 00000006601 13242511133 0013225 FreeTDS API: Member List
    FreeTDS API
    tds_locale Member List

    This is the complete list of members for tds_locale, including all inherited members.

    date_fmt (defined in tds_locale)tds_locale
    language (defined in tds_locale)tds_locale
    server_charset (defined in tds_locale)tds_locale
    freetds-1.00.82/doc/reference/a01109.html100644 025423 025423 00000010015 13242511133 0013222 FreeTDS API: tds_locale Struct Reference
    FreeTDS API
    tds_locale Struct Reference

    Public Attributes

    char * date_fmt
     
    char * language
     
    char * server_charset
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01110.html100644 025423 025423 00000007107 13242511133 0013222 FreeTDS API: Member List
    FreeTDS API
    tds_blob Member List

    This is the complete list of members for tds_blob, including all inherited members.

    textptr (defined in tds_blob)tds_blob
    textvalue (defined in tds_blob)tds_blob
    timestamp (defined in tds_blob)tds_blob
    valid_ptr (defined in tds_blob)tds_blob
    freetds-1.00.82/doc/reference/a01113.html100644 025423 025423 00000011367 13242511133 0013230 FreeTDS API: tds_blob Struct Reference
    FreeTDS API
    tds_blob Struct Reference

    Information about blobs (e.g. More...

    #include <tds.h>

    Public Attributes

    TDS_CHAR textptr [16]
     
    TDS_CHAR * textvalue
     
    TDS_CHAR timestamp [8]
     
    unsigned char valid_ptr
     

    Detailed Description

    Information about blobs (e.g.

    text or image). current_row contains this structure.


    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01114.html100644 025423 025423 00000007505 13242511133 0013230 FreeTDS API: Member List
    FreeTDS API
    tds_variant Member List

    This is the complete list of members for tds_variant, including all inherited members.

    collation (defined in tds_variant)tds_variant
    data (defined in tds_variant)tds_variant
    data_len (defined in tds_variant)tds_variant
    size (defined in tds_variant)tds_variant
    type (defined in tds_variant)tds_variant
    freetds-1.00.82/doc/reference/a01117.html100644 025423 025423 00000012007 13242511133 0013224 FreeTDS API: tds_variant Struct Reference
    FreeTDS API
    tds_variant Struct Reference

    Store variant informations. More...

    #include <tds.h>

    Public Attributes

    TDS_UCHAR collation [5]
     
    TDS_CHAR * data
     
    TDS_INT data_len
     
    TDS_INT size
     
    TDS_SERVER_TYPE type
     

    Detailed Description

    Store variant informations.


    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01118.html100644 025423 025423 00000007132 13242511133 0013230 FreeTDS API: Member List
    FreeTDS API
    tds_encoding Member List

    This is the complete list of members for tds_encoding, including all inherited members.

    canonictds_encoding
    max_bytes_per_char (defined in tds_encoding)tds_encoding
    min_bytes_per_char (defined in tds_encoding)tds_encoding
    nametds_encoding
    freetds-1.00.82/doc/reference/a01121.html100644 025423 025423 00000012375 13242511133 0013227 FreeTDS API: tds_encoding Struct Reference
    FreeTDS API
    tds_encoding Struct Reference

    Information relevant to libiconv. More...

    #include <tds.h>

    Public Attributes

    unsigned char canonic
     internal numeric index into array of all encodings
     
    unsigned char max_bytes_per_char
     
    unsigned char min_bytes_per_char
     
    const char * name
     name of the encoding (ie UTF-8)
     

    Detailed Description

    Information relevant to libiconv.

    The name is an iconv name, not the same as found in master..syslanguages.


    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01122.html100644 025423 025423 00000006625 13242511133 0013231 FreeTDS API: Member List
    FreeTDS API
    tds_bcpcoldata Member List

    This is the complete list of members for tds_bcpcoldata, including all inherited members.

    data (defined in tds_bcpcoldata)tds_bcpcoldata
    datalen (defined in tds_bcpcoldata)tds_bcpcoldata
    is_null (defined in tds_bcpcoldata)tds_bcpcoldata
    freetds-1.00.82/doc/reference/a01125.html100644 025423 025423 00000010020 13242511133 0013214 FreeTDS API: tds_bcpcoldata Struct Reference
    FreeTDS API
    tds_bcpcoldata Struct Reference

    Public Attributes

    TDS_UCHAR * data
     
    TDS_INT datalen
     
    TDS_INT is_null
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01126.html100644 025423 025423 00000010072 13242511133 0013224 FreeTDS API: Member List
    FreeTDS API
    tds_column_funcs Member List

    This is the complete list of members for tds_column_funcs, including all inherited members.

    get_data (defined in tds_column_funcs)tds_column_funcs
    get_info (defined in tds_column_funcs)tds_column_funcs
    put_datatds_column_funcs
    put_infotds_column_funcs
    put_info_lentds_column_funcs
    row_len (defined in tds_column_funcs)tds_column_funcs
    freetds-1.00.82/doc/reference/a01129.html100644 025423 025423 00000020454 13242511133 0013234 FreeTDS API: tds_column_funcs Struct Reference
    FreeTDS API
    tds_column_funcs Struct Reference

    Public Attributes

    tds_func_get_data * get_data
     
    tds_func_get_info * get_info
     
    tds_func_put_data * put_data
     Send column data to server. More...
     
    tds_func_put_info * put_info
     Send metadata column information to server. More...
     
    tds_func_put_info_len * put_info_len
     Returns metadata column information size. More...
     
    tds_func_row_len * row_len
     

    Member Data Documentation

    § put_data

    tds_func_put_data* tds_column_funcs::put_data

    Send column data to server.

    Usually send parameters unless bcp7 is specified, in this case send BCP for TDS7+ (Sybase use a completely different format for BCP)

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    colcolumn to send
    bcp71 to send BCP column on TDS7+

    § put_info

    tds_func_put_info* tds_column_funcs::put_info

    Send metadata column information to server.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    colcolumn to send

    § put_info_len

    tds_func_put_info_len* tds_column_funcs::put_info_len

    Returns metadata column information size.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    colcolumn to send

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01130.html100644 025423 025423 00000027013 13242511133 0013222 FreeTDS API: Member List
    FreeTDS API
    tds_column Member List

    This is the complete list of members for tds_column, including all inherited members.

    bcp_column_data (defined in tds_column)tds_column
    bcp_prefix_lentds_column
    bcp_term_len (defined in tds_column)tds_column
    bcp_terminator (defined in tds_column)tds_column
    char_convtds_column
    column_bindfmt (defined in tds_column)tds_column
    column_bindlen (defined in tds_column)tds_column
    column_bindtype (defined in tds_column)tds_column
    column_collation (defined in tds_column)tds_column
    column_cur_sizetds_column
    column_data (defined in tds_column)tds_column
    column_data_free (defined in tds_column)tds_column
    column_flags (defined in tds_column)tds_column
    column_hidden (defined in tds_column)tds_column
    column_identity (defined in tds_column)tds_column
    column_key (defined in tds_column)tds_column
    column_lenbind (defined in tds_column)tds_column
    column_name (defined in tds_column)tds_column
    column_nullable (defined in tds_column)tds_column
    column_nullbind (defined in tds_column)tds_column
    column_operand (defined in tds_column)tds_column
    column_operator (defined in tds_column)tds_column
    column_output (defined in tds_column)tds_column
    column_prectds_column
    column_scaletds_column
    column_sizetds_column
    column_text_sqlgetdatapos (defined in tds_column)tds_column
    column_text_sqlputdatainfo (defined in tds_column)tds_column
    column_textpos (defined in tds_column)tds_column
    column_timestamp (defined in tds_column)tds_column
    column_typetds_column
    column_usertype (defined in tds_column)tds_column
    column_varaddr (defined in tds_column)tds_column
    column_varint_sizetds_column
    column_writeable (defined in tds_column)tds_column
    funcs (defined in tds_column)tds_column
    on_server (defined in tds_column)tds_column
    table_column_name (defined in tds_column)tds_column
    table_name (defined in tds_column)tds_column
    freetds-1.00.82/doc/reference/a01131.map100644 025423 025423 00000001474 13242511136 0013042 freetds-1.00.82/doc/reference/a01131.md5100644 025423 025423 00000000040 13242511133 00127336fb9e1c64ad1d708578033c3dcbd0de2freetds-1.00.82/doc/reference/a01131.svg100644 025423 025423 00000016134 13242511136 0013063 tds_column Node1 tds_column Node2 tdsiconvinfo Node2->Node1 char_conv Node3 tds_errno_message_flags Node3->Node2 suppress Node4 tdsiconvdir Node4->Node2 from Node5 tds_encoding Node5->Node4 charset Node6 tds_dstr Node6->Node1 column_name table_name table_column_name Node7 tds_column_funcs Node7->Node1 funcs Node8 tds_bcpcoldata Node8->Node1 bcp_column_data freetds-1.00.82/doc/reference/a01133.html100644 025423 025423 00000055354 13242511136 0013241 FreeTDS API: tds_column Struct Reference
    FreeTDS API
    tds_column Struct Reference

    Metadata about columns in regular and compute rows. More...

    #include <tds.h>

    Collaboration diagram for tds_column:
    [legend]

    Public Attributes

    BCPCOLDATAbcp_column_data
     
    TDS_INT bcp_prefix_len
     The length, in bytes, of any length prefix this column may have. More...
     
    TDS_INT bcp_term_len
     
    TDS_CHAR * bcp_terminator
     
    TDSICONVchar_conv
     refers to previously allocated iconv information
     
    TDS_SMALLINT column_bindfmt
     
    TDS_UINT column_bindlen
     
    TDS_SMALLINT column_bindtype
     
    TDS_UCHAR column_collation [5]
     
    TDS_INT column_cur_size
     size written in variable (ie: char, text, binary). More...
     
    unsigned char * column_data
     
    void(* column_data_free )(struct tds_column *column)
     
    TDS_INT column_flags
     
    unsigned int column_hidden:1
     
    unsigned int column_identity:1
     
    unsigned int column_key:1
     
    TDS_INT * column_lenbind
     
    DSTR column_name
     
    unsigned int column_nullable:1
     
    TDS_SMALLINT * column_nullbind
     
    TDS_SMALLINT column_operand
     
    TDS_TINYINT column_operator
     
    unsigned int column_output:1
     
    TDS_TINYINT column_prec
     precision for decimal/numeric
     
    TDS_TINYINT column_scale
     scale for decimal/numeric
     
    TDS_INT column_size
     maximun size of data. More...
     
    TDS_INT column_text_sqlgetdatapos
     
    TDS_CHAR column_text_sqlputdatainfo
     
    TDS_INT column_textpos
     
    unsigned int column_timestamp:1
     
    TDS_SERVER_TYPE column_type
     This type can be different from wire type because conversion (e.g. More...
     
    TDS_INT column_usertype
     
    TDS_CHAR * column_varaddr
     
    TDS_TINYINT column_varint_size
     size of length when reading from wire (0, 1, 2 or 4)
     
    unsigned int column_writeable:1
     
    const TDSCOLUMNFUNCSfuncs
     
    struct {
       TDS_INT   column_size
     
       TDS_SERVER_TYPE   column_type
     type of data, saved from wire
     
    on_server
     
    DSTR table_column_name
     
    DSTR table_name
     

    Detailed Description

    Metadata about columns in regular and compute rows.

    Member Data Documentation

    § bcp_prefix_len

    TDS_INT tds_column::bcp_prefix_len

    The length, in bytes, of any length prefix this column may have.

    For example, strings in some non-C programming languages are made up of a one-byte length prefix, followed by the string data itself. If the data do not have a length prefix, set prefixlen to 0. Currently not very used in code, however do not remove.

    § column_cur_size

    TDS_INT tds_column::column_cur_size

    size written in variable (ie: char, text, binary).

    -1 if NULL.

    § column_size

    TDS_INT tds_column::column_size

    maximun size of data.

    For fixed is the size.

    § column_type

    TDS_SERVER_TYPE tds_column::column_type

    This type can be different from wire type because conversion (e.g.

    type of data, saved from wire

    UCS-2->Ascii) can be applied. I'm beginning to wonder about the wisdom of this, however. April 2003 jkl


    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01138.html100644 025423 025423 00000013014 13242511133 0013226 FreeTDS API: Member List
    FreeTDS API
    tds_result_info Member List

    This is the complete list of members for tds_result_info, including all inherited members.

    attached_to (defined in tds_result_info)tds_result_info
    by_cols (defined in tds_result_info)tds_result_info
    bycolumns (defined in tds_result_info)tds_result_info
    columns (defined in tds_result_info)tds_result_info
    computeid (defined in tds_result_info)tds_result_info
    current_row (defined in tds_result_info)tds_result_info
    more_results (defined in tds_result_info)tds_result_info
    num_cols (defined in tds_result_info)tds_result_info
    ref_count (defined in tds_result_info)tds_result_info
    row_free (defined in tds_result_info)tds_result_info
    row_size (defined in tds_result_info)tds_result_info
    rows_exist (defined in tds_result_info)tds_result_info
    freetds-1.00.82/doc/reference/a01139.map100644 025423 025423 00000004017 13242511136 0013046 freetds-1.00.82/doc/reference/a01139.md5100644 025423 025423 00000000040 13242511133 0012743ab41f8b20d92db9a06b2a6d070a87449freetds-1.00.82/doc/reference/a01139.svg100644 025423 025423 00000057005 13242511136 0013075 tds_result_info Node1 tds_result_info Node2 tds_socket Node1->Node2 param_info current_results res_info comp_info Node8 tds_dynamic Node1->Node8 res_info params Node9 tds_cursor Node1->Node9 res_info Node2->Node1 attached_to Node3 tds_login Node3->Node2 login Node4 tds_capabilities Node4->Node3 capabilities Node11 tds_connection Node4->Node11 capabilities Node6 tds_dstr Node6->Node3 server_realm_name password server_name dump_file library crlfile server_spn client_host _name client_charset openssl_ciphers ... Node21 tds_column Node6->Node21 column_name table_name table_column_name Node7 tds_packet Node7->Node2 recv_packet send_packet Node7->Node7 next Node8->Node2 cur_dyn Node8->Node8 next Node8->Node11 dyns Node9->Node2 cur_cursor Node9->Node9 next Node9->Node11 cursors Node10 tds_cursor_status Node10->Node9 status Node11->Node2 conn Node12 tds_poll_wakeup Node12->Node11 wakeup Node13 tds_env Node13->Node11 env Node14 tds_context Node14->Node11 tds_ctx Node16 tds_authentication Node16->Node11 authentication Node17 tdsiconvinfo Node17->Node11 char_convs Node17->Node21 char_conv Node21->Node1 columns Node22 tds_column_funcs Node22->Node21 funcs Node23 tds_bcpcoldata Node23->Node21 bcp_column_data freetds-1.00.82/doc/reference/a01141.html100644 025423 025423 00000020014 13242511136 0013221 FreeTDS API: tds_result_info Struct Reference
    FreeTDS API
    tds_result_info Struct Reference

    Hold information for any results. More...

    #include <tds.h>

    Collaboration diagram for tds_result_info:
    [legend]

    Public Attributes

    TDSSOCKETattached_to
     
    TDS_USMALLINT by_cols
     
    TDS_SMALLINT * bycolumns
     
    TDSCOLUMN ** columns
     
    TDS_USMALLINT computeid
     
    unsigned char * current_row
     
    TDS_TINYINT more_results
     
    TDS_USMALLINT num_cols
     
    TDS_INT ref_count
     
    void(* row_free )(struct tds_result_info *result, unsigned char *row)
     
    TDS_INT row_size
     
    TDS_TINYINT rows_exist
     

    Detailed Description

    Hold information for any results.


    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01142.html100644 025423 025423 00000011710 13242511133 0013222 FreeTDS API: Member List
    FreeTDS API
    tds_message Member List

    This is the complete list of members for tds_message, including all inherited members.

    line_number (defined in tds_message)tds_message
    message (defined in tds_message)tds_message
    msgno (defined in tds_message)tds_message
    oserr (defined in tds_message)tds_message
    priv_msg_type (defined in tds_message)tds_message
    proc_name (defined in tds_message)tds_message
    server (defined in tds_message)tds_message
    severity (defined in tds_message)tds_message
    sql_state (defined in tds_message)tds_message
    state (defined in tds_message)tds_message
    freetds-1.00.82/doc/reference/a01145.html100644 025423 025423 00000014634 13242511133 0013235 FreeTDS API: tds_message Struct Reference
    FreeTDS API
    tds_message Struct Reference

    Public Attributes

    TDS_INT line_number
     
    TDS_CHAR * message
     
    TDS_INT msgno
     
    int oserr
     
    TDS_TINYINT priv_msg_type
     
    TDS_CHAR * proc_name
     
    TDS_CHAR * server
     
    TDS_TINYINT severity
     
    TDS_CHAR * sql_state
     
    TDS_SMALLINT state
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01146.html100644 025423 025423 00000006606 13242511133 0013236 FreeTDS API: Member List
    FreeTDS API
    tds_upd_col Member List

    This is the complete list of members for tds_upd_col, including all inherited members.

    colnamelength (defined in tds_upd_col)tds_upd_col
    columnname (defined in tds_upd_col)tds_upd_col
    next (defined in tds_upd_col)tds_upd_col
    freetds-1.00.82/doc/reference/a01147.map100644 025423 025423 00000000061 13242511136 0013040 freetds-1.00.82/doc/reference/a01147.md5100644 025423 025423 00000000040 13242511133 0012742080bed39518bd19a023f9eb34cbb2c17freetds-1.00.82/doc/reference/a01147.svg100644 025423 025423 00000002517 13242511136 0013072 tds_upd_col Node1 tds_upd_col Node1->Node1 next freetds-1.00.82/doc/reference/a01149.html100644 025423 025423 00000010721 13242511136 0013235 FreeTDS API: tds_upd_col Struct Reference
    FreeTDS API
    tds_upd_col Struct Reference
    Collaboration diagram for tds_upd_col:
    [legend]

    Public Attributes

    TDS_INT colnamelength
     
    char * columnname
     
    struct tds_upd_colnext
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01150.html100644 025423 025423 00000010172 13242511133 0013222 FreeTDS API: Member List
    FreeTDS API
    tds_cursor_status Member List

    This is the complete list of members for tds_cursor_status, including all inherited members.

    close (defined in tds_cursor_status)tds_cursor_status
    cursor_row (defined in tds_cursor_status)tds_cursor_status
    dealloc (defined in tds_cursor_status)tds_cursor_status
    declare (defined in tds_cursor_status)tds_cursor_status
    fetch (defined in tds_cursor_status)tds_cursor_status
    open (defined in tds_cursor_status)tds_cursor_status
    freetds-1.00.82/doc/reference/a01153.html100644 025423 025423 00000012125 13242511133 0013225 FreeTDS API: tds_cursor_status Struct Reference
    FreeTDS API
    tds_cursor_status Struct Reference

    Public Attributes

    TDS_CURSOR_STATE close
     
    TDS_CURSOR_STATE cursor_row
     
    TDS_CURSOR_STATE dealloc
     
    TDS_CURSOR_STATE declare
     
    TDS_CURSOR_STATE fetch
     
    TDS_CURSOR_STATE open
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01154.html100644 025423 025423 00000012724 13242511133 0013233 FreeTDS API: Member List
    FreeTDS API
    tds_cursor Member List
    freetds-1.00.82/doc/reference/a01155.map100644 025423 025423 00000002677 13242511136 0013056 freetds-1.00.82/doc/reference/a01155.md5100644 025423 025423 00000000040 13242511133 001274175ef5d0078db88873e96609f8a664952freetds-1.00.82/doc/reference/a01155.svg100644 025423 025423 00000044563 13242511136 0013100 tds_cursor Node1 tds_cursor Node1->Node1 next Node4 tds_socket Node1->Node4 cur_cursor Node11 tds_connection Node1->Node11 cursors Node2 tds_cursor_status Node2->Node1 status Node3 tds_result_info Node3->Node1 res_info Node3->Node4 param_info current_results res_info comp_info Node10 tds_dynamic Node3->Node10 res_info params Node4->Node3 attached_to Node5 tds_login Node5->Node4 login Node8 tds_dstr Node8->Node5 server_realm_name password server_name dump_file library crlfile server_spn client_host _name client_charset openssl_ciphers ... Node21 tds_column Node8->Node21 column_name table_name table_column_name Node9 tds_packet Node9->Node4 recv_packet send_packet Node9->Node9 next Node10->Node4 cur_dyn Node10->Node10 next Node10->Node11 dyns Node11->Node4 conn Node17 tdsiconvinfo Node17->Node11 char_convs Node17->Node21 char_conv Node21->Node3 columns Node22 tds_column_funcs Node22->Node21 funcs Node23 tds_bcpcoldata Node23->Node21 bcp_column_data freetds-1.00.82/doc/reference/a01157.html100644 025423 025423 00000026105 13242511136 0013237 FreeTDS API: tds_cursor Struct Reference
    FreeTDS API
    tds_cursor Struct Reference

    Holds informations about a cursor. More...

    #include <tds.h>

    Collaboration diagram for tds_cursor:
    [legend]

    Public Attributes

    TDS_INT concurrency
     
    TDS_INT cursor_id
     cursor id returned by the server after cursor declare
     
    char * cursor_name
     name of the cursor
     
    TDS_INT cursor_rows
     < number of updatable columns More...
     
    TDS_TINYINT defer_close
     true if cursor was marker to be closed when connection is idle
     
    struct tds_cursornext
     next in linked list, keep first
     
    TDS_TINYINT options
     read only|updatable TODO use it
     
    char * query
     SQL query.
     
    TDS_INT ref_count
     reference counter so client can retain safely a pointer
     
    TDSRESULTINFOres_info
     
    TDS_USMALLINT srv_status
     
    TDS_CURSOR_STATUS status
     cursor parameter
     
    TDS_INT type
     row fetched from this cursor
     

    Detailed Description

    Holds informations about a cursor.

    Member Data Documentation

    § cursor_rows

    TDS_INT tds_cursor::cursor_rows

    < number of updatable columns

    < updatable column list number of cursor rows to fetch


    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01158.html100644 025423 025423 00000007030 13242511133 0013231 FreeTDS API: Member List
    FreeTDS API
    tds_env Member List

    This is the complete list of members for tds_env, including all inherited members.

    block_sizetds_env
    charsettds_env
    databasetds_env
    language (defined in tds_env)tds_env
    freetds-1.00.82/doc/reference/a01161.html100644 025423 025423 00000012470 13242511133 0013227 FreeTDS API: tds_env Struct Reference
    FreeTDS API
    tds_env Struct Reference

    Current environment as reported by the server. More...

    #include <tds.h>

    Public Attributes

    int block_size
     packet size (512-65535)
     
    char * charset
     character set encoding
     
    char * database
     database name
     
    char * language
     

    Detailed Description

    Current environment as reported by the server.


    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01162.html100644 025423 025423 00000011115 13242511133 0013223 FreeTDS API: Member List
    FreeTDS API
    tds_dynamic Member List
    freetds-1.00.82/doc/reference/a01163.map100644 025423 025423 00000002471 13242511136 0013045 freetds-1.00.82/doc/reference/a01163.md5100644 025423 025423 00000000040 13242511133 00127406ce0c0238175a8a6d77687e6481a62d1freetds-1.00.82/doc/reference/a01163.svg100644 025423 025423 00000043113 13242511136 0013065 tds_dynamic Node1 tds_dynamic Node1->Node1 next Node3 tds_socket Node1->Node3 cur_dyn Node11 tds_connection Node1->Node11 dyns Node2 tds_result_info Node2->Node1 res_info params Node2->Node3 param_info current_results res_info comp_info Node9 tds_cursor Node2->Node9 res_info Node3->Node2 attached_to Node4 tds_login Node4->Node3 login Node7 tds_dstr Node7->Node4 server_realm_name password server_name dump_file library crlfile server_spn client_host _name client_charset openssl_ciphers ... Node21 tds_column Node7->Node21 column_name table_name table_column_name Node8 tds_packet Node8->Node3 recv_packet send_packet Node8->Node8 next Node9->Node3 cur_cursor Node9->Node9 next Node9->Node11 cursors Node11->Node3 conn Node17 tdsiconvinfo Node17->Node11 char_convs Node17->Node21 char_conv Node21->Node2 columns Node22 tds_column_funcs Node22->Node21 funcs Node23 tds_bcpcoldata Node23->Node21 bcp_column_data freetds-1.00.82/doc/reference/a01165.html100644 025423 025423 00000025620 13242511136 0013237 FreeTDS API: tds_dynamic Struct Reference
    FreeTDS API
    tds_dynamic Struct Reference

    Holds information for a dynamic (also called prepared) query. More...

    #include <tds.h>

    Collaboration diagram for tds_dynamic:
    [legend]

    Public Attributes

    TDS_TINYINT defer_close
     true if dynamic was marker to be closed when connection is idle
     
    TDS_TINYINT emulated
     this dynamic query cannot be prepared so libTDS have to construct a simple query. More...
     
    char id [30]
     id of dynamic. More...
     
    struct tds_dynamicnext
     next in linked list, keep first
     
    TDS_INT num_id
     numeric id for mssql7+
     
    TDSPARAMINFOparams
     query parameters. More...
     
    char * query
     saved query, we need to know original query if prepare is impossible
     
    TDS_INT ref_count
     reference counter so client can retain safely a pointer
     
    TDSPARAMINFOres_info
     query results
     

    Detailed Description

    Holds information for a dynamic (also called prepared) query.

    Member Data Documentation

    § emulated

    TDS_TINYINT tds_dynamic::emulated

    this dynamic query cannot be prepared so libTDS have to construct a simple query.

    This can happen for instance is tds protocol doesn't support dynamics or trying to prepare query under Sybase that have BLOBs as parameters.

    § id

    char tds_dynamic::id[30]

    id of dynamic.

    Usually this id correspond to server one but if not specified is generated automatically by libTDS

    § params

    TDSPARAMINFO* tds_dynamic::params

    query parameters.

    Mostly used executing query however is a good idea to prepare query again if parameter type change in an incompatible way (ie different types or larger size). Is also better to prepare a query knowing parameter types earlier.


    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01166.html100644 025423 025423 00000006225 13242511133 0013235 FreeTDS API: Member List
    FreeTDS API
    tds_multiple Member List

    This is the complete list of members for tds_multiple, including all inherited members.

    flags (defined in tds_multiple)tds_multiple
    type (defined in tds_multiple)tds_multiple
    freetds-1.00.82/doc/reference/a01169.html100644 025423 025423 00000007273 13242511133 0013244 FreeTDS API: tds_multiple Struct Reference
    FreeTDS API
    tds_multiple Struct Reference

    Public Attributes

    unsigned int flags
     
    TDS_MULTIPLE_TYPE type
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01170.html100644 025423 025423 00000007525 13242511133 0013234 FreeTDS API: Member List
    FreeTDS API
    tds_context Member List

    This is the complete list of members for tds_context, including all inherited members.

    err_handler (defined in tds_context)tds_context
    int_handler (defined in tds_context)tds_context
    locale (defined in tds_context)tds_context
    msg_handler (defined in tds_context)tds_context
    parent (defined in tds_context)tds_context
    freetds-1.00.82/doc/reference/a01171.map100644 025423 025423 00000000222 13242511136 0013034 freetds-1.00.82/doc/reference/a01171.md5100644 025423 025423 00000000040 13242511133 00127373f766614ec623ec1a4f9e4d6ba0084a9freetds-1.00.82/doc/reference/a01171.svg100644 025423 025423 00000003217 13242511136 0013065 tds_context Node1 tds_context Node2 tds_locale Node2->Node1 locale freetds-1.00.82/doc/reference/a01173.html100644 025423 025423 00000012705 13242511136 0013236 FreeTDS API: tds_context Struct Reference
    FreeTDS API
    tds_context Struct Reference
    Collaboration diagram for tds_context:
    [legend]

    Public Attributes

    int(* err_handler )(const TDSCONTEXT *, TDSSOCKET *, TDSMESSAGE *)
     
    int(* int_handler )(void *)
     
    TDSLOCALElocale
     
    int(* msg_handler )(const TDSCONTEXT *, TDSSOCKET *, TDSMESSAGE *)
     
    void * parent
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01174.html100644 025423 025423 00000007250 13242511133 0013233 FreeTDS API: Member List
    FreeTDS API
    tds_authentication Member List

    This is the complete list of members for tds_authentication, including all inherited members.

    free (defined in tds_authentication)tds_authentication
    handle_next (defined in tds_authentication)tds_authentication
    packet (defined in tds_authentication)tds_authentication
    packet_len (defined in tds_authentication)tds_authentication
    freetds-1.00.82/doc/reference/a01177.html100644 025423 025423 00000011201 13242511133 0013225 FreeTDS API: tds_authentication Struct Reference
    FreeTDS API
    tds_authentication Struct Reference

    Public Attributes

    TDSRET(* free )(TDSCONNECTION *conn, struct tds_authentication *auth)
     
    TDSRET(* handle_next )(TDSSOCKET *tds, struct tds_authentication *auth, size_t len)
     
    TDS_UCHAR * packet
     
    int packet_len
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01178.html100644 025423 025423 00000007461 13242511133 0013243 FreeTDS API: Member List
    FreeTDS API
    tds_packet Member List

    This is the complete list of members for tds_packet, including all inherited members.

    buf (defined in tds_packet)tds_packet
    capacity (defined in tds_packet)tds_packet
    len (defined in tds_packet)tds_packet
    next (defined in tds_packet)tds_packet
    sid (defined in tds_packet)tds_packet
    freetds-1.00.82/doc/reference/a01179.map100644 025423 025423 00000000057 13242511136 0013052 freetds-1.00.82/doc/reference/a01179.md5100644 025423 025423 00000000040 13242511133 0012747f08c25144305d0edd7a20cef715f8c3bfreetds-1.00.82/doc/reference/a01179.svg100644 025423 025423 00000002512 13242511136 0013072 tds_packet Node1 tds_packet Node1->Node1 next freetds-1.00.82/doc/reference/a01181.html100644 025423 025423 00000012170 13242511136 0013231 FreeTDS API: tds_packet Struct Reference
    FreeTDS API
    tds_packet Struct Reference
    Collaboration diagram for tds_packet:
    [legend]

    Public Attributes

    unsigned char buf [1]
     
    unsigned capacity
     
    unsigned len
     
    struct tds_packetnext
     
    short sid
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01182.html100644 025423 025423 00000006260 13242511133 0013232 FreeTDS API: Member List
    FreeTDS API
    tds_poll_wakeup Member List

    This is the complete list of members for tds_poll_wakeup, including all inherited members.

    s_signal (defined in tds_poll_wakeup)tds_poll_wakeup
    s_signaled (defined in tds_poll_wakeup)tds_poll_wakeup
    freetds-1.00.82/doc/reference/a01185.html100644 025423 025423 00000007311 13242511133 0013233 FreeTDS API: tds_poll_wakeup Struct Reference
    FreeTDS API
    tds_poll_wakeup Struct Reference

    Public Attributes

    TDS_SYS_SOCKET s_signal
     
    TDS_SYS_SOCKET s_signaled
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01186.html100644 025423 025423 00000020662 13242511133 0013240 FreeTDS API: Member List
    FreeTDS API
    tds_connection Member List

    This is the complete list of members for tds_connection, including all inherited members.

    authentication (defined in tds_connection)tds_connection
    capabilities (defined in tds_connection)tds_connection
    char_conv_count (defined in tds_connection)tds_connection
    char_convs (defined in tds_connection)tds_connection
    client_spid (defined in tds_connection)tds_connection
    collation (defined in tds_connection)tds_connection
    cursorstds_connection
    dynstds_connection
    emul_little_endian (defined in tds_connection)tds_connection
    encrypt_single_packet (defined in tds_connection)tds_connection
    envtds_connection
    pending_closetds_connection
    product_name (defined in tds_connection)tds_connection
    product_versiontds_connection
    stds_connection
    server (defined in tds_connection)tds_connection
    spid (defined in tds_connection)tds_connection
    tds71rev1 (defined in tds_connection)tds_connection
    tds72_transaction (defined in tds_connection)tds_connection
    tds_ctx (defined in tds_connection)tds_connection
    tds_version (defined in tds_connection)tds_connection
    tls_dummy (defined in tds_connection)tds_connection
    tls_session (defined in tds_connection)tds_connection
    use_iconv (defined in tds_connection)tds_connection
    wakeup (defined in tds_connection)tds_connection
    freetds-1.00.82/doc/reference/a01187.map100644 025423 025423 00000003140 13242511136 0013045 freetds-1.00.82/doc/reference/a01187.md5100644 025423 025423 00000000040 13242511133 00127460b48343620742ee530942132a43397a4freetds-1.00.82/doc/reference/a01187.svg100644 025423 025423 00000042115 13242511136 0013074 tds_connection Node1 tds_connection Node11 tds_socket Node1->Node11 conn Node2 tds_capabilities Node2->Node1 capabilities Node3 tds_capability_type Node3->Node2 types Node4 tds_poll_wakeup Node4->Node1 wakeup Node5 tds_env Node5->Node1 env Node6 tds_context Node6->Node1 tds_ctx Node7 tds_locale Node7->Node6 locale Node8 tds_authentication Node8->Node1 authentication Node9 tds_dynamic Node9->Node1 dyns Node9->Node9 next Node9->Node11 cur_dyn Node10 tds_result_info Node10->Node9 res_info params Node10->Node11 param_info current_results res_info comp_info Node15 tds_cursor Node10->Node15 res_info Node11->Node10 attached_to Node15->Node1 cursors Node15->Node11 cur_cursor Node15->Node15 next Node17 tds_column Node17->Node10 columns Node18 tdsiconvinfo Node18->Node1 char_convs Node18->Node17 char_conv freetds-1.00.82/doc/reference/a01189.html100644 025423 025423 00000033631 13242511136 0013246 FreeTDS API: tds_connection Struct Reference
    FreeTDS API
    tds_connection Struct Reference
    Collaboration diagram for tds_connection:
    [legend]

    Public Attributes

    TDSAUTHENTICATIONauthentication
     
    TDS_CAPABILITIES capabilities
     
    int char_conv_count
     
    TDSICONV ** char_convs
     
    int client_spid
     
    TDS_UCHAR collation [5]
     
    TDSCURSORcursors
     linked list of cursors allocated for this connection contains only cursors allocated on the server
     
    TDSDYNAMICdyns
     list of dynamic allocated for this connection contains only dynamic allocated on the server
     
    unsigned int emul_little_endian:1
     
    unsigned int encrypt_single_packet:1
     
    TDSENV env
     environment is shared between all sessions
     
    unsigned int pending_close:1
     true is connection has pending closing (cursors or dynamic)
     
    char * product_name
     
    TDS_UINT product_version
     version of product (Sybase/MS and full version)
     
    TDS_SYS_SOCKET s
     tcp socket, INVALID_SOCKET if not connected
     
    char * server
     
    int spid
     
    unsigned int tds71rev1:1
     
    TDS_UCHAR tds72_transaction [8]
     
    const TDSCONTEXTtds_ctx
     
    TDS_USMALLINT tds_version
     
    void * tls_dummy
     
    void * tls_session
     
    unsigned int use_iconv:1
     
    TDSPOLLWAKEUP wakeup
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01190.html100644 025423 025423 00000023127 13242511133 0013232 FreeTDS API: Member List
    FreeTDS API
    tds_socket Member List
    freetds-1.00.82/doc/reference/a01191.map100644 025423 025423 00000004014 13242511136 0013041 freetds-1.00.82/doc/reference/a01191.md5100644 025423 025423 00000000040 13242511133 00127416728ab302e76eb979c6b92568916c786freetds-1.00.82/doc/reference/a01191.svg100644 025423 025423 00000056735 13242511136 0013104 tds_socket Node1 tds_socket Node8 tds_result_info Node1->Node8 attached_to Node2 tds_login Node2->Node1 login Node3 tds_capabilities Node3->Node2 capabilities Node18 tds_connection Node3->Node18 capabilities Node4 tds_capability_type Node4->Node3 types Node5 tds_dstr Node5->Node2 server_realm_name password server_name dump_file library crlfile server_spn client_host _name client_charset openssl_ciphers ... Node9 tds_column Node5->Node9 column_name table_name table_column_name Node6 tds_packet Node6->Node1 recv_packet send_packet Node6->Node6 next Node7 tds_dynamic Node7->Node1 cur_dyn Node7->Node7 next Node7->Node18 dyns Node8->Node1 param_info current_results res_info comp_info Node8->Node7 res_info params Node16 tds_cursor Node8->Node16 res_info Node9->Node8 columns Node10 tdsiconvinfo Node10->Node9 char_conv Node10->Node18 char_convs Node16->Node1 cur_cursor Node16->Node16 next Node16->Node18 cursors Node17 tds_cursor_status Node17->Node16 status Node18->Node1 conn Node19 tds_poll_wakeup Node19->Node18 wakeup Node20 tds_env Node20->Node18 env Node21 tds_context Node21->Node18 tds_ctx Node22 tds_locale Node22->Node21 locale Node23 tds_authentication Node23->Node18 authentication freetds-1.00.82/doc/reference/a01193.html100644 025423 025423 00000056113 13242511136 0013241 FreeTDS API: tds_socket Struct Reference
    FreeTDS API
    tds_socket Struct Reference

    Information for a server connection. More...

    #include <tds.h>

    Collaboration diagram for tds_socket:
    [legend]

    Public Attributes

    TDS_TINYINT bulk_query
     true is query sent was a bulk query so we need to switch state to QUERYING
     
    TDSCOMPUTEINFO ** comp_info
     
    TDSCONNECTION conn [1]
     
    TDSCURSORcur_cursor
     cursor in use
     
    TDSDYNAMICcur_dyn
     dynamic structure in use
     
    TDS_OPERATION current_op
     
    TDSRESULTINFOcurrent_results
     Current query information. More...
     
    void(* env_chg_func )(TDSSOCKET *tds, int type, char *oldval, char *newval)
     
    TDS_TINYINT has_status
     true is ret_status is valid
     
    unsigned char * in_buf
     Input buffer. More...
     
    volatile unsigned char in_cancel
     indicate we are waiting a cancel reply; discard tokens till acknowledge; 1 mean we have to send cancel packet, 2 already sent. More...
     
    unsigned char in_flag
     input buffer type
     
    unsigned in_len
     input buffer length
     
    unsigned in_pos
     current position in in_buf
     
    bool in_row
     true if we are getting rows
     
    TDSLOGINlogin
     config for login stuff. More...
     
    TDS_UINT num_comp_info
     
    int option_value
     
    unsigned char * out_buf
     Output buffer. More...
     
    unsigned int out_buf_max
     Maximum size of packet pointed by out_buf. More...
     
    unsigned char out_flag
     output buffer type
     
    unsigned out_pos
     current position in out_buf
     
    TDSPARAMINFOparam_info
     
    void * parent
     
    TDS_INT query_timeout
     
    TDSPACKETrecv_packet
     
    TDSRESULTINFOres_info
     
    TDS_INT ret_status
     return status from store procedure
     
    TDS_INT8 rows_affected
     rows updated/deleted/inserted/selected, TDS_NO_COUNT if not valid
     
    TDSPACKETsend_packet
     packet we are preparing to send
     
    TDS_STATE state
     
    tds_mutex wire_mtx
     

    Detailed Description

    Information for a server connection.

    Member Data Documentation

    § current_results

    TDSRESULTINFO* tds_socket::current_results

    Current query information.

    Contains information in process, both normal and compute results. This pointer shouldn't be freed; it's just an alias to another structure.

    § in_buf

    unsigned char* tds_socket::in_buf

    Input buffer.

    Points to receiving packet buffer. As input buffer contains just the raw packet actually this pointer is the address of recv_packet->buf.

    § in_cancel

    volatile unsigned char tds_socket::in_cancel

    indicate we are waiting a cancel reply; discard tokens till acknowledge; 1 mean we have to send cancel packet, 2 already sent.

    § login

    TDSLOGIN* tds_socket::login

    config for login stuff.

    After login this field is NULL

    § out_buf

    unsigned char* tds_socket::out_buf

    Output buffer.

    Points to sending packet buffer. Output buffer can contain additional data before the raw TDS packet so this buffer can point some bytes after send_packet->buf.

    § out_buf_max

    unsigned int tds_socket::out_buf_max

    Maximum size of packet pointed by out_buf.

    The buffer is actually a bit larger to make possible to do some optimizations (at least TDS_ADDITIONAL_SPACE bytes).


    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01194.html100644 025423 025423 00000011366 13242511133 0013240 FreeTDS API: Member List
    FreeTDS API
    tds_bcpinfo Member List

    This is the complete list of members for tds_bcpinfo, including all inherited members.

    bind_count (defined in tds_bcpinfo)tds_bcpinfo
    bindinfo (defined in tds_bcpinfo)tds_bcpinfo
    direction (defined in tds_bcpinfo)tds_bcpinfo
    hint (defined in tds_bcpinfo)tds_bcpinfo
    identity_insert_on (defined in tds_bcpinfo)tds_bcpinfo
    insert_stmt (defined in tds_bcpinfo)tds_bcpinfo
    parent (defined in tds_bcpinfo)tds_bcpinfo
    tablename (defined in tds_bcpinfo)tds_bcpinfo
    xfer_init (defined in tds_bcpinfo)tds_bcpinfo
    freetds-1.00.82/doc/reference/a01195.map100644 025423 025423 00000002725 13242511136 0013054 freetds-1.00.82/doc/reference/a01195.md5100644 025423 025423 00000000040 13242511133 001274579fa247b768af66024ff17216910f061freetds-1.00.82/doc/reference/a01195.svg100644 025423 025423 00000046776 13242511136 0013114 tds_bcpinfo Node1 tds_bcpinfo Node2 tds_result_info Node2->Node1 bindinfo Node3 tds_socket Node2->Node3 param_info current_results res_info comp_info Node9 tds_dynamic Node2->Node9 res_info params Node10 tds_cursor Node2->Node10 res_info Node3->Node2 attached_to Node4 tds_login Node4->Node3 login Node7 tds_dstr Node7->Node1 tablename Node7->Node4 server_realm_name password server_name dump_file library crlfile server_spn client_host _name client_charset openssl_ciphers ... Node22 tds_column Node7->Node22 column_name table_name table_column_name Node8 tds_packet Node8->Node3 recv_packet send_packet Node8->Node8 next Node9->Node3 cur_dyn Node9->Node9 next Node12 tds_connection Node9->Node12 dyns Node10->Node3 cur_cursor Node10->Node10 next Node10->Node12 cursors Node12->Node3 conn Node18 tdsiconvinfo Node18->Node12 char_convs Node18->Node22 char_conv Node22->Node2 columns Node23 tds_column_funcs Node23->Node22 funcs Node24 tds_bcpcoldata Node24->Node22 bcp_column_data freetds-1.00.82/doc/reference/a01197.html100644 025423 025423 00000015147 13242511136 0013247 FreeTDS API: tds_bcpinfo Struct Reference
    FreeTDS API
    tds_bcpinfo Struct Reference
    Collaboration diagram for tds_bcpinfo:
    [legend]

    Public Attributes

    TDS_INT bind_count
     
    TDSRESULTINFObindinfo
     
    TDS_INT direction
     
    const char * hint
     
    TDS_INT identity_insert_on
     
    TDS_CHAR * insert_stmt
     
    void * parent
     
    DSTR tablename
     
    TDS_INT xfer_init
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01201.html100644 025423 025423 00000005343 13242511133 0013223 FreeTDS API: tds_raw_mutex Struct Reference
    FreeTDS API
    tds_raw_mutex Struct Reference

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01205.html100644 025423 025423 00000005343 13242511133 0013227 FreeTDS API: tds_condition Struct Reference
    FreeTDS API
    tds_condition Struct Reference

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01209.html100644 025423 025423 00000005335 13242511133 0013234 FreeTDS API: tds_thread Struct Reference
    FreeTDS API
    tds_thread Struct Reference

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01210.html100644 025423 025423 00000006555 13242511133 0013231 FreeTDS API: Member List
    FreeTDS API
    MD4Context Member List

    This is the complete list of members for MD4Context, including all inherited members.

    buf (defined in MD4Context)MD4Context
    bytes (defined in MD4Context)MD4Context
    in (defined in MD4Context)MD4Context
    freetds-1.00.82/doc/reference/a01213.html100644 025423 025423 00000010006 13242511133 0013216 FreeTDS API: MD4Context Struct Reference
    FreeTDS API
    MD4Context Struct Reference

    Public Attributes

    TDS_UINT buf [4]
     
    TDS_UINT8 bytes
     
    unsigned char in [64]
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01214.html100644 025423 025423 00000006555 13242511133 0013235 FreeTDS API: Member List
    FreeTDS API
    MD5Context Member List

    This is the complete list of members for MD5Context, including all inherited members.

    buf (defined in MD5Context)MD5Context
    bytes (defined in MD5Context)MD5Context
    in (defined in MD5Context)MD5Context
    freetds-1.00.82/doc/reference/a01217.html100644 025423 025423 00000010006 13242511133 0013222 FreeTDS API: MD5Context Struct Reference
    FreeTDS API
    MD5Context Struct Reference

    Public Attributes

    TDS_UINT buf [4]
     
    TDS_UINT8 bytes
     
    unsigned char in [64]
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01218.html100644 025423 025423 00000007241 13242511133 0013232 FreeTDS API: Member List
    FreeTDS API
    tagSS_TIME2_STRUCT Member List

    This is the complete list of members for tagSS_TIME2_STRUCT, including all inherited members.

    fraction (defined in tagSS_TIME2_STRUCT)tagSS_TIME2_STRUCT
    hour (defined in tagSS_TIME2_STRUCT)tagSS_TIME2_STRUCT
    minute (defined in tagSS_TIME2_STRUCT)tagSS_TIME2_STRUCT
    second (defined in tagSS_TIME2_STRUCT)tagSS_TIME2_STRUCT
    freetds-1.00.82/doc/reference/a01221.html100644 025423 025423 00000010573 13242511133 0013226 FreeTDS API: tagSS_TIME2_STRUCT Struct Reference
    FreeTDS API
    tagSS_TIME2_STRUCT Struct Reference

    Public Attributes

    SQLUINTEGER fraction
     
    SQLUSMALLINT hour
     
    SQLUSMALLINT minute
     
    SQLUSMALLINT second
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01222.html100644 025423 025423 00000012066 13242511133 0013226 FreeTDS API: Member List
    FreeTDS API
    tagSS_TIMESTAMPOFFSET_STRUCT Member List
    freetds-1.00.82/doc/reference/a01225.html100644 025423 025423 00000014154 13242511133 0013231 FreeTDS API: tagSS_TIMESTAMPOFFSET_STRUCT Struct Reference
    FreeTDS API
    tagSS_TIMESTAMPOFFSET_STRUCT Struct Reference

    Public Attributes

    SQLUSMALLINT day
     
    SQLUINTEGER fraction
     
    SQLUSMALLINT hour
     
    SQLUSMALLINT minute
     
    SQLUSMALLINT month
     
    SQLUSMALLINT second
     
    SQLSMALLINT timezone_hour
     
    SQLSMALLINT timezone_minute
     
    SQLSMALLINT year
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01226.html100644 025423 025423 00000006522 13242511133 0013232 FreeTDS API: Member List
    FreeTDS API
    pollfd Member List

    This is the complete list of members for pollfd, including all inherited members.

    events (defined in pollfd)pollfd
    fd (defined in pollfd)pollfd
    revents (defined in pollfd)pollfd
    freetds-1.00.82/doc/reference/a01229.html100644 025423 025423 00000007767 13242511133 0013251 FreeTDS API: pollfd Struct Reference
    FreeTDS API
    pollfd Struct Reference

    Public Attributes

    short events
     
    int fd
     
    short revents
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01230.html100644 025423 025423 00000011032 13242511133 0013215 FreeTDS API: Member List
    FreeTDS API
    tds_addrinfo Member List

    This is the complete list of members for tds_addrinfo, including all inherited members.

    ai_addr (defined in tds_addrinfo)tds_addrinfo
    ai_addrlen (defined in tds_addrinfo)tds_addrinfo
    ai_canonname (defined in tds_addrinfo)tds_addrinfo
    ai_family (defined in tds_addrinfo)tds_addrinfo
    ai_flags (defined in tds_addrinfo)tds_addrinfo
    ai_next (defined in tds_addrinfo)tds_addrinfo
    ai_protocol (defined in tds_addrinfo)tds_addrinfo
    ai_socktype (defined in tds_addrinfo)tds_addrinfo
    freetds-1.00.82/doc/reference/a01231.map100644 025423 025423 00000000063 13242511136 0013034 freetds-1.00.82/doc/reference/a01231.md5100644 025423 025423 00000000040 13242511133 0012734c83e5e98454109f513e30d6a9e151a2cfreetds-1.00.82/doc/reference/a01231.svg100644 025423 025423 00000002517 13242511136 0013064 tds_addrinfo Node1 tds_addrinfo Node1->Node1 ai_next freetds-1.00.82/doc/reference/a01233.html100644 025423 025423 00000014236 13242511136 0013234 FreeTDS API: tds_addrinfo Struct Reference
    FreeTDS API
    tds_addrinfo Struct Reference
    Collaboration diagram for tds_addrinfo:
    [legend]

    Public Attributes

    struct sockaddr * ai_addr
     
    size_t ai_addrlen
     
    char * ai_canonname
     
    int ai_family
     
    int ai_flags
     
    struct tds_addrinfoai_next
     
    int ai_protocol
     
    int ai_socktype
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01234.html100644 025423 025423 00000006206 13242511133 0013230 FreeTDS API: Member List
    FreeTDS API
    DBVARYCHAR Member List

    This is the complete list of members for DBVARYCHAR, including all inherited members.

    len (defined in DBVARYCHAR)DBVARYCHAR
    str (defined in DBVARYCHAR)DBVARYCHAR
    freetds-1.00.82/doc/reference/a01237.html100644 025423 025423 00000007245 13242511133 0013237 FreeTDS API: DBVARYCHAR Struct Reference
    FreeTDS API
    DBVARYCHAR Struct Reference

    Public Attributes

    DBSMALLINT len
     
    char str [256]
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01238.html100644 025423 025423 00000006202 13242511133 0013230 FreeTDS API: Member List
    FreeTDS API
    DBVARYBIN Member List

    This is the complete list of members for DBVARYBIN, including all inherited members.

    array (defined in DBVARYBIN)DBVARYBIN
    len (defined in DBVARYBIN)DBVARYBIN
    freetds-1.00.82/doc/reference/a01241.html100644 025423 025423 00000007256 13242511133 0013234 FreeTDS API: DBVARYBIN Struct Reference
    FreeTDS API
    DBVARYBIN Struct Reference

    Public Attributes

    unsigned char array [256]
     
    DBSMALLINT len
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01242.html100644 025423 025423 00000006556 13242511133 0013237 FreeTDS API: Member List
    FreeTDS API
    DBNUMERIC Member List

    This is the complete list of members for DBNUMERIC, including all inherited members.

    array (defined in DBNUMERIC)DBNUMERIC
    precision (defined in DBNUMERIC)DBNUMERIC
    scale (defined in DBNUMERIC)DBNUMERIC
    freetds-1.00.82/doc/reference/a01245.html100644 025423 025423 00000010024 13242511133 0013223 FreeTDS API: DBNUMERIC Struct Reference
    FreeTDS API
    DBNUMERIC Struct Reference

    Public Attributes

    unsigned char array [33]
     
    unsigned char precision
     
    unsigned char scale
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01246.html100644 025423 025423 00000006173 13242511133 0013236 FreeTDS API: Member List
    FreeTDS API
    DBMONEY Member List

    This is the complete list of members for DBMONEY, including all inherited members.

    mnyhigh (defined in DBMONEY)DBMONEY
    mnylow (defined in DBMONEY)DBMONEY
    freetds-1.00.82/doc/reference/a01249.html100644 025423 025423 00000007265 13242511133 0013244 FreeTDS API: DBMONEY Struct Reference
    FreeTDS API
    DBMONEY Struct Reference

    Public Attributes

    DBINT mnyhigh
     
    unsigned tds_sysdep_int32_type mnylow
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01250.html100644 025423 025423 00000005646 13242511133 0013235 FreeTDS API: Member List
    FreeTDS API
    DBMONEY4 Member List

    This is the complete list of members for DBMONEY4, including all inherited members.

    mny4 (defined in DBMONEY4)DBMONEY4
    freetds-1.00.82/doc/reference/a01253.html100644 025423 025423 00000006504 13242511133 0013232 FreeTDS API: DBMONEY4 Struct Reference
    FreeTDS API
    DBMONEY4 Struct Reference

    Public Attributes

    DBINT mny4
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01254.html100644 025423 025423 00000006214 13242511133 0013231 FreeTDS API: Member List
    FreeTDS API
    DBDATETIME Member List

    This is the complete list of members for DBDATETIME, including all inherited members.

    dtdays (defined in DBDATETIME)DBDATETIME
    dttime (defined in DBDATETIME)DBDATETIME
    freetds-1.00.82/doc/reference/a01257.html100644 025423 025423 00000007241 13242511133 0013235 FreeTDS API: DBDATETIME Struct Reference
    FreeTDS API
    DBDATETIME Struct Reference

    Public Attributes

    DBINT dtdays
     
    DBINT dttime
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01258.html100644 025423 025423 00000006221 13242511133 0013233 FreeTDS API: Member List
    FreeTDS API
    DBDATETIME4 Member List

    This is the complete list of members for DBDATETIME4, including all inherited members.

    days (defined in DBDATETIME4)DBDATETIME4
    minutes (defined in DBDATETIME4)DBDATETIME4
    freetds-1.00.82/doc/reference/a01261.html100644 025423 025423 00000007256 13242511133 0013236 FreeTDS API: DBDATETIME4 Struct Reference
    FreeTDS API
    DBDATETIME4 Struct Reference

    Public Attributes

    DBUSMALLINT days
     
    DBUSMALLINT minutes
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01262.html100644 025423 025423 00000010740 13242511133 0013227 FreeTDS API: Member List
    FreeTDS API
    DBDATETIMEALL Member List

    This is the complete list of members for DBDATETIMEALL, including all inherited members.

    _res (defined in DBDATETIMEALL)DBDATETIMEALL
    dateDBDATETIMEALL
    has_date (defined in DBDATETIMEALL)DBDATETIMEALL
    has_offset (defined in DBDATETIMEALL)DBDATETIMEALL
    has_time (defined in DBDATETIMEALL)DBDATETIMEALL
    offsetDBDATETIMEALL
    timeDBDATETIMEALL
    time_prec (defined in DBDATETIMEALL)DBDATETIMEALL
    freetds-1.00.82/doc/reference/a01265.html100644 025423 025423 00000014536 13242511133 0013241 FreeTDS API: DBDATETIMEALL Struct Reference
    FreeTDS API
    DBDATETIMEALL Struct Reference

    Public Attributes

    DBUSMALLINT _res:10
     
    DBINT date
     date, 0 = 1900-01-01
     
    DBUSMALLINT has_date:1
     
    DBUSMALLINT has_offset:1
     
    DBUSMALLINT has_time:1
     
    DBSMALLINT offset
     time offset
     
    DBUBIGINT time
     time, 7 digit precision
     
    DBUSMALLINT time_prec:3
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01266.html100644 025423 025423 00000006216 13242511133 0013236 FreeTDS API: Member List
    FreeTDS API
    dbtypeinfo Member List

    This is the complete list of members for dbtypeinfo, including all inherited members.

    precision (defined in dbtypeinfo)dbtypeinfo
    scale (defined in dbtypeinfo)dbtypeinfo
    freetds-1.00.82/doc/reference/a01269.html100644 025423 025423 00000007243 13242511133 0013242 FreeTDS API: dbtypeinfo Struct Reference
    FreeTDS API
    dbtypeinfo Struct Reference

    Public Attributes

    DBINT precision
     
    DBINT scale
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01270.html100644 025423 025423 00000006552 13242511133 0013234 FreeTDS API: Member List
    FreeTDS API
    dbstring Member List

    This is the complete list of members for dbstring, including all inherited members.

    strnext (defined in dbstring)dbstring
    strtext (defined in dbstring)dbstring
    strtotlen (defined in dbstring)dbstring
    freetds-1.00.82/doc/reference/a01271.map100644 025423 025423 00000000053 13242511135 0013036 freetds-1.00.82/doc/reference/a01271.md5100644 025423 025423 00000000040 13242511133 0012740695888c88474e6717294593adfd7ad3ffreetds-1.00.82/doc/reference/a01271.svg100644 025423 025423 00000002506 13242511136 0013066 dbstring Node1 dbstring Node1->Node1 strnext freetds-1.00.82/doc/reference/a01273.html100644 025423 025423 00000010671 13242511136 0013237 FreeTDS API: dbstring Struct Reference
    FreeTDS API
    dbstring Struct Reference
    Collaboration diagram for dbstring:
    [legend]

    Public Attributes

    struct dbstringstrnext
     
    BYTE * strtext
     
    DBINT strtotlen
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01274.html100644 025423 025423 00000013261 13242511133 0013233 FreeTDS API: Member List
    FreeTDS API
    DBCOL Member List

    This is the complete list of members for DBCOL, including all inherited members.

    ActualName (defined in DBCOL)DBCOL
    CaseSensitive (defined in DBCOL)DBCOL
    Identity (defined in DBCOL)DBCOL
    MaxLength (defined in DBCOL)DBCOL
    Name (defined in DBCOL)DBCOL
    Null (defined in DBCOL)DBCOL
    Precision (defined in DBCOL)DBCOL
    Scale (defined in DBCOL)DBCOL
    SizeOfStruct (defined in DBCOL)DBCOL
    TableName (defined in DBCOL)DBCOL
    Type (defined in DBCOL)DBCOL
    Updatable (defined in DBCOL)DBCOL
    UserType (defined in DBCOL)DBCOL
    VarLength (defined in DBCOL)DBCOL
    freetds-1.00.82/doc/reference/a01277.html100644 025423 025423 00000017372 13242511133 0013245 FreeTDS API: DBCOL Struct Reference
    FreeTDS API
    DBCOL Struct Reference

    Public Attributes

    DBCHAR ActualName [MAXCOLNAMELEN+2]
     
    BYTE CaseSensitive
     
    BOOL Identity
     
    DBINT MaxLength
     
    DBCHAR Name [MAXCOLNAMELEN+2]
     
    BYTE Null
     
    BYTE Precision
     
    BYTE Scale
     
    DBINT SizeOfStruct
     
    DBCHAR TableName [MAXCOLNAMELEN+2]
     
    SHORT Type
     
    BYTE Updatable
     
    DBINT UserType
     
    BOOL VarLength
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01278.html100644 025423 025423 00000014601 13242511133 0013236 FreeTDS API: Member List
    FreeTDS API
    DBCOL2 Member List

    This is the complete list of members for DBCOL2, including all inherited members.

    ActualName (defined in DBCOL2)DBCOL2
    CaseSensitive (defined in DBCOL2)DBCOL2
    Identity (defined in DBCOL2)DBCOL2
    MaxLength (defined in DBCOL2)DBCOL2
    Name (defined in DBCOL2)DBCOL2
    Null (defined in DBCOL2)DBCOL2
    Precision (defined in DBCOL2)DBCOL2
    Scale (defined in DBCOL2)DBCOL2
    ServerMaxLength (defined in DBCOL2)DBCOL2
    ServerType (defined in DBCOL2)DBCOL2
    ServerTypeDeclaration (defined in DBCOL2)DBCOL2
    SizeOfStruct (defined in DBCOL2)DBCOL2
    TableName (defined in DBCOL2)DBCOL2
    Type (defined in DBCOL2)DBCOL2
    Updatable (defined in DBCOL2)DBCOL2
    UserType (defined in DBCOL2)DBCOL2
    VarLength (defined in DBCOL2)DBCOL2
    freetds-1.00.82/doc/reference/a01281.html100644 025423 025423 00000021444 13242511133 0013233 FreeTDS API: DBCOL2 Struct Reference
    FreeTDS API
    DBCOL2 Struct Reference

    Public Attributes

    DBCHAR ActualName [MAXCOLNAMELEN+2]
     
    BYTE CaseSensitive
     
    BOOL Identity
     
    DBINT MaxLength
     
    DBCHAR Name [MAXCOLNAMELEN+2]
     
    BYTE Null
     
    BYTE Precision
     
    BYTE Scale
     
    DBINT ServerMaxLength
     
    SHORT ServerType
     
    DBCHAR ServerTypeDeclaration [256]
     
    DBINT SizeOfStruct
     
    DBCHAR TableName [MAXCOLNAMELEN+2]
     
    SHORT Type
     
    BYTE Updatable
     
    DBINT UserType
     
    BOOL VarLength
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01282.html100644 025423 025423 00000013266 13242511133 0013237 FreeTDS API: Member List
    FreeTDS API
    tds_microsoft_dbdaterec Member List
    freetds-1.00.82/doc/reference/a01285.html100644 025423 025423 00000016040 13242511133 0013233 FreeTDS API: tds_microsoft_dbdaterec Struct Reference
    FreeTDS API
    tds_microsoft_dbdaterec Struct Reference

    Public Attributes

    DBINT day
     
    DBINT dayofyear
     
    DBINT hour
     
    DBINT millisecond
     
    DBINT minute
     
    DBINT month
     
    DBINT quarter
     
    DBINT second
     
    DBINT tzone
     
    DBINT week
     
    DBINT weekday
     
    DBINT year
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01286.html100644 025423 025423 00000013211 13242511133 0013231 FreeTDS API: Member List
    FreeTDS API
    tds_sybase_dbdaterec Member List

    This is the complete list of members for tds_sybase_dbdaterec, including all inherited members.

    datedmonth (defined in tds_sybase_dbdaterec)tds_sybase_dbdaterec
    datedweek (defined in tds_sybase_dbdaterec)tds_sybase_dbdaterec
    datedyear (defined in tds_sybase_dbdaterec)tds_sybase_dbdaterec
    datehour (defined in tds_sybase_dbdaterec)tds_sybase_dbdaterec
    dateminute (defined in tds_sybase_dbdaterec)tds_sybase_dbdaterec
    datemonth (defined in tds_sybase_dbdaterec)tds_sybase_dbdaterec
    datemsecond (defined in tds_sybase_dbdaterec)tds_sybase_dbdaterec
    datesecond (defined in tds_sybase_dbdaterec)tds_sybase_dbdaterec
    datetzone (defined in tds_sybase_dbdaterec)tds_sybase_dbdaterec
    dateyear (defined in tds_sybase_dbdaterec)tds_sybase_dbdaterec
    quarter (defined in tds_sybase_dbdaterec)tds_sybase_dbdaterec
    week (defined in tds_sybase_dbdaterec)tds_sybase_dbdaterec
    freetds-1.00.82/doc/reference/a01289.html100644 025423 025423 00000016073 13242511133 0013245 FreeTDS API: tds_sybase_dbdaterec Struct Reference
    FreeTDS API
    tds_sybase_dbdaterec Struct Reference

    Public Attributes

    DBINT datedmonth
     
    DBINT datedweek
     
    DBINT datedyear
     
    DBINT datehour
     
    DBINT dateminute
     
    DBINT datemonth
     
    DBINT datemsecond
     
    DBINT datesecond
     
    DBINT datetzone
     
    DBINT dateyear
     
    DBINT quarter
     
    DBINT week
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01290.html100644 025423 025423 00000013317 13242511133 0013233 FreeTDS API: Member List
    FreeTDS API
    tds_microsoft_dbdaterec2 Member List
    freetds-1.00.82/doc/reference/a01293.html100644 025423 025423 00000016041 13242511133 0013233 FreeTDS API: tds_microsoft_dbdaterec2 Struct Reference
    FreeTDS API
    tds_microsoft_dbdaterec2 Struct Reference

    Public Attributes

    DBINT day
     
    DBINT dayofyear
     
    DBINT hour
     
    DBINT minute
     
    DBINT month
     
    DBINT nanosecond
     
    DBINT quarter
     
    DBINT second
     
    DBINT tzone
     
    DBINT week
     
    DBINT weekday
     
    DBINT year
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01294.html100644 025423 025423 00000013243 13242511133 0013235 FreeTDS API: Member List
    FreeTDS API
    tds_sybase_dbdaterec2 Member List

    This is the complete list of members for tds_sybase_dbdaterec2, including all inherited members.

    datedmonth (defined in tds_sybase_dbdaterec2)tds_sybase_dbdaterec2
    datedweek (defined in tds_sybase_dbdaterec2)tds_sybase_dbdaterec2
    datedyear (defined in tds_sybase_dbdaterec2)tds_sybase_dbdaterec2
    datehour (defined in tds_sybase_dbdaterec2)tds_sybase_dbdaterec2
    dateminute (defined in tds_sybase_dbdaterec2)tds_sybase_dbdaterec2
    datemonth (defined in tds_sybase_dbdaterec2)tds_sybase_dbdaterec2
    datensecond (defined in tds_sybase_dbdaterec2)tds_sybase_dbdaterec2
    datesecond (defined in tds_sybase_dbdaterec2)tds_sybase_dbdaterec2
    datetzone (defined in tds_sybase_dbdaterec2)tds_sybase_dbdaterec2
    dateyear (defined in tds_sybase_dbdaterec2)tds_sybase_dbdaterec2
    quarter (defined in tds_sybase_dbdaterec2)tds_sybase_dbdaterec2
    week (defined in tds_sybase_dbdaterec2)tds_sybase_dbdaterec2
    freetds-1.00.82/doc/reference/a01297.html100644 025423 025423 00000016075 13242511133 0013246 FreeTDS API: tds_sybase_dbdaterec2 Struct Reference
    FreeTDS API
    tds_sybase_dbdaterec2 Struct Reference

    Public Attributes

    DBINT datedmonth
     
    DBINT datedweek
     
    DBINT datedyear
     
    DBINT datehour
     
    DBINT dateminute
     
    DBINT datemonth
     
    DBINT datensecond
     
    DBINT datesecond
     
    DBINT datetzone
     
    DBINT dateyear
     
    DBINT quarter
     
    DBINT week
     

    The documentation for this struct was generated from the following file:
    freetds-1.00.82/doc/reference/a01298.html100644 025423 025423 00000032075 13242511133 0013245 FreeTDS API: How to add a new type
    FreeTDS API
    How to add a new type

    Introduction

    Adding a new type in FreeTDS is a quite complicated task involving different tasks.

    To see an example you can look at commit id adb893f1381fd3ea40564c775e30dc8cdc81dcf2 ("Implement big(date)time types") and parent changes in the source repository.

    libTDS changes

    • protocol. First thing to do is add the type to the protocol. A type usually have some mnemonic constant and a structure. Declare them in include/freetds/proto.h file. Note that here you should declare the structure the server use not the structure to hold the data in libTDS.
      Cfr commit id a74a06e1f97f3137f6cf1bc7319dd7a2cfb52b1f.

    • base information. Add the type to misc/types.csv file (I use LibreOffice Calc to do it). This table maintain the base information for a type.
      Cfr commit id 680cb3371e042bb372cbc5e6feb4054e50d40c1a.

    • data. There should be some code to handle this type to/from the server. This code is implemented in include/freetds/data.h and src/tds/data.c. You can either add a new set of functions to handle this new type or add the type handling do another set of types depending on how complicated is that type. One thing you have to to at this step is determine how you store that type in libTDS. This is quite important at upper level libraries will have to use these structures or even present these data to client code (like DB-Library usually do). Due to the way FreeTDS works now you would get a linker error in the ODBC part. You can either ignore the error and proceed with libTDS, add the code to ODBC or disable temporarily ODBC.
      Cfr commit id 680cb3371e042bb372cbc5e6feb4054e50d40c1a.

    • enable the type from server. In order to receive the new type from the server you have to tell the server that we support that type. This can be either done changing the protocol (usually Microsoft) or enabling some flags (capabilities for Sybase).
      Cfr commit id a498703ff9e309c656b19dd990f4cad0283a47c7.

    • conversions. Conversions are not hard to write but usually require quite a bit of coding. After extending CONV_RESULT type in include/freetds/convert.h and adding the type to the script that generate the conversion tables in src/tds/tds_willconvert.pl you have to write the big part in src/tds/covnert.c. You have to implement all kind of conversions you declared in the previous file. Reuse the functions that are there (for instance there are some parser functions). Also if there are similar types it could be helpful to convert first your type to a super type then use the conversion for that type. For instance for SMALLINT type (tds_convert_int2) the type is just readed and then tds_convert_int is called which handle any int (actually 32 bit integer). Same for data where the TDS_DATETIMEALL structure is used. Note that conversions to binary (which usually are implemented) are done in another function (tds_convert_to_binary).
      Cfr commit id 9ed52cb78f725607ac109c8c284ca7c4658d87a9.

    • string definition. Add string for your type to src/tds/token.c in tds_prtype.
      Cfr commit id ac0d3b46db7d98436cd76f906b7d455f7651faae.

    • conversion tests. You probably will have done some mistake with conversions but don't mind, there are some tests which will help sorting this out. src/tds/unittests/convert.c try any possible combination of conversion to check if all conversion are implemented (it does not check the conversions themself). src/tds/unittests/t0007.c test that your conversion are working. Just add manually the conversions you want to try.
      Cfr commit id abcc09c9a88acd0e9a45b46dab3ca44309917a02.

    • parameter. Add type/parameter declaration in tds_get_column_declaration in src/tds/query.c. Also do any necessary step to initialize the parameter to send to server.
      Cfr commit id 54fdd3233e430c045cf5524ac385770738d9e92c, commit id 88cfea19d91245372779b8893a2d62b42696cd49.

    • emulated prepared/rpc. If needed handle your type in tds_put_param_as_string in src/tds/query.c.
      Cfr commit id 017b7bf2fee0f09847e64546d27382d2f2b756f4.

    ODBC changes

    ODBC is the most complicated library to add a type to. Usually its data are different from libTDS so you have to add additional code for conversions which are not required by other libraries.

    CT-Library changes

    This is quite easy as usual the conversion in libTDS are fine for this library.

    • define type in include/cspublic.h
    • implement conversion in src/ctlib/cs.h
    • set corrent conversion from cs types to server in src/ctlib/ct.c

    Cfr commit id c5e71e5ad4a557038ecedcec457e2531ab02a77b.

    DB-Library changes

    A bit more complicated than CT-Library but not that much.

    • add type and binding type to include/sybdb.h
    • add NULL handling in dbgetnull, dbsetnull and default_null_representation in src/dblib/dblib.c
    • add binding to dbbindtype
    • add support for conversion from/to server
    • add printable size
    • return correct type string

    Cfr commit id 99dd126e0eb248dd3079b2a7cf97437fe3bcd163.

    Applications changes

    datacopy application requires some changes too to support new types so add them to src/apps/datacopy.c.
    Cfr commit id e59c48ac39c76abb036651f8ec238090eef321c9.

    freetds-1.00.82/doc/reference/a01330.html100644 025423 025423 00000064531 13242511136 0013235 FreeTDS API: src/tds/stream.c File Reference
    FreeTDS API
    stream.c File Reference

    Handle stream of data. More...

    #include <config.h>
    #include <assert.h>
    #include <freetds/tds.h>
    #include <freetds/iconv.h>
    #include <freetds/stream.h>
    Include dependency graph for stream.c:

    Functions

    TDSRET tds_convert_stream (TDSSOCKET *tds, TDSICONV *char_conv, TDS_ICONV_DIRECTION direction, TDSINSTREAM *istream, TDSOUTSTREAM *ostream)
     Reads and writes from a stream converting characters. More...
     
    TDSRET tds_copy_stream (TDSSOCKET *tds, TDSINSTREAM *istream, TDSOUTSTREAM *ostream)
     Reads and writes from a stream to another. More...
     
    void tds_datain_stream_init (TDSDATAINSTREAM *stream, TDSSOCKET *tds, size_t wire_size)
     Initialize a data input stream. More...
     
    static int tds_datain_stream_read (TDSINSTREAM *stream, void *ptr, size_t len)
     Reads data from network for input stream.
     
    void tds_dataout_stream_init (TDSDATAOUTSTREAM *stream, TDSSOCKET *tds)
     Initialize a data output stream. More...
     
    static int tds_dataout_stream_write (TDSOUTSTREAM *stream, size_t len)
     Writes data to network for output stream.
     
    TDSRET tds_dynamic_stream_init (TDSDYNAMICSTREAM *stream, void **ptr, size_t allocated)
     Initialize a dynamic output stream. More...
     
    static int tds_dynamic_stream_write (TDSOUTSTREAM *stream, size_t len)
     Writes data to a dynamic allocated buffer.
     
    void tds_staticin_stream_init (TDSSTATICINSTREAM *stream, const void *ptr, size_t len)
     Initialize an input stream for read from a static allocated buffer. More...
     
    static int tds_staticin_stream_read (TDSINSTREAM *stream, void *ptr, size_t len)
     Reads data from a static allocated buffer.
     
    void tds_staticout_stream_init (TDSSTATICOUTSTREAM *stream, void *ptr, size_t len)
     Initialize an output stream for write into a static allocated buffer. More...
     
    static int tds_staticout_stream_write (TDSOUTSTREAM *stream, size_t len)
     Writes data to a static allocated buffer.
     

    Detailed Description

    Handle stream of data.

    Function Documentation

    § tds_convert_stream()

    TDSRET tds_convert_stream ( TDSSOCKET tds,
    TDSICONV char_conv,
    TDS_ICONV_DIRECTION  direction,
    TDSINSTREAM istream,
    TDSOUTSTREAM ostream 
    )

    Reads and writes from a stream converting characters.

    Convert a stream from istream to ostream using a specific conversion.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    char_convconversion structure
    directionspecify conversion to server or from server
    istreaminput stream
    ostreamoutput stream
    Returns
    TDS_SUCCESS of TDS_FAIL
    Here is the caller graph for this function:

    § tds_copy_stream()

    TDSRET tds_copy_stream ( TDSSOCKET tds,
    TDSINSTREAM istream,
    TDSOUTSTREAM ostream 
    )

    Reads and writes from a stream to another.

    Copy data from a stream to another.

    Parameters
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    istreaminput stream
    ostreamoutput stream
    Returns
    TDS_SUCCESS or TDS_FAIL

    § tds_datain_stream_init()

    void tds_datain_stream_init ( TDSDATAINSTREAM stream,
    TDSSOCKET tds,
    size_t  wire_size 
    )

    Initialize a data input stream.

    This stream read data from network.

    Parameters
    streaminput stream to initialize
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    wire_sizebyte to read
    Here is the call graph for this function:
    Here is the caller graph for this function:

    § tds_dataout_stream_init()

    void tds_dataout_stream_init ( TDSDATAOUTSTREAM stream,
    TDSSOCKET tds 
    )

    Initialize a data output stream.

    This stream writes data to network.

    Parameters
    streamoutput stream to initialize
    tdsA pointer to the TDSSOCKET structure managing a client/server operation.
    Here is the call graph for this function:

    § tds_dynamic_stream_init()

    TDSRET tds_dynamic_stream_init ( TDSDYNAMICSTREAM stream,
    void **  ptr,
    size_t  allocated 
    )

    Initialize a dynamic output stream.

    This stream write data into a dynamic allocated buffer.

    Parameters
    streamstream to initialize
    ptrpointer to pointer to buffer to fill. Buffer will be extended as needed
    allocatedbytes initialially allocated for the buffer. Useful to reuse buffers
    Returns
    TDS_SUCCESS on success, TDS_FAIL otherwise
    Here is the call graph for this function:

    § tds_staticin_stream_init()

    void tds_staticin_stream_init ( TDSSTATICINSTREAM stream,
    const void *  ptr,
    size_t  len 
    )

    Initialize an input stream for read from a static allocated buffer.

    Parameters
    streamstream to initialize
    ptrbuffer to read from
    lenbuffer size in bytes
    Here is the call graph for this function:

    § tds_staticout_stream_init()

    void tds_staticout_stream_init ( TDSSTATICOUTSTREAM stream,
    void *  ptr,
    size_t  len 
    )

    Initialize an output stream for write into a static allocated buffer.

    Parameters
    streamstream to initialize
    ptrbuffer to write to
    lenbuffer size in bytes
    Here is the call graph for this function:
    Here is the caller graph for this function:
    freetds-1.00.82/doc/reference/a01330_a4f9e40da6941cb9407d0da5bc3030517_cgraph.map100644 025423 025423 00000000360 13242511134 0021062 freetds-1.00.82/doc/reference/a01330_a4f9e40da6941cb9407d0da5bc3030517_cgraph.md5100644 025423 025423 00000000040 13242511133 0020764ab648cff89c2c49ec4f410156bda022afreetds-1.00.82/doc/reference/a01330_a4f9e40da6941cb9407d0da5bc3030517_cgraph.svg100644 025423 025423 00000003374 13242511136 0021116 tds_dynamic_stream_init Node13 tds_dynamic_stream_init Node14 tds_dynamic_stream _write Node13->Node14 freetds-1.00.82/doc/reference/a01330_a9d8eb43a81ff58ab423dce0ce95b9564_icgraph.map100644 025423 025423 00000000450 13242511134 0021505 freetds-1.00.82/doc/reference/a01331.map100644 025423 025423 00000003641 13242511134 0013040 freetds-1.00.82/doc/reference/a01331.md5100644 025423 025423 00000000040 13242511133 0012735797431aa96050b731a45f1c7af2aadbcfreetds-1.00.82/doc/reference/a01330_a9d8eb43a81ff58ab423dce0ce95b9564_icgraph.md5100644 025423 025423 00000000040 13242511133 00214076557b2795b3c70f7fe11ae106b5527a1freetds-1.00.82/doc/reference/a01330_a9d8eb43a81ff58ab423dce0ce95b9564_icgraph.svg100644 025423 025423 00000003265 13242511136 0021540 tds_convert_stream Node1 tds_convert_stream Node2 read_and_convert Node1->Node2 freetds-1.00.82/doc/reference/a01330_a9fe0d3799d2e3bde49b614c9d0c3785d_cgraph.map100644 025423 025423 00000000363 13242511134 0021266 freetds-1.00.82/doc/reference/a01330_a9fe0d3799d2e3bde49b614c9d0c3785d_cgraph.md5100644 025423 025423 00000000040 13242511133 00211655549987a26e02cf878e470822cc5bec3freetds-1.00.82/doc/reference/a01330_a9fe0d3799d2e3bde49b614c9d0c3785d_cgraph.svg100644 025423 025423 00000003403 13242511136 0021310 tds_staticout_stream_init Node19 tds_staticout_stream_init Node20 tds_staticout_stream _write Node19->Node20 freetds-1.00.82/doc/reference/a01330_a9fe0d3799d2e3bde49b614c9d0c3785d_icgraph.map100644 025423 025423 00000000466 13242511134 0021443 freetds-1.00.82/doc/reference/a01330_a9fe0d3799d2e3bde49b614c9d0c3785d_icgraph.md5100644 025423 025423 00000000040 13242511133 00213366495222170521a725366589bc281f126freetds-1.00.82/doc/reference/a01330_a9fe0d3799d2e3bde49b614c9d0c3785d_icgraph.svg100644 025423 025423 00000003322 13242511136 0021461 tds_staticout_stream_init Node21 tds_staticout_stream_init Node22 read_and_convert Node21->Node22 freetds-1.00.82/doc/reference/a01330_aa038a9125979f8f0915dbd53cbf27e5a_cgraph.map100644 025423 025423 00000000357 13242511134 0021177 freetds-1.00.82/doc/reference/a01330_aa038a9125979f8f0915dbd53cbf27e5a_cgraph.md5100644 025423 025423 00000000040 13242511133 0021073731d40b263462676f20fdfbcec806d94freetds-1.00.82/doc/reference/a01330_aa038a9125979f8f0915dbd53cbf27e5a_cgraph.svg100644 025423 025423 00000003373 13242511136 0021224 tds_dataout_stream_init Node10 tds_dataout_stream_init Node11 tds_dataout_stream _write Node10->Node11 freetds-1.00.82/doc/reference/a01330_aa9e1e45f0305622dd6aed9f8fe158581_cgraph.map100644 025423 025423 00000000362 13242511134 0021174 freetds-1.00.82/doc/reference/a01330_aa9e1e45f0305622dd6aed9f8fe158581_cgraph.md5100644 025423 025423 00000000040 13242511133 0021074bc4a9762ca1b4491a9b997c87233a5effreetds-1.00.82/doc/reference/a01330_aa9e1e45f0305622dd6aed9f8fe158581_cgraph.svg100644 025423 025423 00000003226 13242511136 0021222 tds_staticin_stream_init Node16 tds_staticin_stream_init Node17 tds_staticin_stream_read Node16->Node17 freetds-1.00.82/doc/reference/a01330_abc3a77c8aa28842e7f28583cbabc1415_cgraph.map100644 025423 025423 00000000703 13242511134 0021235 freetds-1.00.82/doc/reference/a01330_abc3a77c8aa28842e7f28583cbabc1415_cgraph.md5100644 025423 025423 00000000040 13242511133 0021136a9ef7f56aa670ddcf0903b7b10570935freetds-1.00.82/doc/reference/a01331.svg100644 025423 025423 00000051125 13242511136 0013064 src/tds/stream.c Node0 src/tds/stream.c Node1 config.h Node0->Node1 Node2 assert.h Node0->Node2 Node3 freetds/tds.h Node0->Node3 Node18 freetds/iconv.h Node0->Node18 Node19 freetds/stream.h Node0->Node19 Node4 stdarg.h Node3->Node4 Node5 stdio.h Node3->Node5 Node6 time.h Node3->Node6 Node7 freetds/version.h Node3->Node7 Node8 tds_sysdep_public.h Node3->Node8 Node9 freetds/sysdep_private.h Node3->Node9 Node10 freetds/thread.h Node3->Node10 Node11 freetds/bool.h Node3->Node11 Node12 replacements.h Node3->Node12 Node14 freetds/pushvis.h Node3->Node14 Node15 freetds/popvis.h Node3->Node15 Node17 freetds/proto.h Node3->Node17 Node6->Node6 Node12->Node4 Node12->Node8 Node12->Node9 Node13 replacements/readpassphrase.h Node12->Node13 Node12->Node14 Node12->Node15 Node16 replacements/poll.h Node12->Node16 Node13->Node14 Node13->Node15 Node16->Node1 Node16->Node14 Node16->Node15 Node18->Node14 Node18->Node15 Node19->Node14 Node19->Node15 freetds-1.00.82/doc/reference/a01330_abc3a77c8aa28842e7f28583cbabc1415_cgraph.svg100644 025423 025423 00000004645 13242511136 0021272 tds_datain_stream_init Node5 tds_datain_stream_init Node6 tds_datain_stream_read Node5->Node6 Node7 tds_get_n Node6->Node7 freetds-1.00.82/doc/reference/a01330_abc3a77c8aa28842e7f28583cbabc1415_icgraph.map100644 025423 025423 00000000460 13242511134 0021406 freetds-1.00.82/doc/reference/a01330_abc3a77c8aa28842e7f28583cbabc1415_icgraph.md5100644 025423 025423 00000000040 13242511133 0021307bfa62abc0ddcc2ec219b765c3d21a5aafreetds-1.00.82/doc/reference/a01330_abc3a77c8aa28842e7f28583cbabc1415_icgraph.svg100644 025423 025423 00000003301 13242511136 0021427 tds_datain_stream_init Node8 tds_datain_stream_init Node9 read_and_convert Node8->Node9 freetds-1.00.82/doc/reference/a01339.html100644 025423 025423 00000036440 13242511136 0013244 FreeTDS API: src/replacements/iconv.c File Reference
    FreeTDS API
    iconv.c File Reference

    This file implements a very simple iconv. More...

    #include <config.h>
    #include <assert.h>
    #include <ctype.h>
    #include <freetds/tds.h>
    #include <freetds/bytes.h>
    #include <freetds/iconv.h>
    Include dependency graph for iconv.c:

    Macros

    #define CD   ((int) (TDS_INTPTR) cd)
     
    #define MASK(n)   ((0xffffffffu << (n)) & 0xffffffffu)
     

    Typedefs

    typedef TDS_UINT ICONV_CHAR
     
    typedef int(* iconv_get_t) (const unsigned char *p, size_t len, ICONV_CHAR *out)
     
    typedef int(* iconv_put_t) (unsigned char *buf, size_t buf_len, ICONV_CHAR c)
     

    Enumerations

    enum  ICONV_CD_VALUE { Like_to_Like = 0x100 }
     

    Functions

    static int get_ascii (const unsigned char *p, size_t len, ICONV_CHAR *out)
     
    static int get_err (const unsigned char *p, size_t len, ICONV_CHAR *out)
     
    static int get_iso1 (const unsigned char *p, size_t len, ICONV_CHAR *out)
     
    static int get_ucs4be (const unsigned char *p, size_t len, ICONV_CHAR *out)
     
    static int get_ucs4le (const unsigned char *p, size_t len, ICONV_CHAR *out)
     
    static int get_utf16be (const unsigned char *p, size_t len, ICONV_CHAR *out)
     
    static int get_utf16le (const unsigned char *p, size_t len, ICONV_CHAR *out)
     
    static int get_utf8 (const unsigned char *p, size_t len, ICONV_CHAR *out)
     
    static int put_ascii (unsigned char *buf, size_t buf_len, ICONV_CHAR c)
     
    static int put_err (unsigned char *buf, size_t buf_len, ICONV_CHAR c)
     
    static int put_iso1 (unsigned char *buf, size_t buf_len, ICONV_CHAR c)
     
    static int put_ucs4be (unsigned char *buf, size_t buf_len, ICONV_CHAR c)
     
    static int put_ucs4le (unsigned char *buf, size_t buf_len, ICONV_CHAR c)
     
    static int put_utf16be (unsigned char *buf, size_t buf_len, ICONV_CHAR c)
     
    static int put_utf16le (unsigned char *buf, size_t buf_len, ICONV_CHAR c)
     
    static int put_utf8 (unsigned char *buf, size_t buf_len, ICONV_CHAR c)
     
    size_t tds_sys_iconv (iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
     
    int tds_sys_iconv_close (iconv_t cd)
     
    iconv_t tds_sys_iconv_open (const char *tocode, const char *fromcode)
     Inputs are FreeTDS canonical names, no other. More...
     

    Variables

    static const iconv_get_t iconv_gets [8]
     
    static const iconv_put_t iconv_puts [8]
     
    static const unsigned char utf8_lengths [256]
     
    static const unsigned char utf8_masks [7]
     

    Detailed Description

    This file implements a very simple iconv.

    Its purpose is to allow ASCII clients to communicate with Microsoft servers that encode their metadata in Unicode (UTF-16).

    It supports ISO-8859-1, ASCII, UTF-16, UCS-4 and UTF-8

    freetds-1.00.82/doc/reference/a01340.map100644 025423 025423 00000003654 13242511134 0013044 freetds-1.00.82/doc/reference/a01340.md5100644 025423 025423 00000000040 13242511133 00127356c359d1aa965fc8cd1b0c67959de9515freetds-1.00.82/doc/reference/a01340.svg100644 025423 025423 00000051274 13242511136 0013071 src/replacements/iconv.c Node0 src/replacements/iconv.c Node1 config.h Node0->Node1 Node2 assert.h Node0->Node2 Node3 ctype.h Node0->Node3 Node4 freetds/tds.h Node0->Node4 Node19 freetds/bytes.h Node0->Node19 Node20 freetds/iconv.h Node0->Node20 Node5 stdarg.h Node4->Node5 Node6 stdio.h Node4->Node6 Node7 time.h Node4->Node7 Node8 freetds/version.h Node4->Node8 Node9 tds_sysdep_public.h Node4->Node9 Node10 freetds/sysdep_private.h Node4->Node10 Node11 freetds/thread.h Node4->Node11 Node12 freetds/bool.h Node4->Node12 Node13 replacements.h Node4->Node13 Node15 freetds/pushvis.h Node4->Node15 Node16 freetds/popvis.h Node4->Node16 Node18 freetds/proto.h Node4->Node18 Node7->Node7 Node13->Node5 Node13->Node9 Node13->Node10 Node14 replacements/readpassphrase.h Node13->Node14 Node13->Node15 Node13->Node16 Node17 replacements/poll.h Node13->Node17 Node14->Node15 Node14->Node16 Node17->Node1 Node17->Node15 Node17->Node16 Node20->Node15 Node20->Node16 freetds-1.00.82/doc/reference/a01342.html100644 025423 025423 00000050371 13242511136 0013235 FreeTDS API: src/tds/iconv.c File Reference
    FreeTDS API
    iconv.c File Reference

    Handle character conversions to/from server. More...

    #include <config.h>
    #include <stdarg.h>
    #include <stdio.h>
    #include <assert.h>
    #include <freetds/tds.h>
    #include <freetds/iconv.h>
    #include "encodings.h"
    Include dependency graph for iconv.c:

    Macros

    #define CHARSIZE(charset)
     
    #define CHUNK_ALLOC   4
     
    #define TDS_ICONV_ENCODING_TABLES
     

    Enumerations

    enum  { POS_ISO1, POS_UTF8, POS_UCS2LE, POS_UCS2BE }
     

    Functions

    static void _iconv_close (iconv_t *cd)
     
    static int collate2charset (int sql_collate, int lcid)
     
    static int lookup_canonic (const CHARACTER_SET_ALIAS aliases[], const char *charset_name)
     
    static size_t skip_one_input_sequence (iconv_t cd, const TDS_ENCODING *charset, const char **input, size_t *input_size)
     Move the input sequence pointer to the next valid position. More...
     
    void tds7_srv_charset_changed (TDSCONNECTION *conn, int sql_collate, int lcid)
     
    static int tds_canonical_charset (const char *charset_name)
     Determine canonical iconv character set. More...
     
    const char * tds_canonical_charset_name (const char *charset_name)
     Determine canonical iconv character set name. More...
     
    size_t tds_iconv (TDSSOCKET *tds, TDSICONV *conv, TDS_ICONV_DIRECTION io, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
     Wrapper around iconv(3). More...
     
    int tds_iconv_alloc (TDSCONNECTION *conn)
     Allocate iconv stuff. More...
     
    void tds_iconv_close (TDSCONNECTION *conn)
     
    static void tds_iconv_err (TDSSOCKET *tds, int err)
     
    void tds_iconv_free (TDSCONNECTION *conn)
     
    TDSICONVtds_iconv_from_collate (TDSCONNECTION *conn, TDS_UCHAR collate[5])
     Get iconv information from a LCID (to support different column encoding under MSSQL2K)
     
    TDSICONVtds_iconv_get (TDSCONNECTION *conn, const char *client_charset, const char *server_charset)
     
    static TDSICONVtds_iconv_get_info (TDSCONNECTION *conn, int canonic_client, int canonic_server)
     Get a iconv info structure, allocate and initialize if needed.
     
    static void tds_iconv_info_close (TDSICONV *char_conv)
     
    static int tds_iconv_info_init (TDSICONV *char_conv, int client_canonical, int server_canonical)
     Open iconv descriptors to convert between character sets (both directions). More...
     
    static int tds_iconv_init (void)
     Initialize charset searching for UTF-8, UCS-2 and ISO8859-1.
     
    TDSRET tds_iconv_open (TDSCONNECTION *conn, const char *charset, int use_utf16)
     
    static void tds_iconv_reset (TDSICONV *conv)
     
    static const char * tds_set_iconv_name (int charset)
     Get iconv name given canonic.
     
    void tds_srv_charset_changed (TDSCONNECTION *conn, const char *charset)
     
    static void tds_srv_charset_changed_num (TDSCONNECTION *conn, int canonic_charset_num)
     

    Variables

    static int iconv_initialized = 0
     
    static const char * iconv_names [sizeof(canonic_charsets)/sizeof(canonic_charsets[0])]
     
    static const char * ucs2name
     

    Detailed Description

    Handle character conversions to/from server.

    Macro Definition Documentation

    § CHARSIZE

    #define CHARSIZE (   charset)
    Value:
    ( ((charset)->min_bytes_per_char == (charset)->max_bytes_per_char )? \
    (charset)->min_bytes_per_char : 0 )

    Function Documentation

    § tds_iconv_alloc()

    int tds_iconv_alloc ( TDSCONNECTION conn)

    Allocate iconv stuff.

    Returns
    0 for success
    freetds-1.00.82/doc/reference/a01343.map100644 025423 025423 00000003621 13242511134 0013041 freetds-1.00.82/doc/reference/a01343.md5100644 025423 025423 00000000040 13242511133 0012740a571bf9a8dd3495fd692e9f23999c3b4freetds-1.00.82/doc/reference/a01343.svg100644 025423 025423 00000051127 13242511136 0013071 src/tds/iconv.c Node0 src/tds/iconv.c Node1 config.h Node0->Node1 Node2 stdarg.h Node0->Node2 Node3 stdio.h Node0->Node3 Node4 assert.h Node0->Node4 Node5 freetds/tds.h Node0->Node5 Node18 freetds/iconv.h Node0->Node18 Node19 encodings.h Node0->Node19 Node5->Node2 Node5->Node3 Node6 time.h Node5->Node6 Node7 freetds/version.h Node5->Node7 Node8 tds_sysdep_public.h Node5->Node8 Node9 freetds/sysdep_private.h Node5->Node9 Node10 freetds/thread.h Node5->Node10 Node11 freetds/bool.h Node5->Node11 Node12 replacements.h Node5->Node12 Node14 freetds/pushvis.h Node5->Node14 Node15 freetds/popvis.h Node5->Node15 Node17 freetds/proto.h Node5->Node17 Node6->Node6 Node12->Node2 Node12->Node8 Node12->Node9 Node13 replacements/readpassphrase.h Node12->Node13 Node12->Node14 Node12->Node15 Node16 replacements/poll.h Node12->Node16 Node13->Node14 Node13->Node15 Node16->Node1 Node16->Node14 Node16->Node15 Node18->Node14 Node18->Node15 freetds-1.00.82/doc/reference/annotated.html100644 025423 025423 00000144303 13242511133 0014374 FreeTDS API: Class List
    FreeTDS API
    Class List
    Here are the classes, structs, unions and interfaces with brief descriptions:
    [detail level 12]
     C_character_set_alias
     C_cs_blkdesc
     C_cs_clientmsg
     C_cs_command
     C_cs_config
     C_cs_connection
     C_cs_context
     C_cs_datafmt
     C_cs_daterec
     C_cs_datetime
     C_cs_datetime4
     C_cs_dynamic
     C_cs_iodesc
     C_cs_locale
     C_cs_money
     C_cs_money4
     C_cs_numeric
     C_cs_objdata
     C_cs_objname
     C_cs_param
     C_cs_servermsg
     C_cs_varbinary
     C_cs_varchar
     C_csremote_proc
     C_ct_colinfo
     C_dblib_error_message
     C_DBREMOTE_PROC
     C_DBREMOTE_PROC_PARAM
     C_dheader
     C_drecord
     C_hcattr
     C_hchk
     C_hdbc
     C_hdesc
     C_heattr
     C_henv
     C_hsattr
     C_hstmt
     C_null_representation
     C_options
     C_procedure
     C_sql_error
     C_sql_errors
     Cagg_t
     Casn1_der_iterator
     CBCP_HOSTCOLINFO
     CBCP_HOSTFILEINFO
     Ccol_t
     Cconf_params
     CCONNECT_EVENT
     Cconv_result
     Ccs_diag_msg
     Ccs_diag_msg_client
     Ccs_diag_msg_svr
     CDATA
     CDBCOL
     CDBCOL2
     CDBDATETIME
     CDBDATETIME4
     CDBDATETIMEALL
     Cdblib_buffer_row
     Cdblib_context
     CDBMONEY
     CDBMONEY4
     CDBNUMERIC
     Cdboption
     Cdbstring
     Cdbtypeinfo
     CDBVARYBIN
     CDBVARYCHAR
     Cdes_key
     CDLIST_LIST_TYPE
     Cdlist_ring
     CDSNINFO
     CEND_LOGIN_EVENT
     Cfunc_info
     CKEY_T
     CLOGIN_EVENT
     CLOGINREC
     CMD4Context
     CMD5Context
     CMETACOMP
     CMETADATA
     Cmetadata_t
     Cmpz_t
     Cname_t
     CnamelistHolds list of names
     Cnames_blob_prefix_t
     Cnative_info
     COBJECTINFO
     Cpd
     Cpivot_t
     Cpollfd
     CProfileParam
     Cptw32_mcs_node_t_
     Crsa_public_key
     Cs_SqlMsgMap
     Cs_v3to2map
     Cselect_info
     Cstring_linked_list
     Ctag_DBPROC_ROWBUF
     CtagSS_TIME2_STRUCT
     CtagSS_TIMESTAMPOFFSET_STRUCT
     CTDS71_COLLATIONTDS 7.1 collation informations
     CTDS72_SMP_HEADERTDS 7.2 SMP packet header
     Ctds_addrinfo
     Ctds_align_struct
     Ctds_answer
     Ctds_authentication
     Ctds_bcpcoldata
     Ctds_bcpinfo
     Ctds_blobInformation about blobs (e.g
     Ctds_capabilities
     Ctds_capability_type
     Ctds_columnMetadata about columns in regular and compute rows
     Ctds_column_funcs
     Ctds_compiletime_settingsA structure to hold all the compile-time settings
     Ctds_condition
     Ctds_connection
     Ctds_context
     Ctds_cursorHolds informations about a cursor
     Ctds_cursor_status
     Ctds_datain_streamInput stream to read data from tds protocol
     Ctds_dataout_streamOutput stream to write data to tds protocol
     CTDS_DATETIMEALLThis structure is not directed connected to a TDS protocol but keeps any DATE/TIME information
     Ctds_dblib_dbprocess
     Ctds_dblib_loginrec
     Ctds_dstrStructure to hold a string
     Ctds_dynamicHolds information for a dynamic (also called prepared) query
     Ctds_dynamic_streamOutput stream to write data to a dynamic buffer
     Ctds_encodingInformation relevant to libiconv
     Ctds_envCurrent environment as reported by the server
     Ctds_errno_message_flags
     Ctds_error_message
     Ctds_file_streamInput stream to read a file
     CTDS_FUNCS
     Ctds_headers
     Ctds_input_streamDefine a stream of data used for input
     Ctds_locale
     Ctds_login
     CTDS_MAY_ALIAS
     Ctds_message
     Ctds_microsoft_dbdaterec
     Ctds_microsoft_dbdaterec2
     Ctds_multiple
     Ctds_ntlm_auth
     Ctds_option_arg
     Ctds_output_streamDefine a stream of data used for output
     Ctds_packet
     CTDS_PARSED_PARAM
     Ctds_pbcbHolds clause buffer
     Ctds_poll_wakeup
     Ctds_pool
     Ctds_pool_event
     Ctds_pool_member
     Ctds_pool_socket
     Ctds_pool_user
     Ctds_raw_mutex
     Ctds_result_infoHold information for any results
     Ctds_save_context
     Ctds_save_env
     Ctds_save_msg
     Ctds_socketInformation for a server connection
     Ctds_staticin_streamInput stream to read data from a static buffer
     Ctds_staticout_streamOutput stream to write data to a static buffer
     Ctds_sybase_dbdaterec
     Ctds_sybase_dbdaterec2
     Ctds_thread
     Ctds_time
     Ctds_upd_col
     Ctds_variantStore variant informations
     Ctds_varmax_stream
     CtdsdaterecUsed by tds_datecrack
     Ctdsdatetime
     Ctdsdatetime4
     Ctdsiconvdir
     Ctdsiconvinfo
     Ctdsmoney
     Ctdsmoney4
     Ctdsnumeric
     Ctdsoldmoney
     Ctdsunique
     Ctdsvername_t
     Ctmp_col_struct
    freetds-1.00.82/doc/reference/bc_s.png100644 025423 025423 00000001244 13242511131 0013137‰PNG  IHDR€_ kIDATxíËkQÆÏ¹É̤I&“¦mš&156*nÄ…”ܸR,4 +Hµ(U­b”ª1‚ŠˆJ.º(E·mßúhëJmKS'C›(‚èäÑ…¤ï &äÖþ ‡ïrÎåü3gö(z÷ýÒ&_9ó}’ÕŸ@‰mÚu ` Øh`ñ÷Ô¯  „ú&·ññ×Ù~“½—Üò‡ÎÝÑM4¸%‰3²§?Êêh)€ÿù™\ÄYi>Jb @gûßiÞˆú²Ñkg§ãê\è½­šEUæv+?E€î"pæÖÛB\ƒY&ðØó$vM+ê’Dn¼)}òþ:§Xoâ ƒ3ŠÚ¯'¯¿.‚fÁ0ìuŠ9òLýj€f6¸%«3Gf”Ô#Ôsm(,ùÃk*Ê’³Jª…¯¼JË¢o䆔¼u_~ °r]%%mnu]z°r5[ÍÆ°«Úò•Xeµ’†Iù<ÈèÐÅg@IÔÚÞàµë3‚:/<JÇ’ÐQ) ñ¹…tÚß÷(Mû\63éCgl!ýí;ÿ¸4Ùhâñ=÷Zë29­w’ÝÒ´·ˆV;ÊL3ƒj&7©·º½÷a!I†)ëë$-öÇÓú³›‹7tIV¾VàñÔübf¨8¡ÈƒB<﫵imnÿœÈ‡„ lߣù‡ÛD —#É5“­'Æ4?쬲øM’™›°»g¬‚|5Åçµ½GNdÓÐr|ô”Ã&„ì"7+'³@ 5‡G➑Džâɬ^;õã–.3Òr"ý_R³¿Â@²oI¾å$IEND®B`‚freetds-1.00.82/doc/reference/bdwn.png100644 025423 025423 00000000223 13242511131 0013157‰PNG  IHDR5åZIDATxíË € DŸP–1ñlžmÀ r±j².e è†D[ØÉ¾ÙÏÔ¼µ¦ã´Þ|陣6€Všë3´Å?Ls'(}¬>+ žKó÷¥¿ch`‚ ^׃ÞnIEND®B`‚freetds-1.00.82/doc/reference/classes.html100644 025423 025423 00000057707 13242511133 0014067 FreeTDS API: Class Index
    FreeTDS API
    Class Index
    _ | a | b | c | d | e | f | k | l | m | n | o | p | r | s | t
      _  
    _sql_errors   
      f  
      t  
    tds_microsoft_dbdaterec   
      a  
    tds_microsoft_dbdaterec2   
    _character_set_alias   func_info   tag_DBPROC_ROWBUF   tds_multiple   
    _cs_blkdesc   agg_t   
      k  
    tagSS_TIME2_STRUCT   tds_ntlm_auth   
    _cs_clientmsg   asn1_der_iterator   tagSS_TIMESTAMPOFFSET_STRUCT   tds_option_arg   
    _cs_command   
      b  
    KEY_T   TDS71_COLLATION   tds_output_stream   
    _cs_config   
      l  
    TDS72_SMP_HEADER   tds_packet   
    _cs_connection   BCP_HOSTCOLINFO   tds_addrinfo   TDS_PARSED_PARAM   
    _cs_context   BCP_HOSTFILEINFO   LOGIN_EVENT   tds_align_struct   tds_pbcb   
    _cs_datafmt   
      c  
    LOGINREC   tds_answer   tds_poll_wakeup   
    _cs_daterec   
      m  
    tds_authentication   tds_pool   
    _cs_datetime   conv_result::cb_t   tds_bcpcoldata   tds_pool_event   
    _cs_datetime4   conv_result::cc_t   MD4Context   tds_bcpinfo   tds_pool_member   
    _cs_dynamic   col_t   MD5Context   tds_blob   tds_pool_socket   
    _cs_iodesc   conf_params   METACOMP   tds_capabilities   tds_pool_user   
    _cs_locale   CONNECT_EVENT   METADATA   tds_capability_type   tds_raw_mutex   
    _cs_money   conv_result   metadata_t   tds_column   tds_result_info   
    _cs_money4   cs_diag_msg   mpz_t   tds_column_funcs   tds_save_context   
    _cs_numeric   cs_diag_msg_client   
      n  
    tds_compiletime_settings   tds_save_env   
    _cs_objdata   cs_diag_msg_svr   tds_condition   tds_save_msg   
    _cs_objname   
      d  
    name_t   tds_connection   tds_socket   
    _cs_param   namelist   tds_context   tds_staticin_stream   
    _cs_servermsg   DATA   names_blob_prefix_t   tds_cursor   tds_staticout_stream   
    _cs_varbinary   DBCOL   native_info   tds_cursor_status   tds_sybase_dbdaterec   
    _cs_varchar   DBCOL2   
      o  
    tds_datain_stream   tds_sybase_dbdaterec2   
    _csremote_proc   DBDATETIME   tds_dataout_stream   tds_thread   
    _ct_colinfo   DBDATETIME4   OBJECTINFO   TDS_DATETIMEALL   tds_time   
    _dblib_error_message   DBDATETIMEALL   
      p  
    tds_dblib_dbprocess   tds_upd_col   
    _DBREMOTE_PROC   dblib_buffer_row   tds_dblib_loginrec   tds_variant   
    _DBREMOTE_PROC_PARAM   dblib_context   pd   tds_dstr   tds_varmax_stream   
    _dheader   DBMONEY   pivot_t   tds_dynamic   tdsdaterec   
    _drecord   DBMONEY4   _options::pivot_t   tds_dynamic_stream   tdsdatetime   
    _hcattr   DBNUMERIC   pollfd   tds_encoding   tdsdatetime4   
    _hchk   dboption   ProfileParam   tds_env   tdsiconvdir   
    _hdbc   dbstring   ptw32_mcs_node_t_   tds_errno_message_flags   tdsiconvinfo   
    _hdesc   dbtypeinfo   
      r  
    tds_error_message   tdsmoney   
    _heattr   DBVARYBIN   tds_file_stream   tdsmoney4   
    _henv   DBVARYCHAR   rsa_public_key   TDS_FUNCS   tdsnumeric   
    _hsattr   des_key   
      s  
    tds_headers   tdsoldmoney   
    _hstmt   DLIST_LIST_TYPE   tds_input_stream   tdsunique   
    _null_representation   dlist_ring   s_SqlMsgMap   tds_locale   tdsvername_t   
    _options   DSNINFO   s_v3to2map   tds_login   tmp_col_struct   
    _procedure   
      e  
    select_info   TDS_MAY_ALIAS   
    _sql_error   string_linked_list   tds_message   
    END_LOGIN_EVENT   
    _ | a | b | c | d | e | f | k | l | m | n | o | p | r | s | t
    freetds-1.00.82/doc/reference/closed.png100644 025423 025423 00000000204 13242511131 0013475‰PNG  IHDR à‘KIDATxíÝm @!†ÑGk™É7À-`&séts¦Àñþòð@åk}ª2€… P%Á_Ëþ¿N² .:0Dk¥‹Â›x" Ö›)¡xÒ5õIEND®B`‚freetds-1.00.82/doc/reference/dir_000000.html100644 025423 025423 00000007342 13242511136 0014000 FreeTDS API: include Directory Reference
    FreeTDS API
    include Directory Reference
    Directory dependency graph for include:

    Directories

    Files

    file  sybdb.h [code]
     Primary include file for db-lib applications.
     
    freetds-1.00.82/doc/reference/dir_000000_000001.html100644 025423 025423 00000005570 13242511133 0014576 FreeTDS API: include -> freetds Relation
    FreeTDS API

    include → freetds Relation

    File in includeIncludes file in include/freetds
    ctlib.htds.h
    freetds-1.00.82/doc/reference/dir_000000_000002.html100644 025423 025423 00000005617 13242511133 0014601 FreeTDS API: include -> replacements Relation
    FreeTDS API

    include → replacements Relation

    File in includeIncludes file in include/replacements
    replacements.hpoll.h
    freetds-1.00.82/doc/reference/dir_000000_dep.map100644 025423 025423 00000001061 13242511136 0014431 freetds-1.00.82/doc/reference/dir_000000_dep.md5100644 025423 025423 00000000040 13242511133 0014332d655451867aefd42064cad5ebd48de1bfreetds-1.00.82/doc/reference/dir_000000_dep.svg100644 025423 025423 00000005504 13242511136 0014461 include clusterdir_000000 dir_000000 include dir_000001 freetds dir_000000->dir_000001 1 dir_000002 replacements dir_000000->dir_000002 1 freetds-1.00.82/doc/reference/dir_000001.html100644 025423 025423 00000006511 13242511133 0013773 FreeTDS API: include/freetds Directory Reference
    FreeTDS API
    freetds Directory Reference

    Files

    file  tds.h [code]
     Main include file for libtds.
     
    freetds-1.00.82/doc/reference/dir_000002.html100644 025423 025423 00000006534 13242511133 0014001 FreeTDS API: include/replacements Directory Reference
    FreeTDS API
    replacements Directory Reference

    Files

    file  poll.h [code]
     Provide poll call where missing.
     
    freetds-1.00.82/doc/reference/dir_000003.html100644 025423 025423 00000006203 13242511136 0013776 FreeTDS API: src Directory Reference
    FreeTDS API
    src Directory Reference
    Directory dependency graph for src:

    Directories

    freetds-1.00.82/doc/reference/dir_000003_dep.map100644 025423 025423 00000003611 13242511136 0014437 freetds-1.00.82/doc/reference/dir_000003_dep.md5100644 025423 025423 00000000040 13242511133 0014335b8a1527ccc81290a6c84ff9f1ba715f9freetds-1.00.82/doc/reference/dir_000003_dep.svg100644 025423 025423 00000021550 13242511136 0014463 src clusterdir_000003 dir_000003 src dir_000004 apps dir_000000 include dir_000004->dir_000000 10 dir_000007 ctlib dir_000007->dir_000000 1 dir_000008 dblib dir_000008->dir_000000 14 dir_000009 odbc dir_000009->dir_000000 3 dir_000010 pool dir_000010->dir_000000 2 dir_000012 replacements dir_000012->dir_000000 4 dir_000013 server dir_000013->dir_000000 4 dir_000011 tds dir_000011->dir_000000 31 freetds-1.00.82/doc/reference/dir_000004.html100644 025423 025423 00000006320 13242511136 0013777 FreeTDS API: src/apps Directory Reference
    FreeTDS API
    apps Directory Reference
    Directory dependency graph for apps:

    Directories

    freetds-1.00.82/doc/reference/dir_000004_000000.html100644 025423 025423 00000010667 13242511133 0014604 FreeTDS API: src/apps -> include Relation
    FreeTDS API

    apps → include Relation

    File in src/appsIncludes file in include
    bsqldb.csybdb.h
    datacopy.csybdb.h
    defncopy.csybdb.h
    freebcp.csybdb.h
    freebcp.cfreetds / tds.h
    tsql.cfreetds / tds.h
    fisql / edit.csybdb.h
    fisql / fisql.csybdb.h
    fisql / handlers.csybdb.h
    fisql / interrupt.csybdb.h
    freetds-1.00.82/doc/reference/dir_000004_dep.map100644 025423 025423 00000001221 13242511136 0014433 freetds-1.00.82/doc/reference/dir_000004_dep.md5100644 025423 025423 00000000040 13242511133 001433655a9f0b4a0267f26ca512288f4b470f0freetds-1.00.82/doc/reference/dir_000004_dep.svg100644 025423 025423 00000006237 13242511136 0014471 src/apps clusterdir_000003 src clusterdir_000004 dir_000004 apps dir_000000 include dir_000004->dir_000000 10 dir_000005 fisql dir_000005->dir_000000 4 freetds-1.00.82/doc/reference/dir_000005.html100644 025423 025423 00000006214 13242511136 0014002 FreeTDS API: src/apps/fisql Directory Reference
    FreeTDS API
    fisql Directory Reference
    Directory dependency graph for fisql:
    freetds-1.00.82/doc/reference/dir_000005_000000.html100644 025423 025423 00000006623 13242511133 0014602 FreeTDS API: src/apps/fisql -> include Relation
    FreeTDS API

    fisql → include Relation

    File in src/apps/fisqlIncludes file in include
    edit.csybdb.h
    fisql.csybdb.h
    handlers.csybdb.h
    interrupt.csybdb.h
    freetds-1.00.82/doc/reference/dir_000005_dep.map100644 025423 025423 00000000721 13242511136 0014440 freetds-1.00.82/doc/reference/dir_000005_dep.md5100644 025423 025423 00000000040 13242511133 0014337ac4fc83439d8096eb85416ccac55847ffreetds-1.00.82/doc/reference/dir_000005_dep.svg100644 025423 025423 00000004265 13242511136 0014471 src/apps/fisql clusterdir_000004 apps dir_000005 fisql dir_000000 include dir_000005->dir_000000 4 freetds-1.00.82/doc/reference/dir_000006.html100644 025423 025423 00000005256 13242511133 0014005 FreeTDS API: vms Directory Reference
    FreeTDS API
    vms Directory Reference
    freetds-1.00.82/doc/reference/dir_000007.html100644 025423 025423 00000006101 13242511136 0013777 FreeTDS API: src/ctlib Directory Reference
    FreeTDS API
    ctlib Directory Reference
    Directory dependency graph for ctlib:
    freetds-1.00.82/doc/reference/dir_000007_000000.html100644 025423 025423 00000005763 13242511133 0014610 FreeTDS API: src/ctlib -> include Relation
    FreeTDS API

    ctlib → include Relation

    File in src/ctlibIncludes file in include
    ctutil.cfreetds / tds.h
    freetds-1.00.82/doc/reference/dir_000007_dep.map100644 025423 025423 00000000706 13242511136 0014445 freetds-1.00.82/doc/reference/dir_000007_dep.md5100644 025423 025423 00000000040 13242511133 0014341049e9e528815107ceca4de820a9c5d86freetds-1.00.82/doc/reference/dir_000007_dep.svg100644 025423 025423 00000004251 13242511136 0014466 src/ctlib clusterdir_000003 src dir_000007 ctlib dir_000000 include dir_000007->dir_000000 1 freetds-1.00.82/doc/reference/dir_000008.html100644 025423 025423 00000007155 13242511136 0014012 FreeTDS API: src/dblib Directory Reference
    FreeTDS API
    dblib Directory Reference
    Directory dependency graph for dblib:

    Files

    file  dblib.c
     Main implementation file for db-lib.
     
    freetds-1.00.82/doc/reference/dir_000008_000000.html100644 025423 025423 00000012050 13242511133 0014574 FreeTDS API: src/dblib -> include Relation
    FreeTDS API

    dblib → include Relation

    File in src/dblibIncludes file in include
    bcp.csybdb.h
    bcp.cfreetds / tds.h
    dblib.csybdb.h
    dblib.cfreetds / tds.h
    dbopen.csybdb.h
    dbopen.cfreetds / tds.h
    dbpivot.csybdb.h
    dbpivot.cfreetds / tds.h
    dbutil.csybdb.h
    dbutil.cfreetds / tds.h
    rpc.csybdb.h
    rpc.cfreetds / tds.h
    xact.csybdb.h
    xact.cfreetds / tds.h
    freetds-1.00.82/doc/reference/dir_000008_dep.map100644 025423 025423 00000000707 13242511136 0014447 freetds-1.00.82/doc/reference/dir_000008_dep.md5100644 025423 025423 00000000040 13242511133 0014342dd71fec8da8c77069c6e17e505ec2759freetds-1.00.82/doc/reference/dir_000008_dep.svg100644 025423 025423 00000004253 13242511136 0014471 src/dblib clusterdir_000003 src dir_000008 dblib dir_000000 include dir_000008->dir_000000 14 freetds-1.00.82/doc/reference/dir_000009.html100644 025423 025423 00000006075 13242511136 0014013 FreeTDS API: src/odbc Directory Reference
    FreeTDS API
    odbc Directory Reference
    Directory dependency graph for odbc:
    freetds-1.00.82/doc/reference/dir_000009_000000.html100644 025423 025423 00000006554 13242511133 0014611 FreeTDS API: src/odbc -> include Relation
    FreeTDS API

    odbc → include Relation

    File in src/odbcIncludes file in include
    bcp.cfreetds / tds.h
    winlogin.cfreetds / tds.h
    winsetup.cfreetds / tds.h
    freetds-1.00.82/doc/reference/dir_000009_dep.map100644 025423 025423 00000000703 13242511136 0014444 freetds-1.00.82/doc/reference/dir_000009_dep.md5100644 025423 025423 00000000040 13242511133 00143435f31a2e233abf1846ceba108981e5254freetds-1.00.82/doc/reference/dir_000009_dep.svg100644 025423 025423 00000004245 13242511136 0014473 src/odbc clusterdir_000003 src dir_000009 odbc dir_000000 include dir_000009->dir_000000 3 freetds-1.00.82/doc/reference/dir_000010.html100644 025423 025423 00000006075 13242511136 0014003 FreeTDS API: src/pool Directory Reference
    FreeTDS API
    pool Directory Reference
    Directory dependency graph for pool:
    freetds-1.00.82/doc/reference/dir_000010_000000.html100644 025423 025423 00000006253 13242511133 0014575 FreeTDS API: src/pool -> include Relation
    FreeTDS API

    pool → include Relation

    File in src/poolIncludes file in include
    pool.hfreetds / tds.h
    stream.cfreetds / tds.h
    freetds-1.00.82/doc/reference/dir_000010_dep.map100644 025423 025423 00000000703 13242511136 0014434 freetds-1.00.82/doc/reference/dir_000010_dep.md5100644 025423 025423 00000000040 13242511133 0014333b7f786e7a8a0d914d735a25519898489freetds-1.00.82/doc/reference/dir_000010_dep.svg100644 025423 025423 00000004245 13242511136 0014463 src/pool clusterdir_000003 src dir_000010 pool dir_000000 include dir_000010->dir_000000 2 freetds-1.00.82/doc/reference/dir_000011.html100644 025423 025423 00000013277 13242511136 0014006 FreeTDS API: src/tds Directory Reference
    FreeTDS API
    tds Directory Reference
    Directory dependency graph for tds:

    Directories

    Files

    file  bulk.c
     Handle bulk copy.
     
    file  data.c
     Handle different data handling from network.
     
    file  iconv.c
     Handle character conversions to/from server.
     
    file  read.c
     Grab data from TDS packets.
     
    file  stream.c
     Handle stream of data.
     
    file  token.c
     Contains all routines to get replies from server.
     
    freetds-1.00.82/doc/reference/dir_000011_000000.html100644 025423 025423 00000021335 13242511133 0014574 FreeTDS API: src/tds -> include Relation
    FreeTDS API

    tds → include Relation

    File in src/tdsIncludes file in include
    bulk.cfreetds / tds.h
    challenge.cfreetds / tds.h
    config.cfreetds / tds.h
    convert.cfreetds / tds.h
    data.cfreetds / tds.h
    des.cfreetds / tds.h
    getmac.cfreetds / tds.h
    hmac_md5.cfreetds / tds.h
    iconv.cfreetds / tds.h
    locale.cfreetds / tds.h
    log.cfreetds / tds.h
    login.cfreetds / tds.h
    md4.cfreetds / tds.h
    md5.cfreetds / tds.h
    mem.cfreetds / tds.h
    net.cfreetds / tds.h
    numeric.cfreetds / tds.h
    packet.cfreetds / tds.h
    query.cfreetds / tds.h
    random.cfreetds / tds.h
    read.cfreetds / tds.h
    sec_negotiate.cfreetds / tds.h
    stream.cfreetds / tds.h
    tds_checks.cfreetds / tds.h
    tdsstring.cfreetds / tds.h
    threadsafe.cfreetds / tds.h
    tls.cfreetds / tds.h
    token.cfreetds / tds.h
    util.cfreetds / tds.h
    vstrbuild.cfreetds / tds.h
    write.cfreetds / tds.h
    freetds-1.00.82/doc/reference/dir_000011_dep.map100644 025423 025423 00000001040 13242511136 0014430 freetds-1.00.82/doc/reference/dir_000011_dep.md5100644 025423 025423 00000000040 13242511133 0014334ebd9f57125f29a0a6cbec9a8b88804e6freetds-1.00.82/doc/reference/dir_000011_dep.svg100644 025423 025423 00000005125 13242511136 0014462 src/tds clusterdir_000003 src clusterdir_000011 dir_000011 tds dir_000000 include dir_000011->dir_000000 31 dir_000014 example freetds-1.00.82/doc/reference/dir_000012.html100644 025423 025423 00000007201 13242511136 0013775 FreeTDS API: src/replacements Directory Reference
    FreeTDS API
    replacements Directory Reference
    Directory dependency graph for replacements:

    Files

    file  iconv.c
     This file implements a very simple iconv.
     
    freetds-1.00.82/doc/reference/dir_000012_000000.html100644 025423 025423 00000007163 13242511133 0014600 FreeTDS API: src/replacements -> include Relation
    FreeTDS API

    replacements → include Relation

    File in src/replacementsIncludes file in include
    getaddrinfo.cfreetds / tds.h
    getpassarg.cfreetds / tds.h
    iconv.cfreetds / tds.h
    socketpair.cfreetds / tds.h
    freetds-1.00.82/doc/reference/dir_000012_dep.map100644 025423 025423 00000000735 13242511136 0014443 freetds-1.00.82/doc/reference/dir_000012_dep.md5100644 025423 025423 00000000040 13242511133 001433592cccd159ba4e98f15e5b9d88812a31afreetds-1.00.82/doc/reference/dir_000012_dep.svg100644 025423 025423 00000004313 13242511136 0014461 src/replacements clusterdir_000003 src dir_000012 replacements dir_000000 include dir_000012->dir_000000 4 freetds-1.00.82/doc/reference/dir_000013.html100644 025423 025423 00000006105 13242511136 0014000 FreeTDS API: src/server Directory Reference
    FreeTDS API
    server Directory Reference
    Directory dependency graph for server:
    freetds-1.00.82/doc/reference/dir_000013_000000.html100644 025423 025423 00000007061 13242511133 0014576 FreeTDS API: src/server -> include Relation
    FreeTDS API

    server → include Relation

    File in src/serverIncludes file in include
    login.cfreetds / tds.h
    query.cfreetds / tds.h
    server.cfreetds / tds.h
    unittest.cfreetds / tds.h
    freetds-1.00.82/doc/reference/dir_000013_dep.map100644 025423 025423 00000000711 13242511136 0014436 freetds-1.00.82/doc/reference/dir_000013_dep.md5100644 025423 025423 00000000040 13242511133 00143360613bc985a2ce291801cabe4fe3dc3f3freetds-1.00.82/doc/reference/dir_000013_dep.svg100644 025423 025423 00000004255 13242511136 0014467 src/server clusterdir_000003 src dir_000013 server dir_000000 include dir_000013->dir_000000 4 freetds-1.00.82/doc/reference/dir_000014.html100644 025423 025423 00000005514 13242511133 0014001 FreeTDS API: src/tds/example Directory Reference
    FreeTDS API
    example Directory Reference
    freetds-1.00.82/doc/reference/dir_000015.html100644 025423 025423 00000005507 13242511133 0014004 FreeTDS API: win32 Directory Reference
    FreeTDS API
    win32 Directory Reference

    Directories

    freetds-1.00.82/doc/reference/dir_000016.html100644 025423 025423 00000005407 13242511133 0014004 FreeTDS API: win32/freetds Directory Reference
    FreeTDS API
    freetds Directory Reference
    freetds-1.00.82/doc/reference/doxygen.css100644 025423 025423 00000063445 13242511131 0013725/* The standard CSS for doxygen 1.8.12 */ body, table, div, p, dl { font: 400 14px/22px Roboto,sans-serif; } /* @group Heading Levels */ h1.groupheader { font-size: 150%; } .title { font: 400 14px/28px Roboto,sans-serif; font-size: 150%; font-weight: bold; margin: 10px 2px; } h2.groupheader { border-bottom: 1px solid #879ECB; color: #354C7B; font-size: 150%; font-weight: normal; margin-top: 1.75em; padding-top: 8px; padding-bottom: 4px; width: 100%; } h3.groupheader { font-size: 100%; } h1, h2, h3, h4, h5, h6 { -webkit-transition: text-shadow 0.5s linear; -moz-transition: text-shadow 0.5s linear; -ms-transition: text-shadow 0.5s linear; -o-transition: text-shadow 0.5s linear; transition: text-shadow 0.5s linear; margin-right: 15px; } h1.glow, h2.glow, h3.glow, h4.glow, h5.glow, h6.glow { text-shadow: 0 0 15px cyan; } dt { font-weight: bold; } div.multicol { -moz-column-gap: 1em; -webkit-column-gap: 1em; -moz-column-count: 3; -webkit-column-count: 3; } p.startli, p.startdd { margin-top: 2px; } p.starttd { margin-top: 0px; } p.endli { margin-bottom: 0px; } p.enddd { margin-bottom: 4px; } p.endtd { margin-bottom: 2px; } /* @end */ caption { font-weight: bold; } span.legend { font-size: 70%; text-align: center; } h3.version { font-size: 90%; text-align: center; } div.qindex, div.navtab{ background-color: #EBEFF6; border: 1px solid #A3B4D7; text-align: center; } div.qindex, div.navpath { width: 100%; line-height: 140%; } div.navtab { margin-right: 15px; } /* @group Link Styling */ a { color: #3D578C; font-weight: normal; text-decoration: none; } .contents a:visited { color: #4665A2; } a:hover { text-decoration: underline; } a.qindex { font-weight: bold; } a.qindexHL { font-weight: bold; background-color: #9CAFD4; color: #ffffff; border: 1px double #869DCA; } .contents a.qindexHL:visited { color: #ffffff; } a.el { font-weight: bold; } a.elRef { } a.code, a.code:visited, a.line, a.line:visited { color: #4665A2; } a.codeRef, a.codeRef:visited, a.lineRef, a.lineRef:visited { color: #4665A2; } /* @end */ dl.el { margin-left: -1cm; } pre.fragment { border: 1px solid #C4CFE5; background-color: #FBFCFD; padding: 4px 6px; margin: 4px 8px 4px 2px; overflow: auto; word-wrap: break-word; font-size: 9pt; line-height: 125%; font-family: monospace, fixed; font-size: 105%; } div.fragment { padding: 0px; margin: 4px 8px 4px 2px; background-color: #FBFCFD; border: 1px solid #C4CFE5; } div.line { font-family: monospace, fixed; font-size: 13px; min-height: 13px; line-height: 1.0; text-wrap: unrestricted; white-space: -moz-pre-wrap; /* Moz */ white-space: -pre-wrap; /* Opera 4-6 */ white-space: -o-pre-wrap; /* Opera 7 */ white-space: pre-wrap; /* CSS3 */ word-wrap: break-word; /* IE 5.5+ */ text-indent: -53px; padding-left: 53px; padding-bottom: 0px; margin: 0px; -webkit-transition-property: background-color, box-shadow; -webkit-transition-duration: 0.5s; -moz-transition-property: background-color, box-shadow; -moz-transition-duration: 0.5s; -ms-transition-property: background-color, box-shadow; -ms-transition-duration: 0.5s; -o-transition-property: background-color, box-shadow; -o-transition-duration: 0.5s; transition-property: background-color, box-shadow; transition-duration: 0.5s; } div.line:after { content:"\000A"; white-space: pre; } div.line.glow { background-color: cyan; box-shadow: 0 0 10px cyan; } span.lineno { padding-right: 4px; text-align: right; border-right: 2px solid #0F0; background-color: #E8E8E8; white-space: pre; } span.lineno a { background-color: #D8D8D8; } span.lineno a:hover { background-color: #C8C8C8; } .lineno { -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } div.ah, span.ah { background-color: black; font-weight: bold; color: #ffffff; margin-bottom: 3px; margin-top: 3px; padding: 0.2em; border: solid thin #333; border-radius: 0.5em; -webkit-border-radius: .5em; -moz-border-radius: .5em; box-shadow: 2px 2px 3px #999; -webkit-box-shadow: 2px 2px 3px #999; -moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px; background-image: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#000),color-stop(0.3, #444)); background-image: -moz-linear-gradient(center top, #eee 0%, #444 40%, #000 110%); } div.classindex ul { list-style: none; padding-left: 0; } div.classindex span.ai { display: inline-block; } div.groupHeader { margin-left: 16px; margin-top: 12px; font-weight: bold; } div.groupText { margin-left: 16px; font-style: italic; } body { background-color: white; color: black; margin: 0; } div.contents { margin-top: 10px; margin-left: 12px; margin-right: 8px; } td.indexkey { background-color: #EBEFF6; font-weight: bold; border: 1px solid #C4CFE5; margin: 2px 0px 2px 0; padding: 2px 10px; white-space: nowrap; vertical-align: top; } td.indexvalue { background-color: #EBEFF6; border: 1px solid #C4CFE5; padding: 2px 10px; margin: 2px 0px; } tr.memlist { background-color: #EEF1F7; } p.formulaDsp { text-align: center; } img.formulaDsp { } img.formulaInl { vertical-align: middle; } div.center { text-align: center; margin-top: 0px; margin-bottom: 0px; padding: 0px; } div.center img { border: 0px; } address.footer { text-align: right; padding-right: 12px; } img.footer { border: 0px; vertical-align: middle; } /* @group Code Colorization */ span.keyword { color: #008000 } span.keywordtype { color: #604020 } span.keywordflow { color: #e08000 } span.comment { color: #800000 } span.preprocessor { color: #806020 } span.stringliteral { color: #002080 } span.charliteral { color: #008080 } span.vhdldigit { color: #ff00ff } span.vhdlchar { color: #000000 } span.vhdlkeyword { color: #700070 } span.vhdllogic { color: #ff0000 } blockquote { background-color: #F7F8FB; border-left: 2px solid #9CAFD4; margin: 0 24px 0 4px; padding: 0 12px 0 16px; } /* @end */ /* .search { color: #003399; font-weight: bold; } form.search { margin-bottom: 0px; margin-top: 0px; } input.search { font-size: 75%; color: #000080; font-weight: normal; background-color: #e8eef2; } */ td.tiny { font-size: 75%; } .dirtab { padding: 4px; border-collapse: collapse; border: 1px solid #A3B4D7; } th.dirtab { background: #EBEFF6; font-weight: bold; } hr { height: 0px; border: none; border-top: 1px solid #4A6AAA; } hr.footer { height: 1px; } /* @group Member Descriptions */ table.memberdecls { border-spacing: 0px; padding: 0px; } .memberdecls td, .fieldtable tr { -webkit-transition-property: background-color, box-shadow; -webkit-transition-duration: 0.5s; -moz-transition-property: background-color, box-shadow; -moz-transition-duration: 0.5s; -ms-transition-property: background-color, box-shadow; -ms-transition-duration: 0.5s; -o-transition-property: background-color, box-shadow; -o-transition-duration: 0.5s; transition-property: background-color, box-shadow; transition-duration: 0.5s; } .memberdecls td.glow, .fieldtable tr.glow { background-color: cyan; box-shadow: 0 0 15px cyan; } .mdescLeft, .mdescRight, .memItemLeft, .memItemRight, .memTemplItemLeft, .memTemplItemRight, .memTemplParams { background-color: #F9FAFC; border: none; margin: 4px; padding: 1px 0 0 8px; } .mdescLeft, .mdescRight { padding: 0px 8px 4px 8px; color: #555; } .memSeparator { border-bottom: 1px solid #DEE4F0; line-height: 1px; margin: 0px; padding: 0px; } .memItemLeft, .memTemplItemLeft { white-space: nowrap; } .memItemRight { width: 100%; } .memTemplParams { color: #4665A2; white-space: nowrap; font-size: 80%; } /* @end */ /* @group Member Details */ /* Styles for detailed member documentation */ .memtitle { padding: 8px; border-top: 1px solid #A8B8D9; border-left: 1px solid #A8B8D9; border-right: 1px solid #A8B8D9; border-top-right-radius: 4px; border-top-left-radius: 4px; margin-bottom: -1px; background-image: url('nav_f.png'); background-repeat: repeat-x; background-color: #E2E8F2; line-height: 1.25; font-weight: 300; float:left; } .permalink { font-size: 65%; display: inline-block; vertical-align: middle; } .memtemplate { font-size: 80%; color: #4665A2; font-weight: normal; margin-left: 9px; } .memnav { background-color: #EBEFF6; border: 1px solid #A3B4D7; text-align: center; margin: 2px; margin-right: 15px; padding: 2px; } .mempage { width: 100%; } .memitem { padding: 0; margin-bottom: 10px; margin-right: 5px; -webkit-transition: box-shadow 0.5s linear; -moz-transition: box-shadow 0.5s linear; -ms-transition: box-shadow 0.5s linear; -o-transition: box-shadow 0.5s linear; transition: box-shadow 0.5s linear; display: table !important; width: 100%; } .memitem.glow { box-shadow: 0 0 15px cyan; } .memname { font-weight: 400; margin-left: 6px; } .memname td { vertical-align: bottom; } .memproto, dl.reflist dt { border-top: 1px solid #A8B8D9; border-left: 1px solid #A8B8D9; border-right: 1px solid #A8B8D9; padding: 6px 0px 6px 0px; color: #253555; font-weight: bold; text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); background-color: #DFE5F1; /* opera specific markup */ box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); border-top-right-radius: 4px; /* firefox specific markup */ -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; -moz-border-radius-topright: 4px; /* webkit specific markup */ -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); -webkit-border-top-right-radius: 4px; } .overload { font-family: "courier new",courier,monospace; font-size: 65%; } .memdoc, dl.reflist dd { border-bottom: 1px solid #A8B8D9; border-left: 1px solid #A8B8D9; border-right: 1px solid #A8B8D9; padding: 6px 10px 2px 10px; background-color: #FBFCFD; border-top-width: 0; background-image:url('nav_g.png'); background-repeat:repeat-x; background-color: #FFFFFF; /* opera specific markup */ border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); /* firefox specific markup */ -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; /* webkit specific markup */ -webkit-border-bottom-left-radius: 4px; -webkit-border-bottom-right-radius: 4px; -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); } dl.reflist dt { padding: 5px; } dl.reflist dd { margin: 0px 0px 10px 0px; padding: 5px; } .paramkey { text-align: right; } .paramtype { white-space: nowrap; } .paramname { color: #602020; white-space: nowrap; } .paramname em { font-style: normal; } .paramname code { line-height: 14px; } .params, .retval, .exception, .tparams { margin-left: 0px; padding-left: 0px; } .params .paramname, .retval .paramname { font-weight: bold; vertical-align: top; } .params .paramtype { font-style: italic; vertical-align: top; } .params .paramdir { font-family: "courier new",courier,monospace; vertical-align: top; } table.mlabels { border-spacing: 0px; } td.mlabels-left { width: 100%; padding: 0px; } td.mlabels-right { vertical-align: bottom; padding: 0px; white-space: nowrap; } span.mlabels { margin-left: 8px; } span.mlabel { background-color: #728DC1; border-top:1px solid #5373B4; border-left:1px solid #5373B4; border-right:1px solid #C4CFE5; border-bottom:1px solid #C4CFE5; text-shadow: none; color: white; margin-right: 4px; padding: 2px 3px; border-radius: 3px; font-size: 7pt; white-space: nowrap; vertical-align: middle; } /* @end */ /* these are for tree view inside a (index) page */ div.directory { margin: 10px 0px; border-top: 1px solid #9CAFD4; border-bottom: 1px solid #9CAFD4; width: 100%; } .directory table { border-collapse:collapse; } .directory td { margin: 0px; padding: 0px; vertical-align: top; } .directory td.entry { white-space: nowrap; padding-right: 6px; padding-top: 3px; } .directory td.entry a { outline:none; } .directory td.entry a img { border: none; } .directory td.desc { width: 100%; padding-left: 6px; padding-right: 6px; padding-top: 3px; border-left: 1px solid rgba(0,0,0,0.05); } .directory tr.even { padding-left: 6px; background-color: #F7F8FB; } .directory img { vertical-align: -30%; } .directory .levels { white-space: nowrap; width: 100%; text-align: right; font-size: 9pt; } .directory .levels span { cursor: pointer; padding-left: 2px; padding-right: 2px; color: #3D578C; } .arrow { color: #9CAFD4; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; cursor: pointer; font-size: 80%; display: inline-block; width: 16px; height: 22px; } .icon { font-family: Arial, Helvetica; font-weight: bold; font-size: 12px; height: 14px; width: 16px; display: inline-block; background-color: #728DC1; color: white; text-align: center; border-radius: 4px; margin-left: 2px; margin-right: 2px; } .icona { width: 24px; height: 22px; display: inline-block; } .iconfopen { width: 24px; height: 18px; margin-bottom: 4px; background-image:url('folderopen.png'); background-position: 0px -4px; background-repeat: repeat-y; vertical-align:top; display: inline-block; } .iconfclosed { width: 24px; height: 18px; margin-bottom: 4px; background-image:url('folderclosed.png'); background-position: 0px -4px; background-repeat: repeat-y; vertical-align:top; display: inline-block; } .icondoc { width: 24px; height: 18px; margin-bottom: 4px; background-image:url('doc.png'); background-position: 0px -4px; background-repeat: repeat-y; vertical-align:top; display: inline-block; } table.directory { font: 400 14px Roboto,sans-serif; } /* @end */ div.dynheader { margin-top: 8px; -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } address { font-style: normal; color: #2A3D61; } table.doxtable caption { caption-side: top; } table.doxtable { border-collapse:collapse; margin-top: 4px; margin-bottom: 4px; } table.doxtable td, table.doxtable th { border: 1px solid #2D4068; padding: 3px 7px 2px; } table.doxtable th { background-color: #374F7F; color: #FFFFFF; font-size: 110%; padding-bottom: 4px; padding-top: 5px; } table.fieldtable { /*width: 100%;*/ margin-bottom: 10px; border: 1px solid #A8B8D9; border-spacing: 0px; -moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius: 4px; -moz-box-shadow: rgba(0, 0, 0, 0.15) 2px 2px 2px; -webkit-box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.15); box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.15); } .fieldtable td, .fieldtable th { padding: 3px 7px 2px; } .fieldtable td.fieldtype, .fieldtable td.fieldname { white-space: nowrap; border-right: 1px solid #A8B8D9; border-bottom: 1px solid #A8B8D9; vertical-align: top; } .fieldtable td.fieldname { padding-top: 3px; } .fieldtable td.fielddoc { border-bottom: 1px solid #A8B8D9; /*width: 100%;*/ } .fieldtable td.fielddoc p:first-child { margin-top: 0px; } .fieldtable td.fielddoc p:last-child { margin-bottom: 2px; } .fieldtable tr:last-child td { border-bottom: none; } .fieldtable th { background-image:url('nav_f.png'); background-repeat:repeat-x; background-color: #E2E8F2; font-size: 90%; color: #253555; padding-bottom: 4px; padding-top: 5px; text-align:left; font-weight: 400; -moz-border-radius-topleft: 4px; -moz-border-radius-topright: 4px; -webkit-border-top-left-radius: 4px; -webkit-border-top-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; border-bottom: 1px solid #A8B8D9; } .tabsearch { top: 0px; left: 10px; height: 36px; background-image: url('tab_b.png'); z-index: 101; overflow: hidden; font-size: 13px; } .navpath ul { font-size: 11px; background-image:url('tab_b.png'); background-repeat:repeat-x; background-position: 0 -5px; height:30px; line-height:30px; color:#8AA0CC; border:solid 1px #C2CDE4; overflow:hidden; margin:0px; padding:0px; } .navpath li { list-style-type:none; float:left; padding-left:10px; padding-right:15px; background-image:url('bc_s.png'); background-repeat:no-repeat; background-position:right; color:#364D7C; } .navpath li.navelem a { height:32px; display:block; text-decoration: none; outline: none; color: #283A5D; font-family: 'Lucida Grande',Geneva,Helvetica,Arial,sans-serif; text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.9); text-decoration: none; } .navpath li.navelem a:hover { color:#6884BD; } .navpath li.footer { list-style-type:none; float:right; padding-left:10px; padding-right:15px; background-image:none; background-repeat:no-repeat; background-position:right; color:#364D7C; font-size: 8pt; } div.summary { float: right; font-size: 8pt; padding-right: 5px; width: 50%; text-align: right; } div.summary a { white-space: nowrap; } table.classindex { margin: 10px; white-space: nowrap; margin-left: 3%; margin-right: 3%; width: 94%; border: 0; border-spacing: 0; padding: 0; } div.ingroups { font-size: 8pt; width: 50%; text-align: left; } div.ingroups a { white-space: nowrap; } div.header { background-image:url('nav_h.png'); background-repeat:repeat-x; background-color: #F9FAFC; margin: 0px; border-bottom: 1px solid #C4CFE5; } div.headertitle { padding: 5px 5px 5px 10px; } dl { padding: 0 0 0 10px; } /* dl.note, dl.warning, dl.attention, dl.pre, dl.post, dl.invariant, dl.deprecated, dl.todo, dl.test, dl.bug */ dl.section { margin-left: 0px; padding-left: 0px; } dl.note { margin-left:-7px; padding-left: 3px; border-left:4px solid; border-color: #D0C000; } dl.warning, dl.attention { margin-left:-7px; padding-left: 3px; border-left:4px solid; border-color: #FF0000; } dl.pre, dl.post, dl.invariant { margin-left:-7px; padding-left: 3px; border-left:4px solid; border-color: #00D000; } dl.deprecated { margin-left:-7px; padding-left: 3px; border-left:4px solid; border-color: #505050; } dl.todo { margin-left:-7px; padding-left: 3px; border-left:4px solid; border-color: #00C0E0; } dl.test { margin-left:-7px; padding-left: 3px; border-left:4px solid; border-color: #3030E0; } dl.bug { margin-left:-7px; padding-left: 3px; border-left:4px solid; border-color: #C08050; } dl.section dd { margin-bottom: 6px; } #projectlogo { text-align: center; vertical-align: bottom; border-collapse: separate; } #projectlogo img { border: 0px none; } #projectalign { vertical-align: middle; } #projectname { font: 300% Tahoma, Arial,sans-serif; margin: 0px; padding: 2px 0px; } #projectbrief { font: 120% Tahoma, Arial,sans-serif; margin: 0px; padding: 0px; } #projectnumber { font: 50% Tahoma, Arial,sans-serif; margin: 0px; padding: 0px; } #titlearea { padding: 0px; margin: 0px; width: 100%; border-bottom: 1px solid #5373B4; } .image { text-align: center; } .dotgraph { text-align: center; } .mscgraph { text-align: center; } .diagraph { text-align: center; } .caption { font-weight: bold; } div.zoom { border: 1px solid #90A5CE; } dl.citelist { margin-bottom:50px; } dl.citelist dt { color:#334975; float:left; font-weight:bold; margin-right:10px; padding:5px; } dl.citelist dd { margin:2px 0; padding:5px 0; } div.toc { padding: 14px 25px; background-color: #F4F6FA; border: 1px solid #D8DFEE; border-radius: 7px 7px 7px 7px; float: right; height: auto; margin: 0 8px 10px 10px; width: 200px; } div.toc li { background: url("bdwn.png") no-repeat scroll 0 5px transparent; font: 10px/1.2 Verdana,DejaVu Sans,Geneva,sans-serif; margin-top: 5px; padding-left: 10px; padding-top: 2px; } div.toc h3 { font: bold 12px/1.2 Arial,FreeSans,sans-serif; color: #4665A2; border-bottom: 0 none; margin: 0; } div.toc ul { list-style: none outside none; border: medium none; padding: 0px; } div.toc li.level1 { margin-left: 0px; } div.toc li.level2 { margin-left: 15px; } div.toc li.level3 { margin-left: 30px; } div.toc li.level4 { margin-left: 45px; } .inherit_header { font-weight: bold; color: gray; cursor: pointer; -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; } .inherit_header td { padding: 6px 0px 2px 5px; } .inherit { display: none; } tr.heading h2 { margin-top: 12px; margin-bottom: 4px; } /* tooltip related style info */ .ttc { position: absolute; display: none; } #powerTip { cursor: default; white-space: nowrap; background-color: white; border: 1px solid gray; border-radius: 4px 4px 4px 4px; box-shadow: 1px 1px 7px gray; display: none; font-size: smaller; max-width: 80%; opacity: 0.9; padding: 1ex 1em 1em; position: absolute; z-index: 2147483647; } #powerTip div.ttdoc { color: grey; font-style: italic; } #powerTip div.ttname a { font-weight: bold; } #powerTip div.ttname { font-weight: bold; } #powerTip div.ttdeci { color: #006318; } #powerTip div { margin: 0px; padding: 0px; font: 12px/16px Roboto,sans-serif; } #powerTip:before, #powerTip:after { content: ""; position: absolute; margin: 0px; } #powerTip.n:after, #powerTip.n:before, #powerTip.s:after, #powerTip.s:before, #powerTip.w:after, #powerTip.w:before, #powerTip.e:after, #powerTip.e:before, #powerTip.ne:after, #powerTip.ne:before, #powerTip.se:after, #powerTip.se:before, #powerTip.nw:after, #powerTip.nw:before, #powerTip.sw:after, #powerTip.sw:before { border: solid transparent; content: " "; height: 0; width: 0; position: absolute; } #powerTip.n:after, #powerTip.s:after, #powerTip.w:after, #powerTip.e:after, #powerTip.nw:after, #powerTip.ne:after, #powerTip.sw:after, #powerTip.se:after { border-color: rgba(255, 255, 255, 0); } #powerTip.n:before, #powerTip.s:before, #powerTip.w:before, #powerTip.e:before, #powerTip.nw:before, #powerTip.ne:before, #powerTip.sw:before, #powerTip.se:before { border-color: rgba(128, 128, 128, 0); } #powerTip.n:after, #powerTip.n:before, #powerTip.ne:after, #powerTip.ne:before, #powerTip.nw:after, #powerTip.nw:before { top: 100%; } #powerTip.n:after, #powerTip.ne:after, #powerTip.nw:after { border-top-color: #ffffff; border-width: 10px; margin: 0px -10px; } #powerTip.n:before { border-top-color: #808080; border-width: 11px; margin: 0px -11px; } #powerTip.n:after, #powerTip.n:before { left: 50%; } #powerTip.nw:after, #powerTip.nw:before { right: 14px; } #powerTip.ne:after, #powerTip.ne:before { left: 14px; } #powerTip.s:after, #powerTip.s:before, #powerTip.se:after, #powerTip.se:before, #powerTip.sw:after, #powerTip.sw:before { bottom: 100%; } #powerTip.s:after, #powerTip.se:after, #powerTip.sw:after { border-bottom-color: #ffffff; border-width: 10px; margin: 0px -10px; } #powerTip.s:before, #powerTip.se:before, #powerTip.sw:before { border-bottom-color: #808080; border-width: 11px; margin: 0px -11px; } #powerTip.s:after, #powerTip.s:before { left: 50%; } #powerTip.sw:after, #powerTip.sw:before { right: 14px; } #powerTip.se:after, #powerTip.se:before { left: 14px; } #powerTip.e:after, #powerTip.e:before { left: 100%; } #powerTip.e:after { border-left-color: #ffffff; border-width: 10px; top: 50%; margin-top: -10px; } #powerTip.e:before { border-left-color: #808080; border-width: 11px; top: 50%; margin-top: -11px; } #powerTip.w:after, #powerTip.w:before { right: 100%; } #powerTip.w:after { border-right-color: #ffffff; border-width: 10px; top: 50%; margin-top: -10px; } #powerTip.w:before { border-right-color: #808080; border-width: 11px; top: 50%; margin-top: -11px; } @media print { #top { display: none; } #side-nav { display: none; } #nav-path { display: none; } body { overflow:visible; } h1, h2, h3, h4, h5, h6 { page-break-after: avoid; } .summary { display: none; } .memitem { page-break-inside: avoid; } #doc-content { margin-left:0 !important; height:auto !important; width:auto !important; overflow:inherit; display:inline; } } freetds-1.00.82/doc/reference/doxygen.png100644 025423 025423 00000007303 13242511131 0013710‰PNG  IHDRh ;ˆØŠIDATxí]y\•Õº~45%TL Q”PE"q–Û11±]8a„w*©¨(*â" ˆzÀè`8 ¨‰¢mÅ,’òà„p$%”œBó(8k†Ü÷ýÜû6lòö»§k÷Ç÷[ÏÞß·Ö;?k½ëßÕÕÕPxÑêÏ't´ÏùÈ€zÀÇÅ3_€Q4€g@œmÿ ¾ò‰âci‰ôçÿ{ ðÇð¬ù~½Á€4:õHcÂü ðŸÁ³„ª'ÕPÆæ P7^h،♠zb„cóP¨„ 3‚† Ò}çÿO²qÁºNkÝTÛ(É?d Ç~z<’«4Óǡ؞Þv­zµÙ¦õ¬ZâdÛ,Ë6Ók±]Fz< ¾ZçƒsÕ?ìƒsUø2SÉåwê1”c`[ì—}%ѽ.Ô¼6‚BLZ˜û!F8[ ¹…×TéÛ— »Þ#gó]å:vžu?‡vèbÙR˜?wùŽŸ¾ÊÐgbÑÉÌÕ$kF~Ê;عÆ•¢ïX®?ÉèlÆÙôõà»Nʪ¼­,ìHC§gAz•ÆlÓº­gÑú ]œjÎñåM…3ÓÚæoÒ³'=‘$Ò÷f}G•ŸS_‡öèco.Êȹ :ó£ Ãds®Ù:1=¼{ƒå9?÷ý…zqÛvîÓi‰D’p¿Ë šmÙíoÛâýaÖüEqÒµwÌ}¿~{òj€ç{ôºŸFNëí[ëOq·ÇOSúXO]°>‚‚muæÄ¾e¤“5Ë{¨JÕ¯£(›´«bÂçû’ÍlÓÅ}žïú`éUÞy„ac§Á†ÔCºŠóAkl‘±y¥†ô¢ùôs÷Aø¬7ÄõôoJ±äÄ ù.¥Be. Z¬Ð×ÇÈöå¹­ù'Ù-PëìŠyF.ž‚žÝÚ€lp&.êˆð•jò7’re’z19»ã§HGíø%œüq°ïüz׈c¬_k_")ŸHJnÐÑ~ˆÐÖ˜á´äÕ5 µÁq€ÿ5#¸·îà¶+9T‘‚ ðŽ÷Rܸrz“Ï´Ì =Ï…{ðáO£Èf ¡Íwg|Ž’Ü/¢Þ$÷¯¢ëðúÀ;¿à¨Ö™âÒÆ­]¯ÜW"Þ/< ‡÷DÏà°½üB}çyIEc^—ƒ=[V“Ýh²ëMä$l];Kû®¸ýr¦È*Åò ÿtÒõ$]•MŸ÷´;×I€1èó!‚œõ¸M õ¨(fÌæ<ÁÎÎò5~z¿ù¶ž mÌêÕ >–âÚ©âëˆIÎÞçz;ãu[i·eç^ÆÜÙÓ³NÞëF6B\}7†»+üŽÓ,Ã'a ½˜-yHY¿,‘^—ñfú~ß?Hcø¸…¸ñó{Z+4\såƒû·¯Ù·nߣð«íFÆ¡sغëû§D¾?ò<–Ævkx0ÅM±ælذÁIÓxÿd”žÜÉ÷EE»AªM«g*È£YEí7Û™^[uíý®v[wGå†=Ed¼n×¶ÆæÖÅl¡'¨pGÚk+‹æ¢À¬¨C8ªâš2 dz3H£ß ¡¨BÒûSÃÅù[wŘ ~xpçútÁæmö¤Å£¥iQæ­‰AB1ÉfÙ‰›4u¹ïìIÒ]Ë6äò%ÿ†† 1t.’NJph¬zÌ ÎR1Ž"3-"¸‡‹&ìó°1âüžìó[:‡ï„¼‘……N m–“W0®_èÜœ ×õ6ùò&»)Æìꦬýæ}¬ñ~»{múù]z½£M•ºP~^Îá:eQTÙ_*7ÕÄ9É8—·Ëï 3°¶47E•î¿u÷“SÉ»U¯ _ NíºôW¬e¸ÄNÓ|»;™¿;ŒæÅd"ȉôøòÞµõï¾®½"èÄ´ÖMM+bYµ‘_ÉæEÝüÎ]P»¹XKÐI½Þ¥oE<_¹(„EP±Œ|mÇÁ¡‘Ý,ŠÓ©ººZ±Îߺ§×kÝ,kÍMš`Äø…jzeU»æ ™Át3ÓÀ½˜6—ÒöùË·r¨¹Ñ}““wö:Χùë¼ ¿|‚TܵÉQˆKßç_ÁâÀ™œ”pÑÐóໃ¼Ydâ0!®àa –øöçW$ÃÁ‘Á$/\¬$ð 2ÞímÞLH‹Ÿ èd£HVÜ,:ò½»RÍZšJ­a„z*>‹_…NT(ù‚^SVF­U¹8ñEþôñ܈óùnd;«®8™\C]ø=Èêm¬Æ:‚´ÆbãDd=Áãßžˆ‹UU5O‹|]þð®Pèêv‰á\]2ßìÿ"yÈ[ïyʧz£g{Y«{„Ùø5©ÿ;w{N3é­nâĨw§Á¢ÍK¢Ý­ûÏ29Id¿’ì y)ìPÞò8ŒÅ©¯‰±@mPÔñwjl,6 áhWÕ˜d öà uõmÁp®.™á£Ç…twöR x­BδYcŒxg*vo  yò‘•“[¬?ÜVœ˜0ÒN¡O난~Žó’¯·h#´Hkýœ±8kÓß^Àq@]àÓ“ø,56´¯÷Í-κU»n…[>]@nîøÏœp›[œ6# €4tën¯:ŽÒþ}…—8äT9_žY$/´G’K™©ù†•(óÑ’Mø©`ŸÉdѺ;ùO‹B Ó&P{qöhJÉ+Úé–§¦l2«MïöÝ_1ÑÓ«’t¸½±l€ëØya ¦ô©«®½ÆL^¬žêñš¸ùy.¾Û½Š[ u/]½‹iS}øN>²e1™q‡jfÚ&¢©iT\=kÏ›ÀXô-.84V5ðu!TE˜ þ.ŒOH´¶4—zwTr.ï‰¦Ë xõµ·œÖ„HÆù£žÈHùg Ñhñ’T$ßyq¸zþ¨p¿´ë< q•ró÷š‰wÿÍÑð–I]´–æI²é²˜sÂ"×:Õ–bÕ¦“ÈÙL6¢9VÊÓWž§<æ;”3?ý©Mê3AV#µ±ËÞ¯‘ž K£UrÝ9!›qát¦H£Ù+6ÇV…/TS^pÃùqgLP'Ú5E ‚–ÀÞºîÄ Ën"2|Ÿ;®W»Îý"Ö¬TwÖâµtúŽO'› á+W Ã+¦âZÌ–<ÕÆ&nOÝ,IŠ£06.ÁZ.Çñúøh*INÚ’Oe½ÉgBXÐÔZóäøä9èü“hÒíDSš¥¡Ê µA¯/Ôc¸ö“`A§¯"zå|‘ €ÅŸ¨ú;HÍ#‚Î|%ÄOˆƒ«OàÌÉÐÜD ž mÜðâc–ƤÉÂqm¶uË&~÷núÒË £ÇÏ€ZÕj =«_n[‡‡÷nN§ÏÝ$_¾bE˜‚€Õ)ù8¾?6‘lú“ÍÙæÖ}#bW( œ³d-®•p&¡ý’œÖa”"9öõņÐ$’Ú›AÜ!ä;ÐÑõè{~á¹8‘ÛÞ£1ÛÓÉ0ž`²#´kÒuäNÅÖ Q¹bhæ ”8ûÓMáŽa›•¿”w±h²¢®qŠæ°(bK ‚’Z¾Ò%ÐÆémáãÖË(Éý‚ÛJ)@> þ›7% ï{y Á“¾ÆÒîohfòô>{pÿ.­_Î%±ÉèägëlZØ\B2B #™¸ÚüÒºp‚hÝšü®[¥Ü<‹#SpñÌA7’ãØHƒt4:Ÿ|g¨tÓL¶*($Æ©»ì…®ù’ó÷$;b›ÔÙ`=¶£¦M„MÌÄ5ò«·Ç¾“H·ÌH.¼žHeAîº5}r­dõ¨±)ÀT};€Q5iÖ2…O0ü…0óñÃ;óæ,Š´²µ냔}g‘£]‹7å9ˆà©_{üèîêžC>úhê{Ž .ÈìðIIð€?[Kswz6Òuíý¬;µ€ç§OåâJÉa˶zv°éd† ¤µâ‚l´é舊«Åüy¾c÷ÁèÖÍ'ràúÅ™TWÕôÓ°¡L €|ʽŒ¼ì­høBã ÝTëî'ò]Kø£ìâÏ(=¹Kx €¿ LÌ,Pý¤Êµu‡¹…׈ §Å¾÷à1Ý«Äý;¿pGDäxZYÛ kfæ6¸ùóæ7®œ®þ6·ÕoÚ¾ÔH~ò®Þ¸â 8Uø“p<ºw3¡a£ÏÑ’‘3èÏ"€bˆ-ÎܺÏ_ªÅ]+ËM©zü°s“f-êçhÇãÑýÊãôÿ5}ZQNb{Ó?å%ÿ\SUõعIÓæ}~}p[œoÔÄ„êÐMMZáNÅå@>Œ„²á6(?¡Åé âK½+ü?À%ÝÝ·/Ç1‚9áUø?B)”ÕèâÞlÈÒêÏ @=àùÄÞžk­®ÅIEND®B`‚freetds-1.00.82/doc/reference/dynsections.js100644 025423 025423 00000006104 13242511131 0014423function toggleVisibility(linkObj) { var base = $(linkObj).attr('id'); var summary = $('#'+base+'-summary'); var content = $('#'+base+'-content'); var trigger = $('#'+base+'-trigger'); var src=$(trigger).attr('src'); if (content.is(':visible')===true) { content.hide(); summary.show(); $(linkObj).addClass('closed').removeClass('opened'); $(trigger).attr('src',src.substring(0,src.length-8)+'closed.png'); } else { content.show(); summary.hide(); $(linkObj).removeClass('closed').addClass('opened'); $(trigger).attr('src',src.substring(0,src.length-10)+'open.png'); } return false; } function updateStripes() { $('table.directory tr'). removeClass('even').filter(':visible:even').addClass('even'); } function toggleLevel(level) { $('table.directory tr').each(function() { var l = this.id.split('_').length-1; var i = $('#img'+this.id.substring(3)); var a = $('#arr'+this.id.substring(3)); if (l FreeTDS API: File List
    FreeTDS API
    File List
    Here is a list of all documented files with brief descriptions:
    [detail level 1234]
      include
      freetds
     alloca.h
     bool.h
     bytes.h
     checks.h
     configs.h
     convert.h
     data.h
     dlist.h
     dlist.tmpl.h
     enum_cap.h
     iconv.h
     odbc.h
     popvis.h
     proto.h
     pushvis.h
     server.h
     stream.h
     string.h
     sysdep_private.h
     tds.hMain include file for libtds
     thread.h
     time.h
     tls.h
     version.h
      replacements
     poll.hProvide poll call where missing
     readpassphrase.h
     bkpublic.h
     config.h
     cspublic.h
     cstypes.h
     ctlib.h
     ctpublic.h
     dblib.h
     des.h
     hmac_md5.h
     md4.h
     md5.h
     odbcss.h
     replacements.h
     sqldb.h
     sqlfront.h
     sybdb.dox.h
     sybdb.hPrimary include file for db-lib applications
     syberror.h
     sybfront.h
     tds_sysdep_public.h
      src
      apps
      fisql
     edit.h
     handlers.h
     interrupt.h
     terminal.h
     freebcp.h
      dblib
     buffering.h
     dblib.cMain implementation file for db-lib
     error_table.h
      odbc
     error_export.h
     odbc_export.h
     resource.h
     sqlwparams.h
      pool
     pool.h
      replacements
     iconv.cThis file implements a very simple iconv
      tds
     alternative_character_sets.h
     bulk.cHandle bulk copy
     character_sets.h
     data.cHandle different data handling from network
     encodings.h
     iconv.cHandle character conversions to/from server
     num_limits.h
     read.cGrab data from TDS packets
     sec_negotiate_gnutls.h
     sec_negotiate_openssl.h
     stream.cHandle stream of data
     tds_types.h
     tds_willconvert.h
     token.cContains all routines to get replies from server
      vms
     vargdefs.h
      win32
      freetds
     sysconfdir.h
    freetds-1.00.82/doc/reference/folderclosed.png100644 025423 025423 00000001150 13242511136 0014677‰PNG  IHDRÚ}\ˆ/IDATxí]MOÔ@~ÚúuØlp]ö¿#›Å]PYECˆ\9ù¼yÑß`ÖÄÿàÿÀÉxóâ¢C &=qÐÄ£—vZçv¶3m؃‡vžLûNç}Þ÷}Þ½ZA@n° OäNp ’xóþK°ññ€xÜj”°8sÑ€“ “€œ_¼[Âíæ§ïD'‚•yye+ø¼û 7#rNŸlïük* ¾0Ь_d«_(àñÖ±àôz=ñxõv§÷h©‰z¹€šØP-äóä’̪uý¼$»\DãJc—B4¯ãÝÖ.:£Ï-ÑÏß}µŠLEíºþ #—ûáºÀÏgN;BŠ€6ïýñ䬜…ö@’Ðåñp&™h>p9¤™EEά¨ÎÊ‘" u¥n€$R"?{¹<˜…ë…%PNtâ$‰ß¶±úá+^<é"§2 ªDq”q´\¬«Ò™a–Œ‘©Aÿ€"Ôµ ™êŸèP£}#Eàz{û.8i îp³ê(ADwD¦E<ê¬cE¦$ HdÊÄ ”.:Ù GŽ-`ŒL‚ý¾'¢‰Ä<¤CIª½;ÙÇTZd±i};>èôß‚z×;K×§8t ¤Ž q”:uvÿv•Ý›¬²ÙvEân{„M·FXg¼ÌfZÖ¨°¹‰*›ßÌß©±ù©:›j–YqèÜë#3çÏSøWøÿÿÑr'ø Ôùù‚ ©¡IEND®B`‚freetds-1.00.82/doc/reference/folderopen.png100644 025423 025423 00000001125 13242511136 0014371‰PNG  IHDRÚ}\ˆIDATxí]?oÓPÿ9iš4i°;ii“¶‰ZЉ‘‰ÀÀ7`bèÔÙ¬Øù,HìU'ô$*Tµ]‚T¡DPÚÄ6wÏ}‰;¡C; a¿ÓߟûÝïîž¼jAÀ­InSþ}€9H“ÓŽ|?íÁ÷ =_ÊÆŠ­†¥Àue*;¯YEäsYäæB¢Ÿ¿þÄ—£sÙ½½ÙŒ† É«›©ÀYÇq !GÇ¿v̇¹ÑØ®š °Œ‚ÔF¹}q¥b]÷7í·0)Úd›¾ÿð-èº}Pfä£ÖY{4™ÑÂ@}úæôñ2ÛüÔ—ñúåNŒI‚ÁǃcçÁº%£¬UаI³mc±ô˜å¼ÔÆüÈ>é¸xþt9Æ$µý OæVE*õU´Ì‚ç#ž×ˆ•ïûr@l$øPÿrHaaÇ¥ ²›dZ®rè‘ãqI„o¼øT\Ž,tªj2FAxv-LŸp׌p TÄI/ \¥sfí½; jViTƒèú¤o^cpÅü¼ûû»Ïb]”€¢¤<†aþÕœ²“ßÓ˜y“£§9:Œîù+À³€ñà,E žf³6éNˆÄE£KU}Ü^;¶ØnZ¢uß­US4— ѬëbížN¶.Úk¦ØjTÄöº%µªâ i¯VÄÊÝò§™ Èù¸)ùÿG€™òºJ@T x”IEND®B`‚freetds-1.00.82/doc/reference/functions.html100644 025423 025423 00000043427 13242511133 0014434 FreeTDS API: Class Members
    FreeTDS API
    Here is a list of all documented class members with links to the class documentation for each member:

    - a -

    - b -

    - c -

    - d -

    - e -

    - f -

    - h -

    - i -

    - l -

    - m -

    - n -

    - o -

    - p -

    - q -

    - r -

    - s -

    - t -

    - u -

    - w -

    - y -

    freetds-1.00.82/doc/reference/functions_vars.html100644 025423 025423 00000043247 13242511133 0015467 FreeTDS API: Class Members - Variables
    FreeTDS API
     

    - a -

    - b -

    - c -

    - d -

    - e -

    - f -

    - h -

    - i -

    - l -

    - m -

    - n -

    - o -

    - p -

    - q -

    - r -

    - s -

    - t -

    - u -

    - w -

    - y -

    freetds-1.00.82/doc/reference/globals.html100644 025423 025423 00000005422 13242511133 0014040 FreeTDS API: File Members
    FreeTDS API
    Here is a list of all documented file members with links to the documentation:

    - _ -

    freetds-1.00.82/doc/reference/globals_a.html100644 025423 025423 00000005273 13242511133 0014344 FreeTDS API: File Members
    FreeTDS API
    Here is a list of all documented file members with links to the documentation:

    - a -

    • adjust_character_column_size() : token.c
    freetds-1.00.82/doc/reference/globals_b.html100644 025423 025423 00000010311 13242511133 0014332 FreeTDS API: File Members
    FreeTDS API
    Here is a list of all documented file members with links to the documentation:

    - b -

    freetds-1.00.82/doc/reference/globals_d.html100644 025423 025423 00000075562 13242511133 0014357 FreeTDS API: File Members
    FreeTDS API
    Here is a list of all documented file members with links to the documentation:

    - d -

    freetds-1.00.82/doc/reference/globals_defs.html100644 025423 025423 00000014173 13242511133 0015044 FreeTDS API: File Members
    FreeTDS API
     

    - b -

    - d -

    - i -

    • is_datetime_type : tds.h

    - t -

    freetds-1.00.82/doc/reference/globals_enum.html100644 025423 025423 00000005350 13242511133 0015064 FreeTDS API: File Members
    FreeTDS API
     
    freetds-1.00.82/doc/reference/globals_eval.html100644 025423 025423 00000010453 13242511133 0015047 FreeTDS API: File Members
    FreeTDS API
     
    freetds-1.00.82/doc/reference/globals_func.html100644 025423 025423 00000005255 13242511133 0015057 FreeTDS API: File Members
    FreeTDS API
     

    - _ -

    freetds-1.00.82/doc/reference/globals_func_a.html100644 025423 025423 00000005126 13242511133 0015354 FreeTDS API: File Members
    FreeTDS API
     

    - a -

    • adjust_character_column_size() : token.c
    freetds-1.00.82/doc/reference/globals_func_b.html100644 025423 025423 00000007777 13242511133 0015373 FreeTDS API: File Members
    FreeTDS API
     

    - b -

    freetds-1.00.82/doc/reference/globals_func_d.html100644 025423 025423 00000067123 13242511133 0015364 FreeTDS API: File Members
    FreeTDS API
     

    - d -

    freetds-1.00.82/doc/reference/globals_func_r.html100644 025423 025423 00000005111 13242511133 0015367 FreeTDS API: File Members
    FreeTDS API
     

    - r -

    freetds-1.00.82/doc/reference/globals_func_s.html100644 025423 025423 00000005121 13242511133 0015371 FreeTDS API: File Members
    FreeTDS API
     

    - s -

    • skip_one_input_sequence() : iconv.c
    freetds-1.00.82/doc/reference/globals_func_t.html100644 025423 025423 00000060160 13242511133 0015376 FreeTDS API: File Members
    FreeTDS API
     

    - t -

    freetds-1.00.82/doc/reference/globals_i.html100644 025423 025423 00000005252 13242511133 0014351 FreeTDS API: File Members
    FreeTDS API
    Here is a list of all documented file members with links to the documentation:

    - i -

    • is_datetime_type : tds.h
    freetds-1.00.82/doc/reference/globals_r.html100644 025423 025423 00000005256 13242511133 0014366 FreeTDS API: File Members
    FreeTDS API
    Here is a list of all documented file members with links to the documentation:

    - r -

    freetds-1.00.82/doc/reference/globals_s.html100644 025423 025423 00000005266 13242511133 0014370 FreeTDS API: File Members
    FreeTDS API
    Here is a list of all documented file members with links to the documentation:

    - s -

    • skip_one_input_sequence() : iconv.c
    freetds-1.00.82/doc/reference/globals_t.html100644 025423 025423 00000070421 13242511133 0014364 FreeTDS API: File Members
    FreeTDS API
    Here is a list of all documented file members with links to the documentation:

    - t -

    freetds-1.00.82/doc/reference/globals_type.html100644 025423 025423 00000007651 13242511133 0015107 FreeTDS API: File Members
    FreeTDS API
     
    freetds-1.00.82/doc/reference/globals_vars.html100644 025423 025423 00000005223 13242511133 0015072 FreeTDS API: File Members
    FreeTDS API
     
    • tds_numeric_bytes_per_prec : tds.h
    • tds_write_dump : tds.h
    freetds-1.00.82/doc/reference/graph_legend.html100644 025423 025423 00000013452 13242511136 0015041 FreeTDS API: Graph Legend
    FreeTDS API
    Graph Legend

    This page explains how to interpret the graphs that are generated by doxygen.

    Consider the following example:

    /*! Invisible class because of truncation */
    class Invisible { };
    /*! Truncated class, inheritance relation is hidden */
    class Truncated : public Invisible { };
    /* Class not documented with doxygen comments */
    class Undocumented { };
    /*! Class that is inherited using public inheritance */
    class PublicBase : public Truncated { };
    /*! A template class */
    template<class T> class Templ { };
    /*! Class that is inherited using protected inheritance */
    class ProtectedBase { };
    /*! Class that is inherited using private inheritance */
    class PrivateBase { };
    /*! Class that is used by the Inherited class */
    class Used { };
    /*! Super class that inherits a number of other classes */
    class Inherited : public PublicBase,
    protected ProtectedBase,
    private PrivateBase,
    public Undocumented,
    public Templ<int>
    {
    private:
    Used *m_usedClass;
    };

    This will result in the following graph:

    The boxes in the above graph have the following meaning:

    • A filled gray box represents the struct or class for which the graph is generated.
    • A box with a black border denotes a documented struct or class.
    • A box with a gray border denotes an undocumented struct or class.
    • A box with a red border denotes a documented struct or class forwhich not all inheritance/containment relations are shown. A graph is truncated if it does not fit within the specified boundaries.

    The arrows have the following meaning:

    • A dark blue arrow is used to visualize a public inheritance relation between two classes.
    • A dark green arrow is used for protected inheritance.
    • A dark red arrow is used for private inheritance.
    • A purple dashed arrow is used if a class is contained or used by another class. The arrow is labelled with the variable(s) through which the pointed class or struct is accessible.
    • A yellow dashed arrow denotes a relation between a template instance and the template class it was instantiated from. The arrow is labelled with the template parameters of the instance.
    freetds-1.00.82/doc/reference/graph_legend.md5100644 025423 025423 00000000040 13242511133 0014544387ff8eb65306fa251338d3c9bd7bffffreetds-1.00.82/doc/reference/graph_legend.svg100644 025423 025423 00000014760 13242511136 0014677 Graph Legend Node9 Inherited Node10 PublicBase Node10->Node9 Node11 Truncated Node11->Node10 Node13 ProtectedBase Node13->Node9 Node14 PrivateBase Node14->Node9 Node15 Undocumented Node15->Node9 Node16 Templ< int > Node16->Node9 Node17 Templ< T > Node17->Node16 < int > Node18 Used Node18->Node9 m_usedClass freetds-1.00.82/doc/reference/index.html100644 025423 025423 00000010267 13242511133 0013527 FreeTDS API: FreeTDS Reference Manual
    FreeTDS API
    FreeTDS Reference Manual

    Introduction

    Given that the vendors provide their own complete documentation for their implementations, one might ask why embark on this adventure at all? The answer is both principled and practical.

    First, this is our implementation, and to be complete it needs independent documentation. Unlike the vendors' offerings, ours offers some features from each version, while lacking others. When we have been forced to choose between documented behaviors, the FreeTDS user is presumably best served by the FreeTDS reference manual.

    Second, while the vendors today freely offer their documentation on the world wide web, that might not – in fact, surely will not – always be the case. Should the vendor decide to drop its offering for whatever reason, it will likely pull its documentation, too, sooner or later. Free sofware, in short, can lean on the capitalist model for support, but it can never rely on it.

    Status

    This manual is incomplete, and is being completed in fits and starts. The focus to date has been on db-lib and the underlying network library, libtds. It's the kind of enormous Quixoitic undertaking that you'd reasonably doubt will ever be completed. If you feel inclined to jump in, please don't hesitate.

    The organization of the manual could be better. We're still learning how to use Doxygen to best effect.

    Probably the most useful link at the moment is "Modules", above. That gives a categorized, alphabetical listing of the documented functions.

    freetds-1.00.82/doc/reference/jquery.js100644 025423 025423 00000521511 13242511131 0013404/*! * jQuery JavaScript Library v1.7.1 * http://jquery.com/ * * Copyright 2011, John Resig * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * Includes Sizzle.js * http://sizzlejs.com/ * Copyright 2011, The Dojo Foundation * Released under the MIT, BSD, and GPL Licenses. * * Date: Mon Nov 21 21:11:03 2011 -0500 */ (function(bb,L){var av=bb.document,bu=bb.navigator,bl=bb.location;var b=(function(){var bF=function(b0,b1){return new bF.fn.init(b0,b1,bD)},bU=bb.jQuery,bH=bb.$,bD,bY=/^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,bM=/\S/,bI=/^\s+/,bE=/\s+$/,bA=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,bN=/^[\],:{}\s]*$/,bW=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,bP=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,bJ=/(?:^|:|,)(?:\s*\[)+/g,by=/(webkit)[ \/]([\w.]+)/,bR=/(opera)(?:.*version)?[ \/]([\w.]+)/,bQ=/(msie) ([\w.]+)/,bS=/(mozilla)(?:.*? rv:([\w.]+))?/,bB=/-([a-z]|[0-9])/ig,bZ=/^-ms-/,bT=function(b0,b1){return(b1+"").toUpperCase()},bX=bu.userAgent,bV,bC,e,bL=Object.prototype.toString,bG=Object.prototype.hasOwnProperty,bz=Array.prototype.push,bK=Array.prototype.slice,bO=String.prototype.trim,bv=Array.prototype.indexOf,bx={};bF.fn=bF.prototype={constructor:bF,init:function(b0,b4,b3){var b2,b5,b1,b6;if(!b0){return this}if(b0.nodeType){this.context=this[0]=b0;this.length=1;return this}if(b0==="body"&&!b4&&av.body){this.context=av;this[0]=av.body;this.selector=b0;this.length=1;return this}if(typeof b0==="string"){if(b0.charAt(0)==="<"&&b0.charAt(b0.length-1)===">"&&b0.length>=3){b2=[null,b0,null]}else{b2=bY.exec(b0)}if(b2&&(b2[1]||!b4)){if(b2[1]){b4=b4 instanceof bF?b4[0]:b4;b6=(b4?b4.ownerDocument||b4:av);b1=bA.exec(b0);if(b1){if(bF.isPlainObject(b4)){b0=[av.createElement(b1[1])];bF.fn.attr.call(b0,b4,true)}else{b0=[b6.createElement(b1[1])]}}else{b1=bF.buildFragment([b2[1]],[b6]);b0=(b1.cacheable?bF.clone(b1.fragment):b1.fragment).childNodes}return bF.merge(this,b0)}else{b5=av.getElementById(b2[2]);if(b5&&b5.parentNode){if(b5.id!==b2[2]){return b3.find(b0)}this.length=1;this[0]=b5}this.context=av;this.selector=b0;return this}}else{if(!b4||b4.jquery){return(b4||b3).find(b0)}else{return this.constructor(b4).find(b0)}}}else{if(bF.isFunction(b0)){return b3.ready(b0)}}if(b0.selector!==L){this.selector=b0.selector;this.context=b0.context}return bF.makeArray(b0,this)},selector:"",jquery:"1.7.1",length:0,size:function(){return this.length},toArray:function(){return bK.call(this,0)},get:function(b0){return b0==null?this.toArray():(b0<0?this[this.length+b0]:this[b0])},pushStack:function(b1,b3,b0){var b2=this.constructor();if(bF.isArray(b1)){bz.apply(b2,b1)}else{bF.merge(b2,b1)}b2.prevObject=this;b2.context=this.context;if(b3==="find"){b2.selector=this.selector+(this.selector?" ":"")+b0}else{if(b3){b2.selector=this.selector+"."+b3+"("+b0+")"}}return b2},each:function(b1,b0){return bF.each(this,b1,b0)},ready:function(b0){bF.bindReady();bC.add(b0);return this},eq:function(b0){b0=+b0;return b0===-1?this.slice(b0):this.slice(b0,b0+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(bK.apply(this,arguments),"slice",bK.call(arguments).join(","))},map:function(b0){return this.pushStack(bF.map(this,function(b2,b1){return b0.call(b2,b1,b2)}))},end:function(){return this.prevObject||this.constructor(null)},push:bz,sort:[].sort,splice:[].splice};bF.fn.init.prototype=bF.fn;bF.extend=bF.fn.extend=function(){var b9,b2,b0,b1,b6,b7,b5=arguments[0]||{},b4=1,b3=arguments.length,b8=false;if(typeof b5==="boolean"){b8=b5;b5=arguments[1]||{};b4=2}if(typeof b5!=="object"&&!bF.isFunction(b5)){b5={}}if(b3===b4){b5=this;--b4}for(;b40){return}bC.fireWith(av,[bF]);if(bF.fn.trigger){bF(av).trigger("ready").off("ready")}}},bindReady:function(){if(bC){return}bC=bF.Callbacks("once memory");if(av.readyState==="complete"){return setTimeout(bF.ready,1)}if(av.addEventListener){av.addEventListener("DOMContentLoaded",e,false);bb.addEventListener("load",bF.ready,false)}else{if(av.attachEvent){av.attachEvent("onreadystatechange",e);bb.attachEvent("onload",bF.ready);var b0=false;try{b0=bb.frameElement==null}catch(b1){}if(av.documentElement.doScroll&&b0){bw()}}}},isFunction:function(b0){return bF.type(b0)==="function"},isArray:Array.isArray||function(b0){return bF.type(b0)==="array"},isWindow:function(b0){return b0&&typeof b0==="object"&&"setInterval" in b0},isNumeric:function(b0){return !isNaN(parseFloat(b0))&&isFinite(b0)},type:function(b0){return b0==null?String(b0):bx[bL.call(b0)]||"object"},isPlainObject:function(b2){if(!b2||bF.type(b2)!=="object"||b2.nodeType||bF.isWindow(b2)){return false}try{if(b2.constructor&&!bG.call(b2,"constructor")&&!bG.call(b2.constructor.prototype,"isPrototypeOf")){return false}}catch(b1){return false}var b0;for(b0 in b2){}return b0===L||bG.call(b2,b0)},isEmptyObject:function(b1){for(var b0 in b1){return false}return true},error:function(b0){throw new Error(b0)},parseJSON:function(b0){if(typeof b0!=="string"||!b0){return null}b0=bF.trim(b0);if(bb.JSON&&bb.JSON.parse){return bb.JSON.parse(b0)}if(bN.test(b0.replace(bW,"@").replace(bP,"]").replace(bJ,""))){return(new Function("return "+b0))()}bF.error("Invalid JSON: "+b0)},parseXML:function(b2){var b0,b1;try{if(bb.DOMParser){b1=new DOMParser();b0=b1.parseFromString(b2,"text/xml")}else{b0=new ActiveXObject("Microsoft.XMLDOM");b0.async="false";b0.loadXML(b2)}}catch(b3){b0=L}if(!b0||!b0.documentElement||b0.getElementsByTagName("parsererror").length){bF.error("Invalid XML: "+b2)}return b0},noop:function(){},globalEval:function(b0){if(b0&&bM.test(b0)){(bb.execScript||function(b1){bb["eval"].call(bb,b1)})(b0)}},camelCase:function(b0){return b0.replace(bZ,"ms-").replace(bB,bT)},nodeName:function(b1,b0){return b1.nodeName&&b1.nodeName.toUpperCase()===b0.toUpperCase()},each:function(b3,b6,b2){var b1,b4=0,b5=b3.length,b0=b5===L||bF.isFunction(b3);if(b2){if(b0){for(b1 in b3){if(b6.apply(b3[b1],b2)===false){break}}}else{for(;b40&&b0[0]&&b0[b1-1])||b1===0||bF.isArray(b0));if(b3){for(;b21?aJ.call(arguments,0):bG;if(!(--bw)){bC.resolveWith(bC,bx)}}}function bz(bF){return function(bG){bB[bF]=arguments.length>1?aJ.call(arguments,0):bG;bC.notifyWith(bE,bB)}}if(e>1){for(;bv
    a";bI=bv.getElementsByTagName("*");bF=bv.getElementsByTagName("a")[0];if(!bI||!bI.length||!bF){return{}}bG=av.createElement("select");bx=bG.appendChild(av.createElement("option"));bE=bv.getElementsByTagName("input")[0];bJ={leadingWhitespace:(bv.firstChild.nodeType===3),tbody:!bv.getElementsByTagName("tbody").length,htmlSerialize:!!bv.getElementsByTagName("link").length,style:/top/.test(bF.getAttribute("style")),hrefNormalized:(bF.getAttribute("href")==="/a"),opacity:/^0.55/.test(bF.style.opacity),cssFloat:!!bF.style.cssFloat,checkOn:(bE.value==="on"),optSelected:bx.selected,getSetAttribute:bv.className!=="t",enctype:!!av.createElement("form").enctype,html5Clone:av.createElement("nav").cloneNode(true).outerHTML!=="<:nav>",submitBubbles:true,changeBubbles:true,focusinBubbles:false,deleteExpando:true,noCloneEvent:true,inlineBlockNeedsLayout:false,shrinkWrapBlocks:false,reliableMarginRight:true};bE.checked=true;bJ.noCloneChecked=bE.cloneNode(true).checked;bG.disabled=true;bJ.optDisabled=!bx.disabled;try{delete bv.test}catch(bC){bJ.deleteExpando=false}if(!bv.addEventListener&&bv.attachEvent&&bv.fireEvent){bv.attachEvent("onclick",function(){bJ.noCloneEvent=false});bv.cloneNode(true).fireEvent("onclick")}bE=av.createElement("input");bE.value="t";bE.setAttribute("type","radio");bJ.radioValue=bE.value==="t";bE.setAttribute("checked","checked");bv.appendChild(bE);bD=av.createDocumentFragment();bD.appendChild(bv.lastChild);bJ.checkClone=bD.cloneNode(true).cloneNode(true).lastChild.checked;bJ.appendChecked=bE.checked;bD.removeChild(bE);bD.appendChild(bv);bv.innerHTML="";if(bb.getComputedStyle){bA=av.createElement("div");bA.style.width="0";bA.style.marginRight="0";bv.style.width="2px";bv.appendChild(bA);bJ.reliableMarginRight=(parseInt((bb.getComputedStyle(bA,null)||{marginRight:0}).marginRight,10)||0)===0}if(bv.attachEvent){for(by in {submit:1,change:1,focusin:1}){bB="on"+by;bw=(bB in bv);if(!bw){bv.setAttribute(bB,"return;");bw=(typeof bv[bB]==="function")}bJ[by+"Bubbles"]=bw}}bD.removeChild(bv);bD=bG=bx=bA=bv=bE=null;b(function(){var bM,bU,bV,bT,bN,bO,bL,bS,bR,e,bP,bQ=av.getElementsByTagName("body")[0];if(!bQ){return}bL=1;bS="position:absolute;top:0;left:0;width:1px;height:1px;margin:0;";bR="visibility:hidden;border:0;";e="style='"+bS+"border:5px solid #000;padding:0;'";bP="
    ";bM=av.createElement("div");bM.style.cssText=bR+"width:0;height:0;position:static;top:0;margin-top:"+bL+"px";bQ.insertBefore(bM,bQ.firstChild);bv=av.createElement("div");bM.appendChild(bv);bv.innerHTML="
    t
    ";bz=bv.getElementsByTagName("td");bw=(bz[0].offsetHeight===0);bz[0].style.display="";bz[1].style.display="none";bJ.reliableHiddenOffsets=bw&&(bz[0].offsetHeight===0);bv.innerHTML="";bv.style.width=bv.style.paddingLeft="1px";b.boxModel=bJ.boxModel=bv.offsetWidth===2;if(typeof bv.style.zoom!=="undefined"){bv.style.display="inline";bv.style.zoom=1;bJ.inlineBlockNeedsLayout=(bv.offsetWidth===2);bv.style.display="";bv.innerHTML="
    ";bJ.shrinkWrapBlocks=(bv.offsetWidth!==2)}bv.style.cssText=bS+bR;bv.innerHTML=bP;bU=bv.firstChild;bV=bU.firstChild;bN=bU.nextSibling.firstChild.firstChild;bO={doesNotAddBorder:(bV.offsetTop!==5),doesAddBorderForTableAndCells:(bN.offsetTop===5)};bV.style.position="fixed";bV.style.top="20px";bO.fixedPosition=(bV.offsetTop===20||bV.offsetTop===15);bV.style.position=bV.style.top="";bU.style.overflow="hidden";bU.style.position="relative";bO.subtractsBorderForOverflowNotVisible=(bV.offsetTop===-5);bO.doesNotIncludeMarginInBodyOffset=(bQ.offsetTop!==bL);bQ.removeChild(bM);bv=bM=null;b.extend(bJ,bO)});return bJ})();var aS=/^(?:\{.*\}|\[.*\])$/,aA=/([A-Z])/g;b.extend({cache:{},uuid:0,expando:"jQuery"+(b.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:true,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:true},hasData:function(e){e=e.nodeType?b.cache[e[b.expando]]:e[b.expando];return !!e&&!S(e)},data:function(bx,bv,bz,by){if(!b.acceptData(bx)){return}var bG,bA,bD,bE=b.expando,bC=typeof bv==="string",bF=bx.nodeType,e=bF?b.cache:bx,bw=bF?bx[bE]:bx[bE]&&bE,bB=bv==="events";if((!bw||!e[bw]||(!bB&&!by&&!e[bw].data))&&bC&&bz===L){return}if(!bw){if(bF){bx[bE]=bw=++b.uuid}else{bw=bE}}if(!e[bw]){e[bw]={};if(!bF){e[bw].toJSON=b.noop}}if(typeof bv==="object"||typeof bv==="function"){if(by){e[bw]=b.extend(e[bw],bv)}else{e[bw].data=b.extend(e[bw].data,bv)}}bG=bA=e[bw];if(!by){if(!bA.data){bA.data={}}bA=bA.data}if(bz!==L){bA[b.camelCase(bv)]=bz}if(bB&&!bA[bv]){return bG.events}if(bC){bD=bA[bv];if(bD==null){bD=bA[b.camelCase(bv)]}}else{bD=bA}return bD},removeData:function(bx,bv,by){if(!b.acceptData(bx)){return}var bB,bA,bz,bC=b.expando,bD=bx.nodeType,e=bD?b.cache:bx,bw=bD?bx[bC]:bC;if(!e[bw]){return}if(bv){bB=by?e[bw]:e[bw].data;if(bB){if(!b.isArray(bv)){if(bv in bB){bv=[bv]}else{bv=b.camelCase(bv);if(bv in bB){bv=[bv]}else{bv=bv.split(" ")}}}for(bA=0,bz=bv.length;bA-1){return true}}return false},val:function(bx){var e,bv,by,bw=this[0];if(!arguments.length){if(bw){e=b.valHooks[bw.nodeName.toLowerCase()]||b.valHooks[bw.type];if(e&&"get" in e&&(bv=e.get(bw,"value"))!==L){return bv}bv=bw.value;return typeof bv==="string"?bv.replace(aU,""):bv==null?"":bv}return}by=b.isFunction(bx);return this.each(function(bA){var bz=b(this),bB;if(this.nodeType!==1){return}if(by){bB=bx.call(this,bA,bz.val())}else{bB=bx}if(bB==null){bB=""}else{if(typeof bB==="number"){bB+=""}else{if(b.isArray(bB)){bB=b.map(bB,function(bC){return bC==null?"":bC+""})}}}e=b.valHooks[this.nodeName.toLowerCase()]||b.valHooks[this.type];if(!e||!("set" in e)||e.set(this,bB,"value")===L){this.value=bB}})}});b.extend({valHooks:{option:{get:function(e){var bv=e.attributes.value;return !bv||bv.specified?e.value:e.text}},select:{get:function(e){var bA,bv,bz,bx,by=e.selectedIndex,bB=[],bC=e.options,bw=e.type==="select-one";if(by<0){return null}bv=bw?by:0;bz=bw?by+1:bC.length;for(;bv=0});if(!e.length){bv.selectedIndex=-1}return e}}},attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true},attr:function(bA,bx,bB,bz){var bw,e,by,bv=bA.nodeType;if(!bA||bv===3||bv===8||bv===2){return}if(bz&&bx in b.attrFn){return b(bA)[bx](bB)}if(typeof bA.getAttribute==="undefined"){return b.prop(bA,bx,bB)}by=bv!==1||!b.isXMLDoc(bA);if(by){bx=bx.toLowerCase();e=b.attrHooks[bx]||(ao.test(bx)?aY:be)}if(bB!==L){if(bB===null){b.removeAttr(bA,bx);return}else{if(e&&"set" in e&&by&&(bw=e.set(bA,bB,bx))!==L){return bw}else{bA.setAttribute(bx,""+bB);return bB}}}else{if(e&&"get" in e&&by&&(bw=e.get(bA,bx))!==null){return bw}else{bw=bA.getAttribute(bx);return bw===null?L:bw}}},removeAttr:function(bx,bz){var by,bA,bv,e,bw=0;if(bz&&bx.nodeType===1){bA=bz.toLowerCase().split(af);e=bA.length;for(;bw=0)}}})});var bd=/^(?:textarea|input|select)$/i,n=/^([^\.]*)?(?:\.(.+))?$/,J=/\bhover(\.\S+)?\b/,aO=/^key/,bf=/^(?:mouse|contextmenu)|click/,T=/^(?:focusinfocus|focusoutblur)$/,U=/^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,Y=function(e){var bv=U.exec(e);if(bv){bv[1]=(bv[1]||"").toLowerCase();bv[3]=bv[3]&&new RegExp("(?:^|\\s)"+bv[3]+"(?:\\s|$)")}return bv},j=function(bw,e){var bv=bw.attributes||{};return((!e[1]||bw.nodeName.toLowerCase()===e[1])&&(!e[2]||(bv.id||{}).value===e[2])&&(!e[3]||e[3].test((bv["class"]||{}).value)))},bt=function(e){return b.event.special.hover?e:e.replace(J,"mouseenter$1 mouseleave$1")};b.event={add:function(bx,bC,bJ,bA,by){var bD,bB,bK,bI,bH,bF,e,bG,bv,bz,bw,bE;if(bx.nodeType===3||bx.nodeType===8||!bC||!bJ||!(bD=b._data(bx))){return}if(bJ.handler){bv=bJ;bJ=bv.handler}if(!bJ.guid){bJ.guid=b.guid++}bK=bD.events;if(!bK){bD.events=bK={}}bB=bD.handle;if(!bB){bD.handle=bB=function(bL){return typeof b!=="undefined"&&(!bL||b.event.triggered!==bL.type)?b.event.dispatch.apply(bB.elem,arguments):L};bB.elem=bx}bC=b.trim(bt(bC)).split(" ");for(bI=0;bI=0){bG=bG.slice(0,-1);bw=true}if(bG.indexOf(".")>=0){bx=bG.split(".");bG=bx.shift();bx.sort()}if((!bA||b.event.customEvent[bG])&&!b.event.global[bG]){return}bv=typeof bv==="object"?bv[b.expando]?bv:new b.Event(bG,bv):new b.Event(bG);bv.type=bG;bv.isTrigger=true;bv.exclusive=bw;bv.namespace=bx.join(".");bv.namespace_re=bv.namespace?new RegExp("(^|\\.)"+bx.join("\\.(?:.*\\.)?")+"(\\.|$)"):null;by=bG.indexOf(":")<0?"on"+bG:"";if(!bA){e=b.cache;for(bC in e){if(e[bC].events&&e[bC].events[bG]){b.event.trigger(bv,bD,e[bC].handle.elem,true)}}return}bv.result=L;if(!bv.target){bv.target=bA}bD=bD!=null?b.makeArray(bD):[];bD.unshift(bv);bF=b.event.special[bG]||{};if(bF.trigger&&bF.trigger.apply(bA,bD)===false){return}bB=[[bA,bF.bindType||bG]];if(!bJ&&!bF.noBubble&&!b.isWindow(bA)){bI=bF.delegateType||bG;bH=T.test(bI+bG)?bA:bA.parentNode;bz=null;for(;bH;bH=bH.parentNode){bB.push([bH,bI]);bz=bH}if(bz&&bz===bA.ownerDocument){bB.push([bz.defaultView||bz.parentWindow||bb,bI])}}for(bC=0;bCbA){bH.push({elem:this,matches:bz.slice(bA)})}for(bC=0;bC0?this.on(e,null,bx,bw):this.trigger(e)};if(b.attrFn){b.attrFn[e]=true}if(aO.test(e)){b.event.fixHooks[e]=b.event.keyHooks}if(bf.test(e)){b.event.fixHooks[e]=b.event.mouseHooks}}); /*! * Sizzle CSS Selector Engine * Copyright 2011, The Dojo Foundation * Released under the MIT, BSD, and GPL Licenses. * More information: http://sizzlejs.com/ */ (function(){var bH=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,bC="sizcache"+(Math.random()+"").replace(".",""),bI=0,bL=Object.prototype.toString,bB=false,bA=true,bK=/\\/g,bO=/\r\n/g,bQ=/\W/;[0,0].sort(function(){bA=false;return 0});var by=function(bV,e,bY,bZ){bY=bY||[];e=e||av;var b1=e;if(e.nodeType!==1&&e.nodeType!==9){return[]}if(!bV||typeof bV!=="string"){return bY}var bS,b3,b6,bR,b2,b5,b4,bX,bU=true,bT=by.isXML(e),bW=[],b0=bV;do{bH.exec("");bS=bH.exec(b0);if(bS){b0=bS[3];bW.push(bS[1]);if(bS[2]){bR=bS[3];break}}}while(bS);if(bW.length>1&&bD.exec(bV)){if(bW.length===2&&bE.relative[bW[0]]){b3=bM(bW[0]+bW[1],e,bZ)}else{b3=bE.relative[bW[0]]?[e]:by(bW.shift(),e);while(bW.length){bV=bW.shift();if(bE.relative[bV]){bV+=bW.shift()}b3=bM(bV,b3,bZ)}}}else{if(!bZ&&bW.length>1&&e.nodeType===9&&!bT&&bE.match.ID.test(bW[0])&&!bE.match.ID.test(bW[bW.length-1])){b2=by.find(bW.shift(),e,bT);e=b2.expr?by.filter(b2.expr,b2.set)[0]:b2.set[0]}if(e){b2=bZ?{expr:bW.pop(),set:bF(bZ)}:by.find(bW.pop(),bW.length===1&&(bW[0]==="~"||bW[0]==="+")&&e.parentNode?e.parentNode:e,bT);b3=b2.expr?by.filter(b2.expr,b2.set):b2.set;if(bW.length>0){b6=bF(b3)}else{bU=false}while(bW.length){b5=bW.pop();b4=b5;if(!bE.relative[b5]){b5=""}else{b4=bW.pop()}if(b4==null){b4=e}bE.relative[b5](b6,b4,bT)}}else{b6=bW=[]}}if(!b6){b6=b3}if(!b6){by.error(b5||bV)}if(bL.call(b6)==="[object Array]"){if(!bU){bY.push.apply(bY,b6)}else{if(e&&e.nodeType===1){for(bX=0;b6[bX]!=null;bX++){if(b6[bX]&&(b6[bX]===true||b6[bX].nodeType===1&&by.contains(e,b6[bX]))){bY.push(b3[bX])}}}else{for(bX=0;b6[bX]!=null;bX++){if(b6[bX]&&b6[bX].nodeType===1){bY.push(b3[bX])}}}}}else{bF(b6,bY)}if(bR){by(bR,b1,bY,bZ);by.uniqueSort(bY)}return bY};by.uniqueSort=function(bR){if(bJ){bB=bA;bR.sort(bJ);if(bB){for(var e=1;e0};by.find=function(bX,e,bY){var bW,bS,bU,bT,bV,bR;if(!bX){return[]}for(bS=0,bU=bE.order.length;bS":function(bW,bR){var bV,bU=typeof bR==="string",bS=0,e=bW.length;if(bU&&!bQ.test(bR)){bR=bR.toLowerCase();for(;bS=0)){if(!bS){e.push(bV)}}else{if(bS){bR[bU]=false}}}}return false},ID:function(e){return e[1].replace(bK,"")},TAG:function(bR,e){return bR[1].replace(bK,"").toLowerCase()},CHILD:function(e){if(e[1]==="nth"){if(!e[2]){by.error(e[0])}e[2]=e[2].replace(/^\+|\s*/g,"");var bR=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(e[2]==="even"&&"2n"||e[2]==="odd"&&"2n+1"||!/\D/.test(e[2])&&"0n+"+e[2]||e[2]);e[2]=(bR[1]+(bR[2]||1))-0;e[3]=bR[3]-0}else{if(e[2]){by.error(e[0])}}e[0]=bI++;return e},ATTR:function(bU,bR,bS,e,bV,bW){var bT=bU[1]=bU[1].replace(bK,"");if(!bW&&bE.attrMap[bT]){bU[1]=bE.attrMap[bT]}bU[4]=(bU[4]||bU[5]||"").replace(bK,"");if(bU[2]==="~="){bU[4]=" "+bU[4]+" "}return bU},PSEUDO:function(bU,bR,bS,e,bV){if(bU[1]==="not"){if((bH.exec(bU[3])||"").length>1||/^\w/.test(bU[3])){bU[3]=by(bU[3],null,null,bR)}else{var bT=by.filter(bU[3],bR,bS,true^bV);if(!bS){e.push.apply(e,bT)}return false}}else{if(bE.match.POS.test(bU[0])||bE.match.CHILD.test(bU[0])){return true}}return bU},POS:function(e){e.unshift(true);return e}},filters:{enabled:function(e){return e.disabled===false&&e.type!=="hidden"},disabled:function(e){return e.disabled===true},checked:function(e){return e.checked===true},selected:function(e){if(e.parentNode){e.parentNode.selectedIndex}return e.selected===true},parent:function(e){return !!e.firstChild},empty:function(e){return !e.firstChild},has:function(bS,bR,e){return !!by(e[3],bS).length},header:function(e){return(/h\d/i).test(e.nodeName)},text:function(bS){var e=bS.getAttribute("type"),bR=bS.type;return bS.nodeName.toLowerCase()==="input"&&"text"===bR&&(e===bR||e===null)},radio:function(e){return e.nodeName.toLowerCase()==="input"&&"radio"===e.type},checkbox:function(e){return e.nodeName.toLowerCase()==="input"&&"checkbox"===e.type},file:function(e){return e.nodeName.toLowerCase()==="input"&&"file"===e.type},password:function(e){return e.nodeName.toLowerCase()==="input"&&"password"===e.type},submit:function(bR){var e=bR.nodeName.toLowerCase();return(e==="input"||e==="button")&&"submit"===bR.type},image:function(e){return e.nodeName.toLowerCase()==="input"&&"image"===e.type},reset:function(bR){var e=bR.nodeName.toLowerCase();return(e==="input"||e==="button")&&"reset"===bR.type},button:function(bR){var e=bR.nodeName.toLowerCase();return e==="input"&&"button"===bR.type||e==="button"},input:function(e){return(/input|select|textarea|button/i).test(e.nodeName)},focus:function(e){return e===e.ownerDocument.activeElement}},setFilters:{first:function(bR,e){return e===0},last:function(bS,bR,e,bT){return bR===bT.length-1},even:function(bR,e){return e%2===0},odd:function(bR,e){return e%2===1},lt:function(bS,bR,e){return bRe[3]-0},nth:function(bS,bR,e){return e[3]-0===bR},eq:function(bS,bR,e){return e[3]-0===bR}},filter:{PSEUDO:function(bS,bX,bW,bY){var e=bX[1],bR=bE.filters[e];if(bR){return bR(bS,bW,bX,bY)}else{if(e==="contains"){return(bS.textContent||bS.innerText||bw([bS])||"").indexOf(bX[3])>=0}else{if(e==="not"){var bT=bX[3];for(var bV=0,bU=bT.length;bV=0)}}},ID:function(bR,e){return bR.nodeType===1&&bR.getAttribute("id")===e},TAG:function(bR,e){return(e==="*"&&bR.nodeType===1)||!!bR.nodeName&&bR.nodeName.toLowerCase()===e},CLASS:function(bR,e){return(" "+(bR.className||bR.getAttribute("class"))+" ").indexOf(e)>-1},ATTR:function(bV,bT){var bS=bT[1],e=by.attr?by.attr(bV,bS):bE.attrHandle[bS]?bE.attrHandle[bS](bV):bV[bS]!=null?bV[bS]:bV.getAttribute(bS),bW=e+"",bU=bT[2],bR=bT[4];return e==null?bU==="!=":!bU&&by.attr?e!=null:bU==="="?bW===bR:bU==="*="?bW.indexOf(bR)>=0:bU==="~="?(" "+bW+" ").indexOf(bR)>=0:!bR?bW&&e!==false:bU==="!="?bW!==bR:bU==="^="?bW.indexOf(bR)===0:bU==="$="?bW.substr(bW.length-bR.length)===bR:bU==="|="?bW===bR||bW.substr(0,bR.length+1)===bR+"-":false},POS:function(bU,bR,bS,bV){var e=bR[2],bT=bE.setFilters[e];if(bT){return bT(bU,bS,bR,bV)}}}};var bD=bE.match.POS,bx=function(bR,e){return"\\"+(e-0+1)};for(var bz in bE.match){bE.match[bz]=new RegExp(bE.match[bz].source+(/(?![^\[]*\])(?![^\(]*\))/.source));bE.leftMatch[bz]=new RegExp(/(^(?:.|\r|\n)*?)/.source+bE.match[bz].source.replace(/\\(\d+)/g,bx))}var bF=function(bR,e){bR=Array.prototype.slice.call(bR,0);if(e){e.push.apply(e,bR);return e}return bR};try{Array.prototype.slice.call(av.documentElement.childNodes,0)[0].nodeType}catch(bP){bF=function(bU,bT){var bS=0,bR=bT||[];if(bL.call(bU)==="[object Array]"){Array.prototype.push.apply(bR,bU)}else{if(typeof bU.length==="number"){for(var e=bU.length;bS";e.insertBefore(bR,e.firstChild);if(av.getElementById(bS)){bE.find.ID=function(bU,bV,bW){if(typeof bV.getElementById!=="undefined"&&!bW){var bT=bV.getElementById(bU[1]);return bT?bT.id===bU[1]||typeof bT.getAttributeNode!=="undefined"&&bT.getAttributeNode("id").nodeValue===bU[1]?[bT]:L:[]}};bE.filter.ID=function(bV,bT){var bU=typeof bV.getAttributeNode!=="undefined"&&bV.getAttributeNode("id");return bV.nodeType===1&&bU&&bU.nodeValue===bT}}e.removeChild(bR);e=bR=null})();(function(){var e=av.createElement("div");e.appendChild(av.createComment(""));if(e.getElementsByTagName("*").length>0){bE.find.TAG=function(bR,bV){var bU=bV.getElementsByTagName(bR[1]);if(bR[1]==="*"){var bT=[];for(var bS=0;bU[bS];bS++){if(bU[bS].nodeType===1){bT.push(bU[bS])}}bU=bT}return bU}}e.innerHTML="";if(e.firstChild&&typeof e.firstChild.getAttribute!=="undefined"&&e.firstChild.getAttribute("href")!=="#"){bE.attrHandle.href=function(bR){return bR.getAttribute("href",2)}}e=null})();if(av.querySelectorAll){(function(){var e=by,bT=av.createElement("div"),bS="__sizzle__";bT.innerHTML="

    ";if(bT.querySelectorAll&&bT.querySelectorAll(".TEST").length===0){return}by=function(b4,bV,bZ,b3){bV=bV||av;if(!b3&&!by.isXML(bV)){var b2=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b4);if(b2&&(bV.nodeType===1||bV.nodeType===9)){if(b2[1]){return bF(bV.getElementsByTagName(b4),bZ)}else{if(b2[2]&&bE.find.CLASS&&bV.getElementsByClassName){return bF(bV.getElementsByClassName(b2[2]),bZ)}}}if(bV.nodeType===9){if(b4==="body"&&bV.body){return bF([bV.body],bZ)}else{if(b2&&b2[3]){var bY=bV.getElementById(b2[3]);if(bY&&bY.parentNode){if(bY.id===b2[3]){return bF([bY],bZ)}}else{return bF([],bZ)}}}try{return bF(bV.querySelectorAll(b4),bZ)}catch(b0){}}else{if(bV.nodeType===1&&bV.nodeName.toLowerCase()!=="object"){var bW=bV,bX=bV.getAttribute("id"),bU=bX||bS,b6=bV.parentNode,b5=/^\s*[+~]/.test(b4);if(!bX){bV.setAttribute("id",bU)}else{bU=bU.replace(/'/g,"\\$&")}if(b5&&b6){bV=bV.parentNode}try{if(!b5||b6){return bF(bV.querySelectorAll("[id='"+bU+"'] "+b4),bZ)}}catch(b1){}finally{if(!bX){bW.removeAttribute("id")}}}}}return e(b4,bV,bZ,b3)};for(var bR in e){by[bR]=e[bR]}bT=null})()}(function(){var e=av.documentElement,bS=e.matchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.msMatchesSelector;if(bS){var bU=!bS.call(av.createElement("div"),"div"),bR=false;try{bS.call(av.documentElement,"[test!='']:sizzle")}catch(bT){bR=true}by.matchesSelector=function(bW,bY){bY=bY.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!by.isXML(bW)){try{if(bR||!bE.match.PSEUDO.test(bY)&&!/!=/.test(bY)){var bV=bS.call(bW,bY);if(bV||!bU||bW.document&&bW.document.nodeType!==11){return bV}}}catch(bX){}}return by(bY,null,null,[bW]).length>0}}})();(function(){var e=av.createElement("div");e.innerHTML="
    ";if(!e.getElementsByClassName||e.getElementsByClassName("e").length===0){return}e.lastChild.className="e";if(e.getElementsByClassName("e").length===1){return}bE.order.splice(1,0,"CLASS");bE.find.CLASS=function(bR,bS,bT){if(typeof bS.getElementsByClassName!=="undefined"&&!bT){return bS.getElementsByClassName(bR[1])}};e=null})();function bv(bR,bW,bV,bZ,bX,bY){for(var bT=0,bS=bZ.length;bT0){bU=e;break}}}e=e[bR]}bZ[bT]=bU}}}if(av.documentElement.contains){by.contains=function(bR,e){return bR!==e&&(bR.contains?bR.contains(e):true)}}else{if(av.documentElement.compareDocumentPosition){by.contains=function(bR,e){return !!(bR.compareDocumentPosition(e)&16)}}else{by.contains=function(){return false}}}by.isXML=function(e){var bR=(e?e.ownerDocument||e:0).documentElement;return bR?bR.nodeName!=="HTML":false};var bM=function(bS,e,bW){var bV,bX=[],bU="",bY=e.nodeType?[e]:e;while((bV=bE.match.PSEUDO.exec(bS))){bU+=bV[0];bS=bS.replace(bE.match.PSEUDO,"")}bS=bE.relative[bS]?bS+"*":bS;for(var bT=0,bR=bY.length;bT0){for(bB=bA;bB=0:b.filter(e,this).length>0:this.filter(e).length>0)},closest:function(by,bx){var bv=[],bw,e,bz=this[0];if(b.isArray(by)){var bB=1;while(bz&&bz.ownerDocument&&bz!==bx){for(bw=0;bw-1:b.find.matchesSelector(bz,by)){bv.push(bz);break}else{bz=bz.parentNode;if(!bz||!bz.ownerDocument||bz===bx||bz.nodeType===11){break}}}}bv=bv.length>1?b.unique(bv):bv;return this.pushStack(bv,"closest",by)},index:function(e){if(!e){return(this[0]&&this[0].parentNode)?this.prevAll().length:-1}if(typeof e==="string"){return b.inArray(this[0],b(e))}return b.inArray(e.jquery?e[0]:e,this)},add:function(e,bv){var bx=typeof e==="string"?b(e,bv):b.makeArray(e&&e.nodeType?[e]:e),bw=b.merge(this.get(),bx);return this.pushStack(C(bx[0])||C(bw[0])?bw:b.unique(bw))},andSelf:function(){return this.add(this.prevObject)}});function C(e){return !e||!e.parentNode||e.parentNode.nodeType===11}b.each({parent:function(bv){var e=bv.parentNode;return e&&e.nodeType!==11?e:null},parents:function(e){return b.dir(e,"parentNode")},parentsUntil:function(bv,e,bw){return b.dir(bv,"parentNode",bw)},next:function(e){return b.nth(e,2,"nextSibling")},prev:function(e){return b.nth(e,2,"previousSibling")},nextAll:function(e){return b.dir(e,"nextSibling")},prevAll:function(e){return b.dir(e,"previousSibling")},nextUntil:function(bv,e,bw){return b.dir(bv,"nextSibling",bw)},prevUntil:function(bv,e,bw){return b.dir(bv,"previousSibling",bw)},siblings:function(e){return b.sibling(e.parentNode.firstChild,e)},children:function(e){return b.sibling(e.firstChild)},contents:function(e){return b.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:b.makeArray(e.childNodes)}},function(e,bv){b.fn[e]=function(by,bw){var bx=b.map(this,bv,by);if(!ab.test(e)){bw=by}if(bw&&typeof bw==="string"){bx=b.filter(bw,bx)}bx=this.length>1&&!ay[e]?b.unique(bx):bx;if((this.length>1||a9.test(bw))&&aq.test(e)){bx=bx.reverse()}return this.pushStack(bx,e,P.call(arguments).join(","))}});b.extend({filter:function(bw,e,bv){if(bv){bw=":not("+bw+")"}return e.length===1?b.find.matchesSelector(e[0],bw)?[e[0]]:[]:b.find.matches(bw,e)},dir:function(bw,bv,by){var e=[],bx=bw[bv];while(bx&&bx.nodeType!==9&&(by===L||bx.nodeType!==1||!b(bx).is(by))){if(bx.nodeType===1){e.push(bx)}bx=bx[bv]}return e},nth:function(by,e,bw,bx){e=e||1;var bv=0;for(;by;by=by[bw]){if(by.nodeType===1&&++bv===e){break}}return by},sibling:function(bw,bv){var e=[];for(;bw;bw=bw.nextSibling){if(bw.nodeType===1&&bw!==bv){e.push(bw)}}return e}});function aG(bx,bw,e){bw=bw||0;if(b.isFunction(bw)){return b.grep(bx,function(bz,by){var bA=!!bw.call(bz,by,bz);return bA===e})}else{if(bw.nodeType){return b.grep(bx,function(bz,by){return(bz===bw)===e})}else{if(typeof bw==="string"){var bv=b.grep(bx,function(by){return by.nodeType===1});if(bp.test(bw)){return b.filter(bw,bv,!e)}else{bw=b.filter(bw,bv)}}}}return b.grep(bx,function(bz,by){return(b.inArray(bz,bw)>=0)===e})}function a(e){var bw=aR.split("|"),bv=e.createDocumentFragment();if(bv.createElement){while(bw.length){bv.createElement(bw.pop())}}return bv}var aR="abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",ag=/ jQuery\d+="(?:\d+|null)"/g,ar=/^\s+/,R=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,d=/<([\w:]+)/,w=/",""],legend:[1,"
    ","
    "],thead:[1,"","
    "],tr:[2,"","
    "],td:[3,"","
    "],col:[2,"","
    "],area:[1,"",""],_default:[0,"",""]},ac=a(av);ax.optgroup=ax.option;ax.tbody=ax.tfoot=ax.colgroup=ax.caption=ax.thead;ax.th=ax.td;if(!b.support.htmlSerialize){ax._default=[1,"div
    ","
    "]}b.fn.extend({text:function(e){if(b.isFunction(e)){return this.each(function(bw){var bv=b(this);bv.text(e.call(this,bw,bv.text()))})}if(typeof e!=="object"&&e!==L){return this.empty().append((this[0]&&this[0].ownerDocument||av).createTextNode(e))}return b.text(this)},wrapAll:function(e){if(b.isFunction(e)){return this.each(function(bw){b(this).wrapAll(e.call(this,bw))})}if(this[0]){var bv=b(e,this[0].ownerDocument).eq(0).clone(true);if(this[0].parentNode){bv.insertBefore(this[0])}bv.map(function(){var bw=this;while(bw.firstChild&&bw.firstChild.nodeType===1){bw=bw.firstChild}return bw}).append(this)}return this},wrapInner:function(e){if(b.isFunction(e)){return this.each(function(bv){b(this).wrapInner(e.call(this,bv))})}return this.each(function(){var bv=b(this),bw=bv.contents();if(bw.length){bw.wrapAll(e)}else{bv.append(e)}})},wrap:function(e){var bv=b.isFunction(e);return this.each(function(bw){b(this).wrapAll(bv?e.call(this,bw):e)})},unwrap:function(){return this.parent().each(function(){if(!b.nodeName(this,"body")){b(this).replaceWith(this.childNodes)}}).end()},append:function(){return this.domManip(arguments,true,function(e){if(this.nodeType===1){this.appendChild(e)}})},prepend:function(){return this.domManip(arguments,true,function(e){if(this.nodeType===1){this.insertBefore(e,this.firstChild)}})},before:function(){if(this[0]&&this[0].parentNode){return this.domManip(arguments,false,function(bv){this.parentNode.insertBefore(bv,this)})}else{if(arguments.length){var e=b.clean(arguments);e.push.apply(e,this.toArray());return this.pushStack(e,"before",arguments)}}},after:function(){if(this[0]&&this[0].parentNode){return this.domManip(arguments,false,function(bv){this.parentNode.insertBefore(bv,this.nextSibling)})}else{if(arguments.length){var e=this.pushStack(this,"after",arguments);e.push.apply(e,b.clean(arguments));return e}}},remove:function(e,bx){for(var bv=0,bw;(bw=this[bv])!=null;bv++){if(!e||b.filter(e,[bw]).length){if(!bx&&bw.nodeType===1){b.cleanData(bw.getElementsByTagName("*"));b.cleanData([bw])}if(bw.parentNode){bw.parentNode.removeChild(bw)}}}return this},empty:function(){for(var e=0,bv;(bv=this[e])!=null;e++){if(bv.nodeType===1){b.cleanData(bv.getElementsByTagName("*"))}while(bv.firstChild){bv.removeChild(bv.firstChild)}}return this},clone:function(bv,e){bv=bv==null?false:bv;e=e==null?bv:e;return this.map(function(){return b.clone(this,bv,e)})},html:function(bx){if(bx===L){return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(ag,""):null}else{if(typeof bx==="string"&&!ae.test(bx)&&(b.support.leadingWhitespace||!ar.test(bx))&&!ax[(d.exec(bx)||["",""])[1].toLowerCase()]){bx=bx.replace(R,"<$1>");try{for(var bw=0,bv=this.length;bw1&&bw0?this.clone(true):this).get();b(bC[bA])[bv](by);bz=bz.concat(by)}return this.pushStack(bz,e,bC.selector)}}});function bg(e){if(typeof e.getElementsByTagName!=="undefined"){return e.getElementsByTagName("*")}else{if(typeof e.querySelectorAll!=="undefined"){return e.querySelectorAll("*")}else{return[]}}}function az(e){if(e.type==="checkbox"||e.type==="radio"){e.defaultChecked=e.checked}}function E(e){var bv=(e.nodeName||"").toLowerCase();if(bv==="input"){az(e)}else{if(bv!=="script"&&typeof e.getElementsByTagName!=="undefined"){b.grep(e.getElementsByTagName("input"),az)}}}function al(e){var bv=av.createElement("div");ac.appendChild(bv);bv.innerHTML=e.outerHTML;return bv.firstChild}b.extend({clone:function(by,bA,bw){var e,bv,bx,bz=b.support.html5Clone||!ah.test("<"+by.nodeName)?by.cloneNode(true):al(by);if((!b.support.noCloneEvent||!b.support.noCloneChecked)&&(by.nodeType===1||by.nodeType===11)&&!b.isXMLDoc(by)){ai(by,bz);e=bg(by);bv=bg(bz);for(bx=0;e[bx];++bx){if(bv[bx]){ai(e[bx],bv[bx])}}}if(bA){t(by,bz);if(bw){e=bg(by);bv=bg(bz);for(bx=0;e[bx];++bx){t(e[bx],bv[bx])}}}e=bv=null;return bz},clean:function(bw,by,bH,bA){var bF;by=by||av;if(typeof by.createElement==="undefined"){by=by.ownerDocument||by[0]&&by[0].ownerDocument||av}var bI=[],bB;for(var bE=0,bz;(bz=bw[bE])!=null;bE++){if(typeof bz==="number"){bz+=""}if(!bz){continue}if(typeof bz==="string"){if(!W.test(bz)){bz=by.createTextNode(bz)}else{bz=bz.replace(R,"<$1>");var bK=(d.exec(bz)||["",""])[1].toLowerCase(),bx=ax[bK]||ax._default,bD=bx[0],bv=by.createElement("div");if(by===av){ac.appendChild(bv)}else{a(by).appendChild(bv)}bv.innerHTML=bx[1]+bz+bx[2];while(bD--){bv=bv.lastChild}if(!b.support.tbody){var e=w.test(bz),bC=bK==="table"&&!e?bv.firstChild&&bv.firstChild.childNodes:bx[1]===""&&!e?bv.childNodes:[];for(bB=bC.length-1;bB>=0;--bB){if(b.nodeName(bC[bB],"tbody")&&!bC[bB].childNodes.length){bC[bB].parentNode.removeChild(bC[bB])}}}if(!b.support.leadingWhitespace&&ar.test(bz)){bv.insertBefore(by.createTextNode(ar.exec(bz)[0]),bv.firstChild)}bz=bv.childNodes}}var bG;if(!b.support.appendChecked){if(bz[0]&&typeof(bG=bz.length)==="number"){for(bB=0;bB=0){return bx+"px"}}else{return bx}}}});if(!b.support.opacity){b.cssHooks.opacity={get:function(bv,e){return au.test((e&&bv.currentStyle?bv.currentStyle.filter:bv.style.filter)||"")?(parseFloat(RegExp.$1)/100)+"":e?"1":""},set:function(by,bz){var bx=by.style,bv=by.currentStyle,e=b.isNumeric(bz)?"alpha(opacity="+bz*100+")":"",bw=bv&&bv.filter||bx.filter||"";bx.zoom=1;if(bz>=1&&b.trim(bw.replace(ak,""))===""){bx.removeAttribute("filter");if(bv&&!bv.filter){return}}bx.filter=ak.test(bw)?bw.replace(ak,e):bw+" "+e}}}b(function(){if(!b.support.reliableMarginRight){b.cssHooks.marginRight={get:function(bw,bv){var e;b.swap(bw,{display:"inline-block"},function(){if(bv){e=Z(bw,"margin-right","marginRight")}else{e=bw.style.marginRight}});return e}}}});if(av.defaultView&&av.defaultView.getComputedStyle){aI=function(by,bw){var bv,bx,e;bw=bw.replace(z,"-$1").toLowerCase();if((bx=by.ownerDocument.defaultView)&&(e=bx.getComputedStyle(by,null))){bv=e.getPropertyValue(bw);if(bv===""&&!b.contains(by.ownerDocument.documentElement,by)){bv=b.style(by,bw)}}return bv}}if(av.documentElement.currentStyle){aX=function(bz,bw){var bA,e,by,bv=bz.currentStyle&&bz.currentStyle[bw],bx=bz.style;if(bv===null&&bx&&(by=bx[bw])){bv=by}if(!bc.test(bv)&&bn.test(bv)){bA=bx.left;e=bz.runtimeStyle&&bz.runtimeStyle.left;if(e){bz.runtimeStyle.left=bz.currentStyle.left}bx.left=bw==="fontSize"?"1em":(bv||0);bv=bx.pixelLeft+"px";bx.left=bA;if(e){bz.runtimeStyle.left=e}}return bv===""?"auto":bv}}Z=aI||aX;function p(by,bw,bv){var bA=bw==="width"?by.offsetWidth:by.offsetHeight,bz=bw==="width"?an:a1,bx=0,e=bz.length;if(bA>0){if(bv!=="border"){for(;bx)<[^<]*)*<\/script>/gi,q=/^(?:select|textarea)/i,h=/\s+/,br=/([?&])_=[^&]*/,K=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,A=b.fn.load,aa={},r={},aE,s,aV=["*/"]+["*"];try{aE=bl.href}catch(aw){aE=av.createElement("a");aE.href="";aE=aE.href}s=K.exec(aE.toLowerCase())||[];function f(e){return function(by,bA){if(typeof by!=="string"){bA=by;by="*"}if(b.isFunction(bA)){var bx=by.toLowerCase().split(h),bw=0,bz=bx.length,bv,bB,bC;for(;bw=0){var e=bw.slice(by,bw.length);bw=bw.slice(0,by)}var bx="GET";if(bz){if(b.isFunction(bz)){bA=bz;bz=L}else{if(typeof bz==="object"){bz=b.param(bz,b.ajaxSettings.traditional);bx="POST"}}}var bv=this;b.ajax({url:bw,type:bx,dataType:"html",data:bz,complete:function(bC,bB,bD){bD=bC.responseText;if(bC.isResolved()){bC.done(function(bE){bD=bE});bv.html(e?b("
    ").append(bD.replace(a6,"")).find(e):bD)}if(bA){bv.each(bA,[bD,bB,bC])}}});return this},serialize:function(){return b.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?b.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||q.test(this.nodeName)||aZ.test(this.type))}).map(function(e,bv){var bw=b(this).val();return bw==null?null:b.isArray(bw)?b.map(bw,function(by,bx){return{name:bv.name,value:by.replace(bs,"\r\n")}}):{name:bv.name,value:bw.replace(bs,"\r\n")}}).get()}});b.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(e,bv){b.fn[bv]=function(bw){return this.on(bv,bw)}});b.each(["get","post"],function(e,bv){b[bv]=function(bw,by,bz,bx){if(b.isFunction(by)){bx=bx||bz;bz=by;by=L}return b.ajax({type:bv,url:bw,data:by,success:bz,dataType:bx})}});b.extend({getScript:function(e,bv){return b.get(e,L,bv,"script")},getJSON:function(e,bv,bw){return b.get(e,bv,bw,"json")},ajaxSetup:function(bv,e){if(e){am(bv,b.ajaxSettings)}else{e=bv;bv=b.ajaxSettings}am(bv,e);return bv},ajaxSettings:{url:aE,isLocal:aM.test(s[1]),global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":aV},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":bb.String,"text html":true,"text json":b.parseJSON,"text xml":b.parseXML},flatOptions:{context:true,url:true}},ajaxPrefilter:f(aa),ajaxTransport:f(r),ajax:function(bz,bx){if(typeof bz==="object"){bx=bz;bz=L}bx=bx||{};var bD=b.ajaxSetup({},bx),bS=bD.context||bD,bG=bS!==bD&&(bS.nodeType||bS instanceof b)?b(bS):b.event,bR=b.Deferred(),bN=b.Callbacks("once memory"),bB=bD.statusCode||{},bC,bH={},bO={},bQ,by,bL,bE,bI,bA=0,bw,bK,bJ={readyState:0,setRequestHeader:function(bT,bU){if(!bA){var e=bT.toLowerCase();bT=bO[e]=bO[e]||bT;bH[bT]=bU}return this},getAllResponseHeaders:function(){return bA===2?bQ:null},getResponseHeader:function(bT){var e;if(bA===2){if(!by){by={};while((e=aD.exec(bQ))){by[e[1].toLowerCase()]=e[2]}}e=by[bT.toLowerCase()]}return e===L?null:e},overrideMimeType:function(e){if(!bA){bD.mimeType=e}return this},abort:function(e){e=e||"abort";if(bL){bL.abort(e)}bF(0,e);return this}};function bF(bZ,bU,b0,bW){if(bA===2){return}bA=2;if(bE){clearTimeout(bE)}bL=L;bQ=bW||"";bJ.readyState=bZ>0?4:0;var bT,b4,b3,bX=bU,bY=b0?bj(bD,bJ,b0):L,bV,b2;if(bZ>=200&&bZ<300||bZ===304){if(bD.ifModified){if((bV=bJ.getResponseHeader("Last-Modified"))){b.lastModified[bC]=bV}if((b2=bJ.getResponseHeader("Etag"))){b.etag[bC]=b2}}if(bZ===304){bX="notmodified";bT=true}else{try{b4=G(bD,bY);bX="success";bT=true}catch(b1){bX="parsererror";b3=b1}}}else{b3=bX;if(!bX||bZ){bX="error";if(bZ<0){bZ=0}}}bJ.status=bZ;bJ.statusText=""+(bU||bX);if(bT){bR.resolveWith(bS,[b4,bX,bJ])}else{bR.rejectWith(bS,[bJ,bX,b3])}bJ.statusCode(bB);bB=L;if(bw){bG.trigger("ajax"+(bT?"Success":"Error"),[bJ,bD,bT?b4:b3])}bN.fireWith(bS,[bJ,bX]);if(bw){bG.trigger("ajaxComplete",[bJ,bD]);if(!(--b.active)){b.event.trigger("ajaxStop")}}}bR.promise(bJ);bJ.success=bJ.done;bJ.error=bJ.fail;bJ.complete=bN.add;bJ.statusCode=function(bT){if(bT){var e;if(bA<2){for(e in bT){bB[e]=[bB[e],bT[e]]}}else{e=bT[bJ.status];bJ.then(e,e)}}return this};bD.url=((bz||bD.url)+"").replace(bq,"").replace(c,s[1]+"//");bD.dataTypes=b.trim(bD.dataType||"*").toLowerCase().split(h);if(bD.crossDomain==null){bI=K.exec(bD.url.toLowerCase());bD.crossDomain=!!(bI&&(bI[1]!=s[1]||bI[2]!=s[2]||(bI[3]||(bI[1]==="http:"?80:443))!=(s[3]||(s[1]==="http:"?80:443))))}if(bD.data&&bD.processData&&typeof bD.data!=="string"){bD.data=b.param(bD.data,bD.traditional)}aW(aa,bD,bx,bJ);if(bA===2){return false}bw=bD.global;bD.type=bD.type.toUpperCase();bD.hasContent=!aQ.test(bD.type);if(bw&&b.active++===0){b.event.trigger("ajaxStart")}if(!bD.hasContent){if(bD.data){bD.url+=(M.test(bD.url)?"&":"?")+bD.data;delete bD.data}bC=bD.url;if(bD.cache===false){var bv=b.now(),bP=bD.url.replace(br,"$1_="+bv);bD.url=bP+((bP===bD.url)?(M.test(bD.url)?"&":"?")+"_="+bv:"")}}if(bD.data&&bD.hasContent&&bD.contentType!==false||bx.contentType){bJ.setRequestHeader("Content-Type",bD.contentType)}if(bD.ifModified){bC=bC||bD.url;if(b.lastModified[bC]){bJ.setRequestHeader("If-Modified-Since",b.lastModified[bC])}if(b.etag[bC]){bJ.setRequestHeader("If-None-Match",b.etag[bC])}}bJ.setRequestHeader("Accept",bD.dataTypes[0]&&bD.accepts[bD.dataTypes[0]]?bD.accepts[bD.dataTypes[0]]+(bD.dataTypes[0]!=="*"?", "+aV+"; q=0.01":""):bD.accepts["*"]);for(bK in bD.headers){bJ.setRequestHeader(bK,bD.headers[bK])}if(bD.beforeSend&&(bD.beforeSend.call(bS,bJ,bD)===false||bA===2)){bJ.abort();return false}for(bK in {success:1,error:1,complete:1}){bJ[bK](bD[bK])}bL=aW(r,bD,bx,bJ);if(!bL){bF(-1,"No Transport")}else{bJ.readyState=1;if(bw){bG.trigger("ajaxSend",[bJ,bD])}if(bD.async&&bD.timeout>0){bE=setTimeout(function(){bJ.abort("timeout")},bD.timeout)}try{bA=1;bL.send(bH,bF)}catch(bM){if(bA<2){bF(-1,bM)}else{throw bM}}}return bJ},param:function(e,bw){var bv=[],by=function(bz,bA){bA=b.isFunction(bA)?bA():bA;bv[bv.length]=encodeURIComponent(bz)+"="+encodeURIComponent(bA)};if(bw===L){bw=b.ajaxSettings.traditional}if(b.isArray(e)||(e.jquery&&!b.isPlainObject(e))){b.each(e,function(){by(this.name,this.value)})}else{for(var bx in e){v(bx,e[bx],bw,by)}}return bv.join("&").replace(k,"+")}});function v(bw,by,bv,bx){if(b.isArray(by)){b.each(by,function(bA,bz){if(bv||ap.test(bw)){bx(bw,bz)}else{v(bw+"["+(typeof bz==="object"||b.isArray(bz)?bA:"")+"]",bz,bv,bx)}})}else{if(!bv&&by!=null&&typeof by==="object"){for(var e in by){v(bw+"["+e+"]",by[e],bv,bx)}}else{bx(bw,by)}}}b.extend({active:0,lastModified:{},etag:{}});function bj(bD,bC,bz){var bv=bD.contents,bB=bD.dataTypes,bw=bD.responseFields,by,bA,bx,e;for(bA in bw){if(bA in bz){bC[bw[bA]]=bz[bA]}}while(bB[0]==="*"){bB.shift();if(by===L){by=bD.mimeType||bC.getResponseHeader("content-type")}}if(by){for(bA in bv){if(bv[bA]&&bv[bA].test(by)){bB.unshift(bA);break}}}if(bB[0] in bz){bx=bB[0]}else{for(bA in bz){if(!bB[0]||bD.converters[bA+" "+bB[0]]){bx=bA;break}if(!e){e=bA}}bx=bx||e}if(bx){if(bx!==bB[0]){bB.unshift(bx)}return bz[bx]}}function G(bH,bz){if(bH.dataFilter){bz=bH.dataFilter(bz,bH.dataType)}var bD=bH.dataTypes,bG={},bA,bE,bw=bD.length,bB,bC=bD[0],bx,by,bF,bv,e;for(bA=1;bA=bw.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();bw.animatedProperties[this.prop]=true;for(bA in bw.animatedProperties){if(bw.animatedProperties[bA]!==true){e=false}}if(e){if(bw.overflow!=null&&!b.support.shrinkWrapBlocks){b.each(["","X","Y"],function(bC,bD){bz.style["overflow"+bD]=bw.overflow[bC]})}if(bw.hide){b(bz).hide()}if(bw.hide||bw.show){for(bA in bw.animatedProperties){b.style(bz,bA,bw.orig[bA]);b.removeData(bz,"fxshow"+bA,true);b.removeData(bz,"toggle"+bA,true)}}bv=bw.complete;if(bv){bw.complete=false;bv.call(bz)}}return false}else{if(bw.duration==Infinity){this.now=bx}else{bB=bx-this.startTime;this.state=bB/bw.duration;this.pos=b.easing[bw.animatedProperties[this.prop]](this.state,bB,0,1,bw.duration);this.now=this.start+((this.end-this.start)*this.pos)}this.update()}return true}};b.extend(b.fx,{tick:function(){var bw,bv=b.timers,e=0;for(;e").appendTo(e),bw=bv.css("display");bv.remove();if(bw==="none"||bw===""){if(!a8){a8=av.createElement("iframe");a8.frameBorder=a8.width=a8.height=0}e.appendChild(a8);if(!m||!a8.createElement){m=(a8.contentWindow||a8.contentDocument).document;m.write((av.compatMode==="CSS1Compat"?"":"")+"");m.close()}bv=m.createElement(bx);m.body.appendChild(bv);bw=b.css(bv,"display");e.removeChild(a8)}Q[bx]=bw}return Q[bx]}var V=/^t(?:able|d|h)$/i,ad=/^(?:body|html)$/i;if("getBoundingClientRect" in av.documentElement){b.fn.offset=function(bI){var by=this[0],bB;if(bI){return this.each(function(e){b.offset.setOffset(this,bI,e)})}if(!by||!by.ownerDocument){return null}if(by===by.ownerDocument.body){return b.offset.bodyOffset(by)}try{bB=by.getBoundingClientRect()}catch(bF){}var bH=by.ownerDocument,bw=bH.documentElement;if(!bB||!b.contains(bw,by)){return bB?{top:bB.top,left:bB.left}:{top:0,left:0}}var bC=bH.body,bD=aK(bH),bA=bw.clientTop||bC.clientTop||0,bE=bw.clientLeft||bC.clientLeft||0,bv=bD.pageYOffset||b.support.boxModel&&bw.scrollTop||bC.scrollTop,bz=bD.pageXOffset||b.support.boxModel&&bw.scrollLeft||bC.scrollLeft,bG=bB.top+bv-bA,bx=bB.left+bz-bE;return{top:bG,left:bx}}}else{b.fn.offset=function(bF){var bz=this[0];if(bF){return this.each(function(bG){b.offset.setOffset(this,bF,bG)})}if(!bz||!bz.ownerDocument){return null}if(bz===bz.ownerDocument.body){return b.offset.bodyOffset(bz)}var bC,bw=bz.offsetParent,bv=bz,bE=bz.ownerDocument,bx=bE.documentElement,bA=bE.body,bB=bE.defaultView,e=bB?bB.getComputedStyle(bz,null):bz.currentStyle,bD=bz.offsetTop,by=bz.offsetLeft;while((bz=bz.parentNode)&&bz!==bA&&bz!==bx){if(b.support.fixedPosition&&e.position==="fixed"){break}bC=bB?bB.getComputedStyle(bz,null):bz.currentStyle;bD-=bz.scrollTop;by-=bz.scrollLeft;if(bz===bw){bD+=bz.offsetTop;by+=bz.offsetLeft;if(b.support.doesNotAddBorder&&!(b.support.doesAddBorderForTableAndCells&&V.test(bz.nodeName))){bD+=parseFloat(bC.borderTopWidth)||0;by+=parseFloat(bC.borderLeftWidth)||0}bv=bw;bw=bz.offsetParent}if(b.support.subtractsBorderForOverflowNotVisible&&bC.overflow!=="visible"){bD+=parseFloat(bC.borderTopWidth)||0;by+=parseFloat(bC.borderLeftWidth)||0}e=bC}if(e.position==="relative"||e.position==="static"){bD+=bA.offsetTop;by+=bA.offsetLeft}if(b.support.fixedPosition&&e.position==="fixed"){bD+=Math.max(bx.scrollTop,bA.scrollTop);by+=Math.max(bx.scrollLeft,bA.scrollLeft)}return{top:bD,left:by}}}b.offset={bodyOffset:function(e){var bw=e.offsetTop,bv=e.offsetLeft;if(b.support.doesNotIncludeMarginInBodyOffset){bw+=parseFloat(b.css(e,"marginTop"))||0;bv+=parseFloat(b.css(e,"marginLeft"))||0}return{top:bw,left:bv}},setOffset:function(bx,bG,bA){var bB=b.css(bx,"position");if(bB==="static"){bx.style.position="relative"}var bz=b(bx),bv=bz.offset(),e=b.css(bx,"top"),bE=b.css(bx,"left"),bF=(bB==="absolute"||bB==="fixed")&&b.inArray("auto",[e,bE])>-1,bD={},bC={},bw,by;if(bF){bC=bz.position();bw=bC.top;by=bC.left}else{bw=parseFloat(e)||0;by=parseFloat(bE)||0}if(b.isFunction(bG)){bG=bG.call(bx,bA,bv)}if(bG.top!=null){bD.top=(bG.top-bv.top)+bw}if(bG.left!=null){bD.left=(bG.left-bv.left)+by}if("using" in bG){bG.using.call(bx,bD)}else{bz.css(bD)}}};b.fn.extend({position:function(){if(!this[0]){return null}var bw=this[0],bv=this.offsetParent(),bx=this.offset(),e=ad.test(bv[0].nodeName)?{top:0,left:0}:bv.offset();bx.top-=parseFloat(b.css(bw,"marginTop"))||0;bx.left-=parseFloat(b.css(bw,"marginLeft"))||0;e.top+=parseFloat(b.css(bv[0],"borderTopWidth"))||0;e.left+=parseFloat(b.css(bv[0],"borderLeftWidth"))||0;return{top:bx.top-e.top,left:bx.left-e.left}},offsetParent:function(){return this.map(function(){var e=this.offsetParent||av.body;while(e&&(!ad.test(e.nodeName)&&b.css(e,"position")==="static")){e=e.offsetParent}return e})}});b.each(["Left","Top"],function(bv,e){var bw="scroll"+e;b.fn[bw]=function(bz){var bx,by;if(bz===L){bx=this[0];if(!bx){return null}by=aK(bx);return by?("pageXOffset" in by)?by[bv?"pageYOffset":"pageXOffset"]:b.support.boxModel&&by.document.documentElement[bw]||by.document.body[bw]:bx[bw]}return this.each(function(){by=aK(this);if(by){by.scrollTo(!bv?bz:b(by).scrollLeft(),bv?bz:b(by).scrollTop())}else{this[bw]=bz}})}});function aK(e){return b.isWindow(e)?e:e.nodeType===9?e.defaultView||e.parentWindow:false}b.each(["Height","Width"],function(bv,e){var bw=e.toLowerCase();b.fn["inner"+e]=function(){var bx=this[0];return bx?bx.style?parseFloat(b.css(bx,bw,"padding")):this[bw]():null};b.fn["outer"+e]=function(by){var bx=this[0];return bx?bx.style?parseFloat(b.css(bx,bw,by?"margin":"border")):this[bw]():null};b.fn[bw]=function(bz){var bA=this[0];if(!bA){return bz==null?null:this}if(b.isFunction(bz)){return this.each(function(bE){var bD=b(this);bD[bw](bz.call(this,bE,bD[bw]()))})}if(b.isWindow(bA)){var bB=bA.document.documentElement["client"+e],bx=bA.document.body;return bA.document.compatMode==="CSS1Compat"&&bB||bx&&bx["client"+e]||bB}else{if(bA.nodeType===9){return Math.max(bA.documentElement["client"+e],bA.body["scroll"+e],bA.documentElement["scroll"+e],bA.body["offset"+e],bA.documentElement["offset"+e])}else{if(bz===L){var bC=b.css(bA,bw),by=parseFloat(bC);return b.isNumeric(by)?by:bC}else{return this.css(bw,typeof bz==="string"?bz:bz+"px")}}}}});bb.jQuery=bb.$=b;if(typeof define==="function"&&define.amd&&define.amd.jQuery){define("jquery",[],function(){return b})}})(window);/*! * jQuery UI 1.8.18 * * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI */ (function(a,d){a.ui=a.ui||{};if(a.ui.version){return}a.extend(a.ui,{version:"1.8.18",keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}});a.fn.extend({propAttr:a.fn.prop||a.fn.attr,_focus:a.fn.focus,focus:function(e,f){return typeof e==="number"?this.each(function(){var g=this;setTimeout(function(){a(g).focus();if(f){f.call(g)}},e)}):this._focus.apply(this,arguments)},scrollParent:function(){var e;if((a.browser.msie&&(/(static|relative)/).test(this.css("position")))||(/absolute/).test(this.css("position"))){e=this.parents().filter(function(){return(/(relative|absolute|fixed)/).test(a.curCSS(this,"position",1))&&(/(auto|scroll)/).test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0)}else{e=this.parents().filter(function(){return(/(auto|scroll)/).test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0)}return(/fixed/).test(this.css("position"))||!e.length?a(document):e},zIndex:function(h){if(h!==d){return this.css("zIndex",h)}if(this.length){var f=a(this[0]),e,g;while(f.length&&f[0]!==document){e=f.css("position");if(e==="absolute"||e==="relative"||e==="fixed"){g=parseInt(f.css("zIndex"),10);if(!isNaN(g)&&g!==0){return g}}f=f.parent()}}return 0},disableSelection:function(){return this.bind((a.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(e){e.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}});a.each(["Width","Height"],function(g,e){var f=e==="Width"?["Left","Right"]:["Top","Bottom"],h=e.toLowerCase(),k={innerWidth:a.fn.innerWidth,innerHeight:a.fn.innerHeight,outerWidth:a.fn.outerWidth,outerHeight:a.fn.outerHeight};function j(m,l,i,n){a.each(f,function(){l-=parseFloat(a.curCSS(m,"padding"+this,true))||0;if(i){l-=parseFloat(a.curCSS(m,"border"+this+"Width",true))||0}if(n){l-=parseFloat(a.curCSS(m,"margin"+this,true))||0}});return l}a.fn["inner"+e]=function(i){if(i===d){return k["inner"+e].call(this)}return this.each(function(){a(this).css(h,j(this,i)+"px")})};a.fn["outer"+e]=function(i,l){if(typeof i!=="number"){return k["outer"+e].call(this,i)}return this.each(function(){a(this).css(h,j(this,i,true,l)+"px")})}});function c(g,e){var j=g.nodeName.toLowerCase();if("area"===j){var i=g.parentNode,h=i.name,f;if(!g.href||!h||i.nodeName.toLowerCase()!=="map"){return false}f=a("img[usemap=#"+h+"]")[0];return !!f&&b(f)}return(/input|select|textarea|button|object/.test(j)?!g.disabled:"a"==j?g.href||e:e)&&b(g)}function b(e){return !a(e).parents().andSelf().filter(function(){return a.curCSS(this,"visibility")==="hidden"||a.expr.filters.hidden(this)}).length}a.extend(a.expr[":"],{data:function(g,f,e){return !!a.data(g,e[3])},focusable:function(e){return c(e,!isNaN(a.attr(e,"tabindex")))},tabbable:function(g){var e=a.attr(g,"tabindex"),f=isNaN(e);return(f||e>=0)&&c(g,!f)}});a(function(){var e=document.body,f=e.appendChild(f=document.createElement("div"));f.offsetHeight;a.extend(f.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});a.support.minHeight=f.offsetHeight===100;a.support.selectstart="onselectstart" in f;e.removeChild(f).style.display="none"});a.extend(a.ui,{plugin:{add:function(f,g,j){var h=a.ui[f].prototype;for(var e in j){h.plugins[e]=h.plugins[e]||[];h.plugins[e].push([g,j[e]])}},call:function(e,g,f){var j=e.plugins[g];if(!j||!e.element[0].parentNode){return}for(var h=0;h0){return true}h[e]=1;g=(h[e]>0);h[e]=0;return g},isOverAxis:function(f,e,g){return(f>e)&&(f<(e+g))},isOver:function(j,f,i,h,e,g){return a.ui.isOverAxis(j,i,e)&&a.ui.isOverAxis(f,h,g)}})})(jQuery);/*! * jQuery UI Widget 1.8.18 * * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Widget */ (function(b,d){if(b.cleanData){var c=b.cleanData;b.cleanData=function(f){for(var g=0,h;(h=f[g])!=null;g++){try{b(h).triggerHandler("remove")}catch(j){}}c(f)}}else{var a=b.fn.remove;b.fn.remove=function(e,f){return this.each(function(){if(!f){if(!e||b.filter(e,[this]).length){b("*",this).add([this]).each(function(){try{b(this).triggerHandler("remove")}catch(g){}})}}return a.call(b(this),e,f)})}}b.widget=function(f,h,e){var g=f.split(".")[0],j;f=f.split(".")[1];j=g+"-"+f;if(!e){e=h;h=b.Widget}b.expr[":"][j]=function(k){return !!b.data(k,f)};b[g]=b[g]||{};b[g][f]=function(k,l){if(arguments.length){this._createWidget(k,l)}};var i=new h();i.options=b.extend(true,{},i.options);b[g][f].prototype=b.extend(true,i,{namespace:g,widgetName:f,widgetEventPrefix:b[g][f].prototype.widgetEventPrefix||f,widgetBaseClass:j},e);b.widget.bridge(f,b[g][f])};b.widget.bridge=function(f,e){b.fn[f]=function(i){var g=typeof i==="string",h=Array.prototype.slice.call(arguments,1),j=this;i=!g&&h.length?b.extend.apply(null,[true,i].concat(h)):i;if(g&&i.charAt(0)==="_"){return j}if(g){this.each(function(){var k=b.data(this,f),l=k&&b.isFunction(k[i])?k[i].apply(k,h):k;if(l!==k&&l!==d){j=l;return false}})}else{this.each(function(){var k=b.data(this,f);if(k){k.option(i||{})._init()}else{b.data(this,f,new e(i,this))}})}return j}};b.Widget=function(e,f){if(arguments.length){this._createWidget(e,f)}};b.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(f,g){b.data(g,this.widgetName,this);this.element=b(g);this.options=b.extend(true,{},this.options,this._getCreateOptions(),f);var e=this;this.element.bind("remove."+this.widgetName,function(){e.destroy()});this._create();this._trigger("create");this._init()},_getCreateOptions:function(){return b.metadata&&b.metadata.get(this.element[0])[this.widgetName]},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled ui-state-disabled")},widget:function(){return this.element},option:function(f,g){var e=f;if(arguments.length===0){return b.extend({},this.options)}if(typeof f==="string"){if(g===d){return this.options[f]}e={};e[f]=g}this._setOptions(e);return this},_setOptions:function(f){var e=this;b.each(f,function(g,h){e._setOption(g,h)});return this},_setOption:function(e,f){this.options[e]=f;if(e==="disabled"){this.widget()[f?"addClass":"removeClass"](this.widgetBaseClass+"-disabled ui-state-disabled").attr("aria-disabled",f)}return this},enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_trigger:function(e,f,g){var j,i,h=this.options[e];g=g||{};f=b.Event(f);f.type=(e===this.widgetEventPrefix?e:this.widgetEventPrefix+e).toLowerCase();f.target=this.element[0];i=f.originalEvent;if(i){for(j in i){if(!(j in f)){f[j]=i[j]}}}this.element.trigger(f,g);return !(b.isFunction(h)&&h.call(this.element[0],f,g)===false||f.isDefaultPrevented())}}})(jQuery);/*! * jQuery UI Mouse 1.8.18 * * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) * Dual licensed under the MIT or GPL Version 2 licenses. * http://jquery.org/license * * http://docs.jquery.com/UI/Mouse * * Depends: * jquery.ui.widget.js */ (function(b,c){var a=false;b(document).mouseup(function(d){a=false});b.widget("ui.mouse",{options:{cancel:":input,option",distance:1,delay:0},_mouseInit:function(){var d=this;this.element.bind("mousedown."+this.widgetName,function(e){return d._mouseDown(e)}).bind("click."+this.widgetName,function(e){if(true===b.data(e.target,d.widgetName+".preventClickEvent")){b.removeData(e.target,d.widgetName+".preventClickEvent");e.stopImmediatePropagation();return false}});this.started=false},_mouseDestroy:function(){this.element.unbind("."+this.widgetName)},_mouseDown:function(f){if(a){return}(this._mouseStarted&&this._mouseUp(f));this._mouseDownEvent=f;var e=this,g=(f.which==1),d=(typeof this.options.cancel=="string"&&f.target.nodeName?b(f.target).closest(this.options.cancel).length:false);if(!g||d||!this._mouseCapture(f)){return true}this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet){this._mouseDelayTimer=setTimeout(function(){e.mouseDelayMet=true},this.options.delay)}if(this._mouseDistanceMet(f)&&this._mouseDelayMet(f)){this._mouseStarted=(this._mouseStart(f)!==false);if(!this._mouseStarted){f.preventDefault();return true}}if(true===b.data(f.target,this.widgetName+".preventClickEvent")){b.removeData(f.target,this.widgetName+".preventClickEvent")}this._mouseMoveDelegate=function(h){return e._mouseMove(h)};this._mouseUpDelegate=function(h){return e._mouseUp(h)};b(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);f.preventDefault();a=true;return true},_mouseMove:function(d){if(b.browser.msie&&!(document.documentMode>=9)&&!d.button){return this._mouseUp(d)}if(this._mouseStarted){this._mouseDrag(d);return d.preventDefault()}if(this._mouseDistanceMet(d)&&this._mouseDelayMet(d)){this._mouseStarted=(this._mouseStart(this._mouseDownEvent,d)!==false);(this._mouseStarted?this._mouseDrag(d):this._mouseUp(d))}return !this._mouseStarted},_mouseUp:function(d){b(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;if(d.target==this._mouseDownEvent.target){b.data(d.target,this.widgetName+".preventClickEvent",true)}this._mouseStop(d)}return false},_mouseDistanceMet:function(d){return(Math.max(Math.abs(this._mouseDownEvent.pageX-d.pageX),Math.abs(this._mouseDownEvent.pageY-d.pageY))>=this.options.distance)},_mouseDelayMet:function(d){return this.mouseDelayMet},_mouseStart:function(d){},_mouseDrag:function(d){},_mouseStop:function(d){},_mouseCapture:function(d){return true}})})(jQuery);(function(c,d){c.widget("ui.resizable",c.ui.mouse,{widgetEventPrefix:"resize",options:{alsoResize:false,animate:false,animateDuration:"slow",animateEasing:"swing",aspectRatio:false,autoHide:false,containment:false,ghost:false,grid:false,handles:"e,s,se",helper:false,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:1000},_create:function(){var f=this,k=this.options;this.element.addClass("ui-resizable");c.extend(this,{_aspectRatio:!!(k.aspectRatio),aspectRatio:k.aspectRatio,originalElement:this.element,_proportionallyResizeElements:[],_helper:k.helper||k.ghost||k.animate?k.helper||"ui-resizable-helper":null});if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)){this.element.wrap(c('
    ').css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")}));this.element=this.element.parent().data("resizable",this.element.data("resizable"));this.elementIsWrapper=true;this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")});this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0});this.originalResizeStyle=this.originalElement.css("resize");this.originalElement.css("resize","none");this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"}));this.originalElement.css({margin:this.originalElement.css("margin")});this._proportionallyResize()}this.handles=k.handles||(!c(".ui-resizable-handle",this.element).length?"e,s,se":{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"});if(this.handles.constructor==String){if(this.handles=="all"){this.handles="n,e,s,w,se,sw,ne,nw"}var l=this.handles.split(",");this.handles={};for(var g=0;g
    ');if(/sw|se|ne|nw/.test(j)){h.css({zIndex:++k.zIndex})}if("se"==j){h.addClass("ui-icon ui-icon-gripsmall-diagonal-se")}this.handles[j]=".ui-resizable-"+j;this.element.append(h)}}this._renderAxis=function(q){q=q||this.element;for(var n in this.handles){if(this.handles[n].constructor==String){this.handles[n]=c(this.handles[n],this.element).show()}if(this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)){var o=c(this.handles[n],this.element),p=0;p=/sw|ne|nw|se|n|s/.test(n)?o.outerHeight():o.outerWidth();var m=["padding",/ne|nw|n/.test(n)?"Top":/se|sw|s/.test(n)?"Bottom":/^e$/.test(n)?"Right":"Left"].join("");q.css(m,p);this._proportionallyResize()}if(!c(this.handles[n]).length){continue}}};this._renderAxis(this.element);this._handles=c(".ui-resizable-handle",this.element).disableSelection();this._handles.mouseover(function(){if(!f.resizing){if(this.className){var i=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)}f.axis=i&&i[1]?i[1]:"se"}});if(k.autoHide){this._handles.hide();c(this.element).addClass("ui-resizable-autohide").hover(function(){if(k.disabled){return}c(this).removeClass("ui-resizable-autohide");f._handles.show()},function(){if(k.disabled){return}if(!f.resizing){c(this).addClass("ui-resizable-autohide");f._handles.hide()}})}this._mouseInit()},destroy:function(){this._mouseDestroy();var e=function(g){c(g).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};if(this.elementIsWrapper){e(this.element);var f=this.element;f.after(this.originalElement.css({position:f.css("position"),width:f.outerWidth(),height:f.outerHeight(),top:f.css("top"),left:f.css("left")})).remove()}this.originalElement.css("resize",this.originalResizeStyle);e(this.originalElement);return this},_mouseCapture:function(f){var g=false;for(var e in this.handles){if(c(this.handles[e])[0]==f.target){g=true}}return !this.options.disabled&&g},_mouseStart:function(g){var j=this.options,f=this.element.position(),e=this.element;this.resizing=true;this.documentScroll={top:c(document).scrollTop(),left:c(document).scrollLeft()};if(e.is(".ui-draggable")||(/absolute/).test(e.css("position"))){e.css({position:"absolute",top:f.top,left:f.left})}this._renderProxy();var k=b(this.helper.css("left")),h=b(this.helper.css("top"));if(j.containment){k+=c(j.containment).scrollLeft()||0;h+=c(j.containment).scrollTop()||0}this.offset=this.helper.offset();this.position={left:k,top:h};this.size=this._helper?{width:e.outerWidth(),height:e.outerHeight()}:{width:e.width(),height:e.height()};this.originalSize=this._helper?{width:e.outerWidth(),height:e.outerHeight()}:{width:e.width(),height:e.height()};this.originalPosition={left:k,top:h};this.sizeDiff={width:e.outerWidth()-e.width(),height:e.outerHeight()-e.height()};this.originalMousePosition={left:g.pageX,top:g.pageY};this.aspectRatio=(typeof j.aspectRatio=="number")?j.aspectRatio:((this.originalSize.width/this.originalSize.height)||1);var i=c(".ui-resizable-"+this.axis).css("cursor");c("body").css("cursor",i=="auto"?this.axis+"-resize":i);e.addClass("ui-resizable-resizing");this._propagate("start",g);return true},_mouseDrag:function(e){var h=this.helper,g=this.options,m={},q=this,j=this.originalMousePosition,n=this.axis;var r=(e.pageX-j.left)||0,p=(e.pageY-j.top)||0;var i=this._change[n];if(!i){return false}var l=i.apply(this,[e,r,p]),k=c.browser.msie&&c.browser.version<7,f=this.sizeDiff;this._updateVirtualBoundaries(e.shiftKey);if(this._aspectRatio||e.shiftKey){l=this._updateRatio(l,e)}l=this._respectSize(l,e);this._propagate("resize",e);h.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"});if(!this._helper&&this._proportionallyResizeElements.length){this._proportionallyResize()}this._updateCache(l);this._trigger("resize",e,this.ui());return false},_mouseStop:function(h){this.resizing=false;var i=this.options,m=this;if(this._helper){var g=this._proportionallyResizeElements,e=g.length&&(/textarea/i).test(g[0].nodeName),f=e&&c.ui.hasScroll(g[0],"left")?0:m.sizeDiff.height,k=e?0:m.sizeDiff.width;var n={width:(m.helper.width()-k),height:(m.helper.height()-f)},j=(parseInt(m.element.css("left"),10)+(m.position.left-m.originalPosition.left))||null,l=(parseInt(m.element.css("top"),10)+(m.position.top-m.originalPosition.top))||null;if(!i.animate){this.element.css(c.extend(n,{top:l,left:j}))}m.helper.height(m.size.height);m.helper.width(m.size.width);if(this._helper&&!i.animate){this._proportionallyResize()}}c("body").css("cursor","auto");this.element.removeClass("ui-resizable-resizing");this._propagate("stop",h);if(this._helper){this.helper.remove()}return false},_updateVirtualBoundaries:function(g){var j=this.options,i,h,f,k,e;e={minWidth:a(j.minWidth)?j.minWidth:0,maxWidth:a(j.maxWidth)?j.maxWidth:Infinity,minHeight:a(j.minHeight)?j.minHeight:0,maxHeight:a(j.maxHeight)?j.maxHeight:Infinity};if(this._aspectRatio||g){i=e.minHeight*this.aspectRatio;f=e.minWidth/this.aspectRatio;h=e.maxHeight*this.aspectRatio;k=e.maxWidth/this.aspectRatio;if(i>e.minWidth){e.minWidth=i}if(f>e.minHeight){e.minHeight=f}if(hl.width),s=a(l.height)&&i.minHeight&&(i.minHeight>l.height);if(h){l.width=i.minWidth}if(s){l.height=i.minHeight}if(t){l.width=i.maxWidth}if(m){l.height=i.maxHeight}var f=this.originalPosition.left+this.originalSize.width,p=this.position.top+this.size.height;var k=/sw|nw|w/.test(q),e=/nw|ne|n/.test(q);if(h&&k){l.left=f-i.minWidth}if(t&&k){l.left=f-i.maxWidth}if(s&&e){l.top=p-i.minHeight}if(m&&e){l.top=p-i.maxHeight}var n=!l.width&&!l.height;if(n&&!l.left&&l.top){l.top=null}else{if(n&&!l.top&&l.left){l.left=null}}return l},_proportionallyResize:function(){var k=this.options;if(!this._proportionallyResizeElements.length){return}var g=this.helper||this.element;for(var f=0;f');var e=c.browser.msie&&c.browser.version<7,g=(e?1:0),h=(e?2:-1);this.helper.addClass(this._helper).css({width:this.element.outerWidth()+h,height:this.element.outerHeight()+h,position:"absolute",left:this.elementOffset.left-g+"px",top:this.elementOffset.top-g+"px",zIndex:++i.zIndex});this.helper.appendTo("body").disableSelection()}else{this.helper=this.element}},_change:{e:function(g,f,e){return{width:this.originalSize.width+f}},w:function(h,f,e){var j=this.options,g=this.originalSize,i=this.originalPosition;return{left:i.left+f,width:g.width-f}},n:function(h,f,e){var j=this.options,g=this.originalSize,i=this.originalPosition;return{top:i.top+e,height:g.height-e}},s:function(g,f,e){return{height:this.originalSize.height+e}},se:function(g,f,e){return c.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[g,f,e]))},sw:function(g,f,e){return c.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[g,f,e]))},ne:function(g,f,e){return c.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[g,f,e]))},nw:function(g,f,e){return c.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[g,f,e]))}},_propagate:function(f,e){c.ui.plugin.call(this,f,[e,this.ui()]);(f!="resize"&&this._trigger(f,e,this.ui()))},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}});c.extend(c.ui.resizable,{version:"1.8.18"});c.ui.plugin.add("resizable","alsoResize",{start:function(f,g){var e=c(this).data("resizable"),i=e.options;var h=function(j){c(j).each(function(){var k=c(this);k.data("resizable-alsoresize",{width:parseInt(k.width(),10),height:parseInt(k.height(),10),left:parseInt(k.css("left"),10),top:parseInt(k.css("top"),10)})})};if(typeof(i.alsoResize)=="object"&&!i.alsoResize.parentNode){if(i.alsoResize.length){i.alsoResize=i.alsoResize[0];h(i.alsoResize)}else{c.each(i.alsoResize,function(j){h(j)})}}else{h(i.alsoResize)}},resize:function(g,i){var f=c(this).data("resizable"),j=f.options,h=f.originalSize,l=f.originalPosition;var k={height:(f.size.height-h.height)||0,width:(f.size.width-h.width)||0,top:(f.position.top-l.top)||0,left:(f.position.left-l.left)||0},e=function(m,n){c(m).each(function(){var q=c(this),r=c(this).data("resizable-alsoresize"),p={},o=n&&n.length?n:q.parents(i.originalElement[0]).length?["width","height"]:["width","height","top","left"];c.each(o,function(s,u){var t=(r[u]||0)+(k[u]||0);if(t&&t>=0){p[u]=t||null}});q.css(p)})};if(typeof(j.alsoResize)=="object"&&!j.alsoResize.nodeType){c.each(j.alsoResize,function(m,n){e(m,n)})}else{e(j.alsoResize)}},stop:function(e,f){c(this).removeData("resizable-alsoresize")}});c.ui.plugin.add("resizable","animate",{stop:function(i,n){var p=c(this).data("resizable"),j=p.options;var h=p._proportionallyResizeElements,e=h.length&&(/textarea/i).test(h[0].nodeName),f=e&&c.ui.hasScroll(h[0],"left")?0:p.sizeDiff.height,l=e?0:p.sizeDiff.width;var g={width:(p.size.width-l),height:(p.size.height-f)},k=(parseInt(p.element.css("left"),10)+(p.position.left-p.originalPosition.left))||null,m=(parseInt(p.element.css("top"),10)+(p.position.top-p.originalPosition.top))||null;p.element.animate(c.extend(g,m&&k?{top:m,left:k}:{}),{duration:j.animateDuration,easing:j.animateEasing,step:function(){var o={width:parseInt(p.element.css("width"),10),height:parseInt(p.element.css("height"),10),top:parseInt(p.element.css("top"),10),left:parseInt(p.element.css("left"),10)};if(h&&h.length){c(h[0]).css({width:o.width,height:o.height})}p._updateCache(o);p._propagate("resize",i)}})}});c.ui.plugin.add("resizable","containment",{start:function(f,r){var t=c(this).data("resizable"),j=t.options,l=t.element;var g=j.containment,k=(g instanceof c)?g.get(0):(/parent/.test(g))?l.parent().get(0):g;if(!k){return}t.containerElement=c(k);if(/document/.test(g)||g==document){t.containerOffset={left:0,top:0};t.containerPosition={left:0,top:0};t.parentData={element:c(document),left:0,top:0,width:c(document).width(),height:c(document).height()||document.body.parentNode.scrollHeight}}else{var n=c(k),i=[];c(["Top","Right","Left","Bottom"]).each(function(p,o){i[p]=b(n.css("padding"+o))});t.containerOffset=n.offset();t.containerPosition=n.position();t.containerSize={height:(n.innerHeight()-i[3]),width:(n.innerWidth()-i[1])};var q=t.containerOffset,e=t.containerSize.height,m=t.containerSize.width,h=(c.ui.hasScroll(k,"left")?k.scrollWidth:m),s=(c.ui.hasScroll(k)?k.scrollHeight:e);t.parentData={element:k,left:q.left,top:q.top,width:h,height:s}}},resize:function(g,q){var t=c(this).data("resizable"),i=t.options,f=t.containerSize,p=t.containerOffset,m=t.size,n=t.position,r=t._aspectRatio||g.shiftKey,e={top:0,left:0},h=t.containerElement;if(h[0]!=document&&(/static/).test(h.css("position"))){e=p}if(n.left<(t._helper?p.left:0)){t.size.width=t.size.width+(t._helper?(t.position.left-p.left):(t.position.left-e.left));if(r){t.size.height=t.size.width/i.aspectRatio}t.position.left=i.helper?p.left:0}if(n.top<(t._helper?p.top:0)){t.size.height=t.size.height+(t._helper?(t.position.top-p.top):t.position.top);if(r){t.size.width=t.size.height*i.aspectRatio}t.position.top=t._helper?p.top:0}t.offset.left=t.parentData.left+t.position.left;t.offset.top=t.parentData.top+t.position.top;var l=Math.abs((t._helper?t.offset.left-e.left:(t.offset.left-e.left))+t.sizeDiff.width),s=Math.abs((t._helper?t.offset.top-e.top:(t.offset.top-p.top))+t.sizeDiff.height);var k=t.containerElement.get(0)==t.element.parent().get(0),j=/relative|absolute/.test(t.containerElement.css("position"));if(k&&j){l-=t.parentData.left}if(l+t.size.width>=t.parentData.width){t.size.width=t.parentData.width-l;if(r){t.size.height=t.size.width/t.aspectRatio}}if(s+t.size.height>=t.parentData.height){t.size.height=t.parentData.height-s;if(r){t.size.width=t.size.height*t.aspectRatio}}},stop:function(f,n){var q=c(this).data("resizable"),g=q.options,l=q.position,m=q.containerOffset,e=q.containerPosition,i=q.containerElement;var j=c(q.helper),r=j.offset(),p=j.outerWidth()-q.sizeDiff.width,k=j.outerHeight()-q.sizeDiff.height;if(q._helper&&!g.animate&&(/relative/).test(i.css("position"))){c(this).css({left:r.left-e.left-m.left,width:p,height:k})}if(q._helper&&!g.animate&&(/static/).test(i.css("position"))){c(this).css({left:r.left-e.left-m.left,width:p,height:k})}}});c.ui.plugin.add("resizable","ghost",{start:function(g,h){var e=c(this).data("resizable"),i=e.options,f=e.size;e.ghost=e.originalElement.clone();e.ghost.css({opacity:0.25,display:"block",position:"relative",height:f.height,width:f.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass(typeof i.ghost=="string"?i.ghost:"");e.ghost.appendTo(e.helper)},resize:function(f,g){var e=c(this).data("resizable"),h=e.options;if(e.ghost){e.ghost.css({position:"relative",height:e.size.height,width:e.size.width})}},stop:function(f,g){var e=c(this).data("resizable"),h=e.options;if(e.ghost&&e.helper){e.helper.get(0).removeChild(e.ghost.get(0))}}});c.ui.plugin.add("resizable","grid",{resize:function(e,m){var p=c(this).data("resizable"),h=p.options,k=p.size,i=p.originalSize,j=p.originalPosition,n=p.axis,l=h._aspectRatio||e.shiftKey;h.grid=typeof h.grid=="number"?[h.grid,h.grid]:h.grid;var g=Math.round((k.width-i.width)/(h.grid[0]||1))*(h.grid[0]||1),f=Math.round((k.height-i.height)/(h.grid[1]||1))*(h.grid[1]||1);if(/^(se|s|e)$/.test(n)){p.size.width=i.width+g;p.size.height=i.height+f}else{if(/^(ne)$/.test(n)){p.size.width=i.width+g;p.size.height=i.height+f;p.position.top=j.top-f}else{if(/^(sw)$/.test(n)){p.size.width=i.width+g;p.size.height=i.height+f;p.position.left=j.left-g}else{p.size.width=i.width+g;p.size.height=i.height+f;p.position.top=j.top-f;p.position.left=j.left-g}}}}});var b=function(e){return parseInt(e,10)||0};var a=function(e){return !isNaN(parseInt(e,10))}})(jQuery);/*! * jQuery hashchange event - v1.3 - 7/21/2010 * http://benalman.com/projects/jquery-hashchange-plugin/ * * Copyright (c) 2010 "Cowboy" Ben Alman * Dual licensed under the MIT and GPL licenses. * http://benalman.com/about/license/ */ (function($,e,b){var c="hashchange",h=document,f,g=$.event.special,i=h.documentMode,d="on"+c in e&&(i===b||i>7);function a(j){j=j||location.href;return"#"+j.replace(/^[^#]*#?(.*)$/,"$1")}$.fn[c]=function(j){return j?this.bind(c,j):this.trigger(c)};$.fn[c].delay=50;g[c]=$.extend(g[c],{setup:function(){if(d){return false}$(f.start)},teardown:function(){if(d){return false}$(f.stop)}});f=(function(){var j={},p,m=a(),k=function(q){return q},l=k,o=k;j.start=function(){p||n()};j.stop=function(){p&&clearTimeout(p);p=b};function n(){var r=a(),q=o(m);if(r!==m){l(m=r,q);$(e).trigger(c)}else{if(q!==m){location.href=location.href.replace(/#.*/,"")+q}}p=setTimeout(n,$.fn[c].delay)}$.browser.msie&&!d&&(function(){var q,r;j.start=function(){if(!q){r=$.fn[c].src;r=r&&r+a();q=$('
    Modules
    Here is a list of all modules:
    [detail level 123]
     The db-lib APIFunctions callable by db-lib client programs
     Primary functionsCore functions needed by most db-lib programs
     Remote Procedure functionsFunctions used with stored procedures
     Bulk copy functionsFunctions to bulk-copy (a/k/a bcp) data to/from the database
     Internal bcp functionsStatic functions internal to the bcp library
     Money functionsFunctions to manipulate the MONEY datatype
     Datetime functionsFunctions to manipulate DBDATETIME structures
     InternalsFunctions called within db-lib for self-help
     UnimplementedFunctions thus far not implemented in the FreeTDS db-lib implementation
     ODBC APIFunctions callable by ODBC client programs
     ODBC utilityFunctions called within ODBC driver
     LibTDS APICallable functions in libtds
     AuthenticationFunctions for handling authentication
     ConfigurationHandle reading of configuration
     ConversionConversions between datatypes
     Charset conversionConvert between different charsets
     Memory allocationAllocate or free resources
     QueryFunction to handle query
     Network functionsFunctions for reading or writing from network
     Dynamic string functionsHandle dynamic string
     Results processingHandle tokens in packets
    freetds-1.00.82/doc/reference/nav_f.png100644 025423 025423 00000000231 13242511131 0013315‰PNG  IHDR8³»`IDATxíÝK€ EÑ–·[†øBÑmkâÄÂH—prÓ¼.‚Žó‚ꎤR6Z VI±E‚5j³„lóš›iI˜¬ÞêçJ0ŒÑÑ/Žû›™uøñóÞ¿6sH ÝõyIEND®B`‚freetds-1.00.82/doc/reference/nav_g.png100644 025423 025423 00000000137 13242511131 0013323‰PNG  IHDRô1&IDATxíÝ1 ÁOHf„á_ ->~¸åM iËMèÀƒS½ü‚<IEND®B`‚freetds-1.00.82/doc/reference/nav_h.png100644 025423 025423 00000000142 13242511131 0013320‰PNG  IHDR ,é@)IDATxíÝA @BQ­³šÛ›Ð¢Žáà) )ëý éaÅèÜ¿Æo‡RlÐßIEND®B`‚freetds-1.00.82/doc/reference/open.png100644 025423 025423 00000000173 13242511131 0013172‰PNG  IHDR à‘BIDATxíÝÁ €0 Ð׬ՙ\Àº€39—b!©9{|ðI>$#Àß´ý8/¨ÄØzƒ/Ï>2À[ÎgiU,/¬~¼Ï\ Ä9Ù¸IEND®B`‚freetds-1.00.82/doc/reference/pages.html100644 025423 025423 00000006427 13242511133 0013522 FreeTDS API: Related Pages
    FreeTDS API
    Related Pages
    Here is a list of all related documentation pages:
    freetds-1.00.82/doc/reference/splitbar.png100644 025423 025423 00000000472 13242511136 0014060‰PNG  IHDRM¸¿IDATxíÝ¡JCa‡ñç(˜ ëƒ%±Ø4 b±È˜Í¶3˜v^Á±˜…ãó–ŽELƒõ…¥•³ ,ÿb;íç{Ã/¼ðÞÀaYÕ¯åóøq:¼º¹›\òIIIIIIIIIIIIIIIIII-Òçl¹›«õ抢è_t/Ï»ã£ÑíYQVõðêäíã÷´×ùY¬Úÿµ§¦ivók¾_íåýÛ£I@$I@$I@$I@$I@$I@$I@$I@$I@$I@$I@$I@$I@$I@$I@$I@$I@$I@$ýC[Vì=ü[„fÆIEND®B`‚freetds-1.00.82/doc/reference/sync_off.png100644 025423 025423 00000001525 13242511131 0014041‰PNG  IHDRàw=øIDATxíÝKhTWÀñÿä1I&3™8M¦Iš™†I3Ú©b$cÌ I1V1±-(Tö±±Ð.* t!‚K[¥Ä¥ˆ„¨´f£`l(øl©"Y”¤6ÆgÌTú}·sgîܹ ±d{8?æÌ¹÷;çÜuíÚ`:!±F¬¢BäŠ?ŰÄm'yÊÅ>ÑlU¯½üý‰è_‹?€Œê ]€Y(ŠNñ±8fý1°Öqún-eâ¨øtºmâÈ Ó0}b›ù%·©µ×Œ®=Ÿ0´³?Š1sŸ‹0€¯8À‘;_ ‹W|%\ Zð— >舽ln¨p©.aÇ{ )t;Ú b nŸš¯›65°¢¡2çÅÔ?Žž>Oдàuönm¤¢Ì`×­Z¬WjC~>‘Ö¾0+á {{©fÝ×Mæ·æÅ•ìÙ¼˜` Ý›%uA6´½ÅÆö¨Á,]k¢ÄW¼™u±›]‹ˆ7§¯iòh€ ¶¶¬ÏÖu1 ló —Ҷ̺–:ÞÍ\ÄcãÏxøhR²Êè‡Qt$¿ß§¨ ª fdºü<4BÿÙ[•f¸d7=.Mé9/—éªÃëù/ÿO Üaàò}€,‘j?Ÿõ.5Úšm?œÿŸ®ŽXÿ2¬#¸d píæ(£?cÛú¼!½›a1¥Þ—ŽòØ©ܾ7dÔK:‚ùÒ‰ì)Ê3‚Ü™àÌà]€,±H€µ+køöäu<|`·LhC7¹ÔeÍ Ÿ×Ÿ˜tÜ‹ óH$^2%l.êaeÐäýE”ÌÉ|ÅÜìî‰Ýsä }¸ýDû^hzé~ðR›¦Ã¡¿]|#ü¯@×—Ö‡[k¹–<|š(Ç*€Ý¹dÇtMé:Ýñø«Ø,êÅû¢]”' øXÓ_nò¡Æ|Øý /c§fžâOIEND®B`‚freetds-1.00.82/doc/reference/sync_on.png100644 025423 025423 00000001515 13242511131 0013702‰PNG  IHDRàw=øIDATxíÝ_HTYÀñï8ã¤ó§i§4-g6ÆËÕ&kQ)¨Ô!Š0ÒURKÚ…„ê¡/»PEÁ>ìK-+KÁ²Ñ.Y”¾dEPaA‰ø°¥¶›ZSÓïÜ;3wºŠ–¯—߯gfîïœsçœWKÇñ.€ÉøD­¨a‘'¬âq_ôˆk¢ÀŒ ÀDŽøQ´ÄïC¨¶åñÏÿgÅ ñ 0„Y‚:qZ¦Á)~õâ€èLý0HVñ× žz-¿‰C“%¨g¦˜6€é8%Úõ¬ëwêÙUÏ¿˜ª³Ä }? ?€·3ÀÀž©Š À”K• @hà a±ðaÇæUe‹ sù~ë2²ì“&Ú&B*AÄljæºììi*˨,Ëçí»÷oÆ£T”,d[˜¼3-*ÁÀ…>å‡Ë çLÉŸçfk˜Ò éw#*AEjKUy>ûšËÉõ&{µ¢8—m5Ki¬ jjƒD*¿NŽÖigwÃ7Dª’mz骹úKÛ¾±ˆ¶M!æ¤ÍkÐ?šoý¬_åÓlXí#Ò~–¸¬ê×ÒÑXŠÓ‘ùRÙ*Eû‚ՂדðEÜ;6«e"Q(²Ù=–¿Ezæ5Kؼָ_ 1òzBªJë ±XŒì96åªjL^7{ùãJÑ÷1½i@%8'7M©_\Qœ#ÓUŒËñýÿyõ Wo Éx8¼s¥v¯ªì|×SnÜ q_m Ýé î>bèÕí[JX,½4[Tú{R£ë¼ôˆ¾þa€tÝjjzzÅ'ÅìȶiIžŽòwÏs ¡€—ÕKøõâC^ŽŒ˜Y­¨µÉ%6¨´êˆº]vÛðhâ½iWv–hôëê°Ò¨¾'æÌ‚·ñ|[ßìúÅ^€YrD=<ýDû]äÇ÷s€Ïõ‹8™ºCì? À ¨—t4õᩎ¡Jã‡W‹É± îr¼cjMɘìx| šE©øNÔ‰œøA¢þ«–€Z¼ñ‡jó î#™§¢¢4gIEND®B`‚freetds-1.00.82/doc/reference/tab_a.png100644 025423 025423 00000000216 13242511131 0013275‰PNG  IHDR$ÇÇ[UIDATxíK €0C'o¤(Šˆ[Žà%Üxÿ#Ù©­ç ùÁöó¦W¦e# 3t I 3+¼øEã~\D½9¯Ûàè’wM·¿öÿ}Yõ_êA4Yžã}IEND®B`‚freetds-1.00.82/doc/reference/tab_b.png100644 025423 025423 00000000251 13242511131 0013275‰PNG  IHDR$ÇÇ[pIDATxíÝMƒ EáÇ»ÐÔ¸¸u`âÀ´V0РÆ}:t]DÁ²s¿ä®‚¶ýËu¥ø|’xùî½À>ÿ1»& mÄ8ÜSÙÑxÜLÀUûšÞ²ÄiE–ŠåOs„¢’nxàÒêÓKN²~jIEND®B`‚freetds-1.00.82/doc/reference/tab_h.png100644 025423 025423 00000000261 13242511131 0013304‰PNG  IHDR$ÇÇ[xIDATxíÝMÁ@†áž~¥ÜÆÎ’Evˆ¿"!•²‘d*×rGq=Š{¼ßSݧçë­ÓÉHÇ uO^õø[À_‡¢ãXvyËþÒ±=·VCffææ{°öŠó´Rçœ%_õçÿŽ¢ö·°Çrug¶(?gh\i>|sIEND®B`‚freetds-1.00.82/doc/reference/tab_s.png100644 025423 025423 00000000270 13242511131 0013317‰PNG  IHDR$ÇÇ[IDATxíÝ ‚@@Ñ£?Q…¤"š¢%¦I‘—Šf–6[´HÃäQƒ<Þâõþ]ždr Í’s?ˆO=Ñññw'ÌF‡Ž íðö-~rÃ[œèŠ­ì¬mƒÖ¬ƒݯнŠÕF)Yº% §`nÌ,9B ™’©!ÑŒ\ý<Å#üîî•IEND®B`‚freetds-1.00.82/doc/reference/tabs.css100644 025423 025423 00000022075 13242511131 0013173.sm{position:relative;z-index:9999}.sm,.sm ul,.sm li{display:block;list-style:none;margin:0;padding:0;line-height:normal;direction:ltr;text-align:left;-webkit-tap-highlight-color:rgba(0,0,0,0)}.sm-rtl,.sm-rtl ul,.sm-rtl li{direction:rtl;text-align:right}.sm>li>h1,.sm>li>h2,.sm>li>h3,.sm>li>h4,.sm>li>h5,.sm>li>h6{margin:0;padding:0}.sm ul{display:none}.sm li,.sm a{position:relative}.sm a{display:block}.sm a.disabled{cursor:not-allowed}.sm:after{content:"\00a0";display:block;height:0;font:0/0 serif;clear:both;visibility:hidden;overflow:hidden}.sm,.sm *,.sm *:before,.sm *:after{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}#doc-content{overflow:auto;display:block;padding:0;margin:0;-webkit-overflow-scrolling:touch}.sm-dox{background-image:url("tab_b.png")}.sm-dox a,.sm-dox a:focus,.sm-dox a:hover,.sm-dox a:active{padding:0 12px;padding-right:43px;font-family:"Lucida Grande","Geneva","Helvetica",Arial,sans-serif;font-size:13px;font-weight:bold;line-height:36px;text-decoration:none;text-shadow:0 1px 1px rgba(255,255,255,0.9);color:#283a5d;outline:0}.sm-dox a:hover{background-image:url("tab_a.png");background-repeat:repeat-x;color:white;text-shadow:0 1px 1px black}.sm-dox a.current{color:#d23600}.sm-dox a.disabled{color:#bbb}.sm-dox a span.sub-arrow{position:absolute;top:50%;margin-top:-14px;left:auto;right:3px;width:28px;height:28px;overflow:hidden;font:bold 12px/28px monospace!important;text-align:center;text-shadow:none;background:rgba(255,255,255,0.5);-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px}.sm-dox a.highlighted span.sub-arrow:before{display:block;content:'-'}.sm-dox>li:first-child>a,.sm-dox>li:first-child>:not(ul) a{-moz-border-radius:5px 5px 0 0;-webkit-border-radius:5px;border-radius:5px 5px 0 0}.sm-dox>li:last-child>a,.sm-dox>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul{-moz-border-radius:0 0 5px 5px;-webkit-border-radius:0;border-radius:0 0 5px 5px}.sm-dox>li:last-child>a.highlighted,.sm-dox>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>a.highlighted,.sm-dox>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>ul>li:last-child>*:not(ul) a.highlighted{-moz-border-radius:0;-webkit-border-radius:0;border-radius:0}.sm-dox ul{background:rgba(162,162,162,0.1)}.sm-dox ul a,.sm-dox ul a:focus,.sm-dox ul a:hover,.sm-dox ul a:active{font-size:12px;border-left:8px solid transparent;line-height:36px;text-shadow:none;background-color:white;background-image:none}.sm-dox ul a:hover{background-image:url("tab_a.png");background-repeat:repeat-x;color:white;text-shadow:0 1px 1px black}.sm-dox ul ul a,.sm-dox ul ul a:hover,.sm-dox ul ul a:focus,.sm-dox ul ul a:active{border-left:16px solid transparent}.sm-dox ul ul ul a,.sm-dox ul ul ul a:hover,.sm-dox ul ul ul a:focus,.sm-dox ul ul ul a:active{border-left:24px solid transparent}.sm-dox ul ul ul ul a,.sm-dox ul ul ul ul a:hover,.sm-dox ul ul ul ul a:focus,.sm-dox ul ul ul ul a:active{border-left:32px solid transparent}.sm-dox ul ul ul ul ul a,.sm-dox ul ul ul ul ul a:hover,.sm-dox ul ul ul ul ul a:focus,.sm-dox ul ul ul ul ul a:active{border-left:40px solid transparent}@media(min-width:768px){.sm-dox ul{position:absolute;width:12em}.sm-dox li{float:left}.sm-dox.sm-rtl li{float:right}.sm-dox ul li,.sm-dox.sm-rtl ul li,.sm-dox.sm-vertical li{float:none}.sm-dox a{white-space:nowrap}.sm-dox ul a,.sm-dox.sm-vertical a{white-space:normal}.sm-dox .sm-nowrap>li>a,.sm-dox .sm-nowrap>li>:not(ul) a{white-space:nowrap}.sm-dox{padding:0 10px;background-image:url("tab_b.png");line-height:36px}.sm-dox a span.sub-arrow{top:50%;margin-top:-2px;right:12px;width:0;height:0;border-width:4px;border-style:solid dashed dashed dashed;border-color:#283a5d transparent transparent transparent;background:transparent;-moz-border-radius:0;-webkit-border-radius:0;border-radius:0}.sm-dox a,.sm-dox a:focus,.sm-dox a:active,.sm-dox a:hover,.sm-dox a.highlighted{padding:0 12px;background-image:url("tab_s.png");background-repeat:no-repeat;background-position:right;-moz-border-radius:0!important;-webkit-border-radius:0;border-radius:0!important}.sm-dox a:hover{background-image:url("tab_a.png");background-repeat:repeat-x;color:white;text-shadow:0 1px 1px black}.sm-dox a:hover span.sub-arrow{border-color:white transparent transparent transparent}.sm-dox a.has-submenu{padding-right:24px}.sm-dox li{border-top:0}.sm-dox>li>ul:before,.sm-dox>li>ul:after{content:'';position:absolute;top:-18px;left:30px;width:0;height:0;overflow:hidden;border-width:9px;border-style:dashed dashed solid dashed;border-color:transparent transparent #bbb transparent}.sm-dox>li>ul:after{top:-16px;left:31px;border-width:8px;border-color:transparent transparent #fff transparent}.sm-dox ul{border:1px solid #bbb;padding:5px 0;background:#fff;-moz-border-radius:5px!important;-webkit-border-radius:5px;border-radius:5px!important;-moz-box-shadow:0 5px 9px rgba(0,0,0,0.2);-webkit-box-shadow:0 5px 9px rgba(0,0,0,0.2);box-shadow:0 5px 9px rgba(0,0,0,0.2)}.sm-dox ul a span.sub-arrow{right:8px;top:50%;margin-top:-5px;border-width:5px;border-color:transparent transparent transparent #555;border-style:dashed dashed dashed solid}.sm-dox ul a,.sm-dox ul a:hover,.sm-dox ul a:focus,.sm-dox ul a:active,.sm-dox ul a.highlighted{color:#555;background-image:none;border:0!important;color:#555;background-image:none}.sm-dox ul a:hover{background-image:url("tab_a.png");background-repeat:repeat-x;color:white;text-shadow:0 1px 1px black}.sm-dox ul a:hover span.sub-arrow{border-color:transparent transparent transparent white}.sm-dox span.scroll-up,.sm-dox span.scroll-down{position:absolute;display:none;visibility:hidden;overflow:hidden;background:#fff;height:36px}.sm-dox span.scroll-up:hover,.sm-dox span.scroll-down:hover{background:#eee}.sm-dox span.scroll-up:hover span.scroll-up-arrow,.sm-dox span.scroll-up:hover span.scroll-down-arrow{border-color:transparent transparent #d23600 transparent}.sm-dox span.scroll-down:hover span.scroll-down-arrow{border-color:#d23600 transparent transparent transparent}.sm-dox span.scroll-up-arrow,.sm-dox span.scroll-down-arrow{position:absolute;top:0;left:50%;margin-left:-6px;width:0;height:0;overflow:hidden;border-width:6px;border-style:dashed dashed solid dashed;border-color:transparent transparent #555 transparent}.sm-dox span.scroll-down-arrow{top:8px;border-style:solid dashed dashed dashed;border-color:#555 transparent transparent transparent}.sm-dox.sm-rtl a.has-submenu{padding-right:12px;padding-left:24px}.sm-dox.sm-rtl a span.sub-arrow{right:auto;left:12px}.sm-dox.sm-rtl.sm-vertical a.has-submenu{padding:10px 20px}.sm-dox.sm-rtl.sm-vertical a span.sub-arrow{right:auto;left:8px;border-style:dashed solid dashed dashed;border-color:transparent #555 transparent transparent}.sm-dox.sm-rtl>li>ul:before{left:auto;right:30px}.sm-dox.sm-rtl>li>ul:after{left:auto;right:31px}.sm-dox.sm-rtl ul a.has-submenu{padding:10px 20px!important}.sm-dox.sm-rtl ul a span.sub-arrow{right:auto;left:8px;border-style:dashed solid dashed dashed;border-color:transparent #555 transparent transparent}.sm-dox.sm-vertical{padding:10px 0;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px}.sm-dox.sm-vertical a{padding:10px 20px}.sm-dox.sm-vertical a:hover,.sm-dox.sm-vertical a:focus,.sm-dox.sm-vertical a:active,.sm-dox.sm-vertical a.highlighted{background:#fff}.sm-dox.sm-vertical a.disabled{background-image:url("tab_b.png")}.sm-dox.sm-vertical a span.sub-arrow{right:8px;top:50%;margin-top:-5px;border-width:5px;border-style:dashed dashed dashed solid;border-color:transparent transparent transparent #555}.sm-dox.sm-vertical>li>ul:before,.sm-dox.sm-vertical>li>ul:after{display:none}.sm-dox.sm-vertical ul a{padding:10px 20px}.sm-dox.sm-vertical ul a:hover,.sm-dox.sm-vertical ul a:focus,.sm-dox.sm-vertical ul a:active,.sm-dox.sm-vertical ul a.highlighted{background:#eee}.sm-dox.sm-vertical ul a.disabled{background:#fff}}freetds-1.00.82/doc/images/callouts/1.gif100644 025423 025423 00000001602 12522201763 0013514GIF89a ÷  !!!"""###$$$%%%&&&'''((()))***+++,,,---...///000111222333444555666777888999:::;;;<<<===>>>???@@@AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQQQRRRSSSTTTUUUVVVWWWXXXYYYZZZ[[[\\\]]]^^^___```aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz{{{|||}}}~~~€€€‚‚‚ƒƒƒ„„„………†††‡‡‡ˆˆˆ‰‰‰ŠŠŠ‹‹‹ŒŒŒŽŽŽ‘‘‘’’’“““”””•••–––———˜˜˜™™™ššš›››œœœžžžŸŸŸ   ¡¡¡¢¢¢£££¤¤¤¥¥¥¦¦¦§§§¨¨¨©©©ªªª«««¬¬¬­­­®®®¯¯¯°°°±±±²²²³³³´´´µµµ¶¶¶···¸¸¸¹¹¹ººº»»»¼¼¼½½½¾¾¾¿¿¿ÀÀÀÁÁÁÂÂÂÃÃÃÄÄÄÅÅÅÆÆÆÇÇÇÈÈÈÉÉÉÊÊÊËËËÌÌÌÍÍÍÎÎÎÏÏÏÐÐÐÑÑÑÒÒÒÓÓÓÔÔÔÕÕÕÖÖÖ×××ØØØÙÙÙÚÚÚÛÛÛÜÜÜÝÝÝÞÞÞßßßàààáááâââãããäääåååæææçççèèèéééêêêëëëìììíííîîîïïïðððñññòòòóóóôôôõõõööö÷÷÷øøøùùùúúúûûûüüüýýýþþþÿÿÿ!ù, _ÿý»G)98Ýøï\ ¤€ãÜÀ‡9ƒ Æ=F•œ»·‘##ŒK•¤ˆ€#N+#¶äÓ%”/cÆI3&£{(Õâè±áD—- ü‚”þ ;freetds-1.00.82/doc/images/callouts/10.gif100644 025423 025423 00000001646 12522201763 0013604GIF89a ÷  !!!"""###$$$%%%&&&'''((()))***+++,,,---...///000111222333444555666777888999:::;;;<<<===>>>???@@@AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQQQRRRSSSTTTUUUVVVWWWXXXYYYZZZ[[[\\\]]]^^^___```aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz{{{|||}}}~~~€€€‚‚‚ƒƒƒ„„„………†††‡‡‡ˆˆˆ‰‰‰ŠŠŠ‹‹‹ŒŒŒŽŽŽ‘‘‘’’’“““”””•••–––———˜˜˜™™™ššš›››œœœžžžŸŸŸ   ¡¡¡¢¢¢£££¤¤¤¥¥¥¦¦¦§§§¨¨¨©©©ªªª«««¬¬¬­­­®®®¯¯¯°°°±±±²²²³³³´´´µµµ¶¶¶···¸¸¸¹¹¹ººº»»»¼¼¼½½½¾¾¾¿¿¿ÀÀÀÁÁÁÂÂÂÃÃÃÄÄÄÅÅÅÆÆÆÇÇÇÈÈÈÉÉÉÊÊÊËËËÌÌÌÍÍÍÎÎÎÏÏÏÐÐÐÑÑÑÒÒÒÓÓÓÔÔÔÕÕÕÖÖÖ×××ØØØÙÙÙÚÚÚÛÛÛÜÜÜÝÝÝÞÞÞßßßàààáááâââãããäääåååæææçççèèèéééêêêëëëìììíííîîîïïïðððñññòòòóóóôôôõõõööö÷÷÷øøøùùùúúúûûûüüüýýýþþþÿÿÿ!ù, ƒÿ 䔄Œî ü÷. ¤€ÛÀjÕJá­×9))î• ñîŸÆZæxÀHIDgµ¬Íã_ˆÀ¼7†sÂ|×3P.uÖrF@Žb” ”‘5”œ±<Ú‹„^÷¬ÅÉ0Uªp\øF‰”þ ;freetds-1.00.82/doc/images/callouts/2.gif100644 025423 025423 00000001623 12522201763 0013520GIF89a ÷  !!!"""###$$$%%%&&&'''((()))***+++,,,---...///000111222333444555666777888999:::;;;<<<===>>>???@@@AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQQQRRRSSSTTTUUUVVVWWWXXXYYYZZZ[[[\\\]]]^^^___```aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz{{{|||}}}~~~€€€‚‚‚ƒƒƒ„„„………†††‡‡‡ˆˆˆ‰‰‰ŠŠŠ‹‹‹ŒŒŒŽŽŽ‘‘‘’’’“““”””•••–––———˜˜˜™™™ššš›››œœœžžžŸŸŸ   ¡¡¡¢¢¢£££¤¤¤¥¥¥¦¦¦§§§¨¨¨©©©ªªª«««¬¬¬­­­®®®¯¯¯°°°±±±²²²³³³´´´µµµ¶¶¶···¸¸¸¹¹¹ººº»»»¼¼¼½½½¾¾¾¿¿¿ÀÀÀÁÁÁÂÂÂÃÃÃÄÄÄÅÅÅÆÆÆÇÇÇÈÈÈÉÉÉÊÊÊËËËÌÌÌÍÍÍÎÎÎÏÏÏÐÐÐÑÑÑÒÒÒÓÓÓÔÔÔÕÕÕÖÖÖ×××ØØØÙÙÙÚÚÚÛÛÛÜÜÜÝÝÝÞÞÞßßßàààáááâââãããäääåååæææçççèèèéééêêêëëëìììíííîîîïïïðððñññòòòóóóôôôõõõööö÷÷÷øøøùùùúúúûûûüüüýýýþþþÿÿÿ!ù, pÿý»G)98Ýøï\ R„€ãÜÀ‡!¬{g €÷A,e @ˆ=ÀhDoµ("€HäˆfÒTr®–N+YÞsYS$€5÷ÆÄˆ!彇œÎI=çdà5- #gJ ÿ;freetds-1.00.82/doc/images/callouts/3.gif100644 025423 025423 00000001632 12522201763 0013521GIF89a ÷  !!!"""###$$$%%%&&&'''((()))***+++,,,---...///000111222333444555666777888999:::;;;<<<===>>>???@@@AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQQQRRRSSSTTTUUUVVVWWWXXXYYYZZZ[[[\\\]]]^^^___```aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz{{{|||}}}~~~€€€‚‚‚ƒƒƒ„„„………†††‡‡‡ˆˆˆ‰‰‰ŠŠŠ‹‹‹ŒŒŒŽŽŽ‘‘‘’’’“““”””•••–––———˜˜˜™™™ššš›››œœœžžžŸŸŸ   ¡¡¡¢¢¢£££¤¤¤¥¥¥¦¦¦§§§¨¨¨©©©ªªª«««¬¬¬­­­®®®¯¯¯°°°±±±²²²³³³´´´µµµ¶¶¶···¸¸¸¹¹¹ººº»»»¼¼¼½½½¾¾¾¿¿¿ÀÀÀÁÁÁÂÂÂÃÃÃÄÄÄÅÅÅÆÆÆÇÇÇÈÈÈÉÉÉÊÊÊËËËÌÌÌÍÍÍÎÎÎÏÏÏÐÐÐÑÑÑÒÒÒÓÓÓÔÔÔÕÕÕÖÖÖ×××ØØØÙÙÙÚÚÚÛÛÛÜÜÜÝÝÝÞÞÞßßßàààáááâââãããäääåååæææçççèèèéééêêêëëëìììíííîîîïïïðððñññòòòóóóôôôõõõööö÷÷÷øøøùùùúúúûûûüüüýýýþþþÿÿÿ!ù, wÿý»G)98Ýøï\ rä@ ƹ!x³æÍ„Š÷0çÿÖŒdô„.SŽŒAq$€Vç¬ÕDPsdŽ1÷TBl©E$gµfeô.FŽw„VÞËØêÞ½Vc,<¢M‹ CÒ„ƒÒÂ;freetds-1.00.82/doc/images/callouts/4.gif100644 025423 025423 00000001623 12522201763 0013522GIF89a ÷  !!!"""###$$$%%%&&&'''((()))***+++,,,---...///000111222333444555666777888999:::;;;<<<===>>>???@@@AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQQQRRRSSSTTTUUUVVVWWWXXXYYYZZZ[[[\\\]]]^^^___```aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz{{{|||}}}~~~€€€‚‚‚ƒƒƒ„„„………†††‡‡‡ˆˆˆ‰‰‰ŠŠŠ‹‹‹ŒŒŒŽŽŽ‘‘‘’’’“““”””•••–––———˜˜˜™™™ššš›››œœœžžžŸŸŸ   ¡¡¡¢¢¢£££¤¤¤¥¥¥¦¦¦§§§¨¨¨©©©ªªª«««¬¬¬­­­®®®¯¯¯°°°±±±²²²³³³´´´µµµ¶¶¶···¸¸¸¹¹¹ººº»»»¼¼¼½½½¾¾¾¿¿¿ÀÀÀÁÁÁÂÂÂÃÃÃÄÄÄÅÅÅÆÆÆÇÇÇÈÈÈÉÉÉÊÊÊËËËÌÌÌÍÍÍÎÎÎÏÏÏÐÐÐÑÑÑÒÒÒÓÓÓÔÔÔÕÕÕÖÖÖ×××ØØØÙÙÙÚÚÚÛÛÛÜÜÜÝÝÝÞÞÞßßßàààáááâââãããäääåååæææçççèèèéééêêêëëëìììíííîîîïïïðððñññòòòóóóôôôõõõööö÷÷÷øøøùùùúúúûûûüüüýýýþþþÿÿÿ!ù, pÿ l%%E %¥ ¼§€Ãä8'°¡C%ÿæ8Ìq¯•C(jtHÉ"€V¥ÞƒC-ç Ü[‰Àe•)î1r AÃ1 –rcèG3?2º—㨷5ïý{×ô(€ÞÞã‚K;freetds-1.00.82/doc/images/callouts/5.gif100644 025423 025423 00000001627 12522201763 0013527GIF89a ÷  !!!"""###$$$%%%&&&'''((()))***+++,,,---...///000111222333444555666777888999:::;;;<<<===>>>???@@@AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQQQRRRSSSTTTUUUVVVWWWXXXYYYZZZ[[[\\\]]]^^^___```aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz{{{|||}}}~~~€€€‚‚‚ƒƒƒ„„„………†††‡‡‡ˆˆˆ‰‰‰ŠŠŠ‹‹‹ŒŒŒŽŽŽ‘‘‘’’’“““”””•••–––———˜˜˜™™™ššš›››œœœžžžŸŸŸ   ¡¡¡¢¢¢£££¤¤¤¥¥¥¦¦¦§§§¨¨¨©©©ªªª«««¬¬¬­­­®®®¯¯¯°°°±±±²²²³³³´´´µµµ¶¶¶···¸¸¸¹¹¹ººº»»»¼¼¼½½½¾¾¾¿¿¿ÀÀÀÁÁÁÂÂÂÃÃÃÄÄÄÅÅÅÆÆÆÇÇÇÈÈÈÉÉÉÊÊÊËËËÌÌÌÍÍÍÎÎÎÏÏÏÐÐÐÑÑÑÒÒÒÓÓÓÔÔÔÕÕÕÖÖÖ×××ØØØÙÙÙÚÚÚÛÛÛÜÜÜÝÝÝÞÞÞßßßàààáááâââãããäääåååæææçççèèèéééêêêëëëìììíííîîîïïïðððñññòòòóóóôôôõõõööö÷÷÷øøøùùùúúúûûûüüüýýýþþþÿÿÿ!ù, tÿ 䔄Œî ü÷.‚)B¤@ÛÀr0|÷N €÷JÈøÁÈ“Œ<’låŒI10ŒÔHHÉ9N#È‚ÐHFïrª„ e$¥s#cˆ„ùOIo”~þÀл>*l˜óe ‹ )9¤˜P`@;freetds-1.00.82/doc/images/callouts/6.gif100644 025423 025423 00000001635 12522201763 0013527GIF89a ÷  !!!"""###$$$%%%&&&'''((()))***+++,,,---...///000111222333444555666777888999:::;;;<<<===>>>???@@@AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQQQRRRSSSTTTUUUVVVWWWXXXYYYZZZ[[[\\\]]]^^^___```aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz{{{|||}}}~~~€€€‚‚‚ƒƒƒ„„„………†††‡‡‡ˆˆˆ‰‰‰ŠŠŠ‹‹‹ŒŒŒŽŽŽ‘‘‘’’’“““”””•••–––———˜˜˜™™™ššš›››œœœžžžŸŸŸ   ¡¡¡¢¢¢£££¤¤¤¥¥¥¦¦¦§§§¨¨¨©©©ªªª«««¬¬¬­­­®®®¯¯¯°°°±±±²²²³³³´´´µµµ¶¶¶···¸¸¸¹¹¹ººº»»»¼¼¼½½½¾¾¾¿¿¿ÀÀÀÁÁÁÂÂÂÃÃÃÄÄÄÅÅÅÆÆÆÇÇÇÈÈÈÉÉÉÊÊÊËËËÌÌÌÍÍÍÎÎÎÏÏÏÐÐÐÑÑÑÒÒÒÓÓÓÔÔÔÕÕÕÖÖÖ×××ØØØÙÙÙÚÚÚÛÛÛÜÜÜÝÝÝÞÞÞßßßàààáááâââãããäääåååæææçççèèèéééêêêëëëìììíííîîîïïïðððñññòòòóóóôôôõõõööö÷÷÷øøøùùùúúúûûûüüüýýýþþþÿÿÿ!ù, zÿ l%%E %¥ ¼§ )æ8'°!€RïÎC ǽVç¼Ã€á]‡”,+•"G‡108<÷ΙMÈàÍïæä´Ø«”Cg„`°æ]ˆ 2ºw¥{÷’HqïŸÉœ/SxSx“K1¦ ;freetds-1.00.82/doc/images/callouts/7.gif100644 025423 025423 00000001616 12522201763 0013527GIF89a ÷  !!!"""###$$$%%%&&&'''((()))***+++,,,---...///000111222333444555666777888999:::;;;<<<===>>>???@@@AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQQQRRRSSSTTTUUUVVVWWWXXXYYYZZZ[[[\\\]]]^^^___```aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz{{{|||}}}~~~€€€‚‚‚ƒƒƒ„„„………†††‡‡‡ˆˆˆ‰‰‰ŠŠŠ‹‹‹ŒŒŒŽŽŽ‘‘‘’’’“““”””•••–––———˜˜˜™™™ššš›››œœœžžžŸŸŸ   ¡¡¡¢¢¢£££¤¤¤¥¥¥¦¦¦§§§¨¨¨©©©ªªª«««¬¬¬­­­®®®¯¯¯°°°±±±²²²³³³´´´µµµ¶¶¶···¸¸¸¹¹¹ººº»»»¼¼¼½½½¾¾¾¿¿¿ÀÀÀÁÁÁÂÂÂÃÃÃÄÄÄÅÅÅÆÆÆÇÇÇÈÈÈÉÉÉÊÊÊËËËÌÌÌÍÍÍÎÎÎÏÏÏÐÐÐÑÑÑÒÒÒÓÓÓÔÔÔÕÕÕÖÖÖ×××ØØØÙÙÙÚÚÚÛÛÛÜÜÜÝÝÝÞÞÞßßßàààáááâââãããäääåååæææçççèèèéééêêêëëëìììíííîîîïïïðððñññòòòóóóôôôõõõööö÷÷÷øøøùùùúúúûûûüüüýýýþþþÿÿÿ!ù, kÿ ¬%%E %­î üwO  !@ÈqN ­þ³ ƽ^B†Äpî"J&EÖ2G ‘¤Ü{ÍÖjÁD2Ç?)0cè É蘌þ) YkhÈ ß ù´âBN9 HQT`@;freetds-1.00.82/doc/images/callouts/8.gif100644 025423 025423 00000001633 12522201763 0013527GIF89a ÷  !!!"""###$$$%%%&&&'''((()))***+++,,,---...///000111222333444555666777888999:::;;;<<<===>>>???@@@AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQQQRRRSSSTTTUUUVVVWWWXXXYYYZZZ[[[\\\]]]^^^___```aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz{{{|||}}}~~~€€€‚‚‚ƒƒƒ„„„………†††‡‡‡ˆˆˆ‰‰‰ŠŠŠ‹‹‹ŒŒŒŽŽŽ‘‘‘’’’“““”””•••–––———˜˜˜™™™ššš›››œœœžžžŸŸŸ   ¡¡¡¢¢¢£££¤¤¤¥¥¥¦¦¦§§§¨¨¨©©©ªªª«««¬¬¬­­­®®®¯¯¯°°°±±±²²²³³³´´´µµµ¶¶¶···¸¸¸¹¹¹ººº»»»¼¼¼½½½¾¾¾¿¿¿ÀÀÀÁÁÁÂÂÂÃÃÃÄÄÄÅÅÅÆÆÆÇÇÇÈÈÈÉÉÉÊÊÊËËËÌÌÌÍÍÍÎÎÎÏÏÏÐÐÐÑÑÑÒÒÒÓÓÓÔÔÔÕÕÕÖÖÖ×××ØØØÙÙÙÚÚÚÛÛÛÜÜÜÝÝÝÞÞÞßßßàààáááâââãããäääåååæææçççèèèéééêêêëëëìììíííîîîïïïðððñññòòòóóóôôôõõõööö÷÷÷øøøùùùúúúûûûüüüýýýþþþÿÿÿ!ù, xÿ l%%E)¥ |§!æ8'PˆÃRÞ¬õ‚ ƽR•ÜãxnŽCJ ‰à݇108Pë\FÈ åž%.s¦,ÕËa«¢A˜óÎà9B'ÿYD@éÜ;J8=þc8sfŽw ÿ•R"„„;freetds-1.00.82/doc/images/callouts/9.gif100644 025423 025423 00000001637 12522201763 0013534GIF89a ÷  !!!"""###$$$%%%&&&'''((()))***+++,,,---...///000111222333444555666777888999:::;;;<<<===>>>???@@@AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQQQRRRSSSTTTUUUVVVWWWXXXYYYZZZ[[[\\\]]]^^^___```aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz{{{|||}}}~~~€€€‚‚‚ƒƒƒ„„„………†††‡‡‡ˆˆˆ‰‰‰ŠŠŠ‹‹‹ŒŒŒŽŽŽ‘‘‘’’’“““”””•••–––———˜˜˜™™™ššš›››œœœžžžŸŸŸ   ¡¡¡¢¢¢£££¤¤¤¥¥¥¦¦¦§§§¨¨¨©©©ªªª«««¬¬¬­­­®®®¯¯¯°°°±±±²²²³³³´´´µµµ¶¶¶···¸¸¸¹¹¹ººº»»»¼¼¼½½½¾¾¾¿¿¿ÀÀÀÁÁÁÂÂÂÃÃÃÄÄÄÅÅÅÆÆÆÇÇÇÈÈÈÉÉÉÊÊÊËËËÌÌÌÍÍÍÎÎÎÏÏÏÐÐÐÑÑÑÒÒÒÓÓÓÔÔÔÕÕÕÖÖÖ×××ØØØÙÙÙÚÚÚÛÛÛÜÜÜÝÝÝÞÞÞßßßàààáááâââãããäääåååæææçççèèèéééêêêëëëìììíííîîîïïïðððñññòòòóóóôôôõõõööö÷÷÷øøøùùùúúúûûûüüüýýýþþþÿÿÿ!ù, |ÿ l%%E)­î üwO <ÌñN ZY;Wjâ½VçxC€áž–‡”.(€µŽr`x¸gdÉ^I>„Ðëݹsµr:̉5JcÀr/„’92º@«ïÖpиña (e|ˆ¸QGE(YÀéaäD`ÊèP 8j’,XÑEJt@ÃP?MºeH›œL)ƒ‚€%¸ªd)ð¥Ø üäJC¨Ž¨geŒp`-[ tÄààÆYÌ«b 16|ø‹ÀÁÙÜûÁoÊ "ؕтd‚‰=àHÉ)UDF¸W4Ê  „•áÂÂ热-—X«ÂöÆÄ‹¹B¾Ý²åÎÄ'†Æ¡:ùo ·Ä ÂùÀ€;freetds-1.00.82/doc/images/important.gif100644 025423 025423 00000002071 12522201763 0013544GIF87a÷)))999BB1BBBJJJRRRZZ)ccccRccckkBkkkssR{{{„„„ŒŒŒŒ9ŒŒ{ŒŒŒ””Z””Œ”””œœZœœcœœ{œœœ¥¥c¥¥„¥¥”¥¥œ¥¥¥­­!­­9­­k­­{­­„­­Œ­­¥­­­µµJµµRµµŒµµµ½½½½Z½½„½½œ½½½ÆÆÆÆZÆÆÆÎÎsÎÎÎÖÖÖÖRÖÖcÖÖkÖÖÖÞÞÞÞ!ÞÞ1ÞÞ9ÞÞRÞÞÞçççç!çç)çç1ççZççcçç{çççïïïïïï1ïïBïïï÷÷÷÷÷÷1÷÷9÷÷J÷÷÷ÿÿÿÿÿÿÿÿ!ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ,þ·Hp‰Aƒ*ܲĆˆ ""BÄae!A+3,|Ò¤cG,à°È0ƒ‡$WRªT©CƒˆŠ ­dˆÑd¥Í”ML¸ˆ9Ó& |Üܰs Ž5WR@AR•M< ¸$J› ˜rSG 8Pܼ"i'c9,Ù""ÈØLd‹ÇOW¾`ÂØ+D2ÜÍ«2$þ<öG+ Æ;ÖÈ;$3¾ùÄÂ%ŠElqÁõæ 9æÞ¬»¥Ç‡±Ìá b­•:nB`jà‡M,0жö@؇/nò… 7µ ½)R¡ˆ „ó0r¡ 5žŒ}Â"ƒ ’­ET@A¤=‘*¨X‹žª ø'ÒO;freetds-1.00.82/doc/images/note.gif100644 025423 025423 00000002056 12522201763 0012477GIF87a÷  !!!"""###$$$%%%&&&'''((()))***+++,,,---...///000111222333444555666777888999:::;;;<<<===>>>???@@@AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQQQRRRSSSTTTUUUVVVWWWXXXYYYZZZ[[[\\\]]]^^^___```aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz{{{|||}}}~~~€€€‚‚‚ƒƒƒ„„„………†††‡‡‡ˆˆˆ‰‰‰ŠŠŠ‹‹‹ŒŒŒŽŽŽ‘‘‘’’’“““”””•••–––———˜˜˜™™™ššš›››œœœžžžŸŸŸ   ¡¡¡¢¢¢£££¤¤¤¥¥¥¦¦¦§§§¨¨¨©©©ªªª«««¬¬¬­­­®®®¯¯¯°°°±±±²²²³³³´´´µµµ¶¶¶···¸¸¸¹¹¹ººº»»»¼¼¼½½½¾¾¾¿¿¿ÀÀÀÁÁÁÂÂÂÃÃÃÄÄÄÅÅÅÆÆÆÇÇÇÈÈÈÉÉÉÊÊÊËËËÌÌÌÍÍÍÎÎÎÏÏÏÐÐÐÑÑÑÒÒÒÓÓÓÔÔÔÕÕÕÖÖÖ×××ØØØÙÙÙÚÚÚÛÛÛÜÜÜÝÝÝÞÞÞßßßàààáááâââãããäääåååæææçççèèèéééêêêëëëìììíííîîîïïïðððñññòòòóóóôôôõõõööö÷÷÷øøøùùùúúúûûûüüüýýýþþþÿÿÿ,þÿ HðœAƒ*Ø«¥R:[˜ð1F¥¬{Çñœ1J”&R<÷ÐÅÎ(ÕZø®ÔÊ“[öªHi&L‚5 :+u³b)“öL¸S`Q‚ÆzÕRÚËÛA„ÿJ‹êí5k¥ÕræÍš3F„ F¤tnë9© · <—Ò˜³9M½u élF²ßQ£E‰”=5k-5öޤ·»Sîáz˜Ò¿wÖ=ëQb½sTö¸$eJ{Jq\³Ç«±=@žýWËšÀZ!×lž3ƦÂR±Æ<-%3!c[BŽ*òŸÓã'{ÙÆšxèÎá¯yýǨøÀ^” Süj l¿ÃÄŠQî9o;µ6‡‰$HÜÚ;freetds-1.00.82/doc/images/tip.gif100644 025423 025423 00000002005 12522201763 0012320GIF87a÷  !!!"""###$$$%%%&&&'''((()))***+++,,,---...///000111222333444555666777888999:::;;;<<<===>>>???@@@AAABBBCCCDDDEEEFFFGGGHHHIIIJJJKKKLLLMMMNNNOOOPPPQQQRRRSSSTTTUUUVVVWWWXXXYYYZZZ[[[\\\]]]^^^___```aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrssstttuuuvvvwwwxxxyyyzzz{{{|||}}}~~~€€€‚‚‚ƒƒƒ„„„………†††‡‡‡ˆˆˆ‰‰‰ŠŠŠ‹‹‹ŒŒŒŽŽŽ‘‘‘’’’“““”””•••–––———˜˜˜™™™ššš›››œœœžžžŸŸŸ   ¡¡¡¢¢¢£££¤¤¤¥¥¥¦¦¦§§§¨¨¨©©©ªªª«««¬¬¬­­­®®®¯¯¯°°°±±±²²²³³³´´´µµµ¶¶¶···¸¸¸¹¹¹ººº»»»¼¼¼½½½¾¾¾¿¿¿ÀÀÀÁÁÁÂÂÂÃÃÃÄÄÄÅÅÅÆÆÆÇÇÇÈÈÈÉÉÉÊÊÊËËËÌÌÌÍÍÍÎÎÎÏÏÏÐÐÐÑÑÑÒÒÒÓÓÓÔÔÔÕÕÕÖÖÖ×××ØØØÙÙÙÚÚÚÛÛÛÜÜÜÝÝÝÞÞÞßßßàààáááâââãããäääåååæææçççèèèéééêêêëëëìììíííîîîïïïðððñññòòòóóóôôôõõõööö÷÷÷øøøùùùúúúûûûüüüýýýþþþÿÿÿ,êÿ HðœAƒ*xÎX)J¥"BtvoaÂ{½&ž»·±!%JÎ,2„èM¤3ˆïQêUQä¿s¥j)TÙK!Ìs W&tVªåÀ{{B¬ÁY°TI†¥ˆ¼7‚¥yF•¹Ð›Ñ…*‰^UÈhϪ k…„é“`Ö”xŽÒËž )åH»vä[¨?ÇÐ]ØömÝ÷ôªåëö&VÁ½¹ý'öð^…¥Bþ³êxpBÀ#ÏD¬°WÍVñ2 ±g-O¼z3&™ £ÖkQ«ÐÙk‘ý='Û˜ËÉ”=x"m‹çŠŒ|ü_@;freetds-1.00.82/doc/images/warning.gif100644 025423 025423 00000002034 12522201763 0013173GIF87a÷!)1BJRZks{„Œ””{{œRRœZZœ{{¥¥99¥JJ¥„„¥””¥¥¥­­11­””µµ))µŒŒµœœµ¥¥µµµ½½­­½µµÆÆÆÆÆÆÎÎÎÎ))ÖÖ))ÖÖÖÞÞÞÞçç!!çççïïïïï÷÷÷÷ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ,þyÈCŒƒâ Èp`Š6Dœ¸a‡… аp#‡ÇQ\̈#E…Ž Sæ@q#ÁPªL‰"ƒK"NªìðÀ…J–SpT9‚@€2C^”!éÇðù3Œ 3shÀ@Œ™7 ÀðÕÄœz {5kŒdeKvæŒÌ‹5+‚öŽÍšC ‚ûÎÑ€ªJºYg0@€,ŠSjˆêuf 8@ ˜Ùa@€3T¾˜ ƒGèÑ;¨P}¡µ@NNIã2C"tïÎñÂ͸ag}Q;ãmÑ7fDŸ>£…oçu˜À½;w ¶ ;freetds-1.00.82/doc/grep_sample_code100755 025423 025423 00000000767 12522201763 0013023#! /usr/bin/perl -w # A simple, not very flexible bit of Perl to extract the sample code # from the User Guide. while(<>) { last if /chapter id="programming"/; } while(<>) { if (///; s/.+$//; s//g; print; } __DATA__ $Id: grep_sample_code,v 1.1 2007-12-10 05:13:11 jklowden Exp $ freetds-1.00.82/doc/tds_ssl.html100644 025423 025423 00000023002 12522201763 0012131 SSL and TDS

    How to enable encryption on MSSQL

    Under Linux (or any system that have openssl)

    # create a file containing key and self-signed certificate
    openssl req \
      -x509 -nodes -days 365 \
      -newkey rsa:1024 -keyout mycert.pem -out mycert.pem
    
    # export mycert.pem as PKCS#12 file, mycert.pfx
    openssl pkcs12 -export \
      -out mycert.pfx -in mycert.pem \
      -name "My Certificate"
    

    So we created a mycert.pfx certificate ready to be imported

    Under Windows

    Open MMC and add certificates snap-in, add our certificate under personal and under ca root (to validate it)

    Add to the registry the thumbprint of our certificato so to be used by mssql. For examples

    REGEDIT4
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\SuperSocketNetLib]
    "Certificate"=hex:DD,5F,6C,EE,47,8E,0C,C0,74,8B,C4,71,8D,87,1C,E6,07,20,F2,28
    

    Restart MSSQL

    Check event viewer for results

    Encryption protocol

    Prelogin packet (tds 7.1 only)

    >From client to server

    00000000  12 01 00 34 00 00 00 00  00 00 15 00 06 01 00 1b ...4.... ........
    00000010  00 01 02 00 1c 00 0c 03  00 28 00 04 ff 08 00 01 ........ .(......
    00000020  55 00 00 01 4d 53 53 51  4c 53 65 72 76 65 72 00 U...MSSQ LServer.
    00000030  38 09 00 00                                      8...
    
    HeaderDescriptionValue
    00 00 15 00 06 netlib version (0) start from 0x15 length 0x06 8.341.0
    01 00 1b 00 01 encrypt flag (1) start from 0x1b length 0x01 1, see below
    02 00 1c 00 0c instance name (2) start from 0x1c length 0x0c "MSSQLServer\0" (as you note string is null terminated)
    03 00 28 00 04 process id (3) start from 0x28 length 0x04 0x938 (why in little endian ??)
    ff end  

    Meaning of encryption flag (client):

    • 0x00 normal
    • 0x01 high encryption (128 bit ??)

    MSSQL 2005 have 9.0.0 as a version and have a single byte option 4 (always seen as zero, I don't know the meaning).

    >From server to client

    00000000  04 01 00 25 00 00 01 00  00 00 15 00 06 01 00 1b ...%.... ........
    00000010  00 01 02 00 1c 00 01 03  00 1d 00 00 ff 08 00 02 ........ ........
    00000020  f8 00 00 01 00     
    

    Similar
    HeaderDescriptionValue
    00 00 15 00 06 version (0) start from 0x15 length 0x06 8.0.760.0
    01 00 1b 00 01 encrypt flag (1) start from 0x1b length 0x01 1, see below
    02 00 1c 00 01 instance name (2) start from 0x1c length 0x01 "\0" (still null terminatted)
    03 00 1d 00 00 process id (3) start from 0x1d length 0x0 no info
    ff end  

    Meaning of encryption flag (server):

    • 0x02, no certificate, no encryption required just do normal jobs (like FreeTDS)
    • 0x00, certificate, no force flag on server, prelogin to see certificate (TLS 1.0, not SSL 2 or 3 !!) login encrypted, after login do normal TDS (not encrypted)
    • 0x01, certificate, high encryption required by client prelogin to see certificate login encrypted, after login changed crypt (my client close connection perhaps a configuration problem...)
    • 0x03, certificate enabled, force encryption configured on server prelogin like 0x00, remains in SSL after login

    Note that mssql2k unpatched do not set last packet flag (byte 2) for this packet.

    Following a valid encrypted connection (0x00 from server, no force)

    >From client to server

    00000034  12 01 00 46 00 00 00 00  16 03 01 00 39 01 00 00 ...F.... ....9...
    00000044  35 03 01 41 b9 5e 02 f8  7d 45 81 31 d9 73 9e 93 5..A.^.. }E.1.s..
    00000054  91 b2 dd f4 4a 80 a3 92  a8 0f aa 67 32 8a 72 6d ....J... ...g2.rm
    00000064  4b 22 07 00 00 0e 00 09  00 64 00 62 00 03 00 06 K"...... .d.b....
    00000074  00 12 00 63 01 00                                ...c..
    

    prelogin packet (0x12), content TLS 1.0 (you can see a ClientHell0, see RFC 2246)

    >From server to client

    00000025  04 01 03 da 00 00 01 00  16 03 01 03 cd 02 00 00 ........ ........
    00000035  46 03 01 41 b9 5e 03 4b  c1 bf 9b a5 7d 83 74 57 F..A.^.K ....}.tW
    00000045  00 03 de b5 fb fc 4d f8  84 15 ce 07 d9 ab fe 2b ......M. .......+
    00000055  57 3c ad 20 96 10 00 00  6f 31 af e4 17 ae 2a 2b W<. .... o1....*+
    00000065  37 29 0e 57 8a 4d 1d 32  aa d9 ed 62 6b 3d 3c d1 7).W.M.2 ...bk=<.
    00000075  d1 c6 a9 cb 00 09 00 0b  00 03 7b 00 03 78 00 03 ........ ..{..x..
    00000085  75 30 82 03 71 30 82 02  da a0 03 02 01 02 02 01 u0..q0.. ........
    00000095  00 30 0d 06 09 2a 86 48  86 f7 0d 01 01 04 05 00 .0...*.H ........
    000000A5  30 81 88 31 0b 30 09 06  03 55 04 06 13 02 49 54 0..1.0.. .U....IT
    000000B5  31 10 30 0e 06 03 55 04  08 13 07 42 6f 6c 6f 67 1.0...U. ...Bolog
    000000C5  6e 61 31 10 30 0e 06 03  55 04 07 13 07 42 6f 6c na1.0... U....Bol
    ... omissis...
    

    normal reply packet (0x4), ServerHello(2), content TLS (certificate).

    NOTE: if server send certificate request client (MS ODBC) crash so I think this is not supported.

    >From client to server

    0000007A  12 01 00 c6 00 00 00 00  16 03 01 00 86 10 00 00 ........ ........
    0000008A  82 00 80 3a c6 96 ba 55  ce 8e 4b a4 e2 d7 b7 bd ...:...U ..K.....
    0000009A  5d 5e f4 28 30 c6 c7 b9  4e 66 60 80 45 ce cb 4e ]^.(0... Nf`.E..N
    000000AA  f6 f7 91 d7 9b 05 79 f8  ad f7 c7 13 77 36 cb 8c ......y. ....w6..
    000000BA  04 58 33 3f 51 c8 0a bb  6a 95 8f 65 a1 e9 74 c5 .X3?Q... j..e..t.
    000000CA  c9 c6 4a 11 b1 36 87 84  f2 96 82 d0 19 8a dd dc ..J..6.. ........
    000000DA  d1 32 6a 32 ab 73 47 76  58 69 16 fd 9f 0b bd d7 .2j2.sGv Xi......
    000000EA  72 79 a7 86 9a 71 2b 70  9a d1 8f e2 54 63 46 81 ry...q+p ....TcF.
    000000FA  3e 6d 8a f7 8d 2e 26 02  3f 2d 0c a1 bc 63 ac 0a >m....&. ?-...c..
    0000010A  8a 38 0e 14 03 01 00 01  01 16 03 01 00 28 12 09 .8...... .....(..
    0000011A  d5 2d 93 8c 60 aa ae ec  e3 9b 2b 3c 27 63 46 ad .-..`... ..+<'cF.
    0000012A  b1 b9 3d 1e 06 60 18 49  6d bb 76 80 8b 7b 51 70 ..=..`.I m.v..{Qp
    0000013A  b7 79 14 b8 ba 62                                .y...b
    

    prelogin (0x12), still TLS handshake, client_key_exchange (??) (0x16, 0x10), change crypt (0x14), handshake (crypted)

    >From server to client

    000003FF  04 01 00 3b 00 00 01 00  14 03 01 00 01 01 16 03 ...;.... ........
    0000040F  01 00 28 96 3c 2e 41 42  09 d3 a8 77 82 19 7f 4b ..(.<.AB ...w...K
    0000041F  ac 04 b8 96 4b f1 65 c2  35 9e ef 6a 1d c2 41 2d ....K.e. 5..j..A-
    0000042F  a3 98 b8 2b 5c 0f 40 d1  98 b0 1e                ...+\.@. ...
    

    normal reply (0x4), still TLS

    0x14 means change crypt, followed by 0x16 (handshake crypted).

    >From client to server

    00000140  17 03 01 01 08 d7 3a b5  c3 fd a7 4d 14 b7 ce c7 ......:. ...M....
    00000150  c6 6f f3 c5 03 1c 5c 86  7b 15 98 45 2a 93 73 c7 .o....\. {..E*.s.
    00000160  72 75 72 23 c2 11 20 7d  5c b1 be e7 ac 72 ac b3 rur#.. } \....r..
    00000170  47 41 4f 45 d8 fa 22 2b  94 b1 67 a5 7f de af 96 GAOE.."+ ..g.....
    00000180  05 ad bb fc e4 33 66 3a  a2 f1 8d c5 5f 84 8b 38 .....3f: ...._..8
    00000190  86 b0 df e8 87 e7 2c 26  e6 c0 66 2e b1 53 86 40 ......,& ..f..S.@
    000001A0  98 0d 9e 2f 49 0b 17 b2  9d 55 d3 e3 7e 08 ca b9 .../I... .U..~...
    000001B0  de 62 87 23 14 98 6e 10  d0 dd c2 94 70 4c 33 4b .b.#..n. ....pL3K
    000001C0  09 8d b8 46 e5 a2 31 52  4d 89 06 b2 10 a8 ed b0 ...F..1R M.......
    000001D0  a8 21 02 79 ab 99 de 67  28 a3 6c ea 18 88 b5 63 .!.y...g (.l....c
    000001E0  02 ab f4 a1 78 0d 83 ec  b6 7b 61 7d 42 d2 38 bb ....x... .{a}B.8.
    000001F0  50 fc e1 9e 1e e0 51 69  93 ea 05 9f d5 a4 a8 2b P.....Qi .......+
    00000200  18 7f 79 4f 29 1a c0 35  3c 55 83 b0 9f af b7 de ..yO)..5 <U......
    00000210  6d 2d 12 fa 27 ef 28 6b  a9 83 12 e6 a1 09 58 00 m-..'.(k ......X.
    00000220  30 b3 3d f0 60 00 97 84  ee 28 b0 ae 31 78 50 d7 0.=.`... .(..1xP.
    00000230  85 82 19 9f 57 ca a6 1c  d2 81 0f 6b 2d fb 47 41 ....W... ...k-.GA
    00000240  37 58 8a ba 4f 38 f6 00  23 24 56 c2 35          7X..O8.. #$V.5
    

    Well... you can note that this it's not a TDS packet !!! This is a fully crypted packet (login packet).

    >From server to client

    0000043A  04 01 01 79 00 33 01 00  e3 1b 00 01 06 6d 00 61 ...y.3.. .....m.a
    0000044A  00 73 00 74 00 65 00 72  00 06 6d 00 61 00 73 00 .s.t.e.r ..m.a.s.
    0000045A  74 00 65 00 72 00 ab 66  00 45 16 00 00 02 00 25 t.e.r..f .E.....%
    0000046A  00 43 00 68 00 61 00 6e  00 67 00 65 00 64 00 20 .C.h.a.n .g.e.d. 
    0000047A  00 64 00 61 00 74 00 61  00 62 00 61 00 73 00 65 .d.a.t.a .b.a.s.e
    0000048A  00 20 00 63 00 6f 00 6e  00 74 00 65 00 78 00 74 . .c.o.n .t.e.x.t
    0000049A  00 20 00 74 00 6f 00 20  00 27 00 6d 00 61 00 73 . .t.o.  .'.m.a.s
    ... omissis ...
    

    Now normal data follow. In this case server used flag 0 (see above).

    With force login (0x03 from server) after crypted login packet server and client continue to keep encrypting full packets

    Note that uncrypted packets are still splitted using packet size selected during login (that is usually 4096 bytes). freetds-1.00.82/doc/userguide_desc.sgml100644 025423 025423 00000000215 13242511066 0013447 freetds-1.00.82/samples/Makefile.am100644 025423 025423 00000001157 12522201763 0012532# version $Id: Makefile.am,v 1.3 2006-09-13 11:56:37 freddy77 Exp $ noinst_SCRIPTS = unixodbc.freetds.driver.template EXTRA_DIST = README debug.c dyntest.c odbc.ini odbctest.php \ odbctest.pl test.php test.pl \ unixodbc.freetds.driver.template.in \ unixodbc.install.sh \ unixodbc.jdbc.datasource.template SUFFIXES = .in edit = sed \ -e 's,@datadir\@,$(pkgdatadir),g' \ -e 's,@libdir\@,$(libdir),g' \ -e 's,@prefix\@,$(prefix),g' unixodbc.freetds.driver.template: unixodbc.freetds.driver.template.in CLEANFILES = unixodbc.freetds.driver.template .in: rm -f $@ $@.tmp $(edit) $< >$@.tmp mv $@.tmp $@ freetds-1.00.82/samples/Makefile.in100644 025423 025423 00000035174 13242511110 0012537# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # version $Id: Makefile.am,v 1.3 2006-09-13 11:56:37 freddy77 Exp $ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = samples ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = \ $(top_srcdir)/m4/ac_caolan_func_which_gethostbyname_r.m4 \ $(top_srcdir)/m4/ac_have_inaddr_none.m4 \ $(top_srcdir)/m4/ac_have_malloc_options.m4 \ $(top_srcdir)/m4/ac_nullzero.m4 \ $(top_srcdir)/m4/ac_raf_func_which_getservbyname_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_gethostbyaddr_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_getpwuid_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_localtime_r.m4 \ $(top_srcdir)/m4/acx_pthread.m4 \ $(top_srcdir)/m4/ax_cflags_gcc_option.m4 \ $(top_srcdir)/m4/check_openssl.m4 \ $(top_srcdir)/m4/gettimemilli.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/pushlibs.m4 \ $(top_srcdir)/m4/sprintf_i64_format.m4 \ $(top_srcdir)/m4/type_socklen_t.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = SCRIPTS = $(noinst_SCRIPTS) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/mkinstalldirs \ README DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BUILD_NUMBER = @BUILD_NUMBER@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOXYGEN = @DOXYGEN@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FREETDS_LIBGCC = @FREETDS_LIBGCC@ FREETDS_ODBC_MODULE = @FREETDS_ODBC_MODULE@ FREETDS_SYMBOLIC = @FREETDS_SYMBOLIC@ GCRYPT_CFLAGS = @GCRYPT_CFLAGS@ GCRYPT_LIBS = @GCRYPT_LIBS@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ HAVE_OPENSSL = @HAVE_OPENSSL@ HAVE_PERL_SOURCES = @HAVE_PERL_SOURCES@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBADD_DL = @LIBADD_DL@ LIBADD_DLD_LINK = @LIBADD_DLD_LINK@ LIBADD_DLOPEN = @LIBADD_DLOPEN@ LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@ LIBICONV = @LIBICONV@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBOBJS = @LTLIBOBJS@ LT_DLLOADERS = @LT_DLLOADERS@ LT_DLPREOPEN = @LT_DLPREOPEN@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ NETTLE_CFLAGS = @NETTLE_CFLAGS@ NETTLE_LIBS = @NETTLE_LIBS@ NETWORK_LIBS = @NETWORK_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ODBC = @ODBC@ ODBCINSTLIB = @ODBCINSTLIB@ ODBCLIB = @ODBCLIB@ ODBCNODMLIB = @ODBCNODMLIB@ ODBCNODMLIBAPP = @ODBCNODMLIBAPP@ ODBC_CONFIG = @ODBC_CONFIG@ ODBC_INC = @ODBC_INC@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ RC = @RC@ READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SUBVERSION = @SUBVERSION@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ dblib_define = @dblib_define@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ tds_sysdep_int16_type = @tds_sysdep_int16_type@ tds_sysdep_int32_type = @tds_sysdep_int32_type@ tds_sysdep_int64_type = @tds_sysdep_int64_type@ tds_sysdep_intptr_type = @tds_sysdep_intptr_type@ tds_sysdep_real32_type = @tds_sysdep_real32_type@ tds_sysdep_real64_type = @tds_sysdep_real64_type@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ noinst_SCRIPTS = unixodbc.freetds.driver.template EXTRA_DIST = README debug.c dyntest.c odbc.ini odbctest.php \ odbctest.pl test.php test.pl \ unixodbc.freetds.driver.template.in \ unixodbc.install.sh \ unixodbc.jdbc.datasource.template SUFFIXES = .in edit = sed \ -e 's,@datadir\@,$(pkgdatadir),g' \ -e 's,@libdir\@,$(libdir),g' \ -e 's,@prefix\@,$(prefix),g' CLEANFILES = unixodbc.freetds.driver.template all: all-am .SUFFIXES: .SUFFIXES: .in $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu samples/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu samples/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs tags TAGS: ctags CTAGS: cscope cscopelist: distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(SCRIPTS) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: all all-am check check-am clean clean-generic clean-libtool \ cscopelist-am ctags-am distclean distclean-generic \ distclean-libtool 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-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags-am uninstall uninstall-am .PRECIOUS: Makefile unixodbc.freetds.driver.template: unixodbc.freetds.driver.template.in .in: rm -f $@ $@.tmp $(edit) $< >$@.tmp mv $@.tmp $@ # 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: freetds-1.00.82/samples/README100644 025423 025423 00000000224 12522201763 0011350The dblib and ctlib test programs in this directory are old. Please refer to the src/dblib/unittests and src/ctlib/unittests for better examples. freetds-1.00.82/samples/debug.c100644 025423 025423 00000003314 12522201763 0011725/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 1998-1999 Brian Bruns * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #include #include #include #include #include #include #include #include static char software_version[] = "$Id: debug.c,v 1.2 2001-10-13 00:02:54 brianb Exp $"; static void *no_unused_var_warn[] = {software_version, no_unused_var_warn}; extern errno; get_incoming (int fd) { FILE *out; int len, i, offs=0; unsigned char buf[BUFSIZ]; out = fopen("client.out","w"); while ((len = read(fd, buf, BUFSIZ)) > 0) { fprintf (out,"len is %d\n",len); for (i=0;i=' ' && buf[i]<'z') fprintf(out," %c",buf[i]); fprintf(out,"\n"); } fflush(out); } close(fd); fclose(out); } freetds-1.00.82/samples/dyntest.c100644 025423 025423 00000007516 12522201763 0012341#include #include void execute(CS_COMMAND *cmd, char *id, CS_DATAFMT *datafmt, char *p1, char *p2, double p3, double p4) ; int main() { CS_CONTEXT *ctx; CS_CONNECTION *conn; CS_COMMAND *cmd; CS_RETCODE ret; CS_RETCODE restype; CS_DATAFMT datafmt[10]; ret = cs_ctx_alloc(CS_VERSION_100, &ctx); ret = ct_init(ctx, CS_VERSION_100); ret = ct_con_alloc(ctx, &conn); ret = ct_con_props(conn, CS_SET, CS_USERNAME, "guest", CS_NULLTERM, NULL); ret = ct_con_props(conn, CS_SET, CS_PASSWORD, "sybase", CS_NULLTERM, NULL); /* ret = ct_con_props(conn, CS_SET, CS_IFILE, "/devl/t3624bb/myinterf", CS_NULLTERM, NULL); */ ret = ct_connect(conn, "JDBC", CS_NULLTERM); ret = ct_cmd_alloc(conn, &cmd); ret = ct_command(cmd, CS_LANG_CMD, "drop table tempdb..prepare_bug ", CS_NULLTERM, CS_UNUSED); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_command() failed\n"); exit(1); } ret = ct_send(cmd); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_send() failed\n"); exit(1); } while(ct_results(cmd, &restype) == CS_SUCCEED) ; ret = ct_command(cmd, CS_LANG_CMD, "create table tempdb..prepare_bug (c1 char(20), c2 varchar(255), p1 float, p2 real) ", CS_NULLTERM, CS_UNUSED); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_command() failed\n"); exit(1); } ret = ct_send(cmd); if (ret != CS_SUCCEED) { fprintf(stderr, "ct_send() failed\n"); exit(1); } while(ct_results(cmd, &restype) == CS_SUCCEED) ; ct_dynamic(cmd, CS_PREPARE, "BUG", CS_NULLTERM, "insert tempdb..prepare_bug values(?, ?, ?, ?)", CS_NULLTERM); if(ct_send(cmd) != CS_SUCCEED) { fprintf(stderr,"ct_send failed in prepare"); exit(1); } while(ct_results(cmd, &restype) == CS_SUCCEED) ; /* ---- Sybase has now created a temporary stored proc ---- now - describe the parameters */ ct_dynamic(cmd, CS_DESCRIBE_INPUT, "BUG", CS_NULLTERM, NULL, CS_UNUSED); ct_send(cmd); while(ct_results(cmd, &restype) == CS_SUCCEED) { if(restype == CS_DESCRIBE_RESULT) { CS_INT num_param, outlen; int i; ct_res_info(cmd, CS_NUMDATA, &num_param, CS_UNUSED, &outlen); for(i = 1; i <= num_param; ++i) { ct_describe(cmd, i, &datafmt[i-1]); printf("column type: %d size: %d\n", datafmt[i-1].datatype, datafmt[i-1].maxlength); } } } /* ---- Now we have CS_DATAFMT struct for each of the input params ---- to the request. ---- so we can execute it with some parameters */ execute(cmd, "BUG", &datafmt[0], "test", "Jan 1 1988", 123.4, 222.334); /* ---- from now on it's a standard fetch all results loop... */ while(ct_results(cmd, &restype) == CS_SUCCEED) { printf("got restype %d\n", restype); if(restype == CS_ROW_RESULT) { int numcols, rows; char string[20]; int i, len, ind, ival; CS_DATAFMT output[2]; ct_res_info(cmd, CS_NUMDATA, &numcols, CS_UNUSED, NULL); for(i = 0; i < numcols; ++i) { ct_describe(cmd, (i + 1), &output[i]); if(output[i].datatype == CS_CHAR_TYPE) { ct_bind(cmd, (i + 1), &output[i], &string, &len, &ind); } else { ct_bind(cmd, (i + 1), &output[i], &ival, &len, &ind); } } while(ct_fetch(cmd, CS_UNUSED, CS_UNUSED, CS_UNUSED, &rows) == CS_SUCCEED) { printf("data = %.3s - %d\n", string, ival); } } } } void execute(CS_COMMAND *cmd, char *id, CS_DATAFMT *datafmt, char *p1, char *p2, double p3, double p4) { CS_INT restype; printf("execute called with %s, %s, %f, %f\n", p1, p2, p3, p4); ct_dynamic(cmd, CS_EXECUTE, id, CS_NULLTERM, NULL, CS_UNUSED); datafmt[0].datatype = CS_CHAR_TYPE; ct_param(cmd, &datafmt[0], p1, CS_NULLTERM, 0); datafmt[1].datatype = CS_CHAR_TYPE; ct_param(cmd, &datafmt[1], p2, CS_NULLTERM, 0); datafmt[2].datatype = CS_FLOAT_TYPE; ct_param(cmd, &datafmt[2], &p3, sizeof(double), 0); datafmt[3].datatype = CS_FLOAT_TYPE; ct_param(cmd, &datafmt[3], &p4, sizeof(double), 0); ct_send(cmd); } freetds-1.00.82/samples/odbc.ini100644 025423 025423 00000000460 12522201763 0012102; ; odbc.ini ; [ODBC Data Sources] JDBC = Sybase JDBC Server [JDBC] Driver = /usr/local/lib/libtdsodbc.so Description = Sybase JDBC Server Trace = No Servername = JDBC Database = pubs2 UID = guest [Default] Driver = /usr/local/lib/libtdsodbc.so freetds-1.00.82/samples/odbctest.php100644 025423 025423 00000001050 12522201763 0013006 freetds-1.00.82/samples/odbctest.pl100644 025423 025423 00000001020 12522201763 0012627#!/usr/local/bin/perl # $Id: odbctest.pl,v 1.2 2005-04-04 22:05:33 jklowden Exp $ use DBI; my ($dsn, $user, $pass, $sql) = @ARGV; $dsn = "dbi:ODBC:JDBC" unless $dsn; $user = 'guest' unless $user; $pass = 'sybase' unless $pass; $sql ="select \@\@servername" unless $sql; my $dbh = DBI->connect($dsn, $user, $pass, {PrintError => 1}); die "Unable for connect to server $DBI::errstr" unless $dbh; my $rc; my $sth = $dbh->prepare($sql); if($sth->execute) { while(@dat = $sth->fetchrow) { print "@dat\n"; } } freetds-1.00.82/samples/test.php100644 025423 025423 00000000453 12522201763 0012164 \n"; } ?> freetds-1.00.82/samples/test.pl100644 025423 025423 00000001134 12522201763 0012005#!/usr/bin/perl # use DBI; my ($servername, $username, $password) = @ARGV; $servername = 'JDBC' unless $servername; $username = 'guest' unless $username; $password = 'sybase' unless $password; my $dbh = DBI->connect("dbi:Sybase:server=$servername", $username, $password, {PrintError => 0}); die "Unable for connect to server $DBI::errstr" unless $dbh; my $rc; my $sth; if (@ARGV > 3) { $query = $ARGV[3]; } else { $query = "select \@\@version"; } $sth = $dbh->prepare($query); print $sth->{"ChopBlanks"} = 0; if($sth->execute) { while(@dat = $sth->fetchrow) { print "@dat\n"; } } freetds-1.00.82/samples/unixodbc.freetds.driver.template.in100644 025423 025423 00000002025 12522201763 0017373# # $Id: unixodbc.freetds.driver.template.in,v 1.2 2006-09-13 11:56:37 freddy77 Exp $ # # FreeTDS - Library of routines accessing Sybase and Microsoft databases # Copyright (C) 1998-1999 Brian Bruns # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library 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 # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # [FreeTDS] Description = FreeTDS unixODBC Driver Driver = @libdir@/libtdsodbc.so Setup = @libdir@/libtdsodbc.so freetds-1.00.82/samples/unixodbc.install.sh100755 025423 025423 00000002607 12522201763 0014316#! /bin/sh # # $Id: unixodbc.install.sh,v 1.1 2002-10-09 17:05:44 castellano Exp $ # # FreeTDS - Library of routines accessing Sybase and Microsoft databases # Copyright (C) 1998-1999 Brian Bruns # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library 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 # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # # Run this script as root to install FreeTDS unixODBC drivers and datasources. # # You will most likely want to edit unixodbc.jdbc.datasource.template # to add your own dataserver instead of the public Sybase dataserver. # # For more information about these template files, please see # http://www.unixodbc.org/doc/FreeTDS.html # # Install driver. odbcinst -i -d -f unixodbc.freetds.driver.template # Install system datasource. odbcinst -i -s -l -f unixodbc.jdbc.datasource.template freetds-1.00.82/samples/unixodbc.jdbc.datasource.template100644 025423 025423 00000002031 12522201763 0017070# # $Id: unixodbc.jdbc.datasource.template,v 1.1 2002-10-09 17:05:44 castellano Exp $ # # FreeTDS - Library of routines accessing Sybase and Microsoft databases # Copyright (C) 1998-1999 Brian Bruns # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library 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 # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # [JDBC] Driver = FreeTDS Description = Sybase JDBC Server Trace = No Servername = JDBC Database = pubs2 UID = guest freetds-1.00.82/win32/freetds/sysconfdir.h100644 025423 025423 00000000040 12522201763 0013752#define FREETDS_SYSCONFDIR "c:" freetds-1.00.82/win32/Makefile.am100644 025423 025423 00000000167 12717145107 0012035EXTRA_DIST = initnet.c \ freetds/sysconfdir.h \ freetds.nsh freetds.nsh.in \ installfreetds.bat freetds.nsi freetds-1.00.82/win32/Makefile.in100644 025423 025423 00000034263 13242511111 0012034# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = win32 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = \ $(top_srcdir)/m4/ac_caolan_func_which_gethostbyname_r.m4 \ $(top_srcdir)/m4/ac_have_inaddr_none.m4 \ $(top_srcdir)/m4/ac_have_malloc_options.m4 \ $(top_srcdir)/m4/ac_nullzero.m4 \ $(top_srcdir)/m4/ac_raf_func_which_getservbyname_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_gethostbyaddr_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_getpwuid_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_localtime_r.m4 \ $(top_srcdir)/m4/acx_pthread.m4 \ $(top_srcdir)/m4/ax_cflags_gcc_option.m4 \ $(top_srcdir)/m4/check_openssl.m4 \ $(top_srcdir)/m4/gettimemilli.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/pushlibs.m4 \ $(top_srcdir)/m4/sprintf_i64_format.m4 \ $(top_srcdir)/m4/type_socklen_t.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = freetds.nsh CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/freetds.nsh.in \ $(top_srcdir)/mkinstalldirs DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BUILD_NUMBER = @BUILD_NUMBER@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOXYGEN = @DOXYGEN@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FREETDS_LIBGCC = @FREETDS_LIBGCC@ FREETDS_ODBC_MODULE = @FREETDS_ODBC_MODULE@ FREETDS_SYMBOLIC = @FREETDS_SYMBOLIC@ GCRYPT_CFLAGS = @GCRYPT_CFLAGS@ GCRYPT_LIBS = @GCRYPT_LIBS@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ HAVE_OPENSSL = @HAVE_OPENSSL@ HAVE_PERL_SOURCES = @HAVE_PERL_SOURCES@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBADD_DL = @LIBADD_DL@ LIBADD_DLD_LINK = @LIBADD_DLD_LINK@ LIBADD_DLOPEN = @LIBADD_DLOPEN@ LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@ LIBICONV = @LIBICONV@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBOBJS = @LTLIBOBJS@ LT_DLLOADERS = @LT_DLLOADERS@ LT_DLPREOPEN = @LT_DLPREOPEN@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ NETTLE_CFLAGS = @NETTLE_CFLAGS@ NETTLE_LIBS = @NETTLE_LIBS@ NETWORK_LIBS = @NETWORK_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ODBC = @ODBC@ ODBCINSTLIB = @ODBCINSTLIB@ ODBCLIB = @ODBCLIB@ ODBCNODMLIB = @ODBCNODMLIB@ ODBCNODMLIBAPP = @ODBCNODMLIBAPP@ ODBC_CONFIG = @ODBC_CONFIG@ ODBC_INC = @ODBC_INC@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ RC = @RC@ READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SUBVERSION = @SUBVERSION@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ dblib_define = @dblib_define@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ tds_sysdep_int16_type = @tds_sysdep_int16_type@ tds_sysdep_int32_type = @tds_sysdep_int32_type@ tds_sysdep_int64_type = @tds_sysdep_int64_type@ tds_sysdep_intptr_type = @tds_sysdep_intptr_type@ tds_sysdep_real32_type = @tds_sysdep_real32_type@ tds_sysdep_real64_type = @tds_sysdep_real64_type@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ EXTRA_DIST = initnet.c \ freetds/sysconfdir.h \ freetds.nsh freetds.nsh.in \ installfreetds.bat freetds.nsi all: all-am .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu win32/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu win32/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): freetds.nsh: $(top_builddir)/config.status $(srcdir)/freetds.nsh.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs tags TAGS: ctags CTAGS: cscope cscopelist: distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: all all-am check check-am clean clean-generic clean-libtool \ cscopelist-am ctags-am distclean distclean-generic \ distclean-libtool 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-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags-am uninstall uninstall-am .PRECIOUS: Makefile # 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: freetds-1.00.82/win32/freetds.nsh.in100644 025423 025423 00000000044 12522201763 0012541!define PRODUCT_VERSION "@VERSION@" freetds-1.00.82/win32/initnet.c100644 025423 025423 00000002204 12717145107 0011611#if defined(_MSC_VER) && defined(_DEBUG) #define _CRTDBG_MAP_ALLOC #include #include #endif #include #ifdef DLL_EXPORT HINSTANCE hinstFreeTDS; BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved); BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { WSADATA wsaData; hinstFreeTDS = hinstDLL; switch (fdwReason) { case DLL_PROCESS_ATTACH: #if defined(_MSC_VER) && defined(_DEBUG) _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDOUT); _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE); _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDOUT); _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE); _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDOUT); _CrtSetDbgFlag(_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF | _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG)); #endif if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) return FALSE; DisableThreadLibraryCalls(hinstDLL); break; case DLL_PROCESS_DETACH: #if defined(_MSC_VER) && defined(_DEBUG) _CrtDumpMemoryLeaks(); #endif break; } return TRUE; } #endif freetds-1.00.82/win32/freetds.nsh100644 025423 025423 00000000042 13242511125 0012126!define PRODUCT_VERSION "1.00.82" freetds-1.00.82/win32/installfreetds.bat100644 025423 025423 00000000413 12717145107 0013506@echo off REM This shell script installs the FreeTDS ODBC driver set dest=%windir%\System IF EXIST %windir%\System32\ODBCCONF.exe SET dest=%windir%\System32 ECHO Installing to %dest% COPY /Y Debug\FreeTDS.dll %dest%\FreeTDS.dll CD %dest% regsvr32 FreeTDS.dll freetds-1.00.82/win32/freetds.nsi100644 025423 025423 00000005145 12717145107 0012151; Script generated by the HM NIS Edit Script Wizard. !include "freetds.nsh" ; HM NIS Edit Wizard helper defines !define PRODUCT_NAME "FreeTDS ODBC driver" !define PRODUCT_PUBLISHER "FreeTDS group" !define PRODUCT_WEB_SITE "http://www.freetds.org" !define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\{fef6e1f0-ef60-43d2-80a4-bfb774df706c}" !define PRODUCT_UNINST_ROOT_KEY "HKLM" SetCompressor lzma ; MUI 1.67 compatible ------ !include "MUI.nsh" ; MUI Settings !define MUI_ABORTWARNING !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico" !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico" ; Welcome page !insertmacro MUI_PAGE_WELCOME ; License page !insertmacro MUI_PAGE_LICENSE "..\COPYING" ; Directory page !insertmacro MUI_PAGE_DIRECTORY ; Instfiles page !insertmacro MUI_PAGE_INSTFILES ; Finish page !insertmacro MUI_PAGE_FINISH ; Uninstaller pages !insertmacro MUI_UNPAGE_INSTFILES ; Language files !insertmacro MUI_LANGUAGE "English" ; Reserve files !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS ; MUI end ------ Name "${PRODUCT_NAME} ${PRODUCT_VERSION}" OutFile "FreeTDS Setup.exe" InstallDir "$PROGRAMFILES\${PRODUCT_NAME}" ShowInstDetails show ShowUnInstDetails show Section "MainSection" SEC01 SetOutPath "$SYSDIR" SetOverwrite ifnewer File ".\FreeTDS.dll" ; install driver ExecWait '"$SYSDIR\rundll32.exe" "$SYSDIR\FreeTDS.dll" DllRegisterServer' SectionEnd Section -Post SetOutPath "$INSTDIR" WriteUninstaller "$INSTDIR\uninst.exe" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}" WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}" SectionEnd Function un.onUninstSuccess HideWindow MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer." FunctionEnd Function un.onInit MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2 Abort FunctionEnd Section Uninstall ExecWait '"$SYSDIR\rundll32.exe" "$SYSDIR\FreeTDS.dll" DllUnregisterServer' Delete "$INSTDIR\uninst.exe" Delete "$SYSDIR\FreeTDS.dll" RMDir "$INSTDIR" DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" SetAutoClose true SectionEnd freetds-1.00.82/vms/Makefile.am100644 025423 025423 00000000500 12522201763 0011662EXTRA_DIST = config_h.vms configure.com edit.c descrip_mms.template \ getpass.c libodbc.opt odbc_driver_axp.opt README.vms \ vargdefs.h vmsarg_command_bcp.cld vmsarg_command_defncopy.cld \ vmsarg_command_isql.cld vmsarg_mapping_bcp.c \ vmsarg_mapping_defncopy.c vmsarg_mapping_isql.c \ vmsarg_parse.c clean: freetds-1.00.82/vms/Makefile.in100644 025423 025423 00000034301 13242511111 0011670# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = vms ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = \ $(top_srcdir)/m4/ac_caolan_func_which_gethostbyname_r.m4 \ $(top_srcdir)/m4/ac_have_inaddr_none.m4 \ $(top_srcdir)/m4/ac_have_malloc_options.m4 \ $(top_srcdir)/m4/ac_nullzero.m4 \ $(top_srcdir)/m4/ac_raf_func_which_getservbyname_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_gethostbyaddr_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_getpwuid_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_localtime_r.m4 \ $(top_srcdir)/m4/acx_pthread.m4 \ $(top_srcdir)/m4/ax_cflags_gcc_option.m4 \ $(top_srcdir)/m4/check_openssl.m4 \ $(top_srcdir)/m4/gettimemilli.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/pushlibs.m4 \ $(top_srcdir)/m4/sprintf_i64_format.m4 \ $(top_srcdir)/m4/type_socklen_t.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/mkinstalldirs DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BUILD_NUMBER = @BUILD_NUMBER@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOXYGEN = @DOXYGEN@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FREETDS_LIBGCC = @FREETDS_LIBGCC@ FREETDS_ODBC_MODULE = @FREETDS_ODBC_MODULE@ FREETDS_SYMBOLIC = @FREETDS_SYMBOLIC@ GCRYPT_CFLAGS = @GCRYPT_CFLAGS@ GCRYPT_LIBS = @GCRYPT_LIBS@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ HAVE_OPENSSL = @HAVE_OPENSSL@ HAVE_PERL_SOURCES = @HAVE_PERL_SOURCES@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBADD_DL = @LIBADD_DL@ LIBADD_DLD_LINK = @LIBADD_DLD_LINK@ LIBADD_DLOPEN = @LIBADD_DLOPEN@ LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@ LIBICONV = @LIBICONV@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBOBJS = @LTLIBOBJS@ LT_DLLOADERS = @LT_DLLOADERS@ LT_DLPREOPEN = @LT_DLPREOPEN@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ NETTLE_CFLAGS = @NETTLE_CFLAGS@ NETTLE_LIBS = @NETTLE_LIBS@ NETWORK_LIBS = @NETWORK_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ODBC = @ODBC@ ODBCINSTLIB = @ODBCINSTLIB@ ODBCLIB = @ODBCLIB@ ODBCNODMLIB = @ODBCNODMLIB@ ODBCNODMLIBAPP = @ODBCNODMLIBAPP@ ODBC_CONFIG = @ODBC_CONFIG@ ODBC_INC = @ODBC_INC@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ RC = @RC@ READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SUBVERSION = @SUBVERSION@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ dblib_define = @dblib_define@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ tds_sysdep_int16_type = @tds_sysdep_int16_type@ tds_sysdep_int32_type = @tds_sysdep_int32_type@ tds_sysdep_int64_type = @tds_sysdep_int64_type@ tds_sysdep_intptr_type = @tds_sysdep_intptr_type@ tds_sysdep_real32_type = @tds_sysdep_real32_type@ tds_sysdep_real64_type = @tds_sysdep_real64_type@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ EXTRA_DIST = config_h.vms configure.com edit.c descrip_mms.template \ getpass.c libodbc.opt odbc_driver_axp.opt README.vms \ vargdefs.h vmsarg_command_bcp.cld vmsarg_command_defncopy.cld \ vmsarg_command_isql.cld vmsarg_mapping_bcp.c \ vmsarg_mapping_defncopy.c vmsarg_mapping_isql.c \ vmsarg_parse.c all: all-am .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu vms/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu vms/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs tags TAGS: ctags CTAGS: cscope cscopelist: distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: all all-am check check-am clean clean-generic clean-libtool \ cscopelist-am ctags-am distclean distclean-generic \ distclean-libtool 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-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags-am uninstall uninstall-am .PRECIOUS: Makefile clean: # 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: freetds-1.00.82/vms/config_h.vms100644 025423 025423 00000024267 12717145107 0012156/* $Id: config_h.vms,v 1.12 2010-09-02 18:01:42 berryc Exp $ */ /* include/config.h.in. Generated from configure.ac by autoheader. */ /* and edited by hand for VMS */ #ifndef CONFIG_H_LOADED #define CONFIG_H_LOADED 1 /* Define to 1 if you need BSD_COMP defined to get FIONBIO defined. */ #undef BSD_COMP /* Define to enable work in progress code */ #undef ENABLE_DEVELOPING /* Define to enable extra checks on code */ #undef ENABLE_EXTRA_CHECKS /* Define to 1 if you have the header file. */ #define HAVE_ARPA_INET_H 1 /* Define to 1 if you have the `alarm' function. */ #define HAVE_ALARM 1 /* Define to 1 if you have the `asprintf' function. */ #define HAVE_ASPRINTF @D_ASPRINTF@ /* Define to 1 if you have the `basename' function. */ #ifndef __CRTL_VER #define __CRTL_VER __VMS_VER #endif #if __CRTL_VER >= 70000000 #define HAVE_BASENAME 1 #else #define HAVE_BASENAME 0 #endif /* Define if you have the clock_gettime function. */ #if __CRTL_VER >= 70302000 #define HAVE_CLOCK_GETTIME 1 #endif /* Define to 1 if you have the header file. */ #define HAVE_ERRNO_H 1 /* Define to 1 if your system provides the 5-parameter version of gethostbyaddr_r(). */ #undef HAVE_FUNC_GETHOSTBYADDR_R_5 /* Define to 1 if your system provides the 6-parameter version of gethostbyaddr_r(). */ #undef HAVE_FUNC_GETHOSTBYADDR_R_7 /* Define to 1 if your system provides the 8-parameter version of gethostbyaddr_r(). */ #undef HAVE_FUNC_GETHOSTBYADDR_R_8 /* Define to 1 if your system provides the 3-parameter version of gethostbyname_r(). */ #undef HAVE_FUNC_GETHOSTBYNAME_R_3 /* Define to 1 if your system provides the 5-parameter version of gethostbyname_r(). */ #undef HAVE_FUNC_GETHOSTBYNAME_R_5 /* Define to 1 if your system provides the 6-parameter version of gethostbyname_r(). */ #undef HAVE_FUNC_GETHOSTBYNAME_R_6 /* Define to 1 if your system provides the 4-parameter version of getpwuid_r(). */ #undef HAVE_FUNC_GETPWUID_R_4 /* Define to 1 if your system getpwuid_r() have 4 parameters and return struct passwd*. */ #undef HAVE_FUNC_GETPWUID_R_4_PW /* Define to 1 if your system provides the 5-parameter version of getpwuid_r(). */ #undef HAVE_FUNC_GETPWUID_R_5 /* Define to 1 if your system provides the 4-parameter version of getservbyname_r(). */ #undef HAVE_FUNC_GETSERVBYNAME_R_4 /* Define to 1 if your system provides the 5-parameter version of getservbyname_r(). */ #undef HAVE_FUNC_GETSERVBYNAME_R_5 /* Define to 1 if your system provides the 6-parameter version of getservbyname_r(). */ #undef HAVE_FUNC_GETSERVBYNAME_R_6 /* Define to 1 if you have the `gethostent_r' function. */ #undef HAVE_GETHOSTENT_R /* Define if you have getaddrinfo function */ #define HAVE_GETADDRINFO 1 /* Define to 1 if you have the `gethostname' function. */ #define HAVE_GETHOSTNAME 1 /* Define to 1 if you have the `getpwuid' function. */ #define HAVE_GETPWUID 1 /* Define to 1 if you have the `getpwuid_r' function. */ #undef HAVE_GETPWUID_R /* Define to 1 if you have the `gettimeofday' function. */ #define HAVE_GETTIMEOFDAY 1 /* Define to 1 if you have the `getopt' function. */ #define HAVE_GETOPT 1 /* Define to 1 if you have the `getuid' function. */ #define HAVE_GETUID 1 /* Define if you have the iconv() function. */ #define HAVE_ICONV @D_HAVE_ICONV@ /* Define to 1 if you have the header file. */ #define HAVE_INTTYPES_H 1 /* Define to 1 if you have the header file. */ #define HAVE_LANGINFO_H 1 /* Define to 1 if you have the header file. */ #define HAVE_LIBGEN_H 1 /* Define to 1 if you have the header file. */ #define HAVE_LOCALE_H 1 /* Define to 1 if you have the header file. */ #undef HAVE_MALLOC_H /* Define to 1 if your system provides the malloc_options variable. */ #undef HAVE_MALLOC_OPTIONS /* Define to 1 if you have the header file. */ #define HAVE_MEMORY_H 1 /* Define to 1 if you have the header file. */ #define HAVE_NETDB_H 1 /* Define to 1 if you have the header file. */ #define HAVE_NETINET_IN_H 1 /* Define to 1 if you have the `nl_langinfo' function. */ #define HAVE_NL_LANGINFO 1 /* Define to 1 if you have the header file. */ #undef HAVE_PATHS_H #if __CRTL_VER >= 70302000 && !defined(__VAX) /* Define to 1 if you have the `poll' function. */ #define HAVE_POLL 1 /* Define to 1 if you have the header file. */ #define HAVE_POLL_H 1 #endif /* Define if you have POSIX threads libraries and header files. */ #define HAVE_PTHREAD 1 /* Define to 1 if you have the `pthread_cond_timedwait' function. */ #define HAVE_PTHREAD_COND_TIMEDWAIT 1 /* Define to 1 if you have the GNU Readline library. */ #define HAVE_READLINE 1 /* Define to 1 if you have the `sethostent_r' function. */ #undef HAVE_SETHOSTENT_R /* Define to 1 if you have the `socketpair' function. */ /* Must be undefined, not defined to 0, when not present. */ #if @D_SOCKETPAIR@ #define HAVE_SOCKETPAIR 1 #endif /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #define HAVE_STDLIB_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STRINGS_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STRING_H 1 /* Define to 1 if you have the `strtok_r' function. */ #define HAVE_STRTOK_R @D_STRTOK_R@ /* Define to 1 if you have the header file. */ #define HAVE_SYS_IOCTL_H 1 /* Define to 1 if you have the header file. */ #undef HAVE_SYS_PARAM_H /* Define to 1 if you have the header file. */ #define HAVE_SYS_SOCKET_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SYS_STAT_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SYS_TIME_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SYS_TYPES_H 1 /* Define to 1 if you have the header file. */ #define HAVE_UNISTD_H 1 /* Define to 1 if you have the `vasprintf' function. */ #define HAVE_VASPRINTF @D_VASPRINTF@ /* Define to 1 if you have the `snprintf' function. */ #define HAVE_SNPRINTF @D_SNPRINTF@ /* Define to 1 if you have the `vsnprintf' function. */ #define HAVE_VSNPRINTF 0 /* Define as const if the declaration of iconv() needs const. */ #if HAVE_ICONV # define ICONV_CONST #else # define ICONV_CONST const #endif /* Define to value of INADDR_NONE if not provided by your system header files. */ /*#undef INADDR_NONE*/ /* Define to 1 if the BSD-style netdb interface is reentrant. */ #undef NETDB_REENTRANT /* Name of package */ #define PACKAGE "freetds" /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the version of this package. */ #undef PACKAGE_VERSION /* The size of a `char', as computed by sizeof. */ #undef SIZEOF_CHAR /* The size of a `double', as computed by sizeof. */ #undef SIZEOF_DOUBLE /* The size of a `float', as computed by sizeof. */ #undef SIZEOF_FLOAT /* The size of a `int', as computed by sizeof. */ #undef SIZEOF_INT /* The size of a `long', as computed by sizeof. */ #undef SIZEOF_LONG /* The size of a `long long', as computed by sizeof. */ #undef SIZEOF_LONG_LONG /* The size of a `short', as computed by sizeof. */ #undef SIZEOF_SHORT /* The size of a `__int64', as computed by sizeof. */ #undef SIZEOF___INT64 /* Define to 1 if you have the ANSI C header files. */ #define STDC_HEADERS 1 /* define to constant to use for clock_gettime */ #if __CRTL_VER >= 70302000 #define TDS_GETTIMEMILLI_CONST CLOCK_REALTIME #endif /* Define if you have pthread with mutex support */ #define TDS_HAVE_PTHREAD_MUTEX 1 /* Define if stdio support locking */ #if __CRTL_VER >= 80200000 #define TDS_HAVE_STDIO_LOCKED 1 #endif /* define to prefix format string used for 64bit integers */ #define TDS_I64_PREFIX "ll" /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Version number of package */ #define VERSION @VERSION@ /* Define to 1 if your processor stores words with the most significant byte first (like Motorola and SPARC, unlike Intel and VAX). */ #undef WORDS_BIGENDIAN /* Enable GNU extensions on systems that have them. */ #ifndef _GNU_SOURCE # undef _GNU_SOURCE #endif /* Additions below not originally from config.h.in */ /* This really just needs to be the current working directory for the tests */ #define FREETDS_SRCDIR "." /* But some tests insist on redefining that in terms of this */ #define FREETDS_TOPDIR "../../.." #include #define MAXPATHLEN PATH_MAX #define _PATH_DEVNULL "_NLA0:" /* FIXME: There are numerous signed/unsigned mismatches in the code * that should really be corrected, but this hushes the compiler for now. */ #pragma message disable PTRMISMATCH1 #include /* we need size_t for replacements */ #pragma extern_prefix save /* We cook up our own version of this, so prototype it here. */ #pragma extern_prefix "freetds_" (getpass) char *getpass( const char* prompt ); #pragma extern_prefix "freetds_" (readpassphrase) char * readpassphrase(const char *, char *, size_t, int); #ifdef HAVE_READPASSPHRASE /* has to be undefined to pick up constants in readpassphrase.h */ # undef HAVE_READPASSPHRASE #endif #pragma extern_prefix restore #define tds_sysdep_intptr_type int /* 32-bit int */ #include "replacements.h" /* If the CRTL ever complies with UNIX98 and defines socklen_t in * sys/socket.h, this _may_ prevent a conflicting definition but * still get us what we need in the meantime. */ #if !defined __SOCKLEN_T # define __SOCKLEN_T 1 typedef __size_t socklen_t; #endif /* We only support unixODBC, so we do have these */ #define HAVE_SQLGETPRIVATEPROFILESTRING 1 #define HAVE_SQLLEN 1 #define HAVE_SQLSETPOSIROW 1 #define TDS_SQLCOLATTRIBUTE_SQLLEN 1 /* Prototype for routine to convert VMS-style arguments to Unix-style. */ int parse_vms_args(int *argc, char **argv[]); /* alloca is a built-in */ #include #define alloca(__x) __ALLOCA(__x) #endif /* CONFIG_H_LOADED */ freetds-1.00.82/vms/configure.com100644 025423 025423 00000025335 12540504221 0012317$! FreeTDS - Library of routines accessing Sybase and Microsoft databases $! Copyright (C) 2003 Craig A. Berry craigberry@mac.com 1-FEB-2003 $! $! This library is free software; you can redistribute it and/or $! modify it under the terms of the GNU Library General Public $! License as published by the Free Software Foundation; either $! version 2 of the License, or (at your option) any later version. $! $! This library 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 $! Library General Public License for more details. $! $! You should have received a copy of the GNU Library General Public $! License along with this library; if not, write to the $! Free Software Foundation, Inc., 59 Temple Place - Suite 330, $! Boston, MA 02111-1307, USA. $! $! $Id: configure.com,v 1.6 2008-02-28 23:27:14 jklowden Exp $ $! $! CONFIGURE.COM -- run from top level source directory as @[.vms]configure $! $! Checks for C library functions and applies its findings to $! description file template and config.h. Much of this cribbed $! from Perl's configure.com, largely the work of Peter Prymmer. $! $ SAY := "write sys$output" $! $ SEARCH/KEY=(POS:2,SIZE:8) SYS$DISK:[]Configure. "VERSION="/EXACT/OUTPUT=version.tmp $ open/read version version.tmp $ read version versionline $ close version $ delete/noconfirm/nolog version.tmp;* $ versionstring = f$element(1, "=", f$edit(versionline, "COLLAPSE")) $ gosub check_crtl $! $! The system-supplied iconv() is fine, but unless the internationalization $! kit has been installed, we may not have the conversions we need. Check $! for their presence and use the homegrown iconv() if necessary. $! $ IF - "FALSE" - ! native iconv() buggy, don't use for now .AND. F$SEARCH("SYS$I18N_ICONV:UCS-2_ISO8859-1.ICONV") .NES. "" - .AND. F$SEARCH("SYS$I18N_ICONV:ISO8859-1_UCS-2.ICONV") .NES. "" - .AND. F$SEARCH("SYS$I18N_ICONV:UTF-8_ISO8859-1.ICONV") .NES. "" - .AND. F$SEARCH("SYS$I18N_ICONV:ISO8859-1_UTF-8.ICONV") .NES. "" $ THEN $ d_have_iconv = "1" $ SAY "Using system-supplied iconv()" $ ELSE $ d_have_iconv = "0" $ SAY "Using replacement iconv()" $ ENDIF $! $! Set socketpair (available with VMS 8.2 and later) $! $ IF F$EXTRACT(1,3,F$EDIT(F$GETSYI("VERSION"),"TRIM")) .GES. "8.2" $ THEN $ d_socketpair = "1" $ SAY "Using system-supplied socketpair()" $ ELSE $ d_socketpair = "0" $ SAY "Using replacement socketpair()" $ ENDIF $! $! Generate config.h $! $ open/write vmsconfigtmp vmsconfigtmp.com $ write vmsconfigtmp "$ define/user_mode/nolog SYS$OUTPUT _NLA0:" $ write vmsconfigtmp "$ edit/tpu/nodisplay/noinitialization -" $ write vmsconfigtmp "/section=sys$library:eve$section.tpu$section -" $ write vmsconfigtmp "/command=sys$input/output=[.include]config.h [.vms]config_h.vms" $ write vmsconfigtmp "input_file := GET_INFO (COMMAND_LINE, ""file_name"");" $ write vmsconfigtmp "main_buffer:= CREATE_BUFFER (""main"", input_file);" $ write vmsconfigtmp "POSITION (BEGINNING_OF (main_buffer));" $ write vmsconfigtmp "eve_global_replace(""@D_ASPRINTF@"",""''d_asprintf'"");" $ write vmsconfigtmp "POSITION (BEGINNING_OF (main_buffer));" $ write vmsconfigtmp "eve_global_replace(""@D_VASPRINTF@"",""''d_vasprintf'"");" $ write vmsconfigtmp "POSITION (BEGINNING_OF (main_buffer));" $ write vmsconfigtmp "eve_global_replace(""@D_STRTOK_R@"",""''d_strtok_r'"");" $ write vmsconfigtmp "POSITION (BEGINNING_OF (main_buffer));" $ write vmsconfigtmp "eve_global_replace(""@VERSION@"",""""""''versionstring'"""""");" $ write vmsconfigtmp "POSITION (BEGINNING_OF (main_buffer));" $ write vmsconfigtmp "eve_global_replace(""@D_HAVE_ICONV@"",""''d_have_iconv'"");" $ write vmsconfigtmp "POSITION (BEGINNING_OF (main_buffer));" $ write vmsconfigtmp "eve_global_replace(""@D_SNPRINTF@"",""''d_snprintf'"");" $ write vmsconfigtmp "POSITION (BEGINNING_OF (main_buffer));" $ write vmsconfigtmp "eve_global_replace(""@D_SOCKETPAIR@"",""''d_socketpair'"");" $ write vmsconfigtmp "out_file := GET_INFO (COMMAND_LINE, ""output_file"");" $ write vmsconfigtmp "WRITE_FILE (main_buffer, out_file);" $ write vmsconfigtmp "quit;" $ write vmsconfigtmp "$ exit" $ close vmsconfigtmp $ @vmsconfigtmp.com $ delete/noconfirm/nolog vmsconfigtmp.com; $! $! Generate descrip.mms from template $! $ if d_asprintf .eqs. "1" $ then $ asprintfobj = " " $ else $ asprintfobj = "[.src.replacements]asprintf$(OBJ)," $ endif $! $ if d_vasprintf .eqs. "1" $ then $ vasprintfobj = " " $ else $ vasprintfobj = "[.src.replacements]vasprintf$(OBJ)," $ endif $! $ if d_strtok_r .eqs. "1" $ then $ strtok_robj = " " $ else $ strtok_robj = "[.src.replacements]strtok_r$(OBJ)," $ endif $! $ if d_have_iconv .eqs. "1" $ then $ libiconvobj = " " $ else $ libiconvobj = "[.src.replacements]libiconv$(OBJ)," $ copy/noconfirm/nolog [.src.replacements]iconv.c [.src.replacements]libiconv.c $ endif $! $ if d_snprintf .eqs. "1" $ then $ snprintfobj = " " $ else $ snprintfobj = "[.src.replacements]snprintf$(OBJ)," $ endif $! $ if d_socketpair .eqs. "1" $ then $ socketpairobj = " " $ else $ socketpairobj = "[.src.replacements]socketpair$(OBJ)," $ endif $! $ if P1 .eqs. "--disable-thread-safe" $ then $ enable_thread_safe = " " $ else $ enable_thread_safe = "ENABLE_THREAD_SAFE = 1" $ endif $! $ open/write vmsconfigtmp vmsconfigtmp.com $ write vmsconfigtmp "$ define/user_mode/nolog SYS$OUTPUT _NLA0:" $ write vmsconfigtmp "$ edit/tpu/nodisplay/noinitialization -" $ write vmsconfigtmp "/section=sys$library:eve$section.tpu$section -" $ write vmsconfigtmp "/command=sys$input/output=[]descrip.mms [.vms]descrip_mms.template" $ write vmsconfigtmp "input_file := GET_INFO (COMMAND_LINE, ""file_name"");" $ write vmsconfigtmp "main_buffer:= CREATE_BUFFER (""main"", input_file);" $ write vmsconfigtmp "POSITION (BEGINNING_OF (main_buffer));" $ write vmsconfigtmp "eve_global_replace(""@ASPRINTFOBJ@"",""''asprintfobj'"");" $ write vmsconfigtmp "POSITION (BEGINNING_OF (main_buffer));" $ write vmsconfigtmp "eve_global_replace(""@VASPRINTFOBJ@"",""''vasprintfobj'"");" $ write vmsconfigtmp "POSITION (BEGINNING_OF (main_buffer));" $ write vmsconfigtmp "eve_global_replace(""@STRTOK_ROBJ@"",""''strtok_robj'"");" $ write vmsconfigtmp "POSITION (BEGINNING_OF (main_buffer));" $ write vmsconfigtmp "eve_global_replace(""@LIBICONVOBJ@"",""''libiconvobj'"");" $ write vmsconfigtmp "POSITION (BEGINNING_OF (main_buffer));" $ write vmsconfigtmp "eve_global_replace(""@SNPRINTFOBJ@"",""''snprintfobj'"");" $ write vmsconfigtmp "POSITION (BEGINNING_OF (main_buffer));" $ write vmsconfigtmp "eve_global_replace(""@SOCKETPAIROBJ@"",""''socketpairobj'"");" $ write vmsconfigtmp "POSITION (BEGINNING_OF (main_buffer));" $ write vmsconfigtmp "eve_global_replace(""@ENABLE_THREAD_SAFE@"",""''enable_thread_safe'"");" $ write vmsconfigtmp "out_file := GET_INFO (COMMAND_LINE, ""output_file"");" $ write vmsconfigtmp "WRITE_FILE (main_buffer, out_file);" $ write vmsconfigtmp "quit;" $ write vmsconfigtmp "$ exit" $ close vmsconfigtmp $ @vmsconfigtmp.com $ delete/noconfirm/nolog vmsconfigtmp.com; $! $! C99 requires t, z, and j modifiers to decimal format specifiers $! but the HP compiler doesn't handle them, so replace the one $! use of %td with %ld. $! $ open/write vmsbsqldbtmp vmsbsqldbtmp.com $ write vmsbsqldbtmp "$ define/user_mode/nolog SYS$OUTPUT _NLA0:" $ write vmsbsqldbtmp "$ edit/tpu/nodisplay/noinitialization -" $ write vmsbsqldbtmp "/section=sys$library:eve$section.tpu$section -" $ write vmsbsqldbtmp "/command=sys$input/output=[.src.apps]bsqldb.c [.src.apps]bsqldb.c" $ write vmsbsqldbtmp "input_file := GET_INFO (COMMAND_LINE, ""file_name"");" $ write vmsbsqldbtmp "main_buffer:= CREATE_BUFFER (""main"", input_file);" $ write vmsbsqldbtmp "POSITION (BEGINNING_OF (main_buffer));" $ write vmsbsqldbtmp "eve_global_replace("" %td "","" %ld "");" $ write vmsbsqldbtmp "out_file := GET_INFO (COMMAND_LINE, ""output_file"");" $ write vmsbsqldbtmp "WRITE_FILE (main_buffer, out_file);" $ write vmsbsqldbtmp "quit;" $ write vmsbsqldbtmp "$ exit" $ close vmsbsqldbtmp $ @vmsbsqldbtmp.com $ delete/noconfirm/nolog vmsbsqldbtmp.com; $! $ Say "" $ Say "Configuration complete; run MMK or MMS to build." $ EXIT $! $ CHECK_CRTL: $! $ OS := "open/write CONFIG []try.c" $ WS := "write CONFIG" $ CS := "close CONFIG" $ DS := "delete/nolog/noconfirm []try.*;*" $ good_compile = %X10B90001 $ good_link = %X10000001 $ tmp = "" ! null string default $! $! Check for asprintf $! $ OS $ WS "#include " $ WS "#include " $ WS "int main()" $ WS "{" $ WS "char *ptr; $ WS "asprintf(&ptr,""%d"",1);" $ WS "exit(0);" $ WS "}" $ CS $ tmp = "asprintf" $ GOSUB inlibc $ d_asprintf == tmp $! $! $! Check for vasprintf $! $ OS $ WS "#include " $ WS "#include " $ WS "#include " $ WS "int main()" $ WS "{" $ WS "char *ptr; $ WS "vasprintf(&ptr,""%d,%d"",1,2);" $ WS "exit(0);" $ WS "}" $ CS $ tmp = "vasprintf" $ GOSUB inlibc $ d_vasprintf == tmp $! $! $! $! Check for strtok_r $! $ OS $ WS "#include " $ WS "#include " $ WS "int main()" $ WS "{" $ WS "char *word, *brkt, mystr[4];" $ WS "strcpy(mystr,""1^2"");" $ WS "word = strtok_r(mystr, ""^"", &brkt);" $ WS "exit(0);" $ WS "}" $ CS $ tmp = "strtok_r" $ GOSUB inlibc $ d_strtok_r == tmp $! $! $! Check for snprintf $! $ OS $ WS "#include " $ WS "#include " $ WS "#include " $ WS "int main()" $ WS "{" $ WS "char ptr[15];" $ WS "snprintf((char*)&ptr,sizeof(ptr),""%d,%d"",1,2);" $ WS "exit(0);" $ WS "}" $ CS $ tmp = "snprintf" $ GOSUB inlibc $ d_snprintf == tmp $! $ DS $ RETURN $! $!******************** $inlibc: $ GOSUB link_ok $ IF compile_status .EQ. good_compile .AND. link_status .EQ. good_link $ THEN $ say "''tmp'() found." $ tmp = "1" $ ELSE $ say "''tmp'() NOT found." $ tmp = "0" $ ENDIF $ RETURN $! $!: define a shorthand compile call $compile: $ GOSUB link_ok $just_mcr_it: $ IF compile_status .EQ. good_compile .AND. link_status .EQ. good_link $ THEN $ OPEN/WRITE CONFIG []try.out $ DEFINE/USER_MODE SYS$ERROR CONFIG $ DEFINE/USER_MODE SYS$OUTPUT CONFIG $ MCR []try.exe $ CLOSE CONFIG $ OPEN/READ CONFIG []try.out $ READ CONFIG tmp $ CLOSE CONFIG $ DELETE/NOLOG/NOCONFIRM []try.out; $ DELETE/NOLOG/NOCONFIRM []try.exe; $ ELSE $ tmp = "" ! null string default $ ENDIF $ RETURN $! $link_ok: $ GOSUB compile_ok $ DEFINE/USER_MODE SYS$ERROR _NLA0: $ DEFINE/USER_MODE SYS$OUTPUT _NLA0: $ SET NOON $ LINK try.obj $ link_status = $status $ SET ON $ IF F$SEARCH("try.obj") .NES. "" THEN DELETE/NOLOG/NOCONFIRM try.obj; $ RETURN $! $!: define a shorthand compile call for compilations that should be ok. $compile_ok: $ DEFINE/USER_MODE SYS$ERROR _NLA0: $ DEFINE/USER_MODE SYS$OUTPUT _NLA0: $ SET NOON $ CC try.c $ compile_status = $status $ SET ON $ DELETE/NOLOG/NOCONFIRM try.c; $ RETURN $! $beyond_compile_ok: $! freetds-1.00.82/vms/edit.c100644 025423 025423 00000003444 12522201763 0010731/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2010 Craig A. Berry craigberry@mac.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /* $Id: edit.c,v */ #include #include #include #include #include #include #if defined(NAML$C_MAXRSS) && !defined(__VAX) # define VMS_MAXRSS (NAML$C_MAXRSS+1) #else # define VMS_MAXRSS (NAM$C_MAXRSS+1) #endif char vms_fnm[VMS_MAXRSS]; static int get_vms_name(char *, int); int edit(const char *editor, const char *arg) { $DESCRIPTOR(fnm_dsc, ""); int status; decc$to_vms(arg, get_vms_name, 0, 0); fnm_dsc.dsc$a_pointer = vms_fnm; fnm_dsc.dsc$w_length = strlen(vms_fnm); if (fnm_dsc.dsc$a_pointer == NULL || fnm_dsc.dsc$w_length == 0) return -1; status = TPU$EDIT(&fnm_dsc, &fnm_dsc); if ($VMS_STATUS_SUCCESS(status)) return 0; else return -1; } static int get_vms_name(char *name, int type) { strncpy(vms_fnm, name, VMS_MAXRSS); return 1; } int reset_term() { return 0; } freetds-1.00.82/vms/descrip_mms.template100644 025423 025423 00000237751 12717145107 0013721# FreeTDS - Library of routines accessing Sybase and Microsoft databases # Copyright (C) 2003 Craig A. Berry craigberry@mac.com 23-JAN-2003 # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library 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 # Library General Public License for more details. # # You should have received a copy of the GNU Library General Public # License along with this library; if not, write to the # Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # # $Id: descrip_mms.template,v 1.20 2011-07-09 18:34:56 berryc Exp $ # OpenVMS description file for FreeTDS # To override default TDS version of "auto" specify /MACRO="TDSVER=TDSxx=1" # where xx is one of 42, 46, 50, 70, 71, 72, 73, or 74. # To build with ODBC support do MM(K|S)/MACRO="ODBC"=1 # This presupposes the existence of an ODBC library in the location pointed to # by the logical name ODBC_LIBDIR and ODBC include files in the location pointed # to by ODBC_INCDIR # To build in debug, do MM(K|S)/MACRO="__DEBUG__"=1 # To build with MSDBLIB-compatbile dblib structures, do MM(K|S)/MACRO="MSDBLIB"=1 OBJ = .OBJ E = .EXE OLB = .OLB .IFDEF ODBC ODBC_INC=,[.src.odbc],ODBC_INCDIR TDSODBCSHR=[]libtdsodbc$(E) TDSODBCCHECK=TDSODBCCHECK ODBCTESTS=ODBCTESTS .ELSE ODBC_INC= TDSODBCSHR= TDSODBCCHECK= ODBCTESTS= .ENDIF .IFDEF SYBASE_COMPAT DBOPENOBJ = [.src.dblib]dbopen$(OBJ), .ELSE DBOPENOBJ = .ENDIF .IFDEF MSDBLIB DBLIB_DEFINE = define MSDBLIB 1 .ELSE DBLIB_DEFINE = define SYBDBLIB 1 .ENDIF CC = CC/DECC .SUFFIXES : .SUFFIXES : $(E) $(OLB) $(OBJ) .C .H @ENABLE_THREAD_SAFE@ .IFDEF ENABLE_THREAD_SAFE PTHREAD_CDEFINE = "_THREAD_SAFE"=1 PTHREAD_LINK_FLAGS = /THREADS=UPCALLS .ELSE PTHREAD_CDEFINE = PTHREAD_LINK_FLAGS = .ENDIF CDEFINE = .IFDEF TDSVER CDEFINE = $(TDSVER) .ENDIF .IFDEF ODBC ODBC_CDEFINE = "UNIXODBC" CODBCFLAGS = /NAMES=(AS_IS,SHORTENED) .ELSE ODBC_CDEFINE = CODBCFLAGS = /NAMES=SHORTENED .ENDIF .IFDEF ODBC_CDEFINE .IFDEF CDEFINE CDEFINE = $(CDEFINE),$(ODBC_CDEFINE) .ELSE CDEFINE = $(ODBC_CDEFINE) .ENDIF .ENDIF .IFDEF PTHREAD_CDEFINE .IFDEF CDEFINE CDEFINE = $(CDEFINE),$(PTHREAD_CDEFINE) .ELSE CDEFINE = $(PTHREAD_CDEFINE) .ENDIF .ENDIF .IFDEF CDEFINE CDEFINE_QUAL = /DEFINE=($(CDEFINE)) .ELSE CDEFINE_QUAL = .ENDIF CPREFIX = ALL CINCLUDE = "./","./include"$(ODBC_INC) .IFDEF __DEBUG__ CDBGFLAGS = /DEBUG/NOOPTIMIZE/LIST=$(MMS$TARGET_NAME)/SHOW=(EXPANSION,INCLUDE) LDBGFLAGS = /DEBUG/MAP .ELSE CDBGFLAGS = LDBGFLAGS = /NOTRACE .ENDIF CFLAGS = $(CDEFINE_QUAL)/PREFIX=($(CPREFIX))/FLOAT=IEEE/IEEE=DENORM/OBJECT=$(MMS$TARGET_NAME)$(OBJ) $(CODBCFLAGS) $(CDBGFLAGS) LINKFLAGS = $(LDBGFLAGS)$(PTHREAD_LINK_FLAGS) .c$(OBJ) : $(CC) $(CFLAGS)/INCLUDE=($(CINCLUDE)) $(MMS$SOURCE) $(OBJ)$(OLB) : @ IF F$SEARCH("$(MMS$TARGET)") .EQS. "" - THEN LIBRARY/CREATE/LOG $(MMS$TARGET) @ LIBRARY /REPLACE /LOG $(MMS$TARGET) $(MMS$SOURCE) ASPRINTFOBJ = @ASPRINTFOBJ@ VASPRINTFOBJ = @VASPRINTFOBJ@ STRTOK_ROBJ = @STRTOK_ROBJ@ LIBICONVOBJ = @LIBICONVOBJ@ SNPRINTFOBJ = @SNPRINTFOBJ@ SOCKETPAIROBJ = @SOCKETPAIROBJ@ TDSOBJS = [.src.tds]bulk$(OBJ), [.src.tds]challenge$(OBJ), [.src.tds]config$(OBJ), \ [.src.tds]convert$(OBJ), [.src.tds]data$(OBJ), [.src.tds]des$(OBJ), [.src.tds]getmac$(OBJ), \ [.src.tds]gssapi$(OBJ), [.src.tds]hmac_md5$(OBJ), [.src.tds]iconv$(OBJ), [.src.tds]locale$(OBJ), \ [.src.tds]login$(OBJ), [.src.tds]md4$(OBJ), [.src.tds]mem$(OBJ), [.src.tds]numeric$(OBJ), \ [.src.tds]query$(OBJ), [.src.tds]read$(OBJ), [.src.tds]tdsstring$(OBJ), \ [.src.tds]threadsafe$(OBJ), [.src.tds]token$(OBJ), [.src.tds]util$(OBJ), \ [.src.tds]vstrbuild$(OBJ), [.src.tds]write$(OBJ), [.src.tds]md5$(OBJ), \ [.src.tds]net$(OBJ), [.src.tds]tls$(OBJ), [.src.tds]log$(OBJ), [.src.tds]packet$(OBJ), \ [.src.tds]stream$(OBJ), [.src.tds]random$(OBJ), [.src.tds]sec_negotiate$(OBJ), \ [.src.replacements]strlcpy$(OBJ), [.src.replacements]getpassarg$(OBJ), \ [.src.replacements]sleep$(OBJ), [.src.replacements]strlcat$(OBJ), \ $(ASPRINTFOBJ) $(VASPRINTFOBJ) $(SNPRINTFOBJ) $(STRTOK_ROBJ) $(LIBICONVOBJ) $(SOCKETPAIROBJ) \ [.vms]getpass$(OBJ) CTLIBOBJS = [.src.ctlib]blk$(OBJ), [.src.ctlib]cs$(OBJ), [.src.ctlib]ct$(OBJ), \ [.src.ctlib]ctutil$(OBJ) DBLIBOBJS = [.src.dblib]bcp$(OBJ), [.src.dblib]dblib$(OBJ), [.src.dblib]dbpivot$(OBJ), $(DBOPENOBJ) \ [.src.dblib]dbutil$(OBJ), [.src.dblib]rpc$(OBJ), [.src.dblib]xact$(OBJ) TDSSRVOBJS = [.src.server]query$(OBJ), [.src.server]server$(OBJ), [.src.server]login$(OBJ) TDSPOOLOBJS = [.src.pool]config$(OBJ), [.src.pool]main$(OBJ), [.src.pool]member$(OBJ), \ [.src.pool]user$(OBJ), [.src.pool]util$(OBJ) TDSODBCOBJS = [.src.odbc]connectparams$(OBJ), \ [.src.odbc]convert_tds2sql$(OBJ), [.src.odbc]descriptor$(OBJ), [.src.odbc]error$(OBJ), \ [.src.odbc]native$(OBJ), [.src.odbc]odbc$(OBJ), [.src.odbc]odbc_checks$(OBJ), \ [.src.odbc]odbc_util$(OBJ) [.src.odbc]prepare_query$(OBJ), [.src.odbc]sql2tds$(OBJ) # This is the top-level target all : []libtds$(OLB) []libct$(OLB) []libsybdb$(OLB) []libtdssrv$(OLB) $(TDSODBCSHR) buildchecks apps @ write sys$output " " @ QUALIFIERS := $(MMSQUALIFIERS) @ QUALIFIERS = QUALIFIERS - """" - """" @ write sys$output " " @ write sys$output " Everything is up to date. '$(MMS)''QUALIFIERS' check' to run test suite." # Configuration dependencies CONFIGS = [.include]config.h [.include.freetds]sysconfdir.h [.include]tds_sysdep_public.h \ [.include]readline.h [.include]history.h $(TDSOBJS) : $(CONFIGS) $(CTLIBOBJS) : $(CONFIGS) $(DBLIBOBJS) : $(CONFIGS) $(TDSSRVOBJS) : $(CONFIGS) [.src.pool]config$(OBJ) : [.src.pool]config.c $(CC) $(CFLAGS)/INCLUDE=($(CINCLUDE),[.src.pool]) $(MMS$SOURCE) [.src.pool]main$(OBJ) : [.src.pool]main.c $(CC) $(CFLAGS)/INCLUDE=($(CINCLUDE),[.src.pool]) $(MMS$SOURCE) [.src.pool]member$(OBJ) : [.src.pool]member.c $(CC) $(CFLAGS)/INCLUDE=($(CINCLUDE),[.src.pool]) $(MMS$SOURCE) [.src.pool]stream$(OBJ) : [.src.pool]stream.c $(CC) $(CFLAGS)/INCLUDE=($(CINCLUDE),[.src.pool]) $(MMS$SOURCE) [.src.pool]user$(OBJ) : [.src.pool]user.c $(CC) $(CFLAGS)/INCLUDE=($(CINCLUDE),[.src.pool]) $(MMS$SOURCE) [.src.pool]util$(OBJ) : [.src.pool]util.c $(CC) $(CFLAGS)/INCLUDE=($(CINCLUDE),[.src.pool]) $(MMS$SOURCE) $(TDSPOOLOBJS) : $(CONFIGS) $(TDSODBCOBJS) : $(CONFIGS) [.include]config.h : [.vms]config_h.vms @ write sys$output "Run @[.vms]configure to generate config.h" @ exit [.include.freetds]sysconfdir.h : @ open/write sysconfh [.include.freetds]sysconfdir.h @ write sysconfh "#define FREETDS_SYSCONFDIR ""/FREETDS_ROOT""" @ close sysconfh [.include]tds_sysdep_public.h_in : @ IF F$SEARCH("$(MMS$TARGET)") .EQS. "" THEN COPY [.include]tds_sysdep_public^.h.in $(MMS$TARGET) [.include]tds_sysdep_public.h : [.include]tds_sysdep_public.h_in @ open/write vmsconfigtmp vmsconfigtmp.com @ write vmsconfigtmp "$ define/user_mode/nolog SYS$OUTPUT _NLA0:" @ write vmsconfigtmp "$ edit/tpu/nodisplay/noinitialization -" @ write vmsconfigtmp "/section=sys$library:eve$section.tpu$section -" @ write vmsconfigtmp "/command=sys$input/output=$(MMS$TARGET) $(MMS$SOURCE)" @ write vmsconfigtmp "input_file := GET_INFO (COMMAND_LINE, ""file_name"");" @ write vmsconfigtmp "main_buffer:= CREATE_BUFFER (""main"", input_file);" @ write vmsconfigtmp "POSITION (BEGINNING_OF (main_buffer));" @ write vmsconfigtmp "eve_global_replace(""@tds_sysdep_int16_type@"",""short"");" @ write vmsconfigtmp "POSITION (BEGINNING_OF (main_buffer));" @ write vmsconfigtmp "eve_global_replace(""@tds_sysdep_int32_type@"",""int"");" @ write vmsconfigtmp "POSITION (BEGINNING_OF (main_buffer));" @ write vmsconfigtmp "eve_global_replace(""@tds_sysdep_int64_type@"",""__int64"");" @ write vmsconfigtmp "POSITION (BEGINNING_OF (main_buffer));" @ write vmsconfigtmp "eve_global_replace(""@tds_sysdep_real32_type@"",""float"");" @ write vmsconfigtmp "POSITION (BEGINNING_OF (main_buffer));" @ write vmsconfigtmp "eve_global_replace(""@tds_sysdep_real64_type@"",""double"");" @ write vmsconfigtmp "POSITION (BEGINNING_OF (main_buffer));" @ write vmsconfigtmp "eve_global_replace(""@tds_sysdep_intptr_type@"",""int"");" @ write vmsconfigtmp "POSITION (BEGINNING_OF (main_buffer));" @ write vmsconfigtmp "eve_global_replace(""@dblib_define@"",""#$(DBLIB_DEFINE)"");" @ write vmsconfigtmp "out_file := GET_INFO (COMMAND_LINE, ""output_file"");" @ write vmsconfigtmp "WRITE_FILE (main_buffer, out_file);" @ write vmsconfigtmp "quit;" @ write vmsconfigtmp "$ exit" @ close vmsconfigtmp @ @vmsconfigtmp.com @ delete/noconfirm/nolog vmsconfigtmp.com; [.include]readline.h : @ open/write readlineh $(MMS$TARGET) @ write readlineh "char *readline(char *prompt);" @ write readlineh "int rl_inhibit_completion;" @ write readlineh "/* The following are needed for fisql. */" @ write readlineh "FILE **rl_outstream_get_addr(void);" @ write readlineh "#define rl_outstream (*rl_outstream_get_addr())" @ write readlineh "FILE **rl_instream_get_addr(void);" @ write readlineh "#define rl_instream (*rl_instream_get_addr())" @ write readlineh "static const char *rl_readline_name = NULL;" @ write readlineh "#define rl_bind_key(c,f) do {} while(0)" @ write readlineh "#define rl_reset_line_state() do {} while(0)" @ write readlineh "#define rl_on_new_line() do {} while(0)" @ close readlineh [.include]history.h : @ open/write historyh $(MMS$TARGET) @ write historyh "void add_history(const char *s);" @ close historyh # Work around MMS bug that confuses these with files in different # directories having the same names. [.src.tds]util$(OBJ) : [.src.tds]util.c [.src.tds]log$(OBJ) : [.src.tds]log.c [.src.tds]config$(OBJ) : [.src.tds]config.c [.src.tds]convert$(OBJ) : [.src.tds]convert.c [.src.tds]data$(OBJ) : [.src.tds]data.c [.src.dblib]bcp$(OBJ) : [.src.dblib]bcp.c [.src.dblib]rpc$(OBJ) : [.src.dblib]rpc.c [.src.odbc]error$(OBJ) : [.src.odbc]error.c [.src.tds]login$(OBJ) : [.src.tds]login.c [.src.server]login$(OBJ) : [.src.server]login.c [.src.tds]query$(OBJ) : [.src.tds]query.c [.src.server]query$(OBJ) : [.src.server]query.c # Build the libraries []libtds$(OLB) : libtds$(OLB)( $(TDSOBJS) ) LIBRARY /COMPRESS $(MMS$TARGET) /OUTPUT=$(MMS$TARGET) []libct$(OLB) : libct$(OLB)( $(CTLIBOBJS) ) LIBRARY /COMPRESS $(MMS$TARGET) /OUTPUT=$(MMS$TARGET) []libsybdb$(OLB) : libsybdb$(OLB)( $(DBLIBOBJS) ) LIBRARY /COMPRESS $(MMS$TARGET) /OUTPUT=$(MMS$TARGET) []libtdssrv$(OLB) : libtdssrv$(OLB)( $(TDSSRVOBJS) ) LIBRARY /COMPRESS $(MMS$TARGET) /OUTPUT=$(MMS$TARGET) []libtdsodbc$(OLB) : libtdsodbc$(OLB)( $(TDSODBCOBJS), $(TDSOBJS) ) LIBRARY /COMPRESS $(MMS$TARGET) /OUTPUT=$(MMS$TARGET) $(TDSODBCSHR) : []libtdsodbc$(OLB) link$(LINKFLAGS) $(MMS$SOURCE)/include=odbc/library,[.vms]odbc_driver_axp.opt/options/share=$(MMS$TARGET) # Build the utility programs and the pool server apps : freebcp$(E) tsql$(E) bsqldb$(E) defncopy$(E) tdspool$(E) fisql$(E) @ continue []vmsarg_parse$(OBJ) : [.vms]vmsarg_parse.c $(CC) $(CFLAGS)/INCLUDE=([.vms],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) freebcp$(E) : [.src.apps]freebcp$(OBJ) []vmsarg_mapping_bcp$(OBJ) []vmsarg_command_bcp$(OBJ) []vmsarg_parse$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library, []libtds$(OLB)/library [.src.apps]freebcp$(OBJ) : [.src.apps]freebcp.c []libsybdb$(OLB) []libtds$(OLB) []vmsarg_mapping_bcp$(OBJ) : [.vms]vmsarg_mapping_bcp.c $(CC) $(CFLAGS)/INCLUDE=([.vms],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) []vmsarg_command_bcp$(OBJ) : [.vms]vmsarg_command_bcp.cld SET COMMAND/OBJECT=$(MMS$TARGET) $(MMS$SOURCE) tsql$(E) : [.src.apps]tsql$(OBJ) []libsybdb$(OLB) []libtds$(OLB) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE),[]libsybdb$(OLB)/library, []libtds$(OLB)/library [.src.apps]tsql$(OBJ) : [.src.apps]tsql.c @ define/nolog/user_mode readline [.include] $(CC) $(CFLAGS)/INCLUDE=($(CINCLUDE)) $(MMS$SOURCE) bsqldb$(E) : [.src.apps]bsqldb$(OBJ) []libsybdb$(OLB) []libtds$(OLB) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE),[]libsybdb$(OLB)/library, []libtds$(OLB)/library [.src.apps]bsqldb$(OBJ) : [.src.apps]bsqldb.c defncopy$(E) : [.src.apps]defncopy$(OBJ) []vmsarg_mapping_defncopy$(OBJ) []vmsarg_command_defncopy$(OBJ) []vmsarg_parse$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library, []libtds$(OLB)/library [.src.apps]defncopy$(OBJ) : [.src.apps]defncopy.c []libsybdb$(OLB) []libtds$(OLB) []vmsarg_mapping_defncopy$(OBJ) : [.vms]vmsarg_mapping_defncopy.c $(CC) $(CFLAGS)/INCLUDE=([.vms],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) []vmsarg_command_defncopy$(OBJ) : [.vms]vmsarg_command_defncopy.cld SET COMMAND/OBJECT=$(MMS$TARGET) $(MMS$SOURCE) tdspool$(E) : $(TDSPOOLOBJS) []libtdssrv$(OLB) []libtds$(OLB) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(TDSPOOLOBJS), []libtdssrv$(OLB)/library, []libtds$(OLB)/library fisql$(E) : [.src.apps.fisql]fisql$(OBJ) [.src.apps.fisql]interrupt$(OBJ) [.src.apps.fisql]handlers$(OBJ) [.vms]edit$(OBJ) \ []vmsarg_mapping_isql$(OBJ) []vmsarg_command_isql$(OBJ) []vmsarg_parse$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library, []libtds$(OLB)/library [.src.apps.fisql]fisql$(OBJ) : [.src.apps.fisql]fisql.c []libsybdb$(OLB) []libtds$(OLB) @ define/nolog/user_mode readline [.include] $(CC) $(CFLAGS)/INCLUDE=($(CINCLUDE)) $(MMS$SOURCE) [.src.apps.fisql]interrupt$(OBJ) : [.src.apps.fisql]interrupt.c [.src.apps.fisql]handlers$(OBJ) : [.src.apps.fisql]handlers.c []vmsarg_mapping_isql$(OBJ) : [.vms]vmsarg_mapping_isql.c $(CC) $(CFLAGS)/INCLUDE=([.vms],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) []vmsarg_command_isql$(OBJ) : [.vms]vmsarg_command_isql.cld SET COMMAND/OBJECT=$(MMS$TARGET) $(MMS$SOURCE) # Run the test suite check : buildchecks PWD libtdscheck ctlibcheck dblibcheck $(tdsodbccheck) @ write sys$output "" @ write sys$output "Test run complete. PWD : PWD.in copy $(MMS$SOURCE) $(MMS$TARGET). libtdscheck : @ set default [.src.tds.unittests] @ define/nolog FREETDSCONF [---]freetds.conf @ run/nodebug []dynamic1$(E) @ run/nodebug []iconv_fread$(E) @ run/nodebug []numeric$(E) @ run/nodebug []t0001$(E) @ run/nodebug []t0002$(E) @ run/nodebug []t0003$(E) @ run/nodebug []t0004$(E) @ run/nodebug []t0005$(E) @ run/nodebug []t0006$(E) @ run/nodebug []t0007$(E) @ run/nodebug []t0008$(E) @ run/nodebug []convert$(E) @ run/nodebug []dataread$(E) @ run/nodebug []utf8_1$(E) @ run/nodebug []utf8_2$(E) @ run/nodebug []utf8_3$(E) @ run/nodebug []toodynamic$(E) @ set default [---] ctlibcheck : @ set default [.src.ctlib.unittests] @ define/nolog FREETDSCONF [---]freetds.conf @ run/nodebug []t0001$(E) @ run/nodebug []t0002$(E) @ run/nodebug []t0003$(E) @ run/nodebug []t0004$(E) @ run/nodebug []t0005$(E) @ run/nodebug []t0006$(E) @ run/nodebug []t0007$(E) @ run/nodebug []t0008$(E) @ run/nodebug []t0009$(E) @ run/nodebug []connect_fail$(E) @ run/nodebug []ct_options$(E) @ run/nodebug []lang_ct_param$(E) @ run/nodebug []array_bind$(E) @ run/nodebug []cs_diag$(E) @ run/nodebug []get_send_data$(E) @ run/nodebug []rpc_ct_param$(E) @ run/nodebug []rpc_ct_setparam$(E) @ run/nodebug []ct_diagclient$(E) @ run/nodebug []ct_diagserver$(E) @ run/nodebug []ct_diagall$(E) @ run/nodebug []cs_config$(E) @ run/nodebug []cancel$(E) @ run/nodebug []blk_in$(E) @ run/nodebug []blk_out$(E) @ run/nodebug []ct_cursor$(E) @ run/nodebug []ct_cursors$(E) @ run/nodebug []ct_dynamic$(E) @ run/nodebug []blk_in2$(E) @ run/nodebug []datafmt$(E) @ set default [---] dblibcheck : @ set default [.src.dblib.unittests] @ define/nolog FREETDSCONF [---]freetds.conf @ run/nodebug []t0001$(E) @ run/nodebug []t0002$(E) @ run/nodebug []t0003$(E) @ run/nodebug []t0004$(E) @ run/nodebug []t0005$(E) @ run/nodebug []t0006$(E) @ run/nodebug []t0007$(E) @ run/nodebug []t0008$(E) @ run/nodebug []t0009$(E) @ run/nodebug []t0011$(E) @ run/nodebug []t0012$(E) @ run/nodebug []t0013$(E) @ run/nodebug []t0014$(E) @ run/nodebug []t0015$(E) @ run/nodebug []t0016$(E) @ run/nodebug []t0017$(E) @ run/nodebug []t0018$(E) @ run/nodebug []t0019$(E) @ run/nodebug []t0020$(E) @ run/nodebug []t0021$(E) @ run/nodebug []t0022$(E) @ run/nodebug []t0023$(E) @ run/nodebug []rpc$(E) @ run/nodebug []dbmorecmds$(E) @ run/nodebug []bcp$(E) @ run/nodebug []thread$(E) @ run/nodebug []text_buffer$(E) @ run/nodebug []done_handling$(E) @ run/nodebug []timeout$(E) @ run/nodebug []hang$(E) @ run/nodebug []null$(E) @ run/nodebug []null2$(E) @ run/nodebug []setnull$(E) @ run/nodebug []numeric$(E) @ run/nodebug []pending$(E) @ run/nodebug []cancel$(E) @ set default [---] tdsodbccheck : @ set default [.src.odbc.unittests] @ define/nolog FREETDSCONF [---]freetds.conf @ define/nolog ODBCINI SYS$DISK:[]ODBC.INI @ define/nolog ODBCSYSINI SYS$DISK:[] @ create/directory [-._libs] @ copy [---]libtdsodbc$(E) [-._libs] @ run/nodebug []t0001$(E) @ run/nodebug []t0002$(E) @ run/nodebug []t0003$(E) @ run/nodebug []t0004$(E) @ run/nodebug []connect$(E) @ run/nodebug []print$(E) @ run/nodebug []date$(E) @ run/nodebug []norowset$(E) @ run/nodebug []funccall$(E) @ run/nodebug []lang_error$(E) @ run/nodebug []tables$(E) @ run/nodebug []binary_test$(E) @ run/nodebug []moreandcount$(E) @ run/nodebug []earlybind$(E) @ run/nodebug []putdata$(E) @ run/nodebug []params$(E) @ run/nodebug []raiserror$(E) @ run/nodebug []getdata$(E) @ run/nodebug []transaction$(E) @ run/nodebug []type$(E) @ run/nodebug []genparams$(E) @ run/nodebug []preperror$(E) @ run/nodebug []prepare_results$(E) @ run/nodebug []testodbc$(E) @ run/nodebug []data$(E) @ run/nodebug []error$(E) @ run/nodebug []rebindpar$(E) @ run/nodebug []rpc$(E) @ run/nodebug []convert_error$(E) @ run/nodebug []typeinfo$(E) @ run/nodebug []const_params$(E) @ run/nodebug []insert_speed$(E) @ run/nodebug []compute$(E) @ run/nodebug []timeout$(E) @ run/nodebug []array$(E) @ run/nodebug []array_out$(E) @ run/nodebug []cursor1$(E) @ run/nodebug []scroll$(E) @ run/nodebug []cursor2$(E) @ run/nodebug []describecol$(E) @ run/nodebug []copydesc$(E) @ run/nodebug []prepclose$(E) @ run/nodebug []warning$(E) @ run/nodebug []paramcore$(E) @ run/nodebug []timeout2$(E) @ run/nodebug []timeout3$(E) @ run/nodebug []connect2$(E) @ run/nodebug []timeout4$(E) @ run/nodebug []freeclose$(E) @ run/nodebug []cursor3$(E) @ run/nodebug []cursor4$(E) @ run/nodebug []cursor5$(E) @ run/nodebug []attributes$(E) @ run/nodebug []hidden$(E) @ run/nodebug []blob1$(E) @ run/nodebug []cancel$(E) @ run/nodebug []wchar$(E) @ run/nodebug []rowset$(E) @ run/nodebug []transaction2$(E) @ set default [---] buildchecks : libtdstests ctlibtests dblibtests $(ODBCTESTS) @ continue libtdstests : [.src.tds.unittests]dynamic1$(E) [.src.tds.unittests]iconv_fread$(E) \ [.src.tds.unittests]numeric$(E) [.src.tds.unittests]t0001$(E) [.src.tds.unittests]t0002$(E) \ [.src.tds.unittests]t0003$(E) [.src.tds.unittests]t0004$(E) [.src.tds.unittests]t0005$(E) \ [.src.tds.unittests]t0006$(E) [.src.tds.unittests]t0007$(E) [.src.tds.unittests]t0008$(E) \ [.src.tds.unittests]convert$(E) [.src.tds.unittests]dataread$(E) \ [.src.tds.unittests]utf8_1$(E) [.src.tds.unittests]utf8_2$(E) [.src.tds.unittests]utf8_3$(E) \ [.src.tds.unittests]toodynamic$(E) @ continue ctlibtests : [.src.ctlib.unittests]t0001$(E) [.src.ctlib.unittests]t0002$(E) [.src.ctlib.unittests]t0003$(E) \ [.src.ctlib.unittests]t0004$(E) [.src.ctlib.unittests]t0005$(E) [.src.ctlib.unittests]t0006$(E) \ [.src.ctlib.unittests]t0007$(E) [.src.ctlib.unittests]t0008$(E) [.src.ctlib.unittests]t0009$(E) \ [.src.ctlib.unittests]connect_fail$(E) [.src.ctlib.unittests]ct_options$(E) \ [.src.ctlib.unittests]lang_ct_param$(E) [.src.ctlib.unittests]array_bind$(E) \ [.src.ctlib.unittests]cs_diag$(E) [.src.ctlib.unittests]get_send_data$(E) \ [.src.ctlib.unittests]rpc_ct_param$(E) [.src.ctlib.unittests]rpc_ct_setparam$(E) \ [.src.ctlib.unittests]ct_diagclient$(E) [.src.ctlib.unittests]ct_diagserver$(E) \ [.src.ctlib.unittests]ct_diagall$(E) [.src.ctlib.unittests]cs_config$(E) \ [.src.ctlib.unittests]cancel$(E) [.src.ctlib.unittests]blk_in$(E) \ [.src.ctlib.unittests]blk_out$(E) [.src.ctlib.unittests]ct_cursor$(E) \ [.src.ctlib.unittests]ct_cursors$(E) [.src.ctlib.unittests]ct_dynamic$(E) \ [.src.ctlib.unittests]blk_in2$(E) [.src.ctlib.unittests]datafmt$(E) @ continue dblibtests : [.src.dblib.unittests]rpc$(E) [.src.dblib.unittests]t0001$(E) [.src.dblib.unittests]t0002$(E) \ [.src.dblib.unittests]t0003$(E) [.src.dblib.unittests]t0004$(E) [.src.dblib.unittests]t0005$(E) \ [.src.dblib.unittests]t0006$(E) [.src.dblib.unittests]t0007$(E) [.src.dblib.unittests]t0008$(E) \ [.src.dblib.unittests]t0009$(E) [.src.dblib.unittests]t0011$(E) \ [.src.dblib.unittests]t0012$(E) [.src.dblib.unittests]t0013$(E) [.src.dblib.unittests]t0014$(E) \ [.src.dblib.unittests]t0015$(E) [.src.dblib.unittests]t0016$(E) [.src.dblib.unittests]t0017$(E) \ [.src.dblib.unittests]t0018$(E) [.src.dblib.unittests]t0019$(E) [.src.dblib.unittests]t0020$(E) \ [.src.dblib.unittests]t0021$(E) [.src.dblib.unittests]t0022$(E) [.src.dblib.unittests]t0023$(E) \ [.src.dblib.unittests]dbmorecmds$(E) [.src.dblib.unittests]bcp$(E) \ [.src.dblib.unittests]thread$(E) [.src.dblib.unittests]text_buffer$(E) \ [.src.dblib.unittests]done_handling$(E) [.src.dblib.unittests]timeout$(E) \ [.src.dblib.unittests]hang$(E) [.src.dblib.unittests]null$(E) \ [.src.dblib.unittests]null2$(E) [.src.dblib.unittests]setnull$(E) \ [.src.dblib.unittests]numeric$(E) [.src.dblib.unittests]pending$(E) \ [.src.dblib.unittests]cancel$(E) @ continue odbctests : [.src.odbc.unittests]t0001$(E) [.src.odbc.unittests]t0002$(E) [.src.odbc.unittests]t0003$(E) \ [.src.odbc.unittests]t0004$(E) [.src.odbc.unittests]connect$(E) [.src.odbc.unittests]print$(E) \ [.src.odbc.unittests]date$(E) [.src.odbc.unittests]norowset$(E) [.src.odbc.unittests]funccall$(E) \ [.src.odbc.unittests]lang_error$(E) [.src.odbc.unittests]tables$(E) \ [.src.odbc.unittests]binary_test$(E) [.src.odbc.unittests]moreandcount$(E) \ [.src.odbc.unittests]earlybind$(E) [.src.odbc.unittests]putdata$(E) [.src.odbc.unittests]params$(E) \ [.src.odbc.unittests]raiserror$(E) [.src.odbc.unittests]getdata$(E) [.src.odbc.unittests]type$(E) \ [.src.odbc.unittests]transaction$(E) [.src.odbc.unittests]genparams$(E) [.src.odbc.unittests]preperror$(E) \ [.src.odbc.unittests]prepare_results$(E) [.src.odbc.unittests]testodbc$(E) \ [.src.odbc.unittests]data$(E) [.src.odbc.unittests]error$(E) [.src.odbc.unittests]rebindpar$(E) \ [.src.odbc.unittests]rpc$(E) [.src.odbc.unittests]convert_error$(E) [.src.odbc.unittests]typeinfo$(E) \ [.src.odbc.unittests]const_params$(E) [.src.odbc.unittests]insert_speed$(E) \ [.src.odbc.unittests]compute$(E) [.src.odbc.unittests]timeout$(E) \ [.src.odbc.unittests]array$(E) [.src.odbc.unittests]array_out$(E) \ [.src.odbc.unittests]cursor1$(E) [.src.odbc.unittests]scroll$(E) [.src.odbc.unittests]cursor2$(E) \ [.src.odbc.unittests]describecol$(E) [.src.odbc.unittests]copydesc$(E) \ [.src.odbc.unittests]prepclose$(E) [.src.odbc.unittests]warning$(E) \ [.src.odbc.unittests]paramcore$(E) [.src.odbc.unittests]timeout2$(E) [.src.odbc.unittests]timeout3$(E) \ [.src.odbc.unittests]connect2$(E) [.src.odbc.unittests]timeout4$(E) [.src.odbc.unittests]freeclose$(E) \ [.src.odbc.unittests]cursor3$(E) [.src.odbc.unittests]cursor4$(E) [.src.odbc.unittests]cursor5$(E) \ [.src.odbc.unittests]attributes$(E) [.src.odbc.unittests]hidden$(E) [.src.odbc.unittests]blob1$(E) \ [.src.odbc.unittests]cancel$(E) [.src.odbc.unittests]wchar$(E) [.src.odbc.unittests]rowset$(E) \ [.src.odbc.unittests]transaction2$(E) @ continue # libtds test detailed dependencies [.src.tds.unittests]dynamic1$(E) : [.src.tds.unittests]dynamic1$(OBJ) [.src.tds.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libtds$(OLB)/library [.src.tds.unittests]dynamic1$(OBJ) : [.src.tds.unittests]dynamic1.c [.src.tds.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.tds.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.tds.unittests]iconv_fread$(E) : [.src.tds.unittests]iconv_fread$(OBJ) [.src.tds.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libtds$(OLB)/library [.src.tds.unittests]iconv_fread$(OBJ) : [.src.tds.unittests]iconv_fread.c [.src.tds.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.tds.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.tds.unittests]numeric$(E) : [.src.tds.unittests]numeric$(OBJ) [.src.tds.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libtds$(OLB)/library [.src.tds.unittests]numeric$(OBJ) : [.src.tds.unittests]numeric.c [.src.tds.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.tds.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.tds.unittests]t0001$(E) : [.src.tds.unittests]t0001$(OBJ) [.src.tds.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libtds$(OLB)/library [.src.tds.unittests]t0001$(OBJ) : [.src.tds.unittests]t0001.c [.src.tds.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.tds.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.tds.unittests]t0002$(E) : [.src.tds.unittests]t0002$(OBJ) [.src.tds.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libtds$(OLB)/library [.src.tds.unittests]t0002$(OBJ) : [.src.tds.unittests]t0002.c [.src.tds.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.tds.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.tds.unittests]t0003$(E) : [.src.tds.unittests]t0003$(OBJ) [.src.tds.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libtds$(OLB)/library [.src.tds.unittests]t0003$(OBJ) : [.src.tds.unittests]t0003.c [.src.tds.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.tds.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.tds.unittests]t0004$(E) : [.src.tds.unittests]t0004$(OBJ) [.src.tds.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libtds$(OLB)/library [.src.tds.unittests]t0004$(OBJ) : [.src.tds.unittests]t0004.c [.src.tds.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.tds.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.tds.unittests]t0005$(E) : [.src.tds.unittests]t0005$(OBJ) [.src.tds.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libtds$(OLB)/library [.src.tds.unittests]t0005$(OBJ) : [.src.tds.unittests]t0005.c [.src.tds.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.tds.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.tds.unittests]t0006$(E) : [.src.tds.unittests]t0006$(OBJ) [.src.tds.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libtds$(OLB)/library [.src.tds.unittests]t0006$(OBJ) : [.src.tds.unittests]t0006.c [.src.tds.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.tds.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.tds.unittests]t0007$(E) : [.src.tds.unittests]t0007$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libtds$(OLB)/library [.src.tds.unittests]t0007$(OBJ) : [.src.tds.unittests]t0007.c $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.tds.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.tds.unittests]t0008$(E) : [.src.tds.unittests]t0008$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libtds$(OLB)/library [.src.tds.unittests]t0008$(OBJ) : [.src.tds.unittests]t0008.c $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.tds.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.tds.unittests]common$(OBJ) : [.src.tds.unittests]common.c [.src.tds.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.tds.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.tds.unittests]convert$(E) : [.src.tds.unittests]convert$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libtds$(OLB)/library [.src.tds.unittests]convert$(OBJ) : [.src.tds.unittests]convert.c $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.tds.unittests],$(CINCLUDE),[.src.tds]) $(CDBGFLAGS) $(MMS$SOURCE) [.src.tds.unittests]dataread$(E) : [.src.tds.unittests]dataread$(OBJ) [.src.tds.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libtds$(OLB)/library [.src.tds.unittests]dataread$(OBJ) : [.src.tds.unittests]dataread.c $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.tds.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.tds.unittests]utf8$(OBJ) : [.src.tds.unittests]utf8.c $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.tds.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.tds.unittests]utf8_1$(E) : [.src.tds.unittests]utf8_1$(OBJ) [.src.tds.unittests]common$(OBJ) [.src.tds.unittests]utf8$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libtds$(OLB)/library [.src.tds.unittests]utf8_1$(OBJ) : [.src.tds.unittests]utf8_1.c $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.tds.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.tds.unittests]utf8_2$(E) : [.src.tds.unittests]utf8_2$(OBJ) [.src.tds.unittests]common$(OBJ) [.src.tds.unittests]utf8$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libtds$(OLB)/library [.src.tds.unittests]utf8_2$(OBJ) : [.src.tds.unittests]utf8_2.c $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.tds.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.tds.unittests]utf8_3$(E) : [.src.tds.unittests]utf8_3$(OBJ) [.src.tds.unittests]common$(OBJ) [.src.tds.unittests]utf8$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libtds$(OLB)/library [.src.tds.unittests]utf8_3$(OBJ) : [.src.tds.unittests]utf8_3.c $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.tds.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.tds.unittests]toodynamic$(E) : [.src.tds.unittests]toodynamic$(OBJ) [.src.tds.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libtds$(OLB)/library [.src.tds.unittests]toodynamic$(OBJ) : [.src.tds.unittests]toodynamic.c $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.tds.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) # ctlib test detailed dependencies [.src.ctlib.unittests]t0001$(E) : [.src.ctlib.unittests]t0001$(OBJ) [.src.ctlib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libct$(OLB)/library,[]libtds$(OLB)/library [.src.ctlib.unittests]t0001$(OBJ) : [.src.ctlib.unittests]t0001.c [.src.ctlib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.ctlib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.ctlib.unittests]t0002$(E) : [.src.ctlib.unittests]t0002$(OBJ) [.src.ctlib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libct$(OLB)/library,[]libtds$(OLB)/library [.src.ctlib.unittests]t0002$(OBJ) : [.src.ctlib.unittests]t0002.c [.src.ctlib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.ctlib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.ctlib.unittests]t0003$(E) : [.src.ctlib.unittests]t0003$(OBJ) [.src.ctlib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libct$(OLB)/library,[]libtds$(OLB)/library [.src.ctlib.unittests]t0003$(OBJ) : [.src.ctlib.unittests]t0003.c [.src.ctlib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.ctlib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.ctlib.unittests]t0004$(E) : [.src.ctlib.unittests]t0004$(OBJ) [.src.ctlib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libct$(OLB)/library,[]libtds$(OLB)/library [.src.ctlib.unittests]t0004$(OBJ) : [.src.ctlib.unittests]t0004.c [.src.ctlib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.ctlib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.ctlib.unittests]t0005$(E) : [.src.ctlib.unittests]t0005$(OBJ) [.src.ctlib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libct$(OLB)/library,[]libtds$(OLB)/library [.src.ctlib.unittests]t0005$(OBJ) : [.src.ctlib.unittests]t0005.c [.src.ctlib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.ctlib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.ctlib.unittests]t0006$(E) : [.src.ctlib.unittests]t0006$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libct$(OLB)/library,[]libtds$(OLB)/library [.src.ctlib.unittests]t0006$(OBJ) : [.src.ctlib.unittests]t0006.c $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.ctlib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.ctlib.unittests]t0007$(E) : [.src.ctlib.unittests]t0007$(OBJ) [.src.ctlib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libct$(OLB)/library,[]libtds$(OLB)/library [.src.ctlib.unittests]t0007$(OBJ) : [.src.ctlib.unittests]t0007.c [.src.ctlib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.ctlib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.ctlib.unittests]t0008$(E) : [.src.ctlib.unittests]t0008$(OBJ) [.src.ctlib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libct$(OLB)/library,[]libtds$(OLB)/library [.src.ctlib.unittests]t0008$(OBJ) : [.src.ctlib.unittests]t0008.c [.src.ctlib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.ctlib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.ctlib.unittests]t0009$(E) : [.src.ctlib.unittests]t0009$(OBJ) [.src.ctlib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libct$(OLB)/library,[]libtds$(OLB)/library [.src.ctlib.unittests]t0009$(OBJ) : [.src.ctlib.unittests]t0009.c [.src.ctlib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.ctlib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.ctlib.unittests]connect_fail$(E) : [.src.ctlib.unittests]connect_fail$(OBJ) [.src.ctlib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libct$(OLB)/library,[]libtds$(OLB)/library [.src.ctlib.unittests]connect_fail$(OBJ) : [.src.ctlib.unittests]connect_fail.c [.src.ctlib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.ctlib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.ctlib.unittests]ct_options$(E) : [.src.ctlib.unittests]ct_options$(OBJ) [.src.ctlib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libct$(OLB)/library,[]libtds$(OLB)/library [.src.ctlib.unittests]ct_options$(OBJ) : [.src.ctlib.unittests]ct_options.c [.src.ctlib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.ctlib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.ctlib.unittests]lang_ct_param$(E) : [.src.ctlib.unittests]lang_ct_param$(OBJ) [.src.ctlib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libct$(OLB)/library,[]libtds$(OLB)/library [.src.ctlib.unittests]lang_ct_param$(OBJ) : [.src.ctlib.unittests]lang_ct_param.c [.src.ctlib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.ctlib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.ctlib.unittests]array_bind$(E) : [.src.ctlib.unittests]array_bind$(OBJ) [.src.ctlib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libct$(OLB)/library,[]libtds$(OLB)/library [.src.ctlib.unittests]array_bind$(OBJ) : [.src.ctlib.unittests]array_bind.c [.src.ctlib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.ctlib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.ctlib.unittests]cs_diag$(E) : [.src.ctlib.unittests]cs_diag$(OBJ) [.src.ctlib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libct$(OLB)/library,[]libtds$(OLB)/library [.src.ctlib.unittests]cs_diag$(OBJ) : [.src.ctlib.unittests]cs_diag.c [.src.ctlib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.ctlib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.ctlib.unittests]get_send_data$(E) : [.src.ctlib.unittests]get_send_data$(OBJ) [.src.ctlib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libct$(OLB)/library,[]libtds$(OLB)/library [.src.ctlib.unittests]get_send_data$(OBJ) : [.src.ctlib.unittests]get_send_data.c [.src.ctlib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.ctlib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.ctlib.unittests]rpc_ct_param$(E) : [.src.ctlib.unittests]rpc_ct_param$(OBJ) [.src.ctlib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libct$(OLB)/library,[]libtds$(OLB)/library [.src.ctlib.unittests]rpc_ct_param$(OBJ) : [.src.ctlib.unittests]rpc_ct_param.c [.src.ctlib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.ctlib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.ctlib.unittests]rpc_ct_setparam$(E) : [.src.ctlib.unittests]rpc_ct_setparam$(OBJ) [.src.ctlib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libct$(OLB)/library,[]libtds$(OLB)/library [.src.ctlib.unittests]rpc_ct_setparam$(OBJ) : [.src.ctlib.unittests]rpc_ct_setparam.c [.src.ctlib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.ctlib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.ctlib.unittests]ct_diagclient$(E) : [.src.ctlib.unittests]ct_diagclient$(OBJ) [.src.ctlib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libct$(OLB)/library,[]libtds$(OLB)/library [.src.ctlib.unittests]ct_diagclient$(OBJ) : [.src.ctlib.unittests]ct_diagclient.c [.src.ctlib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.ctlib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.ctlib.unittests]ct_diagserver$(E) : [.src.ctlib.unittests]ct_diagserver$(OBJ) [.src.ctlib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libct$(OLB)/library,[]libtds$(OLB)/library [.src.ctlib.unittests]ct_diagserver$(OBJ) : [.src.ctlib.unittests]ct_diagserver.c [.src.ctlib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.ctlib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.ctlib.unittests]ct_diagall$(E) : [.src.ctlib.unittests]ct_diagall$(OBJ) [.src.ctlib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libct$(OLB)/library,[]libtds$(OLB)/library [.src.ctlib.unittests]ct_diagall$(OBJ) : [.src.ctlib.unittests]ct_diagall.c [.src.ctlib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.ctlib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.ctlib.unittests]cs_config$(E) : [.src.ctlib.unittests]cs_config$(OBJ) [.src.ctlib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libct$(OLB)/library,[]libtds$(OLB)/library [.src.ctlib.unittests]cs_config$(OBJ) : [.src.ctlib.unittests]cs_config.c [.src.ctlib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.ctlib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.ctlib.unittests]cancel$(E) : [.src.ctlib.unittests]cancel$(OBJ) [.src.ctlib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libct$(OLB)/library,[]libtds$(OLB)/library [.src.ctlib.unittests]cancel$(OBJ) : [.src.ctlib.unittests]cancel.c [.src.ctlib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.ctlib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.ctlib.unittests]blk_in$(E) : [.src.ctlib.unittests]blk_in$(OBJ) [.src.ctlib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libct$(OLB)/library,[]libtds$(OLB)/library [.src.ctlib.unittests]blk_in$(OBJ) : [.src.ctlib.unittests]blk_in.c [.src.ctlib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.ctlib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.ctlib.unittests]blk_out$(E) : [.src.ctlib.unittests]blk_out$(OBJ) [.src.ctlib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libct$(OLB)/library,[]libtds$(OLB)/library [.src.ctlib.unittests]blk_out$(OBJ) : [.src.ctlib.unittests]blk_out.c [.src.ctlib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.ctlib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.ctlib.unittests]ct_cursor$(E) : [.src.ctlib.unittests]ct_cursor$(OBJ) [.src.ctlib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libct$(OLB)/library,[]libtds$(OLB)/library [.src.ctlib.unittests]ct_cursor$(OBJ) : [.src.ctlib.unittests]ct_cursor.c [.src.ctlib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.ctlib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.ctlib.unittests]ct_cursors$(E) : [.src.ctlib.unittests]ct_cursors$(OBJ) [.src.ctlib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libct$(OLB)/library,[]libtds$(OLB)/library [.src.ctlib.unittests]ct_cursors$(OBJ) : [.src.ctlib.unittests]ct_cursors.c [.src.ctlib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.ctlib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.ctlib.unittests]ct_dynamic$(E) : [.src.ctlib.unittests]ct_dynamic$(OBJ) [.src.ctlib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libct$(OLB)/library,[]libtds$(OLB)/library [.src.ctlib.unittests]ct_dynamic$(OBJ) : [.src.ctlib.unittests]ct_dynamic.c [.src.ctlib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.ctlib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.ctlib.unittests]blk_in2$(E) : [.src.ctlib.unittests]blk_in2$(OBJ) [.src.ctlib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libct$(OLB)/library,[]libtds$(OLB)/library [.src.ctlib.unittests]blk_in2$(OBJ) : [.src.ctlib.unittests]blk_in2.c [.src.ctlib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.ctlib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.ctlib.unittests]datafmt$(E) : [.src.ctlib.unittests]datafmt$(OBJ) [.src.ctlib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libct$(OLB)/library,[]libtds$(OLB)/library [.src.ctlib.unittests]datafmt$(OBJ) : [.src.ctlib.unittests]datafmt.c [.src.ctlib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.ctlib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.ctlib.unittests]common$(OBJ) : [.src.ctlib.unittests]common.c [.src.ctlib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.ctlib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) # dblib test detailed dependencies [.src.dblib.unittests]t0001$(E) : [.src.dblib.unittests]t0001$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]t0001$(OBJ) : [.src.dblib.unittests]t0001.c [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]t0002$(E) : [.src.dblib.unittests]t0002$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]t0002$(OBJ) : [.src.dblib.unittests]t0002.c [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]t0003$(E) : [.src.dblib.unittests]t0003$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]t0003$(OBJ) : [.src.dblib.unittests]t0003.c [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]t0004$(E) : [.src.dblib.unittests]t0004$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]t0004$(OBJ) : [.src.dblib.unittests]t0004.c [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]t0005$(E) : [.src.dblib.unittests]t0005$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]t0005$(OBJ) : [.src.dblib.unittests]t0005.c [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]t0006$(E) : [.src.dblib.unittests]t0006$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]t0006$(OBJ) : [.src.dblib.unittests]t0006.c [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]t0007$(E) : [.src.dblib.unittests]t0007$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]t0007$(OBJ) : [.src.dblib.unittests]t0007.c [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]t0008$(E) : [.src.dblib.unittests]t0008$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]t0008$(OBJ) : [.src.dblib.unittests]t0008.c [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]t0009$(E) : [.src.dblib.unittests]t0009$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]t0009$(OBJ) : [.src.dblib.unittests]t0009.c [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]t0011$(E) : [.src.dblib.unittests]t0011$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]t0011$(OBJ) : [.src.dblib.unittests]t0011.c [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]t0012$(E) : [.src.dblib.unittests]t0012$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]t0012$(OBJ) : [.src.dblib.unittests]t0012.c [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]t0013$(E) : [.src.dblib.unittests]t0013$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]t0013$(OBJ) : [.src.dblib.unittests]t0013.c [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]t0014$(E) : [.src.dblib.unittests]t0014$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]t0014$(OBJ) : [.src.dblib.unittests]t0014.c [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]t0015$(E) : [.src.dblib.unittests]t0015$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]t0015$(OBJ) : [.src.dblib.unittests]t0015.c [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]t0016$(E) : [.src.dblib.unittests]t0016$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]t0016$(OBJ) : [.src.dblib.unittests]t0016.c [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]t0017$(E) : [.src.dblib.unittests]t0017$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]t0017$(OBJ) : [.src.dblib.unittests]t0017.c [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]t0018$(E) : [.src.dblib.unittests]t0018$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]t0018$(OBJ) : [.src.dblib.unittests]t0018.c [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]t0019$(E) : [.src.dblib.unittests]t0019$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]t0019$(OBJ) : [.src.dblib.unittests]t0019.c [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]t0020$(E) : [.src.dblib.unittests]t0020$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]t0020$(OBJ) : [.src.dblib.unittests]t0020.c [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]t0021$(E) : [.src.dblib.unittests]t0021$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]t0021$(OBJ) : [.src.dblib.unittests]t0021.c [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]t0022$(E) : [.src.dblib.unittests]t0022$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]t0022$(OBJ) : [.src.dblib.unittests]t0022.c [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]t0023$(E) : [.src.dblib.unittests]t0023$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]t0023$(OBJ) : [.src.dblib.unittests]t0023.c [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]rpc$(E) : [.src.dblib.unittests]rpc$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]rpc$(OBJ) : [.src.dblib.unittests]rpc.c [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]dbmorecmds$(E) : [.src.dblib.unittests]dbmorecmds$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]dbmorecmds$(OBJ) : [.src.dblib.unittests]dbmorecmds.c [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]bcp$(E) : [.src.dblib.unittests]bcp$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]bcp$(OBJ) : [.src.dblib.unittests]bcp.c [.src.dblib.unittests]bcp.h [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]thread$(E) : [.src.dblib.unittests]thread$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]thread$(OBJ) : [.src.dblib.unittests]thread.c [.src.dblib.unittests]bcp.h [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]text_buffer$(E) : [.src.dblib.unittests]text_buffer$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]text_buffer$(OBJ) : [.src.dblib.unittests]text_buffer.c [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]done_handling$(E) : [.src.dblib.unittests]done_handling$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]done_handling$(OBJ) : [.src.dblib.unittests]done_handling.c [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]timeout$(E) : [.src.dblib.unittests]timeout$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]timeout$(OBJ) : [.src.dblib.unittests]timeout.c [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]hang$(E) : [.src.dblib.unittests]hang$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]hang$(OBJ) : [.src.dblib.unittests]hang.c [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]null$(E) : [.src.dblib.unittests]null$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]null$(OBJ) : [.src.dblib.unittests]null.c [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]null2$(E) : [.src.dblib.unittests]null2$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]null2$(OBJ) : [.src.dblib.unittests]null2.c [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]setnull$(E) : [.src.dblib.unittests]setnull$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]setnull$(OBJ) : [.src.dblib.unittests]setnull.c [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]numeric$(E) : [.src.dblib.unittests]numeric$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]numeric$(OBJ) : [.src.dblib.unittests]numeric.c [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]common$(OBJ) : [.src.dblib.unittests]common.c [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]pending$(E) : [.src.dblib.unittests]pending$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]pending$(OBJ) : [.src.dblib.unittests]pending.c [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.dblib.unittests]cancel$(E) : [.src.dblib.unittests]cancel$(OBJ) [.src.dblib.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[]libsybdb$(OLB)/library,[]libtds$(OLB)/library [.src.dblib.unittests]cancel$(OBJ) : [.src.dblib.unittests]cancel.c [.src.dblib.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.dblib.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) # tdsodbc test detailed dependencies [.src.odbc.unittests]t0001$(E) : [.src.odbc.unittests]t0001$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]t0001$(OBJ) : [.src.odbc.unittests]t0001.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]t0002$(E) : [.src.odbc.unittests]t0002$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]t0002$(OBJ) : [.src.odbc.unittests]t0002.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]t0003$(E) : [.src.odbc.unittests]t0003$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]t0003$(OBJ) : [.src.odbc.unittests]t0003.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]t0004$(E) : [.src.odbc.unittests]t0004$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]t0004$(OBJ) : [.src.odbc.unittests]t0004.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]connect$(E) : [.src.odbc.unittests]connect$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]connect$(OBJ) : [.src.odbc.unittests]connect.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]print$(E) : [.src.odbc.unittests]print$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]print$(OBJ) : [.src.odbc.unittests]print.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]date$(E) : [.src.odbc.unittests]date$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]date$(OBJ) : [.src.odbc.unittests]date.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]norowset$(E) : [.src.odbc.unittests]norowset$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]norowset$(OBJ) : [.src.odbc.unittests]norowset.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]funccall$(E) : [.src.odbc.unittests]funccall$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]funccall$(OBJ) : [.src.odbc.unittests]funccall.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]lang_error$(E) : [.src.odbc.unittests]lang_error$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]lang_error$(OBJ) : [.src.odbc.unittests]lang_error.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]tables$(E) : [.src.odbc.unittests]tables$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]tables$(OBJ) : [.src.odbc.unittests]tables.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]binary_test$(E) : [.src.odbc.unittests]binary_test$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]binary_test$(OBJ) : [.src.odbc.unittests]binary_test.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]moreandcount$(E) : [.src.odbc.unittests]moreandcount$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]moreandcount$(OBJ) : [.src.odbc.unittests]moreandcount.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]earlybind$(E) : [.src.odbc.unittests]earlybind$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]earlybind$(OBJ) : [.src.odbc.unittests]earlybind.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]putdata$(E) : [.src.odbc.unittests]putdata$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]putdata$(OBJ) : [.src.odbc.unittests]putdata.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]params$(E) : [.src.odbc.unittests]params$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]params$(OBJ) : [.src.odbc.unittests]params.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]raiserror$(E) : [.src.odbc.unittests]raiserror$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]raiserror$(OBJ) : [.src.odbc.unittests]raiserror.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]getdata$(E) : [.src.odbc.unittests]getdata$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]getdata$(OBJ) : [.src.odbc.unittests]getdata.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]type$(E) : [.src.odbc.unittests]type$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]type$(OBJ) : [.src.odbc.unittests]type.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]transaction$(E) : [.src.odbc.unittests]transaction$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]transaction$(OBJ) : [.src.odbc.unittests]transaction.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]common$(OBJ) : [.src.odbc.unittests]common.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]genparams$(E) : [.src.odbc.unittests]genparams$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]genparams$(OBJ) : [.src.odbc.unittests]genparams.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]preperror$(E) : [.src.odbc.unittests]preperror$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]preperror$(OBJ) : [.src.odbc.unittests]preperror.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]prepare_results$(E) : [.src.odbc.unittests]prepare_results$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]prepare_results$(OBJ) : [.src.odbc.unittests]prepare_results.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]testodbc$(E) : [.src.odbc.unittests]testodbc$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]testodbc$(OBJ) : [.src.odbc.unittests]testodbc.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]data$(E) : [.src.odbc.unittests]data$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]data$(OBJ) : [.src.odbc.unittests]data.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]error$(E) : [.src.odbc.unittests]error$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]error$(OBJ) : [.src.odbc.unittests]error.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]rebindpar$(E) : [.src.odbc.unittests]rebindpar$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]rebindpar$(OBJ) : [.src.odbc.unittests]rebindpar.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]rpc$(E) : [.src.odbc.unittests]rpc$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]rpc$(OBJ) : [.src.odbc.unittests]rpc.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]convert_error$(E) : [.src.odbc.unittests]convert_error$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]convert_error$(OBJ) : [.src.odbc.unittests]convert_error.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]typeinfo$(E) : [.src.odbc.unittests]typeinfo$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]typeinfo$(OBJ) : [.src.odbc.unittests]typeinfo.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]const_params$(E) : [.src.odbc.unittests]const_params$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]const_params$(OBJ) : [.src.odbc.unittests]const_params.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]insert_speed$(E) : [.src.odbc.unittests]insert_speed$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]insert_speed$(OBJ) : [.src.odbc.unittests]insert_speed.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]compute$(E) : [.src.odbc.unittests]compute$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]compute$(OBJ) : [.src.odbc.unittests]compute.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]timeout$(E) : [.src.odbc.unittests]timeout$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]timeout$(OBJ) : [.src.odbc.unittests]timeout.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]array$(E) : [.src.odbc.unittests]array$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]array$(OBJ) : [.src.odbc.unittests]array.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]array_out$(E) : [.src.odbc.unittests]array_out$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]array_out$(OBJ) : [.src.odbc.unittests]array_out.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]cursor1$(E) : [.src.odbc.unittests]cursor1$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]cursor1$(OBJ) : [.src.odbc.unittests]cursor1.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]scroll$(E) : [.src.odbc.unittests]scroll$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]scroll$(OBJ) : [.src.odbc.unittests]scroll.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]cursor2$(E) : [.src.odbc.unittests]cursor2$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]cursor2$(OBJ) : [.src.odbc.unittests]cursor2.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]describecol$(E) : [.src.odbc.unittests]describecol$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]describecol$(OBJ) : [.src.odbc.unittests]describecol.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]copydesc$(E) : [.src.odbc.unittests]copydesc$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]copydesc$(OBJ) : [.src.odbc.unittests]copydesc.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]prepclose$(E) : [.src.odbc.unittests]prepclose$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]prepclose$(OBJ) : [.src.odbc.unittests]prepclose.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]warning$(E) : [.src.odbc.unittests]warning$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]warning$(OBJ) : [.src.odbc.unittests]warning.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]paramcore$(E) : [.src.odbc.unittests]paramcore$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]paramcore$(OBJ) : [.src.odbc.unittests]paramcore.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]timeout2$(E) : [.src.odbc.unittests]timeout2$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]timeout2$(OBJ) : [.src.odbc.unittests]timeout2.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]timeout3$(E) : [.src.odbc.unittests]timeout3$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]timeout3$(OBJ) : [.src.odbc.unittests]timeout3.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]connect2$(E) : [.src.odbc.unittests]connect2$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]connect2$(OBJ) : [.src.odbc.unittests]connect2.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]timeout4$(E) : [.src.odbc.unittests]timeout4$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]timeout4$(OBJ) : [.src.odbc.unittests]timeout4.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]freeclose$(E) : [.src.odbc.unittests]freeclose$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]freeclose$(OBJ) : [.src.odbc.unittests]freeclose.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]cursor3$(E) : [.src.odbc.unittests]cursor3$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]cursor3$(OBJ) : [.src.odbc.unittests]cursor3.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]cursor4$(E) : [.src.odbc.unittests]cursor4$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]cursor4$(OBJ) : [.src.odbc.unittests]cursor4.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]cursor5$(E) : [.src.odbc.unittests]cursor5$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]cursor5$(OBJ) : [.src.odbc.unittests]cursor5.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]attributes$(E) : [.src.odbc.unittests]attributes$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]attributes$(OBJ) : [.src.odbc.unittests]attributes.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]hidden$(E) : [.src.odbc.unittests]hidden$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]hidden$(OBJ) : [.src.odbc.unittests]hidden.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]blob1$(E) : [.src.odbc.unittests]blob1$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]blob1$(OBJ) : [.src.odbc.unittests]blob1.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]rowset$(E) : [.src.odbc.unittests]rowset$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]rowset$(OBJ) : [.src.odbc.unittests]rowset.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]cancel$(E) : [.src.odbc.unittests]cancel$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]cancel$(OBJ) : [.src.odbc.unittests]cancel.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]wchar$(E) : [.src.odbc.unittests]wchar$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]wchar$(OBJ) : [.src.odbc.unittests]wchar.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) [.src.odbc.unittests]transaction2$(E) : [.src.odbc.unittests]transaction2$(OBJ) [.src.odbc.unittests]common$(OBJ) link$(LINKFLAGS)/exe=$(MMS$TARGET) $(MMS$SOURCE_LIST),[.vms]libodbc.opt/options [.src.odbc.unittests]transaction2$(OBJ) : [.src.odbc.unittests]transaction2.c [.src.odbc.unittests]common.h $(CC) $(CFLAGS)/NOWARN/INCLUDE=([.src.odbc.unittests],$(CINCLUDE)) $(CDBGFLAGS) $(MMS$SOURCE) # Clean up distclean : @ if f$search("[...]*$(OBJ)") .nes. "" then delete/noconfirm [...]*$(OBJ);* @ if f$search("[...]*.LIS") .nes. "" then delete/noconfirm [...]*.LIS;* @ if f$search("[...]*.MAP") .nes. "" then delete/noconfirm [...]*.MAP;*/exclude=[.doc...]*.MAP @ if f$search("[...unittests]*$(E)") .nes. "" then delete/noconfirm [...unittests]*$(E);* @ if f$search("[.src.odbc._libs]*$(E)") .nes. "" then delete/noconfirm [.src.odbc._libs]*$(E);* @ if f$search("[...unittests]*.ini") .nes. "" then delete/noconfirm [...unittests]*.ini;* @ if f$search("[...unittests]*.out") .nes. "" then delete/noconfirm [...unittests]*.out;* @ if f$search("*$(OLB)") .nes. "" then purge/noconfirm *$(OLB) @ if f$search("*$(E)") .nes. "" then purge/noconfirm *$(E) clean : distclean @ if f$search("*$(OLB)") .nes. "" then delete/noconfirm *$(OLB);* @ if f$search("*$(E)") .nes. "" then delete/noconfirm *$(E);* @ if f$search("[.include]config.h") .nes. "" then delete/noconfirm [.include]config.h;* @ if f$search("[.include]readline.h") .nes. "" then delete/noconfirm [.include]readline.h;* @ if f$search("[.include]history.h") .nes. "" then delete/noconfirm [.include]history.h;* @ if f$search("[]descrip.mms") .nes. "" then delete/noconfirm []descrip.mms;* @ if f$search("[.include.freetds]sysconfdir.h") .nes. "" then delete/noconfirm [.include.freetds]sysconfdir.h;* @ if f$search("[.include]tds_sysdep_public.h") .nes. "" then delete/noconfirm [.include]tds_sysdep_public.h;* @ if f$search("[.src.replacements]libiconv.c") .nes. "" then delete/noconfirm [.src.replacements]libiconv.c;* freetds-1.00.82/vms/getpass.c100644 025423 025423 00000017746 12717145107 0011471/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2003, 2010 Craig A. Berry craigberry@mac.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "readline.h" static FILE *tds_rl_instream = NULL; static FILE *tds_rl_outstream = NULL; /* * A collection of assorted UNIXy input functions for VMS. The core * functionality is provided by readpassphrase(), and the general * requirements come mostly from Todd Miller's OpenBSD code but are * completely reimplemented using native services. * * There are simple getpass() and readline() implementations wrapped * around readpassphrase(), the main difference being that getpass() * suppresses echoing whereas readline() enables echoing and suppresses * timeouts. There is also an add_history() stub; echoed lines are * already stored in the command recall buffer by SMG$READ_COMPOSED_LINE. */ #define MY_PASSWORD_LEN 8192 #define RECALL_SIZE 50 /* Lines in recall buffer. */ #define DEFAULT_TIMEOUT 30 /* Seconds to wait for user input. */ /* Flags defined below are VMS-specific. Use the high byte to minimize * potential conflicts. */ #define RPP_TIMEOUT_OFF 0x01000000 /* Wait indefinitely for input. */ char * readpassphrase(const char *prompt, char *pbuf, size_t buflen, int flags) { static unsigned long keyboard_id, keytable_id = 0; unsigned long ctrl_mask, saved_ctrl_mask = 0; int timeout_secs = 0; int *timeout_ptr = NULL; unsigned long status = 0; unsigned short iosb[4]; unsigned short ttchan, result_len = 0, stdin_is_tty; $DESCRIPTOR(ttdsc, ""); $DESCRIPTOR(pbuf_dsc, ""); $DESCRIPTOR(prompt_dsc, ""); char *retval = NULL; char *myprompt = NULL; char input_fspec[MY_PASSWORD_LEN + 1]; if (pbuf == NULL || buflen == 0) { errno = EINVAL; return NULL; } bzero(pbuf, buflen); pbuf_dsc.dsc$a_pointer = pbuf; pbuf_dsc.dsc$w_length = buflen - 1; /* * If stdin is not a terminal and only reading from a terminal is allowed, we * stop here. */ stdin_is_tty = isatty(fileno(stdin)); if (stdin_is_tty != 1 && (flags & RPP_REQUIRE_TTY)) { errno = ENOTTY; return NULL; } /* * We need the file or device associated with stdin in VMS format. */ if (fgetname(stdin, input_fspec, 1)) { ttdsc.dsc$a_pointer = (char *)&input_fspec; ttdsc.dsc$w_length = strlen(input_fspec); } else { errno = EMFILE; return NULL; } /* * The prompt is expected to provide its own leading newline. */ myprompt = malloc(strlen(prompt) + 1); if (myprompt == NULL) { errno = ENOMEM; return NULL; } sprintf(myprompt, "\n%s", prompt); prompt_dsc.dsc$a_pointer = myprompt; prompt_dsc.dsc$w_length = strlen(myprompt); if (!(flags & RPP_ECHO_ON) && (stdin_is_tty)) { /* Disable Ctrl-T and Ctrl-Y */ ctrl_mask = LIB$M_CLI_CTRLT | LIB$M_CLI_CTRLY; status = LIB$DISABLE_CTRL(&ctrl_mask, &saved_ctrl_mask); if (!$VMS_STATUS_SUCCESS(status)) { errno = EVMSERR; vaxc$errno = status; free(myprompt); return NULL; } } /* * Unless timeouts are disabled, find out how long should we wait for input * before giving up. */ if (!(flags & RPP_TIMEOUT_OFF)) { unsigned long tmo_item = SYI$_LGI_PWD_TMO; status = LIB$GETSYI(&tmo_item, &timeout_secs); if (!$VMS_STATUS_SUCCESS(status)) timeout_secs = DEFAULT_TIMEOUT; timeout_ptr = &timeout_secs; } if (!(flags & RPP_ECHO_ON) && (stdin_is_tty)) { /* * If we are suppressing echoing, get a line of input with $QIOW. * Non-echoed lines are not stored for recall. (The same thing * could be done with SMG but would require maintenance of a virtual * display and pasteboard.) */ status = SYS$ASSIGN(&ttdsc, &ttchan, 0, 0, 0); if ($VMS_STATUS_SUCCESS(status)) { unsigned long qio_func = IO$_READPROMPT | IO$M_NOECHO | IO$M_PURGE; if (!(flags & RPP_TIMEOUT_OFF)) qio_func |= IO$M_TIMED; bzero(iosb, sizeof(iosb)); status = SYS$QIOW(0, (unsigned long) ttchan, qio_func, &iosb, 0, 0, pbuf, buflen - 1, timeout_secs, 0, myprompt, strlen(myprompt)); if ($VMS_STATUS_SUCCESS(status)) { status = iosb[0]; result_len = iosb[1]; /* bytes actually read */ } (void) SYS$DASSGN(ttchan); } } else { /* * We are not suppressing echoing because echoing has been explicitly * enabled and/or we are not reading from a terminal. In this case we * use SMG, which will store commands for recall. The virtual keyboard * and key table are static and will only be created if we haven't been * here before. */ status = SS$_NORMAL; if (keyboard_id == 0) { unsigned char recall_size = RECALL_SIZE; status = SMG$CREATE_VIRTUAL_KEYBOARD(&keyboard_id, &ttdsc, 0, 0, &recall_size); } if ($VMS_STATUS_SUCCESS(status) && keytable_id == 0) { status = SMG$CREATE_KEY_TABLE(&keytable_id); } if ($VMS_STATUS_SUCCESS(status)) { status = SMG$READ_COMPOSED_LINE(&keyboard_id, &keytable_id, &pbuf_dsc, &prompt_dsc, &result_len, 0, 0, 0, timeout_ptr); } } /* * Process return value from SYS$QIOW or SMG$READ_COMPOSED_LINE. */ switch (status) { case SS$_TIMEOUT: errno = ETIMEDOUT; break; case SMG$_EOF: if (result_len != 0) { status = SS$_NORMAL; } /* fall through */ default: if ($VMS_STATUS_SUCCESS(status)) { int i; if (flags & RPP_FORCELOWER) { for (i = 0; i < result_len; i++) pbuf[i] = tolower(pbuf[i]); } if (flags & RPP_FORCEUPPER) { for (i = 0; i < result_len; i++) pbuf[i] = toupper(pbuf[i]); } if (flags & RPP_SEVENBIT) { for (i = 0; i < result_len; i++) pbuf[i] &= 0x7f; } pbuf[result_len] = '\0'; retval = pbuf; } else { errno = EVMSERR; vaxc$errno = status; } } /* end switch */ free(myprompt); if (!(flags & RPP_ECHO_ON) && (stdin_is_tty)) { /* * Reenable previous control processing. */ status = LIB$ENABLE_CTRL(&saved_ctrl_mask); if (!$VMS_STATUS_SUCCESS(status)) { errno = EVMSERR; vaxc$errno = status; return NULL; } } return retval; } /* getpassphrase */ static char passbuf[MY_PASSWORD_LEN + 1]; char * getpass(const char *prompt) { bzero(passbuf, sizeof(passbuf)); /* caller should do this again */ return (readpassphrase(prompt, passbuf, sizeof(passbuf), RPP_ECHO_OFF) ); } /* getpass */ char * readline(char *prompt) { char *buf = NULL, *s = NULL, *p = NULL, *newline = NULL; if (tds_rl_instream == NULL) s = readpassphrase((const char *) prompt, passbuf, sizeof(passbuf), RPP_ECHO_ON | RPP_TIMEOUT_OFF); else s = fgets(passbuf, sizeof(passbuf), tds_rl_instream); if (s != NULL) { buf = (char *) malloc(strlen(s) + 1); strcpy(buf, s); } /* readline is documented to eat the newline. */ if (buf) { newline = strchr(buf, '\n'); if (newline) *newline = '\0'; } return buf; } /* readline */ void add_history(const char *s) { } FILE ** rl_instream_get_addr(void) { return &tds_rl_instream; } FILE ** rl_outstream_get_addr(void) { return &tds_rl_outstream; } freetds-1.00.82/vms/libodbc.opt100644 025423 025423 00000000022 12522201763 0011747LIBODBC/Shareable freetds-1.00.82/vms/odbc_driver_axp.opt100644 025423 025423 00000007714 12522201763 0013522! FreeTDS - Library of routines accessing Sybase and Microsoft databases ! Copyright (C) 2003 Craig A. Berry craigberry@mac.com 05-MAY-2003 ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Library General Public ! License as published by the Free Software Foundation; either ! version 2 of the License, or (at your option) any later version. ! ! This library 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 ! Library General Public License for more details. ! ! You should have received a copy of the GNU Library General Public ! License along with this library; if not, write to the ! Free Software Foundation, Inc., 59 Temple Place - Suite 330, ! Boston, MA 02111-1307, USA. ! LIBODBCINST/SHAREABLE CASE_SENSITIVE=YES SYMBOL_VECTOR = (SQLAllocConnect=PROCEDURE,- SQLAllocEnv=PROCEDURE,- SQLAllocHandle=PROCEDURE,- SQLAllocStmt=PROCEDURE,- SQLBindCol=PROCEDURE,- SQLBindParam=PROCEDURE,- SQLBindParameter=PROCEDURE,- SQLCancel=PROCEDURE,- SQLCloseCursor=PROCEDURE,- SQLColAttribute=PROCEDURE,- SQLColAttributes=PROCEDURE,- SQLColumnPrivileges=PROCEDURE,- SQLColumns=PROCEDURE,- SQLConnect=PROCEDURE,- SQLCopyDesc=PROCEDURE,- SQLDescribeCol=PROCEDURE,- SQLDisconnect=PROCEDURE,- SQLDriverConnect=PROCEDURE,- SQLEndTran=PROCEDURE,- SQLError=PROCEDURE,- SQLExecDirect=PROCEDURE,- SQLExecute=PROCEDURE,- SQLExtendedFetch=PROCEDURE,- SQLFetch=PROCEDURE,- SQLFetchScroll=PROCEDURE,- SQLForeignKeys=PROCEDURE,- SQLFreeConnect=PROCEDURE,- SQLFreeEnv=PROCEDURE,- SQLFreeHandle=PROCEDURE,- SQLFreeStmt=PROCEDURE,- SQLGetConnectAttr=PROCEDURE,- SQLGetConnectOption=PROCEDURE,- SQLGetConnectOptionW=PROCEDURE,- SQLGetCursorName=PROCEDURE,- SQLGetData=PROCEDURE,- SQLGetDescField=PROCEDURE,- SQLGetDescRec=PROCEDURE,- SQLGetDiagField=PROCEDURE,- SQLGetDiagRec=PROCEDURE,- SQLGetEnvAttr=PROCEDURE,- SQLGetFunctions=PROCEDURE,- SQLGetInfo=PROCEDURE,- SQLGetStmtAttr=PROCEDURE,- SQLGetStmtAttrW=PROCEDURE,- SQLGetStmtOption=PROCEDURE,- SQLGetTypeInfo=PROCEDURE,- SQLGetTypeInfoW=PROCEDURE,- SQLMoreResults=PROCEDURE,- SQLNativeSql=PROCEDURE,- SQLNumParams=PROCEDURE,- SQLNumResultCols=PROCEDURE,- SQLParamData=PROCEDURE,- SQLParamOptions=PROCEDURE,- SQLPrepare=PROCEDURE,- SQLPrimaryKeys=PROCEDURE,- SQLProcedureColumns=PROCEDURE,- SQLProcedures=PROCEDURE,- SQLPutData=PROCEDURE,- SQLRowCount=PROCEDURE,- SQLSetConnectAttr=PROCEDURE,- SQLSetConnectOption=PROCEDURE,- SQLSetConnectOptionW=PROCEDURE,- SQLSetCursorName=PROCEDURE,- SQLSetDescField=PROCEDURE,- SQLSetDescRec=PROCEDURE,- SQLSetEnvAttr=PROCEDURE,- SQLSetParam=PROCEDURE,- SQLSetPos=PROCEDURE,- SQLSetScrollOptions=PROCEDURE,- SQLSetStmtAttr=PROCEDURE,- SQLSetStmtAttrW=PROCEDURE,- SQLSetStmtOption=PROCEDURE,- SQLSpecialColumns=PROCEDURE,- SQLStatistics=PROCEDURE,- SQLTablePrivileges=PROCEDURE,- SQLTables=PROCEDURE,- SQLTransact=PROCEDURE,- SQLColAttributeW=PROCEDURE,- SQLColumnPrivilegesW=PROCEDURE,- SQLColumnsW=PROCEDURE,- SQLConnectW=PROCEDURE,- SQLDescribeColW=PROCEDURE,- SQLDriverConnectW=PROCEDURE,- SQLErrorW=PROCEDURE,- SQLExecDirectW=PROCEDURE,- SQLForeignKeysW=PROCEDURE,- SQLGetConnectAttrW=PROCEDURE,- SQLGetCursorNameW=PROCEDURE,- SQLGetDescFieldW=PROCEDURE,- SQLGetDescRecW=PROCEDURE,- SQLGetDiagFieldW=PROCEDURE,- SQLGetDiagRecW=PROCEDURE,- SQLGetInfoW=PROCEDURE,- SQLNativeSqlW=PROCEDURE,- SQLPrepareW=PROCEDURE,- SQLPrimaryKeysW=PROCEDURE,- SQLProcedureColumnsW=PROCEDURE,- SQLProceduresW=PROCEDURE,- SQLSetConnectAttrW=PROCEDURE,- SQLSetCursorNameW=PROCEDURE,- SQLSetDescFieldW=PROCEDURE,- SQLSpecialColumnsW=PROCEDURE,- SQLStatisticsW=PROCEDURE,- SQLTablePrivilegesW=PROCEDURE,- SQLTablesW=PROCEDURE) ) ! ! SQLBrowseConnect=PROCEDURE,- ! SQLDescribeParam=PROCEDURE,- freetds-1.00.82/vms/README.vms100644 025423 025423 00000007550 12522201763 0011326README.vms -- VMS-specific notes on building and running FreeTDS FreeTDS has successfully built and passed all expected tests in the following environments: OpenVMS Alpha 7.2-1, Compaq C 6.4, OpenVMS Sybase 11.0.2, TDS 5.0 OpenVMS Alpha 7.3-1, Compaq C 6.5, MS SQL Server 7.0, TDS 7.0 OpenVMS Alpha 7.1, Compaq C 6.5, MS SQL Server 2000, TDS 8.0 It will probably build and run on most versions of OpenVMS Alpha 7.0 and later with DEC/Compaq C 6.0 or later. Other prerequisites: gunzip vmstar MMS or MMK Build Instructions Decompress and unpack the source archive using gunzip and vmstar (You probably have already or you wouldn't be reading this). If you are untarring on an ODS-5 disk, you should use the /ODS2 or -o option to create universally VMS-friendly filenames; the build will fail to locate some files otherwise. Set default to the top-level source directory and run the configuration script like so: $ @[.vms]configure This creates a descrip.mms in the top-level source directory which you may execute by simply running MMS (if you have the Module Management System that is part of DECset) or MMK (a freeware MMS alternative available from http://www.madgoat.com). By default the build uses version 5.0 of the TDS protocol and does not include ODBC support. You may change these defaults by sypplying the following macros to the make utility: TDSVER This macro expects a value that will be passed directly to the C compiler. Valid values are TDS42, TDS50 (the default), TDS70, and TDS71. Consult the [.doc] directory for more information about the TDS protocol, what servers use which versions, and the history of the versions. Example: $ MMK/MACRO="TDSVER"="TDS71" MSDBLIB Enables Microsoft behavior in the db-lib API where it diverges from Sybase's. See additional documentation in the [.doc] directory. Example: $ MMK/MACRO="MSDBLIB"=1 ODBC This macro instructs the build to include ODBC support. At the moment, the unixODBC driver manager is assumed (see http://www.unixodbc.org), but others may work as well. The following logical names must be defined in order to build with ODBC support: ODBC_LIBDIR directory containing driver manager's libraries ODBC_INCDIR directory containing driver manager's include files LIBODBC the shareable image comprising the driver manager Note: in unixODBC 2.2.4 and later, all of these logicals except ODBC_INCDIR will be set up by running ODBC_SETUP.COM in the library directory. Examples: $ MMS/MACRO="ODBC"=1 $ MMK/MACRO=("ODBC"=1,"TDSVER"="TDS70") Caveats and To-do: It's probably best to define the locations of your configuration files as logical names; otherwise FreeTDS may concoct an unparseable combination of UNIX and VMS filename syntax. For example: $ DEFINE FREETDSCONF DISK$USER:[TDSDIR]freetds.conf There is currently no install target; it's up to you to put the libraries, include files, etc. wherever you want them. A VAX port is within the realm of possibilities. It would need to convert between IEEE floating point data and native format and/or request native F_FLOAT and D_FLOAT from the server (which may only work on Sybase, not MS SQL Server, but that's TBD). As more ODBC functions are implemented, the file [.vms]odbc_driver_axp.opt needs to be updated to point to the real functions instead of the aliases to the stub for unimplemented functions. The build currently compiles with the /NAMES=AS_IS switch when the ODBC macro is enabled; this results in mixed-case symbol names. Mixed-case symbols were necessary to get the code working with unixODBC but may cause problems when calling the FreeTDS libraries from other languages. There are a variety of approaches that could be taken to work around this but for now you'll have to roll your own. Last updated: 6-NOV-2004 Craig A. Berry $Id: README.vms,v 1.4 2009-09-04 07:12:18 freddy77 Exp $ freetds-1.00.82/vms/vargdefs.h100644 025423 025423 00000004206 12522201763 0011607/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2010 Craig A. Berry craigberry@mac.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. /* * Definitions used by the VMSARG parsing and mapping routines. * * Based on VMSARG Version 2.0 by Tom Wade * * Extensively revised for inclusion in FreeTDS by Craig A. Berry. * * From the VMSARG 2.0 documentation: * * The product is aimed at . . . people who are porting a package from * Unix to VMS. This software is made freely available for inclusion in * such products, whether they are freeware, public domain or commercial. * No licensing is required. */ #if __CRTL_VER >= 70302000 && !defined(__VAX) #define QUAL_LENGTH (4000+1) #define S_LENGTH (4096+1) #else #define QUAL_LENGTH (255+1) #define S_LENGTH (1024+1) #endif #define MAX_ARGS 255 /* bit fields for arg flags. */ #define VARG_M_AFFIRM 1 #define VARG_M_NEGATIVE 2 #define VARG_M_KEYWORDS 4 #define VARG_M_SEPARATOR 8 #define VARG_M_DATE 16 #define VARG_M_APPEND 32 #define VARG_M_HELP 64 /* bit fields for action flags. */ #define VARGACT_M_UPPER 1 #define VARGACT_M_LOWER 2 #define VARGACT_M_SPECIAL 4 #define VARGACT_M_ESCAPE 8 #define VARGACT_M_DOUBLE 16 #define VARGACT_M_IMAGE 32 #define VARGACT_M_SYMBOL 64 #define VARGACT_M_COMMAND 128 #define VARGACT_M_RETURN 256 #define VARGACT_M_PROTECT 512 #define VARGACT_M_UNIXARG 1024 #define VARGACT_M_PROTMASK 1+2+4+8+16 freetds-1.00.82/vms/vmsarg_command_bcp.cld100644 025423 025423 00000005051 12522201763 0014141! FreeTDS - Library of routines accessing Sybase and Microsoft databases ! Copyright (C) 2010 Craig A. Berry craigberry@mac.com ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Library General Public ! License as published by the Free Software Foundation; either ! version 2 of the License, or (at your option) any later version. ! ! This library 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 ! Library General Public License for more details. ! ! You should have received a copy of the GNU Library General Public ! License along with this library; if not, write to the ! Free Software Foundation, Inc., 59 Temple Place - Suite 330, ! Boston, MA 02111-1307, USA. ! Command definitions for the BCP command. Module VARG_CLD Define Verb VARG parameter P1, label=TABLE_NAME value (required) parameter P2, label=DIRECTION value (required,type=DIR_KEYS) parameter P3, label=DATA_FILE value (required,type=$file) qualifier MAX_ERRORS value (required,type=$number) qualifier FORMAT_FILE value (required,type=$file) qualifier ERRORFILE value (required,type=$file) qualifier FIRST_ROW value (required,type=$number) qualifier LAST_ROW value (required,type=$number) qualifier BATCH_SIZE value (required,type=$number) qualifier NATIVE_DEFAULT qualifier CHARACTER_DEFAULT qualifier COLUMN_TERMINATOR value (required) qualifier ROW_TERMINATOR value (required) qualifier USERNAME value qualifier PASSWORD value (default="") qualifier SERVER_NAME value (required) qualifier INPUT value (required,type=$file) qualifier OUTPUT value (required,type=$file) qualifier SERVCHARSET value qualifier CLIENTCHARSET value qualifier DISPCHARSET value qualifier FILECHARSET value qualifier LANGUAGE value qualifier FILECHARSET value qualifier TDSPACKETSIZE value (type=$number) qualifier TEXTSIZE value (type=$number) qualifier VERSION, syntax=NOPARAM qualifier HOMEDIR value qualifier ENCRYPT qualifier IDENTITY disallow (NATIVE_DEFAULT and CHARACTER_DEFAULT) define type DIR_KEYS keyword IN keyword OUT define syntax NOPARAM parameter P1, label=TABLE_NAME parameter P2, label=DIRECTION value (type=DIR_KEYS) parameter P3, label=DATA_FILE value (type=$file) freetds-1.00.82/vms/vmsarg_command_defncopy.cld100644 025423 025423 00000003603 12522201763 0015205! FreeTDS - Library of routines accessing Sybase and Microsoft databases ! Copyright (C) 2010 Craig A. Berry craigberry@mac.com ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Library General Public ! License as published by the Free Software Foundation; either ! version 2 of the License, or (at your option) any later version. ! ! This library 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 ! Library General Public License for more details. ! ! You should have received a copy of the GNU Library General Public ! License along with this library; if not, write to the ! Free Software Foundation, Inc., 59 Temple Place - Suite 330, ! Boston, MA 02111-1307, USA. ! Command definitions for the DEFNCOPY command. Module VARG_CLD define verb VARG parameter P1, label=DIRECTION value (required,type=DIR_KEYS) parameter P2, label=FILE_NAME value (required,type=$file) parameter P3, label=DATABASE_NAME value (required) parameter P4, label=OBJECT_NAME value (list) qualifier USERNAME value qualifier PASSWORD value (default="") qualifier SERVER_NAME, label=SERVERNAME value qualifier VERSION, syntax=NOPARAM qualifier INTERFACES, label=INTERFACE value (type=$file) qualifier DISPCHARSET value qualifier LANGUAGE value qualifier SERVCHARSET value qualifier CLIENTCHARSET value qualifier REAL_VERSION qualifier HOMEDIR value define type DIR_KEYS keyword IN keyword OUT define syntax NOPARAM parameter P1, label=DIRECTION value (type=DIR_KEYS) parameter P2, label=FILE_NAME value (type=$file) parameter P3, label=DATABASE_NAME parameter P4, label=OBJECT_NAME value (list) freetds-1.00.82/vms/vmsarg_command_isql.cld100644 025423 025423 00000004013 12522201763 0014342! FreeTDS - Library of routines accessing Sybase and Microsoft databases ! Copyright (C) 2010 Craig A. Berry craigberry@mac.com ! ! This library is free software; you can redistribute it and/or ! modify it under the terms of the GNU Library General Public ! License as published by the Free Software Foundation; either ! version 2 of the License, or (at your option) any later version. ! ! This library 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 ! Library General Public License for more details. ! ! You should have received a copy of the GNU Library General Public ! License along with this library; if not, write to the ! Free Software Foundation, Inc., 59 Temple Place - Suite 330, ! Boston, MA 02111-1307, USA. ! Command definitions for the ISQL command. Module VARG_CLD Define Verb VARG qualifier ECHO qualifier STATISTICS qualifier NOPROMPT qualifier TERMINATOR value qualifier WIDTH value (type=$number) qualifier COLSEPARATOR value qualifier ROWSINPAGE value (type=$number) qualifier TIMEOUT value qualifier ERRORLEVEL value (type=$number) qualifier USERNAME value qualifier PASSWORD value qualifier SERVER_NAME value qualifier INTERFACE value (type=$file) qualifier HOSTNAME value qualifier CLIENTCHARSET value qualifier DISPCHARSET value qualifier INPUT value (type=$file) qualifier OUTPUT value (type=$file) qualifier LANGUAGE value qualifier HOMEDIR value qualifier VERSION qualifier DEBUG qualifier BROWSE qualifier RECORD_FRONT_TO_SERVER value qualifier LOGINTIME value qualifier EDITOR value qualifier TDSPACKETSIZE value (type=$number) qualifier TRACE value qualifier ADDID qualifier LOOK3 qualifier ENCRYPT qualifier CHAIN_XACT qualifier FIPS define syntax NOPARAM freetds-1.00.82/vms/vmsarg_mapping_bcp.c100644 025423 025423 00000005621 12522201763 0013641/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2010 Craig A. Berry craigberry@mac.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. /* * Mapping table for the BCP command. */ int vmsarg_mapping (int *nvargs, char *vms_arg[], char *unix_arg[], char *unix_narg[], char *vms_key[], char *unix_key[], char *separator[], int flags[], char *pattern[], char **outverb, int *action_flags, char **arg_symbol, char **image_name) { *nvargs = 26; *action_flags = 1301; vms_arg[1] = "TABLE_NAME"; flags[1] = 1; unix_arg[1] = "$"; vms_arg[2] = "DIRECTION"; flags[2] = 1; unix_arg[2] = "$"; vms_arg[3] = "DATA_FILE"; flags[3] = 1; unix_arg[3] = "$"; vms_arg[4] = "MAX_ERRORS"; flags[4] = 1; unix_arg[4] = "-m"; vms_arg[5] = "FORMAT_FILE"; flags[5] = 1; unix_arg[5] = "-f"; vms_arg[6] = "ERRORFILE"; flags[6] = 1; unix_arg[6] = "-e"; vms_arg[7] = "FIRST_ROW"; flags[7] = 1; unix_arg[7] = "-F"; vms_arg[8] = "LAST_ROW"; flags[8] = 1; unix_arg[8] = "-L"; vms_arg[9] = "BATCH_SIZE"; flags[9] = 1; unix_arg[9] = "-b"; vms_arg[10] = "NATIVE_DEFAULT"; flags[10] = 1; unix_arg[10] = "-n"; vms_arg[11] = "CHARACTER_DEFAULT"; flags[11] = 1; unix_arg[11] = "-c"; vms_arg[12] = "COLUMN_TERMINATOR"; flags[12] = 1; unix_arg[12] = "-t"; vms_arg[13] = "ROW_TERMINATOR"; flags[13] = 1; unix_arg[13] = "-r"; vms_arg[14] = "USERNAME"; flags[14] = 1; unix_arg[14] = "-U"; vms_arg[15] = "PASSWORD"; flags[15] = 1; unix_arg[15] = "-P"; vms_arg[16] = "SERVER_NAME"; flags[16] = 1; unix_arg[16] = "-S"; vms_arg[17] = "INPUT"; flags[17] = 1; unix_arg[17] = "-i"; vms_arg[18] = "OUTPUT"; flags[18] = 1; unix_arg[18] = "-o"; vms_arg[19] = "TDSPACKETSIZE"; flags[19] = 1; unix_arg[19] = "-A"; vms_arg[20] = "TEXTSIZE"; flags[20] = 1; unix_arg[20] = "-T"; vms_arg[21] = "VERSION"; flags[21] = 1; unix_arg[21] = "-v"; vms_arg[22] = "DISPCHARSET"; flags[22] = 1; unix_arg[22] = "-a"; vms_arg[23] = "LANGUAGE"; flags[23] = 1; unix_arg[23] = "-z"; vms_arg[24] = "CLIENTCHARSET"; flags[24] = 1; unix_arg[24] = "-J"; vms_arg[25] = "IDENTITY"; flags[25] = 1; unix_arg[25] = "-E"; vms_arg[26] = "ENCRYPT"; flags[26] = 1; unix_arg[26] = "-X"; return 1; } freetds-1.00.82/vms/vmsarg_mapping_defncopy.c100644 025423 025423 00000003733 12522201763 0014706/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2010 Craig A. Berry craigberry@mac.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. /* * Mapping table for the DEFNCOPY command. */ int vmsarg_mapping (int *nvargs, char *vms_arg[], char *unix_arg[], char *unix_narg[], char *vms_key[], char *unix_key[], char *separator[], int flags[], char *pattern[], char **outverb, int *action_flags, char **arg_symbol, char **image_name) { *nvargs = 12; *action_flags = 1301; vms_arg[1] = "DIRECTION"; flags[1] = 1; unix_arg[1] = "$"; vms_arg[2] = "FILE_NAME"; flags[2] = 1; unix_arg[2] = "$"; vms_arg[3] = "DATABASE_NAME"; flags[3] = 1; unix_arg[3] = "$"; vms_arg[4] = "OBJECT_NAME"; flags[4] = 1; unix_arg[4] = "$"; vms_arg[5] = "USERNAME"; flags[5] = 1; unix_arg[5] = "-U"; vms_arg[6] = "PASSOWRD"; flags[6] = 1; unix_arg[6] = "-P"; vms_arg[7] = "SERVER_NAME"; flags[7] = 1; unix_arg[7] = "-S"; vms_arg[8] = "VERSION"; flags[8] = 1; unix_arg[8] = "-v"; vms_arg[9] = "INTERFACES"; flags[9] = 1; unix_arg[9] = "-I"; vms_arg[10] = "DISPCHARSET"; flags[10] = 1; unix_arg[10] = "-a"; vms_arg[11] = "LANGUAGE"; flags[11] = 1; unix_arg[11] = "-z"; vms_arg[12] = "CLIENTCHARSET"; flags[12] = 1; unix_arg[12] = "-J"; return 1; } freetds-1.00.82/vms/vmsarg_mapping_isql.c100644 025423 025423 00000005754 12522201763 0014054/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2010 Craig A. Berry craigberry@mac.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. /* * Mapping table for the ISQL command. */ #include int vmsarg_mapping (int *nvargs, char *vms_arg[], char *unix_arg[], char *unix_narg[], char *vms_key[], char *unix_key[], char *separator[], int flags[], char *pattern[], char **outverb, int *action_flags, char **arg_symbol, char **image_name) { *nvargs = 26; *action_flags = 1301; vms_arg[1] = "USERNAME"; flags[1] = 1; unix_arg[1] = "-U"; vms_arg[2] = "PASSWORD"; flags[2] = 1; unix_arg[2] = "-P"; vms_arg[3] = "SERVER_NAME"; flags[3] = 1; unix_arg[3] = "-S"; vms_arg[4] = "TIMEOUT"; flags[4] = 1; unix_arg[4] = "-t"; vms_arg[5] = "INPUT"; flags[5] = 1; unix_arg[5] = "-i"; vms_arg[6] = "OUTPUT"; flags[6] = 1; unix_arg[6] = "-o"; vms_arg[7] = "VERSION"; flags[7] = 1; unix_arg[7] = "-v"; vms_arg[8] = "ECHO"; flags[8] = 1; unix_arg[8] = "-e"; vms_arg[9] = "FIPS"; flags[9] = 1; unix_arg[9] = "-F"; vms_arg[10] = "STATISTICS"; flags[10] = 1; unix_arg[10] = "-p"; vms_arg[11] = "NOPROMPT"; flags[11] = 1; unix_arg[11] = "-n"; vms_arg[12] = "ENCRYPT"; flags[12] = 1; unix_arg[12] = "-X"; vms_arg[13] = "CHAIN_XACT"; flags[13] = 1; unix_arg[13] = "-Y"; vms_arg[14] = "DISPCHARSET"; flags[14] = 1; unix_arg[14] = "-a"; vms_arg[15] = "TDSPACKETSIZE"; flags[15] = 1; unix_arg[15] = "-A"; vms_arg[16] = "TERMINATOR"; flags[16] = 1; unix_arg[16] = "-c"; vms_arg[17] = "EDITOR"; flags[17] = 1; unix_arg[17] = "-E"; vms_arg[18] = "ROWSINPAGE"; flags[18] = 1; unix_arg[18] = "-h"; vms_arg[19] = "HOSTNAME"; flags[19] = 1; unix_arg[19] = "-H"; vms_arg[20] = "INTERFACE"; flags[20] = 1; unix_arg[20] = "-I"; vms_arg[21] = "CLIENTCHARSET"; flags[21] = 1; unix_arg[21] = "-J"; vms_arg[22] = "ERRORLEVEL"; flags[22] = 1; unix_arg[22] = "-m"; vms_arg[23] = "LOGINTIME"; flags[23] = 1; unix_arg[23] = "-l"; vms_arg[24] = "COLSEPARATOR"; flags[24] = 1; unix_arg[24] = "-s"; vms_arg[25] = "WIDTH"; flags[25] = 1; unix_arg[25] = "-w"; vms_arg[26] = "LANGUAGE"; flags[26] = 1; unix_arg[26] = "-z"; /* Because vi is not a reasonable default on VMS. */ if (setenv("EDITOR", "edit", 0) != 0) return 0; return 1; } freetds-1.00.82/vms/vmsarg_parse.c100644 025423 025423 00000072436 12744631022 0012505/* FreeTDS - Library of routines accessing Sybase and Microsoft databases * Copyright (C) 2010 Craig A. Berry craigberry@mac.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. /* * Program to Parse VMS style arguments. The calling program passes * argc, argv into this routine, and we translate the VMS qualifiers into * Unix style arguments according to a user specified translation table. * It then puts these into a new argv and returns that address to the * caller. The calling program then happily proceeds with the Unix style * qualifiers that it was written to deal with. * * Based on VMSARG Version 2.0 by Tom Wade * * Extensively revised for inclusion in FreeTDS by Craig A. Berry. * * From the VMSARG 2.0 documentation: * * The product is aimed at . . . people who are porting a package from * Unix to VMS. This software is made freely available for inclusion in * such products, whether they are freeware, public domain or commercial. * No licensing is required. */ #include "vargdefs.h" #include #include #include #include #include #include #include #include #include #include #include #include /* Increment arg counter and crash out if we have too many */ #define Increment(x) x = x + 1;\ if (x > MAX_ARGS) sys$exit(SS$_OVRMAXARG); /* Declare internal static routines */ static int varg_get_index(), varg_set_index(), varg_convert_date(), varg_do_help(); static int varg_protect_string(), varg_set_symbol(), varg_do_command(); static int varg_do_exit(); parse_vms_args(int *argc, char **argv[]) { static char command[S_LENGTH], value_template[S_LENGTH]; static char qual_template[S_LENGTH]; char verb[] = "VARG "; char *vms_arg[MAX_ARGS]; char *unix_arg[MAX_ARGS]; char *unix_narg[MAX_ARGS]; char *vms_key[MAX_ARGS]; char *unix_key[MAX_ARGS]; char *separator[MAX_ARGS]; char *pattern[MAX_ARGS]; char *outverb, *arg_symbol, *image_name; char foreign_image[S_LENGTH]; int flags[MAX_ARGS], action_flags; int nvargs, u_length, l_element, index; char arg_string[S_LENGTH], arg_element[S_LENGTH]; static char value[S_LENGTH]; char *special_chars; char default_special[] = "!@#^&()=+\'\"/?,"; $DESCRIPTOR(command_desc, command); $DESCRIPTOR(qual_desc, ""); $DESCRIPTOR(value_desc, value); int i, length, status, i_length, arg_count, q_length; static char command_args[S_LENGTH]; $DESCRIPTOR(command_arg_desc, command_args); extern VARG_CLD; static char *newargv[MAX_ARGS]; int affirm_flag, negative_flag, keywords_flag, separator_flag; int date_flag, append_flag, present, more_flag, multivalue, help_flag; int vmsarg_mapping(); /* Get the VMS -> Unix mapping definitions from the routine generated by the GEN_MAPPING utility. */ vmsarg_mapping(&nvargs, vms_arg, unix_arg, unix_narg, vms_key, unix_key, separator, flags, pattern, &outverb, &action_flags, &arg_symbol, &image_name ); /* Get the original command line from the foreign command utility. */ length = 0; /* RTL only writes word */ lib$get_foreign(&command_arg_desc, 0, &length); command_args[length] = 0; /* add NULL terminator */ /* Check to see if any of the exising arguments start with a "-" character. if so, assume he's already using Unix style arguments so we don't have to do anything. Only do this if the Unix_Arg bit is set in the action flags. */ if ((action_flags & VARGACT_M_UNIXARG)) { for (i = 1; i <= *argc - 1; i++) if ((*argv) [i][0] == '-') { /* He's using Unix style args. */ if ((action_flags & VARGACT_M_RETURN)) { return 1; /* back out quietly */ } else { status = varg_do_exit(action_flags, arg_symbol, command_args, image_name, outverb); sys$exit(status); /* exit with DCL stuff done */ } } } /* Catenate verb and arguments into the command string for DCL to parse. */ strcpy(command, verb); strcat(command, command_args); command_desc.dsc$w_length = strlen(verb) + strlen(command_args); /* Pass it to the DCL parser for its approval. */ status = cli$dcl_parse(&command_desc, &VARG_CLD); if ((status & 1) != 1) sys$exit (status); /* Now that DCL is happy, we go through all the defined VMS qualifiers and parameters to check if they are present or defaulted. */ arg_count = 0; /* so far so good */ for (i = 1; i <= nvargs; i++) { /* Set The various flags for this qualifier. */ affirm_flag = (VARG_M_AFFIRM & flags[i]) != 0; negative_flag = (VARG_M_NEGATIVE & flags[i]) != 0; keywords_flag = (VARG_M_KEYWORDS & flags[i]) != 0; separator_flag = (VARG_M_SEPARATOR & flags[i]) != 0; date_flag = (VARG_M_DATE & flags[i]) != 0; append_flag = (VARG_M_APPEND & flags[i]) != 0; help_flag = (VARG_M_HELP & flags[i]) != 0; /* Check if the qualifier or parameter is present */ qual_desc.dsc$w_length = strlen(vms_arg[i]); qual_desc.dsc$a_pointer = vms_arg[i]; present = cli$present(&qual_desc) & 1; /* if the qualifier is present, and there is a positive translation, then replace the VMS qualifier by its Unix equivalent. Note that if the Unix equivalent starts with a '$', then it is a parameter and we omit the qualifier name, only putting in the value. */ qual_template[0] = 0; /* zero string initially */ if (present && affirm_flag) { if (unix_arg[i][0] != '$') strcpy(qual_template, unix_arg[i]); } if (!(present & 1) && negative_flag) /* NOT present AND negative_flag */ { strcpy(qual_template, unix_narg[i]); } /* Get the first value (if any). We may have to catenate this with the qualifier keyword, or build up multiple values in a single argv element. */ if (present) { value_desc.dsc$w_length = QUAL_LENGTH; status = cli$get_value(&qual_desc, &value_desc, &length); if ((status & 1) != 1) length = 0; value[length] = 0; /* NULL terminator */ more_flag = status == CLI$_COMMA; } else { length = 0; } /* if the /APPEND qualifier was used, then the qualifier and its value are in the same argv element. */ if (append_flag) { strcpy(value_template, qual_template); } else { /* Allocate a fresh argv element and load the Unix keyword into it. */ q_length = strlen(qual_template); if (q_length != 0) { Increment(arg_count); newargv[arg_count] = malloc(q_length + 1); if (newargv[arg_count] == NULL) sys$exit(LIB$_INSVIRMEM); strcpy(newargv[arg_count], qual_template); } } multivalue = more_flag; /* Get all the various values and either append them with appropriate separators to the current template, or load them in successive argv elements. */ while (affirm_flag && (length != 0)) { /* if a keyword list is involved, get the corresponding field from the Unix equivalent. */ if (keywords_flag) { index = varg_get_index(value, vms_key[i]); varg_set_index(value, unix_key[i], index); } /* if the /DATE qualifier was present, we interpret the value as a VMS date/time specification, and convert it to the equivalent Unix type string. */ if (date_flag) varg_convert_date(value, pattern[i]); /* Add the current value to the template so far. Add a separator character if we need one. */ strcat(value_template, value); if (separator_flag) { if (more_flag) strcat(value_template, separator[i]); } else { /* Each value should have its own argv element. */ Increment(arg_count); newargv[arg_count] = malloc(strlen(value_template) + 1); if (newargv[arg_count] == NULL) sys$exit(LIB$_INSVIRMEM); strcpy(newargv[arg_count], value_template); value_template[0] = 0; } /* Get the next value from the DCL parser. */ value_desc.dsc$w_length = QUAL_LENGTH; /* reset string */ status = cli$get_value(&qual_desc, &value_desc, &length); if ((status & 1) != 1) length = 0; value[length] = 0; more_flag = status == CLI$_COMMA; } /* All the values are in for this qualifier - if there were being stacked up then load them all into an argv element. */ if (separator_flag & multivalue) { Increment(arg_count); newargv[arg_count] = malloc(strlen(value_template) + 1); if (newargv[arg_count] == NULL) sys$exit(LIB$_INSVIRMEM); strcpy(newargv[arg_count], value_template); value_template[0] = 0; } /* Check to see if this is a HELP directive. if so, then the help library name is stored in pattern[i] and the initial help string in unix_arg[i] */ if ((present &1) && help_flag) { varg_do_help(pattern[i], unix_arg[i]); } /* And around for the next qualifier. */ } /* We've built the argument vector. Now lets find out what we're supposed to do with it. */ if ((action_flags & VARGACT_M_RETURN)) { /* We should return the result to the caller. Set the corresponding argc & argv variables in the caller to point at these. Make sure the new argv contains the same [0] element as the old one (program name). */ *argc = arg_count + 1; newargv[0] = (*argv)[0]; *argv = newargv; return 1; } /* We must convert the argv elements into an arg string. */ arg_string[0] = 0; special_chars = default_special; for (i = 1; i <= arg_count; i++) { varg_protect_string(newargv[i], arg_element, action_flags, special_chars); strcat(arg_string, arg_element); if (i != arg_count) strcat(arg_string, " "); } status = varg_do_exit(action_flags, arg_symbol, arg_string, image_name, outverb); /* if we got this far then exit to DCL. */ sys$exit(status); } /*****************************************************************************| | Routine to scan the string 'string' to see if it matches any of | | the fields in 'keywords' (fields delimited by "|" characters). if | | so, return the field number (1=first). if it doesn't match, return | | 0. | \*****************************************************************************/ static int varg_get_index(char *string, char *keywords) { int i; char temp[S_LENGTH]; char *field; i = 0; strcpy(temp, keywords); /* don't muck up caller's string. */ /* Get successive fields using STRTOK function and compare. */ field = strtok(temp, "|"); while (field != NULL) { i = i + 1; if (strcmp(field, string) == 0) return i; field = strtok(NULL, "|"); } return 0; } /*****************************************************************************| | Routine to return the 'index' numbered field of 'keywords' in | | 'string'. Keywords are delimited by "|" characters. if 'index' | | is 0 do nothing. | \*****************************************************************************/ static int varg_set_index(char *string, char *keywords, int index) { int i; char temp[S_LENGTH]; char *field; if (index == 0) return 1; strcpy(temp, keywords); /* don't screw up caller's string. */ field = strtok(temp, "|"); for (i = 1; i <= index - 1; i++) { field = strtok(NULL, "|"); } strcpy(string, field); return 1; } /*****************************************************************************| | Invoke a help dialog with the user using the supplied help library | | and initial help command. | \*****************************************************************************/ static int varg_do_help(char *help_library, char *help_command) { $DESCRIPTOR(lib_desc, ""); $DESCRIPTOR(command_desc, ""); int status; lib_desc.dsc$w_length = strlen(help_library); lib_desc.dsc$a_pointer = help_library; command_desc.dsc$w_length = strlen(help_command); command_desc.dsc$a_pointer = help_command; status = lbr$output_help(&lib$put_output, 0, &command_desc, &lib_desc, 0, &lib$get_input); return status; } /*****************************************************************************| | Routine to create a DCL symbol called 'symbol' with value 'value'. | \*****************************************************************************/ static int varg_set_symbol(char *symbol, char *value) { $DESCRIPTOR(symbol_desc, ""); $DESCRIPTOR(value_desc, ""); int status; symbol_desc.dsc$w_length = strlen(symbol); symbol_desc.dsc$a_pointer = symbol; value_desc.dsc$w_length = strlen(value); value_desc.dsc$a_pointer = value; status = lib$set_symbol(&symbol_desc, &value_desc); return status; } /*****************************************************************************| | Routine to exit the program and pass 'command' to DCL for execution. | \*****************************************************************************/ static int varg_do_command(char *command) { $DESCRIPTOR(command_desc, ""); int status; command_desc.dsc$w_length = strlen(command); command_desc.dsc$a_pointer = command; status = lib$do_command(&command_desc); return status; } /*****************************************************************************| | Routine to rebuild 'date_string' converting from a VMS standard | | date/time specifier to the Unix format specified in 'pattern'. | | | \*****************************************************************************/ static int varg_convert_date(char *date_string, char *pattern) { char date_text[30]; int bin_time[2], flags, length, status, i, from, to; char year_4[5], year_2[4], month_name[4]; char month_2[3], month_1[3], date_2[3], date_1[3]; char hour_2[3], hour_1[3], minute[3], second[3]; char *months[] = {"", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; $DESCRIPTOR(date_desc, ""); static int context; /* First convert the date string into internal VMS format */ date_desc.dsc$w_length = strlen(date_string); date_desc.dsc$a_pointer = date_string; context = 0; flags = 0X7F; status = lib$convert_date_string(&date_desc, &bin_time, &context, &flags); if ((status & 1) != 1) return status; /* Now convert it back to string form. This ensures that delta times and keywords like TODAY get translated into a consistent format. */ date_desc.dsc$w_length = 30; /* date_desc.dsc$a_pointer = &date_text;*/ date_desc.dsc$a_pointer = date_text; length = 0; status = sys$asctim(&length, &date_desc, &bin_time, 0); if ((status & 1) != 1) return status; date_text[length] = 0; /* add NULL terminator */ date_string[0] = 0; /* start with empty string */ /* Break the date/time string up into the constituent fields. Fields such as date have two instances - one with leading zero and one without e.g. "05" and "5". */ if (date_text[0] == ' ') { date_2[0] = '0'; date_2[1] = date_text[1]; date_2[2] = 0; date_1[0] = date_text[1]; date_1[1] = 0; } else { date_2[0] = date_text[0]; date_2[1] = date_text[1]; date_2[2] = 0; strcpy(date_1, date_2); } /* Extract the month name and lowercase the 2nd and 3rd characters. */ month_name[0] = date_text [3]; month_name[1] = tolower(date_text [4]); month_name[2] = tolower(date_text [5]); month_name[3] = 0; /* Calculate the month number by looking up the month name in a character array. */ for (i = 1; i <= 12; i++) { if (strcmp(month_name, months[i]) == 0) { sprintf(month_2, "%02d", i); sprintf(month_1, "%d", i); break; } } /* Extract the year field (both 4 digit and 2 digit forms). */ year_2[0] = date_text[9]; year_2[1] = date_text[10]; year_2[3] = 0; for (i = 0; i <= 3; i++) { year_4[i] = date_text[i+7]; } year_4[4] = 0; /* Extract hour field. */ hour_2[0] = date_text[12]; hour_2[1] = date_text[13]; hour_2[2] = 0; if (date_text[12] == '0') { hour_1[0] = date_text[13]; hour_1[1] = 0; } else strcpy(hour_1, hour_2); /* Lastly copy the minutes and seconds. */ for (i = 0; i <= 1; i++) { minute[i] = date_text[i+15]; second[i] = date_text[i+18]; } minute[2] = 0; second[2] = 0; /* Now start building up the output string by copying characters from 'pattern' to 'date_string' substituting the various fields when we encounter an escape pair. */ from = 0; to = 0; while (pattern[from] != 0) { if (pattern[from] == '$') { switch (pattern[from+1]) { case 'Y': strcat(date_string, year_4); to = to + 4; break; case 'y': strcat(date_string, year_2); to = to + 2; break; case 'M': strcat(date_string, month_name); to = to + 3; break; case 'N': strcat(date_string, month_2); to = to + 2; break; case 'n': strcat(date_string, month_1); to = to + strlen(month_1); break; case 'D': strcat(date_string, date_2); to = to + 2; break; case 'd': strcat(date_string, date_1); to = to + strlen(date_1); break; case 'H': strcat(date_string, hour_2); to = to + 2; break; case 'h': strcat(date_string, hour_1); to = to + strlen(hour_1); break; case 'm': strcat(date_string, minute); to = to + 2; break; case 'S': case 's': strcat(date_string, second); to = to + 2; break; case '$': date_string[to] = '$'; date_string[to+1] = 0; to = to + 1; break; } from = from + 2; } else { date_string[to] = pattern[from]; date_string[to+1] = 0; from = from + 1; to = to + 1; } } } /*****************************************************************************| | Routine to decide if a string requires to be enclosed in quotation | | marks, and if so, put them in. The various bits in 'flags' tells | | us what characters require protecting. 'Quote' contains the actual | | quote character (which may require doubling or escaping with "\" | | if it occurs in the string). 'Special' contains a list of characters | | which require protecting. | \*****************************************************************************/ static int varg_protect_string(char *instring, char *outstring, int flags, char *special) { int protection_needed, quote_present; int length, i, j, special_length; char ch, quote = '\"'; char quote_string[2]; quote_string[0] = quote; quote_string[1] = 0; length = strlen(instring); special_length = strlen(special); protection_needed = 0; quote_present = 0; /* Check to see if we actually need the quotes. */ if ((flags & VARGACT_M_PROTMASK) != 0) { for (i = 0; i <= length-1; i++) { ch = instring[i]; if ((flags & VARGACT_M_UPPER) && isupper (ch)) { protection_needed = 1; continue; } if ((flags & VARGACT_M_LOWER) && islower (ch)) { protection_needed = 1; continue; } if ((flags & VARGACT_M_SPECIAL)) { for (j = 0; j <= special_length-1; j++) { if (ch == special[j]) { protection_needed = 1; continue; } } if (protection_needed) continue; } if (((flags & VARGACT_M_ESCAPE) || (flags & VARGACT_M_DOUBLE)) && ch == quote) { protection_needed = 1; quote_present = 1; continue; } } } /* if protection is not needed, just copy the input string to the output string. */ if (!protection_needed) { strcpy(outstring, instring); return 1; } /* Protection is needed. if no quotes are present, then we simply enclose the string in quote marks, otherwise we have to step through the string. */ if (quote_present) { outstring[0] = quote; j = 1; for (i = 0; i <= length-1; i++) { ch = instring[i]; if (ch == quote) { if ((flags & VARGACT_M_ESCAPE)) { outstring[j] = '\\'; j = j + 1; } if ((flags & VARGACT_M_DOUBLE)) { outstring[j] = quote; j = j + 1; } } outstring[j] = ch; j = j + 1; } outstring[j] = 0; } else { /* just append the output string + quote */ outstring[0] = 0; strcat(outstring, quote_string); strcat(outstring, instring); strcat(outstring, quote_string); } return 1; } /*****************************************************************************| | Routine to define any DCL symbols that are required, and if the | | appropriate flag bit is set, exit to DCL using a LIB$DO_COMMAND call | | which will activate the real application image. | \*****************************************************************************/ static int varg_do_exit(int flags, char *arg_symbol, char *arg_string, char *image_name, char *verb) { char *foreign_image; char *command; int status; /* Should we set up a symbol containing this arg string ? */ if ((flags & VARGACT_M_SYMBOL)) varg_set_symbol(arg_symbol, arg_string); /* Should we define an image name in the verb symbol ? */ if ((flags & VARGACT_M_IMAGE)) { foreign_image = malloc(strlen(image_name) + 2); if (foreign_image == NULL) return LIB$_INSVIRMEM; strcpy(foreign_image, "$"); strcat(foreign_image, image_name); varg_set_symbol(verb, foreign_image); } /* Should we exit the program and and activate another image or command procedure ? */ if ((flags & VARGACT_M_COMMAND)) { command = malloc(strlen(verb) + strlen(arg_string) + 2); if (command == NULL) return LIB$_INSVIRMEM; strcpy(command, verb); strcat(command, " "); strcat(command, arg_string); status = varg_do_command(command); return status; } return 1; } freetds-1.00.82/misc/Makefile.am100644 025423 025423 00000000034 12657570224 0012024EXTRA_DIST = cmake_checks.c freetds-1.00.82/misc/Makefile.in100644 025423 025423 00000033660 13242511110 0012024# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = misc ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = \ $(top_srcdir)/m4/ac_caolan_func_which_gethostbyname_r.m4 \ $(top_srcdir)/m4/ac_have_inaddr_none.m4 \ $(top_srcdir)/m4/ac_have_malloc_options.m4 \ $(top_srcdir)/m4/ac_nullzero.m4 \ $(top_srcdir)/m4/ac_raf_func_which_getservbyname_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_gethostbyaddr_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_getpwuid_r.m4 \ $(top_srcdir)/m4/ac_tds_func_which_localtime_r.m4 \ $(top_srcdir)/m4/acx_pthread.m4 \ $(top_srcdir)/m4/ax_cflags_gcc_option.m4 \ $(top_srcdir)/m4/check_openssl.m4 \ $(top_srcdir)/m4/gettimemilli.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/m4/pushlibs.m4 \ $(top_srcdir)/m4/sprintf_i64_format.m4 \ $(top_srcdir)/m4/type_socklen_t.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/mkinstalldirs DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALLOCA = @ALLOCA@ AMTAR = @AMTAR@ AM_CFLAGS = @AM_CFLAGS@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BUILD_NUMBER = @BUILD_NUMBER@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOXYGEN = @DOXYGEN@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FREETDS_LIBGCC = @FREETDS_LIBGCC@ FREETDS_ODBC_MODULE = @FREETDS_ODBC_MODULE@ FREETDS_SYMBOLIC = @FREETDS_SYMBOLIC@ GCRYPT_CFLAGS = @GCRYPT_CFLAGS@ GCRYPT_LIBS = @GCRYPT_LIBS@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ HAVE_OPENSSL = @HAVE_OPENSSL@ HAVE_PERL_SOURCES = @HAVE_PERL_SOURCES@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBADD_DL = @LIBADD_DL@ LIBADD_DLD_LINK = @LIBADD_DLD_LINK@ LIBADD_DLOPEN = @LIBADD_DLOPEN@ LIBADD_SHL_LOAD = @LIBADD_SHL_LOAD@ LIBICONV = @LIBICONV@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBOBJS = @LTLIBOBJS@ LT_DLLOADERS = @LT_DLLOADERS@ LT_DLPREOPEN = @LT_DLPREOPEN@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAJOR = @MAJOR@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MINOR = @MINOR@ MKDIR_P = @MKDIR_P@ NETTLE_CFLAGS = @NETTLE_CFLAGS@ NETTLE_LIBS = @NETTLE_LIBS@ NETWORK_LIBS = @NETWORK_LIBS@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ ODBC = @ODBC@ ODBCINSTLIB = @ODBCINSTLIB@ ODBCLIB = @ODBCLIB@ ODBCNODMLIB = @ODBCNODMLIB@ ODBCNODMLIBAPP = @ODBCNODMLIBAPP@ ODBC_CONFIG = @ODBC_CONFIG@ ODBC_INC = @ODBC_INC@ OPENSSL_CFLAGS = @OPENSSL_CFLAGS@ OPENSSL_LIBS = @OPENSSL_LIBS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ PTHREAD_CC = @PTHREAD_CC@ PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ PTHREAD_LIBS = @PTHREAD_LIBS@ RANLIB = @RANLIB@ RC = @RC@ READLINE_LIBS = @READLINE_LIBS@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SUBVERSION = @SUBVERSION@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ acx_pthread_config = @acx_pthread_config@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ dblib_define = @dblib_define@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ tds_sysdep_int16_type = @tds_sysdep_int16_type@ tds_sysdep_int32_type = @tds_sysdep_int32_type@ tds_sysdep_int64_type = @tds_sysdep_int64_type@ tds_sysdep_intptr_type = @tds_sysdep_intptr_type@ tds_sysdep_real32_type = @tds_sysdep_real32_type@ tds_sysdep_real64_type = @tds_sysdep_real64_type@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ EXTRA_DIST = cmake_checks.c all: all-am .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu misc/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu misc/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs tags TAGS: ctags CTAGS: cscope cscopelist: distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: all all-am check check-am clean clean-generic clean-libtool \ cscopelist-am ctags-am distclean distclean-generic \ distclean-libtool 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-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags-am uninstall uninstall-am .PRECIOUS: Makefile # 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: freetds-1.00.82/misc/cmake_checks.c100644 025423 025423 00000001450 12607665421 0012536#define _GNU_SOURCE #include #include int main(int argc, char **argv) { #if defined(CHECK_ASPRINTF) char *p = NULL; int len = asprintf(&p, "%d", 123)"); #elif defined(CHECK_VASPRINTF) va_list va; char *p = NULL; int len = vasprintf(&p, "%d", va); #elif defined(CHECK_SNPRINTF) char buf[128]; int len = snprintf(buf, 128, "%d", 123); #elif defined(CHECK__SNPRINTF) char buf[128]; int len = _snprintf(buf, 128, "%d", 123); #elif defined(CHECK_VSNPRINTF) va_list va; char buf[128]; int len = vsnprintf(buf, 128, "%d", va); #elif defined(CHECK__VSNPRINTF) va_list va; char buf[128]; int len = _vsnprintf(buf, 128, "%d", va); #elif defined(CHECK__VSCPRINTF) va_list va; int len = _vscprintf("%d", va); #else #error "Check function not specified correctly" #endif return 0; }